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

Modlist Hotfixes #510

Merged
merged 3 commits into from
Oct 8, 2022
Merged
Changes from all commits
Commits
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
49 changes: 30 additions & 19 deletions Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ void function OnModMenuClosed()

void function OnModButtonFocused( var button )
{
if( int ( Hud_GetScriptID( Hud_GetParent( button ) ) ) > file.mods.len() )
return

file.currentButton = button
file.lastMod = file.mods[ int ( Hud_GetScriptID( Hud_GetParent( button ) ) ) + file.scrollOffset - 1 ].mod
string modName = file.lastMod.name
Expand Down Expand Up @@ -209,7 +212,9 @@ void function OnModButtonPressed( var button )
SetControlBoxColor( Hud_GetChild( panel, "ControlBox" ), modName )
SetControlBarColor( modName )
SetModEnabledHelperImageAsset( Hud_GetChild( panel, "EnabledImage" ), modName )
RefreshMods()
// RefreshMods()
UpdateListSliderPosition()
UpdateListSliderHeight()
}
}

Expand Down Expand Up @@ -391,7 +396,7 @@ void function DisplayModPanels()
{
foreach ( int i, var panel in file.panels)
{
if ( i >= file.mods.len() ) // don't try to show more panels than needed
if ( i >= file.mods.len() || file.scrollOffset + i >= file.mods.len() ) // don't try to show more panels than needed
break

panelContent c = file.mods[ file.scrollOffset + i ]
Expand Down Expand Up @@ -534,6 +539,7 @@ void function UpdateMouseDeltaBuffer(int x, int y)
mouseDeltaBuffer.deltaX = x
mouseDeltaBuffer.deltaY = y

UpdateListSliderHeight()
SliderBarUpdate()
}

Expand Down Expand Up @@ -616,45 +622,50 @@ void function OnScrollDown( var button )
{
if ( file.mods.len() <= PANELS_LEN ) return
file.scrollOffset += 5
if (file.scrollOffset + PANELS_LEN > file.mods.len()) {
if (file.scrollOffset + PANELS_LEN > file.mods.len())
file.scrollOffset = file.mods.len() - PANELS_LEN
}
UpdateList()
UpdateListSliderPosition()
Hud_SetFocused( Hud_GetChild( file.menu, "BtnModListSlider" ) )
ValidateScrollOffset()
}

void function OnScrollUp( var button )
{
file.scrollOffset -= 5
if (file.scrollOffset < 0) {
if (file.scrollOffset < 0)
file.scrollOffset = 0
}
UpdateList()
UpdateListSliderPosition()
Hud_SetFocused( Hud_GetChild( file.menu, "BtnModListSlider" ) )
ValidateScrollOffset()
}

void function OnDownArrowSelected( var button )
{
if ( file.mods.len() <= PANELS_LEN ) return
file.scrollOffset += 1
if (file.scrollOffset + PANELS_LEN > file.mods.len()) {
if (file.scrollOffset + PANELS_LEN > file.mods.len())
file.scrollOffset = file.mods.len() - PANELS_LEN
}
UpdateList()
UpdateListSliderPosition()
ValidateScrollOffset()
}

void function OnUpArrowSelected( var button )
{
file.scrollOffset -= 1
if (file.scrollOffset < 0) {
if (file.scrollOffset < 0)
file.scrollOffset = 0
}
UpdateList()
UpdateListSliderPosition()
ValidateScrollOffset()
}

//
void function ValidateScrollOffset()
{
RefreshMods()
if( file.scrollOffset + 15 > file.mods.len() )
file.scrollOffset = file.mods.len() - 15
if( file.scrollOffset < 0 )
file.scrollOffset = 0
HideAllPanels()
DisplayModPanels()
UpdateListSliderHeight()
UpdateListSliderPosition()
}

// Static arrays don't have the .find method for some reason
bool function StaticFind( string mod )
Expand Down