Skip to content

Commit b345b10

Browse files
authored
This is definitely me when the mods are refactored fr fr (#20)
Fixed V+ on recent Northstar update
1 parent 0893338 commit b345b10

File tree

5 files changed

+120
-90
lines changed

5 files changed

+120
-90
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "VanillaPlus",
3-
"version_number": "2.4.1",
3+
"version_number": "2.4.2",
44
"website_url": "https://github.com/Zayveeo5e/NP.VanillaPlus",
55
"description": "THIS MOD HAS SPECIAL INSTALL INSTRUCTIONS IN THE DESCRIPTION, PLEASE READ THEM. Modified Northstar.Client to load Client-Side mods on Vanilla servers",
66
"dependencies": []

mods/NP.VanillaPlus/mod.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"Name" : "VanillaPlus",
33
"Description": "A stripped down and modified Northstar.Client mod that allows for client-side mod loading on official Respawn servers\n\nMade by Nanohm, remastered by Cyn",
44
"LoadPriority": -1,
5-
"Version": "2.4.1",
6-
5+
"Version": "2.4.2",
6+
"InitScript": "vanillaplus_client_init.nut",
77
"Dependencies": {
88
"HAS_CLIENT": "Northstar.Client",
99
"HAS_MORESKINS": "MoreSkins-",

mods/NP.VanillaPlus/mod/scripts/vscripts/ui/menu_set_vanillaplus_version.nut

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ void function VP_SetVersionLabel()
99
{
1010
var mainMenu = GetMenu( "MainMenu" ) //Gets main menu element
1111
var versionLabel = GetElementsByClassname( mainMenu, "nsVersionClass" )[0] //Gets the label from the mainMenu element.
12-
Hud_SetText( versionLabel, NSGetModVersionByModName("VanillaPlus")) //Sets the label text (Getting version from VanillaPlus)
12+
array<ModInfo> infos = NSGetModInformation( "VanillaPlus" )
13+
foreach ( ModInfo modInfo in infos )
14+
{
15+
//Todo: handle multiple copies of v+
16+
Hud_SetText( versionLabel, modInfo.version) //Sets the label text (Getting version from VanillaPlus)
17+
break
18+
}
1319
}
1420
#endif

mods/NP.VanillaPlus/mod/scripts/vscripts/ui/ns_menu_modmenu.nut

Lines changed: 98 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,8 @@ global function AddNorthstarModMenu_MainMenuFooter
1010
global function ReloadMods
1111

1212

13-
struct modData {
14-
string name = ""
15-
string version = ""
16-
string link = ""
17-
int loadPriority = 0
18-
bool enabled = false
19-
array<string> conVars = []
20-
}
21-
2213
struct panelContent {
23-
modData& mod
14+
ModInfo& mod
2415
bool isHeader = false
2516
}
2617

@@ -42,10 +33,10 @@ struct {
4233
var menu
4334
array<var> panels
4435
int scrollOffset = 0
45-
array<string> enabledMods
36+
array<ModInfo> enabledMods
4637
var currentButton
4738
string searchTerm
48-
modData& lastMod
39+
ModInfo& lastMod
4940
} file
5041

5142
const int PANELS_LEN = 15
@@ -155,11 +146,20 @@ void function OnModMenuClosed()
155146
}
156147
catch ( ex ) {}
157148

158-
array<string> current = GetEnabledModsArray()
149+
array<ModInfo> current = GetEnabledModsArray()
159150
bool reload
160-
foreach ( string mod in current )
151+
foreach ( ModInfo mod in current )
161152
{
162-
if ( file.enabledMods.find(mod) == -1 )
153+
bool notFound = true
154+
foreach ( ModInfo enMod in file.enabledMods )
155+
{
156+
if ( mod.name == enMod.name )
157+
{
158+
notFound = false
159+
break
160+
}
161+
}
162+
if ( notFound )
163163
{
164164
reload = true
165165
break
@@ -181,10 +181,10 @@ void function OnModButtonFocused( var button )
181181

182182
RuiSetGameTime( rui, "startTime", -99999.99 ) // make sure it skips the whole animation for showing this
183183
RuiSetString( rui, "headerText", modName )
184-
RuiSetString( rui, "messageText", FormatModDescription( modName ) )
184+
RuiSetString( rui, "messageText", FormatModDescription() )
185185

186186
// Add a button to open the link with if required
187-
string link = NSGetModDownloadLinkByModName( modName )
187+
string link = file.lastMod.downloadLink
188188
var linkButton = Hud_GetChild( file.menu, "ModPageButton" )
189189
if ( link.len() )
190190
{
@@ -198,28 +198,41 @@ void function OnModButtonFocused( var button )
198198
Hud_SetVisible( linkButton, false )
199199
}
200200

201-
SetControlBarColor( modName )
201+
SetControlBarColor( file.lastMod )
202202

203-
bool required = NSIsModRequiredOnClient( modName )
203+
bool required = file.lastMod.requiredOnClient
204204
Hud_SetVisible( Hud_GetChild( file.menu, "WarningLegendLabel" ), required )
205205
Hud_SetVisible( Hud_GetChild( file.menu, "WarningLegendImage" ), required )
206206
}
207207

208208
void function OnModButtonPressed( var button )
209209
{
210-
string modName = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( button ) ) ) + file.scrollOffset - 1 ].mod.name
211-
if ( StaticFind( modName ) && NSIsModEnabled( modName ) )
210+
ModInfo mod = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( button ) ) ) + file.scrollOffset - 1 ].mod
211+
string modName = mod.name
212+
if ( StaticFind( modName ) && mod.enabled )
212213
CoreModToggleDialog( modName )
213214
else
214215
{
215-
NSSetModEnabled( modName, !NSIsModEnabled( modName ) )
216-
var panel = file.panels[ int ( Hud_GetScriptID( Hud_GetParent( button ) ) ) - 1 ]
217-
SetControlBoxColor( Hud_GetChild( panel, "ControlBox" ), modName )
218-
SetControlBarColor( modName )
219-
SetModEnabledHelperImageAsset( Hud_GetChild( panel, "EnabledImage" ), modName )
220-
// RefreshMods()
221-
UpdateListSliderPosition()
222-
UpdateListSliderHeight()
216+
NSSetModEnabled( modName, !mod.enabled )
217+
// retrieve state of the mod that just got toggled
218+
array<ModInfo> infos = NSGetModInformation( mod.name )
219+
foreach ( ModInfo modInfo in infos )
220+
{
221+
if ( modInfo.name != modName || modInfo.version != mod.version )
222+
{
223+
continue
224+
}
225+
// Update UI mod state
226+
file.mods[ int ( Hud_GetScriptID( Hud_GetParent( button ) ) ) + file.scrollOffset - 1 ].mod = modInfo
227+
var panel = file.panels[ int ( Hud_GetScriptID( Hud_GetParent( button ) ) ) - 1 ]
228+
SetControlBoxColor( Hud_GetChild( panel, "ControlBox" ), modInfo )
229+
SetControlBarColor( modInfo )
230+
SetModEnabledHelperImageAsset( Hud_GetChild( panel, "EnabledImage" ), modInfo )
231+
// RefreshMods()
232+
UpdateListSliderPosition()
233+
UpdateListSliderHeight()
234+
break
235+
}
223236
}
224237
}
225238

@@ -235,8 +248,8 @@ void function OnAuthenticationAgreementButtonPressed( var button )
235248

236249
void function OnModLinkButtonPressed( var button )
237250
{
238-
string modName = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( file.currentButton ) ) ) + file.scrollOffset - 1 ].mod.name
239-
string link = NSGetModDownloadLinkByModName( modName )
251+
ModInfo mod = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( file.currentButton ) ) ) + file.scrollOffset - 1 ].mod
252+
string link = mod.downloadLink
240253
if ( link.find("http://") != 0 && link.find("https://") != 0 )
241254
link = "http://" + link // links without the http or https protocol get opened in the internal browser
242255
LaunchExternalWebBrowser( link, WEBBROWSER_FLAG_FORCEEXTERNAL )
@@ -266,7 +279,7 @@ void function OnHideConVarsChange( var n )
266279
if ( modName == "" )
267280
return
268281
var rui = Hud_GetRui( Hud_GetChild( file.menu, "LabelDetails" ) )
269-
RuiSetString( rui, "messageText", FormatModDescription( modName ) )
282+
RuiSetString( rui, "messageText", FormatModDescription() )
270283
}
271284

272285
// LIST LOGIC
@@ -289,23 +302,34 @@ void function CoreModToggleDialog( string mod )
289302

290303
void function DisableMod()
291304
{
292-
string modName = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( file.currentButton ) ) ) + file.scrollOffset - 1 ].mod.name
305+
ModInfo mod = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( file.currentButton ) ) ) + file.scrollOffset - 1 ].mod
306+
string modName = mod.name
293307
NSSetModEnabled( modName, false )
294308

295-
var panel = file.panels[ int ( Hud_GetScriptID( Hud_GetParent( file.currentButton ) ) ) - 1]
296-
SetControlBoxColor( Hud_GetChild( panel, "ControlBox" ), modName )
297-
SetControlBarColor( modName )
298-
SetModEnabledHelperImageAsset( Hud_GetChild( panel, "EnabledImage" ), modName )
309+
// retrieve state of the mod that just got toggled
310+
array<ModInfo> infos = NSGetModInformation( mod.name )
311+
foreach ( modInfo in infos )
312+
{
313+
if ( modInfo.name != modName || modInfo.version != mod.version )
314+
{
315+
continue
316+
}
317+
var panel = file.panels[ int ( Hud_GetScriptID( Hud_GetParent( file.currentButton ) ) ) - 1]
318+
SetControlBoxColor( Hud_GetChild( panel, "ControlBox" ), modInfo )
319+
SetControlBarColor( modInfo )
320+
SetModEnabledHelperImageAsset( Hud_GetChild( panel, "EnabledImage" ), modInfo )
299321

300-
RefreshMods()
322+
RefreshMods()
323+
break
324+
}
301325
}
302326

303-
array<string> function GetEnabledModsArray()
327+
array<ModInfo> function GetEnabledModsArray()
304328
{
305-
array<string> enabledMods
306-
foreach ( string mod in NSGetModNames() )
329+
array<ModInfo> enabledMods
330+
foreach ( ModInfo mod in NSGetModsInformation() )
307331
{
308-
if ( NSIsModEnabled( mod ) )
332+
if ( mod.enabled )
309333
enabledMods.append( mod )
310334
}
311335
return enabledMods
@@ -329,25 +353,26 @@ void function UpdateList()
329353

330354
void function RefreshMods()
331355
{
332-
array<string> modNames = NSGetModNames()
356+
array<ModInfo> mods = NSGetModsInformation()
333357
file.mods.clear()
334358

335359
bool reverse = GetConVarBool( "modlist_reverse" )
336360

337-
int lastLoadPriority = reverse ? NSGetModLoadPriority( modNames[ modNames.len() - 1 ] ) + 1 : -1
361+
int lastLoadPriority = reverse ? mods.top().loadPriority + 1 : -1
338362
string searchTerm = Hud_GetUTF8Text( Hud_GetChild( file.menu, "BtnModsSearch" ) ).tolower()
339363

340-
for ( int i = reverse ? modNames.len() - 1 : 0;
341-
reverse ? ( i >= 0 ) : ( i < modNames.len() );
364+
for ( int i = reverse ? mods.len() - 1 : 0;
365+
reverse ? ( i >= 0 ) : ( i < mods.len() );
342366
i += ( reverse ? -1 : 1) )
343367
{
344-
string mod = modNames[i]
368+
ModInfo mod = mods[i]
369+
string modName = mod.name
345370

346-
if ( searchTerm.len() && mod.tolower().find( searchTerm ) == null )
371+
if ( searchTerm.len() && modName.tolower().find( searchTerm ) == null )
347372
continue
348373

349-
bool enabled = NSIsModEnabled( mod )
350-
bool required = NSIsModRequiredOnClient( mod )
374+
bool enabled = mod.enabled
375+
bool required = mod.requiredOnClient
351376
switch ( GetConVarInt( "filter_mods" ) )
352377
{
353378
case filterShow.ONLY_ENABLED:
@@ -368,11 +393,11 @@ void function RefreshMods()
368393
break
369394
}
370395

371-
int pr = NSGetModLoadPriority( mod )
396+
int pr = mod.loadPriority
372397

373398
if ( reverse ? pr < lastLoadPriority : pr > lastLoadPriority )
374399
{
375-
modData m
400+
ModInfo m
376401
m.name = pr.tostring()
377402

378403
panelContent c
@@ -382,16 +407,9 @@ void function RefreshMods()
382407
lastLoadPriority = pr
383408
}
384409

385-
modData m
386-
m.name = mod
387-
m.version = NSGetModVersionByModName( mod )
388-
m.link = NSGetModDownloadLinkByModName( mod )
389-
m.loadPriority = NSGetModLoadPriority( mod )
390-
m.enabled = enabled
391-
m.conVars = NSGetModConvarsByModName( mod )
392410

393411
panelContent c
394-
c.mod = m
412+
c.mod = mod
395413

396414
file.mods.append( c )
397415
}
@@ -405,7 +423,7 @@ void function DisplayModPanels()
405423
break
406424

407425
panelContent c = file.mods[ file.scrollOffset + i ]
408-
modData mod = c.mod
426+
ModInfo mod = c.mod
409427
var btn = Hud_GetChild( panel, "BtnMod" )
410428
var headerLabel = Hud_GetChild( panel, "Header" )
411429
var box = Hud_GetChild( panel, "ControlBox" )
@@ -435,53 +453,45 @@ void function DisplayModPanels()
435453

436454
Hud_SetVisible( headerLabel, false )
437455

438-
SetControlBoxColor( box, mod.name )
456+
SetControlBoxColor( box, mod )
439457
Hud_SetVisible( box, true )
440458
Hud_SetVisible( line, false )
441459

442-
Hud_SetVisible( warning, NSIsModRequiredOnClient( c.mod.name ) )
460+
Hud_SetVisible( warning, mod.requiredOnClient )
443461

444-
SetModEnabledHelperImageAsset( enabledImage, c.mod.name )
462+
SetModEnabledHelperImageAsset( enabledImage, c.mod )
445463
}
446464
Hud_SetVisible( panel, true )
447465
}
448466
}
449467

450-
void function SetModEnabledHelperImageAsset( var panel, string modName )
468+
void function SetModEnabledHelperImageAsset( var panel, ModInfo mod )
451469
{
452-
if( NSIsModEnabled( modName ) )
470+
if( mod.enabled )
453471
RuiSetImage( Hud_GetRui( panel ), "basicImage", $"rui/menu/common/merit_state_success" )
454472
else
455473
RuiSetImage( Hud_GetRui( panel ), "basicImage", $"rui/menu/common/merit_state_failure" )
456-
RuiSetFloat3(Hud_GetRui( panel ), "basicImageColor", GetControlColorForMod( modName ) )
474+
RuiSetFloat3(Hud_GetRui( panel ), "basicImageColor", GetControlColorForMod( mod ) )
457475
Hud_SetVisible( panel, true )
458476
}
459477

460-
void function SetControlBoxColor( var box, string modName )
478+
void function SetControlBoxColor( var box, ModInfo mod )
461479
{
462480
var rui = Hud_GetRui( box )
463-
// if ( NSIsModEnabled( modName ) )
464-
// RuiSetFloat3(rui, "basicImageColor", <0,1,0>)
465-
// else
466-
// RuiSetFloat3(rui, "basicImageColor", <1,0,0>)
467-
RuiSetFloat3(rui, "basicImageColor", GetControlColorForMod( modName ) )
481+
RuiSetFloat3(rui, "basicImageColor", GetControlColorForMod( mod ) )
468482
}
469483

470-
void function SetControlBarColor( string modName )
484+
void function SetControlBarColor( ModInfo mod )
471485
{
472486
var bar_element = Hud_GetChild( file.menu, "ModEnabledBar" )
473487
var bar = Hud_GetRui( bar_element )
474-
// if ( NSIsModEnabled( modName ) )
475-
// RuiSetFloat3(bar, "basicImageColor", <0,1,0>)
476-
// else
477-
// RuiSetFloat3(bar, "basicImageColor", <1,0,0>)
478-
RuiSetFloat3(bar, "basicImageColor", GetControlColorForMod( modName ) )
488+
RuiSetFloat3(bar, "basicImageColor", GetControlColorForMod( mod ) )
479489
Hud_SetVisible( bar_element, true )
480490
}
481491

482-
vector function GetControlColorForMod( string modName )
492+
vector function GetControlColorForMod( ModInfo mod )
483493
{
484-
if ( NSIsModEnabled( modName ) )
494+
if ( mod.enabled )
485495
switch ( GetConVarInt( "colorblind_mode" ) )
486496
{
487497
case 1:
@@ -503,17 +513,19 @@ vector function GetControlColorForMod( string modName )
503513
unreachable
504514
}
505515

506-
string function FormatModDescription( string modName )
516+
string function FormatModDescription()
507517
{
518+
ModInfo mod = file.lastMod
519+
string modName = mod.name
508520
string ret
509521
// version
510-
ret += format( "Version %s\n", NSGetModVersionByModName( modName ) )
522+
ret += format( "Version %s\n", mod.version )
511523

512524
// load priority
513-
ret += format( "Load Priority: %i\n", NSGetModLoadPriority( modName ) )
525+
ret += format( "Load Priority: %i\n", mod.loadPriority )
514526

515527
// convars
516-
array<string> modCvars = NSGetModConvarsByModName( modName )
528+
array<string> modCvars = mod.conVars
517529
if ( modCvars.len() != 0 && GetConVarBool( "modlist_show_convars" ) )
518530
{
519531
ret += "ConVars: "
@@ -530,7 +542,7 @@ string function FormatModDescription( string modName )
530542
}
531543

532544
// description
533-
ret += format( "\n%s\n", NSGetModDescriptionByModName( modName ) )
545+
ret += format( "\n%s\n", mod.description )
534546

535547
return ret
536548
}

0 commit comments

Comments
 (0)