Author: tschmitz
Date: Tue Aug  2 12:11:41 2011
New Revision: 50550

URL: http://svn.gna.org/viewcvs/wesnoth?rev=50550&view=rev
Log:
Added hide() to class arrow. (whiteboard)

Modified:
    trunk/src/arrow.cpp
    trunk/src/arrow.hpp

Modified: trunk/src/arrow.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/arrow.cpp?rev=50550&r1=50549&r2=50550&view=diff
==============================================================================
--- trunk/src/arrow.cpp (original)
+++ trunk/src/arrow.cpp Tue Aug  2 12:11:41 2011
@@ -33,19 +33,30 @@
 
 #define SCREEN ((display*)resources::screen)
 
-arrow::arrow()
+arrow::arrow(bool hidden)
        : layer_(display::LAYER_ARROWS)
        , color_("red")
        , style_(STYLE_STANDARD)
        , path_()
        , previous_path_()
        , symbols_map_()
-{
-       resources::screen->add_arrow(*this);
+       , hidden_(true)
+{
+       if(!hidden)
+               show();
 }
 
 arrow::~arrow()
 {
+       hide();
+}
+
+void arrow::hide()
+{
+       if(hidden_)
+               return;
+       hidden_ = true;
+
        if (SCREEN)
        {
                invalidate_arrow_path(path_);
@@ -53,15 +64,28 @@
        }
 }
 
+void arrow::show()
+{
+       if(!hidden_)
+               return;
+       hidden_ = false;
+
+       if(SCREEN)
+               SCREEN->add_arrow(*this);
+}
+
 void arrow::set_path(arrow_path_t const& path)
 {
        if (valid_path(path))
        {
                previous_path_ = path_;
                path_ = path;
-               invalidate_arrow_path(previous_path_);
                update_symbols();
-               notify_arrow_changed();
+               if(!hidden_)
+               {
+                       invalidate_arrow_path(previous_path_);
+                       notify_arrow_changed();
+               }
        }
 }
 

Modified: trunk/src/arrow.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/arrow.hpp?rev=50550&r1=50549&r2=50550&view=diff
==============================================================================
--- trunk/src/arrow.hpp (original)
+++ trunk/src/arrow.hpp Tue Aug  2 12:11:41 2011
@@ -32,8 +32,12 @@
 
 public:
 
-       arrow();
+       arrow(bool hidden = false);
        virtual ~arrow();
+
+       ///Sets the arrow's visibility
+       void hide();
+       void show();
 
        virtual void set_path(arrow_path_t const& path);
 
@@ -97,5 +101,7 @@
 
        typedef std::map<map_location, image::locator> arrow_symbols_map_t;
        arrow_symbols_map_t symbols_map_;
+
+       bool hidden_;
 };
 #endif


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to