@ -56,7 +56,7 @@ void Menu::CheckClickAndPerformMenuSelect(Crawler*game){
}
void Menu : : HoverMenuSelect ( Crawler * game ) {
if ( selection = = vi2d { - 1 , - 1 } ) return ;
if ( selection = = vi2d { - 1 , - 1 } | | buttons [ selection . y ] [ selection . x ] - > disabled ) return ;
if ( buttons [ selection . y ] [ selection . x ] - > draggable )
if ( buttonHoldTime < " ThemeGlobal.MenuHoldTime " _F ) CheckClickAndPerformMenuSelect ( game ) ;
else {
@ -67,7 +67,7 @@ void Menu::HoverMenuSelect(Crawler*game){
}
void Menu : : MenuSelect ( Crawler * game ) {
if ( selection = = vi2d { - 1 , - 1 } ) return ;
if ( selection = = vi2d { - 1 , - 1 } | | buttons [ selection . y ] [ selection . x ] - > disabled ) return ;
buttons [ selection . y ] [ selection . x ] - > onClick ( MenuFuncData { * this , game , buttons [ selection . y ] [ selection . x ] } ) ;
if ( buttons [ selection . y ] [ selection . x ] - > menuDest ! = MenuType : : ENUM_END ) {
if ( stack . size ( ) < 32 ) {
@ -90,7 +90,9 @@ void Menu::Update(Crawler*game){
for ( auto & key : buttons ) {
for ( auto & button : key . second ) {
button - > hovered = false ;
if ( ! button - > disabled ) {
button - > hovered = false ;
}
}
}
if ( ! MOUSE_NAVIGATION ) {
@ -99,12 +101,14 @@ void Menu::Update(Crawler*game){
for ( auto & key : buttons ) {
int index = 0 ;
for ( auto & button : key . second ) {
if ( geom2d : : overlaps ( geom2d : : rect < float > { button - > rect . pos + pos , button - > rect . size } , game - > GetMousePos ( ) ) ) {
button - > hovered = true ;
selection . y = key . first ;
selection . x = index ;
if ( ! button - > disabled ) {
if ( button - > GetHoverState ( game ) ) {
button - > hovered = true ;
selection . y = key . first ;
selection . x = index ;
}
index + + ;
}
index + + ;
}
}
}
@ -132,13 +136,13 @@ void Menu::Update(Crawler*game){
for ( auto & key : buttons ) {
for ( auto & button : key . second ) {
if ( button - > renderInMain ) {
button - > Update ( game ) ;
button - > _ Update( game ) ;
}
}
}
for ( auto & component : displayComponents ) {
if ( component - > renderInMain ) {
component - > Update ( game ) ;
component - > _ Update( game ) ;
}
}
} ;
@ -157,13 +161,13 @@ void Menu::Draw(Crawler*game){
for ( auto & key : buttons ) {
for ( auto & button : key . second ) {
if ( button - > renderInMain ) {
button - > Draw ( game , { 0 , 0 } , this = = Menu : : stack . back ( ) ) ;
button - > _ Draw( game , { 0 , 0 } , this = = Menu : : stack . back ( ) ) ;
}
}
}
for ( auto & component : displayComponents ) {
if ( component - > renderInMain ) {
component - > Draw ( game , { 0 , 0 } , this = = Menu : : stack . back ( ) ) ;
component - > _ Draw( game , { 0 , 0 } , this = = Menu : : stack . back ( ) ) ;
}
}
game - > SetPixelMode ( prevMode ) ;
@ -173,13 +177,13 @@ void Menu::Draw(Crawler*game){
for ( auto & key : buttons ) {
for ( auto & button : key . second ) {
if ( button - > renderInMain ) {
button - > DrawDecal ( game , pos , this = = Menu : : stack . back ( ) ) ;
button - > _ DrawDecal( game , pos , this = = Menu : : stack . back ( ) ) ;
}
}
}
for ( auto & component : displayComponents ) {
if ( component - > renderInMain ) {
component - > DrawDecal ( game , pos , this = = Menu : : stack . back ( ) ) ;
component - > _ DrawDecal( game , pos , this = = Menu : : stack . back ( ) ) ;
}
}
@ -220,6 +224,7 @@ void Menu::OpenMenu(MenuType menu){
}
void Menu : : KeyboardButtonNavigation ( Crawler * game , vf2d menuPos ) {
vi2d prevSelection = selection ;
if ( game - > GetKey ( RIGHT ) . bPressed ) {
if ( selection = = vi2d { - 1 , - 1 } ) return ;
MOUSE_NAVIGATION = false ;
@ -345,6 +350,10 @@ void Menu::KeyboardButtonNavigation(Crawler*game,vf2d menuPos){
buttonHoldTime = 0 ;
}
}
if ( prevSelection ! = selection ) {
if ( selection ! = vi2d { - 1 , - 1 } & & buttons [ selection . y ] [ selection . x ] - > disabled ) selection = prevSelection ;
// If the new selection of a button on this frame is disabled for some reason, we need to go back to what we had selected before.
}
}
void Menu : : DrawScaledWindowBorder ( Crawler * game , vf2d menuPos ) {