From 1a9fdabd633ec87328cd4699145334ca978bd24f Mon Sep 17 00:00:00 2001 From: emb <> Date: Thu, 1 Jan 2015 16:50:43 -0600 Subject: [PATCH] Removed dead code and removed static file scope page variable. --- Source/RetroFE.cpp | 49 +++++++++++----------------------------------- Source/RetroFE.h | 3 +-- 2 files changed, 12 insertions(+), 40 deletions(-) diff --git a/Source/RetroFE.cpp b/Source/RetroFE.cpp index 4e26e33..dcd1df0 100644 --- a/Source/RetroFE.cpp +++ b/Source/RetroFE.cpp @@ -22,9 +22,6 @@ #include #endif - -Page *page = NULL; - RetroFE::RetroFE(CollectionDatabase &db, Configuration &c) : Config(c) , CollectionDB(db) @@ -159,30 +156,25 @@ void RetroFE::Run() { int attractModeTime = 0; std::string firstCollection = "Main"; - - Config.GetProperty("attractModeTime", attractModeTime); - Config.GetProperty("firstCollection", firstCollection); - bool running = true; Item *nextPageItem = NULL; bool adminMode = false; float attractModeRandomTime = 0; bool selectActive = false; - - //todo: break up into helper methods - Logger::Write(Logger::ZONE_INFO, "RetroFE", "Loading first page"); - - page = LoadPage(firstCollection); - float frameCount = 0; float fpsStartTime = 0; RETROFE_STATE state = RETROFE_IDLE; + Config.GetProperty("attractModeTime", attractModeTime); + Config.GetProperty("firstCollection", firstCollection); + + LoadPage(firstCollection); + while (running) { float lastTime = 0; float deltaTime = 0; - page = PageChain.back(); + Page *page = PageChain.back(); Launcher l(*this, Config); if(!page) @@ -196,7 +188,7 @@ void RetroFE::Run() switch(state) { case RETROFE_IDLE: - state = ProcessUserInput(); + state = ProcessUserInput(page); break; case RETROFE_NEXT_PAGE_REQUEST: @@ -322,27 +314,6 @@ void RetroFE::Run() } } -bool RetroFE::ItemSelected() -{ - Item *item = page->GetSelectedItem(); - - if(!item) return false; - - if(item->IsLeaf()) - { - Launcher l(*this, Config); - - l.Run(page->GetCollectionName(), item); - } - else - { - NextPageItem = item; - LoadPage(page->GetCollectionName()); - page->Stop(); - } - - return true; -} bool RetroFE::Back(bool &exit) { @@ -351,14 +322,16 @@ bool RetroFE::Back(bool &exit) bool exitOnBack = false; Config.GetProperty("exitOnFirstPageBack", exitOnBack); exit = false; - + if(PageChain.size() > 1) { + Page *page = PageChain.back(); page->Stop(); canGoBack = true; } else if(PageChain.size() == 1 && exitOnBack) { + Page *page = PageChain.back(); page->Stop(); exit = true; canGoBack = true; @@ -368,7 +341,7 @@ bool RetroFE::Back(bool &exit) } -RetroFE::RETROFE_STATE RetroFE::ProcessUserInput() +RetroFE::RETROFE_STATE RetroFE::ProcessUserInput(Page *page) { SDL_Event e; bool exit = false; diff --git a/Source/RetroFE.h b/Source/RetroFE.h index 43f5abe..4446a3f 100644 --- a/Source/RetroFE.h +++ b/Source/RetroFE.h @@ -42,11 +42,10 @@ private: }; void Render(); - bool ItemSelected(); bool Back(bool &exit); void Quit(); Page *LoadPage(std::string collectionName); - RETROFE_STATE ProcessUserInput(); + RETROFE_STATE ProcessUserInput(Page *page); void Update(float dt, bool scrollActive); std::string GetLayout(std::string collectionName); std::vector *GetCollection(std::string collectionName);