From 2b7b1b1a25d90a8a5256924c55792bd34fcbb067 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sat, 22 Feb 2025 02:37:29 -0800 Subject: [PATCH] get rid of auto-disengage option and make it always on otherwise the UI can fight with the player --- docs/plugins/spectate.rst | 10 ++-------- plugins/lua/spectate.lua | 13 ++++--------- plugins/spectate.cpp | 14 +++++--------- scripts | 2 +- 4 files changed, 12 insertions(+), 27 deletions(-) diff --git a/docs/plugins/spectate.rst b/docs/plugins/spectate.rst index a09d0170b9..89aef2b9f4 100644 --- a/docs/plugins/spectate.rst +++ b/docs/plugins/spectate.rst @@ -13,7 +13,7 @@ to following a different dwarf. It can also switch to following animals, hostiles, or visiting units. You can switch to the next target (or a previous target) immediately with the left/right arrow keys. -By default, `spectate` will disengage and turn itself off when you move the +`spectate` will automatically disengage and turn itself off when you move the map, just like the vanilla follow mechanic. It will also disengage immediately if you open the squads menu for military action. @@ -36,7 +36,7 @@ Usage enable spectate spectate [status] spectate toggle - spectate set + spectate set [] spectate overlay enable|disable Examples @@ -71,12 +71,6 @@ Examples Settings -------- -``auto-disengage`` (default: enabled) - Toggle automatically disabling the plugin when the player moves the map or - opens the squad panel. If this is disabled, you will need to manually - disable the plugin to turn off follow mode. You can still interact normally - with the DF UI. - ``auto-unpause`` (default: disabled) Toggle auto-dismissal of announcements that pause the game, like sieges, forgotten beasts, etc. diff --git a/plugins/lua/spectate.lua b/plugins/lua/spectate.lua index b50ab399dc..d9e5f5e566 100644 --- a/plugins/lua/spectate.lua +++ b/plugins/lua/spectate.lua @@ -16,7 +16,6 @@ local max_banner_y_offset = 4 local function get_default_state() return { - ['auto-disengage']=true, ['auto-unpause']=false, ['cinematic-action']=true, ['follow-seconds']=10, @@ -89,7 +88,7 @@ local config, save_state = load_state() -- called by gui/spectate function get_config_elem(name, key) local elem = config[name] - if not elem then return end + if elem == nil then return end if type(elem) == 'table' then return elem[key] end @@ -109,14 +108,10 @@ end function show_squads_warning() local message = { - 'Cannot start spectate mode while auto-disengage is enabled and', - 'the squads panel is open. The auto-disengage feature automatically', - 'stops spectate mode when you open the squads panel.', + 'Cannot start spectate mode while the squads panel is open. Spectate', + 'automatically disengages when you open the squads panel.', '', - 'Please either close the squads panel or disable auto-disengage by', - 'running the following command:', - '', - 'spectate set auto-disengage false', + 'Please close the squads panel before enabling spectate mode.', } dlg.showMessage("Spectate", table.concat(message, '\n')) end diff --git a/plugins/spectate.cpp b/plugins/spectate.cpp index 45512a2042..517d8a29db 100644 --- a/plugins/spectate.cpp +++ b/plugins/spectate.cpp @@ -63,7 +63,6 @@ static const std::unordered_set boring_jobs = { // Configuration static struct Configuration { - bool auto_disengage; bool auto_unpause; bool cinematic_action; bool include_animals; @@ -75,7 +74,6 @@ static struct Configuration { int32_t follow_ms; void reset() { - auto_disengage = true; auto_unpause = false; cinematic_action = true; include_animals = false; @@ -338,8 +336,8 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) { if (!Lua::CallLuaModuleFunction(out, "plugins.spectate", "refresh_cpp_config")) { WARN(control,out).print("Failed to refresh config\n"); } - if (config.auto_disengage && is_squads_open()) { - out.printerr("Cannot enable %s while auto-disengage is enabled and the squads screen is open.\n", plugin_name); + if (is_squads_open()) { + out.printerr("Cannot enable %s while the squads screen is open.\n", plugin_name); Lua::CallLuaModuleFunction(out, "plugins.spectate", "show_squads_warning"); is_enabled = false; return CR_FAILURE; @@ -394,7 +392,7 @@ DFhackCExport command_result plugin_onstatechange(color_ostream &out, state_chan DFhackCExport command_result plugin_onupdate(color_ostream &out) { announcement_settings.on_update(out); - if (config.auto_disengage && (plotinfo->follow_unit < 0 || plotinfo->follow_item > -1 || is_squads_open())) { + if (plotinfo->follow_unit < 0 || plotinfo->follow_item > -1 || is_squads_open()) { DEBUG(cycle,out).print("auto-disengage triggered\n"); is_enabled = false; plotinfo->follow_unit = -1; @@ -402,7 +400,7 @@ DFhackCExport command_result plugin_onupdate(color_ostream &out) { return CR_OK; } - if ((!config.auto_disengage && plotinfo->follow_unit < 0) || Core::getInstance().getUnpausedMs() >= next_cycle_unpaused_ms) { + if (Core::getInstance().getUnpausedMs() >= next_cycle_unpaused_ms) { recent_units.trim(); follow_a_dwarf(out); } @@ -556,9 +554,7 @@ static void follow_a_dwarf(color_ostream &out) { static void spectate_setSetting(color_ostream &out, string name, int val) { DEBUG(control,out).print("entering spectate_setSetting %s = %d\n", name.c_str(), val); - if (name == "auto-disengage") { - config.auto_disengage = val; - } else if (name == "auto-unpause") { + if (name == "auto-unpause") { if (val && !config.auto_unpause) { announcement_settings.save_and_scrub_settings(out); } else if (!val && config.auto_unpause) { diff --git a/scripts b/scripts index cc421f03ee..637eb47ca9 160000 --- a/scripts +++ b/scripts @@ -1 +1 @@ -Subproject commit cc421f03eebed861cdf3a5cd925dd01887373020 +Subproject commit 637eb47ca98e9188fe7cdd73c73b0d994c4bada8