1
// This program is free software; you can redistribute it and/or modify
2
// it under the terms of the GNU General Public License as published by
3
// the Free Software Foundation; either version 2 of the License, or
4
// (at your option) any later version.
6
// This program is distributed in the hope that it will be useful,
7
// but WITHOUT ANY WARRANTY; without even the implied warranty of
8
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9
// GNU Library General Public License for more details.
11
// You should have received a copy of the GNU General Public License
12
// along with this program; if not, write to the Free Software
13
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15
#ifndef GUI_GAME_WINDOW_H
16
#define GUI_GAME_WINDOW_H
20
#include <sigc++/signal.h>
21
#include <sigc++/trackable.h>
22
#include <gtkmm/window.h>
23
#include <gtkmm/dialog.h>
24
#include <gtkmm/eventbox.h>
25
#include <gtkmm/container.h>
26
#include <gtkmm/image.h>
27
#include <gtkmm/button.h>
28
#include <gtkmm/label.h>
29
#include <gtkmm/togglebutton.h>
30
#include <gtkmm/box.h>
31
#include <gtkmm/checkmenuitem.h>
33
#include "army-info-tip.h"
34
#include "stack-info-tip.h"
36
#include "../game-parameters.h"
37
#include "../sidebar-stats.h"
40
#include "../map-tip-position.h"
41
#include "../callback-enums.h"
42
#include "../vector.h"
44
#include "../GraphicsCache.h"
57
/** The main window in which all the game action is going on.
59
* This class takes cares of the widget side of the things around the action
60
* area, delegating the actual drawing to the model classes, but is also
61
* responsible for popping up dialog windows in response to the action.
62
* It has a pane at the bottom with information about the currently selected
63
* stack and a pane to the right with the small map, buttons and statistics.
65
class GameWindow: public sigc::trackable
74
// initialize the SDL widget
75
void init(int width, int height);
78
void new_game(GameParameters g);
80
// setup and use the game stored under file_path
81
void load_game(std::string file_path);
83
// emitted when the game has ended and it is time to show the splash again
84
sigc::signal<void> game_ended;
86
sigc::signal<void> quit_requested;
88
sigc::signal<void> sdl_initialized;
91
std::auto_ptr<Gtk::Window> window;
92
std::auto_ptr<Gtk::Window> map_tip; // tooltip appears over the map
93
std::auto_ptr<Gtk::Window> stack_tip;// tooltip appears over the map
94
Gtk::Container *sdl_container;
95
Gtk::Widget *sdl_widget;
96
Gtk::CheckMenuItem *fullscreen_menuitem;
97
Gtk::MenuItem *end_turn_menuitem;
98
Gtk::MenuItem *move_all_menuitem;
99
Gtk::MenuItem *search_menuitem;
100
Gtk::MenuItem *inspect_menuitem;
101
Gtk::MenuItem *disband_menuitem;
102
Gtk::MenuItem *signpost_menuitem;
103
Gtk::MenuItem *city_history_menuitem;
104
Gtk::MenuItem *event_history_menuitem;
105
Gtk::MenuItem *gold_history_menuitem;
106
Gtk::MenuItem *winner_history_menuitem;
107
Gtk::MenuItem *plant_standard_menuitem;
108
Gtk::MenuItem *group_ungroup_menuitem;
109
Gtk::MenuItem *leave_menuitem;
110
Gtk::MenuItem *next_menuitem;
111
Gtk::Box *stack_info_box;
112
Gtk::Box *stack_info_container;
113
Gtk::Label *group_moves_label;
114
Gtk::Image *terrain_image;
116
Gtk::Image *map_image;
117
Gtk::Label *stats_label;
118
Glib::ustring stats_text; // the text into which the stats are inserted
120
Gtk::Label *cities_stats_label;
121
Gtk::Label *gold_stats_label;
122
Gtk::Label *income_stats_label;
123
Gtk::Label *turn_label;
124
Gtk::HBox *turn_hbox;
125
Gtk::Image *shield_image[MAX_PLAYERS];
127
// the button control panel
128
Gtk::Button *next_movable_button;
129
Gtk::Button *center_button;
130
Gtk::Button *defend_button;
131
Gtk::Button *park_button;
132
Gtk::Button *search_button;
133
Gtk::Button *move_button;
134
Gtk::Button *move_all_button;
135
Gtk::Button *end_turn_button;
137
Stack *currently_selected_stack;
138
std::auto_ptr<ArmyInfoTip> army_info_tip;
139
std::auto_ptr<StackInfoTip> stack_info_tip;
140
typedef std::vector<Gtk::ToggleButton *> army_buttons_type;
141
army_buttons_type army_buttons;
142
Gtk::EventBox *map_eventbox;
143
Gtk::ToggleButton *group_ungroup_toggle;
145
std::string current_save_filename;
147
std::auto_ptr<Game> game;
151
bool on_delete_event(GdkEventAny *e);
153
bool on_sdl_mouse_button_event(GdkEventButton *e);
154
bool on_sdl_mouse_motion_event(GdkEventMotion *e);
155
bool on_sdl_key_event(GdkEventKey *e);
157
bool on_map_mouse_button_event(GdkEventButton *e);
158
bool on_map_mouse_motion_event(GdkEventMotion *e);
160
void on_load_game_activated();
161
void on_save_game_activated();
162
void on_save_game_as_activated();
163
void on_quit_activated();
164
void on_quests_activated();
165
void on_disband_activated();
166
void on_resign_activated();
167
void on_signpost_activated();
168
void on_inspect_activated();
169
void on_plant_standard_activated();
170
void on_item_bonus_activated();
171
void on_army_report_activated();
172
void on_city_report_activated();
173
void on_gold_report_activated();
174
void on_production_report_activated();
175
void on_winning_report_activated();
177
void on_fullscreen_activated();
178
void on_preferences_activated();
179
void on_group_ungroup_activated();
181
void on_fight_order_activated();
182
void on_levels_activated();
183
void on_ruin_report_activated();
184
void on_army_bonus_activated();
185
void on_city_history_activated();
186
void on_event_history_activated();
187
void on_gold_history_activated();
188
void on_winner_history_activated();
190
void on_message_requested(std::string msg);
192
// info pane at the bottom
194
void show_stack(Stack *s);
195
void fill_in_group_info (Stack *s);
196
void on_army_toggled(Gtk::ToggleButton *toggle, Army *army);
197
void on_group_toggled(Gtk::ToggleButton *toggle);
198
bool on_army_button_event(GdkEventButton *e,
199
Gtk::ToggleButton *toggle, Army *army);
200
void on_army_button_has_size();
201
void clear_army_buttons();
202
void update_army_buttons();
203
void ensure_one_army_button_active();
205
// shield set on the top
206
void show_shield_turn();
209
void on_sidebar_stats_changed(SidebarStats s);
210
void on_smallmap_changed(SDL_Surface *map);
211
void on_bigmap_cursor_changed(GraphicsCache::CursorType cursor);
212
void on_stack_info_changed(Stack *s);
213
void on_map_tip_changed(Glib::ustring tip, MapTipPosition pos);
214
void on_stack_tip_changed(Stack *s, MapTipPosition pos);
215
void on_ruin_searched(Ruin *ruin, Stack *s, Reward *reward);
216
void on_sage_visited(Ruin *ruin, Stack *s);
217
void on_fight_started(Fight &fight);
218
void on_ruinfight_started(Stack *attackers, Stack *defenders);
219
void on_ruinfight_finished(Fight::Result result);
220
bool on_hero_offers_service(Player *player, Hero *hero, City *city, int gold);
221
bool on_temple_searched(bool hasHero, Temple *temple, int blessCount);
222
void on_quest_assigned(Hero *hero, Quest *quest);
223
CityDefeatedAction on_city_defeated(City *city, int gold);
224
void on_city_pillaged(City *city, int gold, int pillaged_army_type);
225
void on_city_sacked(City *city, int gold, std::list<Uint32> sacked_types);
226
void on_city_razed(City *city);
227
void on_city_visited(City *city);
228
void on_ruin_visited(Ruin *ruin);
229
void on_temple_visited(Temple *temple);
230
void on_next_player_turn(Player *player, unsigned int turn_number);
231
void on_hero_brings_allies(int alliesCount);
232
void on_medal_awarded_to_army(Army *army);
233
Army::Stat on_army_gains_level(Army *army);
234
void on_game_loaded(Player *player);
235
void on_game_over(Player *winner);
236
void on_player_died(Player *player);
238
// quest manager callbacks
239
void on_quest_completed(Quest *quest, Reward *reward);
240
void on_quest_expired(Quest *quest);
243
void show_map_tip(Glib::ustring msg, MapTipPosition pos);
244
void on_city_looted(City *city, int gold);
247
void setup_game(std::string file_path);
248
void setup_signals();
250
std::list<sigc::connection> connections;
252
void setup_menuitem(Gtk::MenuItem*, sigc::slot<void> , sigc::signal<void, bool> &);
253
void setup_button(Gtk::Button *, sigc::slot<void> slot, sigc::signal<void, bool> &);
255
// not part of the API, but for surface_attached_helper
256
void on_sdl_surface_changed();
257
bool d_quick_fights; //do we speed up fights for this player's turn?