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
|
|
|
|
|
|
|
// Used to smoothly transition the camera between multiple views (e.g. from system to system, from gamelist to gamelist).
|
|
|
|
class ViewController : public GuiComponent
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
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); }
|
|
|
|
void reloadAll(); // Reload everything with a theme. Used when the "ThemeSet" setting changes.
|
|
|
|
|
|
|
|
// Navigation.
|
|
|
|
void goToNextGameList();
|
|
|
|
void goToPrevGameList();
|
|
|
|
void goToGameList(SystemData* system);
|
|
|
|
void goToSystemView(SystemData* system);
|
|
|
|
void goToStart();
|
2017-11-18 22:23:56 +00:00
|
|
|
void ReloadAndGoToStart();
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
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.
|
2017-10-28 20:24:35 +00:00
|
|
|
void launch(FileData* game, Vector3f centerCameraOn = Vector3f(Renderer::getScreenWidth() / 2.0f, Renderer::getScreenHeight() / 2.0f, 0));
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
bool input(InputConfig* config, Input input) override;
|
|
|
|
void update(int deltaTime) override;
|
2017-10-28 20:24:35 +00:00
|
|
|
void render(const Transform4x4f& parentTrans) override;
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
enum ViewMode
|
|
|
|
{
|
|
|
|
NOTHING,
|
|
|
|
START_SCREEN,
|
|
|
|
SYSTEM_SELECT,
|
|
|
|
GAME_LIST
|
|
|
|
};
|
|
|
|
|
2017-03-24 19:30:20 +00:00
|
|
|
enum GameListViewType
|
|
|
|
{
|
|
|
|
AUTOMATIC,
|
|
|
|
BASIC,
|
|
|
|
DETAILED,
|
2018-03-22 07:03:12 +00:00
|
|
|
GRID,
|
2017-03-24 19:30:20 +00:00
|
|
|
VIDEO
|
|
|
|
};
|
|
|
|
|
2014-06-25 16:29:58 +00:00
|
|
|
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();
|
2017-07-18 09:45:50 +00:00
|
|
|
void removeGameListView(SystemData* system);
|
2014-06-25 16:29:58 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
ViewController(Window* window);
|
|
|
|
static ViewController* sInstance;
|
|
|
|
|
|
|
|
void playViewTransition();
|
|
|
|
int getSystemId(SystemData* system);
|
|
|
|
|
|
|
|
std::shared_ptr<GuiComponent> mCurrentView;
|
|
|
|
std::map< SystemData*, std::shared_ptr<IGameListView> > mGameListViews;
|
|
|
|
std::shared_ptr<SystemView> mSystemListView;
|
|
|
|
|
2017-10-28 20:24:35 +00:00
|
|
|
Transform4x4f mCamera;
|
2014-06-25 16:29:58 +00:00
|
|
|
float mFadeOpacity;
|
|
|
|
bool mLockInput;
|
|
|
|
|
|
|
|
State mState;
|
|
|
|
};
|
2017-10-31 17:12:50 +00:00
|
|
|
|
|
|
|
#endif // ES_APP_VIEWS_VIEW_CONTROLLER_H
|