MCPcopy Create free account
hub / github.com/DFHack/dfhack / enable_tweak

Function enable_tweak

plugins/tweak/tweak.cpp:124–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

122}
123
124static command_result enable_tweak(string tweak, color_ostream &out, vector<string> &parameters) {
125 bool recognized = false;
126 string cmd = parameters[0];
127 for (auto &entry : tweak_hooks) {
128 if (entry.first == cmd) {
129 recognized = true;
130 enable_hook(out, entry.second, parameters);
131 }
132 }
133 is_enabled = false;
134 for (auto & entry : tweak_onupdate_hooks) {
135 tweak_onupdate_hookst &hook = entry.second;
136 if (entry.first == cmd) {
137 bool state = (vector_get(parameters, 1) != "disable");
138 recognized = true;
139 hook.enabled = state;
140 out.print("{} tweak {} ({})\n", state ? "Enabled" : "Disabled", cmd, hook.name);
141 }
142 if (hook.enabled)
143 is_enabled = true;
144 }
145 if (!recognized) {
146 out.printerr("Unrecognized tweak: {}\n", cmd);
147 out.print("Run 'help tweak' to display a full list\n");
148 return CR_FAILURE; // Avoid dumping usage information
149 }
150 return CR_OK;
151}
152
153static std::map<string, bool> get_status() {
154 std::map<string, bool> list;

Callers 1

tweakFunction · 0.85

Calls 3

enable_hookFunction · 0.85
vector_getFunction · 0.85
printMethod · 0.45

Tested by

no test coverage detected