Author: ilor
Date: Tue Aug 12 22:43:18 2008
New Revision: 28519

URL: http://svn.gna.org/viewcvs/wesnoth?rev=28519&view=rev
Log:
editor2 resize dialog buttons logic and display (partial)

Modified:
    trunk/src/gui/dialogs/editor_resize_map.cpp
    trunk/src/gui/dialogs/editor_resize_map.hpp

Modified: trunk/src/gui/dialogs/editor_resize_map.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/editor_resize_map.cpp?rev=28519&r1=28518&r2=28519&view=diff
==============================================================================
--- trunk/src/gui/dialogs/editor_resize_map.cpp (original)
+++ trunk/src/gui/dialogs/editor_resize_map.cpp Tue Aug 12 22:43:18 2008
@@ -126,6 +126,23 @@
        window.recalculate_size();
 }
 
+static int resize_grid_xy_to_idx(int x, int y)
+{
+       if (x < 0 || x > 2 || y < 0 || y > 2) {
+               return 9;
+       } else {
+               ERR_GUI << y * 3 + x;
+               return y * 3 + x;
+       }
+}
+
+void teditor_resize_map::set_direction_icon(int index, std::string icon)
+{
+       if (index < 9) {
+               
direction_buttons_[index]->set_icon_name("buttons/resize-direction-" + icon + 
".png");
+       }
+}
+
 void teditor_resize_map::update_expand_direction(twindow& window)
 {
        std::string name_prefix = "expand";
@@ -137,10 +154,43 @@
        }
        for (int i = 0; i < static_cast<int>(expand_direction_); ++i) {
                direction_buttons_[i]->set_value(false);
+               set_direction_icon(i, "none");
        }
        direction_buttons_[expand_direction_]->set_value(true);
        for (int i = expand_direction_ + 1; i < 9; ++i) {
                direction_buttons_[i]->set_value(false);
+               set_direction_icon(i, "none");
+       }
+       
+       int xdiff = map_width_->get_value() - old_width_;
+       int ydiff = map_height_->get_value() - old_height_;
+       int x = static_cast<int>(expand_direction_) % 3;
+       int y = static_cast<int>(expand_direction_) / 3;
+       ERR_GUI << x << " " << y << " " << xdiff << " " << ydiff << "\n";
+       set_direction_icon(expand_direction_, "center");
+       if (xdiff != 0) {
+               int left = resize_grid_xy_to_idx(x - 1, y);
+               int right = resize_grid_xy_to_idx(x + 1, y);
+               if (xdiff < 0) std::swap(left, right);
+               set_direction_icon(left, "left");
+               set_direction_icon(right, "right");
+       }
+       if (ydiff != 0) {
+               int top = resize_grid_xy_to_idx(x, y - 1);
+               int bottom = resize_grid_xy_to_idx(x, y + 1);
+               if (ydiff < 0) std::swap(top, bottom);
+               set_direction_icon(top, "top");
+               set_direction_icon(bottom, "bottom");
+       }
+       if (xdiff != 0 || ydiff != 0) {
+               int nw = resize_grid_xy_to_idx(x - 1, y - 1);
+               int ne = resize_grid_xy_to_idx(x + 1, y - 1);
+               int sw = resize_grid_xy_to_idx(x - 1, y + 1);
+               int se = resize_grid_xy_to_idx(x + 1, y + 1);
+               if (xdiff < 0 || ydiff < 0) {
+                       std::swap(nw, se);
+                       std::swap(ne, sw);
+               }
        }
 }
 

Modified: trunk/src/gui/dialogs/editor_resize_map.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/dialogs/editor_resize_map.hpp?rev=28519&r1=28518&r2=28519&view=diff
==============================================================================
--- trunk/src/gui/dialogs/editor_resize_map.hpp (original)
+++ trunk/src/gui/dialogs/editor_resize_map.hpp Tue Aug 12 22:43:18 2008
@@ -51,6 +51,7 @@
        void update_expand_direction(twindow& window);
 
 private:
+       void set_direction_icon(int index, std::string icon);
        /**
         * NOTE the map sizes are stored in a text variable since there is no
         * integer edit widget yet.


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

Reply via email to