@@ -12,10 +12,6 @@ function isEnabled()
1212 return enabled
1313end
1414
15- local function is_fort_map_loaded ()
16- return df .global .gamemode == df .game_mode .DWARF and dfhack .isMapLoaded ()
17- end
18-
1915local help = df .global .game .main_interface .help
2016
2117local function close_help ()
@@ -43,15 +39,36 @@ function skip_tutorial_prompt()
4339 end
4440end
4541
42+ local function get_prefix ()
43+ if dfhack .world .isFortressMode () then
44+ return ' POPUP_'
45+ elseif dfhack .world .isAdventureMode () then
46+ return ' ADVENTURE_POPUP_'
47+ end
48+ end
49+
4650local function hide_all_popups ()
51+ local prefix = get_prefix ()
52+ if not prefix then return end
4753 for i ,name in ipairs (df .help_context_type ) do
48- if not name :startswith (' POPUP_ ' ) then goto continue end
54+ if not name :startswith (prefix ) then goto continue end
4955 utils .insert_sorted (df .global .plotinfo .tutorial_seen , i )
5056 utils .insert_sorted (df .global .plotinfo .tutorial_hide , i )
5157 :: continue::
5258 end
5359end
5460
61+ local function show_all_popups ()
62+ local prefix = get_prefix ()
63+ if not prefix then return end
64+ for i ,name in ipairs (df .help_context_type ) do
65+ if not name :startswith (prefix ) then goto continue end
66+ utils .erase_sorted (df .global .plotinfo .tutorial_seen , i )
67+ utils .erase_sorted (df .global .plotinfo .tutorial_hide , i )
68+ :: continue::
69+ end
70+ end
71+
5572dfhack .onStateChange [GLOBAL_KEY ] = function (sc )
5673 if not enabled then return end
5774
@@ -65,7 +82,7 @@ dfhack.onStateChange[GLOBAL_KEY] = function(sc)
6582 dfhack .timeout (100 , ' frames' , skip_tutorial_prompt )
6683 dfhack .timeout (1000 , ' frames' , skip_tutorial_prompt )
6784 end
68- elseif sc == SC_MAP_LOADED and df . global . gamemode == df . game_mode . DWARF then
85+ elseif sc == SC_MAP_LOADED then
6986 hide_all_popups ()
7087 end
7188end
8198
8299if args [1 ] == " enable" then
83100 enabled = true
84- if is_fort_map_loaded () then
101+ if dfhack . isMapLoaded () then
85102 hide_all_popups ()
86103 end
87104elseif args [1 ] == " disable" then
88105 enabled = false
89- elseif is_fort_map_loaded () then
106+ elseif args [1 ] == " reset" then
107+ show_all_popups ()
108+ elseif dfhack .isMapLoaded () then
90109 hide_all_popups ()
91110else
92- qerror (' hide-tutorials needs a loaded fortress map to work' )
111+ qerror (' hide-tutorials needs a loaded fortress or adventure map to work' )
93112end
0 commit comments