aboutsummaryrefslogtreecommitdiff
path: root/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut
diff options
context:
space:
mode:
authorBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-08-31 23:14:58 +0100
committerBobTheBob <32057864+BobTheBob9@users.noreply.github.com>2021-08-31 23:14:58 +0100
commit9a96d0bff56f1969c68bb52a2f33296095bdc67d (patch)
tree4175928e488632705692e3cccafa1a38dd854615 /Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut
parent27bd240871b7c0f2f49fef137718b2e3c208e3b4 (diff)
downloadNorthstarMods-9a96d0bff56f1969c68bb52a2f33296095bdc67d.tar.gz
NorthstarMods-9a96d0bff56f1969c68bb52a2f33296095bdc67d.zip
move to new mod format
Diffstat (limited to 'Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut')
-rw-r--r--Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut108
1 files changed, 108 insertions, 0 deletions
diff --git a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut
new file mode 100644
index 000000000..4a56891e3
--- /dev/null
+++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut
@@ -0,0 +1,108 @@
+global function AddNorthstarModMenu
+global function AddNorthstarModMenu_MainMenuFooter
+
+void function AddNorthstarModMenu()
+{
+ AddMenu( "ModListMenu", $"resource/ui/menus/modlist.menu", InitModMenu )
+}
+
+void function AddNorthstarModMenu_MainMenuFooter()
+{
+ AddMenuFooterOption( GetMenu( "MainMenu" ), BUTTON_Y, "#Y_MENU_TITLE_MODS", "#MENU_TITLE_MODS", AdvanceToModListMenu )
+}
+
+void function AdvanceToModListMenu( var button )
+{
+ AdvanceMenu( GetMenu( "ModListMenu" ) )
+}
+
+void function InitModMenu()
+{
+ var menu = GetMenu( "ModListMenu" )
+
+ AddMenuEventHandler( menu, eUIEvent.MENU_OPEN, OnModMenuOpened )
+ AddMenuFooterOption( menu, BUTTON_B, "#B_BUTTON_BACK", "#BACK" )
+ AddMenuFooterOption( menu, BUTTON_Y, "#Y_RELOAD_MODS", "#RELOAD_MODS", ReloadMods )
+
+ foreach ( var button in GetElementsByClassname( GetMenu( "ModListMenu" ), "ModButton" ) )
+ AddButtonEventHandler( button, UIE_GET_FOCUS, OnModMenuButtonFocused )
+}
+
+void function OnModMenuOpened()
+{
+ Hud_SetText( Hud_GetChild( GetMenu( "ModListMenu" ), "Title" ), "#MENU_TITLE_MODS" )
+
+ array<var> buttons = GetElementsByClassname( GetMenu( "ModListMenu" ), "ModButton" )
+
+ // disable all buttons, we'll enable the ones we need later
+ foreach ( var button in buttons )
+ {
+ Hud_SetEnabled( button, false )
+ Hud_SetVisible( button, false )
+ }
+
+ array<string> modNames = NSGetModNames()
+ for ( int i = 0; i < modNames.len() && i < buttons.len(); i++ )
+ {
+ Hud_SetEnabled( buttons[ i ], true )
+ Hud_SetVisible( buttons[ i ], true )
+
+ SetButtonRuiText( buttons[ i ], modNames[ i ] + " v" + NSGetModVersionByModName( modNames[ i ] ) )
+ }
+}
+
+void function OnModMenuButtonFocused( var button )
+{
+ string modName = NSGetModNames()[ int ( Hud_GetScriptID( button ) ) ]
+
+ var rui = Hud_GetRui( Hud_GetChild( GetMenu( "ModListMenu" ), "LabelDetails" ) )
+
+ RuiSetGameTime( rui, "startTime", -99999.99 ) // make sure it skips the whole animation for showing this
+ RuiSetString( rui, "headerText", modName )
+ RuiSetString( rui, "messageText", FormatModDescription( modName ) )
+}
+
+string function FormatModDescription( string modName )
+{
+ string ret
+ // version
+ ret += format( "Version %s\n", NSGetModVersionByModName( modName ) )
+
+ // download link
+ string modLink = NSGetModDownloadLinkByModName( modName )
+ if ( modLink.len() != 0 )
+ ret += format( "Download link: \"%s\"\n", modLink )
+
+ // load priority
+ ret += format( "Load Priority: %i\n", NSGetModLoadPriority( modName ) )
+
+ // todo: add ClientRequired here
+
+ // convars
+ array<string> modCvars = NSGetModConvarsByModName( modName )
+ if ( modCvars.len() != 0 )
+ {
+ ret += "ConVars: "
+
+ for ( int i = 0; i < modCvars.len(); i++ )
+ {
+ if ( i != modCvars.len() - 1 )
+ ret += format( "\"%s\", ", modCvars[ i ] )
+ else
+ ret += format( "\"%s\"", modCvars[ i ] )
+ }
+
+ ret += "\n"
+ }
+
+ // description
+ ret += format( "\n%s\n", NSGetModDescriptionByModName( modName ) )
+
+ return ret
+}
+
+void function ReloadMods( var button )
+{
+ NSReloadMods()
+ OnModMenuOpened() // temp, until we start doing uiscript_reset here
+} \ No newline at end of file