mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-13 08:42:23 +00:00
editor2: Add selection handling in editor_map and editor_display
This commit is contained in:
parent
1795d97916
commit
67a40ebb46
@ -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 @@ image::TYPE editor_display::get_image_type(const gamemap::location& loc)
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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 @@ namespace editor2 {
|
||||
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)
|
||||
|
@ -55,4 +55,30 @@ std::vector<gamemap::location> editor_map::get_tiles_in_radius(const gamemap::lo
|
||||
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
|
||||
|
@ -29,6 +29,16 @@ public:
|
||||
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_;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user