From 6f9ea15696ba5aa510a6c5751e8edd04770cdc0d Mon Sep 17 00:00:00 2001 From: Aloshi Date: Wed, 26 Jun 2013 20:32:51 -0500 Subject: [PATCH 1/6] Fixed GuiGameList screenshot crash. For real, this time, probably. --- src/components/GuiGameList.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/GuiGameList.cpp b/src/components/GuiGameList.cpp index a65c94668..c91d48ade 100644 --- a/src/components/GuiGameList.cpp +++ b/src/components/GuiGameList.cpp @@ -19,6 +19,8 @@ GuiGameList::GuiGameList(Window* window, bool useDetail) : GuiComponent(window), mTheme = new ThemeComponent(mWindow, mDetailed); + mScreenshot = new ImageComponent(mWindow, getImagePos().x, getImagePos().y, "", (unsigned int)mTheme->getFloat("gameImageWidth"), (unsigned int)mTheme->getFloat("gameImageHeight"), false); + //The GuiGameList can use the older, simple game list if so desired. //The old view only shows a list in the center of the screen; the new view can display an image and description. //Those with smaller displays may prefer the older view. @@ -32,7 +34,6 @@ GuiGameList::GuiGameList(Window* window, bool useDetail) : GuiComponent(window), mList = new TextListComponent(mWindow, 0, Renderer::getDefaultFont(Renderer::LARGE)->getHeight() + 2, Renderer::getDefaultFont(Renderer::MEDIUM)); } - mScreenshot = new ImageComponent(mWindow, getImagePos().x, getImagePos().y, "", (unsigned int)mTheme->getFloat("gameImageWidth"), (unsigned int)mTheme->getFloat("gameImageHeight"), false); mScreenshot->setOrigin(mTheme->getFloat("gameImageOriginX"), mTheme->getFloat("gameImageOriginY")); mDescription.setOffset(Vector2i((int)(Renderer::getScreenWidth() * 0.03), mScreenshot->getOffset().y + mScreenshot->getSize().y + 12)); @@ -56,11 +57,11 @@ GuiGameList::~GuiGameList() //undo the parenting hack because otherwise it's not really a child and will try to remove itself on delete mList->setParent(NULL); delete mList; + delete mScreenshot; if(mDetailed) { delete mImageAnimation; - delete mScreenshot; } delete mTheme; From 4a1206aee28705232308024ce4c03f39b96478fa Mon Sep 17 00:00:00 2001 From: Aloshi Date: Wed, 26 Jun 2013 23:25:58 -0500 Subject: [PATCH 2/6] Disable input device polling code to resolve freeze after ~45 minutes. See issue #87. --- src/InputManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/InputManager.cpp b/src/InputManager.cpp index 5df74a951..ae81962f1 100644 --- a/src/InputManager.cpp +++ b/src/InputManager.cpp @@ -165,14 +165,14 @@ void InputManager::init() SDL_JoystickEventState(SDL_ENABLE); //start timer for input device polling - devicePollingTimer = SDL_AddTimer(POLLING_INTERVAL, devicePollingCallback, (void *)this); + //devicePollingTimer = SDL_AddTimer(POLLING_INTERVAL, devicePollingCallback, (void *)this); loadConfig(); } void InputManager::deinit() { - SDL_RemoveTimer(devicePollingTimer); + //SDL_RemoveTimer(devicePollingTimer); SDL_JoystickEventState(SDL_DISABLE); From d986d739b2b139b7b89cfea9d3a35a9f7b34e1f4 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Sat, 29 Jun 2013 07:30:32 -0500 Subject: [PATCH 3/6] Revert "Disable input device polling code to resolve freeze after ~45 minutes." This reverts commit 4a1206aee28705232308024ce4c03f39b96478fa. --- src/InputManager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/InputManager.cpp b/src/InputManager.cpp index ae81962f1..5df74a951 100644 --- a/src/InputManager.cpp +++ b/src/InputManager.cpp @@ -165,14 +165,14 @@ void InputManager::init() SDL_JoystickEventState(SDL_ENABLE); //start timer for input device polling - //devicePollingTimer = SDL_AddTimer(POLLING_INTERVAL, devicePollingCallback, (void *)this); + devicePollingTimer = SDL_AddTimer(POLLING_INTERVAL, devicePollingCallback, (void *)this); loadConfig(); } void InputManager::deinit() { - //SDL_RemoveTimer(devicePollingTimer); + SDL_RemoveTimer(devicePollingTimer); SDL_JoystickEventState(SDL_DISABLE); From 1dfb45e133c04d7e8d38fb35ea5109e6a3565c14 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Sat, 29 Jun 2013 20:37:18 -0500 Subject: [PATCH 4/6] Print all Log messages to cout with --debug set. Added startPolling and stopPolling to InputManager. --- src/InputManager.cpp | 25 ++++++++++++++++++++++--- src/InputManager.h | 3 +++ src/Log.cpp | 3 ++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/InputManager.cpp b/src/InputManager.cpp index e3490e207..168787a9f 100644 --- a/src/InputManager.cpp +++ b/src/InputManager.cpp @@ -28,7 +28,7 @@ bool InputDevice::operator==(const InputDevice & b) const InputManager::InputManager(Window* window) : mWindow(window), mJoysticks(NULL), mInputConfigs(NULL), mKeyboardInputConfig(NULL), mPrevAxisValues(NULL), - mNumJoysticks(0), mNumPlayers(0), devicePollingTimer(nullptr) + mNumJoysticks(0), mNumPlayers(0), devicePollingTimer(NULL) { } @@ -164,14 +164,31 @@ void InputManager::init() SDL_JoystickEventState(SDL_ENABLE); //start timer for input device polling - devicePollingTimer = SDL_AddTimer(POLLING_INTERVAL, devicePollingCallback, (void *)this); + startPolling(); loadConfig(); } +void InputManager::startPolling() +{ + if(devicePollingTimer != NULL) + return; + + devicePollingTimer = SDL_AddTimer(POLLING_INTERVAL, devicePollingCallback, (void *)this); +} + +void InputManager::stopPolling() +{ + if(devicePollingTimer == NULL) + return; + + SDL_RemoveTimer(devicePollingTimer); + devicePollingTimer = NULL; +} + void InputManager::deinit() { - SDL_RemoveTimer(devicePollingTimer); + stopPolling(); SDL_JoystickEventState(SDL_DISABLE); @@ -380,6 +397,8 @@ void InputManager::loadConfig() LOG(LogInfo) << "No input configs loaded. Loading default keyboard config."; loadDefaultConfig(); } + + LOG(LogInfo) << "Loaded InputConfig data for " << getNumPlayers() << " devices."; } //used in an "emergency" where no configs could be loaded from the inputmanager config file diff --git a/src/InputManager.h b/src/InputManager.h index 921a29fa5..e0cef8b61 100644 --- a/src/InputManager.h +++ b/src/InputManager.h @@ -77,6 +77,9 @@ public: bool parseEvent(const SDL_Event& ev); InputConfig* getInputConfigByPlayer(int player); + + void startPolling(); + void stopPolling(); }; #endif diff --git a/src/Log.cpp b/src/Log.cpp index fe3c50c6c..0e8522601 100644 --- a/src/Log.cpp +++ b/src/Log.cpp @@ -65,6 +65,7 @@ Log::~Log() fprintf(getOutput(), "%s", os.str().c_str()); //if it's an error, also print to console - if(messageLevel == LogError) + //print all messages if using --debug + if(messageLevel == LogError || reportingLevel >= LogDebug) fprintf(stderr, "%s", os.str().c_str()); } From f4e2a146857aef210dd5964f94be0a317fd6274b Mon Sep 17 00:00:00 2001 From: Aloshi Date: Sat, 29 Jun 2013 20:43:13 -0500 Subject: [PATCH 5/6] Temporarily disable polling while configuring inputs. Polling is disabled once the first device is chosen, and resumed once the last device is configured. --- src/components/GuiDetectDevice.cpp | 4 ++++ src/components/GuiInputConfig.cpp | 1 + 2 files changed, 5 insertions(+) diff --git a/src/components/GuiDetectDevice.cpp b/src/components/GuiDetectDevice.cpp index 8c05f1d91..570d4c9f4 100644 --- a/src/components/GuiDetectDevice.cpp +++ b/src/components/GuiDetectDevice.cpp @@ -44,6 +44,10 @@ bool GuiDetectDevice::input(InputConfig* config, Input input) if(!input.value) return false; + //don't allow device list to change once the first player has registered + if(mCurrentPlayer == 0) + mWindow->getInputManager()->stopPolling(); + config->setPlayerNum(mCurrentPlayer); mWindow->getInputManager()->setNumPlayers(mWindow->getInputManager()->getNumPlayers() + 1); //inc total number of players mCurrentPlayer++; diff --git a/src/components/GuiInputConfig.cpp b/src/components/GuiInputConfig.cpp index 6f217fcec..78f7a272a 100644 --- a/src/components/GuiInputConfig.cpp +++ b/src/components/GuiInputConfig.cpp @@ -38,6 +38,7 @@ bool GuiInputConfig::input(InputConfig* config, Input input) mWindow->pushGui(new GuiInputConfig(mWindow, mWindow->getInputManager()->getInputConfigByPlayer(mTargetConfig->getPlayerNum() + 1))); }else{ mWindow->getInputManager()->writeConfig(); + mWindow->getInputManager()->startPolling(); //enable polling again since we're done GuiGameList::create(mWindow); } delete this; From 3971fdc674fc8addc4a1a17501e3b3133358e037 Mon Sep 17 00:00:00 2001 From: Aloshi Date: Sat, 29 Jun 2013 20:57:14 -0500 Subject: [PATCH 6/6] Fix last entry not showing (issue #90) --- src/components/TextListComponent.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/TextListComponent.h b/src/components/TextListComponent.h index 0aea6cea4..e5c16e2fd 100644 --- a/src/components/TextListComponent.h +++ b/src/components/TextListComponent.h @@ -117,7 +117,7 @@ void TextListComponent::onRender() //number of entries that can fit on the screen simultaniously int screenCount = (Renderer::getScreenHeight() - cutoff) / entrySize; - //screenCount -= 1; + screenCount -= 1; if((int)mRowVector.size() >= screenCount) {