void cullObjects(){ for (unsigned int i = 0; i < GameObjects.dead_objects.size(); i++) { dynamic_cast<RenderComponent*>(GameObjects.dead_objects[i]->GetComponent(COMPONENT_RENDER))->objRef->setVisible(false); } for (unsigned int i = 0; i < GameObjects.dead_feathers.size(); i++) { dynamic_cast<RenderComponent*>(GameObjects.dead_feathers[i]->GetComponent(COMPONENT_RENDER))->objRef->setVisible(false); } for (unsigned int i = 0; i < GameObjects.dead_minions.size(); i++) { dynamic_cast<RenderComponent*>(GameObjects.dead_minions[i]->GetComponent(COMPONENT_RENDER))->objRef->setVisible(false); } //SCREEN WIDTH SCREEN HEIGHT, coordinates received from renMan seem to be offset so width and height are currently set larger than they should be. RenderManager* renMan = RenderManager::getRenderManager(); int width = SCREEN_WIDTH + (SCREEN_WIDTH/2); int height = SCREEN_HEIGHT * 2; int left, right, top, bot; left = right = top = bot = 0; for (unsigned int i = 0; i < GameObjects.alive_objects.size(); i++) { left = right = top = bot = 0; SDLRenderObject* obj = dynamic_cast<RenderComponent*>(GameObjects.alive_objects[i]->GetComponent(COMPONENT_RENDER))->objRef; renMan->worldCoordToWindowCoord(left, top, obj->posX, obj->posY, obj->posZ); renMan->worldCoordToWindowCoord(right, bot, (obj->posX + obj->width), (obj->posY + obj->height), obj->posZ); if ((right < -width / 2) || (left > width) || (top > height / 2) || (bot < -height / 2)){ //if object is out of screen bounds, dont draw. obj->setVisible(false); } else{ obj->setVisible(true); } } }
void PlayerLogicComponent::playDeathSFX(int playerClass, uint64_t deadPlayerID){ //Need to pass a reference to the GameObject* associated with player who was killed GameObject* deadPlayer = GameObjects.GetGameObject(deadPlayerID); PlayerRenderComponent* rendComp = dynamic_cast<PlayerRenderComponent*>(deadPlayer->GetComponent(COMPONENT_RENDER)); RenderManager* renderMan = RenderManager::getRenderManager(); if (renderMan->isObjOnScreen(rendComp->objRef)){ AudioManager* audioMan = AudioManager::getAudioInstance(); switch (playerClass){ case CLASS_CHICKEN: audioMan->playByName("chickensfx.ogg"); break; case CLASS_PEACOCK: audioMan->playByName("peacocksfx.ogg"); break; case CLASS_FLAMINGO: audioMan->playByName("flamingosfx.ogg"); break; case CLASS_QUAIL: audioMan->playByName("quailsfx.ogg"); break; case CLASS_TURKEY: audioMan->playByName("turkeysfx.ogg"); break; case CLASS_EAGLE: //Unimplemented //audioMan->playByName("eaglesfx.ogg"); break; } } }
void MainMenu::createButtons() { int w, h; float x, y; RenderManager* renderMan = RenderManager::getRenderManager(); renderMan->getWindowSize(&w, &h); // play button renderMan->windowCoordToWorldCoord(x, y, (int)(w*(0.91f)), (int)(h*(0.75f))); playButt = bFactory.Spawn(3521, x, y, 19, 55.0f, 75.0f, 0.3f); ButtonRenderComponent* playRender = dynamic_cast<ButtonRenderComponent*>(playButt->GetComponent(COMPONENT_RENDER)); playRender->addSecondSprite(31); GameObjects.AddObject(playButt); // quit button renderMan->windowCoordToWorldCoord(x, y, (int)(w*(0.91f)), (int)(h*(0.9f))); quitButt = bFactory.Spawn(3522, x, y, 22, 55.0f, 75.0f, 0.3f); ButtonRenderComponent* quitRender = dynamic_cast<ButtonRenderComponent*>(quitButt->GetComponent(COMPONENT_RENDER)); quitRender->addSecondSprite(32); GameObjects.AddObject(quitButt); //configure buttons to work with controller ButtonLogicComponent* playLogic = dynamic_cast<ButtonLogicComponent*>(playButt->GetComponent(COMPONENT_LOGIC)); playLogic->setNavButtons(NULL, quitButt, NULL, NULL); playLogic->selectButton(); ButtonLogicComponent* quitLogic = dynamic_cast<ButtonLogicComponent*>(quitButt->GetComponent(COMPONENT_LOGIC)); quitLogic->setNavButtons(playButt, NULL, NULL, NULL); }
PlayerRenderComponent::PlayerRenderComponent(GameObject* player, function_t func) { gameObjectRef = player; gameObjectRef->AddComponent(COMPONENT_RENDER, this); RenderComponent::RenderComponent(); SceneManager* sceneMan = SceneManager::GetSceneManager(); RenderManager* renderMan = RenderManager::getRenderManager(); std::string playerName = NetworkManager::sInstance->getLobbyMap().find(gameObjectRef->ID)->second; SDLRenderObject * name = sceneMan->InstantiateBlankObject(sceneMan->findLayer("layer2"), 0, 0, 0, 0); int r, g, b; if (gameObjectRef->posY < 0){ r = 200, g=0, b = 200; } else r = 255, g = 255, b=0; name->setResourceObject(renderMan->renderText(playerName.c_str(), r, g, b, 20, "BowlbyOneSC-Regular")); //name->setParent(base); name->setPos(0, -60); allObjs["name"] = name; if (allObjs["box"])allObjs["box"]->visible = true; //pick random egg resource. currently hardcoded to 74 SDLRenderObject* egg = sceneMan->InstantiateObject(sceneMan->findLayer("layer2"), 74, 0, 0); egg->visible = false; egg->setParent(allObjs["base"]); allObjs["egg"] = egg; //assign animations func(&objRef, allObjs, animations); }
void Lobby::updateLobby(){ RenderManager* renderMan = RenderManager::getRenderManager(); GamerServices::sInstance->Update(); NetworkManager::sInstance->ProcessIncomingPackets(); if (playersInLobby) playersInLobby->setResourceObject(renderMan->renderText(std::to_string(numPlayers).c_str(), 255, 0, 0, 50, "VT323-Regular")); SceneManager::GetSceneManager()->AssembleScene(); }
void PowerShieldLogicComponent::playShieldCollisionSFX() { //Need shield object PowerShieldRenderComponent* rendComp = dynamic_cast<PowerShieldRenderComponent*>(gameObjectRef->GetComponent(COMPONENT_RENDER)); RenderManager* renderMan = RenderManager::getRenderManager(); if (renderMan->isObjOnScreen(rendComp->objRef)) { AudioManager* audioMan = AudioManager::getAudioInstance(); audioMan->playByName("chickenshieldsfx.ogg"); } }
nau::render::IRenderer * Nau::getRenderer(void) { RenderManager *r = getRenderManager(); if (r) return r->getRenderer(); else return NULL; }
void main(int argc, char* argv[]) { glutInit(&argc, argv); gRenderManager.StartUp(); glutMainLoop(); gRenderManager.ShutDown(); }
bool ActionSetPartialScreen::execute(ZVision *engine) { RenderManager *renderManager = engine->getRenderManager(); if (_backgroundColor > 0) { renderManager->clearWorkingWindowTo555Color(_backgroundColor); } renderManager->renderImageToScreen(_fileName, _x, _y); return true; }
void CreateGrid2() { int size = 10; int size_l = (2 * size + 1) * 2; int size_v = size_l * 2; VERTEX3D *v = (VERTEX3D*)malloc(sizeof(VERTEX3D)*size_v); LINE* l = (LINE*)malloc(sizeof(LINE)*(size_l)); int current_pos = -size; for (int i = 0; i < size_l / 2; i++){ v[i * 2].x = -size; v[i * 2].y = 0; v[i * 2].z = current_pos; v[i * 2 + 1].x = size; v[i * 2 + 1].y = 0; v[i * 2 + 1].z = current_pos; l[i].i = i * 2; l[i].j = i * 2 + 1; current_pos++; } current_pos = -size; for (int i = size_l / 2; i < size_l; i++){ v[i * 2].x = current_pos; v[i * 2].y = 0; v[i * 2].z = -size; v[i * 2 + 1].x = current_pos; v[i * 2 + 1].y = 0; v[i * 2 + 1].z = size; l[i].i = i * 2; l[i].j = i * 2 + 1; current_pos++; } Object3D *line = new Object3D(v, l, size_v, size_l); RenderManager *rmg = RenderManager::getInstance(); rmg->RegisterObject(line); free(v); free(l); }
void Lobby::createButtons(){ RenderManager* renderMan = RenderManager::getRenderManager(); int w, h; float x, y; renderMan->getWindowSize(&w, &h); // ready button renderMan->windowCoordToWorldCoord(x, y, (int)(w*(7/8.0f)), (int)(h*(48/100.0f))); readyButt = bFactory.Spawn(buttonID++, x, y, 25, 75.0f, 75.0f, 0.75f); GameObjects.AddObject(readyButt); // back button }
Texture2D* TexturePool::GetTexture(const string& inTextureName) { // Find the texture in the pool map<string, PooledTexture>::iterator it = pooledTextures.find(inTextureName); if(it!= pooledTextures.end()) { // If the texture requested exists in the pool, increment the ref count // and return a reference to the pooled texture; it->second.refCount++; return it->second.texResource; } else { // Check if the texture exists const string filepath = gFileManager.FindFile(inTextureName.c_str(), gEngineSettings.GetString("TexturesDirectoryPath", "Paths")); if(filepath.length() > 0) { // Create a new pooled texture and return it PooledTexture newTexture; newTexture.texResource = gRenderAPI->CreateTexture2DFromFile(inTextureName.c_str()); pooledTextures[inTextureName] = newTexture; return newTexture.texResource; } else { // Return the default texture return gRenderManager.GetDefaultTexture(); } } }
void Particles::updateRender(RenderManager& theRenderManager) { for(auto it = getParticlesBegin(); it != getParticlesEnd(); it++) { mpe::Vec2 anPosition = it->getPosition(); mpe::TextRect anTexRect = it->getTextRect(); mpe::Color anColor = it->getColor(); sf::Transform anTransform; Id anLayerID = getParticleLayer(*it); anTransform.translate(anPosition.getX() * getXFactor(), anPosition.getY() * getYFactor()); anTransform.rotate(it->getAngle()); anTransform.scale(it->getSize(), it->getSize()); sf::Vector2f anPositions[4]; anPositions[0] = anTransform.transformPoint(sf::Vector2f(-(anTexRect.width / 2), -(anTexRect.height / 2))); anPositions[1] = anTransform.transformPoint(sf::Vector2f( (anTexRect.width / 2), -(anTexRect.height / 2))); anPositions[2] = anTransform.transformPoint(sf::Vector2f( (anTexRect.width / 2), (anTexRect.height / 2))); anPositions[3] = anTransform.transformPoint(sf::Vector2f(-(anTexRect.width / 2), (anTexRect.height / 2))); sf::Vector2f anTexCoords[4]; anTexCoords[0] = sf::Vector2f(anTexRect.x, anTexRect.y); anTexCoords[1] = sf::Vector2f(anTexRect.x + anTexRect.width - 1, anTexRect.y); anTexCoords[2] = sf::Vector2f(anTexRect.x + anTexRect.width - 1, anTexRect.y + anTexRect.height - 1); anTexCoords[3] = sf::Vector2f(anTexRect.x, anTexRect.y + anTexRect.height - 1); for (int i = 0; i < 4; i++) { theRenderManager.addVertex(anLayerID, sf::Vertex(anPositions[i], sf::Color(anColor.r, anColor.g, anColor.b, anColor.a) , anTexCoords[i])); } } }
void GameSession::LoadHUD(GameObject* player, SystemUIObjectQueue queue){ //initialize HUD info for the player. Should only be called once SceneManager* sceneMan = SceneManager::GetSceneManager(); RenderManager* renderMan = RenderManager::getRenderManager(); //SystemUIObjectQueue queue; UIObjectFactory HUDFactory; renderMan->setBackground("Space-Muscle-Beach__0011_Sky.png"); std::vector<UIObject*> UIObjs; //add the birdseed reference to player logic UIObject* birdseedMeter = HUDFactory.Spawn(BIRDSEED_BAR, 30, 30); UIObjs.push_back(birdseedMeter); queue.AddObject(birdseedMeter); UIObject* birdseedShell = HUDFactory.Spawn(BIRDSEED_SHELL, 30, 30); UIObjs.push_back(birdseedShell); queue.AddObject(birdseedShell); PlayerLogicComponent* playerLogic = dynamic_cast<PlayerLogicComponent*>(player->GetComponent(COMPONENT_LOGIC)); PlayerUIComponent* playerUI = dynamic_cast<PlayerUIComponent*>(player->GetComponent(COMPONENT_UI)); playerUI->birdseedHUD = dynamic_cast<UIRenderComponent*>(birdseedMeter->GetComponent(COMPONENT_RENDER))->objRef; playerUI->defaultRect = playerUI->birdseedHUD->renderRect; //add a timer to top of screen UIObject* countdownTimer = HUDFactory.Spawn(TIMER, SCREEN_WIDTH - 200, 30); UIObjs.push_back(countdownTimer); queue.AddObject(countdownTimer); playerUI->timerHUD = dynamic_cast<UIRenderComponent*>(countdownTimer->GetComponent(COMPONENT_RENDER))->objRef; PlayerRenderComponent* playerRender = dynamic_cast<PlayerRenderComponent*>(player->GetComponent(COMPONENT_RENDER)); //add ui components to show player kills std::vector<std::pair<SDLRenderObject*, clock_t>> killHUD; for (int i = 0; i < 5; i++){ UIObject* currKillHUD = HUDFactory.Spawn(KILL_NOTIFICATION,SCREEN_WIDTH-250,200+i*30); SDLRenderObject* currKillObj = dynamic_cast<UIRenderComponent*>(currKillHUD->GetComponent(COMPONENT_RENDER))->objRef; killHUD.push_back(std::pair<SDLRenderObject*, clock_t>(currKillObj, clock())); UIObjs.push_back(currKillHUD); } playerUI->killHUD = killHUD; playerUI->UIObjs = UIObjs; }
void LobbyMenu::createSlots(){ RenderManager* renderMan = RenderManager::getRenderManager(); GameObject* slot, *readySlot; ButtonRenderComponent* br; int w, h; float topH, bottH, offset; float x, y; renderMan->getWindowSize(&w, &h); // height for the slots on the top half topH = h * (1 / 10.0f); // height for the slots on the bottom half bottH = h * (9 / 10.0f); // finding the offset of the slots offset = w * (1 / 6.0f); for (int i = 0; i < 8; ++i){ if (i % 2){ h = (int)bottH; } else { h = (int)topH; offset += w * (1 / 8.0f); } renderMan->windowCoordToWorldCoord(x, y, (int)offset, h); // ready slots //readySlot = bFactory.Spawn(buttonID++, x, y, 28); readySlot = bFactory.Spawn(buttonID++, x, y-14, 28, 0, 0, 0.3, -1); br = dynamic_cast<ButtonRenderComponent*>(readySlot->GetComponent(COMPONENT_RENDER)); br->addSecondSprite(30); readySlots.push_back(readySlot); GameObjects.AddObject(readySlot); // slots //slot = bFactory.Spawn(buttonID++, x, y, 28); slot = bFactory.Spawn(buttonID++, x, y-14, 28, 0, 0, 0.3, -1); br = dynamic_cast<ButtonRenderComponent*>(slot->GetComponent(COMPONENT_RENDER)); br->changeLayer("layer2"); slots.push_back(slot); GameObjects.AddObject(slot); } }
void GameManager::_init(GameEngine *engine) { // save the game engine mEngine = engine; // create the log mLog = mEngine->getLogManager()->createLog("GameManager.log"); mLog->logMessage("GAMEMANAGER: Initialising game manager"); // create the scene manager mSceneMan = new SceneManager(); // Register listeners // * Render events RenderManager* renderMan = mEngine->getRenderManager(); renderMan->addWindowEventListener(this); renderMan->addRenderListener(this); // * Input events InputManager* inputMan = mEngine->getInputManager(); inputMan->addMouseListener(this); inputMan->addKeyListener(this); inputMan->addJoystickListener(this); }
void main(int argc, char * argv[]){ glutInit(&argc, argv); Vector3D *v1 = new Vector3D(2, 3, 5); Vector3D *v2 = new Vector3D(4, 2, 1); printf("Dot product: %f\n", v1->dotProduct(*v2)); printf("Magnitude v1: %f\n", v1->magnitude()); printf("Magnitude v2: %f\n", v2->magnitude()); printf("Angle between: %f\n", v1->theta(*v2)); VERTEX3D v[] = { { 0, 0, 0 }, { 1, 0, 0 }, { 0, 1, 0 } }; LINE l[] = { { 0, 1 }, { 1, 2 }, { 0, 2 } }; //Step 1: Initialize GLUT glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(800, 600); //Step 2: Create window mainWindow = glutCreateWindow("3D Solar System"); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); renderWindow(); Object3D *cube = new Object3D(v, VECTOR_SIZE(v)); Object3D *line = new Object3D(v, l, VECTOR_SIZE(v), VECTOR_SIZE(l)); RenderManager *rmg = RenderManager::getInstance(); rmg->RegisterObject(cube); rmg->RegisterObject(line); //Step 3: Handlers Functions glutDisplayFunc(Display); glutReshapeFunc(Reshape); glutIdleFunc(Display); glutKeyboardFunc(keyPressed); // Tell GLUT to use the method "keyPressed" for key presses //glutKeyboardFunc(keyUp); glutMainLoop(); }
void Game::Draw() { // clear the back buffer ClearScreen(); RenderManager* pRender = RenderManager::Instance(); pRender->Begin(); // Draw the background pRender->DrawSprite(m_backgroundTexture, SCREEN_WIDTH * 0.5f, SCREEN_HEIGHT * 0.5f, SCREEN_WIDTH, SCREEN_HEIGHT); // Draw mouse texture pRender->DrawSprite(m_mouseTexture, m_v2MousePos.x, m_v2MousePos.y); // Draw info text char buffer[512]; sprintf_s(buffer, 512, "Enemies within range of the mouse turn red.\nThis is linearly checking the distance to every enemy which is slow!\n(The distance check has been artificially slowed down in this project to make this even more obvious)\nA Quadtree would reduce the number of distance checks and would make this a lot faster.\nFPS: %.2f", m_fFPS); pRender->DrawText(m_font, buffer, 50, 30); // Draw enemies for(int i = 0; i < m_EnemyCount; ++i) { m_apEnemyList[i]->Draw(m_spritebatch); } gameTree->draw(); pRender->End(); }
bool kore::IndexedBuffer::uploadData(uint offset, uint sizeInBytes, GLvoid* data) { if (_handle == KORE_GLUINT_HANDLE_INVALID) { Log::getInstance()->write("[ERROR] Use IndexedBuffer::create" " before trying to upload data"); return false; } RenderManager* renderMgr = RenderManager::getInstance(); GLerror::gl_ErrorCheckStart(); renderMgr->bindBufferBase(_bufferTarget, 0, _handle); glBufferSubData(_bufferTarget, offset, sizeInBytes, data); bool success = GLerror::gl_ErrorCheckFinish("IndexedBuffer::uploadData"); if (!success) { Log::getInstance()->write("[ERROR] Failed to upload buffer Data"); return false; } return true; }
void CreateGrid(){ int size = 5; int size_l = (2 * size + 1) * 2; int size_v = size_l * 2; LINE3D* l = (LINE3D*)malloc(sizeof(LINE3D)*size_l); int current_pos = -size; for (int i = 0; i < size_l / 2; i++){ l[i].v1.x = -size; l[i].v1.y = 0; l[i].v1.z = current_pos; l[i].v2.x = size; l[i].v2.y = 0; l[i].v2.z = current_pos; current_pos++; } current_pos = -size; for (int i = size_l / 2; i < size_l; i++){ l[i].v1.x = current_pos; l[i].v1.y = 0; l[i].v1.z = -size; l[i].v2.x = current_pos; l[i].v2.y = 0; l[i].v2.z = size; current_pos++; } Object3D *line = new Object3D(l, size_l); RenderManager *rmg = RenderManager::getInstance(); rmg->RegisterObject(line); free(l); }
void ResultScreen::DrawStatImage(Rect rect) { RenderHelper *helper = RenderHelper::Instance(); RenderManager *manager = RenderManager::Instance(); for(uint32 i = 0; i < testData.GetItemCount(); ++i) { FpsStatItem item = testData.GetItem(i); Rect curRect = testData.TranslateRect(item.rect, rect); for(uint32 j = 0; j < SECTORS_COUNT; j++) { manager->SetColor(SettingsManager::Instance()->GetColorByFps(item.avFps[j])); Polygon2 curSector; curSector.AddPoint(curRect.GetCenter()); curSector.AddPoint(GetVecInRect(curRect, DegToRad((SECTORS_COUNT - j) * 45.f - 22.5f))); curSector.AddPoint(GetVecInRect(curRect, DegToRad((SECTORS_COUNT - j) * 45.f))); curSector.AddPoint(GetVecInRect(curRect, DegToRad((SECTORS_COUNT - j) * 45.f + 22.5f))); helper->FillPolygon(curSector); manager->SetColor(Color::Black()); helper->DrawPolygon(curSector, true); } } }
void LobbyMenu::createButtons(){ RenderManager* renderMan = RenderManager::getRenderManager(); int w, h; float x, y; renderMan->getWindowSize(&w, &h); // ready button renderMan->windowCoordToWorldCoord(x, y, (int)(w*(0.9f)), (int)(h*(90 / 100.0))); readyButt = bFactory.Spawn(buttonID++, x, y, 25, 75.0f, 75.0f, 0.30f,BUTTON_ICON); ButtonRenderComponent* readyRender = dynamic_cast<ButtonRenderComponent*>(readyButt->GetComponent(COMPONENT_RENDER)); readyRender->addSecondSprite(34); GameObjects.AddObject(readyButt); // back button renderMan->windowCoordToWorldCoord(x, y, (int)(w*(0.1f)), (int)(h*(90 / 100.0))); backButt = bFactory.Spawn(buttonID++, x, y, 23, 75.0f, 75.0f, 0.30f); ButtonRenderComponent*backRender = dynamic_cast<ButtonRenderComponent*>(backButt->GetComponent(COMPONENT_RENDER)); backRender->addSecondSprite(33); GameObjects.AddObject(backButt); }
void BoomerangLogicComponent::Update(){ //automatically return if flying for more that 4 seconds if (!returning){ double flightTime = (clock() - flightClock) / (CLOCKS_PER_SEC / 1000); if (flightTime > 4000){ returning = true; dynamic_cast<BoomerangPhysicsComponent*>(gameObjectRef->GetComponent(COMPONENT_PHYSICS))->returning = true; } } //update the target of the boomerang while still in flight double elapsedTime = (clock() - updateClock) / (CLOCKS_PER_SEC / 1000); //send update packet every half second if (elapsedTime > updateInterval && gameObjectRef->isLocal){ //set the target to be new float newX, newY; RenderManager* renderMan = RenderManager::getRenderManager(); InputManager* inputMan = InputManager::getInstance(); renderMan->windowCoordToWorldCoord(newX, newY, inputMan->getMouseX(), inputMan->getMouseY()); dynamic_cast<BoomerangPhysicsComponent*>(gameObjectRef->GetComponent(COMPONENT_PHYSICS))->targetDest = b2Vec2(newX / worldScale, newY / worldScale); //send the update command over the wire dynamic_cast<BoomerangNetworkComponent*>(gameObjectRef->GetComponent(COMPONENT_NETWORK))->sendTargetPacket(); updateClock = clock(); } }
GameManager::~GameManager() { mLog->logMessage("GAMEMANAGER: Shutting down game manager"); // Unregister listeners InputManager* inputMan = mEngine->getInputManager(); inputMan->removeJoystickListener(this); inputMan->removeMouseListener(this); inputMan->removeKeyListener(this); RenderManager* renderMan = mEngine->getRenderManager(); renderMan->removeRenderListener(this); renderMan->removeWindowEventListener(this); // destroy de scene manager delete mSceneMan; mLog->logMessage("GAMEMANAGER: Shutdown complete!"); // destroy log GameEngine::getSingletonPtr()->getLogManager()->destroyLog(mLog); mLog = 0; // dereference the engine mEngine = 0; }
void Lobby::createClassButts(){ RenderManager* renderMan = RenderManager::getRenderManager(); GameObject* button; int w, h; float midHeight, offset; float x, y; renderMan->getWindowSize(&w, &h); // height for the character class buttons midHeight = h * (1 / 2.0f); // finding the offset of the slots offset = w * (1 / 4.0f); // chicken button renderMan->windowCoordToWorldCoord(x, y, (int)offset, (int)midHeight); button = bFactory.Spawn(buttonID++, x, y, 50, 75.0f, 75.0f, 0.75f); dynamic_cast<ButtonLogicComponent*>(button->GetComponent(COMPONENT_LOGIC))->setSound("chickensfx.ogg"); classButt.push_back(button); GameObjects.AddObject(button); offset += w * (1 / 9.0f); // peacock button renderMan->windowCoordToWorldCoord(x, y, (int)offset, (int)midHeight); button = bFactory.Spawn(buttonID++, x, y, 51, 75.0f, 75.0f, 0.75f); dynamic_cast<ButtonLogicComponent*>(button->GetComponent(COMPONENT_LOGIC))->setSound("peacocksfx.ogg"); classButt.push_back(button); GameObjects.AddObject(button); offset += w * (1 / 9.0f); // flamingo button renderMan->windowCoordToWorldCoord(x, y, (int)offset, (int)midHeight); button = bFactory.Spawn(buttonID++, x, y, 52, 75.0f, 75.0f, 0.75f); dynamic_cast<ButtonLogicComponent*>(button->GetComponent(COMPONENT_LOGIC))->setSound("flamingosfx.ogg"); classButt.push_back(button); GameObjects.AddObject(button); offset += w * (1 / 9.0f); // quail button renderMan->windowCoordToWorldCoord(x, y, (int)offset, (int)midHeight); button = bFactory.Spawn(buttonID++, x, y, 53, 75.0f, 75.0f, 0.75f); dynamic_cast<ButtonLogicComponent*>(button->GetComponent(COMPONENT_LOGIC))->setSound("quailsfx.ogg"); classButt.push_back(button); GameObjects.AddObject(button); offset += w * (1 / 9.0f); // turkey button renderMan->windowCoordToWorldCoord(x, y, (int)offset, (int)midHeight); button = bFactory.Spawn(buttonID++, x, y, 54, 75.0f, 75.0f, 0.75f); dynamic_cast<ButtonLogicComponent*>(button->GetComponent(COMPONENT_LOGIC))->setSound("turkeysfx.ogg"); classButt.push_back(button); GameObjects.AddObject(button); offset += w * (1 / 9.0f); }
/** * Render debug primitives * * @param inView View to render * @param dT Delta time elapsed */ void RenderManager::RenderDebugPrimitives(const View* inView, float dT) { if(debugLines.size() > 0) { VertexBuffer* debugDrawVB = gRenderAPI->CreateVertexBuffer(VFMT_P3C3, debugLines.size()*2, NULL, true); VertexContainer_P3C3* pData = (VertexContainer_P3C3*)debugDrawVB->Lock(); for(vector<DebugLineData>::const_iterator it=debugLines.begin(); it!=debugLines.end(); it++) { pData->px = it->start.x; pData->py = it->start.y; pData->pz = it->start.z; pData->cx = it->color.r; pData->cy = it->color.g; pData->cz = it->color.b; pData++; pData->px = it->end.x; pData->py = it->end.y; pData->pz = it->end.z; pData->cx = it->color.r; pData->cy = it->color.g; pData->cz = it->color.b; pData++; } debugDrawVB->Unlock(); // Vertex shader MeshShader* vShader = gRenderManager.GetMeshShader(VFMT_P3C3, INTERPOLANT_MeshColor); vShader->SetValues(inView, Matrix4x4::Identity); vShader->Bind(); // Pixel shader meshColorPixelShader->Bind(); gRenderAPI->SetVertexBuffer(0, debugDrawVB); gRenderAPI->Draw(TOPOLOGY_LineList, debugLines.size()); gRenderAPI->DestroyVertexBuffer(debugDrawVB); } }
// Clears all the level's contents to leave it empty void clear() { EntityMapping::iterator it; for(it = m_entities.begin(); it != m_entities.end(); it++) { delete it->second; it->second = NULL; } for(it = m_nextEntities.begin(); it != m_nextEntities.end(); it++) { delete it->second; it->second = NULL; } m_nextEntities.clear(); m_entities.clear(); m_renderManager.clear(); m_spaceDivider.clear(); r_map = NULL; r_localPlayer = NULL; }
bool ActionSetPartialScreen::execute() { RenderManager *renderManager = _engine->getRenderManager(); if (_engine->getGameId() == GID_NEMESIS) { if (_backgroundColor) renderManager->renderImageToBackground(_fileName, _x, _y, 0, 0); else renderManager->renderImageToBackground(_fileName, _x, _y); } else { if (_backgroundColor >= 0) renderManager->renderImageToBackground(_fileName, _x, _y, _backgroundColor); else if (_backgroundColor == -2) renderManager->renderImageToBackground(_fileName, _x, _y, 0, 0); else renderManager->renderImageToBackground(_fileName, _x, _y); } return true; }
int main( int argc, char * * argv ) { // initialize memory managers MemoryManager::init(); NotePlayHandleManager::init(); // intialize RNG srand( getpid() + time( 0 ) ); disable_denormals(); bool coreOnly = false; bool fullscreen = true; bool exitAfterImport = false; bool allowRoot = false; bool renderLoop = false; bool renderTracks = false; QString fileToLoad, fileToImport, renderOut, profilerOutputFile, configFile; // first of two command-line parsing stages for( int i = 1; i < argc; ++i ) { QString arg = argv[i]; if( arg == "--help" || arg == "-h" || arg == "--version" || arg == "-v" || arg == "--render" || arg == "-r" ) { coreOnly = true; } else if( arg == "--rendertracks" ) { coreOnly = true; renderTracks = true; } else if( arg == "--allowroot" ) { allowRoot = true; } else if( arg == "--geometry" || arg == "-geometry") { if( arg == "--geometry" ) { // Delete the first "-" so Qt recognize the option strcpy(argv[i], "-geometry"); } // option -geometry is filtered by Qt later, // so we need to check its presence now to // determine, if the application should run in // fullscreen mode (default, no -geometry given). fullscreen = false; } } #if !defined(LMMS_BUILD_WIN32) && !defined(LMMS_BUILD_HAIKU) if ( ( getuid() == 0 || geteuid() == 0 ) && !allowRoot ) { printf( "LMMS cannot be run as root.\nUse \"--allowroot\" to override.\n\n" ); return EXIT_FAILURE; } #endif QCoreApplication * app = coreOnly ? new QCoreApplication( argc, argv ) : new MainApplication( argc, argv ); Mixer::qualitySettings qs( Mixer::qualitySettings::Mode_HighQuality ); OutputSettings os( 44100, OutputSettings::BitRateSettings(160, false), OutputSettings::Depth_16Bit ); ProjectRenderer::ExportFileFormats eff = ProjectRenderer::WaveFile; // second of two command-line parsing stages for( int i = 1; i < argc; ++i ) { QString arg = argv[i]; if( arg == "--version" || arg == "-v" ) { printVersion( argv[0] ); return EXIT_SUCCESS; } else if( arg == "--help" || arg == "-h" ) { printHelp(); return EXIT_SUCCESS; } else if( arg == "--upgrade" || arg == "-u" ) { ++i; if( i == argc ) { printf( "\nNo input file specified.\n\n" "Try \"%s --help\" for more information.\n\n", argv[0] ); return EXIT_FAILURE; } DataFile dataFile( QString::fromLocal8Bit( argv[i] ) ); if( argc > i+1 ) // output file specified { dataFile.writeFile( QString::fromLocal8Bit( argv[i+1] ) ); } else // no output file specified; use stdout { QTextStream ts( stdout ); dataFile.write( ts ); fflush( stdout ); } return EXIT_SUCCESS; } else if( arg == "--allowroot" ) { // Ignore, processed earlier #ifdef LMMS_BUILD_WIN32 if( allowRoot ) { printf( "\nOption \"--allowroot\" will be ignored on this platform.\n\n" ); } #endif } else if( arg == "--dump" || arg == "-d" ) { ++i; if( i == argc ) { printf( "\nNo input file specified.\n\n" "Try \"%s --help\" for more information.\n\n", argv[0] ); return EXIT_FAILURE; } QFile f( QString::fromLocal8Bit( argv[i] ) ); f.open( QIODevice::ReadOnly ); QString d = qUncompress( f.readAll() ); printf( "%s\n", d.toUtf8().constData() ); return EXIT_SUCCESS; } else if( arg == "--render" || arg == "-r" || arg == "--rendertracks" ) { ++i; if( i == argc ) { printf( "\nNo input file specified.\n\n" "Try \"%s --help\" for more information.\n\n", argv[0] ); return EXIT_FAILURE; } fileToLoad = QString::fromLocal8Bit( argv[i] ); renderOut = fileToLoad; } else if( arg == "--loop" || arg == "-l" ) { renderLoop = true; } else if( arg == "--output" || arg == "-o" ) { ++i; if( i == argc ) { printf( "\nNo output file specified.\n\n" "Try \"%s --help\" for more information.\n\n", argv[0] ); return EXIT_FAILURE; } renderOut = QString::fromLocal8Bit( argv[i] ); } else if( arg == "--format" || arg == "-f" ) { ++i; if( i == argc ) { printf( "\nNo output format specified.\n\n" "Try \"%s --help\" for more information.\n\n", argv[0] ); return EXIT_FAILURE; } const QString ext = QString( argv[i] ); if( ext == "wav" ) { eff = ProjectRenderer::WaveFile; } #ifdef LMMS_HAVE_OGGVORBIS else if( ext == "ogg" ) { eff = ProjectRenderer::OggFile; } #endif else { printf( "\nInvalid output format %s.\n\n" "Try \"%s --help\" for more information.\n\n", argv[i], argv[0] ); return EXIT_FAILURE; } } else if( arg == "--samplerate" || arg == "-s" ) { ++i; if( i == argc ) { printf( "\nNo samplerate specified.\n\n" "Try \"%s --help\" for more information.\n\n", argv[0] ); return EXIT_FAILURE; } sample_rate_t sr = QString( argv[i] ).toUInt(); if( sr >= 44100 && sr <= 192000 ) { os.setSampleRate(sr); } else { printf( "\nInvalid samplerate %s.\n\n" "Try \"%s --help\" for more information.\n\n", argv[i], argv[0] ); return EXIT_FAILURE; } } else if( arg == "--bitrate" || arg == "-b" ) { ++i; if( i == argc ) { printf( "\nNo bitrate specified.\n\n" "Try \"%s --help\" for more information.\n\n", argv[0] ); return EXIT_FAILURE; } int br = QString( argv[i] ).toUInt(); if( br >= 64 && br <= 384 ) { OutputSettings::BitRateSettings bitRateSettings = os.getBitRateSettings(); bitRateSettings.setBitRate(br); os.setBitRateSettings(bitRateSettings); } else { printf( "\nInvalid bitrate %s.\n\n" "Try \"%s --help\" for more information.\n\n", argv[i], argv[0] ); return EXIT_FAILURE; } } else if( arg =="--float" || arg == "-a" ) { os.setBitDepth(OutputSettings::Depth_32Bit); } else if( arg == "--interpolation" || arg == "-i" ) { ++i; if( i == argc ) { printf( "\nNo interpolation method specified.\n\n" "Try \"%s --help\" for more information.\n\n", argv[0] ); return EXIT_FAILURE; } const QString ip = QString( argv[i] ); if( ip == "linear" ) { qs.interpolation = Mixer::qualitySettings::Interpolation_Linear; } else if( ip == "sincfastest" ) { qs.interpolation = Mixer::qualitySettings::Interpolation_SincFastest; } else if( ip == "sincmedium" ) { qs.interpolation = Mixer::qualitySettings::Interpolation_SincMedium; } else if( ip == "sincbest" ) { qs.interpolation = Mixer::qualitySettings::Interpolation_SincBest; } else { printf( "\nInvalid interpolation method %s.\n\n" "Try \"%s --help\" for more information.\n\n", argv[i], argv[0] ); return EXIT_FAILURE; } } else if( arg == "--oversampling" || arg == "-x" ) { ++i; if( i == argc ) { printf( "\nNo oversampling specified.\n\n" "Try \"%s --help\" for more information.\n\n", argv[0] ); return EXIT_FAILURE; } int o = QString( argv[i] ).toUInt(); switch( o ) { case 1: qs.oversampling = Mixer::qualitySettings::Oversampling_None; break; case 2: qs.oversampling = Mixer::qualitySettings::Oversampling_2x; break; case 4: qs.oversampling = Mixer::qualitySettings::Oversampling_4x; break; case 8: qs.oversampling = Mixer::qualitySettings::Oversampling_8x; break; default: printf( "\nInvalid oversampling %s.\n\n" "Try \"%s --help\" for more information.\n\n", argv[i], argv[0] ); return EXIT_FAILURE; } } else if( arg == "--import" ) { ++i; if( i == argc ) { printf( "\nNo file specified for importing.\n\n" "Try \"%s --help\" for more information.\n\n", argv[0] ); return EXIT_FAILURE; } fileToImport = QString::fromLocal8Bit( argv[i] ); // exit after import? (only for debugging) if( QString( argv[i + 1] ) == "-e" ) { exitAfterImport = true; ++i; } } else if( arg == "--profile" || arg == "-p" ) { ++i; if( i == argc ) { printf( "\nNo profile specified.\n\n" "Try \"%s --help\" for more information.\n\n", argv[0] ); return EXIT_FAILURE; } profilerOutputFile = QString::fromLocal8Bit( argv[i] ); } else if( arg == "--config" || arg == "-c" ) { ++i; if( i == argc ) { printf( "\nNo configuration file specified.\n\n" "Try \"%s --help\" for more information.\n\n", argv[0] ); return EXIT_FAILURE; } configFile = QString::fromLocal8Bit( argv[i] ); } else { if( argv[i][0] == '-' ) { printf( "\nInvalid option %s.\n\n" "Try \"%s --help\" for more information.\n\n", argv[i], argv[0] ); return EXIT_FAILURE; } fileToLoad = QString::fromLocal8Bit( argv[i] ); } } // Test file argument before continuing if( !fileToLoad.isEmpty() ) { fileCheck( fileToLoad ); } else if( !fileToImport.isEmpty() ) { fileCheck( fileToImport ); } ConfigManager::inst()->loadConfigFile(configFile); // set language QString pos = ConfigManager::inst()->value( "app", "language" ); if( pos.isEmpty() ) { pos = QLocale::system().name().left( 2 ); } #ifdef LMMS_BUILD_WIN32 #undef QT_TRANSLATIONS_DIR #define QT_TRANSLATIONS_DIR ConfigManager::inst()->localeDir() #endif #ifdef QT_TRANSLATIONS_DIR // load translation for Qt-widgets/-dialogs loadTranslation( QString( "qt_" ) + pos, QString( QT_TRANSLATIONS_DIR ) ); #endif // load actual translation for LMMS loadTranslation( pos ); // try to set realtime priority #ifdef LMMS_BUILD_LINUX #ifdef LMMS_HAVE_SCHED_H #ifndef __OpenBSD__ struct sched_param sparam; sparam.sched_priority = ( sched_get_priority_max( SCHED_FIFO ) + sched_get_priority_min( SCHED_FIFO ) ) / 2; if( sched_setscheduler( 0, SCHED_FIFO, &sparam ) == -1 ) { printf( "Notice: could not set realtime priority.\n" ); } #endif #endif #endif #ifdef LMMS_BUILD_WIN32 if( !SetPriorityClass( GetCurrentProcess(), HIGH_PRIORITY_CLASS ) ) { printf( "Notice: could not set high priority.\n" ); } #endif #if _POSIX_C_SOURCE >= 1 || _XOPEN_SOURCE || _POSIX_SOURCE struct sigaction sa; sa.sa_handler = SIG_IGN; sa.sa_flags = SA_SIGINFO; if ( sigemptyset( &sa.sa_mask ) ) { fprintf( stderr, "Signal initialization failed.\n" ); } if ( sigaction( SIGPIPE, &sa, NULL ) ) { fprintf( stderr, "Signal initialization failed.\n" ); } #endif bool destroyEngine = false; // if we have an output file for rendering, just render the song // without starting the GUI if( !renderOut.isEmpty() ) { Engine::init( true ); destroyEngine = true; printf( "Loading project...\n" ); Engine::getSong()->loadProject( fileToLoad ); if( Engine::getSong()->isEmpty() ) { printf("The project %s is empty, aborting!\n", fileToLoad.toUtf8().constData() ); exit( EXIT_FAILURE ); } printf( "Done\n" ); Engine::getSong()->setExportLoop( renderLoop ); // when rendering multiple tracks, renderOut is a directory // otherwise, it is a file, so we need to append the file extension if ( !renderTracks ) { renderOut = baseName( renderOut ) + ProjectRenderer::getFileExtensionFromFormat(eff); } // create renderer RenderManager * r = new RenderManager( qs, os, eff, renderOut ); QCoreApplication::instance()->connect( r, SIGNAL( finished() ), SLOT( quit() ) ); // timer for progress-updates QTimer * t = new QTimer( r ); r->connect( t, SIGNAL( timeout() ), SLOT( updateConsoleProgress() ) ); t->start( 200 ); if( profilerOutputFile.isEmpty() == false ) { Engine::mixer()->profiler().setOutputFile( profilerOutputFile ); } // start now! if ( renderTracks ) { r->renderTracks(); } else { r->renderProject(); } } else // otherwise, start the GUI { new GuiApplication(); // re-intialize RNG - shared libraries might have srand() or // srandom() calls in their init procedure srand( getpid() + time( 0 ) ); // recover a file? QString recoveryFile = ConfigManager::inst()->recoveryFile(); bool recoveryFilePresent = QFileInfo( recoveryFile ).exists() && QFileInfo( recoveryFile ).isFile(); bool autoSaveEnabled = ConfigManager::inst()->value( "ui", "enableautosave" ).toInt(); if( recoveryFilePresent ) { QMessageBox mb; mb.setWindowTitle( MainWindow::tr( "Project recovery" ) ); mb.setText( QString( "<html>" "<p style=\"margin-left:6\">%1</p>" "<table cellpadding=\"3\">" " <tr>" " <td><b>%2</b></td>" " <td>%3</td>" " </tr>" " <tr>" " <td><b>%4</b></td>" " <td>%5</td>" " </tr>" " <tr>" " <td><b>%6</b></td>" " <td>%7</td>" " </tr>" "</table>" "</html>" ).arg( MainWindow::tr( "There is a recovery file present. " "It looks like the last session did not end " "properly or another instance of LMMS is " "already running. Do you want to recover the " "project of this session?" ), MainWindow::tr( "Recover" ), MainWindow::tr( "Recover the file. Please don't run " "multiple instances of LMMS when you do this." ), MainWindow::tr( "Ignore" ), MainWindow::tr( "Launch LMMS as usual but with " "automatic backup disabled to prevent the " "present recover file from being overwritten." ), MainWindow::tr( "Discard" ), MainWindow::tr( "Launch a default session and delete " "the restored files. This is not reversible." ) ) ); mb.setIcon( QMessageBox::Warning ); mb.setWindowIcon( embed::getIconPixmap( "icon" ) ); mb.setWindowFlags( Qt::WindowCloseButtonHint ); QPushButton * recover; QPushButton * discard; QPushButton * ignore; QPushButton * exit; #if QT_VERSION >= 0x050000 // setting all buttons to the same roles allows us // to have a custom layout discard = mb.addButton( MainWindow::tr( "Discard" ), QMessageBox::AcceptRole ); ignore = mb.addButton( MainWindow::tr( "Ignore" ), QMessageBox::AcceptRole ); recover = mb.addButton( MainWindow::tr( "Recover" ), QMessageBox::AcceptRole ); # else // in qt4 the button order is reversed recover = mb.addButton( MainWindow::tr( "Recover" ), QMessageBox::AcceptRole ); ignore = mb.addButton( MainWindow::tr( "Ignore" ), QMessageBox::AcceptRole ); discard = mb.addButton( MainWindow::tr( "Discard" ), QMessageBox::AcceptRole ); #endif // have a hidden exit button exit = mb.addButton( "", QMessageBox::RejectRole); exit->setVisible(false); // set icons recover->setIcon( embed::getIconPixmap( "recover" ) ); discard->setIcon( embed::getIconPixmap( "discard" ) ); ignore->setIcon( embed::getIconPixmap( "ignore" ) ); mb.setDefaultButton( recover ); mb.setEscapeButton( exit ); mb.exec(); if( mb.clickedButton() == discard ) { gui->mainWindow()->sessionCleanup(); } else if( mb.clickedButton() == recover ) // Recover { fileToLoad = recoveryFile; gui->mainWindow()->setSession( MainWindow::SessionState::Recover ); } else if( mb.clickedButton() == ignore ) { if( autoSaveEnabled ) { gui->mainWindow()->setSession( MainWindow::SessionState::Limited ); } } else // Exit { return 0; } } // first show the Main Window and then try to load given file // [Settel] workaround: showMaximized() doesn't work with // FVWM2 unless the window is already visible -> show() first gui->mainWindow()->show(); if( fullscreen ) { gui->mainWindow()->showMaximized(); } // Handle macOS-style FileOpen QEvents QString queuedFile = static_cast<MainApplication *>( app )->queuedFile(); if ( !queuedFile.isEmpty() ) { fileToLoad = queuedFile; } if( !fileToLoad.isEmpty() ) { if( fileToLoad == recoveryFile ) { Engine::getSong()->createNewProjectFromTemplate( fileToLoad ); } else { Engine::getSong()->loadProject( fileToLoad ); } } else if( !fileToImport.isEmpty() ) { ImportFilter::import( fileToImport, Engine::getSong() ); if( exitAfterImport ) { return EXIT_SUCCESS; } } // If enabled, open last project if there is one. Else, create // a new one. Also skip recently opened file if limited session to // lower the chance of opening an already opened file. else if( ConfigManager::inst()-> value( "app", "openlastproject" ).toInt() && !ConfigManager::inst()-> recentlyOpenedProjects().isEmpty() && gui->mainWindow()->getSession() != MainWindow::SessionState::Limited ) { QString f = ConfigManager::inst()-> recentlyOpenedProjects().first(); QFileInfo recentFile( f ); if ( recentFile.exists() ) { Engine::getSong()->loadProject( f ); } else { Engine::getSong()->createNewProject(); } } else { Engine::getSong()->createNewProject(); } // Finally we start the auto save timer and also trigger the // autosave one time as recover.mmp is a signal to possible other // instances of LMMS. if( autoSaveEnabled && gui->mainWindow()->getSession() != MainWindow::SessionState::Limited ) { gui->mainWindow()->autoSaveTimerReset(); gui->mainWindow()->autoSave(); } } const int ret = app->exec(); delete app; if( destroyEngine ) { Engine::destroy(); } // cleanup memory managers MemoryManager::cleanup(); // ProjectRenderer::updateConsoleProgress() doesn't return line after render if( coreOnly ) { printf( "\n" ); } return ret; }
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); } } } }