Skip to content

Commit 880688f

Browse files
committed
initial version of tutorials-be-gone
1 parent 734ed2c commit 880688f

File tree

4 files changed

+111
-0
lines changed

4 files changed

+111
-0
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Template for new versions:
2929
## New Tools
3030
- `devel/scan-vtables`: Scan and dump likely vtable addresses (for memory research)
3131
- `hide-interface`: hide the vanilla UI elements for clean screenshots or laid-back fortress observing
32+
- `tutorials-be-gone`: hide the DF tutorial popups; enable in the System tab of `gui/control-panel`
3233

3334
## New Features
3435
- `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!

docs/tutorials-be-gone.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
tutorials-be-gone
2+
=================
3+
4+
.. dfhack-tool::
5+
:summary: Hide new fort tutorial popups.
6+
:tags: fort interface
7+
8+
If you've played the game before and don't need to see the tutorial popups that
9+
show up on every new fort, ``tutorials-be-gone`` can hide them for you. You can
10+
enable this tool as a system service in the "Services" tab of
11+
`gui/control-panel` so it takes effect for all new or loaded forts.
12+
13+
Specifically, this tool hides:
14+
15+
- The popup displayed when creating a new world
16+
- The "Do you want to start a tutorial embark" popup
17+
- Popups displayed the first time you open the labor, burrows, justice, and
18+
other similar screens in a new fort
19+
20+
Usage
21+
-----
22+
23+
::
24+
25+
enable tutorials-be-gone
26+
tutorials-be-gone
27+
28+
If you haven't enabled the tool, but you run the command while a fort is
29+
loaded, all future popups for the loaded fort will be hidden.

gui/control-panel.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ local SYSTEM_SERVICES = {
6262
-- these are fully controlled by the user
6363
local SYSTEM_USER_SERVICES = {
6464
'faststart',
65+
'tutorials-be-gone',
6566
'work-now',
6667
}
6768
for _,v in ipairs(SYSTEM_USER_SERVICES) do

tutorials-be-gone.lua

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
--@module = true
2+
--@enable = true
3+
4+
local gui = require('gui')
5+
local utils = require('utils')
6+
7+
local GLOBAL_KEY = 'tutorials-be-gone'
8+
9+
enabled = enabled or false
10+
11+
function isEnabled()
12+
return enabled
13+
end
14+
15+
local function is_fort_map_loaded()
16+
return df.global.gamemode == df.game_mode.DWARF and dfhack.isMapLoaded()
17+
end
18+
19+
local help = df.global.game.main_interface.help
20+
21+
local function close_help()
22+
help.open = false
23+
end
24+
25+
function skip_tutorial_prompt(scr)
26+
if help.open and help.context == df.help_context_type.EMBARK_TUTORIAL_CHOICE then
27+
help.context = df.help_context_type.EMBARK_MESSAGE
28+
df.global.gps.mouse_x = df.global.gps.dimx // 2
29+
df.global.gps.mouse_y = 18
30+
df.global.enabler.mouse_lbut = 1
31+
df.global.enabler.mouse_lbut_down = 1
32+
gui.simulateInput(scr, '_MOUSE_L_DOWN')
33+
end
34+
end
35+
36+
local function hide_all_popups()
37+
for i,name in ipairs(df.help_context_type) do
38+
if not name:startswith('POPUP_') then goto continue end
39+
utils.insert_sorted(df.global.plotinfo.tutorial_seen, i)
40+
utils.insert_sorted(df.global.plotinfo.tutorial_hide, i)
41+
::continue::
42+
end
43+
end
44+
45+
dfhack.onStateChange[GLOBAL_KEY] = function(sc)
46+
if not enabled then return end
47+
48+
if sc == SC_VIEWSCREEN_CHANGED then
49+
local scr = dfhack.gui.getDFViewscreen(true)
50+
if df.viewscreen_new_regionst:is_instance(scr) then
51+
close_help()
52+
elseif df.viewscreen_choose_start_sitest:is_instance(scr) then
53+
skip_tutorial_prompt(scr)
54+
end
55+
elseif sc == SC_MAP_LOADED and df.global.gamemode == df.game_mode.DWARF then
56+
hide_all_popups()
57+
end
58+
end
59+
60+
if dfhack_flags.module then
61+
return
62+
end
63+
64+
local args = {...}
65+
if dfhack_flags and dfhack_flags.enable then
66+
args = {dfhack_flags.enable_state and 'enable' or 'disable'}
67+
end
68+
69+
if args[1] == "enable" then
70+
enabled = true
71+
if is_fort_map_loaded() then
72+
hide_all_popups()
73+
end
74+
elseif args[1] == "disable" then
75+
enabled = false
76+
elseif is_fort_map_loaded() then
77+
hide_all_popups()
78+
else
79+
qerror('tutorials-be-gone needs a loaded fortress map to work')
80+
end

0 commit comments

Comments
 (0)