I'm just working on a new client for the online game. This one will do lots of cool things like skinning (for top down boards amongst other things) and tracking user points as they play.
One of the things that's been a bugbear since the start is presenting text on the screen. I worked on this for weeks before giving up on it on the last client update. Now I;ve been on it another three weeks and 5 or 6 bugs have been squashed but from a sea of bugs it's an uphill battle.
These are the comments from the top of the game client's richtext module. I thought you might find it interesting because it gives at least some idea why this thing is such a git to get my head around and debug.
/*ThudGame
Java 1.1 version.
This class is used by ThudGame to display Rich Text chat windows.
Maybe I've tried to be too complex. Would doing letters separately be slower? Yes, and it'd still be as complex. So I grouped them into "frag(ment)s" with the same attributes and line, then lumped those into lines.
Wrapping text lines (TL) to screen lines (SL) is complex. Frags can split over many SLs. Rewrapping must recombine and re-split them, so I made frags "parent" or "child".
TLs did store their own SL list, but this made display/scrolling hard, so now SLs are in a central vector and TL stores minSL/maxSL indexes. But tracking these is complex. Maybe better to give TLs an SL vector too?
When rewrapping, if a line changes, must delete old SLs, make new ones, and reupdate minSL/maxSL. If not, must still update minSL/maxSL if earlier lines changed, so must keep a running total of how many SLs added/removed.
Tracking the selection highlight when we wrap/rewrap/scroll is complex. Just unselecting when the size changed'd be easier, but it'd still need to split frags in two, highlighted & not.
For display/scrolling, SLs must know their height, from highest riser to lowest descender in all their frags.
Parsing the tags themselves is admittedly not very complex, just tedious.
Of course, this all becomes vastly more complicated once you get multiple treads working on the same Rich Text object. I should probably try to prevent that...
*All* these complexities are unnecessary in monospaced text. But it's for more than just chat: it also does the whole skinning system, so worth the trouble.
Help to simplify this is appreciated. It's so big I can't even grok it myself.
*/












Re: Day many-lots
wow,that's scary.
good luck and thanks once again for the work you guys do.
_O_
ll( )ll
_] [_
Re: Day many-lots
One of the things that's been a bugbear since the start is presenting text on the screen. I worked on this for weeks before giving up on it on the last client update. Now I;ve been on it another three weeks and 5 or 6 bugs have been squashed but from a sea of bugs it's an uphill battle...
Bugfixing:
4pm: When unwrapping, TextLine.unwrap needs to delete screenlines from
.MinSL to .MaxSL, and then reupdate all other textlines in a for() loop
(one hour)(procrastinated 4-6. Completed 6:30.)
5pm: When rewrapping, TextLine needs to update minsl and maxsl for all
subsequent textlines (30 mins).
7pm: tl.unwrap doesn't delete all SLs. So when wrapping, it is not
enough to just add a SL to the end. Need to insert them in the right
place. ALTERNATIVELY, trash SL array completely and rebuild.
Thinking about it though, tl.unwrap is only ever called by
rt.unwrapLinePerSelection which is only ever called by rt.rewrap().
This means I can just totally trash the SL vector in rt.rewrap and
rebuild from scratch. Doing that instead. Damn wasted time.
OK, turns out I had *already done that*. That was not my problem. So the
above three issues are effectively resolved, and the last few hours were
wasted.
Compiling now though, I get sl.minfrag=1 when it should be 0.
7pm: OK fixed that. AND WOOHOOO! Text appeared on the output! It has
Actual
been seriously months since that has happened. I am sooo happy
progress. This has been a good day. Now I can actually see output, see
my work changing stuff on the screen, I should feel a load more
motivated. Let's see how much more I can do today.
Now, I can see bugs.
The text is too far to the left.
The text is doublespaced.
Making the text long enough to wrap, or shrinking the window, makes it hang.
OK, 10pm! time for the auction...
(from livejournal post at http://dewimorgan.livejournal.com/)
Yet another geek.