BPM: Add Network and HDD settings page

Signed-off-by: SternXD <stern@sidestore.io>
This commit is contained in:
SternXD
2025-10-24 21:41:42 -04:00
committed by Ty
parent 5445cb516a
commit 5fe5148e86
4 changed files with 917 additions and 50 deletions
File diff suppressed because it is too large Load Diff
+3
View File
@@ -40,6 +40,9 @@ namespace FullscreenUI
void Render();
void InvalidateCoverCache();
TinyString TimeToPrintableString(time_t t);
bool CreateHardDriveWithProgress(const std::string& filePath, int sizeInGB, bool use48BitLBA = true);
void CancelAllHddOperations();
} // namespace FullscreenUI
// Host UI triggers from Big Picture mode.
+83 -49
View File
@@ -121,6 +121,7 @@ namespace ImGuiFullscreen
static std::string s_input_dialog_text;
static std::string s_input_dialog_ok_text;
static InputStringDialogCallback s_input_dialog_callback;
static InputFilterType s_input_dialog_filter_type = InputFilterType::None;
static bool s_message_dialog_open = false;
static std::string s_message_dialog_title;
@@ -2492,14 +2493,17 @@ bool ImGuiFullscreen::IsInputDialogOpen()
}
void ImGuiFullscreen::OpenInputStringDialog(
std::string title, std::string message, std::string caption, std::string ok_button_text, InputStringDialogCallback callback)
std::string title, std::string message, std::string caption, std::string ok_button_text, InputStringDialogCallback callback,
std::string default_value, InputFilterType filter_type)
{
s_input_dialog_open = true;
s_input_dialog_title = std::move(title);
s_input_dialog_message = std::move(message);
s_input_dialog_caption = std::move(caption);
s_input_dialog_ok_text = std::move(ok_button_text);
s_input_dialog_text = std::move(default_value);
s_input_dialog_callback = std::move(callback);
s_input_dialog_filter_type = filter_type;
QueueResetFocus(FocusResetType::PopupOpened);
}
@@ -2520,10 +2524,11 @@ void ImGuiFullscreen::DrawInputDialog()
ImGui::PushStyleColor(ImGuiCol_Text, UIPrimaryTextColor);
ImGui::PushStyleColor(ImGuiCol_TitleBg, UIPrimaryDarkColor);
ImGui::PushStyleColor(ImGuiCol_TitleBgActive, UIPrimaryColor);
ImGui::PushStyleColor(ImGuiCol_PopupBg, UIBackgroundColor);
bool is_open = true;
if (ImGui::BeginPopupModal(s_input_dialog_title.c_str(), &is_open,
ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove))
ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove))
{
ResetFocusHere();
ImGui::TextWrapped("%s", s_input_dialog_message.c_str());
@@ -2542,7 +2547,40 @@ void ImGuiFullscreen::DrawInputDialog()
{
ImGui::SetNextItemWidth(ImGui::GetCurrentWindow()->WorkRect.GetWidth());
}
ImGui::InputText("##input", &s_input_dialog_text);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + LayoutScale(10.0f));
static auto input_callback = [](ImGuiInputTextCallbackData* data) -> int {
InputFilterType* filter_type = static_cast<InputFilterType*>(data->UserData);
if (data->EventFlag == ImGuiInputTextFlags_CallbackCharFilter) {
char c = static_cast<char>(data->EventChar);
if (*filter_type == InputFilterType::Numeric) {
if (!std::isdigit(c)) {
return 1;
}
}
else if (*filter_type == InputFilterType::IPAddress) {
if (!std::isdigit(c) && c != '.') {
return 1;
}
}
}
return 0;
};
ImGuiInputTextFlags flags = ImGuiInputTextFlags_None;
if (s_input_dialog_filter_type != InputFilterType::None)
flags |= ImGuiInputTextFlags_CallbackCharFilter;
if (s_focus_reset_queued != FocusResetType::None)
ImGui::SetKeyboardFocusHere();
ImGui::InputText("##input", &s_input_dialog_text, flags,
(s_input_dialog_filter_type != InputFilterType::None) ? input_callback : nullptr,
(s_input_dialog_filter_type != InputFilterType::None) ? static_cast<void*>(&s_input_dialog_filter_type) : nullptr);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + LayoutScale(10.0f));
@@ -2574,7 +2612,7 @@ void ImGuiFullscreen::DrawInputDialog()
else
GetInputDialogHelpText(s_fullscreen_footer_text);
ImGui::PopStyleColor(3);
ImGui::PopStyleColor(4);
ImGui::PopStyleVar(3);
ImGui::PopFont();
}
@@ -2591,6 +2629,7 @@ void ImGuiFullscreen::CloseInputDialog()
s_input_dialog_ok_text = {};
s_input_dialog_text = {};
s_input_dialog_callback = {};
s_input_dialog_filter_type = InputFilterType::None;
}
bool ImGuiFullscreen::IsMessageBoxDialogOpen()
@@ -2831,61 +2870,56 @@ void ImGuiFullscreen::DrawBackgroundProgressDialogs(ImVec2& position, float spac
if (s_background_progress_dialogs.empty())
return;
const float window_width = LayoutScale(500.0f);
const float window_height = LayoutScale(75.0f);
ImGui::PushStyleColor(ImGuiCol_WindowBg, UIPrimaryDarkColor);
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, UISecondaryStrongColor);
ImGui::PushStyleVar(ImGuiStyleVar_PopupRounding, LayoutScale(4.0f));
ImGui::PushStyleVar(ImGuiStyleVar_PopupBorderSize, LayoutScale(1.0f));
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, LayoutScale(10.0f, 10.0f));
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, LayoutScale(10.0f, 10.0f));
ImGui::PushFont(g_medium_font.first, g_medium_font.second);
ImDrawList* dl = ImGui::GetForegroundDrawList();
for (const BackgroundProgressDialogData& data : s_background_progress_dialogs)
{
const float window_pos_x = position.x;
const float window_pos_y = position.y - ((s_notification_vertical_direction < 0.0f) ? window_height : 0.0f);
const std::string popup_id = fmt::format("##background_progress_dialog_{}", data.id);
ImGui::SetNextWindowSize(LayoutScale(600.0f, 0.0f));
ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
ImGui::OpenPopup(popup_id.c_str());
dl->AddRectFilled(ImVec2(window_pos_x, window_pos_y), ImVec2(window_pos_x + window_width, window_pos_y + window_height),
IM_COL32(0x11, 0x11, 0x11, 200), LayoutScale(10.0f));
ImGui::PushFont(g_large_font.first, g_large_font.second);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, LayoutScale(20.0f, 20.0f));
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, LayoutScale(10.0f));
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, LayoutScale(LAYOUT_MENU_BUTTON_X_PADDING, LAYOUT_MENU_BUTTON_Y_PADDING));
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f);
ImGui::PushStyleColor(ImGuiCol_Text, UIPrimaryTextColor);
ImGui::PushStyleColor(ImGuiCol_TitleBg, UIPrimaryDarkColor);
ImGui::PushStyleColor(ImGuiCol_TitleBgActive, UIPrimaryColor);
ImGui::PushStyleColor(ImGuiCol_PopupBg, UIBackgroundColor);
ImGui::PushStyleColor(ImGuiCol_PlotHistogram, UISecondaryColor);
ImVec2 pos(window_pos_x + LayoutScale(10.0f), window_pos_y + LayoutScale(10.0f));
dl->AddText(g_medium_font.first, g_medium_font.second, pos, IM_COL32(255, 255, 255, 255), data.message.c_str(), nullptr, 0.0f);
pos.y += g_medium_font.second + LayoutScale(10.0f);
bool is_open = true;
const u32 flags = ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar;
const ImVec2 box_end(pos.x + window_width - LayoutScale(10.0f * 2.0f), pos.y + LayoutScale(25.0f));
dl->AddRectFilled(pos, box_end, ImGui::GetColorU32(UIPrimaryDarkColor));
if (data.min != data.max)
if (ImGui::BeginPopupModal(popup_id.c_str(), &is_open, flags))
{
const float fraction = static_cast<float>(data.value - data.min) / static_cast<float>(data.max - data.min);
dl->AddRectFilled(pos, ImVec2(pos.x + fraction * (box_end.x - pos.x), box_end.y), ImGui::GetColorU32(UISecondaryColor));
BeginMenuButtons();
ResetFocusHere();
const std::string text(fmt::format("{}%", static_cast<int>(std::round(fraction * 100.0f))));
const ImVec2 text_size(ImGui::CalcTextSize(text.c_str()));
const ImVec2 text_pos(
pos.x + ((box_end.x - pos.x) / 2.0f) - (text_size.x / 2.0f), pos.y + ((box_end.y - pos.y) / 2.0f) - (text_size.y / 2.0f));
dl->AddText(g_medium_font.first, g_medium_font.second, text_pos, ImGui::GetColorU32(UIPrimaryTextColor), text.c_str());
}
else
{
// indeterminate, so draw a scrolling bar
const float bar_width = LayoutScale(30.0f);
const float fraction = std::fmod(ImGui::GetTime(), 2.0f) * 0.5f;
const ImVec2 bar_start(pos.x + ImLerp(0.0f, box_end.x, fraction) - bar_width, pos.y);
const ImVec2 bar_end(std::min(bar_start.x + bar_width, box_end.x), pos.y + LayoutScale(25.0f));
dl->AddRectFilled(ImClamp(bar_start, pos, box_end), ImClamp(bar_end, pos, box_end), ImGui::GetColorU32(UISecondaryColor));
ImGui::TextWrapped("%s", data.message.c_str());
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + LayoutScale(20.0f));
if (data.min != data.max)
{
const float progress = static_cast<float>(data.value - data.min) / static_cast<float>(data.max - data.min);
ImGui::ProgressBar(progress, ImVec2(-1.0f, LayoutScale(30.0f)));
}
else
{
const float fraction = std::fmod(ImGui::GetTime(), 2.0f) * 0.5f;
ImGui::ProgressBar(fraction, ImVec2(-1.0f, LayoutScale(30.0f)));
}
EndMenuButtons();
ImGui::EndPopup();
}
position.y += s_notification_vertical_direction * (window_height + spacing);
ImGui::PopStyleColor(5);
ImGui::PopStyleVar(4);
ImGui::PopFont();
break;
}
ImGui::PopFont();
ImGui::PopStyleVar(4);
ImGui::PopStyleColor(2);
}
//////////////////////////////////////////////////////////////////////////
+9 -1
View File
@@ -257,8 +257,16 @@ namespace ImGuiFullscreen
using InputStringDialogCallback = std::function<void(std::string text)>;
bool IsInputDialogOpen();
enum class InputFilterType : u8
{
None,
Numeric,
IPAddress
};
void OpenInputStringDialog(
std::string title, std::string message, std::string caption, std::string ok_button_text, InputStringDialogCallback callback);
std::string title, std::string message, std::string caption, std::string ok_button_text, InputStringDialogCallback callback,
std::string default_value = std::string(), InputFilterType filter_type = InputFilterType::None);
void CloseInputDialog();
using ConfirmMessageDialogCallback = std::function<void(bool)>;