Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Multiple mod versions #824

Closed
wants to merge 47 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
080e1bd
refactor: use new function names
Alystrasz Jul 28, 2024
eb6ba6f
refactor: use NSGetModsInformation to reduce number of native calls i…
Alystrasz Jul 29, 2024
fb5f74e
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Jul 29, 2024
676b4c1
Merge branch 'R2Northstar:main' into fix/multiple-mod-versions
Alystrasz Jul 30, 2024
9d96ffa
feat: add modVersion parameter to NSSetModEnabled function
Alystrasz Jul 30, 2024
e994cd2
feat: add modVersion parameter to NSIsModEnabled function
Alystrasz Jul 30, 2024
9ac22a5
refactor: remove useless NSGetModNamesAndVersions function
Alystrasz Jul 30, 2024
0cb86a7
refactor: remove NSIsModRequiredOnClient calls where it's not needed
Alystrasz Jul 30, 2024
c24e1ed
feat: add modVersion parameter to NSIsModRequiredOnClient function
Alystrasz Jul 30, 2024
0b2cfd7
refactor: remove FormatModDescription useless parameter
Alystrasz Jul 30, 2024
6797581
refactor: put mod description in NSGetModsInformation results and rem…
Alystrasz Jul 30, 2024
d82f5d1
refactor: remove NSGetModDownloadLinkByModName calls since download l…
Alystrasz Jul 30, 2024
1a157b8
build: remove NSGetModLoadPriority signature from CI configuration si…
Alystrasz Jul 30, 2024
8fa8ae9
build: remove NSGetModConvarsByModName signature from CI configuratio…
Alystrasz Jul 31, 2024
69fb41f
refactor: replace NSGetModVersionByModName function with NSGetModVers…
Alystrasz Jul 31, 2024
81734dc
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Jul 31, 2024
d55c1b1
build: add NSGetModsInformation signature to CI configuration
Alystrasz Jul 31, 2024
dfc6cf6
fix: check targetServer type (must be ServerInfo instance)
Alystrasz Jul 31, 2024
d59fc1a
fix: reload mods when disabling/enabling two versions of a mod at the…
Alystrasz Aug 4, 2024
5b47e98
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Aug 9, 2024
c8d155b
refactor: extract core mod test into a dedicated function
Alystrasz Aug 9, 2024
0fa9b70
refactor: use a mod list to define if a mod is a core mod
Alystrasz Aug 9, 2024
516c6e5
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Aug 29, 2024
fa7b782
refactor: add ModInfo.isRemote member
Alystrasz Aug 29, 2024
60ee024
fix: tolerate Northstar.Custom version differences (with server version)
Alystrasz Aug 30, 2024
2eb5abd
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Aug 30, 2024
1d408ad
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Aug 30, 2024
b606248
fix: enable Northstar.Custom mod if it is disabled
Alystrasz Aug 30, 2024
9b00cff
Merge branch 'fix/multiple-mod-versions' of github.com:Alystrasz/Nort…
Alystrasz Aug 30, 2024
da1a915
feat: complete log messages
Alystrasz Aug 30, 2024
f377942
refactor: remove (pseudo) semver check
Alystrasz Aug 30, 2024
6216e0a
fix: only enable core mod if it currently is disabled
Alystrasz Aug 30, 2024
0242997
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Aug 31, 2024
829559d
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Sep 2, 2024
b512aca
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Sep 3, 2024
5e1fbc1
Merge branch 'R2Northstar:main' into fix/multiple-mod-versions
Alystrasz Sep 3, 2024
2bd36f2
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Sep 7, 2024
dc62123
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Sep 7, 2024
24cfc95
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Sep 11, 2024
6198365
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Sep 12, 2024
56db820
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Sep 14, 2024
27575b3
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Sep 19, 2024
c67879d
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Oct 1, 2024
5c62f23
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Nov 5, 2024
1a8e2f2
Merge commit 'c1649d1e1d719b2859041afa1cbff32ee090a885' into fix/mult…
GeckoEidechse Nov 22, 2024
1b58941
Merge remote-tracking branch 'origin/main' into fix/multiple-mod-vers…
GeckoEidechse Nov 22, 2024
c5bba85
Merge branch 'main' into fix/multiple-mod-versions
Alystrasz Nov 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 60 additions & 6 deletions .github/nativefuncs.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,29 @@
"returnTypeString":"array<ModInfo>",
"argTypes":""
},
{
"name":"NSIsModEnabled",
"helpText":"",
"returnTypeString":"bool",
"argTypes":"string modName, string modVersion"
},
{
"name":"NSSetModEnabled",
"helpText":"",
"returnTypeString":"void",
"argTypes":"string modName, bool enabled"
"argTypes":"string modName, string modVersion, bool enabled"
},
{
"name":"NSGetModVersions",
"helpText":"",
"returnTypeString":"array<string>",
"argTypes":"string modName"
},
{
"name":"NSIsModRequiredOnClient",
"helpText":"",
"returnTypeString":"bool",
"argTypes":"string modName, string modVersion"
},
{
"name":"DecodeJSON",
Expand Down Expand Up @@ -218,11 +236,35 @@
"returnTypeString":"array<string>",
"argTypes":""
},
{
"name":"NSGetModsInformation",
"helpText":"",
"returnTypeString":"array<ModInfo>",
"argTypes":""
},
{
"name":"NSIsModEnabled",
"helpText":"",
"returnTypeString":"bool",
"argTypes":"string modName, string modVersion"
},
{
"name":"NSSetModEnabled",
"helpText":"",
"returnTypeString":"void",
"argTypes":"string modName, bool enabled"
"argTypes":"string modName, string modVersion, bool enabled"
},
{
"name":"NSGetModVersions",
"helpText":"",
"returnTypeString":"array<string>",
"argTypes":"string modName"
},
{
"name":"NSIsModRequiredOnClient",
"helpText":"",
"returnTypeString":"bool",
"argTypes":"string modName, string modVersion"
},
{
"name":"DecodeJSON",
Expand Down Expand Up @@ -383,16 +425,28 @@
"argTypes":""
},
{
"name":"NSGetModInformation",
"name":"NSIsModEnabled",
"helpText":"",
"returnTypeString":"array<ModInfo>",
"argTypes":"string modName"
"returnTypeString":"bool",
"argTypes":"string modName, string modVersion"
},
{
"name":"NSSetModEnabled",
"helpText":"",
"returnTypeString":"void",
"argTypes":"string modName, bool enabled"
"argTypes":"string modName, string modVersion, bool enabled"
},
{
"name":"NSGetModVersions",
"helpText":"",
"returnTypeString":"array<string>",
"argTypes":"string modName"
},
{
"name":"NSIsModRequiredOnClient",
"helpText":"",
"returnTypeString":"bool",
"argTypes":"string modName, string modVersion"
},
{
"name": "NSFetchVerifiedModsManifesto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ global struct UIPresenceStruct {

global struct ModInfo
{
string name = ""
string name = ""
string description = ""
string version = ""
string downloadLink = ""
int loadPriority = 0
bool enabled = false
bool requiredOnClient = false
bool isRemote
array<string> conVars = []
string version = ""
string downloadLink = ""
int loadPriority = 0
bool enabled = false
bool requiredOnClient = false
bool isRemote
array<string> conVars = []
}

global struct RequiredModInfo
Expand Down
94 changes: 38 additions & 56 deletions Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,16 @@ void function OnModMenuClosed()
{
bool notFound = true

foreach ( ModInfo enMod in file.enabledMods )
foreach (ModInfo enMod in file.enabledMods )
{
if ( mod.name == enMod.name )
if (mod.name == enMod.name && mod.version == enMod.version)
{
notFound = false
break
}
}

if ( notFound )
if (notFound)
{
reload = true
break
Expand Down Expand Up @@ -195,7 +195,7 @@ void function OnModButtonFocused( var button )
Hud_SetVisible( linkButton, false )
}

SetControlBarColor( file.lastMod )
SetControlBarColor( modName, file.lastMod.version )

bool required = file.lastMod.requiredOnClient
Hud_SetVisible( Hud_GetChild( file.menu, "WarningLegendLabel" ), required )
Expand All @@ -206,33 +206,18 @@ void function OnModButtonPressed( var button )
{
ModInfo mod = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( button ) ) ) + file.scrollOffset - 1 ].mod
string modName = mod.name
if ( StaticFind( modName ) && mod.enabled )
if ( StaticFind( modName ) && NSIsModEnabled( modName, mod.version ) )
CoreModToggleDialog( modName )
else
{
NSSetModEnabled( modName, !mod.enabled )

// retrieve state of the mod that just got toggled
array<ModInfo> infos = NSGetModInformation( mod.name )
foreach ( modInfo in infos )
{
if ( modInfo.name != modName || modInfo.version != mod.version )
{
continue
}

// Update UI mod state
file.mods[ int ( Hud_GetScriptID( Hud_GetParent( button ) ) ) + file.scrollOffset - 1 ].mod = modInfo

var panel = file.panels[ int ( Hud_GetScriptID( Hud_GetParent( button ) ) ) - 1 ]
SetControlBoxColor( Hud_GetChild( panel, "ControlBox" ), modInfo )
SetControlBarColor( modInfo )
SetModEnabledHelperImageAsset( Hud_GetChild( panel, "EnabledImage" ), modInfo )
// RefreshMods()
UpdateListSliderPosition()
UpdateListSliderHeight()
break
}
NSSetModEnabled( modName, mod.version, !NSIsModEnabled( modName, mod.version ) )
var panel = file.panels[ int ( Hud_GetScriptID( Hud_GetParent( button ) ) ) - 1 ]
SetControlBoxColor( Hud_GetChild( panel, "ControlBox" ), modName, mod.version )
SetControlBarColor( modName, mod.version )
SetModEnabledHelperImageAsset( Hud_GetChild( panel, "EnabledImage" ), modName, mod.version )
// RefreshMods()
UpdateListSliderPosition()
UpdateListSliderHeight()
}
}

Expand Down Expand Up @@ -304,25 +289,14 @@ void function DisableMod()
{
ModInfo mod = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( file.currentButton ) ) ) + file.scrollOffset - 1 ].mod
string modName = mod.name
NSSetModEnabled( modName, false )
NSSetModEnabled( modName, mod.version, false )

// retrieve state of the mod that just got toggled
array<ModInfo> infos = NSGetModInformation( mod.name )
foreach ( modInfo in infos )
{
if ( modInfo.name != modName || modInfo.version != mod.version )
{
continue
}
var panel = file.panels[ int ( Hud_GetScriptID( Hud_GetParent( file.currentButton ) ) ) - 1]
SetControlBoxColor( Hud_GetChild( panel, "ControlBox" ), modName, mod.version )
SetControlBarColor( modName, mod.version )
SetModEnabledHelperImageAsset( Hud_GetChild( panel, "EnabledImage" ), modName, mod.version )

var panel = file.panels[ int ( Hud_GetScriptID( Hud_GetParent( file.currentButton ) ) ) - 1]
SetControlBoxColor( Hud_GetChild( panel, "ControlBox" ), modInfo )
SetControlBarColor( modInfo )
SetModEnabledHelperImageAsset( Hud_GetChild( panel, "EnabledImage" ), modInfo )

RefreshMods()
break
}
RefreshMods()
}

array<ModInfo> function GetEnabledModsArray()
Expand Down Expand Up @@ -457,45 +431,53 @@ void function DisplayModPanels()

Hud_SetVisible( headerLabel, false )

SetControlBoxColor( box, mod )
SetControlBoxColor( box, mod.name, mod.version )
Hud_SetVisible( box, true )
Hud_SetVisible( line, false )

Hud_SetVisible( warning, mod.requiredOnClient )

SetModEnabledHelperImageAsset( enabledImage, c.mod )
SetModEnabledHelperImageAsset( enabledImage, c.mod.name, c.mod.version )
}
Hud_SetVisible( panel, true )
}
}

void function SetModEnabledHelperImageAsset( var panel, ModInfo mod )
void function SetModEnabledHelperImageAsset( var panel, string modName, string modVersion )
{
if( mod.enabled )
if( NSIsModEnabled( modName, modVersion ) )
RuiSetImage( Hud_GetRui( panel ), "basicImage", $"rui/menu/common/merit_state_success" )
else
RuiSetImage( Hud_GetRui( panel ), "basicImage", $"rui/menu/common/merit_state_failure" )
RuiSetFloat3(Hud_GetRui( panel ), "basicImageColor", GetControlColorForMod( mod ) )
RuiSetFloat3(Hud_GetRui( panel ), "basicImageColor", GetControlColorForMod( modName, modVersion ) )
Hud_SetVisible( panel, true )
}

void function SetControlBoxColor( var box, ModInfo mod )
void function SetControlBoxColor( var box, string modName, string modVersion )
{
var rui = Hud_GetRui( box )
RuiSetFloat3(rui, "basicImageColor", GetControlColorForMod( mod ) )
// if ( NSIsModEnabled( modName ) )
// RuiSetFloat3(rui, "basicImageColor", <0,1,0>)
// else
// RuiSetFloat3(rui, "basicImageColor", <1,0,0>)
RuiSetFloat3(rui, "basicImageColor", GetControlColorForMod( modName, modVersion ) )
}

void function SetControlBarColor( ModInfo mod )
void function SetControlBarColor( string modName, string modVersion )
{
var bar_element = Hud_GetChild( file.menu, "ModEnabledBar" )
var bar = Hud_GetRui( bar_element )
RuiSetFloat3(bar, "basicImageColor", GetControlColorForMod( mod ) )
// if ( NSIsModEnabled( modName ) )
// RuiSetFloat3(bar, "basicImageColor", <0,1,0>)
// else
// RuiSetFloat3(bar, "basicImageColor", <1,0,0>)
RuiSetFloat3(bar, "basicImageColor", GetControlColorForMod( modName, modVersion ) )
Hud_SetVisible( bar_element, true )
}

vector function GetControlColorForMod( ModInfo mod )
vector function GetControlColorForMod( string modName, string modVersion )
{
if ( mod.enabled )
if ( NSIsModEnabled( modName, modVersion ) )
switch ( GetConVarInt( "colorblind_mode" ) )
{
case 1:
Expand Down
42 changes: 12 additions & 30 deletions Northstar.Client/mod/scripts/vscripts/ui/menu_ns_serverbrowser.nut
Original file line number Diff line number Diff line change
Expand Up @@ -982,8 +982,7 @@ void function OnServerSelected_Threaded( var button )
uninstalledModFound = true
break
} else {
array<string> modVersions = GetModVersions( requiredModInfo.name )

array<string> modVersions = NSGetModVersions( requiredModInfo.name )
if ( !modVersions.contains( requiredModInfo.version ) ) {
print( format ( "\"%s\" was found locally but has versions:", requiredModInfo.name ) )
foreach ( string version in modVersions )
Expand All @@ -1010,7 +1009,7 @@ void function OnServerSelected_Threaded( var button )
if ( IsCoreMod( mod.name ) )
continue

if ( !NSGetModNames().contains( mod.name ) || !GetModVersions( mod.name ).contains( mod.version ) )
if ( !NSGetModNames().contains( mod.name ) || !NSGetModVersions( mod.name ).contains( mod.version ) )
{
// Auto-download mod
if ( autoDownloadAllowed )
Expand Down Expand Up @@ -1132,7 +1131,7 @@ void function ThreadedAuthAndConnectToServer( string password = "", bool modsCha
if (!found)
{
modsChanged = true
NSSetModEnabled( modName, false )
NSSetModEnabled( modName, modVersion, false )
print(format("Disabled \"%s\" (v%s) since it's not required on server.", modName, modVersion))
}
}
Expand All @@ -1143,31 +1142,24 @@ void function ThreadedAuthAndConnectToServer( string password = "", bool modsCha
{
string modName = mod.name
string modVersion = mod.version
array<ModInfo> localModInfos = NSGetModInformation( modName )

// Tolerate core mods (only Northstar.Custom for now) having a different version than server
if ( IsCoreMod(modName) )
{
if ( !localModInfos[0].enabled )
string coreModVersion = NSGetModVersions( modName )[0]
if ( !NSIsModEnabled( modName, coreModVersion ) )
{
modsChanged = true
NSSetModEnabled( modName, true )
print(format("Enabled \"%s\" (v%s) to join server.", modName, localModInfos[0].version))
NSSetModEnabled( modName, coreModVersion, true )
print(format("Enabled \"%s\" (v%s) to join server.", modName, coreModVersion))
}
}

else
else if ( NSIsModRequiredOnClient( modName, modVersion ) && !NSIsModEnabled( modName, modVersion ) )
{
foreach( localMod in localModInfos )
{
if ( localMod.version == mod.version )
{
modsChanged = true
NSSetModEnabled( mod.name, true )
print(format("Enabled \"%s\" (v%s) to join server.", modName, modVersion))
break
}
}
modsChanged = true
NSSetModEnabled( modName, modVersion, true )
print(format("Enabled \"%s\" (v%s) to join server.", modName, modVersion))
}
}

Expand Down Expand Up @@ -1368,14 +1360,4 @@ const array<string> CORE_MODS = ["Northstar.Client", "Northstar.Coop", "Northsta
bool function IsCoreMod( string modName )
{
return CORE_MODS.find( modName ) != -1
}

array<string> function GetModVersions( string modName )
{
array<string> versions = []
foreach ( ModInfo mod in NSGetModInformation( modName ) )
{
versions.append( mod.version )
}
return versions
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ void function NS_SetVersionLabel()
{
var mainMenu = GetMenu( "MainMenu" ) //Gets main menu element
var versionLabel = GetElementsByClassname( mainMenu, "nsVersionClass" )[0] //Gets the label from the mainMenu element.
Hud_SetText( versionLabel, "v" + NSGetModInformation( "Northstar.Client" )[0].version ) //Sets the label text (Getting Northstar version from Northstar.Client)
Hud_SetText( versionLabel, "v" + NSGetModVersions("Northstar.Client")[0]) //Sets the label text (Getting Northstar version from Northstar.Client)
}

Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ void function UpdatePlayButton( var button )
bool hasNonVanillaMods = false
foreach ( ModInfo mod in NSGetModsInformation() )
{
string modName = mod.name
if ( mod.enabled && mod.requiredOnClient )
{
hasNonVanillaMods = true
Expand Down
Loading