mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-29 23:11:41 +00:00
Basic support for area selecting.
This commit is contained in:
parent
b41322f710
commit
e51aaa626f
@ -486,8 +486,8 @@ bool editor_controller::execute_command(hotkey::HOTKEY_COMMAND command, int inde
|
||||
// toolkit_->get_palette_manager()->draw();
|
||||
return true;
|
||||
case AREA:
|
||||
//TODO
|
||||
return true;
|
||||
//TODO store the selection for the state setting.
|
||||
return context_manager_->get_map_context().select_area(index);
|
||||
}
|
||||
return true;
|
||||
|
||||
|
@ -167,6 +167,16 @@ bool editor_map::add_to_selection(const map_location& loc)
|
||||
return on_board_with_border(loc) ? selection_.insert(loc).second : false;
|
||||
}
|
||||
|
||||
bool editor_map::set_selection(const std::set<map_location>& area)
|
||||
{
|
||||
clear_selection();
|
||||
BOOST_FOREACH(const map_location& loc, area) {
|
||||
if (!add_to_selection(loc))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool editor_map::remove_from_selection(const map_location& loc)
|
||||
{
|
||||
return selection_.erase(loc) != 0;
|
||||
|
@ -138,6 +138,12 @@ public:
|
||||
*/
|
||||
bool remove_from_selection(const map_location& loc);
|
||||
|
||||
/**
|
||||
* Select the given area.
|
||||
* @param area to select.
|
||||
*/
|
||||
bool set_selection(const std::set<map_location>& area);
|
||||
|
||||
/**
|
||||
* Return the selection set.
|
||||
*/
|
||||
|
@ -177,6 +177,11 @@ map_context::~map_context()
|
||||
clear_stack(redo_stack_);
|
||||
}
|
||||
|
||||
bool map_context::select_area(int index)
|
||||
{
|
||||
return map_.set_selection(tod_manager_->get_area_by_index(index));
|
||||
}
|
||||
|
||||
void map_context::draw_terrain(const t_translation::t_terrain & terrain,
|
||||
const map_location& loc, bool one_layer_only)
|
||||
{
|
||||
|
@ -58,6 +58,12 @@ public:
|
||||
*/
|
||||
~map_context();
|
||||
|
||||
/**
|
||||
* Select the nth tod area.
|
||||
* @param index of the tod area to select.
|
||||
*/
|
||||
bool select_area(int index);
|
||||
|
||||
/**
|
||||
* Map accesor
|
||||
*/
|
||||
|
@ -208,6 +208,11 @@ std::vector<std::string> tod_manager::get_area_ids() const
|
||||
return areas;
|
||||
}
|
||||
|
||||
const std::set<map_location>& tod_manager::get_area_by_index(int index) const
|
||||
{
|
||||
return areas_[index].hexes;
|
||||
}
|
||||
|
||||
void tod_manager::add_time_area(const config& cfg)
|
||||
{
|
||||
areas_.push_back(area_time_of_day());
|
||||
|
@ -71,6 +71,11 @@ class tod_manager : public savegame::savegame_config
|
||||
*/
|
||||
std::vector<std::string> get_area_ids() const;
|
||||
|
||||
/**
|
||||
* @returns the nth area.
|
||||
*/
|
||||
const std::set<map_location>& get_area_by_index(int index) const;
|
||||
|
||||
/**
|
||||
* Adds a new local time area from config, making it follow its own
|
||||
* time-of-day sequence.
|
||||
|
Loading…
x
Reference in New Issue
Block a user