diff options
author | uniboi <64006268+uniboi@users.noreply.github.com> | 2022-10-08 10:30:22 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-08 12:30:22 +0200 |
commit | 1804b784eee053a1031a9f095955de88b0179e1e (patch) | |
tree | bcd8644acf3fd0b735274f0b09a684186ddb4d61 | |
parent | 5edc1b0c98aed20cbd3b3bc429db9c5d17939945 (diff) | |
download | NorthstarMods-1.9.8-rc2.tar.gz NorthstarMods-1.9.8-rc2.zip |
Modlist Hotfixes (#510)v1.9.8-rc3v1.9.8-rc2v1.9.8-rc1
* fix mod list overflow
* better offset validation
-rw-r--r-- | Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut | 49 |
1 files changed, 30 insertions, 19 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 index 01149bb0..329ea73f 100644 --- a/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut +++ b/Northstar.Client/mod/scripts/vscripts/ui/menu_ns_modmenu.nut @@ -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 @@ -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() } } @@ -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 ] @@ -534,6 +539,7 @@ void function UpdateMouseDeltaBuffer(int x, int y) mouseDeltaBuffer.deltaX = x mouseDeltaBuffer.deltaY = y + UpdateListSliderHeight() SliderBarUpdate() } @@ -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 ) |