Rewrote most components to use BackgroundComponent instead of NinePatchComponent

This commit is contained in:
Leon Styhre 2025-02-09 18:02:47 +01:00
parent 4e12ad52b6
commit 1c3bc53315
35 changed files with 53 additions and 71 deletions

View file

@ -21,7 +21,6 @@
GuiApplicationUpdater::GuiApplicationUpdater() GuiApplicationUpdater::GuiApplicationUpdater()
: mRenderer {Renderer::getInstance()} : mRenderer {Renderer::getInstance()}
, mBackground {":/graphics/frame.svg"}
, mGrid {glm::ivec2 {4, 11}} , mGrid {glm::ivec2 {4, 11}}
, mDownloadPercentage {0} , mDownloadPercentage {0}
, mLinuxAppImage {false} , mLinuxAppImage {false}

View file

@ -42,7 +42,7 @@ private:
Renderer* mRenderer; Renderer* mRenderer;
BusyComponent mBusyAnim; BusyComponent mBusyAnim;
NinePatchComponent mBackground; BackgroundComponent mBackground;
ComponentGrid mGrid; ComponentGrid mGrid;
std::shared_ptr<ComponentGrid> mButtons; std::shared_ptr<ComponentGrid> mButtons;
std::shared_ptr<ButtonComponent> mButton1; std::shared_ptr<ButtonComponent> mButton1;

View file

@ -17,7 +17,6 @@
GuiLaunchScreen::GuiLaunchScreen() GuiLaunchScreen::GuiLaunchScreen()
: mRenderer {Renderer::getInstance()} : mRenderer {Renderer::getInstance()}
, mBackground {":/graphics/frame.svg"}
, mGrid {nullptr} , mGrid {nullptr}
, mMarquee {nullptr} , mMarquee {nullptr}
{ {

View file

@ -11,9 +11,9 @@
#include "GuiComponent.h" #include "GuiComponent.h"
#include "Window.h" #include "Window.h"
#include "components/BackgroundComponent.h"
#include "components/ComponentGrid.h" #include "components/ComponentGrid.h"
#include "components/ImageComponent.h" #include "components/ImageComponent.h"
#include "components/NinePatchComponent.h"
#include "components/TextComponent.h" #include "components/TextComponent.h"
class FileData; class FileData;
@ -34,7 +34,7 @@ public:
private: private:
Renderer* mRenderer; Renderer* mRenderer;
NinePatchComponent mBackground; BackgroundComponent mBackground;
ComponentGrid* mGrid; ComponentGrid* mGrid;
std::shared_ptr<TextComponent> mTitle; std::shared_ptr<TextComponent> mTitle;

View file

@ -44,7 +44,6 @@ GuiMetaDataEd::GuiMetaDataEd(MetaDataList* md,
std::function<void()> clearGameFunc, std::function<void()> clearGameFunc,
std::function<void()> deleteGameFunc) std::function<void()> deleteGameFunc)
: mRenderer {Renderer::getInstance()} : mRenderer {Renderer::getInstance()}
, mBackground {":/graphics/frame.svg"}
, mGrid {glm::ivec2 {2, 6}} , mGrid {glm::ivec2 {2, 6}}
, mScraperParams {scraperParams} , mScraperParams {scraperParams}
, mControllerBadges {BadgeComponent::getGameControllers()} , mControllerBadges {BadgeComponent::getGameControllers()}

View file

@ -13,9 +13,9 @@
#include "GuiComponent.h" #include "GuiComponent.h"
#include "MetaData.h" #include "MetaData.h"
#include "components/BackgroundComponent.h"
#include "components/BadgeComponent.h" #include "components/BadgeComponent.h"
#include "components/ComponentGrid.h" #include "components/ComponentGrid.h"
#include "components/NinePatchComponent.h"
#include "components/ScrollIndicatorComponent.h" #include "components/ScrollIndicatorComponent.h"
#include "guis/GuiSettings.h" #include "guis/GuiSettings.h"
#include "scrapers/Scraper.h" #include "scrapers/Scraper.h"
@ -46,7 +46,7 @@ private:
void close(); void close();
Renderer* mRenderer; Renderer* mRenderer;
NinePatchComponent mBackground; BackgroundComponent mBackground;
ComponentGrid mGrid; ComponentGrid mGrid;
std::shared_ptr<TextComponent> mTitle; std::shared_ptr<TextComponent> mTitle;

View file

@ -16,7 +16,6 @@
GuiOfflineGenerator::GuiOfflineGenerator(const std::queue<FileData*>& gameQueue) GuiOfflineGenerator::GuiOfflineGenerator(const std::queue<FileData*>& gameQueue)
: mGameQueue {gameQueue} : mGameQueue {gameQueue}
, mRenderer {Renderer::getInstance()} , mRenderer {Renderer::getInstance()}
, mBackground {":/graphics/frame.svg"}
, mGrid {glm::ivec2 {6, 13}} , mGrid {glm::ivec2 {6, 13}}
{ {
addChild(&mBackground); addChild(&mBackground);

View file

@ -12,6 +12,7 @@
#include "GuiComponent.h" #include "GuiComponent.h"
#include "MiximageGenerator.h" #include "MiximageGenerator.h"
#include "components/BackgroundComponent.h"
#include "components/ButtonComponent.h" #include "components/ButtonComponent.h"
#include "components/ComponentGrid.h" #include "components/ComponentGrid.h"
#include "views/ViewController.h" #include "views/ViewController.h"
@ -54,7 +55,7 @@ private:
unsigned int mGamesFailed; unsigned int mGamesFailed;
Renderer* mRenderer; Renderer* mRenderer;
NinePatchComponent mBackground; BackgroundComponent mBackground;
ComponentGrid mGrid; ComponentGrid mGrid;
std::shared_ptr<TextComponent> mTitle; std::shared_ptr<TextComponent> mTitle;

View file

@ -19,7 +19,6 @@
GuiOrphanedDataCleanup::GuiOrphanedDataCleanup(std::function<void()> reloadCallback) GuiOrphanedDataCleanup::GuiOrphanedDataCleanup(std::function<void()> reloadCallback)
: mRenderer {Renderer::getInstance()} : mRenderer {Renderer::getInstance()}
, mBackground {":/graphics/frame.svg"}
, mGrid {glm::ivec2 {4, 11}} , mGrid {glm::ivec2 {4, 11}}
, mReloadCallback {reloadCallback} , mReloadCallback {reloadCallback}
, mCursorPos {0} , mCursorPos {0}

View file

@ -10,6 +10,7 @@
#define ES_APP_GUIS_GUI_ORPHANED_DATA_CLEANUP_H #define ES_APP_GUIS_GUI_ORPHANED_DATA_CLEANUP_H
#include "GuiComponent.h" #include "GuiComponent.h"
#include "components/BackgroundComponent.h"
#include "components/BusyComponent.h" #include "components/BusyComponent.h"
#include "guis/GuiSettings.h" #include "guis/GuiSettings.h"
#include "views/ViewController.h" #include "views/ViewController.h"
@ -38,7 +39,7 @@ private:
std::vector<HelpPrompt> getHelpPrompts() override; std::vector<HelpPrompt> getHelpPrompts() override;
Renderer* mRenderer; Renderer* mRenderer;
NinePatchComponent mBackground; BackgroundComponent mBackground;
ComponentGrid mGrid; ComponentGrid mGrid;
BusyComponent mBusyAnim; BusyComponent mBusyAnim;
std::function<void()> mReloadCallback; std::function<void()> mReloadCallback;

View file

@ -28,7 +28,6 @@ GuiScraperMulti::GuiScraperMulti(
const std::pair<std::queue<ScraperSearchParams>, std::map<SystemData*, int>>& searches, const std::pair<std::queue<ScraperSearchParams>, std::map<SystemData*, int>>& searches,
bool approveResults) bool approveResults)
: mRenderer {Renderer::getInstance()} : mRenderer {Renderer::getInstance()}
, mBackground {":/graphics/frame.svg"}
, mGrid {glm::ivec2 {2, 6}} , mGrid {glm::ivec2 {2, 6}}
, mSearchQueue {searches.first} , mSearchQueue {searches.first}
, mApproveResults {approveResults} , mApproveResults {approveResults}

View file

@ -14,8 +14,8 @@
#include "GuiComponent.h" #include "GuiComponent.h"
#include "MetaData.h" #include "MetaData.h"
#include "components/BackgroundComponent.h"
#include "components/ComponentGrid.h" #include "components/ComponentGrid.h"
#include "components/NinePatchComponent.h"
#include "components/ScrollIndicatorComponent.h" #include "components/ScrollIndicatorComponent.h"
#include "scrapers/Scraper.h" #include "scrapers/Scraper.h"
#include "views/ViewController.h" #include "views/ViewController.h"
@ -43,7 +43,7 @@ private:
void finish(); void finish();
Renderer* mRenderer; Renderer* mRenderer;
NinePatchComponent mBackground; BackgroundComponent mBackground;
ComponentGrid mGrid; ComponentGrid mGrid;
std::shared_ptr<TextComponent> mTitle; std::shared_ptr<TextComponent> mTitle;

View file

@ -23,7 +23,6 @@ GuiScraperSingle::GuiScraperSingle(ScraperSearchParams& params,
bool& savedMediaAndAborted) bool& savedMediaAndAborted)
: mClose {false} : mClose {false}
, mRenderer {Renderer::getInstance()} , mRenderer {Renderer::getInstance()}
, mBackground {":/graphics/frame.svg"}
, mGrid {glm::ivec2 {2, 6}} , mGrid {glm::ivec2 {2, 6}}
, mSearchParams {params} , mSearchParams {params}
, mSavedMediaAndAborted {savedMediaAndAborted} , mSavedMediaAndAborted {savedMediaAndAborted}

View file

@ -12,7 +12,7 @@
#define ES_APP_GUIS_GUI_SCRAPER_SINGLE_H #define ES_APP_GUIS_GUI_SCRAPER_SINGLE_H
#include "GuiComponent.h" #include "GuiComponent.h"
#include "components/NinePatchComponent.h" #include "components/BackgroundComponent.h"
#include "components/ScrollIndicatorComponent.h" #include "components/ScrollIndicatorComponent.h"
#include "guis/GuiScraperSearch.h" #include "guis/GuiScraperSearch.h"
#include "views/ViewController.h" #include "views/ViewController.h"
@ -36,7 +36,7 @@ private:
void close(); void close();
Renderer* mRenderer; Renderer* mRenderer;
NinePatchComponent mBackground; BackgroundComponent mBackground;
ComponentGrid mGrid; ComponentGrid mGrid;
std::shared_ptr<TextComponent> mGameName; std::shared_ptr<TextComponent> mGameName;

View file

@ -28,7 +28,6 @@
GuiThemeDownloader::GuiThemeDownloader(std::function<void()> updateCallback) GuiThemeDownloader::GuiThemeDownloader(std::function<void()> updateCallback)
: mRenderer {Renderer::getInstance()} : mRenderer {Renderer::getInstance()}
, mBackground {":/graphics/frame.svg"}
, mGrid {glm::ivec2 {2, 4}} , mGrid {glm::ivec2 {2, 4}}
, mUpdateCallback(updateCallback) , mUpdateCallback(updateCallback)
, mRepositoryError {RepositoryError::NO_REPO_ERROR} , mRepositoryError {RepositoryError::NO_REPO_ERROR}

View file

@ -10,12 +10,12 @@
#define ES_APP_GUIS_GUI_THEME_DOWNLOADER_H #define ES_APP_GUIS_GUI_THEME_DOWNLOADER_H
#include "GuiComponent.h" #include "GuiComponent.h"
#include "components/BackgroundComponent.h"
#include "components/BusyComponent.h" #include "components/BusyComponent.h"
#include "components/ButtonComponent.h" #include "components/ButtonComponent.h"
#include "components/ComponentGrid.h" #include "components/ComponentGrid.h"
#include "components/ComponentList.h" #include "components/ComponentList.h"
#include "components/ImageComponent.h" #include "components/ImageComponent.h"
#include "components/NinePatchComponent.h"
#include "components/ScrollIndicatorComponent.h" #include "components/ScrollIndicatorComponent.h"
#include "components/TextComponent.h" #include "components/TextComponent.h"
#include "renderers/Renderer.h" #include "renderers/Renderer.h"
@ -107,7 +107,7 @@ private:
void setupFullscreenViewer(); void setupFullscreenViewer();
Renderer* mRenderer; Renderer* mRenderer;
NinePatchComponent mBackground; BackgroundComponent mBackground;
ComponentGrid mGrid; ComponentGrid mGrid;
std::shared_ptr<ComponentGrid> mCenterGrid; std::shared_ptr<ComponentGrid> mCenterGrid;
std::shared_ptr<ComponentList> mList; std::shared_ptr<ComponentList> mList;

View file

@ -72,7 +72,7 @@ void ViewController::setMenuColors()
if (Settings::getInstance()->getString("MenuColorScheme") == "light") { if (Settings::getInstance()->getString("MenuColorScheme") == "light") {
mMenuColorFrame = 0xEFEFEFFF; mMenuColorFrame = 0xEFEFEFFF;
mMenuColorFrameLaunchScreen = 0xDFDFDFFF; mMenuColorFrameLaunchScreen = 0xDFDFDFFF;
mMenuColorFrameBusyComponent = 0xFFFFFFFF; mMenuColorFrameBusyComponent = 0xF5F5F5FF;
mMenuColorPanelDimmed = 0x00000009; mMenuColorPanelDimmed = 0x00000009;
mMenuColorTitle = 0x555555FF; mMenuColorTitle = 0x555555FF;
@ -109,7 +109,7 @@ void ViewController::setMenuColors()
else if (Settings::getInstance()->getString("MenuColorScheme") == "darkred") { else if (Settings::getInstance()->getString("MenuColorScheme") == "darkred") {
mMenuColorFrame = 0x191919FF; mMenuColorFrame = 0x191919FF;
mMenuColorFrameLaunchScreen = 0x121212FF; mMenuColorFrameLaunchScreen = 0x121212FF;
mMenuColorFrameBusyComponent = 0x090909FF; mMenuColorFrameBusyComponent = 0x000000FF;
mMenuColorPanelDimmed = 0x00000024; mMenuColorPanelDimmed = 0x00000024;
mMenuColorTitle = 0x909090FF; mMenuColorTitle = 0x909090FF;
@ -146,7 +146,7 @@ void ViewController::setMenuColors()
else { else {
mMenuColorFrame = 0x191919FF; mMenuColorFrame = 0x191919FF;
mMenuColorFrameLaunchScreen = 0x121212FF; mMenuColorFrameLaunchScreen = 0x121212FF;
mMenuColorFrameBusyComponent = 0x090909FF; mMenuColorFrameBusyComponent = 0x000000FF;
mMenuColorPanelDimmed = 0x00000024; mMenuColorPanelDimmed = 0x00000024;
mMenuColorTitle = 0x909090FF; mMenuColorTitle = 0x909090FF;

View file

@ -375,7 +375,7 @@ protected:
// Default values are for the "light" color scheme. // Default values are for the "light" color scheme.
static inline unsigned int mMenuColorFrame {0xEFEFEFFF}; static inline unsigned int mMenuColorFrame {0xEFEFEFFF};
static inline unsigned int mMenuColorFrameLaunchScreen {0xDFDFDFFF}; static inline unsigned int mMenuColorFrameLaunchScreen {0xDFDFDFFF};
static inline unsigned int mMenuColorFrameBusyComponent {0xFFFFFFFF}; static inline unsigned int mMenuColorFrameBusyComponent {0xF5F5F5FF};
static inline unsigned int mMenuColorPanelDimmed {0x00000009}; static inline unsigned int mMenuColorPanelDimmed {0x00000009};
static inline unsigned int mMenuColorTitle {0x555555FF}; static inline unsigned int mMenuColorTitle {0x555555FF};

View file

@ -179,7 +179,6 @@ bool Window::init(bool resized)
progressBarRect.color = 0x79010FFF; progressBarRect.color = 0x79010FFF;
mProgressBarRectangles.emplace_back(progressBarRect); mProgressBarRectangles.emplace_back(progressBarRect);
mBackgroundOverlay->setImage(":/graphics/frame.png");
mBackgroundOverlay->setResize(mRenderer->getScreenWidth(), mRenderer->getScreenHeight()); mBackgroundOverlay->setResize(mRenderer->getScreenWidth(), mRenderer->getScreenHeight());
mPostprocessedBackground = TextureResource::get("", false, false, false, false, false); mPostprocessedBackground = TextureResource::get("", false, false, false, false, false);

View file

@ -13,7 +13,8 @@
#include "utils/LocalizationUtil.h" #include "utils/LocalizationUtil.h"
BusyComponent::BusyComponent() BusyComponent::BusyComponent()
: mBackground {":/graphics/frame.png"} : mRenderer {Renderer::getInstance()}
, mBackground {glm::vec2 {16.0f, 16.0f}}
, mGrid {glm::ivec2 {5, 3}} , mGrid {glm::ivec2 {5, 3}}
{ {
mAnimation = std::make_shared<AnimatedImageComponent>(); mAnimation = std::make_shared<AnimatedImageComponent>();
@ -36,10 +37,10 @@ void BusyComponent::onSizeChanged()
if (mSize.x == 0.0f || mSize.y == 0.0f) if (mSize.x == 0.0f || mSize.y == 0.0f)
return; return;
const float middleSpacerWidth {0.01f * Renderer::getScreenWidth()}; const float middleSpacerWidth {0.01f * mRenderer->getScreenWidth()};
const float textHeight {mText->getFont()->getLetterHeight()}; const float textHeight {mText->getFont()->getLetterHeight()};
mText->setSize(0.0f, textHeight); mText->setSize(0.0f, textHeight);
const float textWidth {mText->getSize().x + (4.0f * Renderer::getScreenWidthModifier())}; const float textWidth {mText->getSize().x + (4.0f * mRenderer->getScreenWidthModifier())};
mGrid.setColWidthPerc(1, textHeight / mSize.x); // Animation is square. mGrid.setColWidthPerc(1, textHeight / mSize.x); // Animation is square.
mGrid.setColWidthPerc(2, middleSpacerWidth / mSize.x); mGrid.setColWidthPerc(2, middleSpacerWidth / mSize.x);
@ -47,11 +48,11 @@ void BusyComponent::onSizeChanged()
mGrid.setRowHeightPerc(1, mText->getFont()->getLetterHeight() / mSize.y); mGrid.setRowHeightPerc(1, mText->getFont()->getLetterHeight() / mSize.y);
mBackground.setCornerSize({16.0f * Renderer::getScreenResolutionModifier(),
16.0f * Renderer::getScreenResolutionModifier()});
mBackground.fitTo(glm::vec2 {mGrid.getColWidth(1) + mGrid.getColWidth(2) + mGrid.getColWidth(3), mBackground.fitTo(glm::vec2 {mGrid.getColWidth(1) + mGrid.getColWidth(2) + mGrid.getColWidth(3),
textHeight + (2.0f * Renderer::getScreenResolutionModifier())}, textHeight + (2.0f * mRenderer->getScreenResolutionModifier())},
mAnimation->getPosition(), glm::vec2 {0.0f, 0.0f}); mAnimation->getPosition(),
glm::vec2 {32.0f * mRenderer->getScreenResolutionModifier(),
32.0f * mRenderer->getScreenResolutionModifier()});
mBackground.setFrameColor(mMenuColorFrameBusyComponent); mBackground.setFrameColor(mMenuColorFrameBusyComponent);
AnimationFrame BUSY_ANIMATION_FRAMES[] { AnimationFrame BUSY_ANIMATION_FRAMES[] {
@ -64,8 +65,3 @@ void BusyComponent::onSizeChanged()
const AnimationDef animationDef {BUSY_ANIMATION_FRAMES, 4, mMenuColorBusyComponent, true}; const AnimationDef animationDef {BUSY_ANIMATION_FRAMES, 4, mMenuColorBusyComponent, true};
mAnimation->load(&animationDef); mAnimation->load(&animationDef);
} }
void BusyComponent::reset()
{
// mAnimation->reset();
}

View file

@ -10,8 +10,8 @@
#define ES_CORE_COMPONENTS_BUSY_COMPONENT_H #define ES_CORE_COMPONENTS_BUSY_COMPONENT_H
#include "GuiComponent.h" #include "GuiComponent.h"
#include "components/BackgroundComponent.h"
#include "components/ComponentGrid.h" #include "components/ComponentGrid.h"
#include "components/NinePatchComponent.h"
#include "components/TextComponent.h" #include "components/TextComponent.h"
class AnimatedImageComponent; class AnimatedImageComponent;
@ -25,10 +25,9 @@ public:
void setText(const std::string& text) { mText->setText(text, true); } void setText(const std::string& text) { mText->setText(text, true); }
void onSizeChanged() override; void onSizeChanged() override;
void reset(); // Reset to frame 0.
private: private:
NinePatchComponent mBackground; Renderer* mRenderer;
BackgroundComponent mBackground;
ComponentGrid mGrid; ComponentGrid mGrid;
std::shared_ptr<AnimatedImageComponent> mAnimation; std::shared_ptr<AnimatedImageComponent> mAnimation;

View file

@ -27,8 +27,6 @@ MenuComponent::MenuComponent(std::string title, const std::shared_ptr<Font>& tit
addChild(&mBackground); addChild(&mBackground);
addChild(&mGrid); addChild(&mGrid);
mBackground.setImagePath(":/graphics/frame.svg");
// Set up title. // Set up title.
mTitle = std::make_shared<TextComponent>(); mTitle = std::make_shared<TextComponent>();
mTitle->setAutoCalcExtent(glm::ivec2 {0, 0}); mTitle->setAutoCalcExtent(glm::ivec2 {0, 0});

View file

@ -9,11 +9,11 @@
#ifndef ES_CORE_COMPONENTS_MENU_COMPONENT_H #ifndef ES_CORE_COMPONENTS_MENU_COMPONENT_H
#define ES_CORE_COMPONENTS_MENU_COMPONENT_H #define ES_CORE_COMPONENTS_MENU_COMPONENT_H
#include "components/BackgroundComponent.h"
#include "components/ButtonComponent.h" #include "components/ButtonComponent.h"
#include "components/ComponentGrid.h" #include "components/ComponentGrid.h"
#include "components/ComponentList.h" #include "components/ComponentList.h"
#include "components/ImageComponent.h" #include "components/ImageComponent.h"
#include "components/NinePatchComponent.h"
#include "components/ScrollIndicatorComponent.h" #include "components/ScrollIndicatorComponent.h"
#include "components/TextComponent.h" #include "components/TextComponent.h"
#include "utils/LocalizationUtil.h" #include "utils/LocalizationUtil.h"
@ -85,7 +85,7 @@ private:
float getButtonGridHeight() const; float getButtonGridHeight() const;
Renderer* mRenderer; Renderer* mRenderer;
NinePatchComponent mBackground; BackgroundComponent mBackground;
ComponentGrid mGrid; ComponentGrid mGrid;
std::shared_ptr<TextComponent> mTitle; std::shared_ptr<TextComponent> mTitle;

View file

@ -24,7 +24,6 @@ GuiDetectDevice::GuiDetectDevice(bool firstRun,
: mFirstRun {firstRun} : mFirstRun {firstRun}
, mForcedConfig {forcedConfig} , mForcedConfig {forcedConfig}
, mRenderer {Renderer::getInstance()} , mRenderer {Renderer::getInstance()}
, mBackground {":/graphics/frame.svg"}
, mGrid {glm::ivec2 {1, 5}} , mGrid {glm::ivec2 {1, 5}}
{ {
mHoldingConfig = nullptr; mHoldingConfig = nullptr;

View file

@ -10,8 +10,8 @@
#define ES_CORE_GUIS_GUI_DETECT_DEVICE_H #define ES_CORE_GUIS_GUI_DETECT_DEVICE_H
#include "GuiComponent.h" #include "GuiComponent.h"
#include "components/BackgroundComponent.h"
#include "components/ComponentGrid.h" #include "components/ComponentGrid.h"
#include "components/NinePatchComponent.h"
class TextComponent; class TextComponent;
@ -31,7 +31,7 @@ private:
int mHoldTime; int mHoldTime;
Renderer* mRenderer; Renderer* mRenderer;
NinePatchComponent mBackground; BackgroundComponent mBackground;
ComponentGrid mGrid; ComponentGrid mGrid;
std::shared_ptr<TextComponent> mTitle; std::shared_ptr<TextComponent> mTitle;

View file

@ -9,7 +9,6 @@
#include "guis/GuiInfoPopup.h" #include "guis/GuiInfoPopup.h"
#include "components/ComponentGrid.h" #include "components/ComponentGrid.h"
#include "components/NinePatchComponent.h"
#include "components/TextComponent.h" #include "components/TextComponent.h"
#include <SDL2/SDL_timer.h> #include <SDL2/SDL_timer.h>
@ -21,7 +20,7 @@ GuiInfoPopup::GuiInfoPopup(std::string message, int duration)
, mAlpha {1.0f} , mAlpha {1.0f}
, mRunning {true} , mRunning {true}
{ {
mFrame = new NinePatchComponent; mBackground = new BackgroundComponent(glm::vec2 {22.0f, 22.0f});
float maxWidth {Renderer::getScreenWidth() * 0.9f}; float maxWidth {Renderer::getScreenWidth() * 0.9f};
float maxHeight {Renderer::getScreenHeight() * 0.2f}; float maxHeight {Renderer::getScreenHeight() * 0.2f};
@ -54,9 +53,8 @@ GuiInfoPopup::GuiInfoPopup(std::string message, int duration)
setPosition(posX, posY, 0); setPosition(posX, posY, 0);
mFrame->setImagePath(":/graphics/frame.svg"); mBackground->fitTo(mSize);
mFrame->fitTo(mSize); addChild(mBackground);
addChild(mFrame);
// We only initialize the actual time when we first start to render. // We only initialize the actual time when we first start to render.
mStartTime = 0; mStartTime = 0;
@ -71,7 +69,7 @@ GuiInfoPopup::GuiInfoPopup(std::string message, int duration)
GuiInfoPopup::~GuiInfoPopup() GuiInfoPopup::~GuiInfoPopup()
{ {
delete mGrid; delete mGrid;
delete mFrame; delete mBackground;
} }
void GuiInfoPopup::render(const glm::mat4& /*parentTrans*/) void GuiInfoPopup::render(const glm::mat4& /*parentTrans*/)
@ -116,7 +114,7 @@ bool GuiInfoPopup::updateState()
mGrid->setOpacity(mAlpha); mGrid->setOpacity(mAlpha);
// Apply fade-in effect to popup frame. // Apply fade-in effect to popup frame.
mFrame->setFrameColor((mMenuColorFrame & 0xFFFFFF00) | mBackground->setFrameColor((mMenuColorFrame & 0xFFFFFF00) |
static_cast<unsigned char>(mAlpha * 255.0f)); static_cast<unsigned char>(mAlpha * 255.0f));
return true; return true;
} }

View file

@ -10,10 +10,11 @@
#define ES_APP_GUIS_GUI_INFO_POPUP_H #define ES_APP_GUIS_GUI_INFO_POPUP_H
#include "GuiComponent.h" #include "GuiComponent.h"
#include "components/BackgroundComponent.h"
#include "renderers/Renderer.h" #include "renderers/Renderer.h"
class ComponentGrid; class ComponentGrid;
class NinePatchComponent; class BackgroundComponent;
class GuiInfoPopup : public GuiComponent class GuiInfoPopup : public GuiComponent
{ {
@ -30,7 +31,7 @@ private:
Renderer* mRenderer; Renderer* mRenderer;
ComponentGrid* mGrid; ComponentGrid* mGrid;
NinePatchComponent* mFrame; BackgroundComponent* mBackground;
std::string mMessage; std::string mMessage;
int mDuration; int mDuration;

View file

@ -30,8 +30,7 @@ static InputConfigStructure sGuiInputConfigList[inputCount];
GuiInputConfig::GuiInputConfig(InputConfig* target, GuiInputConfig::GuiInputConfig(InputConfig* target,
bool reconfigureAll, bool reconfigureAll,
const std::function<void()>& okCallback) const std::function<void()>& okCallback)
: mBackground {":/graphics/frame.svg"} : mGrid {glm::ivec2 {1, 7}}
, mGrid {glm::ivec2 {1, 7}}
, mTargetConfig {target} , mTargetConfig {target}
, mHoldingInput {false} , mHoldingInput {false}
{ {

View file

@ -10,8 +10,8 @@
#define ES_CORE_GUIS_GUI_INPUT_CONFIG_H #define ES_CORE_GUIS_GUI_INPUT_CONFIG_H
#include "GuiComponent.h" #include "GuiComponent.h"
#include "components/BackgroundComponent.h"
#include "components/ComponentGrid.h" #include "components/ComponentGrid.h"
#include "components/NinePatchComponent.h"
class ComponentList; class ComponentList;
class TextComponent; class TextComponent;
@ -46,7 +46,7 @@ private:
bool assign(Input input, int inputId); bool assign(Input input, int inputId);
void clearAssignment(int inputId); void clearAssignment(int inputId);
NinePatchComponent mBackground; BackgroundComponent mBackground;
ComponentGrid mGrid; ComponentGrid mGrid;
std::shared_ptr<TextComponent> mTitle; std::shared_ptr<TextComponent> mTitle;

View file

@ -27,7 +27,6 @@ GuiMsgBox::GuiMsgBox(const std::string& text,
const bool deleteOnButtonPress, const bool deleteOnButtonPress,
const float maxWidthMultiplier) const float maxWidthMultiplier)
: mRenderer {Renderer::getInstance()} : mRenderer {Renderer::getInstance()}
, mBackground {":/graphics/frame.svg"}
, mGrid {glm::ivec2 {1, 2}} , mGrid {glm::ivec2 {1, 2}}
, mBackFunc {backFunc} , mBackFunc {backFunc}
, mDisableBackButton {disableBackButton} , mDisableBackButton {disableBackButton}

View file

@ -11,8 +11,8 @@
#define ES_CORE_GUIS_GUI_MSG_BOX_H #define ES_CORE_GUIS_GUI_MSG_BOX_H
#include "GuiComponent.h" #include "GuiComponent.h"
#include "components/BackgroundComponent.h"
#include "components/ComponentGrid.h" #include "components/ComponentGrid.h"
#include "components/NinePatchComponent.h"
#include "utils/LocalizationUtil.h" #include "utils/LocalizationUtil.h"
class ButtonComponent; class ButtonComponent;
@ -46,7 +46,7 @@ private:
void deleteMeAndCall(const std::function<void()>& func); void deleteMeAndCall(const std::function<void()>& func);
Renderer* mRenderer; Renderer* mRenderer;
NinePatchComponent mBackground; BackgroundComponent mBackground;
ComponentGrid mGrid; ComponentGrid mGrid;
std::shared_ptr<TextComponent> mMsg; std::shared_ptr<TextComponent> mMsg;

View file

@ -54,7 +54,6 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
const std::string& clearBtnHelpText, const std::string& clearBtnHelpText,
const std::string& cancelBtnHelpText) const std::string& cancelBtnHelpText)
: mRenderer {Renderer::getInstance()} : mRenderer {Renderer::getInstance()}
, mBackground {":/graphics/frame.svg"}
, mGrid {glm::ivec2 {1, (infoString != "" && defaultValue != "" ? 8 : 6)}} , mGrid {glm::ivec2 {1, (infoString != "" && defaultValue != "" ? 8 : 6)}}
, mInitValue {initValue} , mInitValue {initValue}
, mAcceptBtnHelpText {acceptBtnHelpText} , mAcceptBtnHelpText {acceptBtnHelpText}

View file

@ -11,6 +11,7 @@
#define ES_CORE_GUIS_GUI_TEXT_EDIT_KEYBOARD_POPUP_H #define ES_CORE_GUIS_GUI_TEXT_EDIT_KEYBOARD_POPUP_H
#include "GuiComponent.h" #include "GuiComponent.h"
#include "components/BackgroundComponent.h"
#include "components/ButtonComponent.h" #include "components/ButtonComponent.h"
#include "components/ComponentGrid.h" #include "components/ComponentGrid.h"
#include "components/TextComponent.h" #include "components/TextComponent.h"
@ -77,7 +78,7 @@ private:
std::shared_ptr<ButtonComponent> mAltButton; std::shared_ptr<ButtonComponent> mAltButton;
Renderer* mRenderer; Renderer* mRenderer;
NinePatchComponent mBackground; BackgroundComponent mBackground;
ComponentGrid mGrid; ComponentGrid mGrid;
std::shared_ptr<TextComponent> mTitle; std::shared_ptr<TextComponent> mTitle;

View file

@ -26,8 +26,7 @@ GuiTextEditPopup::GuiTextEditPopup(const std::string& title,
const std::string& loadBtnHelpText, const std::string& loadBtnHelpText,
const std::string& clearBtnHelpText, const std::string& clearBtnHelpText,
const std::string& cancelBtnHelpText) const std::string& cancelBtnHelpText)
: mBackground {":/graphics/frame.svg"} : mGrid {glm::ivec2 {1, (infoString != "" && defaultValue != "" ? 5 : 3)}}
, mGrid {glm::ivec2 {1, (infoString != "" && defaultValue != "" ? 5 : 3)}}
, mInitValue {initValue} , mInitValue {initValue}
, mAcceptBtnText {acceptBtnText} , mAcceptBtnText {acceptBtnText}
, mSaveConfirmationText {saveConfirmationText} , mSaveConfirmationText {saveConfirmationText}

View file

@ -11,6 +11,7 @@
#define ES_CORE_GUIS_GUI_TEXT_EDIT_POPUP_H #define ES_CORE_GUIS_GUI_TEXT_EDIT_POPUP_H
#include "GuiComponent.h" #include "GuiComponent.h"
#include "components/BackgroundComponent.h"
#include "components/ButtonComponent.h" #include "components/ButtonComponent.h"
#include "components/ComponentGrid.h" #include "components/ComponentGrid.h"
#include "components/TextComponent.h" #include "components/TextComponent.h"
@ -41,7 +42,7 @@ public:
private: private:
void updateDeleteRepeat(int deltaTime); void updateDeleteRepeat(int deltaTime);
NinePatchComponent mBackground; BackgroundComponent mBackground;
ComponentGrid mGrid; ComponentGrid mGrid;
std::shared_ptr<TextComponent> mTitle; std::shared_ptr<TextComponent> mTitle;