diff --git a/changelog.txt b/changelog.txt index 1ed30ae50..c9e3ffae3 100644 --- a/changelog.txt +++ b/changelog.txt @@ -33,6 +33,7 @@ Template for new versions: ## New Features ## Fixes +- `hide-tutorials`: also suppress the adventure mode start tutorial (defaults its checkbox to off and dismisses the popups) - `bodyswap`: fix "invalid argument count" when the target unit has no nemesis record - `fix/loyaltycascade`: guard against citizens that are not historical figures and emit a warning. - `gui/siegemanager`: fix nil index if there are no siege engines on the map diff --git a/docs/hide-tutorials.rst b/docs/hide-tutorials.rst index 94b2a27a2..b36707460 100644 --- a/docs/hide-tutorials.rst +++ b/docs/hide-tutorials.rst @@ -18,6 +18,9 @@ Specifically, this tool hides: other similar screens in a new fort - Popups displayed when you perform certain actions for the first time in an adventure +- The tutorial checkbox when creating an adventurer (it will default to + unchecked, but you can still enable it if you want the tutorial) and the + tutorial popups it would otherwise show at the start of the game Note that only unsolicited tutorial popups are hidden. If you directly request a tutorial page from the help, then it will still function normally. diff --git a/hide-tutorials.lua b/hide-tutorials.lua index e6124de0d..44d9ad6b6 100644 --- a/hide-tutorials.lua +++ b/hide-tutorials.lua @@ -39,6 +39,22 @@ function skip_tutorial_prompt() end end +local ADVENTURE_TUTORIAL_CONTEXTS = utils.invert{ + 'ADVENTURE_START_MESSAGE', + 'ADVENTURE_START_TUTORIAL_CAMERA_CONTROLS', + 'ADVENTURE_START_TUTORIAL_MOVEMENT', + 'ADVENTURE_START_TUTORIAL_MENU_OVERVIEW', + 'ADVENTURE_DONE_WITH_FIRST_STEPS_MESSAGE', +} + +function skip_adventure_tutorial() + if not dfhack.world.isAdventureMode() then return end + df.global.plotinfo.flags.need_to_do_tutorial = false + if help.open and ADVENTURE_TUTORIAL_CONTEXTS[df.help_context_type[help.context]] then + close_help() + end +end + local function get_prefix() if dfhack.world.isFortressMode() then return 'POPUP_' @@ -81,9 +97,19 @@ dfhack.onStateChange[GLOBAL_KEY] = function(sc) dfhack.timeout(10, 'frames', skip_tutorial_prompt) dfhack.timeout(100, 'frames', skip_tutorial_prompt) dfhack.timeout(1000, 'frames', skip_tutorial_prompt) + elseif df.viewscreen_setupadventurest:is_instance(scr) then + -- default the "tutorial" checkbox to off; the player can still + -- check it if they want the tutorial + scr.want_tutorial = false + elseif df.viewscreen_dungeonmodest:is_instance(scr) then + -- the start tutorial can pop up shortly after the screen appears + skip_adventure_tutorial() + dfhack.timeout(10, 'frames', skip_adventure_tutorial) + dfhack.timeout(100, 'frames', skip_adventure_tutorial) end elseif sc == SC_MAP_LOADED then hide_all_popups() + skip_adventure_tutorial() end end @@ -100,6 +126,7 @@ if args[1] == "enable" then enabled = true if dfhack.isMapLoaded() then hide_all_popups() + skip_adventure_tutorial() end elseif args[1] == "disable" then enabled = false @@ -107,6 +134,7 @@ elseif args[1] == "reset" then show_all_popups() elseif dfhack.isMapLoaded() then hide_all_popups() + skip_adventure_tutorial() else qerror('hide-tutorials needs a loaded fortress or adventure map to work') end