ES-DE/es-core/src/Window.h

204 lines
5.8 KiB
C
Raw Normal View History

// SPDX-License-Identifier: MIT
//
// EmulationStation Desktop Edition
// Window.h
//
// Window management, screensaver management, and help prompts.
// The input stack starts here as well, as this is the first instance called by InputManager.
//
#ifndef ES_CORE_WINDOW_H
#define ES_CORE_WINDOW_H
2017-11-01 22:21:10 +00:00
#include "HelpPrompt.h"
#include "InputConfig.h"
#include "Scripting.h"
#include "Settings.h"
#include "resources/TextureResource.h"
2017-11-01 22:21:10 +00:00
#include <memory>
#include <mutex>
2021-10-07 16:31:40 +00:00
#include <queue>
class FileData;
2017-11-01 22:21:10 +00:00
class Font;
class GuiComponent;
2021-10-07 16:31:40 +00:00
class GuiInfoPopup;
class HelpComponent;
class ImageComponent;
2017-11-01 22:21:10 +00:00
class InputConfig;
class TextCache;
struct HelpStyle;
class Window
{
public:
2020-11-10 21:18:20 +00:00
class Screensaver
{
public:
virtual bool allowSleep() = 0;
virtual bool isScreensaverActive() = 0;
virtual bool isFallbackScreensaver() = 0;
2020-11-10 21:18:20 +00:00
virtual void startScreensaver(bool generateMediaList) = 0;
virtual void stopScreensaver() = 0;
virtual void nextGame() = 0;
virtual void launchGame() = 0;
virtual void goToGame() = 0;
2020-11-10 21:18:20 +00:00
virtual void renderScreensaver() = 0;
virtual void update(int deltaTime) = 0;
virtual FileData* getCurrentGame() = 0;
virtual void triggerNextGame() = 0;
};
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;
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;
virtual void render(const glm::mat4& parentTrans) = 0;
2021-06-14 17:15:22 +00:00
};
Window();
~Window();
void pushGui(GuiComponent* gui);
void removeGui(GuiComponent* gui);
GuiComponent* peekGui();
int getGuiStackSize() { return static_cast<int>(mGuiStack.size()); }
bool isBackgroundDimmed();
2021-06-11 15:02:06 +00:00
bool init();
void deinit();
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);
void update(int deltaTime);
void render();
2021-06-11 15:02:06 +00:00
void normalizeNextUpdate() { mNormalizeNextUpdate = true; }
2021-06-11 15:02:06 +00:00
bool getAllowSleep() { return mAllowSleep; }
void setAllowSleep(bool sleep) { mAllowSleep = sleep; }
bool isSleeping() const { return mSleeping; }
void renderLoadingScreen(std::string text);
// The list scroll overlay is triggered from IList when the highest scrolling tier is reached.
void renderListScrollOverlay(unsigned char opacity, const std::string& text);
void renderHelpPromptsEarly(); // Used to render HelpPrompts before a fade.
void setHelpPrompts(const std::vector<HelpPrompt>& prompts, const HelpStyle& style);
void reloadHelpPrompts();
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));
}
void stopInfoPopup();
2020-11-10 21:18:20 +00:00
void startScreensaver();
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; }
2021-06-14 17:15:22 +00:00
void displayLaunchScreen(FileData* game);
void closeLaunchScreen();
void setLaunchScreen(GuiLaunchScreen* launchScreen) { mLaunchScreen = launchScreen; }
bool isLaunchScreenDisplayed() { return mRenderLaunchScreen; }
void increaseVideoPlayerCount();
void decreaseVideoPlayerCount();
int getVideoPlayerCount();
void setLaunchedGame();
void unsetLaunchedGame();
void invalidateCachedBackground();
2021-06-11 15:02:06 +00:00
bool getGameLaunchedState() { return mGameLaunchedState; }
void setAllowTextScrolling(bool setting) { mAllowTextScrolling = setting; }
bool getAllowTextScrolling() { return mAllowTextScrolling; }
2021-06-11 15:02:06 +00:00
void setChangedThemeSet() { mChangedThemeSet = true; }
bool getChangedThemeSet() { return mChangedThemeSet; }
private:
void onSleep() { Scripting::fireEvent("sleep"); }
void onWake() { Scripting::fireEvent("wake"); }
// Returns true if at least one component on the stack is processing.
bool isProcessing();
HelpComponent* mHelp;
ImageComponent* mBackgroundOverlay;
unsigned char mBackgroundOverlayOpacity;
std::vector<GuiComponent*> mGuiStack;
std::vector<std::shared_ptr<Font>> mDefaultFonts;
std::unique_ptr<TextCache> mFrameDataText;
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-06-14 17:15:22 +00:00
#if defined(USE_OPENGL_21)
std::shared_ptr<TextureResource> mPostprocessedBackground;
#endif
std::string mListScrollText;
std::shared_ptr<Font> mListScrollFont;
unsigned char mListScrollOpacity;
int mFrameTimeElapsed;
int mFrameCountElapsed;
int mAverageDeltaTime;
unsigned int mTimeSinceLastInput;
bool mNormalizeNextUpdate;
bool mAllowSleep;
bool mSleeping;
bool mRenderScreensaver;
bool mRenderMediaViewer;
bool mRenderLaunchScreen;
bool mGameLaunchedState;
bool mAllowTextScrolling;
bool mCachedBackground;
bool mInvalidatedCachedBackground;
2013-08-06 13:15:20 +00:00
int mVideoPlayerCount;
std::mutex mVideoCountMutex;
float mTopScale;
bool mRenderedHelpPrompts;
bool mChangedThemeSet;
};
#endif // ES_CORE_WINDOW_H