MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / DrawFloatRangeSetting

Method DrawFloatRangeSetting

pcsx2/ImGui/FullscreenUI_Settings.cpp:774–844  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

772}
773
774void FullscreenUI::DrawFloatRangeSetting(SettingsInterface* bsi, const char* title, const char* summary, const char* section,
775 const char* key, float default_value, float min_value, float max_value, const char* format, float multiplier, bool enabled,
776 float height, std::pair<ImFont*, float> font, std::pair<ImFont*, float> summary_font)
777{
778 const bool game_settings = IsEditingGameSettings(bsi);
779 const std::optional<float> value =
780 bsi->GetOptionalFloatValue(section, key, game_settings ? std::nullopt : std::optional<float>(default_value));
781 const SmallString value_text =
782 value.has_value() ? SmallString::from_sprintf(format, value.value() * multiplier) : SmallString(FSUI_VSTR("Use Global Setting"));
783
784 if (MenuButtonWithValue(title, summary, value_text.c_str(), enabled, height, font, summary_font))
785 ImGui::OpenPopup(title);
786
787 ImGui::SetNextWindowSize(LayoutScale(500.0f, 190.0f));
788 ImGui::SetNextWindowPos(ImGui::GetIO().DisplaySize * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
789
790 ImGui::PushFont(g_large_font.first, g_large_font.second);
791 ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, LayoutScale(ImGuiFullscreen::LAYOUT_WINDOW_ROUNDING));
792 ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, LayoutScale(20.0f, 20.0f));
793 ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f);
794 ImGui::PushStyleVar(ImGuiStyleVar_FramePadding,
795 LayoutScale(ImGuiFullscreen::LAYOUT_MENU_BUTTON_X_PADDING, ImGuiFullscreen::LAYOUT_MENU_BUTTON_Y_PADDING));
796
797 bool is_open = true;
798 if (ImGui::BeginPopupModal(title, &is_open, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoScrollbar))
799 {
800 BeginMenuButtons();
801
802 const float end = ImGui::GetCurrentWindow()->WorkRect.GetWidth();
803 ImGui::SetNextItemWidth(end);
804 float dlg_value = value.value_or(default_value) * multiplier;
805
806 ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, LayoutScale(ImGuiFullscreen::LAYOUT_FRAME_ROUNDING));
807 ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, LayoutScale(1.0f));
808 ImGui::PushStyleVar(ImGuiStyleVar_GrabRounding, LayoutScale(8.0f));
809 ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(0.2f, 0.2f, 0.2f, 1.0f));
810 ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(0.25f, 0.25f, 0.25f, 1.0f));
811 ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(0.3f, 0.3f, 0.3f, 1.0f));
812 ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.4f, 0.4f, 0.4f, 1.0f));
813 ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImVec4(0.45f, 0.65f, 0.95f, 1.0f));
814 ImGui::PushStyleColor(ImGuiCol_SliderGrabActive, ImVec4(0.55f, 0.75f, 1.0f, 1.0f));
815 ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(1.0f, 1.0f, 1.0f, 1.0f));
816
817 if (ImGui::SliderFloat("##value", &dlg_value, min_value * multiplier, max_value * multiplier, format, ImGuiSliderFlags_NoInput))
818 {
819 dlg_value /= multiplier;
820
821 if (IsEditingGameSettings(bsi) && dlg_value == default_value)
822 bsi->DeleteValue(section, key);
823 else
824 bsi->SetFloatValue(section, key, dlg_value);
825
826 SetSettingsChanged(bsi);
827 }
828
829 ImGui::PopStyleColor(7);
830 ImGui::PopStyleVar(3);
831

Callers

nothing calls this directly

Calls 10

LayoutScaleFunction · 0.85
PushFontFunction · 0.85
GetCurrentWindowFunction · 0.85
ImVec4Class · 0.85
ImVec2Class · 0.70
valueMethod · 0.45
c_strMethod · 0.45
GetWidthMethod · 0.45
DeleteValueMethod · 0.45
SetFloatValueMethod · 0.45

Tested by

no test coverage detected