2012-07-20 01:08:29 +00:00
|
|
|
#include "GuiGameList.h"
|
2012-07-21 19:06:24 +00:00
|
|
|
#include "../InputManager.h"
|
2012-07-20 16:14:09 +00:00
|
|
|
#include <iostream>
|
2012-07-21 19:16:53 +00:00
|
|
|
#include <SDL/SDL.h>
|
2012-07-20 01:08:29 +00:00
|
|
|
|
2012-07-20 16:14:09 +00:00
|
|
|
GuiGameList::GuiGameList(SystemData* system)
|
2012-07-20 01:08:29 +00:00
|
|
|
{
|
2012-07-20 16:14:09 +00:00
|
|
|
mSystem = system;
|
2012-07-20 01:08:29 +00:00
|
|
|
|
|
|
|
mList = new GuiList();
|
2012-07-20 16:14:09 +00:00
|
|
|
updateList();
|
2012-07-20 01:08:29 +00:00
|
|
|
|
|
|
|
addChild(mList);
|
2012-07-20 16:14:09 +00:00
|
|
|
|
|
|
|
Renderer::registerComponent(this);
|
2012-07-21 19:06:24 +00:00
|
|
|
InputManager::registerComponent(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
GuiGameList::~GuiGameList()
|
|
|
|
{
|
|
|
|
Renderer::unregisterComponent(this);
|
|
|
|
InputManager::unregisterComponent(this);
|
2012-07-20 01:08:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GuiGameList::onRender()
|
|
|
|
{
|
2012-07-21 20:16:07 +00:00
|
|
|
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0xFFFFFF);
|
2012-07-20 16:14:09 +00:00
|
|
|
|
2012-07-21 20:16:07 +00:00
|
|
|
Renderer::drawCenteredText(mSystem->getName(), 2, 0x0000FF);
|
2012-07-20 16:14:09 +00:00
|
|
|
}
|
|
|
|
|
2012-07-21 19:06:24 +00:00
|
|
|
void GuiGameList::onInput(InputManager::InputButton button, bool keyDown)
|
|
|
|
{
|
|
|
|
if(button == InputManager::BUTTON1 && keyDown)
|
|
|
|
{
|
2012-07-21 19:16:53 +00:00
|
|
|
SDL_EnableKeyRepeat(0, 0);
|
2012-07-21 19:06:24 +00:00
|
|
|
mSystem->launchGame(mList->getSelection());
|
2012-07-21 19:16:53 +00:00
|
|
|
SDL_EnableKeyRepeat(500, 100);
|
2012-07-21 19:06:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-20 16:14:09 +00:00
|
|
|
void GuiGameList::updateList()
|
|
|
|
{
|
|
|
|
mList->clear();
|
|
|
|
|
|
|
|
for(unsigned int i = 0; i < mSystem->getGameCount(); i++)
|
|
|
|
{
|
|
|
|
GameData* game = mSystem->getGame(i);
|
|
|
|
mList->addObject(game->getName(), game);
|
|
|
|
}
|
2012-07-20 01:08:29 +00:00
|
|
|
}
|