From cc19180ac00c767abe164ad275fab6ab4aeb0888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 9 Aug 2011 01:50:22 +0200 Subject: [PATCH] Add 'help' options to a bunch of commands. --- plugins/cleanmap.cpp | 16 +++++++++++++++- plugins/colonies.cpp | 19 +++++++++++++++---- plugins/deramp.cpp | 12 +++++++++++- plugins/liquids.cpp | 10 ++++++++++ plugins/plants.cpp | 42 +++++++++++++++++++++++++++++++++--------- plugins/prospector.cpp | 19 ++++++++++++++++--- plugins/weather.cpp | 10 ++++++++-- 7 files changed, 108 insertions(+), 20 deletions(-) diff --git a/plugins/cleanmap.cpp b/plugins/cleanmap.cpp index 132b8bd4f..3277d0093 100644 --- a/plugins/cleanmap.cpp +++ b/plugins/cleanmap.cpp @@ -21,7 +21,7 @@ DFhackCExport const char * plugin_name ( void ) DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { commands.clear(); - commands.push_back(PluginCommand("cleanmap","Cleans the map from various substances. Options: 'snow' for removing snow, 'mud' for mud.",cleanmap)); + commands.push_back(PluginCommand("cleanmap","Cleans the map from various substances.",cleanmap)); return CR_OK; } @@ -37,12 +37,26 @@ DFhackCExport command_result cleanmap (Core * c, vector & parameters) bool snow = false; bool mud = false; + bool help = false; for(int i = 0; i < parameters.size();i++) { if(parameters[i] == "snow") snow = true; else if(parameters[i] == "mud") mud = true; + else if(parameters[i] == "help" ||parameters[i] == "?") + { + help = true; + } + } + if(help) + { + c->con.print("This command cleans the coverings from the map. Snow and mud are ignored by default.\n" + "Options:\n" + "snow - also remove snow\n" + "mud - also remove mud\n" + ); + return CR_OK; } c->Suspend(); vector splatter; diff --git a/plugins/colonies.cpp b/plugins/colonies.cpp index 4bba91ad9..ce8beccb8 100644 --- a/plugins/colonies.cpp +++ b/plugins/colonies.cpp @@ -22,9 +22,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector { commands.clear(); commands.push_back(PluginCommand("colonies", - "List or change wild colonies (ants hills and such)\ -\n Options: 'kill' = destroy all colonies\ -\n 'bees' = change all colonies to honey bees", + "List or change wild colonies (ants hills and such)", colonies)); return CR_OK; } @@ -43,6 +41,7 @@ DFhackCExport command_result colonies (Core * c, vector & parameters) { bool destroy = false; bool convert = false; + bool help = false; for(int i = 0; i < parameters.size();i++) { @@ -50,8 +49,20 @@ DFhackCExport command_result colonies (Core * c, vector & parameters) destroy = true; else if(parameters[i] == "bees") convert = true; + else if(parameters[i] == "help" || parameters[i] == "?") + { + help = true; + } + } + if(help) + { + c->con.print("Without any options, this command lists all the vermin colonies present.\n" + "Options:\n" + "kill - destroy colonies\n" + "bees - turn colonies into honey bees\n" + ); + return CR_OK; } - if (destroy && convert) { c->con.printerr("Kill or make bees? DECIDE!\n"); diff --git a/plugins/deramp.cpp b/plugins/deramp.cpp index a52ecf442..49ee415d1 100644 --- a/plugins/deramp.cpp +++ b/plugins/deramp.cpp @@ -51,7 +51,17 @@ DFhackCExport command_result df_deramp (Core * c, vector & parameters) bool dirty= false; int count=0; int countbad=0; - + for(int i = 0; i < parameters.size();i++) + { + if(parameters[i] == "help" || parameters[i] == "?") + { + c->con.print("This command does two things:\n" + "* If there are any ramps designated for removal, thyw will be instantly removed.\n" + "* Any ramps that don't have their counterpart will be removed (fixes bugs with caveins)\n" + ); + return CR_OK; + } + } c->Suspend(); DFHack::Maps *Mapz = c->getMaps(); diff --git a/plugins/liquids.cpp b/plugins/liquids.cpp index 7acfc1b00..27035bff9 100644 --- a/plugins/liquids.cpp +++ b/plugins/liquids.cpp @@ -166,6 +166,16 @@ DFhackCExport command_result df_liquids (Core * c, vector & parameters) DFHack::Maps * Maps; DFHack::Gui * Position; + for(int i = 0; i < parameters.size();i++) + { + if(parameters[i] == "help" || parameters[i] == "?") + { + c->con.print("This tool allows placing magma, water and other similar things.\n" + "It is interactive and further help is available when you run it.\n" + ); + return CR_OK; + } + } Brush * brush = new RectangleBrush(1,1); string brushname = "point"; bool end = false; diff --git a/plugins/plants.cpp b/plugins/plants.cpp index 20e1700d0..7afa0d897 100644 --- a/plugins/plants.cpp +++ b/plugins/plants.cpp @@ -48,7 +48,7 @@ enum do_what do_extirpate }; -static bool getoptions( vector & parameters, bool & shrubs, bool & trees) +static bool getoptions( vector & parameters, bool & shrubs, bool & trees, bool & help) { for(int i = 0;i < parameters.size();i++) { @@ -65,6 +65,10 @@ static bool getoptions( vector & parameters, bool & shrubs, bool & tree trees = true; shrubs = true; } + else if(parameters[i] == "help" || parameters[i] == "?") + { + help = true; + } else { return false; @@ -79,8 +83,21 @@ static bool getoptions( vector & parameters, bool & shrubs, bool & tree * And he cursed the plants and trees for their bloodless wood, turning them into ash and smoldering ruin. * Armok was pleased and great temples were built by the dwarves, for they shared his hatred for trees and plants. */ -static command_result immolations (Core * c, do_what what, bool shrubs, bool trees) +static command_result immolations (Core * c, do_what what, bool shrubs, bool trees, bool help) { + static const char * what1 = "destroys"; + static const char * what2 = "burns"; + if(help) + { + c->con.print("Without any options, this command %s a plant under the cursor.\n" + "Options:\n" + "shrubs - affect all shrubs\n" + "trees - affect all trees\n" + "all - affect all plants\n", + what == do_immolate? what2 : what1 + ); + return CR_OK; + } c->Suspend(); DFHack::Maps *maps = c->getMaps(); if (!maps->Start()) @@ -158,10 +175,10 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre DFhackCExport command_result df_immolate (Core * c, vector & parameters) { - bool shrubs = false, trees = false; - if(getoptions(parameters,shrubs,trees)) + bool shrubs = false, trees = false, help = false; + if(getoptions(parameters,shrubs,trees,help)) { - return immolations(c,do_immolate,shrubs,trees); + return immolations(c,do_immolate,shrubs,trees, help); } else { @@ -172,10 +189,10 @@ DFhackCExport command_result df_immolate (Core * c, vector & parameters DFhackCExport command_result df_extirpate (Core * c, vector & parameters) { - bool shrubs = false, trees = false; - if(getoptions(parameters,shrubs,trees)) + bool shrubs = false, trees = false, help = false; + if(getoptions(parameters,shrubs,trees, help)) { - return immolations(c,do_extirpate,shrubs,trees); + return immolations(c,do_extirpate,shrubs,trees, help); } else { @@ -186,7 +203,14 @@ DFhackCExport command_result df_extirpate (Core * c, vector & parameter DFhackCExport command_result df_grow (Core * c, vector & parameters) { - //uint32_t x_max = 0, y_max = 0, z_max = 0; + for(int i = 0; i < parameters.size();i++) + { + if(parameters[i] == "help" || parameters[i] == "?") + { + c->con.print("This command turns all living saplings into full-grown trees.\n"); + return CR_OK; + } + } c->Suspend(); DFHack::Maps *maps = c->getMaps(); Console & con = c->con; diff --git a/plugins/prospector.cpp b/plugins/prospector.cpp index 751218fc0..6bfca143d 100644 --- a/plugins/prospector.cpp +++ b/plugins/prospector.cpp @@ -125,7 +125,7 @@ DFhackCExport const char * plugin_name ( void ) DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { commands.clear(); - commands.push_back(PluginCommand("prospect","Show stats of available raw resources. Use parameter 'all' to show hidden resources.",prospector)); + commands.push_back(PluginCommand("prospect","Show stats of available raw resources. Use option 'all' to show hidden resources.",prospector)); return CR_OK; } @@ -141,9 +141,22 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector & par bool showSlade = true; bool showTemple = true; Console & con = c->con; - if(parameters.size() && parameters[0] == "all") + for(int i = 0; i < parameters.size();i++) { - showHidden = true; + if (parameters[0] == "all") + { + showHidden = true; + } + else if(parameters[i] == "help" || parameters[i] == "?") + { + c->con.print("Prints a big list of all the present minerals.\n" + "By default, only the visible part of the map is scanned.\n" + "\n" + "Options:\n" + "all - Scan the whole map, as if it was revealed.\n" + ); + return CR_OK; + } } uint32_t x_max = 0, y_max = 0, z_max = 0; c->Suspend(); diff --git a/plugins/weather.cpp b/plugins/weather.cpp index bc3c39b33..76757b257 100644 --- a/plugins/weather.cpp +++ b/plugins/weather.cpp @@ -25,8 +25,7 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector commands.clear(); commands.push_back(PluginCommand("weather", "Print the weather map or change weather.\ -\n Options: 'lock'/'unlock' = disallow game from changing weather\ -\n 'snow' = make it snow, 'rain' = make it rain.\ +\n Options: 'snow' = make it snow, 'rain' = make it rain.\ \n 'clear' = clear the sky",weather)); return CR_OK; } @@ -44,6 +43,7 @@ DFhackCExport command_result weather (Core * c, vector & parameters) bool snow = false; bool rain = false; bool clear = false; + bool help = false; for(int i = 0; i < parameters.size();i++) { if(parameters[i] == "rain") @@ -56,6 +56,12 @@ DFhackCExport command_result weather (Core * c, vector & parameters) lock = true; else if(parameters[i] == "unlock") unlock = true; + else if(parameters[i] == "help" || parameters[i] == "?") + help = true; + } + if(help) + { + } if(lock && unlock) {