Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: spook1 on Mon 17/04/2006 20:22:53

Title: GUI textbox / lable background color
Post by: spook1 on Mon 17/04/2006 20:22:53
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
Title: Re: GUI textbox / lable background color
Post by: Scorpiorus on Mon 17/04/2006 23:09:59
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):

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:

// outside any function
DynamicSprite *spriteForButton[10];


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