mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-22 06:05:38 +00:00
Set the clang-format option SpaceBeforeCpp11BracedList to true.
This commit is contained in:
parent
e64976d4bc
commit
8a6652552f
|
@ -119,7 +119,7 @@ SpaceAfterCStyleCast: false
|
||||||
SpaceAfterLogicalNot: false
|
SpaceAfterLogicalNot: false
|
||||||
SpaceAfterTemplateKeyword: true
|
SpaceAfterTemplateKeyword: true
|
||||||
SpaceBeforeAssignmentOperators: true
|
SpaceBeforeAssignmentOperators: true
|
||||||
SpaceBeforeCpp11BracedList: false
|
SpaceBeforeCpp11BracedList: true
|
||||||
SpaceBeforeCtorInitializerColon: true
|
SpaceBeforeCtorInitializerColon: true
|
||||||
SpaceBeforeInheritanceColon: true
|
SpaceBeforeInheritanceColon: true
|
||||||
SpaceBeforeParens: ControlStatements
|
SpaceBeforeParens: ControlStatements
|
||||||
|
|
|
@ -780,7 +780,7 @@ FileData* CollectionSystemsManager::updateCollectionFolderMetadata(SystemData* s
|
||||||
if (gameCount > 1) {
|
if (gameCount > 1) {
|
||||||
std::random_device randDev;
|
std::random_device randDev;
|
||||||
// Mersenne Twister pseudorandom number generator.
|
// Mersenne Twister pseudorandom number generator.
|
||||||
std::mt19937 engine{randDev()};
|
std::mt19937 engine {randDev()};
|
||||||
unsigned int target;
|
unsigned int target;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < 3; ++i) {
|
for (unsigned int i = 0; i < 3; ++i) {
|
||||||
|
|
|
@ -50,10 +50,10 @@ struct CollectionSystemDecl {
|
||||||
|
|
||||||
struct CollectionSystemData {
|
struct CollectionSystemData {
|
||||||
CollectionSystemData()
|
CollectionSystemData()
|
||||||
: system{nullptr}
|
: system {nullptr}
|
||||||
, decl{}
|
, decl {}
|
||||||
, isEnabled{false}
|
, isEnabled {false}
|
||||||
, isPopulated{false}
|
, isPopulated {false}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
SystemData* system;
|
SystemData* system;
|
||||||
|
|
|
@ -1217,8 +1217,8 @@ const std::string FileData::findEmulatorPath(std::string& command)
|
||||||
std::vector<std::string> emulatorSystemPaths;
|
std::vector<std::string> emulatorSystemPaths;
|
||||||
std::vector<std::string> emulatorStaticPaths;
|
std::vector<std::string> emulatorStaticPaths;
|
||||||
std::string emulatorEntry;
|
std::string emulatorEntry;
|
||||||
size_t startPos{0};
|
size_t startPos {0};
|
||||||
size_t endPos{0};
|
size_t endPos {0};
|
||||||
|
|
||||||
if ((startPos = command.find("%EMULATOR_")) != std::string::npos) {
|
if ((startPos = command.find("%EMULATOR_")) != std::string::npos) {
|
||||||
endPos = command.find("%", startPos + 1);
|
endPos = command.find("%", startPos + 1);
|
||||||
|
@ -1256,7 +1256,7 @@ const std::string FileData::findEmulatorPath(std::string& command)
|
||||||
HKEY registryKey;
|
HKEY registryKey;
|
||||||
LSTATUS keyStatus = -1;
|
LSTATUS keyStatus = -1;
|
||||||
LSTATUS pathStatus = -1;
|
LSTATUS pathStatus = -1;
|
||||||
char registryPath[1024]{};
|
char registryPath[1024] {};
|
||||||
DWORD pathSize = 1024;
|
DWORD pathSize = 1024;
|
||||||
|
|
||||||
// First look in HKEY_CURRENT_USER.
|
// First look in HKEY_CURRENT_USER.
|
||||||
|
@ -1311,7 +1311,7 @@ const std::string FileData::findEmulatorPath(std::string& command)
|
||||||
HKEY registryKey;
|
HKEY registryKey;
|
||||||
LSTATUS keyStatus = -1;
|
LSTATUS keyStatus = -1;
|
||||||
LSTATUS pathStatus = -1;
|
LSTATUS pathStatus = -1;
|
||||||
char path[1024]{};
|
char path[1024] {};
|
||||||
DWORD pathSize = 1024;
|
DWORD pathSize = 1024;
|
||||||
|
|
||||||
// First look in HKEY_CURRENT_USER.
|
// First look in HKEY_CURRENT_USER.
|
||||||
|
|
|
@ -80,7 +80,7 @@ void MediaViewer::update(int deltaTime)
|
||||||
|
|
||||||
void MediaViewer::render(const glm::mat4& /*parentTrans*/)
|
void MediaViewer::render(const glm::mat4& /*parentTrans*/)
|
||||||
{
|
{
|
||||||
glm::mat4 trans{Renderer::getIdentity()};
|
glm::mat4 trans {Renderer::getIdentity()};
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
// Render a black background below the game media.
|
// Render a black background below the game media.
|
||||||
|
@ -92,7 +92,7 @@ void MediaViewer::render(const glm::mat4& /*parentTrans*/)
|
||||||
|
|
||||||
#if defined(USE_OPENGL_21)
|
#if defined(USE_OPENGL_21)
|
||||||
Renderer::shaderParameters videoParameters;
|
Renderer::shaderParameters videoParameters;
|
||||||
unsigned int shaders{0};
|
unsigned int shaders {0};
|
||||||
if (Settings::getInstance()->getBool("MediaViewerVideoScanlines"))
|
if (Settings::getInstance()->getBool("MediaViewerVideoScanlines"))
|
||||||
shaders = Renderer::SHADER_SCANLINES;
|
shaders = Renderer::SHADER_SCANLINES;
|
||||||
if (Settings::getInstance()->getBool("MediaViewerVideoBlur")) {
|
if (Settings::getInstance()->getBool("MediaViewerVideoBlur")) {
|
||||||
|
@ -118,7 +118,7 @@ void MediaViewer::render(const glm::mat4& /*parentTrans*/)
|
||||||
Renderer::shaderPostprocessing(shaders, videoParameters);
|
Renderer::shaderPostprocessing(shaders, videoParameters);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (mImage && mImage->hasImage() && mImage->getSize() != glm::vec2{}) {
|
else if (mImage && mImage->hasImage() && mImage->getSize() != glm::vec2 {}) {
|
||||||
mImage->render(trans);
|
mImage->render(trans);
|
||||||
|
|
||||||
#if defined(USE_OPENGL_21)
|
#if defined(USE_OPENGL_21)
|
||||||
|
|
|
@ -17,14 +17,14 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
MiximageGenerator::MiximageGenerator(FileData* game, std::string& resultMessage)
|
MiximageGenerator::MiximageGenerator(FileData* game, std::string& resultMessage)
|
||||||
: mGame{game}
|
: mGame {game}
|
||||||
, mResultMessage{resultMessage}
|
, mResultMessage {resultMessage}
|
||||||
, mWidth{1280}
|
, mWidth {1280}
|
||||||
, mHeight{960}
|
, mHeight {960}
|
||||||
, mMarquee{false}
|
, mMarquee {false}
|
||||||
, mBox3D{false}
|
, mBox3D {false}
|
||||||
, mCover{false}
|
, mCover {false}
|
||||||
, mPhysicalMedia{false}
|
, mPhysicalMedia {false}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1093,7 +1093,7 @@ SystemData* SystemData::getRandomSystem(const SystemData* currentSystem)
|
||||||
// Get a random number in range.
|
// Get a random number in range.
|
||||||
std::random_device randDev;
|
std::random_device randDev;
|
||||||
// Mersenne Twister pseudorandom number generator.
|
// Mersenne Twister pseudorandom number generator.
|
||||||
std::mt19937 engine{randDev()};
|
std::mt19937 engine {randDev()};
|
||||||
std::uniform_int_distribution<int> uniform_dist(0, total - 1);
|
std::uniform_int_distribution<int> uniform_dist(0, total - 1);
|
||||||
int target = uniform_dist(engine);
|
int target = uniform_dist(engine);
|
||||||
|
|
||||||
|
@ -1172,7 +1172,7 @@ FileData* SystemData::getRandomGame(const FileData* currentGame)
|
||||||
// Get a random number in range.
|
// Get a random number in range.
|
||||||
std::random_device randDev;
|
std::random_device randDev;
|
||||||
// Mersenne Twister pseudorandom number generator.
|
// Mersenne Twister pseudorandom number generator.
|
||||||
std::mt19937 engine{randDev()};
|
std::mt19937 engine {randDev()};
|
||||||
std::uniform_int_distribution<int> uniform_dist(0, total - 1);
|
std::uniform_int_distribution<int> uniform_dist(0, total - 1);
|
||||||
target = uniform_dist(engine);
|
target = uniform_dist(engine);
|
||||||
} while (currentGame && gameList.at(target) == currentGame);
|
} while (currentGame && gameList.at(target) == currentGame);
|
||||||
|
|
|
@ -242,7 +242,7 @@ void SystemScreensaver::renderScreensaver()
|
||||||
|
|
||||||
// Only render the video if the state requires it.
|
// Only render the video if the state requires it.
|
||||||
if (static_cast<int>(mState) >= STATE_FADE_IN_VIDEO) {
|
if (static_cast<int>(mState) >= STATE_FADE_IN_VIDEO) {
|
||||||
glm::mat4 trans{Renderer::getIdentity()};
|
glm::mat4 trans {Renderer::getIdentity()};
|
||||||
mVideoScreensaver->render(trans);
|
mVideoScreensaver->render(trans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,7 +256,7 @@ void SystemScreensaver::renderScreensaver()
|
||||||
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(255 - static_cast<unsigned char>(mOpacity * 255));
|
||||||
glm::mat4 trans{Renderer::getIdentity()};
|
glm::mat4 trans {Renderer::getIdentity()};
|
||||||
mImageScreensaver->render(trans);
|
mImageScreensaver->render(trans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -502,7 +502,7 @@ void SystemScreensaver::pickRandomImage(std::string& path)
|
||||||
// Get a random number in range.
|
// Get a random number in range.
|
||||||
std::random_device randDev;
|
std::random_device randDev;
|
||||||
// Mersenne Twister pseudorandom number generator.
|
// Mersenne Twister pseudorandom number generator.
|
||||||
std::mt19937 engine{randDev()};
|
std::mt19937 engine {randDev()};
|
||||||
std::uniform_int_distribution<int> uniform_dist(0,
|
std::uniform_int_distribution<int> uniform_dist(0,
|
||||||
static_cast<int>(mImageFiles.size()) - 1);
|
static_cast<int>(mImageFiles.size()) - 1);
|
||||||
index = uniform_dist(engine);
|
index = uniform_dist(engine);
|
||||||
|
@ -536,7 +536,7 @@ void SystemScreensaver::pickRandomVideo(std::string& path)
|
||||||
// Get a random number in range.
|
// Get a random number in range.
|
||||||
std::random_device randDev;
|
std::random_device randDev;
|
||||||
// Mersenne Twister pseudorandom number generator.
|
// Mersenne Twister pseudorandom number generator.
|
||||||
std::mt19937 engine{randDev()};
|
std::mt19937 engine {randDev()};
|
||||||
std::uniform_int_distribution<int> uniform_dist(0,
|
std::uniform_int_distribution<int> uniform_dist(0,
|
||||||
static_cast<int>(mVideoFiles.size()) - 1);
|
static_cast<int>(mVideoFiles.size()) - 1);
|
||||||
index = uniform_dist(engine);
|
index = uniform_dist(engine);
|
||||||
|
@ -564,7 +564,7 @@ void SystemScreensaver::pickRandomCustomImage(std::string& path)
|
||||||
// Get a random number in range.
|
// Get a random number in range.
|
||||||
std::random_device randDev;
|
std::random_device randDev;
|
||||||
// Mersenne Twister pseudorandom number generator.
|
// Mersenne Twister pseudorandom number generator.
|
||||||
std::mt19937 engine{randDev()};
|
std::mt19937 engine {randDev()};
|
||||||
std::uniform_int_distribution<int> uniform_dist(
|
std::uniform_int_distribution<int> uniform_dist(
|
||||||
0, static_cast<int>(mImageCustomFiles.size()) - 1);
|
0, static_cast<int>(mImageCustomFiles.size()) - 1);
|
||||||
index = uniform_dist(engine);
|
index = uniform_dist(engine);
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
#include "views/ViewController.h"
|
#include "views/ViewController.h"
|
||||||
|
|
||||||
GuiAlternativeEmulators::GuiAlternativeEmulators(Window* window)
|
GuiAlternativeEmulators::GuiAlternativeEmulators(Window* window)
|
||||||
: GuiComponent{window}
|
: GuiComponent {window}
|
||||||
, mMenu{window, "ALTERNATIVE EMULATORS"}
|
, mMenu {window, "ALTERNATIVE EMULATORS"}
|
||||||
, mHasSystems(false)
|
, mHasSystems(false)
|
||||||
{
|
{
|
||||||
addChild(&mMenu);
|
addChild(&mMenu);
|
||||||
|
@ -216,12 +216,12 @@ void GuiAlternativeEmulators::selectorWindow(SystemData* system)
|
||||||
else
|
else
|
||||||
width = systemTextWidth;
|
width = systemTextWidth;
|
||||||
|
|
||||||
s->setMenuSize(glm::vec2{width, s->getMenuSize().y});
|
s->setMenuSize(glm::vec2 {width, s->getMenuSize().y});
|
||||||
|
|
||||||
auto menuSize = s->getMenuSize();
|
auto menuSize = s->getMenuSize();
|
||||||
auto menuPos = s->getMenuPosition();
|
auto menuPos = s->getMenuPosition();
|
||||||
|
|
||||||
s->setMenuPosition(glm::vec3{(s->getSize().x - menuSize.x) / 2.0f, menuPos.y, menuPos.z});
|
s->setMenuPosition(glm::vec3 {(s->getSize().x - menuSize.x) / 2.0f, menuPos.y, menuPos.z});
|
||||||
|
|
||||||
mWindow->pushGui(s);
|
mWindow->pushGui(s);
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,7 +169,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
|
||||||
auto bracketThemeCollection = std::make_shared<ImageComponent>(mWindow);
|
auto bracketThemeCollection = std::make_shared<ImageComponent>(mWindow);
|
||||||
bracketThemeCollection->setImage(":/graphics/arrow.svg");
|
bracketThemeCollection->setImage(":/graphics/arrow.svg");
|
||||||
bracketThemeCollection->setResize(
|
bracketThemeCollection->setResize(
|
||||||
glm::vec2{0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
|
glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
|
||||||
row.addElement(themeCollection, true);
|
row.addElement(themeCollection, true);
|
||||||
row.addElement(bracketThemeCollection, false);
|
row.addElement(bracketThemeCollection, false);
|
||||||
row.makeAcceptInputHandler([this, unusedFolders] {
|
row.makeAcceptInputHandler([this, unusedFolders] {
|
||||||
|
@ -203,7 +203,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
|
||||||
auto bracketNewCollection = std::make_shared<ImageComponent>(mWindow);
|
auto bracketNewCollection = std::make_shared<ImageComponent>(mWindow);
|
||||||
bracketNewCollection->setImage(":/graphics/arrow.svg");
|
bracketNewCollection->setImage(":/graphics/arrow.svg");
|
||||||
bracketNewCollection->setResize(
|
bracketNewCollection->setResize(
|
||||||
glm::vec2{0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
|
glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
|
||||||
row.addElement(newCollection, true);
|
row.addElement(newCollection, true);
|
||||||
row.addElement(bracketNewCollection, false);
|
row.addElement(bracketNewCollection, false);
|
||||||
auto createCollectionCall = [this](const std::string& newVal) {
|
auto createCollectionCall = [this](const std::string& newVal) {
|
||||||
|
@ -239,7 +239,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
|
||||||
auto bracketDeleteCollection = std::make_shared<ImageComponent>(mWindow);
|
auto bracketDeleteCollection = std::make_shared<ImageComponent>(mWindow);
|
||||||
bracketDeleteCollection->setImage(":/graphics/arrow.svg");
|
bracketDeleteCollection->setImage(":/graphics/arrow.svg");
|
||||||
bracketDeleteCollection->setResize(
|
bracketDeleteCollection->setResize(
|
||||||
glm::vec2{0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
|
glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
|
||||||
row.addElement(deleteCollection, true);
|
row.addElement(deleteCollection, true);
|
||||||
row.addElement(bracketDeleteCollection, false);
|
row.addElement(bracketDeleteCollection, false);
|
||||||
row.makeAcceptInputHandler([this, customSystems] {
|
row.makeAcceptInputHandler([this, customSystems] {
|
||||||
|
@ -303,9 +303,9 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
|
||||||
ss->addRow(row);
|
ss->addRow(row);
|
||||||
}
|
}
|
||||||
// Make the menu slightly wider to fit the scroll indicators.
|
// Make the menu slightly wider to fit the scroll indicators.
|
||||||
glm::vec2 menuSize{ss->getMenuSize()};
|
glm::vec2 menuSize {ss->getMenuSize()};
|
||||||
glm::vec3 menuPos{ss->getMenuPosition()};
|
glm::vec3 menuPos {ss->getMenuPosition()};
|
||||||
ss->setMenuSize(glm::vec2{menuSize.x * 1.08f, menuSize.y});
|
ss->setMenuSize(glm::vec2 {menuSize.x * 1.08f, menuSize.y});
|
||||||
menuPos.x = static_cast<float>((Renderer::getScreenWidth()) - ss->getMenuSize().x) / 2.0f;
|
menuPos.x = static_cast<float>((Renderer::getScreenWidth()) - ss->getMenuSize().x) / 2.0f;
|
||||||
ss->setMenuPosition(menuPos);
|
ss->setMenuPosition(menuPos);
|
||||||
mWindow->pushGui(ss);
|
mWindow->pushGui(ss);
|
||||||
|
|
|
@ -116,7 +116,7 @@ void GuiGamelistFilter::addFiltersToMenu()
|
||||||
|
|
||||||
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
||||||
bracket->setImage(":/graphics/arrow.svg");
|
bracket->setImage(":/graphics/arrow.svg");
|
||||||
bracket->setResize(glm::vec2{0.0f, lbl->getFont()->getLetterHeight()});
|
bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()});
|
||||||
row.addElement(bracket, false);
|
row.addElement(bracket, false);
|
||||||
|
|
||||||
mTextFilterField->setValue(mFilterIndex->getTextFilter());
|
mTextFilterField->setValue(mFilterIndex->getTextFilter());
|
||||||
|
|
|
@ -33,7 +33,7 @@ GuiLaunchScreen::~GuiLaunchScreen()
|
||||||
|
|
||||||
void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
||||||
{
|
{
|
||||||
mGrid = new ComponentGrid(mWindow, glm::ivec2{3, 8});
|
mGrid = new ComponentGrid(mWindow, glm::ivec2 {3, 8});
|
||||||
addChild(mGrid);
|
addChild(mGrid);
|
||||||
|
|
||||||
mImagePath = game->getMarqueePath();
|
mImagePath = game->getMarqueePath();
|
||||||
|
@ -50,8 +50,8 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
||||||
const float gameNameFontSize = 0.073f;
|
const float gameNameFontSize = 0.073f;
|
||||||
|
|
||||||
// Spacer row.
|
// Spacer row.
|
||||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{1, 0}, false, false,
|
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {1, 0}, false, false,
|
||||||
glm::ivec2{1, 1});
|
glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Title.
|
// Title.
|
||||||
mTitle = std::make_shared<TextComponent>(
|
mTitle = std::make_shared<TextComponent>(
|
||||||
|
@ -59,19 +59,19 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
||||||
Font::get(static_cast<int>(
|
Font::get(static_cast<int>(
|
||||||
titleFontSize * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth()))),
|
titleFontSize * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth()))),
|
||||||
0x666666FF, ALIGN_CENTER);
|
0x666666FF, ALIGN_CENTER);
|
||||||
mGrid->setEntry(mTitle, glm::ivec2{1, 1}, false, true, glm::ivec2{1, 1});
|
mGrid->setEntry(mTitle, glm::ivec2 {1, 1}, false, true, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Spacer row.
|
// Spacer row.
|
||||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{1, 2}, false, false,
|
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {1, 2}, false, false,
|
||||||
glm::ivec2{1, 1});
|
glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Row for the marquee.
|
// Row for the marquee.
|
||||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{1, 3}, false, false,
|
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {1, 3}, false, false,
|
||||||
glm::ivec2{1, 1});
|
glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Spacer row.
|
// Spacer row.
|
||||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{1, 4}, false, false,
|
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {1, 4}, false, false,
|
||||||
glm::ivec2{1, 1});
|
glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Game name.
|
// Game name.
|
||||||
mGameName = std::make_shared<TextComponent>(
|
mGameName = std::make_shared<TextComponent>(
|
||||||
|
@ -79,24 +79,24 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
||||||
Font::get(static_cast<int>(
|
Font::get(static_cast<int>(
|
||||||
gameNameFontSize * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth()))),
|
gameNameFontSize * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth()))),
|
||||||
0x444444FF, ALIGN_CENTER);
|
0x444444FF, ALIGN_CENTER);
|
||||||
mGrid->setEntry(mGameName, glm::ivec2{1, 5}, false, true, glm::ivec2{1, 1});
|
mGrid->setEntry(mGameName, glm::ivec2 {1, 5}, false, true, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// System name.
|
// System name.
|
||||||
mSystemName = std::make_shared<TextComponent>(
|
mSystemName = std::make_shared<TextComponent>(
|
||||||
mWindow, "SYSTEM NAME", Font::get(FONT_SIZE_MEDIUM), 0x666666FF, ALIGN_CENTER);
|
mWindow, "SYSTEM NAME", Font::get(FONT_SIZE_MEDIUM), 0x666666FF, ALIGN_CENTER);
|
||||||
mGrid->setEntry(mSystemName, glm::ivec2{1, 6}, false, true, glm::ivec2{1, 1});
|
mGrid->setEntry(mSystemName, glm::ivec2 {1, 6}, false, true, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Spacer row.
|
// Spacer row.
|
||||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{1, 7}, false, false,
|
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {1, 7}, false, false,
|
||||||
glm::ivec2{1, 1});
|
glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Left spacer.
|
// Left spacer.
|
||||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{0, 0}, false, false,
|
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {0, 0}, false, false,
|
||||||
glm::ivec2{1, 8});
|
glm::ivec2 {1, 8});
|
||||||
|
|
||||||
// Right spacer.
|
// Right spacer.
|
||||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{2, 0}, false, false,
|
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {2, 0}, false, false,
|
||||||
glm::ivec2{1, 8});
|
glm::ivec2 {1, 8});
|
||||||
|
|
||||||
// Adjust the width depending on the aspect ratio of the screen, to make the screen look
|
// Adjust the width depending on the aspect ratio of the screen, to make the screen look
|
||||||
// somewhat coherent regardless of screen type. The 1.778 aspect ratio value is the 16:9
|
// somewhat coherent regardless of screen type. The 1.778 aspect ratio value is the 16:9
|
||||||
|
@ -168,7 +168,7 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
||||||
mGrid->getRowHeight(3));
|
mGrid->getRowHeight(3));
|
||||||
|
|
||||||
mMarquee->setOrigin(0.5f, 0.5f);
|
mMarquee->setOrigin(0.5f, 0.5f);
|
||||||
glm::vec3 currentPos{mMarquee->getPosition()};
|
glm::vec3 currentPos {mMarquee->getPosition()};
|
||||||
|
|
||||||
// Position the image in the middle of row four.
|
// Position the image in the middle of row four.
|
||||||
currentPos.x = mSize.x / 2.0f;
|
currentPos.x = mSize.x / 2.0f;
|
||||||
|
@ -183,7 +183,7 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
||||||
setPosition(static_cast<float>(Renderer::getScreenWidth()) / 2.0f,
|
setPosition(static_cast<float>(Renderer::getScreenWidth()) / 2.0f,
|
||||||
static_cast<float>(Renderer::getScreenHeight()) / 2.25f);
|
static_cast<float>(Renderer::getScreenHeight()) / 2.25f);
|
||||||
|
|
||||||
mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f});
|
||||||
mBackground.setEdgeColor(0xEEEEEEFF);
|
mBackground.setEdgeColor(0xEEEEEEFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,7 +225,7 @@ void GuiLaunchScreen::render(const glm::mat4& /*parentTrans*/)
|
||||||
// Scale up animation.
|
// Scale up animation.
|
||||||
setScale(mScaleUp);
|
setScale(mScaleUp);
|
||||||
|
|
||||||
glm::mat4 trans{Renderer::getIdentity() * getTransform()};
|
glm::mat4 trans {Renderer::getIdentity() * getTransform()};
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
GuiComponent::renderChildren(trans);
|
GuiComponent::renderChildren(trans);
|
||||||
|
|
|
@ -821,7 +821,7 @@ void GuiMenu::openOtherOptions()
|
||||||
auto bracketMediaDirectory = std::make_shared<ImageComponent>(mWindow);
|
auto bracketMediaDirectory = std::make_shared<ImageComponent>(mWindow);
|
||||||
bracketMediaDirectory->setImage(":/graphics/arrow.svg");
|
bracketMediaDirectory->setImage(":/graphics/arrow.svg");
|
||||||
bracketMediaDirectory->setResize(
|
bracketMediaDirectory->setResize(
|
||||||
glm::vec2{0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
|
glm::vec2 {0.0f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight()});
|
||||||
rowMediaDir.addElement(media_directory, true);
|
rowMediaDir.addElement(media_directory, true);
|
||||||
rowMediaDir.addElement(bracketMediaDirectory, false);
|
rowMediaDir.addElement(bracketMediaDirectory, false);
|
||||||
std::string titleMediaDir = "ENTER GAME MEDIA DIRECTORY";
|
std::string titleMediaDir = "ENTER GAME MEDIA DIRECTORY";
|
||||||
|
|
|
@ -41,20 +41,20 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
||||||
std::function<void()> saveCallback,
|
std::function<void()> saveCallback,
|
||||||
std::function<void()> clearGameFunc,
|
std::function<void()> clearGameFunc,
|
||||||
std::function<void()> deleteGameFunc)
|
std::function<void()> deleteGameFunc)
|
||||||
: GuiComponent{window}
|
: GuiComponent {window}
|
||||||
, mBackground{window, ":/graphics/frame.svg"}
|
, mBackground {window, ":/graphics/frame.svg"}
|
||||||
, mGrid{window, glm::ivec2{2, 6}}
|
, mGrid {window, glm::ivec2 {2, 6}}
|
||||||
, mScraperParams{scraperParams}
|
, mScraperParams {scraperParams}
|
||||||
, mControllerBadges{BadgeComponent::getGameControllers()}
|
, mControllerBadges {BadgeComponent::getGameControllers()}
|
||||||
, mMetaDataDecl{mdd}
|
, mMetaDataDecl {mdd}
|
||||||
, mMetaData{md}
|
, mMetaData {md}
|
||||||
, mSavedCallback{saveCallback}
|
, mSavedCallback {saveCallback}
|
||||||
, mClearGameFunc{clearGameFunc}
|
, mClearGameFunc {clearGameFunc}
|
||||||
, mDeleteGameFunc{deleteGameFunc}
|
, mDeleteGameFunc {deleteGameFunc}
|
||||||
, mIsCustomCollection{false}
|
, mIsCustomCollection {false}
|
||||||
, mMediaFilesUpdated{false}
|
, mMediaFilesUpdated {false}
|
||||||
, mSavedMediaAndAborted{false}
|
, mSavedMediaAndAborted {false}
|
||||||
, mInvalidEmulatorEntry{false}
|
, mInvalidEmulatorEntry {false}
|
||||||
{
|
{
|
||||||
if (ViewController::getInstance()->getState().getSystem()->isCustomCollection() ||
|
if (ViewController::getInstance()->getState().getSystem()->isCustomCollection() ||
|
||||||
ViewController::getInstance()->getState().getSystem()->getThemeFolder() ==
|
ViewController::getInstance()->getState().getSystem()->getThemeFolder() ==
|
||||||
|
@ -70,7 +70,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
||||||
|
|
||||||
mTitle = std::make_shared<TextComponent>(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE),
|
mTitle = std::make_shared<TextComponent>(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE),
|
||||||
0x555555FF, ALIGN_CENTER);
|
0x555555FF, ALIGN_CENTER);
|
||||||
mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{2, 2});
|
mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2});
|
||||||
|
|
||||||
// Extract possible subfolders from the path.
|
// Extract possible subfolders from the path.
|
||||||
std::string folderPath =
|
std::string folderPath =
|
||||||
|
@ -94,10 +94,10 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
||||||
(scraperParams.game->getType() == FOLDER ? " " + ViewController::FOLDER_CHAR : ""),
|
(scraperParams.game->getType() == FOLDER ? " " + ViewController::FOLDER_CHAR : ""),
|
||||||
Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER);
|
Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER);
|
||||||
|
|
||||||
mGrid.setEntry(mSubtitle, glm::ivec2{0, 2}, false, true, glm::ivec2{2, 1});
|
mGrid.setEntry(mSubtitle, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1});
|
||||||
|
|
||||||
mList = std::make_shared<ComponentList>(mWindow);
|
mList = std::make_shared<ComponentList>(mWindow);
|
||||||
mGrid.setEntry(mList, glm::ivec2{0, 4}, true, true, glm::ivec2{2, 1});
|
mGrid.setEntry(mList, glm::ivec2 {0, 4}, true, true, glm::ivec2 {2, 1});
|
||||||
|
|
||||||
// Set up scroll indicators.
|
// Set up scroll indicators.
|
||||||
mScrollUp = std::make_shared<ImageComponent>(mWindow);
|
mScrollUp = std::make_shared<ImageComponent>(mWindow);
|
||||||
|
@ -110,8 +110,8 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
||||||
mScrollDown->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f);
|
mScrollDown->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f);
|
||||||
mScrollDown->setOrigin(0.0f, 0.35f);
|
mScrollDown->setOrigin(0.0f, 0.35f);
|
||||||
|
|
||||||
mGrid.setEntry(mScrollUp, glm::ivec2{1, 0}, false, false, glm::ivec2{1, 1});
|
mGrid.setEntry(mScrollUp, glm::ivec2 {1, 0}, false, false, glm::ivec2 {1, 1});
|
||||||
mGrid.setEntry(mScrollDown, glm::ivec2{1, 1}, false, false, glm::ivec2{1, 1});
|
mGrid.setEntry(mScrollDown, glm::ivec2 {1, 1}, false, false, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Populate list.
|
// Populate list.
|
||||||
for (auto it = mdd.cbegin(); it != mdd.cend(); ++it) {
|
for (auto it = mdd.cbegin(); it != mdd.cend(); ++it) {
|
||||||
|
@ -152,7 +152,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
||||||
case MD_BOOL: {
|
case MD_BOOL: {
|
||||||
ed = std::make_shared<SwitchComponent>(window);
|
ed = std::make_shared<SwitchComponent>(window);
|
||||||
// Make the switches slightly smaller.
|
// Make the switches slightly smaller.
|
||||||
glm::vec2 switchSize{ed->getSize() * 0.9f};
|
glm::vec2 switchSize {ed->getSize() * 0.9f};
|
||||||
ed->setResize(ceilf(switchSize.x), switchSize.y);
|
ed->setResize(ceilf(switchSize.x), switchSize.y);
|
||||||
|
|
||||||
ed->setChangedColor(ICONCOLOR_USERMARKED);
|
ed->setChangedColor(ICONCOLOR_USERMARKED);
|
||||||
|
@ -202,7 +202,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
||||||
|
|
||||||
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
||||||
bracket->setImage(":/graphics/arrow.svg");
|
bracket->setImage(":/graphics/arrow.svg");
|
||||||
bracket->setResize(glm::vec2{0.0f, lbl->getFont()->getLetterHeight()});
|
bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()});
|
||||||
row.addElement(bracket, false);
|
row.addElement(bracket, false);
|
||||||
|
|
||||||
const std::string title = it->displayPrompt;
|
const std::string title = it->displayPrompt;
|
||||||
|
@ -265,9 +265,9 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
||||||
float maxWidth =
|
float maxWidth =
|
||||||
static_cast<float>(Renderer::getScreenWidth()) * maxWidthModifier;
|
static_cast<float>(Renderer::getScreenWidth()) * maxWidthModifier;
|
||||||
|
|
||||||
s->setMenuSize(glm::vec2{maxWidth, s->getMenuSize().y});
|
s->setMenuSize(glm::vec2 {maxWidth, s->getMenuSize().y});
|
||||||
s->setMenuPosition(
|
s->setMenuPosition(
|
||||||
glm::vec3{(s->getSize().x - maxWidth) / 2.0f, mPosition.y, mPosition.z});
|
glm::vec3 {(s->getSize().x - maxWidth) / 2.0f, mPosition.y, mPosition.z});
|
||||||
mWindow->pushGui(s);
|
mWindow->pushGui(s);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
@ -286,7 +286,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
||||||
|
|
||||||
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
||||||
bracket->setImage(":/graphics/arrow.svg");
|
bracket->setImage(":/graphics/arrow.svg");
|
||||||
bracket->setResize(glm::vec2{0.0f, lbl->getFont()->getLetterHeight()});
|
bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()});
|
||||||
row.addElement(bracket, false);
|
row.addElement(bracket, false);
|
||||||
|
|
||||||
const std::string title = it->displayPrompt;
|
const std::string title = it->displayPrompt;
|
||||||
|
@ -398,9 +398,9 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
||||||
float maxWidth =
|
float maxWidth =
|
||||||
static_cast<float>(Renderer::getScreenWidth()) * maxWidthModifier;
|
static_cast<float>(Renderer::getScreenWidth()) * maxWidthModifier;
|
||||||
|
|
||||||
s->setMenuSize(glm::vec2{maxWidth, s->getMenuSize().y});
|
s->setMenuSize(glm::vec2 {maxWidth, s->getMenuSize().y});
|
||||||
s->setMenuPosition(glm::vec3{(s->getSize().x - maxWidth) / 2.0f,
|
s->setMenuPosition(glm::vec3 {(s->getSize().x - maxWidth) / 2.0f,
|
||||||
mPosition.y, mPosition.z});
|
mPosition.y, mPosition.z});
|
||||||
mWindow->pushGui(s);
|
mWindow->pushGui(s);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -424,7 +424,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
||||||
|
|
||||||
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
||||||
bracket->setImage(":/graphics/arrow.svg");
|
bracket->setImage(":/graphics/arrow.svg");
|
||||||
bracket->setResize(glm::vec2{0.0f, lbl->getFont()->getLetterHeight()});
|
bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()});
|
||||||
row.addElement(bracket, false);
|
row.addElement(bracket, false);
|
||||||
|
|
||||||
bool multiLine = it->type == MD_MULTILINE_STRING;
|
bool multiLine = it->type == MD_MULTILINE_STRING;
|
||||||
|
@ -584,7 +584,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
||||||
}
|
}
|
||||||
|
|
||||||
mButtons = makeButtonGrid(mWindow, buttons);
|
mButtons = makeButtonGrid(mWindow, buttons);
|
||||||
mGrid.setEntry(mButtons, glm::ivec2{0, 5}, true, false, glm::ivec2{2, 1});
|
mGrid.setEntry(mButtons, glm::ivec2 {0, 5}, true, false, glm::ivec2 {2, 1});
|
||||||
|
|
||||||
// Resize + center.
|
// Resize + center.
|
||||||
float width =
|
float width =
|
||||||
|
@ -611,7 +611,7 @@ void GuiMetaDataEd::onSizeChanged()
|
||||||
mGrid.setColWidthPerc(1, 0.055f);
|
mGrid.setColWidthPerc(1, 0.055f);
|
||||||
|
|
||||||
mGrid.setSize(mSize);
|
mGrid.setSize(mSize);
|
||||||
mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f});
|
||||||
|
|
||||||
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,
|
setPosition((Renderer::getScreenWidth() - mSize.x) / 2.0f,
|
||||||
(Renderer::getScreenHeight() - mSize.y) / 2.0f);
|
(Renderer::getScreenHeight() - mSize.y) / 2.0f);
|
||||||
|
@ -629,10 +629,10 @@ void GuiMetaDataEd::save()
|
||||||
|
|
||||||
// We need this to handle the special situation where the user sets a game to hidden while
|
// We need this to handle the special situation where the user sets a game to hidden while
|
||||||
// ShowHiddenGames is set to false, meaning it will immediately disappear from the gamelist.
|
// ShowHiddenGames is set to false, meaning it will immediately disappear from the gamelist.
|
||||||
bool showHiddenGames{Settings::getInstance()->getBool("ShowHiddenGames")};
|
bool showHiddenGames {Settings::getInstance()->getBool("ShowHiddenGames")};
|
||||||
bool hideGameWhileHidden{false};
|
bool hideGameWhileHidden {false};
|
||||||
bool setGameAsCounted{false};
|
bool setGameAsCounted {false};
|
||||||
int offset{0};
|
int offset {0};
|
||||||
|
|
||||||
for (unsigned int i = 0; i < mEditors.size(); ++i) {
|
for (unsigned int i = 0; i < mEditors.size(); ++i) {
|
||||||
// The offset is needed to make the editor and metadata fields match up if we're
|
// The offset is needed to make the editor and metadata fields match up if we're
|
||||||
|
@ -644,7 +644,7 @@ void GuiMetaDataEd::save()
|
||||||
if (mMetaDataDecl.at(i + offset).isStatistic)
|
if (mMetaDataDecl.at(i + offset).isStatistic)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const std::string& key{mMetaDataDecl.at(i + offset).key};
|
const std::string& key {mMetaDataDecl.at(i + offset).key};
|
||||||
|
|
||||||
if (key == "altemulator" && mInvalidEmulatorEntry == true)
|
if (key == "altemulator" && mInvalidEmulatorEntry == true)
|
||||||
continue;
|
continue;
|
||||||
|
@ -756,10 +756,10 @@ void GuiMetaDataEd::fetch()
|
||||||
void GuiMetaDataEd::fetchDone(const ScraperSearchResult& result)
|
void GuiMetaDataEd::fetchDone(const ScraperSearchResult& result)
|
||||||
{
|
{
|
||||||
// Clone the mMetaData object.
|
// Clone the mMetaData object.
|
||||||
MetaDataList* metadata{new MetaDataList(*mMetaData)};
|
MetaDataList* metadata {new MetaDataList(*mMetaData)};
|
||||||
|
|
||||||
mMediaFilesUpdated = result.savedNewMedia;
|
mMediaFilesUpdated = result.savedNewMedia;
|
||||||
int offset{0};
|
int offset {0};
|
||||||
|
|
||||||
// Check if any values were manually changed before starting the scraping.
|
// Check if any values were manually changed before starting the scraping.
|
||||||
// If so, it's these values we should compare against when scraping, not
|
// If so, it's these values we should compare against when scraping, not
|
||||||
|
@ -768,7 +768,7 @@ void GuiMetaDataEd::fetchDone(const ScraperSearchResult& result)
|
||||||
if (mMetaDataDecl.at(i).key == "collectionsortname" && !mIsCustomCollection)
|
if (mMetaDataDecl.at(i).key == "collectionsortname" && !mIsCustomCollection)
|
||||||
offset = 1;
|
offset = 1;
|
||||||
|
|
||||||
const std::string& key{mMetaDataDecl.at(i + offset).key};
|
const std::string& key {mMetaDataDecl.at(i + offset).key};
|
||||||
|
|
||||||
if (metadata->get(key) != mEditors[i]->getValue())
|
if (metadata->get(key) != mEditors[i]->getValue())
|
||||||
metadata->set(key, mEditors[i]->getValue());
|
metadata->set(key, mEditors[i]->getValue());
|
||||||
|
@ -783,7 +783,7 @@ void GuiMetaDataEd::fetchDone(const ScraperSearchResult& result)
|
||||||
if (mMetaDataDecl.at(i).key == "collectionsortname" && !mIsCustomCollection)
|
if (mMetaDataDecl.at(i).key == "collectionsortname" && !mIsCustomCollection)
|
||||||
offset = 1;
|
offset = 1;
|
||||||
|
|
||||||
const std::string& key{mMetaDataDecl.at(i + offset).key};
|
const std::string& key {mMetaDataDecl.at(i + offset).key};
|
||||||
|
|
||||||
if (key == "controller" && metadata->get(key) != "") {
|
if (key == "controller" && metadata->get(key) != "") {
|
||||||
std::string displayName = BadgeComponent::getDisplayName(metadata->get(key));
|
std::string displayName = BadgeComponent::getDisplayName(metadata->get(key));
|
||||||
|
@ -808,20 +808,20 @@ void GuiMetaDataEd::fetchDone(const ScraperSearchResult& result)
|
||||||
void GuiMetaDataEd::close()
|
void GuiMetaDataEd::close()
|
||||||
{
|
{
|
||||||
// Find out if the user made any changes.
|
// Find out if the user made any changes.
|
||||||
bool metadataUpdated{false};
|
bool metadataUpdated {false};
|
||||||
int offset{0};
|
int offset {0};
|
||||||
|
|
||||||
for (unsigned int i = 0; i < mEditors.size(); ++i) {
|
for (unsigned int i = 0; i < mEditors.size(); ++i) {
|
||||||
if (mMetaDataDecl.at(i).key == "collectionsortname" && !mIsCustomCollection)
|
if (mMetaDataDecl.at(i).key == "collectionsortname" && !mIsCustomCollection)
|
||||||
offset = 1;
|
offset = 1;
|
||||||
|
|
||||||
const std::string& key{mMetaDataDecl.at(i + offset).key};
|
const std::string& key {mMetaDataDecl.at(i + offset).key};
|
||||||
|
|
||||||
if (key == "altemulator" && mInvalidEmulatorEntry == true)
|
if (key == "altemulator" && mInvalidEmulatorEntry == true)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
std::string mMetaDataValue{mMetaData->get(key)};
|
std::string mMetaDataValue {mMetaData->get(key)};
|
||||||
std::string mEditorsValue{mEditors.at(i)->getValue()};
|
std::string mEditorsValue {mEditors.at(i)->getValue()};
|
||||||
|
|
||||||
if (key == "controller" && mEditors.at(i)->getValue() != "") {
|
if (key == "controller" && mEditors.at(i)->getValue() != "") {
|
||||||
std::string shortName = BadgeComponent::getShortName(mEditors.at(i)->getValue());
|
std::string shortName = BadgeComponent::getShortName(mEditors.at(i)->getValue());
|
||||||
|
|
|
@ -17,7 +17,7 @@ GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue<FileDa
|
||||||
: GuiComponent(window)
|
: GuiComponent(window)
|
||||||
, mGameQueue(gameQueue)
|
, mGameQueue(gameQueue)
|
||||||
, mBackground(window, ":/graphics/frame.svg")
|
, mBackground(window, ":/graphics/frame.svg")
|
||||||
, mGrid(window, glm::ivec2{6, 13})
|
, mGrid(window, glm::ivec2 {6, 13})
|
||||||
{
|
{
|
||||||
addChild(&mBackground);
|
addChild(&mBackground);
|
||||||
addChild(&mGrid);
|
addChild(&mGrid);
|
||||||
|
@ -38,100 +38,100 @@ GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue<FileDa
|
||||||
// Header.
|
// Header.
|
||||||
mTitle = std::make_shared<TextComponent>(mWindow, "MIXIMAGE OFFLINE GENERATOR",
|
mTitle = std::make_shared<TextComponent>(mWindow, "MIXIMAGE OFFLINE GENERATOR",
|
||||||
Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER);
|
Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER);
|
||||||
mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{6, 1});
|
mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {6, 1});
|
||||||
|
|
||||||
mStatus = std::make_shared<TextComponent>(mWindow, "NOT STARTED", Font::get(FONT_SIZE_MEDIUM),
|
mStatus = std::make_shared<TextComponent>(mWindow, "NOT STARTED", Font::get(FONT_SIZE_MEDIUM),
|
||||||
0x777777FF, ALIGN_CENTER);
|
0x777777FF, ALIGN_CENTER);
|
||||||
mGrid.setEntry(mStatus, glm::ivec2{0, 1}, false, true, glm::ivec2{6, 1});
|
mGrid.setEntry(mStatus, glm::ivec2 {0, 1}, false, true, glm::ivec2 {6, 1});
|
||||||
|
|
||||||
mGameCounter = std::make_shared<TextComponent>(
|
mGameCounter = std::make_shared<TextComponent>(
|
||||||
mWindow,
|
mWindow,
|
||||||
std::to_string(mGamesProcessed) + " OF " + std::to_string(mTotalGames) +
|
std::to_string(mGamesProcessed) + " OF " + std::to_string(mTotalGames) +
|
||||||
(mTotalGames == 1 ? " GAME " : " GAMES ") + "PROCESSED",
|
(mTotalGames == 1 ? " GAME " : " GAMES ") + "PROCESSED",
|
||||||
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER);
|
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER);
|
||||||
mGrid.setEntry(mGameCounter, glm::ivec2{0, 2}, false, true, glm::ivec2{6, 1});
|
mGrid.setEntry(mGameCounter, glm::ivec2 {0, 2}, false, true, glm::ivec2 {6, 1});
|
||||||
|
|
||||||
// Spacer row with top border.
|
// Spacer row with top border.
|
||||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{0, 3}, false, false,
|
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {0, 3}, false, false,
|
||||||
glm::ivec2{6, 1}, GridFlags::BORDER_TOP);
|
glm::ivec2 {6, 1}, GridFlags::BORDER_TOP);
|
||||||
|
|
||||||
// Left spacer.
|
// Left spacer.
|
||||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{0, 4}, false, false,
|
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {0, 4}, false, false,
|
||||||
glm::ivec2{1, 7});
|
glm::ivec2 {1, 7});
|
||||||
|
|
||||||
// Generated label.
|
// Generated label.
|
||||||
mGeneratedLbl = std::make_shared<TextComponent>(
|
mGeneratedLbl = std::make_shared<TextComponent>(
|
||||||
mWindow, "Generated:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
mWindow, "Generated:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||||
mGrid.setEntry(mGeneratedLbl, glm::ivec2{1, 4}, false, true, glm::ivec2{1, 1});
|
mGrid.setEntry(mGeneratedLbl, glm::ivec2 {1, 4}, false, true, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Generated value/counter.
|
// Generated value/counter.
|
||||||
mGeneratedVal =
|
mGeneratedVal =
|
||||||
std::make_shared<TextComponent>(mWindow, std::to_string(mGamesProcessed),
|
std::make_shared<TextComponent>(mWindow, std::to_string(mGamesProcessed),
|
||||||
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||||
mGrid.setEntry(mGeneratedVal, glm::ivec2{2, 4}, false, true, glm::ivec2{1, 1});
|
mGrid.setEntry(mGeneratedVal, glm::ivec2 {2, 4}, false, true, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Overwritten label.
|
// Overwritten label.
|
||||||
mOverwrittenLbl = std::make_shared<TextComponent>(
|
mOverwrittenLbl = std::make_shared<TextComponent>(
|
||||||
mWindow, "Overwritten:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
mWindow, "Overwritten:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||||
mGrid.setEntry(mOverwrittenLbl, glm::ivec2{1, 5}, false, true, glm::ivec2{1, 1});
|
mGrid.setEntry(mOverwrittenLbl, glm::ivec2 {1, 5}, false, true, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Overwritten value/counter.
|
// Overwritten value/counter.
|
||||||
mOverwrittenVal =
|
mOverwrittenVal =
|
||||||
std::make_shared<TextComponent>(mWindow, std::to_string(mImagesOverwritten),
|
std::make_shared<TextComponent>(mWindow, std::to_string(mImagesOverwritten),
|
||||||
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||||
mGrid.setEntry(mOverwrittenVal, glm::ivec2{2, 5}, false, true, glm::ivec2{1, 1});
|
mGrid.setEntry(mOverwrittenVal, glm::ivec2 {2, 5}, false, true, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Skipping label.
|
// Skipping label.
|
||||||
mSkippedLbl = std::make_shared<TextComponent>(
|
mSkippedLbl = std::make_shared<TextComponent>(
|
||||||
mWindow, "Skipped (existing):", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
mWindow, "Skipped (existing):", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||||
mGrid.setEntry(mSkippedLbl, glm::ivec2{1, 6}, false, true, glm::ivec2{1, 1});
|
mGrid.setEntry(mSkippedLbl, glm::ivec2 {1, 6}, false, true, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Skipping value/counter.
|
// Skipping value/counter.
|
||||||
mSkippedVal = std::make_shared<TextComponent>(
|
mSkippedVal = std::make_shared<TextComponent>(
|
||||||
mWindow, std::to_string(mGamesSkipped), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
mWindow, std::to_string(mGamesSkipped), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||||
mGrid.setEntry(mSkippedVal, glm::ivec2{2, 6}, false, true, glm::ivec2{1, 1});
|
mGrid.setEntry(mSkippedVal, glm::ivec2 {2, 6}, false, true, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Failed label.
|
// Failed label.
|
||||||
mFailedLbl = std::make_shared<TextComponent>(mWindow, "Failed:", Font::get(FONT_SIZE_SMALL),
|
mFailedLbl = std::make_shared<TextComponent>(mWindow, "Failed:", Font::get(FONT_SIZE_SMALL),
|
||||||
0x888888FF, ALIGN_LEFT);
|
0x888888FF, ALIGN_LEFT);
|
||||||
mGrid.setEntry(mFailedLbl, glm::ivec2{1, 7}, false, true, glm::ivec2{1, 1});
|
mGrid.setEntry(mFailedLbl, glm::ivec2 {1, 7}, false, true, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Failed value/counter.
|
// Failed value/counter.
|
||||||
mFailedVal = std::make_shared<TextComponent>(
|
mFailedVal = std::make_shared<TextComponent>(
|
||||||
mWindow, std::to_string(mGamesFailed), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
mWindow, std::to_string(mGamesFailed), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||||
mGrid.setEntry(mFailedVal, glm::ivec2{2, 7}, false, true, glm::ivec2{1, 1});
|
mGrid.setEntry(mFailedVal, glm::ivec2 {2, 7}, false, true, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Processing label.
|
// Processing label.
|
||||||
mProcessingLbl = std::make_shared<TextComponent>(
|
mProcessingLbl = std::make_shared<TextComponent>(
|
||||||
mWindow, "Processing: ", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
mWindow, "Processing: ", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||||
mGrid.setEntry(mProcessingLbl, glm::ivec2{3, 4}, false, true, glm::ivec2{1, 1});
|
mGrid.setEntry(mProcessingLbl, glm::ivec2 {3, 4}, false, true, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Processing value.
|
// Processing value.
|
||||||
mProcessingVal = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_SMALL),
|
mProcessingVal = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_SMALL),
|
||||||
0x888888FF, ALIGN_LEFT);
|
0x888888FF, ALIGN_LEFT);
|
||||||
mGrid.setEntry(mProcessingVal, glm::ivec2{4, 4}, false, true, glm::ivec2{1, 1});
|
mGrid.setEntry(mProcessingVal, glm::ivec2 {4, 4}, false, true, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Spacer row.
|
// Spacer row.
|
||||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{1, 8}, false, false,
|
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {1, 8}, false, false,
|
||||||
glm::ivec2{4, 1});
|
glm::ivec2 {4, 1});
|
||||||
|
|
||||||
// Last error message label.
|
// Last error message label.
|
||||||
mLastErrorLbl = std::make_shared<TextComponent>(
|
mLastErrorLbl = std::make_shared<TextComponent>(
|
||||||
mWindow, "Last error message:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
mWindow, "Last error message:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||||
mGrid.setEntry(mLastErrorLbl, glm::ivec2{1, 9}, false, true, glm::ivec2{4, 1});
|
mGrid.setEntry(mLastErrorLbl, glm::ivec2 {1, 9}, false, true, glm::ivec2 {4, 1});
|
||||||
|
|
||||||
// Last error message value.
|
// Last error message value.
|
||||||
mLastErrorVal = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_SMALL),
|
mLastErrorVal = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_SMALL),
|
||||||
0x888888FF, ALIGN_LEFT);
|
0x888888FF, ALIGN_LEFT);
|
||||||
mGrid.setEntry(mLastErrorVal, glm::ivec2{1, 10}, false, true, glm::ivec2{4, 1});
|
mGrid.setEntry(mLastErrorVal, glm::ivec2 {1, 10}, false, true, glm::ivec2 {4, 1});
|
||||||
|
|
||||||
// Right spacer.
|
// Right spacer.
|
||||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{5, 4}, false, false,
|
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {5, 4}, false, false,
|
||||||
glm::ivec2{1, 7});
|
glm::ivec2 {1, 7});
|
||||||
|
|
||||||
// Spacer row with bottom border.
|
// Spacer row with bottom border.
|
||||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{0, 11}, false, false,
|
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {0, 11}, false, false,
|
||||||
glm::ivec2{6, 1}, GridFlags::BORDER_BOTTOM);
|
glm::ivec2 {6, 1}, GridFlags::BORDER_BOTTOM);
|
||||||
|
|
||||||
// Buttons.
|
// Buttons.
|
||||||
std::vector<std::shared_ptr<ButtonComponent>> buttons;
|
std::vector<std::shared_ptr<ButtonComponent>> buttons;
|
||||||
|
@ -177,7 +177,7 @@ GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue<FileDa
|
||||||
buttons.push_back(mCloseButton);
|
buttons.push_back(mCloseButton);
|
||||||
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
||||||
|
|
||||||
mGrid.setEntry(mButtonGrid, glm::ivec2{0, 12}, true, false, glm::ivec2{6, 1});
|
mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 12}, true, false, glm::ivec2 {6, 1});
|
||||||
|
|
||||||
// For narrower displays (e.g. in 4:3 ratio), allow the window to fill 95% of the screen
|
// For narrower displays (e.g. in 4:3 ratio), allow the window to fill 95% of the screen
|
||||||
// width rather than the 85% allowed for wider displays.
|
// width rather than the 85% allowed for wider displays.
|
||||||
|
@ -203,7 +203,7 @@ GuiOfflineGenerator::~GuiOfflineGenerator()
|
||||||
|
|
||||||
void GuiOfflineGenerator::onSizeChanged()
|
void GuiOfflineGenerator::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f});
|
||||||
|
|
||||||
// Set row heights.
|
// Set row heights.
|
||||||
mGrid.setRowHeightPerc(0, mTitle->getFont()->getLetterHeight() * 1.9725f / mSize.y, false);
|
mGrid.setRowHeightPerc(0, mTitle->getFont()->getLetterHeight() * 1.9725f / mSize.y, false);
|
||||||
|
|
|
@ -29,7 +29,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
|
||||||
bool approveResults)
|
bool approveResults)
|
||||||
: GuiComponent(window)
|
: GuiComponent(window)
|
||||||
, mBackground(window, ":/graphics/frame.svg")
|
, mBackground(window, ":/graphics/frame.svg")
|
||||||
, mGrid(window, glm::ivec2{2, 6})
|
, mGrid(window, glm::ivec2 {2, 6})
|
||||||
, mSearchQueue(searches)
|
, mSearchQueue(searches)
|
||||||
, mApproveResults(approveResults)
|
, mApproveResults(approveResults)
|
||||||
{
|
{
|
||||||
|
@ -48,15 +48,15 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
|
||||||
// Set up grid.
|
// Set up grid.
|
||||||
mTitle = std::make_shared<TextComponent>(mWindow, "SCRAPING IN PROGRESS",
|
mTitle = std::make_shared<TextComponent>(mWindow, "SCRAPING IN PROGRESS",
|
||||||
Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER);
|
Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER);
|
||||||
mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{2, 2});
|
mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2});
|
||||||
|
|
||||||
mSystem = std::make_shared<TextComponent>(mWindow, "SYSTEM", Font::get(FONT_SIZE_MEDIUM),
|
mSystem = std::make_shared<TextComponent>(mWindow, "SYSTEM", Font::get(FONT_SIZE_MEDIUM),
|
||||||
0x777777FF, ALIGN_CENTER);
|
0x777777FF, ALIGN_CENTER);
|
||||||
mGrid.setEntry(mSystem, glm::ivec2{0, 2}, false, true, glm::ivec2{2, 1});
|
mGrid.setEntry(mSystem, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1});
|
||||||
|
|
||||||
mSubtitle = std::make_shared<TextComponent>(
|
mSubtitle = std::make_shared<TextComponent>(
|
||||||
mWindow, "subtitle text", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER);
|
mWindow, "subtitle text", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER);
|
||||||
mGrid.setEntry(mSubtitle, glm::ivec2{0, 3}, false, true, glm::ivec2{2, 1});
|
mGrid.setEntry(mSubtitle, glm::ivec2 {0, 3}, false, true, glm::ivec2 {2, 1});
|
||||||
|
|
||||||
if (mApproveResults && !Settings::getInstance()->getBool("ScraperSemiautomatic"))
|
if (mApproveResults && !Settings::getInstance()->getBool("ScraperSemiautomatic"))
|
||||||
mSearchComp = std::make_shared<GuiScraperSearch>(
|
mSearchComp = std::make_shared<GuiScraperSearch>(
|
||||||
|
@ -77,9 +77,9 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
|
||||||
mResultList->resetScrollIndicatorStatus();
|
mResultList->resetScrollIndicatorStatus();
|
||||||
});
|
});
|
||||||
|
|
||||||
mGrid.setEntry(mSearchComp, glm::ivec2{0, 4},
|
mGrid.setEntry(mSearchComp, glm::ivec2 {0, 4},
|
||||||
mSearchComp->getSearchType() != GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT,
|
mSearchComp->getSearchType() != GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT,
|
||||||
true, glm::ivec2{2, 1});
|
true, glm::ivec2 {2, 1});
|
||||||
|
|
||||||
mResultList = mSearchComp->getResultList();
|
mResultList = mSearchComp->getResultList();
|
||||||
|
|
||||||
|
@ -95,8 +95,8 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
|
||||||
mScrollDown->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f);
|
mScrollDown->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f);
|
||||||
mScrollDown->setOrigin(0.0f, 0.35f);
|
mScrollDown->setOrigin(0.0f, 0.35f);
|
||||||
|
|
||||||
mGrid.setEntry(mScrollUp, glm::ivec2{1, 0}, false, false, glm::ivec2{1, 1});
|
mGrid.setEntry(mScrollUp, glm::ivec2 {1, 0}, false, false, glm::ivec2 {1, 1});
|
||||||
mGrid.setEntry(mScrollDown, glm::ivec2{1, 1}, false, false, glm::ivec2{1, 1});
|
mGrid.setEntry(mScrollDown, glm::ivec2 {1, 1}, false, false, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Buttons.
|
// Buttons.
|
||||||
std::vector<std::shared_ptr<ButtonComponent>> buttons;
|
std::vector<std::shared_ptr<ButtonComponent>> buttons;
|
||||||
|
@ -150,7 +150,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
|
||||||
std::bind(&GuiScraperMulti::finish, this)));
|
std::bind(&GuiScraperMulti::finish, this)));
|
||||||
|
|
||||||
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
||||||
mGrid.setEntry(mButtonGrid, glm::ivec2{0, 5}, true, false, glm::ivec2{2, 1});
|
mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 5}, true, false, glm::ivec2 {2, 1});
|
||||||
|
|
||||||
// Limit the width of the GUI on ultrawide monitors. The 1.778 aspect ratio value is
|
// Limit the width of the GUI on ultrawide monitors. The 1.778 aspect ratio value is
|
||||||
// the 16:9 reference.
|
// the 16:9 reference.
|
||||||
|
@ -206,7 +206,7 @@ void GuiScraperMulti::onSizeChanged()
|
||||||
mGrid.setColWidthPerc(1, 0.04f);
|
mGrid.setColWidthPerc(1, 0.04f);
|
||||||
|
|
||||||
mGrid.setSize(mSize);
|
mGrid.setSize(mSize);
|
||||||
mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f});
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiScraperMulti::doNextSearch()
|
void GuiScraperMulti::doNextSearch()
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int scrapeCount)
|
GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int scrapeCount)
|
||||||
: GuiComponent(window)
|
: GuiComponent(window)
|
||||||
, mGrid(window, glm::ivec2{5, 3})
|
, mGrid(window, glm::ivec2 {5, 3})
|
||||||
, mSearchType(type)
|
, mSearchType(type)
|
||||||
, mScrapeCount(scrapeCount)
|
, mScrapeCount(scrapeCount)
|
||||||
, mRefinedSearch(false)
|
, mRefinedSearch(false)
|
||||||
|
@ -55,8 +55,8 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int
|
||||||
mRetryCount = 0;
|
mRetryCount = 0;
|
||||||
|
|
||||||
// Left spacer (empty component, needed for borders).
|
// Left spacer (empty component, needed for borders).
|
||||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{0, 0}, false, false,
|
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {0, 0}, false, false,
|
||||||
glm::ivec2{1, 3}, GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM);
|
glm::ivec2 {1, 3}, GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM);
|
||||||
|
|
||||||
// Selected result name.
|
// Selected result name.
|
||||||
mResultName = std::make_shared<TextComponent>(mWindow, "Result name",
|
mResultName = std::make_shared<TextComponent>(mWindow, "Result name",
|
||||||
|
@ -64,7 +64,7 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int
|
||||||
|
|
||||||
// Selected result thumbnail.
|
// Selected result thumbnail.
|
||||||
mResultThumbnail = std::make_shared<ImageComponent>(mWindow);
|
mResultThumbnail = std::make_shared<ImageComponent>(mWindow);
|
||||||
mGrid.setEntry(mResultThumbnail, glm::ivec2{1, 1}, false, false, glm::ivec2{1, 1});
|
mGrid.setEntry(mResultThumbnail, glm::ivec2 {1, 1}, false, false, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Selected result description and container.
|
// Selected result description and container.
|
||||||
mDescContainer = std::make_shared<ScrollableContainer>(mWindow);
|
mDescContainer = std::make_shared<ScrollableContainer>(mWindow);
|
||||||
|
@ -91,7 +91,7 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int
|
||||||
mMD_Developer = std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT);
|
mMD_Developer = std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT);
|
||||||
mMD_Publisher = std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT);
|
mMD_Publisher = std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT);
|
||||||
mMD_Genre =
|
mMD_Genre =
|
||||||
std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT, glm::vec3{});
|
std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT, glm::vec3 {});
|
||||||
mMD_Players = std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT);
|
mMD_Players = std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT);
|
||||||
mMD_Filler = std::make_shared<TextComponent>(mWindow, "", font, mdColor);
|
mMD_Filler = std::make_shared<TextComponent>(mWindow, "", font, mdColor);
|
||||||
|
|
||||||
|
@ -121,15 +121,15 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int
|
||||||
std::make_shared<TextComponent>(mWindow, "", font, mdLblColor), mMD_Filler));
|
std::make_shared<TextComponent>(mWindow, "", font, mdLblColor), mMD_Filler));
|
||||||
|
|
||||||
mMD_Grid = std::make_shared<ComponentGrid>(
|
mMD_Grid = std::make_shared<ComponentGrid>(
|
||||||
mWindow, glm::ivec2{2, static_cast<int>(mMD_Pairs.size() * 2 - 1)});
|
mWindow, glm::ivec2 {2, static_cast<int>(mMD_Pairs.size() * 2 - 1)});
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
for (auto it = mMD_Pairs.cbegin(); it != mMD_Pairs.cend(); ++it) {
|
for (auto it = mMD_Pairs.cbegin(); it != mMD_Pairs.cend(); ++it) {
|
||||||
mMD_Grid->setEntry(it->first, glm::ivec2{0, i}, false, true);
|
mMD_Grid->setEntry(it->first, glm::ivec2 {0, i}, false, true);
|
||||||
mMD_Grid->setEntry(it->second, glm::ivec2{1, i}, false, it->resize);
|
mMD_Grid->setEntry(it->second, glm::ivec2 {1, i}, false, it->resize);
|
||||||
i += 2;
|
i += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
mGrid.setEntry(mMD_Grid, glm::ivec2{2, 1}, false, false);
|
mGrid.setEntry(mMD_Grid, glm::ivec2 {2, 1}, false, false);
|
||||||
|
|
||||||
// Result list.
|
// Result list.
|
||||||
mResultList = std::make_shared<ComponentList>(mWindow);
|
mResultList = std::make_shared<ComponentList>(mWindow);
|
||||||
|
@ -288,30 +288,30 @@ void GuiScraperSearch::updateViewStyle()
|
||||||
// Add them back depending on search type.
|
// Add them back depending on search type.
|
||||||
if (mSearchType == ALWAYS_ACCEPT_FIRST_RESULT) {
|
if (mSearchType == ALWAYS_ACCEPT_FIRST_RESULT) {
|
||||||
// Show name.
|
// Show name.
|
||||||
mGrid.setEntry(mResultName, glm::ivec2{1, 0}, false, false, glm::ivec2{3, 1},
|
mGrid.setEntry(mResultName, glm::ivec2 {1, 0}, false, false, glm::ivec2 {3, 1},
|
||||||
GridFlags::BORDER_TOP);
|
GridFlags::BORDER_TOP);
|
||||||
|
|
||||||
// Need a border on the bottom left.
|
// Need a border on the bottom left.
|
||||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{0, 2}, false, false,
|
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {0, 2}, false, false,
|
||||||
glm::ivec2{4, 1}, GridFlags::BORDER_BOTTOM);
|
glm::ivec2 {4, 1}, GridFlags::BORDER_BOTTOM);
|
||||||
|
|
||||||
// Show description on the right.
|
// Show description on the right.
|
||||||
mGrid.setEntry(mDescContainer, glm::ivec2{4, 0}, false, false, glm::ivec2{1, 3},
|
mGrid.setEntry(mDescContainer, glm::ivec2 {4, 0}, false, false, glm::ivec2 {1, 3},
|
||||||
GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM | GridFlags::BORDER_LEFT);
|
GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM | GridFlags::BORDER_LEFT);
|
||||||
// Make description text wrap at edge of container.
|
// Make description text wrap at edge of container.
|
||||||
mResultDesc->setSize(mDescContainer->getSize().x, 0.0f);
|
mResultDesc->setSize(mDescContainer->getSize().x, 0.0f);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Fake row where name would be.
|
// Fake row where name would be.
|
||||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{1, 0}, false, true,
|
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {1, 0}, false, true,
|
||||||
glm::ivec2{3, 1}, GridFlags::BORDER_TOP);
|
glm::ivec2 {3, 1}, GridFlags::BORDER_TOP);
|
||||||
|
|
||||||
// Show result list on the right.
|
// Show result list on the right.
|
||||||
mGrid.setEntry(mResultList, glm::ivec2{4, 0}, true, true, glm::ivec2{1, 3},
|
mGrid.setEntry(mResultList, glm::ivec2 {4, 0}, true, true, glm::ivec2 {1, 3},
|
||||||
GridFlags::BORDER_LEFT | GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM);
|
GridFlags::BORDER_LEFT | GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM);
|
||||||
|
|
||||||
// Show description under image/info.
|
// Show description under image/info.
|
||||||
mGrid.setEntry(mDescContainer, glm::ivec2{1, 2}, false, false, glm::ivec2{3, 1},
|
mGrid.setEntry(mDescContainer, glm::ivec2 {1, 2}, false, false, glm::ivec2 {3, 1},
|
||||||
GridFlags::BORDER_BOTTOM);
|
GridFlags::BORDER_BOTTOM);
|
||||||
// Make description text wrap at edge of container.
|
// Make description text wrap at edge of container.
|
||||||
mResultDesc->setSize(mDescContainer->getSize().x, 0);
|
mResultDesc->setSize(mDescContainer->getSize().x, 0);
|
||||||
|
@ -634,7 +634,7 @@ bool GuiScraperSearch::input(InputConfig* config, Input input)
|
||||||
|
|
||||||
void GuiScraperSearch::render(const glm::mat4& parentTrans)
|
void GuiScraperSearch::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
|
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
Renderer::drawRect(0.0f, 0.0f, mSize.x, mSize.y, 0x00000009, 0x00000009);
|
Renderer::drawRect(0.0f, 0.0f, mSize.x, mSize.y, 0x00000009, 0x00000009);
|
||||||
|
|
|
@ -24,7 +24,7 @@ GuiScraperSingle::GuiScraperSingle(Window* window,
|
||||||
bool& savedMediaAndAborted)
|
bool& savedMediaAndAborted)
|
||||||
: GuiComponent(window)
|
: GuiComponent(window)
|
||||||
, mClose(false)
|
, mClose(false)
|
||||||
, mGrid(window, glm::ivec2{2, 6})
|
, mGrid(window, glm::ivec2 {2, 6})
|
||||||
, mBox(window, ":/graphics/frame.svg")
|
, mBox(window, ":/graphics/frame.svg")
|
||||||
, mSearchParams(params)
|
, mSearchParams(params)
|
||||||
, mSavedMediaAndAborted(savedMediaAndAborted)
|
, mSavedMediaAndAborted(savedMediaAndAborted)
|
||||||
|
@ -53,18 +53,18 @@ GuiScraperSingle::GuiScraperSingle(Window* window,
|
||||||
((mSearchParams.game->getType() == FOLDER) ? " " + ViewController::FOLDER_CHAR : ""),
|
((mSearchParams.game->getType() == FOLDER) ? " " + ViewController::FOLDER_CHAR : ""),
|
||||||
Font::get(FONT_SIZE_LARGE), 0x777777FF, ALIGN_CENTER);
|
Font::get(FONT_SIZE_LARGE), 0x777777FF, ALIGN_CENTER);
|
||||||
mGameName->setColor(0x555555FF);
|
mGameName->setColor(0x555555FF);
|
||||||
mGrid.setEntry(mGameName, glm::ivec2{0, 0}, false, true, glm::ivec2{2, 2});
|
mGrid.setEntry(mGameName, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2});
|
||||||
|
|
||||||
mSystemName = std::make_shared<TextComponent>(
|
mSystemName = std::make_shared<TextComponent>(
|
||||||
mWindow, Utils::String::toUpper(mSearchParams.system->getFullName()),
|
mWindow, Utils::String::toUpper(mSearchParams.system->getFullName()),
|
||||||
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER);
|
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER);
|
||||||
mGrid.setEntry(mSystemName, glm::ivec2{0, 2}, false, true, glm::ivec2{2, 1});
|
mGrid.setEntry(mSystemName, glm::ivec2 {0, 2}, false, true, glm::ivec2 {2, 1});
|
||||||
|
|
||||||
// Row 3 is a spacer.
|
// Row 3 is a spacer.
|
||||||
|
|
||||||
// GuiScraperSearch.
|
// GuiScraperSearch.
|
||||||
mSearch = std::make_shared<GuiScraperSearch>(window, GuiScraperSearch::NEVER_AUTO_ACCEPT, 1);
|
mSearch = std::make_shared<GuiScraperSearch>(window, GuiScraperSearch::NEVER_AUTO_ACCEPT, 1);
|
||||||
mGrid.setEntry(mSearch, glm::ivec2{0, 4}, true, true, glm::ivec2{2, 1});
|
mGrid.setEntry(mSearch, glm::ivec2 {0, 4}, true, true, glm::ivec2 {2, 1});
|
||||||
|
|
||||||
mResultList = mSearch->getResultList();
|
mResultList = mSearch->getResultList();
|
||||||
|
|
||||||
|
@ -80,8 +80,8 @@ GuiScraperSingle::GuiScraperSingle(Window* window,
|
||||||
mScrollDown->setResize(0.0f, mGameName->getFont()->getLetterHeight() / 2.0f);
|
mScrollDown->setResize(0.0f, mGameName->getFont()->getLetterHeight() / 2.0f);
|
||||||
mScrollDown->setOrigin(0.0f, 0.35f);
|
mScrollDown->setOrigin(0.0f, 0.35f);
|
||||||
|
|
||||||
mGrid.setEntry(mScrollUp, glm::ivec2{1, 0}, false, false, glm::ivec2{1, 1});
|
mGrid.setEntry(mScrollUp, glm::ivec2 {1, 0}, false, false, glm::ivec2 {1, 1});
|
||||||
mGrid.setEntry(mScrollDown, glm::ivec2{1, 1}, false, false, glm::ivec2{1, 1});
|
mGrid.setEntry(mScrollDown, glm::ivec2 {1, 1}, false, false, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
// Buttons
|
// Buttons
|
||||||
std::vector<std::shared_ptr<ButtonComponent>> buttons;
|
std::vector<std::shared_ptr<ButtonComponent>> buttons;
|
||||||
|
@ -109,7 +109,7 @@ GuiScraperSingle::GuiScraperSingle(Window* window,
|
||||||
}));
|
}));
|
||||||
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
||||||
|
|
||||||
mGrid.setEntry(mButtonGrid, glm::ivec2{0, 5}, true, false, glm::ivec2{2, 1});
|
mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 5}, true, false, glm::ivec2 {2, 1});
|
||||||
|
|
||||||
mSearch->setAcceptCallback([this, doneFunc](const ScraperSearchResult& result) {
|
mSearch->setAcceptCallback([this, doneFunc](const ScraperSearchResult& result) {
|
||||||
doneFunc(result);
|
doneFunc(result);
|
||||||
|
@ -156,7 +156,7 @@ void GuiScraperSingle::onSizeChanged()
|
||||||
mGrid.setColWidthPerc(1, 0.04f);
|
mGrid.setColWidthPerc(1, 0.04f);
|
||||||
|
|
||||||
mGrid.setSize(glm::round(mSize));
|
mGrid.setSize(glm::round(mSize));
|
||||||
mBox.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
mBox.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f});
|
||||||
|
|
||||||
// Add some extra margins to the game name.
|
// Add some extra margins to the game name.
|
||||||
const float newSizeX = mSize.x * 0.96f;
|
const float newSizeX = mSize.x * 0.96f;
|
||||||
|
|
|
@ -171,7 +171,7 @@ void GuiSettings::addEditableTextComponent(const std::string label,
|
||||||
|
|
||||||
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
||||||
bracket->setImage(":/graphics/arrow.svg");
|
bracket->setImage(":/graphics/arrow.svg");
|
||||||
bracket->setResize(glm::vec2{0.0f, lbl->getFont()->getLetterHeight()});
|
bracket->setResize(glm::vec2 {0.0f, lbl->getFont()->getLetterHeight()});
|
||||||
row.addElement(bracket, false);
|
row.addElement(bracket, false);
|
||||||
|
|
||||||
// OK callback (apply new value to ed).
|
// OK callback (apply new value to ed).
|
||||||
|
|
|
@ -56,12 +56,12 @@
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
SDL_Event event{};
|
SDL_Event event {};
|
||||||
Window* window{nullptr};
|
Window* window {nullptr};
|
||||||
int lastTime{0};
|
int lastTime {0};
|
||||||
|
|
||||||
bool forceInputConfig{false};
|
bool forceInputConfig {false};
|
||||||
bool settingsNeedSaving{false};
|
bool settingsNeedSaving {false};
|
||||||
|
|
||||||
enum loadSystemsReturnCode {
|
enum loadSystemsReturnCode {
|
||||||
LOADING_OK, // Replace with AllowShortEnumsOnASingleLine: false (clang-format >=11.0).
|
LOADING_OK, // Replace with AllowShortEnumsOnASingleLine: false (clang-format >=11.0).
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace
|
||||||
{
|
{
|
||||||
TheGamesDBJSONRequestResources resources;
|
TheGamesDBJSONRequestResources resources;
|
||||||
|
|
||||||
const std::map<PlatformId, std::string> gamesdb_new_platformid_map{
|
const std::map<PlatformId, std::string> gamesdb_new_platformid_map {
|
||||||
{THREEDO, "25"},
|
{THREEDO, "25"},
|
||||||
{COMMODORE_AMIGA, "4911"},
|
{COMMODORE_AMIGA, "4911"},
|
||||||
{COMMODORE_AMIGA_CD32, "4947"},
|
{COMMODORE_AMIGA_CD32, "4947"},
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
const std::map<std::string, generate_scraper_requests_func> scraper_request_funcs{
|
const std::map<std::string, generate_scraper_requests_func> scraper_request_funcs {
|
||||||
{"thegamesdb", &thegamesdb_generate_json_scraper_requests},
|
{"thegamesdb", &thegamesdb_generate_json_scraper_requests},
|
||||||
{"screenscraper", &screenscraper_generate_scraper_requests}};
|
{"screenscraper", &screenscraper_generate_scraper_requests}};
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,11 +43,11 @@ struct ScraperSearchParams {
|
||||||
struct ScraperSearchResult {
|
struct ScraperSearchResult {
|
||||||
ScraperSearchResult()
|
ScraperSearchResult()
|
||||||
: mdl(GAME_METADATA)
|
: mdl(GAME_METADATA)
|
||||||
, scraperRequestAllowance{0}
|
, scraperRequestAllowance {0}
|
||||||
, mediaURLFetch{NOT_STARTED}
|
, mediaURLFetch {NOT_STARTED}
|
||||||
, thumbnailDownloadStatus{NOT_STARTED}
|
, thumbnailDownloadStatus {NOT_STARTED}
|
||||||
, mediaFilesDownloadStatus{NOT_STARTED}
|
, mediaFilesDownloadStatus {NOT_STARTED}
|
||||||
, savedNewMedia{false}
|
, savedNewMedia {false}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace
|
||||||
{
|
{
|
||||||
// List of systems and their IDs from:
|
// List of systems and their IDs from:
|
||||||
// https://www.screenscraper.fr/api/systemesListe.php?devid=xxx&devpassword=yyy&softname=zzz&output=XML
|
// https://www.screenscraper.fr/api/systemesListe.php?devid=xxx&devpassword=yyy&softname=zzz&output=XML
|
||||||
const std::map<PlatformId, unsigned short> screenscraper_platformid_map{
|
const std::map<PlatformId, unsigned short> screenscraper_platformid_map {
|
||||||
{THREEDO, 29},
|
{THREEDO, 29},
|
||||||
{COMMODORE_AMIGA, 64},
|
{COMMODORE_AMIGA, 64},
|
||||||
{COMMODORE_AMIGA_CD32, 130},
|
{COMMODORE_AMIGA_CD32, 130},
|
||||||
|
@ -611,7 +611,7 @@ void ScreenScraperRequest::processMedia(ScraperSearchResult& result,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Region fallback: WOR(LD), US, CUS(TOM?), JP, EU.
|
// Region fallback: WOR(LD), US, CUS(TOM?), JP, EU.
|
||||||
for (auto _region : std::vector<std::string>{region, "wor", "us", "cus", "jp", "eu"}) {
|
for (auto _region : std::vector<std::string> {region, "wor", "us", "cus", "jp", "eu"}) {
|
||||||
if (art)
|
if (art)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -91,8 +91,8 @@ void SystemView::populate()
|
||||||
// No logo available? Make placeholder.
|
// No logo available? Make placeholder.
|
||||||
if (!e.data.logo) {
|
if (!e.data.logo) {
|
||||||
|
|
||||||
glm::vec2 resolution = glm::vec2{static_cast<float>(Renderer::getScreenWidth()),
|
glm::vec2 resolution = glm::vec2 {static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight())};
|
static_cast<float>(Renderer::getScreenHeight())};
|
||||||
glm::vec3 center = {resolution.x / 2.0f, resolution.y / 2.0f, 1.0f};
|
glm::vec3 center = {resolution.x / 2.0f, resolution.y / 2.0f, 1.0f};
|
||||||
|
|
||||||
// Placeholder Image.
|
// Placeholder Image.
|
||||||
|
@ -182,7 +182,7 @@ void SystemView::populate()
|
||||||
e.data.logo->setOrigin(0.5, 0.5);
|
e.data.logo->setOrigin(0.5, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 denormalized{mCarousel.logoSize * e.data.logo->getOrigin()};
|
glm::vec2 denormalized {mCarousel.logoSize * e.data.logo->getOrigin()};
|
||||||
glm::vec3 v = {denormalized.x, denormalized.y, 0.0f};
|
glm::vec3 v = {denormalized.x, denormalized.y, 0.0f};
|
||||||
e.data.logo->setPosition(v + offsetLogo);
|
e.data.logo->setPosition(v + offsetLogo);
|
||||||
if (e.data.logoPlaceholderText)
|
if (e.data.logoPlaceholderText)
|
||||||
|
@ -462,7 +462,7 @@ void SystemView::render(const glm::mat4& parentTrans)
|
||||||
if (size() == 0)
|
if (size() == 0)
|
||||||
return; // Nothing to render.
|
return; // Nothing to render.
|
||||||
|
|
||||||
glm::mat4 trans{getTransform() * parentTrans};
|
glm::mat4 trans {getTransform() * parentTrans};
|
||||||
|
|
||||||
if (mCarousel.legacyZIndexMode) {
|
if (mCarousel.legacyZIndexMode) {
|
||||||
// Render all extras.
|
// Render all extras.
|
||||||
|
@ -555,18 +555,18 @@ void SystemView::getViewElements(const std::shared_ptr<ThemeData>& theme)
|
||||||
void SystemView::renderCarousel(const glm::mat4& trans)
|
void SystemView::renderCarousel(const glm::mat4& trans)
|
||||||
{
|
{
|
||||||
// Background box behind logos.
|
// Background box behind logos.
|
||||||
glm::mat4 carouselTrans{trans};
|
glm::mat4 carouselTrans {trans};
|
||||||
carouselTrans =
|
carouselTrans =
|
||||||
glm::translate(carouselTrans, glm::vec3{mCarousel.pos.x, mCarousel.pos.y, 0.0f});
|
glm::translate(carouselTrans, glm::vec3 {mCarousel.pos.x, mCarousel.pos.y, 0.0f});
|
||||||
carouselTrans = glm::translate(carouselTrans,
|
carouselTrans = glm::translate(carouselTrans,
|
||||||
glm::vec3{mCarousel.origin.x * mCarousel.size.x * -1.0f,
|
glm::vec3 {mCarousel.origin.x * mCarousel.size.x * -1.0f,
|
||||||
mCarousel.origin.y * mCarousel.size.y * -1.0f, 0.0f});
|
mCarousel.origin.y * mCarousel.size.y * -1.0f, 0.0f});
|
||||||
|
|
||||||
glm::vec2 clipPos{carouselTrans[3].x, carouselTrans[3].y};
|
glm::vec2 clipPos {carouselTrans[3].x, carouselTrans[3].y};
|
||||||
Renderer::pushClipRect(glm::ivec2{static_cast<int>(std::round(clipPos.x)),
|
Renderer::pushClipRect(glm::ivec2 {static_cast<int>(std::round(clipPos.x)),
|
||||||
static_cast<int>(std::round(clipPos.y))},
|
static_cast<int>(std::round(clipPos.y))},
|
||||||
glm::ivec2{static_cast<int>(std::round(mCarousel.size.x)),
|
glm::ivec2 {static_cast<int>(std::round(mCarousel.size.x)),
|
||||||
static_cast<int>(std::round(mCarousel.size.y))});
|
static_cast<int>(std::round(mCarousel.size.y))});
|
||||||
|
|
||||||
Renderer::setMatrix(carouselTrans);
|
Renderer::setMatrix(carouselTrans);
|
||||||
Renderer::drawRect(0.0f, 0.0f, mCarousel.size.x, mCarousel.size.y, mCarousel.color,
|
Renderer::drawRect(0.0f, 0.0f, mCarousel.size.x, mCarousel.size.y, mCarousel.color,
|
||||||
|
@ -574,7 +574,7 @@ void SystemView::renderCarousel(const glm::mat4& trans)
|
||||||
|
|
||||||
// Draw logos.
|
// Draw logos.
|
||||||
// Note: logoSpacing will also include the size of the logo itself.
|
// Note: logoSpacing will also include the size of the logo itself.
|
||||||
glm::vec2 logoSpacing{};
|
glm::vec2 logoSpacing {};
|
||||||
float xOff = 0.0f;
|
float xOff = 0.0f;
|
||||||
float yOff = 0.0f;
|
float yOff = 0.0f;
|
||||||
|
|
||||||
|
@ -652,9 +652,9 @@ void SystemView::renderCarousel(const glm::mat4& trans)
|
||||||
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 logoTrans {carouselTrans};
|
||||||
logoTrans = glm::translate(
|
logoTrans = glm::translate(
|
||||||
logoTrans, glm::vec3{i * logoSpacing.x + xOff, i * logoSpacing.y + yOff, 0.0f});
|
logoTrans, glm::vec3 {i * logoSpacing.x + xOff, i * logoSpacing.y + yOff, 0.0f});
|
||||||
|
|
||||||
float distance = i - mCamOffset;
|
float distance = i - mCamOffset;
|
||||||
|
|
||||||
|
@ -703,10 +703,10 @@ void SystemView::renderExtras(const glm::mat4& trans, float lower, float upper)
|
||||||
int extrasCenter = static_cast<int>(mExtrasCamOffset);
|
int extrasCenter = static_cast<int>(mExtrasCamOffset);
|
||||||
|
|
||||||
// Adding texture loading buffers depending on scrolling speed and status.
|
// Adding texture loading buffers depending on scrolling speed and status.
|
||||||
int bufferIndex{getScrollingVelocity() + 1};
|
int bufferIndex {getScrollingVelocity() + 1};
|
||||||
|
|
||||||
Renderer::pushClipRect(glm::ivec2{},
|
Renderer::pushClipRect(glm::ivec2 {},
|
||||||
glm::ivec2{static_cast<int>(mSize.x), static_cast<int>(mSize.y)});
|
glm::ivec2 {static_cast<int>(mSize.x), static_cast<int>(mSize.y)});
|
||||||
|
|
||||||
for (int i = extrasCenter + logoBuffersLeft[bufferIndex];
|
for (int i = extrasCenter + logoBuffersLeft[bufferIndex];
|
||||||
i <= extrasCenter + logoBuffersRight[bufferIndex]; ++i) {
|
i <= extrasCenter + logoBuffersRight[bufferIndex]; ++i) {
|
||||||
|
@ -718,17 +718,17 @@ void SystemView::renderExtras(const glm::mat4& trans, float lower, float upper)
|
||||||
|
|
||||||
// Only render selected system when not showing.
|
// Only render selected system when not showing.
|
||||||
if (mShowing || index == mCursor) {
|
if (mShowing || index == mCursor) {
|
||||||
glm::mat4 extrasTrans{trans};
|
glm::mat4 extrasTrans {trans};
|
||||||
if (mCarousel.type == HORIZONTAL || mCarousel.type == HORIZONTAL_WHEEL)
|
if (mCarousel.type == HORIZONTAL || mCarousel.type == HORIZONTAL_WHEEL)
|
||||||
extrasTrans = glm::translate(
|
extrasTrans = glm::translate(
|
||||||
extrasTrans, glm::vec3{(i - mExtrasCamOffset) * mSize.x, 0.0f, 0.0f});
|
extrasTrans, glm::vec3 {(i - mExtrasCamOffset) * mSize.x, 0.0f, 0.0f});
|
||||||
else
|
else
|
||||||
extrasTrans = glm::translate(
|
extrasTrans = glm::translate(
|
||||||
extrasTrans, glm::vec3{0.0f, (i - mExtrasCamOffset) * mSize.y, 0.0f});
|
extrasTrans, glm::vec3 {0.0f, (i - mExtrasCamOffset) * mSize.y, 0.0f});
|
||||||
|
|
||||||
Renderer::pushClipRect(
|
Renderer::pushClipRect(
|
||||||
glm::ivec2{static_cast<int>(extrasTrans[3].x), static_cast<int>(extrasTrans[3].y)},
|
glm::ivec2 {static_cast<int>(extrasTrans[3].x), static_cast<int>(extrasTrans[3].y)},
|
||||||
glm::ivec2{static_cast<int>(mSize.x), static_cast<int>(mSize.y)});
|
glm::ivec2 {static_cast<int>(mSize.x), static_cast<int>(mSize.y)});
|
||||||
SystemViewData data = mEntries.at(index).data;
|
SystemViewData data = mEntries.at(index).data;
|
||||||
for (unsigned int j = 0; j < data.backgroundExtras.size(); ++j) {
|
for (unsigned int j = 0; j < data.backgroundExtras.size(); ++j) {
|
||||||
GuiComponent* extra = data.backgroundExtras[j];
|
GuiComponent* extra = data.backgroundExtras[j];
|
||||||
|
|
|
@ -333,7 +333,7 @@ int ViewController::getSystemId(SystemData* system)
|
||||||
void ViewController::restoreViewPosition()
|
void ViewController::restoreViewPosition()
|
||||||
{
|
{
|
||||||
if (mPreviousView) {
|
if (mPreviousView) {
|
||||||
glm::vec3 restorePosition{mPreviousView->getPosition()};
|
glm::vec3 restorePosition {mPreviousView->getPosition()};
|
||||||
restorePosition.x = mWrapPreviousPositionX;
|
restorePosition.x = mWrapPreviousPositionX;
|
||||||
mPreviousView->setPosition(restorePosition);
|
mPreviousView->setPosition(restorePosition);
|
||||||
mWrapPreviousPositionX = 0;
|
mWrapPreviousPositionX = 0;
|
||||||
|
@ -514,9 +514,9 @@ void ViewController::goToGamelist(SystemData* system)
|
||||||
// movements will be correct. This is accomplished by simply offsetting the X position
|
// movements will be correct. This is accomplished by simply offsetting the X position
|
||||||
// with the position of the first or last system plus the screen width.
|
// with the position of the first or last system plus the screen width.
|
||||||
if (wrapFirstToLast) {
|
if (wrapFirstToLast) {
|
||||||
glm::vec3 currentPosition{mCurrentView->getPosition()};
|
glm::vec3 currentPosition {mCurrentView->getPosition()};
|
||||||
mWrapPreviousPositionX = currentPosition.x;
|
mWrapPreviousPositionX = currentPosition.x;
|
||||||
float offsetX{getGamelistView(system)->getPosition().x};
|
float offsetX {getGamelistView(system)->getPosition().x};
|
||||||
// This is needed to move the camera in the correct direction if there are only two systems.
|
// This is needed to move the camera in the correct direction if there are only two systems.
|
||||||
if (SystemData::sSystemVector.size() == 2 && mNextSystem)
|
if (SystemData::sSystemVector.size() == 2 && mNextSystem)
|
||||||
offsetX -= Renderer::getScreenWidth();
|
offsetX -= Renderer::getScreenWidth();
|
||||||
|
@ -528,9 +528,9 @@ void ViewController::goToGamelist(SystemData* system)
|
||||||
mWrappedViews = true;
|
mWrappedViews = true;
|
||||||
}
|
}
|
||||||
else if (wrapLastToFirst) {
|
else if (wrapLastToFirst) {
|
||||||
glm::vec3 currentPosition{mCurrentView->getPosition()};
|
glm::vec3 currentPosition {mCurrentView->getPosition()};
|
||||||
mWrapPreviousPositionX = currentPosition.x;
|
mWrapPreviousPositionX = currentPosition.x;
|
||||||
float offsetX{getGamelistView(system)->getPosition().x};
|
float offsetX {getGamelistView(system)->getPosition().x};
|
||||||
if (SystemData::sSystemVector.size() == 2 && !mNextSystem)
|
if (SystemData::sSystemVector.size() == 2 && !mNextSystem)
|
||||||
offsetX += Renderer::getScreenWidth();
|
offsetX += Renderer::getScreenWidth();
|
||||||
else
|
else
|
||||||
|
@ -584,7 +584,7 @@ void ViewController::playViewTransition(bool instant)
|
||||||
{
|
{
|
||||||
mCancelledTransition = false;
|
mCancelledTransition = false;
|
||||||
|
|
||||||
glm::vec3 target{};
|
glm::vec3 target {};
|
||||||
if (mCurrentView)
|
if (mCurrentView)
|
||||||
target = mCurrentView->getPosition();
|
target = mCurrentView->getPosition();
|
||||||
|
|
||||||
|
@ -593,7 +593,7 @@ void ViewController::playViewTransition(bool instant)
|
||||||
if (target == static_cast<glm::vec3>(-mCamera[3]) && !isAnimationPlaying(0))
|
if (target == static_cast<glm::vec3>(-mCamera[3]) && !isAnimationPlaying(0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::string transition_style{Settings::getInstance()->getString("TransitionStyle")};
|
std::string transition_style {Settings::getInstance()->getString("TransitionStyle")};
|
||||||
|
|
||||||
if (instant || transition_style == "instant") {
|
if (instant || transition_style == "instant") {
|
||||||
setAnimation(new LambdaAnimation(
|
setAnimation(new LambdaAnimation(
|
||||||
|
@ -906,14 +906,14 @@ void ViewController::update(int deltaTime)
|
||||||
|
|
||||||
void ViewController::render(const glm::mat4& parentTrans)
|
void ViewController::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
glm::mat4 trans{mCamera * parentTrans};
|
glm::mat4 trans {mCamera * parentTrans};
|
||||||
glm::mat4 transInverse{glm::inverse(trans)};
|
glm::mat4 transInverse {glm::inverse(trans)};
|
||||||
|
|
||||||
// Camera position, position + size.
|
// Camera position, position + size.
|
||||||
glm::vec3 viewStart{transInverse[3]};
|
glm::vec3 viewStart {transInverse[3]};
|
||||||
glm::vec3 viewEnd{std::fabs(trans[3].x) + static_cast<float>(Renderer::getScreenWidth()),
|
glm::vec3 viewEnd {std::fabs(trans[3].x) + static_cast<float>(Renderer::getScreenWidth()),
|
||||||
std::fabs(trans[3].y) + static_cast<float>(Renderer::getScreenHeight()),
|
std::fabs(trans[3].y) + static_cast<float>(Renderer::getScreenHeight()),
|
||||||
0.0f};
|
0.0f};
|
||||||
|
|
||||||
// Keep track of UI mode changes.
|
// Keep track of UI mode changes.
|
||||||
UIModeController::getInstance()->monitorUIMode();
|
UIModeController::getInstance()->monitorUIMode();
|
||||||
|
@ -928,9 +928,9 @@ void ViewController::render(const glm::mat4& parentTrans)
|
||||||
// Same thing as for the system view, limit the rendering only to what needs to be drawn.
|
// Same thing as for the system view, limit the rendering only to what needs to be drawn.
|
||||||
if (it->second == mCurrentView || (it->second == mPreviousView && isCameraMoving())) {
|
if (it->second == mCurrentView || (it->second == mPreviousView && isCameraMoving())) {
|
||||||
// Clipping.
|
// Clipping.
|
||||||
glm::vec3 guiStart{it->second->getPosition()};
|
glm::vec3 guiStart {it->second->getPosition()};
|
||||||
glm::vec3 guiEnd{it->second->getPosition() +
|
glm::vec3 guiEnd {it->second->getPosition() +
|
||||||
glm::vec3{it->second->getSize().x, it->second->getSize().y, 0.0f}};
|
glm::vec3 {it->second->getSize().x, it->second->getSize().y, 0.0f}};
|
||||||
|
|
||||||
if (guiEnd.x >= viewStart.x && guiEnd.y >= viewStart.y && guiStart.x <= viewEnd.x &&
|
if (guiEnd.x >= viewStart.x && guiEnd.y >= viewStart.y && guiStart.x <= viewEnd.x &&
|
||||||
guiStart.y <= viewEnd.y)
|
guiStart.y <= viewEnd.y)
|
||||||
|
|
|
@ -180,7 +180,7 @@ void DetailedGamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& them
|
||||||
|
|
||||||
mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT);
|
mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT);
|
||||||
// If there is no position defined in the theme for gamelistInfo, then hide it.
|
// If there is no position defined in the theme for gamelistInfo, then hide it.
|
||||||
if (mGamelistInfo.getPosition() == glm::vec3{})
|
if (mGamelistInfo.getPosition() == glm::vec3 {})
|
||||||
mGamelistInfo.setVisible(false);
|
mGamelistInfo.setVisible(false);
|
||||||
else
|
else
|
||||||
mGamelistInfo.setVisible(true);
|
mGamelistInfo.setVisible(true);
|
||||||
|
@ -195,21 +195,21 @@ void DetailedGamelistView::initMDLabels()
|
||||||
const unsigned int colCount = 2;
|
const unsigned int colCount = 2;
|
||||||
const unsigned int rowCount = static_cast<int>(components.size() / 2);
|
const unsigned int rowCount = static_cast<int>(components.size() / 2);
|
||||||
|
|
||||||
glm::vec3 start{mSize.x * 0.01f, mSize.y * 0.625f, 0.0f};
|
glm::vec3 start {mSize.x * 0.01f, mSize.y * 0.625f, 0.0f};
|
||||||
|
|
||||||
const float colSize = (mSize.x * 0.48f) / colCount;
|
const float colSize = (mSize.x * 0.48f) / colCount;
|
||||||
const float rowPadding = 0.01f * mSize.y;
|
const float rowPadding = 0.01f * mSize.y;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < components.size(); ++i) {
|
for (unsigned int i = 0; i < components.size(); ++i) {
|
||||||
const unsigned int row = i % rowCount;
|
const unsigned int row = i % rowCount;
|
||||||
glm::vec3 pos{};
|
glm::vec3 pos {};
|
||||||
if (row == 0) {
|
if (row == 0) {
|
||||||
pos = start + glm::vec3{colSize * (i / rowCount), 0.0f, 0.0f};
|
pos = start + glm::vec3 {colSize * (i / rowCount), 0.0f, 0.0f};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Work from the last component.
|
// Work from the last component.
|
||||||
GuiComponent* lc = components[i - 1];
|
GuiComponent* lc = components[i - 1];
|
||||||
pos = lc->getPosition() + glm::vec3{0.0f, lc->getSize().y + rowPadding, 0.0f};
|
pos = lc->getPosition() + glm::vec3 {0.0f, lc->getSize().y + rowPadding, 0.0f};
|
||||||
}
|
}
|
||||||
|
|
||||||
components[i]->setFont(Font::get(FONT_SIZE_SMALL));
|
components[i]->setFont(Font::get(FONT_SIZE_SMALL));
|
||||||
|
@ -239,7 +239,7 @@ void DetailedGamelistView::initMDValues()
|
||||||
for (unsigned int i = 0; i < labels.size(); ++i) {
|
for (unsigned int i = 0; i < labels.size(); ++i) {
|
||||||
const float heightDiff = (labels[i]->getSize().y - values[i]->getSize().y) / 2.0f;
|
const float heightDiff = (labels[i]->getSize().y - values[i]->getSize().y) / 2.0f;
|
||||||
values[i]->setPosition(labels[i]->getPosition() +
|
values[i]->setPosition(labels[i]->getPosition() +
|
||||||
glm::vec3{labels[i]->getSize().x, heightDiff, 0.0f});
|
glm::vec3 {labels[i]->getSize().x, heightDiff, 0.0f});
|
||||||
values[i]->setSize(colSize - labels[i]->getSize().x, values[i]->getSize().y);
|
values[i]->setSize(colSize - labels[i]->getSize().x, values[i]->getSize().y);
|
||||||
values[i]->setDefaultZIndex(40.0f);
|
values[i]->setDefaultZIndex(40.0f);
|
||||||
|
|
||||||
|
|
|
@ -278,7 +278,7 @@ void GridGamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
||||||
|
|
||||||
mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT);
|
mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT);
|
||||||
// If there is no position defined in the theme for gamelistInfo, then hide it.
|
// If there is no position defined in the theme for gamelistInfo, then hide it.
|
||||||
if (mGamelistInfo.getPosition() == glm::vec3{})
|
if (mGamelistInfo.getPosition() == glm::vec3 {})
|
||||||
mGamelistInfo.setVisible(false);
|
mGamelistInfo.setVisible(false);
|
||||||
else
|
else
|
||||||
mGamelistInfo.setVisible(true);
|
mGamelistInfo.setVisible(true);
|
||||||
|
@ -303,21 +303,21 @@ void GridGamelistView::initMDLabels()
|
||||||
const unsigned int colCount = 2;
|
const unsigned int colCount = 2;
|
||||||
const unsigned int rowCount = static_cast<int>(components.size() / 2);
|
const unsigned int rowCount = static_cast<int>(components.size() / 2);
|
||||||
|
|
||||||
glm::vec3 start{mSize.x * 0.01f, mSize.y * 0.625f, 0.0f};
|
glm::vec3 start {mSize.x * 0.01f, mSize.y * 0.625f, 0.0f};
|
||||||
|
|
||||||
const float colSize = (mSize.x * 0.48f) / colCount;
|
const float colSize = (mSize.x * 0.48f) / colCount;
|
||||||
const float rowPadding = 0.01f * mSize.y;
|
const float rowPadding = 0.01f * mSize.y;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < components.size(); ++i) {
|
for (unsigned int i = 0; i < components.size(); ++i) {
|
||||||
const unsigned int row = i % rowCount;
|
const unsigned int row = i % rowCount;
|
||||||
glm::vec3 pos{};
|
glm::vec3 pos {};
|
||||||
if (row == 0) {
|
if (row == 0) {
|
||||||
pos = start + glm::vec3{colSize * (i / rowCount), 0.0f, 0.0f};
|
pos = start + glm::vec3 {colSize * (i / rowCount), 0.0f, 0.0f};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Work from the last component.
|
// Work from the last component.
|
||||||
GuiComponent* lc = components[i - 1];
|
GuiComponent* lc = components[i - 1];
|
||||||
pos = lc->getPosition() + glm::vec3{0.0f, lc->getSize().y + rowPadding, 0.0f};
|
pos = lc->getPosition() + glm::vec3 {0.0f, lc->getSize().y + rowPadding, 0.0f};
|
||||||
}
|
}
|
||||||
|
|
||||||
components[i]->setFont(Font::get(FONT_SIZE_SMALL));
|
components[i]->setFont(Font::get(FONT_SIZE_SMALL));
|
||||||
|
@ -347,7 +347,7 @@ void GridGamelistView::initMDValues()
|
||||||
for (unsigned int i = 0; i < labels.size(); ++i) {
|
for (unsigned int i = 0; i < labels.size(); ++i) {
|
||||||
const float heightDiff = (labels[i]->getSize().y - values[i]->getSize().y) / 2.0f;
|
const float heightDiff = (labels[i]->getSize().y - values[i]->getSize().y) / 2.0f;
|
||||||
values[i]->setPosition(labels[i]->getPosition() +
|
values[i]->setPosition(labels[i]->getPosition() +
|
||||||
glm::vec3{labels[i]->getSize().x, heightDiff, 0.0f});
|
glm::vec3 {labels[i]->getSize().x, heightDiff, 0.0f});
|
||||||
values[i]->setSize(colSize - labels[i]->getSize().x, values[i]->getSize().y);
|
values[i]->setSize(colSize - labels[i]->getSize().x, values[i]->getSize().y);
|
||||||
values[i]->setDefaultZIndex(40.0f);
|
values[i]->setDefaultZIndex(40.0f);
|
||||||
|
|
||||||
|
|
|
@ -61,15 +61,15 @@ HelpStyle IGamelistView::getHelpStyle()
|
||||||
|
|
||||||
void IGamelistView::render(const glm::mat4& parentTrans)
|
void IGamelistView::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
|
|
||||||
float scaleX = trans[0].x;
|
float scaleX = trans[0].x;
|
||||||
float scaleY = trans[1].y;
|
float scaleY = trans[1].y;
|
||||||
|
|
||||||
glm::ivec2 pos{static_cast<int>(std::round(trans[3].x)),
|
glm::ivec2 pos {static_cast<int>(std::round(trans[3].x)),
|
||||||
static_cast<int>(std::round(trans[3].y))};
|
static_cast<int>(std::round(trans[3].y))};
|
||||||
glm::ivec2 size{static_cast<int>(std::round(mSize.x * scaleX)),
|
glm::ivec2 size {static_cast<int>(std::round(mSize.x * scaleX)),
|
||||||
static_cast<int>(std::round(mSize.y * scaleY))};
|
static_cast<int>(std::round(mSize.y * scaleY))};
|
||||||
|
|
||||||
Renderer::pushClipRect(pos, size);
|
Renderer::pushClipRect(pos, size);
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
|
|
|
@ -32,7 +32,7 @@ public:
|
||||||
void setTheme(const std::shared_ptr<ThemeData>& theme);
|
void setTheme(const std::shared_ptr<ThemeData>& theme);
|
||||||
const std::shared_ptr<ThemeData> getTheme() const { return mTheme; }
|
const std::shared_ptr<ThemeData> getTheme() const { return mTheme; }
|
||||||
|
|
||||||
virtual void preloadGamelist(){};
|
virtual void preloadGamelist() {};
|
||||||
|
|
||||||
virtual FileData* getCursor() = 0;
|
virtual FileData* getCursor() = 0;
|
||||||
virtual void setCursor(FileData*) = 0;
|
virtual void setCursor(FileData*) = 0;
|
||||||
|
|
|
@ -190,7 +190,7 @@ void VideoGamelistView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
||||||
|
|
||||||
mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT);
|
mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT);
|
||||||
// If there is no position defined in the theme for gamelistInfo, then hide it.
|
// If there is no position defined in the theme for gamelistInfo, then hide it.
|
||||||
if (mGamelistInfo.getPosition() == glm::vec3{})
|
if (mGamelistInfo.getPosition() == glm::vec3 {})
|
||||||
mGamelistInfo.setVisible(false);
|
mGamelistInfo.setVisible(false);
|
||||||
else
|
else
|
||||||
mGamelistInfo.setVisible(true);
|
mGamelistInfo.setVisible(true);
|
||||||
|
@ -205,21 +205,21 @@ void VideoGamelistView::initMDLabels()
|
||||||
const unsigned int colCount = 2;
|
const unsigned int colCount = 2;
|
||||||
const unsigned int rowCount = static_cast<int>(components.size() / 2);
|
const unsigned int rowCount = static_cast<int>(components.size() / 2);
|
||||||
|
|
||||||
glm::vec3 start{mSize.x * 0.01f, mSize.y * 0.625f, 0.0f};
|
glm::vec3 start {mSize.x * 0.01f, mSize.y * 0.625f, 0.0f};
|
||||||
|
|
||||||
const float colSize = (mSize.x * 0.48f) / colCount;
|
const float colSize = (mSize.x * 0.48f) / colCount;
|
||||||
const float rowPadding = 0.01f * mSize.y;
|
const float rowPadding = 0.01f * mSize.y;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < components.size(); ++i) {
|
for (unsigned int i = 0; i < components.size(); ++i) {
|
||||||
const unsigned int row = i % rowCount;
|
const unsigned int row = i % rowCount;
|
||||||
glm::vec3 pos{};
|
glm::vec3 pos {};
|
||||||
if (row == 0) {
|
if (row == 0) {
|
||||||
pos = start + glm::vec3{colSize * (i / rowCount), 0.0f, 0.0f};
|
pos = start + glm::vec3 {colSize * (i / rowCount), 0.0f, 0.0f};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Work from the last component.
|
// Work from the last component.
|
||||||
GuiComponent* lc = components[i - 1];
|
GuiComponent* lc = components[i - 1];
|
||||||
pos = lc->getPosition() + glm::vec3{0.0f, lc->getSize().y + rowPadding, 0.0f};
|
pos = lc->getPosition() + glm::vec3 {0.0f, lc->getSize().y + rowPadding, 0.0f};
|
||||||
}
|
}
|
||||||
|
|
||||||
components[i]->setFont(Font::get(FONT_SIZE_SMALL));
|
components[i]->setFont(Font::get(FONT_SIZE_SMALL));
|
||||||
|
@ -249,7 +249,7 @@ void VideoGamelistView::initMDValues()
|
||||||
for (unsigned int i = 0; i < labels.size(); ++i) {
|
for (unsigned int i = 0; i < labels.size(); ++i) {
|
||||||
const float heightDiff = (labels[i]->getSize().y - values[i]->getSize().y) / 2.0f;
|
const float heightDiff = (labels[i]->getSize().y - values[i]->getSize().y) / 2.0f;
|
||||||
values[i]->setPosition(labels[i]->getPosition() +
|
values[i]->setPosition(labels[i]->getPosition() +
|
||||||
glm::vec3{labels[i]->getSize().x, heightDiff, 0.0f});
|
glm::vec3 {labels[i]->getSize().x, heightDiff, 0.0f});
|
||||||
values[i]->setSize(colSize - labels[i]->getSize().x, values[i]->getSize().y);
|
values[i]->setSize(colSize - labels[i]->getSize().x, values[i]->getSize().y);
|
||||||
values[i]->setDefaultZIndex(40.0f);
|
values[i]->setDefaultZIndex(40.0f);
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ void GuiComponent::render(const glm::mat4& parentTrans)
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ void GuiComponent::setPosition(float x, float y, float z)
|
||||||
if (mPosition.x == x && mPosition.y == y && mPosition.z == z)
|
if (mPosition.x == x && mPosition.y == y && mPosition.z == z)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mPosition = glm::vec3{x, y, z};
|
mPosition = glm::vec3 {x, y, z};
|
||||||
onPositionChanged();
|
onPositionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ void GuiComponent::setOrigin(float x, float y)
|
||||||
if (mOrigin.x == x && mOrigin.y == y)
|
if (mOrigin.x == x && mOrigin.y == y)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mOrigin = glm::vec2{x, y};
|
mOrigin = glm::vec2 {x, y};
|
||||||
onOriginChanged();
|
onOriginChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,14 +116,14 @@ void GuiComponent::setSize(const float w, const float h)
|
||||||
if (mSize.x == w && mSize.y == h)
|
if (mSize.x == w && mSize.y == h)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mSize = glm::vec2{w, h};
|
mSize = glm::vec2 {w, h};
|
||||||
onSizeChanged();
|
onSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 GuiComponent::getCenter() const
|
glm::vec2 GuiComponent::getCenter() const
|
||||||
{
|
{
|
||||||
return glm::vec2{mPosition.x - (getSize().x * mOrigin.x) + getSize().x / 2.0f,
|
return glm::vec2 {mPosition.x - (getSize().x * mOrigin.x) + getSize().x / 2.0f,
|
||||||
mPosition.y - (getSize().y * mOrigin.y) + getSize().y / 2.0f};
|
mPosition.y - (getSize().y * mOrigin.y) + getSize().y / 2.0f};
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiComponent::addChild(GuiComponent* cmp)
|
void GuiComponent::addChild(GuiComponent* cmp)
|
||||||
|
@ -189,27 +189,27 @@ const glm::mat4& GuiComponent::getTransform()
|
||||||
mTransform = glm::translate(mTransform, mPosition);
|
mTransform = glm::translate(mTransform, mPosition);
|
||||||
|
|
||||||
if (mScale != 1.0f)
|
if (mScale != 1.0f)
|
||||||
mTransform = glm::scale(mTransform, glm::vec3{mScale});
|
mTransform = glm::scale(mTransform, glm::vec3 {mScale});
|
||||||
|
|
||||||
if (mRotation != 0.0f) {
|
if (mRotation != 0.0f) {
|
||||||
// Calculate offset as difference between origin and rotation origin.
|
// Calculate offset as difference between origin and rotation origin.
|
||||||
glm::vec2 rotationSize{getRotationSize()};
|
glm::vec2 rotationSize {getRotationSize()};
|
||||||
float xOff{(mOrigin.x - mRotationOrigin.x) * rotationSize.x};
|
float xOff {(mOrigin.x - mRotationOrigin.x) * rotationSize.x};
|
||||||
float yOff{(mOrigin.y - mRotationOrigin.y) * rotationSize.y};
|
float yOff {(mOrigin.y - mRotationOrigin.y) * rotationSize.y};
|
||||||
|
|
||||||
// Transform to offset point.
|
// Transform to offset point.
|
||||||
if (xOff != 0.0f || yOff != 0.0f)
|
if (xOff != 0.0f || yOff != 0.0f)
|
||||||
mTransform = glm::translate(mTransform, glm::vec3{xOff * -1.0f, yOff * -1.0f, 0.0f});
|
mTransform = glm::translate(mTransform, glm::vec3 {xOff * -1.0f, yOff * -1.0f, 0.0f});
|
||||||
|
|
||||||
// Apply rotation transform.
|
// Apply rotation transform.
|
||||||
mTransform = glm::rotate(mTransform, mRotation, glm::vec3{0.0f, 0.0f, 1.0f});
|
mTransform = glm::rotate(mTransform, mRotation, glm::vec3 {0.0f, 0.0f, 1.0f});
|
||||||
|
|
||||||
// Transform back to original point.
|
// Transform back to original point.
|
||||||
if (xOff != 0.0f || yOff != 0.0f)
|
if (xOff != 0.0f || yOff != 0.0f)
|
||||||
mTransform = glm::translate(mTransform, glm::vec3{xOff, yOff, 0.0f});
|
mTransform = glm::translate(mTransform, glm::vec3 {xOff, yOff, 0.0f});
|
||||||
}
|
}
|
||||||
mTransform = glm::translate(
|
mTransform = glm::translate(
|
||||||
mTransform, glm::vec3{mOrigin.x * mSize.x * -1.0f, mOrigin.y * mSize.y * -1.0f, 0.0f});
|
mTransform, glm::vec3 {mOrigin.x * mSize.x * -1.0f, mOrigin.y * mSize.y * -1.0f, 0.0f});
|
||||||
|
|
||||||
return mTransform;
|
return mTransform;
|
||||||
}
|
}
|
||||||
|
@ -314,9 +314,9 @@ void GuiComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
const std::string& element,
|
const std::string& element,
|
||||||
unsigned int properties)
|
unsigned int properties)
|
||||||
{
|
{
|
||||||
glm::vec2 scale{getParent() ? getParent()->getSize() :
|
glm::vec2 scale {getParent() ? getParent()->getSize() :
|
||||||
glm::vec2{static_cast<float>(Renderer::getScreenWidth()),
|
glm::vec2 {static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight())}};
|
static_cast<float>(Renderer::getScreenHeight())}};
|
||||||
|
|
||||||
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "");
|
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "");
|
||||||
if (!elem)
|
if (!elem)
|
||||||
|
@ -324,8 +324,8 @@ void GuiComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
|
|
||||||
using namespace ThemeFlags;
|
using namespace ThemeFlags;
|
||||||
if (properties & POSITION && elem->has("pos")) {
|
if (properties & POSITION && elem->has("pos")) {
|
||||||
glm::vec2 denormalized{elem->get<glm::vec2>("pos") * scale};
|
glm::vec2 denormalized {elem->get<glm::vec2>("pos") * scale};
|
||||||
setPosition(glm::vec3{denormalized.x, denormalized.y, 0.0f});
|
setPosition(glm::vec3 {denormalized.x, denormalized.y, 0.0f});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties & ThemeFlags::SIZE && elem->has("size"))
|
if (properties & ThemeFlags::SIZE && elem->has("size"))
|
||||||
|
|
|
@ -82,7 +82,7 @@ public:
|
||||||
// (e.g. (0, 0) is top left, (0.5, 0.5) is the center.)
|
// (e.g. (0, 0) is top left, (0.5, 0.5) is the center.)
|
||||||
void setRotationOrigin(float originX, float originY)
|
void setRotationOrigin(float originX, float originY)
|
||||||
{
|
{
|
||||||
mRotationOrigin = glm::vec2{originX, originY};
|
mRotationOrigin = glm::vec2 {originX, originY};
|
||||||
}
|
}
|
||||||
void setRotationOrigin(glm::vec2 origin) { setRotationOrigin(origin.x, origin.y); }
|
void setRotationOrigin(glm::vec2 origin) { setRotationOrigin(origin.x, origin.y); }
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ public:
|
||||||
virtual void onUnpauseVideo();
|
virtual void onUnpauseVideo();
|
||||||
virtual bool isVideoPaused() { return false; }
|
virtual bool isVideoPaused() { return false; }
|
||||||
// For Lottie animations.
|
// For Lottie animations.
|
||||||
virtual void resetFileAnimation(){};
|
virtual void resetFileAnimation() {};
|
||||||
|
|
||||||
virtual void onScreensaverActivate();
|
virtual void onScreensaverActivate();
|
||||||
virtual void onScreensaverDeactivate();
|
virtual void onScreensaverDeactivate();
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
HelpStyle::HelpStyle()
|
HelpStyle::HelpStyle()
|
||||||
{
|
{
|
||||||
position =
|
position =
|
||||||
glm::vec2{Renderer::getScreenWidth() * 0.012f, Renderer::getScreenHeight() * 0.9515f};
|
glm::vec2 {Renderer::getScreenWidth() * 0.012f, Renderer::getScreenHeight() * 0.9515f};
|
||||||
origin = glm::vec2{};
|
origin = glm::vec2 {};
|
||||||
textColor = 0x777777FF;
|
textColor = 0x777777FF;
|
||||||
textColorDimmed = 0x777777FF;
|
textColorDimmed = 0x777777FF;
|
||||||
iconColor = 0x777777FF;
|
iconColor = 0x777777FF;
|
||||||
|
@ -38,8 +38,8 @@ void HelpStyle::applyTheme(const std::shared_ptr<ThemeData>& theme, const std::s
|
||||||
|
|
||||||
if (elem->has("pos"))
|
if (elem->has("pos"))
|
||||||
position = elem->get<glm::vec2>("pos") *
|
position = elem->get<glm::vec2>("pos") *
|
||||||
glm::vec2{static_cast<float>(Renderer::getScreenWidth()),
|
glm::vec2 {static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight())};
|
static_cast<float>(Renderer::getScreenHeight())};
|
||||||
|
|
||||||
if (elem->has("origin"))
|
if (elem->has("origin"))
|
||||||
origin = elem->get<glm::vec2>("origin");
|
origin = elem->get<glm::vec2>("origin");
|
||||||
|
|
|
@ -52,11 +52,11 @@ protected:
|
||||||
std::ostringstream mOutStringStream;
|
std::ostringstream mOutStringStream;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::map<LogLevel, std::string> mLogLevelMap{// Log level indicators.
|
std::map<LogLevel, std::string> mLogLevelMap {// Log level indicators.
|
||||||
{LogError, "Error"},
|
{LogError, "Error"},
|
||||||
{LogWarning, "Warn"},
|
{LogWarning, "Warn"},
|
||||||
{LogInfo, "Info"},
|
{LogInfo, "Info"},
|
||||||
{LogDebug, "Debug"}};
|
{LogDebug, "Debug"}};
|
||||||
inline static std::ofstream sFile;
|
inline static std::ofstream sFile;
|
||||||
inline static LogLevel sReportingLevel = LogInfo;
|
inline static LogLevel sReportingLevel = LogInfo;
|
||||||
LogLevel mMessageLevel;
|
LogLevel mMessageLevel;
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace
|
||||||
// the in-program settings menu. Most can be set using command-line arguments,
|
// the in-program settings menu. Most can be set using command-line arguments,
|
||||||
// but some are debug flags that are either hardcoded or set by internal debug
|
// but some are debug flags that are either hardcoded or set by internal debug
|
||||||
// functions.
|
// functions.
|
||||||
std::vector<std::string> settingsSkipSaving{
|
std::vector<std::string> settingsSkipSaving {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
// These options can be set using command-line arguments:
|
// These options can be set using command-line arguments:
|
||||||
"WindowWidth", // Set via --resolution [width] [height]
|
"WindowWidth", // Set via --resolution [width] [height]
|
||||||
|
|
|
@ -21,212 +21,213 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
|
|
||||||
std::vector<std::string> ThemeData::sSupportedViews{{"all"}, {"system"}, {"basic"},
|
std::vector<std::string> ThemeData::sSupportedViews {{"all"}, {"system"}, {"basic"},
|
||||||
{"detailed"}, {"grid"}, {"video"}};
|
{"detailed"}, {"grid"}, {"video"}};
|
||||||
std::vector<std::string> ThemeData::sSupportedFeatures{
|
std::vector<std::string> ThemeData::sSupportedFeatures {
|
||||||
{"navigationsounds"}, {"video"}, {"carousel"}, {"z-index"}, {"visible"}};
|
{"navigationsounds"}, {"video"}, {"carousel"}, {"z-index"}, {"visible"}};
|
||||||
|
|
||||||
std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>> ThemeData::sElementMap{
|
std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
||||||
{"image",
|
ThemeData::sElementMap // Line break.
|
||||||
{{"pos", NORMALIZED_PAIR},
|
{{"image",
|
||||||
{"size", NORMALIZED_PAIR},
|
{{"pos", NORMALIZED_PAIR},
|
||||||
{"maxSize", NORMALIZED_PAIR},
|
{"size", NORMALIZED_PAIR},
|
||||||
{"origin", NORMALIZED_PAIR},
|
{"maxSize", NORMALIZED_PAIR},
|
||||||
{"rotation", FLOAT},
|
{"origin", NORMALIZED_PAIR},
|
||||||
{"rotationOrigin", NORMALIZED_PAIR},
|
{"rotation", FLOAT},
|
||||||
{"path", PATH},
|
{"rotationOrigin", NORMALIZED_PAIR},
|
||||||
{"default", PATH},
|
{"path", PATH},
|
||||||
{"tile", BOOLEAN},
|
{"default", PATH},
|
||||||
{"color", COLOR},
|
{"tile", BOOLEAN},
|
||||||
{"colorEnd", COLOR},
|
{"color", COLOR},
|
||||||
{"gradientType", STRING},
|
{"colorEnd", COLOR},
|
||||||
{"visible", BOOLEAN},
|
{"gradientType", STRING},
|
||||||
{"zIndex", FLOAT}}},
|
{"visible", BOOLEAN},
|
||||||
{"imagegrid",
|
{"zIndex", FLOAT}}},
|
||||||
{{"pos", NORMALIZED_PAIR},
|
{"imagegrid",
|
||||||
{"size", NORMALIZED_PAIR},
|
{{"pos", NORMALIZED_PAIR},
|
||||||
{"margin", NORMALIZED_PAIR},
|
{"size", NORMALIZED_PAIR},
|
||||||
{"padding", NORMALIZED_RECT},
|
{"margin", NORMALIZED_PAIR},
|
||||||
{"autoLayout", NORMALIZED_PAIR},
|
{"padding", NORMALIZED_RECT},
|
||||||
{"autoLayoutSelectedZoom", FLOAT},
|
{"autoLayout", NORMALIZED_PAIR},
|
||||||
{"gameImage", PATH},
|
{"autoLayoutSelectedZoom", FLOAT},
|
||||||
{"folderImage", PATH},
|
{"gameImage", PATH},
|
||||||
{"imageSource", STRING},
|
{"folderImage", PATH},
|
||||||
{"scrollDirection", STRING},
|
{"imageSource", STRING},
|
||||||
{"centerSelection", BOOLEAN},
|
{"scrollDirection", STRING},
|
||||||
{"scrollLoop", BOOLEAN},
|
{"centerSelection", BOOLEAN},
|
||||||
{"animate", BOOLEAN},
|
{"scrollLoop", BOOLEAN},
|
||||||
{"zIndex", FLOAT}}},
|
{"animate", BOOLEAN},
|
||||||
{"gridtile",
|
{"zIndex", FLOAT}}},
|
||||||
{{"size", NORMALIZED_PAIR},
|
{"gridtile",
|
||||||
{"padding", NORMALIZED_PAIR},
|
{{"size", NORMALIZED_PAIR},
|
||||||
{"imageColor", COLOR},
|
{"padding", NORMALIZED_PAIR},
|
||||||
{"backgroundImage", PATH},
|
{"imageColor", COLOR},
|
||||||
{"backgroundCornerSize", NORMALIZED_PAIR},
|
{"backgroundImage", PATH},
|
||||||
{"backgroundColor", COLOR},
|
{"backgroundCornerSize", NORMALIZED_PAIR},
|
||||||
{"backgroundCenterColor", COLOR},
|
{"backgroundColor", COLOR},
|
||||||
{"backgroundEdgeColor", COLOR}}},
|
{"backgroundCenterColor", COLOR},
|
||||||
{"text",
|
{"backgroundEdgeColor", COLOR}}},
|
||||||
{{"pos", NORMALIZED_PAIR},
|
{"text",
|
||||||
{"size", NORMALIZED_PAIR},
|
{{"pos", NORMALIZED_PAIR},
|
||||||
{"origin", NORMALIZED_PAIR},
|
{"size", NORMALIZED_PAIR},
|
||||||
{"rotation", FLOAT},
|
{"origin", NORMALIZED_PAIR},
|
||||||
{"rotationOrigin", NORMALIZED_PAIR},
|
{"rotation", FLOAT},
|
||||||
{"text", STRING},
|
{"rotationOrigin", NORMALIZED_PAIR},
|
||||||
{"backgroundColor", COLOR},
|
{"text", STRING},
|
||||||
{"fontPath", PATH},
|
{"backgroundColor", COLOR},
|
||||||
{"fontSize", FLOAT},
|
{"fontPath", PATH},
|
||||||
{"color", COLOR},
|
{"fontSize", FLOAT},
|
||||||
{"alignment", STRING},
|
{"color", COLOR},
|
||||||
{"forceUppercase", BOOLEAN},
|
{"alignment", STRING},
|
||||||
{"lineSpacing", FLOAT},
|
{"forceUppercase", BOOLEAN},
|
||||||
{"value", STRING},
|
{"lineSpacing", FLOAT},
|
||||||
{"visible", BOOLEAN},
|
{"value", STRING},
|
||||||
{"zIndex", FLOAT}}},
|
{"visible", BOOLEAN},
|
||||||
{"textlist",
|
{"zIndex", FLOAT}}},
|
||||||
{{"pos", NORMALIZED_PAIR},
|
{"textlist",
|
||||||
{"size", NORMALIZED_PAIR},
|
{{"pos", NORMALIZED_PAIR},
|
||||||
{"origin", NORMALIZED_PAIR},
|
{"size", NORMALIZED_PAIR},
|
||||||
{"selectorHeight", FLOAT},
|
{"origin", NORMALIZED_PAIR},
|
||||||
{"selectorOffsetY", FLOAT},
|
{"selectorHeight", FLOAT},
|
||||||
{"selectorColor", COLOR},
|
{"selectorOffsetY", FLOAT},
|
||||||
{"selectorColorEnd", COLOR},
|
{"selectorColor", COLOR},
|
||||||
{"selectorGradientType", STRING},
|
{"selectorColorEnd", COLOR},
|
||||||
{"selectorImagePath", PATH},
|
{"selectorGradientType", STRING},
|
||||||
{"selectorImageTile", BOOLEAN},
|
{"selectorImagePath", PATH},
|
||||||
{"selectedColor", COLOR},
|
{"selectorImageTile", BOOLEAN},
|
||||||
{"primaryColor", COLOR},
|
{"selectedColor", COLOR},
|
||||||
{"secondaryColor", COLOR},
|
{"primaryColor", COLOR},
|
||||||
{"fontPath", PATH},
|
{"secondaryColor", COLOR},
|
||||||
{"fontSize", FLOAT},
|
{"fontPath", PATH},
|
||||||
{"scrollSound", PATH}, // For backward compatibility with old themes.
|
{"fontSize", FLOAT},
|
||||||
{"alignment", STRING},
|
{"scrollSound", PATH}, // For backward compatibility with old themes.
|
||||||
{"horizontalMargin", FLOAT},
|
{"alignment", STRING},
|
||||||
{"forceUppercase", BOOLEAN},
|
{"horizontalMargin", FLOAT},
|
||||||
{"lineSpacing", FLOAT},
|
{"forceUppercase", BOOLEAN},
|
||||||
{"zIndex", FLOAT}}},
|
{"lineSpacing", FLOAT},
|
||||||
{"container",
|
{"zIndex", FLOAT}}},
|
||||||
{{"pos", NORMALIZED_PAIR},
|
{"container",
|
||||||
{"size", NORMALIZED_PAIR},
|
{{"pos", NORMALIZED_PAIR},
|
||||||
{"origin", NORMALIZED_PAIR},
|
{"size", NORMALIZED_PAIR},
|
||||||
{"visible", BOOLEAN},
|
{"origin", NORMALIZED_PAIR},
|
||||||
{"zIndex", FLOAT}}},
|
{"visible", BOOLEAN},
|
||||||
{"ninepatch",
|
{"zIndex", FLOAT}}},
|
||||||
{{"pos", NORMALIZED_PAIR},
|
{"ninepatch",
|
||||||
{"size", NORMALIZED_PAIR},
|
{{"pos", NORMALIZED_PAIR},
|
||||||
{"path", PATH},
|
{"size", NORMALIZED_PAIR},
|
||||||
{"visible", BOOLEAN},
|
{"path", PATH},
|
||||||
{"zIndex", FLOAT}}},
|
{"visible", BOOLEAN},
|
||||||
{"datetime",
|
{"zIndex", FLOAT}}},
|
||||||
{{"pos", NORMALIZED_PAIR},
|
{"datetime",
|
||||||
{"size", NORMALIZED_PAIR},
|
{{"pos", NORMALIZED_PAIR},
|
||||||
{"origin", NORMALIZED_PAIR},
|
{"size", NORMALIZED_PAIR},
|
||||||
{"rotation", FLOAT},
|
{"origin", NORMALIZED_PAIR},
|
||||||
{"rotationOrigin", NORMALIZED_PAIR},
|
{"rotation", FLOAT},
|
||||||
{"backgroundColor", COLOR},
|
{"rotationOrigin", NORMALIZED_PAIR},
|
||||||
{"fontPath", PATH},
|
{"backgroundColor", COLOR},
|
||||||
{"fontSize", FLOAT},
|
{"fontPath", PATH},
|
||||||
{"color", COLOR},
|
{"fontSize", FLOAT},
|
||||||
{"alignment", STRING},
|
{"color", COLOR},
|
||||||
{"forceUppercase", BOOLEAN},
|
{"alignment", STRING},
|
||||||
{"lineSpacing", FLOAT},
|
{"forceUppercase", BOOLEAN},
|
||||||
{"value", STRING},
|
{"lineSpacing", FLOAT},
|
||||||
{"format", STRING},
|
{"value", STRING},
|
||||||
{"displayRelative", BOOLEAN},
|
{"format", STRING},
|
||||||
{"visible", BOOLEAN},
|
{"displayRelative", BOOLEAN},
|
||||||
{"zIndex", FLOAT}}},
|
{"visible", BOOLEAN},
|
||||||
{"rating",
|
{"zIndex", FLOAT}}},
|
||||||
{{"pos", NORMALIZED_PAIR},
|
{"rating",
|
||||||
{"size", NORMALIZED_PAIR},
|
{{"pos", NORMALIZED_PAIR},
|
||||||
{"origin", NORMALIZED_PAIR},
|
{"size", NORMALIZED_PAIR},
|
||||||
{"rotation", FLOAT},
|
{"origin", NORMALIZED_PAIR},
|
||||||
{"rotationOrigin", NORMALIZED_PAIR},
|
{"rotation", FLOAT},
|
||||||
{"color", COLOR},
|
{"rotationOrigin", NORMALIZED_PAIR},
|
||||||
{"filledPath", PATH},
|
{"color", COLOR},
|
||||||
{"unfilledPath", PATH},
|
{"filledPath", PATH},
|
||||||
{"visible", BOOLEAN},
|
{"unfilledPath", PATH},
|
||||||
{"zIndex", FLOAT}}},
|
{"visible", BOOLEAN},
|
||||||
{"animation",
|
{"zIndex", FLOAT}}},
|
||||||
{{"pos", NORMALIZED_PAIR},
|
{"animation",
|
||||||
{"size", NORMALIZED_PAIR},
|
{{"pos", NORMALIZED_PAIR},
|
||||||
{"origin", NORMALIZED_PAIR},
|
{"size", NORMALIZED_PAIR},
|
||||||
{"rotation", FLOAT},
|
{"origin", NORMALIZED_PAIR},
|
||||||
{"rotationOrigin", NORMALIZED_PAIR},
|
{"rotation", FLOAT},
|
||||||
{"path", PATH},
|
{"rotationOrigin", NORMALIZED_PAIR},
|
||||||
{"speed", FLOAT},
|
{"path", PATH},
|
||||||
{"direction", STRING},
|
{"speed", FLOAT},
|
||||||
{"keepAspectRatio", BOOLEAN},
|
{"direction", STRING},
|
||||||
{"visible", BOOLEAN},
|
{"keepAspectRatio", BOOLEAN},
|
||||||
{"zIndex", FLOAT}}},
|
{"visible", BOOLEAN},
|
||||||
{"badges",
|
{"zIndex", FLOAT}}},
|
||||||
{{"pos", NORMALIZED_PAIR},
|
{"badges",
|
||||||
{"size", NORMALIZED_PAIR},
|
{{"pos", NORMALIZED_PAIR},
|
||||||
{"origin", NORMALIZED_PAIR},
|
{"size", NORMALIZED_PAIR},
|
||||||
{"rotation", FLOAT},
|
{"origin", NORMALIZED_PAIR},
|
||||||
{"rotationOrigin", NORMALIZED_PAIR},
|
{"rotation", FLOAT},
|
||||||
{"alignment", STRING},
|
{"rotationOrigin", NORMALIZED_PAIR},
|
||||||
{"direction", STRING},
|
{"alignment", STRING},
|
||||||
{"lines", FLOAT},
|
{"direction", STRING},
|
||||||
{"itemsPerLine", FLOAT},
|
{"lines", FLOAT},
|
||||||
{"itemMargin", NORMALIZED_PAIR},
|
{"itemsPerLine", FLOAT},
|
||||||
{"slots", STRING},
|
{"itemMargin", NORMALIZED_PAIR},
|
||||||
{"controllerPos", NORMALIZED_PAIR},
|
{"slots", STRING},
|
||||||
{"controllerSize", FLOAT},
|
{"controllerPos", NORMALIZED_PAIR},
|
||||||
{"customBadgeIcon", PATH},
|
{"controllerSize", FLOAT},
|
||||||
{"customControllerIcon", PATH},
|
{"customBadgeIcon", PATH},
|
||||||
{"visible", BOOLEAN},
|
{"customControllerIcon", PATH},
|
||||||
{"zIndex", FLOAT}}},
|
{"visible", BOOLEAN},
|
||||||
{"sound", {{"path", PATH}}},
|
{"zIndex", FLOAT}}},
|
||||||
{"helpsystem",
|
{"sound", {{"path", PATH}}},
|
||||||
{{"pos", NORMALIZED_PAIR},
|
{"helpsystem",
|
||||||
{"origin", NORMALIZED_PAIR},
|
{{"pos", NORMALIZED_PAIR},
|
||||||
{"textColor", COLOR},
|
{"origin", NORMALIZED_PAIR},
|
||||||
{"textColorDimmed", COLOR},
|
{"textColor", COLOR},
|
||||||
{"iconColor", COLOR},
|
{"textColorDimmed", COLOR},
|
||||||
{"iconColorDimmed", COLOR},
|
{"iconColor", COLOR},
|
||||||
{"fontPath", PATH},
|
{"iconColorDimmed", COLOR},
|
||||||
{"fontSize", FLOAT},
|
{"fontPath", PATH},
|
||||||
{"entrySpacing", FLOAT},
|
{"fontSize", FLOAT},
|
||||||
{"iconTextSpacing", FLOAT},
|
{"entrySpacing", FLOAT},
|
||||||
{"textStyle", STRING},
|
{"iconTextSpacing", FLOAT},
|
||||||
{"customButtonIcon", PATH}}},
|
{"textStyle", STRING},
|
||||||
{"navigationsounds",
|
{"customButtonIcon", PATH}}},
|
||||||
{{"systembrowseSound", PATH},
|
{"navigationsounds",
|
||||||
{"quicksysselectSound", PATH},
|
{{"systembrowseSound", PATH},
|
||||||
{"selectSound", PATH},
|
{"quicksysselectSound", PATH},
|
||||||
{"backSound", PATH},
|
{"selectSound", PATH},
|
||||||
{"scrollSound", PATH},
|
{"backSound", PATH},
|
||||||
{"favoriteSound", PATH},
|
{"scrollSound", PATH},
|
||||||
{"launchSound", PATH}}},
|
{"favoriteSound", PATH},
|
||||||
{"video",
|
{"launchSound", PATH}}},
|
||||||
{{"pos", NORMALIZED_PAIR},
|
{"video",
|
||||||
{"size", NORMALIZED_PAIR},
|
{{"pos", NORMALIZED_PAIR},
|
||||||
{"maxSize", NORMALIZED_PAIR},
|
{"size", NORMALIZED_PAIR},
|
||||||
{"origin", NORMALIZED_PAIR},
|
{"maxSize", NORMALIZED_PAIR},
|
||||||
{"rotation", FLOAT},
|
{"origin", NORMALIZED_PAIR},
|
||||||
{"rotationOrigin", NORMALIZED_PAIR},
|
{"rotation", FLOAT},
|
||||||
{"default", PATH},
|
{"rotationOrigin", NORMALIZED_PAIR},
|
||||||
{"delay", FLOAT},
|
{"default", PATH},
|
||||||
{"visible", BOOLEAN},
|
{"delay", FLOAT},
|
||||||
{"zIndex", FLOAT},
|
{"visible", BOOLEAN},
|
||||||
{"showSnapshotNoVideo", BOOLEAN},
|
{"zIndex", FLOAT},
|
||||||
{"showSnapshotDelay", BOOLEAN}}},
|
{"showSnapshotNoVideo", BOOLEAN},
|
||||||
{"carousel",
|
{"showSnapshotDelay", BOOLEAN}}},
|
||||||
{{"type", STRING},
|
{"carousel",
|
||||||
{"size", NORMALIZED_PAIR},
|
{{"type", STRING},
|
||||||
{"pos", NORMALIZED_PAIR},
|
{"size", NORMALIZED_PAIR},
|
||||||
{"origin", NORMALIZED_PAIR},
|
{"pos", NORMALIZED_PAIR},
|
||||||
{"color", COLOR},
|
{"origin", NORMALIZED_PAIR},
|
||||||
{"colorEnd", COLOR},
|
{"color", COLOR},
|
||||||
{"gradientType", STRING},
|
{"colorEnd", COLOR},
|
||||||
{"logoScale", FLOAT},
|
{"gradientType", STRING},
|
||||||
{"logoRotation", FLOAT},
|
{"logoScale", FLOAT},
|
||||||
{"logoRotationOrigin", NORMALIZED_PAIR},
|
{"logoRotation", FLOAT},
|
||||||
{"logoSize", NORMALIZED_PAIR},
|
{"logoRotationOrigin", NORMALIZED_PAIR},
|
||||||
{"logoAlignment", STRING},
|
{"logoSize", NORMALIZED_PAIR},
|
||||||
{"maxLogoCount", FLOAT},
|
{"logoAlignment", STRING},
|
||||||
{"zIndex", FLOAT},
|
{"maxLogoCount", FLOAT},
|
||||||
{"legacyZIndexMode", STRING}}}};
|
{"zIndex", FLOAT},
|
||||||
|
{"legacyZIndexMode", STRING}}}};
|
||||||
|
|
||||||
#define MINIMUM_THEME_FORMAT_VERSION 3
|
#define MINIMUM_THEME_FORMAT_VERSION 3
|
||||||
#define CURRENT_THEME_FORMAT_VERSION 7
|
#define CURRENT_THEME_FORMAT_VERSION 7
|
||||||
|
@ -488,16 +489,16 @@ void ThemeData::parseElement(const pugi::xml_node& root,
|
||||||
|
|
||||||
auto splits = Utils::String::delimitedStringToVector(str, " ");
|
auto splits = Utils::String::delimitedStringToVector(str, " ");
|
||||||
if (splits.size() == 2) {
|
if (splits.size() == 2) {
|
||||||
val = glm::vec4{static_cast<float>(atof(splits.at(0).c_str())),
|
val = glm::vec4 {static_cast<float>(atof(splits.at(0).c_str())),
|
||||||
static_cast<float>(atof(splits.at(1).c_str())),
|
static_cast<float>(atof(splits.at(1).c_str())),
|
||||||
static_cast<float>(atof(splits.at(0).c_str())),
|
static_cast<float>(atof(splits.at(0).c_str())),
|
||||||
static_cast<float>(atof(splits.at(1).c_str()))};
|
static_cast<float>(atof(splits.at(1).c_str()))};
|
||||||
}
|
}
|
||||||
else if (splits.size() == 4) {
|
else if (splits.size() == 4) {
|
||||||
val = glm::vec4{static_cast<float>(atof(splits.at(0).c_str())),
|
val = glm::vec4 {static_cast<float>(atof(splits.at(0).c_str())),
|
||||||
static_cast<float>(atof(splits.at(1).c_str())),
|
static_cast<float>(atof(splits.at(1).c_str())),
|
||||||
static_cast<float>(atof(splits.at(2).c_str())),
|
static_cast<float>(atof(splits.at(2).c_str())),
|
||||||
static_cast<float>(atof(splits.at(3).c_str()))};
|
static_cast<float>(atof(splits.at(3).c_str()))};
|
||||||
}
|
}
|
||||||
|
|
||||||
element.properties[node.name()] = val;
|
element.properties[node.name()] = val;
|
||||||
|
@ -509,11 +510,11 @@ void ThemeData::parseElement(const pugi::xml_node& root,
|
||||||
throw error << "invalid normalized pair (property \"" << node.name()
|
throw error << "invalid normalized pair (property \"" << node.name()
|
||||||
<< "\", value \"" << str.c_str() << "\")";
|
<< "\", value \"" << str.c_str() << "\")";
|
||||||
|
|
||||||
std::string first{str.substr(0, divider)};
|
std::string first {str.substr(0, divider)};
|
||||||
std::string second{str.substr(divider, std::string::npos)};
|
std::string second {str.substr(divider, std::string::npos)};
|
||||||
|
|
||||||
glm::vec2 val{static_cast<float>(atof(first.c_str())),
|
glm::vec2 val {static_cast<float>(atof(first.c_str())),
|
||||||
static_cast<float>(atof(second.c_str()))};
|
static_cast<float>(atof(second.c_str()))};
|
||||||
|
|
||||||
element.properties[node.name()] = val;
|
element.properties[node.name()] = val;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -106,8 +106,8 @@ public:
|
||||||
void operator=(const glm::vec4& value)
|
void operator=(const glm::vec4& value)
|
||||||
{
|
{
|
||||||
r = value;
|
r = value;
|
||||||
const glm::vec4 initVector{value};
|
const glm::vec4 initVector {value};
|
||||||
v = glm::vec2{initVector.x, initVector.y};
|
v = glm::vec2 {initVector.x, initVector.y};
|
||||||
}
|
}
|
||||||
void operator=(const glm::vec2& value) { v = value; }
|
void operator=(const glm::vec2& value) { v = value; }
|
||||||
void operator=(const std::string& value) { s = value; }
|
void operator=(const std::string& value) { s = value; }
|
||||||
|
|
|
@ -45,8 +45,8 @@ Window::Window() noexcept
|
||||||
, mAllowFileAnimation(true)
|
, mAllowFileAnimation(true)
|
||||||
, mCachedBackground(false)
|
, mCachedBackground(false)
|
||||||
, mInvalidatedCachedBackground(false)
|
, mInvalidatedCachedBackground(false)
|
||||||
, mInitiateCacheTimer{false}
|
, mInitiateCacheTimer {false}
|
||||||
, mInvalidateCacheTimer{0}
|
, mInvalidateCacheTimer {0}
|
||||||
, mVideoPlayerCount(0)
|
, mVideoPlayerCount(0)
|
||||||
, mTopScale(0.5)
|
, mTopScale(0.5)
|
||||||
, mChangedThemeSet(false)
|
, mChangedThemeSet(false)
|
||||||
|
@ -253,7 +253,7 @@ void Window::input(InputConfig* config, Input input)
|
||||||
// from the submenu.
|
// from the submenu.
|
||||||
mTopScale = 1.0f;
|
mTopScale = 1.0f;
|
||||||
GuiComponent* menu = mGuiStack.back();
|
GuiComponent* menu = mGuiStack.back();
|
||||||
glm::vec2 menuCenter{menu->getCenter()};
|
glm::vec2 menuCenter {menu->getCenter()};
|
||||||
menu->setOrigin(0.5f, 0.5f);
|
menu->setOrigin(0.5f, 0.5f);
|
||||||
menu->setPosition(menuCenter.x, menuCenter.y, 0.0f);
|
menu->setPosition(menuCenter.x, menuCenter.y, 0.0f);
|
||||||
menu->setScale(1.0f);
|
menu->setScale(1.0f);
|
||||||
|
@ -409,7 +409,7 @@ void Window::render()
|
||||||
mInitiateCacheTimer = false;
|
mInitiateCacheTimer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::mat4 trans{Renderer::getIdentity()};
|
glm::mat4 trans {Renderer::getIdentity()};
|
||||||
|
|
||||||
mRenderedHelpPrompts = false;
|
mRenderedHelpPrompts = false;
|
||||||
|
|
||||||
|
@ -531,7 +531,7 @@ void Window::render()
|
||||||
if (Settings::getInstance()->getString("MenuOpeningEffect") == "scale-up") {
|
if (Settings::getInstance()->getString("MenuOpeningEffect") == "scale-up") {
|
||||||
if (mTopScale < 1.0f) {
|
if (mTopScale < 1.0f) {
|
||||||
mTopScale = glm::clamp(mTopScale + 0.07f, 0.0f, 1.0f);
|
mTopScale = glm::clamp(mTopScale + 0.07f, 0.0f, 1.0f);
|
||||||
glm::vec2 topCenter{top->getCenter()};
|
glm::vec2 topCenter {top->getCenter()};
|
||||||
top->setOrigin(0.5f, 0.5f);
|
top->setOrigin(0.5f, 0.5f);
|
||||||
top->setPosition(topCenter.x, topCenter.y, 0.0f);
|
top->setPosition(topCenter.x, topCenter.y, 0.0f);
|
||||||
top->setScale(mTopScale);
|
top->setScale(mTopScale);
|
||||||
|
@ -554,7 +554,7 @@ void Window::render()
|
||||||
static_cast<float>(Renderer::getScreenHeight()),
|
static_cast<float>(Renderer::getScreenHeight()),
|
||||||
0x00000000 | mListScrollOpacity, 0x00000000 | mListScrollOpacity);
|
0x00000000 | mListScrollOpacity, 0x00000000 | mListScrollOpacity);
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
@ -613,7 +613,7 @@ void Window::render()
|
||||||
|
|
||||||
void Window::renderLoadingScreen(std::string text)
|
void Window::renderLoadingScreen(std::string text)
|
||||||
{
|
{
|
||||||
glm::mat4 trans{Renderer::getIdentity()};
|
glm::mat4 trans {Renderer::getIdentity()};
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
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()), 0x000000FF, 0x000000FF);
|
static_cast<float>(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF);
|
||||||
|
@ -630,7 +630,7 @@ void Window::renderLoadingScreen(std::string text)
|
||||||
|
|
||||||
float x = std::round((Renderer::getScreenWidth() - cache->metrics.size.x) / 2.0f);
|
float x = std::round((Renderer::getScreenWidth() - cache->metrics.size.x) / 2.0f);
|
||||||
float y = std::round(Renderer::getScreenHeight() * 0.835f);
|
float y = std::round(Renderer::getScreenHeight() * 0.835f);
|
||||||
trans = glm::translate(trans, glm::vec3{x, y, 0.0f});
|
trans = glm::translate(trans, glm::vec3 {x, y, 0.0f});
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
font->renderTextCache(cache);
|
font->renderTextCache(cache);
|
||||||
delete cache;
|
delete cache;
|
||||||
|
|
|
@ -62,11 +62,11 @@ namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
BadgeComponent::BadgeComponent(Window* window)
|
BadgeComponent::BadgeComponent(Window* window)
|
||||||
: GuiComponent{window}
|
: GuiComponent {window}
|
||||||
, mFlexboxItems{}
|
, mFlexboxItems {}
|
||||||
, mFlexboxComponent{window, mFlexboxItems}
|
, mFlexboxComponent {window, mFlexboxItems}
|
||||||
, mBadgeTypes{{SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDGAME, SLOT_BROKEN, SLOT_CONTROLLER,
|
, mBadgeTypes {{SLOT_FAVORITE, SLOT_COMPLETED, SLOT_KIDGAME, SLOT_BROKEN, SLOT_CONTROLLER,
|
||||||
SLOT_ALTEMULATOR}}
|
SLOT_ALTEMULATOR}}
|
||||||
{
|
{
|
||||||
mBadgeIcons[SLOT_FAVORITE] = ":/graphics/badge_favorite.svg";
|
mBadgeIcons[SLOT_FAVORITE] = ":/graphics/badge_favorite.svg";
|
||||||
mBadgeIcons[SLOT_COMPLETED] = ":/graphics/badge_completed.svg";
|
mBadgeIcons[SLOT_COMPLETED] = ":/graphics/badge_completed.svg";
|
||||||
|
@ -190,12 +190,12 @@ void BadgeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
|
|
||||||
using namespace ThemeFlags;
|
using namespace ThemeFlags;
|
||||||
|
|
||||||
const ThemeData::ThemeElement* elem{theme->getElement(view, element, "badges")};
|
const ThemeData::ThemeElement* elem {theme->getElement(view, element, "badges")};
|
||||||
if (!elem)
|
if (!elem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (elem->has("alignment")) {
|
if (elem->has("alignment")) {
|
||||||
const std::string alignment{elem->get<std::string>("alignment")};
|
const std::string alignment {elem->get<std::string>("alignment")};
|
||||||
if (alignment != "left" && alignment != "right") {
|
if (alignment != "left" && alignment != "right") {
|
||||||
LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, <alignment> set to \""
|
LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, <alignment> set to \""
|
||||||
<< alignment << "\"";
|
<< alignment << "\"";
|
||||||
|
@ -206,7 +206,7 @@ void BadgeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("direction")) {
|
if (elem->has("direction")) {
|
||||||
const std::string direction{elem->get<std::string>("direction")};
|
const std::string direction {elem->get<std::string>("direction")};
|
||||||
if (direction != "row" && direction != "column") {
|
if (direction != "row" && direction != "column") {
|
||||||
LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, <direction> set to \""
|
LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, <direction> set to \""
|
||||||
<< direction << "\"";
|
<< direction << "\"";
|
||||||
|
@ -217,7 +217,7 @@ void BadgeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("lines")) {
|
if (elem->has("lines")) {
|
||||||
const float lines{elem->get<float>("lines")};
|
const float lines {elem->get<float>("lines")};
|
||||||
if (lines < 1.0f || lines > 10.0f) {
|
if (lines < 1.0f || lines > 10.0f) {
|
||||||
LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, <lines> set to \""
|
LOG(LogWarning) << "BadgeComponent: Invalid theme configuration, <lines> set to \""
|
||||||
<< lines << "\"";
|
<< lines << "\"";
|
||||||
|
@ -228,7 +228,7 @@ void BadgeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("itemsPerLine")) {
|
if (elem->has("itemsPerLine")) {
|
||||||
const float itemsPerLine{elem->get<float>("itemsPerLine")};
|
const float itemsPerLine {elem->get<float>("itemsPerLine")};
|
||||||
if (itemsPerLine < 1.0f || itemsPerLine > 10.0f) {
|
if (itemsPerLine < 1.0f || itemsPerLine > 10.0f) {
|
||||||
LOG(LogWarning)
|
LOG(LogWarning)
|
||||||
<< "BadgeComponent: Invalid theme configuration, <itemsPerLine> set to \""
|
<< "BadgeComponent: Invalid theme configuration, <itemsPerLine> set to \""
|
||||||
|
@ -295,10 +295,10 @@ void BadgeComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
FlexboxComponent::FlexboxItem item;
|
FlexboxComponent::FlexboxItem item;
|
||||||
item.label = slot;
|
item.label = slot;
|
||||||
|
|
||||||
ImageComponent badgeImage{mWindow, false, false};
|
ImageComponent badgeImage {mWindow, false, false};
|
||||||
badgeImage.setImage(mBadgeIcons[slot]);
|
badgeImage.setImage(mBadgeIcons[slot]);
|
||||||
item.baseImage = badgeImage;
|
item.baseImage = badgeImage;
|
||||||
item.overlayImage = ImageComponent{mWindow};
|
item.overlayImage = ImageComponent {mWindow};
|
||||||
|
|
||||||
mFlexboxItems.emplace_back(std::move(item));
|
mFlexboxItems.emplace_back(std::move(item));
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ const AnimationDef BUSY_ANIMATION_DEF = {BUSY_ANIMATION_FRAMES, 4, true};
|
||||||
BusyComponent::BusyComponent(Window* window)
|
BusyComponent::BusyComponent(Window* window)
|
||||||
: GuiComponent(window)
|
: GuiComponent(window)
|
||||||
, mBackground(window, ":/graphics/frame.png")
|
, mBackground(window, ":/graphics/frame.png")
|
||||||
, mGrid(window, glm::ivec2{5, 3})
|
, mGrid(window, glm::ivec2 {5, 3})
|
||||||
{
|
{
|
||||||
mAnimation = std::make_shared<AnimatedImageComponent>(mWindow);
|
mAnimation = std::make_shared<AnimatedImageComponent>(mWindow);
|
||||||
mAnimation->load(&BUSY_ANIMATION_DEF);
|
mAnimation->load(&BUSY_ANIMATION_DEF);
|
||||||
|
@ -33,8 +33,8 @@ BusyComponent::BusyComponent(Window* window)
|
||||||
0x777777FF);
|
0x777777FF);
|
||||||
|
|
||||||
// Col 0 = animation, col 1 = spacer, col 2 = text.
|
// Col 0 = animation, col 1 = spacer, col 2 = text.
|
||||||
mGrid.setEntry(mAnimation, glm::ivec2{1, 1}, false, true);
|
mGrid.setEntry(mAnimation, glm::ivec2 {1, 1}, false, true);
|
||||||
mGrid.setEntry(mText, glm::ivec2{3, 1}, false, true);
|
mGrid.setEntry(mText, glm::ivec2 {3, 1}, false, true);
|
||||||
|
|
||||||
addChild(&mBackground);
|
addChild(&mBackground);
|
||||||
addChild(&mGrid);
|
addChild(&mGrid);
|
||||||
|
@ -60,9 +60,9 @@ void BusyComponent::onSizeChanged()
|
||||||
|
|
||||||
mBackground.setCornerSize(
|
mBackground.setCornerSize(
|
||||||
{16.0f * Renderer::getScreenWidthModifier(), 16.0f * Renderer::getScreenHeightModifier()});
|
{16.0f * Renderer::getScreenWidthModifier(), 16.0f * Renderer::getScreenHeightModifier()});
|
||||||
mBackground.fitTo(glm::vec2{mGrid.getColWidth(1) + mGrid.getColWidth(2) + mGrid.getColWidth(3),
|
mBackground.fitTo(glm::vec2 {mGrid.getColWidth(1) + mGrid.getColWidth(2) + mGrid.getColWidth(3),
|
||||||
textHeight + (2.0f * Renderer::getScreenHeightModifier())},
|
textHeight + (2.0f * Renderer::getScreenHeightModifier())},
|
||||||
mAnimation->getPosition(), glm::vec2{});
|
mAnimation->getPosition(), glm::vec2 {});
|
||||||
}
|
}
|
||||||
|
|
||||||
void BusyComponent::reset()
|
void BusyComponent::reset()
|
||||||
|
|
|
@ -18,17 +18,17 @@ ButtonComponent::ButtonComponent(Window* window,
|
||||||
const std::function<void()>& func,
|
const std::function<void()>& func,
|
||||||
bool upperCase,
|
bool upperCase,
|
||||||
bool flatStyle)
|
bool flatStyle)
|
||||||
: GuiComponent{window}
|
: GuiComponent {window}
|
||||||
, mBox{window, ":/graphics/button.svg"}
|
, mBox {window, ":/graphics/button.svg"}
|
||||||
, mFont{Font::get(FONT_SIZE_MEDIUM)}
|
, mFont {Font::get(FONT_SIZE_MEDIUM)}
|
||||||
, mPadding{{}}
|
, mPadding {{}}
|
||||||
, mFocused{false}
|
, mFocused {false}
|
||||||
, mEnabled{true}
|
, mEnabled {true}
|
||||||
, mFlatStyle{flatStyle}
|
, mFlatStyle {flatStyle}
|
||||||
, mTextColorFocused{0xFFFFFFFF}
|
, mTextColorFocused {0xFFFFFFFF}
|
||||||
, mTextColorUnfocused{0x777777FF}
|
, mTextColorUnfocused {0x777777FF}
|
||||||
, mFlatColorFocused{0x878787FF}
|
, mFlatColorFocused {0x878787FF}
|
||||||
, mFlatColorUnfocused{0x60606025}
|
, mFlatColorUnfocused {0x60606025}
|
||||||
|
|
||||||
{
|
{
|
||||||
mBox.setSharpCorners(true);
|
mBox.setSharpCorners(true);
|
||||||
|
@ -46,9 +46,9 @@ void ButtonComponent::onSizeChanged()
|
||||||
|
|
||||||
auto cornerSize = mBox.getCornerSize();
|
auto cornerSize = mBox.getCornerSize();
|
||||||
|
|
||||||
mBox.fitTo(glm::vec2{mSize.x - mPadding.x - mPadding.z, mSize.y - mPadding.y - mPadding.w},
|
mBox.fitTo(glm::vec2 {mSize.x - mPadding.x - mPadding.z, mSize.y - mPadding.y - mPadding.w},
|
||||||
glm::vec3{mPadding.x, mPadding.y, 0.0f},
|
glm::vec3 {mPadding.x, mPadding.y, 0.0f},
|
||||||
glm::vec2{-cornerSize.x * 2.0f, -cornerSize.y * 2.0f});
|
glm::vec2 {-cornerSize.x * 2.0f, -cornerSize.y * 2.0f});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ButtonComponent::onFocusGained()
|
void ButtonComponent::onFocusGained()
|
||||||
|
@ -110,7 +110,7 @@ bool ButtonComponent::input(InputConfig* config, Input input)
|
||||||
|
|
||||||
void ButtonComponent::render(const glm::mat4& parentTrans)
|
void ButtonComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
|
|
||||||
if (mFlatStyle) {
|
if (mFlatStyle) {
|
||||||
if (mFocused) {
|
if (mFocused) {
|
||||||
|
@ -131,8 +131,8 @@ void ButtonComponent::render(const glm::mat4& parentTrans)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTextCache) {
|
if (mTextCache) {
|
||||||
glm::vec3 centerOffset{(mSize.x - mTextCache->metrics.size.x) / 2.0f,
|
glm::vec3 centerOffset {(mSize.x - mTextCache->metrics.size.x) / 2.0f,
|
||||||
(mSize.y - mTextCache->metrics.size.y) / 2.0f, 0.0f};
|
(mSize.y - mTextCache->metrics.size.y) / 2.0f, 0.0f};
|
||||||
trans = glm::translate(trans, centerOffset);
|
trans = glm::translate(trans, centerOffset);
|
||||||
|
|
||||||
if (Settings::getInstance()->getBool("DebugText")) {
|
if (Settings::getInstance()->getBool("DebugText")) {
|
||||||
|
|
|
@ -136,17 +136,17 @@ bool ComponentGrid::removeEntry(const std::shared_ptr<GuiComponent>& comp)
|
||||||
void ComponentGrid::updateCellComponent(const GridEntry& cell)
|
void ComponentGrid::updateCellComponent(const GridEntry& cell)
|
||||||
{
|
{
|
||||||
// Size.
|
// Size.
|
||||||
glm::vec2 size{0.0f};
|
glm::vec2 size {0.0f};
|
||||||
for (int x = cell.pos.x; x < cell.pos.x + cell.dim.x; ++x)
|
for (int x = cell.pos.x; x < cell.pos.x + cell.dim.x; ++x)
|
||||||
size.x += getColWidth(x);
|
size.x += getColWidth(x);
|
||||||
for (int y = cell.pos.y; y < cell.pos.y + cell.dim.y; ++y)
|
for (int y = cell.pos.y; y < cell.pos.y + cell.dim.y; ++y)
|
||||||
size.y += getRowHeight(y);
|
size.y += getRowHeight(y);
|
||||||
|
|
||||||
if (cell.resize && size != glm::vec2{} && cell.component->getSize() != size)
|
if (cell.resize && size != glm::vec2 {} && cell.component->getSize() != size)
|
||||||
cell.component->setSize(size);
|
cell.component->setSize(size);
|
||||||
|
|
||||||
// Find top left corner.
|
// Find top left corner.
|
||||||
glm::vec3 pos{};
|
glm::vec3 pos {};
|
||||||
for (int x = 0; x < cell.pos.x; ++x)
|
for (int x = 0; x < cell.pos.x; ++x)
|
||||||
pos.x += getColWidth(x);
|
pos.x += getColWidth(x);
|
||||||
for (int y = 0; y < cell.pos.y; ++y)
|
for (int y = 0; y < cell.pos.y; ++y)
|
||||||
|
@ -173,8 +173,8 @@ void ComponentGrid::updateSeparators()
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Find component position + size.
|
// Find component position + size.
|
||||||
pos = glm::vec2{};
|
pos = glm::vec2 {};
|
||||||
size = glm::vec2{};
|
size = glm::vec2 {};
|
||||||
for (int x = 0; x < it->pos.x; ++x)
|
for (int x = 0; x < it->pos.x; ++x)
|
||||||
pos[0] += getColWidth(x);
|
pos[0] += getColWidth(x);
|
||||||
for (int y = 0; y < it->pos.y; ++y)
|
for (int y = 0; y < it->pos.y; ++y)
|
||||||
|
@ -184,7 +184,7 @@ void ComponentGrid::updateSeparators()
|
||||||
for (int y = it->pos.y; y < it->pos.y + it->dim.y; ++y)
|
for (int y = it->pos.y; y < it->pos.y + it->dim.y; ++y)
|
||||||
size[1] += getRowHeight(y);
|
size[1] += getRowHeight(y);
|
||||||
|
|
||||||
if (size == glm::vec2{})
|
if (size == glm::vec2 {})
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (it->border & BORDER_TOP || drawAll) {
|
if (it->border & BORDER_TOP || drawAll) {
|
||||||
|
@ -259,16 +259,16 @@ bool ComponentGrid::input(InputConfig* config, Input input)
|
||||||
bool withinBoundary = false;
|
bool withinBoundary = false;
|
||||||
|
|
||||||
if (config->isMappedLike("down", input))
|
if (config->isMappedLike("down", input))
|
||||||
withinBoundary = moveCursor(glm::ivec2{0, 1});
|
withinBoundary = moveCursor(glm::ivec2 {0, 1});
|
||||||
|
|
||||||
if (config->isMappedLike("up", input))
|
if (config->isMappedLike("up", input))
|
||||||
withinBoundary = moveCursor(glm::ivec2{0, -1});
|
withinBoundary = moveCursor(glm::ivec2 {0, -1});
|
||||||
|
|
||||||
if (config->isMappedLike("left", input))
|
if (config->isMappedLike("left", input))
|
||||||
withinBoundary = moveCursor(glm::ivec2{-1, 0});
|
withinBoundary = moveCursor(glm::ivec2 {-1, 0});
|
||||||
|
|
||||||
if (config->isMappedLike("right", input))
|
if (config->isMappedLike("right", input))
|
||||||
withinBoundary = moveCursor(glm::ivec2{1, 0});
|
withinBoundary = moveCursor(glm::ivec2 {1, 0});
|
||||||
|
|
||||||
if (!withinBoundary && mPastBoundaryCallback)
|
if (!withinBoundary && mPastBoundaryCallback)
|
||||||
return mPastBoundaryCallback(config, input);
|
return mPastBoundaryCallback(config, input);
|
||||||
|
@ -295,21 +295,21 @@ bool ComponentGrid::moveCursor(glm::ivec2 dir)
|
||||||
{
|
{
|
||||||
assert(dir.x || dir.y);
|
assert(dir.x || dir.y);
|
||||||
|
|
||||||
const glm::ivec2 origCursor{mCursor};
|
const glm::ivec2 origCursor {mCursor};
|
||||||
const GridEntry* currentCursorEntry = getCellAt(mCursor);
|
const GridEntry* currentCursorEntry = getCellAt(mCursor);
|
||||||
glm::ivec2 searchAxis(dir.x == 0, dir.y == 0);
|
glm::ivec2 searchAxis(dir.x == 0, dir.y == 0);
|
||||||
|
|
||||||
// Logic to handle entries that span several cells.
|
// Logic to handle entries that span several cells.
|
||||||
if (currentCursorEntry->dim.x > 1) {
|
if (currentCursorEntry->dim.x > 1) {
|
||||||
if (dir.x < 0 && currentCursorEntry->pos.x == 0 && mCursor.x > currentCursorEntry->pos.x) {
|
if (dir.x < 0 && currentCursorEntry->pos.x == 0 && mCursor.x > currentCursorEntry->pos.x) {
|
||||||
onCursorMoved(mCursor, glm::ivec2{0, mCursor.y});
|
onCursorMoved(mCursor, glm::ivec2 {0, mCursor.y});
|
||||||
mCursor.x = 0;
|
mCursor.x = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dir.x > 0 && currentCursorEntry->pos.x + currentCursorEntry->dim.x == mGridSize.x &&
|
if (dir.x > 0 && currentCursorEntry->pos.x + currentCursorEntry->dim.x == mGridSize.x &&
|
||||||
mCursor.x < currentCursorEntry->pos.x + currentCursorEntry->dim.x - 1) {
|
mCursor.x < currentCursorEntry->pos.x + currentCursorEntry->dim.x - 1) {
|
||||||
onCursorMoved(mCursor, glm::ivec2{mGridSize.x - 1, mCursor.y});
|
onCursorMoved(mCursor, glm::ivec2 {mGridSize.x - 1, mCursor.y});
|
||||||
mCursor.x = mGridSize.x - 1;
|
mCursor.x = mGridSize.x - 1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ bool ComponentGrid::moveCursor(glm::ivec2 dir)
|
||||||
|
|
||||||
while (mCursor.x >= 0 && mCursor.y >= 0 && mCursor.x < mGridSize.x && mCursor.y < mGridSize.y) {
|
while (mCursor.x >= 0 && mCursor.y >= 0 && mCursor.x < mGridSize.x && mCursor.y < mGridSize.y) {
|
||||||
mCursor = mCursor + dir;
|
mCursor = mCursor + dir;
|
||||||
glm::ivec2 curDirPos{mCursor};
|
glm::ivec2 curDirPos {mCursor};
|
||||||
const GridEntry* cursorEntry;
|
const GridEntry* cursorEntry;
|
||||||
|
|
||||||
// Spread out on search axis+
|
// Spread out on search axis+
|
||||||
|
@ -374,7 +374,7 @@ bool ComponentGrid::moveCursor(glm::ivec2 dir)
|
||||||
|
|
||||||
void ComponentGrid::moveCursorTo(int xPos, int yPos, bool selectLeftCell)
|
void ComponentGrid::moveCursorTo(int xPos, int yPos, bool selectLeftCell)
|
||||||
{
|
{
|
||||||
const glm::ivec2 origCursor{mCursor};
|
const glm::ivec2 origCursor {mCursor};
|
||||||
|
|
||||||
if (xPos != -1)
|
if (xPos != -1)
|
||||||
mCursor.x = xPos;
|
mCursor.x = xPos;
|
||||||
|
@ -424,7 +424,7 @@ void ComponentGrid::update(int deltaTime)
|
||||||
|
|
||||||
void ComponentGrid::render(const glm::mat4& parentTrans)
|
void ComponentGrid::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
|
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ void ComponentGrid::setCursorTo(const std::shared_ptr<GuiComponent>& comp)
|
||||||
{
|
{
|
||||||
for (auto it = mCells.cbegin(); it != mCells.cend(); ++it) {
|
for (auto it = mCells.cbegin(); it != mCells.cend(); ++it) {
|
||||||
if (it->component == comp) {
|
if (it->component == comp) {
|
||||||
glm::ivec2 oldCursor{mCursor};
|
glm::ivec2 oldCursor {mCursor};
|
||||||
mCursor = it->pos;
|
mCursor = it->pos;
|
||||||
onCursorMoved(oldCursor, mCursor);
|
onCursorMoved(oldCursor, mCursor);
|
||||||
return;
|
return;
|
||||||
|
@ -484,12 +484,12 @@ std::vector<HelpPrompt> ComponentGrid::getHelpPrompts()
|
||||||
// above or below are actually focusable as otherwise they should not affect the help prompts.
|
// above or below are actually focusable as otherwise they should not affect the help prompts.
|
||||||
if (mGridSize.y > 1 && e->dim.y < mGridSize.y) {
|
if (mGridSize.y > 1 && e->dim.y < mGridSize.y) {
|
||||||
if (e->pos.y - e->dim.y >= 0) {
|
if (e->pos.y - e->dim.y >= 0) {
|
||||||
const GridEntry* cell = getCellAt(glm::ivec2{e->pos.x, e->pos.y - e->dim.y});
|
const GridEntry* cell = getCellAt(glm::ivec2 {e->pos.x, e->pos.y - e->dim.y});
|
||||||
if (cell != nullptr && cell->canFocus)
|
if (cell != nullptr && cell->canFocus)
|
||||||
canScrollVert = true;
|
canScrollVert = true;
|
||||||
}
|
}
|
||||||
if (e->pos.y + e->dim.y < mGridSize.y) {
|
if (e->pos.y + e->dim.y < mGridSize.y) {
|
||||||
const GridEntry* cell = getCellAt(glm::ivec2{e->pos.x, e->pos.y + e->dim.y});
|
const GridEntry* cell = getCellAt(glm::ivec2 {e->pos.x, e->pos.y + e->dim.y});
|
||||||
if (cell != nullptr && cell->canFocus)
|
if (cell != nullptr && cell->canFocus)
|
||||||
canScrollVert = true;
|
canScrollVert = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
const glm::ivec2& pos,
|
const glm::ivec2& pos,
|
||||||
bool canFocus,
|
bool canFocus,
|
||||||
bool resize = true,
|
bool resize = true,
|
||||||
const glm::ivec2& size = glm::ivec2{1, 1},
|
const glm::ivec2& size = glm::ivec2 {1, 1},
|
||||||
unsigned int border = GridFlags::BORDER_NONE,
|
unsigned int border = GridFlags::BORDER_NONE,
|
||||||
GridFlags::UpdateType updateType = GridFlags::UPDATE_ALWAYS);
|
GridFlags::UpdateType updateType = GridFlags::UPDATE_ALWAYS);
|
||||||
|
|
||||||
|
@ -100,8 +100,8 @@ private:
|
||||||
GridFlags::UpdateType updateType;
|
GridFlags::UpdateType updateType;
|
||||||
unsigned int border;
|
unsigned int border;
|
||||||
|
|
||||||
GridEntry(const glm::ivec2& p = glm::ivec2{},
|
GridEntry(const glm::ivec2& p = glm::ivec2 {},
|
||||||
const glm::ivec2& d = glm::ivec2{},
|
const glm::ivec2& d = glm::ivec2 {},
|
||||||
const std::shared_ptr<GuiComponent>& cmp = nullptr,
|
const std::shared_ptr<GuiComponent>& cmp = nullptr,
|
||||||
bool f = false,
|
bool f = false,
|
||||||
bool r = true,
|
bool r = true,
|
||||||
|
|
|
@ -13,23 +13,23 @@
|
||||||
#define TOTAL_HORIZONTAL_PADDING_PX 20.0f
|
#define TOTAL_HORIZONTAL_PADDING_PX 20.0f
|
||||||
|
|
||||||
ComponentList::ComponentList(Window* window)
|
ComponentList::ComponentList(Window* window)
|
||||||
: IList<ComponentListRow, void*>{window, LIST_SCROLL_STYLE_SLOW, LIST_NEVER_LOOP}
|
: IList<ComponentListRow, void*> {window, LIST_SCROLL_STYLE_SLOW, LIST_NEVER_LOOP}
|
||||||
, mFocused{false}
|
, mFocused {false}
|
||||||
, mSetupCompleted{false}
|
, mSetupCompleted {false}
|
||||||
, mBottomCameraOffset{false}
|
, mBottomCameraOffset {false}
|
||||||
, mSingleRowScroll{false}
|
, mSingleRowScroll {false}
|
||||||
, mSelectorBarOffset{0.0f}
|
, mSelectorBarOffset {0.0f}
|
||||||
, mCameraOffset{0.0f}
|
, mCameraOffset {0.0f}
|
||||||
, mLoopRows{false}
|
, mLoopRows {false}
|
||||||
, mLoopScroll{false}
|
, mLoopScroll {false}
|
||||||
, mLoopOffset{0}
|
, mLoopOffset {0}
|
||||||
, mLoopOffset2{0}
|
, mLoopOffset2 {0}
|
||||||
, mLoopTime{0}
|
, mLoopTime {0}
|
||||||
, mScrollIndicatorStatus{SCROLL_NONE}
|
, mScrollIndicatorStatus {SCROLL_NONE}
|
||||||
{
|
{
|
||||||
// Adjust the padding relative to the aspect ratio and screen resolution to make it look
|
// Adjust the padding relative to the aspect ratio and screen resolution to make it look
|
||||||
// coherent regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference.
|
// coherent regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference.
|
||||||
float aspectValue{1.778f / Renderer::getScreenAspectRatio()};
|
float aspectValue {1.778f / Renderer::getScreenAspectRatio()};
|
||||||
mHorizontalPadding =
|
mHorizontalPadding =
|
||||||
TOTAL_HORIZONTAL_PADDING_PX * aspectValue * Renderer::getScreenWidthModifier();
|
TOTAL_HORIZONTAL_PADDING_PX * aspectValue * Renderer::getScreenWidthModifier();
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ void ComponentList::update(int deltaTime)
|
||||||
listUpdate(deltaTime);
|
listUpdate(deltaTime);
|
||||||
|
|
||||||
if (size()) {
|
if (size()) {
|
||||||
float rowWidth{0.0f};
|
float rowWidth {0.0f};
|
||||||
|
|
||||||
// Update our currently selected row.
|
// Update our currently selected row.
|
||||||
for (auto it = mEntries.at(mCursor).data.elements.cbegin();
|
for (auto it = mEntries.at(mCursor).data.elements.cbegin();
|
||||||
|
@ -176,14 +176,14 @@ void ComponentList::update(int deltaTime)
|
||||||
|
|
||||||
if (mLoopRows && rowWidth + mHorizontalPadding / 2.0f > mSize.x) {
|
if (mLoopRows && rowWidth + mHorizontalPadding / 2.0f > mSize.x) {
|
||||||
// Loop the text.
|
// Loop the text.
|
||||||
const float speed{
|
const float speed {
|
||||||
Font::get(FONT_SIZE_MEDIUM)->sizeText("ABCDEFGHIJKLMNOPQRSTUVWXYZ").x * 0.247f};
|
Font::get(FONT_SIZE_MEDIUM)->sizeText("ABCDEFGHIJKLMNOPQRSTUVWXYZ").x * 0.247f};
|
||||||
const float delay{1500.0f};
|
const float delay {1500.0f};
|
||||||
const float scrollLength{rowWidth};
|
const float scrollLength {rowWidth};
|
||||||
const float returnLength{speed * 1.5f};
|
const float returnLength {speed * 1.5f};
|
||||||
const float scrollTime{(scrollLength * 1000.0f) / speed};
|
const float scrollTime {(scrollLength * 1000.0f) / speed};
|
||||||
const float returnTime{(returnLength * 1000.0f) / speed};
|
const float returnTime {(returnLength * 1000.0f) / speed};
|
||||||
const int maxTime{static_cast<int>(delay + scrollTime + returnTime)};
|
const int maxTime {static_cast<int>(delay + scrollTime + returnTime)};
|
||||||
|
|
||||||
mLoopTime += deltaTime;
|
mLoopTime += deltaTime;
|
||||||
while (mLoopTime > maxTime)
|
while (mLoopTime > maxTime)
|
||||||
|
@ -282,25 +282,25 @@ void ComponentList::render(const glm::mat4& parentTrans)
|
||||||
if (!size())
|
if (!size())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
|
|
||||||
// Clip everything to be inside our bounds.
|
// Clip everything to be inside our bounds.
|
||||||
glm::vec3 dim{mSize.x, mSize.y, 0.0f};
|
glm::vec3 dim {mSize.x, mSize.y, 0.0f};
|
||||||
dim.x = (trans[0].x * dim.x + trans[3].x) - trans[3].x;
|
dim.x = (trans[0].x * dim.x + trans[3].x) - trans[3].x;
|
||||||
dim.y = (trans[1].y * dim.y + trans[3].y) - trans[3].y;
|
dim.y = (trans[1].y * dim.y + trans[3].y) - trans[3].y;
|
||||||
|
|
||||||
const int clipRectPosX{static_cast<int>(std::ceil(trans[3].x))};
|
const int clipRectPosX {static_cast<int>(std::ceil(trans[3].x))};
|
||||||
const int clipRectPosY{static_cast<int>(std::round(trans[3].y))};
|
const int clipRectPosY {static_cast<int>(std::round(trans[3].y))};
|
||||||
const int clipRectSizeX{static_cast<int>(std::round(dim.x))};
|
const int clipRectSizeX {static_cast<int>(std::round(dim.x))};
|
||||||
const int clipRectSizeY{static_cast<int>(std::round(dim.y))};
|
const int clipRectSizeY {static_cast<int>(std::round(dim.y))};
|
||||||
|
|
||||||
Renderer::pushClipRect(glm::ivec2{clipRectPosX, clipRectPosY},
|
Renderer::pushClipRect(glm::ivec2 {clipRectPosX, clipRectPosY},
|
||||||
glm::ivec2{clipRectSizeX, clipRectSizeY});
|
glm::ivec2 {clipRectSizeX, clipRectSizeY});
|
||||||
|
|
||||||
// Scroll the camera.
|
// Scroll the camera.
|
||||||
trans = glm::translate(trans, glm::vec3{0.0f, -mCameraOffset, 0.0f});
|
trans = glm::translate(trans, glm::vec3 {0.0f, -mCameraOffset, 0.0f});
|
||||||
|
|
||||||
glm::mat4 loopTrans{trans};
|
glm::mat4 loopTrans {trans};
|
||||||
|
|
||||||
// Draw our entries.
|
// Draw our entries.
|
||||||
std::vector<GuiComponent*> drawAfterCursor;
|
std::vector<GuiComponent*> drawAfterCursor;
|
||||||
|
@ -309,7 +309,7 @@ void ComponentList::render(const glm::mat4& parentTrans)
|
||||||
|
|
||||||
if (mLoopRows && mFocused && mLoopOffset > 0) {
|
if (mLoopRows && mFocused && mLoopOffset > 0) {
|
||||||
loopTrans =
|
loopTrans =
|
||||||
glm::translate(trans, glm::vec3{static_cast<float>(-mLoopOffset), 0.0f, 0.0f});
|
glm::translate(trans, glm::vec3 {static_cast<float>(-mLoopOffset), 0.0f, 0.0f});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& entry = mEntries.at(i);
|
auto& entry = mEntries.at(i);
|
||||||
|
@ -325,7 +325,7 @@ void ComponentList::render(const glm::mat4& parentTrans)
|
||||||
if (mLoopOffset2 < 0 || mLoopScroll) {
|
if (mLoopOffset2 < 0 || mLoopScroll) {
|
||||||
mLoopScroll = true;
|
mLoopScroll = true;
|
||||||
loopTrans = glm::translate(
|
loopTrans = glm::translate(
|
||||||
trans, glm::vec3{static_cast<float>(-mLoopOffset2), 0.0f, 0.0f});
|
trans, glm::vec3 {static_cast<float>(-mLoopOffset2), 0.0f, 0.0f});
|
||||||
it->component->render(loopTrans);
|
it->component->render(loopTrans);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,18 +16,18 @@
|
||||||
#include "utils/StringUtil.h"
|
#include "utils/StringUtil.h"
|
||||||
|
|
||||||
DateTimeEditComponent::DateTimeEditComponent(Window* window, bool alignRight, DisplayMode dispMode)
|
DateTimeEditComponent::DateTimeEditComponent(Window* window, bool alignRight, DisplayMode dispMode)
|
||||||
: GuiComponent{window}
|
: GuiComponent {window}
|
||||||
, mEditing{false}
|
, mEditing {false}
|
||||||
, mEditIndex{0}
|
, mEditIndex {0}
|
||||||
, mDisplayMode{dispMode}
|
, mDisplayMode {dispMode}
|
||||||
, mKeyRepeatDir{0}
|
, mKeyRepeatDir {0}
|
||||||
, mKeyRepeatTimer{0}
|
, mKeyRepeatTimer {0}
|
||||||
, mRelativeUpdateAccumulator{0}
|
, mRelativeUpdateAccumulator {0}
|
||||||
, mColor{0x777777FF}
|
, mColor {0x777777FF}
|
||||||
, mFont{Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT)}
|
, mFont {Font::get(FONT_SIZE_SMALL, FONT_PATH_LIGHT)}
|
||||||
, mAlignRight{alignRight}
|
, mAlignRight {alignRight}
|
||||||
, mUppercase{false}
|
, mUppercase {false}
|
||||||
, mAutoSize{true}
|
, mAutoSize {true}
|
||||||
{
|
{
|
||||||
updateTextCache();
|
updateTextCache();
|
||||||
}
|
}
|
||||||
|
@ -166,17 +166,17 @@ void DateTimeEditComponent::update(int deltaTime)
|
||||||
|
|
||||||
void DateTimeEditComponent::render(const glm::mat4& parentTrans)
|
void DateTimeEditComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
|
|
||||||
if (mTextCache) {
|
if (mTextCache) {
|
||||||
std::shared_ptr<Font> font = getFont();
|
std::shared_ptr<Font> font = getFont();
|
||||||
float referenceSize{0.0f};
|
float referenceSize {0.0f};
|
||||||
|
|
||||||
if (mAlignRight)
|
if (mAlignRight)
|
||||||
referenceSize = std::round(mParent->getSize().x * 0.1045f);
|
referenceSize = std::round(mParent->getSize().x * 0.1045f);
|
||||||
|
|
||||||
// Vertically center.
|
// Vertically center.
|
||||||
glm::vec3 off{0.0f, (mSize.y - mTextCache->metrics.size.y) / 2.0f, 0.0f};
|
glm::vec3 off {0.0f, (mSize.y - mTextCache->metrics.size.y) / 2.0f, 0.0f};
|
||||||
|
|
||||||
if (mAlignRight)
|
if (mAlignRight)
|
||||||
off.x += referenceSize - mTextCache->metrics.size.x;
|
off.x += referenceSize - mTextCache->metrics.size.x;
|
||||||
|
@ -389,22 +389,22 @@ void DateTimeEditComponent::updateTextCache()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Year.
|
// Year.
|
||||||
glm::vec2 start{};
|
glm::vec2 start {};
|
||||||
glm::vec2 end{font->sizeText(dispString.substr(0, 4))};
|
glm::vec2 end {font->sizeText(dispString.substr(0, 4))};
|
||||||
glm::vec2 diff{end - start};
|
glm::vec2 diff {end - start};
|
||||||
mCursorBoxes.push_back(glm::vec4{start[0], start[1], diff[0], diff[1]});
|
mCursorBoxes.push_back(glm::vec4 {start[0], start[1], diff[0], diff[1]});
|
||||||
|
|
||||||
// Month.
|
// Month.
|
||||||
start[0] = font->sizeText(dispString.substr(0, 5)).x;
|
start[0] = font->sizeText(dispString.substr(0, 5)).x;
|
||||||
end = font->sizeText(dispString.substr(0, 7));
|
end = font->sizeText(dispString.substr(0, 7));
|
||||||
diff = end - start;
|
diff = end - start;
|
||||||
mCursorBoxes.push_back(glm::vec4{start[0], start[1], diff[0], diff[1]});
|
mCursorBoxes.push_back(glm::vec4 {start[0], start[1], diff[0], diff[1]});
|
||||||
|
|
||||||
// Day.
|
// Day.
|
||||||
start[0] = font->sizeText(dispString.substr(0, 8)).x;
|
start[0] = font->sizeText(dispString.substr(0, 8)).x;
|
||||||
end = font->sizeText(dispString.substr(0, 10));
|
end = font->sizeText(dispString.substr(0, 10));
|
||||||
diff = end - start;
|
diff = end - start;
|
||||||
mCursorBoxes.push_back(glm::vec4{start[0], start[1], diff[0], diff[1]});
|
mCursorBoxes.push_back(glm::vec4 {start[0], start[1], diff[0], diff[1]});
|
||||||
|
|
||||||
// The logic for handling time for 'mode = DISP_DATE_TIME' is missing, but
|
// The logic for handling time for 'mode = DISP_DATE_TIME' is missing, but
|
||||||
// nobody will use it anyway so it's not worthwhile implementing.
|
// nobody will use it anyway so it's not worthwhile implementing.
|
||||||
|
|
|
@ -20,17 +20,17 @@
|
||||||
#include "ThemeData.h"
|
#include "ThemeData.h"
|
||||||
|
|
||||||
FlexboxComponent::FlexboxComponent(Window* window, std::vector<FlexboxItem>& items)
|
FlexboxComponent::FlexboxComponent(Window* window, std::vector<FlexboxItem>& items)
|
||||||
: GuiComponent{window}
|
: GuiComponent {window}
|
||||||
, mItems(items)
|
, mItems(items)
|
||||||
, mDirection{DEFAULT_DIRECTION}
|
, mDirection {DEFAULT_DIRECTION}
|
||||||
, mAlignment{DEFAULT_ALIGNMENT}
|
, mAlignment {DEFAULT_ALIGNMENT}
|
||||||
, mLines{DEFAULT_LINES}
|
, mLines {DEFAULT_LINES}
|
||||||
, mItemsPerLine{DEFAULT_ITEMS_PER_LINE}
|
, mItemsPerLine {DEFAULT_ITEMS_PER_LINE}
|
||||||
, mItemPlacement{DEFAULT_ITEM_PLACEMENT}
|
, mItemPlacement {DEFAULT_ITEM_PLACEMENT}
|
||||||
, mItemMargin{glm::vec2{DEFAULT_MARGIN_X, DEFAULT_MARGIN_Y}}
|
, mItemMargin {glm::vec2 {DEFAULT_MARGIN_X, DEFAULT_MARGIN_Y}}
|
||||||
, mOverlayPosition{0.5f, 0.5f}
|
, mOverlayPosition {0.5f, 0.5f}
|
||||||
, mOverlaySize{0.5f}
|
, mOverlaySize {0.5f}
|
||||||
, mLayoutValid{false}
|
, mLayoutValid {false}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ void FlexboxComponent::render(const glm::mat4& parentTrans)
|
||||||
if (!mLayoutValid)
|
if (!mLayoutValid)
|
||||||
computeLayout();
|
computeLayout();
|
||||||
|
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
if (Settings::getInstance()->getBool("DebugImage"))
|
if (Settings::getInstance()->getBool("DebugImage"))
|
||||||
|
@ -105,24 +105,24 @@ void FlexboxComponent::computeLayout()
|
||||||
mItemsPerLine = static_cast<unsigned int>(mItems.size());
|
mItemsPerLine = static_cast<unsigned int>(mItems.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 grid{};
|
glm::vec2 grid {};
|
||||||
|
|
||||||
if (mDirection == "row")
|
if (mDirection == "row")
|
||||||
grid = {mItemsPerLine, mLines};
|
grid = {mItemsPerLine, mLines};
|
||||||
else
|
else
|
||||||
grid = {mLines, mItemsPerLine};
|
grid = {mLines, mItemsPerLine};
|
||||||
|
|
||||||
glm::vec2 maxItemSize{(mSize + mItemMargin - grid * mItemMargin) / grid};
|
glm::vec2 maxItemSize {(mSize + mItemMargin - grid * mItemMargin) / grid};
|
||||||
|
|
||||||
float rowHeight{0.0f};
|
float rowHeight {0.0f};
|
||||||
bool firstItem{true};
|
bool firstItem {true};
|
||||||
|
|
||||||
// Calculate maximum item dimensions.
|
// Calculate maximum item dimensions.
|
||||||
for (auto& item : mItems) {
|
for (auto& item : mItems) {
|
||||||
if (!item.visible)
|
if (!item.visible)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
glm::vec2 sizeDiff{item.baseImage.getSize() / maxItemSize};
|
glm::vec2 sizeDiff {item.baseImage.getSize() / maxItemSize};
|
||||||
|
|
||||||
// The first item dictates the maximum width for the rest.
|
// The first item dictates the maximum width for the rest.
|
||||||
if (firstItem) {
|
if (firstItem) {
|
||||||
|
@ -150,8 +150,8 @@ void FlexboxComponent::computeLayout()
|
||||||
|
|
||||||
maxItemSize = glm::round(maxItemSize);
|
maxItemSize = glm::round(maxItemSize);
|
||||||
|
|
||||||
bool alignRight{mAlignment == "right"};
|
bool alignRight {mAlignment == "right"};
|
||||||
float alignRightComp{0.0f};
|
float alignRightComp {0.0f};
|
||||||
|
|
||||||
// If right-aligning, move the overall container contents during grid setup.
|
// If right-aligning, move the overall container contents during grid setup.
|
||||||
if (alignRight && mDirection == "row")
|
if (alignRight && mDirection == "row")
|
||||||
|
@ -165,16 +165,16 @@ void FlexboxComponent::computeLayout()
|
||||||
for (int y = 0; y < grid.y; ++y) {
|
for (int y = 0; y < grid.y; ++y) {
|
||||||
for (int x = 0; x < grid.x; ++x) {
|
for (int x = 0; x < grid.x; ++x) {
|
||||||
itemPositions.emplace_back(
|
itemPositions.emplace_back(
|
||||||
glm::vec2{(x * (maxItemSize.x + mItemMargin.x) + alignRightComp),
|
glm::vec2 {(x * (maxItemSize.x + mItemMargin.x) + alignRightComp),
|
||||||
y * (rowHeight + mItemMargin.y)});
|
y * (rowHeight + mItemMargin.y)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mDirection == "column" && !alignRight) {
|
else if (mDirection == "column" && !alignRight) {
|
||||||
for (int x = 0; x < grid.x; ++x) {
|
for (int x = 0; x < grid.x; ++x) {
|
||||||
for (int y = 0; y < grid.y; ++y) {
|
for (int y = 0; y < grid.y; ++y) {
|
||||||
itemPositions.emplace_back(glm::vec2{(x * (maxItemSize.x + mItemMargin.x)),
|
itemPositions.emplace_back(glm::vec2 {(x * (maxItemSize.x + mItemMargin.x)),
|
||||||
y * (rowHeight + mItemMargin.y)});
|
y * (rowHeight + mItemMargin.y)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,15 +182,15 @@ void FlexboxComponent::computeLayout()
|
||||||
for (int x = 0; x < grid.x; ++x) {
|
for (int x = 0; x < grid.x; ++x) {
|
||||||
for (int y = 0; y < grid.y; ++y) {
|
for (int y = 0; y < grid.y; ++y) {
|
||||||
itemPositions.emplace_back(
|
itemPositions.emplace_back(
|
||||||
glm::vec2{(mSize.x - (x * (maxItemSize.x + mItemMargin.x)) - maxItemSize.x),
|
glm::vec2 {(mSize.x - (x * (maxItemSize.x + mItemMargin.x)) - maxItemSize.x),
|
||||||
y * (rowHeight + mItemMargin.y)});
|
y * (rowHeight + mItemMargin.y)});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int pos{0};
|
int pos {0};
|
||||||
float lastY{0.0f};
|
float lastY {0.0f};
|
||||||
float itemsOnLastRow{0};
|
float itemsOnLastRow {0};
|
||||||
|
|
||||||
// Position items on the grid.
|
// Position items on the grid.
|
||||||
for (auto& item : mItems) {
|
for (auto& item : mItems) {
|
||||||
|
@ -204,7 +204,7 @@ void FlexboxComponent::computeLayout()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float verticalOffset{0.0f};
|
float verticalOffset {0.0f};
|
||||||
|
|
||||||
// For any items that do not fill the maximum height, position these either on
|
// For any items that do not fill the maximum height, position these either on
|
||||||
// top/start (implicit), center or bottom/end.
|
// top/start (implicit), center or bottom/end.
|
||||||
|
@ -242,9 +242,9 @@ void FlexboxComponent::computeLayout()
|
||||||
for (auto& item : mItems) {
|
for (auto& item : mItems) {
|
||||||
if (!item.visible)
|
if (!item.visible)
|
||||||
continue;
|
continue;
|
||||||
glm::vec3 currPos{item.baseImage.getPosition()};
|
glm::vec3 currPos {item.baseImage.getPosition()};
|
||||||
if (currPos.y == lastY) {
|
if (currPos.y == lastY) {
|
||||||
const float offset{(grid.x - itemsOnLastRow) * (maxItemSize.x + mItemMargin.x)};
|
const float offset {(grid.x - itemsOnLastRow) * (maxItemSize.x + mItemMargin.x)};
|
||||||
item.baseImage.setPosition(currPos.x + offset, currPos.y, currPos.z);
|
item.baseImage.setPosition(currPos.x + offset, currPos.y, currPos.z);
|
||||||
if (item.overlayImage.getTexture() != nullptr) {
|
if (item.overlayImage.getTexture() != nullptr) {
|
||||||
currPos = item.overlayImage.getPosition();
|
currPos = item.overlayImage.getPosition();
|
||||||
|
|
|
@ -20,9 +20,9 @@ public:
|
||||||
// Optional label, mostly a convenience for the calling class to track items.
|
// Optional label, mostly a convenience for the calling class to track items.
|
||||||
std::string label;
|
std::string label;
|
||||||
// Main image that governs grid sizing and placement.
|
// Main image that governs grid sizing and placement.
|
||||||
ImageComponent baseImage{nullptr};
|
ImageComponent baseImage {nullptr};
|
||||||
// Optional overlay image that can be sized and positioned relative to the base image.
|
// Optional overlay image that can be sized and positioned relative to the base image.
|
||||||
ImageComponent overlayImage{nullptr};
|
ImageComponent overlayImage {nullptr};
|
||||||
bool visible = false;
|
bool visible = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -17,12 +17,12 @@ GridTileComponent::GridTileComponent(Window* window)
|
||||||
, mBackground(window, ":/graphics/frame.png")
|
, mBackground(window, ":/graphics/frame.png")
|
||||||
{
|
{
|
||||||
mDefaultProperties.mSize = getDefaultTileSize();
|
mDefaultProperties.mSize = getDefaultTileSize();
|
||||||
mDefaultProperties.mPadding = glm::vec2{16.0f * Renderer::getScreenWidthModifier(),
|
mDefaultProperties.mPadding = glm::vec2 {16.0f * Renderer::getScreenWidthModifier(),
|
||||||
16.0f * Renderer::getScreenHeightModifier()};
|
16.0f * Renderer::getScreenHeightModifier()};
|
||||||
mDefaultProperties.mImageColor = 0xAAAAAABB;
|
mDefaultProperties.mImageColor = 0xAAAAAABB;
|
||||||
// Attempting to use frame.svg instead causes quite severe performance problems.
|
// Attempting to use frame.svg instead causes quite severe performance problems.
|
||||||
mDefaultProperties.mBackgroundImage = ":/graphics/frame.png";
|
mDefaultProperties.mBackgroundImage = ":/graphics/frame.png";
|
||||||
mDefaultProperties.mBackgroundCornerSize = glm::vec2{16.0f, 16.0f};
|
mDefaultProperties.mBackgroundCornerSize = glm::vec2 {16.0f, 16.0f};
|
||||||
mDefaultProperties.mBackgroundCenterColor = 0xAAAAEEFF;
|
mDefaultProperties.mBackgroundCenterColor = 0xAAAAEEFF;
|
||||||
mDefaultProperties.mBackgroundEdgeColor = 0xAAAAEEFF;
|
mDefaultProperties.mBackgroundEdgeColor = 0xAAAAEEFF;
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ GridTileComponent::GridTileComponent(Window* window)
|
||||||
|
|
||||||
void GridTileComponent::render(const glm::mat4& parentTrans)
|
void GridTileComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
glm::mat4 trans{getTransform() * parentTrans};
|
glm::mat4 trans {getTransform() * parentTrans};
|
||||||
|
|
||||||
if (mVisible)
|
if (mVisible)
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
|
@ -76,8 +76,8 @@ void GridTileComponent::update(int deltaTime)
|
||||||
|
|
||||||
void applyThemeToProperties(const ThemeData::ThemeElement* elem, GridTileProperties* properties)
|
void applyThemeToProperties(const ThemeData::ThemeElement* elem, GridTileProperties* properties)
|
||||||
{
|
{
|
||||||
glm::vec2 screen{static_cast<float>(Renderer::getScreenWidth()),
|
glm::vec2 screen {static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight())};
|
static_cast<float>(Renderer::getScreenHeight())};
|
||||||
|
|
||||||
if (elem->has("size"))
|
if (elem->has("size"))
|
||||||
properties->mSize = elem->get<glm::vec2>("size") * screen;
|
properties->mSize = elem->get<glm::vec2>("size") * screen;
|
||||||
|
@ -132,8 +132,8 @@ void GridTileComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
|
|
||||||
glm::vec2 GridTileComponent::getDefaultTileSize()
|
glm::vec2 GridTileComponent::getDefaultTileSize()
|
||||||
{
|
{
|
||||||
glm::vec2 screen{glm::vec2(static_cast<float>(Renderer::getScreenWidth()),
|
glm::vec2 screen {glm::vec2(static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight()))};
|
static_cast<float>(Renderer::getScreenHeight()))};
|
||||||
|
|
||||||
return screen * 0.22f;
|
return screen * 0.22f;
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ void GridTileComponent::setSelected(bool selected,
|
||||||
resize();
|
resize();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mAnimPosition = glm::vec3{pPosition->x, pPosition->y, pPosition->z};
|
mAnimPosition = glm::vec3 {pPosition->x, pPosition->y, pPosition->z};
|
||||||
|
|
||||||
auto func = [this](float t) {
|
auto func = [this](float t) {
|
||||||
t -= 1;
|
t -= 1;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "resources/TextureResource.h"
|
#include "resources/TextureResource.h"
|
||||||
#include "utils/StringUtil.h"
|
#include "utils/StringUtil.h"
|
||||||
|
|
||||||
static std::map<std::string, std::string> sIconPathMap{};
|
static std::map<std::string, std::string> sIconPathMap {};
|
||||||
|
|
||||||
HelpComponent::HelpComponent(Window* window)
|
HelpComponent::HelpComponent(Window* window)
|
||||||
: GuiComponent(window)
|
: GuiComponent(window)
|
||||||
|
@ -203,7 +203,7 @@ void HelpComponent::updateGrid()
|
||||||
std::shared_ptr<Font>& font = mStyle.font;
|
std::shared_ptr<Font>& font = mStyle.font;
|
||||||
|
|
||||||
mGrid = std::make_shared<ComponentGrid>(mWindow,
|
mGrid = std::make_shared<ComponentGrid>(mWindow,
|
||||||
glm::ivec2{static_cast<int>(mPrompts.size()) * 4, 1});
|
glm::ivec2 {static_cast<int>(mPrompts.size()) * 4, 1});
|
||||||
|
|
||||||
// [icon] [spacer1] [text] [spacer2]
|
// [icon] [spacer1] [text] [spacer2]
|
||||||
|
|
||||||
|
@ -249,8 +249,8 @@ void HelpComponent::updateGrid()
|
||||||
col + 1, (mStyle.iconTextSpacing * Renderer::getScreenWidthModifier()) / width);
|
col + 1, (mStyle.iconTextSpacing * Renderer::getScreenWidthModifier()) / width);
|
||||||
mGrid->setColWidthPerc(col + 2, labels.at(i)->getSize().x / width);
|
mGrid->setColWidthPerc(col + 2, labels.at(i)->getSize().x / width);
|
||||||
|
|
||||||
mGrid->setEntry(icons.at(i), glm::ivec2{col, 0}, false, false);
|
mGrid->setEntry(icons.at(i), glm::ivec2 {col, 0}, false, false);
|
||||||
mGrid->setEntry(labels.at(i), glm::ivec2{col + 2, 0}, false, false);
|
mGrid->setEntry(labels.at(i), glm::ivec2 {col + 2, 0}, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
mGrid->setPosition({mStyle.position.x, mStyle.position.y, 0.0f});
|
mGrid->setPosition({mStyle.position.x, mStyle.position.y, 0.0f});
|
||||||
|
@ -291,7 +291,7 @@ void HelpComponent::setOpacity(unsigned char opacity)
|
||||||
|
|
||||||
void HelpComponent::render(const glm::mat4& parentTrans)
|
void HelpComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
|
|
||||||
if (mGrid)
|
if (mGrid)
|
||||||
mGrid->render(trans);
|
mGrid->render(trans);
|
||||||
|
|
|
@ -20,7 +20,7 @@ glm::ivec2 ImageComponent::getTextureSize() const
|
||||||
if (mTexture)
|
if (mTexture)
|
||||||
return mTexture->getSize();
|
return mTexture->getSize();
|
||||||
else
|
else
|
||||||
return glm::ivec2{};
|
return glm::ivec2 {};
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 ImageComponent::getSize() const
|
glm::vec2 ImageComponent::getSize() const
|
||||||
|
@ -54,8 +54,8 @@ void ImageComponent::resize()
|
||||||
if (!mTexture)
|
if (!mTexture)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const glm::vec2 textureSize{mTexture->getSourceImageSize()};
|
const glm::vec2 textureSize {mTexture->getSourceImageSize()};
|
||||||
if (textureSize == glm::vec2{})
|
if (textureSize == glm::vec2 {})
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mTexture->isTiled()) {
|
if (mTexture->isTiled()) {
|
||||||
|
@ -69,7 +69,7 @@ void ImageComponent::resize()
|
||||||
if (mTargetIsMax) {
|
if (mTargetIsMax) {
|
||||||
mSize = textureSize;
|
mSize = textureSize;
|
||||||
|
|
||||||
glm::vec2 resizeScale{(mTargetSize.x / mSize.x), (mTargetSize.y / mSize.y)};
|
glm::vec2 resizeScale {(mTargetSize.x / mSize.x), (mTargetSize.y / mSize.y)};
|
||||||
|
|
||||||
if (resizeScale.x < resizeScale.y) {
|
if (resizeScale.x < resizeScale.y) {
|
||||||
// This will be mTargetSize.x. We can't exceed it, nor be lower than it.
|
// This will be mTargetSize.x. We can't exceed it, nor be lower than it.
|
||||||
|
@ -86,7 +86,7 @@ void ImageComponent::resize()
|
||||||
else if (mTargetIsMin) {
|
else if (mTargetIsMin) {
|
||||||
mSize = textureSize;
|
mSize = textureSize;
|
||||||
|
|
||||||
glm::vec2 resizeScale{(mTargetSize.x / mSize.x), (mTargetSize.y / mSize.y)};
|
glm::vec2 resizeScale {(mTargetSize.x / mSize.x), (mTargetSize.y / mSize.y)};
|
||||||
|
|
||||||
if (resizeScale.x > resizeScale.y) {
|
if (resizeScale.x > resizeScale.y) {
|
||||||
mSize.x *= resizeScale.x;
|
mSize.x *= resizeScale.x;
|
||||||
|
@ -108,7 +108,7 @@ void ImageComponent::resize()
|
||||||
else {
|
else {
|
||||||
// If both components are set, we just stretch.
|
// If both components are set, we just stretch.
|
||||||
// If no components are set, we don't resize at all.
|
// If no components are set, we don't resize at all.
|
||||||
mSize = mTargetSize == glm::vec2{} ? textureSize : mTargetSize;
|
mSize = mTargetSize == glm::vec2 {} ? textureSize : mTargetSize;
|
||||||
|
|
||||||
// If only one component is set, we resize in a way that maintains aspect ratio.
|
// If only one component is set, we resize in a way that maintains aspect ratio.
|
||||||
if (!mTargetSize.x && mTargetSize.y) {
|
if (!mTargetSize.x && mTargetSize.y) {
|
||||||
|
@ -174,7 +174,7 @@ void ImageComponent::setImage(const std::shared_ptr<TextureResource>& texture, b
|
||||||
|
|
||||||
void ImageComponent::setResize(float width, float height)
|
void ImageComponent::setResize(float width, float height)
|
||||||
{
|
{
|
||||||
mTargetSize = glm::vec2{width, height};
|
mTargetSize = glm::vec2 {width, height};
|
||||||
mTargetIsMax = false;
|
mTargetIsMax = false;
|
||||||
mTargetIsMin = false;
|
mTargetIsMin = false;
|
||||||
resize();
|
resize();
|
||||||
|
@ -182,7 +182,7 @@ void ImageComponent::setResize(float width, float height)
|
||||||
|
|
||||||
void ImageComponent::setMaxSize(const float width, const float height)
|
void ImageComponent::setMaxSize(const float width, const float height)
|
||||||
{
|
{
|
||||||
mTargetSize = glm::vec2{width, height};
|
mTargetSize = glm::vec2 {width, height};
|
||||||
mTargetIsMax = true;
|
mTargetIsMax = true;
|
||||||
mTargetIsMin = false;
|
mTargetIsMin = false;
|
||||||
resize();
|
resize();
|
||||||
|
@ -190,7 +190,7 @@ void ImageComponent::setMaxSize(const float width, const float height)
|
||||||
|
|
||||||
void ImageComponent::setMinSize(const float width, const float height)
|
void ImageComponent::setMinSize(const float width, const float height)
|
||||||
{
|
{
|
||||||
mTargetSize = glm::vec2{width, height};
|
mTargetSize = glm::vec2 {width, height};
|
||||||
mTargetIsMax = false;
|
mTargetIsMax = false;
|
||||||
mTargetIsMin = true;
|
mTargetIsMin = true;
|
||||||
resize();
|
resize();
|
||||||
|
@ -236,7 +236,7 @@ void ImageComponent::uncrop()
|
||||||
|
|
||||||
void ImageComponent::cropTransparentPadding(const float maxSizeX, const float maxSizeY)
|
void ImageComponent::cropTransparentPadding(const float maxSizeX, const float maxSizeY)
|
||||||
{
|
{
|
||||||
if (mSize == glm::vec2{})
|
if (mSize == glm::vec2 {})
|
||||||
return;
|
return;
|
||||||
|
|
||||||
std::vector<unsigned char> imageRGBA = mTexture.get()->getRawRGBAData();
|
std::vector<unsigned char> imageRGBA = mTexture.get()->getRawRGBAData();
|
||||||
|
@ -244,10 +244,10 @@ void ImageComponent::cropTransparentPadding(const float maxSizeX, const float ma
|
||||||
if (imageRGBA.size() == 0)
|
if (imageRGBA.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glm::ivec2 imageSize{mTexture.get()->getSize()};
|
glm::ivec2 imageSize {mTexture.get()->getSize()};
|
||||||
cimg_library::CImg<unsigned char> imageCImg(imageSize.x, imageSize.y, 1, 4, 0);
|
cimg_library::CImg<unsigned char> imageCImg(imageSize.x, imageSize.y, 1, 4, 0);
|
||||||
|
|
||||||
int paddingCoords[4]{};
|
int paddingCoords[4] {};
|
||||||
|
|
||||||
// We need to convert our RGBA data to the CImg internal format as CImg does not interleave
|
// We need to convert our RGBA data to the CImg internal format as CImg does not interleave
|
||||||
// the pixels (as in RGBARGBARGBA).
|
// the pixels (as in RGBARGBARGBA).
|
||||||
|
@ -256,12 +256,12 @@ void ImageComponent::cropTransparentPadding(const float maxSizeX, const float ma
|
||||||
// This will give us the coordinates for the fully transparent areas.
|
// This will give us the coordinates for the fully transparent areas.
|
||||||
Utils::CImg::getTransparentPaddingCoords(imageCImg, paddingCoords);
|
Utils::CImg::getTransparentPaddingCoords(imageCImg, paddingCoords);
|
||||||
|
|
||||||
glm::vec2 originalSize{mSize};
|
glm::vec2 originalSize {mSize};
|
||||||
|
|
||||||
float cropLeft{static_cast<float>(paddingCoords[0]) / static_cast<float>(imageSize.x)};
|
float cropLeft {static_cast<float>(paddingCoords[0]) / static_cast<float>(imageSize.x)};
|
||||||
float cropTop{static_cast<float>(paddingCoords[1]) / static_cast<float>(imageSize.y)};
|
float cropTop {static_cast<float>(paddingCoords[1]) / static_cast<float>(imageSize.y)};
|
||||||
float cropRight{static_cast<float>(paddingCoords[2]) / static_cast<float>(imageSize.x)};
|
float cropRight {static_cast<float>(paddingCoords[2]) / static_cast<float>(imageSize.x)};
|
||||||
float cropBottom{static_cast<float>(paddingCoords[3]) / static_cast<float>(imageSize.y)};
|
float cropBottom {static_cast<float>(paddingCoords[3]) / static_cast<float>(imageSize.y)};
|
||||||
|
|
||||||
crop(cropLeft, cropTop, cropRight, cropBottom);
|
crop(cropLeft, cropTop, cropRight, cropBottom);
|
||||||
|
|
||||||
|
@ -339,10 +339,10 @@ void ImageComponent::updateVertices()
|
||||||
|
|
||||||
// We go through this mess to make sure everything is properly rounded.
|
// We go through this mess to make sure everything is properly rounded.
|
||||||
// If we just round vertices at the end, edge cases occur near sizes of 0.5.
|
// If we just round vertices at the end, edge cases occur near sizes of 0.5.
|
||||||
const glm::vec2 topLeft{};
|
const glm::vec2 topLeft {};
|
||||||
const glm::vec2 bottomRight{mSize};
|
const glm::vec2 bottomRight {mSize};
|
||||||
const float px{mTexture->isTiled() ? mSize.x / getTextureSize().x : 1.0f};
|
const float px {mTexture->isTiled() ? mSize.x / getTextureSize().x : 1.0f};
|
||||||
const float py{mTexture->isTiled() ? mSize.y / getTextureSize().y : 1.0f};
|
const float py {mTexture->isTiled() ? mSize.y / getTextureSize().y : 1.0f};
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
mVertices[0] = {{topLeft.x, topLeft.y }, {mTopLeftCrop.x, py - mTopLeftCrop.y }, 0};
|
mVertices[0] = {{topLeft.x, topLeft.y }, {mTopLeftCrop.x, py - mTopLeftCrop.y }, 0};
|
||||||
|
@ -388,18 +388,18 @@ void ImageComponent::render(const glm::mat4& parentTrans)
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
if (mTexture && mOpacity > 0) {
|
if (mTexture && mOpacity > 0) {
|
||||||
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,
|
||||||
0xFF000033, 0xFF000033);
|
0xFF000033, 0xFF000033);
|
||||||
Renderer::drawRect(0.0f, 0.0f, mSize.x, mSize.y, 0xFF000033, 0xFF000033);
|
Renderer::drawRect(0.0f, 0.0f, mSize.x, mSize.y, 0xFF000033, 0xFF000033);
|
||||||
}
|
}
|
||||||
// An image with zero size would normally indicate a corrupt image file.
|
// An image with zero size would normally indicate a corrupt image file.
|
||||||
if (mTexture->getSize() != glm::ivec2{}) {
|
if (mTexture->getSize() != glm::ivec2 {}) {
|
||||||
// Actually draw the image.
|
// Actually draw the image.
|
||||||
// The bind() function returns false if the texture is not currently loaded. A blank
|
// The bind() function returns false if the texture is not currently loaded. A blank
|
||||||
// texture is bound in this case but we want to handle a fade so it doesn't just
|
// texture is bound in this case but we want to handle a fade so it doesn't just
|
||||||
|
@ -485,9 +485,9 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
if (!elem)
|
if (!elem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glm::vec2 scale{getParent() ? getParent()->getSize() :
|
glm::vec2 scale {getParent() ? getParent()->getSize() :
|
||||||
glm::vec2(static_cast<float>(Renderer::getScreenWidth()),
|
glm::vec2(static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight()))};
|
static_cast<float>(Renderer::getScreenHeight()))};
|
||||||
|
|
||||||
if (properties & ThemeFlags::SIZE) {
|
if (properties & ThemeFlags::SIZE) {
|
||||||
if (elem->has("size"))
|
if (elem->has("size"))
|
||||||
|
|
|
@ -126,13 +126,13 @@ template <typename T>
|
||||||
ImageGridComponent<T>::ImageGridComponent(Window* window)
|
ImageGridComponent<T>::ImageGridComponent(Window* window)
|
||||||
: IList<ImageGridData, T>(window)
|
: IList<ImageGridData, T>(window)
|
||||||
{
|
{
|
||||||
glm::vec2 screen{static_cast<float>(Renderer::getScreenWidth()),
|
glm::vec2 screen {static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight())};
|
static_cast<float>(Renderer::getScreenHeight())};
|
||||||
|
|
||||||
mCamera = 0.0f;
|
mCamera = 0.0f;
|
||||||
mCameraDirection = 1.0f;
|
mCameraDirection = 1.0f;
|
||||||
|
|
||||||
mAutoLayout = glm::vec2{};
|
mAutoLayout = glm::vec2 {};
|
||||||
mAutoLayoutZoom = 1.0f;
|
mAutoLayoutZoom = 1.0f;
|
||||||
|
|
||||||
mStartPosition = 0;
|
mStartPosition = 0;
|
||||||
|
@ -171,7 +171,7 @@ template <typename T> bool ImageGridComponent<T>::input(InputConfig* config, Inp
|
||||||
if (input.value != 0) {
|
if (input.value != 0) {
|
||||||
int idx = isVertical() ? 0 : 1;
|
int idx = isVertical() ? 0 : 1;
|
||||||
|
|
||||||
glm::ivec2 dir{};
|
glm::ivec2 dir {};
|
||||||
if (config->isMappedLike("up", input))
|
if (config->isMappedLike("up", input))
|
||||||
dir[1 ^ idx] = -1;
|
dir[1 ^ idx] = -1;
|
||||||
else if (config->isMappedLike("down", input))
|
else if (config->isMappedLike("down", input))
|
||||||
|
@ -181,7 +181,7 @@ template <typename T> bool ImageGridComponent<T>::input(InputConfig* config, Inp
|
||||||
else if (config->isMappedLike("right", input))
|
else if (config->isMappedLike("right", input))
|
||||||
dir[0 ^ idx] = 1;
|
dir[0 ^ idx] = 1;
|
||||||
|
|
||||||
if (dir != glm::ivec2{}) {
|
if (dir != glm::ivec2 {}) {
|
||||||
if (isVertical())
|
if (isVertical())
|
||||||
listInput(dir.x + dir.y * mGridDimension.x);
|
listInput(dir.x + dir.y * mGridDimension.x);
|
||||||
else
|
else
|
||||||
|
@ -210,13 +210,13 @@ template <typename T> void ImageGridComponent<T>::update(int deltaTime)
|
||||||
|
|
||||||
template <typename T> void ImageGridComponent<T>::render(const glm::mat4& parentTrans)
|
template <typename T> void ImageGridComponent<T>::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
glm::mat4 trans{getTransform() * parentTrans};
|
glm::mat4 trans {getTransform() * parentTrans};
|
||||||
glm::mat4 tileTrans{trans};
|
glm::mat4 tileTrans {trans};
|
||||||
|
|
||||||
float offsetX{isVertical() ? 0.0f : mCamera * mCameraDirection * (mTileSize.x + mMargin.x)};
|
float offsetX {isVertical() ? 0.0f : mCamera * mCameraDirection * (mTileSize.x + mMargin.x)};
|
||||||
float offsetY{isVertical() ? mCamera * mCameraDirection * (mTileSize.y + mMargin.y) : 0.0f};
|
float offsetY {isVertical() ? mCamera * mCameraDirection * (mTileSize.y + mMargin.y) : 0.0f};
|
||||||
|
|
||||||
tileTrans = glm::translate(tileTrans, glm::vec3{offsetX, offsetY, 0.0f});
|
tileTrans = glm::translate(tileTrans, glm::vec3 {offsetX, offsetY, 0.0f});
|
||||||
|
|
||||||
if (mEntriesDirty) {
|
if (mEntriesDirty) {
|
||||||
updateTiles();
|
updateTiles();
|
||||||
|
@ -227,10 +227,10 @@ template <typename T> void ImageGridComponent<T>::render(const glm::mat4& parent
|
||||||
float scaleX = trans[0].x;
|
float scaleX = trans[0].x;
|
||||||
float scaleY = trans[1].y;
|
float scaleY = trans[1].y;
|
||||||
|
|
||||||
glm::ivec2 pos{static_cast<int>(std::round(trans[3].x)),
|
glm::ivec2 pos {static_cast<int>(std::round(trans[3].x)),
|
||||||
static_cast<int>(std::round(trans[3].y))};
|
static_cast<int>(std::round(trans[3].y))};
|
||||||
glm::ivec2 size{static_cast<int>(std::round(mSize.x * scaleX)),
|
glm::ivec2 size {static_cast<int>(std::round(mSize.x * scaleX)),
|
||||||
static_cast<int>(std::round(mSize.y * scaleY))};
|
static_cast<int>(std::round(mSize.y * scaleY))};
|
||||||
|
|
||||||
Renderer::pushClipRect(pos, size);
|
Renderer::pushClipRect(pos, size);
|
||||||
|
|
||||||
|
@ -269,8 +269,8 @@ void ImageGridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
// Keep the theme pointer to apply it on the tiles later on.
|
// Keep the theme pointer to apply it on the tiles later on.
|
||||||
mTheme = theme;
|
mTheme = theme;
|
||||||
|
|
||||||
glm::vec2 screen{static_cast<float>(Renderer::getScreenWidth()),
|
glm::vec2 screen {static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight())};
|
static_cast<float>(Renderer::getScreenHeight())};
|
||||||
|
|
||||||
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "imagegrid");
|
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "imagegrid");
|
||||||
if (elem) {
|
if (elem) {
|
||||||
|
@ -278,8 +278,8 @@ void ImageGridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
mMargin = elem->get<glm::vec2>("margin") * screen;
|
mMargin = elem->get<glm::vec2>("margin") * screen;
|
||||||
|
|
||||||
if (elem->has("padding"))
|
if (elem->has("padding"))
|
||||||
mPadding =
|
mPadding = elem->get<glm::vec4>("padding") *
|
||||||
elem->get<glm::vec4>("padding") * glm::vec4{screen.x, screen.y, screen.x, screen.y};
|
glm::vec4 {screen.x, screen.y, screen.x, screen.y};
|
||||||
|
|
||||||
if (elem->has("autoLayout"))
|
if (elem->has("autoLayout"))
|
||||||
mAutoLayout = elem->get<glm::vec2>("autoLayout");
|
mAutoLayout = elem->get<glm::vec2>("autoLayout");
|
||||||
|
@ -447,7 +447,7 @@ template <typename T> void ImageGridComponent<T>::onCursorChanged(const CursorSt
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 oldPos{};
|
glm::vec3 oldPos {};
|
||||||
|
|
||||||
if (oldTile != nullptr && oldTile != newTile) {
|
if (oldTile != nullptr && oldTile != newTile) {
|
||||||
oldPos = oldTile->getBackgroundPosition();
|
oldPos = oldTile->getBackgroundPosition();
|
||||||
|
@ -455,7 +455,7 @@ template <typename T> void ImageGridComponent<T>::onCursorChanged(const CursorSt
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newTile != nullptr)
|
if (newTile != nullptr)
|
||||||
newTile->setSelected(true, true, oldPos == glm::vec3{} ? nullptr : &oldPos, true);
|
newTile->setSelected(true, true, oldPos == glm::vec3 {} ? nullptr : &oldPos, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int firstVisibleCol = mStartPosition / dimOpposite;
|
int firstVisibleCol = mStartPosition / dimOpposite;
|
||||||
|
@ -532,7 +532,7 @@ template <typename T> void ImageGridComponent<T>::buildTiles()
|
||||||
mStartPosition -= static_cast<int>(floorf(dimScrollable / 2.0f));
|
mStartPosition -= static_cast<int>(floorf(dimScrollable / 2.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 tileDistance{mTileSize + mMargin};
|
glm::vec2 tileDistance {mTileSize + mMargin};
|
||||||
|
|
||||||
if (mAutoLayout.x != 0.0f && mAutoLayout.y != 0.0f) {
|
if (mAutoLayout.x != 0.0f && mAutoLayout.y != 0.0f) {
|
||||||
auto x = (mSize.x - (mMargin.x * (mAutoLayout.x - 1.0f)) - mPadding.x - mPadding.z) /
|
auto x = (mSize.x - (mMargin.x * (mAutoLayout.x - 1.0f)) - mPadding.x - mPadding.z) /
|
||||||
|
@ -540,12 +540,12 @@ template <typename T> void ImageGridComponent<T>::buildTiles()
|
||||||
auto y = (mSize.y - (mMargin.y * (mAutoLayout.y - 1.0f)) - mPadding.y - mPadding.w) /
|
auto y = (mSize.y - (mMargin.y * (mAutoLayout.y - 1.0f)) - mPadding.y - mPadding.w) /
|
||||||
static_cast<int>(mAutoLayout.y);
|
static_cast<int>(mAutoLayout.y);
|
||||||
|
|
||||||
mTileSize = glm::vec2{x, y};
|
mTileSize = glm::vec2 {x, y};
|
||||||
tileDistance = mTileSize + mMargin;
|
tileDistance = mTileSize + mMargin;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool vert = isVertical();
|
bool vert = isVertical();
|
||||||
glm::vec2 startPosition{mTileSize / 2.0f};
|
glm::vec2 startPosition {mTileSize / 2.0f};
|
||||||
startPosition.x += mPadding.x;
|
startPosition.x += mPadding.x;
|
||||||
startPosition.y += mPadding.y;
|
startPosition.y += mPadding.y;
|
||||||
|
|
||||||
|
@ -673,7 +673,7 @@ void ImageGridComponent<T>::updateTileAtPos(int tilePos,
|
||||||
if (idx < 0 || idx >= static_cast<int>(mTiles.size()))
|
if (idx < 0 || idx >= static_cast<int>(mTiles.size()))
|
||||||
idx = 0;
|
idx = 0;
|
||||||
|
|
||||||
glm::vec3 pos{mTiles.at(idx)->getBackgroundPosition()};
|
glm::vec3 pos {mTiles.at(idx)->getBackgroundPosition()};
|
||||||
tile->setSelected(true, allowAnimation, &pos);
|
tile->setSelected(true, allowAnimation, &pos);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -689,7 +689,7 @@ template <typename T> void ImageGridComponent<T>::calcGridDimension()
|
||||||
{
|
{
|
||||||
// grid_size = columns * tile_size + (columns - 1) * margin
|
// grid_size = columns * tile_size + (columns - 1) * margin
|
||||||
// <=> columns = (grid_size + margin) / (tile_size + margin)
|
// <=> columns = (grid_size + margin) / (tile_size + margin)
|
||||||
glm::vec2 gridDimension{(mSize + mMargin) / (mTileSize + mMargin)};
|
glm::vec2 gridDimension {(mSize + mMargin) / (mTileSize + mMargin)};
|
||||||
|
|
||||||
if (mAutoLayout.x != 0.0f && mAutoLayout.y != 0.0f)
|
if (mAutoLayout.x != 0.0f && mAutoLayout.y != 0.0f)
|
||||||
gridDimension = mAutoLayout;
|
gridDimension = mAutoLayout;
|
||||||
|
@ -697,8 +697,8 @@ template <typename T> void ImageGridComponent<T>::calcGridDimension()
|
||||||
mLastRowPartial = floorf(gridDimension.y) != gridDimension.y;
|
mLastRowPartial = floorf(gridDimension.y) != gridDimension.y;
|
||||||
|
|
||||||
// Ceil y dim so we can display partial last row.
|
// Ceil y dim so we can display partial last row.
|
||||||
mGridDimension = glm::ivec2{static_cast<const int>(gridDimension.x),
|
mGridDimension = glm::ivec2 {static_cast<const int>(gridDimension.x),
|
||||||
static_cast<const int>(ceilf(gridDimension.y))};
|
static_cast<const int>(ceilf(gridDimension.y))};
|
||||||
|
|
||||||
// Grid dimension validation.
|
// Grid dimension validation.
|
||||||
if (mGridDimension.x < 1) {
|
if (mGridDimension.x < 1) {
|
||||||
|
|
|
@ -19,26 +19,26 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
LottieComponent::LottieComponent(Window* window)
|
LottieComponent::LottieComponent(Window* window)
|
||||||
: GuiComponent{window}
|
: GuiComponent {window}
|
||||||
, mCacheFrames{true}
|
, mCacheFrames {true}
|
||||||
, mMaxCacheSize{0}
|
, mMaxCacheSize {0}
|
||||||
, mCacheSize{0}
|
, mCacheSize {0}
|
||||||
, mFrameSize{0}
|
, mFrameSize {0}
|
||||||
, mAnimation{nullptr}
|
, mAnimation {nullptr}
|
||||||
, mSurface{nullptr}
|
, mSurface {nullptr}
|
||||||
, mStartDirection{"normal"}
|
, mStartDirection {"normal"}
|
||||||
, mTotalFrames{0}
|
, mTotalFrames {0}
|
||||||
, mFrameNum{0}
|
, mFrameNum {0}
|
||||||
, mFrameRate{0.0}
|
, mFrameRate {0.0}
|
||||||
, mSpeedModifier{1.0f}
|
, mSpeedModifier {1.0f}
|
||||||
, mTargetPacing{0}
|
, mTargetPacing {0}
|
||||||
, mTimeAccumulator{0}
|
, mTimeAccumulator {0}
|
||||||
, mLastRenderedFrame{-1}
|
, mLastRenderedFrame {-1}
|
||||||
, mSkippedFrames{0}
|
, mSkippedFrames {0}
|
||||||
, mHoldFrame{false}
|
, mHoldFrame {false}
|
||||||
, mPause{false}
|
, mPause {false}
|
||||||
, mAlternate{false}
|
, mAlternate {false}
|
||||||
, mKeepAspectRatio{true}
|
, mKeepAspectRatio {true}
|
||||||
{
|
{
|
||||||
// Get an empty texture for rendering the animation.
|
// Get an empty texture for rendering the animation.
|
||||||
mTexture = TextureResource::get("");
|
mTexture = TextureResource::get("");
|
||||||
|
@ -117,12 +117,12 @@ void LottieComponent::setAnimation(const std::string& path)
|
||||||
"disabling of <keepAspectRatio> so ignoring this setting";
|
"disabling of <keepAspectRatio> so ignoring this setting";
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t width{0};
|
size_t width {0};
|
||||||
size_t height{0};
|
size_t height {0};
|
||||||
|
|
||||||
if (mSize.x == 0.0f || mSize.y == 0.0f) {
|
if (mSize.x == 0.0f || mSize.y == 0.0f) {
|
||||||
size_t viewportWidth{0};
|
size_t viewportWidth {0};
|
||||||
size_t viewportHeight{0};
|
size_t viewportHeight {0};
|
||||||
|
|
||||||
mAnimation->size(viewportWidth, viewportHeight);
|
mAnimation->size(viewportWidth, viewportHeight);
|
||||||
double sizeRatio = static_cast<double>(viewportWidth) / static_cast<double>(viewportHeight);
|
double sizeRatio = static_cast<double>(viewportWidth) / static_cast<double>(viewportHeight);
|
||||||
|
@ -216,7 +216,7 @@ void LottieComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
{
|
{
|
||||||
using namespace ThemeFlags;
|
using namespace ThemeFlags;
|
||||||
|
|
||||||
const ThemeData::ThemeElement* elem{theme->getElement(view, element, "animation")};
|
const ThemeData::ThemeElement* elem {theme->getElement(view, element, "animation")};
|
||||||
|
|
||||||
if (elem->has("size")) {
|
if (elem->has("size")) {
|
||||||
glm::vec2 size = elem->get<glm::vec2>("size");
|
glm::vec2 size = elem->get<glm::vec2>("size");
|
||||||
|
@ -228,7 +228,7 @@ void LottieComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elem->has("speed")) {
|
if (elem->has("speed")) {
|
||||||
const float speed{elem->get<float>("speed")};
|
const float speed {elem->get<float>("speed")};
|
||||||
if (speed < 0.2f || speed > 3.0f) {
|
if (speed < 0.2f || speed > 3.0f) {
|
||||||
LOG(LogWarning) << "LottieComponent: Invalid theme configuration, <speed> set to \""
|
LOG(LogWarning) << "LottieComponent: Invalid theme configuration, <speed> set to \""
|
||||||
<< std::fixed << std::setprecision(1) << speed << "\"";
|
<< std::fixed << std::setprecision(1) << speed << "\"";
|
||||||
|
@ -271,7 +271,7 @@ void LottieComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
GuiComponent::applyTheme(theme, view, element, properties);
|
GuiComponent::applyTheme(theme, view, element, properties);
|
||||||
|
|
||||||
if (elem->has("path")) {
|
if (elem->has("path")) {
|
||||||
std::string path{elem->get<std::string>("path")};
|
std::string path {elem->get<std::string>("path")};
|
||||||
if (path != "") {
|
if (path != "") {
|
||||||
setAnimation(path);
|
setAnimation(path);
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ void LottieComponent::render(const glm::mat4& parentTrans)
|
||||||
if (mAnimation == nullptr)
|
if (mAnimation == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
|
|
||||||
// This is necessary as there may otherwise be no texture to render when paused.
|
// This is necessary as there may otherwise be no texture to render when paused.
|
||||||
if (mPause && mTexture->getSize().x == 0.0f) {
|
if (mPause && mTexture->getSize().x == 0.0f) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ MenuComponent::MenuComponent(Window* window,
|
||||||
const std::shared_ptr<Font>& titleFont)
|
const std::shared_ptr<Font>& titleFont)
|
||||||
: GuiComponent(window)
|
: GuiComponent(window)
|
||||||
, mBackground(window)
|
, mBackground(window)
|
||||||
, mGrid(window, glm::ivec2{2, 4})
|
, mGrid(window, glm::ivec2 {2, 4})
|
||||||
, mNeedsSaving(false)
|
, mNeedsSaving(false)
|
||||||
{
|
{
|
||||||
addChild(&mBackground);
|
addChild(&mBackground);
|
||||||
|
@ -35,11 +35,11 @@ MenuComponent::MenuComponent(Window* window,
|
||||||
mTitle->setHorizontalAlignment(ALIGN_CENTER);
|
mTitle->setHorizontalAlignment(ALIGN_CENTER);
|
||||||
mTitle->setColor(0x555555FF);
|
mTitle->setColor(0x555555FF);
|
||||||
setTitle(title, titleFont);
|
setTitle(title, titleFont);
|
||||||
mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{2, 2});
|
mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {2, 2});
|
||||||
|
|
||||||
// Set up list which will never change (externally, anyway).
|
// Set up list which will never change (externally, anyway).
|
||||||
mList = std::make_shared<ComponentList>(mWindow);
|
mList = std::make_shared<ComponentList>(mWindow);
|
||||||
mGrid.setEntry(mList, glm::ivec2{0, 2}, true, true, glm::ivec2{2, 1});
|
mGrid.setEntry(mList, glm::ivec2 {0, 2}, true, true, glm::ivec2 {2, 1});
|
||||||
|
|
||||||
// Set up scroll indicators.
|
// Set up scroll indicators.
|
||||||
mScrollUp = std::make_shared<ImageComponent>(mWindow);
|
mScrollUp = std::make_shared<ImageComponent>(mWindow);
|
||||||
|
@ -52,8 +52,8 @@ MenuComponent::MenuComponent(Window* window,
|
||||||
mScrollDown->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f);
|
mScrollDown->setResize(0.0f, mTitle->getFont()->getLetterHeight() / 2.0f);
|
||||||
mScrollDown->setOrigin(0.0f, 0.35f);
|
mScrollDown->setOrigin(0.0f, 0.35f);
|
||||||
|
|
||||||
mGrid.setEntry(mScrollUp, glm::ivec2{1, 0}, false, false, glm::ivec2{1, 1});
|
mGrid.setEntry(mScrollUp, glm::ivec2 {1, 0}, false, false, glm::ivec2 {1, 1});
|
||||||
mGrid.setEntry(mScrollDown, glm::ivec2{1, 1}, false, false, glm::ivec2{1, 1});
|
mGrid.setEntry(mScrollDown, glm::ivec2 {1, 1}, false, false, glm::ivec2 {1, 1});
|
||||||
|
|
||||||
updateGrid();
|
updateGrid();
|
||||||
updateSize();
|
updateSize();
|
||||||
|
@ -120,7 +120,7 @@ void MenuComponent::updateSize()
|
||||||
|
|
||||||
void MenuComponent::onSizeChanged()
|
void MenuComponent::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f});
|
||||||
|
|
||||||
// Update grid row/column sizes.
|
// Update grid row/column sizes.
|
||||||
mGrid.setRowHeightPerc(0, TITLE_HEIGHT / mSize.y / 2.0f);
|
mGrid.setRowHeightPerc(0, TITLE_HEIGHT / mSize.y / 2.0f);
|
||||||
|
@ -151,7 +151,7 @@ void MenuComponent::updateGrid()
|
||||||
|
|
||||||
if (mButtons.size()) {
|
if (mButtons.size()) {
|
||||||
mButtonGrid = makeButtonGrid(mWindow, mButtons);
|
mButtonGrid = makeButtonGrid(mWindow, mButtons);
|
||||||
mGrid.setEntry(mButtonGrid, glm::ivec2{0, 3}, true, false, glm::ivec2{2, 1});
|
mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 3}, true, false, glm::ivec2 {2, 1});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,13 +159,13 @@ std::shared_ptr<ComponentGrid> makeButtonGrid(
|
||||||
Window* window, const std::vector<std::shared_ptr<ButtonComponent>>& buttons)
|
Window* window, const std::vector<std::shared_ptr<ButtonComponent>>& buttons)
|
||||||
{
|
{
|
||||||
std::shared_ptr<ComponentGrid> buttonGrid =
|
std::shared_ptr<ComponentGrid> buttonGrid =
|
||||||
std::make_shared<ComponentGrid>(window, glm::ivec2{static_cast<int>(buttons.size()), 2});
|
std::make_shared<ComponentGrid>(window, glm::ivec2 {static_cast<int>(buttons.size()), 2});
|
||||||
|
|
||||||
// Initialize to padding.
|
// Initialize to padding.
|
||||||
float buttonGridWidth = BUTTON_GRID_HORIZ_PADDING * buttons.size();
|
float buttonGridWidth = BUTTON_GRID_HORIZ_PADDING * buttons.size();
|
||||||
|
|
||||||
for (int i = 0; i < static_cast<int>(buttons.size()); ++i) {
|
for (int i = 0; i < static_cast<int>(buttons.size()); ++i) {
|
||||||
buttonGrid->setEntry(buttons.at(i), glm::ivec2{i, 0}, true, false);
|
buttonGrid->setEntry(buttons.at(i), glm::ivec2 {i, 0}, true, false);
|
||||||
buttonGridWidth += buttons.at(i)->getSize().x;
|
buttonGridWidth += buttons.at(i)->getSize().x;
|
||||||
}
|
}
|
||||||
for (unsigned int i = 0; i < buttons.size(); ++i)
|
for (unsigned int i = 0; i < buttons.size(); ++i)
|
||||||
|
|
|
@ -17,13 +17,13 @@ NinePatchComponent::NinePatchComponent(Window* window,
|
||||||
const std::string& path,
|
const std::string& path,
|
||||||
unsigned int edgeColor,
|
unsigned int edgeColor,
|
||||||
unsigned int centerColor)
|
unsigned int centerColor)
|
||||||
: GuiComponent{window}
|
: GuiComponent {window}
|
||||||
, mVertices{nullptr}
|
, mVertices {nullptr}
|
||||||
, mPath{path}
|
, mPath {path}
|
||||||
, mCornerSize{16.0f, 16.0f}
|
, mCornerSize {16.0f, 16.0f}
|
||||||
, mSharpCorners{false}
|
, mSharpCorners {false}
|
||||||
, mEdgeColor{edgeColor}
|
, mEdgeColor {edgeColor}
|
||||||
, mCenterColor{centerColor}
|
, mCenterColor {centerColor}
|
||||||
{
|
{
|
||||||
if (!mPath.empty())
|
if (!mPath.empty())
|
||||||
buildVertices();
|
buildVertices();
|
||||||
|
@ -55,7 +55,7 @@ void NinePatchComponent::buildVertices()
|
||||||
if (mVertices != nullptr)
|
if (mVertices != nullptr)
|
||||||
delete[] mVertices;
|
delete[] mVertices;
|
||||||
|
|
||||||
glm::vec2 relCornerSize{};
|
glm::vec2 relCornerSize {};
|
||||||
|
|
||||||
// Don't scale the rasterized version of the frame as it would look bad.
|
// Don't scale the rasterized version of the frame as it would look bad.
|
||||||
if (mPath.substr(mPath.size() - 4, std::string::npos) == ".png") {
|
if (mPath.substr(mPath.size() - 4, std::string::npos) == ".png") {
|
||||||
|
@ -74,7 +74,7 @@ void NinePatchComponent::buildVertices()
|
||||||
|
|
||||||
mTexture->rasterizeAt(texSize.x, texSize.y);
|
mTexture->rasterizeAt(texSize.x, texSize.y);
|
||||||
|
|
||||||
if (mTexture->getSize() == glm::ivec2{}) {
|
if (mTexture->getSize() == glm::ivec2 {}) {
|
||||||
mVertices = nullptr;
|
mVertices = nullptr;
|
||||||
LOG(LogWarning) << "NinePatchComponent has no texture";
|
LOG(LogWarning) << "NinePatchComponent has no texture";
|
||||||
return;
|
return;
|
||||||
|
@ -82,10 +82,10 @@ void NinePatchComponent::buildVertices()
|
||||||
|
|
||||||
mVertices = new Renderer::Vertex[6 * 9];
|
mVertices = new Renderer::Vertex[6 * 9];
|
||||||
|
|
||||||
const float imgSizeX[3]{relCornerSize.x, mSize.x - relCornerSize.x * 2.0f, relCornerSize.x};
|
const float imgSizeX[3] {relCornerSize.x, mSize.x - relCornerSize.x * 2.0f, relCornerSize.x};
|
||||||
const float imgSizeY[3]{relCornerSize.y, mSize.y - relCornerSize.y * 2.0f, relCornerSize.y};
|
const float imgSizeY[3] {relCornerSize.y, mSize.y - relCornerSize.y * 2.0f, relCornerSize.y};
|
||||||
const float imgPosX[3]{0, imgSizeX[0], imgSizeX[0] + imgSizeX[1]};
|
const float imgPosX[3] {0, imgSizeX[0], imgSizeX[0] + imgSizeX[1]};
|
||||||
const float imgPosY[3]{0, imgSizeY[0], imgSizeY[0] + imgSizeY[1]};
|
const float imgPosY[3] {0, imgSizeY[0], imgSizeY[0] + imgSizeY[1]};
|
||||||
|
|
||||||
// The "1 +" in posY and "-" in sizeY is to deal with texture coordinates having a bottom
|
// The "1 +" in posY and "-" in sizeY is to deal with texture coordinates having a bottom
|
||||||
// left corner origin vs. verticies having a top left origin.
|
// left corner origin vs. verticies having a top left origin.
|
||||||
|
@ -100,12 +100,12 @@ void NinePatchComponent::buildVertices()
|
||||||
int v = 0;
|
int v = 0;
|
||||||
|
|
||||||
for (int slice = 0; slice < 9; ++slice) {
|
for (int slice = 0; slice < 9; ++slice) {
|
||||||
const int sliceX{slice % 3};
|
const int sliceX {slice % 3};
|
||||||
const int sliceY{slice / 3};
|
const int sliceY {slice / 3};
|
||||||
const glm::vec2 imgPos{imgPosX[sliceX], imgPosY[sliceY]};
|
const glm::vec2 imgPos {imgPosX[sliceX], imgPosY[sliceY]};
|
||||||
const glm::vec2 imgSize{imgSizeX[sliceX], imgSizeY[sliceY]};
|
const glm::vec2 imgSize {imgSizeX[sliceX], imgSizeY[sliceY]};
|
||||||
const glm::vec2 texPos{texPosX[sliceX], texPosY[sliceY]};
|
const glm::vec2 texPos {texPosX[sliceX], texPosY[sliceY]};
|
||||||
const glm::vec2 texSizeSlice{texSizeX[sliceX], texSizeY[sliceY]};
|
const glm::vec2 texSizeSlice {texSizeX[sliceX], texSizeY[sliceY]};
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
mVertices[v + 1] = {{imgPos.x , imgPos.y }, {texPos.x, texPos.y }, 0};
|
mVertices[v + 1] = {{imgPos.x , imgPos.y }, {texPos.x, texPos.y }, 0};
|
||||||
|
@ -133,7 +133,7 @@ void NinePatchComponent::render(const glm::mat4& parentTrans)
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
|
|
||||||
if (mTexture && mVertices != nullptr) {
|
if (mTexture && mVertices != nullptr) {
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
|
@ -33,22 +33,22 @@ public:
|
||||||
bool multiSelect = false,
|
bool multiSelect = false,
|
||||||
bool multiExclusiveSelect = false,
|
bool multiExclusiveSelect = false,
|
||||||
bool multiShowTotal = false)
|
bool multiShowTotal = false)
|
||||||
: GuiComponent{window}
|
: GuiComponent {window}
|
||||||
, mHelpStyle{helpstyle}
|
, mHelpStyle {helpstyle}
|
||||||
, mMultiSelect{multiSelect}
|
, mMultiSelect {multiSelect}
|
||||||
, mMultiExclusiveSelect{multiExclusiveSelect}
|
, mMultiExclusiveSelect {multiExclusiveSelect}
|
||||||
, mMultiShowTotal{multiShowTotal}
|
, mMultiShowTotal {multiShowTotal}
|
||||||
, mKeyRepeat{false}
|
, mKeyRepeat {false}
|
||||||
, mKeyRepeatDir{0}
|
, mKeyRepeatDir {0}
|
||||||
, mKeyRepeatTimer{0}
|
, mKeyRepeatTimer {0}
|
||||||
, mKeyRepeatStartDelay{OPTIONLIST_REPEAT_START_DELAY}
|
, mKeyRepeatStartDelay {OPTIONLIST_REPEAT_START_DELAY}
|
||||||
, mKeyRepeatSpeed{OPTIONLIST_REPEAT_SPEED}
|
, mKeyRepeatSpeed {OPTIONLIST_REPEAT_SPEED}
|
||||||
, mName{name}
|
, mName {name}
|
||||||
, mText{window}
|
, mText {window}
|
||||||
, mLeftArrow{window}
|
, mLeftArrow {window}
|
||||||
, mRightArrow{window}
|
, mRightArrow {window}
|
||||||
{
|
{
|
||||||
auto font{Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)};
|
auto font {Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)};
|
||||||
mText.setFont(font);
|
mText.setFont(font);
|
||||||
mText.setColor(0x777777FF);
|
mText.setColor(0x777777FF);
|
||||||
mText.setHorizontalAlignment(ALIGN_CENTER);
|
mText.setHorizontalAlignment(ALIGN_CENTER);
|
||||||
|
|
|
@ -25,7 +25,7 @@ RatingComponent::RatingComponent(Window* window, bool colorizeChanges)
|
||||||
mFilledTexture = TextureResource::get(":/graphics/star_filled.svg", true);
|
mFilledTexture = TextureResource::get(":/graphics/star_filled.svg", true);
|
||||||
mUnfilledTexture = TextureResource::get(":/graphics/star_unfilled.svg", true);
|
mUnfilledTexture = TextureResource::get(":/graphics/star_unfilled.svg", true);
|
||||||
mValue = 0.5f;
|
mValue = 0.5f;
|
||||||
mSize = glm::vec2{64.0f * NUM_RATING_STARS, 64.0f};
|
mSize = glm::vec2 {64.0f * NUM_RATING_STARS, 64.0f};
|
||||||
updateVertices();
|
updateVertices();
|
||||||
updateColors();
|
updateColors();
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,7 @@ void RatingComponent::render(const glm::mat4& parentTrans)
|
||||||
if (!isVisible() || mFilledTexture == nullptr || mUnfilledTexture == nullptr)
|
if (!isVisible() || mFilledTexture == nullptr || mUnfilledTexture == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
|
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ public:
|
||||||
componentList.get()->setScrollIndicatorChangedCallback(
|
componentList.get()->setScrollIndicatorChangedCallback(
|
||||||
[this, scrollUp, scrollDown](ComponentList::ScrollIndicator state,
|
[this, scrollUp, scrollDown](ComponentList::ScrollIndicator state,
|
||||||
bool singleRowScroll) {
|
bool singleRowScroll) {
|
||||||
float fadeTime{FADE_IN_TIME};
|
float fadeTime {FADE_IN_TIME};
|
||||||
|
|
||||||
bool upFadeIn = false;
|
bool upFadeIn = false;
|
||||||
bool upFadeOut = false;
|
bool upFadeOut = false;
|
||||||
|
|
|
@ -15,16 +15,16 @@
|
||||||
#include "resources/Font.h"
|
#include "resources/Font.h"
|
||||||
|
|
||||||
ScrollableContainer::ScrollableContainer(Window* window)
|
ScrollableContainer::ScrollableContainer(Window* window)
|
||||||
: GuiComponent{window}
|
: GuiComponent {window}
|
||||||
, mScrollPos{0.0f, 0.0f}
|
, mScrollPos {0.0f, 0.0f}
|
||||||
, mScrollDir{0.0f, 0.0f}
|
, mScrollDir {0.0f, 0.0f}
|
||||||
, mClipSpacing{0.0f}
|
, mClipSpacing {0.0f}
|
||||||
, mAutoScrollDelay{0}
|
, mAutoScrollDelay {0}
|
||||||
, mAutoScrollSpeed{0}
|
, mAutoScrollSpeed {0}
|
||||||
, mAutoScrollAccumulator{0}
|
, mAutoScrollAccumulator {0}
|
||||||
, mAutoScrollResetAccumulator{0}
|
, mAutoScrollResetAccumulator {0}
|
||||||
, mAdjustedAutoScrollSpeed{0}
|
, mAdjustedAutoScrollSpeed {0}
|
||||||
, mUpdatedSize{false}
|
, mUpdatedSize {false}
|
||||||
{
|
{
|
||||||
// Set the modifier to get equivalent scrolling speed regardless of screen resolution.
|
// Set the modifier to get equivalent scrolling speed regardless of screen resolution.
|
||||||
mResolutionModifier = Renderer::getScreenHeightModifier();
|
mResolutionModifier = Renderer::getScreenHeightModifier();
|
||||||
|
@ -37,12 +37,12 @@ ScrollableContainer::ScrollableContainer(Window* window)
|
||||||
void ScrollableContainer::setAutoScroll(bool autoScroll)
|
void ScrollableContainer::setAutoScroll(bool autoScroll)
|
||||||
{
|
{
|
||||||
if (autoScroll) {
|
if (autoScroll) {
|
||||||
mScrollDir = glm::vec2{0.0f, 1.0f};
|
mScrollDir = glm::vec2 {0.0f, 1.0f};
|
||||||
mAutoScrollDelay = static_cast<int>(mAutoScrollDelayConstant);
|
mAutoScrollDelay = static_cast<int>(mAutoScrollDelayConstant);
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mScrollDir = glm::vec2{};
|
mScrollDir = glm::vec2 {};
|
||||||
mAutoScrollDelay = 0;
|
mAutoScrollDelay = 0;
|
||||||
mAutoScrollSpeed = 0;
|
mAutoScrollSpeed = 0;
|
||||||
mAutoScrollAccumulator = 0;
|
mAutoScrollAccumulator = 0;
|
||||||
|
@ -60,17 +60,17 @@ void ScrollableContainer::setScrollParameters(float autoScrollDelayConstant,
|
||||||
|
|
||||||
void ScrollableContainer::reset()
|
void ScrollableContainer::reset()
|
||||||
{
|
{
|
||||||
mScrollPos = glm::vec2{};
|
mScrollPos = glm::vec2 {};
|
||||||
mAutoScrollResetAccumulator = 0;
|
mAutoScrollResetAccumulator = 0;
|
||||||
mAutoScrollAccumulator = -mAutoScrollDelay + mAutoScrollSpeed;
|
mAutoScrollAccumulator = -mAutoScrollDelay + mAutoScrollSpeed;
|
||||||
mAtEnd = false;
|
mAtEnd = false;
|
||||||
// This is needed to resize to the font height boundary when we keep running in the background
|
// This is needed to resize to the font height boundary when we keep running in the background
|
||||||
// while launching games.
|
// while launching games.
|
||||||
if (!mChildren.empty()) {
|
if (!mChildren.empty()) {
|
||||||
float combinedHeight{
|
float combinedHeight {
|
||||||
mChildren.front()->getFont()->getHeight(mChildren.front()->getLineSpacing())};
|
mChildren.front()->getFont()->getHeight(mChildren.front()->getLineSpacing())};
|
||||||
if (mChildren.front()->getSize().y > mSize.y) {
|
if (mChildren.front()->getSize().y > mSize.y) {
|
||||||
float numLines{mSize.y / combinedHeight};
|
float numLines {mSize.y / combinedHeight};
|
||||||
mSize.y = floorf(numLines) * combinedHeight;
|
mSize.y = floorf(numLines) * combinedHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,16 +81,16 @@ void ScrollableContainer::update(int deltaTime)
|
||||||
// Don't scroll if the media viewer or screensaver is active or if text scrolling is disabled;
|
// Don't scroll if the media viewer or screensaver is active or if text scrolling is disabled;
|
||||||
if (mWindow->isMediaViewerActive() || mWindow->isScreensaverActive() ||
|
if (mWindow->isMediaViewerActive() || mWindow->isScreensaverActive() ||
|
||||||
!mWindow->getAllowTextScrolling()) {
|
!mWindow->getAllowTextScrolling()) {
|
||||||
if (mScrollPos != glm::vec2{} && !mWindow->isLaunchScreenDisplayed())
|
if (mScrollPos != glm::vec2 {} && !mWindow->isLaunchScreenDisplayed())
|
||||||
reset();
|
reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const glm::vec2 contentSize{mChildren.front()->getSize()};
|
const glm::vec2 contentSize {mChildren.front()->getSize()};
|
||||||
float rowModifier{1.0f};
|
float rowModifier {1.0f};
|
||||||
|
|
||||||
float lineSpacing{mChildren.front()->getLineSpacing()};
|
float lineSpacing {mChildren.front()->getLineSpacing()};
|
||||||
float combinedHeight{mChildren.front()->getFont()->getHeight(lineSpacing)};
|
float combinedHeight {mChildren.front()->getFont()->getHeight(lineSpacing)};
|
||||||
|
|
||||||
// Calculate the spacing which will be used to clip the container.
|
// Calculate the spacing which will be used to clip the container.
|
||||||
if (lineSpacing > 1.2f && mClipSpacing == 0.0f) {
|
if (lineSpacing > 1.2f && mClipSpacing == 0.0f) {
|
||||||
|
@ -101,23 +101,23 @@ void ScrollableContainer::update(int deltaTime)
|
||||||
|
|
||||||
// Resize container to font height boundary to avoid rendering a fraction of the last line.
|
// Resize container to font height boundary to avoid rendering a fraction of the last line.
|
||||||
if (!mUpdatedSize && contentSize.y > mSize.y) {
|
if (!mUpdatedSize && contentSize.y > mSize.y) {
|
||||||
float numLines{mSize.y / combinedHeight};
|
float numLines {mSize.y / combinedHeight};
|
||||||
mSize.y = floorf(numLines) * combinedHeight;
|
mSize.y = floorf(numLines) * combinedHeight;
|
||||||
mUpdatedSize = true;
|
mUpdatedSize = true;
|
||||||
}
|
}
|
||||||
else if (mUpdatedSize) {
|
else if (mUpdatedSize) {
|
||||||
// If there are less than 8 lines of text, accelerate the scrolling further.
|
// If there are less than 8 lines of text, accelerate the scrolling further.
|
||||||
float lines{mSize.y / combinedHeight};
|
float lines {mSize.y / combinedHeight};
|
||||||
if (lines < 8.0f)
|
if (lines < 8.0f)
|
||||||
rowModifier = lines / 8.0f;
|
rowModifier = lines / 8.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mAdjustedAutoScrollSpeed) {
|
if (!mAdjustedAutoScrollSpeed) {
|
||||||
float fontSize{static_cast<float>(mChildren.front()->getFont()->getSize())};
|
float fontSize {static_cast<float>(mChildren.front()->getFont()->getSize())};
|
||||||
float width{contentSize.x / (fontSize * 1.3f)};
|
float width {contentSize.x / (fontSize * 1.3f)};
|
||||||
|
|
||||||
// Keep speed adjustments within reason.
|
// Keep speed adjustments within reason.
|
||||||
float speedModifier{glm::clamp(width, 10.0f, 40.0f)};
|
float speedModifier {glm::clamp(width, 10.0f, 40.0f)};
|
||||||
|
|
||||||
speedModifier *= mAutoScrollSpeedConstant;
|
speedModifier *= mAutoScrollSpeedConstant;
|
||||||
speedModifier /= mResolutionModifier;
|
speedModifier /= mResolutionModifier;
|
||||||
|
@ -163,7 +163,7 @@ void ScrollableContainer::update(int deltaTime)
|
||||||
// Fade in the text as it resets to the start position.
|
// Fade in the text as it resets to the start position.
|
||||||
auto func = [this](float t) {
|
auto func = [this](float t) {
|
||||||
this->setOpacity(static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
this->setOpacity(static_cast<unsigned char>(glm::mix(0.0f, 1.0f, t) * 255));
|
||||||
mScrollPos = glm::vec2{};
|
mScrollPos = glm::vec2 {};
|
||||||
mAutoScrollResetAccumulator = 0;
|
mAutoScrollResetAccumulator = 0;
|
||||||
mAutoScrollAccumulator = -mAutoScrollDelay + mAutoScrollSpeed;
|
mAutoScrollAccumulator = -mAutoScrollDelay + mAutoScrollSpeed;
|
||||||
mAtEnd = false;
|
mAtEnd = false;
|
||||||
|
@ -180,16 +180,16 @@ void ScrollableContainer::render(const glm::mat4& parentTrans)
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
|
|
||||||
glm::ivec2 clipPos{static_cast<int>(trans[3].x), static_cast<int>(trans[3].y)};
|
glm::ivec2 clipPos {static_cast<int>(trans[3].x), static_cast<int>(trans[3].y)};
|
||||||
|
|
||||||
glm::vec3 dimScaled{};
|
glm::vec3 dimScaled {};
|
||||||
dimScaled.x = std::fabs(trans[3].x + mSize.x);
|
dimScaled.x = std::fabs(trans[3].x + mSize.x);
|
||||||
dimScaled.y = std::fabs(trans[3].y + mSize.y);
|
dimScaled.y = std::fabs(trans[3].y + mSize.y);
|
||||||
|
|
||||||
glm::ivec2 clipDim{static_cast<int>(ceilf(dimScaled.x - trans[3].x)),
|
glm::ivec2 clipDim {static_cast<int>(ceilf(dimScaled.x - trans[3].x)),
|
||||||
static_cast<int>(ceilf(dimScaled.y - trans[3].y))};
|
static_cast<int>(ceilf(dimScaled.y - trans[3].y))};
|
||||||
|
|
||||||
// By effectively clipping the upper and lower boundaries of the container we mostly avoid
|
// By effectively clipping the upper and lower boundaries of the container we mostly avoid
|
||||||
// scrolling outside the vertical starting and ending positions.
|
// scrolling outside the vertical starting and ending positions.
|
||||||
|
@ -198,7 +198,7 @@ void ScrollableContainer::render(const glm::mat4& parentTrans)
|
||||||
|
|
||||||
Renderer::pushClipRect(clipPos, clipDim);
|
Renderer::pushClipRect(clipPos, clipDim);
|
||||||
|
|
||||||
trans = glm::translate(trans, -glm::vec3{mScrollPos.x, mScrollPos.y, 0.0f});
|
trans = glm::translate(trans, -glm::vec3 {mScrollPos.x, mScrollPos.y, 0.0f});
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
GuiComponent::renderChildren(trans);
|
GuiComponent::renderChildren(trans);
|
||||||
|
|
|
@ -16,14 +16,14 @@
|
||||||
|
|
||||||
SliderComponent::SliderComponent(
|
SliderComponent::SliderComponent(
|
||||||
Window* window, float min, float max, float increment, const std::string& suffix)
|
Window* window, float min, float max, float increment, const std::string& suffix)
|
||||||
: GuiComponent{window}
|
: GuiComponent {window}
|
||||||
, mMin{min}
|
, mMin {min}
|
||||||
, mMax{max}
|
, mMax {max}
|
||||||
, mSingleIncrement{increment}
|
, mSingleIncrement {increment}
|
||||||
, mMoveRate{0.0f}
|
, mMoveRate {0.0f}
|
||||||
, mBarHeight{0.0f}
|
, mBarHeight {0.0f}
|
||||||
, mKnob{window}
|
, mKnob {window}
|
||||||
, mSuffix{suffix}
|
, mSuffix {suffix}
|
||||||
{
|
{
|
||||||
assert((min - max) != 0.0f);
|
assert((min - max) != 0.0f);
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ void SliderComponent::update(int deltaTime)
|
||||||
|
|
||||||
void SliderComponent::render(const glm::mat4& parentTrans)
|
void SliderComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
if (Settings::getInstance()->getBool("DebugText")) {
|
if (Settings::getInstance()->getBool("DebugText")) {
|
||||||
|
@ -89,10 +89,10 @@ void SliderComponent::render(const glm::mat4& parentTrans)
|
||||||
mSize.y, 0x00000033, 0x00000033);
|
mSize.y, 0x00000033, 0x00000033);
|
||||||
}
|
}
|
||||||
|
|
||||||
float width{mSize.x - mKnob.getSize().x -
|
float width {mSize.x - mKnob.getSize().x -
|
||||||
(mTextCache ?
|
(mTextCache ?
|
||||||
mTextCache->metrics.size.x + (4.0f * Renderer::getScreenWidthModifier()) :
|
mTextCache->metrics.size.x + (4.0f * Renderer::getScreenWidthModifier()) :
|
||||||
0.0f)};
|
0.0f)};
|
||||||
|
|
||||||
// Render suffix.
|
// Render suffix.
|
||||||
if (mTextCache)
|
if (mTextCache)
|
||||||
|
|
|
@ -44,7 +44,7 @@ bool SwitchComponent::input(InputConfig* config, Input input)
|
||||||
|
|
||||||
void SwitchComponent::render(const glm::mat4& parentTrans)
|
void SwitchComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
mImage.render(trans);
|
mImage.render(trans);
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,18 +13,18 @@
|
||||||
#include "utils/StringUtil.h"
|
#include "utils/StringUtil.h"
|
||||||
|
|
||||||
TextComponent::TextComponent(Window* window)
|
TextComponent::TextComponent(Window* window)
|
||||||
: GuiComponent{window}
|
: GuiComponent {window}
|
||||||
, mFont{Font::get(FONT_SIZE_MEDIUM)}
|
, mFont {Font::get(FONT_SIZE_MEDIUM)}
|
||||||
, mColor{0x000000FF}
|
, mColor {0x000000FF}
|
||||||
, mBgColor{0}
|
, mBgColor {0}
|
||||||
, mRenderBackground{false}
|
, mRenderBackground {false}
|
||||||
, mUppercase{false}
|
, mUppercase {false}
|
||||||
, mAutoCalcExtent{1, 1}
|
, mAutoCalcExtent {1, 1}
|
||||||
, mHorizontalAlignment{ALIGN_LEFT}
|
, mHorizontalAlignment {ALIGN_LEFT}
|
||||||
, mVerticalAlignment{ALIGN_CENTER}
|
, mVerticalAlignment {ALIGN_CENTER}
|
||||||
, mLineSpacing{1.5f}
|
, mLineSpacing {1.5f}
|
||||||
, mNoTopMargin{false}
|
, mNoTopMargin {false}
|
||||||
, mSelectable{false}
|
, mSelectable {false}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,18 +36,18 @@ TextComponent::TextComponent(Window* window,
|
||||||
glm::vec3 pos,
|
glm::vec3 pos,
|
||||||
glm::vec2 size,
|
glm::vec2 size,
|
||||||
unsigned int bgcolor)
|
unsigned int bgcolor)
|
||||||
: GuiComponent{window}
|
: GuiComponent {window}
|
||||||
, mFont{nullptr}
|
, mFont {nullptr}
|
||||||
, mColor{0x000000FF}
|
, mColor {0x000000FF}
|
||||||
, mBgColor{0}
|
, mBgColor {0}
|
||||||
, mRenderBackground{false}
|
, mRenderBackground {false}
|
||||||
, mUppercase{false}
|
, mUppercase {false}
|
||||||
, mAutoCalcExtent{1, 1}
|
, mAutoCalcExtent {1, 1}
|
||||||
, mHorizontalAlignment{align}
|
, mHorizontalAlignment {align}
|
||||||
, mVerticalAlignment{ALIGN_CENTER}
|
, mVerticalAlignment {ALIGN_CENTER}
|
||||||
, mLineSpacing{1.5f}
|
, mLineSpacing {1.5f}
|
||||||
, mNoTopMargin{false}
|
, mNoTopMargin {false}
|
||||||
, mSelectable{false}
|
, mSelectable {false}
|
||||||
{
|
{
|
||||||
setFont(font);
|
setFont(font);
|
||||||
setColor(color);
|
setColor(color);
|
||||||
|
@ -59,7 +59,7 @@ TextComponent::TextComponent(Window* window,
|
||||||
|
|
||||||
void TextComponent::onSizeChanged()
|
void TextComponent::onSizeChanged()
|
||||||
{
|
{
|
||||||
mAutoCalcExtent = glm::ivec2{(getSize().x == 0), (getSize().y == 0)};
|
mAutoCalcExtent = glm::ivec2 {(getSize().x == 0), (getSize().y == 0)};
|
||||||
onTextChanged();
|
onTextChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,7 +127,7 @@ void TextComponent::render(const glm::mat4& parentTrans)
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
|
|
||||||
if (mRenderBackground) {
|
if (mRenderBackground) {
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
@ -135,7 +135,7 @@ void TextComponent::render(const glm::mat4& parentTrans)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mTextCache) {
|
if (mTextCache) {
|
||||||
const glm::vec2& textSize{mTextCache->metrics.size};
|
const glm::vec2& textSize {mTextCache->metrics.size};
|
||||||
float yOff = 0.0f;
|
float yOff = 0.0f;
|
||||||
switch (mVerticalAlignment) {
|
switch (mVerticalAlignment) {
|
||||||
case ALIGN_TOP: {
|
case ALIGN_TOP: {
|
||||||
|
@ -154,7 +154,7 @@ void TextComponent::render(const glm::mat4& parentTrans)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glm::vec3 off{0.0f, yOff, 0.0f};
|
glm::vec3 off {0.0f, yOff, 0.0f};
|
||||||
|
|
||||||
if (Settings::getInstance()->getBool("DebugText")) {
|
if (Settings::getInstance()->getBool("DebugText")) {
|
||||||
// Draw the "textbox" area, what we are aligned within.
|
// Draw the "textbox" area, what we are aligned within.
|
||||||
|
@ -230,11 +230,11 @@ void TextComponent::onTextChanged()
|
||||||
addAbbrev = newline != std::string::npos;
|
addAbbrev = newline != std::string::npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 size{f->sizeText(text)};
|
glm::vec2 size {f->sizeText(text)};
|
||||||
if (!isMultiline && mSize.x > 0.0f && text.size() && (size.x > mSize.x || addAbbrev)) {
|
if (!isMultiline && mSize.x > 0.0f && text.size() && (size.x > mSize.x || addAbbrev)) {
|
||||||
// Abbreviate text.
|
// Abbreviate text.
|
||||||
const std::string abbrev = "...";
|
const std::string abbrev = "...";
|
||||||
glm::vec2 abbrevSize{f->sizeText(abbrev)};
|
glm::vec2 abbrevSize {f->sizeText(abbrev)};
|
||||||
|
|
||||||
while (text.size() && size.x + abbrevSize.x > mSize.x) {
|
while (text.size() && size.x + abbrevSize.x > mSize.x) {
|
||||||
size_t newSize = Utils::String::prevCursor(text, text.size());
|
size_t newSize = Utils::String::prevCursor(text, text.size());
|
||||||
|
@ -247,12 +247,12 @@ void TextComponent::onTextChanged()
|
||||||
text.append(abbrev);
|
text.append(abbrev);
|
||||||
|
|
||||||
mTextCache = std::shared_ptr<TextCache>(
|
mTextCache = std::shared_ptr<TextCache>(
|
||||||
f->buildTextCache(text, glm::vec2{}, (mColor >> 8 << 8) | mOpacity, mSize.x,
|
f->buildTextCache(text, glm::vec2 {}, (mColor >> 8 << 8) | mOpacity, mSize.x,
|
||||||
mHorizontalAlignment, mLineSpacing, mNoTopMargin));
|
mHorizontalAlignment, mLineSpacing, mNoTopMargin));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
mTextCache = std::shared_ptr<TextCache>(f->buildTextCache(
|
mTextCache = std::shared_ptr<TextCache>(f->buildTextCache(
|
||||||
f->wrapText(text, mSize.x), glm::vec2{}, (mColor >> 8 << 8) | mOpacity, mSize.x,
|
f->wrapText(text, mSize.x), glm::vec2 {}, (mColor >> 8 << 8) | mOpacity, mSize.x,
|
||||||
mHorizontalAlignment, mLineSpacing, mNoTopMargin));
|
mHorizontalAlignment, mLineSpacing, mNoTopMargin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,15 +19,15 @@
|
||||||
#define BLINKTIME 1000
|
#define BLINKTIME 1000
|
||||||
|
|
||||||
TextEditComponent::TextEditComponent(Window* window)
|
TextEditComponent::TextEditComponent(Window* window)
|
||||||
: GuiComponent{window}
|
: GuiComponent {window}
|
||||||
, mFocused{false}
|
, mFocused {false}
|
||||||
, mEditing{false}
|
, mEditing {false}
|
||||||
, mCursor{0}
|
, mCursor {0}
|
||||||
, mBlinkTime{0}
|
, mBlinkTime {0}
|
||||||
, mCursorRepeatDir{0}
|
, mCursorRepeatDir {0}
|
||||||
, mScrollOffset{0.0f, 0.0f}
|
, mScrollOffset {0.0f, 0.0f}
|
||||||
, mBox{window, ":/graphics/textinput.svg"}
|
, mBox {window, ":/graphics/textinput.svg"}
|
||||||
, mFont{Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)}
|
, mFont {Font::get(FONT_SIZE_MEDIUM, FONT_PATH_LIGHT)}
|
||||||
{
|
{
|
||||||
mBox.setSharpCorners(true);
|
mBox.setSharpCorners(true);
|
||||||
addChild(&mBox);
|
addChild(&mBox);
|
||||||
|
@ -51,8 +51,8 @@ void TextEditComponent::onFocusLost()
|
||||||
void TextEditComponent::onSizeChanged()
|
void TextEditComponent::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBox.fitTo(
|
mBox.fitTo(
|
||||||
mSize, glm::vec3{},
|
mSize, glm::vec3 {},
|
||||||
glm::vec2{-34.0f, -32.0f - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier())});
|
glm::vec2 {-34.0f, -32.0f - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier())});
|
||||||
onTextChanged(); // Wrap point probably changed.
|
onTextChanged(); // Wrap point probably changed.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +269,7 @@ void TextEditComponent::onTextChanged()
|
||||||
void TextEditComponent::onCursorChanged()
|
void TextEditComponent::onCursorChanged()
|
||||||
{
|
{
|
||||||
if (isMultiline()) {
|
if (isMultiline()) {
|
||||||
glm::vec2 textSize{mFont->getWrappedTextCursorOffset(mText, getTextAreaSize().x, mCursor)};
|
glm::vec2 textSize {mFont->getWrappedTextCursorOffset(mText, getTextAreaSize().x, mCursor)};
|
||||||
|
|
||||||
// Need to scroll down?
|
// Need to scroll down?
|
||||||
if (mScrollOffset.y + getTextAreaSize().y < textSize.y + mFont->getHeight())
|
if (mScrollOffset.y + getTextAreaSize().y < textSize.y + mFont->getHeight())
|
||||||
|
@ -279,7 +279,7 @@ void TextEditComponent::onCursorChanged()
|
||||||
mScrollOffset.y = textSize.y;
|
mScrollOffset.y = textSize.y;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
glm::vec2 cursorPos{mFont->sizeText(mText.substr(0, mCursor))};
|
glm::vec2 cursorPos {mFont->sizeText(mText.substr(0, mCursor))};
|
||||||
|
|
||||||
if (mScrollOffset.x + getTextAreaSize().x < cursorPos.x)
|
if (mScrollOffset.x + getTextAreaSize().x < cursorPos.x)
|
||||||
mScrollOffset.x = cursorPos.x - getTextAreaSize().x;
|
mScrollOffset.x = cursorPos.x - getTextAreaSize().x;
|
||||||
|
@ -290,24 +290,24 @@ void TextEditComponent::onCursorChanged()
|
||||||
|
|
||||||
void TextEditComponent::render(const glm::mat4& parentTrans)
|
void TextEditComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
glm::mat4 trans{getTransform() * parentTrans};
|
glm::mat4 trans {getTransform() * parentTrans};
|
||||||
renderChildren(trans);
|
renderChildren(trans);
|
||||||
|
|
||||||
// Text + cursor rendering.
|
// Text + cursor rendering.
|
||||||
// Offset into our "text area" (padding).
|
// Offset into our "text area" (padding).
|
||||||
trans = glm::translate(trans, glm::vec3{getTextAreaPos().x, getTextAreaPos().y, 0.0f});
|
trans = glm::translate(trans, glm::vec3 {getTextAreaPos().x, getTextAreaPos().y, 0.0f});
|
||||||
|
|
||||||
glm::ivec2 clipPos{static_cast<int>(trans[3].x), static_cast<int>(trans[3].y)};
|
glm::ivec2 clipPos {static_cast<int>(trans[3].x), static_cast<int>(trans[3].y)};
|
||||||
// Use "text area" size for clipping.
|
// Use "text area" size for clipping.
|
||||||
glm::vec3 dimScaled{};
|
glm::vec3 dimScaled {};
|
||||||
dimScaled.x = std::fabs(trans[3].x + getTextAreaSize().x);
|
dimScaled.x = std::fabs(trans[3].x + getTextAreaSize().x);
|
||||||
dimScaled.y = std::fabs(trans[3].y + getTextAreaSize().y);
|
dimScaled.y = std::fabs(trans[3].y + getTextAreaSize().y);
|
||||||
|
|
||||||
glm::ivec2 clipDim{static_cast<int>(dimScaled.x - trans[3].x),
|
glm::ivec2 clipDim {static_cast<int>(dimScaled.x - trans[3].x),
|
||||||
static_cast<int>(dimScaled.y - trans[3].y)};
|
static_cast<int>(dimScaled.y - trans[3].y)};
|
||||||
Renderer::pushClipRect(clipPos, clipDim);
|
Renderer::pushClipRect(clipPos, clipDim);
|
||||||
|
|
||||||
trans = glm::translate(trans, glm::vec3{-mScrollOffset.x, -mScrollOffset.y, 0.0f});
|
trans = glm::translate(trans, glm::vec3 {-mScrollOffset.x, -mScrollOffset.y, 0.0f});
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
||||||
if (mTextCache)
|
if (mTextCache)
|
||||||
|
@ -343,14 +343,14 @@ void TextEditComponent::render(const glm::mat4& parentTrans)
|
||||||
|
|
||||||
glm::vec2 TextEditComponent::getTextAreaPos() const
|
glm::vec2 TextEditComponent::getTextAreaPos() const
|
||||||
{
|
{
|
||||||
return glm::vec2{(TEXT_PADDING_HORIZ * Renderer::getScreenWidthModifier()) / 2.0f,
|
return glm::vec2 {(TEXT_PADDING_HORIZ * Renderer::getScreenWidthModifier()) / 2.0f,
|
||||||
(TEXT_PADDING_VERT * Renderer::getScreenHeightModifier()) / 2.0f};
|
(TEXT_PADDING_VERT * Renderer::getScreenHeightModifier()) / 2.0f};
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 TextEditComponent::getTextAreaSize() const
|
glm::vec2 TextEditComponent::getTextAreaSize() const
|
||||||
{
|
{
|
||||||
return glm::vec2{mSize.x - (TEXT_PADDING_HORIZ * Renderer::getScreenWidthModifier()),
|
return glm::vec2 {mSize.x - (TEXT_PADDING_HORIZ * Renderer::getScreenWidthModifier()),
|
||||||
mSize.y - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier())};
|
mSize.y - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier())};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<HelpPrompt> TextEditComponent::getHelpPrompts()
|
std::vector<HelpPrompt> TextEditComponent::getHelpPrompts()
|
||||||
|
|
|
@ -164,24 +164,24 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
|
||||||
if (size() == 0)
|
if (size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
std::shared_ptr<Font>& font{mFont};
|
std::shared_ptr<Font>& font {mFont};
|
||||||
|
|
||||||
int startEntry{0};
|
int startEntry {0};
|
||||||
float y{0.0f};
|
float y {0.0f};
|
||||||
|
|
||||||
const float entrySize{std::max(floorf(font->getHeight(1.0f)),
|
const float entrySize {std::max(floorf(font->getHeight(1.0f)),
|
||||||
floorf(static_cast<float>(font->getSize())) * mLineSpacing)};
|
floorf(static_cast<float>(font->getSize())) * mLineSpacing)};
|
||||||
const float lineSpacingHeight{floorf(font->getHeight(mLineSpacing) - font->getHeight(1.0f))};
|
const float lineSpacingHeight {floorf(font->getHeight(mLineSpacing) - font->getHeight(1.0f))};
|
||||||
|
|
||||||
// This extra vertical margin is technically incorrect, but it adds a little extra leeway
|
// This extra vertical margin is technically incorrect, but it adds a little extra leeway
|
||||||
// to avoid removing the last row on some older theme sets. There was a sizing bug in the
|
// to avoid removing the last row on some older theme sets. There was a sizing bug in the
|
||||||
// RetroPie fork of EmulationStation and some theme authors set sizes that are just slightly
|
// RetroPie fork of EmulationStation and some theme authors set sizes that are just slightly
|
||||||
// too small for the last row to show up when the sizing calculation is done correctly.
|
// too small for the last row to show up when the sizing calculation is done correctly.
|
||||||
const float extraMargin{(Renderer::getScreenHeightModifier() >= 1.0f ? 3.0f : 0.0f)};
|
const float extraMargin {(Renderer::getScreenHeightModifier() >= 1.0f ? 3.0f : 0.0f)};
|
||||||
|
|
||||||
// Number of entries that can fit on the screen simultaneously.
|
// Number of entries that can fit on the screen simultaneously.
|
||||||
int screenCount{
|
int screenCount {
|
||||||
static_cast<int>(floorf((mSize.y + lineSpacingHeight / 2.0f + extraMargin) / entrySize))};
|
static_cast<int>(floorf((mSize.y + lineSpacingHeight / 2.0f + extraMargin) / entrySize))};
|
||||||
|
|
||||||
if (size() >= screenCount) {
|
if (size() >= screenCount) {
|
||||||
|
@ -218,15 +218,15 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clip to inside margins.
|
// Clip to inside margins.
|
||||||
glm::vec3 dim{mSize.x, mSize.y, 0.0f};
|
glm::vec3 dim {mSize.x, mSize.y, 0.0f};
|
||||||
dim.x = (trans[0].x * dim.x + trans[3].x) - trans[3].x;
|
dim.x = (trans[0].x * dim.x + trans[3].x) - trans[3].x;
|
||||||
dim.y = (trans[1].y * dim.y + trans[3].y) - trans[3].y;
|
dim.y = (trans[1].y * dim.y + trans[3].y) - trans[3].y;
|
||||||
|
|
||||||
Renderer::pushClipRect(
|
Renderer::pushClipRect(
|
||||||
glm::ivec2{static_cast<int>(std::round(trans[3].x + mHorizontalMargin)),
|
glm::ivec2 {static_cast<int>(std::round(trans[3].x + mHorizontalMargin)),
|
||||||
static_cast<int>(std::round(trans[3].y))},
|
static_cast<int>(std::round(trans[3].y))},
|
||||||
glm::ivec2{static_cast<int>(std::round(dim.x - mHorizontalMargin * 2.0f)),
|
glm::ivec2 {static_cast<int>(std::round(dim.x - mHorizontalMargin * 2.0f)),
|
||||||
static_cast<int>(std::round(dim.y))});
|
static_cast<int>(std::round(dim.y))});
|
||||||
|
|
||||||
for (int i = startEntry; i < listCutoff; ++i) {
|
for (int i = startEntry; i < listCutoff; ++i) {
|
||||||
typename IList<TextListData, T>::Entry& entry = mEntries.at(static_cast<unsigned int>(i));
|
typename IList<TextListData, T>::Entry& entry = mEntries.at(static_cast<unsigned int>(i));
|
||||||
|
@ -250,7 +250,7 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
|
||||||
else
|
else
|
||||||
entry.data.textCache->setColor(color);
|
entry.data.textCache->setColor(color);
|
||||||
|
|
||||||
glm::vec3 offset{0.0f, y, 0.0f};
|
glm::vec3 offset {0.0f, y, 0.0f};
|
||||||
|
|
||||||
switch (mAlignment) {
|
switch (mAlignment) {
|
||||||
case ALIGN_LEFT:
|
case ALIGN_LEFT:
|
||||||
|
@ -271,12 +271,12 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
|
||||||
}
|
}
|
||||||
|
|
||||||
// Render text.
|
// Render text.
|
||||||
glm::mat4 drawTrans{trans};
|
glm::mat4 drawTrans {trans};
|
||||||
|
|
||||||
// Currently selected item text might be looping.
|
// Currently selected item text might be looping.
|
||||||
if (mCursor == i && mLoopOffset > 0)
|
if (mCursor == i && mLoopOffset > 0)
|
||||||
drawTrans = glm::translate(
|
drawTrans = glm::translate(
|
||||||
drawTrans, offset - glm::vec3{static_cast<float>(mLoopOffset), 0.0f, 0.0f});
|
drawTrans, offset - glm::vec3 {static_cast<float>(mLoopOffset), 0.0f, 0.0f});
|
||||||
else
|
else
|
||||||
drawTrans = glm::translate(drawTrans, offset);
|
drawTrans = glm::translate(drawTrans, offset);
|
||||||
|
|
||||||
|
@ -292,7 +292,7 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
|
||||||
mLoopScroll = true;
|
mLoopScroll = true;
|
||||||
drawTrans = trans;
|
drawTrans = trans;
|
||||||
drawTrans = glm::translate(
|
drawTrans = glm::translate(
|
||||||
drawTrans, offset - glm::vec3{static_cast<float>(mLoopOffset2), 0.0f, 0.0f});
|
drawTrans, offset - glm::vec3 {static_cast<float>(mLoopOffset2), 0.0f, 0.0f});
|
||||||
Renderer::setMatrix(drawTrans);
|
Renderer::setMatrix(drawTrans);
|
||||||
font->renderTextCache(entry.data.textCache.get());
|
font->renderTextCache(entry.data.textCache.get());
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,7 +178,7 @@ void VideoComponent::render(const glm::mat4& parentTrans)
|
||||||
if (!isVisible())
|
if (!isVisible())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
GuiComponent::renderChildren(trans);
|
GuiComponent::renderChildren(trans);
|
||||||
|
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
@ -225,9 +225,9 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
if (!elem)
|
if (!elem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
glm::vec2 scale{getParent() ? getParent()->getSize() :
|
glm::vec2 scale {getParent() ? getParent()->getSize() :
|
||||||
glm::vec2{static_cast<float>(Renderer::getScreenWidth()),
|
glm::vec2 {static_cast<float>(Renderer::getScreenWidth()),
|
||||||
static_cast<float>(Renderer::getScreenHeight())}};
|
static_cast<float>(Renderer::getScreenHeight())}};
|
||||||
|
|
||||||
if (properties & ThemeFlags::SIZE) {
|
if (properties & ThemeFlags::SIZE) {
|
||||||
if (elem->has("size")) {
|
if (elem->has("size")) {
|
||||||
|
|
|
@ -60,7 +60,7 @@ VideoFFmpegComponent::~VideoFFmpegComponent() { stopVideo(); }
|
||||||
void VideoFFmpegComponent::setResize(float width, float height)
|
void VideoFFmpegComponent::setResize(float width, float height)
|
||||||
{
|
{
|
||||||
// This resize function is used when stretching videos to full screen in the video screensaver.
|
// This resize function is used when stretching videos to full screen in the video screensaver.
|
||||||
mTargetSize = glm::vec2{width, height};
|
mTargetSize = glm::vec2 {width, height};
|
||||||
mTargetIsMax = false;
|
mTargetIsMax = false;
|
||||||
mStaticImage.setResize(width, height);
|
mStaticImage.setResize(width, height);
|
||||||
resize();
|
resize();
|
||||||
|
@ -70,7 +70,7 @@ void VideoFFmpegComponent::setMaxSize(float width, float height)
|
||||||
{
|
{
|
||||||
// This resize function is used in most instances, such as non-stretched video screensaver
|
// This resize function is used in most instances, such as non-stretched video screensaver
|
||||||
// and the gamelist videos.
|
// and the gamelist videos.
|
||||||
mTargetSize = glm::vec2{width, height};
|
mTargetSize = glm::vec2 {width, height};
|
||||||
mTargetIsMax = true;
|
mTargetIsMax = true;
|
||||||
mStaticImage.setMaxSize(width, height);
|
mStaticImage.setMaxSize(width, height);
|
||||||
resize();
|
resize();
|
||||||
|
@ -81,15 +81,15 @@ void VideoFFmpegComponent::resize()
|
||||||
if (!mTexture)
|
if (!mTexture)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const glm::vec2 textureSize{static_cast<float>(mVideoWidth), static_cast<float>(mVideoHeight)};
|
const glm::vec2 textureSize {static_cast<float>(mVideoWidth), static_cast<float>(mVideoHeight)};
|
||||||
|
|
||||||
if (textureSize == glm::vec2{})
|
if (textureSize == glm::vec2 {})
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mTargetIsMax) {
|
if (mTargetIsMax) {
|
||||||
mSize = textureSize;
|
mSize = textureSize;
|
||||||
|
|
||||||
glm::vec2 resizeScale{(mTargetSize.x / mSize.x), (mTargetSize.y / mSize.y)};
|
glm::vec2 resizeScale {(mTargetSize.x / mSize.x), (mTargetSize.y / mSize.y)};
|
||||||
|
|
||||||
if (resizeScale.x < resizeScale.y) {
|
if (resizeScale.x < resizeScale.y) {
|
||||||
mSize.x *= resizeScale.x;
|
mSize.x *= resizeScale.x;
|
||||||
|
@ -106,7 +106,7 @@ void VideoFFmpegComponent::resize()
|
||||||
else {
|
else {
|
||||||
// If both components are set, we just stretch.
|
// If both components are set, we just stretch.
|
||||||
// If no components are set, we don't resize at all.
|
// If no components are set, we don't resize at all.
|
||||||
mSize = mTargetSize == glm::vec2{} ? textureSize : mTargetSize;
|
mSize = mTargetSize == glm::vec2 {} ? textureSize : mTargetSize;
|
||||||
|
|
||||||
// If only one component is set, we resize in a way that maintains aspect ratio.
|
// If only one component is set, we resize in a way that maintains aspect ratio.
|
||||||
if (!mTargetSize.x && mTargetSize.y) {
|
if (!mTargetSize.x && mTargetSize.y) {
|
||||||
|
@ -125,7 +125,7 @@ void VideoFFmpegComponent::resize()
|
||||||
void VideoFFmpegComponent::render(const glm::mat4& parentTrans)
|
void VideoFFmpegComponent::render(const glm::mat4& parentTrans)
|
||||||
{
|
{
|
||||||
VideoComponent::render(parentTrans);
|
VideoComponent::render(parentTrans);
|
||||||
glm::mat4 trans{parentTrans * getTransform()};
|
glm::mat4 trans {parentTrans * getTransform()};
|
||||||
GuiComponent::renderChildren(trans);
|
GuiComponent::renderChildren(trans);
|
||||||
|
|
||||||
if (mIsPlaying && mFormatContext) {
|
if (mIsPlaying && mFormatContext) {
|
||||||
|
@ -864,7 +864,7 @@ void VideoFFmpegComponent::calculateBlackRectangle()
|
||||||
// otherwise it will exactly match the video size. The reason to add a black rectangle
|
// otherwise it will exactly match the video size. The reason to add a black rectangle
|
||||||
// behind videos in this second instance is that the scanline rendering will make the
|
// behind videos in this second instance is that the scanline rendering will make the
|
||||||
// video partially transparent so this may avoid some unforseen issues with some themes.
|
// video partially transparent so this may avoid some unforseen issues with some themes.
|
||||||
if (mVideoAreaPos != glm::vec2{} && mVideoAreaSize != glm::vec2{}) {
|
if (mVideoAreaPos != glm::vec2 {} && mVideoAreaSize != glm::vec2 {}) {
|
||||||
mVideoRectangleCoords.clear();
|
mVideoRectangleCoords.clear();
|
||||||
|
|
||||||
if (Settings::getInstance()->getBool("GamelistVideoPillarbox")) {
|
if (Settings::getInstance()->getBool("GamelistVideoPillarbox")) {
|
||||||
|
|
|
@ -25,7 +25,7 @@ GuiDetectDevice::GuiDetectDevice(Window* window,
|
||||||
, mFirstRun(firstRun)
|
, mFirstRun(firstRun)
|
||||||
, mForcedConfig(forcedConfig)
|
, mForcedConfig(forcedConfig)
|
||||||
, mBackground(window, ":/graphics/frame.svg")
|
, mBackground(window, ":/graphics/frame.svg")
|
||||||
, mGrid(window, glm::ivec2{1, 5})
|
, mGrid(window, glm::ivec2 {1, 5})
|
||||||
{
|
{
|
||||||
mHoldingConfig = nullptr;
|
mHoldingConfig = nullptr;
|
||||||
mHoldTime = 0;
|
mHoldTime = 0;
|
||||||
|
@ -38,7 +38,7 @@ GuiDetectDevice::GuiDetectDevice(Window* window,
|
||||||
mTitle =
|
mTitle =
|
||||||
std::make_shared<TextComponent>(mWindow, firstRun ? "WELCOME" : "CONFIGURE INPUT DEVICE",
|
std::make_shared<TextComponent>(mWindow, firstRun ? "WELCOME" : "CONFIGURE INPUT DEVICE",
|
||||||
Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER);
|
Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER);
|
||||||
mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{1, 1},
|
mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true, glm::ivec2 {1, 1},
|
||||||
GridFlags::BORDER_BOTTOM);
|
GridFlags::BORDER_BOTTOM);
|
||||||
|
|
||||||
// Device info.
|
// Device info.
|
||||||
|
@ -55,7 +55,7 @@ GuiDetectDevice::GuiDetectDevice(Window* window,
|
||||||
|
|
||||||
mDeviceInfo = std::make_shared<TextComponent>(
|
mDeviceInfo = std::make_shared<TextComponent>(
|
||||||
mWindow, deviceInfo.str(), Font::get(FONT_SIZE_SMALL), 0x999999FF, ALIGN_CENTER);
|
mWindow, deviceInfo.str(), Font::get(FONT_SIZE_SMALL), 0x999999FF, ALIGN_CENTER);
|
||||||
mGrid.setEntry(mDeviceInfo, glm::ivec2{0, 1}, false, true);
|
mGrid.setEntry(mDeviceInfo, glm::ivec2 {0, 1}, false, true);
|
||||||
|
|
||||||
// Message.
|
// Message.
|
||||||
if (numDevices > 0) {
|
if (numDevices > 0) {
|
||||||
|
@ -69,18 +69,18 @@ GuiDetectDevice::GuiDetectDevice(Window* window,
|
||||||
0x777777FF, ALIGN_CENTER);
|
0x777777FF, ALIGN_CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
mGrid.setEntry(mMsg1, glm::ivec2{0, 2}, false, true);
|
mGrid.setEntry(mMsg1, glm::ivec2 {0, 2}, false, true);
|
||||||
|
|
||||||
const std::string msg2str =
|
const std::string msg2str =
|
||||||
firstRun ? "PRESS ESC TO SKIP (OR F4 TO QUIT AT ANY TIME)" : "PRESS ESC TO CANCEL";
|
firstRun ? "PRESS ESC TO SKIP (OR F4 TO QUIT AT ANY TIME)" : "PRESS ESC TO CANCEL";
|
||||||
mMsg2 = std::make_shared<TextComponent>(mWindow, msg2str, Font::get(FONT_SIZE_SMALL),
|
mMsg2 = std::make_shared<TextComponent>(mWindow, msg2str, Font::get(FONT_SIZE_SMALL),
|
||||||
0x777777FF, ALIGN_CENTER);
|
0x777777FF, ALIGN_CENTER);
|
||||||
mGrid.setEntry(mMsg2, glm::ivec2{0, 3}, false, true);
|
mGrid.setEntry(mMsg2, glm::ivec2 {0, 3}, false, true);
|
||||||
|
|
||||||
// Currently held device.
|
// Currently held device.
|
||||||
mDeviceHeld = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_MEDIUM),
|
mDeviceHeld = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_MEDIUM),
|
||||||
0xFFFFFFFF, ALIGN_CENTER);
|
0xFFFFFFFF, ALIGN_CENTER);
|
||||||
mGrid.setEntry(mDeviceHeld, glm::ivec2{0, 4}, false, true);
|
mGrid.setEntry(mDeviceHeld, glm::ivec2 {0, 4}, false, true);
|
||||||
|
|
||||||
// Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent
|
// Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent
|
||||||
// regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference.
|
// regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference.
|
||||||
|
@ -94,7 +94,7 @@ GuiDetectDevice::GuiDetectDevice(Window* window,
|
||||||
|
|
||||||
void GuiDetectDevice::onSizeChanged()
|
void GuiDetectDevice::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f});
|
||||||
|
|
||||||
// Grid.
|
// Grid.
|
||||||
mGrid.setSize(mSize);
|
mGrid.setSize(mSize);
|
||||||
|
|
|
@ -54,15 +54,15 @@ GuiInfoPopup::GuiInfoPopup(Window* window, std::string message, int duration)
|
||||||
setPosition(posX, posY, 0);
|
setPosition(posX, posY, 0);
|
||||||
|
|
||||||
mFrame->setImagePath(":/graphics/frame.svg");
|
mFrame->setImagePath(":/graphics/frame.svg");
|
||||||
mFrame->fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
mFrame->fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f});
|
||||||
addChild(mFrame);
|
addChild(mFrame);
|
||||||
|
|
||||||
// We only initialize the actual time when we first start to render.
|
// We only initialize the actual time when we first start to render.
|
||||||
mStartTime = 0;
|
mStartTime = 0;
|
||||||
|
|
||||||
mGrid = new ComponentGrid(window, glm::ivec2{1, 3});
|
mGrid = new ComponentGrid(window, glm::ivec2 {1, 3});
|
||||||
mGrid->setSize(mSize);
|
mGrid->setSize(mSize);
|
||||||
mGrid->setEntry(s, glm::ivec2{0, 1}, false, true);
|
mGrid->setEntry(s, glm::ivec2 {0, 1}, false, true);
|
||||||
addChild(mGrid);
|
addChild(mGrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ GuiInfoPopup::~GuiInfoPopup()
|
||||||
void GuiInfoPopup::render(const glm::mat4& /*parentTrans*/)
|
void GuiInfoPopup::render(const glm::mat4& /*parentTrans*/)
|
||||||
{
|
{
|
||||||
// We use getIdentity() as we want to render on a specific window position, not on the view.
|
// We use getIdentity() as we want to render on a specific window position, not on the view.
|
||||||
glm::mat4 trans{getTransform() * Renderer::getIdentity()};
|
glm::mat4 trans {getTransform() * Renderer::getIdentity()};
|
||||||
if (mRunning && updateState()) {
|
if (mRunning && updateState()) {
|
||||||
// If we're still supposed to be rendering it.
|
// If we're still supposed to be rendering it.
|
||||||
Renderer::setMatrix(trans);
|
Renderer::setMatrix(trans);
|
||||||
|
|
|
@ -33,7 +33,7 @@ GuiInputConfig::GuiInputConfig(Window* window,
|
||||||
const std::function<void()>& okCallback)
|
const std::function<void()>& okCallback)
|
||||||
: GuiComponent(window)
|
: GuiComponent(window)
|
||||||
, mBackground(window, ":/graphics/frame.svg")
|
, mBackground(window, ":/graphics/frame.svg")
|
||||||
, mGrid(window, glm::ivec2{1, 7})
|
, mGrid(window, glm::ivec2 {1, 7})
|
||||||
, mTargetConfig(target)
|
, mTargetConfig(target)
|
||||||
, mHoldingInput(false)
|
, mHoldingInput(false)
|
||||||
{
|
{
|
||||||
|
@ -54,11 +54,11 @@ GuiInputConfig::GuiInputConfig(Window* window,
|
||||||
addChild(&mGrid);
|
addChild(&mGrid);
|
||||||
|
|
||||||
// 0 is a spacer row.
|
// 0 is a spacer row.
|
||||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{0, 0}, false);
|
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2 {0, 0}, false);
|
||||||
|
|
||||||
mTitle = std::make_shared<TextComponent>(mWindow, "CONFIGURING", Font::get(FONT_SIZE_LARGE),
|
mTitle = std::make_shared<TextComponent>(mWindow, "CONFIGURING", Font::get(FONT_SIZE_LARGE),
|
||||||
0x555555FF, ALIGN_CENTER);
|
0x555555FF, ALIGN_CENTER);
|
||||||
mGrid.setEntry(mTitle, glm::ivec2{0, 1}, false, true);
|
mGrid.setEntry(mTitle, glm::ivec2 {0, 1}, false, true);
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
if (target->getDeviceId() == DEVICE_KEYBOARD)
|
if (target->getDeviceId() == DEVICE_KEYBOARD)
|
||||||
|
@ -70,7 +70,7 @@ GuiInputConfig::GuiInputConfig(Window* window,
|
||||||
mSubtitle1 =
|
mSubtitle1 =
|
||||||
std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(ss.str()),
|
std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(ss.str()),
|
||||||
Font::get(FONT_SIZE_MEDIUM), 0x555555FF, ALIGN_CENTER);
|
Font::get(FONT_SIZE_MEDIUM), 0x555555FF, ALIGN_CENTER);
|
||||||
mGrid.setEntry(mSubtitle1, glm::ivec2{0, 2}, false, true);
|
mGrid.setEntry(mSubtitle1, glm::ivec2 {0, 2}, false, true);
|
||||||
|
|
||||||
mSubtitle2 =
|
mSubtitle2 =
|
||||||
std::make_shared<TextComponent>(mWindow, "HOLD ANY BUTTON 1 SECOND TO SKIP",
|
std::make_shared<TextComponent>(mWindow, "HOLD ANY BUTTON 1 SECOND TO SKIP",
|
||||||
|
@ -78,11 +78,11 @@ GuiInputConfig::GuiInputConfig(Window* window,
|
||||||
// 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);
|
||||||
|
|
||||||
mGrid.setEntry(mSubtitle2, glm::ivec2{0, 3}, false, true);
|
mGrid.setEntry(mSubtitle2, glm::ivec2 {0, 3}, false, true);
|
||||||
|
|
||||||
// 4 is a spacer row.
|
// 4 is a spacer row.
|
||||||
mList = std::make_shared<ComponentList>(mWindow);
|
mList = std::make_shared<ComponentList>(mWindow);
|
||||||
mGrid.setEntry(mList, glm::ivec2{0, 5}, true, true);
|
mGrid.setEntry(mList, glm::ivec2 {0, 5}, true, true);
|
||||||
|
|
||||||
for (int i = 0; i < inputCount; ++i) {
|
for (int i = 0; i < inputCount; ++i) {
|
||||||
ComponentListRow row;
|
ComponentListRow row;
|
||||||
|
@ -184,7 +184,7 @@ GuiInputConfig::GuiInputConfig(Window* window,
|
||||||
std::make_shared<ButtonComponent>(mWindow, "OK", "ok", [okFunction] { okFunction(); }));
|
std::make_shared<ButtonComponent>(mWindow, "OK", "ok", [okFunction] { okFunction(); }));
|
||||||
|
|
||||||
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
||||||
mGrid.setEntry(mButtonGrid, glm::ivec2{0, 6}, true, false);
|
mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 6}, true, false);
|
||||||
|
|
||||||
// Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent
|
// Adjust the width relative to the aspect ratio of the screen to make the GUI look coherent
|
||||||
// regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference.
|
// regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference.
|
||||||
|
@ -293,7 +293,7 @@ void GuiInputConfig::update(int deltaTime)
|
||||||
|
|
||||||
void GuiInputConfig::onSizeChanged()
|
void GuiInputConfig::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f});
|
||||||
|
|
||||||
// Update grid.
|
// Update grid.
|
||||||
mGrid.setSize(mSize);
|
mGrid.setSize(mSize);
|
||||||
|
@ -313,7 +313,7 @@ void GuiInputConfig::rowDone()
|
||||||
// At bottom of list, we're done.
|
// At bottom of list, we're done.
|
||||||
mConfiguringAll = false;
|
mConfiguringAll = false;
|
||||||
mConfiguringRow = false;
|
mConfiguringRow = false;
|
||||||
mGrid.moveCursor(glm::ivec2{0, 1});
|
mGrid.moveCursor(glm::ivec2 {0, 1});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// On another row.
|
// On another row.
|
||||||
|
|
|
@ -28,7 +28,7 @@ GuiMsgBox::GuiMsgBox(Window* window,
|
||||||
bool deleteOnButtonPress)
|
bool deleteOnButtonPress)
|
||||||
: GuiComponent(window)
|
: GuiComponent(window)
|
||||||
, mBackground(window, ":/graphics/frame.svg")
|
, mBackground(window, ":/graphics/frame.svg")
|
||||||
, mGrid(window, glm::ivec2{1, 2})
|
, mGrid(window, glm::ivec2 {1, 2})
|
||||||
, mHelpStyle(helpstyle)
|
, mHelpStyle(helpstyle)
|
||||||
, mDisableBackButton(disableBackButton)
|
, mDisableBackButton(disableBackButton)
|
||||||
, mDeleteOnButtonPress(deleteOnButtonPress)
|
, mDeleteOnButtonPress(deleteOnButtonPress)
|
||||||
|
@ -44,7 +44,7 @@ GuiMsgBox::GuiMsgBox(Window* window,
|
||||||
|
|
||||||
mMsg = std::make_shared<TextComponent>(mWindow, text, Font::get(FONT_SIZE_MEDIUM), 0x777777FF,
|
mMsg = std::make_shared<TextComponent>(mWindow, text, Font::get(FONT_SIZE_MEDIUM), 0x777777FF,
|
||||||
ALIGN_CENTER);
|
ALIGN_CENTER);
|
||||||
mGrid.setEntry(mMsg, glm::ivec2{0, 0}, false, false);
|
mGrid.setEntry(mMsg, glm::ivec2 {0, 0}, false, false);
|
||||||
|
|
||||||
// Create the buttons.
|
// Create the buttons.
|
||||||
mButtons.push_back(std::make_shared<ButtonComponent>(
|
mButtons.push_back(std::make_shared<ButtonComponent>(
|
||||||
|
@ -72,7 +72,7 @@ GuiMsgBox::GuiMsgBox(Window* window,
|
||||||
|
|
||||||
// Put the buttons into a ComponentGrid.
|
// Put the buttons into a ComponentGrid.
|
||||||
mButtonGrid = makeButtonGrid(mWindow, mButtons);
|
mButtonGrid = makeButtonGrid(mWindow, mButtons);
|
||||||
mGrid.setEntry(mButtonGrid, glm::ivec2{0, 1}, true, false, glm::ivec2{1, 1},
|
mGrid.setEntry(mButtonGrid, glm::ivec2 {0, 1}, true, false, glm::ivec2 {1, 1},
|
||||||
GridFlags::BORDER_TOP);
|
GridFlags::BORDER_TOP);
|
||||||
|
|
||||||
// Decide final width.
|
// Decide final width.
|
||||||
|
@ -167,7 +167,7 @@ void GuiMsgBox::onSizeChanged()
|
||||||
mGrid.getRowHeight(0));
|
mGrid.getRowHeight(0));
|
||||||
mGrid.onSizeChanged();
|
mGrid.onSizeChanged();
|
||||||
|
|
||||||
mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f});
|
||||||
}
|
}
|
||||||
|
|
||||||
void GuiMsgBox::deleteMeAndCall(const std::function<void()>& func)
|
void GuiMsgBox::deleteMeAndCall(const std::function<void()>& func)
|
||||||
|
|
|
@ -87,26 +87,26 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
||||||
const std::string& loadBtnHelpText,
|
const std::string& loadBtnHelpText,
|
||||||
const std::string& clearBtnHelpText,
|
const std::string& clearBtnHelpText,
|
||||||
const std::string& cancelBtnHelpText)
|
const std::string& cancelBtnHelpText)
|
||||||
: GuiComponent{window}
|
: GuiComponent {window}
|
||||||
, mBackground{window, ":/graphics/frame.svg"}
|
, mBackground {window, ":/graphics/frame.svg"}
|
||||||
, mGrid{window, glm::ivec2{1, (infoString != "" && defaultValue != "" ? 8 : 6)}}
|
, mGrid {window, glm::ivec2 {1, (infoString != "" && defaultValue != "" ? 8 : 6)}}
|
||||||
, mHelpStyle{helpstyle}
|
, mHelpStyle {helpstyle}
|
||||||
, mInitValue{initValue}
|
, mInitValue {initValue}
|
||||||
, mAcceptBtnHelpText{acceptBtnHelpText}
|
, mAcceptBtnHelpText {acceptBtnHelpText}
|
||||||
, mSaveConfirmationText{saveConfirmationText}
|
, mSaveConfirmationText {saveConfirmationText}
|
||||||
, mLoadBtnHelpText{loadBtnHelpText}
|
, mLoadBtnHelpText {loadBtnHelpText}
|
||||||
, mClearBtnHelpText{clearBtnHelpText}
|
, mClearBtnHelpText {clearBtnHelpText}
|
||||||
, mCancelBtnHelpText{cancelBtnHelpText}
|
, mCancelBtnHelpText {cancelBtnHelpText}
|
||||||
, mOkCallback{okCallback}
|
, mOkCallback {okCallback}
|
||||||
, mMultiLine{multiLine}
|
, mMultiLine {multiLine}
|
||||||
, mComplexMode{(infoString != "" && defaultValue != "")}
|
, mComplexMode {(infoString != "" && defaultValue != "")}
|
||||||
, mDeleteRepeat{false}
|
, mDeleteRepeat {false}
|
||||||
, mShift{false}
|
, mShift {false}
|
||||||
, mAlt{false}
|
, mAlt {false}
|
||||||
, mDeleteRepeatTimer{0}
|
, mDeleteRepeatTimer {0}
|
||||||
, mNavigationRepeatTimer{0}
|
, mNavigationRepeatTimer {0}
|
||||||
, mNavigationRepeatDirX{0}
|
, mNavigationRepeatDirX {0}
|
||||||
, mNavigationRepeatDirY{0}
|
, mNavigationRepeatDirY {0}
|
||||||
{
|
{
|
||||||
addChild(&mBackground);
|
addChild(&mBackground);
|
||||||
addChild(&mGrid);
|
addChild(&mGrid);
|
||||||
|
@ -134,23 +134,23 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
||||||
mText->setValue(initValue);
|
mText->setValue(initValue);
|
||||||
|
|
||||||
// Header.
|
// Header.
|
||||||
mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true);
|
mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true);
|
||||||
|
|
||||||
int yPos = 1;
|
int yPos = 1;
|
||||||
|
|
||||||
if (mComplexMode) {
|
if (mComplexMode) {
|
||||||
mInfoString = std::make_shared<TextComponent>(
|
mInfoString = std::make_shared<TextComponent>(
|
||||||
mWindow, infoString, Font::get(FONT_SIZE_MEDIUM), 0x555555FF, ALIGN_CENTER);
|
mWindow, infoString, Font::get(FONT_SIZE_MEDIUM), 0x555555FF, ALIGN_CENTER);
|
||||||
mGrid.setEntry(mInfoString, glm::ivec2{0, yPos}, false, true);
|
mGrid.setEntry(mInfoString, glm::ivec2 {0, yPos}, false, true);
|
||||||
|
|
||||||
mDefaultValue = std::make_shared<TextComponent>(
|
mDefaultValue = std::make_shared<TextComponent>(
|
||||||
mWindow, defaultValue, Font::get(FONT_SIZE_SMALL), 0x555555FF, ALIGN_CENTER);
|
mWindow, defaultValue, Font::get(FONT_SIZE_SMALL), 0x555555FF, ALIGN_CENTER);
|
||||||
mGrid.setEntry(mDefaultValue, glm::ivec2{0, yPos + 1}, false, true);
|
mGrid.setEntry(mDefaultValue, glm::ivec2 {0, yPos + 1}, false, true);
|
||||||
yPos += 2;
|
yPos += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Text edit field.
|
// Text edit field.
|
||||||
mGrid.setEntry(mText, glm::ivec2{0, yPos}, true, false, glm::ivec2{1, 1},
|
mGrid.setEntry(mText, glm::ivec2 {0, yPos}, true, false, glm::ivec2 {1, 1},
|
||||||
GridFlags::BORDER_TOP);
|
GridFlags::BORDER_TOP);
|
||||||
|
|
||||||
std::vector<std::vector<std::shared_ptr<ButtonComponent>>> buttonList;
|
std::vector<std::vector<std::shared_ptr<ButtonComponent>>> buttonList;
|
||||||
|
@ -230,14 +230,14 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
mKeyboardGrid->setEntry(button, glm::ivec2{j, i}, true, true,
|
mKeyboardGrid->setEntry(button, glm::ivec2 {j, i}, true, true,
|
||||||
glm::ivec2{colSpan, rowSpan});
|
glm::ivec2 {colSpan, rowSpan});
|
||||||
|
|
||||||
buttonList.push_back(buttons);
|
buttonList.push_back(buttons);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mGrid.setEntry(mKeyboardGrid, glm::ivec2{0, yPos + 1}, true, true, glm::ivec2{1, 4});
|
mGrid.setEntry(mKeyboardGrid, glm::ivec2 {0, yPos + 1}, true, true, glm::ivec2 {1, 4});
|
||||||
|
|
||||||
float textHeight = mText->getFont()->getHeight();
|
float textHeight = mText->getFont()->getHeight();
|
||||||
// If the multiLine option has been set, then include three lines of text on screen.
|
// If the multiLine option has been set, then include three lines of text on screen.
|
||||||
|
@ -293,7 +293,7 @@ GuiTextEditKeyboardPopup::GuiTextEditKeyboardPopup(
|
||||||
|
|
||||||
void GuiTextEditKeyboardPopup::onSizeChanged()
|
void GuiTextEditKeyboardPopup::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f});
|
||||||
mText->setSize(mSize.x - KEYBOARD_PADDINGX - KEYBOARD_PADDINGX, mText->getSize().y);
|
mText->setSize(mSize.x - KEYBOARD_PADDINGX - KEYBOARD_PADDINGX, mText->getSize().y);
|
||||||
|
|
||||||
// Update grid.
|
// Update grid.
|
||||||
|
|
|
@ -53,11 +53,11 @@ private:
|
||||||
const std::string& sk,
|
const std::string& sk,
|
||||||
const std::string& ak,
|
const std::string& ak,
|
||||||
const std::string& ask)
|
const std::string& ask)
|
||||||
: button{b}
|
: button {b}
|
||||||
, key{k}
|
, key {k}
|
||||||
, shiftedKey{sk}
|
, shiftedKey {sk}
|
||||||
, altedKey{ak}
|
, altedKey {ak}
|
||||||
, altshiftedKey{ask} {};
|
, altshiftedKey {ask} {};
|
||||||
};
|
};
|
||||||
|
|
||||||
void updateDeleteRepeat(int deltaTime);
|
void updateDeleteRepeat(int deltaTime);
|
||||||
|
|
|
@ -28,21 +28,21 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window,
|
||||||
const std::string& loadBtnHelpText,
|
const std::string& loadBtnHelpText,
|
||||||
const std::string& clearBtnHelpText,
|
const std::string& clearBtnHelpText,
|
||||||
const std::string& cancelBtnHelpText)
|
const std::string& cancelBtnHelpText)
|
||||||
: GuiComponent{window}
|
: GuiComponent {window}
|
||||||
, mBackground{window, ":/graphics/frame.svg"}
|
, mBackground {window, ":/graphics/frame.svg"}
|
||||||
, mGrid{window, glm::ivec2{1, (infoString != "" && defaultValue != "" ? 5 : 3)}}
|
, mGrid {window, glm::ivec2 {1, (infoString != "" && defaultValue != "" ? 5 : 3)}}
|
||||||
, mHelpStyle{helpstyle}
|
, mHelpStyle {helpstyle}
|
||||||
, mInitValue{initValue}
|
, mInitValue {initValue}
|
||||||
, mAcceptBtnText{acceptBtnText}
|
, mAcceptBtnText {acceptBtnText}
|
||||||
, mSaveConfirmationText{saveConfirmationText}
|
, mSaveConfirmationText {saveConfirmationText}
|
||||||
, mLoadBtnHelpText{loadBtnHelpText}
|
, mLoadBtnHelpText {loadBtnHelpText}
|
||||||
, mClearBtnHelpText{clearBtnHelpText}
|
, mClearBtnHelpText {clearBtnHelpText}
|
||||||
, mCancelBtnHelpText{cancelBtnHelpText}
|
, mCancelBtnHelpText {cancelBtnHelpText}
|
||||||
, mOkCallback{okCallback}
|
, mOkCallback {okCallback}
|
||||||
, mMultiLine{multiLine}
|
, mMultiLine {multiLine}
|
||||||
, mComplexMode{(infoString != "" && defaultValue != "")}
|
, mComplexMode {(infoString != "" && defaultValue != "")}
|
||||||
, mDeleteRepeat{false}
|
, mDeleteRepeat {false}
|
||||||
, mDeleteRepeatTimer{0}
|
, mDeleteRepeatTimer {0}
|
||||||
{
|
{
|
||||||
addChild(&mBackground);
|
addChild(&mBackground);
|
||||||
addChild(&mGrid);
|
addChild(&mGrid);
|
||||||
|
@ -83,19 +83,19 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window,
|
||||||
|
|
||||||
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
||||||
|
|
||||||
mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true);
|
mGrid.setEntry(mTitle, glm::ivec2 {0, 0}, false, true);
|
||||||
|
|
||||||
int yPos = 1;
|
int yPos = 1;
|
||||||
|
|
||||||
if (mComplexMode) {
|
if (mComplexMode) {
|
||||||
mGrid.setEntry(mInfoString, glm::ivec2{0, yPos}, false, true);
|
mGrid.setEntry(mInfoString, glm::ivec2 {0, yPos}, false, true);
|
||||||
mGrid.setEntry(mDefaultValue, glm::ivec2{0, yPos + 1}, false, false);
|
mGrid.setEntry(mDefaultValue, glm::ivec2 {0, yPos + 1}, false, false);
|
||||||
yPos += 2;
|
yPos += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
mGrid.setEntry(mText, glm::ivec2{0, yPos}, true, false, glm::ivec2{1, 1},
|
mGrid.setEntry(mText, glm::ivec2 {0, yPos}, true, false, glm::ivec2 {1, 1},
|
||||||
GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM);
|
GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM);
|
||||||
mGrid.setEntry(mButtonGrid, glm::ivec2{0, yPos + 1}, true, false);
|
mGrid.setEntry(mButtonGrid, glm::ivec2 {0, yPos + 1}, true, false);
|
||||||
|
|
||||||
float textHeight = mText->getFont()->getHeight();
|
float textHeight = mText->getFont()->getHeight();
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window,
|
||||||
|
|
||||||
void GuiTextEditPopup::onSizeChanged()
|
void GuiTextEditPopup::onSizeChanged()
|
||||||
{
|
{
|
||||||
mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
mBackground.fitTo(mSize, glm::vec3 {}, glm::vec2 {-32.0f, -32.0f});
|
||||||
mText->setSize(mSize.x - 40.0f * Renderer::getScreenHeightModifier(), mText->getSize().y);
|
mText->setSize(mSize.x - 40.0f * Renderer::getScreenHeightModifier(), mText->getSize().y);
|
||||||
|
|
||||||
// Update grid.
|
// Update grid.
|
||||||
|
|
|
@ -316,8 +316,8 @@ namespace Renderer
|
||||||
if (!createWindow())
|
if (!createWindow())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
glm::mat4 projection{getIdentity()};
|
glm::mat4 projection {getIdentity()};
|
||||||
Rect viewport{0, 0, 0, 0};
|
Rect viewport {0, 0, 0, 0};
|
||||||
|
|
||||||
switch (screenRotate) {
|
switch (screenRotate) {
|
||||||
case 1: {
|
case 1: {
|
||||||
|
|
|
@ -20,13 +20,13 @@ struct SDL_Window;
|
||||||
|
|
||||||
namespace Renderer
|
namespace Renderer
|
||||||
{
|
{
|
||||||
const unsigned int SHADER_DESATURATE{1};
|
const unsigned int SHADER_DESATURATE {1};
|
||||||
const unsigned int SHADER_OPACITY{2};
|
const unsigned int SHADER_OPACITY {2};
|
||||||
const unsigned int SHADER_DIM{4};
|
const unsigned int SHADER_DIM {4};
|
||||||
const unsigned int SHADER_BLUR_HORIZONTAL{8};
|
const unsigned int SHADER_BLUR_HORIZONTAL {8};
|
||||||
const unsigned int SHADER_BLUR_VERTICAL{16};
|
const unsigned int SHADER_BLUR_VERTICAL {16};
|
||||||
const unsigned int SHADER_SCANLINES{32};
|
const unsigned int SHADER_SCANLINES {32};
|
||||||
const unsigned int SHADER_BGRA_TO_RGBA{64};
|
const unsigned int SHADER_BGRA_TO_RGBA {64};
|
||||||
|
|
||||||
struct shaderParameters {
|
struct shaderParameters {
|
||||||
std::array<GLfloat, 2> textureSize;
|
std::array<GLfloat, 2> textureSize;
|
||||||
|
@ -37,12 +37,12 @@ namespace Renderer
|
||||||
unsigned int blurPasses;
|
unsigned int blurPasses;
|
||||||
|
|
||||||
shaderParameters()
|
shaderParameters()
|
||||||
: textureSize{0.0f, 0.0f}
|
: textureSize {0.0f, 0.0f}
|
||||||
, textureCoordinates{0.0f, 0.0f, 0.0f, 0.0f}
|
, textureCoordinates {0.0f, 0.0f, 0.0f, 0.0f}
|
||||||
, fragmentSaturation{1.0f}
|
, fragmentSaturation {1.0f}
|
||||||
, fragmentDimValue{0.4f}
|
, fragmentDimValue {0.4f}
|
||||||
, fragmentOpacity{1.0f}
|
, fragmentOpacity {1.0f}
|
||||||
, blurPasses{1}
|
, blurPasses {1}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -52,7 +52,7 @@ namespace Renderer
|
||||||
// This is simply to get rid of a GCC false positive -Wunused-variable compiler warning.
|
// This is simply to get rid of a GCC false positive -Wunused-variable compiler warning.
|
||||||
static GLuint shaderFBODummy = shaderFBO;
|
static GLuint shaderFBODummy = shaderFBO;
|
||||||
|
|
||||||
static constexpr glm::mat4 getIdentity() { return glm::mat4{1.0f}; }
|
static constexpr glm::mat4 getIdentity() { return glm::mat4 {1.0f}; }
|
||||||
|
|
||||||
#if !defined(NDEBUG)
|
#if !defined(NDEBUG)
|
||||||
#define GL_CHECK_ERROR(Function) (Function, _GLCheckError(#Function))
|
#define GL_CHECK_ERROR(Function) (Function, _GLCheckError(#Function))
|
||||||
|
@ -125,9 +125,9 @@ namespace Renderer
|
||||||
glm::vec2 pos;
|
glm::vec2 pos;
|
||||||
glm::vec2 tex;
|
glm::vec2 tex;
|
||||||
unsigned int col;
|
unsigned int col;
|
||||||
float saturation{1.0};
|
float saturation {1.0};
|
||||||
float opacity{1.0};
|
float opacity {1.0};
|
||||||
unsigned int shaders{0};
|
unsigned int shaders {0};
|
||||||
};
|
};
|
||||||
|
|
||||||
bool init();
|
bool init();
|
||||||
|
|
|
@ -379,7 +379,7 @@ namespace Renderer
|
||||||
|
|
||||||
void setMatrix(const glm::mat4& matrix)
|
void setMatrix(const glm::mat4& matrix)
|
||||||
{
|
{
|
||||||
glm::mat4 newMatrix{matrix};
|
glm::mat4 newMatrix {matrix};
|
||||||
newMatrix[3] = glm::round(newMatrix[3]);
|
newMatrix[3] = glm::round(newMatrix[3]);
|
||||||
|
|
||||||
GL_CHECK_ERROR(glMatrixMode(GL_MODELVIEW));
|
GL_CHECK_ERROR(glMatrixMode(GL_MODELVIEW));
|
||||||
|
|
|
@ -128,10 +128,10 @@ namespace Renderer
|
||||||
|
|
||||||
// Not sure why the corresponding variables are missing in the OpenGL ES include files
|
// Not sure why the corresponding variables are missing in the OpenGL ES include files
|
||||||
// when specifying the values manually seems to work with all graphics drivers.
|
// when specifying the values manually seems to work with all graphics drivers.
|
||||||
int _GL_TEXTURE_SWIZZLE_R{0x8E42};
|
int _GL_TEXTURE_SWIZZLE_R {0x8E42};
|
||||||
int _GL_TEXTURE_SWIZZLE_B{0x8E44};
|
int _GL_TEXTURE_SWIZZLE_B {0x8E44};
|
||||||
int _GL_RED{0x1903};
|
int _GL_RED {0x1903};
|
||||||
int _GL_BLUE{0x1905};
|
int _GL_BLUE {0x1905};
|
||||||
|
|
||||||
// Convert from BGRA to RGBA.
|
// Convert from BGRA to RGBA.
|
||||||
if (format == Texture::Type::BGRA) {
|
if (format == Texture::Type::BGRA) {
|
||||||
|
@ -223,7 +223,7 @@ namespace Renderer
|
||||||
|
|
||||||
void setMatrix(const glm::mat4& matrix)
|
void setMatrix(const glm::mat4& matrix)
|
||||||
{
|
{
|
||||||
glm::mat4 newMatrix{matrix};
|
glm::mat4 newMatrix {matrix};
|
||||||
newMatrix[3] = glm::round(newMatrix[3]);
|
newMatrix[3] = glm::round(newMatrix[3]);
|
||||||
|
|
||||||
GL_CHECK_ERROR(glMatrixMode(GL_MODELVIEW));
|
GL_CHECK_ERROR(glMatrixMode(GL_MODELVIEW));
|
||||||
|
|
|
@ -18,40 +18,40 @@
|
||||||
|
|
||||||
namespace Renderer
|
namespace Renderer
|
||||||
{
|
{
|
||||||
static SDL_GLContext sdlContext{nullptr};
|
static SDL_GLContext sdlContext {nullptr};
|
||||||
static glm::mat4 projectionMatrix{getIdentity()};
|
static glm::mat4 projectionMatrix {getIdentity()};
|
||||||
glm::mat4 worldViewMatrix{getIdentity()};
|
glm::mat4 worldViewMatrix {getIdentity()};
|
||||||
static GLuint shaderProgram{0};
|
static GLuint shaderProgram {0};
|
||||||
static GLint mvpUniform{0};
|
static GLint mvpUniform {0};
|
||||||
static GLint texAttrib{0};
|
static GLint texAttrib {0};
|
||||||
static GLint colAttrib{0};
|
static GLint colAttrib {0};
|
||||||
static GLint posAttrib{0};
|
static GLint posAttrib {0};
|
||||||
static GLuint vertexBuffer{0};
|
static GLuint vertexBuffer {0};
|
||||||
static GLuint whiteTexture{0};
|
static GLuint whiteTexture {0};
|
||||||
|
|
||||||
static void setupShaders()
|
static void setupShaders()
|
||||||
{
|
{
|
||||||
// Vertex shader.
|
// Vertex shader.
|
||||||
const GLchar* vertexSource{"uniform mat4 u_mvp; \n"
|
const GLchar* vertexSource {"uniform mat4 u_mvp; \n"
|
||||||
"attribute vec2 a_pos; \n"
|
"attribute vec2 a_pos; \n"
|
||||||
"attribute vec2 a_tex; \n"
|
"attribute vec2 a_tex; \n"
|
||||||
"attribute vec4 a_col; \n"
|
"attribute vec4 a_col; \n"
|
||||||
"varying vec2 v_tex; \n"
|
"varying vec2 v_tex; \n"
|
||||||
"varying vec4 v_col; \n"
|
"varying vec4 v_col; \n"
|
||||||
"void main(void) \n"
|
"void main(void) \n"
|
||||||
"{ \n"
|
"{ \n"
|
||||||
" gl_Position = u_mvp * vec4(a_pos.xy, 0.0, 1.0); \n"
|
" gl_Position = u_mvp * vec4(a_pos.xy, 0.0, 1.0); \n"
|
||||||
" v_tex = a_tex; \n"
|
" v_tex = a_tex; \n"
|
||||||
" v_col = a_col; \n"
|
" v_col = a_col; \n"
|
||||||
"} \n"};
|
"} \n"};
|
||||||
|
|
||||||
const GLuint vertexShader{glCreateShader(GL_VERTEX_SHADER)};
|
const GLuint vertexShader {glCreateShader(GL_VERTEX_SHADER)};
|
||||||
GL_CHECK_ERROR(glShaderSource(vertexShader, 1, &vertexSource, nullptr));
|
GL_CHECK_ERROR(glShaderSource(vertexShader, 1, &vertexSource, nullptr));
|
||||||
GL_CHECK_ERROR(glCompileShader(vertexShader));
|
GL_CHECK_ERROR(glCompileShader(vertexShader));
|
||||||
|
|
||||||
{
|
{
|
||||||
GLint isCompiled{GL_FALSE};
|
GLint isCompiled {GL_FALSE};
|
||||||
GLint maxLength{0};
|
GLint maxLength {0};
|
||||||
|
|
||||||
GL_CHECK_ERROR(glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &isCompiled));
|
GL_CHECK_ERROR(glGetShaderiv(vertexShader, GL_COMPILE_STATUS, &isCompiled));
|
||||||
GL_CHECK_ERROR(glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &maxLength));
|
GL_CHECK_ERROR(glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &maxLength));
|
||||||
|
@ -76,22 +76,22 @@ namespace Renderer
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fragment shader.
|
// Fragment shader.
|
||||||
const GLchar* fragmentSource{"precision highp float; \n"
|
const GLchar* fragmentSource {"precision highp float; \n"
|
||||||
"uniform sampler2D u_tex; \n"
|
"uniform sampler2D u_tex; \n"
|
||||||
"varying vec2 v_tex; \n"
|
"varying vec2 v_tex; \n"
|
||||||
"varying vec4 v_col; \n"
|
"varying vec4 v_col; \n"
|
||||||
"void main(void) \n"
|
"void main(void) \n"
|
||||||
"{ \n"
|
"{ \n"
|
||||||
" gl_FragColor = texture2D(u_tex, v_tex) * v_col; \n"
|
" gl_FragColor = texture2D(u_tex, v_tex) * v_col; \n"
|
||||||
"} \n"};
|
"} \n"};
|
||||||
|
|
||||||
const GLuint fragmentShader{glCreateShader(GL_FRAGMENT_SHADER)};
|
const GLuint fragmentShader {glCreateShader(GL_FRAGMENT_SHADER)};
|
||||||
GL_CHECK_ERROR(glShaderSource(fragmentShader, 1, &fragmentSource, nullptr));
|
GL_CHECK_ERROR(glShaderSource(fragmentShader, 1, &fragmentSource, nullptr));
|
||||||
GL_CHECK_ERROR(glCompileShader(fragmentShader));
|
GL_CHECK_ERROR(glCompileShader(fragmentShader));
|
||||||
|
|
||||||
{
|
{
|
||||||
GLint isCompiled{GL_FALSE};
|
GLint isCompiled {GL_FALSE};
|
||||||
GLint maxLength{0};
|
GLint maxLength {0};
|
||||||
|
|
||||||
GL_CHECK_ERROR(glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &isCompiled));
|
GL_CHECK_ERROR(glGetShaderiv(fragmentShader, GL_COMPILE_STATUS, &isCompiled));
|
||||||
GL_CHECK_ERROR(glGetShaderiv(fragmentShader, GL_INFO_LOG_LENGTH, &maxLength));
|
GL_CHECK_ERROR(glGetShaderiv(fragmentShader, GL_INFO_LOG_LENGTH, &maxLength));
|
||||||
|
@ -123,8 +123,8 @@ namespace Renderer
|
||||||
GL_CHECK_ERROR(glLinkProgram(shaderProgram));
|
GL_CHECK_ERROR(glLinkProgram(shaderProgram));
|
||||||
|
|
||||||
{
|
{
|
||||||
GLint isCompiled{GL_FALSE};
|
GLint isCompiled {GL_FALSE};
|
||||||
GLint maxLength{0};
|
GLint maxLength {0};
|
||||||
|
|
||||||
GL_CHECK_ERROR(glGetProgramiv(shaderProgram, GL_LINK_STATUS, &isCompiled));
|
GL_CHECK_ERROR(glGetProgramiv(shaderProgram, GL_LINK_STATUS, &isCompiled));
|
||||||
GL_CHECK_ERROR(glGetProgramiv(shaderProgram, GL_INFO_LOG_LENGTH, &maxLength));
|
GL_CHECK_ERROR(glGetProgramiv(shaderProgram, GL_INFO_LOG_LENGTH, &maxLength));
|
||||||
|
@ -270,7 +270,7 @@ namespace Renderer
|
||||||
const unsigned int height,
|
const unsigned int height,
|
||||||
void* data)
|
void* data)
|
||||||
{
|
{
|
||||||
const GLenum textureType{convertTextureType(type)};
|
const GLenum textureType {convertTextureType(type)};
|
||||||
unsigned int texture;
|
unsigned int texture;
|
||||||
|
|
||||||
GL_CHECK_ERROR(glGenTextures(1, &texture));
|
GL_CHECK_ERROR(glGenTextures(1, &texture));
|
||||||
|
@ -278,10 +278,10 @@ namespace Renderer
|
||||||
|
|
||||||
// Not sure why the corresponding variables are missing in the OpenGL ES include files
|
// Not sure why the corresponding variables are missing in the OpenGL ES include files
|
||||||
// when specifying the values manually seems to work with all graphics drivers.
|
// when specifying the values manually seems to work with all graphics drivers.
|
||||||
int _GL_TEXTURE_SWIZZLE_R{0x8E42};
|
int _GL_TEXTURE_SWIZZLE_R {0x8E42};
|
||||||
int _GL_TEXTURE_SWIZZLE_B{0x8E44};
|
int _GL_TEXTURE_SWIZZLE_B {0x8E44};
|
||||||
int _GL_RED{0x1903};
|
int _GL_RED {0x1903};
|
||||||
int _GL_BLUE{0x1905};
|
int _GL_BLUE {0x1905};
|
||||||
|
|
||||||
// Convert from BGRA to RGBA.
|
// Convert from BGRA to RGBA.
|
||||||
if (format == Texture::Type::BGRA) {
|
if (format == Texture::Type::BGRA) {
|
||||||
|
@ -300,8 +300,8 @@ namespace Renderer
|
||||||
// Regular GL_ALPHA textures are black + alpha when used in shaders, so create a
|
// Regular GL_ALPHA textures are black + alpha when used in shaders, so create a
|
||||||
// GL_LUMINANCE_ALPHA texture instead so it's white + alpha.
|
// GL_LUMINANCE_ALPHA texture instead so it's white + alpha.
|
||||||
if (textureType == GL_LUMINANCE_ALPHA) {
|
if (textureType == GL_LUMINANCE_ALPHA) {
|
||||||
uint8_t* a_data{reinterpret_cast<uint8_t*>(data)};
|
uint8_t* a_data {reinterpret_cast<uint8_t*>(data)};
|
||||||
uint8_t* la_data{new uint8_t[width * height * 2]};
|
uint8_t* la_data {new uint8_t[width * height * 2]};
|
||||||
for (uint32_t i = 0; i < (width * height); ++i) {
|
for (uint32_t i = 0; i < (width * height); ++i) {
|
||||||
la_data[(i * 2) + 0] = 255;
|
la_data[(i * 2) + 0] = 255;
|
||||||
la_data[(i * 2) + 1] = a_data ? a_data[i] : 255;
|
la_data[(i * 2) + 1] = a_data ? a_data[i] : 255;
|
||||||
|
@ -340,8 +340,8 @@ namespace Renderer
|
||||||
// Regular GL_ALPHA textures are black + alpha when used in shaders, so create a
|
// Regular GL_ALPHA textures are black + alpha when used in shaders, so create a
|
||||||
// GL_LUMINANCE_ALPHA texture instead so it's white + alpha.
|
// GL_LUMINANCE_ALPHA texture instead so it's white + alpha.
|
||||||
if (textureType == GL_LUMINANCE_ALPHA) {
|
if (textureType == GL_LUMINANCE_ALPHA) {
|
||||||
uint8_t* a_data{reinterpret_cast<uint8_t*>(data)};
|
uint8_t* a_data {reinterpret_cast<uint8_t*>(data)};
|
||||||
uint8_t* la_data{new uint8_t[width * height * 2]};
|
uint8_t* la_data {new uint8_t[width * height * 2]};
|
||||||
for (uint32_t i = 0; i < (width * height); ++i) {
|
for (uint32_t i = 0; i < (width * height); ++i) {
|
||||||
la_data[(i * 2) + 0] = 255;
|
la_data[(i * 2) + 0] = 255;
|
||||||
la_data[(i * 2) + 1] = a_data ? a_data[i] : 255;
|
la_data[(i * 2) + 1] = a_data ? a_data[i] : 255;
|
||||||
|
@ -416,7 +416,7 @@ namespace Renderer
|
||||||
{
|
{
|
||||||
projectionMatrix = projection;
|
projectionMatrix = projection;
|
||||||
|
|
||||||
glm::mat4 mvpMatrix{projectionMatrix * worldViewMatrix};
|
glm::mat4 mvpMatrix {projectionMatrix * worldViewMatrix};
|
||||||
GL_CHECK_ERROR(
|
GL_CHECK_ERROR(
|
||||||
glUniformMatrix4fv(mvpUniform, 1, GL_FALSE, reinterpret_cast<float*>(&mvpMatrix)));
|
glUniformMatrix4fv(mvpUniform, 1, GL_FALSE, reinterpret_cast<float*>(&mvpMatrix)));
|
||||||
}
|
}
|
||||||
|
@ -426,7 +426,7 @@ namespace Renderer
|
||||||
worldViewMatrix = matrix;
|
worldViewMatrix = matrix;
|
||||||
worldViewMatrix[3] = glm::round(worldViewMatrix[3]);
|
worldViewMatrix[3] = glm::round(worldViewMatrix[3]);
|
||||||
|
|
||||||
glm::mat4 mvpMatrix{projectionMatrix * worldViewMatrix};
|
glm::mat4 mvpMatrix {projectionMatrix * worldViewMatrix};
|
||||||
GL_CHECK_ERROR(
|
GL_CHECK_ERROR(
|
||||||
glUniformMatrix4fv(mvpUniform, 1, GL_FALSE, reinterpret_cast<float*>(&mvpMatrix)));
|
glUniformMatrix4fv(mvpUniform, 1, GL_FALSE, reinterpret_cast<float*>(&mvpMatrix)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,7 +145,7 @@ Font::FontTexture::FontTexture(const int mSize)
|
||||||
// This is a hack to add some extra texture size when running at very low resolutions. If not
|
// This is a hack to add some extra texture size when running at very low resolutions. If not
|
||||||
// doing this, the use of fallback fonts (such as Japanese characters) could result in the
|
// doing this, the use of fallback fonts (such as Japanese characters) could result in the
|
||||||
// texture not fitting the glyphs which would crash the application.
|
// texture not fitting the glyphs which would crash the application.
|
||||||
int extraTextureSize{0};
|
int extraTextureSize {0};
|
||||||
const float screenSizeModifier =
|
const float screenSizeModifier =
|
||||||
std::min(Renderer::getScreenWidthModifier(), Renderer::getScreenHeightModifier());
|
std::min(Renderer::getScreenWidthModifier(), Renderer::getScreenHeightModifier());
|
||||||
|
|
||||||
|
@ -157,8 +157,8 @@ Font::FontTexture::FontTexture(const int mSize)
|
||||||
// It's not entirely clear if the 18 and 6 constants are correct, but they seem to provide
|
// It's not entirely clear if the 18 and 6 constants are correct, but they seem to provide
|
||||||
// a texture buffer large enough to hold the fonts (otherwise the application would crash).
|
// a texture buffer large enough to hold the fonts (otherwise the application would crash).
|
||||||
// This logic is obviously a hack though and needs to be properly reviewed and improved.
|
// This logic is obviously a hack though and needs to be properly reviewed and improved.
|
||||||
textureSize = glm::ivec2{mSize * (18 + extraTextureSize), mSize * (6 + extraTextureSize / 2)};
|
textureSize = glm::ivec2 {mSize * (18 + extraTextureSize), mSize * (6 + extraTextureSize / 2)};
|
||||||
writePos = glm::ivec2{};
|
writePos = glm::ivec2 {};
|
||||||
rowHeight = 0;
|
rowHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +177,7 @@ bool Font::FontTexture::findEmpty(const glm::ivec2& size, glm::ivec2& cursor_out
|
||||||
writePos.y + rowHeight + size.y + 1 < textureSize.y) {
|
writePos.y + rowHeight + size.y + 1 < textureSize.y) {
|
||||||
// Row full, but it should fit on the next row so move the cursor there.
|
// Row full, but it should fit on the next row so move the cursor there.
|
||||||
// Leave 1px of space between glyphs.
|
// Leave 1px of space between glyphs.
|
||||||
writePos = glm::ivec2{0, writePos.y + rowHeight + 1};
|
writePos = glm::ivec2 {0, writePos.y + rowHeight + 1};
|
||||||
rowHeight = 0;
|
rowHeight = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ Font::Glyph* Font::getGlyph(unsigned int id)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::ivec2 glyphSize{g->bitmap.width, g->bitmap.rows};
|
glm::ivec2 glyphSize {g->bitmap.width, g->bitmap.rows};
|
||||||
|
|
||||||
FontTexture* tex = nullptr;
|
FontTexture* tex = nullptr;
|
||||||
glm::ivec2 cursor;
|
glm::ivec2 cursor;
|
||||||
|
@ -335,15 +335,15 @@ Font::Glyph* Font::getGlyph(unsigned int id)
|
||||||
Glyph& glyph = mGlyphMap[id];
|
Glyph& glyph = mGlyphMap[id];
|
||||||
|
|
||||||
glyph.texture = tex;
|
glyph.texture = tex;
|
||||||
glyph.texPos = glm::vec2{cursor.x / static_cast<float>(tex->textureSize.x),
|
glyph.texPos = glm::vec2 {cursor.x / static_cast<float>(tex->textureSize.x),
|
||||||
cursor.y / static_cast<float>(tex->textureSize.y)};
|
cursor.y / static_cast<float>(tex->textureSize.y)};
|
||||||
glyph.texSize = glm::vec2{glyphSize.x / static_cast<float>(tex->textureSize.x),
|
glyph.texSize = glm::vec2 {glyphSize.x / static_cast<float>(tex->textureSize.x),
|
||||||
glyphSize.y / static_cast<float>(tex->textureSize.y)};
|
glyphSize.y / static_cast<float>(tex->textureSize.y)};
|
||||||
|
|
||||||
glyph.advance = glm::vec2{static_cast<float>(g->metrics.horiAdvance) / 64.0f,
|
glyph.advance = glm::vec2 {static_cast<float>(g->metrics.horiAdvance) / 64.0f,
|
||||||
static_cast<float>(g->metrics.vertAdvance) / 64.0f};
|
static_cast<float>(g->metrics.vertAdvance) / 64.0f};
|
||||||
glyph.bearing = glm::vec2{static_cast<float>(g->metrics.horiBearingX) / 64.0f,
|
glyph.bearing = glm::vec2 {static_cast<float>(g->metrics.horiBearingX) / 64.0f,
|
||||||
static_cast<float>(g->metrics.horiBearingY) / 64.0f};
|
static_cast<float>(g->metrics.horiBearingY) / 64.0f};
|
||||||
|
|
||||||
// Upload glyph bitmap to texture.
|
// Upload glyph bitmap to texture.
|
||||||
Renderer::updateTexture(tex->textureId, Renderer::Texture::ALPHA, cursor.x, cursor.y,
|
Renderer::updateTexture(tex->textureId, Renderer::Texture::ALPHA, cursor.x, cursor.y,
|
||||||
|
@ -374,10 +374,10 @@ void Font::rebuildTextures()
|
||||||
FontTexture* tex = it->second.texture;
|
FontTexture* tex = it->second.texture;
|
||||||
|
|
||||||
// Find the position/size.
|
// Find the position/size.
|
||||||
glm::ivec2 cursor{static_cast<int>(it->second.texPos.x * tex->textureSize.x),
|
glm::ivec2 cursor {static_cast<int>(it->second.texPos.x * tex->textureSize.x),
|
||||||
static_cast<int>(it->second.texPos.y * tex->textureSize.y)};
|
static_cast<int>(it->second.texPos.y * tex->textureSize.y)};
|
||||||
glm::ivec2 glyphSize{static_cast<int>(it->second.texSize.x * tex->textureSize.x),
|
glm::ivec2 glyphSize {static_cast<int>(it->second.texSize.x * tex->textureSize.x),
|
||||||
static_cast<int>(it->second.texSize.y * tex->textureSize.y)};
|
static_cast<int>(it->second.texSize.y * tex->textureSize.y)};
|
||||||
|
|
||||||
// Upload to texture.
|
// Upload to texture.
|
||||||
Renderer::updateTexture(tex->textureId, Renderer::Texture::ALPHA, cursor.x, cursor.y,
|
Renderer::updateTexture(tex->textureId, Renderer::Texture::ALPHA, cursor.x, cursor.y,
|
||||||
|
@ -432,7 +432,7 @@ glm::vec2 Font::sizeText(std::string text, float lineSpacing)
|
||||||
if (lineWidth > highestWidth)
|
if (lineWidth > highestWidth)
|
||||||
highestWidth = lineWidth;
|
highestWidth = lineWidth;
|
||||||
|
|
||||||
return glm::vec2{highestWidth, y};
|
return glm::vec2 {highestWidth, y};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Font::getTextMaxWidth(std::string text, float maxWidth)
|
std::string Font::getTextMaxWidth(std::string text, float maxWidth)
|
||||||
|
@ -557,7 +557,7 @@ glm::vec2 Font::getWrappedTextCursorOffset(std::string text,
|
||||||
lineWidth += glyph->advance.x;
|
lineWidth += glyph->advance.x;
|
||||||
}
|
}
|
||||||
|
|
||||||
return glm::vec2{lineWidth, y};
|
return glm::vec2 {lineWidth, y};
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -652,8 +652,8 @@ TextCache* Font::buildTextCache(const std::string& text,
|
||||||
verts.resize(oldVertSize + 6);
|
verts.resize(oldVertSize + 6);
|
||||||
Renderer::Vertex* vertices = verts.data() + oldVertSize;
|
Renderer::Vertex* vertices = verts.data() + oldVertSize;
|
||||||
|
|
||||||
const float glyphStartX{x + glyph->bearing.x};
|
const float glyphStartX {x + glyph->bearing.x};
|
||||||
const glm::ivec2& textureSize{glyph->texture->textureSize};
|
const glm::ivec2& textureSize {glyph->texture->textureSize};
|
||||||
const unsigned int convertedColor = Renderer::convertRGBAToABGR(color);
|
const unsigned int convertedColor = Renderer::convertRGBAToABGR(color);
|
||||||
|
|
||||||
vertices[1] = {{glyphStartX, y - glyph->bearing.y},
|
vertices[1] = {{glyphStartX, y - glyph->bearing.y},
|
||||||
|
@ -705,7 +705,7 @@ TextCache* Font::buildTextCache(const std::string& text,
|
||||||
float lineSpacing,
|
float lineSpacing,
|
||||||
bool noTopMargin)
|
bool noTopMargin)
|
||||||
{
|
{
|
||||||
return buildTextCache(text, glm::vec2{offsetX, offsetY}, color, 0.0f, ALIGN_LEFT, lineSpacing,
|
return buildTextCache(text, glm::vec2 {offsetX, offsetY}, color, 0.0f, ALIGN_LEFT, lineSpacing,
|
||||||
noTopMargin);
|
noTopMargin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,19 +24,19 @@
|
||||||
#define DPI 96
|
#define DPI 96
|
||||||
|
|
||||||
TextureData::TextureData(bool tile)
|
TextureData::TextureData(bool tile)
|
||||||
: mTile{tile}
|
: mTile {tile}
|
||||||
, mTextureID{0}
|
, mTextureID {0}
|
||||||
, mDataRGBA({})
|
, mDataRGBA({})
|
||||||
, mFormat{Renderer::Texture::RGBA}
|
, mFormat {Renderer::Texture::RGBA}
|
||||||
, mWidth{0}
|
, mWidth {0}
|
||||||
, mHeight{0}
|
, mHeight {0}
|
||||||
, mSourceWidth{0.0f}
|
, mSourceWidth {0.0f}
|
||||||
, mSourceHeight{0.0f}
|
, mSourceHeight {0.0f}
|
||||||
, mScalable{false}
|
, mScalable {false}
|
||||||
, mHasRGBAData{false}
|
, mHasRGBAData {false}
|
||||||
, mPendingRasterization{false}
|
, mPendingRasterization {false}
|
||||||
, mLinearMagnify{false}
|
, mLinearMagnify {false}
|
||||||
, mForceRasterization{false}
|
, mForceRasterization {false}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,20 +56,20 @@ void TextureData::initFromPath(const std::string& path)
|
||||||
|
|
||||||
bool TextureData::initSVGFromMemory(const std::string& fileData)
|
bool TextureData::initSVGFromMemory(const std::string& fileData)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock{mMutex};
|
std::unique_lock<std::mutex> lock {mMutex};
|
||||||
|
|
||||||
// If already initialized then don't process it again unless it needs to be rasterized.
|
// If already initialized then don't process it again unless it needs to be rasterized.
|
||||||
if (!mDataRGBA.empty() && !mPendingRasterization)
|
if (!mDataRGBA.empty() && !mPendingRasterization)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
NSVGimage* svgImage{nsvgParse(const_cast<char*>(fileData.c_str()), "px", DPI)};
|
NSVGimage* svgImage {nsvgParse(const_cast<char*>(fileData.c_str()), "px", DPI)};
|
||||||
|
|
||||||
if (!svgImage || svgImage->width == 0 || svgImage->height == 0) {
|
if (!svgImage || svgImage->width == 0 || svgImage->height == 0) {
|
||||||
LOG(LogError) << "Couldn't parse SVG image";
|
LOG(LogError) << "Couldn't parse SVG image";
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rasterize{true};
|
bool rasterize {true};
|
||||||
|
|
||||||
// If there is no image size defined yet, then don't rasterize unless mForceRasterization has
|
// If there is no image size defined yet, then don't rasterize unless mForceRasterization has
|
||||||
// been set.
|
// been set.
|
||||||
|
|
|
@ -57,7 +57,7 @@ public:
|
||||||
float sourceWidth();
|
float sourceWidth();
|
||||||
float sourceHeight();
|
float sourceHeight();
|
||||||
void setSourceSize(float width, float height);
|
void setSourceSize(float width, float height);
|
||||||
glm::vec2 getSize() { return glm::vec2{static_cast<int>(mWidth), static_cast<int>(mHeight)}; }
|
glm::vec2 getSize() { return glm::vec2 {static_cast<int>(mWidth), static_cast<int>(mHeight)}; }
|
||||||
|
|
||||||
// Whether to use linear filtering when magnifying the texture.
|
// Whether to use linear filtering when magnifying the texture.
|
||||||
void setLinearMagnify(bool setting) { mLinearMagnify = setting; }
|
void setLinearMagnify(bool setting) { mLinearMagnify = setting; }
|
||||||
|
|
|
@ -44,15 +44,15 @@ TextureResource::TextureResource(
|
||||||
data->load();
|
data->load();
|
||||||
}
|
}
|
||||||
|
|
||||||
mSize = glm::ivec2{static_cast<int>(data->width()), static_cast<int>(data->height())};
|
mSize = glm::ivec2 {static_cast<int>(data->width()), static_cast<int>(data->height())};
|
||||||
mSourceSize = glm::vec2{data->sourceWidth(), data->sourceHeight()};
|
mSourceSize = glm::vec2 {data->sourceWidth(), data->sourceHeight()};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Create a texture managed by this class because it cannot be dynamically
|
// Create a texture managed by this class because it cannot be dynamically
|
||||||
// loaded and unloaded. This would normally be a video texture, where the player
|
// loaded and unloaded. This would normally be a video texture, where the player
|
||||||
// reserves a texture to later be used for the video rendering.
|
// reserves a texture to later be used for the video rendering.
|
||||||
mTextureData = std::shared_ptr<TextureData>(new TextureData(tile));
|
mTextureData = std::shared_ptr<TextureData>(new TextureData(tile));
|
||||||
mSize = glm::ivec2{};
|
mSize = glm::ivec2 {};
|
||||||
}
|
}
|
||||||
sAllTextures.insert(this);
|
sAllTextures.insert(this);
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,8 @@ void TextureResource::initFromPixels(const unsigned char* dataRGBA, size_t width
|
||||||
mTextureData->releaseRAM();
|
mTextureData->releaseRAM();
|
||||||
mTextureData->initFromRGBA(dataRGBA, width, height);
|
mTextureData->initFromRGBA(dataRGBA, width, height);
|
||||||
// Cache the image dimensions.
|
// Cache the image dimensions.
|
||||||
mSize = glm::ivec2{static_cast<int>(width), static_cast<int>(height)};
|
mSize = glm::ivec2 {static_cast<int>(width), static_cast<int>(height)};
|
||||||
mSourceSize = glm::vec2{mTextureData->sourceWidth(), mTextureData->sourceHeight()};
|
mSourceSize = glm::vec2 {mTextureData->sourceWidth(), mTextureData->sourceHeight()};
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureResource::initFromMemory(const char* data, size_t length)
|
void TextureResource::initFromMemory(const char* data, size_t length)
|
||||||
|
@ -85,9 +85,9 @@ void TextureResource::initFromMemory(const char* data, size_t length)
|
||||||
mTextureData->releaseRAM();
|
mTextureData->releaseRAM();
|
||||||
mTextureData->initImageFromMemory(reinterpret_cast<const unsigned char*>(data), length);
|
mTextureData->initImageFromMemory(reinterpret_cast<const unsigned char*>(data), length);
|
||||||
// Get the size from the texture data.
|
// Get the size from the texture data.
|
||||||
mSize = glm::ivec2{static_cast<int>(mTextureData->width()),
|
mSize = glm::ivec2 {static_cast<int>(mTextureData->width()),
|
||||||
static_cast<int>(mTextureData->height())};
|
static_cast<int>(mTextureData->height())};
|
||||||
mSourceSize = glm::vec2{mTextureData->sourceWidth(), mTextureData->sourceHeight()};
|
mSourceSize = glm::vec2 {mTextureData->sourceWidth(), mTextureData->sourceHeight()};
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureResource::manualUnload(std::string path, bool tile)
|
void TextureResource::manualUnload(std::string path, bool tile)
|
||||||
|
@ -205,7 +205,7 @@ void TextureResource::rasterizeAt(float width, float height)
|
||||||
data = mTextureData;
|
data = mTextureData;
|
||||||
else
|
else
|
||||||
data = sTextureDataManager.get(this);
|
data = sTextureDataManager.get(this);
|
||||||
mSourceSize = glm::vec2{static_cast<float>(width), static_cast<float>(height)};
|
mSourceSize = glm::vec2 {static_cast<float>(width), static_cast<float>(height)};
|
||||||
data->setSourceSize(static_cast<float>(width), static_cast<float>(height));
|
data->setSourceSize(static_cast<float>(width), static_cast<float>(height));
|
||||||
if (mForceLoad || mTextureData != nullptr)
|
if (mForceLoad || mTextureData != nullptr)
|
||||||
data->load();
|
data->load();
|
||||||
|
@ -228,7 +228,7 @@ size_t TextureResource::getTotalMemUsage()
|
||||||
|
|
||||||
size_t TextureResource::getTotalTextureSize()
|
size_t TextureResource::getTotalTextureSize()
|
||||||
{
|
{
|
||||||
size_t total{0};
|
size_t total {0};
|
||||||
// Count up all textures that manage their own texture data.
|
// Count up all textures that manage their own texture data.
|
||||||
for (auto tex : sAllTextures) {
|
for (auto tex : sAllTextures) {
|
||||||
if (tex->mTextureData != nullptr)
|
if (tex->mTextureData != nullptr)
|
||||||
|
|
|
@ -22,13 +22,13 @@ namespace Utils
|
||||||
{
|
{
|
||||||
float smoothStep(const float left, const float right, const float value)
|
float smoothStep(const float left, const float right, const float value)
|
||||||
{
|
{
|
||||||
const float x{glm::clamp((value - left) / (right - left), 0.0f, 1.0f)};
|
const float x {glm::clamp((value - left) / (right - left), 0.0f, 1.0f)};
|
||||||
return x * x * (3.0f - (2.0f * x));
|
return x * x * (3.0f - (2.0f * x));
|
||||||
}
|
}
|
||||||
|
|
||||||
float smootherStep(const float left, const float right, const float value)
|
float smootherStep(const float left, const float right, const float value)
|
||||||
{
|
{
|
||||||
const float x{glm::clamp((value - left) / (right - left), 0.0f, 1.0f)};
|
const float x {glm::clamp((value - left) / (right - left), 0.0f, 1.0f)};
|
||||||
return x * x * x * (x * ((x * 6.0f) - 15.0f) + 10.0f);
|
return x * x * x * (x * ((x * 6.0f) - 15.0f) + 10.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ namespace Utils
|
||||||
}
|
}
|
||||||
else if (currentTime < (delayTime + scrollTime)) {
|
else if (currentTime < (delayTime + scrollTime)) {
|
||||||
// Interpolate from 0 to scrollLength.
|
// Interpolate from 0 to scrollLength.
|
||||||
const float fraction{(currentTime - delayTime) / scrollTime};
|
const float fraction {(currentTime - delayTime) / scrollTime};
|
||||||
return glm::mix(0.0f, scrollLength, fraction);
|
return glm::mix(0.0f, scrollLength, fraction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ namespace Utils
|
||||||
}
|
}
|
||||||
else if (currentTime < (delayTime + scrollTime)) {
|
else if (currentTime < (delayTime + scrollTime)) {
|
||||||
// Interpolate from 0 to scrollLength.
|
// Interpolate from 0 to scrollLength.
|
||||||
const float fraction{(currentTime - delayTime) / scrollTime};
|
const float fraction {(currentTime - delayTime) / scrollTime};
|
||||||
return glm::mix(0.0f, scrollLength, smootherStep(0.0f, 1.0f, fraction));
|
return glm::mix(0.0f, scrollLength, smootherStep(0.0f, 1.0f, fraction));
|
||||||
}
|
}
|
||||||
else if (currentTime < (delayTime + scrollTime + delayTime)) {
|
else if (currentTime < (delayTime + scrollTime + delayTime)) {
|
||||||
|
@ -71,8 +71,8 @@ namespace Utils
|
||||||
}
|
}
|
||||||
else if (currentTime < (delayTime + scrollTime + delayTime + scrollTime)) {
|
else if (currentTime < (delayTime + scrollTime + delayTime + scrollTime)) {
|
||||||
// Interpolate back from scrollLength to 0.
|
// Interpolate back from scrollLength to 0.
|
||||||
const float fraction{(currentTime - delayTime - scrollTime - delayTime) /
|
const float fraction {(currentTime - delayTime - scrollTime - delayTime) /
|
||||||
scrollTime};
|
scrollTime};
|
||||||
return glm::mix(scrollLength, 0.0f, smootherStep(0.0f, 1.0f, fraction));
|
return glm::mix(scrollLength, 0.0f, smootherStep(0.0f, 1.0f, fraction));
|
||||||
}
|
}
|
||||||
// And back to waiting.
|
// And back to waiting.
|
||||||
|
@ -82,9 +82,9 @@ namespace Utils
|
||||||
std::string md5Hash(const std::string& data)
|
std::string md5Hash(const std::string& data)
|
||||||
{
|
{
|
||||||
// Data that didn't fit in last 64 byte chunk.
|
// Data that didn't fit in last 64 byte chunk.
|
||||||
unsigned char buffer[64]{};
|
unsigned char buffer[64] {};
|
||||||
// 64 bit counter for the number of bits (low, high).
|
// 64 bit counter for the number of bits (low, high).
|
||||||
unsigned int count[2]{};
|
unsigned int count[2] {};
|
||||||
|
|
||||||
// Digest so far.
|
// Digest so far.
|
||||||
unsigned int state[4];
|
unsigned int state[4];
|
||||||
|
@ -98,10 +98,10 @@ namespace Utils
|
||||||
md5Update(reinterpret_cast<const unsigned char*>(data.c_str()),
|
md5Update(reinterpret_cast<const unsigned char*>(data.c_str()),
|
||||||
static_cast<unsigned int>(data.length()), state, count, buffer);
|
static_cast<unsigned int>(data.length()), state, count, buffer);
|
||||||
|
|
||||||
static unsigned char padding[64]{0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
static unsigned char padding[64] {0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
// Encodes unsigned int input into unsigned char output. Assumes len is a multiple of 4.
|
// Encodes unsigned int input into unsigned char output. Assumes len is a multiple of 4.
|
||||||
auto encodeFunc = [](unsigned char output[], const unsigned int input[],
|
auto encodeFunc = [](unsigned char output[], const unsigned int input[],
|
||||||
|
@ -181,11 +181,11 @@ namespace Utils
|
||||||
|
|
||||||
void md5Transform(const unsigned char block[64], unsigned int (&state)[4])
|
void md5Transform(const unsigned char block[64], unsigned int (&state)[4])
|
||||||
{
|
{
|
||||||
unsigned int a{state[0]};
|
unsigned int a {state[0]};
|
||||||
unsigned int b{state[1]};
|
unsigned int b {state[1]};
|
||||||
unsigned int c{state[2]};
|
unsigned int c {state[2]};
|
||||||
unsigned int d{state[3]};
|
unsigned int d {state[3]};
|
||||||
unsigned int x[16]{};
|
unsigned int x[16] {};
|
||||||
|
|
||||||
// Encodes unsigned int input into unsigned char output. Assumes len is a multiple of 4.
|
// Encodes unsigned int input into unsigned char output. Assumes len is a multiple of 4.
|
||||||
for (unsigned int i = 0, j = 0; j < 64; ++i, j += 4)
|
for (unsigned int i = 0, j = 0; j < 64; ++i, j += 4)
|
||||||
|
@ -194,22 +194,22 @@ namespace Utils
|
||||||
((static_cast<unsigned int>(block[j + 2])) << 16) |
|
((static_cast<unsigned int>(block[j + 2])) << 16) |
|
||||||
((static_cast<unsigned int>(block[j + 3])) << 24);
|
((static_cast<unsigned int>(block[j + 3])) << 24);
|
||||||
|
|
||||||
const unsigned int S11{7};
|
const unsigned int S11 {7};
|
||||||
const unsigned int S12{12};
|
const unsigned int S12 {12};
|
||||||
const unsigned int S13{17};
|
const unsigned int S13 {17};
|
||||||
const unsigned int S14{22};
|
const unsigned int S14 {22};
|
||||||
const unsigned int S21{5};
|
const unsigned int S21 {5};
|
||||||
const unsigned int S22{9};
|
const unsigned int S22 {9};
|
||||||
const unsigned int S23{14};
|
const unsigned int S23 {14};
|
||||||
const unsigned int S24{20};
|
const unsigned int S24 {20};
|
||||||
const unsigned int S31{4};
|
const unsigned int S31 {4};
|
||||||
const unsigned int S32{11};
|
const unsigned int S32 {11};
|
||||||
const unsigned int S33{16};
|
const unsigned int S33 {16};
|
||||||
const unsigned int S34{23};
|
const unsigned int S34 {23};
|
||||||
const unsigned int S41{6};
|
const unsigned int S41 {6};
|
||||||
const unsigned int S42{10};
|
const unsigned int S42 {10};
|
||||||
const unsigned int S43{15};
|
const unsigned int S43 {15};
|
||||||
const unsigned int S44{21};
|
const unsigned int S44 {21};
|
||||||
|
|
||||||
// fFunc, gFunc, hFunc and iFunc are basic MD5 functions.
|
// fFunc, gFunc, hFunc and iFunc are basic MD5 functions.
|
||||||
auto fFunc = [](unsigned int x, unsigned int y, unsigned int z) {
|
auto fFunc = [](unsigned int x, unsigned int y, unsigned int z) {
|
||||||
|
|
|
@ -144,7 +144,7 @@ namespace Utils
|
||||||
int launchGameWindows(const std::wstring& cmd_utf16, bool runInBackground, bool hideWindow)
|
int launchGameWindows(const std::wstring& cmd_utf16, bool runInBackground, bool hideWindow)
|
||||||
{
|
{
|
||||||
#if defined(_WIN64)
|
#if defined(_WIN64)
|
||||||
STARTUPINFOW si{};
|
STARTUPINFOW si {};
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
|
|
||||||
si.cb = sizeof(si);
|
si.cb = sizeof(si);
|
||||||
|
@ -172,8 +172,8 @@ namespace Utils
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
if (!runInBackground) {
|
if (!runInBackground) {
|
||||||
int width{};
|
int width {};
|
||||||
int height{};
|
int height {};
|
||||||
|
|
||||||
// Hack to make the emulator window render correctly when launching games while
|
// Hack to make the emulator window render correctly when launching games while
|
||||||
// running in full screen mode. If not done, the emulator window will simply be
|
// running in full screen mode. If not done, the emulator window will simply be
|
||||||
|
|
Loading…
Reference in a new issue