diff options
| author | Alexander Gavrilov | 2011-12-24 14:51:58 +0400 |
|---|---|---|
| committer | Alexander Gavrilov | 2011-12-24 14:51:58 +0400 |
| commit | 79ac2a781a3bfd3395a5785098a16403c1a9d3ce (patch) | |
| tree | 91b5942ba1a17f81554f6ae89d95b81d2aeb2ee5 /plugins/initflags.cpp | |
| parent | 0b5a470a3894b1cbaaf3970e4416bd35371493d0 (diff) | |
| download | dfhack-79ac2a781a3bfd3395a5785098a16403c1a9d3ce.tar.gz dfhack-79ac2a781a3bfd3395a5785098a16403c1a9d3ce.tar.bz2 dfhack-79ac2a781a3bfd3395a5785098a16403c1a9d3ce.tar.xz | |
Add infrastructure necessary to use the generated headers.
As a usage example, allow toggling water level display and idlers,
and implement a ui tweak for easily copying stockpiles.
Also disable df2mc by default - default options shouldn't
require anything not in the base package.
Diffstat (limited to 'plugins/initflags.cpp')
| -rw-r--r-- | plugins/initflags.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/plugins/initflags.cpp b/plugins/initflags.cpp new file mode 100644 index 00000000..f27a318a --- /dev/null +++ b/plugins/initflags.cpp @@ -0,0 +1,60 @@ +#include <dfhack/Core.h> +#include <dfhack/Console.h> +#include <dfhack/Export.h> +#include <dfhack/PluginManager.h> + +#include <dfhack/DataDefs.h> +#include <dfhack/df/d_init.h> + +using std::vector; +using std::string; +using std::endl; +using namespace DFHack; +using namespace df::enums; + +using df::global::d_init; + +DFhackCExport command_result twaterlvl(Core * c, vector <string> & parameters); +DFhackCExport command_result tidlers(Core * c, vector <string> & parameters); + +DFhackCExport const char * plugin_name ( void ) +{ + return "initflags"; +} + +DFhackCExport command_result plugin_init (Core *c, std::vector <PluginCommand> &commands) +{ + commands.clear(); + if (d_init) { + commands.push_back(PluginCommand("twaterlvl", "Toggle display of water/magma depth.", twaterlvl)); + commands.push_back(PluginCommand("tidlers", "Toggle display of idlers.", tidlers)); + } + std::cerr << "d_init: " << sizeof(df::d_init) << endl; + return CR_OK; +} + +DFhackCExport command_result plugin_shutdown ( Core * c ) +{ + return CR_OK; +} + +DFhackCExport command_result twaterlvl(Core * c, vector <string> & parameters) +{ + c->Suspend(); + df::global::d_init->flags1.toggle(d_init_flags1::SHOW_FLOW_AMOUNTS); + c->con << "Toggled the display of water/magma depth." << endl; + c->Resume(); + return CR_OK; +} + +DFhackCExport command_result tidlers(Core * c, vector <string> & parameters) +{ + c->Suspend(); + df::d_init_idlers iv = df::d_init_idlers(int(d_init->idlers) + 1); + if (!d_init_idlers::is_valid(iv)) + iv = ENUM_FIRST_ITEM(d_init_idlers); + d_init->idlers = iv; + c->con << "Toggled the display of idlers to " << ENUM_KEY_STR(d_init_idlers, iv) << endl; + c->Resume(); + return CR_OK; +} |
