'Select all' operation added.
This commit is contained in:
parent
8abbc7fba0
commit
3ee1fbff42
6 changed files with 38 additions and 2 deletions
|
@ -178,6 +178,14 @@ alt=no
|
|||
shift=no
|
||||
[/hotkey]
|
||||
|
||||
[hotkey]
|
||||
command="editselectall"
|
||||
key="a"
|
||||
ctrl=yes
|
||||
alt=no
|
||||
shift=no
|
||||
[/hotkey]
|
||||
|
||||
[resolution]
|
||||
width=800
|
||||
height=600
|
||||
|
|
|
@ -496,6 +496,7 @@ action_editpaste="Paste"
|
|||
action_editrevert="Revert from Disk"
|
||||
action_editresize="Resize Map"
|
||||
action_editflip="Flip Map"
|
||||
action_editselectall="Select All"
|
||||
save_hotkeys_button="Save Hotkeys"
|
||||
change_hotkey_button="Change Hotkey"
|
||||
hotkeys_dialog="Hotkey Settings"
|
||||
|
|
|
@ -82,7 +82,7 @@ map_editor::map_editor(display &gui, gamemap &map, config &theme, config &game_c
|
|||
: gui_(gui), map_(map), abort_(DONT_ABORT),
|
||||
theme_(theme), game_config_(game_config), map_dirty_(false),
|
||||
palette_(gui, size_specs_, map), brush_(gui, size_specs_),
|
||||
l_button_func_(NONE), prefs_disp_manager_(&gui_) {
|
||||
l_button_func_(NONE), prefs_disp_manager_(&gui_), all_hexes_selected_(false) {
|
||||
|
||||
// Set size specs.
|
||||
adjust_sizes(gui_, size_specs_);
|
||||
|
@ -389,6 +389,22 @@ void map_editor::edit_flip() {
|
|||
}
|
||||
}
|
||||
|
||||
void map_editor::edit_select_all() {
|
||||
if (!all_hexes_selected_) {
|
||||
for (int i = 0; i < map_.x(); i++) {
|
||||
for (int j = 0; j < map_.y(); j++) {
|
||||
selected_hexes_.insert(gamemap::location(i, j));
|
||||
}
|
||||
}
|
||||
all_hexes_selected_ = true;
|
||||
}
|
||||
else {
|
||||
selected_hexes_.clear();
|
||||
all_hexes_selected_ = false;
|
||||
}
|
||||
highlight_selected_hexes();
|
||||
}
|
||||
|
||||
std::string map_editor::load_map(const std::string filename) {
|
||||
bool load_successful = true;
|
||||
std::string msg = "'";
|
||||
|
@ -464,6 +480,7 @@ bool map_editor::can_execute_command(hotkey::HOTKEY_COMMAND command) const {
|
|||
case hotkey::HOTKEY_EDIT_REVERT:
|
||||
case hotkey::HOTKEY_EDIT_RESIZE:
|
||||
case hotkey::HOTKEY_EDIT_FLIP:
|
||||
case hotkey::HOTKEY_EDIT_SELECT_ALL:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
|
|
@ -106,6 +106,9 @@ public:
|
|||
virtual void edit_revert();
|
||||
virtual void edit_resize();
|
||||
virtual void edit_flip();
|
||||
/// Either select or deselect all hexes on the map depending on if
|
||||
/// this operations has been invoked before or not.
|
||||
virtual void edit_select_all();
|
||||
|
||||
virtual bool can_execute_command(hotkey::HOTKEY_COMMAND command) const;
|
||||
|
||||
|
@ -263,6 +266,7 @@ private:
|
|||
const preferences::display_manager prefs_disp_manager_;
|
||||
static config prefs_;
|
||||
static bool first_time_created_;
|
||||
bool all_hexes_selected_;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ HOTKEY_COMMAND string_to_command(const std::string& str)
|
|||
m.insert(val("editrevert",HOTKEY_EDIT_REVERT));
|
||||
m.insert(val("editresize",HOTKEY_EDIT_RESIZE));
|
||||
m.insert(val("editflip",HOTKEY_EDIT_FLIP));
|
||||
m.insert(val("editselectall",HOTKEY_EDIT_SELECT_ALL));
|
||||
m.insert(val("delayshroud",HOTKEY_DELAY_SHROUD));
|
||||
m.insert(val("updateshroud",HOTKEY_UPDATE_SHROUD));
|
||||
m.insert(val("continue",HOTKEY_CONTINUE_MOVE));
|
||||
|
@ -477,6 +478,10 @@ void execute_command(display& disp, HOTKEY_COMMAND command, command_executor* ex
|
|||
if(executor)
|
||||
executor->edit_flip();
|
||||
break;
|
||||
case HOTKEY_EDIT_SELECT_ALL:
|
||||
if(executor)
|
||||
executor->edit_select_all();
|
||||
break;
|
||||
default:
|
||||
std::cerr << "command_executor: unknown command number " << command << ", ignoring.\n";
|
||||
break;
|
||||
|
|
|
@ -44,7 +44,7 @@ enum HOTKEY_COMMAND { HOTKEY_CYCLE_UNITS, HOTKEY_END_UNIT_TURN, HOTKEY_LEADER,
|
|||
HOTKEY_EDIT_NEW_MAP, HOTKEY_EDIT_LOAD_MAP, HOTKEY_EDIT_FLOOD_FILL,
|
||||
HOTKEY_EDIT_FILL_SELECTION, HOTKEY_EDIT_CUT, HOTKEY_EDIT_COPY,
|
||||
HOTKEY_EDIT_PASTE, HOTKEY_EDIT_REVERT, HOTKEY_EDIT_RESIZE,
|
||||
HOTKEY_EDIT_FLIP,
|
||||
HOTKEY_EDIT_FLIP, HOTKEY_EDIT_SELECT_ALL,
|
||||
HOTKEY_NULL };
|
||||
|
||||
struct hotkey_item {
|
||||
|
@ -135,6 +135,7 @@ public:
|
|||
virtual void edit_revert() {}
|
||||
virtual void edit_resize() {}
|
||||
virtual void edit_flip() {}
|
||||
virtual void edit_select_all() {}
|
||||
|
||||
//Gets the action's image (if any). Displayed left of the action text in menus.
|
||||
virtual std::string get_action_image(hotkey::HOTKEY_COMMAND command) const { return ""; }
|
||||
|
|
Loading…
Add table
Reference in a new issue