mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-18 04:45:39 +00:00
Changed the opacity data type and functions from unsigned char to float.
This commit is contained in:
parent
8fd05bb2a2
commit
2c2e624160
|
@ -27,7 +27,7 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define FADE_TIME 300
|
#define FADE_TIME 300.0f
|
||||||
|
|
||||||
Screensaver::Screensaver()
|
Screensaver::Screensaver()
|
||||||
: mWindow {Window::getInstance()}
|
: mWindow {Window::getInstance()}
|
||||||
|
@ -255,7 +255,7 @@ void Screensaver::renderScreensaver()
|
||||||
// Only render the image if the state requires it.
|
// Only render the image if the state requires it.
|
||||||
if (static_cast<int>(mState) >= STATE_FADE_IN_VIDEO) {
|
if (static_cast<int>(mState) >= STATE_FADE_IN_VIDEO) {
|
||||||
if (mImageScreensaver->hasImage()) {
|
if (mImageScreensaver->hasImage()) {
|
||||||
mImageScreensaver->setOpacity(255 - static_cast<unsigned char>(mOpacity * 255));
|
mImageScreensaver->setOpacity(1.0f - mOpacity);
|
||||||
glm::mat4 trans {Renderer::getIdentity()};
|
glm::mat4 trans {Renderer::getIdentity()};
|
||||||
mImageScreensaver->render(trans);
|
mImageScreensaver->render(trans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -299,8 +299,10 @@ void GuiMenu::openUIOptions()
|
||||||
}
|
}
|
||||||
if (!selectedSet->second.capabilities.legacyTheme && selectableVariants > 0) {
|
if (!selectedSet->second.capabilities.legacyTheme && selectableVariants > 0) {
|
||||||
themeVariant->setEnabled(true);
|
themeVariant->setEnabled(true);
|
||||||
themeVariant->setOpacity(255);
|
themeVariant->setOpacity(1.0f);
|
||||||
themeVariant->getParent()->getChild(themeVariant->getChildIndex() - 1)->setOpacity(255);
|
themeVariant->getParent()
|
||||||
|
->getChild(themeVariant->getChildIndex() - 1)
|
||||||
|
->setOpacity(1.0f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
themeVariant->setEnabled(false);
|
themeVariant->setEnabled(false);
|
||||||
|
@ -313,10 +315,10 @@ void GuiMenu::openUIOptions()
|
||||||
if (!selectedSet->second.capabilities.legacyTheme &&
|
if (!selectedSet->second.capabilities.legacyTheme &&
|
||||||
selectedSet->second.capabilities.aspectRatios.size() > 0) {
|
selectedSet->second.capabilities.aspectRatios.size() > 0) {
|
||||||
themeAspectRatio->setEnabled(true);
|
themeAspectRatio->setEnabled(true);
|
||||||
themeAspectRatio->setOpacity(255);
|
themeAspectRatio->setOpacity(1.0f);
|
||||||
themeAspectRatio->getParent()
|
themeAspectRatio->getParent()
|
||||||
->getChild(themeAspectRatio->getChildIndex() - 1)
|
->getChild(themeAspectRatio->getChildIndex() - 1)
|
||||||
->setOpacity(255);
|
->setOpacity(1.0f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
themeAspectRatio->setEnabled(false);
|
themeAspectRatio->setEnabled(false);
|
||||||
|
@ -340,16 +342,16 @@ void GuiMenu::openUIOptions()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
gamelist_view_style->setEnabled(true);
|
gamelist_view_style->setEnabled(true);
|
||||||
gamelist_view_style->setOpacity(255);
|
gamelist_view_style->setOpacity(1.0f);
|
||||||
gamelist_view_style->getParent()
|
gamelist_view_style->getParent()
|
||||||
->getChild(gamelist_view_style->getChildIndex() - 1)
|
->getChild(gamelist_view_style->getChildIndex() - 1)
|
||||||
->setOpacity(255);
|
->setOpacity(1.0f);
|
||||||
|
|
||||||
transition_style->setEnabled(true);
|
transition_style->setEnabled(true);
|
||||||
transition_style->setOpacity(255);
|
transition_style->setOpacity(1.0f);
|
||||||
transition_style->getParent()
|
transition_style->getParent()
|
||||||
->getChild(transition_style->getChildIndex() - 1)
|
->getChild(transition_style->getChildIndex() - 1)
|
||||||
->setOpacity(255);
|
->setOpacity(1.0f);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -915,10 +915,10 @@ void GuiScraperMenu::openOtherOptions()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scraper_semiautomatic->setEnabled(true);
|
scraper_semiautomatic->setEnabled(true);
|
||||||
scraper_semiautomatic->setOpacity(255);
|
scraper_semiautomatic->setOpacity(1.0f);
|
||||||
scraper_semiautomatic->getParent()
|
scraper_semiautomatic->getParent()
|
||||||
->getChild(scraper_semiautomatic->getChildIndex() - 1)
|
->getChild(scraper_semiautomatic->getChildIndex() - 1)
|
||||||
->setOpacity(255);
|
->setOpacity(1.0f);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -932,10 +932,10 @@ void GuiScraperMenu::openOtherOptions()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
scraper_exclude_recursively->setEnabled(true);
|
scraper_exclude_recursively->setEnabled(true);
|
||||||
scraper_exclude_recursively->setOpacity(255);
|
scraper_exclude_recursively->setOpacity(1.0f);
|
||||||
scraper_exclude_recursively->getParent()
|
scraper_exclude_recursively->getParent()
|
||||||
->getChild(scraper_exclude_recursively->getChildIndex() - 1)
|
->getChild(scraper_exclude_recursively->getChildIndex() - 1)
|
||||||
->setOpacity(255);
|
->setOpacity(1.0f);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -70,8 +70,8 @@ GuiScraperMulti::GuiScraperMulti(const std::queue<ScraperSearchParams>& searches
|
||||||
mSearchComp->setSkipCallback(std::bind(&GuiScraperMulti::skip, this));
|
mSearchComp->setSkipCallback(std::bind(&GuiScraperMulti::skip, this));
|
||||||
mSearchComp->setCancelCallback(std::bind(&GuiScraperMulti::finish, this));
|
mSearchComp->setCancelCallback(std::bind(&GuiScraperMulti::finish, this));
|
||||||
mSearchComp->setRefineCallback([&] {
|
mSearchComp->setRefineCallback([&] {
|
||||||
mScrollUp->setOpacity(0);
|
mScrollUp->setOpacity(0.0f);
|
||||||
mScrollDown->setOpacity(0);
|
mScrollDown->setOpacity(0.0f);
|
||||||
mResultList->resetScrollIndicatorStatus();
|
mResultList->resetScrollIndicatorStatus();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -230,8 +230,8 @@ void GuiScraperMulti::doNextSearch()
|
||||||
scrapeName = Utils::FileSystem::getFileName(mSearchQueue.front().game->getPath());
|
scrapeName = Utils::FileSystem::getFileName(mSearchQueue.front().game->getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
mScrollUp->setOpacity(0);
|
mScrollUp->setOpacity(0.0f);
|
||||||
mScrollDown->setOpacity(0);
|
mScrollDown->setOpacity(0.0f);
|
||||||
mResultList->resetScrollIndicatorStatus();
|
mResultList->resetScrollIndicatorStatus();
|
||||||
|
|
||||||
// Extract possible subfolders from the path.
|
// Extract possible subfolders from the path.
|
||||||
|
|
|
@ -557,7 +557,7 @@ void GuiScraperSearch::updateInfoPane()
|
||||||
// Metadata.
|
// Metadata.
|
||||||
if (mScrapeRatings) {
|
if (mScrapeRatings) {
|
||||||
mMD_Rating->setValue(Utils::String::toUpper(res.mdl.get("rating")));
|
mMD_Rating->setValue(Utils::String::toUpper(res.mdl.get("rating")));
|
||||||
mMD_Rating->setOpacity(255);
|
mMD_Rating->setOpacity(1.0f);
|
||||||
}
|
}
|
||||||
mMD_ReleaseDate->setValue(Utils::String::toUpper(res.mdl.get("releasedate")));
|
mMD_ReleaseDate->setValue(Utils::String::toUpper(res.mdl.get("releasedate")));
|
||||||
mMD_Developer->setText(Utils::String::toUpper(res.mdl.get("developer")));
|
mMD_Developer->setText(Utils::String::toUpper(res.mdl.get("developer")));
|
||||||
|
@ -574,7 +574,7 @@ void GuiScraperSearch::updateInfoPane()
|
||||||
// Metadata.
|
// Metadata.
|
||||||
if (mScrapeRatings) {
|
if (mScrapeRatings) {
|
||||||
mMD_Rating->setValue("");
|
mMD_Rating->setValue("");
|
||||||
mMD_Rating->setOpacity(0);
|
mMD_Rating->setOpacity(0.0f);
|
||||||
}
|
}
|
||||||
// Set the release date to this value to force DateTimeEditComponent to put a
|
// Set the release date to this value to force DateTimeEditComponent to put a
|
||||||
// blank instead of the text 'unknown' prior to the scrape result being returned.
|
// blank instead of the text 'unknown' prior to the scrape result being returned.
|
||||||
|
|
|
@ -113,8 +113,8 @@ GuiScraperSingle::GuiScraperSingle(ScraperSearchParams& params,
|
||||||
});
|
});
|
||||||
mSearch->setCancelCallback([&] { delete this; });
|
mSearch->setCancelCallback([&] { delete this; });
|
||||||
mSearch->setRefineCallback([&] {
|
mSearch->setRefineCallback([&] {
|
||||||
mScrollUp->setOpacity(0);
|
mScrollUp->setOpacity(0.0f);
|
||||||
mScrollDown->setOpacity(0);
|
mScrollDown->setOpacity(0.0f);
|
||||||
mResultList->resetScrollIndicatorStatus();
|
mResultList->resetScrollIndicatorStatus();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -466,8 +466,8 @@ void GamelistView::legacyUpdateInfoPanel()
|
||||||
if (mViewStyle == ViewController::DETAILED) {
|
if (mViewStyle == ViewController::DETAILED) {
|
||||||
// Fade in the game image.
|
// Fade in the game image.
|
||||||
auto func = [this](float t) {
|
auto func = [this](float t) {
|
||||||
mImageComponents[LegacyImage::MD_IMAGE]->setOpacity(static_cast<unsigned char>(
|
mImageComponents[LegacyImage::MD_IMAGE]->setOpacity(
|
||||||
glm::mix(static_cast<float>(FADE_IN_START_OPACITY), 1.0f, t) * 255));
|
glm::mix(FADE_IN_START_OPACITY, 1.0f, t));
|
||||||
};
|
};
|
||||||
mImageComponents[LegacyImage::MD_IMAGE]->setAnimation(
|
mImageComponents[LegacyImage::MD_IMAGE]->setAnimation(
|
||||||
new LambdaAnimation(func, FADE_IN_TIME), 0, nullptr, false);
|
new LambdaAnimation(func, FADE_IN_TIME), 0, nullptr, false);
|
||||||
|
@ -475,8 +475,7 @@ void GamelistView::legacyUpdateInfoPanel()
|
||||||
else if (mViewStyle == ViewController::VIDEO) {
|
else if (mViewStyle == ViewController::VIDEO) {
|
||||||
// Fade in the static image.
|
// Fade in the static image.
|
||||||
auto func = [this](float t) {
|
auto func = [this](float t) {
|
||||||
mVideoComponents.front()->setOpacity(static_cast<unsigned char>(
|
mVideoComponents.front()->setOpacity(glm::mix(FADE_IN_START_OPACITY, 1.0f, t));
|
||||||
glm::mix(static_cast<float>(FADE_IN_START_OPACITY), 1.0f, t) * 255));
|
|
||||||
};
|
};
|
||||||
mVideoComponents.front()->setAnimation(new LambdaAnimation(func, FADE_IN_TIME), 0,
|
mVideoComponents.front()->setAnimation(new LambdaAnimation(func, FADE_IN_TIME), 0,
|
||||||
nullptr, false);
|
nullptr, false);
|
||||||
|
@ -560,10 +559,8 @@ void GamelistView::legacyUpdateInfoPanel()
|
||||||
// An animation is playing, then animate if reverse != fadingOut.
|
// An animation is playing, then animate if reverse != fadingOut.
|
||||||
// An animation is not playing, then animate if opacity != our target opacity.
|
// An animation is not playing, then animate if opacity != our target opacity.
|
||||||
if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) ||
|
if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) ||
|
||||||
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) {
|
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0.0f : 1.0f))) {
|
||||||
auto func = [comp](float t) {
|
auto func = [comp](float t) { comp->setOpacity(glm::mix(0.0f, 1.0f, t)); };
|
||||||
comp->setOpacity(static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
|
||||||
};
|
|
||||||
comp->setAnimation(new LambdaAnimation(func, 150), 0, nullptr, fadingOut);
|
comp->setAnimation(new LambdaAnimation(func, 150), 0, nullptr, fadingOut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,7 @@ void GamelistView::update(int deltaTime)
|
||||||
video->onHide();
|
video->onHide();
|
||||||
else if (!video->hasStaticImage())
|
else if (!video->hasStaticImage())
|
||||||
video->onHide();
|
video->onHide();
|
||||||
else if (video->getOpacity() == 0)
|
else if (video->getOpacity() == 0.0f)
|
||||||
video->onHide();
|
video->onHide();
|
||||||
}
|
}
|
||||||
else if (mVideoPlaying && !video->isVideoPaused() && !mWindow->isScreensaverActive()) {
|
else if (mVideoPlaying && !video->isVideoPaused() && !mWindow->isScreensaverActive()) {
|
||||||
|
@ -562,8 +562,7 @@ void GamelistView::updateInfoPanel()
|
||||||
for (auto& image : mImageComponents) {
|
for (auto& image : mImageComponents) {
|
||||||
if (image->getScrollFadeIn()) {
|
if (image->getScrollFadeIn()) {
|
||||||
auto func = [&image](float t) {
|
auto func = [&image](float t) {
|
||||||
image->setOpacity(static_cast<unsigned char>(
|
image->setOpacity(glm::mix(FADE_IN_START_OPACITY, 1.0f, t));
|
||||||
glm::mix(static_cast<float>(FADE_IN_START_OPACITY), 1.0f, t) * 255));
|
|
||||||
};
|
};
|
||||||
image->setAnimation(new LambdaAnimation(func, FADE_IN_TIME), 0, nullptr, false);
|
image->setAnimation(new LambdaAnimation(func, FADE_IN_TIME), 0, nullptr, false);
|
||||||
}
|
}
|
||||||
|
@ -573,8 +572,7 @@ void GamelistView::updateInfoPanel()
|
||||||
for (auto& video : mVideoComponents) {
|
for (auto& video : mVideoComponents) {
|
||||||
if (video->getScrollFadeIn()) {
|
if (video->getScrollFadeIn()) {
|
||||||
auto func = [&video](float t) {
|
auto func = [&video](float t) {
|
||||||
video->setOpacity(static_cast<unsigned char>(
|
video->setOpacity(glm::mix(FADE_IN_START_OPACITY, 1.0f, t));
|
||||||
glm::mix(static_cast<float>(FADE_IN_START_OPACITY), 1.0f, t) * 255));
|
|
||||||
};
|
};
|
||||||
video->setAnimation(new LambdaAnimation(func, FADE_IN_TIME), 0, nullptr, false);
|
video->setAnimation(new LambdaAnimation(func, FADE_IN_TIME), 0, nullptr, false);
|
||||||
}
|
}
|
||||||
|
@ -762,10 +760,8 @@ void GamelistView::updateInfoPanel()
|
||||||
// An animation is playing, then animate if reverse != fadingOut.
|
// An animation is playing, then animate if reverse != fadingOut.
|
||||||
// An animation is not playing, then animate if opacity != our target opacity.
|
// An animation is not playing, then animate if opacity != our target opacity.
|
||||||
if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) ||
|
if ((comp->isAnimationPlaying(0) && comp->isAnimationReversed(0) != fadingOut) ||
|
||||||
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0 : 255))) {
|
(!comp->isAnimationPlaying(0) && comp->getOpacity() != (fadingOut ? 0.0f : 1.0f))) {
|
||||||
auto func = [comp](float t) {
|
auto func = [comp](float t) { comp->setOpacity(glm::mix(0.0f, 1.0f, t)); };
|
||||||
comp->setOpacity(static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
|
||||||
};
|
|
||||||
comp->setAnimation(new LambdaAnimation(func, 150), 0, nullptr, fadingOut);
|
comp->setAnimation(new LambdaAnimation(func, 150), 0, nullptr, fadingOut);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
GuiComponent::GuiComponent()
|
GuiComponent::GuiComponent()
|
||||||
: mWindow {Window::getInstance()}
|
: mWindow {Window::getInstance()}
|
||||||
, mParent {nullptr}
|
, mParent {nullptr}
|
||||||
, mOpacity {255}
|
|
||||||
, mColor {0}
|
, mColor {0}
|
||||||
, mSaturation {1.0f}
|
, mSaturation {1.0f}
|
||||||
, mColorShift {0}
|
, mColorShift {0}
|
||||||
|
@ -31,6 +30,7 @@ GuiComponent::GuiComponent()
|
||||||
, mOrigin {0.0f, 0.0f}
|
, mOrigin {0.0f, 0.0f}
|
||||||
, mRotationOrigin {0.5f, 0.5f}
|
, mRotationOrigin {0.5f, 0.5f}
|
||||||
, mSize {0.0f, 0.0f}
|
, mSize {0.0f, 0.0f}
|
||||||
|
, mOpacity {1.0f}
|
||||||
, mRotation {0.0f}
|
, mRotation {0.0f}
|
||||||
, mScale {1.0f}
|
, mScale {1.0f}
|
||||||
, mDefaultZIndex {0.0f}
|
, mDefaultZIndex {0.0f}
|
||||||
|
@ -180,7 +180,7 @@ const int GuiComponent::getChildIndex() const
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::setOpacity(unsigned char opacity)
|
void GuiComponent::setOpacity(float opacity)
|
||||||
{
|
{
|
||||||
if (mOpacity == opacity)
|
if (mOpacity == opacity)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#define ICONCOLOR_USERMARKED 0x7777FFFF
|
#define ICONCOLOR_USERMARKED 0x7777FFFF
|
||||||
#define TEXTCOLOR_SCRAPERMARKED 0x992222FF
|
#define TEXTCOLOR_SCRAPERMARKED 0x992222FF
|
||||||
#define TEXTCOLOR_USERMARKED 0x222299FF
|
#define TEXTCOLOR_USERMARKED 0x222299FF
|
||||||
#define DISABLED_OPACITY 80
|
#define DISABLED_OPACITY 0.314f
|
||||||
|
|
||||||
class Animation;
|
class Animation;
|
||||||
class AnimationController;
|
class AnimationController;
|
||||||
|
@ -191,8 +191,8 @@ public:
|
||||||
|
|
||||||
virtual bool isListScrolling() { return false; }
|
virtual bool isListScrolling() { return false; }
|
||||||
virtual void stopListScrolling() {}
|
virtual void stopListScrolling() {}
|
||||||
virtual unsigned char getOpacity() const { return mOpacity; }
|
virtual float getOpacity() const { return mOpacity; }
|
||||||
virtual void setOpacity(unsigned char opacity);
|
virtual void setOpacity(float opacity);
|
||||||
virtual unsigned int getColor() const { return mColor; }
|
virtual unsigned int getColor() const { return mColor; }
|
||||||
virtual unsigned int getColorShift() const { return mColorShift; }
|
virtual unsigned int getColorShift() const { return mColorShift; }
|
||||||
virtual float getLineSpacing() { return 0.0f; }
|
virtual float getLineSpacing() { return 0.0f; }
|
||||||
|
@ -277,7 +277,6 @@ protected:
|
||||||
|
|
||||||
std::string mMetadataField;
|
std::string mMetadataField;
|
||||||
|
|
||||||
unsigned char mOpacity;
|
|
||||||
unsigned int mColor;
|
unsigned int mColor;
|
||||||
float mSaturation;
|
float mSaturation;
|
||||||
unsigned int mColorShift;
|
unsigned int mColorShift;
|
||||||
|
@ -291,6 +290,7 @@ protected:
|
||||||
glm::vec2 mRotationOrigin;
|
glm::vec2 mRotationOrigin;
|
||||||
glm::vec2 mSize;
|
glm::vec2 mSize;
|
||||||
|
|
||||||
|
float mOpacity;
|
||||||
float mRotation;
|
float mRotation;
|
||||||
float mScale;
|
float mScale;
|
||||||
float mDefaultZIndex;
|
float mDefaultZIndex;
|
||||||
|
|
|
@ -29,7 +29,7 @@ Window::Window() noexcept
|
||||||
, mMediaViewer {nullptr}
|
, mMediaViewer {nullptr}
|
||||||
, mLaunchScreen {nullptr}
|
, mLaunchScreen {nullptr}
|
||||||
, mInfoPopup {nullptr}
|
, mInfoPopup {nullptr}
|
||||||
, mListScrollOpacity {0}
|
, mListScrollOpacity {0.0f}
|
||||||
, mFrameTimeElapsed {0}
|
, mFrameTimeElapsed {0}
|
||||||
, mFrameCountElapsed {0}
|
, mFrameCountElapsed {0}
|
||||||
, mAverageDeltaTime {10}
|
, mAverageDeltaTime {10}
|
||||||
|
@ -121,7 +121,7 @@ bool Window::init()
|
||||||
|
|
||||||
mHelp = new HelpComponent;
|
mHelp = new HelpComponent;
|
||||||
mBackgroundOverlay = new ImageComponent;
|
mBackgroundOverlay = new ImageComponent;
|
||||||
mBackgroundOverlayOpacity = 0;
|
mBackgroundOverlayOpacity = 0.0f;
|
||||||
|
|
||||||
// Keep a reference to the default fonts, so they don't keep getting destroyed/recreated.
|
// Keep a reference to the default fonts, so they don't keep getting destroyed/recreated.
|
||||||
if (mDefaultFonts.empty()) {
|
if (mDefaultFonts.empty()) {
|
||||||
|
@ -443,7 +443,7 @@ void Window::render()
|
||||||
// a new cached background has been generated.
|
// a new cached background has been generated.
|
||||||
if (mGuiStack.size() > 1 && mCachedBackground) {
|
if (mGuiStack.size() > 1 && mCachedBackground) {
|
||||||
if ((Settings::getInstance()->getString("MenuOpeningEffect") == "scale-up" &&
|
if ((Settings::getInstance()->getString("MenuOpeningEffect") == "scale-up" &&
|
||||||
mBackgroundOverlayOpacity == 255) ||
|
mBackgroundOverlayOpacity == 1.0f) ||
|
||||||
Settings::getInstance()->getString("MenuOpeningEffect") != "scale-up")
|
Settings::getInstance()->getString("MenuOpeningEffect") != "scale-up")
|
||||||
renderBottom = false;
|
renderBottom = false;
|
||||||
}
|
}
|
||||||
|
@ -509,11 +509,11 @@ void Window::render()
|
||||||
// The following is done to avoid fading in if the cached image was
|
// The following is done to avoid fading in if the cached image was
|
||||||
// invalidated (rather than the menu being opened).
|
// invalidated (rather than the menu being opened).
|
||||||
if (mInvalidatedCachedBackground) {
|
if (mInvalidatedCachedBackground) {
|
||||||
mBackgroundOverlayOpacity = 255;
|
mBackgroundOverlayOpacity = 1.0f;
|
||||||
mInvalidatedCachedBackground = false;
|
mInvalidatedCachedBackground = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mBackgroundOverlayOpacity = 25;
|
mBackgroundOverlayOpacity = 0.1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] processedTexture;
|
delete[] processedTexture;
|
||||||
|
@ -530,8 +530,9 @@ void Window::render()
|
||||||
// Fade in the cached background if the menu opening effect has been set to scale-up.
|
// Fade in the cached background if the menu opening effect has been set to scale-up.
|
||||||
if (Settings::getInstance()->getString("MenuOpeningEffect") == "scale-up") {
|
if (Settings::getInstance()->getString("MenuOpeningEffect") == "scale-up") {
|
||||||
mBackgroundOverlay->setOpacity(mBackgroundOverlayOpacity);
|
mBackgroundOverlay->setOpacity(mBackgroundOverlayOpacity);
|
||||||
if (mBackgroundOverlayOpacity < 255)
|
if (mBackgroundOverlayOpacity < 1.0f)
|
||||||
mBackgroundOverlayOpacity = glm::clamp(mBackgroundOverlayOpacity + 30, 0, 255);
|
mBackgroundOverlayOpacity =
|
||||||
|
glm::clamp(mBackgroundOverlayOpacity + 0.118f, 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
#endif // USE_OPENGL_21
|
#endif // USE_OPENGL_21
|
||||||
|
|
||||||
|
@ -558,18 +559,20 @@ void Window::render()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render the quick list scrolling overlay, which is triggered in IList.
|
// Render the quick list scrolling overlay, which is triggered in IList.
|
||||||
if (mListScrollOpacity != 0) {
|
if (mListScrollOpacity != 0.0f) {
|
||||||
Renderer::setMatrix(Renderer::getIdentity());
|
Renderer::setMatrix(Renderer::getIdentity());
|
||||||
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
|
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight()),
|
static_cast<float>(Renderer::getScreenHeight()),
|
||||||
0x00000000 | mListScrollOpacity, 0x00000000 | mListScrollOpacity);
|
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 {mListScrollFont->sizeText(mListScrollText)};
|
||||||
offset.x = (Renderer::getScreenWidth() - offset.x) * 0.5f;
|
offset.x = (Renderer::getScreenWidth() - offset.x) * 0.5f;
|
||||||
offset.y = (Renderer::getScreenHeight() - offset.y) * 0.5f;
|
offset.y = (Renderer::getScreenHeight() - offset.y) * 0.5f;
|
||||||
|
|
||||||
TextCache* cache = mListScrollFont->buildTextCache(mListScrollText, offset.x, offset.y,
|
TextCache* cache {mListScrollFont->buildTextCache(
|
||||||
0xFFFFFF00 | mListScrollOpacity);
|
mListScrollText, offset.x, offset.y,
|
||||||
|
0xFFFFFF00 | static_cast<unsigned char>(mListScrollOpacity * 255.0f))};
|
||||||
mListScrollFont->renderTextCache(cache);
|
mListScrollFont->renderTextCache(cache);
|
||||||
delete cache;
|
delete cache;
|
||||||
}
|
}
|
||||||
|
@ -648,9 +651,9 @@ void Window::renderLoadingScreen(std::string text)
|
||||||
Renderer::swapBuffers();
|
Renderer::swapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::renderListScrollOverlay(unsigned char opacity, const std::string& text)
|
void Window::renderListScrollOverlay(const float opacity, const std::string& text)
|
||||||
{
|
{
|
||||||
mListScrollOpacity = static_cast<unsigned char>(opacity * 0.6f);
|
mListScrollOpacity = opacity * 0.6f;
|
||||||
mListScrollText = text;
|
mListScrollText = text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ public:
|
||||||
|
|
||||||
void renderLoadingScreen(std::string text);
|
void renderLoadingScreen(std::string text);
|
||||||
// The list scroll overlay is triggered from IList when the highest scrolling tier is reached.
|
// The list scroll overlay is triggered from IList when the highest scrolling tier is reached.
|
||||||
void renderListScrollOverlay(unsigned char opacity, const std::string& text);
|
void renderListScrollOverlay(const float opacity, const std::string& text);
|
||||||
|
|
||||||
void renderHelpPromptsEarly(); // Used to render HelpPrompts before a fade.
|
void renderHelpPromptsEarly(); // Used to render HelpPrompts before a fade.
|
||||||
void setHelpPrompts(const std::vector<HelpPrompt>& prompts, const HelpStyle& style);
|
void setHelpPrompts(const std::vector<HelpPrompt>& prompts, const HelpStyle& style);
|
||||||
|
@ -162,7 +162,7 @@ private:
|
||||||
|
|
||||||
HelpComponent* mHelp;
|
HelpComponent* mHelp;
|
||||||
ImageComponent* mBackgroundOverlay;
|
ImageComponent* mBackgroundOverlay;
|
||||||
unsigned char 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<TextCache> mFrameDataText;
|
||||||
|
@ -180,7 +180,7 @@ private:
|
||||||
|
|
||||||
std::string mListScrollText;
|
std::string mListScrollText;
|
||||||
std::shared_ptr<Font> mListScrollFont;
|
std::shared_ptr<Font> mListScrollFont;
|
||||||
unsigned char mListScrollOpacity;
|
float mListScrollOpacity;
|
||||||
|
|
||||||
int mFrameTimeElapsed;
|
int mFrameTimeElapsed;
|
||||||
int mFrameCountElapsed;
|
int mFrameCountElapsed;
|
||||||
|
|
|
@ -104,7 +104,6 @@ void BadgeComponent::setBadges(const std::vector<BadgeInfo>& badges)
|
||||||
[badge](FlexboxComponent::FlexboxItem item) { return item.label == badge.badgeType; });
|
[badge](FlexboxComponent::FlexboxItem item) { return item.label == badge.badgeType; });
|
||||||
|
|
||||||
if (it != mFlexboxItems.end()) {
|
if (it != mFlexboxItems.end()) {
|
||||||
|
|
||||||
// Don't show the alternative emulator badge if the corresponding setting has been
|
// Don't show the alternative emulator badge if the corresponding setting has been
|
||||||
// disabled.
|
// disabled.
|
||||||
if (badge.badgeType == "altemulator" &&
|
if (badge.badgeType == "altemulator" &&
|
||||||
|
@ -172,13 +171,13 @@ void BadgeComponent::render(const glm::mat4& parentTrans)
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mOpacity == 255) {
|
if (mOpacity == 1.0f) {
|
||||||
mFlexboxComponent.render(parentTrans);
|
mFlexboxComponent.render(parentTrans);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mFlexboxComponent.setOpacity(mOpacity);
|
mFlexboxComponent.setOpacity(mOpacity);
|
||||||
mFlexboxComponent.render(parentTrans);
|
mFlexboxComponent.render(parentTrans);
|
||||||
mFlexboxComponent.setOpacity(255);
|
mFlexboxComponent.setOpacity(1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -291,7 +291,7 @@ void CarouselComponent::render(const glm::mat4& parentTrans)
|
||||||
scale = glm::clamp(scale, 1.0f / mLogoScale + 0.01f, 1.0f);
|
scale = glm::clamp(scale, 1.0f / mLogoScale + 0.01f, 1.0f);
|
||||||
|
|
||||||
comp->setScale(scale);
|
comp->setScale(scale);
|
||||||
comp->setOpacity(static_cast<unsigned char>(opacity));
|
comp->setOpacity(static_cast<float>(opacity) / 255.0f);
|
||||||
comp->render(logoTrans);
|
comp->render(logoTrans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,19 +376,17 @@ void ComponentList::render(const glm::mat4& parentTrans)
|
||||||
// Custom rendering.
|
// Custom rendering.
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
float opacity = mOpacity / 255.0f;
|
|
||||||
|
|
||||||
// Draw selector bar.
|
// Draw selector bar.
|
||||||
if (mFocused) {
|
if (mFocused) {
|
||||||
const float selectedRowHeight = getRowHeight(mEntries.at(mCursor).data);
|
const float selectedRowHeight = getRowHeight(mEntries.at(mCursor).data);
|
||||||
|
|
||||||
if (opacity == 1) {
|
if (mOpacity == 1.0f) {
|
||||||
Renderer::drawRect(0.0f, mSelectorBarOffset, std::ceil(mSize.x), selectedRowHeight,
|
Renderer::drawRect(0.0f, mSelectorBarOffset, std::ceil(mSize.x), selectedRowHeight,
|
||||||
0xFFFFFFFF, 0xFFFFFFFF, false, opacity, trans,
|
0xFFFFFFFF, 0xFFFFFFFF, false, mOpacity, trans,
|
||||||
Renderer::Blend::ONE_MINUS_DST_COLOR, Renderer::Blend::ZERO);
|
Renderer::Blend::ONE_MINUS_DST_COLOR, Renderer::Blend::ZERO);
|
||||||
|
|
||||||
Renderer::drawRect(0.0f, mSelectorBarOffset, std::ceil(mSize.x), selectedRowHeight,
|
Renderer::drawRect(0.0f, mSelectorBarOffset, std::ceil(mSize.x), selectedRowHeight,
|
||||||
0x777777FF, 0x777777FF, false, opacity, trans, Renderer::Blend::ONE,
|
0x777777FF, 0x777777FF, false, mOpacity, trans, Renderer::Blend::ONE,
|
||||||
Renderer::Blend::ONE);
|
Renderer::Blend::ONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,12 +402,12 @@ void ComponentList::render(const glm::mat4& parentTrans)
|
||||||
float y = 0;
|
float y = 0;
|
||||||
for (unsigned int i = 0; i < mEntries.size(); ++i) {
|
for (unsigned int i = 0; i < mEntries.size(); ++i) {
|
||||||
Renderer::drawRect(0.0f, y, std::ceil(mSize.x), 1.0f * Renderer::getScreenHeightModifier(),
|
Renderer::drawRect(0.0f, y, std::ceil(mSize.x), 1.0f * Renderer::getScreenHeightModifier(),
|
||||||
0xC6C7C6FF, 0xC6C7C6FF, false, opacity, trans);
|
0xC6C7C6FF, 0xC6C7C6FF, false, mOpacity, trans);
|
||||||
y += getRowHeight(mEntries.at(i).data);
|
y += getRowHeight(mEntries.at(i).data);
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer::drawRect(0.0f, y, std::ceil(mSize.x), 1.0f * Renderer::getScreenHeightModifier(),
|
Renderer::drawRect(0.0f, y, std::ceil(mSize.x), 1.0f * Renderer::getScreenHeightModifier(),
|
||||||
0xC6C7C6FF, 0xC6C7C6FF, false, opacity, trans);
|
0xC6C7C6FF, 0xC6C7C6FF, false, mOpacity, trans);
|
||||||
Renderer::popClipRect();
|
Renderer::popClipRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -193,7 +193,7 @@ void DateTimeEditComponent::render(const glm::mat4& parentTrans)
|
||||||
0x00000033, 0x00000033);
|
0x00000033, 0x00000033);
|
||||||
}
|
}
|
||||||
|
|
||||||
mTextCache->setColor((mColor & 0xFFFFFF00) | getOpacity());
|
mTextCache->setColor((mColor & 0xFFFFFF00) | static_cast<int>(getOpacity() * 255.0f));
|
||||||
font->renderTextCache(mTextCache.get());
|
font->renderTextCache(mTextCache.get());
|
||||||
|
|
||||||
if (mEditing && mTime != 0) {
|
if (mEditing && mTime != 0) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ void FlexboxComponent::render(const glm::mat4& parentTrans)
|
||||||
for (auto& item : mItems) {
|
for (auto& item : mItems) {
|
||||||
if (!item.visible)
|
if (!item.visible)
|
||||||
continue;
|
continue;
|
||||||
if (mOpacity == 255) {
|
if (mOpacity == 1.0f) {
|
||||||
item.baseImage.render(trans);
|
item.baseImage.render(trans);
|
||||||
if (item.overlayImage.getTexture() != nullptr)
|
if (item.overlayImage.getTexture() != nullptr)
|
||||||
item.overlayImage.render(trans);
|
item.overlayImage.render(trans);
|
||||||
|
@ -58,11 +58,11 @@ void FlexboxComponent::render(const glm::mat4& parentTrans)
|
||||||
else {
|
else {
|
||||||
item.baseImage.setOpacity(mOpacity);
|
item.baseImage.setOpacity(mOpacity);
|
||||||
item.baseImage.render(trans);
|
item.baseImage.render(trans);
|
||||||
item.baseImage.setOpacity(255);
|
item.baseImage.setOpacity(1.0f);
|
||||||
if (item.overlayImage.getTexture() != nullptr) {
|
if (item.overlayImage.getTexture() != nullptr) {
|
||||||
item.overlayImage.setOpacity(mOpacity);
|
item.overlayImage.setOpacity(mOpacity);
|
||||||
item.overlayImage.render(trans);
|
item.overlayImage.render(trans);
|
||||||
item.overlayImage.setOpacity(255);
|
item.overlayImage.setOpacity(1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -280,7 +280,7 @@ std::shared_ptr<TextureResource> HelpComponent::getIconTexture(const char* name)
|
||||||
return tex;
|
return tex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpComponent::setOpacity(unsigned char opacity)
|
void HelpComponent::setOpacity(float opacity)
|
||||||
{
|
{
|
||||||
GuiComponent::setOpacity(opacity);
|
GuiComponent::setOpacity(opacity);
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
void setPrompts(const std::vector<HelpPrompt>& prompts);
|
void setPrompts(const std::vector<HelpPrompt>& prompts);
|
||||||
|
|
||||||
void render(const glm::mat4& parent) override;
|
void render(const glm::mat4& parent) override;
|
||||||
void setOpacity(unsigned char opacity) override;
|
void setOpacity(float opacity) override;
|
||||||
|
|
||||||
void setStyle(const HelpStyle& style);
|
void setStyle(const HelpStyle& style);
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ protected:
|
||||||
int mScrollTierAccumulator;
|
int mScrollTierAccumulator;
|
||||||
int mScrollCursorAccumulator;
|
int mScrollCursorAccumulator;
|
||||||
|
|
||||||
unsigned char mTitleOverlayOpacity;
|
float mTitleOverlayOpacity;
|
||||||
unsigned int mTitleOverlayColor;
|
unsigned int mTitleOverlayColor;
|
||||||
|
|
||||||
const ScrollTierList& mTierList;
|
const ScrollTierList& mTierList;
|
||||||
|
@ -95,7 +95,7 @@ public:
|
||||||
mScrollTierAccumulator = 0;
|
mScrollTierAccumulator = 0;
|
||||||
mScrollCursorAccumulator = 0;
|
mScrollCursorAccumulator = 0;
|
||||||
|
|
||||||
mTitleOverlayOpacity = 0x00;
|
mTitleOverlayOpacity = 0.0f;
|
||||||
mTitleOverlayColor = 0xFFFFFF00;
|
mTitleOverlayColor = 0xFFFFFF00;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ public:
|
||||||
|
|
||||||
void stopScrolling()
|
void stopScrolling()
|
||||||
{
|
{
|
||||||
mTitleOverlayOpacity = 0;
|
mTitleOverlayOpacity = 0.0f;
|
||||||
|
|
||||||
listInput(0);
|
listInput(0);
|
||||||
if (mScrollVelocity == 0)
|
if (mScrollVelocity == 0)
|
||||||
|
@ -243,15 +243,10 @@ protected:
|
||||||
{
|
{
|
||||||
// Update the title overlay opacity.
|
// Update the title overlay opacity.
|
||||||
// Fade in if scroll tier is >= 1, otherwise fade out.
|
// Fade in if scroll tier is >= 1, otherwise fade out.
|
||||||
const int dir = (mScrollTier >= mTierList.count - 1) ? 1 : -1;
|
const float dir {(mScrollTier >= mTierList.count - 1) ? 1.0f : -1.0f};
|
||||||
// We simply translate the time directly to opacity, i.e. no scaling is performed.
|
// We simply translate the time directly to opacity, i.e. no scaling is performed.
|
||||||
int op = mTitleOverlayOpacity + deltaTime * dir;
|
mTitleOverlayOpacity = glm::clamp(
|
||||||
if (op >= 255)
|
mTitleOverlayOpacity + (static_cast<float>(deltaTime) / 255.0f) * dir, 0.0f, 1.0f);
|
||||||
mTitleOverlayOpacity = 255;
|
|
||||||
else if (op <= 0)
|
|
||||||
mTitleOverlayOpacity = 0;
|
|
||||||
else
|
|
||||||
mTitleOverlayOpacity = static_cast<unsigned char>(op);
|
|
||||||
|
|
||||||
if (mScrollVelocity == 0 || size() < 2)
|
if (mScrollVelocity == 0 || size() < 2)
|
||||||
return;
|
return;
|
||||||
|
@ -285,8 +280,8 @@ protected:
|
||||||
if (!Settings::getInstance()->getBool("ListScrollOverlay"))
|
if (!Settings::getInstance()->getBool("ListScrollOverlay"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (size() == 0 || mTitleOverlayOpacity == 0) {
|
if (size() == 0 || mTitleOverlayOpacity == 0.0f) {
|
||||||
mWindow->renderListScrollOverlay(0, "");
|
mWindow->renderListScrollOverlay(0.0f, "");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ ImageComponent::ImageComponent(bool forceLoad, bool dynamic)
|
||||||
, mColorShift {0xFFFFFFFF}
|
, mColorShift {0xFFFFFFFF}
|
||||||
, mColorShiftEnd {0xFFFFFFFF}
|
, mColorShiftEnd {0xFFFFFFFF}
|
||||||
, mColorGradientHorizontal {true}
|
, mColorGradientHorizontal {true}
|
||||||
, mFadeOpacity {0}
|
, mFadeOpacity {0.0f}
|
||||||
, mFading {false}
|
, mFading {false}
|
||||||
, mForceLoad {forceLoad}
|
, mForceLoad {forceLoad}
|
||||||
, mDynamic {dynamic}
|
, mDynamic {dynamic}
|
||||||
|
@ -319,7 +319,7 @@ void ImageComponent::setColorGradientHorizontal(bool horizontal)
|
||||||
updateColors();
|
updateColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageComponent::setOpacity(unsigned char opacity)
|
void ImageComponent::setOpacity(float opacity)
|
||||||
{
|
{
|
||||||
mOpacity = opacity;
|
mOpacity = opacity;
|
||||||
updateColors();
|
updateColors();
|
||||||
|
@ -369,7 +369,7 @@ void ImageComponent::updateVertices()
|
||||||
|
|
||||||
void ImageComponent::updateColors()
|
void ImageComponent::updateColors()
|
||||||
{
|
{
|
||||||
const float opacity = (mOpacity * (mFading ? mFadeOpacity / 255.0f : 1.0f)) / 255.0f;
|
const float opacity = (mOpacity * (mFading ? mFadeOpacity : 1.0f));
|
||||||
const unsigned int color = Renderer::convertRGBAToABGR(
|
const unsigned int color = Renderer::convertRGBAToABGR(
|
||||||
(mColorShift & 0xFFFFFF00) | static_cast<unsigned char>((mColorShift & 0xFF) * opacity));
|
(mColorShift & 0xFFFFFF00) | static_cast<unsigned char>((mColorShift & 0xFF) * opacity));
|
||||||
const unsigned int colorEnd =
|
const unsigned int colorEnd =
|
||||||
|
@ -391,7 +391,7 @@ void ImageComponent::render(const glm::mat4& parentTrans)
|
||||||
glm::mat4 trans {parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
if (mTexture && mOpacity > 0) {
|
if (mTexture && mOpacity > 0.0f) {
|
||||||
if (Settings::getInstance()->getBool("DebugImage")) {
|
if (Settings::getInstance()->getBool("DebugImage")) {
|
||||||
glm::vec2 targetSizePos {(mTargetSize - mSize) * mOrigin * glm::vec2 {-1.0f}};
|
glm::vec2 targetSizePos {(mTargetSize - mSize) * mOrigin * glm::vec2 {-1.0f}};
|
||||||
Renderer::drawRect(targetSizePos.x, targetSizePos.y, mTargetSize.x, mTargetSize.y,
|
Renderer::drawRect(targetSizePos.x, targetSizePos.y, mTargetSize.x, mTargetSize.y,
|
||||||
|
@ -447,7 +447,7 @@ void ImageComponent::fadeIn(bool textureLoaded)
|
||||||
// Start the fade if this is the first time we've encountered the unloaded texture.
|
// Start the fade if this is the first time we've encountered the unloaded texture.
|
||||||
if (!mFading) {
|
if (!mFading) {
|
||||||
// Start with a zero opacity and flag it as fading.
|
// Start with a zero opacity and flag it as fading.
|
||||||
mFadeOpacity = 0;
|
mFadeOpacity = 0.0f;
|
||||||
mFading = true;
|
mFading = true;
|
||||||
updateColors();
|
updateColors();
|
||||||
}
|
}
|
||||||
|
@ -456,14 +456,14 @@ void ImageComponent::fadeIn(bool textureLoaded)
|
||||||
// The texture is loaded and we need to fade it in. The fade is based on the frame
|
// The texture is loaded and we need to fade it in. The fade is based on the frame
|
||||||
// rate and is 1/4 second if running at 60 frames per second although the actual
|
// rate and is 1/4 second if running at 60 frames per second although the actual
|
||||||
// value is not that important.
|
// value is not that important.
|
||||||
int opacity = mFadeOpacity + 255 / 15;
|
float opacity {mFadeOpacity + 1.0f / 15.0f};
|
||||||
// See if we've finished fading.
|
// See if we've finished fading.
|
||||||
if (opacity >= 255) {
|
if (opacity >= 1.0f) {
|
||||||
mFadeOpacity = 255;
|
mFadeOpacity = 1.0f;
|
||||||
mFading = false;
|
mFading = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mFadeOpacity = static_cast<unsigned char>(opacity);
|
mFadeOpacity = opacity;
|
||||||
}
|
}
|
||||||
updateColors();
|
updateColors();
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public:
|
||||||
|
|
||||||
unsigned int getColorShift() const override { return mColorShift; }
|
unsigned int getColorShift() const override { return mColorShift; }
|
||||||
|
|
||||||
void setOpacity(unsigned char opacity) override;
|
void setOpacity(float opacity) override;
|
||||||
void setSaturation(float saturation) override;
|
void setSaturation(float saturation) override;
|
||||||
|
|
||||||
void setFlipX(bool flip); // Mirror on the X axis.
|
void setFlipX(bool flip); // Mirror on the X axis.
|
||||||
|
@ -124,7 +124,7 @@ private:
|
||||||
std::string mDefaultPath;
|
std::string mDefaultPath;
|
||||||
|
|
||||||
std::shared_ptr<TextureResource> mTexture;
|
std::shared_ptr<TextureResource> mTexture;
|
||||||
unsigned char mFadeOpacity;
|
float mFadeOpacity;
|
||||||
bool mFading;
|
bool mFading;
|
||||||
bool mForceLoad;
|
bool mForceLoad;
|
||||||
bool mDynamic;
|
bool mDynamic;
|
||||||
|
|
|
@ -135,9 +135,9 @@ void NinePatchComponent::render(const glm::mat4& parentTrans)
|
||||||
|
|
||||||
if (mTexture && mVertices != nullptr) {
|
if (mTexture && mVertices != nullptr) {
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
if (mOpacity < 255) {
|
if (mOpacity < 1.0f) {
|
||||||
mVertices[0].shaders = Renderer::SHADER_OPACITY;
|
mVertices[0].shaders = Renderer::SHADER_OPACITY;
|
||||||
mVertices[0].opacity = mOpacity / 255.0f;
|
mVertices[0].opacity = mOpacity;
|
||||||
}
|
}
|
||||||
else if (mVertices[0].shaders & Renderer::SHADER_OPACITY) {
|
else if (mVertices[0].shaders & Renderer::SHADER_OPACITY) {
|
||||||
// We have reached full opacity, so disable the opacity shader and set
|
// We have reached full opacity, so disable the opacity shader and set
|
||||||
|
|
|
@ -500,8 +500,8 @@ private:
|
||||||
else {
|
else {
|
||||||
mEnabled = true;
|
mEnabled = true;
|
||||||
list->getChild(i)->setEnabled(true);
|
list->getChild(i)->setEnabled(true);
|
||||||
list->getChild(i)->setOpacity(255);
|
list->getChild(i)->setOpacity(1.0f);
|
||||||
list->getChild(i + 1)->setOpacity(255);
|
list->getChild(i + 1)->setOpacity(1.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -545,8 +545,8 @@ private:
|
||||||
mParent->mEntries.at(i).selected = false;
|
mParent->mEntries.at(i).selected = false;
|
||||||
checkBoxes.at(i)->setImage(UNCHECKED_PATH);
|
checkBoxes.at(i)->setImage(UNCHECKED_PATH);
|
||||||
if (mParent->mMultiExclusiveSelect) {
|
if (mParent->mMultiExclusiveSelect) {
|
||||||
checkBoxes.at(i)->setOpacity(255);
|
checkBoxes.at(i)->setOpacity(1.0f);
|
||||||
textEntries.at(i)->setOpacity(255);
|
textEntries.at(i)->setOpacity(1.0f);
|
||||||
textEntries.at(i)->setEnabled(true);
|
textEntries.at(i)->setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,10 +82,10 @@ std::string RatingComponent::getRatingValue() const
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RatingComponent::setOpacity(unsigned char opacity)
|
void RatingComponent::setOpacity(float opacity)
|
||||||
{
|
{
|
||||||
mOpacity = opacity;
|
mOpacity = opacity;
|
||||||
mColorShift = (mColorShift >> 8 << 8) | mOpacity;
|
mColorShift = (mColorShift >> 8 << 8) | static_cast<unsigned char>(mOpacity * 255.0f);
|
||||||
updateColors();
|
updateColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ void RatingComponent::setColorShift(unsigned int color)
|
||||||
|
|
||||||
// Grab the opacity from the color shift because we may need
|
// Grab the opacity from the color shift because we may need
|
||||||
// to apply it if fading in textures.
|
// to apply it if fading in textures.
|
||||||
mOpacity = color & 0xff;
|
mOpacity = static_cast<float>(color & 0xff) / 255.0f;
|
||||||
updateColors();
|
updateColors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ void RatingComponent::render(const glm::mat4& parentTrans)
|
||||||
|
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
if (mOpacity > 0) {
|
if (mOpacity > 0.0f) {
|
||||||
if (Settings::getInstance()->getBool("DebugImage")) {
|
if (Settings::getInstance()->getBool("DebugImage")) {
|
||||||
Renderer::drawRect(0.0f, 0.0f, mSize.y * NUM_RATING_STARS, mSize.y, 0xFF000033,
|
Renderer::drawRect(0.0f, 0.0f, mSize.y * NUM_RATING_STARS, mSize.y, 0xFF000033,
|
||||||
0xFF000033);
|
0xFF000033);
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
|
|
||||||
void onSizeChanged() override;
|
void onSizeChanged() override;
|
||||||
|
|
||||||
void setOpacity(unsigned char opacity) override;
|
void setOpacity(float opacity) override;
|
||||||
|
|
||||||
// Multiply all pixels in the image by this color when rendering.
|
// Multiply all pixels in the image by this color when rendering.
|
||||||
void setColorShift(unsigned int color) override;
|
void setColorShift(unsigned int color) override;
|
||||||
|
|
|
@ -27,8 +27,8 @@ public:
|
||||||
scrollUp->setImage(":/graphics/scroll_up.svg");
|
scrollUp->setImage(":/graphics/scroll_up.svg");
|
||||||
scrollDown->setImage(":/graphics/scroll_down.svg");
|
scrollDown->setImage(":/graphics/scroll_down.svg");
|
||||||
|
|
||||||
scrollUp->setOpacity(0);
|
scrollUp->setOpacity(0.0f);
|
||||||
scrollDown->setOpacity(0);
|
scrollDown->setOpacity(0.0f);
|
||||||
|
|
||||||
if (!Settings::getInstance()->getBool("ScrollIndicators")) {
|
if (!Settings::getInstance()->getBool("ScrollIndicators")) {
|
||||||
// If the scroll indicators setting is disabled, then show a permanent down arrow
|
// If the scroll indicators setting is disabled, then show a permanent down arrow
|
||||||
|
@ -38,7 +38,7 @@ public:
|
||||||
if (state == ComponentList::SCROLL_UP ||
|
if (state == ComponentList::SCROLL_UP ||
|
||||||
state == ComponentList::SCROLL_UP_DOWN ||
|
state == ComponentList::SCROLL_UP_DOWN ||
|
||||||
state == ComponentList::SCROLL_DOWN) {
|
state == ComponentList::SCROLL_DOWN) {
|
||||||
scrollDown->setOpacity(255);
|
scrollDown->setOpacity(1.0f);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public:
|
||||||
|
|
||||||
if (state == ComponentList::SCROLL_UP &&
|
if (state == ComponentList::SCROLL_UP &&
|
||||||
mPreviousScrollState == ComponentList::SCROLL_NONE) {
|
mPreviousScrollState == ComponentList::SCROLL_NONE) {
|
||||||
scrollUp->setOpacity(255);
|
scrollUp->setOpacity(1.0f);
|
||||||
}
|
}
|
||||||
else if (state == ComponentList::SCROLL_UP &&
|
else if (state == ComponentList::SCROLL_UP &&
|
||||||
mPreviousScrollState == ComponentList::SCROLL_UP_DOWN) {
|
mPreviousScrollState == ComponentList::SCROLL_UP_DOWN) {
|
||||||
|
@ -70,12 +70,12 @@ public:
|
||||||
mPreviousScrollState == ComponentList::SCROLL_DOWN) {
|
mPreviousScrollState == ComponentList::SCROLL_DOWN) {
|
||||||
upFadeIn = true;
|
upFadeIn = true;
|
||||||
fadeTime *= 2.0f;
|
fadeTime *= 2.0f;
|
||||||
scrollDown->setOpacity(0);
|
scrollDown->setOpacity(0.0f);
|
||||||
}
|
}
|
||||||
else if (state == ComponentList::SCROLL_UP_DOWN &&
|
else if (state == ComponentList::SCROLL_UP_DOWN &&
|
||||||
mPreviousScrollState == ComponentList::SCROLL_NONE) {
|
mPreviousScrollState == ComponentList::SCROLL_NONE) {
|
||||||
scrollUp->setOpacity(255);
|
scrollUp->setOpacity(1.0f);
|
||||||
scrollDown->setOpacity(255);
|
scrollDown->setOpacity(1.0f);
|
||||||
}
|
}
|
||||||
else if (state == ComponentList::SCROLL_UP_DOWN &&
|
else if (state == ComponentList::SCROLL_UP_DOWN &&
|
||||||
mPreviousScrollState == ComponentList::SCROLL_DOWN) {
|
mPreviousScrollState == ComponentList::SCROLL_DOWN) {
|
||||||
|
@ -87,7 +87,7 @@ public:
|
||||||
}
|
}
|
||||||
else if (state == ComponentList::SCROLL_DOWN &&
|
else if (state == ComponentList::SCROLL_DOWN &&
|
||||||
mPreviousScrollState == ComponentList::SCROLL_NONE) {
|
mPreviousScrollState == ComponentList::SCROLL_NONE) {
|
||||||
scrollDown->setOpacity(255);
|
scrollDown->setOpacity(1.0f);
|
||||||
}
|
}
|
||||||
else if (state == ComponentList::SCROLL_DOWN &&
|
else if (state == ComponentList::SCROLL_DOWN &&
|
||||||
mPreviousScrollState == ComponentList::SCROLL_UP_DOWN) {
|
mPreviousScrollState == ComponentList::SCROLL_UP_DOWN) {
|
||||||
|
@ -97,7 +97,7 @@ public:
|
||||||
mPreviousScrollState == ComponentList::SCROLL_UP) {
|
mPreviousScrollState == ComponentList::SCROLL_UP) {
|
||||||
downFadeIn = true;
|
downFadeIn = true;
|
||||||
fadeTime *= 2.0f;
|
fadeTime *= 2.0f;
|
||||||
scrollUp->setOpacity(0);
|
scrollUp->setOpacity(0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If jumping more than one row using the shoulder or trigger buttons, then
|
// If jumping more than one row using the shoulder or trigger buttons, then
|
||||||
|
@ -107,8 +107,7 @@ public:
|
||||||
|
|
||||||
if (upFadeIn) {
|
if (upFadeIn) {
|
||||||
auto upFadeInFunc = [scrollUp](float t) {
|
auto upFadeInFunc = [scrollUp](float t) {
|
||||||
scrollUp->setOpacity(
|
scrollUp->setOpacity(glm::mix(0.0f, 1.0f, t));
|
||||||
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
|
||||||
};
|
};
|
||||||
scrollUp->setAnimation(
|
scrollUp->setAnimation(
|
||||||
new LambdaAnimation(upFadeInFunc, static_cast<int>(fadeTime)), 0,
|
new LambdaAnimation(upFadeInFunc, static_cast<int>(fadeTime)), 0,
|
||||||
|
@ -117,8 +116,7 @@ public:
|
||||||
|
|
||||||
if (upFadeOut) {
|
if (upFadeOut) {
|
||||||
auto upFadeOutFunc = [scrollUp](float t) {
|
auto upFadeOutFunc = [scrollUp](float t) {
|
||||||
scrollUp->setOpacity(
|
scrollUp->setOpacity(glm::mix(0.0f, 1.0f, t));
|
||||||
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
|
||||||
};
|
};
|
||||||
scrollUp->setAnimation(
|
scrollUp->setAnimation(
|
||||||
new LambdaAnimation(upFadeOutFunc, static_cast<int>(fadeTime)), 0,
|
new LambdaAnimation(upFadeOutFunc, static_cast<int>(fadeTime)), 0,
|
||||||
|
@ -127,8 +125,7 @@ public:
|
||||||
|
|
||||||
if (downFadeIn) {
|
if (downFadeIn) {
|
||||||
auto downFadeInFunc = [scrollDown](float t) {
|
auto downFadeInFunc = [scrollDown](float t) {
|
||||||
scrollDown->setOpacity(
|
scrollDown->setOpacity(glm::mix(0.0f, 1.0f, t));
|
||||||
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
|
||||||
};
|
};
|
||||||
scrollDown->setAnimation(
|
scrollDown->setAnimation(
|
||||||
new LambdaAnimation(downFadeInFunc, static_cast<int>(fadeTime)), 0,
|
new LambdaAnimation(downFadeInFunc, static_cast<int>(fadeTime)), 0,
|
||||||
|
@ -137,8 +134,7 @@ public:
|
||||||
|
|
||||||
if (downFadeOut) {
|
if (downFadeOut) {
|
||||||
auto downFadeOutFunc = [scrollDown](float t) {
|
auto downFadeOutFunc = [scrollDown](float t) {
|
||||||
scrollDown->setOpacity(
|
scrollDown->setOpacity(glm::mix(0.0f, 1.0f, t));
|
||||||
static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
|
||||||
};
|
};
|
||||||
scrollDown->setAnimation(
|
scrollDown->setAnimation(
|
||||||
new LambdaAnimation(downFadeOutFunc, static_cast<int>(fadeTime)), 0,
|
new LambdaAnimation(downFadeOutFunc, static_cast<int>(fadeTime)), 0,
|
||||||
|
|
|
@ -197,9 +197,8 @@ void ScrollableContainer::update(int deltaTime)
|
||||||
255.0f};
|
255.0f};
|
||||||
auto func = [this, maxOpacity](float t) {
|
auto func = [this, maxOpacity](float t) {
|
||||||
unsigned int color {mChildren.front()->getColor()};
|
unsigned int color {mChildren.front()->getColor()};
|
||||||
unsigned int opacity {
|
float opacity {glm::mix(0.0f, maxOpacity, t)};
|
||||||
static_cast<unsigned int>(glm::mix(0.0f, maxOpacity, t) * 255)};
|
color = (color & 0xFFFFFF00) + static_cast<unsigned char>(opacity * 255.0f);
|
||||||
color = (color & 0xFFFFFF00) + opacity;
|
|
||||||
this->mChildren.front()->setColor(color);
|
this->mChildren.front()->setColor(color);
|
||||||
mScrollPos = glm::vec2 {};
|
mScrollPos = glm::vec2 {};
|
||||||
mAutoScrollResetAccumulator = 0;
|
mAutoScrollResetAccumulator = 0;
|
||||||
|
|
|
@ -32,8 +32,8 @@ public:
|
||||||
void setChangedColor(unsigned int color) override { mColorChangedValue = color; }
|
void setChangedColor(unsigned int color) override { mColorChangedValue = color; }
|
||||||
void setCallback(const std::function<void()>& callbackFunc) { mToggleCallback = callbackFunc; }
|
void setCallback(const std::function<void()>& callbackFunc) { mToggleCallback = callbackFunc; }
|
||||||
|
|
||||||
unsigned char getOpacity() const override { return mImage.getOpacity(); }
|
float getOpacity() const override { return mImage.getOpacity(); }
|
||||||
void setOpacity(unsigned char opacity) override { mImage.setOpacity(opacity); }
|
void setOpacity(float opacity) override { mImage.setOpacity(opacity); }
|
||||||
// Multiply all pixels in the image by this color when rendering.
|
// Multiply all pixels in the image by this color when rendering.
|
||||||
void setColorShift(unsigned int color) override { mImage.setColorShift(color); }
|
void setColorShift(unsigned int color) override { mImage.setColorShift(color); }
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,8 @@ TextComponent::TextComponent()
|
||||||
: mFont {Font::get(FONT_SIZE_MEDIUM)}
|
: mFont {Font::get(FONT_SIZE_MEDIUM)}
|
||||||
, mColor {0x000000FF}
|
, mColor {0x000000FF}
|
||||||
, mBgColor {0x00000000}
|
, mBgColor {0x00000000}
|
||||||
, mColorOpacity {0x000000FF}
|
, mColorOpacity {1.0f}
|
||||||
, mBgColorOpacity {0x00000000}
|
, mBgColorOpacity {0.0f}
|
||||||
, mRenderBackground {false}
|
, mRenderBackground {false}
|
||||||
, mUppercase {false}
|
, mUppercase {false}
|
||||||
, mLowercase {false}
|
, mLowercase {false}
|
||||||
|
@ -41,8 +41,8 @@ TextComponent::TextComponent(const std::string& text,
|
||||||
: mFont {nullptr}
|
: mFont {nullptr}
|
||||||
, mColor {0x000000FF}
|
, mColor {0x000000FF}
|
||||||
, mBgColor {0x00000000}
|
, mBgColor {0x00000000}
|
||||||
, mColorOpacity {0x000000FF}
|
, mColorOpacity {1.0f}
|
||||||
, mBgColorOpacity {0x00000000}
|
, mBgColorOpacity {0.0f}
|
||||||
, mRenderBackground {false}
|
, mRenderBackground {false}
|
||||||
, mUppercase {false}
|
, mUppercase {false}
|
||||||
, mLowercase {false}
|
, mLowercase {false}
|
||||||
|
@ -81,7 +81,7 @@ void TextComponent::setFont(const std::shared_ptr<Font>& font)
|
||||||
void TextComponent::setColor(unsigned int color)
|
void TextComponent::setColor(unsigned int color)
|
||||||
{
|
{
|
||||||
mColor = color;
|
mColor = color;
|
||||||
mColorOpacity = mColor & 0x000000FF;
|
mColorOpacity = static_cast<float>(mColor & 0x000000FF) / 255.0f;
|
||||||
onColorChanged();
|
onColorChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,22 +89,18 @@ void TextComponent::setColor(unsigned int color)
|
||||||
void TextComponent::setBackgroundColor(unsigned int color)
|
void TextComponent::setBackgroundColor(unsigned int color)
|
||||||
{
|
{
|
||||||
mBgColor = color;
|
mBgColor = color;
|
||||||
mBgColorOpacity = mBgColor & 0x000000FF;
|
mBgColorOpacity = static_cast<float>(mBgColor & 0x000000FF) / 255.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scale the opacity.
|
// Scale the opacity.
|
||||||
void TextComponent::setOpacity(unsigned char opacity)
|
void TextComponent::setOpacity(float opacity)
|
||||||
{
|
{
|
||||||
// This function is mostly called to do fade in and fade out of the text component element.
|
// This function is mostly called to do fade in and fade out of the text component element.
|
||||||
// Therefore we assume here that opacity is a fractional value (expressed as an unsigned
|
float o {opacity * mColorOpacity};
|
||||||
// char 0 - 255) of the opacity originally set with setColor() or setBackgroundColor().
|
mColor = (mColor & 0xFFFFFF00) | static_cast<unsigned char>(o * 255.0f);
|
||||||
unsigned char o = static_cast<unsigned char>(static_cast<float>(opacity) / 255.0f *
|
|
||||||
static_cast<float>(mColorOpacity));
|
|
||||||
mColor = (mColor & 0xFFFFFF00) | static_cast<unsigned char>(o);
|
|
||||||
|
|
||||||
unsigned char bgo = static_cast<unsigned char>(static_cast<float>(opacity) / 255.0f *
|
float bgo {opacity * mBgColorOpacity};
|
||||||
static_cast<float>(mBgColorOpacity));
|
mBgColor = (mBgColor & 0xFFFFFF00) | static_cast<unsigned char>(bgo * 255.0f);
|
||||||
mBgColor = (mBgColor & 0xFFFFFF00) | static_cast<unsigned char>(bgo);
|
|
||||||
|
|
||||||
onColorChanged();
|
onColorChanged();
|
||||||
GuiComponent::setOpacity(opacity);
|
GuiComponent::setOpacity(opacity);
|
||||||
|
@ -307,14 +303,15 @@ void TextComponent::onTextChanged()
|
||||||
|
|
||||||
text.append(abbrev);
|
text.append(abbrev);
|
||||||
|
|
||||||
mTextCache = std::shared_ptr<TextCache>(
|
mTextCache = std::shared_ptr<TextCache>(f->buildTextCache(
|
||||||
f->buildTextCache(text, glm::vec2 {}, (mColor >> 8 << 8) | mOpacity, mSize.x,
|
text, glm::vec2 {}, (mColor >> 8 << 8) | static_cast<unsigned char>(mOpacity * 255.0f),
|
||||||
mHorizontalAlignment, mLineSpacing, mNoTopMargin));
|
mSize.x, mHorizontalAlignment, mLineSpacing, mNoTopMargin));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mTextCache = std::shared_ptr<TextCache>(f->buildTextCache(
|
mTextCache = std::shared_ptr<TextCache>(
|
||||||
f->wrapText(text, mSize.x), glm::vec2 {}, (mColor >> 8 << 8) | mOpacity, mSize.x,
|
f->buildTextCache(f->wrapText(text, mSize.x), glm::vec2 {},
|
||||||
mHorizontalAlignment, mLineSpacing, mNoTopMargin));
|
(mColor >> 8 << 8) | static_cast<unsigned char>(mOpacity * 255.0f),
|
||||||
|
mSize.x, mHorizontalAlignment, mLineSpacing, mNoTopMargin));
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is required to set the color transparency.
|
// This is required to set the color transparency.
|
||||||
|
|
|
@ -57,8 +57,8 @@ public:
|
||||||
std::string getHiddenValue() const override { return mHiddenText; }
|
std::string getHiddenValue() const override { return mHiddenText; }
|
||||||
void setHiddenValue(const std::string& value) override { setHiddenText(value); }
|
void setHiddenValue(const std::string& value) override { setHiddenText(value); }
|
||||||
|
|
||||||
unsigned char getOpacity() const override { return mColor & 0x000000FF; }
|
float getOpacity() const override { return static_cast<float>((mColor & 0x000000FF) / 255.0f); }
|
||||||
void setOpacity(unsigned char opacity) override;
|
void setOpacity(float opacity) override;
|
||||||
|
|
||||||
void setSelectable(bool status) { mSelectable = status; }
|
void setSelectable(bool status) { mSelectable = status; }
|
||||||
|
|
||||||
|
@ -87,8 +87,8 @@ private:
|
||||||
|
|
||||||
unsigned int mColor;
|
unsigned int mColor;
|
||||||
unsigned int mBgColor;
|
unsigned int mBgColor;
|
||||||
unsigned char mColorOpacity;
|
float mColorOpacity;
|
||||||
unsigned char mBgColorOpacity;
|
float mBgColorOpacity;
|
||||||
bool mRenderBackground;
|
bool mRenderBackground;
|
||||||
|
|
||||||
bool mUppercase;
|
bool mUppercase;
|
||||||
|
|
|
@ -258,8 +258,8 @@ void TextEditComponent::setCursor(size_t pos)
|
||||||
void TextEditComponent::onTextChanged()
|
void TextEditComponent::onTextChanged()
|
||||||
{
|
{
|
||||||
std::string wrappedText = (isMultiline() ? mFont->wrapText(mText, getTextAreaSize().x) : mText);
|
std::string wrappedText = (isMultiline() ? mFont->wrapText(mText, getTextAreaSize().x) : mText);
|
||||||
mTextCache = std::unique_ptr<TextCache>(
|
mTextCache = std::unique_ptr<TextCache>(mFont->buildTextCache(
|
||||||
mFont->buildTextCache(wrappedText, 0.0f, 0.0f, 0x77777700 | getOpacity()));
|
wrappedText, 0.0f, 0.0f, 0x77777700 | static_cast<unsigned char>(mOpacity * 255.0f)));
|
||||||
|
|
||||||
if (mCursor > static_cast<int>(mText.length()))
|
if (mCursor > static_cast<int>(mText.length()))
|
||||||
mCursor = static_cast<int>(mText.length());
|
mCursor = static_cast<int>(mText.length());
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
// Sets whether we're in screensaver mode.
|
// Sets whether we're in screensaver mode.
|
||||||
void setScreensaverMode(bool isScreensaver) { mScreensaverMode = isScreensaver; }
|
void setScreensaverMode(bool isScreensaver) { mScreensaverMode = isScreensaver; }
|
||||||
// Set the opacity for the embedded static image.
|
// Set the opacity for the embedded static image.
|
||||||
void setOpacity(unsigned char opacity) override { mOpacity = opacity; }
|
void setOpacity(float opacity) override { mOpacity = opacity; }
|
||||||
|
|
||||||
bool hasStaticVideo() { return !mConfig.staticVideoPath.empty(); }
|
bool hasStaticVideo() { return !mConfig.staticVideoPath.empty(); }
|
||||||
bool hasStaticImage() { return mStaticImage.getTextureSize() != glm::ivec2 {0, 0}; }
|
bool hasStaticImage() { return mStaticImage.getTextureSize() != glm::ivec2 {0, 0}; }
|
||||||
|
|
|
@ -123,7 +123,7 @@ bool GuiDetectDevice::input(InputConfig* config, Input input)
|
||||||
if (input.value && mHoldingConfig == nullptr) {
|
if (input.value && mHoldingConfig == nullptr) {
|
||||||
// Started holding.
|
// Started holding.
|
||||||
mHoldingConfig = config;
|
mHoldingConfig = config;
|
||||||
mHoldTime = HOLD_TIME;
|
mHoldTime = static_cast<int>(HOLD_TIME);
|
||||||
mDeviceHeld->setText(Utils::String::toUpper(config->getDeviceName()));
|
mDeviceHeld->setText(Utils::String::toUpper(config->getDeviceName()));
|
||||||
}
|
}
|
||||||
else if (!input.value && mHoldingConfig == config) {
|
else if (!input.value && mHoldingConfig == config) {
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
GuiInfoPopup::GuiInfoPopup(std::string message, int duration)
|
GuiInfoPopup::GuiInfoPopup(std::string message, int duration)
|
||||||
: mMessage {message}
|
: mMessage {message}
|
||||||
, mDuration {duration}
|
, mDuration {duration}
|
||||||
|
, mAlpha {1.0f}
|
||||||
, mRunning {true}
|
, mRunning {true}
|
||||||
{
|
{
|
||||||
mFrame = new NinePatchComponent;
|
mFrame = new NinePatchComponent;
|
||||||
|
@ -102,18 +103,18 @@ bool GuiInfoPopup::updateState()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (curTime - mStartTime <= 500) {
|
else if (curTime - mStartTime <= 500) {
|
||||||
mAlpha = ((curTime - mStartTime) * 255 / 500);
|
mAlpha = static_cast<float>((curTime - mStartTime) / 500.0f);
|
||||||
}
|
}
|
||||||
else if (curTime - mStartTime < mDuration - 500) {
|
else if (curTime - mStartTime < mDuration - 500) {
|
||||||
mAlpha = 255;
|
mAlpha = 1.0f;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mAlpha = ((-(curTime - mStartTime - mDuration) * 255) / 500);
|
mAlpha = static_cast<float>((-(curTime - mStartTime - mDuration)) / 500.0f);
|
||||||
}
|
}
|
||||||
mGrid->setOpacity(static_cast<unsigned char>(mAlpha));
|
mGrid->setOpacity(mAlpha);
|
||||||
|
|
||||||
// Apply fade-in effect to popup frame.
|
// Apply fade-in effect to popup frame.
|
||||||
mFrame->setEdgeColor(0xFFFFFF00 | static_cast<unsigned char>(mAlpha));
|
mFrame->setEdgeColor(0xFFFFFF00 | static_cast<unsigned char>(mAlpha * 255.0f));
|
||||||
mFrame->setCenterColor(0xFFFFFF00 | static_cast<unsigned char>(mAlpha));
|
mFrame->setCenterColor(0xFFFFFF00 | static_cast<unsigned char>(mAlpha * 255.0f));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ private:
|
||||||
|
|
||||||
std::string mMessage;
|
std::string mMessage;
|
||||||
int mDuration;
|
int mDuration;
|
||||||
int mAlpha;
|
float mAlpha;
|
||||||
int mStartTime;
|
int mStartTime;
|
||||||
bool mRunning;
|
bool mRunning;
|
||||||
};
|
};
|
||||||
|
|
|
@ -71,7 +71,7 @@ GuiInputConfig::GuiInputConfig(InputConfig* target,
|
||||||
mSubtitle2 = std::make_shared<TextComponent>(
|
mSubtitle2 = std::make_shared<TextComponent>(
|
||||||
"HOLD ANY BUTTON 1 SECOND TO SKIP", Font::get(FONT_SIZE_SMALL), 0x999999FF, ALIGN_CENTER);
|
"HOLD ANY BUTTON 1 SECOND TO SKIP", Font::get(FONT_SIZE_SMALL), 0x999999FF, ALIGN_CENTER);
|
||||||
// The opacity will be set to visible for any row that is skippable.
|
// The opacity will be set to visible for any row that is skippable.
|
||||||
mSubtitle2->setOpacity(0);
|
mSubtitle2->setOpacity(0.0f);
|
||||||
|
|
||||||
mGrid.setEntry(mSubtitle2, glm::ivec2 {0, 3}, false, true);
|
mGrid.setEntry(mSubtitle2, glm::ivec2 {0, 3}, false, true);
|
||||||
|
|
||||||
|
@ -157,8 +157,10 @@ GuiInputConfig::GuiInputConfig(InputConfig* target,
|
||||||
|
|
||||||
// Only show "HOLD TO SKIP" if this input is skippable.
|
// Only show "HOLD TO SKIP" if this input is skippable.
|
||||||
mList->setCursorChangedCallback([this](CursorState) {
|
mList->setCursorChangedCallback([this](CursorState) {
|
||||||
bool skippable = sGuiInputConfigList[mList->getCursorId()].skippable;
|
if (sGuiInputConfigList[mList->getCursorId()].skippable)
|
||||||
mSubtitle2->setOpacity(skippable * 255);
|
mSubtitle2->setOpacity(1.0f);
|
||||||
|
else
|
||||||
|
mSubtitle2->setOpacity(0.0f);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Make the first one say "PRESS ANYTHING" if we're re-configuring everything.
|
// Make the first one say "PRESS ANYTHING" if we're re-configuring everything.
|
||||||
|
|
Loading…
Reference in a new issue