menuDef_t *Menus_ActivateByName(const char *p, qboolean modalStack) { int i; menuDef_t *m = NULL; menuDef_t *focus = Menu_GetFocused(); for (i = 0; i < menuCount; i++) { if (Q_stricmp(Menus[i].window.name, p) == 0) { m = &Menus[i]; Menus_Activate(m); if (modalStack && (m->window.flags & WINDOW_MODAL)) { if (modalMenuCount >= MAX_MODAL_MENUS) { Com_Error(ERR_DROP, "MAX_MODAL_MENUS exceeded"); } modalMenuStack[modalMenuCount++] = focus; } break; // found it, don't continue searching as we might unfocus the menu we just activated again. } else { Menus[i].window.flags &= ~(WINDOW_HASFOCUS | WINDOW_MOUSEOVER); } } Display_CloseCinematics(); return m; }
/* * The notify code on the UI for the shop menu */ void JKG_ForceItemMenuUpdates() { menuDef_t* focusedMenu = Menu_GetFocused(); if (focusedMenu == nullptr) { return; // No focused menu? } if (!Q_stricmp(focusedMenu->window.name, "jkg_inventory")) { JKG_ConstructInventoryList(); } else if (!Q_stricmp(focusedMenu->window.name, "jkg_shop")) { JKG_ShopInventorySortChanged(); } }
void Menu_SetFeederSelection(menuDef_t *menu, int feeder, int index, const char *name) { if (menu == NULL) { if (name == NULL) { menu = Menu_GetFocused(); } else { menu = Menus_FindByName(name); } } if (menu) { int i; for (i = 0; i < menu->itemCount; i++) { if (menu->items[i]->special == feeder) { if (index == 0) { listBoxDef_t *listPtr = (listBoxDef_t *)menu->items[i]->typeData; listPtr->cursorPos = 0; listPtr->startPos = 0; } menu->items[i]->cursorPos = index; DC->feederSelection(menu->items[i]->special, menu->items[i]->cursorPos); return; } } } }
//----------------------------------------------------------------------------- // Name: CommunicatorStatusUpdate // Desc: XHV Callback - called when the engine detects that the status of a // communicator has changed. May not be called if a communicator // is quickly removed and re-inserted, but in that case there is // nothing the game has to do. //----------------------------------------------------------------------------- HRESULT CVoiceManager::CommunicatorStatusUpdate( DWORD dwPort, XHV_VOICE_COMMUNICATOR_STATUS status ) { // If we're not initialized, then do nothing if( !m_bInitialized ) return S_OK; if( status == XHV_VOICE_COMMUNICATOR_STATUS_INSERTED ) { // Got a new headset: // Let the UI know that we have a headset, so it can enable things! Cvar_SetValue( "ui_headset", 1 ); // Awful UI hack. If we're on the online options screen, move off any item // that just became disabled. menuDef_t *menu = Menu_GetFocused(); if( menu && !Q_stricmp(menu->window.name, "xbl_onlineoptions") ) { VM_Call( uivm, UI_KEY_EVENT, A_CURSOR_DOWN, qtrue ); // Send a "move the cursor down" // Also, if we had "Speakers" selected, switch it to "Enabled" if( Cvar_VariableIntegerValue( "ui_voiceMode" ) == 1 ) Cvar_SetValue( "ui_voiceMode", 2 ); } // Always re-route voice to headset m_XHVVoiceManager.SetVoiceThroughSpeakers( FALSE ); // Don't do anything else if banned, or voice is disabled: if( m_bVoiceDisabled || (logged_on && !XOnlineIsUserVoiceAllowed( XBLLoggedOnUsers[ IN_GetMainController() ].xuid.dwUserFlags ) ) ) return S_OK; // If we're logged onto live, update our voice flag if( logged_on ) XBL_F_SetState( XONLINE_FRIENDSTATE_FLAG_VOICE, true ); // Finally, if we're in a session, update our status and tell everyone: if( m_bRunning ) { xbOnlineInfo.xbPlayerList[xbOnlineInfo.localIndex].flags |= VOICE_CAN_RECV; xbOnlineInfo.xbPlayerList[xbOnlineInfo.localIndex].flags |= VOICE_CAN_SEND; SendVoiceInfo( VOICEINFO_HAVEVOICE, NULL ); } } else if( status == XHV_VOICE_COMMUNICATOR_STATUS_REMOVED ) { // Lost a headset: // Let the UI know that we don't have a headset, so it can disable things! Cvar_SetValue( "ui_headset", 0 ); // Awful UI hack. If we're on the online options screen, move off any item // that just became disabled. menuDef_t *menu = Menu_GetFocused(); if( menu && !Q_stricmp(menu->window.name, "xbl_onlineoptions") ) { VM_Call( uivm, UI_KEY_EVENT, A_CURSOR_UP, qtrue ); // Send a "move the cursor up" // Also, if we had "Enabled" selected, that's no longer valid. Change ui_voiceMode: if( Cvar_VariableIntegerValue( "ui_voiceMode" ) == 2 ) Cvar_SetValue( "ui_voiceMode", 1 ); } // If the user pulls the headset and it was set to "speakers" or "enabled", // then change to "speakers" m_XHVVoiceManager.SetVoiceThroughSpeakers( !m_bVoiceDisabled ); // Don't do anything else if banned, or voice is disabled: if( m_bVoiceDisabled || (logged_on && !XOnlineIsUserVoiceAllowed( XBLLoggedOnUsers[ IN_GetMainController() ].xuid.dwUserFlags ) ) ) return S_OK; // If we're logged onto live, update our voice flag if( logged_on ) XBL_F_SetState( XONLINE_FRIENDSTATE_FLAG_VOICE, false ); // Finally, if we're in a session, update our status and tell everyone: if( m_bRunning ) { xbOnlineInfo.xbPlayerList[xbOnlineInfo.localIndex].flags |= VOICE_CAN_RECV; xbOnlineInfo.xbPlayerList[xbOnlineInfo.localIndex].flags &= ~VOICE_CAN_SEND; SendVoiceInfo( VOICEINFO_SPEAKERS, NULL ); } } return S_OK; }