2020-09-15 19:12:32 +00:00
|
|
|
// SPDX-License-Identifier: MIT
|
2020-06-21 12:25:28 +00:00
|
|
|
//
|
2020-09-15 19:12:32 +00:00
|
|
|
// EmulationStation Desktop Edition
|
2020-06-21 12:25:28 +00:00
|
|
|
// Window.h
|
|
|
|
//
|
2020-11-11 23:46:59 +00:00
|
|
|
// Window management, screensaver management, and help prompts.
|
2020-09-15 19:12:32 +00:00
|
|
|
// The input stack starts here as well, as this is the first instance called by InputManager.
|
2020-06-21 12:25:28 +00:00
|
|
|
//
|
|
|
|
|
2017-10-31 17:12:50 +00:00
|
|
|
#ifndef ES_CORE_WINDOW_H
|
2020-09-13 17:20:30 +00:00
|
|
|
#define ES_CORE_WINDOW_H
|
2013-04-08 14:41:25 +00:00
|
|
|
|
2017-11-01 22:21:10 +00:00
|
|
|
#include "HelpPrompt.h"
|
|
|
|
#include "InputConfig.h"
|
2017-09-08 14:49:47 +00:00
|
|
|
#include "Settings.h"
|
2021-07-07 18:31:46 +00:00
|
|
|
#include "resources/TextureResource.h"
|
2017-11-01 22:21:10 +00:00
|
|
|
|
2021-11-16 16:49:05 +00:00
|
|
|
#include <atomic>
|
2017-11-01 22:21:10 +00:00
|
|
|
#include <memory>
|
2021-10-07 16:31:40 +00:00
|
|
|
#include <queue>
|
2013-04-08 14:41:25 +00:00
|
|
|
|
2017-06-01 20:08:44 +00:00
|
|
|
class FileData;
|
2017-11-01 22:21:10 +00:00
|
|
|
class Font;
|
|
|
|
class GuiComponent;
|
2021-10-07 16:31:40 +00:00
|
|
|
class GuiInfoPopup;
|
2014-01-25 23:34:29 +00:00
|
|
|
class HelpComponent;
|
2014-03-04 22:48:33 +00:00
|
|
|
class ImageComponent;
|
2017-11-01 22:21:10 +00:00
|
|
|
class InputConfig;
|
|
|
|
class TextCache;
|
|
|
|
struct HelpStyle;
|
2013-11-12 23:28:15 +00:00
|
|
|
|
2013-04-08 14:41:25 +00:00
|
|
|
class Window
|
|
|
|
{
|
|
|
|
public:
|
2020-11-10 21:18:20 +00:00
|
|
|
class Screensaver
|
2020-07-14 17:16:21 +00:00
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
public:
|
2020-11-12 16:13:24 +00:00
|
|
|
virtual bool isScreensaverActive() = 0;
|
2021-03-18 19:07:07 +00:00
|
|
|
virtual bool isFallbackScreensaver() = 0;
|
2020-11-12 16:13:24 +00:00
|
|
|
|
2020-11-10 21:18:20 +00:00
|
|
|
virtual void startScreensaver(bool generateMediaList) = 0;
|
|
|
|
virtual void stopScreensaver() = 0;
|
2020-07-28 09:10:14 +00:00
|
|
|
virtual void nextGame() = 0;
|
2020-11-12 16:13:24 +00:00
|
|
|
virtual void launchGame() = 0;
|
|
|
|
virtual void goToGame() = 0;
|
|
|
|
|
2020-11-10 21:18:20 +00:00
|
|
|
virtual void renderScreensaver() = 0;
|
2020-06-21 12:25:28 +00:00
|
|
|
virtual void update(int deltaTime) = 0;
|
2020-11-12 16:13:24 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
virtual FileData* getCurrentGame() = 0;
|
2020-11-12 16:13:24 +00:00
|
|
|
virtual void triggerNextGame() = 0;
|
2020-06-21 12:25:28 +00:00
|
|
|
};
|
|
|
|
|
2021-05-16 11:12:31 +00:00
|
|
|
class MediaViewer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual bool startMediaViewer(FileData* game) = 0;
|
|
|
|
virtual void stopMediaViewer() = 0;
|
|
|
|
|
|
|
|
virtual void showNext() = 0;
|
|
|
|
virtual void showPrevious() = 0;
|
|
|
|
|
|
|
|
virtual void update(int deltaTime) = 0;
|
2021-09-18 09:49:39 +00:00
|
|
|
virtual void render(const glm::mat4& parentTrans) = 0;
|
2021-05-16 11:12:31 +00:00
|
|
|
};
|
|
|
|
|
2021-06-14 17:15:22 +00:00
|
|
|
class GuiLaunchScreen
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual void displayLaunchScreen(FileData* game) = 0;
|
|
|
|
virtual void closeLaunchScreen() = 0;
|
|
|
|
virtual void update(int deltaTime) = 0;
|
2021-09-18 09:49:39 +00:00
|
|
|
virtual void render(const glm::mat4& parentTrans) = 0;
|
2021-06-14 17:15:22 +00:00
|
|
|
};
|
|
|
|
|
2022-01-04 20:21:26 +00:00
|
|
|
static Window* getInstance();
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
void pushGui(GuiComponent* gui);
|
|
|
|
void removeGui(GuiComponent* gui);
|
|
|
|
GuiComponent* peekGui();
|
2021-07-07 18:31:46 +00:00
|
|
|
int getGuiStackSize() { return static_cast<int>(mGuiStack.size()); }
|
2021-08-22 14:43:15 +00:00
|
|
|
bool isBackgroundDimmed();
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2021-06-11 15:02:06 +00:00
|
|
|
bool init();
|
|
|
|
void deinit();
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
void input(InputConfig* config, Input input);
|
2021-06-11 15:02:06 +00:00
|
|
|
void textInput(const std::string& text);
|
2020-12-16 22:59:00 +00:00
|
|
|
void logInput(InputConfig* config, Input input);
|
2020-06-21 12:25:28 +00:00
|
|
|
void update(int deltaTime);
|
|
|
|
void render();
|
|
|
|
|
2021-06-11 15:02:06 +00:00
|
|
|
void normalizeNextUpdate() { mNormalizeNextUpdate = true; }
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
void renderLoadingScreen(std::string text);
|
2021-01-12 21:41:28 +00:00
|
|
|
// The list scroll overlay is triggered from IList when the highest scrolling tier is reached.
|
2022-02-11 21:10:25 +00:00
|
|
|
void renderListScrollOverlay(const float opacity, const std::string& text);
|
2020-06-21 12:25:28 +00:00
|
|
|
|
|
|
|
void renderHelpPromptsEarly(); // Used to render HelpPrompts before a fade.
|
|
|
|
void setHelpPrompts(const std::vector<HelpPrompt>& prompts, const HelpStyle& style);
|
2021-05-23 17:12:31 +00:00
|
|
|
void reloadHelpPrompts();
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2021-10-07 16:31:40 +00:00
|
|
|
// GuiInfoPopup notifications.
|
|
|
|
void queueInfoPopup(const std::string& message, const int& duration)
|
|
|
|
{
|
|
|
|
mInfoPopupQueue.emplace(std::make_pair(message, duration));
|
|
|
|
}
|
2021-03-21 15:10:09 +00:00
|
|
|
void stopInfoPopup();
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2022-05-18 21:56:51 +00:00
|
|
|
void startScreensaver(bool onTimer);
|
2020-11-12 16:13:24 +00:00
|
|
|
bool stopScreensaver();
|
2020-11-10 21:18:20 +00:00
|
|
|
void renderScreensaver();
|
2021-06-11 15:02:06 +00:00
|
|
|
void screensaverTriggerNextGame() { mScreensaver->triggerNextGame(); }
|
|
|
|
void setScreensaver(Screensaver* screensaver) { mScreensaver = screensaver; }
|
|
|
|
bool isScreensaverActive() { return mRenderScreensaver; }
|
2021-05-16 11:12:31 +00:00
|
|
|
|
|
|
|
void startMediaViewer(FileData* game);
|
|
|
|
void stopMediaViewer();
|
|
|
|
void setMediaViewer(MediaViewer* mediaViewer) { mMediaViewer = mediaViewer; }
|
2021-06-11 15:02:06 +00:00
|
|
|
bool isMediaViewerActive() { return mRenderMediaViewer; }
|
2017-06-01 20:08:44 +00:00
|
|
|
|
2021-06-14 17:15:22 +00:00
|
|
|
void displayLaunchScreen(FileData* game);
|
|
|
|
void closeLaunchScreen();
|
|
|
|
void setLaunchScreen(GuiLaunchScreen* launchScreen) { mLaunchScreen = launchScreen; }
|
|
|
|
bool isLaunchScreenDisplayed() { return mRenderLaunchScreen; }
|
|
|
|
|
2022-02-19 16:04:23 +00:00
|
|
|
void increaseVideoPlayerCount() { ++mVideoPlayerCount; }
|
|
|
|
void decreaseVideoPlayerCount() { --mVideoPlayerCount; }
|
2021-05-29 08:58:51 +00:00
|
|
|
int getVideoPlayerCount();
|
|
|
|
|
2022-02-19 16:04:23 +00:00
|
|
|
void setLaunchedGame(bool state) { mGameLaunchedState = state; }
|
2021-03-21 15:10:09 +00:00
|
|
|
void invalidateCachedBackground();
|
2022-01-09 16:56:17 +00:00
|
|
|
bool isInvalidatingCachedBackground() { return mInvalidateCacheTimer > 0; }
|
2021-01-12 21:41:28 +00:00
|
|
|
|
2021-06-11 15:02:06 +00:00
|
|
|
bool getGameLaunchedState() { return mGameLaunchedState; }
|
2022-01-09 12:43:42 +00:00
|
|
|
void setAllowTextScrolling(bool value) { mAllowTextScrolling = value; }
|
2021-06-11 15:02:06 +00:00
|
|
|
bool getAllowTextScrolling() { return mAllowTextScrolling; }
|
2020-07-18 11:21:44 +00:00
|
|
|
|
2022-01-09 12:43:42 +00:00
|
|
|
// For Lottie animations.
|
|
|
|
void setAllowFileAnimation(bool value) { mAllowFileAnimation = value; }
|
|
|
|
bool getAllowFileAnimation() { return mAllowFileAnimation; }
|
|
|
|
|
2021-06-11 15:02:06 +00:00
|
|
|
void setChangedThemeSet() { mChangedThemeSet = true; }
|
2021-06-22 16:08:20 +00:00
|
|
|
bool getChangedThemeSet() { return mChangedThemeSet; }
|
2021-04-05 08:05:08 +00:00
|
|
|
|
2013-04-08 14:41:25 +00:00
|
|
|
private:
|
2022-01-04 20:21:26 +00:00
|
|
|
Window() noexcept;
|
|
|
|
~Window();
|
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
// Returns true if at least one component on the stack is processing.
|
|
|
|
bool isProcessing();
|
2019-02-20 07:33:00 +00:00
|
|
|
|
2022-03-14 18:51:48 +00:00
|
|
|
Renderer* mRenderer;
|
2020-06-21 12:25:28 +00:00
|
|
|
HelpComponent* mHelp;
|
|
|
|
ImageComponent* mBackgroundOverlay;
|
2022-02-11 21:10:25 +00:00
|
|
|
float mBackgroundOverlayOpacity;
|
2020-06-21 12:25:28 +00:00
|
|
|
std::vector<GuiComponent*> mGuiStack;
|
|
|
|
std::vector<std::shared_ptr<Font>> mDefaultFonts;
|
2020-09-17 20:00:07 +00:00
|
|
|
std::unique_ptr<TextCache> mFrameDataText;
|
2013-07-17 06:47:02 +00:00
|
|
|
|
2021-09-18 07:53:26 +00:00
|
|
|
Screensaver* mScreensaver;
|
2021-05-16 11:12:31 +00:00
|
|
|
MediaViewer* mMediaViewer;
|
2021-06-14 17:15:22 +00:00
|
|
|
GuiLaunchScreen* mLaunchScreen;
|
2021-10-07 16:31:40 +00:00
|
|
|
GuiInfoPopup* mInfoPopup;
|
|
|
|
|
|
|
|
std::queue<std::pair<std::string, int>> mInfoPopupQueue;
|
2021-11-07 18:21:01 +00:00
|
|
|
std::shared_ptr<TextureResource> mPostprocessedBackground;
|
|
|
|
|
2021-01-12 21:41:28 +00:00
|
|
|
std::string mListScrollText;
|
|
|
|
std::shared_ptr<Font> mListScrollFont;
|
2022-02-11 21:10:25 +00:00
|
|
|
float mListScrollOpacity;
|
2021-01-12 21:41:28 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
int mFrameTimeElapsed;
|
|
|
|
int mFrameCountElapsed;
|
|
|
|
int mAverageDeltaTime;
|
2021-09-18 07:53:26 +00:00
|
|
|
unsigned int mTimeSinceLastInput;
|
|
|
|
|
|
|
|
bool mNormalizeNextUpdate;
|
2014-04-12 00:42:04 +00:00
|
|
|
|
2020-11-10 21:33:57 +00:00
|
|
|
bool mRenderScreensaver;
|
2021-09-18 07:53:26 +00:00
|
|
|
bool mRenderMediaViewer;
|
|
|
|
bool mRenderLaunchScreen;
|
2020-09-17 20:00:07 +00:00
|
|
|
bool mGameLaunchedState;
|
|
|
|
bool mAllowTextScrolling;
|
2022-01-09 12:43:42 +00:00
|
|
|
bool mAllowFileAnimation;
|
2020-09-17 20:00:07 +00:00
|
|
|
bool mCachedBackground;
|
2020-11-11 23:46:59 +00:00
|
|
|
bool mInvalidatedCachedBackground;
|
2022-01-09 16:56:17 +00:00
|
|
|
bool mInitiateCacheTimer;
|
|
|
|
int mInvalidateCacheTimer;
|
2013-08-06 13:15:20 +00:00
|
|
|
|
2021-11-16 16:49:05 +00:00
|
|
|
std::atomic<int> mVideoPlayerCount;
|
2021-05-29 08:58:51 +00:00
|
|
|
|
2020-09-13 11:21:38 +00:00
|
|
|
float mTopScale;
|
2020-06-21 12:25:28 +00:00
|
|
|
bool mRenderedHelpPrompts;
|
2021-04-05 08:05:08 +00:00
|
|
|
bool mChangedThemeSet;
|
2013-04-08 14:41:25 +00:00
|
|
|
};
|
2017-10-31 17:12:50 +00:00
|
|
|
|
|
|
|
#endif // ES_CORE_WINDOW_H
|