mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 14:15:38 +00:00
Changed the variable names in CarouselComponent to use 'item' instead of 'logo'.
This commit is contained in:
parent
01c2d7ff17
commit
a112fc035f
|
@ -575,24 +575,24 @@ void GamelistBase::populateList(const std::vector<FileData*>& files, FileData* f
|
||||||
carouselEntry.name = (*it)->getName();
|
carouselEntry.name = (*it)->getName();
|
||||||
carouselEntry.object = *it;
|
carouselEntry.object = *it;
|
||||||
if (carouselItemType == "" || carouselItemType == "marquee")
|
if (carouselItemType == "" || carouselItemType == "marquee")
|
||||||
carouselEntry.data.logoPath = (*it)->getMarqueePath();
|
carouselEntry.data.itemPath = (*it)->getMarqueePath();
|
||||||
else if (carouselItemType == "cover")
|
else if (carouselItemType == "cover")
|
||||||
carouselEntry.data.logoPath = (*it)->getCoverPath();
|
carouselEntry.data.itemPath = (*it)->getCoverPath();
|
||||||
else if (carouselItemType == "3dbox")
|
else if (carouselItemType == "3dbox")
|
||||||
carouselEntry.data.logoPath = (*it)->get3DBoxPath();
|
carouselEntry.data.itemPath = (*it)->get3DBoxPath();
|
||||||
else if (carouselItemType == "screenshot")
|
else if (carouselItemType == "screenshot")
|
||||||
carouselEntry.data.logoPath = (*it)->getScreenshotPath();
|
carouselEntry.data.itemPath = (*it)->getScreenshotPath();
|
||||||
else if (carouselItemType == "titlescreen")
|
else if (carouselItemType == "titlescreen")
|
||||||
carouselEntry.data.logoPath = (*it)->getTitleScreenPath();
|
carouselEntry.data.itemPath = (*it)->getTitleScreenPath();
|
||||||
else if (carouselItemType == "backcover")
|
else if (carouselItemType == "backcover")
|
||||||
carouselEntry.data.logoPath = (*it)->getBackCoverPath();
|
carouselEntry.data.itemPath = (*it)->getBackCoverPath();
|
||||||
else if (carouselItemType == "miximage")
|
else if (carouselItemType == "miximage")
|
||||||
carouselEntry.data.logoPath = (*it)->getMiximagePath();
|
carouselEntry.data.itemPath = (*it)->getMiximagePath();
|
||||||
else if (carouselItemType == "fanart")
|
else if (carouselItemType == "fanart")
|
||||||
carouselEntry.data.logoPath = (*it)->getFanArtPath();
|
carouselEntry.data.itemPath = (*it)->getFanArtPath();
|
||||||
|
|
||||||
if (carouselDefaultItem != "")
|
if (carouselDefaultItem != "")
|
||||||
carouselEntry.data.defaultLogoPath = carouselDefaultItem;
|
carouselEntry.data.defaultItemPath = carouselDefaultItem;
|
||||||
|
|
||||||
mCarousel->addEntry(carouselEntry, theme);
|
mCarousel->addEntry(carouselEntry, theme);
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,8 +374,8 @@ void SystemView::populate()
|
||||||
|
|
||||||
for (auto it : SystemData::sSystemVector) {
|
for (auto it : SystemData::sSystemVector) {
|
||||||
const std::shared_ptr<ThemeData>& theme {it->getTheme()};
|
const std::shared_ptr<ThemeData>& theme {it->getTheme()};
|
||||||
std::string logoPath;
|
std::string itemPath;
|
||||||
std::string defaultLogoPath;
|
std::string defaultItemPath;
|
||||||
|
|
||||||
if (mLegacyMode && mViewNeedsReload) {
|
if (mLegacyMode && mViewNeedsReload) {
|
||||||
if (mCarousel == nullptr) {
|
if (mCarousel == nullptr) {
|
||||||
|
@ -467,9 +467,9 @@ void SystemView::populate()
|
||||||
});
|
});
|
||||||
if (mCarousel != nullptr) {
|
if (mCarousel != nullptr) {
|
||||||
if (element.second.has("staticItem"))
|
if (element.second.has("staticItem"))
|
||||||
logoPath = element.second.get<std::string>("staticItem");
|
itemPath = element.second.get<std::string>("staticItem");
|
||||||
if (element.second.has("defaultItem"))
|
if (element.second.has("defaultItem"))
|
||||||
defaultLogoPath = element.second.get<std::string>("defaultItem");
|
defaultItemPath = element.second.get<std::string>("defaultItem");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (element.second.type == "image") {
|
else if (element.second.type == "image") {
|
||||||
|
@ -604,8 +604,8 @@ void SystemView::populate()
|
||||||
CarouselComponent<SystemData*>::Entry entry;
|
CarouselComponent<SystemData*>::Entry entry;
|
||||||
entry.name = it->getName();
|
entry.name = it->getName();
|
||||||
entry.object = it;
|
entry.object = it;
|
||||||
entry.data.logoPath = logoPath;
|
entry.data.itemPath = itemPath;
|
||||||
entry.data.defaultLogoPath = defaultLogoPath;
|
entry.data.defaultItemPath = defaultItemPath;
|
||||||
mCarousel->addEntry(entry, theme);
|
mCarousel->addEntry(entry, theme);
|
||||||
}
|
}
|
||||||
if (mTextList != nullptr) {
|
if (mTextList != nullptr) {
|
||||||
|
|
|
@ -17,9 +17,9 @@
|
||||||
#include "resources/Font.h"
|
#include "resources/Font.h"
|
||||||
|
|
||||||
struct CarouselElement {
|
struct CarouselElement {
|
||||||
std::shared_ptr<GuiComponent> logo;
|
std::shared_ptr<GuiComponent> item;
|
||||||
std::string logoPath;
|
std::string itemPath;
|
||||||
std::string defaultLogoPath;
|
std::string defaultItemPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -122,13 +122,13 @@ private:
|
||||||
unsigned int mTextBackgroundColor;
|
unsigned int mTextBackgroundColor;
|
||||||
std::string mText;
|
std::string mText;
|
||||||
float mLineSpacing;
|
float mLineSpacing;
|
||||||
Alignment mLogoHorizontalAlignment;
|
Alignment mItemHorizontalAlignment;
|
||||||
Alignment mLogoVerticalAlignment;
|
Alignment mItemVerticalAlignment;
|
||||||
float mMaxLogoCount;
|
float mMaxItemCount;
|
||||||
glm::vec2 mLogoSize;
|
glm::vec2 mItemSize;
|
||||||
float mLogoScale;
|
float mItemScale;
|
||||||
float mLogoRotation;
|
float mItemRotation;
|
||||||
glm::vec2 mLogoRotationOrigin;
|
glm::vec2 mItemRotationOrigin;
|
||||||
unsigned int mCarouselColor;
|
unsigned int mCarouselColor;
|
||||||
unsigned int mCarouselColorEnd;
|
unsigned int mCarouselColorEnd;
|
||||||
bool mColorGradientHorizontal;
|
bool mColorGradientHorizontal;
|
||||||
|
@ -149,13 +149,13 @@ CarouselComponent<T>::CarouselComponent()
|
||||||
, mTextColor {0x000000FF}
|
, mTextColor {0x000000FF}
|
||||||
, mTextBackgroundColor {0xFFFFFF00}
|
, mTextBackgroundColor {0xFFFFFF00}
|
||||||
, mLineSpacing {1.5f}
|
, mLineSpacing {1.5f}
|
||||||
, mLogoHorizontalAlignment {ALIGN_CENTER}
|
, mItemHorizontalAlignment {ALIGN_CENTER}
|
||||||
, mLogoVerticalAlignment {ALIGN_CENTER}
|
, mItemVerticalAlignment {ALIGN_CENTER}
|
||||||
, mMaxLogoCount {3.0f}
|
, mMaxItemCount {3.0f}
|
||||||
, mLogoSize {Renderer::getScreenWidth() * 0.25f, Renderer::getScreenHeight() * 0.155f}
|
, mItemSize {Renderer::getScreenWidth() * 0.25f, Renderer::getScreenHeight() * 0.155f}
|
||||||
, mLogoScale {1.2f}
|
, mItemScale {1.2f}
|
||||||
, mLogoRotation {7.5f}
|
, mItemRotation {7.5f}
|
||||||
, mLogoRotationOrigin {-3.0f, 0.5f}
|
, mItemRotationOrigin {-3.0f, 0.5f}
|
||||||
, mCarouselColor {0}
|
, mCarouselColor {0}
|
||||||
, mCarouselColorEnd {0}
|
, mCarouselColorEnd {0}
|
||||||
, mColorGradientHorizontal {true}
|
, mColorGradientHorizontal {true}
|
||||||
|
@ -167,56 +167,55 @@ void CarouselComponent<T>::addEntry(Entry& entry, const std::shared_ptr<ThemeDat
|
||||||
{
|
{
|
||||||
bool legacyMode {theme->isLegacyTheme()};
|
bool legacyMode {theme->isLegacyTheme()};
|
||||||
|
|
||||||
// Make logo.
|
|
||||||
if (legacyMode) {
|
if (legacyMode) {
|
||||||
const ThemeData::ThemeElement* logoElem {
|
const ThemeData::ThemeElement* itemElem {
|
||||||
theme->getElement("system", "image_logo", "image")};
|
theme->getElement("system", "image_logo", "image")};
|
||||||
|
|
||||||
if (logoElem) {
|
if (itemElem) {
|
||||||
std::string path;
|
std::string path;
|
||||||
if (logoElem->has("path"))
|
if (itemElem->has("path"))
|
||||||
path = logoElem->get<std::string>("path");
|
path = itemElem->get<std::string>("path");
|
||||||
std::string defaultPath {
|
std::string defaultPath {
|
||||||
logoElem->has("default") ? logoElem->get<std::string>("default") : ""};
|
itemElem->has("default") ? itemElem->get<std::string>("default") : ""};
|
||||||
if ((!path.empty() && ResourceManager::getInstance().fileExists(path)) ||
|
if ((!path.empty() && ResourceManager::getInstance().fileExists(path)) ||
|
||||||
(!defaultPath.empty() && ResourceManager::getInstance().fileExists(defaultPath))) {
|
(!defaultPath.empty() && ResourceManager::getInstance().fileExists(defaultPath))) {
|
||||||
auto logo = std::make_shared<ImageComponent>(false, false);
|
auto item = std::make_shared<ImageComponent>(false, false);
|
||||||
logo->setLinearInterpolation(true);
|
item->setLinearInterpolation(true);
|
||||||
logo->setMaxSize(glm::round(mLogoSize * mLogoScale));
|
item->setMaxSize(glm::round(mItemSize * mItemScale));
|
||||||
logo->applyTheme(theme, "system", "image_logo",
|
item->applyTheme(theme, "system", "image_logo",
|
||||||
ThemeFlags::PATH | ThemeFlags::COLOR);
|
ThemeFlags::PATH | ThemeFlags::COLOR);
|
||||||
logo->setRotateByTargetSize(true);
|
item->setRotateByTargetSize(true);
|
||||||
entry.data.logo = logo;
|
entry.data.item = item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (entry.data.logoPath != "" &&
|
if (entry.data.itemPath != "" &&
|
||||||
ResourceManager::getInstance().fileExists(entry.data.logoPath)) {
|
ResourceManager::getInstance().fileExists(entry.data.itemPath)) {
|
||||||
auto logo = std::make_shared<ImageComponent>(false, false);
|
auto item = std::make_shared<ImageComponent>(false, false);
|
||||||
logo->setLinearInterpolation(true);
|
item->setLinearInterpolation(true);
|
||||||
logo->setImage(entry.data.logoPath);
|
item->setImage(entry.data.itemPath);
|
||||||
logo->setMaxSize(glm::round(mLogoSize * mLogoScale));
|
item->setMaxSize(glm::round(mItemSize * mItemScale));
|
||||||
logo->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
item->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
||||||
logo->setRotateByTargetSize(true);
|
item->setRotateByTargetSize(true);
|
||||||
entry.data.logo = logo;
|
entry.data.item = item;
|
||||||
}
|
}
|
||||||
else if (entry.data.defaultLogoPath != "" &&
|
else if (entry.data.defaultItemPath != "" &&
|
||||||
ResourceManager::getInstance().fileExists(entry.data.defaultLogoPath)) {
|
ResourceManager::getInstance().fileExists(entry.data.defaultItemPath)) {
|
||||||
auto defaultLogo = std::make_shared<ImageComponent>(false, false);
|
auto defaultItem = std::make_shared<ImageComponent>(false, false);
|
||||||
defaultLogo->setLinearInterpolation(true);
|
defaultItem->setLinearInterpolation(true);
|
||||||
defaultLogo->setImage(entry.data.defaultLogoPath);
|
defaultItem->setImage(entry.data.defaultItemPath);
|
||||||
defaultLogo->setMaxSize(glm::round(mLogoSize * mLogoScale));
|
defaultItem->setMaxSize(glm::round(mItemSize * mItemScale));
|
||||||
defaultLogo->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
defaultItem->applyTheme(theme, "system", "", ThemeFlags::ALL);
|
||||||
defaultLogo->setRotateByTargetSize(true);
|
defaultItem->setRotateByTargetSize(true);
|
||||||
entry.data.logo = defaultLogo;
|
entry.data.item = defaultItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!entry.data.logo) {
|
if (!entry.data.item) {
|
||||||
// If no logo image is present, add logo text as fallback.
|
// If no item image is present, add item text as fallback.
|
||||||
auto text = std::make_shared<TextComponent>(entry.name, mFont, 0x000000FF, ALIGN_CENTER);
|
auto text = std::make_shared<TextComponent>(entry.name, mFont, 0x000000FF, ALIGN_CENTER);
|
||||||
text->setSize(mLogoSize * mLogoScale);
|
text->setSize(mItemSize * mItemScale);
|
||||||
if (legacyMode) {
|
if (legacyMode) {
|
||||||
text->applyTheme(theme, "system", "text_logoText",
|
text->applyTheme(theme, "system", "text_logoText",
|
||||||
ThemeFlags::FONT_PATH | ThemeFlags::FONT_SIZE | ThemeFlags::COLOR |
|
ThemeFlags::FONT_PATH | ThemeFlags::FONT_SIZE | ThemeFlags::COLOR |
|
||||||
|
@ -233,29 +232,29 @@ void CarouselComponent<T>::addEntry(Entry& entry, const std::shared_ptr<ThemeDat
|
||||||
text->setBackgroundColor(mTextBackgroundColor);
|
text->setBackgroundColor(mTextBackgroundColor);
|
||||||
text->setRenderBackground(true);
|
text->setRenderBackground(true);
|
||||||
}
|
}
|
||||||
entry.data.logo = text;
|
entry.data.item = text;
|
||||||
|
|
||||||
text->setHorizontalAlignment(mLogoHorizontalAlignment);
|
text->setHorizontalAlignment(mItemHorizontalAlignment);
|
||||||
text->setVerticalAlignment(mLogoVerticalAlignment);
|
text->setVerticalAlignment(mItemVerticalAlignment);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set origin for the logos based on their alignment so they line up properly.
|
// Set origin for the items based on their alignment so they line up properly.
|
||||||
if (mLogoHorizontalAlignment == ALIGN_LEFT)
|
if (mItemHorizontalAlignment == ALIGN_LEFT)
|
||||||
entry.data.logo->setOrigin(0, 0.5);
|
entry.data.item->setOrigin(0.0f, 0.5f);
|
||||||
else if (mLogoHorizontalAlignment == ALIGN_RIGHT)
|
else if (mItemHorizontalAlignment == ALIGN_RIGHT)
|
||||||
entry.data.logo->setOrigin(1.0, 0.5);
|
entry.data.item->setOrigin(1.0f, 0.5f);
|
||||||
else
|
else
|
||||||
entry.data.logo->setOrigin(0.5, 0.5);
|
entry.data.item->setOrigin(0.5f, 0.5f);
|
||||||
|
|
||||||
if (mLogoVerticalAlignment == ALIGN_TOP)
|
if (mItemVerticalAlignment == ALIGN_TOP)
|
||||||
entry.data.logo->setOrigin(entry.data.logo->getOrigin().x, 0);
|
entry.data.item->setOrigin(entry.data.item->getOrigin().x, 0.0f);
|
||||||
else if (mLogoVerticalAlignment == ALIGN_BOTTOM)
|
else if (mItemVerticalAlignment == ALIGN_BOTTOM)
|
||||||
entry.data.logo->setOrigin(entry.data.logo->getOrigin().x, 1);
|
entry.data.item->setOrigin(entry.data.item->getOrigin().x, 1.0f);
|
||||||
else
|
else
|
||||||
entry.data.logo->setOrigin(entry.data.logo->getOrigin().x, 0.5);
|
entry.data.item->setOrigin(entry.data.item->getOrigin().x, 0.5f);
|
||||||
|
|
||||||
glm::vec2 denormalized {mLogoSize * entry.data.logo->getOrigin()};
|
glm::vec2 denormalized {mItemSize * entry.data.item->getOrigin()};
|
||||||
entry.data.logo->setPosition(glm::vec3 {denormalized.x, denormalized.y, 0.0f});
|
entry.data.item->setPosition(glm::vec3 {denormalized.x, denormalized.y, 0.0f});
|
||||||
|
|
||||||
List::add(entry);
|
List::add(entry);
|
||||||
}
|
}
|
||||||
|
@ -388,57 +387,57 @@ template <typename T> void CarouselComponent<T>::render(const glm::mat4& parentT
|
||||||
|
|
||||||
mRenderer->setMatrix(carouselTrans);
|
mRenderer->setMatrix(carouselTrans);
|
||||||
|
|
||||||
// Background box behind logos.
|
// Background box behind the items.
|
||||||
mRenderer->drawRect(0.0f, 0.0f, mSize.x, mSize.y, mCarouselColor, mCarouselColorEnd,
|
mRenderer->drawRect(0.0f, 0.0f, mSize.x, mSize.y, mCarouselColor, mCarouselColorEnd,
|
||||||
mColorGradientHorizontal);
|
mColorGradientHorizontal);
|
||||||
|
|
||||||
// Draw logos.
|
// Draw the items.
|
||||||
// logoSpacing will also include the size of the logo itself.
|
// itemSpacing will also include the size of the item itself.
|
||||||
glm::vec2 logoSpacing {};
|
glm::vec2 itemSpacing {0.0f, 0.0f};
|
||||||
float xOff {0.0f};
|
float xOff {0.0f};
|
||||||
float yOff {0.0f};
|
float yOff {0.0f};
|
||||||
|
|
||||||
switch (mType) {
|
switch (mType) {
|
||||||
case CarouselType::HORIZONTAL_WHEEL:
|
case CarouselType::HORIZONTAL_WHEEL:
|
||||||
case CarouselType::VERTICAL_WHEEL:
|
case CarouselType::VERTICAL_WHEEL:
|
||||||
xOff = std::round((mSize.x - mLogoSize.x) / 2.0f - (mEntryCamOffset * logoSpacing.y));
|
xOff = std::round((mSize.x - mItemSize.x) / 2.0f - (mEntryCamOffset * itemSpacing.y));
|
||||||
yOff = (mSize.y - mLogoSize.y) / 2.0f;
|
yOff = (mSize.y - mItemSize.y) / 2.0f;
|
||||||
break;
|
break;
|
||||||
case CarouselType::VERTICAL:
|
case CarouselType::VERTICAL:
|
||||||
logoSpacing.y =
|
itemSpacing.y =
|
||||||
((mSize.y - (mLogoSize.y * mMaxLogoCount)) / (mMaxLogoCount)) + mLogoSize.y;
|
((mSize.y - (mItemSize.y * mMaxItemCount)) / (mMaxItemCount)) + mItemSize.y;
|
||||||
yOff = (mSize.y - mLogoSize.y) / 2.0f - (mEntryCamOffset * logoSpacing.y);
|
yOff = (mSize.y - mItemSize.y) / 2.0f - (mEntryCamOffset * itemSpacing.y);
|
||||||
if (mLogoHorizontalAlignment == ALIGN_LEFT)
|
if (mItemHorizontalAlignment == ALIGN_LEFT)
|
||||||
xOff = mLogoSize.x / 10.0f;
|
xOff = mItemSize.x / 10.0f;
|
||||||
else if (mLogoHorizontalAlignment == ALIGN_RIGHT)
|
else if (mItemHorizontalAlignment == ALIGN_RIGHT)
|
||||||
xOff = mSize.x - (mLogoSize.x * 1.1f);
|
xOff = mSize.x - (mItemSize.x * 1.1f);
|
||||||
else
|
else
|
||||||
xOff = (mSize.x - mLogoSize.x) / 2.0f;
|
xOff = (mSize.x - mItemSize.x) / 2.0f;
|
||||||
break;
|
break;
|
||||||
case CarouselType::HORIZONTAL:
|
case CarouselType::HORIZONTAL:
|
||||||
default:
|
default:
|
||||||
logoSpacing.x =
|
itemSpacing.x =
|
||||||
((mSize.x - (mLogoSize.x * mMaxLogoCount)) / (mMaxLogoCount)) + mLogoSize.x;
|
((mSize.x - (mItemSize.x * mMaxItemCount)) / (mMaxItemCount)) + mItemSize.x;
|
||||||
xOff = std::round((mSize.x - mLogoSize.x) / 2.0f - (mEntryCamOffset * logoSpacing.x));
|
xOff = std::round((mSize.x - mItemSize.x) / 2.0f - (mEntryCamOffset * itemSpacing.x));
|
||||||
if (mLogoVerticalAlignment == ALIGN_TOP)
|
if (mItemVerticalAlignment == ALIGN_TOP)
|
||||||
yOff = mLogoSize.y / 10.0f;
|
yOff = mItemSize.y / 10.0f;
|
||||||
else if (mLogoVerticalAlignment == ALIGN_BOTTOM)
|
else if (mItemVerticalAlignment == ALIGN_BOTTOM)
|
||||||
yOff = mSize.y - (mLogoSize.y * 1.1f);
|
yOff = mSize.y - (mItemSize.y * 1.1f);
|
||||||
else
|
else
|
||||||
yOff = (mSize.y - mLogoSize.y) / 2.0f;
|
yOff = (mSize.y - mItemSize.y) / 2.0f;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int center {static_cast<int>(mEntryCamOffset)};
|
int center {static_cast<int>(mEntryCamOffset)};
|
||||||
int logoInclusion {static_cast<int>(std::ceil(mMaxLogoCount / 2.0f))};
|
int itemInclusion {static_cast<int>(std::ceil(mMaxItemCount / 2.0f))};
|
||||||
bool singleEntry {mEntries.size() == 1};
|
bool singleEntry {mEntries.size() == 1};
|
||||||
|
|
||||||
for (int i = center - logoInclusion; i < center + logoInclusion + 2; ++i) {
|
for (int i = center - itemInclusion; i < center + itemInclusion + 2; ++i) {
|
||||||
int index {i};
|
int index {i};
|
||||||
|
|
||||||
// If there is only a single system, then only render the logo once (in the center).
|
// If there is only a single entry, then only render the item once (in the center).
|
||||||
if (singleEntry) {
|
if (singleEntry) {
|
||||||
mEntries.at(0).data.logo->render(
|
mEntries.at(0).data.item->render(
|
||||||
glm::translate(carouselTrans, glm::vec3 {0 + xOff, 0 + yOff, 0.0f}));
|
glm::translate(carouselTrans, glm::vec3 {0 + xOff, 0 + yOff, 0.0f}));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -448,41 +447,41 @@ template <typename T> void CarouselComponent<T>::render(const glm::mat4& parentT
|
||||||
while (index >= static_cast<int>(mEntries.size()))
|
while (index >= static_cast<int>(mEntries.size()))
|
||||||
index -= static_cast<int>(mEntries.size());
|
index -= static_cast<int>(mEntries.size());
|
||||||
|
|
||||||
glm::mat4 logoTrans {carouselTrans};
|
glm::mat4 itemTrans {carouselTrans};
|
||||||
logoTrans = glm::translate(
|
itemTrans = glm::translate(
|
||||||
logoTrans, glm::vec3 {i * logoSpacing.x + xOff, i * logoSpacing.y + yOff, 0.0f});
|
itemTrans, glm::vec3 {i * itemSpacing.x + xOff, i * itemSpacing.y + yOff, 0.0f});
|
||||||
|
|
||||||
float distance {i - mEntryCamOffset};
|
float distance {i - mEntryCamOffset};
|
||||||
|
|
||||||
float scale {1.0f + ((mLogoScale - 1.0f) * (1.0f - fabsf(distance)))};
|
float scale {1.0f + ((mItemScale - 1.0f) * (1.0f - fabsf(distance)))};
|
||||||
scale = std::min(mLogoScale, std::max(1.0f, scale));
|
scale = std::min(mItemScale, std::max(1.0f, scale));
|
||||||
scale /= mLogoScale;
|
scale /= mItemScale;
|
||||||
|
|
||||||
int opacity {
|
int opacity {
|
||||||
static_cast<int>(std::round(0x80 + ((0xFF - 0x80) * (1.0f - fabsf(distance)))))};
|
static_cast<int>(std::round(0x80 + ((0xFF - 0x80) * (1.0f - fabsf(distance)))))};
|
||||||
opacity = std::max(static_cast<int>(0x80), opacity);
|
opacity = std::max(static_cast<int>(0x80), opacity);
|
||||||
|
|
||||||
const std::shared_ptr<GuiComponent>& comp {mEntries.at(index).data.logo};
|
const std::shared_ptr<GuiComponent>& comp {mEntries.at(index).data.item};
|
||||||
|
|
||||||
if (comp == nullptr)
|
if (comp == nullptr)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (mType == CarouselType::VERTICAL_WHEEL || mType == CarouselType::HORIZONTAL_WHEEL) {
|
if (mType == CarouselType::VERTICAL_WHEEL || mType == CarouselType::HORIZONTAL_WHEEL) {
|
||||||
comp->setRotationDegrees(mLogoRotation * distance);
|
comp->setRotationDegrees(mItemRotation * distance);
|
||||||
comp->setRotationOrigin(mLogoRotationOrigin);
|
comp->setRotationOrigin(mItemRotationOrigin);
|
||||||
}
|
}
|
||||||
|
|
||||||
// When running at lower resolutions, prevent the scale-down to go all the way to
|
// When running at lower resolutions, prevent the scale-down to go all the way to
|
||||||
// the minimum value. This avoids potential single-pixel alignment issues when the
|
// the minimum value. This avoids potential single-pixel alignment issues when the
|
||||||
// logo can't be vertically placed exactly in the middle of the carousel. Although
|
// item can't be vertically placed exactly in the middle of the carousel. Although
|
||||||
// the problem theoretically exists at all resolutions, it's not visble at around
|
// the problem theoretically exists at all resolutions, it's not visble at around
|
||||||
// 1080p and above.
|
// 1080p and above.
|
||||||
if (std::min(Renderer::getScreenWidth(), Renderer::getScreenHeight()) < 1080.0f)
|
if (std::min(Renderer::getScreenWidth(), Renderer::getScreenHeight()) < 1080.0f)
|
||||||
scale = glm::clamp(scale, 1.0f / mLogoScale + 0.01f, 1.0f);
|
scale = glm::clamp(scale, 1.0f / mItemScale + 0.01f, 1.0f);
|
||||||
|
|
||||||
comp->setScale(scale);
|
comp->setScale(scale);
|
||||||
comp->setOpacity(static_cast<float>(opacity) / 255.0f);
|
comp->setOpacity(static_cast<float>(opacity) / 255.0f);
|
||||||
comp->render(logoTrans);
|
comp->render(itemTrans);
|
||||||
}
|
}
|
||||||
mRenderer->popClipRect();
|
mRenderer->popClipRect();
|
||||||
}
|
}
|
||||||
|
@ -555,67 +554,67 @@ void CarouselComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
|
|
||||||
if (!theme->isLegacyTheme()) {
|
if (!theme->isLegacyTheme()) {
|
||||||
if (elem->has("itemScale"))
|
if (elem->has("itemScale"))
|
||||||
mLogoScale = glm::clamp(elem->get<float>("itemScale"), 0.5f, 3.0f);
|
mItemScale = glm::clamp(elem->get<float>("itemScale"), 0.5f, 3.0f);
|
||||||
if (elem->has("itemSize")) {
|
if (elem->has("itemSize")) {
|
||||||
// Keep size within a 0.05 and 1.0 multiple of the screen size.
|
// Keep size within a 0.05 and 1.0 multiple of the screen size.
|
||||||
glm::vec2 logoSize {elem->get<glm::vec2>("itemSize")};
|
glm::vec2 itemSize {elem->get<glm::vec2>("itemSize")};
|
||||||
if (std::max(logoSize.x, logoSize.y) > 1.0f) {
|
if (std::max(itemSize.x, itemSize.y) > 1.0f) {
|
||||||
logoSize /= std::max(logoSize.x, logoSize.y);
|
itemSize /= std::max(itemSize.x, itemSize.y);
|
||||||
}
|
}
|
||||||
else if (std::min(logoSize.x, logoSize.y) < 0.005f) {
|
else if (std::min(itemSize.x, itemSize.y) < 0.005f) {
|
||||||
float ratio {std::min(logoSize.x, logoSize.y) / 0.005f};
|
float ratio {std::min(itemSize.x, itemSize.y) / 0.005f};
|
||||||
logoSize /= ratio;
|
itemSize /= ratio;
|
||||||
// Just an extra precaution if a crazy ratio was used.
|
// Just an extra precaution if a crazy ratio was used.
|
||||||
logoSize.x = glm::clamp(logoSize.x, 0.005f, 1.0f);
|
itemSize.x = glm::clamp(itemSize.x, 0.005f, 1.0f);
|
||||||
logoSize.y = glm::clamp(logoSize.y, 0.005f, 1.0f);
|
itemSize.y = glm::clamp(itemSize.y, 0.005f, 1.0f);
|
||||||
}
|
}
|
||||||
mLogoSize =
|
mItemSize =
|
||||||
logoSize * glm::vec2(Renderer::getScreenWidth(), Renderer::getScreenHeight());
|
itemSize * glm::vec2(Renderer::getScreenWidth(), Renderer::getScreenHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("maxItemCount"))
|
if (elem->has("maxItemCount"))
|
||||||
mMaxLogoCount = glm::clamp(elem->get<float>("maxItemCount"), 0.5f, 30.0f);
|
mMaxItemCount = glm::clamp(elem->get<float>("maxItemCount"), 0.5f, 30.0f);
|
||||||
|
|
||||||
if (elem->has("itemRotation"))
|
if (elem->has("itemRotation"))
|
||||||
mLogoRotation = elem->get<float>("itemRotation");
|
mItemRotation = elem->get<float>("itemRotation");
|
||||||
if (elem->has("itemRotationOrigin"))
|
if (elem->has("itemRotationOrigin"))
|
||||||
mLogoRotationOrigin = elem->get<glm::vec2>("itemRotationOrigin");
|
mItemRotationOrigin = elem->get<glm::vec2>("itemRotationOrigin");
|
||||||
|
|
||||||
if (elem->has("itemHorizontalAlignment")) {
|
if (elem->has("itemHorizontalAlignment")) {
|
||||||
const std::string alignment {elem->get<std::string>("itemHorizontalAlignment")};
|
const std::string alignment {elem->get<std::string>("itemHorizontalAlignment")};
|
||||||
if (alignment == "left" && mType != CarouselType::HORIZONTAL) {
|
if (alignment == "left" && mType != CarouselType::HORIZONTAL) {
|
||||||
mLogoHorizontalAlignment = ALIGN_LEFT;
|
mItemHorizontalAlignment = ALIGN_LEFT;
|
||||||
}
|
}
|
||||||
else if (alignment == "right" && mType != CarouselType::HORIZONTAL) {
|
else if (alignment == "right" && mType != CarouselType::HORIZONTAL) {
|
||||||
mLogoHorizontalAlignment = ALIGN_RIGHT;
|
mItemHorizontalAlignment = ALIGN_RIGHT;
|
||||||
}
|
}
|
||||||
else if (alignment == "center") {
|
else if (alignment == "center") {
|
||||||
mLogoHorizontalAlignment = ALIGN_CENTER;
|
mItemHorizontalAlignment = ALIGN_CENTER;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG(LogWarning) << "CarouselComponent: Invalid theme configuration, property "
|
LOG(LogWarning) << "CarouselComponent: Invalid theme configuration, property "
|
||||||
"<itemHorizontalAlignment> defined as \""
|
"<itemHorizontalAlignment> defined as \""
|
||||||
<< alignment << "\"";
|
<< alignment << "\"";
|
||||||
mLogoHorizontalAlignment = ALIGN_CENTER;
|
mItemHorizontalAlignment = ALIGN_CENTER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("itemVerticalAlignment")) {
|
if (elem->has("itemVerticalAlignment")) {
|
||||||
const std::string alignment {elem->get<std::string>("itemVerticalAlignment")};
|
const std::string alignment {elem->get<std::string>("itemVerticalAlignment")};
|
||||||
if (alignment == "top" && mType != CarouselType::VERTICAL) {
|
if (alignment == "top" && mType != CarouselType::VERTICAL) {
|
||||||
mLogoVerticalAlignment = ALIGN_TOP;
|
mItemVerticalAlignment = ALIGN_TOP;
|
||||||
}
|
}
|
||||||
else if (alignment == "bottom" && mType != CarouselType::VERTICAL) {
|
else if (alignment == "bottom" && mType != CarouselType::VERTICAL) {
|
||||||
mLogoVerticalAlignment = ALIGN_BOTTOM;
|
mItemVerticalAlignment = ALIGN_BOTTOM;
|
||||||
}
|
}
|
||||||
else if (alignment == "center") {
|
else if (alignment == "center") {
|
||||||
mLogoVerticalAlignment = ALIGN_CENTER;
|
mItemVerticalAlignment = ALIGN_CENTER;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG(LogWarning) << "CarouselComponent: Invalid theme configuration, property "
|
LOG(LogWarning) << "CarouselComponent: Invalid theme configuration, property "
|
||||||
"<itemVerticalAlignment> defined as \""
|
"<itemVerticalAlignment> defined as \""
|
||||||
<< alignment << "\"";
|
<< alignment << "\"";
|
||||||
mLogoVerticalAlignment = ALIGN_CENTER;
|
mItemVerticalAlignment = ALIGN_CENTER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -623,63 +622,63 @@ void CarouselComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
// Start of legacy themes only section.
|
// Start of legacy themes only section.
|
||||||
|
|
||||||
if (elem->has("logoScale"))
|
if (elem->has("logoScale"))
|
||||||
mLogoScale = glm::clamp(elem->get<float>("logoScale"), 0.5f, 3.0f);
|
mItemScale = glm::clamp(elem->get<float>("logoScale"), 0.5f, 3.0f);
|
||||||
if (elem->has("logoSize")) {
|
if (elem->has("logoSize")) {
|
||||||
// Keep size within a 0.05 and 1.0 multiple of the screen size.
|
// Keep size within a 0.05 and 1.0 multiple of the screen size.
|
||||||
glm::vec2 logoSize {elem->get<glm::vec2>("logoSize")};
|
glm::vec2 itemSize {elem->get<glm::vec2>("logoSize")};
|
||||||
if (std::max(logoSize.x, logoSize.y) > 1.0f) {
|
if (std::max(itemSize.x, itemSize.y) > 1.0f) {
|
||||||
logoSize /= std::max(logoSize.x, logoSize.y);
|
itemSize /= std::max(itemSize.x, itemSize.y);
|
||||||
}
|
}
|
||||||
else if (std::min(logoSize.x, logoSize.y) < 0.005f) {
|
else if (std::min(itemSize.x, itemSize.y) < 0.005f) {
|
||||||
float ratio {std::min(logoSize.x, logoSize.y) / 0.005f};
|
float ratio {std::min(itemSize.x, itemSize.y) / 0.005f};
|
||||||
logoSize /= ratio;
|
itemSize /= ratio;
|
||||||
// Just an extra precaution if a crazy ratio was used.
|
// Just an extra precaution if a crazy ratio was used.
|
||||||
logoSize.x = glm::clamp(logoSize.x, 0.005f, 1.0f);
|
itemSize.x = glm::clamp(itemSize.x, 0.005f, 1.0f);
|
||||||
logoSize.y = glm::clamp(logoSize.y, 0.005f, 1.0f);
|
itemSize.y = glm::clamp(itemSize.y, 0.005f, 1.0f);
|
||||||
}
|
}
|
||||||
mLogoSize = logoSize * glm::vec2(Renderer::getScreenWidth(), Renderer::getScreenHeight());
|
mItemSize = itemSize * glm::vec2(Renderer::getScreenWidth(), Renderer::getScreenHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("maxLogoCount")) {
|
if (elem->has("maxLogoCount")) {
|
||||||
if (theme->isLegacyTheme())
|
if (theme->isLegacyTheme())
|
||||||
mMaxLogoCount = std::ceil(glm::clamp(elem->get<float>("maxLogoCount"), 0.5f, 30.0f));
|
mMaxItemCount = std::ceil(glm::clamp(elem->get<float>("maxLogoCount"), 0.5f, 30.0f));
|
||||||
else
|
else
|
||||||
mMaxLogoCount = glm::clamp(elem->get<float>("maxLogoCount"), 0.5f, 30.0f);
|
mMaxItemCount = glm::clamp(elem->get<float>("maxLogoCount"), 0.5f, 30.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("logoRotation"))
|
if (elem->has("logoRotation"))
|
||||||
mLogoRotation = elem->get<float>("logoRotation");
|
mItemRotation = elem->get<float>("logoRotation");
|
||||||
if (elem->has("logoRotationOrigin"))
|
if (elem->has("logoRotationOrigin"))
|
||||||
mLogoRotationOrigin = elem->get<glm::vec2>("logoRotationOrigin");
|
mItemRotationOrigin = elem->get<glm::vec2>("logoRotationOrigin");
|
||||||
|
|
||||||
if (elem->has("logoAlignment")) {
|
if (elem->has("logoAlignment")) {
|
||||||
const std::string alignment {elem->get<std::string>("logoAlignment")};
|
const std::string alignment {elem->get<std::string>("logoAlignment")};
|
||||||
if (alignment == "left" && mType != CarouselType::HORIZONTAL) {
|
if (alignment == "left" && mType != CarouselType::HORIZONTAL) {
|
||||||
mLogoHorizontalAlignment = ALIGN_LEFT;
|
mItemHorizontalAlignment = ALIGN_LEFT;
|
||||||
mLogoVerticalAlignment = ALIGN_CENTER;
|
mItemVerticalAlignment = ALIGN_CENTER;
|
||||||
}
|
}
|
||||||
else if (alignment == "right" && mType != CarouselType::HORIZONTAL) {
|
else if (alignment == "right" && mType != CarouselType::HORIZONTAL) {
|
||||||
mLogoHorizontalAlignment = ALIGN_RIGHT;
|
mItemHorizontalAlignment = ALIGN_RIGHT;
|
||||||
mLogoVerticalAlignment = ALIGN_CENTER;
|
mItemVerticalAlignment = ALIGN_CENTER;
|
||||||
}
|
}
|
||||||
else if (alignment == "top" && mType != CarouselType::VERTICAL) {
|
else if (alignment == "top" && mType != CarouselType::VERTICAL) {
|
||||||
mLogoVerticalAlignment = ALIGN_TOP;
|
mItemVerticalAlignment = ALIGN_TOP;
|
||||||
mLogoHorizontalAlignment = ALIGN_CENTER;
|
mItemHorizontalAlignment = ALIGN_CENTER;
|
||||||
}
|
}
|
||||||
else if (alignment == "bottom" && mType != CarouselType::VERTICAL) {
|
else if (alignment == "bottom" && mType != CarouselType::VERTICAL) {
|
||||||
mLogoVerticalAlignment = ALIGN_BOTTOM;
|
mItemVerticalAlignment = ALIGN_BOTTOM;
|
||||||
mLogoHorizontalAlignment = ALIGN_CENTER;
|
mItemHorizontalAlignment = ALIGN_CENTER;
|
||||||
}
|
}
|
||||||
else if (alignment == "center") {
|
else if (alignment == "center") {
|
||||||
mLogoHorizontalAlignment = ALIGN_CENTER;
|
mItemHorizontalAlignment = ALIGN_CENTER;
|
||||||
mLogoVerticalAlignment = ALIGN_CENTER;
|
mItemVerticalAlignment = ALIGN_CENTER;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
LOG(LogWarning) << "CarouselComponent: Invalid theme configuration, property "
|
LOG(LogWarning) << "CarouselComponent: Invalid theme configuration, property "
|
||||||
"<logoAlignment> defined as \""
|
"<logoAlignment> defined as \""
|
||||||
<< alignment << "\"";
|
<< alignment << "\"";
|
||||||
mLogoHorizontalAlignment = ALIGN_CENTER;
|
mItemHorizontalAlignment = ALIGN_CENTER;
|
||||||
mLogoVerticalAlignment = ALIGN_CENTER;
|
mItemVerticalAlignment = ALIGN_CENTER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -752,7 +751,7 @@ template <typename T> void CarouselComponent<T>::onCursorChanged(const CursorSta
|
||||||
endPos = target - posMax; // Loop around the start (max - 1 -> -1).
|
endPos = target - posMax; // Loop around the start (max - 1 -> -1).
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure there are no reverse jumps between logos.
|
// Make sure there are no reverse jumps between items.
|
||||||
bool changedDirection {false};
|
bool changedDirection {false};
|
||||||
if (mPreviousScrollVelocity != 0 && mPreviousScrollVelocity != mScrollVelocity)
|
if (mPreviousScrollVelocity != 0 && mPreviousScrollVelocity != mScrollVelocity)
|
||||||
changedDirection = true;
|
changedDirection = true;
|
||||||
|
|
Loading…
Reference in a new issue