ES-DE/es-app/src/views/GamelistBase.h

102 lines
3.2 KiB
C
Raw Normal View History

// SPDX-License-Identifier: MIT
//
// EmulationStation Desktop Edition
// GamelistBase.h
//
// Gamelist base class with utility functions and other low-level logic.
//
#ifndef ES_APP_VIEWS_GAMELIST_BASE_H
#define ES_APP_VIEWS_GAMELIST_BASE_H
#include "FileData.h"
#include "GuiComponent.h"
#include "SystemData.h"
#include "ThemeData.h"
#include "Window.h"
#include "components/BadgeComponent.h"
#include "components/DateTimeComponent.h"
#include "components/RatingComponent.h"
#include "components/ScrollableContainer.h"
#include "components/TextComponent.h"
#include "components/TextListComponent.h"
#include <stack>
class GamelistBase : public GuiComponent
{
public:
FileData* getCursor() { return mList.getSelected(); }
void setCursor(FileData*);
bool input(InputConfig* config, Input input) override;
FileData* getNextEntry() { return mList.getNext(); }
FileData* getPreviousEntry() { return mList.getPrevious(); }
FileData* getFirstEntry() { return mList.getFirst(); }
FileData* getLastEntry() { return mList.getLast(); }
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
// during a view reload. The calling function stores the history temporarily.
void copyCursorHistory(std::vector<FileData*>& cursorHistory)
{
cursorHistory = mCursorStackHistory;
}
void populateCursorHistory(std::vector<FileData*>& cursorHistory)
{
mCursorStackHistory = cursorHistory;
}
FileData* mRoot;
TextListComponent<FileData*> mList;
// Points to the first game in the list, i.e. the first entry which is of the type "GAME".
FileData* mFirstGameEntry;
// This game is randomly selected in the grouped custom collections view.
FileData* mRandomGame;
FileData* mLastUpdated;
std::stack<FileData*> mCursorStack;
std::vector<FileData*> mCursorStackHistory;
std::vector<std::string> mFirstLetterIndex;
unsigned int mGameCount;
unsigned int mFavoritesGameCount;
unsigned int mFilteredGameCount;
unsigned int mFilteredGameCountAll;
bool mIsFiltered;
bool mIsFolder;
private:
};
#endif // ES_APP_VIEWS_GAMELIST_BASE_H