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-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-20 16:14:09 +00:00
|
|
|
Renderer::drawRect(0, 0, 640, 480, 0xFFFFFF);
|
|
|
|
|
|
|
|
SDL_Color color = {0, 155, 100};
|
|
|
|
Renderer::drawCenteredText(mSystem->getName(), 2, color);
|
|
|
|
}
|
|
|
|
|
2012-07-21 19:06:24 +00:00
|
|
|
void GuiGameList::onInput(InputManager::InputButton button, bool keyDown)
|
|
|
|
{
|
|
|
|
if(button == InputManager::BUTTON1 && keyDown)
|
|
|
|
{
|
|
|
|
mSystem->launchGame(mList->getSelection());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|