GUI textbox / lable background color

Started by spook1, Mon 17/04/2006 20:22:53

Previous topic - Next topic

spook1

For my simulation game I need a Gui that consists of six similar sections (screensize)
I need each of the sections to change color under certain conditions. So I need to have a function or property like

Gui[2].Textbox[3].BGColorÃ, 

so I can make a setting likeÃ, 
:

If (blue) then Gui[2].Textbox[3].BGColorÃ,  = 9;

Can this be done in AGS?

Thanks in advance for thinking along...,

Martijn

Scorpiorus

#1
It's not possible at the moment, if I recall correctly.

One workaround would be to use a button as a background with its normal graphic set to a sprite of a desired solid colour.

You can write a function to create such sprites at run-time (using room background as a canvas to draw them):

Code: ags
DynamicSprite* CreateOfColour(int colour, int width, int height) {

	RawSaveScreen();
	
	RawSetColor(colour);
	RawDrawRectangle(0, 0, width-1, height-1);
	
	DynamicSprite *sprite = DynamicSprite.CreateFromBackground(GetBackgroundFrame(), 0, 0, width, height);
	
	RawRestoreScreen();
	
	return sprite;
}



And use it like so:

Code: ags
// outside any function
DynamicSprite *spriteForButton[10];


Code: ags
if (blue)
{
	int width = gui[2].Controls[button_id].AsButton.Width;
	int height = gui[2].Controls[button_id].AsButton.Height;

	// create solid blue sprite
	spriteForButton[button_id] = CreateOfColour(9, width, height);

	// use it as a button's normal graphic
	gui[2].Controls[button_id].AsButton.NormalGraphic = spriteForButton[button_id].Graphic;
}


And don't forget to Delete dynamic sprites when you've done with them (when the GUI is closed or whenever).

SMF spam blocked by CleanTalk