Skip to content

Commit

Permalink
Separate the UIs from BMLMod with some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
doyaGu committed Sep 15, 2024
1 parent 3f4bdf4 commit 717dc45
Show file tree
Hide file tree
Showing 12 changed files with 1,283 additions and 901 deletions.
19 changes: 12 additions & 7 deletions include/BML/Bui.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <string>
#include <stack>
#include <vector>
#include <unordered_map>
#include <functional>
#include <utility>
Expand All @@ -12,7 +11,6 @@

#include "BML/Export.h"
#include "CKContext.h"
#include "CKRenderContext.h"

namespace Bui {
enum ButtonType {
Expand Down Expand Up @@ -143,6 +141,7 @@ namespace Bui {
OnEnd();
m_Hovered = ImGui::IsWindowHovered();
ImGui::End();
OnAfterEnd();
}

void Render() {
Expand All @@ -161,6 +160,7 @@ namespace Bui {
virtual void OnAfterBegin() {}
virtual void OnDraw() = 0;
virtual void OnEnd() {}
virtual void OnAfterEnd() {}
virtual void OnShow() {}
virtual void OnHide() {}

Expand Down Expand Up @@ -337,6 +337,7 @@ namespace Bui {
class Menu {
public:
Menu() = default;
virtual ~Menu() = default;

bool AddPage(Page *page) {
if (!page)
Expand Down Expand Up @@ -386,14 +387,17 @@ namespace Bui {
m_CurrentPage->Show();
return true;
}
void ShowPrevPage() {
bool ShowPrevPage() {
HidePage();
auto *page = PopPage();
m_CurrentPage = page;
if (m_CurrentPage)
m_CurrentPage->Show();
else
if (m_CurrentPage) {
m_CurrentPage->Show();
return true;
} else {
OnClose();
return false;
}
}

void HidePage() {
Expand All @@ -414,7 +418,8 @@ namespace Bui {
}

void Close() {
ShowPrevPage();
HidePage();
m_CurrentPage = PopPage();
HidePage();
OnClose();
}
Expand Down
Loading

0 comments on commit 717dc45

Please sign in to comment.