Permalink
Browse files

Add possibility to kill unit under cursor

...with context menu in debug mode.
Also assign the hotkey "shift+k" for this action.
Patch by pl_kolek. See https://gna.org/patch/?3905
  • Loading branch information...
1 parent 02f73a6 commit 9d1dfe063858f06e7c259b9d3b6f5526eef4707c @flixx flixx committed Jun 9, 2013
View
@@ -32,6 +32,7 @@ Version 1.11.4+dev:
on purpose.
* Regular and menu buttons are now in subdirectories of images/buttons/
* Button icon overlays are now in images/icons/
+ * Added possibility to kill unit under cursor with context menu in debug mode.
* WML engine:
* Added new aspect 'advancements' which with lua engine can handle a
function return type of the form f(x, y) -> String. 'advancements'
View
@@ -101,6 +101,11 @@
key=" "
shift=yes
[/hotkey]
+[hotkey]
+ command=killunit
+ key=k
+ shift=yes
+[/hotkey]
[hotkey]
command=labelteamterrain
key=l
View
@@ -123,7 +123,7 @@
[menu]
is_context_menu=true
- items=wml,undo,redo,wbexecuteaction,wbdeleteaction,wbbumpupaction,wbbumpdownaction,wbsupposedead,describeunit,renameunit,createunit,changeside,labelteamterrain,labelterrain,clearlabels,speak,continue,recruit,recall,wbtoggle,delayshroud,updateshroud,cycle,endturn
+ items=wml,undo,redo,wbexecuteaction,wbdeleteaction,wbbumpupaction,wbbumpdownaction,wbsupposedead,describeunit,renameunit,createunit,changeside,,killunit,labelteamterrain,labelterrain,clearlabels,speak,continue,recruit,recall,wbtoggle,delayshroud,updateshroud,cycle,endturn
[/menu]
[mini_map]
id=mini-map
View
@@ -125,7 +125,7 @@
[menu]
is_context_menu=true
- items=wml,undo,redo,wbexecuteaction,wbdeleteaction,wbbumpupaction,wbbumpdownaction,wbsupposedead,describeunit,renameunit,createunit,changeside,labelteamterrain,labelterrain,clearlabels,speak,continue,recruit,recall,wbtoggle,delayshroud,updateshroud,cycle,endturn
+ items=wml,undo,redo,wbexecuteaction,wbdeleteaction,wbbumpupaction,wbbumpdownaction,wbsupposedead,describeunit,renameunit,createunit,changeside,killunit,labelteamterrain,labelterrain,clearlabels,speak,continue,recruit,recall,wbtoggle,delayshroud,updateshroud,cycle,endturn
[/menu]
@@ -155,7 +155,7 @@
[menu]
is_context_menu=true
- items=wml,undo,redo,wbexecuteaction,wbdeleteaction,wbbumpupaction,wbbumpdownaction,wbsupposedead,describeunit,renameunit,createunit,changeside,labelteamterrain,labelterrain,clearlabels,speak,continue,recruit,recall,wbtoggle,delayshroud,updateshroud,cycle,endturn
+ items=wml,undo,redo,wbexecuteaction,wbdeleteaction,wbbumpupaction,wbbumpdownaction,wbsupposedead,describeunit,renameunit,createunit,changeside,killunit,labelteamterrain,labelterrain,clearlabels,speak,continue,recruit,recall,wbtoggle,delayshroud,updateshroud,cycle,endturn
[/menu]
[mini_map]
id=mini-map
View
@@ -103,6 +103,7 @@ const hotkey_command hotkey_list_[] = {
{ hotkey::HOTKEY_SPEAK, "speak", N_("Speak"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_CREATE_UNIT, "createunit", N_("Create Unit (Debug!)"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_CHANGE_SIDE, "changeside", N_("Change Side (Debug!)"), false, hotkey::SCOPE_GAME, NULL },
+ { hotkey::HOTKEY_KILL_UNIT, "killunit", N_("Kill Unit (Debug!)"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_PREFERENCES, "preferences", N_("Preferences"), false, hotkey::SCOPE_GENERAL, NULL },
{ hotkey::HOTKEY_OBJECTIVES, "objectives", N_("Scenario Objectives"), false, hotkey::SCOPE_GAME, NULL },
{ hotkey::HOTKEY_UNIT_LIST, "unitlist", N_("Unit List"), false, hotkey::SCOPE_GENERAL, NULL },
@@ -1026,6 +1027,9 @@ bool command_executor::execute_command(HOTKEY_COMMAND command, int /*index*/)
case HOTKEY_CHANGE_SIDE:
change_side();
break;
+ case HOTKEY_KILL_UNIT:
+ kill_unit();
+ break;
case HOTKEY_PREFERENCES:
preferences();
break;
View
@@ -59,7 +59,7 @@ enum HOTKEY_COMMAND {
HOTKEY_SAVE_GAME, HOTKEY_SAVE_REPLAY, HOTKEY_SAVE_MAP, HOTKEY_LOAD_GAME,
HOTKEY_RECRUIT, HOTKEY_REPEAT_RECRUIT, HOTKEY_RECALL, HOTKEY_ENDTURN,
HOTKEY_TOGGLE_ELLIPSES, HOTKEY_TOGGLE_GRID, HOTKEY_STATUS_TABLE, HOTKEY_MUTE, HOTKEY_MOUSE_SCROLL,
- HOTKEY_SPEAK, HOTKEY_CREATE_UNIT, HOTKEY_CHANGE_SIDE, HOTKEY_PREFERENCES,
+ HOTKEY_SPEAK, HOTKEY_CREATE_UNIT, HOTKEY_CHANGE_SIDE, HOTKEY_KILL_UNIT, HOTKEY_PREFERENCES,
HOTKEY_OBJECTIVES, HOTKEY_UNIT_LIST, HOTKEY_STATISTICS, HOTKEY_STOP_NETWORK, HOTKEY_START_NETWORK, HOTKEY_QUIT_GAME,
HOTKEY_LABEL_TEAM_TERRAIN, HOTKEY_LABEL_TERRAIN, HOTKEY_CLEAR_LABELS,HOTKEY_SHOW_ENEMY_MOVES, HOTKEY_BEST_ENEMY_MOVES,
HOTKEY_DELAY_SHROUD, HOTKEY_UPDATE_SHROUD, HOTKEY_CONTINUE_MOVE,
@@ -353,6 +353,7 @@ class command_executor
virtual void shout() {}
virtual void create_unit() {}
virtual void change_side() {}
+ virtual void kill_unit() {}
virtual void preferences() {}
virtual void objectives() {}
virtual void unit_list() {}
View
@@ -1069,6 +1069,23 @@ void menu_handler::change_side(mouse_handler& mousehandler)
}
}
+void menu_handler::kill_unit(mouse_handler& mousehandler)
+{
+ const map_location& loc = mousehandler.get_last_hex();
+ const unit_map::iterator i = units_.find(loc);
+ if(i != units_.end()) {
+ const int dying_side = i->side();
+ game_events::fire("last breath", loc, loc);
+ if (i.valid()) {
+ unit_display::unit_die(loc, *i);
+ }
+ resources::screen->redraw_minimap();
+ game_events::fire("die", loc, loc);
+ resources::units->erase(i);
+ actions::recalculate_fog(dying_side);
+ }
+}
+
void menu_handler::label_terrain(mouse_handler& mousehandler, bool team_only)
{
const map_location& loc = mousehandler.get_last_hex();
View
@@ -67,6 +67,7 @@ class menu_handler : private chat_handler {
void create_unit(mouse_handler& mousehandler);
void create_unit_2(mouse_handler& mousehandler); // TODO: replace create_unit when complete
void change_side(mouse_handler& mousehandler);
+ void kill_unit(mouse_handler& mousehandler);
void label_terrain(mouse_handler& mousehandler, bool team_only);
void clear_labels();
void continue_move(mouse_handler &mousehandler, int side_num);
@@ -172,6 +172,10 @@ void playsingle_controller::change_side(){
menu_handler_.change_side(mouse_handler_);
}
+void playsingle_controller::kill_unit(){
+ menu_handler_.kill_unit(mouse_handler_);
+}
+
void playsingle_controller::label_terrain(bool team_only){
menu_handler_.label_terrain(mouse_handler_, team_only);
}
@@ -942,6 +946,7 @@ bool playsingle_controller::can_execute_command(hotkey::HOTKEY_COMMAND command,
// Commands we can only do if in debug mode
case hotkey::HOTKEY_CREATE_UNIT:
case hotkey::HOTKEY_CHANGE_SIDE:
+ case hotkey::HOTKEY_KILL_UNIT:
return !events::commands_disabled && game_config::debug && map_.on_board(mouse_handler_.get_last_hex());
case hotkey::HOTKEY_CLEAR_LABELS:
@@ -42,6 +42,7 @@ class playsingle_controller : public play_controller
virtual void rename_unit();
virtual void create_unit();
virtual void change_side();
+ virtual void kill_unit();
virtual void label_terrain(bool);
virtual void clear_labels();
virtual void continue_move();

0 comments on commit 9d1dfe0

Please sign in to comment.