2014-06-25 16:29:58 +00:00
|
|
|
#include "views/gamelist/ISimpleGameListView.h"
|
|
|
|
#include "ThemeData.h"
|
|
|
|
#include "Window.h"
|
|
|
|
#include "views/ViewController.h"
|
|
|
|
#include "Sound.h"
|
2017-06-12 16:38:59 +00:00
|
|
|
#include "Log.h"
|
2014-06-25 16:29:58 +00:00
|
|
|
#include "Settings.h"
|
2017-06-12 16:38:59 +00:00
|
|
|
#include "CollectionSystemManager.h"
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
ISimpleGameListView::ISimpleGameListView(Window* window, FileData* root) : IGameListView(window, root),
|
2017-04-22 14:15:16 +00:00
|
|
|
mHeaderText(window), mHeaderImage(window), mBackground(window)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
|
|
|
mHeaderText.setText("Logo Text");
|
|
|
|
mHeaderText.setSize(mSize.x(), 0);
|
|
|
|
mHeaderText.setPosition(0, 0);
|
2017-08-15 02:34:34 +00:00
|
|
|
mHeaderText.setHorizontalAlignment(ALIGN_CENTER);
|
2017-04-22 14:15:16 +00:00
|
|
|
mHeaderText.setDefaultZIndex(50);
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
mHeaderImage.setResize(0, mSize.y() * 0.185f);
|
|
|
|
mHeaderImage.setOrigin(0.5f, 0.0f);
|
|
|
|
mHeaderImage.setPosition(mSize.x() / 2, 0);
|
2017-04-22 14:15:16 +00:00
|
|
|
mHeaderImage.setDefaultZIndex(50);
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
mBackground.setResize(mSize.x(), mSize.y());
|
2017-04-22 14:15:16 +00:00
|
|
|
mBackground.setDefaultZIndex(0);
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
addChild(&mHeaderText);
|
|
|
|
addChild(&mBackground);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ISimpleGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
|
|
|
{
|
|
|
|
using namespace ThemeFlags;
|
|
|
|
mBackground.applyTheme(theme, getName(), "background", ALL);
|
|
|
|
mHeaderImage.applyTheme(theme, getName(), "logo", ALL);
|
|
|
|
mHeaderText.applyTheme(theme, getName(), "logoText", ALL);
|
2017-04-22 14:15:16 +00:00
|
|
|
|
|
|
|
// Remove old theme extras
|
|
|
|
for (auto extra : mThemeExtras)
|
|
|
|
{
|
|
|
|
removeChild(extra);
|
|
|
|
delete extra;
|
|
|
|
}
|
|
|
|
mThemeExtras.clear();
|
|
|
|
|
|
|
|
// Add new theme extras
|
|
|
|
mThemeExtras = ThemeData::makeExtras(theme, getName(), mWindow);
|
|
|
|
for (auto extra : mThemeExtras)
|
|
|
|
{
|
|
|
|
addChild(extra);
|
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
if(mHeaderImage.hasImage())
|
|
|
|
{
|
|
|
|
removeChild(&mHeaderText);
|
|
|
|
addChild(&mHeaderImage);
|
|
|
|
}else{
|
|
|
|
addChild(&mHeaderText);
|
|
|
|
removeChild(&mHeaderImage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ISimpleGameListView::onFileChanged(FileData* file, FileChangeType change)
|
|
|
|
{
|
|
|
|
// we could be tricky here to be efficient;
|
|
|
|
// but this shouldn't happen very often so we'll just always repopulate
|
|
|
|
FileData* cursor = getCursor();
|
2017-03-18 17:54:39 +00:00
|
|
|
if (!cursor->isPlaceHolder()) {
|
|
|
|
populateList(cursor->getParent()->getChildrenListToDisplay());
|
|
|
|
setCursor(cursor);
|
|
|
|
}
|
2017-05-18 10:16:57 +00:00
|
|
|
else
|
2017-03-18 17:54:39 +00:00
|
|
|
{
|
|
|
|
populateList(mRoot->getChildrenListToDisplay());
|
|
|
|
setCursor(cursor);
|
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ISimpleGameListView::input(InputConfig* config, Input input)
|
|
|
|
{
|
|
|
|
if(input.value != 0)
|
|
|
|
{
|
|
|
|
if(config->isMappedTo("a", input))
|
|
|
|
{
|
|
|
|
FileData* cursor = getCursor();
|
|
|
|
if(cursor->getType() == GAME)
|
|
|
|
{
|
|
|
|
Sound::getFromTheme(getTheme(), getName(), "launch")->play();
|
|
|
|
launch(cursor);
|
|
|
|
}else{
|
|
|
|
// it's a folder
|
|
|
|
if(cursor->getChildren().size() > 0)
|
|
|
|
{
|
|
|
|
mCursorStack.push(cursor);
|
2017-03-18 17:54:39 +00:00
|
|
|
populateList(cursor->getChildrenListToDisplay());
|
2017-07-18 09:45:50 +00:00
|
|
|
FileData* cursor = getCursor();
|
|
|
|
setCursor(cursor);
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
}
|
2017-05-18 10:16:57 +00:00
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
return true;
|
|
|
|
}else if(config->isMappedTo("b", input))
|
|
|
|
{
|
|
|
|
if(mCursorStack.size())
|
|
|
|
{
|
|
|
|
populateList(mCursorStack.top()->getParent()->getChildren());
|
|
|
|
setCursor(mCursorStack.top());
|
|
|
|
mCursorStack.pop();
|
|
|
|
Sound::getFromTheme(getTheme(), getName(), "back")->play();
|
|
|
|
}else{
|
|
|
|
onFocusLost();
|
2017-07-18 09:45:50 +00:00
|
|
|
SystemData* systemToView = getCursor()->getSystem();
|
|
|
|
if (systemToView->isCollection())
|
|
|
|
{
|
|
|
|
systemToView = CollectionSystemManager::get()->getSystemToView(systemToView);
|
|
|
|
}
|
|
|
|
ViewController::get()->goToSystemView(systemToView);
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}else if(config->isMappedTo("right", input))
|
|
|
|
{
|
|
|
|
if(Settings::getInstance()->getBool("QuickSystemSelect"))
|
|
|
|
{
|
|
|
|
onFocusLost();
|
|
|
|
ViewController::get()->goToNextGameList();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}else if(config->isMappedTo("left", input))
|
|
|
|
{
|
|
|
|
if(Settings::getInstance()->getBool("QuickSystemSelect"))
|
|
|
|
{
|
|
|
|
onFocusLost();
|
|
|
|
ViewController::get()->goToPrevGameList();
|
|
|
|
return true;
|
|
|
|
}
|
2016-12-20 20:25:35 +00:00
|
|
|
}else if (config->isMappedTo("x", input))
|
|
|
|
{
|
2017-06-12 16:38:59 +00:00
|
|
|
// go to random system game
|
2017-07-18 09:45:50 +00:00
|
|
|
FileData* randomGame = getCursor()->getSystem()->getRandomGame();
|
|
|
|
if (randomGame)
|
|
|
|
{
|
|
|
|
setCursor(randomGame);
|
|
|
|
}
|
2016-12-20 20:25:35 +00:00
|
|
|
return true;
|
2017-06-12 16:38:59 +00:00
|
|
|
}else if (config->isMappedTo("y", input))
|
|
|
|
{
|
2017-07-18 09:45:50 +00:00
|
|
|
if(mRoot->getSystem()->isGameSystem())
|
2017-06-12 16:38:59 +00:00
|
|
|
{
|
2017-07-18 09:45:50 +00:00
|
|
|
if(CollectionSystemManager::get()->toggleGameInCollection(getCursor()))
|
2017-06-12 16:38:59 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return IGameListView::input(config, input);
|
|
|
|
}
|
2017-06-12 16:38:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|