ui: add title to select file/folder popups. fix frame padding
android: always do write test in new home folder
This commit is contained in:
parent
aed4d21a4f
commit
46340e7e77
129
core/ui/gui.cpp
129
core/ui/gui.cpp
|
@ -130,13 +130,12 @@ void gui_init()
|
|||
return;
|
||||
inited = true;
|
||||
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
#if FC_PROFILER
|
||||
ImPlot::CreateContext();
|
||||
#endif
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.BackendFlags |= ImGuiBackendFlags_HasGamepad;
|
||||
|
||||
io.IniFilename = NULL;
|
||||
|
@ -1562,8 +1561,9 @@ static void contentpath_warning_popup()
|
|||
if (show_contentpath_selection)
|
||||
{
|
||||
scanner.stop();
|
||||
ImGui::OpenPopup("Select Directory");
|
||||
select_file_popup("Select Directory", [](bool cancelled, std::string selection)
|
||||
const char *title = "Select a Content Directory";
|
||||
ImGui::OpenPopup(title);
|
||||
select_file_popup(title, [](bool cancelled, std::string selection)
|
||||
{
|
||||
show_contentpath_selection = false;
|
||||
if (!cancelled)
|
||||
|
@ -1708,8 +1708,8 @@ static void gui_settings_general()
|
|||
if (ImGui::Button("X"))
|
||||
to_delete = i;
|
||||
}
|
||||
ImguiStyleVar _(ImGuiStyleVar_FramePadding, ScaledVec2(24, 3));
|
||||
#ifdef __ANDROID__
|
||||
ImguiStyleVar _(ImGuiStyleVar_FramePadding, ScaledVec2(24, 3));
|
||||
if (ImGui::Button("Add"))
|
||||
{
|
||||
hostfs::addStorage(true, false, [](bool cancelled, std::string selection) {
|
||||
|
@ -1718,13 +1718,15 @@ static void gui_settings_general()
|
|||
});
|
||||
}
|
||||
#else
|
||||
if (ImGui::Button("Add"))
|
||||
ImGui::OpenPopup("Select Directory");
|
||||
select_file_popup("Select Directory", [](bool cancelled, std::string selection) {
|
||||
const char *title = "Select a Content Directory";
|
||||
select_file_popup(title, [](bool cancelled, std::string selection) {
|
||||
if (!cancelled)
|
||||
addContentPath(selection);
|
||||
return true;
|
||||
});
|
||||
ImguiStyleVar _(ImGuiStyleVar_FramePadding, ScaledVec2(24, 3));
|
||||
if (ImGui::Button("Add"))
|
||||
ImGui::OpenPopup(title);
|
||||
#endif
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("Rescan Content"))
|
||||
|
@ -2860,27 +2862,7 @@ static void gui_settings_about()
|
|||
#if defined(__ANDROID__) && HOST_CPU == CPU_ARM64 && USE_VULKAN
|
||||
if (isVulkan(config::RendererType))
|
||||
{
|
||||
ImguiStyleVar _(ImGuiStyleVar_FramePadding, ScaledVec2(20, 10));
|
||||
if (config::CustomGpuDriver)
|
||||
{
|
||||
std::string name, description, vendor, version;
|
||||
if (getCustomGpuDriverInfo(name, description, vendor, version))
|
||||
{
|
||||
ImGui::Text("Custom Driver:");
|
||||
ImGui::Indent();
|
||||
ImGui::Text("%s - %s", name.c_str(), description.c_str());
|
||||
ImGui::Text("%s - %s", vendor.c_str(), version.c_str());
|
||||
ImGui::Unindent();
|
||||
}
|
||||
|
||||
if (ImGui::Button("Use Default Driver")) {
|
||||
config::CustomGpuDriver = false;
|
||||
ImGui::OpenPopup("Reset Vulkan");
|
||||
}
|
||||
}
|
||||
else if (ImGui::Button("Upload Custom Driver"))
|
||||
ImGui::OpenPopup("Select custom GPU driver");
|
||||
|
||||
const char *fileSelectTitle = "Select a custom GPU driver";
|
||||
static bool driverDirty;
|
||||
const auto& callback = [](bool cancelled, std::string selection) {
|
||||
if (!cancelled) {
|
||||
|
@ -2895,30 +2877,53 @@ static void gui_settings_about()
|
|||
}
|
||||
return true;
|
||||
};
|
||||
select_file_popup("Select custom GPU driver", callback, true, "zip");
|
||||
|
||||
if (driverDirty) {
|
||||
ImGui::OpenPopup("Reset Vulkan");
|
||||
driverDirty = false;
|
||||
}
|
||||
|
||||
ImguiStyleVar _1(ImGuiStyleVar_WindowPadding, ScaledVec2(20, 20));
|
||||
if (ImGui::BeginPopupModal("Reset Vulkan", NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar))
|
||||
{
|
||||
ImGui::Text("Do you want to reset Vulkan to use new driver?");
|
||||
ImGui::NewLine();
|
||||
ImguiStyleVar _(ImGuiStyleVar_ItemSpacing, ImVec2(uiScaled(20), ImGui::GetStyle().ItemSpacing.y));
|
||||
ImguiStyleVar _1(ImGuiStyleVar_FramePadding, ScaledVec2(10, 10));
|
||||
if (ImGui::Button("Yes"))
|
||||
ImguiStyleVar _(ImGuiStyleVar_FramePadding, ScaledVec2(20, 10));
|
||||
if (config::CustomGpuDriver)
|
||||
{
|
||||
mainui_reinit();
|
||||
ImGui::CloseCurrentPopup();
|
||||
std::string name, description, vendor, version;
|
||||
if (getCustomGpuDriverInfo(name, description, vendor, version))
|
||||
{
|
||||
ImGui::Text("Custom Driver:");
|
||||
ImGui::Indent();
|
||||
ImGui::Text("%s - %s", name.c_str(), description.c_str());
|
||||
ImGui::Text("%s - %s", vendor.c_str(), version.c_str());
|
||||
ImGui::Unindent();
|
||||
}
|
||||
|
||||
if (ImGui::Button("Use Default Driver")) {
|
||||
config::CustomGpuDriver = false;
|
||||
ImGui::OpenPopup("Reset Vulkan");
|
||||
}
|
||||
}
|
||||
else if (ImGui::Button("Upload Custom Driver"))
|
||||
ImGui::OpenPopup(fileSelectTitle);
|
||||
|
||||
if (driverDirty) {
|
||||
ImGui::OpenPopup("Reset Vulkan");
|
||||
driverDirty = false;
|
||||
}
|
||||
|
||||
ImguiStyleVar _1(ImGuiStyleVar_WindowPadding, ScaledVec2(20, 20));
|
||||
if (ImGui::BeginPopupModal("Reset Vulkan", NULL, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar))
|
||||
{
|
||||
ImGui::Text("Do you want to reset Vulkan to use new driver?");
|
||||
ImGui::NewLine();
|
||||
ImguiStyleVar _(ImGuiStyleVar_ItemSpacing, ImVec2(uiScaled(20), ImGui::GetStyle().ItemSpacing.y));
|
||||
ImguiStyleVar _1(ImGuiStyleVar_FramePadding, ScaledVec2(10, 10));
|
||||
if (ImGui::Button("Yes"))
|
||||
{
|
||||
mainui_reinit();
|
||||
ImGui::CloseCurrentPopup();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("No"))
|
||||
ImGui::CloseCurrentPopup();
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if (ImGui::Button("No"))
|
||||
ImGui::CloseCurrentPopup();
|
||||
ImGui::EndPopup();
|
||||
}
|
||||
select_file_popup(fileSelectTitle, callback, true, "zip");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -3302,20 +3307,19 @@ static bool systemdir_selected_callback(bool cancelled, std::string selection)
|
|||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
// We might be able to create a directory but not a file. Because ... android
|
||||
// So let's test to be sure.
|
||||
std::string testPath = data_path + "writetest.txt";
|
||||
FILE *file = fopen(testPath.c_str(), "w");
|
||||
if (file == nullptr)
|
||||
{
|
||||
// Test
|
||||
std::string testPath = data_path + "writetest.txt";
|
||||
FILE *file = fopen(testPath.c_str(), "w");
|
||||
if (file == nullptr)
|
||||
{
|
||||
WARN_LOG(BOOT, "Cannot write in the 'data' directory");
|
||||
gui_error("Invalid selection:\nFlycast cannot write to this directory.");
|
||||
return false;
|
||||
}
|
||||
fclose(file);
|
||||
unlink(testPath.c_str());
|
||||
WARN_LOG(BOOT, "Cannot write in the 'data' directory");
|
||||
gui_error("Invalid selection:\nFlycast cannot write to this directory.");
|
||||
return false;
|
||||
}
|
||||
fclose(file);
|
||||
unlink(testPath.c_str());
|
||||
|
||||
set_user_config_dir(selection);
|
||||
add_system_data_dir(selection);
|
||||
set_user_data_dir(data_path);
|
||||
|
@ -3338,8 +3342,9 @@ static bool systemdir_selected_callback(bool cancelled, std::string selection)
|
|||
|
||||
static void gui_display_onboarding()
|
||||
{
|
||||
ImGui::OpenPopup("Select System Directory");
|
||||
select_file_popup("Select System Directory", &systemdir_selected_callback);
|
||||
const char *title = "Select Flycast Home Directory";
|
||||
ImGui::OpenPopup(title);
|
||||
select_file_popup(title, &systemdir_selected_callback);
|
||||
}
|
||||
|
||||
static std::future<bool> networkStatus;
|
||||
|
|
|
@ -86,6 +86,7 @@ void gui_cheats()
|
|||
ImGui::Begin("##main", nullptr, ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoTitleBar
|
||||
| ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize);
|
||||
|
||||
const char *title = "Select a cheat file";
|
||||
{
|
||||
ImguiStyleVar _(ImGuiStyleVar_FramePadding, ScaledVec2(20, 8));
|
||||
ImGui::AlignTextToFramePadding();
|
||||
|
@ -103,12 +104,7 @@ void gui_cheats()
|
|||
hostfs::addStorage(false, true, cheatFileSelected);
|
||||
#else
|
||||
if (ImGui::Button("Load"))
|
||||
ImGui::OpenPopup("Select cheat file");
|
||||
select_file_popup("Select cheat file", [](bool cancelled, std::string selection)
|
||||
{
|
||||
cheatFileSelected(cancelled, selection);
|
||||
return true;
|
||||
}, true, "cht");
|
||||
ImGui::OpenPopup(title);
|
||||
#endif
|
||||
|
||||
ImGui::SameLine();
|
||||
|
@ -117,6 +113,11 @@ void gui_cheats()
|
|||
|
||||
ImGui::Unindent(uiScaled(10));
|
||||
}
|
||||
select_file_popup(title, [](bool cancelled, std::string selection)
|
||||
{
|
||||
cheatFileSelected(cancelled, selection);
|
||||
return true;
|
||||
}, true, "cht");
|
||||
|
||||
ImGui::BeginChild(ImGui::GetID("cheats"), ImVec2(0, 0), ImGuiChildFlags_Border, ImGuiWindowFlags_DragScrolling | ImGuiWindowFlags_NavFlattened);
|
||||
{
|
||||
|
|
|
@ -98,6 +98,15 @@ void select_file_popup(const char *prompt, StringCallback callback,
|
|||
std::sort(folderFiles.begin(), folderFiles.end());
|
||||
subfolders_read = true;
|
||||
}
|
||||
if (prompt != nullptr) {
|
||||
ImguiStyleVar _(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.f, 0.5f)); // Left
|
||||
ImguiStyleVar _1(ImGuiStyleVar_DisabledAlpha, 1.0f);
|
||||
ImGui::BeginDisabled();
|
||||
ImGui::PushFont(largeFont);
|
||||
ImGui::ButtonEx(prompt, ImVec2(-1, 0));
|
||||
ImGui::PopFont();
|
||||
ImGui::EndDisabled();
|
||||
}
|
||||
std::string title;
|
||||
if (!error_message.empty())
|
||||
title = error_message;
|
||||
|
|
Loading…
Reference in New Issue