mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-02-16 20:15:38 +00:00
Replaced the internal Vector2i data type and functions with the GLM library equivalent.
Also applied some code formatting changes for braced lists using clang-format.
This commit is contained in:
parent
9a30e2da87
commit
7b5d673050
|
@ -425,8 +425,7 @@ bool FileFilterIndex::isKeyBeingFilteredBy(std::string key, FilterIndexType type
|
|||
std::vector<std::string> filterKeysList[9] = {
|
||||
mFavoritesIndexFilteredKeys, mGenreIndexFilteredKeys, mPlayersIndexFilteredKeys,
|
||||
mPubDevIndexFilteredKeys, mRatingsIndexFilteredKeys, mKidGameIndexFilteredKeys,
|
||||
mCompletedIndexFilteredKeys, mBrokenIndexFilteredKeys, mHiddenIndexFilteredKeys
|
||||
};
|
||||
mCompletedIndexFilteredKeys, mBrokenIndexFilteredKeys, mHiddenIndexFilteredKeys};
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (filterTypes[i] == type) {
|
||||
|
|
|
@ -45,8 +45,7 @@ namespace FileSorts
|
|||
FileData::SortType(&compareTimesPlayedDescending, "times played, descending"),
|
||||
|
||||
FileData::SortType(&compareSystem, "system, ascending"),
|
||||
FileData::SortType(&compareSystemDescending, "system, descending")
|
||||
};
|
||||
FileData::SortType(&compareSystemDescending, "system, descending")};
|
||||
|
||||
const std::vector<FileData::SortType> SortTypes(typesArr,
|
||||
typesArr +
|
||||
|
|
|
@ -83,7 +83,7 @@ void MediaViewer::update(int deltaTime)
|
|||
|
||||
void MediaViewer::render()
|
||||
{
|
||||
glm::mat4 trans = Renderer::getIdentity();
|
||||
glm::mat4 trans{Renderer::getIdentity()};
|
||||
Renderer::setMatrix(trans);
|
||||
|
||||
// Render a black background below the game media.
|
||||
|
@ -95,7 +95,7 @@ void MediaViewer::render()
|
|||
|
||||
#if defined(USE_OPENGL_21)
|
||||
Renderer::shaderParameters videoParameters;
|
||||
unsigned int shaders = 0;
|
||||
unsigned int shaders{0};
|
||||
if (Settings::getInstance()->getBool("MediaViewerVideoScanlines"))
|
||||
shaders = Renderer::SHADER_SCANLINES;
|
||||
if (Settings::getInstance()->getBool("MediaViewerVideoBlur")) {
|
||||
|
@ -121,7 +121,7 @@ void MediaViewer::render()
|
|||
Renderer::shaderPostprocessing(shaders, videoParameters);
|
||||
#endif
|
||||
}
|
||||
else if (mImage && mImage->hasImage() && mImage->getSize() != glm::vec2({})) {
|
||||
else if (mImage && mImage->hasImage() && mImage->getSize() != glm::vec2{}) {
|
||||
mImage->render(trans);
|
||||
|
||||
#if defined(USE_OPENGL_21)
|
||||
|
|
|
@ -254,7 +254,7 @@ void SystemScreensaver::renderScreensaver()
|
|||
|
||||
// Only render the video if the state requires it.
|
||||
if (static_cast<int>(mState) >= STATE_FADE_IN_VIDEO) {
|
||||
glm::mat4 trans = Renderer::getIdentity();
|
||||
glm::mat4 trans{Renderer::getIdentity()};
|
||||
mVideoScreensaver->render(trans);
|
||||
}
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ void SystemScreensaver::renderScreensaver()
|
|||
if (static_cast<int>(mState) >= STATE_FADE_IN_VIDEO) {
|
||||
if (mImageScreensaver->hasImage()) {
|
||||
mImageScreensaver->setOpacity(255 - static_cast<unsigned char>(mOpacity * 255));
|
||||
glm::mat4 trans = Renderer::getIdentity();
|
||||
glm::mat4 trans{Renderer::getIdentity()};
|
||||
mImageScreensaver->render(trans);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
|
|||
auto bracketThemeCollection = std::make_shared<ImageComponent>(mWindow);
|
||||
bracketThemeCollection->setImage(":/graphics/arrow.svg");
|
||||
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(bracketThemeCollection, false);
|
||||
row.makeAcceptInputHandler([this, unusedFolders] {
|
||||
|
@ -196,7 +196,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
|
|||
auto bracketNewCollection = std::make_shared<ImageComponent>(mWindow);
|
||||
bracketNewCollection->setImage(":/graphics/arrow.svg");
|
||||
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(bracketNewCollection, false);
|
||||
auto createCollectionCall = [this](const std::string& newVal) {
|
||||
|
@ -221,7 +221,7 @@ GuiCollectionSystemsOptions::GuiCollectionSystemsOptions(Window* window, std::st
|
|||
auto bracketDeleteCollection = std::make_shared<ImageComponent>(mWindow);
|
||||
bracketDeleteCollection->setImage(":/graphics/arrow.svg");
|
||||
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(bracketDeleteCollection, false);
|
||||
row.makeAcceptInputHandler([this, customSystems] {
|
||||
|
|
|
@ -22,7 +22,7 @@ GuiGameScraper::GuiGameScraper(Window* window,
|
|||
ScraperSearchParams params,
|
||||
std::function<void(const ScraperSearchResult&)> doneFunc)
|
||||
: GuiComponent(window)
|
||||
, mGrid(window, Vector2i(1, 7))
|
||||
, mGrid(window, glm::ivec2{1, 7})
|
||||
, mBox(window, ":/graphics/frame.svg")
|
||||
, mSearchParams(params)
|
||||
, mClose(false)
|
||||
|
@ -52,20 +52,20 @@ GuiGameScraper::GuiGameScraper(Window* window,
|
|||
scrapeName +
|
||||
((mSearchParams.game->getType() == FOLDER) ? " " + ViewController::FOLDER_CHAR : ""),
|
||||
Font::get(FONT_SIZE_MEDIUM), 0x777777FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mGameName, Vector2i(0, 1), false, true);
|
||||
mGrid.setEntry(mGameName, glm::ivec2{0, 1}, false, true);
|
||||
|
||||
// Row 2 is a spacer.
|
||||
|
||||
mSystemName = std::make_shared<TextComponent>(
|
||||
mWindow, Utils::String::toUpper(mSearchParams.system->getFullName()),
|
||||
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mSystemName, Vector2i(0, 3), false, true);
|
||||
mGrid.setEntry(mSystemName, glm::ivec2{0, 3}, false, true);
|
||||
|
||||
// Row 4 is a spacer.
|
||||
|
||||
// GuiScraperSearch.
|
||||
mSearch = std::make_shared<GuiScraperSearch>(window, GuiScraperSearch::NEVER_AUTO_ACCEPT, 1);
|
||||
mGrid.setEntry(mSearch, Vector2i(0, 5), true);
|
||||
mGrid.setEntry(mSearch, glm::ivec2{0, 5}, true);
|
||||
|
||||
// Buttons
|
||||
std::vector<std::shared_ptr<ButtonComponent>> buttons;
|
||||
|
@ -92,7 +92,7 @@ GuiGameScraper::GuiGameScraper(Window* window,
|
|||
}));
|
||||
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
||||
|
||||
mGrid.setEntry(mButtonGrid, Vector2i(0, 6), true, false);
|
||||
mGrid.setEntry(mButtonGrid, glm::ivec2{0, 6}, true, false);
|
||||
|
||||
mSearch->setAcceptCallback([this, doneFunc](const ScraperSearchResult& result) {
|
||||
doneFunc(result);
|
||||
|
@ -115,7 +115,7 @@ GuiGameScraper::GuiGameScraper(Window* window,
|
|||
|
||||
void GuiGameScraper::onSizeChanged()
|
||||
{
|
||||
mBox.fitTo(mSize, glm::vec3({}), glm::vec2(-32.0f, -32.0f));
|
||||
mBox.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
||||
|
||||
mGrid.setRowHeightPerc(0, 0.04f, false);
|
||||
mGrid.setRowHeightPerc(1, mGameName->getFont()->getLetterHeight() / mSize.y, false);
|
||||
|
|
|
@ -106,7 +106,7 @@ void GuiGamelistFilter::addFiltersToMenu()
|
|||
|
||||
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
||||
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);
|
||||
|
||||
mTextFilterField->setValue(mFilterIndex->getTextFilter());
|
||||
|
|
|
@ -54,15 +54,15 @@ GuiInfoPopup::GuiInfoPopup(Window* window, std::string message, int duration)
|
|||
setPosition(posX, posY, 0);
|
||||
|
||||
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);
|
||||
|
||||
// We only initialize the actual time when we first start to render.
|
||||
mStartTime = 0;
|
||||
|
||||
mGrid = new ComponentGrid(window, Vector2i(1, 3));
|
||||
mGrid = new ComponentGrid(window, glm::ivec2{1, 3});
|
||||
mGrid->setSize(mSize);
|
||||
mGrid->setEntry(s, Vector2i(0, 1), false, true);
|
||||
mGrid->setEntry(s, glm::ivec2{0, 1}, false, true);
|
||||
addChild(mGrid);
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ GuiInfoPopup::~GuiInfoPopup()
|
|||
void GuiInfoPopup::render(const glm::mat4& /*parentTrans*/)
|
||||
{
|
||||
// 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 we're still supposed to be rendering it.
|
||||
Renderer::setMatrix(trans);
|
||||
|
|
|
@ -34,7 +34,7 @@ GuiLaunchScreen::~GuiLaunchScreen()
|
|||
|
||||
void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
||||
{
|
||||
mGrid = new ComponentGrid(mWindow, Vector2i(3, 8));
|
||||
mGrid = new ComponentGrid(mWindow, glm::ivec2{3, 8});
|
||||
addChild(mGrid);
|
||||
|
||||
mImagePath = game->getMarqueePath();
|
||||
|
@ -51,8 +51,8 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
|||
const float gameNameFontSize = 0.073f;
|
||||
|
||||
// Spacer row.
|
||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), Vector2i(1, 0), false, false,
|
||||
Vector2i(1, 1));
|
||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{1, 0}, false, false,
|
||||
glm::ivec2{1, 1});
|
||||
|
||||
// Title.
|
||||
mTitle = std::make_shared<TextComponent>(
|
||||
|
@ -60,19 +60,19 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
|||
Font::get(static_cast<int>(
|
||||
titleFontSize * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth()))),
|
||||
0x666666FF, ALIGN_CENTER);
|
||||
mGrid->setEntry(mTitle, Vector2i(1, 1), false, true, Vector2i(1, 1));
|
||||
mGrid->setEntry(mTitle, glm::ivec2{1, 1}, false, true, glm::ivec2{1, 1});
|
||||
|
||||
// Spacer row.
|
||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), Vector2i(1, 2), false, false,
|
||||
Vector2i(1, 1));
|
||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{1, 2}, false, false,
|
||||
glm::ivec2{1, 1});
|
||||
|
||||
// Row for the marquee.
|
||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), Vector2i(1, 3), false, false,
|
||||
Vector2i(1, 1));
|
||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{1, 3}, false, false,
|
||||
glm::ivec2{1, 1});
|
||||
|
||||
// Spacer row.
|
||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), Vector2i(1, 4), false, false,
|
||||
Vector2i(1, 1));
|
||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{1, 4}, false, false,
|
||||
glm::ivec2{1, 1});
|
||||
|
||||
// Game name.
|
||||
mGameName = std::make_shared<TextComponent>(
|
||||
|
@ -80,24 +80,24 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
|||
Font::get(static_cast<int>(
|
||||
gameNameFontSize * std::min(Renderer::getScreenHeight(), Renderer::getScreenWidth()))),
|
||||
0x444444FF, ALIGN_CENTER);
|
||||
mGrid->setEntry(mGameName, Vector2i(1, 5), false, true, Vector2i(1, 1));
|
||||
mGrid->setEntry(mGameName, glm::ivec2{1, 5}, false, true, glm::ivec2{1, 1});
|
||||
|
||||
// System name.
|
||||
mSystemName = std::make_shared<TextComponent>(
|
||||
mWindow, "SYSTEM NAME", Font::get(FONT_SIZE_MEDIUM), 0x666666FF, ALIGN_CENTER);
|
||||
mGrid->setEntry(mSystemName, Vector2i(1, 6), false, true, Vector2i(1, 1));
|
||||
mGrid->setEntry(mSystemName, glm::ivec2{1, 6}, false, true, glm::ivec2{1, 1});
|
||||
|
||||
// Spacer row.
|
||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), Vector2i(1, 7), false, false,
|
||||
Vector2i(1, 1));
|
||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{1, 7}, false, false,
|
||||
glm::ivec2{1, 1});
|
||||
|
||||
// Left spacer.
|
||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), Vector2i(0, 0), false, false,
|
||||
Vector2i(1, 8));
|
||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{0, 0}, false, false,
|
||||
glm::ivec2{1, 8});
|
||||
|
||||
// Right spacer.
|
||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), Vector2i(2, 0), false, false,
|
||||
Vector2i(1, 8));
|
||||
mGrid->setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{2, 0}, false, false,
|
||||
glm::ivec2{1, 8});
|
||||
|
||||
// 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
|
||||
|
@ -169,8 +169,8 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
|||
mGrid->getRowHeight(3));
|
||||
|
||||
mMarquee->setOrigin(0.5f, 0.5f);
|
||||
glm::vec3 currentPos = mMarquee->getPosition();
|
||||
glm::vec2 currentSize = mMarquee->getSize();
|
||||
glm::vec3 currentPos{mMarquee->getPosition()};
|
||||
glm::vec2 currentSize{mMarquee->getSize()};
|
||||
|
||||
// Position the image in the middle of row four.
|
||||
currentPos.x = mSize.x / 2.0f;
|
||||
|
@ -185,7 +185,7 @@ void GuiLaunchScreen::displayLaunchScreen(FileData* game)
|
|||
setPosition(static_cast<float>(Renderer::getScreenWidth()) / 2.0f,
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -228,7 +228,7 @@ void GuiLaunchScreen::render()
|
|||
if (mScaleUp < 1.0f)
|
||||
setScale(mScaleUp);
|
||||
|
||||
glm::mat4 trans = Renderer::getIdentity() * getTransform();
|
||||
glm::mat4 trans{Renderer::getIdentity() * getTransform()};
|
||||
Renderer::setMatrix(trans);
|
||||
|
||||
GuiComponent::renderChildren(trans);
|
||||
|
|
|
@ -898,7 +898,7 @@ void GuiMenu::openOtherOptions()
|
|||
auto bracketMediaDirectory = std::make_shared<ImageComponent>(mWindow);
|
||||
bracketMediaDirectory->setImage(":/graphics/arrow.svg");
|
||||
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(bracketMediaDirectory, false);
|
||||
std::string titleMediaDir = "ENTER GAME MEDIA DIRECTORY";
|
||||
|
|
|
@ -42,7 +42,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
|||
: GuiComponent(window)
|
||||
, mScraperParams(scraperParams)
|
||||
, mBackground(window, ":/graphics/frame.svg")
|
||||
, mGrid(window, Vector2i(1, 3))
|
||||
, mGrid(window, glm::ivec2{1, 3})
|
||||
, mMetaDataDecl(mdd)
|
||||
, mMetaData(md)
|
||||
, mSavedCallback(saveCallback)
|
||||
|
@ -53,7 +53,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
|||
addChild(&mBackground);
|
||||
addChild(&mGrid);
|
||||
|
||||
mHeaderGrid = std::make_shared<ComponentGrid>(mWindow, Vector2i(1, 5));
|
||||
mHeaderGrid = std::make_shared<ComponentGrid>(mWindow, glm::ivec2{1, 5});
|
||||
|
||||
mTitle = std::make_shared<TextComponent>(mWindow, "EDIT METADATA", Font::get(FONT_SIZE_LARGE),
|
||||
0x555555FF, ALIGN_CENTER);
|
||||
|
@ -78,15 +78,15 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
|||
folderPath + Utils::FileSystem::getFileName(scraperParams.game->getPath()) + " [" +
|
||||
Utils::String::toUpper(scraperParams.system->getName()) + "]" +
|
||||
(scraperParams.game->getType() == FOLDER ? " " + ViewController::FOLDER_CHAR : ""),
|
||||
Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER, glm::vec3({}), glm::vec2({}),
|
||||
0x00000000, 0.05f);
|
||||
mHeaderGrid->setEntry(mTitle, Vector2i(0, 1), false, true);
|
||||
mHeaderGrid->setEntry(mSubtitle, Vector2i(0, 3), false, true);
|
||||
Font::get(FONT_SIZE_SMALL), 0x777777FF, ALIGN_CENTER, glm::vec3{}, glm::vec2{}, 0x00000000,
|
||||
0.05f);
|
||||
mHeaderGrid->setEntry(mTitle, glm::ivec2{0, 1}, false, true);
|
||||
mHeaderGrid->setEntry(mSubtitle, glm::ivec2{0, 3}, false, true);
|
||||
|
||||
mGrid.setEntry(mHeaderGrid, Vector2i(0, 0), false, true);
|
||||
mGrid.setEntry(mHeaderGrid, glm::ivec2{0, 0}, false, true);
|
||||
|
||||
mList = std::make_shared<ComponentList>(mWindow);
|
||||
mGrid.setEntry(mList, Vector2i(0, 1), true, true);
|
||||
mGrid.setEntry(mList, glm::ivec2{0, 1}, true, true);
|
||||
|
||||
// Populate list.
|
||||
for (auto iter = mdd.cbegin(); iter != mdd.cend(); iter++) {
|
||||
|
@ -123,7 +123,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
|||
case MD_BOOL: {
|
||||
ed = std::make_shared<SwitchComponent>(window);
|
||||
// Make the switches slightly smaller.
|
||||
glm::vec2 switchSize = ed->getSize() * 0.9f;
|
||||
glm::vec2 switchSize{ed->getSize() * 0.9f};
|
||||
ed->setResize(switchSize.x, switchSize.y);
|
||||
ed->setOrigin(-0.05f, -0.09f);
|
||||
|
||||
|
@ -182,7 +182,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
|||
|
||||
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
||||
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);
|
||||
|
||||
bool multiLine = false;
|
||||
|
@ -223,7 +223,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
|||
|
||||
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
||||
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);
|
||||
|
||||
bool multiLine = iter->type == MD_MULTILINE_STRING;
|
||||
|
@ -346,7 +346,7 @@ GuiMetaDataEd::GuiMetaDataEd(Window* window,
|
|||
}
|
||||
|
||||
mButtons = makeButtonGrid(mWindow, buttons);
|
||||
mGrid.setEntry(mButtons, Vector2i(0, 2), true, false);
|
||||
mGrid.setEntry(mButtons, glm::ivec2{0, 2}, true, false);
|
||||
|
||||
// Resize + center.
|
||||
float width =
|
||||
|
@ -386,12 +386,12 @@ void GuiMetaDataEd::onSizeChanged()
|
|||
// Adjust the size of the list and window.
|
||||
float heightAdjustment = listSize - listHeight;
|
||||
mList->setSize(mList->getSize().x, listHeight);
|
||||
glm::vec2 newWindowSize = mSize;
|
||||
glm::vec2 newWindowSize{mSize};
|
||||
newWindowSize.y -= heightAdjustment;
|
||||
mBackground.fitTo(newWindowSize, glm::vec3({}), glm::vec2(-32.0f, -32.0f));
|
||||
mBackground.fitTo(newWindowSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
||||
|
||||
// Move the buttons up as well to make the layout align correctly after the resize.
|
||||
glm::vec3 newButtonPos = mButtons->getPosition();
|
||||
glm::vec3 newButtonPos{mButtons->getPosition()};
|
||||
newButtonPos.y -= heightAdjustment;
|
||||
mButtons->setPosition(newButtonPos);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue<FileData*>& gameQueue)
|
||||
: GuiComponent(window)
|
||||
, mBackground(window, ":/graphics/frame.svg")
|
||||
, mGrid(window, Vector2i(6, 13))
|
||||
, mGrid(window, glm::ivec2{6, 13})
|
||||
, mGameQueue(gameQueue)
|
||||
{
|
||||
addChild(&mBackground);
|
||||
|
@ -38,100 +38,100 @@ GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue<FileDa
|
|||
// Header.
|
||||
mTitle = std::make_shared<TextComponent>(mWindow, "MIXIMAGE OFFLINE GENERATOR",
|
||||
Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mTitle, Vector2i(0, 0), false, true, Vector2i(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),
|
||||
0x777777FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mStatus, Vector2i(0, 1), false, true, Vector2i(6, 1));
|
||||
mGrid.setEntry(mStatus, glm::ivec2{0, 1}, false, true, glm::ivec2{6, 1});
|
||||
|
||||
mGameCounter = std::make_shared<TextComponent>(
|
||||
mWindow,
|
||||
std::to_string(mGamesProcessed) + " OF " + std::to_string(mTotalGames) +
|
||||
(mTotalGames == 1 ? " GAME " : " GAMES ") + "PROCESSED",
|
||||
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mGameCounter, Vector2i(0, 2), false, true, Vector2i(6, 1));
|
||||
mGrid.setEntry(mGameCounter, glm::ivec2{0, 2}, false, true, glm::ivec2{6, 1});
|
||||
|
||||
// Spacer row with top border.
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), Vector2i(0, 3), false, false,
|
||||
Vector2i(6, 1), GridFlags::BORDER_TOP);
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{0, 3}, false, false,
|
||||
glm::ivec2{6, 1}, GridFlags::BORDER_TOP);
|
||||
|
||||
// Left spacer.
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), Vector2i(0, 4), false, false,
|
||||
Vector2i(1, 7));
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{0, 4}, false, false,
|
||||
glm::ivec2{1, 7});
|
||||
|
||||
// Generated label.
|
||||
mGeneratedLbl = std::make_shared<TextComponent>(
|
||||
mWindow, "Generated:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||
mGrid.setEntry(mGeneratedLbl, Vector2i(1, 4), false, true, Vector2i(1, 1));
|
||||
mGrid.setEntry(mGeneratedLbl, glm::ivec2{1, 4}, false, true, glm::ivec2{1, 1});
|
||||
|
||||
// Generated value/counter.
|
||||
mGeneratedVal =
|
||||
std::make_shared<TextComponent>(mWindow, std::to_string(mGamesProcessed),
|
||||
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||
mGrid.setEntry(mGeneratedVal, Vector2i(2, 4), false, true, Vector2i(1, 1));
|
||||
mGrid.setEntry(mGeneratedVal, glm::ivec2{2, 4}, false, true, glm::ivec2{1, 1});
|
||||
|
||||
// Overwritten label.
|
||||
mOverwrittenLbl = std::make_shared<TextComponent>(
|
||||
mWindow, "Overwritten:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||
mGrid.setEntry(mOverwrittenLbl, Vector2i(1, 5), false, true, Vector2i(1, 1));
|
||||
mGrid.setEntry(mOverwrittenLbl, glm::ivec2{1, 5}, false, true, glm::ivec2{1, 1});
|
||||
|
||||
// Overwritten value/counter.
|
||||
mOverwrittenVal =
|
||||
std::make_shared<TextComponent>(mWindow, std::to_string(mImagesOverwritten),
|
||||
Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||
mGrid.setEntry(mOverwrittenVal, Vector2i(2, 5), false, true, Vector2i(1, 1));
|
||||
mGrid.setEntry(mOverwrittenVal, glm::ivec2{2, 5}, false, true, glm::ivec2{1, 1});
|
||||
|
||||
// Skipping label.
|
||||
mSkippedLbl = std::make_shared<TextComponent>(
|
||||
mWindow, "Skipped (existing):", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||
mGrid.setEntry(mSkippedLbl, Vector2i(1, 6), false, true, Vector2i(1, 1));
|
||||
mGrid.setEntry(mSkippedLbl, glm::ivec2{1, 6}, false, true, glm::ivec2{1, 1});
|
||||
|
||||
// Skipping value/counter.
|
||||
mSkippedVal = std::make_shared<TextComponent>(
|
||||
mWindow, std::to_string(mGamesSkipped), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||
mGrid.setEntry(mSkippedVal, Vector2i(2, 6), false, true, Vector2i(1, 1));
|
||||
mGrid.setEntry(mSkippedVal, glm::ivec2{2, 6}, false, true, glm::ivec2{1, 1});
|
||||
|
||||
// Failed label.
|
||||
mFailedLbl = std::make_shared<TextComponent>(mWindow, "Failed:", Font::get(FONT_SIZE_SMALL),
|
||||
0x888888FF, ALIGN_LEFT);
|
||||
mGrid.setEntry(mFailedLbl, Vector2i(1, 7), false, true, Vector2i(1, 1));
|
||||
mGrid.setEntry(mFailedLbl, glm::ivec2{1, 7}, false, true, glm::ivec2{1, 1});
|
||||
|
||||
// Failed value/counter.
|
||||
mFailedVal = std::make_shared<TextComponent>(
|
||||
mWindow, std::to_string(mGamesFailed), Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||
mGrid.setEntry(mFailedVal, Vector2i(2, 7), false, true, Vector2i(1, 1));
|
||||
mGrid.setEntry(mFailedVal, glm::ivec2{2, 7}, false, true, glm::ivec2{1, 1});
|
||||
|
||||
// Processing label.
|
||||
mProcessingLbl = std::make_shared<TextComponent>(
|
||||
mWindow, "Processing: ", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||
mGrid.setEntry(mProcessingLbl, Vector2i(3, 4), false, true, Vector2i(1, 1));
|
||||
mGrid.setEntry(mProcessingLbl, glm::ivec2{3, 4}, false, true, glm::ivec2{1, 1});
|
||||
|
||||
// Processing value.
|
||||
mProcessingVal = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_SMALL),
|
||||
0x888888FF, ALIGN_LEFT);
|
||||
mGrid.setEntry(mProcessingVal, Vector2i(4, 4), false, true, Vector2i(1, 1));
|
||||
mGrid.setEntry(mProcessingVal, glm::ivec2{4, 4}, false, true, glm::ivec2{1, 1});
|
||||
|
||||
// Spacer row.
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), Vector2i(1, 8), false, false,
|
||||
Vector2i(4, 1));
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{1, 8}, false, false,
|
||||
glm::ivec2{4, 1});
|
||||
|
||||
// Last error message label.
|
||||
mLastErrorLbl = std::make_shared<TextComponent>(
|
||||
mWindow, "Last error message:", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_LEFT);
|
||||
mGrid.setEntry(mLastErrorLbl, Vector2i(1, 9), false, true, Vector2i(4, 1));
|
||||
mGrid.setEntry(mLastErrorLbl, glm::ivec2{1, 9}, false, true, glm::ivec2{4, 1});
|
||||
|
||||
// Last error message value.
|
||||
mLastErrorVal = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_SMALL),
|
||||
0x888888FF, ALIGN_LEFT);
|
||||
mGrid.setEntry(mLastErrorVal, Vector2i(1, 10), false, true, Vector2i(4, 1));
|
||||
mGrid.setEntry(mLastErrorVal, glm::ivec2{1, 10}, false, true, glm::ivec2{4, 1});
|
||||
|
||||
// Right spacer.
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), Vector2i(5, 4), false, false,
|
||||
Vector2i(1, 7));
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{5, 4}, false, false,
|
||||
glm::ivec2{1, 7});
|
||||
|
||||
// Spacer row with bottom border.
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), Vector2i(0, 11), false, false,
|
||||
Vector2i(6, 1), GridFlags::BORDER_BOTTOM);
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{0, 11}, false, false,
|
||||
glm::ivec2{6, 1}, GridFlags::BORDER_BOTTOM);
|
||||
|
||||
// Buttons.
|
||||
std::vector<std::shared_ptr<ButtonComponent>> buttons;
|
||||
|
@ -177,7 +177,7 @@ GuiOfflineGenerator::GuiOfflineGenerator(Window* window, const std::queue<FileDa
|
|||
buttons.push_back(mCloseButton);
|
||||
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
||||
|
||||
mGrid.setEntry(mButtonGrid, Vector2i(0, 12), true, false, Vector2i(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
|
||||
// width rather than the 85% allowed for wider displays.
|
||||
|
@ -203,7 +203,7 @@ GuiOfflineGenerator::~GuiOfflineGenerator()
|
|||
|
||||
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.
|
||||
mGrid.setRowHeightPerc(0, mTitle->getFont()->getLetterHeight() * 1.9725f / mSize.y, false);
|
||||
|
|
|
@ -28,7 +28,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
|
|||
bool approveResults)
|
||||
: GuiComponent(window)
|
||||
, mBackground(window, ":/graphics/frame.svg")
|
||||
, mGrid(window, Vector2i(1, 5))
|
||||
, mGrid(window, glm::ivec2{1, 5})
|
||||
, mSearchQueue(searches)
|
||||
, mApproveResults(approveResults)
|
||||
{
|
||||
|
@ -47,15 +47,15 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
|
|||
// Set up grid.
|
||||
mTitle = std::make_shared<TextComponent>(mWindow, "SCRAPING IN PROGRESS",
|
||||
Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mTitle, Vector2i(0, 0), false, true);
|
||||
mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true);
|
||||
|
||||
mSystem = std::make_shared<TextComponent>(mWindow, "SYSTEM", Font::get(FONT_SIZE_MEDIUM),
|
||||
0x777777FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mSystem, Vector2i(0, 1), false, true);
|
||||
mGrid.setEntry(mSystem, glm::ivec2{0, 1}, false, true);
|
||||
|
||||
mSubtitle = std::make_shared<TextComponent>(
|
||||
mWindow, "subtitle text", Font::get(FONT_SIZE_SMALL), 0x888888FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mSubtitle, Vector2i(0, 2), false, true);
|
||||
mGrid.setEntry(mSubtitle, glm::ivec2{0, 2}, false, true);
|
||||
|
||||
if (mApproveResults && !Settings::getInstance()->getBool("ScraperSemiautomatic"))
|
||||
mSearchComp = std::make_shared<GuiScraperSearch>(
|
||||
|
@ -70,7 +70,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
|
|||
std::bind(&GuiScraperMulti::acceptResult, this, std::placeholders::_1));
|
||||
mSearchComp->setSkipCallback(std::bind(&GuiScraperMulti::skip, this));
|
||||
mSearchComp->setCancelCallback(std::bind(&GuiScraperMulti::finish, this));
|
||||
mGrid.setEntry(mSearchComp, Vector2i(0, 3),
|
||||
mGrid.setEntry(mSearchComp, glm::ivec2{0, 3},
|
||||
mSearchComp->getSearchType() != GuiScraperSearch::ALWAYS_ACCEPT_FIRST_RESULT,
|
||||
true);
|
||||
|
||||
|
@ -102,7 +102,7 @@ GuiScraperMulti::GuiScraperMulti(Window* window,
|
|||
std::bind(&GuiScraperMulti::finish, this)));
|
||||
|
||||
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
||||
mGrid.setEntry(mButtonGrid, Vector2i(0, 4), true, false);
|
||||
mGrid.setEntry(mButtonGrid, glm::ivec2{0, 4}, true, false);
|
||||
|
||||
// Limit the width of the GUI on ultrawide monitors. The 1.778 aspect ratio value is
|
||||
// the 16:9 reference.
|
||||
|
@ -130,7 +130,7 @@ GuiScraperMulti::~GuiScraperMulti()
|
|||
|
||||
void GuiScraperMulti::onSizeChanged()
|
||||
{
|
||||
mBackground.fitTo(mSize, glm::vec3({}), glm::vec2(-32.0f, -32.0f));
|
||||
mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
||||
|
||||
mGrid.setRowHeightPerc(0, mTitle->getFont()->getLetterHeight() * 1.9725f / mSize.y, false);
|
||||
mGrid.setRowHeightPerc(1, (mSystem->getFont()->getLetterHeight() + 2.0f) / mSize.y, false);
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int scrapeCount)
|
||||
: GuiComponent(window)
|
||||
, mGrid(window, Vector2i(4, 3))
|
||||
, mGrid(window, glm::ivec2{4, 3})
|
||||
, mBusyAnim(window)
|
||||
, mSearchType(type)
|
||||
, mScrapeCount(scrapeCount)
|
||||
|
@ -54,8 +54,8 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int
|
|||
mRetryCount = 0;
|
||||
|
||||
// Left spacer (empty component, needed for borders).
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), Vector2i(0, 0), false, false,
|
||||
Vector2i(1, 3), GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM);
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{0, 0}, false, false,
|
||||
glm::ivec2{1, 3}, GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM);
|
||||
|
||||
// Selected result name.
|
||||
mResultName = std::make_shared<TextComponent>(mWindow, "Result name",
|
||||
|
@ -63,7 +63,7 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int
|
|||
|
||||
// Selected result thumbnail.
|
||||
mResultThumbnail = std::make_shared<ImageComponent>(mWindow);
|
||||
mGrid.setEntry(mResultThumbnail, Vector2i(1, 1), false, false, Vector2i(1, 1));
|
||||
mGrid.setEntry(mResultThumbnail, glm::ivec2{1, 1}, false, false, glm::ivec2{1, 1});
|
||||
|
||||
// Selected result description and container.
|
||||
mDescContainer = std::make_shared<ScrollableContainer>(mWindow);
|
||||
|
@ -87,14 +87,14 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int
|
|||
mMD_ReleaseDate = std::make_shared<DateTimeEditComponent>(mWindow);
|
||||
mMD_ReleaseDate->setColor(mdColor);
|
||||
mMD_ReleaseDate->setUppercase(true);
|
||||
mMD_Developer = std::make_shared<TextComponent>(
|
||||
mWindow, "", font, mdColor, ALIGN_LEFT, glm::vec3({}), glm::vec2({}), 0x00000000, 0.02f);
|
||||
mMD_Publisher = std::make_shared<TextComponent>(
|
||||
mWindow, "", font, mdColor, ALIGN_LEFT, glm::vec3({}), glm::vec2({}), 0x00000000, 0.02f);
|
||||
mMD_Genre = std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT,
|
||||
glm::vec3({}), glm::vec2({}), 0x00000000, 0.02f);
|
||||
mMD_Developer = std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT,
|
||||
glm::vec3{}, glm::vec2{}, 0x00000000, 0.02f);
|
||||
mMD_Publisher = std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT,
|
||||
glm::vec3{}, glm::vec2{}, 0x00000000, 0.02f);
|
||||
mMD_Genre = std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT, glm::vec3{},
|
||||
glm::vec2{}, 0x00000000, 0.02f);
|
||||
mMD_Players = std::make_shared<TextComponent>(mWindow, "", font, mdColor, ALIGN_LEFT,
|
||||
glm::vec3({}), glm::vec2({}), 0x00000000, 0.02f);
|
||||
glm::vec3{}, glm::vec2{}, 0x00000000, 0.02f);
|
||||
mMD_Filler = std::make_shared<TextComponent>(mWindow, "", font, mdColor);
|
||||
|
||||
if (Settings::getInstance()->getString("Scraper") != "thegamesdb")
|
||||
|
@ -123,15 +123,15 @@ GuiScraperSearch::GuiScraperSearch(Window* window, SearchType type, unsigned int
|
|||
std::make_shared<TextComponent>(mWindow, "", font, mdLblColor), mMD_Filler));
|
||||
|
||||
mMD_Grid = std::make_shared<ComponentGrid>(
|
||||
mWindow, Vector2i(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;
|
||||
for (auto it = mMD_Pairs.cbegin(); it != mMD_Pairs.cend(); it++) {
|
||||
mMD_Grid->setEntry(it->first, Vector2i(0, i), false, true);
|
||||
mMD_Grid->setEntry(it->second, Vector2i(1, i), false, it->resize);
|
||||
mMD_Grid->setEntry(it->first, glm::ivec2{0, i}, false, true);
|
||||
mMD_Grid->setEntry(it->second, glm::ivec2{1, i}, false, it->resize);
|
||||
i += 2;
|
||||
}
|
||||
|
||||
mGrid.setEntry(mMD_Grid, Vector2i(2, 1), false, false);
|
||||
mGrid.setEntry(mMD_Grid, glm::ivec2{2, 1}, false, false);
|
||||
|
||||
// Result list.
|
||||
mResultList = std::make_shared<ComponentList>(mWindow);
|
||||
|
@ -229,7 +229,7 @@ void GuiScraperSearch::onSizeChanged()
|
|||
mResultDesc->setSize(mDescContainer->getSize().x, 0.0f);
|
||||
|
||||
// Set the width of mResultName to the cell width so that text abbreviation will work correctly.
|
||||
glm::vec2 resultNameSize = mResultName->getSize();
|
||||
glm::vec2 resultNameSize{mResultName->getSize()};
|
||||
mResultName->setSize(mGrid.getColWidth(3), resultNameSize.y);
|
||||
|
||||
mGrid.onSizeChanged();
|
||||
|
@ -288,30 +288,30 @@ void GuiScraperSearch::updateViewStyle()
|
|||
// Add them back depending on search type.
|
||||
if (mSearchType == ALWAYS_ACCEPT_FIRST_RESULT) {
|
||||
// Show name.
|
||||
mGrid.setEntry(mResultName, Vector2i(1, 0), false, false, Vector2i(2, 1),
|
||||
mGrid.setEntry(mResultName, glm::ivec2{1, 0}, false, false, glm::ivec2{2, 1},
|
||||
GridFlags::BORDER_TOP);
|
||||
|
||||
// Need a border on the bottom left.
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), Vector2i(0, 2), false, false,
|
||||
Vector2i(3, 1), GridFlags::BORDER_BOTTOM);
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{0, 2}, false, false,
|
||||
glm::ivec2{3, 1}, GridFlags::BORDER_BOTTOM);
|
||||
|
||||
// Show description on the right.
|
||||
mGrid.setEntry(mDescContainer, Vector2i(3, 0), false, false, Vector2i(1, 3),
|
||||
mGrid.setEntry(mDescContainer, glm::ivec2{3, 0}, false, false, glm::ivec2{1, 3},
|
||||
GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM);
|
||||
// Make description text wrap at edge of container.
|
||||
mResultDesc->setSize(mDescContainer->getSize().x, 0.0f);
|
||||
}
|
||||
else {
|
||||
// Fake row where name would be.
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), Vector2i(1, 0), false, true,
|
||||
Vector2i(2, 1), GridFlags::BORDER_TOP);
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), glm::ivec2{1, 0}, false, true,
|
||||
glm::ivec2{2, 1}, GridFlags::BORDER_TOP);
|
||||
|
||||
// Show result list on the right.
|
||||
mGrid.setEntry(mResultList, Vector2i(3, 0), true, true, Vector2i(1, 3),
|
||||
mGrid.setEntry(mResultList, glm::ivec2{3, 0}, true, true, glm::ivec2{1, 3},
|
||||
GridFlags::BORDER_LEFT | GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM);
|
||||
|
||||
// Show description under image/info.
|
||||
mGrid.setEntry(mDescContainer, Vector2i(1, 2), false, false, Vector2i(2, 1),
|
||||
mGrid.setEntry(mDescContainer, glm::ivec2{1, 2}, false, false, glm::ivec2{2, 1},
|
||||
GridFlags::BORDER_BOTTOM);
|
||||
// Make description text wrap at edge of container.
|
||||
mResultDesc->setSize(mDescContainer->getSize().x, 0);
|
||||
|
@ -562,7 +562,7 @@ bool GuiScraperSearch::input(InputConfig* config, Input input)
|
|||
|
||||
void GuiScraperSearch::render(const glm::mat4& parentTrans)
|
||||
{
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
|
||||
renderChildren(trans);
|
||||
Renderer::drawRect(0.0f, 0.0f, mSize.x, mSize.y, 0x00000009, 0x00000009);
|
||||
|
|
|
@ -170,7 +170,7 @@ void GuiSettings::addEditableTextComponent(const std::string label,
|
|||
|
||||
auto bracket = std::make_shared<ImageComponent>(mWindow);
|
||||
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);
|
||||
|
||||
// OK callback (apply new value to ed).
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
|
||||
const std::map<std::string, generate_scraper_requests_func> scraper_request_funcs{
|
||||
{"thegamesdb", &thegamesdb_generate_json_scraper_requests},
|
||||
{ "screenscraper", &screenscraper_generate_scraper_requests }
|
||||
};
|
||||
{"screenscraper", &screenscraper_generate_scraper_requests}};
|
||||
|
||||
std::unique_ptr<ScraperSearchHandle> startScraperSearch(const ScraperSearchParams& params)
|
||||
{
|
||||
|
|
|
@ -127,8 +127,7 @@ const std::map<PlatformId, unsigned short> screenscraper_platformid_map {
|
|||
{THOMSON_MOTO, 141},
|
||||
{UZEBOX, 216},
|
||||
{SPECTRAVIDEO, 218},
|
||||
{ PALM_OS, 219 }
|
||||
};
|
||||
{PALM_OS, 219}};
|
||||
|
||||
// Helper XML parsing method, finding a node-by-name recursively.
|
||||
pugi::xml_node find_node_by_name_re(const pugi::xml_node& node,
|
||||
|
@ -333,8 +332,7 @@ void ScreenScraperRequest::processGame(const pugi::xml_document& xmldoc,
|
|||
Utils::String::toLower(Settings::getInstance()->getString("ScraperLanguage"));
|
||||
|
||||
// Name fallback: US, WOR(LD). (Xpath: Data/jeu[0]/noms/nom[*]).
|
||||
result.mdl.set("name",
|
||||
find_child_by_attribute_list(game.child("noms"), "nom", "region",
|
||||
result.mdl.set("name", find_child_by_attribute_list(game.child("noms"), "nom", "region",
|
||||
{region, "wor", "us", "ss", "eu", "jp"})
|
||||
.text()
|
||||
.get());
|
||||
|
@ -411,8 +409,8 @@ void ScreenScraperRequest::processGame(const pugi::xml_document& xmldoc,
|
|||
}
|
||||
|
||||
// Genre fallback language: EN. (Xpath: Data/jeu[0]/genres/genre[*]).
|
||||
std::string genre = find_child_by_attribute_list(game.child("genres"), "genre", "langue",
|
||||
{ language, "en" })
|
||||
std::string genre =
|
||||
find_child_by_attribute_list(game.child("genres"), "genre", "langue", {language, "en"})
|
||||
.text()
|
||||
.get();
|
||||
if (!genre.empty()) {
|
||||
|
@ -482,8 +480,7 @@ void ScreenScraperRequest::processMedia(ScraperSearchResult& result,
|
|||
}
|
||||
else {
|
||||
// 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)
|
||||
break;
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ void SystemView::populate()
|
|||
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()};
|
||||
e.data.logo->setPosition(denormalized.x, denormalized.y, 0.0f);
|
||||
|
||||
// Make background extras.
|
||||
|
@ -401,7 +401,7 @@ void SystemView::render(const glm::mat4& parentTrans)
|
|||
if (size() == 0)
|
||||
return; // Nothing to render.
|
||||
|
||||
glm::mat4 trans = getTransform() * parentTrans;
|
||||
glm::mat4 trans{getTransform() * parentTrans};
|
||||
|
||||
renderExtras(trans, INT16_MIN, INT16_MAX);
|
||||
|
||||
|
@ -475,17 +475,17 @@ void SystemView::getViewElements(const std::shared_ptr<ThemeData>& theme)
|
|||
void SystemView::renderCarousel(const glm::mat4& trans)
|
||||
{
|
||||
// Background box behind logos.
|
||||
glm::mat4 carouselTrans = trans;
|
||||
glm::mat4 carouselTrans{trans};
|
||||
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,
|
||||
glm::vec3(mCarousel.origin.x * mCarousel.size.x * -1.0f,
|
||||
mCarousel.origin.y * mCarousel.size.y * -1.0f, 0.0f));
|
||||
glm::vec3{mCarousel.origin.x * mCarousel.size.x * -1.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(
|
||||
Vector2i(static_cast<int>(clipPos.x), static_cast<int>(clipPos.y)),
|
||||
Vector2i(static_cast<int>(mCarousel.size.x), static_cast<int>(mCarousel.size.y)));
|
||||
glm::ivec2{static_cast<int>(clipPos.x), static_cast<int>(clipPos.y)},
|
||||
glm::ivec2{static_cast<int>(mCarousel.size.x), static_cast<int>(mCarousel.size.y)});
|
||||
|
||||
Renderer::setMatrix(carouselTrans);
|
||||
Renderer::drawRect(0.0f, 0.0f, mCarousel.size.x, mCarousel.size.y, mCarousel.color,
|
||||
|
@ -493,7 +493,7 @@ void SystemView::renderCarousel(const glm::mat4& trans)
|
|||
|
||||
// Draw logos.
|
||||
// Note: logoSpacing will also include the size of the logo itself.
|
||||
glm::vec2 logoSpacing(0.0f, 0.0f);
|
||||
glm::vec2 logoSpacing{};
|
||||
float xOff = 0.0f;
|
||||
float yOff = 0.0f;
|
||||
|
||||
|
@ -569,9 +569,9 @@ void SystemView::renderCarousel(const glm::mat4& trans)
|
|||
while (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::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;
|
||||
|
||||
|
@ -600,10 +600,10 @@ void SystemView::renderExtras(const glm::mat4& trans, float lower, float upper)
|
|||
int extrasCenter = static_cast<int>(mExtrasCamOffset);
|
||||
|
||||
// Adding texture loading buffers depending on scrolling speed and status.
|
||||
int bufferIndex = getScrollingVelocity() + 1;
|
||||
int bufferIndex{getScrollingVelocity() + 1};
|
||||
|
||||
Renderer::pushClipRect(Vector2i::Zero(),
|
||||
Vector2i(static_cast<int>(mSize.x), static_cast<int>(mSize.y)));
|
||||
Renderer::pushClipRect(glm::ivec2{},
|
||||
glm::ivec2{static_cast<int>(mSize.x), static_cast<int>(mSize.y)});
|
||||
|
||||
for (int i = extrasCenter + logoBuffersLeft[bufferIndex];
|
||||
i <= extrasCenter + logoBuffersRight[bufferIndex]; i++) {
|
||||
|
@ -615,17 +615,17 @@ void SystemView::renderExtras(const glm::mat4& trans, float lower, float upper)
|
|||
|
||||
// Only render selected system when not showing.
|
||||
if (mShowing || index == mCursor) {
|
||||
glm::mat4 extrasTrans = trans;
|
||||
glm::mat4 extrasTrans{trans};
|
||||
if (mCarousel.type == HORIZONTAL || mCarousel.type == HORIZONTAL_WHEEL)
|
||||
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
|
||||
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(
|
||||
Vector2i(static_cast<int>(extrasTrans[3].x), static_cast<int>(extrasTrans[3].y)),
|
||||
Vector2i(static_cast<int>(mSize.x), static_cast<int>(mSize.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)});
|
||||
SystemViewData data = mEntries.at(index).data;
|
||||
for (unsigned int j = 0; j < data.backgroundExtras.size(); j++) {
|
||||
GuiComponent* extra = data.backgroundExtras[j];
|
||||
|
|
|
@ -58,9 +58,7 @@ private:
|
|||
int mPassKeyCounter;
|
||||
|
||||
// These are Xbox button names, so they may be different in pracise on non-Xbox controllers.
|
||||
const std::vector<std::string> mInputVals = {
|
||||
"up", "down", "left", "right", "a", "b", "x", "y"
|
||||
};
|
||||
const std::vector<std::string> mInputVals = {"up", "down", "left", "right", "a", "b", "x", "y"};
|
||||
};
|
||||
|
||||
#endif // ES_APP_VIEWS_UI_MODE_CONTROLLER_H
|
||||
|
|
|
@ -285,7 +285,7 @@ int ViewController::getSystemId(SystemData* system)
|
|||
void ViewController::restoreViewPosition()
|
||||
{
|
||||
if (mPreviousView) {
|
||||
glm::vec3 restorePosition = mPreviousView->getPosition();
|
||||
glm::vec3 restorePosition{mPreviousView->getPosition()};
|
||||
restorePosition.x = mWrapPreviousPositionX;
|
||||
mPreviousView->setPosition(restorePosition);
|
||||
mWrapPreviousPositionX = 0;
|
||||
|
@ -458,9 +458,9 @@ void ViewController::goToGameList(SystemData* system)
|
|||
// 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.
|
||||
if (wrapFirstToLast) {
|
||||
glm::vec3 currentPosition = mCurrentView->getPosition();
|
||||
glm::vec3 currentPosition{mCurrentView->getPosition()};
|
||||
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.
|
||||
if (SystemData::sSystemVector.size() == 2 && mNextSystem)
|
||||
offsetX -= Renderer::getScreenWidth();
|
||||
|
@ -472,9 +472,9 @@ void ViewController::goToGameList(SystemData* system)
|
|||
mWrappedViews = true;
|
||||
}
|
||||
else if (wrapLastToFirst) {
|
||||
glm::vec3 currentPosition = mCurrentView->getPosition();
|
||||
glm::vec3 currentPosition{mCurrentView->getPosition()};
|
||||
mWrapPreviousPositionX = currentPosition.x;
|
||||
float offsetX = getGameListView(system)->getPosition().x;
|
||||
float offsetX{getGameListView(system)->getPosition().x};
|
||||
if (SystemData::sSystemVector.size() == 2 && !mNextSystem)
|
||||
offsetX += Renderer::getScreenWidth();
|
||||
else
|
||||
|
@ -537,7 +537,7 @@ void ViewController::playViewTransition(bool instant)
|
|||
if (target == static_cast<glm::vec3>(-mCamera[3]) && !isAnimationPlaying(0))
|
||||
return;
|
||||
|
||||
std::string transition_style = Settings::getInstance()->getString("TransitionStyle");
|
||||
std::string transition_style{Settings::getInstance()->getString("TransitionStyle")};
|
||||
|
||||
if (instant || transition_style == "instant") {
|
||||
setAnimation(new LambdaAnimation(
|
||||
|
@ -854,13 +854,12 @@ void ViewController::update(int deltaTime)
|
|||
|
||||
void ViewController::render(const glm::mat4& parentTrans)
|
||||
{
|
||||
glm::mat4 trans = mCamera * parentTrans;
|
||||
glm::mat4 transInverse;
|
||||
transInverse = glm::inverse(trans);
|
||||
glm::mat4 trans{mCamera * parentTrans};
|
||||
glm::mat4 transInverse{glm::inverse(trans)};
|
||||
|
||||
// Camera position, position + size.
|
||||
glm::vec3 viewStart = transInverse[3];
|
||||
glm::vec3 viewEnd = { std::fabs(trans[3].x) + static_cast<float>(Renderer::getScreenWidth()),
|
||||
glm::vec3 viewStart{transInverse[3]};
|
||||
glm::vec3 viewEnd{std::fabs(trans[3].x) + static_cast<float>(Renderer::getScreenWidth()),
|
||||
std::fabs(trans[3].y) + static_cast<float>(Renderer::getScreenHeight()),
|
||||
0.0f};
|
||||
|
||||
|
@ -877,9 +876,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.
|
||||
if (it->second == mCurrentView || (it->second == mPreviousView && isCameraMoving())) {
|
||||
// Clipping.
|
||||
glm::vec3 guiStart = it->second->getPosition();
|
||||
glm::vec3 guiEnd = it->second->getPosition() +
|
||||
glm::vec3(it->second->getSize().x, it->second->getSize().y, 0.0f);
|
||||
glm::vec3 guiStart{it->second->getPosition()};
|
||||
glm::vec3 guiEnd{it->second->getPosition() +
|
||||
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 &&
|
||||
guiStart.y <= viewEnd.y)
|
||||
|
|
|
@ -145,10 +145,9 @@ void DetailedGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& them
|
|||
initMDLabels();
|
||||
std::vector<TextComponent*> labels = getMDLabels();
|
||||
assert(labels.size() == 8);
|
||||
std::vector<std::string> lblElements = { "md_lbl_rating", "md_lbl_releasedate",
|
||||
"md_lbl_developer", "md_lbl_publisher",
|
||||
"md_lbl_genre", "md_lbl_players",
|
||||
"md_lbl_lastplayed", "md_lbl_playcount" };
|
||||
std::vector<std::string> lblElements = {
|
||||
"md_lbl_rating", "md_lbl_releasedate", "md_lbl_developer", "md_lbl_publisher",
|
||||
"md_lbl_genre", "md_lbl_players", "md_lbl_lastplayed", "md_lbl_playcount"};
|
||||
|
||||
for (unsigned int i = 0; i < labels.size(); i++)
|
||||
labels[i]->applyTheme(theme, getName(), lblElements[i], ALL);
|
||||
|
@ -187,7 +186,7 @@ void DetailedGameListView::initMDLabels()
|
|||
const unsigned int colCount = 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 rowPadding = 0.01f * mSize.y;
|
||||
|
@ -196,12 +195,12 @@ void DetailedGameListView::initMDLabels()
|
|||
const unsigned int row = i % rowCount;
|
||||
glm::vec3 pos{};
|
||||
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 {
|
||||
// Work from the last component.
|
||||
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));
|
||||
|
@ -231,7 +230,7 @@ void DetailedGameListView::initMDValues()
|
|||
for (unsigned int i = 0; i < labels.size(); i++) {
|
||||
const float heightDiff = (labels[i]->getSize().y - values[i]->getSize().y) / 2.0f;
|
||||
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]->setDefaultZIndex(40.0f);
|
||||
|
||||
|
|
|
@ -244,10 +244,9 @@ void GridGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
|||
initMDLabels();
|
||||
std::vector<TextComponent*> labels = getMDLabels();
|
||||
assert(labels.size() == 8);
|
||||
std::vector<std::string> lblElements = { "md_lbl_rating", "md_lbl_releasedate",
|
||||
"md_lbl_developer", "md_lbl_publisher",
|
||||
"md_lbl_genre", "md_lbl_players",
|
||||
"md_lbl_lastplayed", "md_lbl_playcount" };
|
||||
std::vector<std::string> lblElements = {
|
||||
"md_lbl_rating", "md_lbl_releasedate", "md_lbl_developer", "md_lbl_publisher",
|
||||
"md_lbl_genre", "md_lbl_players", "md_lbl_lastplayed", "md_lbl_playcount"};
|
||||
|
||||
for (unsigned int i = 0; i < labels.size(); i++)
|
||||
labels[i]->applyTheme(theme, getName(), lblElements[i], ALL);
|
||||
|
@ -277,7 +276,7 @@ void GridGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
|||
|
||||
mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT);
|
||||
// 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);
|
||||
else
|
||||
mGamelistInfo.setVisible(true);
|
||||
|
@ -298,7 +297,7 @@ void GridGameListView::initMDLabels()
|
|||
const unsigned int colCount = 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 rowPadding = 0.01f * mSize.y;
|
||||
|
@ -307,12 +306,12 @@ void GridGameListView::initMDLabels()
|
|||
const unsigned int row = i % rowCount;
|
||||
glm::vec3 pos{};
|
||||
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 {
|
||||
// Work from the last component.
|
||||
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));
|
||||
|
@ -342,7 +341,7 @@ void GridGameListView::initMDValues()
|
|||
for (unsigned int i = 0; i < labels.size(); i++) {
|
||||
const float heightDiff = (labels[i]->getSize().y - values[i]->getSize().y) / 2.0f;
|
||||
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]->setDefaultZIndex(40.0f);
|
||||
|
||||
|
|
|
@ -62,15 +62,15 @@ HelpStyle IGameListView::getHelpStyle()
|
|||
|
||||
void IGameListView::render(const glm::mat4& parentTrans)
|
||||
{
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
|
||||
float scaleX = trans[0].x;
|
||||
float scaleY = trans[1].y;
|
||||
|
||||
Vector2i pos(static_cast<int>(std::round(trans[3].x)),
|
||||
static_cast<int>(std::round(trans[3].y)));
|
||||
Vector2i size(static_cast<int>(std::round(mSize.x * scaleX)),
|
||||
static_cast<int>(std::round(mSize.y * scaleY)));
|
||||
glm::ivec2 pos{static_cast<int>(std::round(trans[3].x)),
|
||||
static_cast<int>(std::round(trans[3].y))};
|
||||
glm::ivec2 size{static_cast<int>(std::round(mSize.x * scaleX)),
|
||||
static_cast<int>(std::round(mSize.y * scaleY))};
|
||||
|
||||
Renderer::pushClipRect(pos, size);
|
||||
renderChildren(trans);
|
||||
|
|
|
@ -167,10 +167,9 @@ void VideoGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
|||
initMDLabels();
|
||||
std::vector<TextComponent*> labels = getMDLabels();
|
||||
assert(labels.size() == 8);
|
||||
std::vector<std::string> lblElements = { "md_lbl_rating", "md_lbl_releasedate",
|
||||
"md_lbl_developer", "md_lbl_publisher",
|
||||
"md_lbl_genre", "md_lbl_players",
|
||||
"md_lbl_lastplayed", "md_lbl_playcount" };
|
||||
std::vector<std::string> lblElements = {
|
||||
"md_lbl_rating", "md_lbl_releasedate", "md_lbl_developer", "md_lbl_publisher",
|
||||
"md_lbl_genre", "md_lbl_players", "md_lbl_lastplayed", "md_lbl_playcount"};
|
||||
|
||||
for (unsigned int i = 0; i < labels.size(); i++)
|
||||
labels[i]->applyTheme(theme, getName(), lblElements[i], ALL);
|
||||
|
@ -194,7 +193,7 @@ void VideoGameListView::onThemeChanged(const std::shared_ptr<ThemeData>& theme)
|
|||
|
||||
mGamelistInfo.applyTheme(theme, getName(), "gamelistInfo", ALL ^ ThemeFlags::TEXT);
|
||||
// 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);
|
||||
else
|
||||
mGamelistInfo.setVisible(true);
|
||||
|
@ -209,7 +208,7 @@ void VideoGameListView::initMDLabels()
|
|||
const unsigned int colCount = 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 rowPadding = 0.01f * mSize.y;
|
||||
|
@ -218,12 +217,12 @@ void VideoGameListView::initMDLabels()
|
|||
const unsigned int row = i % rowCount;
|
||||
glm::vec3 pos{};
|
||||
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 {
|
||||
// Work from the last component.
|
||||
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));
|
||||
|
@ -253,7 +252,7 @@ void VideoGameListView::initMDValues()
|
|||
for (unsigned int i = 0; i < labels.size(); i++) {
|
||||
const float heightDiff = (labels[i]->getSize().y - values[i]->getSize().y) / 2.0f;
|
||||
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]->setDefaultZIndex(40.0f);
|
||||
|
||||
|
|
|
@ -83,7 +83,7 @@ void GuiComponent::render(const glm::mat4& parentTrans)
|
|||
if (!isVisible())
|
||||
return;
|
||||
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
renderChildren(trans);
|
||||
}
|
||||
|
||||
|
@ -95,26 +95,26 @@ void GuiComponent::renderChildren(const glm::mat4& transform) const
|
|||
|
||||
void GuiComponent::setPosition(float x, float y, float z)
|
||||
{
|
||||
mPosition = glm::vec3(x, y, z);
|
||||
mPosition = glm::vec3{x, y, z};
|
||||
onPositionChanged();
|
||||
}
|
||||
|
||||
void GuiComponent::setOrigin(float x, float y)
|
||||
{
|
||||
mOrigin = glm::vec2(x, y);
|
||||
mOrigin = glm::vec2{x, y};
|
||||
onOriginChanged();
|
||||
}
|
||||
|
||||
void GuiComponent::setSize(float w, float h)
|
||||
{
|
||||
mSize = glm::vec2(w, h);
|
||||
mSize = glm::vec2{w, h};
|
||||
onSizeChanged();
|
||||
}
|
||||
|
||||
glm::vec2 GuiComponent::getCenter() const
|
||||
{
|
||||
return glm::vec2(mPosition.x - (getSize().x * mOrigin.x) + getSize().x / 2.0f,
|
||||
mPosition.y - (getSize().y * mOrigin.y) + getSize().y / 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};
|
||||
}
|
||||
|
||||
void GuiComponent::addChild(GuiComponent* cmp)
|
||||
|
@ -177,27 +177,27 @@ const glm::mat4& GuiComponent::getTransform()
|
|||
mTransform = glm::translate(mTransform, mPosition);
|
||||
|
||||
if (mScale != 1.0f)
|
||||
mTransform = glm::scale(mTransform, glm::vec3(mScale));
|
||||
mTransform = glm::scale(mTransform, glm::vec3{mScale});
|
||||
|
||||
if (mRotation != 0.0f) {
|
||||
// Calculate offset as difference between origin and rotation origin.
|
||||
glm::vec2 rotationSize = getRotationSize();
|
||||
float xOff = (mOrigin.x - mRotationOrigin.x) * rotationSize.x;
|
||||
float yOff = (mOrigin.y - mRotationOrigin.y) * rotationSize.y;
|
||||
glm::vec2 rotationSize{getRotationSize()};
|
||||
float xOff{(mOrigin.x - mRotationOrigin.x) * rotationSize.x};
|
||||
float yOff{(mOrigin.y - mRotationOrigin.y) * rotationSize.y};
|
||||
|
||||
// Transform to offset point.
|
||||
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.
|
||||
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.
|
||||
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::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;
|
||||
}
|
||||
|
@ -302,9 +302,9 @@ void GuiComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
const std::string& element,
|
||||
unsigned int properties)
|
||||
{
|
||||
glm::vec2 scale = getParent() ? getParent()->getSize() :
|
||||
glm::vec2(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()));
|
||||
glm::vec2 scale{getParent() ? getParent()->getSize() :
|
||||
glm::vec2{static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight())}};
|
||||
|
||||
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "");
|
||||
if (!elem)
|
||||
|
@ -312,8 +312,8 @@ void GuiComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
|
||||
using namespace ThemeFlags;
|
||||
if (properties & POSITION && elem->has("pos")) {
|
||||
glm::vec2 denormalized = elem->get<glm::vec2>("pos") * scale;
|
||||
setPosition(glm::vec3(denormalized.x, denormalized.y, 0.0f));
|
||||
glm::vec2 denormalized{elem->get<glm::vec2>("pos") * scale};
|
||||
setPosition(glm::vec3{denormalized.x, denormalized.y, 0.0f});
|
||||
}
|
||||
|
||||
if (properties & ThemeFlags::SIZE && elem->has("size"))
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
// By default, just calls renderChildren(parentTrans * getTransform())
|
||||
// Normally the following steps are required:
|
||||
// 1. Calculate the new transform that your component will draw at
|
||||
// glm::mat4 trans = parentTrans * getTransform();
|
||||
// glm::mat4 trans {parentTrans * getTransform()};
|
||||
// 2. Set the renderer to use that new transform as the model matrix
|
||||
// Renderer::setMatrix(trans);
|
||||
// 3. Draw your component
|
||||
|
@ -83,7 +83,7 @@ public:
|
|||
// (e.g. (0, 0) is top left, (0.5, 0.5) is the center.)
|
||||
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); }
|
||||
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
HelpStyle::HelpStyle()
|
||||
{
|
||||
position =
|
||||
glm::vec2(Renderer::getScreenWidth() * 0.012f, Renderer::getScreenHeight() * 0.9515f);
|
||||
origin = glm::vec2(0.0f, 0.0f);
|
||||
glm::vec2{Renderer::getScreenWidth() * 0.012f, Renderer::getScreenHeight() * 0.9515f};
|
||||
origin = glm::vec2{};
|
||||
iconColor = 0x777777FF;
|
||||
textColor = 0x777777FF;
|
||||
|
||||
|
@ -33,8 +33,8 @@ void HelpStyle::applyTheme(const std::shared_ptr<ThemeData>& theme, const std::s
|
|||
|
||||
if (elem->has("pos"))
|
||||
position = elem->get<glm::vec2>("pos") *
|
||||
glm::vec2(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()));
|
||||
glm::vec2{static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight())};
|
||||
|
||||
if (elem->has("origin"))
|
||||
origin = elem->get<glm::vec2>("origin");
|
||||
|
|
|
@ -53,8 +53,7 @@ private:
|
|||
{LogError, "Error"},
|
||||
{LogWarning, "Warn"},
|
||||
{LogInfo, "Info"},
|
||||
{ LogDebug, "Debug" }
|
||||
};
|
||||
{LogDebug, "Debug"}};
|
||||
|
||||
static LogLevel reportingLevel;
|
||||
LogLevel messageLevel;
|
||||
|
|
|
@ -24,11 +24,9 @@
|
|||
std::vector<std::string> ThemeData::sSupportedViews{{"all"}, {"system"}, {"basic"},
|
||||
{"detailed"}, {"grid"}, {"video"}};
|
||||
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>> ThemeData::sElementMap{
|
||||
{"image",
|
||||
{{"pos", NORMALIZED_PAIR},
|
||||
{"size", NORMALIZED_PAIR},
|
||||
|
@ -191,8 +189,7 @@ std::map<std::string, std::map<std::string, ThemeData::ElementPropertyType>>
|
|||
{"logoSize", NORMALIZED_PAIR},
|
||||
{"logoAlignment", STRING},
|
||||
{"maxLogoCount", FLOAT},
|
||||
{ "zIndex", FLOAT } } }
|
||||
};
|
||||
{"zIndex", FLOAT}}}};
|
||||
|
||||
#define MINIMUM_THEME_FORMAT_VERSION 3
|
||||
#define CURRENT_THEME_FORMAT_VERSION 6
|
||||
|
@ -454,16 +451,16 @@ void ThemeData::parseElement(const pugi::xml_node& root,
|
|||
|
||||
auto splits = Utils::String::delimitedStringToVector(str, " ");
|
||||
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(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) {
|
||||
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(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;
|
||||
|
@ -475,11 +472,11 @@ void ThemeData::parseElement(const pugi::xml_node& root,
|
|||
throw error << "invalid normalized pair (property \"" << node.name()
|
||||
<< "\", value \"" << str.c_str() << "\")";
|
||||
|
||||
std::string first = str.substr(0, divider);
|
||||
std::string second = str.substr(divider, std::string::npos);
|
||||
std::string first{str.substr(0, divider)};
|
||||
std::string second{str.substr(divider, std::string::npos)};
|
||||
|
||||
glm::vec2 val(static_cast<float>(atof(first.c_str())),
|
||||
static_cast<float>(atof(second.c_str())));
|
||||
glm::vec2 val{static_cast<float>(atof(first.c_str())),
|
||||
static_cast<float>(atof(second.c_str()))};
|
||||
|
||||
element.properties[node.name()] = val;
|
||||
break;
|
||||
|
|
|
@ -105,8 +105,8 @@ public:
|
|||
void operator=(const glm::vec4& value)
|
||||
{
|
||||
r = value;
|
||||
const glm::vec4 initVector = value;
|
||||
v = glm::vec2(initVector.x, initVector.y);
|
||||
const glm::vec4 initVector{value};
|
||||
v = glm::vec2{initVector.x, initVector.y};
|
||||
}
|
||||
void operator=(const glm::vec2& value) { v = value; }
|
||||
void operator=(const std::string& value) { s = value; }
|
||||
|
|
|
@ -349,7 +349,7 @@ void Window::update(int deltaTime)
|
|||
|
||||
void Window::render()
|
||||
{
|
||||
glm::mat4 trans = Renderer::getIdentity();
|
||||
glm::mat4 trans{Renderer::getIdentity()};
|
||||
|
||||
mRenderedHelpPrompts = false;
|
||||
|
||||
|
@ -475,7 +475,7 @@ void Window::render()
|
|||
if (Settings::getInstance()->getString("MenuOpeningEffect") == "scale-up") {
|
||||
if (mTopScale < 1.0f) {
|
||||
mTopScale = Math::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->setPosition({topCenter.x, topCenter.y, 0.0f});
|
||||
top->setScale(mTopScale);
|
||||
|
@ -499,7 +499,7 @@ void Window::render()
|
|||
static_cast<float>(Renderer::getScreenHeight()),
|
||||
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.y = (Renderer::getScreenHeight() - offset.y) * 0.5f;
|
||||
|
||||
|
@ -558,7 +558,7 @@ void Window::render()
|
|||
|
||||
void Window::renderLoadingScreen(std::string text)
|
||||
{
|
||||
glm::mat4 trans = Renderer::getIdentity();
|
||||
glm::mat4 trans{Renderer::getIdentity()};
|
||||
Renderer::setMatrix(trans);
|
||||
Renderer::drawRect(0.0f, 0.0f, static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()), 0x000000FF, 0x000000FF);
|
||||
|
@ -575,7 +575,7 @@ void Window::renderLoadingScreen(std::string text)
|
|||
|
||||
float x = std::round((Renderer::getScreenWidth() - cache->metrics.size.x) / 2.0f);
|
||||
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);
|
||||
font->renderTextCache(cache);
|
||||
delete cache;
|
||||
|
|
|
@ -25,7 +25,7 @@ const AnimationDef BUSY_ANIMATION_DEF = { BUSY_ANIMATION_FRAMES, 4, true };
|
|||
BusyComponent::BusyComponent(Window* window)
|
||||
: GuiComponent(window)
|
||||
, mBackground(window, ":/graphics/frame.png")
|
||||
, mGrid(window, Vector2i(5, 3))
|
||||
, mGrid(window, glm::ivec2{5, 3})
|
||||
{
|
||||
mAnimation = std::make_shared<AnimatedImageComponent>(mWindow);
|
||||
mAnimation->load(&BUSY_ANIMATION_DEF);
|
||||
|
@ -33,8 +33,8 @@ BusyComponent::BusyComponent(Window* window)
|
|||
0x777777FF);
|
||||
|
||||
// Col 0 = animation, col 1 = spacer, col 2 = text.
|
||||
mGrid.setEntry(mAnimation, Vector2i(1, 1), false, true);
|
||||
mGrid.setEntry(mText, Vector2i(3, 1), false, true);
|
||||
mGrid.setEntry(mAnimation, glm::ivec2{1, 1}, false, true);
|
||||
mGrid.setEntry(mText, glm::ivec2{3, 1}, false, true);
|
||||
|
||||
addChild(&mBackground);
|
||||
addChild(&mGrid);
|
||||
|
@ -58,11 +58,11 @@ void BusyComponent::onSizeChanged()
|
|||
|
||||
mGrid.setRowHeightPerc(1, textHeight / mSize.y);
|
||||
|
||||
mBackground.setCornerSize({ 16.0f * Renderer::getScreenWidthModifier(),
|
||||
16.0f * Renderer::getScreenHeightModifier() });
|
||||
mBackground.fitTo(glm::vec2(mGrid.getColWidth(1) + mGrid.getColWidth(2) + mGrid.getColWidth(3),
|
||||
textHeight + (2.0f * Renderer::getScreenHeightModifier())),
|
||||
mAnimation->getPosition(), glm::vec2(0.0f, 0.0f));
|
||||
mBackground.setCornerSize(
|
||||
{16.0f * Renderer::getScreenWidthModifier(), 16.0f * Renderer::getScreenHeightModifier()});
|
||||
mBackground.fitTo(glm::vec2{mGrid.getColWidth(1) + mGrid.getColWidth(2) + mGrid.getColWidth(3),
|
||||
textHeight + (2.0f * Renderer::getScreenHeightModifier())},
|
||||
mAnimation->getPosition(), glm::vec2{});
|
||||
}
|
||||
|
||||
void BusyComponent::reset()
|
||||
|
|
|
@ -32,7 +32,7 @@ ButtonComponent::ButtonComponent(Window* window,
|
|||
void ButtonComponent::onSizeChanged()
|
||||
{
|
||||
// Fit to mBox.
|
||||
mBox.fitTo(mSize, glm::vec3({}), glm::vec2(-32.0f, -32.0f));
|
||||
mBox.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
||||
}
|
||||
|
||||
bool ButtonComponent::input(InputConfig* config, Input input)
|
||||
|
@ -95,13 +95,13 @@ void ButtonComponent::updateImage()
|
|||
|
||||
void ButtonComponent::render(const glm::mat4& parentTrans)
|
||||
{
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
|
||||
mBox.render(trans);
|
||||
|
||||
if (mTextCache) {
|
||||
glm::vec3 centerOffset((mSize.x - mTextCache->metrics.size.x) / 2.0f,
|
||||
(mSize.y - mTextCache->metrics.size.y) / 2.0f, 0.0f);
|
||||
glm::vec3 centerOffset{(mSize.x - mTextCache->metrics.size.x) / 2.0f,
|
||||
(mSize.y - mTextCache->metrics.size.y) / 2.0f, 0.0f};
|
||||
trans = glm::translate(trans, centerOffset);
|
||||
|
||||
if (Settings::getInstance()->getBool("DebugText")) {
|
||||
|
|
|
@ -12,21 +12,21 @@
|
|||
|
||||
using namespace GridFlags;
|
||||
|
||||
ComponentGrid::ComponentGrid(Window* window, const Vector2i& gridDimensions)
|
||||
ComponentGrid::ComponentGrid(Window* window, const glm::ivec2& gridDimensions)
|
||||
: GuiComponent(window)
|
||||
, mGridSize(gridDimensions)
|
||||
, mCursor(0, 0)
|
||||
{
|
||||
assert(gridDimensions.x() > 0 && gridDimensions.y() > 0);
|
||||
assert(gridDimensions.x > 0 && gridDimensions.y > 0);
|
||||
|
||||
mCells.reserve(gridDimensions.x() * gridDimensions.y());
|
||||
mCells.reserve(gridDimensions.x * gridDimensions.y);
|
||||
|
||||
mColWidths = new float[gridDimensions.x()];
|
||||
mRowHeights = new float[gridDimensions.y()];
|
||||
mColWidths = new float[gridDimensions.x];
|
||||
mRowHeights = new float[gridDimensions.y];
|
||||
|
||||
for (int x = 0; x < gridDimensions.x(); x++)
|
||||
for (int x = 0; x < gridDimensions.x; x++)
|
||||
mColWidths[x] = 0;
|
||||
for (int y = 0; y < gridDimensions.y(); y++)
|
||||
for (int y = 0; y < gridDimensions.y; y++)
|
||||
mRowHeights[y] = 0;
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ float ComponentGrid::getColWidth(int col)
|
|||
// Calculate automatic width.
|
||||
float freeWidthPerc = 1;
|
||||
int between = 0;
|
||||
for (int x = 0; x < mGridSize.x(); x++) {
|
||||
for (int x = 0; x < mGridSize.x; x++) {
|
||||
freeWidthPerc -= mColWidths[x]; // If it's 0 it won't do anything.
|
||||
if (mColWidths[x] == 0)
|
||||
between++;
|
||||
|
@ -61,7 +61,7 @@ float ComponentGrid::getRowHeight(int row)
|
|||
// Calculate automatic height.
|
||||
float freeHeightPerc = 1;
|
||||
int between = 0;
|
||||
for (int y = 0; y < mGridSize.y(); y++) {
|
||||
for (int y = 0; y < mGridSize.y; y++) {
|
||||
freeHeightPerc -= mRowHeights[y]; // If it's 0 it won't do anything.
|
||||
if (mRowHeights[y] == 0)
|
||||
between++;
|
||||
|
@ -72,7 +72,7 @@ float ComponentGrid::getRowHeight(int row)
|
|||
|
||||
void ComponentGrid::setColWidthPerc(int col, float width, bool update)
|
||||
{
|
||||
assert(col >= 0 && col < mGridSize.x());
|
||||
assert(col >= 0 && col < mGridSize.x);
|
||||
mColWidths[col] = width;
|
||||
|
||||
if (update)
|
||||
|
@ -82,7 +82,7 @@ void ComponentGrid::setColWidthPerc(int col, float width, bool update)
|
|||
void ComponentGrid::setRowHeightPerc(int row, float height, bool update)
|
||||
{
|
||||
assert(height >= 0 && height <= 1);
|
||||
assert(row >= 0 && row < mGridSize.y());
|
||||
assert(row >= 0 && row < mGridSize.y);
|
||||
mRowHeights[row] = height;
|
||||
|
||||
if (update)
|
||||
|
@ -90,14 +90,14 @@ void ComponentGrid::setRowHeightPerc(int row, float height, bool update)
|
|||
}
|
||||
|
||||
void ComponentGrid::setEntry(const std::shared_ptr<GuiComponent>& comp,
|
||||
const Vector2i& pos,
|
||||
const glm::ivec2& pos,
|
||||
bool canFocus,
|
||||
bool resize,
|
||||
const Vector2i& size,
|
||||
const glm::ivec2& size,
|
||||
unsigned int border,
|
||||
GridFlags::UpdateType updateType)
|
||||
{
|
||||
assert(pos.x() >= 0 && pos.x() < mGridSize.x() && pos.y() >= 0 && pos.y() < mGridSize.y());
|
||||
assert(pos.x >= 0 && pos.x < mGridSize.x && pos.y >= 0 && pos.y < mGridSize.y);
|
||||
assert(comp != nullptr);
|
||||
assert(comp->getParent() == nullptr);
|
||||
|
||||
|
@ -132,10 +132,10 @@ bool ComponentGrid::removeEntry(const std::shared_ptr<GuiComponent>& comp)
|
|||
void ComponentGrid::updateCellComponent(const GridEntry& cell)
|
||||
{
|
||||
// Size.
|
||||
glm::vec2 size(0.0f, 0.0f);
|
||||
for (int x = cell.pos.x(); x < cell.pos.x() + cell.dim.x(); x++)
|
||||
glm::vec2 size{0.0f};
|
||||
for (int x = cell.pos.x; x < cell.pos.x + cell.dim.x; 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);
|
||||
|
||||
if (cell.resize)
|
||||
|
@ -143,9 +143,9 @@ void ComponentGrid::updateCellComponent(const GridEntry& cell)
|
|||
|
||||
// Find top left corner.
|
||||
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);
|
||||
for (int y = 0; y < cell.pos.y(); y++)
|
||||
for (int y = 0; y < cell.pos.y; y++)
|
||||
pos.y += getRowHeight(y);
|
||||
|
||||
// Center component.
|
||||
|
@ -169,18 +169,18 @@ void ComponentGrid::updateSeparators()
|
|||
continue;
|
||||
|
||||
// Find component position + size.
|
||||
pos = glm::vec2(0.0f, 0.0f);
|
||||
size = glm::vec2(0.0f, 0.0f);
|
||||
for (int x = 0; x < it->pos.x(); x++)
|
||||
pos = glm::vec2{};
|
||||
size = glm::vec2{};
|
||||
for (int x = 0; x < it->pos.x; x++)
|
||||
pos[0] += getColWidth(x);
|
||||
for (int y = 0; y < it->pos.y(); y++)
|
||||
for (int y = 0; y < it->pos.y; y++)
|
||||
pos[1] += getRowHeight(y);
|
||||
for (int x = it->pos.x(); x < it->pos.x() + it->dim.x(); x++)
|
||||
for (int x = it->pos.x; x < it->pos.x + it->dim.x; x++)
|
||||
size[0] += getColWidth(x);
|
||||
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);
|
||||
|
||||
if (size == glm::vec2({}))
|
||||
if (size == glm::vec2{})
|
||||
return;
|
||||
|
||||
if (it->border & BORDER_TOP || drawAll) {
|
||||
|
@ -228,13 +228,13 @@ void ComponentGrid::onSizeChanged()
|
|||
|
||||
const ComponentGrid::GridEntry* ComponentGrid::getCellAt(int x, int y) const
|
||||
{
|
||||
assert(x >= 0 && x < mGridSize.x() && y >= 0 && y < mGridSize.y());
|
||||
assert(x >= 0 && x < mGridSize.x && y >= 0 && y < mGridSize.y);
|
||||
|
||||
for (auto it = mCells.cbegin(); it != mCells.cend(); it++) {
|
||||
int xmin = it->pos.x();
|
||||
int xmax = xmin + it->dim.x();
|
||||
int ymin = it->pos.y();
|
||||
int ymax = ymin + it->dim.y();
|
||||
int xmin = it->pos.x;
|
||||
int xmax = xmin + it->dim.x;
|
||||
int ymin = it->pos.y;
|
||||
int ymax = ymin + it->dim.y;
|
||||
|
||||
if (x >= xmin && y >= ymin && x < xmax && y < ymax)
|
||||
return &(*it);
|
||||
|
@ -253,16 +253,16 @@ bool ComponentGrid::input(InputConfig* config, Input input)
|
|||
return false;
|
||||
|
||||
if (config->isMappedLike("down", input))
|
||||
return moveCursor(Vector2i(0, 1));
|
||||
return moveCursor(glm::ivec2{0, 1});
|
||||
|
||||
if (config->isMappedLike("up", input))
|
||||
return moveCursor(Vector2i(0, -1));
|
||||
return moveCursor(glm::ivec2{0, -1});
|
||||
|
||||
if (config->isMappedLike("left", input))
|
||||
return moveCursor(Vector2i(-1, 0));
|
||||
return moveCursor(glm::ivec2{-1, 0});
|
||||
|
||||
if (config->isMappedLike("right", input))
|
||||
return moveCursor(Vector2i(1, 0));
|
||||
return moveCursor(glm::ivec2{1, 0});
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ void ComponentGrid::resetCursor()
|
|||
|
||||
for (auto it = mCells.cbegin(); it != mCells.cend(); it++) {
|
||||
if (it->canFocus) {
|
||||
Vector2i origCursor = mCursor;
|
||||
glm::ivec2 origCursor = mCursor;
|
||||
mCursor = it->pos;
|
||||
onCursorMoved(origCursor, mCursor);
|
||||
break;
|
||||
|
@ -282,23 +282,22 @@ void ComponentGrid::resetCursor()
|
|||
}
|
||||
}
|
||||
|
||||
bool ComponentGrid::moveCursor(Vector2i dir)
|
||||
bool ComponentGrid::moveCursor(glm::ivec2 dir)
|
||||
{
|
||||
assert(dir.x() || dir.y());
|
||||
assert(dir.x || dir.y);
|
||||
|
||||
const Vector2i origCursor = mCursor;
|
||||
const glm::ivec2 origCursor{mCursor};
|
||||
const GridEntry* currentCursorEntry = getCellAt(mCursor);
|
||||
Vector2i searchAxis(dir.x() == 0, dir.y() == 0);
|
||||
glm::ivec2 searchAxis(dir.x == 0, dir.y == 0);
|
||||
|
||||
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;
|
||||
Vector2i curDirPos = mCursor;
|
||||
glm::ivec2 curDirPos{mCursor};
|
||||
const GridEntry* cursorEntry;
|
||||
|
||||
// Spread out on search axis+
|
||||
while (mCursor.x() < mGridSize.x() && mCursor.y() < mGridSize.y() && mCursor.x() >= 0 &&
|
||||
mCursor.y() >= 0) {
|
||||
while (mCursor.x < mGridSize.x && mCursor.y < mGridSize.y && mCursor.x >= 0 &&
|
||||
mCursor.y >= 0) {
|
||||
cursorEntry = getCellAt(mCursor);
|
||||
if (cursorEntry && cursorEntry->canFocus && cursorEntry != currentCursorEntry) {
|
||||
onCursorMoved(origCursor, mCursor);
|
||||
|
@ -309,8 +308,8 @@ bool ComponentGrid::moveCursor(Vector2i dir)
|
|||
|
||||
// Now again on search axis-
|
||||
mCursor = curDirPos;
|
||||
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) {
|
||||
cursorEntry = getCellAt(mCursor);
|
||||
|
||||
if (cursorEntry && cursorEntry->canFocus && cursorEntry != currentCursorEntry) {
|
||||
|
@ -361,7 +360,7 @@ void ComponentGrid::update(int deltaTime)
|
|||
|
||||
void ComponentGrid::render(const glm::mat4& parentTrans)
|
||||
{
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
|
||||
renderChildren(trans);
|
||||
|
||||
|
@ -380,7 +379,7 @@ void ComponentGrid::textInput(const std::string& text)
|
|||
selectedEntry->component->textInput(text);
|
||||
}
|
||||
|
||||
void ComponentGrid::onCursorMoved(Vector2i from, Vector2i to)
|
||||
void ComponentGrid::onCursorMoved(glm::ivec2 from, glm::ivec2 to)
|
||||
{
|
||||
const GridEntry* cell = getCellAt(from);
|
||||
if (cell)
|
||||
|
@ -397,7 +396,7 @@ void ComponentGrid::setCursorTo(const std::shared_ptr<GuiComponent>& comp)
|
|||
{
|
||||
for (auto it = mCells.cbegin(); it != mCells.cend(); it++) {
|
||||
if (it->component == comp) {
|
||||
Vector2i oldCursor = mCursor;
|
||||
glm::ivec2 oldCursor{mCursor};
|
||||
mCursor = it->pos;
|
||||
onCursorMoved(oldCursor, mCursor);
|
||||
return;
|
||||
|
@ -415,8 +414,8 @@ std::vector<HelpPrompt> ComponentGrid::getHelpPrompts()
|
|||
if (e)
|
||||
prompts = e->component->getHelpPrompts();
|
||||
|
||||
bool canScrollVert = mGridSize.y() > 1;
|
||||
bool canScrollHoriz = mGridSize.x() > 1;
|
||||
bool canScrollVert = mGridSize.y > 1;
|
||||
bool canScrollHoriz = mGridSize.x > 1;
|
||||
for (auto it = prompts.cbegin(); it != prompts.cend(); it++) {
|
||||
if (it->first == "up/down/left/right") {
|
||||
canScrollHoriz = false;
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#define ES_CORE_COMPONENTS_COMPONENT_GRID_H
|
||||
|
||||
#include "GuiComponent.h"
|
||||
#include "math/Vector2i.h"
|
||||
#include "renderers/Renderer.h"
|
||||
|
||||
namespace GridFlags
|
||||
|
@ -34,16 +33,16 @@ namespace GridFlags
|
|||
class ComponentGrid : public GuiComponent
|
||||
{
|
||||
public:
|
||||
ComponentGrid(Window* window, const Vector2i& gridDimensions);
|
||||
ComponentGrid(Window* window, const glm::ivec2& gridDimensions);
|
||||
virtual ~ComponentGrid();
|
||||
|
||||
bool removeEntry(const std::shared_ptr<GuiComponent>& comp);
|
||||
|
||||
void setEntry(const std::shared_ptr<GuiComponent>& comp,
|
||||
const Vector2i& pos,
|
||||
const glm::ivec2& pos,
|
||||
bool canFocus,
|
||||
bool resize = true,
|
||||
const Vector2i& size = Vector2i(1, 1),
|
||||
const glm::ivec2& size = glm::ivec2{1, 1},
|
||||
unsigned int border = GridFlags::BORDER_NONE,
|
||||
GridFlags::UpdateType updateType = GridFlags::UPDATE_ALWAYS);
|
||||
|
||||
|
@ -65,7 +64,7 @@ public:
|
|||
// Dito.
|
||||
void setRowHeightPerc(int row, float height, bool update = true);
|
||||
|
||||
bool moveCursor(Vector2i dir);
|
||||
bool moveCursor(glm::ivec2 dir);
|
||||
void setCursorTo(const std::shared_ptr<GuiComponent>& comp);
|
||||
|
||||
std::shared_ptr<GuiComponent> getSelectedComponent()
|
||||
|
@ -86,16 +85,16 @@ private:
|
|||
class GridEntry
|
||||
{
|
||||
public:
|
||||
Vector2i pos;
|
||||
Vector2i dim;
|
||||
glm::ivec2 pos;
|
||||
glm::ivec2 dim;
|
||||
std::shared_ptr<GuiComponent> component;
|
||||
bool canFocus;
|
||||
bool resize;
|
||||
GridFlags::UpdateType updateType;
|
||||
unsigned int border;
|
||||
|
||||
GridEntry(const Vector2i& p = Vector2i::Zero(),
|
||||
const Vector2i& d = Vector2i::Zero(),
|
||||
GridEntry(const glm::ivec2& p = glm::ivec2{},
|
||||
const glm::ivec2& d = glm::ivec2{},
|
||||
const std::shared_ptr<GuiComponent>& cmp = nullptr,
|
||||
bool f = false,
|
||||
bool r = true,
|
||||
|
@ -118,14 +117,14 @@ private:
|
|||
void updateCellComponent(const GridEntry& cell);
|
||||
void updateSeparators();
|
||||
|
||||
void onCursorMoved(Vector2i from, Vector2i to);
|
||||
void onCursorMoved(glm::ivec2 from, glm::ivec2 to);
|
||||
const GridEntry* getCellAt(int x, int y) const;
|
||||
const GridEntry* getCellAt(const Vector2i& pos) const { return getCellAt(pos.x(), pos.y()); }
|
||||
const GridEntry* getCellAt(const glm::ivec2& pos) const { return getCellAt(pos.x, pos.y); }
|
||||
|
||||
std::vector<std::vector<float>> mSeparators;
|
||||
Vector2i mGridSize;
|
||||
glm::ivec2 mGridSize;
|
||||
std::vector<GridEntry> mCells;
|
||||
Vector2i mCursor;
|
||||
glm::ivec2 mCursor;
|
||||
|
||||
float* mRowHeights;
|
||||
float* mColWidths;
|
||||
|
|
|
@ -172,20 +172,20 @@ void ComponentList::render(const glm::mat4& parentTrans)
|
|||
if (!size())
|
||||
return;
|
||||
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
|
||||
// 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.y = (trans[1].y * dim.y + trans[3].y) - trans[3].y;
|
||||
|
||||
Renderer::pushClipRect(
|
||||
Vector2i(static_cast<int>(std::round(trans[3].x)),
|
||||
static_cast<int>(std::round(trans[3].y))),
|
||||
Vector2i(static_cast<int>(std::round(dim.x)), static_cast<int>(std::round(dim.y))));
|
||||
glm::ivec2{static_cast<int>(std::round(trans[3].x)),
|
||||
static_cast<int>(std::round(trans[3].y))},
|
||||
glm::ivec2{static_cast<int>(std::round(dim.x)), static_cast<int>(std::round(dim.y))});
|
||||
|
||||
// Scroll the camera.
|
||||
trans = glm::translate(trans, glm::vec3(0.0f, -std::round(mCameraOffset), 0.0f));
|
||||
trans = glm::translate(trans, glm::vec3{0.0f, -std::round(mCameraOffset), 0.0f});
|
||||
|
||||
// Draw our entries.
|
||||
std::vector<GuiComponent*> drawAfterCursor;
|
||||
|
|
|
@ -156,7 +156,7 @@ void DateTimeEditComponent::update(int deltaTime)
|
|||
|
||||
void DateTimeEditComponent::render(const glm::mat4& parentTrans)
|
||||
{
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
|
||||
if (mTextCache) {
|
||||
std::shared_ptr<Font> font = getFont();
|
||||
|
@ -170,7 +170,7 @@ void DateTimeEditComponent::render(const glm::mat4& parentTrans)
|
|||
}
|
||||
|
||||
// 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)
|
||||
off.x += referenceSize - mTextCache->metrics.size.x;
|
||||
|
@ -300,22 +300,22 @@ void DateTimeEditComponent::updateTextCache()
|
|||
return;
|
||||
|
||||
// Year.
|
||||
glm::vec2 start(0.0f, 0.0f);
|
||||
glm::vec2 end = font->sizeText(dispString.substr(0, 4));
|
||||
glm::vec2 diff = end - start;
|
||||
mCursorBoxes.push_back(glm::vec4(start[0], start[1], diff[0], diff[1]));
|
||||
glm::vec2 start{};
|
||||
glm::vec2 end{font->sizeText(dispString.substr(0, 4))};
|
||||
glm::vec2 diff{end - start};
|
||||
mCursorBoxes.push_back(glm::vec4{start[0], start[1], diff[0], diff[1]});
|
||||
|
||||
// Month.
|
||||
start[0] = font->sizeText(dispString.substr(0, 5)).x;
|
||||
end = font->sizeText(dispString.substr(0, 7));
|
||||
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.
|
||||
start[0] = font->sizeText(dispString.substr(0, 8)).x;
|
||||
end = font->sizeText(dispString.substr(0, 10));
|
||||
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
|
||||
// nobody will use it anyway so it's not worthwhile implementing.
|
||||
|
|
|
@ -17,12 +17,12 @@ GridTileComponent::GridTileComponent(Window* window)
|
|||
, mBackground(window, ":/graphics/frame.png")
|
||||
{
|
||||
mDefaultProperties.mSize = getDefaultTileSize();
|
||||
mDefaultProperties.mPadding = glm::vec2(16.0f * Renderer::getScreenWidthModifier(),
|
||||
16.0f * Renderer::getScreenHeightModifier());
|
||||
mDefaultProperties.mPadding = glm::vec2{16.0f * Renderer::getScreenWidthModifier(),
|
||||
16.0f * Renderer::getScreenHeightModifier()};
|
||||
mDefaultProperties.mImageColor = 0xAAAAAABB;
|
||||
// Attempting to use frame.svg instead causes quite severe performance problems.
|
||||
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.mBackgroundEdgeColor = 0xAAAAEEFF;
|
||||
|
||||
|
@ -52,7 +52,7 @@ GridTileComponent::GridTileComponent(Window* window)
|
|||
|
||||
void GridTileComponent::render(const glm::mat4& parentTrans)
|
||||
{
|
||||
glm::mat4 trans = getTransform() * parentTrans;
|
||||
glm::mat4 trans{getTransform() * parentTrans};
|
||||
|
||||
if (mVisible)
|
||||
renderChildren(trans);
|
||||
|
@ -76,8 +76,8 @@ void GridTileComponent::update(int deltaTime)
|
|||
|
||||
void applyThemeToProperties(const ThemeData::ThemeElement* elem, GridTileProperties* properties)
|
||||
{
|
||||
glm::vec2 screen(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()));
|
||||
glm::vec2 screen{static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight())};
|
||||
|
||||
if (elem->has("size"))
|
||||
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 screen = glm::vec2(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()));
|
||||
glm::vec2 screen{glm::vec2(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()))};
|
||||
|
||||
return screen * 0.22f;
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ void GridTileComponent::setSelected(bool selected,
|
|||
resize();
|
||||
}
|
||||
else {
|
||||
mAnimPosition = glm::vec3(pPosition->x, pPosition->y, pPosition->z);
|
||||
mAnimPosition = glm::vec3{pPosition->x, pPosition->y, pPosition->z};
|
||||
|
||||
auto func = [this](float t) {
|
||||
t -= 1;
|
||||
|
|
|
@ -114,7 +114,7 @@ void HelpComponent::updateGrid()
|
|||
std::shared_ptr<Font>& font = mStyle.font;
|
||||
|
||||
mGrid = std::make_shared<ComponentGrid>(mWindow,
|
||||
Vector2i(static_cast<int>(mPrompts.size()) * 4, 1));
|
||||
glm::ivec2{static_cast<int>(mPrompts.size()) * 4, 1});
|
||||
|
||||
// [icon] [spacer1] [text] [spacer2]
|
||||
|
||||
|
@ -148,8 +148,8 @@ void HelpComponent::updateGrid()
|
|||
(ICON_TEXT_SPACING * Renderer::getScreenWidthModifier()) / width);
|
||||
mGrid->setColWidthPerc(col + 2, labels.at(i)->getSize().x / width);
|
||||
|
||||
mGrid->setEntry(icons.at(i), Vector2i(col, 0), false, false);
|
||||
mGrid->setEntry(labels.at(i), Vector2i(col + 2, 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->setPosition({mStyle.position.x, mStyle.position.y, 0.0f});
|
||||
|
@ -189,7 +189,7 @@ void HelpComponent::setOpacity(unsigned char opacity)
|
|||
|
||||
void HelpComponent::render(const glm::mat4& parentTrans)
|
||||
{
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
|
||||
if (mGrid)
|
||||
mGrid->render(trans);
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
#include "resources/TextureResource.h"
|
||||
#include "utils/CImgUtil.h"
|
||||
|
||||
Vector2i ImageComponent::getTextureSize() const
|
||||
glm::ivec2 ImageComponent::getTextureSize() const
|
||||
{
|
||||
if (mTexture)
|
||||
return mTexture->getSize();
|
||||
else
|
||||
return Vector2i::Zero();
|
||||
return glm::ivec2{};
|
||||
}
|
||||
|
||||
glm::vec2 ImageComponent::getSize() const
|
||||
|
@ -53,8 +53,8 @@ void ImageComponent::resize()
|
|||
if (!mTexture)
|
||||
return;
|
||||
|
||||
const glm::vec2 textureSize = mTexture->getSourceImageSize();
|
||||
if (textureSize == glm::vec2({}))
|
||||
const glm::vec2 textureSize{mTexture->getSourceImageSize()};
|
||||
if (textureSize == glm::vec2{})
|
||||
return;
|
||||
|
||||
if (mTexture->isTiled()) {
|
||||
|
@ -71,7 +71,7 @@ void ImageComponent::resize()
|
|||
if (mTargetIsMax) {
|
||||
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) {
|
||||
// This will be mTargetSize.x. We can't exceed it, nor be lower than it.
|
||||
|
@ -90,7 +90,7 @@ void ImageComponent::resize()
|
|||
else if (mTargetIsMin) {
|
||||
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) {
|
||||
mSize.x *= resizeScale.x;
|
||||
|
@ -114,7 +114,7 @@ void ImageComponent::resize()
|
|||
else {
|
||||
// If both components are set, we just stretch.
|
||||
// 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.
|
||||
// For SVG rasterization, we always calculate width from rounded height (see
|
||||
|
@ -177,7 +177,7 @@ void ImageComponent::setImage(const std::shared_ptr<TextureResource>& texture)
|
|||
|
||||
void ImageComponent::setResize(float width, float height)
|
||||
{
|
||||
mTargetSize = glm::vec2(width, height);
|
||||
mTargetSize = glm::vec2{width, height};
|
||||
mTargetIsMax = false;
|
||||
mTargetIsMin = false;
|
||||
resize();
|
||||
|
@ -185,7 +185,7 @@ void ImageComponent::setResize(float width, float height)
|
|||
|
||||
void ImageComponent::setMaxSize(float width, float height)
|
||||
{
|
||||
mTargetSize = glm::vec2(width, height);
|
||||
mTargetSize = glm::vec2{width, height};
|
||||
mTargetIsMax = true;
|
||||
mTargetIsMin = false;
|
||||
resize();
|
||||
|
@ -193,7 +193,7 @@ void ImageComponent::setMaxSize(float width, float height)
|
|||
|
||||
void ImageComponent::setMinSize(float width, float height)
|
||||
{
|
||||
mTargetSize = glm::vec2(width, height);
|
||||
mTargetSize = glm::vec2{width, height};
|
||||
mTargetIsMax = false;
|
||||
mTargetIsMin = true;
|
||||
resize();
|
||||
|
@ -239,7 +239,7 @@ void ImageComponent::uncrop()
|
|||
|
||||
void ImageComponent::cropTransparentPadding(float maxSizeX, float maxSizeY)
|
||||
{
|
||||
if (mSize == glm::vec2({}))
|
||||
if (mSize == glm::vec2{})
|
||||
return;
|
||||
|
||||
std::vector<unsigned char> imageRGBA = mTexture.get()->getRawRGBAData();
|
||||
|
@ -247,10 +247,10 @@ void ImageComponent::cropTransparentPadding(float maxSizeX, float maxSizeY)
|
|||
if (imageRGBA.size() == 0)
|
||||
return;
|
||||
|
||||
Vector2i imageSize = mTexture.get()->getSize();
|
||||
cimg_library::CImg<unsigned char> imageCImg(imageSize.x(), imageSize.y(), 1, 4, 0);
|
||||
glm::ivec2 imageSize{mTexture.get()->getSize()};
|
||||
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
|
||||
// the pixels (as in RGBARGBARGBA).
|
||||
|
@ -259,12 +259,12 @@ void ImageComponent::cropTransparentPadding(float maxSizeX, float maxSizeY)
|
|||
// This will give us the coordinates for the fully transparent areas.
|
||||
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 cropTop = static_cast<float>(paddingCoords[1]) / static_cast<float>(imageSize.y());
|
||||
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 cropLeft{static_cast<float>(paddingCoords[0]) / static_cast<float>(imageSize.x)};
|
||||
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 cropBottom{static_cast<float>(paddingCoords[3]) / static_cast<float>(imageSize.y)};
|
||||
|
||||
crop(cropLeft, cropTop, cropRight, cropBottom);
|
||||
|
||||
|
@ -342,10 +342,10 @@ void ImageComponent::updateVertices()
|
|||
|
||||
// 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.
|
||||
const glm::vec2 topLeft = { 0.0f, 0.0f };
|
||||
const glm::vec2 bottomRight = mSize;
|
||||
const float px = mTexture->isTiled() ? mSize.x / getTextureSize().x() : 1.0f;
|
||||
const float py = mTexture->isTiled() ? mSize.y / getTextureSize().y() : 1.0f;
|
||||
const glm::vec2 topLeft{};
|
||||
const glm::vec2 bottomRight{mSize};
|
||||
const float px{mTexture->isTiled() ? mSize.x / getTextureSize().x : 1.0f};
|
||||
const float py{mTexture->isTiled() ? mSize.y / getTextureSize().y : 1.0f};
|
||||
|
||||
// clang-format off
|
||||
mVertices[0] = {{topLeft.x, topLeft.y }, {mTopLeftCrop.x, py - mTopLeftCrop.y }, 0};
|
||||
|
@ -391,18 +391,18 @@ void ImageComponent::render(const glm::mat4& parentTrans)
|
|||
if (!isVisible())
|
||||
return;
|
||||
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
Renderer::setMatrix(trans);
|
||||
|
||||
if (mTexture && mOpacity > 0) {
|
||||
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,
|
||||
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.
|
||||
if (mTexture->isInitialized() && mTexture->getSize() != 0) {
|
||||
if (mTexture->isInitialized() && mTexture->getSize() != glm::ivec2{}) {
|
||||
// Actually draw the image.
|
||||
// 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
|
||||
|
@ -482,9 +482,9 @@ void ImageComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
if (!elem)
|
||||
return;
|
||||
|
||||
glm::vec2 scale = getParent() ? getParent()->getSize() :
|
||||
glm::vec2 scale{getParent() ? getParent()->getSize() :
|
||||
glm::vec2(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()));
|
||||
static_cast<float>(Renderer::getScreenHeight()))};
|
||||
|
||||
if (properties & ThemeFlags::SIZE) {
|
||||
if (elem->has("size"))
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#define ES_CORE_COMPONENTS_IMAGE_COMPONENT_H
|
||||
|
||||
#include "GuiComponent.h"
|
||||
#include "math/Vector2i.h"
|
||||
#include "renderers/Renderer.h"
|
||||
|
||||
class TextureResource;
|
||||
|
@ -83,7 +82,7 @@ public:
|
|||
|
||||
// Returns the size of the current texture, or (0, 0) if none is loaded.
|
||||
// May be different than drawn size (use getSize() for that).
|
||||
Vector2i getTextureSize() const;
|
||||
glm::ivec2 getTextureSize() const;
|
||||
|
||||
glm::vec2 getSize() const override;
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ private:
|
|||
glm::vec4 mPadding;
|
||||
glm::vec2 mMargin;
|
||||
glm::vec2 mTileSize;
|
||||
Vector2i mGridDimension;
|
||||
glm::ivec2 mGridDimension;
|
||||
std::shared_ptr<ThemeData> mTheme;
|
||||
std::vector<std::shared_ptr<GridTileComponent>> mTiles;
|
||||
|
||||
|
@ -126,13 +126,13 @@ template <typename T>
|
|||
ImageGridComponent<T>::ImageGridComponent(Window* window)
|
||||
: IList<ImageGridData, T>(window)
|
||||
{
|
||||
glm::vec2 screen(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()));
|
||||
glm::vec2 screen{static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight())};
|
||||
|
||||
mCamera = 0.0f;
|
||||
mCameraDirection = 1.0f;
|
||||
|
||||
mAutoLayout = glm::vec2({});
|
||||
mAutoLayout = glm::vec2{};
|
||||
mAutoLayoutZoom = 1.0f;
|
||||
|
||||
mStartPosition = 0;
|
||||
|
@ -171,7 +171,7 @@ template <typename T> bool ImageGridComponent<T>::input(InputConfig* config, Inp
|
|||
if (input.value != 0) {
|
||||
int idx = isVertical() ? 0 : 1;
|
||||
|
||||
Vector2i dir = Vector2i::Zero();
|
||||
glm::ivec2 dir{};
|
||||
if (config->isMappedLike("up", input))
|
||||
dir[1 ^ idx] = -1;
|
||||
else if (config->isMappedLike("down", input))
|
||||
|
@ -181,11 +181,11 @@ template <typename T> bool ImageGridComponent<T>::input(InputConfig* config, Inp
|
|||
else if (config->isMappedLike("right", input))
|
||||
dir[0 ^ idx] = 1;
|
||||
|
||||
if (dir != Vector2i::Zero()) {
|
||||
if (dir != glm::ivec2{}) {
|
||||
if (isVertical())
|
||||
listInput(dir.x() + dir.y() * mGridDimension.x());
|
||||
listInput(dir.x + dir.y * mGridDimension.x);
|
||||
else
|
||||
listInput(dir.x() + dir.y() * mGridDimension.y());
|
||||
listInput(dir.x + dir.y * mGridDimension.y);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -210,13 +210,13 @@ template <typename T> void ImageGridComponent<T>::update(int deltaTime)
|
|||
|
||||
template <typename T> void ImageGridComponent<T>::render(const glm::mat4& parentTrans)
|
||||
{
|
||||
glm::mat4 trans = getTransform() * parentTrans;
|
||||
glm::mat4 tileTrans = trans;
|
||||
glm::mat4 trans{getTransform() * parentTrans};
|
||||
glm::mat4 tileTrans{trans};
|
||||
|
||||
float offsetX = isVertical() ? 0.0f : mCamera * mCameraDirection * (mTileSize.x + mMargin.x);
|
||||
float offsetY = isVertical() ? mCamera * mCameraDirection * (mTileSize.y + mMargin.y) : 0.0f;
|
||||
float offsetX{isVertical() ? 0.0f : mCamera * mCameraDirection * (mTileSize.x + mMargin.x)};
|
||||
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) {
|
||||
updateTiles();
|
||||
|
@ -227,10 +227,10 @@ template <typename T> void ImageGridComponent<T>::render(const glm::mat4& parent
|
|||
float scaleX = trans[0].x;
|
||||
float scaleY = trans[1].y;
|
||||
|
||||
Vector2i pos(static_cast<int>(std::round(trans[3].x)),
|
||||
static_cast<int>(std::round(trans[3].y)));
|
||||
Vector2i size(static_cast<int>(std::round(mSize.x * scaleX)),
|
||||
static_cast<int>(std::round(mSize.y * scaleY)));
|
||||
glm::ivec2 pos{static_cast<int>(std::round(trans[3].x)),
|
||||
static_cast<int>(std::round(trans[3].y))};
|
||||
glm::ivec2 size{static_cast<int>(std::round(mSize.x * scaleX)),
|
||||
static_cast<int>(std::round(mSize.y * scaleY))};
|
||||
|
||||
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.
|
||||
mTheme = theme;
|
||||
|
||||
glm::vec2 screen(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()));
|
||||
glm::vec2 screen{static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight())};
|
||||
|
||||
const ThemeData::ThemeElement* elem = theme->getElement(view, element, "imagegrid");
|
||||
if (elem) {
|
||||
|
@ -279,7 +279,7 @@ void ImageGridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
|
||||
if (elem->has("padding"))
|
||||
mPadding =
|
||||
elem->get<glm::vec4>("padding") * glm::vec4(screen.x, screen.y, screen.x, screen.y);
|
||||
elem->get<glm::vec4>("padding") * glm::vec4{screen.x, screen.y, screen.x, screen.y};
|
||||
|
||||
if (elem->has("autoLayout"))
|
||||
mAutoLayout = elem->get<glm::vec2>("autoLayout");
|
||||
|
@ -399,8 +399,8 @@ template <typename T> void ImageGridComponent<T>::onCursorChanged(const CursorSt
|
|||
|
||||
int oldStart = mStartPosition;
|
||||
|
||||
int dimScrollable = (isVertical() ? mGridDimension.y() : mGridDimension.x()) - 2 * EXTRAITEMS;
|
||||
int dimOpposite = isVertical() ? mGridDimension.x() : mGridDimension.y();
|
||||
int dimScrollable = (isVertical() ? mGridDimension.y : mGridDimension.x) - 2 * EXTRAITEMS;
|
||||
int dimOpposite = isVertical() ? mGridDimension.x : mGridDimension.y;
|
||||
|
||||
int centralCol = static_cast<int>((static_cast<float>(dimScrollable) - 0.5f) / 2.0f);
|
||||
int maxCentralCol = dimScrollable / 2;
|
||||
|
@ -455,7 +455,7 @@ template <typename T> void ImageGridComponent<T>::onCursorChanged(const CursorSt
|
|||
}
|
||||
|
||||
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;
|
||||
|
@ -528,12 +528,11 @@ template <typename T> void ImageGridComponent<T>::buildTiles()
|
|||
calcGridDimension();
|
||||
|
||||
if (mCenterSelection) {
|
||||
int dimScrollable =
|
||||
(isVertical() ? mGridDimension.y() : mGridDimension.x()) - 2 * EXTRAITEMS;
|
||||
int dimScrollable = (isVertical() ? mGridDimension.y : mGridDimension.x) - 2 * EXTRAITEMS;
|
||||
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) {
|
||||
auto x = (mSize.x - (mMargin.x * (mAutoLayout.x - 1.0f)) - mPadding.x - mPadding.z) /
|
||||
|
@ -541,12 +540,12 @@ template <typename T> void ImageGridComponent<T>::buildTiles()
|
|||
auto y = (mSize.y - (mMargin.y * (mAutoLayout.y - 1.0f)) - mPadding.y - mPadding.w) /
|
||||
static_cast<int>(mAutoLayout.y);
|
||||
|
||||
mTileSize = glm::vec2(x, y);
|
||||
mTileSize = glm::vec2{x, y};
|
||||
tileDistance = mTileSize + mMargin;
|
||||
}
|
||||
|
||||
bool vert = isVertical();
|
||||
glm::vec2 startPosition = mTileSize / 2.0f;
|
||||
glm::vec2 startPosition{mTileSize / 2.0f};
|
||||
startPosition.x += mPadding.x;
|
||||
startPosition.y += mPadding.y;
|
||||
|
||||
|
@ -554,8 +553,8 @@ template <typename T> void ImageGridComponent<T>::buildTiles()
|
|||
int Y;
|
||||
|
||||
// Layout tile size and position.
|
||||
for (int y = 0; y < (vert ? mGridDimension.y() : mGridDimension.x()); y++) {
|
||||
for (int x = 0; x < (vert ? mGridDimension.x() : mGridDimension.y()); x++) {
|
||||
for (int y = 0; y < (vert ? mGridDimension.y : mGridDimension.x); y++) {
|
||||
for (int x = 0; x < (vert ? mGridDimension.x : mGridDimension.y); x++) {
|
||||
// Create tiles.
|
||||
auto tile = std::make_shared<GridTileComponent>(mWindow);
|
||||
|
||||
|
@ -614,7 +613,7 @@ void ImageGridComponent<T>::updateTiles(bool ascending,
|
|||
int end = ascending ? static_cast<int>(mTiles.size()) : -1;
|
||||
int img = mStartPosition + ti;
|
||||
|
||||
img -= EXTRAITEMS * (isVertical() ? mGridDimension.x() : mGridDimension.y());
|
||||
img -= EXTRAITEMS * (isVertical() ? mGridDimension.x : mGridDimension.y);
|
||||
|
||||
// Update the tiles.
|
||||
while (ti != end) {
|
||||
|
@ -674,7 +673,7 @@ void ImageGridComponent<T>::updateTileAtPos(int tilePos,
|
|||
if (idx < 0 || idx >= mTiles.size())
|
||||
idx = 0;
|
||||
|
||||
glm::vec3 pos = mTiles.at(idx)->getBackgroundPosition();
|
||||
glm::vec3 pos{mTiles.at(idx)->getBackgroundPosition()};
|
||||
tile->setSelected(true, allowAnimation, &pos);
|
||||
}
|
||||
else {
|
||||
|
@ -690,7 +689,7 @@ template <typename T> void ImageGridComponent<T>::calcGridDimension()
|
|||
{
|
||||
// grid_size = columns * tile_size + (columns - 1) * 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)
|
||||
gridDimension = mAutoLayout;
|
||||
|
@ -698,22 +697,22 @@ template <typename T> void ImageGridComponent<T>::calcGridDimension()
|
|||
mLastRowPartial = floorf(gridDimension.y) != gridDimension.y;
|
||||
|
||||
// Ceil y dim so we can display partial last row.
|
||||
mGridDimension = Vector2i(static_cast<const int>(gridDimension.x),
|
||||
static_cast<const int>(ceilf(gridDimension.y)));
|
||||
mGridDimension = glm::ivec2{static_cast<const int>(gridDimension.x),
|
||||
static_cast<const int>(ceilf(gridDimension.y))};
|
||||
|
||||
// Grid dimension validation.
|
||||
if (mGridDimension.x() < 1) {
|
||||
if (mGridDimension.x < 1) {
|
||||
LOG(LogError) << "Theme defined grid X dimension below 1";
|
||||
}
|
||||
if (mGridDimension.y() < 1) {
|
||||
if (mGridDimension.y < 1) {
|
||||
LOG(LogError) << "Theme defined grid Y dimension below 1";
|
||||
}
|
||||
|
||||
// Add extra tiles to both sides.
|
||||
if (isVertical())
|
||||
mGridDimension.y() += 2 * EXTRAITEMS;
|
||||
mGridDimension.y += 2 * EXTRAITEMS;
|
||||
else
|
||||
mGridDimension.x() += 2 * EXTRAITEMS;
|
||||
mGridDimension.x += 2 * EXTRAITEMS;
|
||||
}
|
||||
|
||||
template <typename T> bool ImageGridComponent<T>::isScrollLoop()
|
||||
|
@ -721,8 +720,8 @@ template <typename T> bool ImageGridComponent<T>::isScrollLoop()
|
|||
if (!mScrollLoop)
|
||||
return false;
|
||||
if (isVertical())
|
||||
return (mGridDimension.x() * (mGridDimension.y() - 2 * EXTRAITEMS)) <= mEntries.size();
|
||||
return (mGridDimension.y() * (mGridDimension.x() - 2 * EXTRAITEMS)) <= mEntries.size();
|
||||
return (mGridDimension.x * (mGridDimension.y - 2 * EXTRAITEMS)) <= mEntries.size();
|
||||
return (mGridDimension.y * (mGridDimension.x - 2 * EXTRAITEMS)) <= mEntries.size();
|
||||
}
|
||||
|
||||
#endif // ES_CORE_COMPONENTS_IMAGE_GRID_COMPONENT_H
|
||||
|
|
|
@ -21,7 +21,7 @@ MenuComponent::MenuComponent(Window* window,
|
|||
const std::shared_ptr<Font>& titleFont)
|
||||
: GuiComponent(window)
|
||||
, mBackground(window)
|
||||
, mGrid(window, Vector2i(1, 3))
|
||||
, mGrid(window, glm::ivec2{1, 3})
|
||||
, mNeedsSaving(false)
|
||||
{
|
||||
addChild(&mBackground);
|
||||
|
@ -34,11 +34,11 @@ MenuComponent::MenuComponent(Window* window,
|
|||
mTitle->setHorizontalAlignment(ALIGN_CENTER);
|
||||
mTitle->setColor(0x555555FF);
|
||||
setTitle(title, titleFont);
|
||||
mGrid.setEntry(mTitle, Vector2i(0, 0), false);
|
||||
mGrid.setEntry(mTitle, glm::ivec2{}, false);
|
||||
|
||||
// Set up list which will never change (externally, anyway).
|
||||
mList = std::make_shared<ComponentList>(mWindow);
|
||||
mGrid.setEntry(mList, Vector2i(0, 1), true);
|
||||
mGrid.setEntry(mList, glm::ivec2{0, 1}, true);
|
||||
|
||||
updateGrid();
|
||||
updateSize();
|
||||
|
@ -106,7 +106,7 @@ void MenuComponent::updateSize()
|
|||
|
||||
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.
|
||||
mGrid.setRowHeightPerc(0, TITLE_HEIGHT / mSize.y);
|
||||
|
@ -134,7 +134,7 @@ void MenuComponent::updateGrid()
|
|||
|
||||
if (mButtons.size()) {
|
||||
mButtonGrid = makeButtonGrid(mWindow, mButtons);
|
||||
mGrid.setEntry(mButtonGrid, Vector2i(0, 2), true, false);
|
||||
mGrid.setEntry(mButtonGrid, glm::ivec2{0, 2}, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -142,13 +142,13 @@ std::shared_ptr<ComponentGrid> makeButtonGrid(
|
|||
Window* window, const std::vector<std::shared_ptr<ButtonComponent>>& buttons)
|
||||
{
|
||||
std::shared_ptr<ComponentGrid> buttonGrid =
|
||||
std::make_shared<ComponentGrid>(window, Vector2i(static_cast<int>(buttons.size()), 2));
|
||||
std::make_shared<ComponentGrid>(window, glm::ivec2{static_cast<int>(buttons.size()), 2});
|
||||
|
||||
// Initialize to padding.
|
||||
float buttonGridWidth =
|
||||
BUTTON_GRID_HORIZ_PADDING * Renderer::getScreenWidthModifier() * buttons.size();
|
||||
for (int i = 0; i < static_cast<int>(buttons.size()); i++) {
|
||||
buttonGrid->setEntry(buttons.at(i), Vector2i(i, 0), true, false);
|
||||
buttonGrid->setEntry(buttons.at(i), glm::ivec2{i, 0}, true, false);
|
||||
buttonGridWidth += buttons.at(i)->getSize().x;
|
||||
}
|
||||
for (unsigned int i = 0; i < buttons.size(); i++)
|
||||
|
|
|
@ -61,41 +61,40 @@ void NinePatchComponent::buildVertices()
|
|||
|
||||
mTexture = TextureResource::get(mPath, false, false, true, scaleFactor);
|
||||
|
||||
if (mTexture->getSize() == Vector2i::Zero()) {
|
||||
if (mTexture->getSize() == glm::ivec2{}) {
|
||||
mVertices = nullptr;
|
||||
LOG(LogWarning) << "NinePatchComponent has no texture";
|
||||
return;
|
||||
}
|
||||
|
||||
glm::vec2 texSize;
|
||||
mVertices = new Renderer::Vertex[6 * 9];
|
||||
|
||||
texSize = glm::vec2(static_cast<float>(mTexture->getSize().x()),
|
||||
static_cast<float>(mTexture->getSize().y()));
|
||||
glm::vec2 texSize{static_cast<float>(mTexture->getSize().x),
|
||||
static_cast<float>(mTexture->getSize().y)};
|
||||
|
||||
// clang-format off
|
||||
const float imgSizeX[3] = { mCornerSize.x, mSize.x - mCornerSize.x * 2.0f, mCornerSize.x };
|
||||
const float imgSizeY[3] = { mCornerSize.y, mSize.y - mCornerSize.y * 2.0f, mCornerSize.y };
|
||||
const float imgPosX[3] = { 0, imgSizeX[0], imgSizeX[0] + imgSizeX[1] };
|
||||
const float imgPosY[3] = { 0, imgSizeY[0], imgSizeY[0] + imgSizeY[1] };
|
||||
const float imgSizeX[3]{mCornerSize.x, mSize.x - mCornerSize.x * 2.0f, mCornerSize.x};
|
||||
const float imgSizeY[3]{mCornerSize.y, mSize.y - mCornerSize.y * 2.0f, mCornerSize.y};
|
||||
const float imgPosX[3]{0, imgSizeX[0], imgSizeX[0] + imgSizeX[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
|
||||
// left corner origin vs. verticies having a top left origin.
|
||||
const float texSizeX[3] = { mCornerSize.x / texSize.x, (texSize.x - mCornerSize.x * 2.0f) / texSize.x, mCornerSize.x / texSize.x };
|
||||
const float texSizeY[3] = { -mCornerSize.y / texSize.y, -(texSize.y - mCornerSize.y * 2.0f) / texSize.y, -mCornerSize.y / texSize.y };
|
||||
const float texPosX[3] = { 0.0f, texSizeX[0], texSizeX[0] + texSizeX[1] };
|
||||
const float texPosY[3] = { 1.0f, 1.0f + texSizeY[0], 1.0f + texSizeY[0] + texSizeY[1] };
|
||||
const float texSizeX[3]{mCornerSize.x / texSize.x, (texSize.x - mCornerSize.x * 2.0f) / texSize.x, mCornerSize.x / texSize.x};
|
||||
const float texSizeY[3]{-mCornerSize.y / texSize.y, -(texSize.y - mCornerSize.y * 2.0f) / texSize.y, -mCornerSize.y / texSize.y};
|
||||
|
||||
const float texPosX[3]{0.0f, texSizeX[0], texSizeX[0] + texSizeX[1]};
|
||||
const float texPosY[3]{1.0f, 1.0f + texSizeY[0], 1.0f + texSizeY[0] + texSizeY[1]};
|
||||
// clang-format on
|
||||
|
||||
int v = 0;
|
||||
|
||||
for (int slice = 0; slice < 9; slice++) {
|
||||
const int sliceX = slice % 3;
|
||||
const int sliceY = slice / 3;
|
||||
const glm::vec2 imgPos = glm::vec2(imgPosX[sliceX], imgPosY[sliceY]);
|
||||
const glm::vec2 imgSize = glm::vec2(imgSizeX[sliceX], imgSizeY[sliceY]);
|
||||
const glm::vec2 texPos = glm::vec2(texPosX[sliceX], texPosY[sliceY]);
|
||||
const glm::vec2 texSize = glm::vec2(texSizeX[sliceX], texSizeY[sliceY]);
|
||||
const int sliceX{slice % 3};
|
||||
const int sliceY{slice / 3};
|
||||
const glm::vec2 imgPos{imgPosX[sliceX], imgPosY[sliceY]};
|
||||
const glm::vec2 imgSize{imgSizeX[sliceX], imgSizeY[sliceY]};
|
||||
const glm::vec2 texPos{texPosX[sliceX], texPosY[sliceY]};
|
||||
const glm::vec2 texSize{texSizeX[sliceX], texSizeY[sliceY]};
|
||||
|
||||
// clang-format off
|
||||
mVertices[v + 1] = {{imgPos.x , imgPos.y }, {texPos.x, texPos.y }, 0};
|
||||
|
@ -123,7 +122,7 @@ void NinePatchComponent::render(const glm::mat4& parentTrans)
|
|||
if (!isVisible())
|
||||
return;
|
||||
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
|
||||
if (mTexture && mVertices != nullptr) {
|
||||
Renderer::setMatrix(trans);
|
||||
|
@ -144,8 +143,6 @@ void NinePatchComponent::render(const glm::mat4& parentTrans)
|
|||
renderChildren(trans);
|
||||
}
|
||||
|
||||
void NinePatchComponent::onSizeChanged() { buildVertices(); }
|
||||
|
||||
void NinePatchComponent::fitTo(glm::vec2 size, glm::vec3 position, glm::vec2 padding)
|
||||
{
|
||||
size += padding;
|
||||
|
|
|
@ -37,8 +37,7 @@ public:
|
|||
|
||||
void render(const glm::mat4& parentTrans) override;
|
||||
|
||||
void onSizeChanged() override;
|
||||
|
||||
void onSizeChanged() override { buildVertices(); }
|
||||
void fitTo(glm::vec2 size, glm::vec3 position = {}, glm::vec2 padding = {});
|
||||
|
||||
void setImagePath(const std::string& path);
|
||||
|
|
|
@ -25,7 +25,7 @@ RatingComponent::RatingComponent(Window* window, bool colorizeChanges)
|
|||
mFilledTexture = TextureResource::get(":/graphics/star_filled.svg", true);
|
||||
mUnfilledTexture = TextureResource::get(":/graphics/star_unfilled.svg", true);
|
||||
mValue = 0.5f;
|
||||
mSize = glm::vec2(64.0f * NUM_RATING_STARS, 64.0f);
|
||||
mSize = glm::vec2{64.0f * NUM_RATING_STARS, 64.0f};
|
||||
updateVertices();
|
||||
updateColors();
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ void RatingComponent::render(const glm::mat4& parentTrans)
|
|||
if (!isVisible() || mFilledTexture == nullptr || mUnfilledTexture == nullptr)
|
||||
return;
|
||||
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
|
||||
Renderer::setMatrix(trans);
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
|
||||
#include "Window.h"
|
||||
#include "animations/LambdaAnimation.h"
|
||||
#include "math/Vector2i.h"
|
||||
#include "renderers/Renderer.h"
|
||||
#include "resources/Font.h"
|
||||
|
||||
|
@ -45,7 +44,7 @@ ScrollableContainer::ScrollableContainer(Window* window)
|
|||
void ScrollableContainer::setAutoScroll(bool autoScroll)
|
||||
{
|
||||
if (autoScroll) {
|
||||
mScrollDir = glm::vec2(0.0f, 1.0f);
|
||||
mScrollDir = glm::vec2{0.0f, 1.0f};
|
||||
mAutoScrollDelay = static_cast<int>(mAutoScrollDelayConstant);
|
||||
mAutoScrollSpeed = mAutoScrollSpeedConstant;
|
||||
mAutoScrollSpeed =
|
||||
|
@ -53,7 +52,7 @@ void ScrollableContainer::setAutoScroll(bool autoScroll)
|
|||
reset();
|
||||
}
|
||||
else {
|
||||
mScrollDir = glm::vec2(0.0f, 0.0f);
|
||||
mScrollDir = glm::vec2{};
|
||||
mAutoScrollDelay = 0;
|
||||
mAutoScrollSpeed = 0;
|
||||
mAutoScrollAccumulator = 0;
|
||||
|
@ -71,7 +70,7 @@ void ScrollableContainer::setScrollParameters(float autoScrollDelayConstant,
|
|||
|
||||
void ScrollableContainer::reset()
|
||||
{
|
||||
mScrollPos = glm::vec2(0.0f, 0.0f);
|
||||
mScrollPos = glm::vec2{};
|
||||
mAutoScrollResetAccumulator = 0;
|
||||
mAutoScrollAccumulator = -mAutoScrollDelay + mAutoScrollSpeed;
|
||||
mAtEnd = false;
|
||||
|
@ -82,12 +81,12 @@ void ScrollableContainer::update(int deltaTime)
|
|||
// Don't scroll if the media viewer or screensaver is active or if text scrolling is disabled;
|
||||
if (mWindow->isMediaViewerActive() || mWindow->isScreensaverActive() ||
|
||||
!mWindow->getAllowTextScrolling()) {
|
||||
if (mScrollPos != glm::vec2({}) && !mWindow->isLaunchScreenDisplayed())
|
||||
if (mScrollPos != glm::vec2{} && !mWindow->isLaunchScreenDisplayed())
|
||||
reset();
|
||||
return;
|
||||
}
|
||||
|
||||
const glm::vec2 contentSize = getContentSize();
|
||||
const glm::vec2 contentSize{getContentSize()};
|
||||
int adjustedAutoScrollSpeed = mAutoScrollSpeed;
|
||||
|
||||
// Adjust the scrolling speed based on the width of the container.
|
||||
|
@ -136,7 +135,7 @@ void ScrollableContainer::update(int deltaTime)
|
|||
// Fade in the text as it resets to the start position.
|
||||
auto func = [this](float t) {
|
||||
this->setOpacity(static_cast<unsigned char>(Math::lerp(0.0f, 1.0f, t) * 255));
|
||||
mScrollPos = glm::vec2(0.0f, 0.0f);
|
||||
mScrollPos = glm::vec2{};
|
||||
mAutoScrollResetAccumulator = 0;
|
||||
mAutoScrollAccumulator = -mAutoScrollDelay + mAutoScrollSpeed;
|
||||
mAtEnd = false;
|
||||
|
@ -153,21 +152,20 @@ void ScrollableContainer::render(const glm::mat4& parentTrans)
|
|||
if (!isVisible())
|
||||
return;
|
||||
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
|
||||
Vector2i 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{};
|
||||
|
||||
dimScaled.x = std::fabs(trans[3].x + mSize.x);
|
||||
dimScaled.y = std::fabs(trans[3].y + mSize.y);
|
||||
|
||||
Vector2i clipDim(static_cast<int>(dimScaled.x - trans[3].x),
|
||||
static_cast<int>(dimScaled.y - trans[3].y));
|
||||
glm::ivec2 clipDim{static_cast<int>(dimScaled.x - trans[3].x),
|
||||
static_cast<int>(dimScaled.y - trans[3].y)};
|
||||
|
||||
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);
|
||||
|
||||
GuiComponent::renderChildren(trans);
|
||||
|
@ -176,10 +174,10 @@ void ScrollableContainer::render(const glm::mat4& parentTrans)
|
|||
|
||||
glm::vec2 ScrollableContainer::getContentSize()
|
||||
{
|
||||
glm::vec2 max(0.0f, 0.0f);
|
||||
glm::vec2 max{};
|
||||
for (unsigned int i = 0; i < mChildren.size(); i++) {
|
||||
glm::vec2 pos(mChildren.at(i)->getPosition().x, mChildren.at(i)->getPosition().y);
|
||||
glm::vec2 bottomRight = mChildren.at(i)->getSize() + pos;
|
||||
glm::vec2 pos{mChildren.at(i)->getPosition().x, mChildren.at(i)->getPosition().y};
|
||||
glm::vec2 bottomRight{mChildren.at(i)->getSize() + pos};
|
||||
if (bottomRight.x > max.x)
|
||||
max.x = bottomRight.x;
|
||||
if (bottomRight.y > max.y)
|
||||
|
|
|
@ -76,20 +76,20 @@ void SliderComponent::update(int deltaTime)
|
|||
|
||||
void SliderComponent::render(const glm::mat4& parentTrans)
|
||||
{
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
Renderer::setMatrix(trans);
|
||||
|
||||
// Render suffix.
|
||||
if (mValueCache)
|
||||
mFont->renderTextCache(mValueCache.get());
|
||||
|
||||
float width =
|
||||
mSize.x - mKnob.getSize().x -
|
||||
(mValueCache ? mValueCache->metrics.size.x + (4.0f * Renderer::getScreenWidthModifier()) :
|
||||
0.0f);
|
||||
float width{mSize.x - mKnob.getSize().x -
|
||||
(mValueCache ?
|
||||
mValueCache->metrics.size.x + (4.0f * Renderer::getScreenWidthModifier()) :
|
||||
0.0f)};
|
||||
|
||||
// Render line.
|
||||
const float lineWidth = 2.0f * Renderer::getScreenHeightModifier();
|
||||
const float lineWidth{2.0f * Renderer::getScreenHeightModifier()};
|
||||
Renderer::drawRect(mKnob.getSize().x / 2.0f, mSize.y / 2.0f - lineWidth / 2.0f, width,
|
||||
lineWidth, 0x777777FF, 0x777777FF);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ bool SwitchComponent::input(InputConfig* config, Input input)
|
|||
|
||||
void SwitchComponent::render(const glm::mat4& parentTrans)
|
||||
{
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
mImage.render(trans);
|
||||
renderChildren(trans);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ TextComponent::TextComponent(Window* window,
|
|||
|
||||
void TextComponent::onSizeChanged()
|
||||
{
|
||||
mAutoCalcExtent = Vector2i((getSize().x == 0), (getSize().y == 0));
|
||||
mAutoCalcExtent = glm::ivec2{(getSize().x == 0), (getSize().y == 0)};
|
||||
onTextChanged();
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ void TextComponent::render(const glm::mat4& parentTrans)
|
|||
if (!isVisible())
|
||||
return;
|
||||
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
|
||||
if (mRenderBackground) {
|
||||
Renderer::setMatrix(trans);
|
||||
|
@ -128,7 +128,7 @@ void TextComponent::render(const glm::mat4& parentTrans)
|
|||
}
|
||||
|
||||
if (mTextCache) {
|
||||
const glm::vec2& textSize = mTextCache->metrics.size;
|
||||
const glm::vec2& textSize{mTextCache->metrics.size};
|
||||
float yOff = 0.0f;
|
||||
switch (mVerticalAlignment) {
|
||||
case ALIGN_TOP: {
|
||||
|
@ -147,7 +147,7 @@ void TextComponent::render(const glm::mat4& parentTrans)
|
|||
break;
|
||||
}
|
||||
}
|
||||
glm::vec3 off(0.0f, yOff, 0.0f);
|
||||
glm::vec3 off{0.0f, yOff, 0.0f};
|
||||
|
||||
if (Settings::getInstance()->getBool("DebugText")) {
|
||||
// Draw the "textbox" area, what we are aligned within.
|
||||
|
@ -189,11 +189,11 @@ void TextComponent::render(const glm::mat4& parentTrans)
|
|||
|
||||
void TextComponent::calculateExtent()
|
||||
{
|
||||
if (mAutoCalcExtent.x()) {
|
||||
if (mAutoCalcExtent.x) {
|
||||
mSize = mFont->sizeText(mUppercase ? Utils::String::toUpper(mText) : mText, mLineSpacing);
|
||||
}
|
||||
else {
|
||||
if (mAutoCalcExtent.y())
|
||||
if (mAutoCalcExtent.y)
|
||||
mSize.y = mFont
|
||||
->sizeWrappedText(mUppercase ? Utils::String::toUpper(mText) : mText,
|
||||
getSize().x, mLineSpacing)
|
||||
|
@ -223,11 +223,11 @@ void TextComponent::onTextChanged()
|
|||
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)) {
|
||||
// Abbreviate text.
|
||||
const std::string abbrev = "...";
|
||||
glm::vec2 abbrevSize = f->sizeText(abbrev);
|
||||
glm::vec2 abbrevSize{f->sizeText(abbrev)};
|
||||
// mMargin adds a margin around the text if it's abbreviated.
|
||||
float marginAdjustedSize = mSize.x - (mSize.x * mMargin);
|
||||
|
||||
|
@ -240,12 +240,12 @@ void TextComponent::onTextChanged()
|
|||
text.append(abbrev);
|
||||
|
||||
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));
|
||||
}
|
||||
else {
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ private:
|
|||
bool mRenderBackground;
|
||||
|
||||
bool mUppercase;
|
||||
Vector2i mAutoCalcExtent;
|
||||
glm::ivec2 mAutoCalcExtent;
|
||||
std::shared_ptr<TextCache> mTextCache;
|
||||
Alignment mHorizontalAlignment;
|
||||
Alignment mVerticalAlignment;
|
||||
|
|
|
@ -46,9 +46,9 @@ void TextEditComponent::onFocusLost()
|
|||
|
||||
void TextEditComponent::onSizeChanged()
|
||||
{
|
||||
mBox.fitTo(mSize, glm::vec3({}),
|
||||
glm::vec2(-34.0f + mResolutionAdjustment,
|
||||
-32.0f - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier())));
|
||||
mBox.fitTo(mSize, glm::vec3{},
|
||||
glm::vec2{-34.0f + mResolutionAdjustment,
|
||||
-32.0f - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier())});
|
||||
onTextChanged(); // Wrap point probably changed.
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ void TextEditComponent::onTextChanged()
|
|||
void TextEditComponent::onCursorChanged()
|
||||
{
|
||||
if (isMultiline()) {
|
||||
glm::vec2 textSize = mFont->getWrappedTextCursorOffset(mText, getTextAreaSize().x, mCursor);
|
||||
glm::vec2 textSize{mFont->getWrappedTextCursorOffset(mText, getTextAreaSize().x, mCursor)};
|
||||
|
||||
// Need to scroll down?
|
||||
if (mScrollOffset.y + getTextAreaSize().y < textSize.y + mFont->getHeight())
|
||||
|
@ -260,7 +260,7 @@ void TextEditComponent::onCursorChanged()
|
|||
mScrollOffset.y = textSize.y;
|
||||
}
|
||||
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)
|
||||
mScrollOffset.x = cursorPos.x - getTextAreaSize().x;
|
||||
|
@ -271,24 +271,24 @@ void TextEditComponent::onCursorChanged()
|
|||
|
||||
void TextEditComponent::render(const glm::mat4& parentTrans)
|
||||
{
|
||||
glm::mat4 trans = getTransform() * parentTrans;
|
||||
glm::mat4 trans{getTransform() * parentTrans};
|
||||
renderChildren(trans);
|
||||
|
||||
// Text + cursor rendering.
|
||||
// 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});
|
||||
|
||||
Vector2i 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.
|
||||
glm::vec3 dimScaled{};
|
||||
dimScaled.x = std::fabs(trans[3].x + getTextAreaSize().x);
|
||||
dimScaled.y = std::fabs(trans[3].y + getTextAreaSize().y);
|
||||
|
||||
Vector2i clipDim(static_cast<int>(dimScaled.x - trans[3].x),
|
||||
static_cast<int>(dimScaled.y - trans[3].y));
|
||||
glm::ivec2 clipDim{static_cast<int>(dimScaled.x - trans[3].x),
|
||||
static_cast<int>(dimScaled.y - trans[3].y)};
|
||||
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);
|
||||
|
||||
if (mTextCache)
|
||||
|
@ -317,16 +317,16 @@ void TextEditComponent::render(const glm::mat4& parentTrans)
|
|||
|
||||
glm::vec2 TextEditComponent::getTextAreaPos() const
|
||||
{
|
||||
return glm::vec2(
|
||||
return glm::vec2{
|
||||
(-mResolutionAdjustment + (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
|
||||
{
|
||||
return glm::vec2(mSize.x + mResolutionAdjustment -
|
||||
return glm::vec2{mSize.x + mResolutionAdjustment -
|
||||
(TEXT_PADDING_HORIZ * Renderer::getScreenWidthModifier()),
|
||||
mSize.y - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier()));
|
||||
mSize.y - (TEXT_PADDING_VERT * Renderer::getScreenHeightModifier())};
|
||||
}
|
||||
|
||||
std::vector<HelpPrompt> TextEditComponent::getHelpPrompts()
|
||||
|
|
|
@ -160,14 +160,14 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
|
|||
if (size() == 0)
|
||||
return;
|
||||
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
std::shared_ptr<Font>& font = mFont;
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
std::shared_ptr<Font>& font{mFont};
|
||||
|
||||
int startEntry = 0;
|
||||
float y = 0;
|
||||
int startEntry{0};
|
||||
float y{0.0f};
|
||||
|
||||
const float entrySize =
|
||||
std::max(font->getHeight(1.0), static_cast<float>(font->getSize())) * mLineSpacing;
|
||||
const float entrySize{std::max(font->getHeight(1.0), static_cast<float>(font->getSize())) *
|
||||
mLineSpacing};
|
||||
|
||||
// Number of entries that can fit on the screen simultaneously.
|
||||
int screenCount = static_cast<int>(mSize.y / entrySize + 0.5f);
|
||||
|
@ -206,13 +206,13 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
|
|||
}
|
||||
|
||||
// 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.y = (trans[1].y * dim.y + trans[3].y) - trans[3].y;
|
||||
|
||||
Renderer::pushClipRect(
|
||||
Vector2i(static_cast<int>(trans[3].x + mHorizontalMargin), static_cast<int>(trans[3].y)),
|
||||
Vector2i(static_cast<int>(dim.x - mHorizontalMargin * 2.0f), static_cast<int>(dim.y)));
|
||||
glm::ivec2{static_cast<int>(trans[3].x + mHorizontalMargin), static_cast<int>(trans[3].y)},
|
||||
glm::ivec2{static_cast<int>(dim.x - mHorizontalMargin * 2.0f), static_cast<int>(dim.y)});
|
||||
|
||||
for (int i = startEntry; i < listCutoff; i++) {
|
||||
typename IList<TextListData, T>::Entry& entry = mEntries.at(static_cast<unsigned int>(i));
|
||||
|
@ -236,7 +236,7 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
|
|||
else
|
||||
entry.data.textCache->setColor(color);
|
||||
|
||||
glm::vec3 offset(0.0f, y, 0.0f);
|
||||
glm::vec3 offset{0.0f, y, 0.0f};
|
||||
|
||||
switch (mAlignment) {
|
||||
case ALIGN_LEFT:
|
||||
|
@ -257,12 +257,12 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
|
|||
}
|
||||
|
||||
// Render text.
|
||||
glm::mat4 drawTrans = trans;
|
||||
glm::mat4 drawTrans{trans};
|
||||
|
||||
// Currently selected item text might be scrolling.
|
||||
if (mCursor == i && mMarqueeOffset > 0)
|
||||
drawTrans = glm::translate(
|
||||
drawTrans, offset - glm::vec3(static_cast<float>(mMarqueeOffset), 0.0f, 0.0f));
|
||||
drawTrans, offset - glm::vec3{static_cast<float>(mMarqueeOffset), 0.0f, 0.0f});
|
||||
else
|
||||
drawTrans = glm::translate(drawTrans, offset);
|
||||
|
||||
|
@ -278,7 +278,7 @@ template <typename T> void TextListComponent<T>::render(const glm::mat4& parentT
|
|||
mMarqueeScroll = true;
|
||||
drawTrans = trans;
|
||||
drawTrans = glm::translate(
|
||||
drawTrans, offset - glm::vec3(static_cast<float>(mMarqueeOffset2), 0.0f, 0.0f));
|
||||
drawTrans, offset - glm::vec3{static_cast<float>(mMarqueeOffset2), 0.0f, 0.0f});
|
||||
Renderer::setMatrix(drawTrans);
|
||||
font->renderTextCache(entry.data.textCache.get());
|
||||
}
|
||||
|
|
|
@ -176,7 +176,7 @@ void VideoComponent::render(const glm::mat4& parentTrans)
|
|||
if (!isVisible())
|
||||
return;
|
||||
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
GuiComponent::renderChildren(trans);
|
||||
|
||||
Renderer::setMatrix(trans);
|
||||
|
@ -223,9 +223,9 @@ void VideoComponent::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
|||
if (!elem)
|
||||
return;
|
||||
|
||||
glm::vec2 scale = getParent() ? getParent()->getSize() :
|
||||
glm::vec2(static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight()));
|
||||
glm::vec2 scale{getParent() ? getParent()->getSize() :
|
||||
glm::vec2{static_cast<float>(Renderer::getScreenWidth()),
|
||||
static_cast<float>(Renderer::getScreenHeight())}};
|
||||
|
||||
if (properties & ThemeFlags::SIZE) {
|
||||
if (elem->has("size")) {
|
||||
|
|
|
@ -57,7 +57,7 @@ VideoFFmpegComponent::~VideoFFmpegComponent() { stopVideo(); }
|
|||
void VideoFFmpegComponent::setResize(float width, float height)
|
||||
{
|
||||
// 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;
|
||||
mStaticImage.setResize(width, height);
|
||||
resize();
|
||||
|
@ -67,7 +67,7 @@ void VideoFFmpegComponent::setMaxSize(float width, float height)
|
|||
{
|
||||
// This resize function is used in most instances, such as non-stretched video screensaver
|
||||
// and the gamelist videos.
|
||||
mTargetSize = glm::vec2(width, height);
|
||||
mTargetSize = glm::vec2{width, height};
|
||||
mTargetIsMax = true;
|
||||
mStaticImage.setMaxSize(width, height);
|
||||
resize();
|
||||
|
@ -78,15 +78,15 @@ void VideoFFmpegComponent::resize()
|
|||
if (!mTexture)
|
||||
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;
|
||||
|
||||
if (mTargetIsMax) {
|
||||
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) {
|
||||
mSize.x *= resizeScale.x;
|
||||
|
@ -97,13 +97,13 @@ void VideoFFmpegComponent::resize()
|
|||
mSize.y *= resizeScale.y;
|
||||
}
|
||||
|
||||
mSize.y = std::round(mSize[1.0f]);
|
||||
mSize.y = std::round(mSize.y);
|
||||
mSize.x = (mSize.y / textureSize.y) * textureSize.x;
|
||||
}
|
||||
else {
|
||||
// If both components are set, we just stretch.
|
||||
// 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 (!mTargetSize.x && mTargetSize.y) {
|
||||
|
@ -122,7 +122,7 @@ void VideoFFmpegComponent::resize()
|
|||
void VideoFFmpegComponent::render(const glm::mat4& parentTrans)
|
||||
{
|
||||
VideoComponent::render(parentTrans);
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
GuiComponent::renderChildren(trans);
|
||||
|
||||
if (mIsPlaying && mFormatContext) {
|
||||
|
@ -798,7 +798,7 @@ void VideoFFmpegComponent::calculateBlackRectangle()
|
|||
// 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
|
||||
// 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();
|
||||
|
||||
if (Settings::getInstance()->getBool("GamelistVideoPillarbox")) {
|
||||
|
|
|
@ -63,7 +63,7 @@ void VideoVlcComponent::deinit()
|
|||
void VideoVlcComponent::setResize(float width, float height)
|
||||
{
|
||||
// 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;
|
||||
mStaticImage.setResize(width, height);
|
||||
resize();
|
||||
|
@ -73,7 +73,7 @@ void VideoVlcComponent::setMaxSize(float width, float height)
|
|||
{
|
||||
// This resize function is used in most instances, such as non-stretched video screensaver
|
||||
// and the gamelist videos.
|
||||
mTargetSize = glm::vec2(width, height);
|
||||
mTargetSize = glm::vec2{width, height};
|
||||
mTargetIsMax = true;
|
||||
mStaticImage.setMaxSize(width, height);
|
||||
resize();
|
||||
|
@ -129,13 +129,13 @@ void VideoVlcComponent::resize()
|
|||
|
||||
const glm::vec2 textureSize(static_cast<float>(mVideoWidth), static_cast<float>(mVideoHeight));
|
||||
|
||||
if (textureSize == glm::vec2({}))
|
||||
if (textureSize == glm::vec2{})
|
||||
return;
|
||||
|
||||
if (mTargetIsMax) {
|
||||
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) {
|
||||
mSize.x *= resizeScale.x;
|
||||
|
@ -152,7 +152,7 @@ void VideoVlcComponent::resize()
|
|||
else {
|
||||
// If both components are set, we just stretch.
|
||||
// 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 (!mTargetSize.x && mTargetSize.y) {
|
||||
|
@ -179,7 +179,7 @@ void VideoVlcComponent::render(const glm::mat4& parentTrans)
|
|||
setAudioVolume();
|
||||
|
||||
VideoComponent::render(parentTrans);
|
||||
glm::mat4 trans = parentTrans * getTransform();
|
||||
glm::mat4 trans{parentTrans * getTransform()};
|
||||
GuiComponent::renderChildren(trans);
|
||||
|
||||
// Check the actual VLC state, i.e. if the video is really playing rather than
|
||||
|
@ -255,7 +255,7 @@ void VideoVlcComponent::calculateBlackRectangle()
|
|||
// 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
|
||||
// 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();
|
||||
|
||||
if (Settings::getInstance()->getBool("GamelistVideoPillarbox")) {
|
||||
|
|
|
@ -35,7 +35,7 @@ GuiComplexTextEditPopup::GuiComplexTextEditPopup(
|
|||
: GuiComponent(window)
|
||||
, mHelpStyle(helpstyle)
|
||||
, mBackground(window, ":/graphics/frame.svg")
|
||||
, mGrid(window, Vector2i(1, 5))
|
||||
, mGrid(window, glm::ivec2{1, 5})
|
||||
, mMultiLine(multiLine)
|
||||
, mInitValue(initValue)
|
||||
, mOkCallback(okCallback)
|
||||
|
@ -75,12 +75,12 @@ GuiComplexTextEditPopup::GuiComplexTextEditPopup(
|
|||
|
||||
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
||||
|
||||
mGrid.setEntry(mTitle, Vector2i(0, 0), false, true);
|
||||
mGrid.setEntry(mInfoString1, Vector2i(0, 1), false, true);
|
||||
mGrid.setEntry(mInfoString2, Vector2i(0, 2), false, false);
|
||||
mGrid.setEntry(mText, Vector2i(0, 3), true, false, Vector2i(1, 1),
|
||||
mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true);
|
||||
mGrid.setEntry(mInfoString1, glm::ivec2{0, 1}, false, true);
|
||||
mGrid.setEntry(mInfoString2, glm::ivec2{0, 2}, false, false);
|
||||
mGrid.setEntry(mText, glm::ivec2{0, 3}, true, false, glm::ivec2{1, 1},
|
||||
GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM);
|
||||
mGrid.setEntry(mButtonGrid, Vector2i(0, 4), true, false);
|
||||
mGrid.setEntry(mButtonGrid, glm::ivec2{0, 4}, true, false);
|
||||
mGrid.setRowHeightPerc(1, 0.15f, true);
|
||||
|
||||
float textHeight = mText->getFont()->getHeight();
|
||||
|
@ -106,7 +106,7 @@ GuiComplexTextEditPopup::GuiComplexTextEditPopup(
|
|||
|
||||
void GuiComplexTextEditPopup::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, mText->getSize().y);
|
||||
|
||||
// Update grid.
|
||||
|
|
|
@ -25,7 +25,7 @@ GuiDetectDevice::GuiDetectDevice(Window* window,
|
|||
, mFirstRun(firstRun)
|
||||
, mForcedConfig(forcedConfig)
|
||||
, mBackground(window, ":/graphics/frame.svg")
|
||||
, mGrid(window, Vector2i(1, 5))
|
||||
, mGrid(window, glm::ivec2{1, 5})
|
||||
{
|
||||
mHoldingConfig = nullptr;
|
||||
mHoldTime = 0;
|
||||
|
@ -38,7 +38,8 @@ GuiDetectDevice::GuiDetectDevice(Window* window,
|
|||
mTitle =
|
||||
std::make_shared<TextComponent>(mWindow, firstRun ? "WELCOME" : "CONFIGURE INPUT DEVICE",
|
||||
Font::get(FONT_SIZE_LARGE), 0x555555FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mTitle, Vector2i(0, 0), false, true, Vector2i(1, 1), GridFlags::BORDER_BOTTOM);
|
||||
mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true, glm::ivec2{1, 1},
|
||||
GridFlags::BORDER_BOTTOM);
|
||||
|
||||
// Device info.
|
||||
std::stringstream deviceInfo;
|
||||
|
@ -54,7 +55,7 @@ GuiDetectDevice::GuiDetectDevice(Window* window,
|
|||
|
||||
mDeviceInfo = std::make_shared<TextComponent>(
|
||||
mWindow, deviceInfo.str(), Font::get(FONT_SIZE_SMALL), 0x999999FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mDeviceInfo, Vector2i(0, 1), false, true);
|
||||
mGrid.setEntry(mDeviceInfo, glm::ivec2{0, 1}, false, true);
|
||||
|
||||
// Message.
|
||||
if (numDevices > 0) {
|
||||
|
@ -68,18 +69,18 @@ GuiDetectDevice::GuiDetectDevice(Window* window,
|
|||
0x777777FF, ALIGN_CENTER);
|
||||
}
|
||||
|
||||
mGrid.setEntry(mMsg1, Vector2i(0, 2), false, true);
|
||||
mGrid.setEntry(mMsg1, glm::ivec2{0, 2}, false, true);
|
||||
|
||||
const std::string msg2str =
|
||||
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),
|
||||
0x777777FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mMsg2, Vector2i(0, 3), false, true);
|
||||
mGrid.setEntry(mMsg2, glm::ivec2{0, 3}, false, true);
|
||||
|
||||
// Currently held device.
|
||||
mDeviceHeld = std::make_shared<TextComponent>(mWindow, "", Font::get(FONT_SIZE_MEDIUM),
|
||||
0xFFFFFFFF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mDeviceHeld, Vector2i(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
|
||||
// regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference.
|
||||
|
@ -93,7 +94,7 @@ GuiDetectDevice::GuiDetectDevice(Window* window,
|
|||
|
||||
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.
|
||||
mGrid.setSize(mSize);
|
||||
|
|
|
@ -33,7 +33,7 @@ GuiInputConfig::GuiInputConfig(Window* window,
|
|||
const std::function<void()>& okCallback)
|
||||
: GuiComponent(window)
|
||||
, mBackground(window, ":/graphics/frame.svg")
|
||||
, mGrid(window, Vector2i(1, 7))
|
||||
, mGrid(window, glm::ivec2{1, 7})
|
||||
, mTargetConfig(target)
|
||||
, mHoldingInput(false)
|
||||
{
|
||||
|
@ -54,11 +54,11 @@ GuiInputConfig::GuiInputConfig(Window* window,
|
|||
addChild(&mGrid);
|
||||
|
||||
// 0 is a spacer row.
|
||||
mGrid.setEntry(std::make_shared<GuiComponent>(mWindow), Vector2i(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),
|
||||
0x555555FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mTitle, Vector2i(0, 1), false, true);
|
||||
mGrid.setEntry(mTitle, glm::ivec2{0, 1}, false, true);
|
||||
|
||||
std::stringstream ss;
|
||||
if (target->getDeviceId() == DEVICE_KEYBOARD)
|
||||
|
@ -70,7 +70,7 @@ GuiInputConfig::GuiInputConfig(Window* window,
|
|||
mSubtitle1 =
|
||||
std::make_shared<TextComponent>(mWindow, Utils::String::toUpper(ss.str()),
|
||||
Font::get(FONT_SIZE_MEDIUM), 0x555555FF, ALIGN_CENTER);
|
||||
mGrid.setEntry(mSubtitle1, Vector2i(0, 2), false, true);
|
||||
mGrid.setEntry(mSubtitle1, glm::ivec2{0, 2}, false, true);
|
||||
|
||||
mSubtitle2 =
|
||||
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.
|
||||
mSubtitle2->setOpacity(0);
|
||||
|
||||
mGrid.setEntry(mSubtitle2, Vector2i(0, 3), false, true);
|
||||
mGrid.setEntry(mSubtitle2, glm::ivec2{0, 3}, false, true);
|
||||
|
||||
// 4 is a spacer row.
|
||||
mList = std::make_shared<ComponentList>(mWindow);
|
||||
mGrid.setEntry(mList, Vector2i(0, 5), true, true);
|
||||
mGrid.setEntry(mList, glm::ivec2{0, 5}, true, true);
|
||||
|
||||
for (int i = 0; i < inputCount; i++) {
|
||||
ComponentListRow row;
|
||||
|
@ -184,7 +184,7 @@ GuiInputConfig::GuiInputConfig(Window* window,
|
|||
[this, okFunction] { okFunction(); }));
|
||||
|
||||
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
||||
mGrid.setEntry(mButtonGrid, Vector2i(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
|
||||
// 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()
|
||||
{
|
||||
mBackground.fitTo(mSize, glm::vec3({}), glm::vec2(-32.0f, -32.0f));
|
||||
mBackground.fitTo(mSize, glm::vec3{}, glm::vec2{-32.0f, -32.0f});
|
||||
|
||||
// Update grid.
|
||||
mGrid.setSize(mSize);
|
||||
|
@ -313,7 +313,7 @@ void GuiInputConfig::rowDone()
|
|||
// At bottom of list, we're done.
|
||||
mConfiguringAll = false;
|
||||
mConfiguringRow = false;
|
||||
mGrid.moveCursor(Vector2i(0, 1));
|
||||
mGrid.moveCursor(glm::ivec2{0, 1});
|
||||
}
|
||||
else {
|
||||
// On another row.
|
||||
|
|
|
@ -28,7 +28,7 @@ GuiMsgBox::GuiMsgBox(Window* window,
|
|||
: GuiComponent(window)
|
||||
, mHelpStyle(helpstyle)
|
||||
, mBackground(window, ":/graphics/frame.svg")
|
||||
, mGrid(window, Vector2i(1, 2))
|
||||
, mGrid(window, glm::ivec2{1, 2})
|
||||
, mDisableBackButton(disableBackButton)
|
||||
, mDeleteOnButtonPress(deleteOnButtonPress)
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ GuiMsgBox::GuiMsgBox(Window* window,
|
|||
|
||||
mMsg = std::make_shared<TextComponent>(mWindow, text, Font::get(FONT_SIZE_MEDIUM), 0x777777FF,
|
||||
ALIGN_CENTER);
|
||||
mGrid.setEntry(mMsg, Vector2i(0, 0), false, false);
|
||||
mGrid.setEntry(mMsg, glm::ivec2{0, 0}, false, false);
|
||||
|
||||
// Create the buttons.
|
||||
mButtons.push_back(std::make_shared<ButtonComponent>(
|
||||
|
@ -71,7 +71,8 @@ GuiMsgBox::GuiMsgBox(Window* window,
|
|||
|
||||
// Put the buttons into a ComponentGrid.
|
||||
mButtonGrid = makeButtonGrid(mWindow, mButtons);
|
||||
mGrid.setEntry(mButtonGrid, Vector2i(0, 1), true, false, Vector2i(1, 1), GridFlags::BORDER_TOP);
|
||||
mGrid.setEntry(mButtonGrid, glm::ivec2{0, 1}, true, false, glm::ivec2{1, 1},
|
||||
GridFlags::BORDER_TOP);
|
||||
|
||||
// Decide final width.
|
||||
if (mMsg->getSize().x < width && mButtonGrid->getSize().x < width) {
|
||||
|
@ -160,7 +161,7 @@ void GuiMsgBox::onSizeChanged()
|
|||
mGrid.getRowHeight(0));
|
||||
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)
|
||||
|
|
|
@ -25,7 +25,7 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window,
|
|||
: GuiComponent(window)
|
||||
, mHelpStyle(helpstyle)
|
||||
, mBackground(window, ":/graphics/frame.svg")
|
||||
, mGrid(window, Vector2i(1, 3))
|
||||
, mGrid(window, glm::ivec2{1, 3})
|
||||
, mMultiLine(multiLine)
|
||||
, mInitValue(initValue)
|
||||
, mOkCallback(okCallback)
|
||||
|
@ -53,10 +53,10 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window,
|
|||
|
||||
mButtonGrid = makeButtonGrid(mWindow, buttons);
|
||||
|
||||
mGrid.setEntry(mTitle, Vector2i(0, 0), false, true);
|
||||
mGrid.setEntry(mText, Vector2i(0, 1), true, false, Vector2i(1, 1),
|
||||
mGrid.setEntry(mTitle, glm::ivec2{0, 0}, false, true);
|
||||
mGrid.setEntry(mText, glm::ivec2{0, 1}, true, false, glm::ivec2{1, 1},
|
||||
GridFlags::BORDER_TOP | GridFlags::BORDER_BOTTOM);
|
||||
mGrid.setEntry(mButtonGrid, Vector2i(0, 2), true, false);
|
||||
mGrid.setEntry(mButtonGrid, glm::ivec2{0, 2}, true, false);
|
||||
|
||||
float textHeight = mText->getFont()->getHeight();
|
||||
|
||||
|
@ -78,7 +78,7 @@ GuiTextEditPopup::GuiTextEditPopup(Window* window,
|
|||
|
||||
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, mText->getSize().y);
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "Log.h"
|
||||
#include "Settings.h"
|
||||
#include "Shader_GL21.h"
|
||||
#include "math/Vector2i.h"
|
||||
#include "resources/ResourceManager.h"
|
||||
|
||||
#include <SDL2/SDL.h>
|
||||
|
@ -325,8 +324,8 @@ namespace Renderer
|
|||
if (!createWindow())
|
||||
return false;
|
||||
|
||||
glm::mat4 projection = getIdentity();
|
||||
Rect viewport = Rect(0, 0, 0, 0);
|
||||
glm::mat4 projection{getIdentity()};
|
||||
Rect viewport{0, 0, 0, 0};
|
||||
|
||||
switch (screenRotate) {
|
||||
case 1: {
|
||||
|
@ -393,9 +392,9 @@ namespace Renderer
|
|||
destroyWindow();
|
||||
}
|
||||
|
||||
void pushClipRect(const Vector2i& _pos, const Vector2i& _size)
|
||||
void pushClipRect(const glm::ivec2& _pos, const glm::ivec2& _size)
|
||||
{
|
||||
Rect box(_pos.x(), _pos.y(), _size.x(), _size.y());
|
||||
Rect box(_pos.x, _pos.y, _size.x, _size.y);
|
||||
|
||||
if (box.w == 0)
|
||||
box.w = screenWidth - box.x;
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
|
||||
struct SDL_Window;
|
||||
|
||||
class Vector2i;
|
||||
|
||||
namespace Renderer
|
||||
{
|
||||
const unsigned int SHADER_DESATURATE = 1;
|
||||
|
@ -51,7 +49,7 @@ namespace Renderer
|
|||
static std::vector<Shader*> sShaderProgramVector;
|
||||
static GLuint shaderFBO;
|
||||
static glm::mat4 mProjectionMatrix;
|
||||
static constexpr glm::mat4 getIdentity() { return glm::mat4(1.0f); }
|
||||
static constexpr glm::mat4 getIdentity() { return glm::mat4{1.0f}; }
|
||||
|
||||
#if !defined(NDEBUG)
|
||||
#define GL_CHECK_ERROR(Function) (Function, _GLCheckError(#Function))
|
||||
|
@ -130,7 +128,7 @@ namespace Renderer
|
|||
|
||||
bool init();
|
||||
void deinit();
|
||||
void pushClipRect(const Vector2i& _pos, const Vector2i& _size);
|
||||
void pushClipRect(const glm::ivec2& _pos, const glm::ivec2& _size);
|
||||
void popClipRect();
|
||||
void drawRect(const float _x,
|
||||
const float _y,
|
||||
|
|
|
@ -360,7 +360,7 @@ namespace Renderer
|
|||
|
||||
void setMatrix(const glm::mat4& _matrix)
|
||||
{
|
||||
glm::mat4 matrix = _matrix;
|
||||
glm::mat4 matrix{_matrix};
|
||||
matrix[3] = glm::round(matrix[3]);
|
||||
|
||||
GL_CHECK_ERROR(glMatrixMode(GL_MODELVIEW));
|
||||
|
|
|
@ -207,7 +207,7 @@ namespace Renderer
|
|||
|
||||
void setMatrix(const glm::mat4& _matrix)
|
||||
{
|
||||
glm::mat4 matrix = _matrix;
|
||||
glm::mat4 matrix{_matrix};
|
||||
matrix[3] = glm::round(matrix[3]);
|
||||
|
||||
GL_CHECK_ERROR(glMatrixMode(GL_MODELVIEW));
|
||||
|
|
|
@ -49,7 +49,7 @@ size_t Font::getMemUsage() const
|
|||
{
|
||||
size_t memUsage = 0;
|
||||
for (auto it = mTextures.cbegin(); it != mTextures.cend(); it++)
|
||||
memUsage += it->textureSize.x() * it->textureSize.y() * 4;
|
||||
memUsage += it->textureSize.x * it->textureSize.y * 4;
|
||||
|
||||
for (auto it = mFaceCache.cbegin(); it != mFaceCache.cend(); it++)
|
||||
memUsage += it->second->data.length;
|
||||
|
@ -137,8 +137,8 @@ Font::FontTexture::FontTexture(const int mSize)
|
|||
// I'm not entirely sure if the 16 and 6 constants are correct, but they seem to provide
|
||||
// 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.
|
||||
textureSize = Vector2i(mSize * 16, mSize * 6);
|
||||
writePos = Vector2i::Zero();
|
||||
textureSize = glm::ivec2{mSize * 16, mSize * 6};
|
||||
writePos = glm::ivec2{};
|
||||
rowHeight = 0;
|
||||
}
|
||||
|
||||
|
@ -148,28 +148,30 @@ Font::FontTexture::~FontTexture()
|
|||
deinitTexture();
|
||||
}
|
||||
|
||||
bool Font::FontTexture::findEmpty(const Vector2i& size, Vector2i& cursor_out)
|
||||
bool Font::FontTexture::findEmpty(const glm::ivec2& size, glm::ivec2& cursor_out)
|
||||
{
|
||||
if (size.x() >= textureSize.x() || size.y() >= textureSize.y())
|
||||
if (size.x >= textureSize.x || size.y >= textureSize.y)
|
||||
return false;
|
||||
|
||||
if (writePos.x() + size.x() >= textureSize.x() &&
|
||||
writePos.y() + rowHeight + size.y() + 1 < textureSize.y()) {
|
||||
if (writePos.x + size.x >= textureSize.x &&
|
||||
writePos.y + rowHeight + size.y + 1 < textureSize.y) {
|
||||
// Row full, but it should fit on the next row so move the cursor there.
|
||||
writePos = Vector2i(0, writePos.y() + rowHeight + 1); // Leave 1px of space between glyphs.
|
||||
// Leave 1px of space between glyphs.
|
||||
writePos = glm::ivec2{0, writePos.y + rowHeight + 1};
|
||||
rowHeight = 0;
|
||||
}
|
||||
|
||||
if (writePos.x() + size.x() >= textureSize.x() || writePos.y() + size.y() >= textureSize.y()) {
|
||||
if (writePos.x + size.x >= textureSize.x || writePos.y + size.y >= textureSize.y) {
|
||||
// Nope, still won't fit.
|
||||
return false;
|
||||
}
|
||||
|
||||
cursor_out = writePos;
|
||||
writePos[0] += size.x() + 1; // Leave 1px of space between glyphs.
|
||||
// Leave 1px of space between glyphs.
|
||||
writePos.x += size.x + 1;
|
||||
|
||||
if (size.y() > rowHeight)
|
||||
rowHeight = size.y();
|
||||
if (size.y > rowHeight)
|
||||
rowHeight = size.y;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -177,8 +179,8 @@ bool Font::FontTexture::findEmpty(const Vector2i& size, Vector2i& cursor_out)
|
|||
void Font::FontTexture::initTexture()
|
||||
{
|
||||
assert(textureId == 0);
|
||||
textureId = Renderer::createTexture(Renderer::Texture::ALPHA, false, false, textureSize.x(),
|
||||
textureSize.y(), nullptr);
|
||||
textureId = Renderer::createTexture(Renderer::Texture::ALPHA, false, false, textureSize.x,
|
||||
textureSize.y, nullptr);
|
||||
}
|
||||
|
||||
void Font::FontTexture::deinitTexture()
|
||||
|
@ -189,9 +191,9 @@ void Font::FontTexture::deinitTexture()
|
|||
}
|
||||
}
|
||||
|
||||
void Font::getTextureForNewGlyph(const Vector2i& glyphSize,
|
||||
void Font::getTextureForNewGlyph(const glm::ivec2& glyphSize,
|
||||
FontTexture*& tex_out,
|
||||
Vector2i& cursor_out)
|
||||
glm::ivec2& cursor_out)
|
||||
{
|
||||
if (mTextures.size()) {
|
||||
// Check if the most recent texture has space.
|
||||
|
@ -210,7 +212,7 @@ void Font::getTextureForNewGlyph(const Vector2i& glyphSize,
|
|||
bool ok = tex_out->findEmpty(glyphSize, cursor_out);
|
||||
if (!ok) {
|
||||
LOG(LogError) << "Glyph too big to fit on a new texture (glyph size > "
|
||||
<< tex_out->textureSize.x() << ", " << tex_out->textureSize.y() << ")";
|
||||
<< tex_out->textureSize.x << ", " << tex_out->textureSize.y << ")";
|
||||
tex_out = nullptr;
|
||||
}
|
||||
}
|
||||
|
@ -296,10 +298,10 @@ Font::Glyph* Font::getGlyph(unsigned int id)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Vector2i glyphSize(g->bitmap.width, g->bitmap.rows);
|
||||
glm::ivec2 glyphSize{g->bitmap.width, g->bitmap.rows};
|
||||
|
||||
FontTexture* tex = nullptr;
|
||||
Vector2i cursor;
|
||||
glm::ivec2 cursor;
|
||||
getTextureForNewGlyph(glyphSize, tex, cursor);
|
||||
|
||||
// getTextureForNewGlyph can fail if the glyph is bigger than the max texture
|
||||
|
@ -314,23 +316,23 @@ Font::Glyph* Font::getGlyph(unsigned int id)
|
|||
Glyph& glyph = mGlyphMap[id];
|
||||
|
||||
glyph.texture = tex;
|
||||
glyph.texPos = glm::vec2(cursor.x() / static_cast<float>(tex->textureSize.x()),
|
||||
cursor.y() / static_cast<float>(tex->textureSize.y()));
|
||||
glyph.texSize = glm::vec2(glyphSize.x() / static_cast<float>(tex->textureSize.x()),
|
||||
glyphSize.y() / static_cast<float>(tex->textureSize.y()));
|
||||
glyph.texPos = glm::vec2{cursor.x / static_cast<float>(tex->textureSize.x),
|
||||
cursor.y / static_cast<float>(tex->textureSize.y)};
|
||||
glyph.texSize = glm::vec2{glyphSize.x / static_cast<float>(tex->textureSize.x),
|
||||
glyphSize.y / static_cast<float>(tex->textureSize.y)};
|
||||
|
||||
glyph.advance = glm::vec2(static_cast<float>(g->metrics.horiAdvance) / 64.0f,
|
||||
static_cast<float>(g->metrics.vertAdvance) / 64.0f);
|
||||
glyph.bearing = glm::vec2(static_cast<float>(g->metrics.horiBearingX) / 64.0f,
|
||||
static_cast<float>(g->metrics.horiBearingY) / 64.0f);
|
||||
glyph.advance = glm::vec2{static_cast<float>(g->metrics.horiAdvance) / 64.0f,
|
||||
static_cast<float>(g->metrics.vertAdvance) / 64.0f};
|
||||
glyph.bearing = glm::vec2{static_cast<float>(g->metrics.horiBearingX) / 64.0f,
|
||||
static_cast<float>(g->metrics.horiBearingY) / 64.0f};
|
||||
|
||||
// Upload glyph bitmap to texture.
|
||||
Renderer::updateTexture(tex->textureId, Renderer::Texture::ALPHA, cursor.x(), cursor.y(),
|
||||
glyphSize.x(), glyphSize.y(), g->bitmap.buffer);
|
||||
Renderer::updateTexture(tex->textureId, Renderer::Texture::ALPHA, cursor.x, cursor.y,
|
||||
glyphSize.x, glyphSize.y, g->bitmap.buffer);
|
||||
|
||||
// Update max glyph height.
|
||||
if (glyphSize.y() > mMaxGlyphHeight)
|
||||
mMaxGlyphHeight = glyphSize.y();
|
||||
if (glyphSize.y > mMaxGlyphHeight)
|
||||
mMaxGlyphHeight = glyphSize.y;
|
||||
|
||||
// Done.
|
||||
return &glyph;
|
||||
|
@ -354,14 +356,14 @@ void Font::rebuildTextures()
|
|||
FontTexture* tex = it->second.texture;
|
||||
|
||||
// Find the position/size.
|
||||
Vector2i cursor(static_cast<int>(it->second.texPos.x * tex->textureSize.x()),
|
||||
static_cast<int>(it->second.texPos.y * tex->textureSize.y()));
|
||||
Vector2i glyphSize(static_cast<int>(it->second.texSize.x * tex->textureSize.x()),
|
||||
static_cast<int>(it->second.texSize.y * tex->textureSize.y()));
|
||||
glm::ivec2 cursor{static_cast<int>(it->second.texPos.x * tex->textureSize.x),
|
||||
static_cast<int>(it->second.texPos.y * tex->textureSize.y)};
|
||||
glm::ivec2 glyphSize{static_cast<int>(it->second.texSize.x * tex->textureSize.x),
|
||||
static_cast<int>(it->second.texSize.y * tex->textureSize.y)};
|
||||
|
||||
// Upload to texture.
|
||||
Renderer::updateTexture(tex->textureId, Renderer::Texture::ALPHA, cursor.x(), cursor.y(),
|
||||
glyphSize.x(), glyphSize.y(), glyphSlot->bitmap.buffer);
|
||||
Renderer::updateTexture(tex->textureId, Renderer::Texture::ALPHA, cursor.x, cursor.y,
|
||||
glyphSize.x, glyphSize.y, glyphSlot->bitmap.buffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -412,7 +414,7 @@ glm::vec2 Font::sizeText(std::string text, float lineSpacing)
|
|||
if (lineWidth > highestWidth)
|
||||
highestWidth = lineWidth;
|
||||
|
||||
return glm::vec2(highestWidth, y);
|
||||
return glm::vec2{highestWidth, y};
|
||||
}
|
||||
|
||||
std::string Font::getTextMaxWidth(std::string text, float maxWidth)
|
||||
|
@ -435,7 +437,7 @@ float Font::getLetterHeight()
|
|||
{
|
||||
Glyph* glyph = getGlyph('S');
|
||||
assert(glyph);
|
||||
return glyph->texSize.y * glyph->texture->textureSize.y();
|
||||
return glyph->texSize.y * glyph->texture->textureSize.y;
|
||||
}
|
||||
|
||||
// Breaks up a normal string with newlines to make it fit xLen.
|
||||
|
@ -538,7 +540,7 @@ glm::vec2 Font::getWrappedTextCursorOffset(std::string text,
|
|||
lineWidth += glyph->advance.x;
|
||||
}
|
||||
|
||||
return glm::vec2(lineWidth, y);
|
||||
return glm::vec2{lineWidth, y};
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -631,22 +633,21 @@ TextCache* Font::buildTextCache(const std::string& text,
|
|||
verts.resize(oldVertSize + 6);
|
||||
Renderer::Vertex* vertices = verts.data() + oldVertSize;
|
||||
|
||||
const float glyphStartX = x + glyph->bearing.x;
|
||||
const Vector2i& textureSize = glyph->texture->textureSize;
|
||||
const float glyphStartX{x + glyph->bearing.x};
|
||||
const glm::ivec2& textureSize{glyph->texture->textureSize};
|
||||
const unsigned int convertedColor = Renderer::convertRGBAToABGR(color);
|
||||
|
||||
vertices[1] = {{glyphStartX, y - glyph->bearing.y},
|
||||
{glyph->texPos.x, glyph->texPos.y},
|
||||
convertedColor};
|
||||
vertices[2] = { { glyphStartX,
|
||||
y - glyph->bearing.y + (glyph->texSize.y * textureSize.y()) },
|
||||
vertices[2] = {{glyphStartX, y - glyph->bearing.y + (glyph->texSize.y * textureSize.y)},
|
||||
{glyph->texPos.x, glyph->texPos.y + glyph->texSize.y},
|
||||
convertedColor};
|
||||
vertices[3] = { { glyphStartX + glyph->texSize.x * textureSize.x(), y - glyph->bearing.y },
|
||||
vertices[3] = {{glyphStartX + glyph->texSize.x * textureSize.x, y - glyph->bearing.y},
|
||||
{glyph->texPos.x + glyph->texSize.x, glyph->texPos.y},
|
||||
convertedColor};
|
||||
vertices[4] = { { glyphStartX + glyph->texSize.x * textureSize.x(),
|
||||
y - glyph->bearing.y + (glyph->texSize.y * textureSize.y()) },
|
||||
vertices[4] = {{glyphStartX + glyph->texSize.x * textureSize.x,
|
||||
y - glyph->bearing.y + (glyph->texSize.y * textureSize.y)},
|
||||
{glyph->texPos.x + glyph->texSize.x, glyph->texPos.y + glyph->texSize.y},
|
||||
convertedColor};
|
||||
|
||||
|
@ -687,7 +688,7 @@ TextCache* Font::buildTextCache(const std::string& text,
|
|||
float lineSpacing,
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#define ES_CORE_RESOURCES_FONT_H
|
||||
|
||||
#include "ThemeData.h"
|
||||
#include "math/Vector2i.h"
|
||||
#include "renderers/Renderer.h"
|
||||
#include "resources/ResourceManager.h"
|
||||
|
||||
|
@ -114,14 +113,14 @@ private:
|
|||
|
||||
struct FontTexture {
|
||||
unsigned int textureId;
|
||||
Vector2i textureSize;
|
||||
glm::ivec2 textureSize;
|
||||
|
||||
Vector2i writePos;
|
||||
glm::ivec2 writePos;
|
||||
int rowHeight;
|
||||
|
||||
FontTexture(const int mSize);
|
||||
~FontTexture();
|
||||
bool findEmpty(const Vector2i& size, Vector2i& cursor_out);
|
||||
bool findEmpty(const glm::ivec2& size, glm::ivec2& cursor_out);
|
||||
|
||||
// You must call initTexture() after creating a FontTexture to get a textureId.
|
||||
// Initializes the OpenGL texture according to this FontTexture's settings,
|
||||
|
@ -146,9 +145,9 @@ private:
|
|||
|
||||
std::vector<FontTexture> mTextures;
|
||||
|
||||
void getTextureForNewGlyph(const Vector2i& glyphSize,
|
||||
void getTextureForNewGlyph(const glm::ivec2& glyphSize,
|
||||
FontTexture*& tex_out,
|
||||
Vector2i& cursor_out);
|
||||
glm::ivec2& cursor_out);
|
||||
|
||||
std::map<unsigned int, std::unique_ptr<FontFace>> mFaceCache;
|
||||
FT_Face getFaceForChar(unsigned int id);
|
||||
|
|
|
@ -46,15 +46,15 @@ TextureResource::TextureResource(const std::string& path,
|
|||
data->load();
|
||||
}
|
||||
|
||||
mSize = Vector2i(static_cast<int>(data->width()), static_cast<int>(data->height()));
|
||||
mSourceSize = glm::vec2(data->sourceWidth(), data->sourceHeight());
|
||||
mSize = glm::ivec2{static_cast<int>(data->width()), static_cast<int>(data->height())};
|
||||
mSourceSize = glm::vec2{data->sourceWidth(), data->sourceHeight()};
|
||||
}
|
||||
else {
|
||||
// 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
|
||||
// reserves a texture to later be used for the video rendering.
|
||||
mTextureData = std::shared_ptr<TextureData>(new TextureData(tile));
|
||||
mSize = Vector2i(0, 0);
|
||||
mSize = glm::ivec2{};
|
||||
}
|
||||
sAllTextures.insert(this);
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ void TextureResource::initFromPixels(const unsigned char* dataRGBA, size_t width
|
|||
mTextureData->releaseRAM();
|
||||
mTextureData->initFromRGBA(dataRGBA, width, height);
|
||||
// Cache the image dimensions.
|
||||
mSize = Vector2i(static_cast<int>(width), static_cast<int>(height));
|
||||
mSourceSize = glm::vec2(mTextureData->sourceWidth(), mTextureData->sourceHeight());
|
||||
mSize = glm::ivec2{static_cast<int>(width), static_cast<int>(height)};
|
||||
mSourceSize = glm::vec2{mTextureData->sourceWidth(), mTextureData->sourceHeight()};
|
||||
}
|
||||
|
||||
void TextureResource::initFromMemory(const char* data, size_t length)
|
||||
|
@ -87,9 +87,9 @@ void TextureResource::initFromMemory(const char* data, size_t length)
|
|||
mTextureData->releaseRAM();
|
||||
mTextureData->initImageFromMemory(reinterpret_cast<const unsigned char*>(data), length);
|
||||
// Get the size from the texture data.
|
||||
mSize =
|
||||
Vector2i(static_cast<int>(mTextureData->width()), static_cast<int>(mTextureData->height()));
|
||||
mSourceSize = glm::vec2(mTextureData->sourceWidth(), mTextureData->sourceHeight());
|
||||
mSize = glm::ivec2{static_cast<int>(mTextureData->width()),
|
||||
static_cast<int>(mTextureData->height())};
|
||||
mSourceSize = glm::vec2{mTextureData->sourceWidth(), mTextureData->sourceHeight()};
|
||||
}
|
||||
|
||||
void TextureResource::manualUnload(std::string path, bool tile)
|
||||
|
@ -197,7 +197,7 @@ void TextureResource::rasterizeAt(size_t width, size_t height)
|
|||
data = mTextureData;
|
||||
else
|
||||
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));
|
||||
if (mForceLoad || (mTextureData != nullptr))
|
||||
data->load();
|
||||
|
@ -220,11 +220,11 @@ size_t TextureResource::getTotalMemUsage()
|
|||
|
||||
size_t TextureResource::getTotalTextureSize()
|
||||
{
|
||||
size_t total = 0;
|
||||
size_t total{0};
|
||||
// Count up all textures that manage their own texture data.
|
||||
for (auto tex : sAllTextures) {
|
||||
if (tex->mTextureData != nullptr)
|
||||
total += tex->getSize().x() * tex->getSize().y() * 4;
|
||||
total += tex->getSize().x * tex->getSize().y * 4;
|
||||
}
|
||||
// Now get the total memory from the manager.
|
||||
total += sTextureDataManager.getTotalSize();
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#define ES_CORE_RESOURCES_TEXTURE_RESOURCE_H
|
||||
|
||||
#include "math/Misc.h"
|
||||
#include "math/Vector2i.h"
|
||||
#include "resources/ResourceManager.h"
|
||||
#include "resources/TextureDataManager.h"
|
||||
|
||||
|
@ -52,7 +51,7 @@ public:
|
|||
bool isInitialized() const { return true; }
|
||||
bool isTiled() const;
|
||||
|
||||
const Vector2i getSize() const { return mSize; }
|
||||
const glm::ivec2 getSize() const { return mSize; }
|
||||
bool bind();
|
||||
|
||||
// Returns an approximation of total VRAM used by textures (in bytes).
|
||||
|
@ -73,7 +72,7 @@ private:
|
|||
// The texture data manager manages loading and unloading of filesystem based textures.
|
||||
static TextureDataManager sTextureDataManager;
|
||||
|
||||
Vector2i mSize;
|
||||
glm::ivec2 mSize;
|
||||
glm::vec2 mSourceSize;
|
||||
bool mForceLoad;
|
||||
|
||||
|
|
|
@ -153,8 +153,7 @@ namespace Utils
|
|||
(wchar_t)0xFF4B, (wchar_t)0xFF4C, (wchar_t)0xFF4D, (wchar_t)0xFF4E, (wchar_t)0xFF4F,
|
||||
(wchar_t)0xFF50, (wchar_t)0xFF51, (wchar_t)0xFF52, (wchar_t)0xFF53, (wchar_t)0xFF54,
|
||||
(wchar_t)0xFF55, (wchar_t)0xFF56, (wchar_t)0xFF57, (wchar_t)0xFF58, (wchar_t)0xFF59,
|
||||
(wchar_t)0xFF5A
|
||||
};
|
||||
(wchar_t)0xFF5A};
|
||||
|
||||
static wchar_t unicodeUppercase[] = {
|
||||
(wchar_t)0x0041, (wchar_t)0x0042, (wchar_t)0x0043, (wchar_t)0x0044, (wchar_t)0x0045,
|
||||
|
@ -290,8 +289,7 @@ namespace Utils
|
|||
(wchar_t)0xFF2B, (wchar_t)0xFF2C, (wchar_t)0xFF2D, (wchar_t)0xFF2E, (wchar_t)0xFF2F,
|
||||
(wchar_t)0xFF30, (wchar_t)0xFF31, (wchar_t)0xFF32, (wchar_t)0xFF33, (wchar_t)0xFF34,
|
||||
(wchar_t)0xFF35, (wchar_t)0xFF36, (wchar_t)0xFF37, (wchar_t)0xFF38, (wchar_t)0xFF39,
|
||||
(wchar_t)0xFF3A
|
||||
};
|
||||
(wchar_t)0xFF3A};
|
||||
|
||||
unsigned int chars2Unicode(const std::string& stringArg, size_t& cursor)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue