Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't colorize GUI labels #59

Open
Disinterpreter opened this issue Jun 26, 2020 · 4 comments
Open

Can't colorize GUI labels #59

Disinterpreter opened this issue Jun 26, 2020 · 4 comments
Labels
bug Something isn't working depends on blue The feature might depend on MTA:SA source code

Comments

@Disinterpreter
Copy link
Member

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

@Disinterpreter Disinterpreter added the bug Something isn't working label Jun 26, 2020
@colistro123
Copy link
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.

@qaisjp
Copy link
Contributor

qaisjp commented Jun 28, 2020

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

@colistro123
Copy link
Collaborator

colistro123 commented Jun 28, 2020

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.

@qaisjp
Copy link
Contributor

qaisjp commented Jun 29, 2020

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

@AGraber AGraber added the depends on blue The feature might depend on MTA:SA source code label Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working depends on blue The feature might depend on MTA:SA source code
Projects
None yet
Development

No branches or pull requests

4 participants