From e14548ba4c392e65c24af12eaabd274bb043fa6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Mon, 15 Aug 2011 06:48:25 +0200 Subject: [PATCH] Added menu ID watcher command and some info on bug reporting/error logs --- README.rst | 2 +- plugins/devel/kittens.cpp | 39 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index cd9bc697f..b32ce4f4e 100644 --- a/README.rst +++ b/README.rst @@ -53,7 +53,7 @@ DFHack basically extends what DF can do with something similar to a quake consol Basic interaction with dfhack involves entering commands into the console. For some basic instroduction, use the 'help' command. To list all possible commands, use the 'ls' command. Many commands have their own help or detailed description. You can use 'command help' or 'command ?' to show that. -The command line has some nce line editing capabilities, including history that's preserved between different runs of DF (use up/down keys to go through the history). +The command line has some nice line editing capabilities, including history that's preserved between different runs of DF (use up/down keys to go through the history). The second way to interact with DFHack is to bind the available commands to in-game hotkeys. This is done in the hotkey/zoom menu (normally opened with the 'h' key). Binding the commands is done by assigning a command as a hotkey name (with 'n'). Some commands can't be used from hotkeys - this includes interactive commands like 'liquids' and commands that have names longer than 9 characters. diff --git a/plugins/devel/kittens.cpp b/plugins/devel/kittens.cpp index 6becd3763..c161df1e5 100644 --- a/plugins/devel/kittens.cpp +++ b/plugins/devel/kittens.cpp @@ -15,11 +15,14 @@ using namespace DFHack; bool shutdown_flag = false; bool final_flag = true; bool timering = false; +bool trackmenu_flg = false; +uint32_t last_menu = 0; uint64_t timeLast = 0; DFhackCExport command_result kittens (Core * c, vector & parameters); DFhackCExport command_result ktimer (Core * c, vector & parameters); DFhackCExport command_result bflags (Core * c, vector & parameters); +DFhackCExport command_result trackmenu (Core * c, vector & parameters); DFhackCExport const char * plugin_name ( void ) { @@ -30,8 +33,9 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector { commands.clear(); commands.push_back(PluginCommand("nyan","NYAN CAT INVASION!",kittens, true)); - commands.push_back(PluginCommand("ktimer","Measure time between game updates and console lag.",ktimer)); + commands.push_back(PluginCommand("ktimer","Measure time between game updates and console lag (toggle).",ktimer)); commands.push_back(PluginCommand("blockflags","Look up block flags",bflags)); + commands.push_back(PluginCommand("trackmenu","Track menu ID changes (toggle).",trackmenu)); return CR_OK; } @@ -56,8 +60,41 @@ DFhackCExport command_result plugin_onupdate ( Core * c ) timeLast = time2; c->con.print("Time delta = %d ms\n", delta); } + if(trackmenu_flg) + { + DFHack::Gui * g =c->getGui(); + if (last_menu != *g->df_menu_state) + { + last_menu = *g->df_menu_state; + c->con.print("Menu: %d\n",last_menu); + } + } return CR_OK; } +DFhackCExport command_result trackmenu (Core * c, vector & parameters) +{ + if(trackmenu_flg) + { + trackmenu_flg = false; + return CR_OK; + } + else + { + DFHack::Gui * g =c->getGui(); + if(g->df_menu_state) + { + trackmenu_flg = true; + last_menu = *g->df_menu_state; + c->con.print("Menu: %d\n",last_menu); + return CR_OK; + } + else + { + c->con.printerr("Can't read menu state\n"); + return CR_FAILURE; + } + } +} DFhackCExport command_result bflags (Core * c, vector & parameters) {