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
|
|
|
|
2020-09-13 11:21:38 +00:00
|
|
|
#include "resources/TextureResource.h"
|
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"
|
2017-11-01 22:21:10 +00:00
|
|
|
|
|
|
|
#include <memory>
|
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;
|
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;
|
|
|
|
class Transform4x4f;
|
|
|
|
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 allowSleep() = 0;
|
|
|
|
virtual bool isScreensaverActive() = 0;
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2020-07-14 17:16:21 +00:00
|
|
|
class InfoPopup
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
public:
|
|
|
|
virtual void render(const Transform4x4f& parentTrans) = 0;
|
|
|
|
virtual void stop() = 0;
|
|
|
|
virtual ~InfoPopup() {};
|
|
|
|
};
|
|
|
|
|
|
|
|
Window();
|
|
|
|
~Window();
|
|
|
|
|
|
|
|
void pushGui(GuiComponent* gui);
|
|
|
|
void removeGui(GuiComponent* gui);
|
|
|
|
GuiComponent* peekGui();
|
2020-09-17 20:00:07 +00:00
|
|
|
inline int getGuiStackSize() { return static_cast<int>(mGuiStack.size()); }
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2020-12-16 22:59:00 +00:00
|
|
|
void textInput(const std::string& text);
|
2020-06-21 12:25:28 +00:00
|
|
|
void input(InputConfig* config, Input input);
|
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();
|
|
|
|
|
|
|
|
bool init();
|
|
|
|
void deinit();
|
|
|
|
|
|
|
|
void normalizeNextUpdate();
|
|
|
|
|
|
|
|
inline bool isSleeping() const { return mSleeping; }
|
|
|
|
bool getAllowSleep();
|
|
|
|
void setAllowSleep(bool sleep);
|
|
|
|
|
|
|
|
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.
|
|
|
|
void renderListScrollOverlay(unsigned char 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);
|
|
|
|
|
2020-11-10 21:33:57 +00:00
|
|
|
void setScreensaver(Screensaver* screensaver) { mScreensaver = screensaver; }
|
2021-01-12 21:41:28 +00:00
|
|
|
void setInfoPopup(InfoPopup* infoPopup)
|
|
|
|
{
|
|
|
|
delete mInfoPopup;
|
|
|
|
mInfoPopup = infoPopup;
|
|
|
|
}
|
|
|
|
void stopInfoPopup()
|
|
|
|
{
|
|
|
|
if (mInfoPopup)
|
|
|
|
mInfoPopup->stop();
|
|
|
|
};
|
2020-06-21 12:25:28 +00:00
|
|
|
|
2020-11-12 16:13:24 +00:00
|
|
|
bool isScreensaverActive() { return mRenderScreensaver; };
|
2020-11-10 21:18:20 +00:00
|
|
|
void startScreensaver();
|
2020-11-12 16:13:24 +00:00
|
|
|
bool stopScreensaver();
|
2020-11-10 21:18:20 +00:00
|
|
|
void renderScreensaver();
|
2020-11-12 16:13:24 +00:00
|
|
|
void screensaverTriggerNextGame() { mScreensaver->triggerNextGame(); };
|
2017-06-01 20:08:44 +00:00
|
|
|
|
2020-07-18 11:21:44 +00:00
|
|
|
void setLaunchedGame();
|
|
|
|
void unsetLaunchedGame();
|
2021-01-12 21:41:28 +00:00
|
|
|
|
2020-07-18 11:21:44 +00:00
|
|
|
bool getGameLaunchedState() { return mGameLaunchedState; };
|
2020-09-17 20:00:07 +00:00
|
|
|
void setAllowTextScrolling(bool setting) { mAllowTextScrolling = setting; };
|
|
|
|
bool getAllowTextScrolling() { return mAllowTextScrolling; };
|
2020-07-18 11:21:44 +00:00
|
|
|
|
2020-11-11 23:46:59 +00:00
|
|
|
void invalidateCachedBackground()
|
2021-01-12 21:41:28 +00:00
|
|
|
{
|
|
|
|
mCachedBackground = false;
|
|
|
|
mInvalidatedCachedBackground = true;
|
|
|
|
};
|
2020-09-13 17:20:30 +00:00
|
|
|
|
2013-04-08 14:41:25 +00:00
|
|
|
private:
|
2020-06-21 12:25:28 +00:00
|
|
|
void onSleep();
|
|
|
|
void onWake();
|
2014-06-02 00:14:22 +00:00
|
|
|
|
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
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
HelpComponent* mHelp;
|
|
|
|
ImageComponent* mBackgroundOverlay;
|
2020-11-11 23:46:59 +00:00
|
|
|
unsigned char mBackgroundOverlayOpacity;
|
2020-11-10 21:33:57 +00:00
|
|
|
Screensaver* mScreensaver;
|
2020-06-21 12:25:28 +00:00
|
|
|
InfoPopup* mInfoPopup;
|
|
|
|
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-01-12 21:41:28 +00:00
|
|
|
std::string mListScrollText;
|
|
|
|
std::shared_ptr<Font> mListScrollFont;
|
|
|
|
unsigned char mListScrollOpacity;
|
|
|
|
|
2020-09-17 20:00:07 +00:00
|
|
|
bool mNormalizeNextUpdate;
|
2020-06-21 12:25:28 +00:00
|
|
|
int mFrameTimeElapsed;
|
|
|
|
int mFrameCountElapsed;
|
|
|
|
int mAverageDeltaTime;
|
2020-09-17 20:00:07 +00:00
|
|
|
bool mAllowSleep;
|
|
|
|
bool mSleeping;
|
|
|
|
unsigned int mTimeSinceLastInput;
|
2014-04-12 00:42:04 +00:00
|
|
|
|
2020-11-10 21:33:57 +00:00
|
|
|
bool mRenderScreensaver;
|
2020-09-17 20:00:07 +00:00
|
|
|
bool mGameLaunchedState;
|
|
|
|
bool mAllowTextScrolling;
|
|
|
|
bool mCachedBackground;
|
2020-11-11 23:46:59 +00:00
|
|
|
bool mInvalidatedCachedBackground;
|
2013-08-06 13:15:20 +00:00
|
|
|
|
2020-09-13 11:21:38 +00:00
|
|
|
unsigned char mTopOpacity;
|
|
|
|
float mTopScale;
|
2020-06-21 12:25:28 +00:00
|
|
|
bool mRenderedHelpPrompts;
|
2013-04-08 14:41:25 +00:00
|
|
|
};
|
2017-10-31 17:12:50 +00:00
|
|
|
|
|
|
|
#endif // ES_CORE_WINDOW_H
|