mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-27 00:25:38 +00:00
8fcb56cfb3
Also added an option to hide the taskbar.
127 lines
3 KiB
C++
127 lines
3 KiB
C++
//
|
|
// Window.h
|
|
//
|
|
// Window management, screensaver and help prompts.
|
|
//
|
|
|
|
#pragma once
|
|
#ifndef ES_CORE_WINDOW_H
|
|
#define ES_CORE_WInDOW_H
|
|
|
|
#include "HelpPrompt.h"
|
|
#include "InputConfig.h"
|
|
#include "Settings.h"
|
|
|
|
#include <memory>
|
|
|
|
class FileData;
|
|
class Font;
|
|
class GuiComponent;
|
|
class HelpComponent;
|
|
class ImageComponent;
|
|
class InputConfig;
|
|
class TextCache;
|
|
class Transform4x4f;
|
|
struct HelpStyle;
|
|
|
|
class Window
|
|
{
|
|
public:
|
|
class ScreenSaver
|
|
{
|
|
public:
|
|
virtual void startScreenSaver() = 0;
|
|
virtual void stopScreenSaver() = 0;
|
|
virtual void nextVideo() = 0;
|
|
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;
|
|
};
|
|
|
|
class InfoPopup
|
|
{
|
|
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);
|
|
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; };
|
|
|
|
void setLaunchedGame();
|
|
void unsetLaunchedGame();
|
|
bool getGameLaunchedState() { return mGameLaunchedState; };
|
|
|
|
private:
|
|
void onSleep();
|
|
void onWake();
|
|
|
|
// Returns true if at least one component on the stack is processing.
|
|
bool isProcessing();
|
|
|
|
HelpComponent* mHelp;
|
|
ImageComponent* mBackgroundOverlay;
|
|
ScreenSaver* mScreenSaver;
|
|
InfoPopup* mInfoPopup;
|
|
bool mRenderScreenSaver;
|
|
bool mGameLaunchedState;
|
|
|
|
std::vector<GuiComponent*> mGuiStack;
|
|
|
|
std::vector<std::shared_ptr<Font>> mDefaultFonts;
|
|
|
|
int mFrameTimeElapsed;
|
|
int mFrameCountElapsed;
|
|
int mAverageDeltaTime;
|
|
|
|
std::unique_ptr<TextCache> mFrameDataText;
|
|
|
|
bool mNormalizeNextUpdate;
|
|
|
|
bool mAllowSleep;
|
|
bool mSleeping;
|
|
unsigned int mTimeSinceLastInput;
|
|
|
|
bool mRenderedHelpPrompts;
|
|
};
|
|
|
|
#endif // ES_CORE_WINDOW_H
|