whiteboard/recall.hpp

Go to the documentation of this file.
00001 /* $Id: recall.hpp 53789 2012-04-05 21:16:56Z ejls $ */
00002 /*
00003  Copyright (C) 2010 - 2012 by Gabriel Morin <gabrielmorin (at) gmail (dot) com>
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 
00016 /**
00017  * @file
00018  */
00019 
00020 #ifndef WB_RECALL_HPP_
00021 #define WB_RECALL_HPP_
00022 
00023 #include "action.hpp"
00024 
00025 namespace wb
00026 {
00027 
00028 class recall: public action
00029 {
00030 public:
00031     recall(size_t team_index, bool hidden, const unit& unit, const map_location& recall_hex);
00032     recall(config const&, bool hidden); // For deserialization
00033     virtual ~recall();
00034 
00035     friend class validate_visitor;
00036     friend class highlight_visitor;
00037 
00038     virtual std::ostream& print(std::ostream& s) const;
00039 
00040     virtual void accept(visitor& v);
00041 
00042     virtual void execute(bool& success, bool& complete);
00043 
00044     /** Applies temporarily the result of this action to the specified unit map. */
00045     virtual void apply_temp_modifier(unit_map& unit_map);
00046     /** Removes the result of this action from the specified unit map. */
00047     virtual void remove_temp_modifier(unit_map& unit_map);
00048 
00049     /** Gets called by display when drawing a hex, to allow actions to draw to the screen. */
00050     virtual void draw_hex(const map_location& hex);
00051 
00052     /**
00053      * Indicates whether this hex is the preferred hex to draw the numbering for this action.
00054      */
00055     virtual map_location get_numbering_hex() const { return recall_hex_; }
00056 
00057     /** @return pointer to a copy of the recall unit. */
00058     virtual unit* get_unit() const { return temp_unit_.get(); }
00059     /** @return pointer to the fake unit used only for visuals */
00060     virtual fake_unit_ptr get_fake_unit() { return fake_unit_; }
00061 
00062     map_location const get_recall_hex() const { return recall_hex_; }
00063 
00064     /**
00065      * Indicates to an action whether its status is invalid, and whether it should change its
00066      * display (and avoid any change to the game state) accordingly
00067      */
00068     virtual void set_valid(bool valid) { valid_ = valid; }
00069     virtual bool is_valid() const { return valid_; }
00070 
00071     virtual config to_config() const;
00072 
00073 protected:
00074 
00075     boost::shared_ptr<recall> shared_from_this() {
00076         return boost::static_pointer_cast<recall>(action::shared_from_this());
00077     }
00078 
00079 private:
00080     void init();
00081 
00082     virtual void do_hide();
00083     virtual void do_show();
00084 
00085     std::auto_ptr<unit> temp_unit_;
00086     map_location recall_hex_;
00087     bool valid_;
00088     fake_unit_ptr fake_unit_;
00089 };
00090 
00091 std::ostream& operator<<(std::ostream& s, recall_ptr recall);
00092 std::ostream& operator<<(std::ostream& s, recall_const_ptr recall);
00093 
00094 }
00095 
00096 #endif /* WB_RECALL_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Fri May 25 2012 01:03:15 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs