Added rudimentary menu buttons, not yet connected to anything... it feels a bit hackish, to be honest, but I don't think we'll ever have too many to worry about, and if so, we can think about refactoring then
This commit is contained in:
43
game.cpp
43
game.cpp
@ -41,6 +41,13 @@ bool Game::init()
|
||||
return false;
|
||||
}
|
||||
|
||||
move_button = MenuButton("Move", font, 155, display->h - 95, BUTTON_MOVE);
|
||||
attack_button = MenuButton("Attack", font, 260, display->h - 95,
|
||||
BUTTON_ATTACK);
|
||||
build_button = MenuButton("Build", font, 155, display->h - 50,
|
||||
BUTTON_BUILD);
|
||||
|
||||
|
||||
return GameState::init();
|
||||
}
|
||||
|
||||
@ -112,15 +119,43 @@ void Game::render()
|
||||
}
|
||||
|
||||
// draw the rest of the bottom menu
|
||||
|
||||
// horizontal line across the whole thing
|
||||
DrawUtils::draw_line(display, 0, display->h - 100,
|
||||
display->w, display->h - 100, 2, 0x000000);
|
||||
|
||||
// vertical line to separate info pane from button pane
|
||||
DrawUtils::draw_line(display, 150, display->h - 100, 150, display->h, 2,
|
||||
0x000000);
|
||||
|
||||
if (data.get_current_vertex() != NULL)
|
||||
{
|
||||
draw_button(&move_button);
|
||||
draw_button(&build_button);
|
||||
draw_button(&attack_button);
|
||||
}
|
||||
|
||||
SDL_Flip(display);
|
||||
}
|
||||
|
||||
|
||||
void Game::draw_button(MenuButton* button)
|
||||
{
|
||||
int colour = 0x000000;
|
||||
ButtonAction action = button->get_action();
|
||||
Mode mode = data.get_mode();
|
||||
|
||||
// fixme - there's really got to be a better way...
|
||||
if ((action == BUTTON_BUILD && mode == MODE_BUILD) ||
|
||||
(action == BUTTON_ATTACK && mode == MODE_ATTACK) ||
|
||||
(action == BUTTON_MOVE && mode == MODE_MOVE))
|
||||
colour = 0x0000ff;
|
||||
else if (button->is_at(cursor_x, cursor_y)) colour = 0xff0000;
|
||||
|
||||
button->draw(display, colour);
|
||||
}
|
||||
|
||||
|
||||
void Game::draw_stats(Vertex* v)
|
||||
{
|
||||
int num_lines = 4;
|
||||
@ -171,6 +206,14 @@ void Game::on_key_down(SDLKey sym, SDLMod mod, Uint16 unicode)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Game::on_mouse_move(int mX, int mY, int relX, int relY, bool left, bool right, bool middle)
|
||||
{
|
||||
cursor_x = mX;
|
||||
cursor_y = mY;
|
||||
}
|
||||
|
||||
|
||||
#ifdef DEBUG
|
||||
void Game::print_debug_info()
|
||||
{
|
||||
|
Reference in New Issue
Block a user