Skip to content

Can't colorize GUI labels #59

Open

Description

@Disinterpreter

Describe the bug
Can't colorize GUI labels. In action there are only color tags.

To reproduce
write into dialog big text with different colors

Expected behaviour
It must colorized.

Screenshots
image

Activity

  1. colistro123 commented on Jun 28, 2020

    @colistro123
    Collaborator

    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.

  2. qaisjp commented on Jun 28, 2020

    @qaisjp
    Member

    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.)

  3. colistro123 commented on Jun 28, 2020

    @colistro123
    Collaborator

    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.

  4. qaisjp commented on Jun 29, 2020

    @qaisjp
    Member

    Those formatting tags look good. @Lpsd is working on the dream of updating CEGUI. multitheftauto/mtasa-blue#1459

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdepends on blueThe feature might depend on MTA:SA source code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions