Skip to content

Commit

Permalink
Update MapListPage
Browse files Browse the repository at this point in the history
  • Loading branch information
doyaGu committed Jul 11, 2024
1 parent de30438 commit 746262f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
32 changes: 14 additions & 18 deletions src/BMLMod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,29 +410,13 @@ void MapListPage::OnDraw() {

if (m_MapSearchBuf[0] == '\0') {
DrawEntries([&](std::size_t index) {
if (index >= m_Maps.size())
return false;
auto &info = m_Maps[n + index];
if (Bui::LevelButton(info.name.c_str(), &v)) {
Hide();
m_Mod->OnCloseMapMenu(false);
m_Mod->LoadMap(info.path);
}
return true;
return OnDrawEntry(n + index, &v);
}, ImVec2(0.4031f, 0.23f), 0.06f, 10);
} else {
DrawEntries([&](std::size_t index) {
if (index >= m_MapSearchResult.size())
return false;

auto &info = m_Maps[m_MapSearchResult[n + index]];

if (Bui::LevelButton(info.name.c_str(), &v)) {
Hide();
m_Mod->OnCloseMapMenu(false);
m_Mod->LoadMap(info.path);
}
return true;
return OnDrawEntry(m_MapSearchResult[n + index], &v);
}, ImVec2(0.4031f, 0.23f), 0.06f, 10);
}
}
Expand Down Expand Up @@ -529,6 +513,18 @@ void MapListPage::OnSearchMaps() {
onig_free(reg);
}

bool MapListPage::OnDrawEntry(std::size_t index, bool *v) {
if (index >= m_Maps.size())
return false;
auto &info = m_Maps[index];
if (Bui::LevelButton(info.name.c_str(), v)) {
Hide();
m_Mod->OnCloseMapMenu(false);
m_Mod->LoadMap(info.path);
}
return true;
}

void BMLMod::OnLoad() {
m_CKContext = m_BML->GetCKContext();
m_RenderContext = m_BML->GetRenderContext();
Expand Down
1 change: 1 addition & 0 deletions src/BMLMod.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ class MapListPage : public Bui::Page {

size_t ExploreMaps(const std::wstring &path, std::vector<MapInfo> &maps);
void OnSearchMaps();
bool OnDrawEntry(std::size_t index, bool *v);

BMLMod *m_Mod;
char m_MapSearchBuf[65536] = {};
Expand Down

0 comments on commit 746262f

Please sign in to comment.