2020-05-24 08:29:29 +00:00
|
|
|
//
|
2020-06-21 12:25:28 +00:00
|
|
|
// ViewController.h
|
2020-05-24 08:29:29 +00:00
|
|
|
//
|
2020-06-21 12:25:28 +00:00
|
|
|
// Handles overall system navigation including animations and transitions.
|
|
|
|
// Also creates the gamelist views and handles refresh and reloads of these when needed
|
|
|
|
// (for example when metadata has been changed or when a list sorting has taken place).
|
|
|
|
// Initiates the launching of games, calling FileData to do the actual launch.
|
2020-05-24 08:29:29 +00:00
|
|
|
//
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
#pragma once
|
2017-10-31 17:12:50 +00:00
|
|
|
#ifndef ES_APP_VIEWS_VIEW_CONTROLLER_H
|
|
|
|
#define ES_APP_VIEWS_VIEW_CONTROLLER_H
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2019-08-08 20:16:11 +00:00
|
|
|
#include "renderers/Renderer.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "FileData.h"
|
|
|
|
#include "GuiComponent.h"
|
|
|
|
#include <vector>
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2017-11-01 22:21:10 +00:00
|
|
|
class IGameListView;
|
2014-06-25 16:29:58 +00:00
|
|
|
class SystemData;
|
2017-11-01 22:21:10 +00:00
|
|
|
class SystemView;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-05-24 08:29:29 +00:00
|
|
|
// Handles transitions between views, e.g. from system to system and from gamelist to gamelist.
|
|
|
|
// Also sets up the initial gamelists and refreshes and reloads them as required.
|
2014-06-25 16:29:58 +00:00
|
|
|
class ViewController : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
2020-06-21 12:25:28 +00:00
|
|
|
static void init(Window* window);
|
|
|
|
static ViewController* get();
|
|
|
|
|
|
|
|
virtual ~ViewController();
|
|
|
|
|
|
|
|
// Try to completely populate the GameListView map.
|
|
|
|
// Caches things so there's no pauses during transitions.
|
|
|
|
void preload();
|
|
|
|
|
|
|
|
// If a basic view detected a metadata change, it can request to recreate
|
|
|
|
// the current gamelist view (as it may change to be detailed).
|
|
|
|
void reloadGameListView(IGameListView* gamelist, bool reloadTheme = false);
|
|
|
|
inline void reloadGameListView(SystemData* system, bool reloadTheme = false)
|
|
|
|
{ reloadGameListView(getGameListView(system).get(), reloadTheme); }
|
|
|
|
// Reload everything with a theme.
|
|
|
|
// Used when the "ThemeSet" setting changes.
|
|
|
|
void reloadAll();
|
|
|
|
|
|
|
|
// Navigation.
|
|
|
|
void goToNextGameList();
|
|
|
|
void goToPrevGameList();
|
|
|
|
void goToGameList(SystemData* system);
|
|
|
|
void goToSystemView(SystemData* system);
|
|
|
|
void goToStart();
|
|
|
|
void ReloadAndGoToStart();
|
|
|
|
|
|
|
|
void onFileChanged(FileData* file, FileChangeType change);
|
|
|
|
|
|
|
|
// Plays a nice launch effect and launches the game at the end of it.
|
|
|
|
// Once the game terminates, plays a return effect.
|
|
|
|
void launch(FileData* game, Vector3f centerCameraOn =
|
|
|
|
Vector3f(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f, 0));
|
|
|
|
|
|
|
|
bool input(InputConfig* config, Input input) override;
|
|
|
|
void update(int deltaTime) override;
|
|
|
|
void render(const Transform4x4f& parentTrans) override;
|
|
|
|
|
|
|
|
enum ViewMode {
|
|
|
|
NOTHING,
|
|
|
|
START_SCREEN,
|
|
|
|
SYSTEM_SELECT,
|
|
|
|
GAME_LIST
|
|
|
|
};
|
|
|
|
|
|
|
|
enum GameListViewType {
|
|
|
|
AUTOMATIC,
|
|
|
|
BASIC,
|
|
|
|
DETAILED,
|
|
|
|
GRID,
|
|
|
|
VIDEO
|
|
|
|
};
|
|
|
|
|
|
|
|
struct State {
|
|
|
|
ViewMode viewing;
|
|
|
|
|
|
|
|
inline SystemData* getSystem() const
|
|
|
|
{ assert(viewing == GAME_LIST || viewing == SYSTEM_SELECT); return system; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend ViewController;
|
|
|
|
SystemData* system;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline const State& getState() const { return mState; }
|
|
|
|
|
|
|
|
virtual std::vector<HelpPrompt> getHelpPrompts() override;
|
|
|
|
virtual HelpStyle getHelpStyle() override;
|
|
|
|
|
|
|
|
std::shared_ptr<IGameListView> getGameListView(SystemData* system);
|
|
|
|
std::shared_ptr<SystemView> getSystemListView();
|
|
|
|
void removeGameListView(SystemData* system);
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
private:
|
2020-06-21 12:25:28 +00:00
|
|
|
ViewController(Window* window);
|
|
|
|
static ViewController* sInstance;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
void playViewTransition();
|
|
|
|
int getSystemId(SystemData* system);
|
2019-08-25 15:23:02 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
std::shared_ptr<GuiComponent> mCurrentView;
|
2020-08-08 20:33:27 +00:00
|
|
|
std::map<SystemData*, std::shared_ptr<IGameListView>> mGameListViews;
|
2020-06-21 12:25:28 +00:00
|
|
|
std::shared_ptr<SystemView> mSystemListView;
|
2019-08-25 15:23:02 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
Transform4x4f mCamera;
|
|
|
|
float mFadeOpacity;
|
|
|
|
bool mLockInput;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
State mState;
|
2014-06-25 16:29:58 +00:00
|
|
|
};
|
2017-10-31 17:12:50 +00:00
|
|
|
|
|
|
|
#endif // ES_APP_VIEWS_VIEW_CONTROLLER_H
|