Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Template for new versions:
## Misc Improvements
- `assign-preferences`: new ``--show`` option to display the preferences of the selected unit
- `pref-adjust`: new ``show`` command to display the preferences of the selected unit
- `hide-tutorials`: if enabled, also hide tutorial popups for adventure mode
- `hide-tutorials`: new ``reset`` command that will re-enable popups in the current game

## Removed

Expand Down
14 changes: 10 additions & 4 deletions docs/hide-tutorials.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ hide-tutorials

.. dfhack-tool::
:summary: Hide new fort tutorial popups.
:tags: fort interface
:tags: adventure 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, ``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.
`gui/control-panel` so it takes effect for all forts and adventures.

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
- Popups displayed when you perform certain actions for the first time in an
adventure

Note that only unsolicited tutorial popups are hidden. If you directly request
a tutorial page from the help, then it will still function normally.
Expand All @@ -27,6 +29,10 @@ Usage

enable hide-tutorials
hide-tutorials
hide-tutorials reset

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.
If you haven't enabled the tool, but you run the command while a fort or
adventure is loaded, all future popups for the loaded game will be hidden.

If you run the command with the ``reset`` option, all popups will be re-enabled
as if they had never been seen or dismissed.
37 changes: 28 additions & 9 deletions hide-tutorials.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ 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()
Expand Down Expand Up @@ -43,15 +39,36 @@ function skip_tutorial_prompt()
end
end

local function get_prefix()
if dfhack.world.isFortressMode() then
return 'POPUP_'
elseif dfhack.world.isAdventureMode() then
return 'ADVENTURE_POPUP_'
end
end

local function hide_all_popups()
local prefix = get_prefix()
if not prefix then return end
for i,name in ipairs(df.help_context_type) do
if not name:startswith('POPUP_') then goto continue end
if not name:startswith(prefix) 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

local function show_all_popups()
local prefix = get_prefix()
if not prefix then return end
for i,name in ipairs(df.help_context_type) do
if not name:startswith(prefix) then goto continue end
utils.erase_sorted(df.global.plotinfo.tutorial_seen, i)
utils.erase_sorted(df.global.plotinfo.tutorial_hide, i)
::continue::
end
end

dfhack.onStateChange[GLOBAL_KEY] = function(sc)
if not enabled then return end

Expand All @@ -65,7 +82,7 @@ dfhack.onStateChange[GLOBAL_KEY] = function(sc)
dfhack.timeout(100, 'frames', skip_tutorial_prompt)
dfhack.timeout(1000, 'frames', skip_tutorial_prompt)
end
elseif sc == SC_MAP_LOADED and df.global.gamemode == df.game_mode.DWARF then
elseif sc == SC_MAP_LOADED then
hide_all_popups()
end
end
Expand All @@ -81,13 +98,15 @@ end

if args[1] == "enable" then
enabled = true
if is_fort_map_loaded() then
if dfhack.isMapLoaded() then
hide_all_popups()
end
elseif args[1] == "disable" then
enabled = false
elseif is_fort_map_loaded() then
elseif args[1] == "reset" then
show_all_popups()
elseif dfhack.isMapLoaded() then
hide_all_popups()
else
qerror('hide-tutorials needs a loaded fortress map to work')
qerror('hide-tutorials needs a loaded fortress or adventure map to work')
end
Loading