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