@@ -12,6 +12,10 @@ 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+
1519local help = df .global .game .main_interface .help
1620
1721local function close_help ()
@@ -39,36 +43,15 @@ function skip_tutorial_prompt()
3943 end
4044end
4145
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-
5046local function hide_all_popups ()
51- local prefix = get_prefix ()
52- if not prefix then return end
5347 for i ,name in ipairs (df .help_context_type ) do
54- if not name :startswith (prefix ) then goto continue end
48+ if not name :startswith (' POPUP_ ' ) then goto continue end
5549 utils .insert_sorted (df .global .plotinfo .tutorial_seen , i )
5650 utils .insert_sorted (df .global .plotinfo .tutorial_hide , i )
5751 :: continue::
5852 end
5953end
6054
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-
7255dfhack .onStateChange [GLOBAL_KEY ] = function (sc )
7356 if not enabled then return end
7457
@@ -82,7 +65,7 @@ dfhack.onStateChange[GLOBAL_KEY] = function(sc)
8265 dfhack .timeout (100 , ' frames' , skip_tutorial_prompt )
8366 dfhack .timeout (1000 , ' frames' , skip_tutorial_prompt )
8467 end
85- elseif sc == SC_MAP_LOADED then
68+ elseif sc == SC_MAP_LOADED and df . global . gamemode == df . game_mode . DWARF then
8669 hide_all_popups ()
8770 end
8871end
9881
9982if args [1 ] == " enable" then
10083 enabled = true
101- if dfhack . isMapLoaded () then
84+ if is_fort_map_loaded () then
10285 hide_all_popups ()
10386 end
10487elseif args [1 ] == " disable" then
10588 enabled = false
106- elseif args [1 ] == " reset" then
107- show_all_popups ()
108- elseif dfhack .isMapLoaded () then
89+ elseif is_fort_map_loaded () then
10990 hide_all_popups ()
11091else
111- qerror (' hide-tutorials needs a loaded fortress or adventure map to work' )
92+ qerror (' hide-tutorials needs a loaded fortress map to work' )
11293end
0 commit comments