From e5ac4354a4250baa8f66cff44e665bb4ddcd5b8d Mon Sep 17 00:00:00 2001 From: CaptainFrito Date: Tue, 3 Feb 2026 19:19:39 +0700 Subject: [PATCH] Removed useless bools in components --- open-x4-sdk | 2 +- src/activities/home/HomeActivity.cpp | 2 +- src/activities/home/MyLibraryActivity.cpp | 2 +- src/activities/home/RecentBooksActivity.cpp | 4 ++-- src/activities/settings/SettingsActivity.cpp | 2 +- src/components/themes/BaseTheme.cpp | 19 ++++++++++--------- src/components/themes/BaseTheme.h | 8 ++++---- src/components/themes/lyra/LyraTheme.cpp | 17 +++++++++-------- src/components/themes/lyra/LyraTheme.h | 8 ++++---- 9 files changed, 33 insertions(+), 31 deletions(-) diff --git a/open-x4-sdk b/open-x4-sdk index bd4e6707..c8ce3949 160000 --- a/open-x4-sdk +++ b/open-x4-sdk @@ -1 +1 @@ -Subproject commit bd4e6707503ab9c97d13ee0d8f8c69e9ff03cd12 +Subproject commit c8ce3949b3368329c290ca1858e65dc3416fc591 diff --git a/src/activities/home/HomeActivity.cpp b/src/activities/home/HomeActivity.cpp index 60bf89b9..07e86bba 100644 --- a/src/activities/home/HomeActivity.cpp +++ b/src/activities/home/HomeActivity.cpp @@ -277,7 +277,7 @@ void HomeActivity::render() { pageHeight - (metrics.headerHeight + metrics.homeTopPadding + metrics.verticalSpacing * 2 + metrics.buttonHintsHeight)}, static_cast(menuItems.size()), selectorIndex - recentBooks.size(), - [&menuItems](int index) { return std::string(menuItems[index]); }, false, nullptr); + [&menuItems](int index) { return std::string(menuItems[index]); }, nullptr); const auto labels = mappedInput.mapLabels("", "Select", "Up", "Down"); GUI.drawButtonHints(renderer, labels.btn1, labels.btn2, labels.btn3, labels.btn4); diff --git a/src/activities/home/MyLibraryActivity.cpp b/src/activities/home/MyLibraryActivity.cpp index 5628994b..35fbd44f 100644 --- a/src/activities/home/MyLibraryActivity.cpp +++ b/src/activities/home/MyLibraryActivity.cpp @@ -201,7 +201,7 @@ void MyLibraryActivity::render() const { } else { GUI.drawList( renderer, Rect{0, contentTop, pageWidth, contentHeight}, files.size(), selectorIndex, - [this](int index) { return files[index]; }, false, nullptr, false, nullptr, false, nullptr); + [this](int index) { return files[index]; }, nullptr, nullptr, nullptr); } // Help text diff --git a/src/activities/home/RecentBooksActivity.cpp b/src/activities/home/RecentBooksActivity.cpp index c47a67d0..9d22ae16 100644 --- a/src/activities/home/RecentBooksActivity.cpp +++ b/src/activities/home/RecentBooksActivity.cpp @@ -137,8 +137,8 @@ void RecentBooksActivity::render() const { } else { GUI.drawList( renderer, Rect{0, contentTop, pageWidth, contentHeight}, recentBooks.size(), selectorIndex, - [this](int index) { return recentBooks[index].title; }, true, - [this](int index) { return recentBooks[index].author; }, false, nullptr, false, nullptr); + [this](int index) { return recentBooks[index].title; }, [this](int index) { return recentBooks[index].author; }, + nullptr, nullptr); } // Help text diff --git a/src/activities/settings/SettingsActivity.cpp b/src/activities/settings/SettingsActivity.cpp index 3ad1c60c..6461a6d5 100644 --- a/src/activities/settings/SettingsActivity.cpp +++ b/src/activities/settings/SettingsActivity.cpp @@ -277,7 +277,7 @@ void SettingsActivity::render() const { pageHeight - (metrics.topPadding + metrics.headerHeight + metrics.tabBarHeight + metrics.buttonHintsHeight + metrics.verticalSpacing * 2)}, settingsCount, selectedSettingIndex - 1, [this](int index) { return std::string(settingsList[index].name); }, - false, nullptr, false, nullptr, true, + nullptr, nullptr, [this](int i) { const auto& setting = settingsList[i]; std::string valueText = ""; diff --git a/src/components/themes/BaseTheme.cpp b/src/components/themes/BaseTheme.cpp index dd632671..d79c9144 100644 --- a/src/components/themes/BaseTheme.cpp +++ b/src/components/themes/BaseTheme.cpp @@ -158,11 +158,12 @@ void BaseTheme::drawSideButtonHints(const GfxRenderer& renderer, const char* top } void BaseTheme::drawList(const GfxRenderer& renderer, Rect rect, int itemCount, int selectedIndex, - const std::function& rowTitle, bool hasSubtitle, - const std::function& rowSubtitle, bool hasIcon, - const std::function& rowIcon, bool hasValue, + const std::function& rowTitle, + const std::function& rowSubtitle, + const std::function& rowIcon, const std::function& rowValue) const { - int rowHeight = hasSubtitle ? BaseMetrics::values.listWithSubtitleRowHeight : BaseMetrics::values.listRowHeight; + int rowHeight = + (rowSubtitle != nullptr) ? BaseMetrics::values.listWithSubtitleRowHeight : BaseMetrics::values.listRowHeight; int pageItems = rect.height / rowHeight; const int totalPages = (itemCount + pageItems - 1) / pageItems; @@ -200,15 +201,15 @@ void BaseTheme::drawList(const GfxRenderer& renderer, Rect rect, int itemCount, const auto pageStartIndex = selectedIndex / pageItems * pageItems; for (int i = pageStartIndex; i < itemCount && i < pageStartIndex + pageItems; i++) { const int itemY = rect.y + (i % pageItems) * rowHeight; - int textWidth = contentWidth - BaseMetrics::values.contentSidePadding * 2 - (hasValue ? 60 : 0); + int textWidth = contentWidth - BaseMetrics::values.contentSidePadding * 2 - (rowValue != nullptr ? 60 : 0); // Draw name auto itemName = rowTitle(i); - auto font = hasSubtitle ? UI_12_FONT_ID : UI_10_FONT_ID; + auto font = (rowSubtitle != nullptr) ? UI_12_FONT_ID : UI_10_FONT_ID; auto item = renderer.truncatedText(font, itemName.c_str(), textWidth); renderer.drawText(font, rect.x + BaseMetrics::values.contentSidePadding, itemY, item.c_str(), i != selectedIndex); - if (hasSubtitle) { + if (rowSubtitle != nullptr) { // Draw subtitle std::string subtitleText = rowSubtitle(i); auto subtitle = renderer.truncatedText(UI_10_FONT_ID, subtitleText.c_str(), textWidth); @@ -216,7 +217,7 @@ void BaseTheme::drawList(const GfxRenderer& renderer, Rect rect, int itemCount, i != selectedIndex); } - if (hasValue) { + if (rowValue != nullptr) { // Draw value std::string valueText = rowValue(i); const auto valueTextWidth = renderer.getTextWidth(UI_10_FONT_ID, valueText.c_str()); @@ -570,7 +571,7 @@ void BaseTheme::drawRecentBookCover(GfxRenderer& renderer, Rect rect, const std: } void BaseTheme::drawButtonMenu(GfxRenderer& renderer, Rect rect, int buttonCount, int selectedIndex, - const std::function& buttonLabel, bool hasIcon, + const std::function& buttonLabel, const std::function& rowIcon) const { for (int i = 0; i < buttonCount; ++i) { const int tileY = BaseMetrics::values.verticalSpacing + rect.y + diff --git a/src/components/themes/BaseTheme.h b/src/components/themes/BaseTheme.h index 43b684d0..11e7a378 100644 --- a/src/components/themes/BaseTheme.h +++ b/src/components/themes/BaseTheme.h @@ -98,9 +98,9 @@ class BaseTheme { const char* btn4) const; virtual void drawSideButtonHints(const GfxRenderer& renderer, const char* topBtn, const char* bottomBtn) const; virtual void drawList(const GfxRenderer& renderer, Rect rect, int itemCount, int selectedIndex, - const std::function& rowTitle, bool hasSubtitle, - const std::function& rowSubtitle, bool hasIcon, - const std::function& rowIcon, bool hasValue, + const std::function& rowTitle, + const std::function& rowSubtitle, + const std::function& rowIcon, const std::function& rowValue) const; virtual void drawHeader(const GfxRenderer& renderer, Rect rect, const char* title) const; @@ -110,7 +110,7 @@ class BaseTheme { const int selectorIndex, bool& coverRendered, bool& coverBufferStored, bool& bufferRestored, std::function storeCoverBuffer) const; virtual void drawButtonMenu(GfxRenderer& renderer, Rect rect, int buttonCount, int selectedIndex, - const std::function& buttonLabel, bool hasIcon, + const std::function& buttonLabel, const std::function& rowIcon) const; virtual Rect drawPopup(const GfxRenderer& renderer, const char* message) const; virtual void fillPopupProgress(const GfxRenderer& renderer, const Rect& layout, const int progress) const; diff --git a/src/components/themes/lyra/LyraTheme.cpp b/src/components/themes/lyra/LyraTheme.cpp index 1ce4cdbe..71d6a15d 100644 --- a/src/components/themes/lyra/LyraTheme.cpp +++ b/src/components/themes/lyra/LyraTheme.cpp @@ -115,11 +115,12 @@ void LyraTheme::drawTabBar(const GfxRenderer& renderer, Rect rect, const std::ve } void LyraTheme::drawList(const GfxRenderer& renderer, Rect rect, int itemCount, int selectedIndex, - const std::function& rowTitle, bool hasSubtitle, - const std::function& rowSubtitle, bool hasIcon, - const std::function& rowIcon, bool hasValue, + const std::function& rowTitle, + const std::function& rowSubtitle, + const std::function& rowIcon, const std::function& rowValue) const { - int rowHeight = hasSubtitle ? LyraMetrics::values.listWithSubtitleRowHeight : LyraMetrics::values.listRowHeight; + int rowHeight = + (rowSubtitle != nullptr) ? LyraMetrics::values.listWithSubtitleRowHeight : LyraMetrics::values.listRowHeight; int pageItems = rect.height / rowHeight; const int totalPages = (itemCount + pageItems - 1) / pageItems; @@ -153,13 +154,13 @@ void LyraTheme::drawList(const GfxRenderer& renderer, Rect rect, int itemCount, // Draw name int textWidth = contentWidth - LyraMetrics::values.contentSidePadding * 2 - hPaddingInSelection * 2 - - (hasValue ? 60 : 0); // TODO truncate according to value width? + (rowValue != nullptr ? 60 : 0); // TODO truncate according to value width? auto itemName = rowTitle(i); auto item = renderer.truncatedText(UI_10_FONT_ID, itemName.c_str(), textWidth); renderer.drawText(UI_10_FONT_ID, rect.x + LyraMetrics::values.contentSidePadding + hPaddingInSelection * 2, itemY + 6, item.c_str(), true); - if (hasSubtitle) { + if (rowSubtitle != nullptr) { // Draw subtitle std::string subtitleText = rowSubtitle(i); auto subtitle = renderer.truncatedText(SMALL_FONT_ID, subtitleText.c_str(), textWidth); @@ -167,7 +168,7 @@ void LyraTheme::drawList(const GfxRenderer& renderer, Rect rect, int itemCount, itemY + 30, subtitle.c_str(), true); } - if (hasValue) { + if (rowValue != nullptr) { // Draw value std::string valueText = rowValue(i); if (!valueText.empty()) { @@ -329,7 +330,7 @@ void LyraTheme::drawRecentBookCover(GfxRenderer& renderer, Rect rect, const std: } void LyraTheme::drawButtonMenu(GfxRenderer& renderer, Rect rect, int buttonCount, int selectedIndex, - const std::function& buttonLabel, bool hasIcon, + const std::function& buttonLabel, const std::function& rowIcon) const { for (int i = 0; i < buttonCount; ++i) { int tileWidth = (rect.width - LyraMetrics::values.contentSidePadding * 2 - LyraMetrics::values.menuSpacing) / 2; diff --git a/src/components/themes/lyra/LyraTheme.h b/src/components/themes/lyra/LyraTheme.h index f2e28970..f00758cf 100644 --- a/src/components/themes/lyra/LyraTheme.h +++ b/src/components/themes/lyra/LyraTheme.h @@ -41,15 +41,15 @@ class LyraTheme : public BaseTheme { void drawTabBar(const GfxRenderer& renderer, Rect rect, const std::vector& tabs, bool selected) const override; void drawList(const GfxRenderer& renderer, Rect rect, int itemCount, int selectedIndex, - const std::function& rowTitle, bool hasSubtitle, - const std::function& rowSubtitle, bool hasIcon, - const std::function& rowIcon, bool hasValue, + const std::function& rowTitle, + const std::function& rowSubtitle, + const std::function& rowIcon, const std::function& rowValue) const override; void drawButtonHints(GfxRenderer& renderer, const char* btn1, const char* btn2, const char* btn3, const char* btn4) const override; void drawSideButtonHints(const GfxRenderer& renderer, const char* topBtn, const char* bottomBtn) const override; void drawButtonMenu(GfxRenderer& renderer, Rect rect, int buttonCount, int selectedIndex, - const std::function& buttonLabel, bool hasIcon, + const std::function& buttonLabel, const std::function& rowIcon) const override; void drawRecentBookCover(GfxRenderer& renderer, Rect rect, const std::vector& recentBooks, const int selectorIndex, bool& coverRendered, bool& coverBufferStored, bool& bufferRestored,