dialogs.hpp

Go to the documentation of this file.
00001 /* $Id: dialogs.hpp 52954 2012-02-07 13:35:22Z fendrin $ */
00002 /*
00003    Copyright (C) 2003 - 2012 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 as published by
00008    the Free Software Foundation; either version 2 of the License, or
00009    (at your option) any later version.
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY.
00012 
00013    See the COPYING file for more details.
00014 */
00015 #ifndef DIALOGS_H_INCLUDED
00016 #define DIALOGS_H_INCLUDED
00017 
00018 class attack_type;
00019 class config;
00020 class display;
00021 class game_display;
00022 class unit;
00023 class unit_map;
00024 class unit_type;
00025 
00026 #include "map_location.hpp"
00027 #include "construct_dialog.hpp"
00028 #include "network.hpp"
00029 
00030 namespace dialogs {
00031 
00032 /**
00033  * Function to handle an advancing unit. If there is only one choice to advance
00034  * to, the unit will be automatically advanced. If there is a choice, and
00035  * 'random_choice' is true, then a unit will be selected at random. Otherwise,
00036  * a dialog will be displayed asking the user what to advance to.
00037  *
00038  * Note that 'loc' is not a reference, because deleting an item from the units
00039  * map (when replacing the unit that is being advanced) will possibly
00040  * invalidate the reference.
00041  *
00042  * The game only expects an advancement to be triggered by a fight, if the
00043  * cause for advancement is different (eg unstore_unit) this routine
00044  * should _not_ be used.
00045  */
00046 void advance_unit(const map_location &loc, bool random_choice = false, bool add_replay_event = false);
00047 
00048 /**
00049  * Lets the user to select a unit advancement. This should always be used
00050  * from WML events, advance_unit can only be used safely for normal levels.
00051  */
00052 int advance_unit_dialog(const map_location &loc);
00053 
00054 /**
00055  * Actually levels a unit up. This is the other part of the low-level
00056  * interface to the advancing code (along with advance_unit_dialog). This needs
00057  * to be used to implement advances from any nonstandard situation. It does
00058  * not add a replay.
00059  */
00060 bool animate_unit_advancement(const map_location &loc, size_t choice, const bool &fire_event = true);
00061 
00062 void show_objectives(const config &level, const std::string &objectives);
00063 
00064 /**
00065  * Allow user to select the game they want to load. Returns the name of the
00066  * save they want to load. Stores whether the user wants to show a replay of
00067  * the game in show_replay. If show_replay is NULL, then the user will not be
00068  * asked if they want to show a replay.
00069  */
00070 std::string load_game_dialog(display& disp, const config& terrain_config, bool* select_difficulty, bool* show_replay, bool* cancel_orders);
00071 
00072 /** Show unit-stats in a side-pane to unit-list, recall-list, etc. */
00073 class unit_preview_pane : public gui::preview_pane
00074 {
00075 public:
00076     enum TYPE { SHOW_ALL, SHOW_BASIC };
00077     struct details {
00078         details();
00079 
00080         surface image;
00081         std::string name, type_name, race;
00082         int level;
00083         std::string alignment, traits;
00084         std::vector<t_string> abilities;
00085         int hitpoints, max_hitpoints;
00086         int experience, max_experience;
00087         std::string hp_color, xp_color;
00088         int movement_left, total_movement;
00089         std::vector<attack_type> attacks;
00090     };
00091 
00092     unit_preview_pane(const gui::filter_textbox *filter = NULL,
00093             TYPE type = SHOW_ALL, bool left_side = true);
00094 
00095     bool show_above() const;
00096     bool left_side() const;
00097     void set_selection(int index);
00098 
00099     handler_vector handler_members();
00100 
00101 protected:
00102     int index_;
00103     gui::button details_button_;
00104 
00105 private:
00106     virtual size_t size() const = 0;
00107     virtual const details get_details() const = 0;
00108     virtual void process_event() = 0;
00109 
00110     void draw_contents();
00111 
00112     const gui::filter_textbox* filter_;
00113     bool weapons_;
00114     bool left_;
00115 };
00116 
00117 class units_list_preview_pane : public dialogs::unit_preview_pane
00118 {
00119 public:
00120     units_list_preview_pane(const unit *u, TYPE type = SHOW_ALL, bool left_side = true);
00121     units_list_preview_pane(const std::vector<const unit *> &units,
00122         const gui::filter_textbox *filter = NULL,
00123         TYPE type = SHOW_ALL, bool left_side = true);
00124     units_list_preview_pane(const std::vector<unit> &units,
00125         const gui::filter_textbox *filter = NULL,
00126         TYPE type = SHOW_ALL, bool left_side = true);
00127 
00128 private:
00129     size_t size() const;
00130     const details get_details() const;
00131     void process_event();
00132 
00133     std::vector<const unit *> units_;
00134 };
00135 
00136 
00137 class unit_types_preview_pane : public dialogs::unit_preview_pane
00138 {
00139 public:
00140     unit_types_preview_pane(
00141             std::vector<const unit_type*>& unit_types, const gui::filter_textbox* filterbox=NULL,
00142             int side = 1, TYPE type=SHOW_ALL, bool left_side=true);
00143 
00144 private:
00145     size_t size() const;
00146     const details get_details() const;
00147     void process_event();
00148 
00149     std::vector<const unit_type*>* unit_types_;
00150     int side_;
00151 };
00152 
00153 
00154 void show_unit_description(const unit_type &t);
00155 void show_unit_description(const unit &u);
00156 
00157 network::connection network_send_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num=0);
00158 network::connection network_receive_dialog(display& disp, const std::string& msg, config& cfg, network::connection connection_num=0);
00159 network::connection network_connect_dialog(display& disp, const std::string& msg, const std::string& hostname, int port);
00160 
00161 } //end namespace dialogs
00162 
00163 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:02:33 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs