Author: mog
Date: Sun Apr  6 17:50:07 2008
New Revision: 25632

URL: http://svn.gna.org/viewcvs/wesnoth?rev=25632&view=rev
Log:
Implement drawing under overlay terrains (use ALT)

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

Modified: trunk/changelog
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=25632&r1=25631&r2=25632&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sun Apr  6 17:50:07 2008
@@ -33,6 +33,7 @@
    * Fixed not working "Update transition" and make "Delay transition update"
      directly trigger an update when toggled off.
    * add-ons can now make their custom terrains available in the editor
+   * Draw base terrain under an overlay when ALT is pressed
  * game engine
    * Implemented lazy loading for unit_types
  * multiplayer:

Modified: trunk/src/editor/editor.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor/editor.cpp?rev=25632&r1=25631&r2=25632&view=diff
==============================================================================
--- trunk/src/editor/editor.cpp (original)
+++ trunk/src/editor/editor.cpp Sun Apr  6 17:50:07 2008
@@ -412,6 +412,11 @@
                }
                l_button_held_func_ = NONE;
        }
+       else if ( (key_[SDLK_RALT] || key_[SDLK_LALT]) && l_button_func_ == 
DRAW) {
+               reset_mouseover_overlay();
+               draw_on_mouseover_hexes(palette_.selected_fg_terrain(), true);
+               l_button_held_func_ = DRAW_BASE_TERRAIN;
+       }
        else if (selected_hexes_.find(hex_clicked) != selected_hexes_.end()) {
                l_button_held_func_ = MOVE_SELECTION;
                selection_move_start_ = hex_clicked;
@@ -1181,6 +1186,10 @@
                reset_mouseover_overlay();
                draw_on_mouseover_hexes(palette_.selected_fg_terrain());
        }
+       else if (l_button_held_func_ == DRAW_BASE_TERRAIN && mouse_moved_) {
+               reset_mouseover_overlay();
+               draw_on_mouseover_hexes(palette_.selected_fg_terrain(), true);
+       }
        else if (l_button_held_func_ == MOVE_SELECTION && mouse_moved_) {
                reset_mouseover_overlay();
                //(*it-selection_move_start_) + hex
@@ -1196,16 +1205,16 @@
        }
 }
 
-void map_editor::draw_on_mouseover_hexes(const t_translation::t_terrain 
terrain) {
+void map_editor::draw_on_mouseover_hexes(const t_translation::t_terrain 
terrain, const bool base_only) {
        if(map_.on_board(selected_hex_, true)) {
                std::vector<gamemap::location> hexes =
                        get_tiles(map_, selected_hex_, 
brush_.selected_brush_size());
-               draw_terrain(terrain, hexes);
+               draw_terrain(terrain, hexes, base_only);
        }
 }
 
 void map_editor::draw_terrain(const t_translation::t_terrain terrain,
-               const std::vector<gamemap::location> &hexes)
+                              const std::vector<gamemap::location> &hexes, 
const bool base_only)
 {
        map_undo_action undo_action;
        
@@ -1214,12 +1223,16 @@
                const t_translation::t_terrain old_terrain = 
map_.get_terrain(*it);
                if(terrain != old_terrain) {
                        undo_action.add_terrain(old_terrain, terrain, *it);
-            if (terrain.base == t_translation::NO_LAYER) {
-                map_.set_overlay(*it, terrain);
-            }
-            else {
-                map_.set_terrain(*it, terrain);
-            }
+                       if (terrain.base == t_translation::NO_LAYER) {
+                               map_.set_overlay(*it, terrain);
+                       }
+                       else if (base_only) {
+                               map_.set_base(*it, terrain);
+                       }
+                       else {
+                               map_.set_terrain(*it, terrain);
+                       }
+
                        // always rebuild localy to show the drawing progress
                        gui_.rebuild_terrain(*it);
                        gui_.invalidate(*it);
@@ -1262,7 +1275,12 @@
        // Draw with the background terrain on rightclick,
        // no matter what operations are wanted with the left button.
        //! @todo TODO evaluate if this is what is the smartest thing to do.
-       draw_on_mouseover_hexes(palette_.selected_bg_terrain());
+       if (DRAW_BASE_TERRAIN) {
+               draw_on_mouseover_hexes(palette_.selected_bg_terrain(), true);
+       }
+       else {
+               draw_on_mouseover_hexes(palette_.selected_bg_terrain());
+       }
 }
 
 void map_editor::middle_button_down(const int mousex, const int mousey) {

Modified: trunk/src/editor/editor.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor/editor.hpp?rev=25632&r1=25631&r2=25632&view=diff
==============================================================================
--- trunk/src/editor/editor.hpp (original)
+++ trunk/src/editor/editor.hpp Sun Apr  6 17:50:07 2008
@@ -155,7 +155,7 @@
 
 private:
        //! What to perform while the left button is held down.
-       enum LEFT_BUTTON_HELD_FUNC {DRAW_TERRAIN, ADD_SELECTION, 
REMOVE_SELECTION,
+       enum LEFT_BUTTON_HELD_FUNC {DRAW_TERRAIN, DRAW_BASE_TERRAIN, 
ADD_SELECTION, REMOVE_SELECTION,
                                                                MOVE_SELECTION, 
NONE};
 
        //! What to perform on a left button click.
@@ -205,7 +205,7 @@
        //! Draw terrain at a location. The operation is saved in the undo
        //! stack. Update the map to reflect the change.
        void draw_terrain(const t_translation::t_terrain terrain,
-                                         const std::vector<gamemap::location> 
&hexes);
+                                         const std::vector<gamemap::location> 
&hexes, const bool base_only);
 
        //! Re-set the labels for the starting positions of the
        //! players. Should be called when the terrain has changed, which
@@ -272,7 +272,7 @@
 
        //! Draw the terrain on the hexes the mouse is over, taking account
        //! for brush size.
-       void draw_on_mouseover_hexes(const t_translation::t_terrain t);
+       void draw_on_mouseover_hexes(const t_translation::t_terrain t, const 
bool base_only = false);
 
        // Load the tooltips for each button
        void load_tooltips(void);


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

Reply via email to