Skip to content

Commit

Permalink
Make Sys_SetInteractiveIngameGuiActive() work better
Browse files Browse the repository at this point in the history
it could happen that UIs are added to the internal list twice,
and also that the last UI wasn't removed from the list when a new one
was focused fast enough.

That should work better now, I hope I didn't break anything..
  • Loading branch information
DanielGibson committed Mar 17, 2024
1 parent 0d4405b commit 27aeda2
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions neo/d3xp/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5539,6 +5539,11 @@ void idPlayer::UpdateFocus( void ) {

if ( focusGUIent && focusUI ) {
if ( !oldFocus || oldFocus != focusGUIent ) {
// DG: tell the old UI it isn't focused anymore
if ( oldFocus != NULL && oldUI != NULL ) {
command = oldUI->Activate( false, gameLocal.time );
// TODO: HandleGuiCommands( oldFocus, command ); ?
} // DG end
command = focusUI->Activate( true, gameLocal.time );
HandleGuiCommands( focusGUIent, command );
StartSound( "snd_guienter", SND_CHANNEL_ANY, 0, false, NULL );
Expand Down
5 changes: 5 additions & 0 deletions neo/game/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4559,6 +4559,11 @@ void idPlayer::UpdateFocus( void ) {

if ( focusGUIent && focusUI ) {
if ( !oldFocus || oldFocus != focusGUIent ) {
// DG: tell the old UI it isn't focused anymore
if ( oldFocus != NULL && oldUI != NULL ) {
command = oldUI->Activate( false, gameLocal.time );
// TODO: HandleGuiCommands( oldFocus, command ); ?
} // DG end
command = focusUI->Activate( true, gameLocal.time );
HandleGuiCommands( focusGUIent, command );
StartSound( "snd_guienter", SND_CHANNEL_ANY, 0, false, NULL );
Expand Down
7 changes: 5 additions & 2 deletions neo/sys/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,9 @@ void Sys_SetInteractiveIngameGuiActive( bool active, idUserInterface* ui )
if ( sessLocal.GetActiveMenu() == NULL && active ) {
// add ui to lastuis, if it has been activated and no proper menu
// (like main menu) is currently open
lastuis.Append( ui );
if ( idx == -1 ) {
lastuis.Append( ui );
}
} else if ( idx != -1 ) {
// if the UI is in lastuis and has been deactivated, or there
// is a proper menu opened, remove it from the list.
Expand All @@ -1049,7 +1051,8 @@ void Sys_SetInteractiveIngameGuiActive( bool active, idUserInterface* ui )
// And because it's possible that we have an ingame UI focussed while opening
// the multiplayer-main-menu, we keep a list of lastuis, instead of just one,
// so D3_IN_interactiveIngameGuiActive remains true in that case
// (the ingame UI is still in the list)
// (the ingame UI is still in the list); the lastuis list is also needed
// for the case of opening the PDA while an ingame GUI is focused

lastuis.RemoveIndex( idx );
}
Expand Down
1 change: 1 addition & 0 deletions neo/sys/sys_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ void Sys_GrabMouseCursor( bool grabIt );
// DG: added this for an ungodly hack for gamepad support
// active = true means "currently a GUI with a cursor is active/focused"
// active = false means "that GUI is not active anymore"
// ui == NULL means "clear all currently remembered GUIs"
class idUserInterface;
void Sys_SetInteractiveIngameGuiActive( bool active, idUserInterface* ui );

Expand Down

0 comments on commit 27aeda2

Please sign in to comment.