initial commit, lordsawar source, slightly modified
[lordsawar] / src / gui / driver.h
1 //  Copyright (C) 2007 Ole Laursen
2 //  Copyright (C) 2007, 2008, 2009 Ben Asselstine
3 //
4 //  This program is free software; you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation; either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU Library General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program; if not, write to the Free Software
16 //  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 
17 //  02110-1301, USA.
18
19 #ifndef GUI_DRIVER_H
20 #define GUI_DRIVER_H
21
22 #include <memory>
23 #include <string>
24 #include <sigc++/trackable.h>
25
26 #include "splash-window.h"
27 #include "game-window.h"
28 #include "game-lobby-dialog.h"
29 #include "new-network-game-download-window.h"
30 #include "game-parameters.h"
31
32 // takes care of setting up the splash window and the game window, the
33 // interaction between them and the model classes
34 // it also takes care of the game lobby window.
35 class Driver: public sigc::trackable
36 {
37  public:
38     Driver(std::string load_filename);
39     ~Driver();
40
41     void run();
42
43  private:
44     GameWindow* game_window;
45     GameLobbyDialog* game_lobby_dialog;
46     SplashWindow* splash_window;
47     NewNetworkGameDownloadWindow* download_window;
48     std::string d_load_filename;
49     sigc::connection heartbeat_conn;
50     Player::Type robot_player_type;
51     unsigned int number_of_robots;
52     std::string game_scenario_downloaded;
53     sigc::signal<void, std::string> game_scenario_received;
54     sigc::signal<void, Player*> player_replaced;
55
56     void on_new_game_requested(GameParameters g);
57     void on_new_remote_network_game_requested(std::string host, unsigned short port, std::string nick);
58     void on_new_hosted_network_game_requested(GameParameters g, int port, std::string nick);
59     void on_new_pbm_game_requested(GameParameters g);
60     void on_game_scenario_downloaded(std::string filename);
61     void on_game_scenario_received(std::string path);
62     void on_load_requested(std::string filename);
63     void on_quit_requested();
64
65     void on_game_ended();
66
67     void init_game_window();
68
69
70     void on_hosted_player_sat_down(Player *player);
71     void on_hosted_player_stood_up(Player *player);
72     void on_client_player_sat_down(Player *player);
73     void on_client_player_stood_up(Player *player);
74     void on_server_went_away();
75     void on_client_could_not_connect();
76
77     GameScenario *new_game(GameParameters g);
78     GameScenario *load_game(std::string file_path);
79     void stress_test();
80     void stressTestNextRound();
81
82     void lordsawaromatic(std::string host, unsigned short port, Player::Type type, int num_players);
83     void on_game_scenario_received_for_robots(std::string path);
84   
85
86     void heartbeat();
87
88     void on_client_player_chat(std::string message);
89     void on_hosted_player_chat(std::string message);
90
91     void on_show_lobby_requested();
92
93     void start_network_game_requested(GameScenario *game_scenario,
94                                       NextTurnNetworked *next_turn);
95
96     void on_player_unavailable(Player *p);
97
98     GameScenario *create_new_scenario(GameParameters &g, GameScenario::PlayMode m);
99 };
100
101
102 #endif