diff options
-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 ) |