From c1044c0b3c08800efc4be8fefc1734e6b57fb945 Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Fri, 10 Feb 2023 00:49:42 +0100 Subject: [PATCH] Worked around an issue where some menu clipping boxes were not calculated correctly. Also cleaned up some code. --- es-app/assets/emulationstation.6.gz | Bin 1004 -> 1016 bytes es-app/src/views/GamelistLegacy.h | 2 +- es-core/src/Window.cpp | 2 ++ es-core/src/components/ComponentList.cpp | 25 +++++++++++++++-------- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/es-app/assets/emulationstation.6.gz b/es-app/assets/emulationstation.6.gz index 2cda87e8065a3f2239c625bb395ba59e612e80c5..1d20e75705ebc04d2e196a42acab7ba015f0a31b 100644 GIT binary patch literal 1016 zcmVY+-b1Z*FsRVRUJ4ZZ0+eg;iUR;x-h1_pdnRr67^O z&{f-ARV%Rz(}@ZLBFsvw2@fW5h(%(jzHsTU@3Av<0-EVQ0P^wqK7Z#*m~>#WfXBre z=8H*m{~gv3Q4IIdZ2A*GWZ+0O?3iGR8kWKK3aQyvov5cdbgkRv6gFGjBl=NloZOI_XR~rwSOyjSs zXz79>Kh)iw#=&IT1FnHWuB0$bWROb*TP2U0iycrjl+=o}aHpLM&3RUEmR12iV0cjD zD+sFmHKejES?c&P$IB)0vKC$uhO%CgB>$2GNsw`kz%wd`=Q}VGK5WROu?;FIxIr0c zwVJh2ifLI|$L@hgo|$3;&jsVV!feR6u1lUa(Z0I233RF$6G~!An5P)_;Uj+Tejft9 zIQnh4AuE3ijVlJ^@?ta`xxp*|ZM|{iB9q59|3RNc+5|N~2c#ShWS(!x+A0CxV!VaM zj#lVqET@=6R{|+|ZK8^vkWJCblWG1B+mJau!MD|T{*oBzqMV9t`Sxs>?!lH}8Bq5T zC1SbSY*ZMI-zBH6te3z?P6y^aW(MZ*cnsHW?inl--Igpv=act7wP}UKjAF@jfs|w- z#m@$GA&+1R)Zs5KY0Rv0l-R(^*t$*P+NR{%B!LvAYX}nWc@5MWSz(&frmt3uI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JFpZl2Av@TrZ8zpOu9K(?Ym0uOd#u#}yPZA~~&taWz z8+vPfA*61Kii9csKHkmJE#4Ws7}OMFFetCEzW4U%;&_@vDHCR^b&r>CU=CdB!@Hor z?CqPV98wf6{8p{|6)-O1l`8%gYyM zZ~LIV!@g9wTBPFFNy=r}&T&O?6W|7Ey_(C!;7@^d0egM5g4n)xir3hsRvI2rrrl-q zc4r*1nC-?Hf-@am^S8?iUT)t5+uxp7q#K*CE^))*-qj4p5C4YPHks92@2T6F)2Hpj zYC{$b-9ppk*uedp4L*QBa$_p}aWrBY!||ocMxO}TFzn+sw?!z+8uw@e{r_yJ@Gu}` zidz~MGX1;8X@EW^HRFO7mrw>yLoW;hm@dLqkJv7QM8Ik$(Z!xIlfw2LJ$9?(78s diff --git a/es-app/src/views/GamelistLegacy.h b/es-app/src/views/GamelistLegacy.h index f6b319648..19c59a520 100644 --- a/es-app/src/views/GamelistLegacy.h +++ b/es-app/src/views/GamelistLegacy.h @@ -174,7 +174,7 @@ void GamelistView::legacyPopulateFields() mTextComponents.push_back(std::make_unique()); mTextComponents.back()->setThemeMetadata("text_md_name"); mTextComponents.back()->setPosition(mSize.x, mSize.y); - mTextComponents.back()->setFont(Font::get(FONT_SIZE_MEDIUM)); + mTextComponents.back()->setFont(Font::get(FONT_SIZE_MEDIUM_FIXED)); mTextComponents.back()->setHorizontalAlignment(ALIGN_CENTER); mTextComponents.back()->setColor(0xAAAAAAFF); mTextComponents.back()->setDefaultZIndex(40.0f); diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index cf4177428..9d8d89944 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -120,7 +120,9 @@ bool Window::init() if (mDefaultFonts.empty()) { mDefaultFonts.push_back(Font::get(FONT_SIZE_SMALL)); mDefaultFonts.push_back(Font::get(FONT_SIZE_MEDIUM)); + mDefaultFonts.push_back(Font::get(FONT_SIZE_MEDIUM_FIXED)); mDefaultFonts.push_back(Font::get(FONT_SIZE_LARGE)); + mDefaultFonts.push_back(Font::get(FONT_SIZE_LARGE_FIXED)); } if (mRenderer->getIsVerticalOrientation()) diff --git a/es-core/src/components/ComponentList.cpp b/es-core/src/components/ComponentList.cpp index d361ffe7d..91b657476 100644 --- a/es-core/src/components/ComponentList.cpp +++ b/es-core/src/components/ComponentList.cpp @@ -30,7 +30,7 @@ ComponentList::ComponentList() { // Adjust the padding relative to the aspect ratio and screen resolution to make it look // coherent regardless of screen type. The 1.778 aspect ratio value is the 16:9 reference. - float aspectValue {1.778f / mRenderer->getScreenAspectRatio()}; + const float aspectValue {1.778f / mRenderer->getScreenAspectRatio()}; mHorizontalPadding = TOTAL_HORIZONTAL_PADDING_PX * aspectValue * mRenderer->getScreenWidthModifier(); @@ -140,7 +140,7 @@ void ComponentList::update(int deltaTime) const float totalHeight {getTotalRowHeight()}; // Scroll indicator logic, used by ScrollIndicatorComponent. - bool scrollIndicatorChanged = false; + bool scrollIndicatorChanged {false}; if (totalHeight > mSize.y) { if (mCameraOffset == 0) { @@ -218,7 +218,7 @@ void ComponentList::onCursorChanged(const CursorState& state) // Update the selector bar position. // In the future this might be animated. mSelectorBarOffset = 0; - for (int i = 0; i < mCursor; ++i) + for (int i {0}; i < mCursor; ++i) mSelectorBarOffset += getRowHeight(mEntries.at(i).data); updateCameraOffset(); @@ -244,8 +244,8 @@ void ComponentList::updateCameraOffset() // Move the camera to scroll. const float totalHeight {getTotalRowHeight()}; if (totalHeight > mSize.y) { - float target {mSelectorBarOffset + getRowHeight(mEntries.at(mCursor).data) / 2.0f - - (mSize.y / 2.0f)}; + const float target {mSelectorBarOffset + getRowHeight(mEntries.at(mCursor).data) / 2.0f - + (mSize.y / 2.0f)}; // Clamp the camera to prevent a fraction of a row from being displayed. mCameraOffset = 0.0f; @@ -288,7 +288,14 @@ void ComponentList::render(const glm::mat4& parentTrans) glm::mat4 trans {parentTrans * getTransform()}; + // TODO: Fix the rounding error properly instead of working around it. + const float roundErrorComp { + static_cast(static_cast(mSize.y) % + static_cast(getRowHeight(mEntries.at(0).data))) - + 2.0f}; + // Clip everything to be inside our bounds. + glm::vec3 dim {mSize.x, mSize.y - roundErrorComp, 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; @@ -309,7 +316,7 @@ void ComponentList::render(const glm::mat4& parentTrans) // Draw our entries. std::vector drawAfterCursor; bool drawAll {false}; - for (size_t i = 0; i < mEntries.size(); ++i) { + for (size_t i {0}; i < mEntries.size(); ++i) { if (mLoopRows && mFocused && mLoopOffset > 0) { loopTrans = @@ -405,7 +412,7 @@ void ComponentList::render(const glm::mat4& parentTrans) // Draw separators. float y {0.0f}; - for (unsigned int i = 0; i < mEntries.size(); ++i) { + for (unsigned int i {0}; i < mEntries.size(); ++i) { mRenderer->drawRect(0.0f, y, mSize.x, 1.0f * mRenderer->getScreenHeightModifier(), 0xC6C7C6FF, 0xC6C7C6FF, false, mOpacity, mDimming); y += getRowHeight(mEntries.at(i).data); @@ -420,7 +427,7 @@ float ComponentList::getRowHeight(const ComponentListRow& row) const { // Returns the highest component height found in the row. float height {0.0f}; - for (unsigned int i = 0; i < row.elements.size(); ++i) { + for (unsigned int i {0}; i < row.elements.size(); ++i) { if (row.elements.at(i).component->getSize().y > height) height = row.elements.at(i).component->getSize().y; } @@ -448,7 +455,7 @@ void ComponentList::updateElementPosition(const ComponentListRow& row) float rowHeight {getRowHeight(row)}; float x {mHorizontalPadding / 2.0f}; - for (unsigned int i = 0; i < row.elements.size(); ++i) { + for (unsigned int i {0}; i < row.elements.size(); ++i) { const auto comp = row.elements.at(i).component; // Center vertically.