int main (int argc, char *argv[]) { CWindow a ("Sample window", 10, 10, 600, 480); a.Add (CButton (1, 0.1, 0.8, 0.3, 0.1, "Ok")) .Add (CButton (2, 0.6, 0.8, 0.3, 0.1, "Cancel")); a.Add (CLabel (10, 0.1, 0.1, 0.2, 0.1, "Username:"******"chucknorris")); a.Add (CComboBox (20, 0.1, 0.3, 0.8, 0.1) .Add ("Karate") .Add ("Judo") .Add ("Box") .Add ("Progtest")); cout << a; CWindow b = a; CControl *ctl = b.Search (20); cout << *ctl; CComboBox *cb = dynamic_cast<CComboBox *> (b.Search (20)); cb->SetSelected (3); CInput *il = dynamic_cast<CInput *> (b.Search (11)); il->SetValue ("*****@*****.**"); b.Add (CComboBox (21, 0.1, 0.5, 0.8, 0.1) .Add ("PA2") .Add ("OSY") .Add ("Both")); cout << b; b.SetPosition (20, 30, 640, 520); cout << b; return 0; }
// // HandleSingleTouchButtonCB - The system will call this callback when the user touches the screen // void HandleSingleTouchButtonCB(s3ePointerEvent* event) { CTouch* touch = g_Input.getTouch(0); touch->active = event->m_Pressed != 0; touch->x = event->m_x; touch->y = event->m_y; }
int main() { // Initialize our data Init(); // Below we do our basic game loop. This is what control the game primarily. // We only want the game to keep going as long as the character is alive. Of // course, in this tutorial the character can't die, but we set this up for later. // In the game loop we always check for input every frame, then we draw the map. // We don't draw the map every frame, but inside the Draw() function there is // a check to see if the draw flag is set. That is why we use the SetDrawFlag() // function to tell the map to draw. If we don't set that each frame, the map // will not draw, even though we call the Draw() flag. // Keep the game going while the player is alive while(g_Player.IsAlive()) { // If the user did some input, let's check it and handle it if(g_Input.CheckInput()) HandleGameInput(); // Let's draw the map when we need to draw (if the draw flag = true). g_Map.Draw(); } // Return a success with no problems return 1; }
int main(int argc, char *argv[]) { CBall *cPlayer; cPlayer = new CBall(); CDisplay *cDsp; cDsp = new CDisplay(XRES,YRES,BPP,SDL_SWSURFACE|SDL_DOUBLEBUF|SDL_ANYFORMAT,0); CInput *cInp; cInp = new CInput(1); CPaddle *cPdl; cPdl = new CPaddle(); cout << cPlayer->GetLives()<<endl; cPlayer->LoadIMG("images/ball.png"); cPdl->LoadIMG("images/paddle.png"); cPdl->setY((YRES/3)*2); cPdl->setX((XRES/2)); cout << cPdl->getX() << " " << cPdl->getY(); cPdl->srect.w = cPdl->Surface->w; cPdl->srect.h = cPdl->Surface->h; cPdl->srect.x = cPdl->srect.y = 0; cPdl->drect.w = cPdl->Surface->w; cPdl->drect.h = cPdl->Surface->h; while (CBall::running) { cPdl->drect.x = cPdl->xco; cPdl->drect.y = cPdl->yco; SDL_Event event; while(SDL_PollEvent(&event)) { CInput *cInp; cInp = new CInput(1); cout<<(cInp->updateInput(event))<<endl; delete cInp; } cPdl->Blit(*cDsp->Surface,cPdl->srect);//,&cPdl->drect); updateGameData(); SDL_Flip(cDsp->Surface); } return(0); }
// // HandleMultiTouchMotionCB - For multitouch devices the system will call this callback when the user moves their finger on the screen. This callback is called once for each screen touch // void HandleMultiTouchMotionCB(s3ePointerTouchMotionEvent* event) { // Check to see if the touch already exists CTouch* touch = g_Input.findTouch(event->m_TouchID); if (touch != NULL) { // Updates the touches positional information touch->x = event->m_x; touch->y = event->m_y; } }
// // // Input callback handlers // // // // HandleMultiTouchButtonCB - For multitouch devices the system will call this callback when the user touches the screen. This callback is called once for each screen touch // void HandleMultiTouchButtonCB(s3ePointerTouchEvent* event) { // Check to see if the touch already exists CTouch* touch = g_Input.findTouch(event->m_TouchID); if (touch != NULL) { // Yes it does, so update the touch information touch->active = event->m_Pressed != 0; touch->x = event->m_x; touch->y = event->m_y; } }
void HandleGameInput() { // This is not a function in our CInput class. We wanted the CInput class // to be generic and not actually handle our game code, but just tell us what // the user did. We can then make different function to handle the input // for a given situation. We do this for character movement, save\load prompts, // menus, etc... // Let's get the key that the user pressed int keyCode = g_Input.GetKeyCode(); // If we just hit a key from the keyboard, handle the input accordingly. if(g_Input.IsKeyboardEvent() && g_Input.IsKeyDown()) { if(keyCode == VK_ESCAPE) // If escape was pressed exit(0); // Quit the game else if(keyCode == VK_UP) // If up arrow key was pressed g_Player.Move(kUp); // Move the character up else if(keyCode == VK_DOWN) // If down arrow key was pressed g_Player.Move(kDown); // Move the character down else if(keyCode == VK_LEFT) // If left arrow key was pressed g_Player.Move(kLeft); // Move the character left else if(keyCode == VK_RIGHT) // If right arrow key was pressed g_Player.Move(kRight); // Move the character right // If the key pressed was for character movement, let's check for special tiles if(keyCode == VK_RIGHT || keyCode == VK_LEFT || keyCode == VK_UP || keyCode == VK_DOWN) { // Here we check if the character stepped on an exit, if so .... exit. g_Map.CheckForExit(g_Player.GetPosition().X, g_Player.GetPosition().Y); // We want to draw the screen again if the character moved g_Map.SetDrawFlag(true); } } }
void HandleGameInput() { // Store the position of the player before we possibly move POINT lastPosition = g_Player.GetLastPosition(); if(g_Input.IsKeyDown(VK_ESCAPE)) // If escape was pressed g_Menu.BringUpMenu(); // Bring up the main menu else if(g_Input.IsKeyDown(VK_UP)) // If up arrow key was pressed g_Player.Move(kUp); // Move the character up else if(g_Input.IsKeyDown(VK_DOWN)) // If down arrow key was pressed g_Player.Move(kDown); // Move the character down else if(g_Input.IsKeyDown(VK_LEFT)) // If left arrow key was pressed g_Player.Move(kLeft); // Move the character left else if(g_Input.IsKeyDown(VK_RIGHT)) // If right arrow key was pressed g_Player.Move(kRight); // Move the character right //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // If we hit space let's toggle on and off the stats at the botton of the screen else if(g_Input.IsKeyDown(VK_SPACE)) g_Map.ToggleStatsFlag(); //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // Store the new current position of the player POINT curPosition = g_Player.GetPosition(); // Check if the player moved by testing the current position against the last position if(lastPosition.x != curPosition.x || lastPosition.y != curPosition.y) { // We want to draw the screen again if the character moved g_Map.SetDrawFlag(true); //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // Since we need to pick up items, we need to check for them just like exits, etc. g_Map.CheckForItem(curPosition.x, curPosition.y); //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // If we run into an NPC, we need to know so we can display dialog g_Map.CheckForNpc(curPosition.x, curPosition.y); // Set the previous position of the player g_Player.SetLastPosition(curPosition); // Here we check to see if the player moved into an exit. If so, exit! g_Map.CheckForExit(curPosition.x, curPosition.y); } }
void FuzzwinAlgorithm::callPintool() { // ligne de commande pour appel de PIN avec l'entree en cours std::string cmdLine(this->getCmdLinePintool()); // mise à zéro de la formule _formula.erase(); STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory(&si, sizeof(si)); ZeroMemory(&pi, sizeof(pi)); si.cb = sizeof(si); if (CreateProcess(nullptr, (LPSTR) cmdLine.c_str(), NULL, // process security attributes NULL, // primary thread security attributes TRUE, // handles are inherited CREATE_NO_WINDOW, // creation flags NULL, // use parent's environment NULL, // use parent's current directory &si, &pi)) { /***********************/ /** CONNEXION AU PIPE **/ /***********************/ BOOL fSuccess = ConnectNamedPipe(_hPintoolPipe, NULL); if (!fSuccess && GetLastError() != ERROR_PIPE_CONNECTED) { this->logTimeStamp(); this->log("erreur de connexion au pipe FuzzWin GLE=" + std::to_string(GetLastError())); this->logEndOfLine(); return; // formule vide } // envoi dans le pipe du chemin vers l'entrée étudiée if (EXIT_FAILURE == sendArgumentToPintool(_pCurrentInput->getFilePath())) { return; // formule vide } /********************************************************/ /** ATTENTE DE L'ARRIVEE DES DONNEES DEPUIS LE PINTOOL **/ /********************************************************/ char buffer[512]; // buffer de récupération des données DWORD cbBytesRead = 0; // lecture successive de blocs de 512 octets // et construction progressive de la formule do { fSuccess = ReadFile(_hPintoolPipe, // pipe handle &buffer[0], // buffer to receive reply 512, // size of buffer &cbBytesRead, // number of bytes read NULL); // not overlapped if ( ! fSuccess && (GetLastError() != ERROR_MORE_DATA) ) break; // ajout des données lues au resultat _formula.append(&buffer[0], cbBytesRead); } while (!fSuccess); // repetition si ERROR_MORE_DATA // deconnexion du pipe DisconnectNamedPipe(_hPintoolPipe); // attente de la fermeture de l'application WaitForSingleObject(pi.hProcess, INFINITE); // recupération du code de retour du pintool // (NON ENCORE IMPLEMENTE) DWORD exitCode = 0; GetExitCodeProcess(pi.hProcess, &exitCode); // fermeture des handles processus et thread CloseHandle(pi.hProcess); CloseHandle(pi.hThread); // si option 'keepfiles' ou 'traceonly': sauvegarde de la formule (extension .smt2) if (_keepFiles || _traceOnly) { std::ofstream ofs(_pCurrentInput->getLogFile()); // entete (version pin Z3 etc) et nom de l'entrée ofs << infoHeader << '\n'; ofs << "; Fichier instrumenté : "; ofs << _pCurrentInput->getFileName(); // ajout de l'arbre généalogique (si objet non-root et mode verbeux) CInput *pFather = _pCurrentInput->getFather(); if (_verbose && pFather) { ofs << '('; do // boucle récursive de déclaration des parents de chaque fichier { ofs << " <- " << pFather->getFileName(); pFather = pFather->getFather(); } while (pFather); ofs << ')'; } ofs << "\n\n"; // configuration du solveur ofs << solverConfig; ofs << "\n\n"; // formule brute smt2 ofs << _formula; ofs << "\n\n"; // commandes de lancement et de récupération des résultats ofs << "(check-sat)\n(get-model)\n"; ofs.close(); } } else { this->logVerboseTimeStamp(); this->logVerbose("erreur process FuzzWin GLE=" + std::to_string(GetLastError())); this->logVerboseEndOfLine(); } }
int WINAPI WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow ) { CoInitialize(NULL); Mycapp.Initilize(hInstance,TEXT("MY"),WndProc); hwnd = Mycapp.GetHWND(); ghInstance = hInstance; w.Initialize(Mycapp); CInput cinput; cinput.Initialize(hInstance,Mycapp.GetHWND()); pcinput = &cinput; RECT _rect ={0,0,640,480}; PlaySound(TEXT("melody of life.wav"),hInstance,SND_LOOP|SND_FILENAME|SND_ASYNC ); LeadReader r; Attribute attr = r.GetAttr(); CLead lead(&w,attr); lead.Initialize(); CWeaponReader cwR; CSceneReader cr; vector<WeaponInfo> vecWeapon = cwR.GetWeapons(); CWeapons Weapon(&w); Weapon.SetVec(vecWeapon); psmanger.SetWeapon(&Weapon); psmanger.SetDraw(&w); psmanger.SetOverImage(TEXT("gameover.bmp")); CSceneInit csi; CScene* pscene = csi.InitScene("4096",&lead,&w,pcinput); CScene* pscene2 = csi.InitScene("4097",&lead,&w,pcinput); CScene* pscene3 = csi.InitScene("4098",&lead,&w,pcinput); CScene* pscene4 = csi.InitScene("4099",&lead,&w,pcinput); CScene* pscene5 = csi.InitScene("4100",&lead,&w,pcinput); CPathReader cpr; psmanger.SetPaths(cpr.GetPaths()); psmanger.RegisterScene(pscene); psmanger.RegisterScene(pscene2); psmanger.RegisterScene(pscene3); psmanger.RegisterScene(pscene4); psmanger.RegisterScene(pscene5); CSceneReader sr; SceneDesc scenedesc = sr.GetDesc("4097"); scenedesc.lpImage = NULL; scenedesc.pCDraw = &w; scenedesc.pcInput = &cinput; scenedesc.lpwFileName = TEXT("4.bmp"); scenedesc.bIsFightable = true; CMyMenu menuRectVictory(TEXT("6.bmp"),pcinput,&w,250,400); CMyMenu menuSelect(TEXT("6.bmp"),pcinput,&w,250,200); menuSelect.Initialize(); menuSelect.AddItem(TEXT("Attack!")); menuSelect.AddItem(TEXT("使用药水:10个")); CMyMenu menuStatus(TEXT("6.bmp"),pcinput,&w,250,200); menuStatus.Initialize(); menuStatus.AddItem(TEXT("主 角 H P:")); menuStatus.AddItem(TEXT("主角攻击力:")); menuStatus.AddItem(TEXT("主角防御力:")); menuRectVictory.Initialize(); CFightScene csceneFight(scenedesc,&menuRectVictory,&menuSelect,TEXT("bomb.bmp"),&menuStatus); CMyMenu menuSelectBuy(TEXT("6.bmp"),pcinput,&w,250,400); menuSelectBuy.Initialize(); cwR.FillItems( vecWeapon,menuSelectBuy); CSellScene css(scenedesc,&menuSelectBuy); css.Initialize(); css.SetWeapons(&Weapon); css.RegisterLead(&lead); psmanger.SetSellScene(&css); csceneFight.Initialize(); psmanger.SetFightScene(&csceneFight); #ifndef WINDOW_DEBUG psmanger.Draw(); #else psmanger.Draw(Mycapp.GetHWND()); #endif MSG msg; msg.message = WM_NULL; for(;;) { if(PeekMessage(&msg,NULL,NULL,NULL,PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } if(msg.message == WM_QUIT) break; else { #ifndef WINDOW_DEBUG psmanger.Draw(); #else psmanger.Draw(Mycapp.GetHWND()); #endif } } CoUninitialize(); return msg.message; }
// // HandleSingleTouchMotionCB - The system will call this callback when the user moves their finger on the screen // void HandleSingleTouchMotionCB(s3ePointerMotionEvent* event) { CTouch* touch = g_Input.getTouch(0); touch->x = event->m_x; touch->y = event->m_y; }
bool WinState::Input(CInput& _input ) { _input.ReadMouse(); _input.ReadKeyboard(); static bool ifPressedD_WIN = false; static bool ifPressedU_WIN = false; static bool ifPressedEnter_WIN = false; // Updates the reticle location based on the mouse pos. m_reticle.SetPosX(_input.GetMousePosX() - m_reticle.GetRect().GetWidth() * 0.5f); m_reticle.SetPosY(_input.GetMousePosY() - m_reticle.GetRect().GetHeight() * 0.5f); m_reticle.BuildGeometry(m_Renderer->GetScreenWidth(), m_Renderer->GetScreenHeight()); //Mouse Active over keybard if(_input.GetMousePosX() == m_PrevMousePosX && _input.GetMousePosY() == m_PrevMousePosY) { m_bMouseActive = false; } if(_input.GetMousePosX() != m_PrevMousePosX) { m_bMouseActive = true; m_PrevMousePosX = _input.GetMousePosX(); } if(_input.GetMousePosY() != m_PrevMousePosY) { m_bMouseActive = true; m_PrevMousePosY = _input.GetMousePosY(); } static bool ifPressedEsc_WIN = false; if(!ifPressedEsc_WIN) { ifPressedEsc_WIN = true; if(_input.KeyDown(DIK_ESCAPE)) { m_bFadeOut = true; if (m_bEsc) { m_bEsc = false; } if (m_bSoundCheck) { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT); m_bSoundCheck = false; } return true; } } else ifPressedEsc_WIN = false; //MOUSE INPUT FOR SELECTING BUTTONS---------------------------------------------------------------------- #pragma region Mouse Input for Selecting Buttons int _mouseX = _input.GetMousePosX(); int _mouseY = _input.GetMousePosY(); //MAIN MENU BUTTON //float _mainWidth1 = m_WinElements[WIN_MAIN_ELEMENT].GetRect().GetWidth(); //256 //float _mainHeight1 = m_WinElements[WIN_MAIN_ELEMENT].GetRect().GetHeight(); //64 //float _mainPosX1 = m_WinElements[WIN_MAIN_ELEMENT].GetPosX(); //280 //float _mainPosY1 = m_WinElements[WIN_MAIN_ELEMENT].GetPosY(); //612 //float _mainCombinedX1 = _mainPosX1 + _mainWidth1; //536 //float _mainCombinedY1 = _mainPosY1 + _mainHeight1; //676 //if (_mouseX >= _mainPosX1 && _mouseX <= _mainCombinedX1 && _mouseY <= _mainCombinedY1 && _mouseY >= _mainPosY1) //{ // if (m_FadeTimer <= 1.0f && !m_bFadeOut) //Fadded in, set to 0, and not FadeOut. // { // if (m_bMouseActive) // { // m_Choice = W_MAIN_MENU; // if (m_bSoundMain) // { // // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER); // m_bSoundMain = false; // m_bSoundCredits = true; // } // } // if (m_Timer > 0.5f) // { // if (_input.IsLeftClicked()) // { // // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT); // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT); // m_bFadeOut = true; // } // /*ProcessStates((eWinChoices)m_Choice);*/ // } // } //} //CREDITS BUTTON float _creditsWidth1 = m_WinElements[WIN_CREDITS_ELEMENT].GetRect().GetWidth(); //256 float _creditsHeight1 = m_WinElements[WIN_CREDITS_ELEMENT].GetRect().GetHeight(); //64 float _creditsPosX1 = m_WinElements[WIN_CREDITS_ELEMENT].GetPosX(); //280 float _creditsPosY1 = m_WinElements[WIN_CREDITS_ELEMENT].GetPosY(); //612 float _creditsCombinedX1 = _creditsPosX1 + _creditsWidth1; //536 float _creditsCombinedY1 = _creditsPosY1 + _creditsHeight1; //676 if (_mouseX >= _creditsPosX1 && _mouseX <= _creditsCombinedX1 && _mouseY <= _creditsCombinedY1 && _mouseY >= _creditsPosY1) { if (m_FadeTimer <= 1.0f && !m_bFadeOut) //Fadded in, set to 0, and not FadeOut. { if (m_bMouseActive) { m_Choice = W_CREDITS; if (m_bSoundCredits) { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER); m_bSoundMain = true; m_bSoundCredits = false; } } if (m_Timer > 0.5f) { if (_input.IsLeftClicked()) { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT); m_bFadeOut = true; } } } } #pragma endregion //KEYBOARD INPUT FOR SELECTING BUTTONS---------------------------------------------------------------------- #pragma region Keyboard Input for Selecting Buttons //float _winPosY1 = m_WinElements[WIN_HIGHLIGHTED_ELEMENT].GetPosY(); /*if(_input.KeyDown(DIK_A) || _input.KeyDown(DIK_LEFT) || _input.GetController().GetControllerState().Gamepad.sThumbLY < - 8000 || _input.GetController().GetControllerState().Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_LEFT) { if (m_FadeTimer <= 1.0f && !m_bFadeOut) { if(!ifPressedD_WIN) { m_Choice++; if(m_Choice == WIN_NUM_CHOICES) { m_Choice = W_MAIN_MENU; } ifPressedD_WIN = true; } } } else ifPressedD_WIN = false; if(_input.KeyDown(DIK_D) || _input.KeyDown(DIK_RIGHT) || _input.GetController().GetControllerState().Gamepad.sThumbLY > 8000 || _input.GetController().GetControllerState().Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_RIGHT) { if (m_FadeTimer <= 1.0f && !m_bFadeOut) { if(!ifPressedU_WIN) { m_Choice--; if(m_Choice < 0) { m_Choice = W_CREDITS; } ifPressedU_WIN = true; } } } else ifPressedU_WIN = false;*/ if (m_Timer > 0.5f) { if(_input.KeyDown(DIK_RETURN) || (_input.GetController().GetControllerState().Gamepad.wButtons & XINPUT_GAMEPAD_A) ) { if(!ifPressedEnter_WIN) { m_bFadeOut = true; ifPressedEnter_WIN = true; } } else ifPressedEnter_WIN = false; } //if (m_Choice == W_MAIN_MENU) //{ // if (m_bSoundMain) // { // // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER); // m_bSoundMain = false; // m_bSoundCredits = true; // } //} if (m_Choice == W_CREDITS) { if (m_bSoundCredits) { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT); m_bSoundMain = true; m_bSoundCredits = false; } } //if (m_Choice == W_MAIN_MENU) //{ // m_bMain = false; // m_bCredits = true; //} if (m_Choice == W_CREDITS) { m_bMain = true; m_bCredits = false; } #pragma endregion return true; }
bool CDifficultyMenu::Input( CInput& _input ) { _input.ReadMouse(); _input.ReadKeyboard(); static bool ifPressedDown = false; static bool ifPressedUp = false; static bool ifPressedEnter1 = false; static bool ifPressedEnter2 = false; //static bool ifPressedEsc = false; // Updates the reticle location based on the mouse pos. m_reticle.SetPosX(_input.GetMousePosX() - m_reticle.GetRect().GetWidth() * 0.5f); m_reticle.SetPosY(_input.GetMousePosY() - m_reticle.GetRect().GetHeight() * 0.5f); m_reticle.BuildGeometry(m_Renderer->GetScreenWidth(), m_Renderer->GetScreenHeight()); if(_input.GetMousePosX() == m_PrevMousePosX && _input.GetMousePosY() == m_PrevMousePosY) m_MouseActive = true; if(_input.GetMousePosX() != m_PrevMousePosX || _input.GetMousePosY() != m_PrevMousePosY) { m_MouseActive = true; m_PrevMousePosX = _input.GetMousePosX(); m_PrevMousePosY = _input.GetMousePosY(); } //Esc (EXIT THE PROGRAM) static bool ifPressedEsc_Cred = false; if(!ifPressedEsc_Cred) { if(_input.KeyDown(DIK_ESCAPE)) { m_Choice = CHOICE_BACK; m_FadeOut = true; ifPressedEsc_Cred = true; return true; } } else ifPressedEsc_Cred = false; #pragma region Keyboard inputs if(_input.KeyDown(DIK_S) || _input.KeyDown(DIK_DOWN) || _input.GetController().GetControllerState().Gamepad.sThumbLY < - 8000 || _input.GetController().GetControllerState().Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN ) { if(m_FadeTimer <= 1.0f && !m_FadeOut) { if(!ifPressedDown) { m_Choice++; if(m_Choice == CHOICE_TOTAL) { m_Choice = CHOICE_EASY; } ifPressedDown = true; } } } else ifPressedDown = false; if(_input.KeyDown(DIK_W) || _input.KeyDown(DIK_UP) || _input.GetController().GetControllerState().Gamepad.sThumbLY > 8000 || _input.GetController().GetControllerState().Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP) { if(m_FadeTimer <= 1.0f && !m_FadeOut) { if(!ifPressedUp) { m_Choice--; if(m_Choice < 0) { m_Choice = CHOICE_BACK; } ifPressedUp = true; } } } else ifPressedUp = false; #pragma endregion switch(m_Choice) { case CHOICE_EASY: { if(m_SoundEasy) { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER); m_SoundEasy = false; m_SoundNormal = true; m_SoundHard = true; m_SoundBack = true; m_isHighlighted = true; } } break; case CHOICE_NORMAL: { if(m_SoundNormal) { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER); m_SoundEasy = true; m_SoundNormal = false; m_SoundHard = true; m_SoundBack = true; m_isHighlighted = true; } } break; case CHOICE_HARD: { if(m_SoundHard) { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER); m_SoundEasy = true; m_SoundNormal = true; m_SoundHard = false; m_SoundBack = true; m_isHighlighted = true; } } break; case CHOICE_BACK: { if(m_SoundBack) { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER); m_SoundEasy = true; m_SoundNormal = true; m_SoundHard = true; m_SoundBack = false; m_isHighlighted = true; } } break; }; if(_input.KeyDown(DIK_RETURN) || (_input.GetController().GetControllerState().Gamepad.wButtons & XINPUT_GAMEPAD_A) ) { if(!ifPressedEnter1) { m_FadeOut = true; // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT); ifPressedEnter1 = true; } } else ifPressedEnter1 = false; #pragma region Mouse Input int _mX = _input.GetMousePosX(); int _mY = _input.GetMousePosY(); static bool ifLeftClickEasy = false; static bool ifLeftClickMedium = false; static bool ifLeftClickHard = false; static bool ifLeftClickBack = false; // play -> options -> credits // EASY float _assetwidth = m_DMElements[DM_EASY].GetRect().GetWidth(); float _assetHeight = m_DMElements[DM_EASY].GetRect().GetHeight(); float _assetPosX = m_DMElements[DM_EASY].GetPosX(); float _assetPosY = m_DMElements[DM_EASY].GetPosY(); float _assetCombinedX = _assetPosX + _assetwidth; float _assetCombinedY = _assetPosY + _assetHeight; if(_input.IsLeftClicked()) { if(!ifLeftClickEasy) { ifLeftClickEasy = true; if( _mX >= _assetPosX && _mX <= _assetCombinedX && _mY <= _assetCombinedY && _mY >= _assetPosY ) { if( m_Timer > 0.5f) { m_FadeOut = true; // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT); //AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::); } } } } else { ifLeftClickEasy = false; } if (_mX >= _assetPosX && _mX <= _assetCombinedX && _mY <= _assetCombinedY && _mY >= _assetPosY ) { if(m_FadeTimer <= 1.0f && !m_FadeOut) { if(m_MouseActive) { m_Choice = CHOICE_EASY; if(m_SoundEasy) { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER); m_SoundEasy = false; m_SoundNormal = true; m_SoundHard = true; m_SoundBack = true; m_isHighlighted = true; } } } } // NORMAL _assetwidth = m_DMElements[DM_NORMAL].GetRect().GetWidth(); _assetHeight = m_DMElements[DM_NORMAL].GetRect().GetHeight(); _assetPosX = m_DMElements[DM_NORMAL].GetPosX(); _assetPosY = m_DMElements[DM_NORMAL].GetPosY(); _assetCombinedX = _assetPosX + _assetwidth; _assetCombinedY = _assetPosY + _assetHeight; if(_input.IsLeftClicked()) { if(!ifLeftClickMedium) { ifLeftClickMedium = true; if( _mX >= _assetPosX && _mX <= _assetCombinedX && _mY <= _assetCombinedY && _mY >= _assetPosY ) { if( m_Timer > 0.5f) { m_FadeOut = true; // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT); } } } } else { ifLeftClickMedium = false; } if (_mX >= _assetPosX && _mX <= _assetCombinedX && _mY <= _assetCombinedY && _mY >= _assetPosY ) { if(m_FadeTimer <= 1.0f && !m_FadeOut) { if(m_MouseActive) { m_Choice = CHOICE_NORMAL; if(m_SoundNormal) { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER); m_SoundEasy = true; m_SoundNormal = false; m_SoundHard = true; m_SoundBack = true; m_isHighlighted = true; } } } } // HARD _assetwidth = m_DMElements[DM_HARD].GetRect().GetWidth(); _assetHeight = m_DMElements[DM_HARD].GetRect().GetHeight(); _assetPosX = m_DMElements[DM_HARD].GetPosX(); _assetPosY = m_DMElements[DM_HARD].GetPosY(); _assetCombinedX = _assetPosX + _assetwidth; _assetCombinedY = _assetPosY + _assetHeight; if(_input.IsLeftClicked()) { if(!ifLeftClickHard) { ifLeftClickHard = true; if( _mX >= _assetPosX && _mX <= _assetCombinedX && _mY <= _assetCombinedY && _mY >= _assetPosY ) { if( m_Timer > 0.5f) { m_FadeOut = true; // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT); } } } } else { ifLeftClickHard = false; } if (_mX >= _assetPosX && _mX <= _assetCombinedX && _mY <= _assetCombinedY && _mY >= _assetPosY ) { if(m_FadeTimer <= 1.0f && !m_FadeOut) { if(m_MouseActive) { m_Choice = CHOICE_HARD; if(m_SoundHard) { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER); m_SoundEasy = true; m_SoundNormal = true; m_SoundHard = false; m_SoundBack = true; m_isHighlighted = true; } } } } // BACK _assetwidth = m_DMElements[DM_BACK].GetRect().GetWidth(); _assetHeight = m_DMElements[DM_BACK].GetRect().GetHeight(); _assetPosX = m_DMElements[DM_BACK].GetPosX(); _assetPosY = m_DMElements[DM_BACK].GetPosY(); _assetCombinedX = _assetPosX + _assetwidth; _assetCombinedY = _assetPosY + _assetHeight; if(_input.IsLeftClicked()) { if(!ifLeftClickBack) { ifLeftClickBack = true; if( _mX >= _assetPosX && _mX <= _assetCombinedX && _mY <= _assetCombinedY && _mY >= _assetPosY ) { if( m_Timer > 0.5f) { m_FadeOut = true; // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT); } } } } else { ifLeftClickBack = false; } if (_mX >= _assetPosX && _mX <= _assetCombinedX && _mY <= _assetCombinedY && _mY >= _assetPosY ) { if(m_FadeTimer <= 1.0f && !m_FadeOut) { if(m_MouseActive) { m_Choice = CHOICE_BACK; if(m_SoundBack) { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER); m_SoundEasy = true; m_SoundNormal = true; m_SoundHard = true; m_SoundBack = false; m_isHighlighted = true; } } } } #pragma endregion return true; }
void HandleGameInput() { // Store the position of the player before we possibly move POINT lastPosition = g_Player.GetLastPosition(); if(g_Input.IsKeyDown(VK_ESCAPE)) // If escape was pressed g_Menu.BringUpMenu(); // Bring up the main menu else if(g_Input.IsKeyDown(VK_UP)) // If up arrow key was pressed g_Player.Move(kUp); // Move the character up else if(g_Input.IsKeyDown(VK_DOWN)) // If down arrow key was pressed g_Player.Move(kDown); // Move the character down else if(g_Input.IsKeyDown(VK_LEFT)) // If left arrow key was pressed g_Player.Move(kLeft); // Move the character left else if(g_Input.IsKeyDown(VK_RIGHT)) // If right arrow key was pressed g_Player.Move(kRight); // Move the character right else if(g_Input.IsKeyDown(VK_SPACE)) // If space bar was pressed g_Map.ToggleStatsFlag(); // Turn on and off the stats menu // Store the new current position of the player POINT curPosition = g_Player.GetPosition(); // Check if the player moved by testing the current position against the last position if(lastPosition.x != curPosition.x || lastPosition.y != curPosition.y) { //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // This function updates our party to take the last position of the // party member in front of them. If we have 3 players in our party // there will be a domino effect each time the main player moves. The // second player will take the last step of the first player, and the // third player will take the last step of the second player. They follow // you every step of the way... What a loyal party :) g_Player.MoveParty(); //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // We want to draw the screen again if the character moved g_Map.SetDrawFlag(true); // Since we need to pick up items, we need to check for them just like exits, etc. g_Map.CheckForItem(curPosition.x, curPosition.y); // If we run into an NPC, we need to know so we can display dialog g_Map.CheckForNpc(curPosition.x, curPosition.y); //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // Now that we have monsters moving around we need to check to see if we // ran into them so we know when to attack. Notice that this takes no // parameters. This is because we do a loop inside that goes through all // of our party members and checks if they ran into the monster. g_Map.CheckForMonster(); //////////// *** NEW *** ////////// *** NEW *** ///////////// *** NEW *** //////////////////// // Set the previous position of the player g_Player.SetLastPosition(curPosition); // Here we check to see if the player moved into an exit. If so, exit! g_Map.CheckForExit(curPosition.x, curPosition.y); } }
void CController::InitKeyboardMouseListening() { //Input模块会自动把信息发送到Controller的单例来,因此这样就好了 CInput input; input.InitListener(); }
bool CPauseState::Input( CInput& _input ) { static bool ifPressedD = false; static bool ifPressedU = false; static bool ifPressedEnter_Paused = false; // Updates the reticle location based on the mouse pos. m_reticle.SetPosX(_input.GetMousePosX() - m_reticle.GetRect().GetWidth() * 0.5f); m_reticle.SetPosY(_input.GetMousePosY() - m_reticle.GetRect().GetHeight() * 0.5f); m_reticle.BuildGeometry(m_Renderer->GetScreenWidth(), m_Renderer->GetScreenHeight()); //Mouse Active over keybard if(_input.GetMousePosX() == m_PrevMousePosX && _input.GetMousePosY() == m_PrevMousePosY) { m_bMouseActive = false; } if(_input.GetMousePosX() != m_PrevMousePosX) { m_bMouseActive = true; m_PrevMousePosX = _input.GetMousePosX(); } if(_input.GetMousePosY() != m_PrevMousePosY) { m_bMouseActive = true; m_PrevMousePosY = _input.GetMousePosY(); } if (m_Timer > 0.5f) { static bool ifPressEsc = true; if(_input.IsEscapePressed() ) { if(!ifPressEsc) { m_bFadeOut = true; m_Esc = true; m_Choice = P_PLAY; ifPressEsc = true; /// AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUUNPAUSE); } } else ifPressEsc = false; } if (m_bFadeOut && m_FadeTimer >= 1.0f ) { switch(m_Choice) { case P_PLAY: { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUUNPAUSE); m_Game->GetStateManager()->PopState(); return true; } break; case P_OPTIONS: { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT); m_Game->GetStateManager()->PushState(OPTIONS_STATE); return true; } break; case P_EXIT: { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUACCEPT); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_ACCEPT); m_Game->GetStateManager()->ChangeState(MAINMENU_STATE); return true; } break; }; } //KEYBOARD INPUT FOR SELECTING BUTTONS---------------------------------------------------------------------- #pragma region Keyboard Input for Selecting Buttons if((_input.KeyDown(DIK_S) || _input.KeyDown(DIK_DOWN) || _input.GetController().GetControllerState().Gamepad.sThumbLY < - 8000 || _input.GetController().GetControllerState().Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_DOWN) && !m_bFadeOut ) { if(!ifPressedD) { m_Choice++; //m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].SetPosX((m_Game->GetScreenWidth() / 2.0f) - 150); //m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].SetPosY(m_Choice * 128.0f + 128.0f); //m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].BuildGeometry(); if(m_Choice == PAUSE_NUM_CHOICES) { m_Choice = P_PLAY; //m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].SetPosY((m_Game->GetScreenHeight() / 2.0f) - 160); //m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].BuildGeometry(); } ifPressedD = true; } } else ifPressedD = false; if((_input.KeyDown(DIK_W) || _input.KeyDown(DIK_UP) || abs(_input.GetController().GetControllerState().Gamepad.sThumbLY) > 8000 || _input.GetController().GetControllerState().Gamepad.wButtons & XINPUT_GAMEPAD_DPAD_UP) && !m_bFadeOut) { if(!ifPressedU) { m_Choice--; //m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].SetPosX((m_Game->GetScreenWidth() / 2.0f) - 150); //m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].SetPosY(m_Choice * 128.0f + 128.0f); //m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].BuildGeometry(); if(m_Choice < 0) { m_Choice = P_EXIT; //m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].SetPosY((m_Game->GetScreenHeight() / 2.0f) + 96.0f); //m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].BuildGeometry(); } ifPressedU = true; } } else ifPressedU = false; if(_input.KeyDown(DIK_RETURN) || (_input.GetController().GetControllerState().Gamepad.wButtons & XINPUT_GAMEPAD_A) ) { if(!ifPressedEnter_Paused) { m_bFadeOut = true; ifPressedEnter_Paused = true; } } else ifPressedEnter_Paused = false; if (m_Choice == P_PLAY && !m_Esc) { if (m_bSoundPlay) { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER); m_bSoundPlay = false; m_bSoundExit = true; m_bSoundOptions = true; } } if (m_Choice == P_OPTIONS) { if (m_bSoundExit) { /// AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER); m_bSoundPlay = true; m_bSoundExit = false; m_bSoundOptions = true; } } if (m_Choice == P_EXIT) { if (m_bSoundOptions) { // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_SFX_MENU_HOVER); m_bSoundPlay = true; m_bSoundExit = true; m_bSoundOptions = false; } } if (m_Choice == P_PLAY && !m_Esc) { m_bPlay = false; m_bOptions = true; m_bExit = true; } if (m_Choice == P_OPTIONS) { m_bPlay = true; m_bOptions = false; m_bExit = true; } if (m_Choice == P_EXIT) { m_bPlay = true; m_bOptions = true; m_bExit = false; } #pragma endregion //MOUSE INPUT FOR SELECTING BUTTONS------------------------------------------------------------------------- #pragma region Mouse Input for Selecting Buttons int _mouseX = _input.GetMousePosX(); int _mouseY = _input.GetMousePosY(); //PLAY BUTTON float _playWidth1 = m_PauseElements[PAUSE_RESUME_ELEMENTS].GetRect().GetWidth(); //256 float _playHeight1 = m_PauseElements[PAUSE_RESUME_ELEMENTS].GetRect().GetHeight(); //64 float _playPosX1 = m_PauseElements[PAUSE_RESUME_ELEMENTS].GetPosX(); //280 float _playPosY1 = m_PauseElements[PAUSE_RESUME_ELEMENTS].GetPosY(); //612 float _playCombinedX1 = _playPosX1 + _playWidth1; //536 float _playCombinedY1 = _playPosY1 + _playHeight1; //676 if (_mouseX >= _playPosX1 && _mouseX <= _playCombinedX1 && _mouseY <= _playCombinedY1 && _mouseY >= _playPosY1) { if (!m_bFadeOut) { if (m_bMouseActive) { m_Choice = P_PLAY; //m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].SetPosY(_playPosY1); //m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].BuildGeometry(); //if (m_bSoundPlay) //{ // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); // m_bSoundPlay = false; // m_bSoundExit = true; // m_bSoundOptions = true; //} } if (m_Timer > 0.5f) { if (_input.IsLeftClicked()) m_bFadeOut = true; } } } //OPTIONS BUTTON float _optionsWidth1 = m_PauseElements[PAUSE_OPTIONS_ELEMENTS].GetRect().GetWidth(); //256 float _optionsHeight1 = m_PauseElements[PAUSE_OPTIONS_ELEMENTS].GetRect().GetHeight(); //64 float _optionsPosX1 = m_PauseElements[PAUSE_OPTIONS_ELEMENTS].GetPosX(); //280 float _optionsPosY1 = m_PauseElements[PAUSE_OPTIONS_ELEMENTS].GetPosY(); //612 float _optionsCombinedX1 = _optionsPosX1 + _optionsWidth1; //536 float _optionsCombinedY1 = _optionsPosY1 + _optionsHeight1; //676 if (_mouseX >= _optionsPosX1 && _mouseX <= _optionsCombinedX1 && _mouseY <= _optionsCombinedY1 && _mouseY >= _optionsPosY1) { if(!m_bFadeOut) { if (m_bMouseActive) { m_Choice = P_OPTIONS; //m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].SetPosY(_optionsPosY1); //m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].BuildGeometry(); //if (m_bSoundOptions) //{ // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); // m_bSoundPlay = true; // m_bSoundExit = true; // m_bSoundOptions = false; //} } if (m_Timer > 0.5f) { if (_input.IsLeftClicked()) m_bFadeOut = true; } } } //EXIT BUTTON float _exitWidth1 = m_PauseElements[PAUSE_EXIT_ELEMENTS].GetRect().GetWidth(); //256 float _exitHeight1 = m_PauseElements[PAUSE_EXIT_ELEMENTS].GetRect().GetHeight(); //64 float _exitPosX1 = m_PauseElements[PAUSE_EXIT_ELEMENTS].GetPosX(); //280 float _exitPosY1 = m_PauseElements[PAUSE_EXIT_ELEMENTS].GetPosY(); //612 float _exitCombinedX1 = _exitPosX1 + _exitWidth1; //536 float _exitCombinedY1 = _exitPosY1 + _exitHeight1; //676 if (_mouseX >= _exitPosX1 && _mouseX <= _exitCombinedX1 && _mouseY <= _exitCombinedY1 && _mouseY >= _exitPosY1) { if(!m_bFadeOut) { if (m_bMouseActive) { m_bExit = false; m_Choice = P_EXIT; //m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].SetPosY(_exitPosY1); //m_PauseElements[PAUSE_HIGHLIGHTED_ELEMENTS].BuildGeometry(); //if (m_bSoundExit) //{ // AudioSystemWwise::GetInstance()->PostEvent(AK::EVENTS::PLAY_FX_2D_MENUMOVE_HOVER); // m_bSoundPlay = true; // m_bSoundExit = false; // m_bSoundOptions = true; //} } if (m_Timer > 0.5f) { if (_input.IsLeftClicked()) m_bFadeOut = true; } } } #pragma endregion return true; }
bool CInputs::ConfigureInputs(const GameInfo *game) { m_system->UngrabMouse(); // Print header and help message int gameFlags; if (game != NULL) { PrintHeader("Configure Inputs for %s", game->title); gameFlags = game->inputFlags; } else { PrintHeader("Configure Inputs"); gameFlags = GAME_INPUT_ALL; } PrintConfigureInputsHelp(); // Get all inputs to be configured vector<CInput*> toConfigure; vector<CInput*>::iterator it; for (it = m_inputs.begin(); it != m_inputs.end(); it++) { if ((*it)->IsConfigurable() && ((*it)->gameFlags & gameFlags)) toConfigure.push_back(*it); } // Remember current mappings for each input in case changes need to be undone later vector<string> oldMappings(toConfigure.size()); size_t index = 0; for (it = toConfigure.begin(); it != toConfigure.end(); it++) oldMappings[index++] = (*it)->GetMapping(); const char *groupLabel = NULL; bool cancelled = false; // Loop through all the inputs to be configured index = 0; while (index < toConfigure.size()) { // Get the current input CInput *input = toConfigure[index]; // If have moved to a new input group, print the group heading const char *itGroupLabel = input->GetInputGroup(); if (groupLabel == NULL || stricmp(groupLabel, itGroupLabel) != 0) { groupLabel = itGroupLabel; printf("%s:\n", groupLabel); } Redisplay: // Print the input label, current input mapping and available options if (index > 0) printf(" %s [%s]: Ret/c/s/a/r/Up/Down/b/h/q/Esc? ", input->label, input->GetMapping()); else printf(" %s [%s]: Ret/c/s/a/r/Down/h/b/q/Esc? ", input->label, input->GetMapping()); fflush(stdout); // required on terminals that use buffering // Loop until user has selected a valid option bool done = false; char mapping[50]; while (!done) { // Wait for input from user if (!m_system->ReadMapping(mapping, 50, false, READ_KEYBOARD|READ_MERGE, uiExit->GetMapping())) { // If user pressed aborted input, then undo all changes and finish configuration index = 0; for (it = toConfigure.begin(); it != toConfigure.end(); it++) { (*it)->SetMapping(oldMappings[index].c_str()); index++; } cancelled = true; goto Finish; } if (stricmp(mapping, "KEY_RETURN") == 0 || stricmp(mapping, "KEY_S") == 0) { // Set the input mapping printf("Setting... "); fflush(stdout); // required on terminals that use buffering if (input->Configure(false, uiExit->GetMapping())) { puts(input->GetMapping()); if (stricmp(mapping, "KEY_RETURN") == 0) index++; done = true; } else { puts("[Cancelled]"); goto Redisplay; } } else if (stricmp(mapping, "KEY_A") == 0) { // Append to the input mapping(s) printf("Appending... "); fflush(stdout); // required on terminals that use buffering if (input->Configure(true, uiExit->GetMapping())) puts(input->GetMapping()); else puts("[Cancelled]"); goto Redisplay; } else if (stricmp(mapping, "KEY_C") == 0) { // Clear the input mapping(s) input->SetMapping("NONE"); puts("Cleared"); goto Redisplay; } else if (stricmp(mapping, "KEY_R") == 0) { // Reset the input mapping(s) to the default input->ResetToDefaultMapping(); puts("Reset"); goto Redisplay; } else if (stricmp(mapping, "KEY_DOWN") == 0) { // Move forward to the next mapping puts(""); index++; done = true; } else if (stricmp(mapping, "KEY_UP") == 0) { // Move back to the previous mapping if (index > 0) { puts(""); index--; done = true; } } else if (stricmp(mapping, "KEY_HOME") == 0) { // Move to first input puts(""); index = 0; done = true; } else if (stricmp(mapping, "KEY_B") == 0) { // Calibrate joysticks printf("\n\n"); CalibrateJoysticks(); puts(""); goto Redisplay; } else if (stricmp(mapping, "KEY_I") == 0) { // Print info about input system printf("\n\n"); m_system->PrintSettings(); goto Redisplay; } else if (stricmp(mapping, "KEY_H") == 0) { // Print the help message again printf("\n\n"); PrintConfigureInputsHelp(); goto Redisplay; } else if (stricmp(mapping, "KEY_Q") == 0) goto Finish; } } Finish: printf("\n\n"); m_system->GrabMouse(); return !cancelled; }