handle menu choices in run()
This commit is contained in:
parent
f10bd59226
commit
9414c30773
@ -1,7 +1,6 @@
|
||||
#include <math.h>
|
||||
#include "Client.h"
|
||||
#include "Types.h"
|
||||
#include <SFGUI/SFGUI.hpp>
|
||||
|
||||
/* TODO: this should be moved to common somewhere */
|
||||
#define MAX_SHOT_DISTANCE 250.0
|
||||
@ -94,7 +93,22 @@ void Client::run(bool fullscreen, int width, int height, std::string pname)
|
||||
m_clock.restart();
|
||||
recenter_cursor();
|
||||
|
||||
run_main_menu();
|
||||
bool in_game = true;
|
||||
while (in_game)
|
||||
{
|
||||
run_main_menu();
|
||||
switch (m_menu_action)
|
||||
{
|
||||
case MAIN_MENU_SINGLE:
|
||||
start_server();
|
||||
run_client();
|
||||
stop_server();
|
||||
break;
|
||||
case MAIN_MENU_EXIT:
|
||||
in_game = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Client::play_single_player_game_button_clicked()
|
||||
@ -113,7 +127,6 @@ void Client::run_main_menu()
|
||||
m_window->resetGLStates();
|
||||
|
||||
m_menu_action = MAIN_MENU_NONE;
|
||||
sfg::SFGUI sfgui;
|
||||
sfg::Box::Ptr box = sfg::Box::Create(sfg::Box::VERTICAL, 10.0f);
|
||||
sfg::Button::Ptr btn_singleplayer =
|
||||
sfg::Button::Create("Play Single Player Game");
|
||||
@ -177,24 +190,11 @@ void Client::run_main_menu()
|
||||
|
||||
desktop.Update(m_clock.restart().asSeconds());
|
||||
m_window->clear();
|
||||
sfgui.Display(*m_window);
|
||||
m_sfgui.Display(*m_window);
|
||||
m_window->display();
|
||||
|
||||
if (m_menu_action != MAIN_MENU_NONE)
|
||||
{
|
||||
switch (m_menu_action)
|
||||
{
|
||||
case MAIN_MENU_SINGLE:
|
||||
start_server();
|
||||
run_client();
|
||||
m_window->resetGLStates();
|
||||
break;
|
||||
case MAIN_MENU_EXIT:
|
||||
in_menu = false;
|
||||
break;
|
||||
}
|
||||
m_menu_action = MAIN_MENU_NONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,6 +203,11 @@ void Client::start_server()
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void Client::stop_server()
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
void Client::run_client()
|
||||
{
|
||||
m_window->setMouseCursorVisible(false);
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "GLMatrix.h"
|
||||
#include "GLBuffer.h"
|
||||
#include "Network.h"
|
||||
#include <SFGUI/SFGUI.hpp>
|
||||
|
||||
#define SHOT_RING_WIDTH 10.0f
|
||||
|
||||
@ -35,6 +36,7 @@ class Client
|
||||
protected:
|
||||
void run_main_menu();
|
||||
void start_server();
|
||||
void stop_server();
|
||||
void run_client();
|
||||
void connect(int port, const char *host);
|
||||
void disconnect();
|
||||
@ -59,6 +61,7 @@ class Client
|
||||
void play_single_player_game_button_clicked();
|
||||
void exit_button_clicked();
|
||||
|
||||
sfg::SFGUI m_sfgui;
|
||||
int m_menu_action;
|
||||
bool m_mouse_grabbed;
|
||||
double m_player_dir_x;
|
||||
|
Loading…
x
Reference in New Issue
Block a user