From 880688f626e6a7528fefa9e973b5d4c3afff6b03 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 27 Aug 2023 13:45:48 -0700 Subject: [PATCH 1/3] initial version of tutorials-be-gone --- changelog.txt | 1 + docs/tutorials-be-gone.rst | 29 ++++++++++++++ gui/control-panel.lua | 1 + tutorials-be-gone.lua | 80 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 docs/tutorials-be-gone.rst create mode 100644 tutorials-be-gone.lua 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 From e8bdb953403e228ee4d0d8f397df44f7f27318f1 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 27 Aug 2023 16:40:32 -0700 Subject: [PATCH 2/3] change name to hide-tutorials --- changelog.txt | 2 +- docs/{tutorials-be-gone.rst => hide-tutorials.rst} | 10 +++++----- gui/control-panel.lua | 2 +- tutorials-be-gone.lua => hide-tutorials.lua | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) rename docs/{tutorials-be-gone.rst => hide-tutorials.rst} (80%) rename tutorials-be-gone.lua => hide-tutorials.lua (94%) diff --git a/changelog.txt b/changelog.txt index d268bf768e..e2217bc85f 100644 --- a/changelog.txt +++ b/changelog.txt @@ -29,7 +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` +- `hide-tutorials`: 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/hide-tutorials.rst similarity index 80% rename from docs/tutorials-be-gone.rst rename to docs/hide-tutorials.rst index 4e38d859e1..a1cc934b7b 100644 --- a/docs/tutorials-be-gone.rst +++ b/docs/hide-tutorials.rst @@ -1,12 +1,12 @@ -tutorials-be-gone -================= +hide-tutorials +============== .. 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 +show up on every new fort, ``hide-tutorials`` 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. @@ -22,8 +22,8 @@ Usage :: - enable tutorials-be-gone - tutorials-be-gone + enable hide-tutorials + hide-tutorials 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 58e2fc5e2c..fba07bd633 100644 --- a/gui/control-panel.lua +++ b/gui/control-panel.lua @@ -62,7 +62,7 @@ local SYSTEM_SERVICES = { -- these are fully controlled by the user local SYSTEM_USER_SERVICES = { 'faststart', - 'tutorials-be-gone', + 'hide-tutorials', 'work-now', } for _,v in ipairs(SYSTEM_USER_SERVICES) do diff --git a/tutorials-be-gone.lua b/hide-tutorials.lua similarity index 94% rename from tutorials-be-gone.lua rename to hide-tutorials.lua index 63b4a0d5b2..6887a77df4 100644 --- a/tutorials-be-gone.lua +++ b/hide-tutorials.lua @@ -4,7 +4,7 @@ local gui = require('gui') local utils = require('utils') -local GLOBAL_KEY = 'tutorials-be-gone' +local GLOBAL_KEY = 'hide-tutorials' enabled = enabled or false @@ -76,5 +76,5 @@ elseif args[1] == "disable" then elseif is_fort_map_loaded() then hide_all_popups() else - qerror('tutorials-be-gone needs a loaded fortress map to work') + qerror('hide-tutorials needs a loaded fortress map to work') end From c3715aa1a5264565135907a03973c5e58b426fbb Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 27 Aug 2023 17:47:12 -0700 Subject: [PATCH 3/3] clarify that solicited tutorials still work --- docs/hide-tutorials.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/hide-tutorials.rst b/docs/hide-tutorials.rst index a1cc934b7b..417d5e278c 100644 --- a/docs/hide-tutorials.rst +++ b/docs/hide-tutorials.rst @@ -17,6 +17,9 @@ Specifically, this tool hides: - Popups displayed the first time you open the labor, burrows, justice, and other similar screens in a new fort +Note that only unsolicited tutorial popups are hidden. If you directly request +a tutorial page from the help, then it will still function normally. + Usage -----