| 122 | } |
| 123 | |
| 124 | DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) { |
| 125 | if (!Core::getInstance().isMapLoaded() || !World::isFortressMode()) { |
| 126 | out.printerr("Cannot enable {} without a loaded fort.\n", plugin_name); |
| 127 | return CR_FAILURE; |
| 128 | } |
| 129 | |
| 130 | if (enable != is_enabled) { |
| 131 | is_enabled = enable; |
| 132 | DEBUG(control,out).print("{} from the API; persisting\n", |
| 133 | is_enabled ? "enabled" : "disabled"); |
| 134 | config.set_bool(CONFIG_IS_ENABLED, is_enabled); |
| 135 | if (enable) |
| 136 | do_cycle(out, true); |
| 137 | } else { |
| 138 | DEBUG(control,out).print("{} from the API, but already {}; no action\n", |
| 139 | is_enabled ? "enabled" : "disabled", |
| 140 | is_enabled ? "enabled" : "disabled"); |
| 141 | } |
| 142 | return CR_OK; |
| 143 | } |
| 144 | |
| 145 | DFhackCExport command_result plugin_shutdown (color_ostream &out) { |
| 146 | DEBUG(control,out).print("shutting down {}\n", plugin_name); |