dialogs.hpp

Go to the documentation of this file.
00001 /* $Id: dialogs.hpp 25704 2008-04-09 15:02:43Z esr $ */
00002 /*
00003    Copyright (C) 2003 - 2008 by David White <dave@whitevine.net>
00004    Part of the Battle for Wesnoth Project http://www.wesnoth.org/
00005 
00006    This program is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License version 2
00008    or at your option any later version.
00009    This program is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY.
00011 
00012    See the COPYING file for more details.
00013 */
00014 #ifndef DIALOGS_H_INCLUDED
00015 #define DIALOGS_H_INCLUDED
00016 
00017 class attack_type;
00018 class config;
00019 class display;
00020 class game_display;
00021 class unit;
00022 class unit_map;
00023 class unit_type;
00024 
00025 #include "map.hpp"
00026 #include "construct_dialog.hpp"
00027 #include "events.hpp"
00028 
00029 #include "widgets/button.hpp"
00030 
00031 #include "file_chooser.hpp"
00032 
00033 namespace dialogs {
00034 
00035 //function to handle an advancing unit. If there is only one choice to advance
00036 //to, the unit will be automatically advanced. If there is a choice, and 'random_choice'
00037 //is true, then a unit will be selected at random. Otherwise, a dialog will be displayed
00038 //asking the user what to advance to.
00039 //
00040 //note that 'loc' is not a reference, because deleting an item from the units map
00041 //(when replacing the unit that is being advanced) will possibly invalidate the reference
00042 //
00043 // the game only expects an advancement to be triggered by a fight, it the cause for
00044 // advancement is different (eg unstore_unit) the add_replay_event should be set
00045 void advance_unit(const gamemap& map,unit_map& units, gamemap::location loc,
00046                   game_display& gui, bool random_choice=false, const bool add_replay_event=false);
00047 
00048 bool animate_unit_advancement(unit_map& units, gamemap::location loc, game_display& gui, size_t choice);
00049 
00050 void show_objectives(game_display& disp, const config& level, const std::string& objectives);
00051 
00052 // check if a character is valid for a filename
00053 bool is_illegal_file_char(char c);
00054 
00055 // Ask user if I should really save the game and what name I should use
00056 // returns 0 if user wants to save the game
00057 int get_save_name(display & disp,const std::string& message, const std::string& txt_label,
00058                   std::string* fname, gui::DIALOG_TYPE dialog_type=gui::YES_NO,
00059                   const std::string& title="", const bool has_exit_button=false,
00060                   const bool ask_for_filename=true);
00061 
00062 //allow user to select the game they want to load. Returns the name
00063 //of the save they want to load. Stores whether the user wants to show
00064 //a replay of the game in show_replay. If show_replay is NULL, then
00065 //the user will not be asked if they want to show a replay.
00066 std::string load_game_dialog(display& disp, const config& terrain_config, bool* show_replay, bool* cancel_orders);
00067 
00068 class unit_preview_pane : public gui::preview_pane
00069 {
00070 public:
00071     enum TYPE { SHOW_ALL, SHOW_BASIC };
00072     struct details {
00073         surface image;
00074         std::string name, type_name;
00075         int level;
00076         std::string alignment, traits;
00077         std::vector<std::string> abilities;
00078         int hitpoints, max_hitpoints;
00079         int experience, max_experience;
00080         std::string hp_color, xp_color;
00081         int movement_left, total_movement;
00082         std::vector<attack_type> attacks;
00083     };
00084 
00085     unit_preview_pane(game_display &disp, const gamemap* map, TYPE type=SHOW_ALL, bool left_side=true);
00086 
00087     bool show_above() const;
00088     bool left_side() const;
00089     void set_selection(int index);
00090 
00091     handler_vector handler_members();
00092 
00093 protected:
00094     game_display& disp_;
00095     const gamemap* map_;
00096     int index_;
00097     gui::button details_button_;
00098 
00099 private:
00100     virtual size_t size() const = 0;
00101     virtual const details get_details() const = 0;
00102     virtual void process_event() = 0;
00103 
00104     void draw_contents();
00105 
00106     bool left_;
00107     bool weapons_;
00108 };
00109 
00110 class units_list_preview_pane : public dialogs::unit_preview_pane
00111 {
00112 public:
00113     units_list_preview_pane(game_display &disp, const gamemap* map, const unit& u, TYPE type=SHOW_ALL, bool left_side=true);
00114     units_list_preview_pane(game_display &disp, const gamemap* map, std::vector<unit>& units, TYPE type=SHOW_ALL, bool left_side=true);
00115 
00116 private:
00117     size_t size() const;
00118     const details get_details() const;
00119     void process_event();
00120 
00121     std::vector<unit>* units_;
00122     std::vector<unit> unit_store_;
00123 };
00124 
00125 
00126 class unit_types_preview_pane : public dialogs::unit_preview_pane
00127 {
00128 public:
00129     unit_types_preview_pane(game_display &disp, const gamemap* map, std::vector<const unit_type*>& unit_types, int side = 1, TYPE type=SHOW_ALL, bool left_side=true);
00130 
00131 private:
00132     size_t size() const;
00133     const details get_details() const;
00134     void process_event();
00135 
00136     std::vector<const unit_type*>* unit_types_;
00137     int side_;
00138 };
00139 
00140 
00141 void show_unit_description(game_display &disp, const unit_type& t);
00142 void show_unit_description(game_display &disp, const unit& u);
00143 
00144 
00145 class campaign_preview_pane : public gui::preview_pane
00146 {
00147 public:
00148     campaign_preview_pane(CVideo &video,std::vector<std::pair<std::string,std::string> >* descriptions);
00149 
00150     bool show_above() const;
00151     bool left_side() const;
00152     void set_selection(int index);
00153 
00154 private:
00155     void draw_contents();
00156 
00157     const std::vector<std::pair<std::string,std::string> >* descriptions_;
00158     int index_;
00159 };
00160 
00161 network::connection network_send_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num=0);
00162 network::connection network_receive_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num=0);
00163 network::connection network_connect_dialog(display& disp, const std::string& msg, const std::string& hostname, int port);
00164 
00165 } //end namespace dialogs
00166 
00167 #endif

Generated by doxygen 1.5.5 on 23 May 2008 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs