Author: ilor
Date: Mon Jul 7 15:54:13 2008
New Revision: 27815
URL: http://svn.gna.org/viewcvs/wesnoth?rev=27815&view=rev
Log:
editor2: Add selection handling in editor_map and editor_display
Modified:
trunk/src/editor2/editor_display.cpp
trunk/src/editor2/editor_display.hpp
trunk/src/editor2/editor_map.cpp
trunk/src/editor2/editor_map.hpp
Modified: trunk/src/editor2/editor_display.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_display.cpp?rev=27815&r1=27814&r2=27815&view=diff
==============================================================================
--- trunk/src/editor2/editor_display.cpp (original)
+++ trunk/src/editor2/editor_display.cpp Mon Jul 7 15:54:13 2008
@@ -17,7 +17,7 @@
namespace editor2 {
-editor_display::editor_display(CVideo& video, const gamemap& map,
+editor_display::editor_display(CVideo& video, const editor_map& map,
const config& theme_cfg, const config& cfg,
const config& level) :
display(video, map, theme_cfg, cfg, level)
@@ -35,7 +35,9 @@
return image::BRIGHTENED;
} else if (highlighted_locations_.find(loc) !=
highlighted_locations_.end()) {
return image::SEMI_BRIGHTENED;
- }
+ } else if (map().in_selection(loc)) {
+ return image::SEMI_BRIGHTENED;
+ }
return image::SCALED_TO_HEX;
}
Modified: trunk/src/editor2/editor_display.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_display.hpp?rev=27815&r1=27814&r2=27815&view=diff
==============================================================================
--- trunk/src/editor2/editor_display.hpp (original)
+++ trunk/src/editor2/editor_display.hpp Mon Jul 7 15:54:13 2008
@@ -14,6 +14,7 @@
#ifndef EDITOR2_EDITOR_DISPLAY_HPP_INCLUDED
#define EDITOR2_EDITOR_DISPLAY_HPP_INCLUDED
+#include "editor_map.hpp"
#include "../display.hpp"
namespace editor2 {
@@ -21,12 +22,13 @@
class editor_display : public display
{
public:
- editor_display(CVideo& video, const gamemap& map, const config&
theme_cfg,
+ editor_display(CVideo& video, const editor_map& map, const config&
theme_cfg,
const config& cfg, const config& level);
bool in_editor() const { return true; }
protected:
+ const editor_map& map() { return static_cast<const editor_map&>(map_); }
void pre_draw();
/**
* The editor uses different rules for terrain highligting (e.g.
selections)
Modified: trunk/src/editor2/editor_map.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_map.cpp?rev=27815&r1=27814&r2=27815&view=diff
==============================================================================
--- trunk/src/editor2/editor_map.cpp (original)
+++ trunk/src/editor2/editor_map.cpp Mon Jul 7 15:54:13 2008
@@ -55,4 +55,30 @@
return res;
}
+bool editor_map::in_selection(const gamemap::location& loc) const
+{
+ return selection_.find(loc) != selection_.end();
+}
+bool editor_map::add_to_selection(const gamemap::location& loc)
+{
+ return selection_.insert(loc).second;
+}
+bool editor_map::remove_from_selection(const gamemap::location& loc)
+{
+ return selection_.erase(loc);
+}
+void editor_map::clear_selection()
+{
+ selection_.clear();
+}
+void editor_map::invert_selection()
+{
+
+}
+void editor_map::select_all()
+{
+ clear_selection();
+ invert_selection();
+}
+
} //end namespace editor2
Modified: trunk/src/editor2/editor_map.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/editor2/editor_map.hpp?rev=27815&r1=27814&r2=27815&view=diff
==============================================================================
--- trunk/src/editor2/editor_map.hpp (original)
+++ trunk/src/editor2/editor_map.hpp Mon Jul 7 15:54:13 2008
@@ -29,6 +29,16 @@
editor_map(const config& terrain_cfg, const std::string& data);
std::vector<gamemap::location> get_tiles_in_radius(const
gamemap::location& center, const unsigned int radius);
static editor_map new_map(const config& terrain_cfg, size_t width,
size_t height, t_translation::t_terrain filler);
+
+ bool in_selection(const gamemap::location& loc) const;
+ bool add_to_selection(const gamemap::location& loc);
+ bool remove_from_selection(const gamemap::location& loc);
+ const std::set<gamemap::location> selection() const { return
selection_; }
+ void clear_selection();
+ void invert_selection();
+ void select_all();
+protected:
+ std::set<gamemap::location> selection_;
};
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits