diff --git a/changelog.txt b/changelog.txt index 9f09192b1e..d268bf768e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -29,6 +29,7 @@ Template for new versions: ## New Tools - `devel/scan-vtables`: Scan and dump likely vtable addresses (for memory research) - `hide-interface`: hide the vanilla UI elements for clean screenshots or laid-back fortress observing +- `tutorials-be-gone`: hide the DF tutorial popups; enable in the System tab of `gui/control-panel` ## New Features - `exportlegends`: new overlay that integrates with the vanilla "Export XML" button. Now you can generate both the vanilla export and the extended data export with a single click! diff --git a/docs/tutorials-be-gone.rst b/docs/tutorials-be-gone.rst new file mode 100644 index 0000000000..4e38d859e1 --- /dev/null +++ b/docs/tutorials-be-gone.rst @@ -0,0 +1,29 @@ +tutorials-be-gone +================= + +.. dfhack-tool:: + :summary: Hide new fort tutorial popups. + :tags: fort interface + +If you've played the game before and don't need to see the tutorial popups that +show up on every new fort, ``tutorials-be-gone`` can hide them for you. You can +enable this tool as a system service in the "Services" tab of +`gui/control-panel` so it takes effect for all new or loaded forts. + +Specifically, this tool hides: + +- The popup displayed when creating a new world +- The "Do you want to start a tutorial embark" popup +- Popups displayed the first time you open the labor, burrows, justice, and + other similar screens in a new fort + +Usage +----- + +:: + + enable tutorials-be-gone + tutorials-be-gone + +If you haven't enabled the tool, but you run the command while a fort is +loaded, all future popups for the loaded fort will be hidden. diff --git a/gui/control-panel.lua b/gui/control-panel.lua index 4ee57ea6e5..58e2fc5e2c 100644 --- a/gui/control-panel.lua +++ b/gui/control-panel.lua @@ -62,6 +62,7 @@ local SYSTEM_SERVICES = { -- these are fully controlled by the user local SYSTEM_USER_SERVICES = { 'faststart', + 'tutorials-be-gone', 'work-now', } for _,v in ipairs(SYSTEM_USER_SERVICES) do diff --git a/tutorials-be-gone.lua b/tutorials-be-gone.lua new file mode 100644 index 0000000000..63b4a0d5b2 --- /dev/null +++ b/tutorials-be-gone.lua @@ -0,0 +1,80 @@ +--@module = true +--@enable = true + +local gui = require('gui') +local utils = require('utils') + +local GLOBAL_KEY = 'tutorials-be-gone' + +enabled = enabled or false + +function isEnabled() + return enabled +end + +local function is_fort_map_loaded() + return df.global.gamemode == df.game_mode.DWARF and dfhack.isMapLoaded() +end + +local help = df.global.game.main_interface.help + +local function close_help() + help.open = false +end + +function skip_tutorial_prompt(scr) + if help.open and help.context == df.help_context_type.EMBARK_TUTORIAL_CHOICE then + help.context = df.help_context_type.EMBARK_MESSAGE + df.global.gps.mouse_x = df.global.gps.dimx // 2 + df.global.gps.mouse_y = 18 + df.global.enabler.mouse_lbut = 1 + df.global.enabler.mouse_lbut_down = 1 + gui.simulateInput(scr, '_MOUSE_L_DOWN') + end +end + +local function hide_all_popups() + for i,name in ipairs(df.help_context_type) do + if not name:startswith('POPUP_') then goto continue end + utils.insert_sorted(df.global.plotinfo.tutorial_seen, i) + utils.insert_sorted(df.global.plotinfo.tutorial_hide, i) + ::continue:: + end +end + +dfhack.onStateChange[GLOBAL_KEY] = function(sc) + if not enabled then return end + + if sc == SC_VIEWSCREEN_CHANGED then + local scr = dfhack.gui.getDFViewscreen(true) + if df.viewscreen_new_regionst:is_instance(scr) then + close_help() + elseif df.viewscreen_choose_start_sitest:is_instance(scr) then + skip_tutorial_prompt(scr) + end + elseif sc == SC_MAP_LOADED and df.global.gamemode == df.game_mode.DWARF then + hide_all_popups() + end +end + +if dfhack_flags.module then + return +end + +local args = {...} +if dfhack_flags and dfhack_flags.enable then + args = {dfhack_flags.enable_state and 'enable' or 'disable'} +end + +if args[1] == "enable" then + enabled = true + if is_fort_map_loaded() then + hide_all_popups() + end +elseif args[1] == "disable" then + enabled = false +elseif is_fort_map_loaded() then + hide_all_popups() +else + qerror('tutorials-be-gone needs a loaded fortress map to work') +end