mail[Wesnoth-commits] r44068 - in /trunk/src/whiteboard: attack.cpp attack.hpp manager.cpp move.hpp


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by gabrielmorin on July 10, 2010 - 02:36:
Author: gabba
Date: Sat Jul 10 02:36:01 2010
New Revision: 44068

URL: http://svn.gna.org/viewcvs/wesnoth?rev=44068&view=rev
Log:
Whiteboard: adding the attack action, step 4 (skeleton execution code)

Modified:
    trunk/src/whiteboard/attack.cpp
    trunk/src/whiteboard/attack.hpp
    trunk/src/whiteboard/manager.cpp
    trunk/src/whiteboard/move.hpp

Modified: trunk/src/whiteboard/attack.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/attack.cpp?rev=44068&r1=44067&r2=44068&view=diff
==============================================================================
--- trunk/src/whiteboard/attack.cpp (original)
+++ trunk/src/whiteboard/attack.cpp Sat Jul 10 02:36:01 2010
@@ -21,6 +21,8 @@
 #include "visitor.hpp"
 
 #include "arrow.hpp"
+#include "play_controller.hpp"
+#include "resources.hpp"
 #include "unit.hpp"
 
 namespace wb
@@ -43,4 +45,25 @@
        
v.visit_attack(boost::static_pointer_cast<attack>(shared_from_this()));
 }
 
+bool attack::execute()
+{
+       if (arrow_->get_path().size() >= 2)
+       {
+               if (!move::execute())
+               {
+                       //Move didn't complete for some reason, so we're not 
at
+                       //the right hex to execute the attack.
+                       return false;
+               }
+       }
+
+       int choice = 
resources::controller->get_mouse_handler_base().show_attack_dialog(
+                       unit_.get_location(), target_hex_);
+       if (choice >=0 ) {
+               
resources::controller->get_mouse_handler_base().attack_enemy(unit_.get_location(),
 target_hex_, choice);
+       }
+
+       return true;
+}
+
 } // end namespace wb

Modified: trunk/src/whiteboard/attack.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/attack.hpp?rev=44068&r1=44067&r2=44068&view=diff
==============================================================================
--- trunk/src/whiteboard/attack.hpp (original)
+++ trunk/src/whiteboard/attack.hpp Sat Jul 10 02:36:01 2010
@@ -37,6 +37,8 @@
 
        virtual void accept(visitor& v);
 
+       virtual bool execute();
+
 private:
                ///the target of the attack
                map_location target_hex_;

Modified: trunk/src/whiteboard/manager.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/manager.cpp?rev=44068&r1=44067&r2=44068&view=diff
==============================================================================
--- trunk/src/whiteboard/manager.cpp (original)
+++ trunk/src/whiteboard/manager.cpp Sat Jul 10 02:36:01 2010
@@ -64,9 +64,10 @@
 
 void manager::set_planned_unit_map()
 {
-       if (active_)
-       {
-               assert(!modifying_actions_);
+       if (active_ && !modifying_actions_)
+       {
+               //TODO: enable back this assert, after modifying the mouse 
code that triggers it constantly
+               //assert(!modifying_actions_);
                if (!planned_unit_map_active_)
                {
                        DBG_WB << "Building planned unit map.\n";
@@ -83,9 +84,10 @@
 
 void manager::set_real_unit_map()
 {
-       if (active_)
-       {
-               assert(!modifying_actions_);
+       if (active_ && !modifying_actions_)
+       {
+               //TODO: enable back this assert, after modifying the mouse 
code that triggers it constantly
+               //assert(!modifying_actions_);
                if (planned_unit_map_active_)
                {
                        DBG_WB << "Restoring regular unit map.\n";

Modified: trunk/src/whiteboard/move.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/whiteboard/move.hpp?rev=44068&r1=44067&r2=44068&view=diff
==============================================================================
--- trunk/src/whiteboard/move.hpp (original)
+++ trunk/src/whiteboard/move.hpp Sat Jul 10 02:36:01 2010
@@ -43,7 +43,6 @@
        static const std::string ARROW_STYLE_VALID;
        static const std::string ARROW_STYLE_INVALID;
 
-public:
        move(unit& subject, const map_location& source_hex, const 
map_location& target_hex, arrow_ptr arrow,
                        fake_unit_ptr fake_unit);
        virtual ~move();
@@ -71,7 +70,7 @@
        virtual void set_valid(bool valid);
        virtual bool is_valid() { return valid_; }
 
-private:
+protected:
        unit & unit_;
        map_location source_hex_;
        map_location dest_hex_;




Related Messages


Powered by MHonArc, Updated Sat Jul 10 02:40:11 2010