ui: replace Exit by Close Game. Better format for some UI values.

Issue #1383
This commit is contained in:
Flyinghead 2024-02-07 11:05:09 +01:00
parent e592650afc
commit 9aa9b5bebc
3 changed files with 15 additions and 7 deletions

View File

@ -650,7 +650,7 @@ static void gui_display_commands()
ImGui::Columns(1, nullptr, false); ImGui::Columns(1, nullptr, false);
// Exit // Exit
if (ImGui::Button("Exit", ScaledVec2(300, 50) if (ImGui::Button(commandLineStart ? "Exit" : "Close Game", ScaledVec2(300, 50)
+ ImVec2(ImGui::GetStyle().ColumnsMinSpacing + ImGui::GetStyle().FramePadding.x * 2 - 1, 0))) + ImVec2(ImGui::GetStyle().ColumnsMinSpacing + ImGui::GetStyle().FramePadding.x * 2 - 1, 0)))
{ {
gui_stop_game(); gui_stop_game();
@ -2164,7 +2164,7 @@ static void gui_display_settings()
ShowHelpMarker("Internal render resolution. Higher is better, but more demanding on the GPU. Values higher than your display resolution (but no more than double your display resolution) can be used for supersampling, which provides high-quality antialiasing without reducing sharpness."); ShowHelpMarker("Internal render resolution. Higher is better, but more demanding on the GPU. Values higher than your display resolution (but no more than double your display resolution) can be used for supersampling, which provides high-quality antialiasing without reducing sharpness.");
OptionSlider("Horizontal Stretching", config::ScreenStretching, 100, 250, OptionSlider("Horizontal Stretching", config::ScreenStretching, 100, 250,
"Stretch the screen horizontally"); "Stretch the screen horizontally", "%d%%");
OptionArrowButtons("Frame Skipping", config::SkipFrame, 0, 6, OptionArrowButtons("Frame Skipping", config::SkipFrame, 0, 6,
"Number of frames to skip between two actually rendered frames"); "Number of frames to skip between two actually rendered frames");
} }
@ -2230,7 +2230,7 @@ static void gui_display_settings()
{ {
#ifdef _OPENMP #ifdef _OPENMP
OptionArrowButtons("Texture Upscaling", config::TextureUpscale, 1, 8, OptionArrowButtons("Texture Upscaling", config::TextureUpscale, 1, 8,
"Upscale textures with the xBRZ algorithm. Only on fast platforms and for certain 2D games"); "Upscale textures with the xBRZ algorithm. Only on fast platforms and for certain 2D games", "x%d");
OptionSlider("Texture Max Size", config::MaxFilteredTextureSize, 8, 1024, OptionSlider("Texture Max Size", config::MaxFilteredTextureSize, 8, 1024,
"Textures larger than this dimension squared will not be upscaled"); "Textures larger than this dimension squared will not be upscaled");
OptionArrowButtons("Max Threads", config::MaxThreads, 1, 8, OptionArrowButtons("Max Threads", config::MaxThreads, 1, 8,
@ -2293,7 +2293,7 @@ static void gui_display_settings()
"Enable the Dreamcast Digital Sound Processor. Only recommended on fast platforms"); "Enable the Dreamcast Digital Sound Processor. Only recommended on fast platforms");
OptionCheckbox("Enable VMU Sounds", config::VmuSound, "Play VMU beeps when enabled."); OptionCheckbox("Enable VMU Sounds", config::VmuSound, "Play VMU beeps when enabled.");
if (OptionSlider("Volume Level", config::AudioVolume, 0, 100, "Adjust the emulator's audio level")) if (OptionSlider("Volume Level", config::AudioVolume, 0, 100, "Adjust the emulator's audio level", "%d%%"))
{ {
config::AudioVolume.calcDbPower(); config::AudioVolume.calcDbPower();
}; };

View File

@ -517,7 +517,7 @@ bool OptionSlider(const char *name, config::Option<int, PerGameOption>& option,
template bool OptionSlider(const char *name, config::Option<int, true>& option, int min, int max, const char *help, const char *format); template bool OptionSlider(const char *name, config::Option<int, true>& option, int min, int max, const char *help, const char *format);
template bool OptionSlider(const char *name, config::Option<int, false>& option, int min, int max, const char *help, const char *format); template bool OptionSlider(const char *name, config::Option<int, false>& option, int min, int max, const char *help, const char *format);
bool OptionArrowButtons(const char *name, config::Option<int>& option, int min, int max, const char *help) bool OptionArrowButtons(const char *name, config::Option<int>& option, int min, int max, const char *help, const char *format)
{ {
const float innerSpacing = ImGui::GetStyle().ItemInnerSpacing.x; const float innerSpacing = ImGui::GetStyle().ItemInnerSpacing.x;
ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.f, 0.5f)); // Left ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0.f, 0.5f)); // Left
@ -526,7 +526,15 @@ bool OptionArrowButtons(const char *name, config::Option<int>& option, int min,
std::string id = "##" + std::string(name); std::string id = "##" + std::string(name);
ImGui::PushStyleVar(ImGuiStyleVar_DisabledAlpha, 1.0f); ImGui::PushStyleVar(ImGuiStyleVar_DisabledAlpha, 1.0f);
ImGui::BeginDisabled(); ImGui::BeginDisabled();
ImGui::ButtonEx((std::to_string((int)option) + id).c_str(), ImVec2(width, 0)); int size = snprintf(nullptr, 0, format, (int)option);
std::string value;
if (size >= 0)
{
value.resize(size + 1);
snprintf(value.data(), size + 1, format, (int)option);
value.resize(size);
}
ImGui::ButtonEx((value + id).c_str(), ImVec2(width, 0));
ImGui::EndDisabled(); ImGui::EndDisabled();
ImGui::PopStyleVar(); ImGui::PopStyleVar();
ImGui::PopStyleColor(); ImGui::PopStyleColor();

View File

@ -50,7 +50,7 @@ template<typename T>
bool OptionRadioButton(const char *name, config::Option<T>& option, T value, const char *help = nullptr); bool OptionRadioButton(const char *name, config::Option<T>& option, T value, const char *help = nullptr);
void OptionComboBox(const char *name, config::Option<int>& option, const char *values[], int count, void OptionComboBox(const char *name, config::Option<int>& option, const char *values[], int count,
const char *help = nullptr); const char *help = nullptr);
bool OptionArrowButtons(const char *name, config::Option<int>& option, int min, int max, const char *help = nullptr); bool OptionArrowButtons(const char *name, config::Option<int>& option, int min, int max, const char *help = nullptr, const char *format = "%d");
static inline void centerNextWindow() static inline void centerNextWindow()
{ {