From 67e657391a08c5305ddf7b746619f8ceffa53910 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Thu, 16 Aug 2012 10:23:23 -0500 Subject: [PATCH] Fixed positioning on game images with the new 50/50 split. Game images and descriptions are no longer displayed while scrolling - this should provide a better framerate for nicer scrolling. --- src/components/GuiGameList.cpp | 14 +++++++++----- src/components/GuiList.cpp | 6 ++++++ src/components/GuiList.h | 3 ++- src/main.cpp | 10 ++++++++-- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/components/GuiGameList.cpp b/src/components/GuiGameList.cpp index 2bc5b636a..e463713fb 100644 --- a/src/components/GuiGameList.cpp +++ b/src/components/GuiGameList.cpp @@ -13,6 +13,7 @@ const float GuiGameList::sInfoWidth = 0.5; + GuiGameList::GuiGameList(bool useDetail) { std::cout << "Creating GuiGameList\n"; @@ -25,7 +26,7 @@ GuiGameList::GuiGameList(bool useDetail) { mList = new GuiList(Renderer::getScreenWidth() * sInfoWidth, Renderer::getFontHeight(Renderer::LARGE) + 2); - mScreenshot = new GuiImage(Renderer::getScreenWidth() * 0.2, Renderer::getFontHeight(Renderer::LARGE) + 2, "", Renderer::getScreenWidth() * 0.3); + mScreenshot = new GuiImage(Renderer::getScreenWidth() * sInfoWidth * 0.5, Renderer::getFontHeight(Renderer::LARGE) + 2, "", Renderer::getScreenWidth() * sInfoWidth * 0.7); mScreenshot->setOrigin(0.5, 0.0); mScreenshot->setAlpha(true); //slower, but requested addChild(mScreenshot); @@ -110,8 +111,8 @@ void GuiGameList::onRender() if(!mTheme->getDividersHidden()) Renderer::drawRect(Renderer::getScreenWidth() * sInfoWidth - 4, Renderer::getFontHeight(Renderer::LARGE) + 2, 8, Renderer::getScreenHeight(), 0x0000FF); - //if we have selected a non-folder - if(mList->getSelectedObject() && !mList->getSelectedObject()->isFolder()) + //if we're not scrolling and we have selected a non-folder + if(!mList->isScrolling() && mList->getSelectedObject() && !mList->getSelectedObject()->isFolder()) { GameData* game = (GameData*)mList->getSelectedObject(); @@ -166,9 +167,12 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown) if(mDetailed) { - if(!keyDown && (button == InputManager::UP || button == InputManager::DOWN)) + if(button == InputManager::UP || button == InputManager::DOWN) { - updateDetailData(); + if(!keyDown) + updateDetailData(); + else + mScreenshot->setImage(""); //clear the image when we start scrolling } } } diff --git a/src/components/GuiList.cpp b/src/components/GuiList.cpp index 458d1ed37..257de14f3 100644 --- a/src/components/GuiList.cpp +++ b/src/components/GuiList.cpp @@ -184,6 +184,12 @@ int GuiList::getSelection() return mSelection; } +template +bool GuiList::isScrolling() +{ + return mScrolling; +} + template void GuiList::onPause() { diff --git a/src/components/GuiList.h b/src/components/GuiList.h index 11fec8802..2d3a056a9 100644 --- a/src/components/GuiList.h +++ b/src/components/GuiList.h @@ -8,7 +8,7 @@ #include #define SCROLLDELAY 507 -#define SCROLLTIME (57*6) +#define SCROLLTIME (57*5) //this should really be a template template @@ -31,6 +31,7 @@ public: std::string getSelectedName(); listType getSelectedObject(); int getSelection(); + bool isScrolling(); void setSelectorColor(int selectorColor); void setCentered(bool centered); diff --git a/src/main.cpp b/src/main.cpp index 93526bc79..5b783d077 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,7 +9,10 @@ bool PARSEGAMELISTONLY = false; bool IGNOREGAMELIST = false; -float FRAMERATE = 0; + +#ifdef DRAWFRAMERATE + float FRAMERATE = 0; +#endif namespace fs = boost::filesystem; @@ -177,7 +180,10 @@ int main(int argc, char* argv[]) int deltaTime = curTime - lastTime; lastTime = curTime; - FRAMERATE = 1/((float)deltaTime)*1000; + #ifdef DRAWFRAMERATE + FRAMERATE = 1/((float)deltaTime)*1000; + #endif + GuiComponent::processTicks(deltaTime); Renderer::render();