mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-29 09:35:39 +00:00
Replaced the legacy gamelist code with rudimentary support for GamelistBase and GamelistView.
This commit is contained in:
parent
dfeddebc66
commit
51578903ff
|
@ -49,12 +49,6 @@ set(ES_HEADERS
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/ScreenScraper.h
|
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/ScreenScraper.h
|
||||||
|
|
||||||
# Views
|
# Views
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/BasicGamelistView.h
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/DetailedGamelistView.h
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/GridGamelistView.h
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/IGamelistView.h
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/ISimpleGamelistView.h
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/VideoGamelistView.h
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/GamelistBase.h
|
${CMAKE_CURRENT_SOURCE_DIR}/src/views/GamelistBase.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/GamelistView.h
|
${CMAKE_CURRENT_SOURCE_DIR}/src/views/GamelistView.h
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/SystemView.h
|
${CMAKE_CURRENT_SOURCE_DIR}/src/views/SystemView.h
|
||||||
|
@ -101,12 +95,6 @@ set(ES_SOURCES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/ScreenScraper.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/scrapers/ScreenScraper.cpp
|
||||||
|
|
||||||
# Views
|
# Views
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/BasicGamelistView.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/DetailedGamelistView.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/GridGamelistView.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/IGamelistView.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/ISimpleGamelistView.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/gamelist/VideoGamelistView.cpp
|
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/GamelistBase.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/views/GamelistBase.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/GamelistView.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/views/GamelistView.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/src/views/SystemView.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/src/views/SystemView.cpp
|
||||||
|
|
|
@ -32,8 +32,8 @@
|
||||||
#include "utils/FileSystemUtil.h"
|
#include "utils/FileSystemUtil.h"
|
||||||
#include "utils/StringUtil.h"
|
#include "utils/StringUtil.h"
|
||||||
#include "utils/TimeUtil.h"
|
#include "utils/TimeUtil.h"
|
||||||
|
#include "views/GamelistView.h"
|
||||||
#include "views/ViewController.h"
|
#include "views/ViewController.h"
|
||||||
#include "views/gamelist/IGamelistView.h"
|
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
|
@ -449,7 +449,7 @@ void CollectionSystemsManager::updateCollectionSystem(FileData* file, Collection
|
||||||
auto nTime = Utils::Time::now();
|
auto nTime = Utils::Time::now();
|
||||||
if (nTime - Utils::Time::stringToTime(file->metadata.get("lastplayed")) < 2) {
|
if (nTime - Utils::Time::stringToTime(file->metadata.get("lastplayed")) < 2) {
|
||||||
// Select the first row of the gamelist (the game just played).
|
// Select the first row of the gamelist (the game just played).
|
||||||
IGamelistView* gameList = ViewController::getInstance()
|
GamelistView* gameList = ViewController::getInstance()
|
||||||
->getGamelistView(getSystemToView(sysData.system))
|
->getGamelistView(getSystemToView(sysData.system))
|
||||||
.get();
|
.get();
|
||||||
gameList->setCursor(gameList->getFirstEntry());
|
gameList->setCursor(gameList->getFirstEntry());
|
||||||
|
@ -1286,7 +1286,7 @@ void CollectionSystemsManager::addEnabledCollectionsToDisplayedSystems(
|
||||||
rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
|
rootFolder->getSortTypeFromString(rootFolder->getSortTypeString()),
|
||||||
Settings::getInstance()->getBool("FavFirstCustom"));
|
Settings::getInstance()->getBool("FavFirstCustom"));
|
||||||
// Jump to the first row of the game list, assuming it's not empty.
|
// Jump to the first row of the game list, assuming it's not empty.
|
||||||
IGamelistView* gameList =
|
GamelistView* gameList =
|
||||||
ViewController::getInstance()->getGamelistView((it->second.system)).get();
|
ViewController::getInstance()->getGamelistView((it->second.system)).get();
|
||||||
if (!gameList->getCursor()->isPlaceHolder()) {
|
if (!gameList->getCursor()->isPlaceHolder()) {
|
||||||
gameList->setCursor(gameList->getFirstEntry());
|
gameList->setCursor(gameList->getFirstEntry());
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
#include "resources/Font.h"
|
#include "resources/Font.h"
|
||||||
#include "utils/FileSystemUtil.h"
|
#include "utils/FileSystemUtil.h"
|
||||||
#include "utils/StringUtil.h"
|
#include "utils/StringUtil.h"
|
||||||
|
#include "views/GamelistView.h"
|
||||||
#include "views/ViewController.h"
|
#include "views/ViewController.h"
|
||||||
#include "views/gamelist/IGamelistView.h"
|
|
||||||
|
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
@ -211,7 +211,7 @@ void Screensaver::launchGame()
|
||||||
// Launching game
|
// Launching game
|
||||||
ViewController::getInstance()->triggerGameLaunch(mCurrentGame);
|
ViewController::getInstance()->triggerGameLaunch(mCurrentGame);
|
||||||
ViewController::getInstance()->goToGamelist(mCurrentGame->getSystem());
|
ViewController::getInstance()->goToGamelist(mCurrentGame->getSystem());
|
||||||
IGamelistView* view =
|
GamelistView* view =
|
||||||
ViewController::getInstance()->getGamelistView(mCurrentGame->getSystem()).get();
|
ViewController::getInstance()->getGamelistView(mCurrentGame->getSystem()).get();
|
||||||
view->setCursor(mCurrentGame);
|
view->setCursor(mCurrentGame);
|
||||||
ViewController::getInstance()->cancelViewTransitions();
|
ViewController::getInstance()->cancelViewTransitions();
|
||||||
|
@ -223,7 +223,7 @@ void Screensaver::goToGame()
|
||||||
if (mCurrentGame != nullptr) {
|
if (mCurrentGame != nullptr) {
|
||||||
// Go to the game in the gamelist view, but don't launch it.
|
// Go to the game in the gamelist view, but don't launch it.
|
||||||
ViewController::getInstance()->goToGamelist(mCurrentGame->getSystem());
|
ViewController::getInstance()->goToGamelist(mCurrentGame->getSystem());
|
||||||
IGamelistView* view =
|
GamelistView* view =
|
||||||
ViewController::getInstance()->getGamelistView(mCurrentGame->getSystem()).get();
|
ViewController::getInstance()->getGamelistView(mCurrentGame->getSystem()).get();
|
||||||
view->setCursor(mCurrentGame);
|
view->setCursor(mCurrentGame);
|
||||||
ViewController::getInstance()->cancelViewTransitions();
|
ViewController::getInstance()->cancelViewTransitions();
|
||||||
|
|
|
@ -22,8 +22,8 @@
|
||||||
#include "resources/ResourceManager.h"
|
#include "resources/ResourceManager.h"
|
||||||
#include "utils/FileSystemUtil.h"
|
#include "utils/FileSystemUtil.h"
|
||||||
#include "utils/StringUtil.h"
|
#include "utils/StringUtil.h"
|
||||||
|
#include "views/GamelistView.h"
|
||||||
#include "views/ViewController.h"
|
#include "views/ViewController.h"
|
||||||
#include "views/gamelist/IGamelistView.h"
|
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
|
@ -1212,7 +1212,7 @@ void SystemData::sortSystem(bool reloadGamelist, bool jumpToFirstRow)
|
||||||
ViewController::getInstance()->reloadGamelistView(this, false);
|
ViewController::getInstance()->reloadGamelistView(this, false);
|
||||||
|
|
||||||
if (jumpToFirstRow) {
|
if (jumpToFirstRow) {
|
||||||
IGamelistView* gameList = ViewController::getInstance()->getGamelistView(this).get();
|
GamelistView* gameList {ViewController::getInstance()->getGamelistView(this).get()};
|
||||||
gameList->setCursor(gameList->getFirstEntry());
|
gameList->setCursor(gameList->getFirstEntry());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "guis/GuiGamelistFilter.h"
|
#include "guis/GuiGamelistFilter.h"
|
||||||
#include "scrapers/Scraper.h"
|
#include "scrapers/Scraper.h"
|
||||||
#include "views/ViewController.h"
|
#include "views/ViewController.h"
|
||||||
#include "views/gamelist/IGamelistView.h"
|
|
||||||
|
|
||||||
GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system)
|
GuiGamelistOptions::GuiGamelistOptions(Window* window, SystemData* system)
|
||||||
: GuiComponent {window}
|
: GuiComponent {window}
|
||||||
|
@ -454,7 +453,7 @@ void GuiGamelistOptions::openMetaDataEd()
|
||||||
if (file->getType() == FOLDER) {
|
if (file->getType() == FOLDER) {
|
||||||
mWindow->pushGui(new GuiMetaDataEd(
|
mWindow->pushGui(new GuiMetaDataEd(
|
||||||
mWindow, &file->metadata, file->metadata.getMDD(FOLDER_METADATA), p,
|
mWindow, &file->metadata, file->metadata.getMDD(FOLDER_METADATA), p,
|
||||||
std::bind(&IGamelistView::onFileChanged,
|
std::bind(&GamelistView::onFileChanged,
|
||||||
ViewController::getInstance()->getGamelistView(file->getSystem()).get(), file,
|
ViewController::getInstance()->getGamelistView(file->getSystem()).get(), file,
|
||||||
true),
|
true),
|
||||||
clearGameBtnFunc, deleteGameBtnFunc));
|
clearGameBtnFunc, deleteGameBtnFunc));
|
||||||
|
@ -462,7 +461,7 @@ void GuiGamelistOptions::openMetaDataEd()
|
||||||
else {
|
else {
|
||||||
mWindow->pushGui(new GuiMetaDataEd(
|
mWindow->pushGui(new GuiMetaDataEd(
|
||||||
mWindow, &file->metadata, file->metadata.getMDD(GAME_METADATA), p,
|
mWindow, &file->metadata, file->metadata.getMDD(GAME_METADATA), p,
|
||||||
std::bind(&IGamelistView::onFileChanged,
|
std::bind(&GamelistView::onFileChanged,
|
||||||
ViewController::getInstance()->getGamelistView(file->getSystem()).get(), file,
|
ViewController::getInstance()->getGamelistView(file->getSystem()).get(), file,
|
||||||
true),
|
true),
|
||||||
clearGameBtnFunc, deleteGameBtnFunc));
|
clearGameBtnFunc, deleteGameBtnFunc));
|
||||||
|
@ -566,7 +565,7 @@ std::vector<HelpPrompt> GuiGamelistOptions::getHelpPrompts()
|
||||||
return prompts;
|
return prompts;
|
||||||
}
|
}
|
||||||
|
|
||||||
IGamelistView* GuiGamelistOptions::getGamelist()
|
GamelistView* GuiGamelistOptions::getGamelist()
|
||||||
{
|
{
|
||||||
return ViewController::getInstance()->getGamelistView(mSystem).get();
|
return ViewController::getInstance()->getGamelistView(mSystem).get();
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
#include "components/MenuComponent.h"
|
#include "components/MenuComponent.h"
|
||||||
#include "components/OptionListComponent.h"
|
#include "components/OptionListComponent.h"
|
||||||
#include "utils/StringUtil.h"
|
#include "utils/StringUtil.h"
|
||||||
|
#include "views/GamelistView.h"
|
||||||
|
|
||||||
class IGamelistView;
|
|
||||||
class SystemData;
|
class SystemData;
|
||||||
|
|
||||||
class GuiGamelistOptions : public GuiComponent
|
class GuiGamelistOptions : public GuiComponent
|
||||||
|
@ -50,7 +50,7 @@ private:
|
||||||
std::shared_ptr<SortList> mListSort;
|
std::shared_ptr<SortList> mListSort;
|
||||||
|
|
||||||
SystemData* mSystem;
|
SystemData* mSystem;
|
||||||
IGamelistView* getGamelist();
|
GamelistView* getGamelist();
|
||||||
bool mFoldersOnTop;
|
bool mFoldersOnTop;
|
||||||
bool mFavoritesSorting;
|
bool mFavoritesSorting;
|
||||||
bool mOnlyHasFolders;
|
bool mOnlyHasFolders;
|
||||||
|
|
|
@ -35,7 +35,6 @@
|
||||||
#include "guis/GuiTextEditPopup.h"
|
#include "guis/GuiTextEditPopup.h"
|
||||||
#include "utils/PlatformUtil.h"
|
#include "utils/PlatformUtil.h"
|
||||||
#include "views/ViewController.h"
|
#include "views/ViewController.h"
|
||||||
#include "views/gamelist/IGamelistView.h"
|
|
||||||
|
|
||||||
#include <SDL2/SDL_events.h>
|
#include <SDL2/SDL_events.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
#include "components/HelpComponent.h"
|
#include "components/HelpComponent.h"
|
||||||
#include "guis/GuiTextEditKeyboardPopup.h"
|
#include "guis/GuiTextEditKeyboardPopup.h"
|
||||||
#include "guis/GuiTextEditPopup.h"
|
#include "guis/GuiTextEditPopup.h"
|
||||||
|
#include "views/GamelistView.h"
|
||||||
#include "views/ViewController.h"
|
#include "views/ViewController.h"
|
||||||
#include "views/gamelist/IGamelistView.h"
|
|
||||||
|
|
||||||
GuiSettings::GuiSettings(Window* window, std::string title)
|
GuiSettings::GuiSettings(Window* window, std::string title)
|
||||||
: GuiComponent(window)
|
: GuiComponent(window)
|
||||||
|
@ -77,7 +77,7 @@ void GuiSettings::save()
|
||||||
(*it)->sortSystem(true);
|
(*it)->sortSystem(true);
|
||||||
|
|
||||||
// Jump to the first row of the gamelist.
|
// Jump to the first row of the gamelist.
|
||||||
IGamelistView* gameList = ViewController::getInstance()->getGamelistView((*it)).get();
|
GamelistView* gameList = ViewController::getInstance()->getGamelistView((*it)).get();
|
||||||
gameList->setCursor(gameList->getFirstEntry());
|
gameList->setCursor(gameList->getFirstEntry());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,15 @@ GamelistBase::GamelistBase(Window* window, FileData* root)
|
||||||
, mRandomGame {nullptr}
|
, mRandomGame {nullptr}
|
||||||
, mLastUpdated(nullptr)
|
, mLastUpdated(nullptr)
|
||||||
{
|
{
|
||||||
|
setSize(static_cast<float>(Renderer::getScreenWidth()),
|
||||||
|
static_cast<float>(Renderer::getScreenHeight()));
|
||||||
|
|
||||||
|
mList.setSize(mSize.x, mSize.y * 0.8f);
|
||||||
|
mList.setPosition(0.0f, mSize.y * 0.2f);
|
||||||
|
mList.setDefaultZIndex(20.0f);
|
||||||
|
addChild(&mList);
|
||||||
|
|
||||||
|
populateList(root->getChildrenListToDisplay(), root);
|
||||||
}
|
}
|
||||||
|
|
||||||
GamelistBase::~GamelistBase()
|
GamelistBase::~GamelistBase()
|
||||||
|
@ -381,12 +390,11 @@ bool GamelistBase::input(InputConfig* config, Input input)
|
||||||
// was unmarked. We couldn't do this earlier as we didn't have the list
|
// was unmarked. We couldn't do this earlier as we didn't have the list
|
||||||
// sorted yet.
|
// sorted yet.
|
||||||
if (removedLastFavorite) {
|
if (removedLastFavorite) {
|
||||||
// TEMPORARY
|
ViewController::getInstance()
|
||||||
// ViewController::getInstance()
|
->getGamelistView(entryToUpdate->getSystem())
|
||||||
// ->getGamelistView(entryToUpdate->getSystem())
|
->setCursor(ViewController::getInstance()
|
||||||
// ->setCursor(ViewController::getInstance()
|
->getGamelistView(entryToUpdate->getSystem())
|
||||||
// ->getGamelistView(entryToUpdate->getSystem())
|
->getFirstEntry());
|
||||||
// ->getFirstEntry());
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -400,27 +408,25 @@ bool GamelistBase::input(InputConfig* config, Input input)
|
||||||
// As the toggling of the game destroyed this object, we need to get the view
|
// As the toggling of the game destroyed this object, we need to get the view
|
||||||
// from ViewController instead of using the reference that existed before the
|
// from ViewController instead of using the reference that existed before the
|
||||||
// destruction. Otherwise we get random crashes.
|
// destruction. Otherwise we get random crashes.
|
||||||
// TEMPORARY
|
GamelistView* view =
|
||||||
// IGamelistView* view =
|
ViewController::getInstance()->getGamelistView(system).get();
|
||||||
// ViewController::getInstance()->getGamelistView(system).get();
|
|
||||||
// Jump to the first entry in the gamelist if the last favorite was unmarked.
|
// Jump to the first entry in the gamelist if the last favorite was unmarked.
|
||||||
if (foldersOnTop && removedLastFavorite &&
|
if (foldersOnTop && removedLastFavorite &&
|
||||||
!entryToUpdate->getSystem()->isCustomCollection()) {
|
!entryToUpdate->getSystem()->isCustomCollection()) {
|
||||||
// TEMPORARY
|
ViewController::getInstance()
|
||||||
// ViewController::getInstance()
|
->getGamelistView(entryToUpdate->getSystem())
|
||||||
// ->getGamelistView(entryToUpdate->getSystem())
|
->setCursor(ViewController::getInstance()
|
||||||
// ->setCursor(ViewController::getInstance()
|
->getGamelistView(entryToUpdate->getSystem())
|
||||||
// ->getGamelistView(entryToUpdate->getSystem())
|
->getFirstGameEntry());
|
||||||
// ->getFirstGameEntry());
|
|
||||||
}
|
}
|
||||||
else if (removedLastFavorite &&
|
else if (removedLastFavorite &&
|
||||||
!entryToUpdate->getSystem()->isCustomCollection()) {
|
!entryToUpdate->getSystem()->isCustomCollection()) {
|
||||||
setCursor(getFirstEntry());
|
setCursor(getFirstEntry());
|
||||||
// view->setCursor(view->getFirstEntry());
|
view->setCursor(view->getFirstEntry());
|
||||||
}
|
}
|
||||||
else if (selectLastEntry) {
|
else if (selectLastEntry) {
|
||||||
setCursor(getLastEntry());
|
setCursor(getLastEntry());
|
||||||
// view->setCursor(view->getLastEntry());
|
view->setCursor(view->getLastEntry());
|
||||||
}
|
}
|
||||||
// Display the indication icons which show what games are part of the
|
// Display the indication icons which show what games are part of the
|
||||||
// custom collection currently being edited. This is done cheaply using
|
// custom collection currently being edited. This is done cheaply using
|
||||||
|
@ -428,10 +434,9 @@ bool GamelistBase::input(InputConfig* config, Input input)
|
||||||
if (isEditing) {
|
if (isEditing) {
|
||||||
for (auto it = SystemData::sSystemVector.begin();
|
for (auto it = SystemData::sSystemVector.begin();
|
||||||
it != SystemData::sSystemVector.end(); ++it) {
|
it != SystemData::sSystemVector.end(); ++it) {
|
||||||
// TEMPORARY
|
ViewController::getInstance()->getGamelistView((*it))->onFileChanged(
|
||||||
// ViewController::getInstance()->getGamelistView((*it))->onFileChanged(
|
ViewController::getInstance()->getGamelistView((*it))->getCursor(),
|
||||||
// ViewController::getInstance()->getGamelistView((*it))->getCursor(),
|
false);
|
||||||
// false);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -443,7 +448,6 @@ bool GamelistBase::input(InputConfig* config, Input input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// return IGamelistView::input(config, input);
|
|
||||||
// Select button opens GuiGamelistOptions.
|
// Select button opens GuiGamelistOptions.
|
||||||
if (!UIModeController::getInstance()->isUIModeKid() && // Line break.
|
if (!UIModeController::getInstance()->isUIModeKid() && // Line break.
|
||||||
config->isMappedTo("back", input) && input.value) {
|
config->isMappedTo("back", input) && input.value) {
|
||||||
|
@ -458,9 +462,8 @@ bool GamelistBase::input(InputConfig* config, Input input)
|
||||||
config->getDeviceId() == DEVICE_KEYBOARD &&
|
config->getDeviceId() == DEVICE_KEYBOARD &&
|
||||||
(SDL_GetModState() & (KMOD_LCTRL | KMOD_RCTRL)) && input.id == SDLK_r &&
|
(SDL_GetModState() & (KMOD_LCTRL | KMOD_RCTRL)) && input.id == SDLK_r &&
|
||||||
input.value != 0) {
|
input.value != 0) {
|
||||||
LOG(LogDebug) << "IGamelistView::input(): Reloading view";
|
LOG(LogDebug) << "GamelistView::input(): Reloading view";
|
||||||
// TEMPORARY
|
ViewController::getInstance()->reloadGamelistView(this->mRoot->getSystem(), true);
|
||||||
// ViewController::getInstance()->reloadGamelistView(this, true);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,31 +37,6 @@ public:
|
||||||
FileData* getLastEntry() { return mList.getLast(); }
|
FileData* getLastEntry() { return mList.getLast(); }
|
||||||
FileData* getFirstGameEntry() { return mFirstGameEntry; }
|
FileData* getFirstGameEntry() { return mFirstGameEntry; }
|
||||||
|
|
||||||
protected:
|
|
||||||
GamelistBase(Window* window, FileData* root);
|
|
||||||
~GamelistBase();
|
|
||||||
|
|
||||||
// Called when a FileData* is added, has its metadata changed, or is removed.
|
|
||||||
virtual void onFileChanged(FileData* file, bool reloadGamelist) = 0;
|
|
||||||
|
|
||||||
void populateList(const std::vector<FileData*>& files, FileData* firstEntry);
|
|
||||||
void addPlaceholder(FileData*);
|
|
||||||
|
|
||||||
void generateFirstLetterIndex(const std::vector<FileData*>& files);
|
|
||||||
void generateGamelistInfo(FileData* cursor, FileData* firstEntry);
|
|
||||||
|
|
||||||
void remove(FileData* game, bool deleteFile);
|
|
||||||
void removeMedia(FileData* game);
|
|
||||||
|
|
||||||
virtual void launch(FileData* game) = 0;
|
|
||||||
|
|
||||||
bool isListScrolling() override { return mList.isScrolling(); }
|
|
||||||
void stopListScrolling() override { mList.stopScrolling(); }
|
|
||||||
|
|
||||||
const std::vector<std::string>& getFirstLetterIndex() { return mFirstLetterIndex; }
|
|
||||||
std::string getQuickSystemSelectRightButton() { return "right"; }
|
|
||||||
std::string getQuickSystemSelectLeftButton() { return "left"; }
|
|
||||||
|
|
||||||
// These functions are used to retain the folder cursor history, for instance
|
// These functions are used to retain the folder cursor history, for instance
|
||||||
// during a view reload. The calling function stores the history temporarily.
|
// during a view reload. The calling function stores the history temporarily.
|
||||||
void copyCursorHistory(std::vector<FileData*>& cursorHistory)
|
void copyCursorHistory(std::vector<FileData*>& cursorHistory)
|
||||||
|
@ -73,6 +48,33 @@ protected:
|
||||||
mCursorStackHistory = cursorHistory;
|
mCursorStackHistory = cursorHistory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void addPlaceholder(FileData*);
|
||||||
|
|
||||||
|
void remove(FileData* game, bool deleteFile);
|
||||||
|
void removeMedia(FileData* game);
|
||||||
|
|
||||||
|
const std::vector<std::string>& getFirstLetterIndex() { return mFirstLetterIndex; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
GamelistBase(Window* window, FileData* root);
|
||||||
|
~GamelistBase();
|
||||||
|
|
||||||
|
// Called when a FileData* is added, has its metadata changed, or is removed.
|
||||||
|
virtual void onFileChanged(FileData* file, bool reloadGamelist) = 0;
|
||||||
|
|
||||||
|
void populateList(const std::vector<FileData*>& files, FileData* firstEntry);
|
||||||
|
|
||||||
|
void generateFirstLetterIndex(const std::vector<FileData*>& files);
|
||||||
|
void generateGamelistInfo(FileData* cursor, FileData* firstEntry);
|
||||||
|
|
||||||
|
virtual void launch(FileData* game) = 0;
|
||||||
|
|
||||||
|
bool isListScrolling() override { return mList.isScrolling(); }
|
||||||
|
void stopListScrolling() override { mList.stopScrolling(); }
|
||||||
|
|
||||||
|
std::string getQuickSystemSelectRightButton() { return "right"; }
|
||||||
|
std::string getQuickSystemSelectLeftButton() { return "left"; }
|
||||||
|
|
||||||
FileData* mRoot;
|
FileData* mRoot;
|
||||||
TextListComponent<FileData*> mList;
|
TextListComponent<FileData*> mList;
|
||||||
|
|
||||||
|
|
|
@ -45,20 +45,41 @@ GamelistView::GamelistView(Window* window, FileData* root)
|
||||||
, mDescription {window}
|
, mDescription {window}
|
||||||
, mGamelistInfo {window}
|
, mGamelistInfo {window}
|
||||||
{
|
{
|
||||||
|
mHeaderText.setText("Logo Text", false);
|
||||||
|
mHeaderText.setSize(mSize.x, 0.0f);
|
||||||
|
mHeaderText.setPosition(0.0f, 0.0f);
|
||||||
|
mHeaderText.setHorizontalAlignment(ALIGN_CENTER);
|
||||||
|
mHeaderText.setDefaultZIndex(50.0f);
|
||||||
|
|
||||||
mHeaderText.setText(mRoot->getSystem()->getFullName());
|
mHeaderText.setText(mRoot->getSystem()->getFullName());
|
||||||
|
|
||||||
|
mHeaderImage.setResize(0.0f, mSize.y * 0.185f);
|
||||||
|
mHeaderImage.setOrigin(0.5f, 0.0f);
|
||||||
|
mHeaderImage.setPosition(mSize.x / 2.0f, 0.0f);
|
||||||
|
mHeaderImage.setDefaultZIndex(50.0f);
|
||||||
|
|
||||||
|
mBackground.setResize(mSize.x, mSize.y);
|
||||||
|
mBackground.setDefaultZIndex(0.0f);
|
||||||
|
|
||||||
|
addChild(&mHeaderText);
|
||||||
|
addChild(&mBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
GamelistView::~GamelistView()
|
GamelistView::~GamelistView()
|
||||||
{
|
{
|
||||||
//
|
// Remove theme extras.
|
||||||
|
for (auto extra : mThemeExtras) {
|
||||||
|
removeChild(extra);
|
||||||
|
delete extra;
|
||||||
|
}
|
||||||
|
mThemeExtras.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GamelistView::onFileChanged(FileData* file, bool reloadGamelist)
|
void GamelistView::onFileChanged(FileData* file, bool reloadGamelist)
|
||||||
{
|
{
|
||||||
if (reloadGamelist) {
|
if (reloadGamelist) {
|
||||||
// Might switch to a detailed view.
|
// Might switch to a detailed view.
|
||||||
// TEMPORARY.
|
ViewController::getInstance()->reloadGamelistView(this);
|
||||||
// ViewController::getInstance()->reloadGamelistView(this);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,8 @@
|
||||||
#include "guis/GuiMenu.h"
|
#include "guis/GuiMenu.h"
|
||||||
#include "guis/GuiTextEditKeyboardPopup.h"
|
#include "guis/GuiTextEditKeyboardPopup.h"
|
||||||
#include "guis/GuiTextEditPopup.h"
|
#include "guis/GuiTextEditPopup.h"
|
||||||
|
#include "views/GamelistView.h"
|
||||||
#include "views/SystemView.h"
|
#include "views/SystemView.h"
|
||||||
#include "views/gamelist/DetailedGamelistView.h"
|
|
||||||
#include "views/gamelist/GridGamelistView.h"
|
|
||||||
#include "views/gamelist/IGamelistView.h"
|
|
||||||
#include "views/gamelist/VideoGamelistView.h"
|
|
||||||
|
|
||||||
ViewController* ViewController::getInstance()
|
ViewController* ViewController::getInstance()
|
||||||
{
|
{
|
||||||
|
@ -718,7 +715,7 @@ void ViewController::removeGamelistView(SystemData* system)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<IGamelistView> ViewController::getGamelistView(SystemData* system)
|
std::shared_ptr<GamelistView> ViewController::getGamelistView(SystemData* system)
|
||||||
{
|
{
|
||||||
// If we have already created an entry for this system, then return that one.
|
// If we have already created an entry for this system, then return that one.
|
||||||
auto exists = mGamelistViews.find(system);
|
auto exists = mGamelistViews.find(system);
|
||||||
|
@ -727,14 +724,14 @@ std::shared_ptr<IGamelistView> ViewController::getGamelistView(SystemData* syste
|
||||||
|
|
||||||
system->getIndex()->setKidModeFilters();
|
system->getIndex()->setKidModeFilters();
|
||||||
// If there's no entry, then create it and return it.
|
// If there's no entry, then create it and return it.
|
||||||
std::shared_ptr<IGamelistView> view;
|
std::shared_ptr<GamelistView> view;
|
||||||
|
|
||||||
bool themeHasVideoView = system->getTheme()->hasView("video");
|
bool themeHasVideoView {system->getTheme()->hasView("video")};
|
||||||
|
|
||||||
// Decide which view style to use.
|
// Decide which view style to use.
|
||||||
GamelistViewStyle selectedViewStyle = AUTOMATIC;
|
GamelistViewStyle selectedViewStyle = AUTOMATIC;
|
||||||
|
|
||||||
std::string viewPreference = Settings::getInstance()->getString("GamelistViewStyle");
|
std::string viewPreference {Settings::getInstance()->getString("GamelistViewStyle")};
|
||||||
if (viewPreference.compare("basic") == 0)
|
if (viewPreference.compare("basic") == 0)
|
||||||
selectedViewStyle = BASIC;
|
selectedViewStyle = BASIC;
|
||||||
if (viewPreference.compare("detailed") == 0)
|
if (viewPreference.compare("detailed") == 0)
|
||||||
|
@ -745,7 +742,7 @@ std::shared_ptr<IGamelistView> ViewController::getGamelistView(SystemData* syste
|
||||||
selectedViewStyle = VIDEO;
|
selectedViewStyle = VIDEO;
|
||||||
|
|
||||||
if (selectedViewStyle == AUTOMATIC) {
|
if (selectedViewStyle == AUTOMATIC) {
|
||||||
std::vector<FileData*> files = system->getRootFolder()->getFilesRecursive(GAME | FOLDER);
|
std::vector<FileData*> files {system->getRootFolder()->getFilesRecursive(GAME | FOLDER)};
|
||||||
for (auto it = files.cbegin(); it != files.cend(); ++it) {
|
for (auto it = files.cbegin(); it != files.cend(); ++it) {
|
||||||
if (themeHasVideoView && !(*it)->getVideoPath().empty()) {
|
if (themeHasVideoView && !(*it)->getVideoPath().empty()) {
|
||||||
selectedViewStyle = VIDEO;
|
selectedViewStyle = VIDEO;
|
||||||
|
@ -759,6 +756,7 @@ std::shared_ptr<IGamelistView> ViewController::getGamelistView(SystemData* syste
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the view.
|
// Create the view.
|
||||||
|
/*
|
||||||
switch (selectedViewStyle) {
|
switch (selectedViewStyle) {
|
||||||
case VIDEO: {
|
case VIDEO: {
|
||||||
view = std::shared_ptr<IGamelistView>(
|
view = std::shared_ptr<IGamelistView>(
|
||||||
|
@ -787,11 +785,13 @@ std::shared_ptr<IGamelistView> ViewController::getGamelistView(SystemData* syste
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
view = std::shared_ptr<GamelistView>(new GamelistView(mWindow, system->getRootFolder()));
|
||||||
|
|
||||||
view->setTheme(system->getTheme());
|
view->setTheme(system->getTheme());
|
||||||
|
|
||||||
std::vector<SystemData*>& sysVec = SystemData::sSystemVector;
|
std::vector<SystemData*>& sysVec = SystemData::sSystemVector;
|
||||||
int id = static_cast<int>(std::find(sysVec.cbegin(), sysVec.cend(), system) - sysVec.cbegin());
|
int id {static_cast<int>(std::find(sysVec.cbegin(), sysVec.cend(), system) - sysVec.cbegin())};
|
||||||
view->setPosition(id * static_cast<float>(Renderer::getScreenWidth()),
|
view->setPosition(id * static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight() * 2));
|
static_cast<float>(Renderer::getScreenHeight() * 2));
|
||||||
|
|
||||||
|
@ -967,13 +967,13 @@ void ViewController::preload()
|
||||||
NavigationSounds::getInstance().loadThemeNavigationSounds(nullptr);
|
NavigationSounds::getInstance().loadThemeNavigationSounds(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ViewController::reloadGamelistView(IGamelistView* view, bool reloadTheme)
|
void ViewController::reloadGamelistView(GamelistView* view, bool reloadTheme)
|
||||||
{
|
{
|
||||||
for (auto it = mGamelistViews.cbegin(); it != mGamelistViews.cend(); ++it) {
|
for (auto it = mGamelistViews.cbegin(); it != mGamelistViews.cend(); ++it) {
|
||||||
if (it->second.get() == view) {
|
if (it->second.get() == view) {
|
||||||
bool isCurrent = (mCurrentView == it->second);
|
bool isCurrent {(mCurrentView == it->second)};
|
||||||
SystemData* system = it->first;
|
SystemData* system {it->first};
|
||||||
FileData* cursor = view->getCursor();
|
FileData* cursor {view->getCursor()};
|
||||||
|
|
||||||
// Retain the cursor history for the view.
|
// Retain the cursor history for the view.
|
||||||
std::vector<FileData*> cursorHistoryTemp;
|
std::vector<FileData*> cursorHistoryTemp;
|
||||||
|
@ -987,7 +987,7 @@ void ViewController::reloadGamelistView(IGamelistView* view, bool reloadTheme)
|
||||||
if (reloadTheme)
|
if (reloadTheme)
|
||||||
system->loadTheme();
|
system->loadTheme();
|
||||||
system->getIndex()->setKidModeFilters();
|
system->getIndex()->setKidModeFilters();
|
||||||
std::shared_ptr<IGamelistView> newView = getGamelistView(system);
|
std::shared_ptr<GamelistView> newView = getGamelistView(system);
|
||||||
|
|
||||||
// To counter having come from a placeholder.
|
// To counter having come from a placeholder.
|
||||||
if (!cursor->isPlaceHolder()) {
|
if (!cursor->isPlaceHolder()) {
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class IGamelistView;
|
class GamelistView;
|
||||||
class SystemData;
|
class SystemData;
|
||||||
class SystemView;
|
class SystemView;
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ public:
|
||||||
|
|
||||||
// If a basic view detected a metadata change, it can request to recreate
|
// If a basic view detected a metadata change, it can request to recreate
|
||||||
// the current gamelist view (as it may change to be detailed).
|
// the current gamelist view (as it may change to be detailed).
|
||||||
void reloadGamelistView(IGamelistView* gamelist, bool reloadTheme = false);
|
void reloadGamelistView(GamelistView* gamelist, bool reloadTheme = false);
|
||||||
void reloadGamelistView(SystemData* system, bool reloadTheme = false)
|
void reloadGamelistView(SystemData* system, bool reloadTheme = false)
|
||||||
{
|
{
|
||||||
reloadGamelistView(getGamelistView(system).get(), reloadTheme);
|
reloadGamelistView(getGamelistView(system).get(), reloadTheme);
|
||||||
|
@ -110,10 +110,10 @@ public:
|
||||||
|
|
||||||
const State& getState() const { return mState; }
|
const State& getState() const { return mState; }
|
||||||
|
|
||||||
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
std::vector<HelpPrompt> getHelpPrompts() override;
|
||||||
virtual HelpStyle getHelpStyle() override;
|
HelpStyle getHelpStyle() override;
|
||||||
|
|
||||||
std::shared_ptr<IGamelistView> getGamelistView(SystemData* system);
|
std::shared_ptr<GamelistView> getGamelistView(SystemData* system);
|
||||||
std::shared_ptr<SystemView> getSystemListView();
|
std::shared_ptr<SystemView> getSystemListView();
|
||||||
void removeGamelistView(SystemData* system);
|
void removeGamelistView(SystemData* system);
|
||||||
|
|
||||||
|
@ -158,7 +158,7 @@ private:
|
||||||
std::shared_ptr<GuiComponent> mCurrentView;
|
std::shared_ptr<GuiComponent> mCurrentView;
|
||||||
std::shared_ptr<GuiComponent> mPreviousView;
|
std::shared_ptr<GuiComponent> mPreviousView;
|
||||||
std::shared_ptr<GuiComponent> mSkipView;
|
std::shared_ptr<GuiComponent> mSkipView;
|
||||||
std::map<SystemData*, std::shared_ptr<IGamelistView>> mGamelistViews;
|
std::map<SystemData*, std::shared_ptr<GamelistView>> mGamelistViews;
|
||||||
std::shared_ptr<SystemView> mSystemListView;
|
std::shared_ptr<SystemView> mSystemListView;
|
||||||
|
|
||||||
FileData* mGameToLaunch;
|
FileData* mGameToLaunch;
|
||||||
|
|
Loading…
Reference in a new issue