00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef PLAY_CONTROLLER_H_INCLUDED
00017 #define PLAY_CONTROLLER_H_INCLUDED
00018
00019 #include "global.hpp"
00020
00021 #include "game_events.hpp"
00022 #include "gamestatus.hpp"
00023 #include "generic_event.hpp"
00024 #include "halo.hpp"
00025 #include "help.hpp"
00026 #include "hotkeys.hpp"
00027 #include "menu_events.hpp"
00028 #include "mouse_events.hpp"
00029 #include "preferences_display.hpp"
00030 #include "replay.hpp"
00031 #include "soundsource.hpp"
00032 #include "statistics.hpp"
00033 #include "tooltips.hpp"
00034
00035 #include <vector>
00036
00037 class game_display;
00038 class team;
00039
00040 class play_controller : public hotkey::command_executor, public events::handler, public events::observer
00041 {
00042 public:
00043 play_controller(const config& level, game_state& state_of_game,
00044 int ticks, int num_turns, const config& game_config, CVideo& video, bool skip_replay, bool is_replay);
00045 ~play_controller();
00046
00047 virtual void play_slice();
00048
00049
00050
00051 virtual void handle_generic_event(const std::string& ) {}
00052
00053
00054 virtual void objectives();
00055 virtual void show_statistics();
00056 virtual void unit_list();
00057 virtual void status_table();
00058 virtual void save_game();
00059 virtual void save_replay();
00060 virtual void save_map();
00061 virtual void load_game();
00062 virtual void preferences();
00063 virtual void show_chat_log();
00064 virtual void show_help();
00065 virtual void cycle_units();
00066 virtual void cycle_back_units();
00067 virtual void undo();
00068 virtual void redo();
00069 virtual void show_enemy_moves(bool ignore_units);
00070 virtual void goto_leader();
00071 virtual void unit_description();
00072 virtual void toggle_grid();
00073 virtual void search();
00074
00075 virtual void play_side(const unsigned int team_num, bool save) = 0;
00076
00077 int get_ticks();
00078
00079 protected:
00080 void handle_event(const SDL_Event& event);
00081 virtual std::string get_action_image(hotkey::HOTKEY_COMMAND, int index) const;
00082 virtual hotkey::ACTION_STATE get_action_state(hotkey::HOTKEY_COMMAND command) const;
00083 virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command, int index=-1) const;
00084 virtual bool execute_command(hotkey::HOTKEY_COMMAND command, int index=-1);
00085 void show_menu(const std::vector<std::string>& items_arg, int xloc, int yloc, bool context_menu);
00086 bool in_context_menu(hotkey::HOTKEY_COMMAND command) const;
00087
00088 virtual void init(CVideo& video, bool is_replay);
00089 void init_managers();
00090 void fire_prestart(bool execute);
00091 void fire_start(bool execute);
00092 virtual void init_gui();
00093 virtual void init_side(const unsigned int team_index, bool is_replay = false);
00094 void place_sides_in_preferred_locations(gamemap& map, const config::child_list& sides);
00095 virtual void finish_side_turn();
00096 void finish_turn();
00097 bool clear_shroud();
00098 bool enemies_visible() const;
00099 void enter_textbox();
00100
00101 team& current_team();
00102 const team& current_team() const;
00103
00104 int find_human_team_before(const size_t team) const;
00105
00106
00107 const verification_manager verify_manager_;
00108 teams_manager team_manager_;
00109 preferences::display_manager* prefs_disp_manager_;
00110 tooltips::manager* tooltips_manager_;
00111 game_events::manager* events_manager_;
00112 halo::manager* halo_manager_;
00113 font::floating_label_context labels_manager_;
00114 help::help_manager help_manager_;
00115 events::mouse_handler mouse_handler_;
00116 events::menu_handler menu_handler_;
00117 soundsource::manager* soundsources_manager_;
00118
00119
00120 game_display* gui_;
00121 const set_random_generator generator_setter;
00122 const statistics::scenario_context statistics_context_;
00123 const config& level_;
00124 const config& game_config_;
00125 std::vector<team> teams_;
00126 game_state& gamestate_;
00127 gamestatus status_;
00128 gamemap map_;
00129 unit_map units_;
00130 undo_list undo_stack_;
00131 undo_list redo_stack_;
00132
00133 const int ticks_;
00134 const unit_type::experience_accelerator xp_mod_;
00135
00136
00137 const bool loading_game_;
00138
00139 CKey key_;
00140 int first_human_team_;
00141 unsigned int player_number_;
00142 unsigned int first_player_;
00143 unsigned int start_turn_;
00144 bool is_host_;
00145 bool skip_replay_;
00146 bool browse_;
00147 bool linger_;
00148 bool scrolling_;
00149 bool first_turn_;
00150
00151 private:
00152
00153 void expand_autosaves(std::vector<std::string>& items);
00154 std::vector<std::string> savenames_;
00155
00156 void expand_wml_commands(std::vector<std::string>& items);
00157 std::vector<wml_menu_item *> wml_commands_;
00158 #define MAX_WML_COMMANDS 7
00159
00160 };
00161
00162
00163 #endif