void changeState(ChopperDrop* game, State newState) { deleteCurrentState(game); game->currentState = newState; switch(game->currentState) { case MAIN_MENU_STATE: game->state = newMainMenuState(); break; case GAME_STATE: game->state = newGameState(); break; case GAME_OVER_STATE: game->state = newGameOverState(); break; case GAME_WON_STATE: game->state = newGameWonState(); break; default: break; } game->draw = 1; }
void stopChopperDrop(ChopperDrop* game) { // unsubscribe devices unsubscribeKeyboard(); unsubscribeTimer(); unsubscribeMouse(); deleteBitmap(game->mouseCursor); deleteCurrentState(game); disableMouse(); cleanBuffer(); deleteMouse(); deleteTimer(game->timer); deleteDate(game->date); free(game); }
void CreditsState::step() { IMGUI& imgui = IMGUI::getSingleton(); imgui.doCursor(); imgui.doImage(GEN_ID, Vector2(400.0, 300.0), "background"); imgui.doOverlay(GEN_ID, Vector2(0.0, 0.0), Vector2(800.0, 600.0)); const float xPosition = 50; imgui.doText(GEN_ID, Vector2(xPosition, mYPosition), TextManager::getSingleton()->getString(TextManager::CRD_PROGRAMMERS)); imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+30), "Daniel Knobe"); imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+60), " (daniel-knobe(at)web.de)", TF_SMALL_FONT); imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+85), "Jonathan Sieber"); imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+115), " (jonathan_sieber(at)yahoo.de)", TF_SMALL_FONT); imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+140), "Sven Rech"); imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+170), " (svenrech(at)gmx.de)", TF_SMALL_FONT); imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+195), "Erik Schultheis"); imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+225), " (erik-schutlheis(at)freenet.de)", TF_SMALL_FONT); imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+255), TextManager::getSingleton()->getString(TextManager::CRD_GRAPHICS)); imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+285), "Silvio Mummert"); imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+315), " (mummertathome(at)t-online.de)", TF_SMALL_FONT); imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+340), "Richard Bertrand"); imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+370), " (ricbertrand(at)hotmail.com)", TF_SMALL_FONT); imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+415), TextManager::getSingleton()->getString(TextManager::CRD_THX)); imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+445), "Daniel Skoraszewsky"); imgui.doText(GEN_ID, Vector2(xPosition, mYPosition+475), " (skoraszewsky(at)t-online.de)", TF_SMALL_FONT); if (mYPosition > 20) mYPosition -= 2.5; if (imgui.doButton(GEN_ID, Vector2(400.0, 560.0), TextManager::getSingleton()->getString(TextManager::LBL_OK))) { deleteCurrentState(); setCurrentState(new MainMenuState()); return; } }
void ReplayMenuState::step() { IMGUI& imgui = IMGUI::getSingleton(); if (mReplaying) { RenderManager* rmanager = &RenderManager::getSingleton(); if(mReplayRecorder->getPacketType()==ID_INPUT) { mReplayMatch->setPlayersInput(mReplayRecorder->getInput()); mReplayMatch->step(); } presentGame(*mReplayMatch); rmanager->setBlobColor(LEFT_PLAYER, mLeftPlayer.getColor()); rmanager->setBlobColor(RIGHT_PLAYER, mRightPlayer.getColor()); PlayerSide side = mReplayMatch->winningPlayer(); if (side != NO_PLAYER) { std::stringstream tmp; if(side == LEFT_PLAYER) tmp << mReplayRecorder->getPlayerName(LEFT_PLAYER); else tmp << mReplayRecorder->getPlayerName(RIGHT_PLAYER); imgui.doOverlay(GEN_ID, Vector2(200, 150), Vector2(650, 450)); imgui.doImage(GEN_ID, Vector2(200, 250), "gfx/pokal.bmp"); imgui.doText(GEN_ID, Vector2(274, 250), tmp.str()); imgui.doText(GEN_ID, Vector2(274, 300), TextManager::getSingleton()->getString(TextManager::GAME_WIN)); if (imgui.doButton(GEN_ID, Vector2(290, 350), TextManager::getSingleton()->getString(TextManager::LBL_OK))) { mReplaying = false; delete mReplayMatch; delete mReplayRecorder; imgui.resetSelection(); } if (imgui.doButton(GEN_ID, Vector2(400, 350), TextManager::getSingleton()->getString(TextManager::RP_SHOW_AGAIN))) { delete mReplayMatch; delete mReplayRecorder; loadCurrentReplay(); imgui.resetSelection(); } imgui.doCursor(); } else if ((InputManager::getSingleton()->exit()) || (mReplayRecorder->endOfFile())) { mReplaying = false; delete mReplayMatch; delete mReplayRecorder; imgui.resetSelection(); } } else { imgui.doCursor(); imgui.doImage(GEN_ID, Vector2(400.0, 300.0), "background"); imgui.doOverlay(GEN_ID, Vector2(0.0, 0.0), Vector2(800.0, 600.0)); if (imgui.doButton(GEN_ID, Vector2(224.0, 10.0), TextManager::getSingleton()->getString(TextManager::RP_PLAY)) && mSelectedReplay != -1) { loadCurrentReplay(); imgui.resetSelection(); } else if (imgui.doButton(GEN_ID, Vector2(424.0, 10.0), TextManager::getSingleton()->getString(TextManager::LBL_CANCEL))) { deleteCurrentState(); setCurrentState(new MainMenuState()); } else imgui.doSelectbox(GEN_ID, Vector2(34.0, 50.0), Vector2(634.0, 550.0), mReplayFiles, mSelectedReplay); if (imgui.doButton(GEN_ID, Vector2(644.0, 60.0), TextManager::getSingleton()->getString(TextManager::RP_DELETE))) { if (!mReplayFiles.empty()) if (PHYSFS_delete(std::string("replays/" + mReplayFiles[mSelectedReplay] + ".bvr").c_str())) { mReplayFiles.erase(mReplayFiles.begin()+mSelectedReplay); if (mSelectedReplay >= mReplayFiles.size()) mSelectedReplay = mReplayFiles.size()-1; } } if (mChecksumError) { imgui.doInactiveMode(false); imgui.doOverlay(GEN_ID, Vector2(210, 180), Vector2(650, 370)); imgui.doText(GEN_ID, Vector2(250, 200), TextManager::getSingleton()->getString(TextManager::RP_CHECKSUM)); imgui.doText(GEN_ID, Vector2(250, 250), TextManager::getSingleton()->getString(TextManager::RP_FILE_CORRUPT)); if (imgui.doButton(GEN_ID, Vector2(400, 330), TextManager::getSingleton()->getString(TextManager::LBL_OK))) { mChecksumError = false; } else { imgui.doInactiveMode(true); } } } }
void MainMenuState::step() { RenderManager::getSingleton().drawGame(false); IMGUI& imgui = IMGUI::getSingleton(); imgui.doCursor(); imgui.doImage(GEN_ID, Vector2(400.0, 300.0), "background"); imgui.doOverlay(GEN_ID, Vector2(0.0, 0.0), Vector2(800.0, 600.0)); imgui.doImage(GEN_ID, Vector2(250.0, 210.0), "gfx/titel.bmp"); if (imgui.doButton(GEN_ID, Vector2(434, 350.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_ONLINE))) { deleteCurrentState(); setCurrentState(new OnlineSearchState()); } if (imgui.doButton(GEN_ID, Vector2(434, 380.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_LAN))) { deleteCurrentState(); setCurrentState(new LANSearchState()); } if (imgui.doButton(GEN_ID, Vector2(434.0, 410.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_START))) { try { deleteCurrentState(); setCurrentState(new LocalGameState()); } catch (ScriptException except) { FILE* file = fopen("lualog.txt", "wb"); fprintf(file, "Lua Error: %s\n", except.luaerror.c_str()); fclose(file); } } if (imgui.doButton(GEN_ID, Vector2(434.0, 440.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_OPTIONS))) { deleteCurrentState(); setCurrentState(new OptionState()); } if (imgui.doButton(GEN_ID, Vector2(434.0, 470.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_REPLAY))) { deleteCurrentState(); setCurrentState(new ReplayMenuState()); } if (imgui.doButton(GEN_ID, Vector2(434.0, 500.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_CREDITS))) { deleteCurrentState(); setCurrentState(new CreditsState()); } if (imgui.doButton(GEN_ID, Vector2(434.0, 530.0), TextManager::getSingleton()->getString(TextManager::MNU_LABEL_EXIT))) { RenderManager::getSingleton().deinit(); SoundManager::getSingleton().deinit(); deleteCurrentState(); SDL_Quit(); exit(0); } }