mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-17 07:45:45 -04:00
FullscreenUI: Support modal error/confirmation
This commit is contained in:
@ -39,6 +39,8 @@ using ImGuiFullscreen::LAYOUT_LARGE_FONT_SIZE;
|
||||
using ImGuiFullscreen::LAYOUT_MEDIUM_FONT_SIZE;
|
||||
using ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT;
|
||||
using ImGuiFullscreen::LAYOUT_MENU_BUTTON_HEIGHT_NO_SUMMARY;
|
||||
using ImGuiFullscreen::LAYOUT_MENU_BUTTON_X_PADDING;
|
||||
using ImGuiFullscreen::LAYOUT_MENU_BUTTON_Y_PADDING;
|
||||
using ImGuiFullscreen::LAYOUT_SCREEN_HEIGHT;
|
||||
using ImGuiFullscreen::LAYOUT_SCREEN_WIDTH;
|
||||
|
||||
@ -2762,6 +2764,98 @@ void DrawAboutWindow()
|
||||
ImGui::PopFont();
|
||||
}
|
||||
|
||||
bool DrawErrorWindow(const char* message)
|
||||
{
|
||||
bool is_open = true;
|
||||
|
||||
ImGuiFullscreen::BeginLayout();
|
||||
|
||||
ImGui::SetNextWindowSize(LayoutScale(500.0f, 0.0f));
|
||||
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
ImGui::OpenPopup("ReportError");
|
||||
|
||||
ImGui::PushFont(g_large_font);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, LayoutScale(10.0f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, LayoutScale(10.0f, 10.0f));
|
||||
|
||||
if (ImGui::BeginPopupModal("ReportError", &is_open, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize))
|
||||
{
|
||||
ImGui::SetCursorPos(LayoutScale(LAYOUT_MENU_BUTTON_X_PADDING, LAYOUT_MENU_BUTTON_Y_PADDING));
|
||||
ImGui::TextWrapped(message);
|
||||
ImGui::GetCurrentWindow()->DC.CursorPos.y += LayoutScale(5.0f);
|
||||
|
||||
BeginMenuButtons();
|
||||
|
||||
if (ActiveButton(ICON_FA_WINDOW_CLOSE " Close", false))
|
||||
{
|
||||
ImGui::CloseCurrentPopup();
|
||||
is_open = false;
|
||||
}
|
||||
EndMenuButtons();
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
ImGui::PopFont();
|
||||
|
||||
ImGuiFullscreen::EndLayout();
|
||||
return !is_open;
|
||||
}
|
||||
|
||||
bool DrawConfirmWindow(const char* message, bool* result)
|
||||
{
|
||||
bool is_open = true;
|
||||
|
||||
ImGuiFullscreen::BeginLayout();
|
||||
|
||||
ImGui::SetNextWindowSize(LayoutScale(500.0f, 0.0f));
|
||||
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
|
||||
ImGui::OpenPopup("ConfirmMessage");
|
||||
|
||||
ImGui::PushFont(g_large_font);
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, LayoutScale(10.0f));
|
||||
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, LayoutScale(10.0f, 10.0f));
|
||||
|
||||
if (ImGui::BeginPopupModal("ConfirmMessage", &is_open, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize))
|
||||
{
|
||||
ImGui::SetCursorPos(LayoutScale(LAYOUT_MENU_BUTTON_X_PADDING, LAYOUT_MENU_BUTTON_Y_PADDING));
|
||||
ImGui::TextWrapped(message);
|
||||
ImGui::GetCurrentWindow()->DC.CursorPos.y += LayoutScale(5.0f);
|
||||
|
||||
BeginMenuButtons();
|
||||
|
||||
bool done = false;
|
||||
|
||||
if (ActiveButton(ICON_FA_CHECK " Yes", false))
|
||||
{
|
||||
*result = true;
|
||||
done = true;
|
||||
}
|
||||
|
||||
if (ActiveButton(ICON_FA_TIMES " No", false))
|
||||
{
|
||||
*result = false;
|
||||
done = true;
|
||||
}
|
||||
if (done)
|
||||
{
|
||||
ImGui::CloseCurrentPopup();
|
||||
is_open = false;
|
||||
}
|
||||
|
||||
EndMenuButtons();
|
||||
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
|
||||
ImGui::PopStyleVar(2);
|
||||
ImGui::PopFont();
|
||||
|
||||
ImGuiFullscreen::EndLayout();
|
||||
return !is_open;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Debug Menu
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
@ -47,6 +47,10 @@ void CloseQuickMenu();
|
||||
void Shutdown();
|
||||
void Render();
|
||||
|
||||
// Returns true if the message has been dismissed.
|
||||
bool DrawErrorWindow(const char* message);
|
||||
bool DrawConfirmWindow(const char* message, bool* result);
|
||||
|
||||
void EnsureGameListLoaded();
|
||||
|
||||
Settings& GetSettingsCopy();
|
||||
|
Reference in New Issue
Block a user