I've been working on the text rendering code. The next feature I'd like to do is to allow text to be truncated instead of linewrapped, in such a way that the truncated text is visually marked with something like an ellipsis ("..."). Text truncation is useful in places where there is limited space, such as tables and button texts. It would be nicer if we never have to truncate, but with all the supported languages and multi-use strings such as item names, it is hard to be sure.
I've made a first draft patch for it, which adds a R_FontDrawLine function that is designed for single-line text and uses it in a couple of places. I've made it take a "trunc string" from the caller, which can be an ellipsis if desired. The reason for taking the string for the caller is that it makes it translatable. Some languages have different conventions for this, and in any case it is nice if the English locale can use the Unicode ellipsis instead of three ASCII dots. This makes three reasonable values for the trunc parameter:
_("...")
""
NULL
The third one means line-wrap as usual, though of course R_FontDrawLine will still only print the first line.
Now I'm wondering how to add the truncation string to the menu system. I would like to do something like this in menu_buy.ufo:
text market
{
color "0 .78 0 1"
num TEXT_MARKET_NAMES
height "28"
format "25 0"
pos "55 40"
size "265 700"
click
wheel { cmd "market_scroll" }
mousefx true
truncate "_..."
}
This menu node contains item names separated by newlines, and adding the truncate value would mean the text should be rendered line by line with long lines truncated with _("...") as a visual marker. It will get a column like this:
Short item
Long item name
Really long ite...
Questions:
How do I add a string value to text nodes? I couldn't figure it out from the code.
Should it be a string value? Or is a numeric code enough? (say, 0 = don't truncate, 1 = truncate silently, 2 = truncate with ellipsis)
Is R_FontDrawLine useful or should everything continue to go through the general-purpose R_FontDrawString? (which is getting long in the parameter list)
[attachment deleted by admin]