Author: alink
Date: Wed Apr 30 05:52:10 2008
New Revision: 26242
URL: http://svn.gna.org/viewcvs/wesnoth?rev=26242&view=rev
Log:
New hotkey for debugging : "Custom command" which execute a saved command.
With a new command : "custom <command>" to assign a command to this hotkey.
examples: "custom refresh" or "custom create Troll" etc...
This custom command is saved in preferences.
Modified:
trunk/src/game_preferences.cpp
trunk/src/game_preferences.hpp
trunk/src/hotkeys.cpp
trunk/src/hotkeys.hpp
trunk/src/menu_events.cpp
trunk/src/menu_events.hpp
trunk/src/playsingle_controller.cpp
trunk/src/playsingle_controller.hpp
Modified: trunk/src/game_preferences.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_preferences.cpp?rev=26242&r1=26241&r2=26242&view=diff
==============================================================================
--- trunk/src/game_preferences.cpp (original)
+++ trunk/src/game_preferences.cpp Wed Apr 30 05:52:10 2008
@@ -704,6 +704,13 @@
return encountered_terrains_set;
}
+std::string custom_command() {
+ return preferences::get("custom_command");
+}
+
+void set_custom_command(const std::string& command) {
+ return preferences::set("custom_command", command);
+}
//! Returns a pointer to the history vector associated with given id
//! making a new one if it doesn't exist.
Modified: trunk/src/game_preferences.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game_preferences.hpp?rev=26242&r1=26241&r2=26242&view=diff
==============================================================================
--- trunk/src/game_preferences.hpp (original)
+++ trunk/src/game_preferences.hpp Wed Apr 30 05:52:10 2008
@@ -183,6 +183,9 @@
std::set<std::string> &encountered_units();
std::set<t_translation::t_terrain> &encountered_terrains();
+ std::string custom_command();
+ void set_custom_command(const std::string command);
+
std::vector<std::string>* get_history(const std::string& id);
std::string client_type();
Modified: trunk/src/hotkeys.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/hotkeys.cpp?rev=26242&r1=26241&r2=26242&view=diff
==============================================================================
--- trunk/src/hotkeys.cpp (original)
+++ trunk/src/hotkeys.cpp Wed Apr 30 05:52:10 2008
@@ -139,6 +139,7 @@
{ hotkey::HOTKEY_LANGUAGE, "changelanguage", N_("Change the language"),
true },
{ hotkey::HOTKEY_USER_CMD, "command", N_("Enter user command"), false },
+ { hotkey::HOTKEY_CUSTOM_CMD, "customcommand", N_("Custom command"),
false },
{ hotkey::HOTKEY_AI_FORMULA, "aiformula", N_("Run AI formula"), false },
{ hotkey::HOTKEY_CLEAR_MSG, "clearmessages", N_("Clear messages"),
false },
#ifdef USRCMD2
@@ -674,6 +675,9 @@
break;
case HOTKEY_USER_CMD:
user_command();
+ break;
+ case HOTKEY_CUSTOM_CMD:
+ custom_command();
break;
//%%
case HOTKEY_AI_FORMULA:
Modified: trunk/src/hotkeys.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/hotkeys.hpp?rev=26242&r1=26241&r2=26242&view=diff
==============================================================================
--- trunk/src/hotkeys.hpp (original)
+++ trunk/src/hotkeys.hpp Wed Apr 30 05:52:10 2008
@@ -61,6 +61,7 @@
//misc.
HOTKEY_USER_CMD,
+ HOTKEY_CUSTOM_CMD,
HOTKEY_AI_FORMULA,
HOTKEY_CLEAR_MSG,
#ifdef USRCMD2
@@ -212,6 +213,7 @@
virtual void show_help() {}
virtual void show_chat_log() {}
virtual void user_command() {}
+ virtual void custom_command() {}
virtual void ai_formula() {}
virtual void clear_messages() {}
#ifdef USRCMD2
Modified: trunk/src/menu_events.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.cpp?rev=26242&r1=26241&r2=26242&view=diff
==============================================================================
--- trunk/src/menu_events.cpp (original)
+++ trunk/src/menu_events.cpp Wed Apr 30 05:52:10 2008
@@ -2295,6 +2295,7 @@
void do_next_level();
void do_debug();
void do_nodebug();
+ void do_custom();
void do_set_var();
void do_show_var();
void do_unit();
@@ -2367,6 +2368,8 @@
_("Turn debug mode on."));
register_command("nodebug",
&console_handler::do_nodebug,
_("Turn debug mode off."), "", "D");
+ register_command("custom",
&console_handler::do_custom,
+ _("Set the command used by the custom
command hotkey"), "<command>");
register_command("set_var",
&console_handler::do_set_var,
_("Set a scenario variable."),
"<var>=<value>", "D");
register_command("show_var",
&console_handler::do_show_var,
@@ -2780,6 +2783,9 @@
print(get_cmd(), _("Debug mode deactivated!"));
game_config::debug = false;
}
+ void console_handler::do_custom() {
+ preferences::set("custom_command", get_data());
+ }
void console_handler::do_set_var() {
const std::string data = get_data();
const std::string::const_iterator j =
std::find(data.begin(),data.end(),'=');
@@ -2896,6 +2902,11 @@
textbox_info_.show(gui::TEXTBOX_COMMAND,sgettext("prompt^Command:"), "", false,
*gui_);
}
+ void menu_handler::custom_command(mouse_handler& mousehandler, const
unsigned int team_num)
+ {
+ do_command(preferences::custom_command(), team_num,
mousehandler);
+ }
+
void menu_handler::ai_formula()
{
std::cerr << "showing ai formula...\n";
Modified: trunk/src/menu_events.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/menu_events.hpp?rev=26242&r1=26241&r2=26242&view=diff
==============================================================================
--- trunk/src/menu_events.hpp (original)
+++ trunk/src/menu_events.hpp Wed Apr 30 05:52:10 2008
@@ -136,6 +136,7 @@
void end_unit_turn(mouse_handler& mousehandler, const unsigned int
team_num);
void search();
void user_command();
+ void custom_command(mouse_handler& mousehandler, const unsigned int
team_num);
void ai_formula();
void clear_messages();
#ifdef USRCMD2
Modified: trunk/src/playsingle_controller.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playsingle_controller.cpp?rev=26242&r1=26241&r2=26242&view=diff
==============================================================================
--- trunk/src/playsingle_controller.cpp (original)
+++ trunk/src/playsingle_controller.cpp Wed Apr 30 05:52:10 2008
@@ -129,6 +129,10 @@
void playsingle_controller::user_command(){
menu_handler_.user_command();
+}
+
+void playsingle_controller::custom_command(){
+ menu_handler_.custom_command(mouse_handler_, player_number_);
}
void playsingle_controller::ai_formula(){
Modified: trunk/src/playsingle_controller.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/playsingle_controller.hpp?rev=26242&r1=26241&r2=26242&view=diff
==============================================================================
--- trunk/src/playsingle_controller.hpp (original)
+++ trunk/src/playsingle_controller.hpp Wed Apr 30 05:52:10 2008
@@ -51,6 +51,7 @@
virtual void unit_hold_position();
virtual void end_unit_turn();
virtual void user_command();
+ virtual void custom_command();
virtual void ai_formula();
virtual void clear_messages();
#ifdef USRCMD2
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits