mail[Wesnoth-commits] r20689 - in /trunk/src/editor: editor.cpp editor.hpp


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

Header


Content

Posted by alinktomine on September 24, 2007 - 17:28:
Author: alink
Date: Mon Sep 24 17:28:27 2007
New Revision: 20689

URL: http://svn.gna.org/viewcvs/wesnoth?rev=20689&view=rev
Log:
correct and slightly improve the bugfix of r20653
(the undo system mix operations on the same hexes, I will improve it later)

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

Modified: trunk/src/editor/editor.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor/editor.cpp?rev=20689&r1=20688&r2=20689&view=diff
==============================================================================
--- trunk/src/editor/editor.cpp (original)
+++ trunk/src/editor/editor.cpp Mon Sep 24 17:28:27 2007
@@ -636,7 +636,7 @@
 
 void map_editor::edit_fill_selection() {
        map_undo_action undo_action;
-       perform_fill_selection(undo_action);
+       perform_fill_hexes(selected_hexes_, palette_.selected_bg_terrain(), 
undo_action);
        save_undo_action(undo_action);
 }
 
@@ -833,7 +833,6 @@
 }
 
 void map_editor::insert_selection_in_clipboard() {
-
        // Find the hex that is closest to the selected one,
        // use this as origin
        gamemap::location origin(1000,1000);
@@ -848,23 +847,33 @@
        copy_buffer(clipboard_, selected_hexes_, origin);
 }
 
-void map_editor::perform_fill_selection(map_undo_action &undo_action) {
+void map_editor::perform_fill_hexes(std::set<gamemap::location> &fill_hexes,
+       const t_translation::t_letter terrain, map_undo_action &undo_action) {
        std::set<gamemap::location>::const_iterator it;
-       for (it = selected_hexes_.begin(); it != selected_hexes_.end(); it++) 
{
+       for (it = fill_hexes.begin(); it != fill_hexes.end(); it++) {
                if (map_.on_board(*it)) {
-                       undo_action.add_terrain(map_.get_terrain(*it), 
palette_.selected_bg_terrain(), *it);
-                       map_.set_terrain(*it, palette_.selected_bg_terrain());
-               }
-       }
-       terrain_changed(selected_hexes_);
+                       undo_action.add_terrain(map_.get_terrain(*it), 
terrain, *it);
+                       map_.set_terrain(*it, terrain);
+               }
+       }
+       terrain_changed(fill_hexes);
 }
 
 void map_editor::perform_selection_move() {
        map_undo_action undo_action;
+       std::set<gamemap::location> old_selection = selected_hexes_;
+
        map_buffer buf;
        copy_buffer(buf, selected_hexes_, selection_move_start_);
-       perform_fill_selection(undo_action);
        paste_buffer(buf,selected_hex_, undo_action);
+
+       std::set<gamemap::location>::const_iterator it;
+       for (it = old_selection.begin(); it != old_selection.end(); it++) {
+               if (selected_hexes_.find(*it) != selected_hexes_.end())
+                       old_selection.erase(*it);
+       }
+       perform_fill_hexes(old_selection, 
palette_.selected_bg_terrain(),undo_action);
+
        save_undo_action(undo_action);
 }
 

Modified: trunk/src/editor/editor.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor/editor.hpp?rev=20689&r1=20688&r2=20689&view=diff
==============================================================================
--- trunk/src/editor/editor.hpp (original)
+++ trunk/src/editor/editor.hpp Mon Sep 24 17:28:27 2007
@@ -233,9 +233,10 @@
        /// Insert the currently selected locations in the clipboard.
        void insert_selection_in_clipboard();
 
-       /// Commit a selection filling.
-       void perform_fill_selection(map_undo_action &undo_action);
-
+       /// Commit hexes filling.
+       void perform_fill_hexes(std::set<gamemap::location> &fill_hexes,
+               const t_translation::t_letter terrain, map_undo_action 
&undo_action);
+       
        /// Commit the movement of a selection.
        void perform_selection_move();
 




Related Messages


Powered by MHonArc, Updated Mon Sep 24 19:00:52 2007