int EndGameMenu::Run() { this->mSets[this->mCurrentSet].AddSetToRenderer(this->mGe); this->mIsRunning = true; bool IsClicked = false; bool mousePressed = false; GUIEvent *returnEvent = NULL; CursorControl cc; cc.SetVisibility(true); while(this->mGe->GetKeyListener()->IsClicked(1)) { } while(this->mIsRunning) { /*If mouse is clicked*/ if(IsClicked && !mousePressed) { mousePressed = true; } this->mGe->Update(); IsClicked = this->mGe->GetKeyListener()->IsClicked(1); D3DXVECTOR2 mousePos; mousePos = this->mGe->GetKeyListener()->GetMousePosition(); returnEvent = this->mSets[this->mCurrentSet].UpdateAndCheckCollision(mousePos.x, mousePos.y, IsClicked, this->mGe); if(returnEvent != NULL) { if(returnEvent->GetEventMessage() == "ChangeSetEvent") { ChangeSetEvent* temp = (ChangeSetEvent*)returnEvent; int whatSet = temp->GetSet(); if(whatSet == QUITGAME) { this->mSets[this->mCurrentSet].RemoveSetFromRenderer(this->mGe); this->mIsRunning = false; return QUITGAME; } if(whatSet == PLAYAGAIN) { this->mSets[this->mCurrentSet].RemoveSetFromRenderer(this->mGe); this->mIsRunning = false; return PLAYAGAIN; } } } if(!IsClicked && mousePressed) { mousePressed = false; } if(!this->mGe->isRunning()) this->mIsRunning = false; } cc.SetVisibility(false); return true; }
bool InGameMenu::Run() { this->mSets[IGNBACKGROUND].AddSetToRenderer(this->mGe); this->mSets[INGAMEMENU].AddSetToRenderer(this->mGe); this->mIsRunning = true; bool IsClicked = false; bool mousePressed = false; GUIEvent *returnEvent = NULL; this->mGe->GetKeyListener()->KeyUp(VK_ESCAPE); CursorControl cc; cc.SetVisibility(true); while(this->mIsRunning) { /*If mouse is clicked*/ if(IsClicked && !mousePressed) { mousePressed = true; } this->mGe->Update(); IsClicked = this->mGe->GetKeyListener()->IsClicked(1); D3DXVECTOR2 mousePos; mousePos = this->mGe->GetKeyListener()->GetMousePosition(); returnEvent = this->mSets[this->mCurrentSet].UpdateAndCheckCollision(mousePos.x, mousePos.y, IsClicked, this->mGe); if(returnEvent == NULL) returnEvent = this->mSets[this->mSubSet].UpdateAndCheckCollision(mousePos.x, mousePos.y, IsClicked, this->mGe); if(returnEvent != NULL) { if(returnEvent->GetEventMessage() == "ChangeSetEvent") { ChangeSetEvent* temp = (ChangeSetEvent*)returnEvent; int whatSet = temp->GetSet(); if(whatSet == IGNQUIT) { this->mSets[this->mCurrentSet].RemoveSetFromRenderer(this->mGe); this->mSets[this->mSubSet].RemoveSetFromRenderer(this->mGe); this->mIsRunning = false; return false; } if(whatSet == IGNRESUME) { this->mSets[this->mCurrentSet].RemoveSetFromRenderer(this->mGe); this->mSets[this->mSubSet].RemoveSetFromRenderer(this->mGe); this->mIsRunning = false; return true; } if(whatSet == IGNOPTIONS) { this->mSets[this->mCurrentSet].RemoveSetFromRenderer(this->mGe); this->mSets[this->mSubSet].RemoveSetFromRenderer(this->mGe); this->mCurrentSet = IGNOPTIONS; this->mSets[this->mCurrentSet].AddSetToRenderer(this->mGe); this->mSets[this->mSubSet].AddSetToRenderer(this->mGe); } if(whatSet == INGAMEMENU) { this->mSets[this->mCurrentSet].RemoveSetFromRenderer(this->mGe); this->mSets[this->mSubSet].RemoveSetFromRenderer(this->mGe); this->mCurrentSet = INGAMEMENU; this->mSets[this->mCurrentSet].AddSetToRenderer(this->mGe); } } else if(returnEvent->GetEventMessage() == "ChangeSubSetEvent") { this->mSets[this->mSubSet].RemoveSetFromRenderer(this->mGe); ChangeSubSetEvent* tempReturnEvent = (ChangeSubSetEvent*)returnEvent; int tempEventSet = tempReturnEvent->GetSet(); if(tempEventSet == IGNOPTIONS_SOUND) { CheckBox* temp = this->mSets[IGNOPTIONS_SOUND].GetCheckBox("Sound"); temp->SetChecked(GameOptions::isPlaying); } int set = tempReturnEvent->GetSet(); this->mSubSet = set; this->mSets[this->mSubSet].AddSetToRenderer(this->mGe); int menuChangeTime = 50; while(menuChangeTime > 0) menuChangeTime -= (int)this->mGe->Update(); } else if(returnEvent->GetEventMessage() == "ChangeOptionEvent") { ChangeOptionEvent* tempReturnEvent = (ChangeOptionEvent*)returnEvent; if(tempReturnEvent->GetOption() == "Sound") { if(tempReturnEvent->GetValue() == "true") { GameOptions::songPlaying->Unmute(); GameOptions::isPlaying = true; } else { GameOptions::songPlaying->Mute(); GameOptions::isPlaying = false; } } } } if(!IsClicked && mousePressed) { mousePressed = false; } if(!this->mGe->isRunning()) this->mIsRunning = false; } cc.SetVisibility(false); return true; }