Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -919,6 +919,12 @@ void Menu::ProcessInputEventQueue()
if (key == event.keyCode)
key = MapVirtualKeyEx(event.keyCode, MAPVK_VSC_TO_VK_EX, GetKeyboardLayout(0));
if (!event.IsPressed()) {
// Skip key release if it was used to close the first-time setup dialog
if (HomePageRenderer::ShouldSkipKeyRelease(key)) {
io.AddKeyEvent(Util::Input::VirtualKeyToImGuiKey(key), event.IsPressed());
continue;
}

struct HotkeyAction
{
uint32_t* settingKey;
Expand Down
25 changes: 20 additions & 5 deletions src/Menu/HomePageRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@

// Static member definitions
bool HomePageRenderer::isFirstTimeSetupShown = false;
uint32_t HomePageRenderer::keyThatClosedDialog = 0;

bool HomePageRenderer::ShouldSkipKeyRelease(uint32_t key)
{
if (keyThatClosedDialog && key == keyThatClosedDialog) {
keyThatClosedDialog = 0;
return true;
}
return false;
}

void HomePageRenderer::RenderHomePage()
{
Expand Down Expand Up @@ -249,6 +259,10 @@ void HomePageRenderer::RenderFAQSection()

void HomePageRenderer::RenderFirstTimeSetupDialog()
{
if (!ShouldShowFirstTimeSetup()) {
return;
}

// Block input to the game and make cursor visible - input blocking is handled by ShouldSwallowInput()
auto& io = ImGui::GetIO();
io.WantCaptureMouse = true;
Expand Down Expand Up @@ -408,9 +422,9 @@ void HomePageRenderer::RenderFirstTimeSetupDialog()
ImGui::Spacing();

// Check for Enter or Escape key to close, but only if not capturing a hotkey
if ((ImGui::IsKeyPressed(ImGuiKey_Enter) || ImGui::IsKeyPressed(ImGuiKey_Escape)) && !isCapturing) {
MarkFirstTimeSetupComplete();
// Note: Settings are automatically saved to ensure welcome screen won't show again
bool escapePressed = ImGui::IsKeyPressed(ImGuiKey_Escape);
if ((ImGui::IsKeyPressed(ImGuiKey_Enter) || escapePressed) && !isCapturing) {
MarkFirstTimeSetupComplete(escapePressed ? VK_ESCAPE : VK_RETURN);
}

// Help text with breathing animation
Expand Down Expand Up @@ -444,7 +458,7 @@ bool HomePageRenderer::ShouldShowFirstTimeSetup()
return !menu->GetSettings().FirstTimeSetupCompleted;
}

void HomePageRenderer::MarkFirstTimeSetupComplete()
void HomePageRenderer::MarkFirstTimeSetupComplete(uint32_t closingKey)
{
// Set the flag in the Menu settings
auto menu = Menu::GetSingleton();
Expand All @@ -454,5 +468,6 @@ void HomePageRenderer::MarkFirstTimeSetupComplete()
// This prevents the welcome screen from showing again even if user doesn't manually save
globals::state->Save();

isFirstTimeSetupShown = true; // Mark as shown this session
isFirstTimeSetupShown = true;
keyThatClosedDialog = closingKey;
}
6 changes: 5 additions & 1 deletion src/Menu/HomePageRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ class HomePageRenderer
static bool ShouldShowFirstTimeSetup();
static void RenderFirstTimeSetupDialog();

// Returns true and clears state if key release should be skipped (was used to close dialog)
static bool ShouldSkipKeyRelease(uint32_t key);

private:
static void RenderWelcomeSection();
static void RenderQuickLinksSection();
static void RenderFAQSection();

static void MarkFirstTimeSetupComplete();
static void MarkFirstTimeSetupComplete(uint32_t closingKey);

// State
static bool isFirstTimeSetupShown;
static uint32_t keyThatClosedDialog;
};