Basic support for area selecting.

This commit is contained in:
fendrin 2013-05-07 16:05:19 +02:00
parent b41322f710
commit e51aaa626f
7 changed files with 39 additions and 2 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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.
*/

View File

@ -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)
{

View File

@ -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
*/

View File

@ -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());

View File

@ -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.