Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Bim 2013-06-30 18:00:16 +02:00
commit b329a5e1a0
7 changed files with 36 additions and 7 deletions

View file

@ -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

View file

@ -77,6 +77,9 @@ public:
bool parseEvent(const SDL_Event& ev);
InputConfig* getInputConfigByPlayer(int player);
void startPolling();
void stopPolling();
};
#endif

View file

@ -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());
}

View file

@ -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++;

View file

@ -35,6 +35,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.
@ -48,7 +50,6 @@ GuiGameList::GuiGameList(Window* window, bool useDetail) : GuiComponent(window),
mList = new TextListComponent<FileData*>(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));
@ -72,11 +73,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;

View file

@ -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;

View file

@ -117,7 +117,7 @@ void TextListComponent<T>::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)
{