Added some code for disabling button visually, but it doesn't quite work
This commit is contained in:
@ -24,6 +24,7 @@ bool MenuButton::init()
|
||||
hover = false;
|
||||
selected = false;
|
||||
visible = true;
|
||||
enabled = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -54,7 +55,8 @@ void MenuButton::render(SDL_Surface* display)
|
||||
if (!visible) return;
|
||||
|
||||
int colour_to_use = colour;
|
||||
if (selected) colour_to_use = selected_colour;
|
||||
if (!enabled) colour_to_use = 0xbbbbbb;
|
||||
else if (selected) colour_to_use = selected_colour;
|
||||
else if (hover) colour_to_use = hover_colour;
|
||||
|
||||
SDL_Rect pen = {x, y, 80, 20};
|
||||
@ -75,10 +77,12 @@ bool MenuButton::is_at(int test_x, int test_y)
|
||||
}
|
||||
|
||||
|
||||
void MenuButton::set_state(Mode mode, VertexType type, GameVertex* current)
|
||||
void MenuButton::set_state(Mode mode, VertexType type, GameVertex* current,
|
||||
bool can_build)
|
||||
{
|
||||
selected = false;
|
||||
visible = false;
|
||||
enabled = true;
|
||||
|
||||
if (action & BUTTON_END_TURN)
|
||||
{
|
||||
@ -108,6 +112,16 @@ void MenuButton::set_state(Mode mode, VertexType type, GameVertex* current)
|
||||
if (mode & MODE_BUILD && action & (BUTTON_BUILD_ATTACKER |
|
||||
BUTTON_BUILD_DEFENDER |
|
||||
BUTTON_BUILD_PRODUCER))
|
||||
{
|
||||
visible = true;
|
||||
|
||||
if (!can_build &&
|
||||
((action == BUTTON_BUILD_ATTACKER && type == VERTEX_ATTACKER) ||
|
||||
(action == BUTTON_BUILD_DEFENDER && type == VERTEX_DEFENDER) ||
|
||||
(action == BUTTON_BUILD_PRODUCER && type == VERTEX_PRODUCER)))
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
if (action == BUTTON_ATTACK && current->attacked) enabled = false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user