Author: fendrin
Date: Fri Mar 30 17:42:21 2012
New Revision: 53695

URL: http://svn.gna.org/viewcvs/wesnoth?rev=53695&view=rev
Log:
Reenabled the select terrain from map feature.
More code cleanups.

Modified:
    trunk/src/editor/action/mouse/mouse_action.cpp
    trunk/src/editor/palette/editor_palettes.hpp
    trunk/src/editor/palette/terrain_palettes.cpp
    trunk/src/editor/palette/terrain_palettes.hpp
    trunk/src/reports.cpp

Modified: trunk/src/editor/action/mouse/mouse_action.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor/action/mouse/mouse_action.cpp?rev=53695&r1=53694&r2=53695&view=diff
==============================================================================
--- trunk/src/editor/action/mouse/mouse_action.cpp (original)
+++ trunk/src/editor/action/mouse/mouse_action.cpp Fri Mar 30 17:42:21 2012
@@ -22,6 +22,7 @@
 #include "construct_dialog.hpp"
 #include "gettext.hpp"
 #include "gui/dialogs/editor_set_starting_position.hpp"
+#include "editor/palette/terrain_palettes.hpp"
 
 namespace editor {
 
@@ -255,10 +256,8 @@
 editor_action* mouse_action_paint::click_left(editor_display& disp, int x, int 
y)
 {
        if (has_ctrl_modifier()) {
-//             map_location hex = disp.hex_clicked_on(x, y);
-//             TODO
-//             terrain_left_ = disp.map().get_terrain(hex);
-//             terrain_palette_->select_fg_item( 
(disp.map().get_terrain(hex)).id()    );
+               map_location hex = disp.hex_clicked_on(x, y);
+               set_selected_fg_terrain(disp.map().get_terrain(hex));
                return NULL;
        } else {
                return brush_drag_mouse_action::click_left(disp, x, y);
@@ -268,9 +267,8 @@
 editor_action* mouse_action_paint::click_right(editor_display& disp, int x, 
int y)
 {
        if (has_ctrl_modifier()) {
-//             map_location hex = disp.hex_clicked_on(x, y);
-//             TODO
-//             terrain_right_ = disp.map().get_terrain(hex);
+               map_location hex = disp.hex_clicked_on(x, y);
+               set_selected_bg_terrain(disp.map().get_terrain(hex));
                return NULL;
        } else {
                return brush_drag_mouse_action::click_right(disp, x, y);
@@ -386,8 +384,7 @@
 {
        map_location hex = disp.hex_clicked_on(x, y);
        if (has_ctrl_modifier()) {
-               //TODO
-               //terrain_left_ = disp.map().get_terrain(hex);
+               set_selected_fg_terrain(disp.map().get_terrain(hex));
                return NULL;
        } else {
                //TODO only take the base terrain into account when searching 
for contiguous terrain when painting base only
@@ -402,8 +399,7 @@
 {
        map_location hex = disp.hex_clicked_on(x, y);
        if (has_ctrl_modifier()) {
-               //TODO
-               //terrain_right_ = disp.map().get_terrain(hex);
+               set_selected_bg_terrain(disp.map().get_terrain(hex));
                return NULL;
        } else {
                //TODO only take the base terrain into account when searching 
for contiguous terrain when painting base only

Modified: trunk/src/editor/palette/editor_palettes.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor/palette/editor_palettes.hpp?rev=53695&r1=53694&r2=53695&view=diff
==============================================================================
--- trunk/src/editor/palette/editor_palettes.hpp (original)
+++ trunk/src/editor/palette/editor_palettes.hpp Fri Mar 30 17:42:21 2012
@@ -24,7 +24,9 @@
 
 template<class Item>
 class editor_palette : public common_palette {
+
 public:
+
        editor_palette(editor_display &gui, const size_specs &sizes, const 
config& /*cfg*/
                        , size_t item_size, size_t item_width, mouse_action** 
active_mouse_action)
                : groups_()
@@ -48,13 +50,16 @@
        {
        };
 
+       void set_start_item(size_t index) { items_start_ = index; };
+
+       size_t start_num(void) { return items_start_; };
+
        /** Menu expanding for palette group list */
        void expand_palette_groups_menu(std::vector<std::string>& items);
 
        void set_group(size_t index);
 
        const std::vector<item_group>& get_groups() const { return groups_; };
-
 
        virtual void draw(bool);
 
@@ -75,16 +80,23 @@
         */
        void adjust_size(const size_specs& size);
 
+       virtual bool scroll_up();
+       virtual bool scroll_down();
 
+       virtual const config active_group_report();
+
+       void swap();
+
+       /** Return the currently selected foreground/background item. */
+       const Item& selected_fg_item() const { return 
item_map_.find(selected_fg_item_)->second; };
+       const Item& selected_bg_item() const { return 
item_map_.find(selected_bg_item_)->second; };
+
+private:
 
        /** Return the number of the tile that is at coordinates (x, y) in the 
panel. */
        int tile_selected(const int x, const int y) const;
 
-       virtual bool scroll_up();
-       virtual bool scroll_down();
-
-private:
-
+       /** TODO */
        size_t active_group_index();
 
        /** Scroll the editor-palette to the top. */
@@ -102,9 +114,10 @@
 
        virtual const std::string& active_group_id() {return active_group_;};
 
-public:
-       virtual const config active_group_report();
+       /** Return the number of items in the palette. */
+       size_t num_items();
 
+       void draw_old(bool);
 
 protected:
        /**
@@ -116,16 +129,10 @@
        virtual void set_group(const std::string& id);
        const std::vector<std::string>& active_group() { return 
group_map_[active_group_]; };
 
-public:
-       /** Return the currently selected foreground/background item. */
-       const Item& selected_fg_item() const { return 
item_map_.find(selected_fg_item_)->second; };
-       const Item& selected_bg_item() const { return 
item_map_.find(selected_bg_item_)->second; };
+       /** Select a foreground item. */
+       virtual void select_fg_item(std::string item_id);
+       virtual void select_bg_item(std::string item_id);
 
-       void set_start_item(size_t index) { items_start_ = index; };
-
-       size_t start_num(void) { return items_start_; };
-
-protected:
        /**
         * The editor_groups as defined in editor-groups.cfg.
         *
@@ -134,40 +141,12 @@
         */
        std::vector<item_group> groups_;
 
-private:
-       /** Return the currently selected background item. */
-//     Item selected_bg_item() const { return selected_bg_item_; };
-
-       void swap();
-
-protected:
-       /** Select a foreground item. */
-       virtual void select_fg_item(std::string item_id);
-       virtual void select_bg_item(std::string item_id);
-
-private:
-
-       /** Return the number of items in the palette. */
-       size_t num_items();
-
-       void draw_old(bool);
-
-protected:
        editor_display &gui_;
        const size_specs &size_specs_;
 
        int item_size_;
        int item_width_;
        int item_space_;
-
-protected:
-
-       /** Update the report with the currently selected items. */
-/*
-       virtual void update_report() = 0;
-*/
-
-protected:
 
 private:
        unsigned int palette_y_;

Modified: trunk/src/editor/palette/terrain_palettes.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor/palette/terrain_palettes.cpp?rev=53695&r1=53694&r2=53695&view=diff
==============================================================================
--- trunk/src/editor/palette/terrain_palettes.cpp (original)
+++ trunk/src/editor/palette/terrain_palettes.cpp Fri Mar 30 17:42:21 2012
@@ -26,12 +26,19 @@
 
 namespace {
        static std::string selected_terrain;
+       static t_translation::t_terrain fg_terrain;
        static t_translation::t_terrain bg_terrain;
 }
 
-
-
 namespace editor {
+
+void set_selected_bg_terrain(t_translation::t_terrain terrain) {
+       bg_terrain = terrain;
+}
+
+void set_selected_fg_terrain(t_translation::t_terrain terrain) {
+       fg_terrain = terrain;
+}
 
 t_translation::t_terrain get_selected_bg_terrain() {
        return bg_terrain;

Modified: trunk/src/editor/palette/terrain_palettes.hpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor/palette/terrain_palettes.hpp?rev=53695&r1=53694&r2=53695&view=diff
==============================================================================
--- trunk/src/editor/palette/terrain_palettes.hpp (original)
+++ trunk/src/editor/palette/terrain_palettes.hpp Fri Mar 30 17:42:21 2012
@@ -25,9 +25,15 @@
 
 namespace editor {
 
-std::string get_selected_terrain();
+//TODO
+//std::string get_selected_terrain();
 
+t_translation::t_terrain get_selected_fg_terrain();
 t_translation::t_terrain get_selected_bg_terrain();
+
+//Those could be moved inside the class.
+void set_selected_fg_terrain(t_translation::t_terrain terrain);
+void set_selected_bg_terrain(t_translation::t_terrain terrain);
 
 /** Palette where the terrain to be drawn can be selected. */
 class terrain_palette : public editor_palette<t_translation::t_terrain> {

Modified: trunk/src/reports.cpp
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/src/reports.cpp?rev=53695&r1=53694&r2=53695&view=diff
==============================================================================
--- trunk/src/reports.cpp (original)
+++ trunk/src/reports.cpp Fri Mar 30 17:42:21 2012
@@ -1184,6 +1184,7 @@
        return image_report(game_config::images::observer, str.str());
 }
 
+/* TODO unused
 REPORT_GENERATOR(selected_terrain)
 {
        const std::string selected_terrain = editor::get_selected_terrain();
@@ -1192,6 +1193,7 @@
        else
                return text_report(selected_terrain);
 }
+*/
 
 /* TODO this is unused
 REPORT_GENERATOR(edit_left_button_function)


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

Reply via email to