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
|
|
|
|
//
|
|
|
|
// Window management, screensaver 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-07-14 17:16:21 +00:00
|
|
|
class ScreenSaver
|
|
|
|
{
|
2020-06-21 12:25:28 +00:00
|
|
|
public:
|
|
|
|
virtual void startScreenSaver() = 0;
|
|
|
|
virtual void stopScreenSaver() = 0;
|
2020-07-28 09:10:14 +00:00
|
|
|
virtual void nextGame() = 0;
|
2020-06-21 12:25:28 +00:00
|
|
|
virtual void renderScreenSaver() = 0;
|
|
|
|
virtual bool allowSleep() = 0;
|
|
|
|
virtual void update(int deltaTime) = 0;
|
|
|
|
virtual bool isScreenSaverActive() = 0;
|
|
|
|
virtual FileData* getCurrentGame() = 0;
|
|
|
|
virtual void launchGame() = 0;
|
|
|
|
virtual void resetCounts() = 0;
|
2020-09-13 11:21:38 +00:00
|
|
|
virtual unsigned int getVideoCount() = 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();
|
|
|
|
inline int getGuiStackSize() { return (int)mGuiStack.size(); }
|
|
|
|
|
|
|
|
void textInput(const char* text);
|
|
|
|
void input(InputConfig* config, Input input);
|
2020-09-15 19:12:32 +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);
|
|
|
|
|
|
|
|
void renderHelpPromptsEarly(); // Used to render HelpPrompts before a fade.
|
|
|
|
void setHelpPrompts(const std::vector<HelpPrompt>& prompts, const HelpStyle& style);
|
|
|
|
|
|
|
|
void setScreenSaver(ScreenSaver* screenSaver) { mScreenSaver = screenSaver; }
|
|
|
|
void setInfoPopup(InfoPopup* infoPopup) { delete mInfoPopup; mInfoPopup = infoPopup; }
|
|
|
|
inline void stopInfoPopup() { if (mInfoPopup) mInfoPopup->stop(); };
|
|
|
|
|
|
|
|
void startScreenSaver();
|
|
|
|
bool cancelScreenSaver();
|
|
|
|
void renderScreenSaver();
|
|
|
|
bool isScreenSaverActive() { return mRenderScreenSaver; };
|
2017-06-01 20:08:44 +00:00
|
|
|
|
2020-07-18 11:21:44 +00:00
|
|
|
void setLaunchedGame();
|
|
|
|
void unsetLaunchedGame();
|
|
|
|
bool getGameLaunchedState() { return mGameLaunchedState; };
|
|
|
|
|
2020-09-13 17:20:30 +00:00
|
|
|
void invalidateCachedBackground() { mCachedBackground = false; };
|
|
|
|
|
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;
|
|
|
|
ScreenSaver* mScreenSaver;
|
|
|
|
InfoPopup* mInfoPopup;
|
|
|
|
bool mRenderScreenSaver;
|
2020-07-18 11:21:44 +00:00
|
|
|
bool mGameLaunchedState;
|
2014-03-04 22:48:33 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
std::vector<GuiComponent*> mGuiStack;
|
2013-07-03 07:54:55 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
std::vector<std::shared_ptr<Font>> mDefaultFonts;
|
2013-07-17 06:47:02 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
int mFrameTimeElapsed;
|
|
|
|
int mFrameCountElapsed;
|
|
|
|
int mAverageDeltaTime;
|
2014-04-12 00:42:04 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
std::unique_ptr<TextCache> mFrameDataText;
|
2013-07-17 06:47:02 +00:00
|
|
|
|
2020-06-21 12:25:28 +00:00
|
|
|
bool mNormalizeNextUpdate;
|
2013-08-06 13:15:20 +00:00
|
|
|
|
2020-09-13 11:21:38 +00:00
|
|
|
float mSaturationAmount;
|
|
|
|
unsigned char mTopOpacity;
|
|
|
|
float mTopScale;
|
|
|
|
float mDimValue;
|
|
|
|
bool mCachedBackground;
|
2020-06-21 12:25:28 +00:00
|
|
|
bool mAllowSleep;
|
|
|
|
bool mSleeping;
|
|
|
|
unsigned int mTimeSinceLastInput;
|
2014-06-02 00:14:22 +00:00
|
|
|
|
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
|