mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-18 04:45:39 +00:00
Changed Window to use TextComponent instead of using Font facilities directly
This commit is contained in:
parent
8ff6f50635
commit
ccf680b433
|
@ -179,7 +179,11 @@ bool Window::init()
|
||||||
|
|
||||||
mPostprocessedBackground = TextureResource::get("", false, false, false, false, false);
|
mPostprocessedBackground = TextureResource::get("", false, false, false, false, false);
|
||||||
|
|
||||||
mListScrollFont = Font::get(FONT_SIZE_LARGE);
|
mListScrollText = std::make_unique<TextComponent>("", Font::get(FONT_SIZE_LARGE));
|
||||||
|
mGPUStatisticsText = std::make_unique<TextComponent>(
|
||||||
|
"", Font::get(FONT_SIZE_SMALL), 0xFF00FFFF, ALIGN_LEFT, ALIGN_CENTER,
|
||||||
|
glm::vec3 {mRenderer->getScreenWidth() * 0.02f, mRenderer->getScreenHeight() * 0.02f, 0.0f},
|
||||||
|
glm::vec2 {0.0f, 0.0f}, 0x00000000, 1.3f);
|
||||||
|
|
||||||
// Update our help because font sizes probably changed.
|
// Update our help because font sizes probably changed.
|
||||||
if (peekGui())
|
if (peekGui())
|
||||||
|
@ -378,9 +382,9 @@ void Window::update(int deltaTime)
|
||||||
ss << "\nFont VRAM: " << fontVramUsageMiB
|
ss << "\nFont VRAM: " << fontVramUsageMiB
|
||||||
<< " MiB\nTexture VRAM: " << textureVramUsageMiB
|
<< " MiB\nTexture VRAM: " << textureVramUsageMiB
|
||||||
<< " MiB\nMax Texture VRAM: " << textureTotalUsageMiB << " MiB";
|
<< " MiB\nMax Texture VRAM: " << textureTotalUsageMiB << " MiB";
|
||||||
mFrameDataText = std::unique_ptr<TextCache>(mDefaultFonts.at(0)->buildTextCache(
|
mGPUStatisticsText->setText(ss.str());
|
||||||
ss.str(), mRenderer->getScreenWidth() * 0.02f, mRenderer->getScreenHeight() * 0.02f,
|
// Setting the Y size to zero makes the text area expand vertically as needed.
|
||||||
0xFF00FFFF, 1.3f));
|
mGPUStatisticsText->setSize(mGPUStatisticsText->getSize().x, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
mFrameTimeElapsed = 0;
|
mFrameTimeElapsed = 0;
|
||||||
|
@ -613,15 +617,13 @@ void Window::render()
|
||||||
0x00000000 | static_cast<unsigned char>(mListScrollOpacity * 255.0f),
|
0x00000000 | static_cast<unsigned char>(mListScrollOpacity * 255.0f),
|
||||||
0x00000000 | static_cast<unsigned char>(mListScrollOpacity * 255.0f));
|
0x00000000 | static_cast<unsigned char>(mListScrollOpacity * 255.0f));
|
||||||
|
|
||||||
glm::vec2 offset {mListScrollFont->sizeText(mListScrollText)};
|
glm::vec2 offset {mListScrollText->getSize()};
|
||||||
offset.x = (mRenderer->getScreenWidth() - offset.x) * 0.5f;
|
offset.x = (mRenderer->getScreenWidth() - offset.x) * 0.5f;
|
||||||
offset.y = (mRenderer->getScreenHeight() - offset.y) * 0.5f;
|
offset.y = (mRenderer->getScreenHeight() - offset.y) * 0.5f;
|
||||||
|
mListScrollText->setPosition(offset.x, offset.y);
|
||||||
TextCache* cache {mListScrollFont->buildTextCache(
|
mListScrollText->setColor(0xFFFFFF00 |
|
||||||
mListScrollText, offset.x, offset.y,
|
static_cast<unsigned char>(mListScrollOpacity * 255.0f));
|
||||||
0xFFFFFF00 | static_cast<unsigned char>(mListScrollOpacity * 255.0f))};
|
mListScrollText->render(mRenderer->getIdentity());
|
||||||
mListScrollFont->renderTextCache(cache);
|
|
||||||
delete cache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int screensaverTimer {
|
unsigned int screensaverTimer {
|
||||||
|
@ -659,31 +661,29 @@ void Window::render()
|
||||||
InputOverlay::getInstance().render(mRenderer->getIdentity());
|
InputOverlay::getInstance().render(mRenderer->getIdentity());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (Settings::getInstance()->getBool("DisplayGPUStatistics") && mFrameDataText) {
|
if (Settings::getInstance()->getBool("DisplayGPUStatistics"))
|
||||||
mRenderer->setMatrix(mRenderer->getIdentity());
|
mGPUStatisticsText->render(mRenderer->getIdentity());
|
||||||
mDefaultFonts.at(1)->renderTextCache(mFrameDataText.get());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::updateSplashScreenText()
|
void Window::updateSplashScreenText()
|
||||||
{
|
{
|
||||||
mSplashTextScanning = std::unique_ptr<TextCache>(
|
mSplashTextScanning = std::make_unique<TextComponent>(_("Searching for games..."),
|
||||||
mDefaultFonts.at(1)->buildTextCache(_("Searching for games..."), 0.0f, 0.0f, 0x777777FF));
|
Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
|
||||||
mSplashTextPopulating = std::unique_ptr<TextCache>(
|
mSplashTextPopulating = std::make_unique<TextComponent>(
|
||||||
mDefaultFonts.at(1)->buildTextCache(_("Loading systems..."), 0.0f, 0.0f, 0x777777FF));
|
_("Loading systems..."), Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
|
||||||
mSplashTextReloading = std::unique_ptr<TextCache>(
|
mSplashTextReloading =
|
||||||
mDefaultFonts.at(1)->buildTextCache(_("Reloading..."), 0.0f, 0.0f, 0x777777FF));
|
std::make_unique<TextComponent>(_("Reloading..."), Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
|
||||||
mSplashTextResourceCopy = std::unique_ptr<TextCache>(
|
mSplashTextResourceCopy = std::make_unique<TextComponent>(
|
||||||
mDefaultFonts.at(1)->buildTextCache(_("Copying resources..."), 0.0f, 0.0f, 0x777777FF));
|
_("Copying resources..."), Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
|
||||||
mSplashTextDirCreation = std::unique_ptr<TextCache>(mDefaultFonts.at(1)->buildTextCache(
|
mSplashTextDirCreation = std::make_unique<TextComponent>(
|
||||||
_("Creating system directories..."), 0.0f, 0.0f, 0x777777FF));
|
_("Creating system directories..."), Font::get(FONT_SIZE_MEDIUM), 0x777777FF);
|
||||||
|
|
||||||
mSplashTextPositions.x =
|
mSplashTextPositions.x =
|
||||||
(mRenderer->getScreenWidth() - mSplashTextScanning->metrics.size.x) / 2.0f;
|
(mRenderer->getScreenWidth() - mSplashTextScanning->getSize().x) / 2.0f;
|
||||||
mSplashTextPositions.z =
|
mSplashTextPositions.z =
|
||||||
(mRenderer->getScreenWidth() - mSplashTextPopulating->metrics.size.x) / 2.0f;
|
(mRenderer->getScreenWidth() - mSplashTextPopulating->getSize().x) / 2.0f;
|
||||||
mSplashTextPositions.w =
|
mSplashTextPositions.w =
|
||||||
(mRenderer->getScreenWidth() - mSplashTextReloading->metrics.size.x) / 2.0f;
|
(mRenderer->getScreenWidth() - mSplashTextReloading->getSize().x) / 2.0f;
|
||||||
mSplashTextPositions.y =
|
mSplashTextPositions.y =
|
||||||
mRenderer->getScreenHeight() * (mRenderer->getIsVerticalOrientation() ? 0.620f : 0.745f);
|
mRenderer->getScreenHeight() * (mRenderer->getIsVerticalOrientation() ? 0.620f : 0.745f);
|
||||||
}
|
}
|
||||||
|
@ -723,25 +723,24 @@ void Window::renderSplashScreen(SplashScreenState state, float progress)
|
||||||
textPosY += mDefaultFonts.at(1)->getLetterHeight();
|
textPosY += mDefaultFonts.at(1)->getLetterHeight();
|
||||||
}
|
}
|
||||||
else if (state == SplashScreenState::RESOURCE_COPY) {
|
else if (state == SplashScreenState::RESOURCE_COPY) {
|
||||||
textPosX = (mRenderer->getScreenWidth() - mSplashTextResourceCopy->metrics.size.x) / 2.0f;
|
textPosX = (mRenderer->getScreenWidth() - mSplashTextResourceCopy->getSize().x) / 2.0f;
|
||||||
}
|
}
|
||||||
else if (state == SplashScreenState::DIR_CREATION) {
|
else if (state == SplashScreenState::DIR_CREATION) {
|
||||||
textPosX = (mRenderer->getScreenWidth() - mSplashTextDirCreation->metrics.size.x) / 2.0f;
|
textPosX = (mRenderer->getScreenWidth() - mSplashTextDirCreation->getSize().x) / 2.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
trans = glm::translate(trans, glm::round(glm::vec3 {textPosX, textPosY, 0.0f}));
|
trans = glm::translate(trans, glm::round(glm::vec3 {textPosX, textPosY, 0.0f}));
|
||||||
mRenderer->setMatrix(trans);
|
|
||||||
|
|
||||||
if (state == SplashScreenState::SCANNING)
|
if (state == SplashScreenState::SCANNING)
|
||||||
mDefaultFonts.at(1)->renderTextCache(mSplashTextScanning.get());
|
mSplashTextScanning->render(trans);
|
||||||
else if (state == SplashScreenState::POPULATING)
|
else if (state == SplashScreenState::POPULATING)
|
||||||
mDefaultFonts.at(1)->renderTextCache(mSplashTextPopulating.get());
|
mSplashTextPopulating->render(trans);
|
||||||
else if (state == SplashScreenState::RELOADING)
|
else if (state == SplashScreenState::RELOADING)
|
||||||
mDefaultFonts.at(1)->renderTextCache(mSplashTextReloading.get());
|
mSplashTextReloading->render(trans);
|
||||||
else if (state == SplashScreenState::RESOURCE_COPY)
|
else if (state == SplashScreenState::RESOURCE_COPY)
|
||||||
mDefaultFonts.at(1)->renderTextCache(mSplashTextResourceCopy.get());
|
mSplashTextResourceCopy->render(trans);
|
||||||
else if (state == SplashScreenState::DIR_CREATION)
|
else if (state == SplashScreenState::DIR_CREATION)
|
||||||
mDefaultFonts.at(1)->renderTextCache(mSplashTextDirCreation.get());
|
mSplashTextDirCreation->render(trans);
|
||||||
|
|
||||||
mRenderer->swapBuffers();
|
mRenderer->swapBuffers();
|
||||||
}
|
}
|
||||||
|
@ -749,7 +748,7 @@ void Window::renderSplashScreen(SplashScreenState state, float progress)
|
||||||
void Window::renderListScrollOverlay(const float opacity, const std::string& text)
|
void Window::renderListScrollOverlay(const float opacity, const std::string& text)
|
||||||
{
|
{
|
||||||
mListScrollOpacity = opacity * 0.6f;
|
mListScrollOpacity = opacity * 0.6f;
|
||||||
mListScrollText = text;
|
mListScrollText->setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::renderHelpPromptsEarly()
|
void Window::renderHelpPromptsEarly()
|
||||||
|
|
|
@ -10,9 +10,16 @@
|
||||||
#ifndef ES_CORE_WINDOW_H
|
#ifndef ES_CORE_WINDOW_H
|
||||||
#define ES_CORE_WINDOW_H
|
#define ES_CORE_WINDOW_H
|
||||||
|
|
||||||
|
#include "GuiComponent.h"
|
||||||
#include "HelpPrompt.h"
|
#include "HelpPrompt.h"
|
||||||
|
#include "HelpStyle.h"
|
||||||
#include "InputConfig.h"
|
#include "InputConfig.h"
|
||||||
#include "Settings.h"
|
#include "Settings.h"
|
||||||
|
#include "components/HelpComponent.h"
|
||||||
|
#include "components/ImageComponent.h"
|
||||||
|
#include "components/TextComponent.h"
|
||||||
|
#include "guis/GuiInfoPopup.h"
|
||||||
|
#include "resources/Font.h"
|
||||||
#include "resources/TextureResource.h"
|
#include "resources/TextureResource.h"
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
@ -20,14 +27,6 @@
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
|
||||||
class FileData;
|
class FileData;
|
||||||
class Font;
|
|
||||||
class GuiComponent;
|
|
||||||
class GuiInfoPopup;
|
|
||||||
class HelpComponent;
|
|
||||||
class ImageComponent;
|
|
||||||
class InputConfig;
|
|
||||||
class TextCache;
|
|
||||||
struct HelpStyle;
|
|
||||||
|
|
||||||
class Window
|
class Window
|
||||||
{
|
{
|
||||||
|
@ -189,18 +188,19 @@ private:
|
||||||
std::unique_ptr<HelpComponent> mHelp;
|
std::unique_ptr<HelpComponent> mHelp;
|
||||||
std::unique_ptr<ImageComponent> mBackgroundOverlay;
|
std::unique_ptr<ImageComponent> mBackgroundOverlay;
|
||||||
std::unique_ptr<ImageComponent> mSplash;
|
std::unique_ptr<ImageComponent> mSplash;
|
||||||
std::unique_ptr<TextCache> mSplashTextScanning;
|
std::unique_ptr<TextComponent> mSplashTextScanning;
|
||||||
std::unique_ptr<TextCache> mSplashTextPopulating;
|
std::unique_ptr<TextComponent> mSplashTextPopulating;
|
||||||
std::unique_ptr<TextCache> mSplashTextReloading;
|
std::unique_ptr<TextComponent> mSplashTextReloading;
|
||||||
std::unique_ptr<TextCache> mSplashTextResourceCopy;
|
std::unique_ptr<TextComponent> mSplashTextResourceCopy;
|
||||||
std::unique_ptr<TextCache> mSplashTextDirCreation;
|
std::unique_ptr<TextComponent> mSplashTextDirCreation;
|
||||||
|
|
||||||
glm::vec4 mSplashTextPositions;
|
glm::vec4 mSplashTextPositions;
|
||||||
std::vector<ProgressBarRectangle> mProgressBarRectangles;
|
std::vector<ProgressBarRectangle> mProgressBarRectangles;
|
||||||
|
|
||||||
float mBackgroundOverlayOpacity;
|
float mBackgroundOverlayOpacity;
|
||||||
std::vector<GuiComponent*> mGuiStack;
|
std::vector<GuiComponent*> mGuiStack;
|
||||||
std::vector<std::shared_ptr<Font>> mDefaultFonts;
|
std::vector<std::shared_ptr<Font>> mDefaultFonts;
|
||||||
std::unique_ptr<TextCache> mFrameDataText;
|
std::unique_ptr<TextComponent> mGPUStatisticsText;
|
||||||
|
|
||||||
Screensaver* mScreensaver;
|
Screensaver* mScreensaver;
|
||||||
MediaViewer* mMediaViewer;
|
MediaViewer* mMediaViewer;
|
||||||
|
@ -212,8 +212,7 @@ private:
|
||||||
std::shared_ptr<TextureResource> mPostprocessedBackground;
|
std::shared_ptr<TextureResource> mPostprocessedBackground;
|
||||||
|
|
||||||
std::vector<std::string> mGameEndEventParams;
|
std::vector<std::string> mGameEndEventParams;
|
||||||
std::string mListScrollText;
|
std::unique_ptr<TextComponent> mListScrollText;
|
||||||
std::shared_ptr<Font> mListScrollFont;
|
|
||||||
float mListScrollOpacity;
|
float mListScrollOpacity;
|
||||||
|
|
||||||
int mFrameTimeElapsed;
|
int mFrameTimeElapsed;
|
||||||
|
|
Loading…
Reference in a new issue