2014-06-25 16:29:58 +00:00
|
|
|
#include "views/gamelist/ISimpleGameListView.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
|
2017-11-18 22:23:56 +00:00
|
|
|
#include "views/UIModeController.h"
|
2014-06-25 16:29:58 +00:00
|
|
|
#include "views/ViewController.h"
|
2017-06-12 16:38:59 +00:00
|
|
|
#include "CollectionSystemManager.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "Settings.h"
|
|
|
|
#include "Sound.h"
|
|
|
|
#include "SystemData.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);
|
2019-08-25 15:23:02 +00:00
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-17 14:58:52 +00:00
|
|
|
void ISimpleGameListView::onFileChanged(FileData* /*file*/, FileChangeType /*change*/)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
|
|
|
// 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)
|
|
|
|
{
|
2020-05-15 16:08:26 +00:00
|
|
|
std::shared_ptr<Sound> soundfile;
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
if(input.value != 0)
|
|
|
|
{
|
|
|
|
if(config->isMappedTo("a", input))
|
|
|
|
{
|
|
|
|
FileData* cursor = getCursor();
|
|
|
|
if(cursor->getType() == GAME)
|
|
|
|
{
|
2020-05-15 16:08:26 +00:00
|
|
|
soundfile = Sound::getFromTheme(getTheme(), "navigationsounds", "launchSound");
|
|
|
|
soundfile->play();
|
|
|
|
while(soundfile->isPlaying());
|
2014-06-25 16:29:58 +00:00
|
|
|
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();
|
|
|
|
}else{
|
2020-05-15 16:08:26 +00:00
|
|
|
Sound::getFromTheme(getTheme(), "navigationsounds", "backSound")->play();
|
2014-06-25 16:29:58 +00:00
|
|
|
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;
|
2018-11-15 16:38:20 +00:00
|
|
|
}else if(config->isMappedLike(getQuickSystemSelectRightButton(), input))
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
|
|
|
if(Settings::getInstance()->getBool("QuickSystemSelect"))
|
|
|
|
{
|
2020-05-15 16:08:26 +00:00
|
|
|
Sound::getFromTheme(getTheme(), "navigationsounds", "quicksysselectSound")->play();
|
2014-06-25 16:29:58 +00:00
|
|
|
onFocusLost();
|
|
|
|
ViewController::get()->goToNextGameList();
|
|
|
|
return true;
|
|
|
|
}
|
2018-11-15 16:38:20 +00:00
|
|
|
}else if(config->isMappedLike(getQuickSystemSelectLeftButton(), input))
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
|
|
|
if(Settings::getInstance()->getBool("QuickSystemSelect"))
|
|
|
|
{
|
2020-05-15 16:08:26 +00:00
|
|
|
Sound::getFromTheme(getTheme(), "navigationsounds", "quicksysselectSound")->play();
|
2014-06-25 16:29:58 +00:00
|
|
|
onFocusLost();
|
|
|
|
ViewController::get()->goToPrevGameList();
|
|
|
|
return true;
|
|
|
|
}
|
2016-12-20 20:25:35 +00:00
|
|
|
}else if (config->isMappedTo("x", input))
|
|
|
|
{
|
2018-04-07 12:21:02 +00:00
|
|
|
if (mRoot->getSystem()->isGameSystem())
|
2017-07-18 09:45:50 +00:00
|
|
|
{
|
2018-04-07 12:21:02 +00:00
|
|
|
// go to random system game
|
2020-05-15 16:08:26 +00:00
|
|
|
Sound::getFromTheme(getTheme(), "navigationsounds", "scrollSound")->play();
|
2018-04-07 12:21:02 +00:00
|
|
|
FileData* randomGame = getCursor()->getSystem()->getRandomGame();
|
|
|
|
if (randomGame)
|
|
|
|
{
|
|
|
|
setCursor(randomGame);
|
|
|
|
}
|
|
|
|
return true;
|
2017-07-18 09:45:50 +00:00
|
|
|
}
|
2019-06-19 09:04:17 +00:00
|
|
|
}else if (config->isMappedTo("y", input) && !UIModeController::getInstance()->isUIModeKid())
|
2017-06-12 16:38:59 +00:00
|
|
|
{
|
2017-07-18 09:45:50 +00:00
|
|
|
if(mRoot->getSystem()->isGameSystem())
|
2017-06-12 16:38:59 +00:00
|
|
|
{
|
2020-05-15 16:08:26 +00:00
|
|
|
Sound::getFromTheme(getTheme(), "navigationsounds", "favoriteSound")->play();
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|