2020-05-24 08:29:29 +00:00
|
|
|
//
|
2020-06-21 12:25:28 +00:00
|
|
|
// ISimpleGameListView.cpp
|
2020-05-24 08:29:29 +00:00
|
|
|
//
|
2020-06-21 12:25:28 +00:00
|
|
|
// Interface that defines a simple GameListView.
|
2020-05-24 08:29:29 +00:00
|
|
|
//
|
|
|
|
|
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
|
|
|
|
2020-05-24 08:29:29 +00:00
|
|
|
ISimpleGameListView::ISimpleGameListView(
|
2020-06-21 12:25:28 +00:00
|
|
|
Window* window,
|
|
|
|
FileData* root)
|
|
|
|
: IGameListView(window, root),
|
|
|
|
mHeaderText(window),
|
|
|
|
mHeaderImage(window),
|
|
|
|
mBackground(window)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
mHeaderText.setText("Logo Text");
|
|
|
|
mHeaderText.setSize(mSize.x(), 0);
|
|
|
|
mHeaderText.setPosition(0, 0);
|
|
|
|
mHeaderText.setHorizontalAlignment(ALIGN_CENTER);
|
|
|
|
mHeaderText.setDefaultZIndex(50);
|
2019-08-25 15:23:02 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
mHeaderImage.setResize(0, mSize.y() * 0.185f);
|
|
|
|
mHeaderImage.setOrigin(0.5f, 0.0f);
|
|
|
|
mHeaderImage.setPosition(mSize.x() / 2, 0);
|
|
|
|
mHeaderImage.setDefaultZIndex(50);
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
mBackground.setResize(mSize.x(), mSize.y());
|
|
|
|
mBackground.setDefaultZIndex(0);
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
addChild(&mHeaderText);
|
|
|
|
addChild(&mBackground);
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ISimpleGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
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
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
// Remove old theme extras.
|
2020-07-13 18:58:25 +00:00
|
|
|
for (auto extra : mThemeExtras) {
|
2020-06-21 12:25:28 +00:00
|
|
|
removeChild(extra);
|
|
|
|
delete extra;
|
|
|
|
}
|
|
|
|
mThemeExtras.clear();
|
2017-04-22 14:15:16 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
// Add new theme extras.
|
|
|
|
mThemeExtras = ThemeData::makeExtras(theme, getName(), mWindow);
|
|
|
|
for (auto extra : mThemeExtras)
|
|
|
|
addChild(extra);
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
if (mHeaderImage.hasImage()) {
|
|
|
|
removeChild(&mHeaderText);
|
|
|
|
addChild(&mHeaderImage);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
addChild(&mHeaderText);
|
|
|
|
removeChild(&mHeaderImage);
|
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
2017-11-17 14:58:52 +00:00
|
|
|
void ISimpleGameListView::onFileChanged(FileData* /*file*/, FileChangeType /*change*/)
|
2014-06-25 16:29:58 +00:00
|
|
|
{
|
2020-06-21 12:25:28 +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();
|
|
|
|
if (!cursor->isPlaceHolder()) {
|
|
|
|
populateList(cursor->getParent()->getChildrenListToDisplay());
|
|
|
|
setCursor(cursor);
|
|
|
|
}
|
2020-07-13 18:58:25 +00:00
|
|
|
else {
|
2020-06-21 12:25:28 +00:00
|
|
|
populateList(mRoot->getChildrenListToDisplay());
|
|
|
|
setCursor(cursor);
|
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool ISimpleGameListView::input(InputConfig* config, Input input)
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
if (input.value != 0) {
|
|
|
|
if (config->isMappedTo("a", input)) {
|
|
|
|
FileData* cursor = getCursor();
|
|
|
|
if (cursor->getType() == GAME) {
|
|
|
|
launch(cursor);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// It's a folder.
|
|
|
|
if (cursor->getChildren().size() > 0) {
|
|
|
|
NavigationSounds::getInstance()->playThemeNavigationSound(SELECTSOUND);
|
|
|
|
mCursorStack.push(cursor);
|
|
|
|
populateList(cursor->getChildrenListToDisplay());
|
|
|
|
FileData* cursor = getCursor();
|
|
|
|
setCursor(cursor);
|
|
|
|
}
|
|
|
|
}
|
2017-05-18 10:16:57 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (config->isMappedTo("b", input)) {
|
|
|
|
if (mCursorStack.size()) {
|
|
|
|
NavigationSounds::getInstance()->playThemeNavigationSound(BACKSOUND);
|
|
|
|
populateList(mCursorStack.top()->getParent()->getChildren());
|
|
|
|
setCursor(mCursorStack.top());
|
|
|
|
mCursorStack.pop();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
NavigationSounds::getInstance()->playThemeNavigationSound(BACKSOUND);
|
|
|
|
onFocusLost();
|
|
|
|
SystemData* systemToView = getCursor()->getSystem();
|
|
|
|
if (systemToView->isCollection())
|
|
|
|
systemToView = CollectionSystemManager::get()->getSystemToView(systemToView);
|
2020-07-13 18:58:25 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
ViewController::get()->goToSystemView(systemToView);
|
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else if (config->isMappedLike(getQuickSystemSelectRightButton(), input)) {
|
|
|
|
if (Settings::getInstance()->getBool("QuickSystemSelect")) {
|
|
|
|
onFocusLost();
|
|
|
|
ViewController::get()->goToNextGameList();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (config->isMappedLike(getQuickSystemSelectLeftButton(), input)) {
|
|
|
|
if (Settings::getInstance()->getBool("QuickSystemSelect")) {
|
|
|
|
onFocusLost();
|
|
|
|
ViewController::get()->goToPrevGameList();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (config->isMappedTo("x", input)) {
|
|
|
|
if (mRoot->getSystem()->isGameSystem()) {
|
|
|
|
// Go to random system game.
|
|
|
|
NavigationSounds::getInstance()->playThemeNavigationSound(SCROLLSOUND);
|
2020-07-28 13:19:54 +00:00
|
|
|
FileData* randomGame = getCursor()->getSystem()->getRandomGame(getCursor());
|
2020-06-21 12:25:28 +00:00
|
|
|
if (randomGame)
|
|
|
|
setCursor(randomGame);
|
2020-07-28 13:19:54 +00:00
|
|
|
// If it's not a game, maybe it's a folder for an unthemed collection.
|
|
|
|
else if (getCursor()->getSystem()->isCollection()) {
|
|
|
|
FileData* randomFolder =
|
|
|
|
mRoot->getSystem()->getRandomCollectionFolder(getCursor());
|
|
|
|
if (randomFolder)
|
|
|
|
setCursor(randomFolder);
|
|
|
|
}
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (config->isMappedTo("y", input) &&
|
|
|
|
!UIModeController::getInstance()->isUIModeKid()) {
|
|
|
|
if (mRoot->getSystem()->isGameSystem()) {
|
|
|
|
if (getCursor()->getType() == GAME)
|
|
|
|
NavigationSounds::getInstance()->playThemeNavigationSound(FAVORITESOUND);
|
|
|
|
if (CollectionSystemManager::get()->toggleGameInCollection(getCursor()))
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
return IGameListView::input(config, input);
|
2014-06-25 16:29:58 +00:00
|
|
|
}
|