void UpdateInputState (void) { DWORD NewTime; /* First, if the game is, in fact, paused, we stall until * unpaused. Every thread with control over game logic calls * UpdateInputState routinely, so we handle pause and exit * state updates here. */ // Automatically pause and enter low-activity state while inactive, // for example, window minimized. if (!GameActive) SleepGame (); if (GamePaused) PauseGame (); if (ExitRequested) ConfirmExit (); CurrentInputState = ImmediateInputState; OldInputState = CachedInputState; CachedInputState = ImmediateInputState; BeginInputFrame (); NewTime = GetTimeCounter (); if (_gestalt_keys) { _check_gestalt (NewTime); } else { int i, j; for (i = 0; i < NUM_TEMPLATES; i++) { for (j = 0; j < NUM_KEYS; j++) { _check_for_pulse (&PulsedInputState.key[i][j], &CachedInputState.key[i][j], &OldInputState.key[i][j], &RepeatDelays.key[i][j], &NewTime, &Times.key[i][j]); } } for (i = 0; i < NUM_MENU_KEYS; i++) { _check_for_pulse (&PulsedInputState.menu[i], &CachedInputState.menu[i], &OldInputState.menu[i], &RepeatDelays.menu[i], &NewTime, &Times.menu[i]); } } if (CurrentInputState.menu[KEY_PAUSE]) GamePaused = TRUE; if (CurrentInputState.menu[KEY_EXIT]) ExitRequested = TRUE; #if defined(DEBUG) || defined(USE_DEBUG_KEY) if (PulsedInputState.menu[KEY_DEBUG]) debugKeyPressedSynchronous (); #endif }
int main() { /// Initialize Environment initscr(); cbreak(); keypad(stdscr, TRUE); nodelay(stdscr, TRUE); noecho(); curs_set(0); start_color(); /// Initialize Color Pair init_pair(RED_BLACK, COLOR_RED, COLOR_BLACK); init_pair(GREEN_BLACK, COLOR_GREEN, COLOR_BLACK); init_pair(BLUE_BLACK, COLOR_BLUE, COLOR_BLACK); init_pair(YELLOW_BLACK, COLOR_YELLOW, COLOR_BLACK); /// Create Class Object CMenu menu; CSnakeGame snake; // Setup Menu menu.SetTitle("Welcome to SnakeGame"); menu.SetPrompt("Please choose a item:"); menu.AddItem("1. New Game"); menu.AddItem("2. Load Game"); menu.AddItem("3. Score Board"); menu.AddItem("4. Help"); menu.AddItem("5. Exit"); // Wait for user while(true) { int select = menu.WaitChoice(); if (select == 1) snake.NewGame(); else if (select == 2) snake.LoadGame(); else if (select == 3) snake.ShowScoreBoard(); else if (select == 4) snake.ShowHelp(); else if (select == 5) { if (ConfirmExit()) break; } } /// Clean Up endwin(); return 0; }
LRESULT CWebinosUI::OnTray(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { bHandled = TRUE; switch (lParam) { case NIN_BALLOONUSERCLICK: { //ConfirmExit(); break; } case WM_LBUTTONDBLCLK: ShowWindow(SW_SHOW); SetForegroundWindow(m_hWnd); break; case WM_RBUTTONUP: { HMENU contextMenu = LoadMenu(_Module.GetResourceInstance(),MAKEINTRESOURCE(IDR_CONTEXT_MENU)); HMENU subMenu = GetSubMenu(contextMenu,0); POINT pt; GetCursorPos(&pt); SetForegroundWindow(m_hWnd); int cmd = TrackPopupMenu(subMenu,TPM_CENTERALIGN | TPM_BOTTOMALIGN | TPM_RETURNCMD | TPM_VERNEGANIMATION, pt.x, pt.y, 0, m_hWnd, NULL); ::PostMessage(m_hWnd, WM_NULL, 0, 0); switch (cmd) { case ID_CONTEXT_EXIT: ConfirmExit(); break; case ID_CONTEXT_CONFIGURE: ShowWindow(SW_SHOW); break; } break; } default: bHandled = FALSE; break; } return 0; }
ECode CActivityOne::OnKeyDown( /* [in] */ Int32 keyCode, /* [in] */ IKeyEvent* event, /* [out] */ Boolean* result) { Boolean b = FALSE; if ((keyCode == IKeyEvent::KEYCODE_BACK) && (mWebView->CanGoBack(&b), b)) { mWebView->GoBack(); *result = TRUE; return NOERROR; } else if(keyCode == IKeyEvent::KEYCODE_BACK) { ConfirmExit(); *result = TRUE; return NOERROR; } return Activity::OnKeyDown(keyCode, event, result); }
void Interface::Update() { START_PROFILE( "EclUpdate" ); EclUpdate(); END_PROFILE( "EclUpdate" ); // // Screenshot? if( g_keyDeltas[KEY_P] && !UsingChatWindow() && g_app->m_gameRunning ) { g_renderer->SaveScreenshot(); if( g_app->GetWorld()->AmISpectating() ) { int teamId = g_app->GetClientToServer()->m_clientId; g_app->GetClientToServer()->SendChatMessageReliably( teamId, 100, LANGUAGEPHRASE("dialog_saved_screenshot"), true ); } else { int teamId = g_app->GetWorld()->m_myTeamId; g_app->GetClientToServer()->SendChatMessageReliably( teamId, 100, LANGUAGEPHRASE("dialog_saved_screenshot"), false ); } } // // Pop up main menu? if( m_escTimer > 0.0f ) { m_escTimer -= g_advanceTime; } if (QuitKeyPressed()) ConfirmExit( NULL ); if (QuitImmediatelyKeyPressed() || g_inputManager->m_quitRequested) { g_inputManager->m_quitRequested = false; AttemptQuitImmediately(); } if (ToggleFullscreenKeyPressed() || s_toggleFullscreen) { g_preferences->SetInt( PREFS_SCREEN_WINDOWED, !g_preferences->GetInt( PREFS_SCREEN_WINDOWED )); g_app->ReinitialiseWindow(); s_toggleFullscreen = false; } if( g_keyDeltas[KEY_ESC] ) { // // panic key (double esc) bool panicKeyEnabled = g_preferences->GetInt(PREFS_INTERFACE_PANICKEY); bool officeMode = (g_app->GetGame()->GetOptionValue("GameMode") == GAMEMODE_OFFICEMODE); if( officeMode ) panicKeyEnabled = true; if( panicKeyEnabled && m_escTimer > 0.0f ) { g_app->HideWindow(); m_escTimer = 0.0f; g_keys[KEY_ESC] = 0; g_keyDeltas[KEY_ESC] = 0; } if( !EclGetWindow( "Main Menu" ) ) { EclRegisterWindow( new MainMenu() ); } else { EclRemoveWindow( "Main Menu" ); } m_escTimer = 0.5f; } if( !g_app->m_gameRunning && EclGetWindows()->Size() == 0 ) { EclRegisterWindow( new MainMenu() ); } }
// Returns FALSE if aborted. static BOOLEAN SelectShip_processInput (GETMELEE_STATE *gms, COUNT playerI, BATTLE_INPUT_STATE inputState) { if (inputState & BATTLE_WEAPON) { if (gms->player[playerI].col == NUM_PICKMELEE_COLUMNS && gms->player[playerI].row == 0) { // Random ship (void) setShipSelected (gms, playerI, (COUNT) ~0, TRUE); } else if (gms->player[playerI].col == NUM_PICKMELEE_COLUMNS && gms->player[playerI].row == 1) { // Selected exit if (ConfirmExit ()) return FALSE; } else { // Selection is on a ship slot. COUNT slotNr = PickMelee_GetShipIndex (gms->player[playerI].row, gms->player[playerI].col); (void) setShipSelected (gms, playerI, slotNr, TRUE); // If the choice is not valid, setShipSelected() // will not set .done. } } else { // Process motion commands. COUNT new_row, new_col; new_row = gms->player[playerI].row; new_col = gms->player[playerI].col; if (inputState & BATTLE_LEFT) { if (new_col-- == 0) new_col = NUM_PICKMELEE_COLUMNS; } else if (inputState & BATTLE_RIGHT) { if (new_col++ == NUM_PICKMELEE_COLUMNS) new_col = 0; } if (inputState & BATTLE_THRUST) { if (new_row-- == 0) new_row = NUM_PICKMELEE_ROWS - 1; } else if (inputState & BATTLE_DOWN) { if (++new_row == NUM_PICKMELEE_ROWS) new_row = 0; } if (new_row != gms->player[playerI].row || new_col != gms->player[playerI].col) { gms->player[playerI].row = new_row; gms->player[playerI].col = new_col; PlayMenuSound (MENU_SOUND_MOVE); PickMelee_ChangedSelection (gms, playerI); } } return TRUE; }
int main(int argc, icChar* argv[]) { if (argc<=1) { printf("Usage: CmdIccProfLibTest profile\n"); return -1; } CIccFileIO FileIO; if (!FileIO.Open(argv[1], "rb")) { printf("Unable to open '%s'\n", argv[1]); return -1; } CIccProfile *pIcc = new CIccProfile; if(!pIcc->Read(&FileIO)) { printf("Unable to read '%s'\n", argv[1]); delete pIcc; return -1; } bool Exit = false; std::string Option; ShowMenu(); while(!Exit) { Option = GetUserInput(); if(Option.size() >=2) { printf("\nInvalid Option\n"); return -1; } icChar temp = Option[0]; switch(temp) { case '0': ShowMenu(); break; case '1': ShowHeader(pIcc); ShowMenu(); break; case '2': ReadTag(pIcc); ShowMenu(); break; case '3': AddTag(&FileIO,pIcc); ShowMenu(); break; case '4': SaveProfile(pIcc); return 0; case '5': IsValidProfile(&FileIO, pIcc); ShowMenu(); break; case '6': DeleteTag(&FileIO, pIcc); ShowMenu(); break; case '7': SaveProfCopy(pIcc); ShowMenu(); break; case '9': Exit = ConfirmExit(); if(!Exit) ShowMenu(); break; default: printf("\nInvalid Option\n"); ShowMenu(); } } delete pIcc; return 0; }
LRESULT CWebinosUI::OnBnClickedShutdownBtn(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { ConfirmExit(); return 0; }