Can't colorize GUI labels
Disinterpreter opened this issue · 4 comments
Yeah, this is going to be impossible since there's no colorcoded support by default. So I'm stuck doing weird workarounds that simply don't even work, the text doesn't even display properly to begin with. I don't know why one would have colorcoded support for mostly everything else, but not for CEGUI based things.
Here's what I quickly wrapped up anyway, credit goes to Patrick and Sarrum for the regex:
function guiSetTextCustom( parent, inputstr )
local words = {}
local grid = guiCreateGridList(0.5, 0.5, 1.0, 1.0, true, parent)
guiGridListSetScrollBars(grid,false,false) --This does absolutely nothing, the bars still show regardless, perhaps due to text overflow as in text being cut out?
for word in inputstr:gmatch("%S+%s*") do
table.insert(words, word)
end
for k,v in pairs(words) do
local w = dxGetTextWidth ( v, 1, "default", true )
local listColumn = guiGridListAddColumn(grid, "genericList", w * 0.01)
local items = v:split("\n")
for k2,v2 in ipairs(items) do
local row = guiGridListAddRow ( grid )
guiGridListSetItemText ( grid, row, listColumn, v2, false, true)
end
outputConsole('Result: k->' .. k .. ' v->' .. v)
end
--guiSetText(parent, inputstr) --Set it anyway
end
And the output:
http://whileago.mov.re/nffiles/images/proxy_sa_2020-06-28_18-36-52.png
There's other ways that I can think of to resolve this:
A. Use dgs which supports colorcoded arguments. https://wiki.multitheftauto.com/wiki/Resource:Dgs
B. Make dialogs html based and color appropriately?
C. Using dxdrawtext with colorcoding enabled and drawing on top of the UI, but this of course won't work for lists
Option A is easier, but then there's the downfall where you need to add yet another library to the project.
Not keen on having a dependency on another GUI renderer.
Instead of importing all that logic, another option is writing/including logic that creates multiple labels, split up by colour. (And setting the label colours.)
Me neither honestly, I just wrote it down as a possibility. I wonder, would this work right out of the box?
http://cegui.org.uk/wiki/Formatting_Tags_in_CEGUI
Edit: Nevermind, just noticed the vendor version being earlier (0.4.0), so not supported it seems.
Those formatting tags look good. @Lpsd is working on the dream of updating CEGUI. multitheftauto/mtasa-blue#1459