diff --git a/sphaira/include/ui/menus/ghdl.hpp b/sphaira/include/ui/menus/ghdl.hpp index 372d2a5..75c5c8e 100644 --- a/sphaira/include/ui/menus/ghdl.hpp +++ b/sphaira/include/ui/menus/ghdl.hpp @@ -68,7 +68,6 @@ private: private: std::vector m_entries; s64 m_index{}; - s64 m_index_offset{}; std::unique_ptr m_list; }; diff --git a/sphaira/include/ui/popup_list.hpp b/sphaira/include/ui/popup_list.hpp index 1bfb3c7..ddf9dc7 100644 --- a/sphaira/include/ui/popup_list.hpp +++ b/sphaira/include/ui/popup_list.hpp @@ -36,7 +36,6 @@ private: Items m_items; Callback m_callback; s64 m_index; // index in list array - s64 m_index_offset{}; // drawing from array start std::unique_ptr m_list; diff --git a/sphaira/include/ui/sidebar.hpp b/sphaira/include/ui/sidebar.hpp index 24a8b96..3489c7d 100644 --- a/sphaira/include/ui/sidebar.hpp +++ b/sphaira/include/ui/sidebar.hpp @@ -13,7 +13,6 @@ public: protected: std::string m_title; - Vec2 m_offset{}; }; class SidebarEntryBool final : public SidebarEntryBase { @@ -117,7 +116,6 @@ private: Side m_side; Items m_items; s64 m_index{}; - s64 m_index_offset{}; std::unique_ptr m_list; diff --git a/sphaira/source/ui/menus/appstore.cpp b/sphaira/source/ui/menus/appstore.cpp index 7e7acd3..21dfefe 100644 --- a/sphaira/source/ui/menus/appstore.cpp +++ b/sphaira/source/ui/menus/appstore.cpp @@ -767,11 +767,6 @@ void EntryMenu::Draw(NVGcontext* vg, Theme* theme) { if (m_index == i) { text_id = ThemeEntryID_TEXT_SELECTED; gfx::drawRectOutline(vg, 4.f, theme->elements[ThemeEntryID_SELECTED_OVERLAY].colour, x, y, w, h, theme->elements[ThemeEntryID_SELECTED].colour); - } else { - // if (i == m_index_offset) { - // gfx::drawRect(vg, x, y, w, 1.f, text_col); - // } - // gfx::drawRect(vg, x, y + h, w, 1.f, text_col); } gfx::drawTextArgs(vg, x + w / 2, y + h / 2, 22, NVG_ALIGN_MIDDLE | NVG_ALIGN_CENTER, theme->elements[ThemeEntryID_TEXT].colour, option.display_text.c_str()); diff --git a/sphaira/source/ui/menus/ghdl.cpp b/sphaira/source/ui/menus/ghdl.cpp index a3c1552..a19fcc1 100644 --- a/sphaira/source/ui/menus/ghdl.cpp +++ b/sphaira/source/ui/menus/ghdl.cpp @@ -404,7 +404,7 @@ void Menu::Draw(NVGcontext* vg, Theme* theme) { text_id = ThemeEntryID_TEXT_SELECTED; gfx::drawRectOutline(vg, 4.f, theme->elements[ThemeEntryID_SELECTED_OVERLAY].colour, x, y, w, h, theme->elements[ThemeEntryID_SELECTED].colour); } else { - if (i == m_index_offset) { + if (i == m_index) { gfx::drawRect(vg, x, y, w, 1.f, text_col); } gfx::drawRect(vg, x, y + h, w, 1.f, text_col); @@ -429,11 +429,7 @@ void Menu::OnFocusGained() { void Menu::SetIndex(s64 index) { m_index = index; if (!m_index) { - m_index_offset = 0; - } - - if (m_index > m_index_offset && m_index - m_index_offset >= 7) { - m_index_offset = m_index - 7; + m_list->SetYoff(0); } SetTitleSubHeading(m_entries[m_index].json_path); @@ -442,8 +438,6 @@ void Menu::SetIndex(s64 index) { void Menu::Scan() { m_entries.clear(); - m_index = 0; - m_index_offset = 0; // load from romfs first if (R_SUCCEEDED(romfsInit())) { diff --git a/sphaira/source/ui/popup_list.cpp b/sphaira/source/ui/popup_list.cpp index 232c645..82ca5e6 100644 --- a/sphaira/source/ui/popup_list.cpp +++ b/sphaira/source/ui/popup_list.cpp @@ -23,7 +23,7 @@ PopupList::PopupList(std::string title, Items items, std::string& index_ref) if (it != m_items.cend()) { m_index = std::distance(m_items.cbegin(), it); if (m_index >= 7) { - m_index_offset = m_index - 6; + // m_list->SetYoff((m_index - 6) * m_list->GetMaxY()); } } @@ -51,7 +51,7 @@ PopupList::PopupList(std::string title, Items items, Callback cb, std::string in if (it != m_items.cend()) { SetIndex(std::distance(m_items.cbegin(), it)); if (m_index >= 7) { - m_index_offset = m_index - 6; + // m_list->SetYoff((m_index - 6) * m_list->GetMaxY()); } } } @@ -89,15 +89,16 @@ PopupList::PopupList(std::string title, Items items, Callback cb, s64 index) m_pos.y = 720.f - m_pos.h; m_line_top = m_pos.y + 70.f; m_line_bottom = 720.f - 73.f; - if (m_index >= 7) { - m_index_offset = m_index - 6; - } Vec4 v{m_block}; v.y = m_line_top + 1.f + 42.f; const Vec4 pos{0, m_line_top, 1280.f, m_line_bottom - m_line_top}; m_list = std::make_unique(1, 7, pos, v); m_list->SetScrollBarPos(1250, m_line_top + 20, m_line_bottom - m_line_top - 40); + + if (m_index >= 7) { + m_list->SetYoff((m_index - 6) * m_list->GetMaxY()); + } } auto PopupList::Update(Controller* controller, TouchInfo* touch) -> void { @@ -143,10 +144,6 @@ auto PopupList::OnFocusLost() noexcept -> void { void PopupList::SetIndex(s64 index) { m_index = index; - - if (m_index > m_index_offset && m_index - m_index_offset >= 6) { - m_index_offset = m_index - 6; - } } } // namespace sphaira::ui diff --git a/sphaira/source/ui/sidebar.cpp b/sphaira/source/ui/sidebar.cpp index 59564a1..e3fda9d 100644 --- a/sphaira/source/ui/sidebar.cpp +++ b/sphaira/source/ui/sidebar.cpp @@ -266,11 +266,6 @@ void Sidebar::SetIndex(s64 index) { m_items[m_index]->OnFocusLost(); m_index = index; m_items[m_index]->OnFocusGained(); - - if (m_index > m_index_offset && m_index - m_index_offset >= 5) { - m_index_offset = m_index - 5; - } - SetupButtons(); } }