Make prelaunch sticky & kill ImGui prelaunch

This commit is contained in:
Luke Street
2026-05-02 10:44:59 -06:00
parent 9b4a9a6bd9
commit e1c201f4bd
4 changed files with 45 additions and 12 deletions
+7 -10
View File
@@ -324,21 +324,18 @@ namespace dusk {
ImGuiMenuGame::ToggleFullscreen();
}
if (!dusk::IsGameLaunched) {
m_preLaunchWindow.draw();
}
// if (!dusk::IsGameLaunched) {
// m_preLaunchWindow.draw();
// }
m_isHidden = !getSettings().backend.duskMenuOpen;
if (ImGui::GetIO().KeyShift && ImGui::IsKeyPressed(ImGuiKey_F1)) {
m_isHidden = !m_isHidden;
}
bool showMenu = !dusk::IsGameLaunched || !m_isHidden;
if (dusk::IsGameLaunched) {
const bool menuOpen = !m_isHidden;
if (getSettings().backend.duskMenuOpen != menuOpen) {
getSettings().backend.duskMenuOpen.setValue(menuOpen);
Save();
}
bool showMenu = !m_isHidden;
if (getSettings().backend.duskMenuOpen != showMenu) {
getSettings().backend.duskMenuOpen.setValue(showMenu);
Save();
}
// The menu bar renders with ImGuiCol_WindowBg behind it. We just want ImGuiCol_MenuBarBg,
+32
View File
@@ -12,6 +12,8 @@
#include "dusk/main.h"
#include <cmath>
namespace dusk::ui {
namespace {
@@ -67,6 +69,36 @@ void Popup::hide() {
mRoot->RemoveAttribute("open");
}
void Popup::update() {
update_safe_area();
Document::update();
}
void Popup::update_safe_area() noexcept {
if (mDocument == nullptr || mTabBar == nullptr) {
return;
}
Rml::Context* context = mDocument->GetContext();
Insets safeInsets = safe_area_insets(context);
safeInsets = {
0.0f,
std::round(safeInsets.right),
0.0f,
std::round(safeInsets.left),
};
if (safeInsets == mTabBarPadding) {
return;
}
mTabBarPadding = safeInsets;
auto* tabBar = mTabBar->root();
tabBar->SetProperty(
Rml::PropertyId::PaddingRight, Rml::Property(safeInsets.right, Rml::Unit::PX));
tabBar->SetProperty(
Rml::PropertyId::PaddingLeft, Rml::Property(safeInsets.left, Rml::Unit::PX));
}
void Popup::toggle() {
if (visible()) {
hide();
+4
View File
@@ -17,6 +17,7 @@ public:
void show() override;
void hide() override;
void update() override;
bool focus() override;
bool visible() const override;
@@ -26,9 +27,12 @@ protected:
bool handle_nav_command(Rml::Event& event, NavCommand cmd) override;
private:
void update_safe_area() noexcept;
Rml::Element* mRoot;
std::unique_ptr<TabBar> mTabBar;
std::unique_ptr<Button> mCloseButton;
Insets mTabBarPadding;
bool mVisible = false;
};
+2 -2
View File
@@ -110,7 +110,7 @@ Prelaunch::Prelaunch() : Document(kDocumentSource) {
if (auto* menuList = mDocument->GetElementById("menu-list")) {
const bool hasValidPath = is_selected_path_valid();
mMenuButtons.push_back(std::make_unique<Button>(menuList, hasValidPath ? "Start Game" : "Select Disk Image"));
mMenuButtons.back()->on_pressed([this] {
mMenuButtons.back()->on_pressed([] {
if (!is_selected_path_valid()) {
open_iso_picker();
return;
@@ -224,7 +224,7 @@ bool Prelaunch::focus() {
}
bool Prelaunch::handle_nav_command(Rml::Event& event, NavCommand cmd) {
return Document::handle_nav_command(event, cmd);
return false;
}
} // namespace dusk::ui