From b2c443cbe04361933bd4531ab8e747a8ffa368cd Mon Sep 17 00:00:00 2001 From: F1F7Y <64418963+F1F7Y@users.noreply.github.com> Date: Mon, 10 Jan 2022 21:59:56 +0100 Subject: Add a warning when disabling core mods (#98) --- .../mod/scripts/vscripts/ui/menu_ns_modmenu.nut | 43 ++++++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) (limited to 'Northstar.Client/mod/scripts') diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut index cb1535d3..cc681e95 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut @@ -4,6 +4,8 @@ global function ReloadMods struct { bool shouldReloadModsOnEnd + string currentMod + var currentButton } file void function AddNorthstarModMenu() @@ -83,9 +85,44 @@ void function SetModMenuNameText( var button ) void function OnModMenuButtonPressed( var button ) { string modName = NSGetModNames()[ int ( Hud_GetScriptID( button ) ) ] - NSSetModEnabled( modName, !NSIsModEnabled( modName ) ) - SetModMenuNameText( button ) - + if ( ( modName == "Northstar.Client" || modName == "Northstar.Coop" || modName == "Northstar.CustomServers") && NSIsModEnabled( modName ) ) + { + file.currentMod = modName + file.currentButton = button + CoreModToggleDialog( modName ) + } + else + { + NSSetModEnabled( modName, !NSIsModEnabled( modName ) ) + + SetModMenuNameText( button ) + + file.shouldReloadModsOnEnd = true + } +} + +void function CoreModToggleDialog( string mod ) +{ + DialogData dialogData + dialogData.header = "#WARNING" + dialogData.message = "#CORE_MOD_DISABLE_WARNING" + + AddDialogButton( dialogData, "#CANCEL" ) + // This can't have any arguments so we use the file struct + AddDialogButton( dialogData, "#DISABLE", DisableMod ) + + AddDialogFooter( dialogData, "#A_BUTTON_SELECT" ) + AddDialogFooter( dialogData, "#B_BUTTON_CANCEL" ) + + OpenDialog( dialogData ) +} + +void function DisableMod() +{ + NSSetModEnabled( file.currentMod, false ) + + SetModMenuNameText( file.currentButton ) + file.shouldReloadModsOnEnd = true } -- cgit v1.2.3