Skip to content

Commit 828cfba

Browse files
committed
Add adjustable menu/HUD distance and size
1 parent 3d1b180 commit 828cfba

File tree

1 file changed

+56
-4
lines changed

1 file changed

+56
-4
lines changed

src/rendering/vulkan_imgui.cpp

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,55 @@ void RND_Renderer::ImGuiOverlay::DrawHelpMenu() {
657657
return tabBar;
658658
};
659659

660+
auto formatDistance = [&](float distance) {
661+
float distanceInches = distance * 39.3700787f;
662+
int32_t distanceFeet = std::floor(distanceInches / 12.0f);
663+
distanceInches -= distanceFeet * 12.0f;
664+
return std::format("{:.02f}m / {}\' {:.02f}\"", distance, distanceFeet, distanceInches);
665+
};
666+
667+
auto DrawLayerSettingsRow = [&](const char* label, bool* changed, FloatSetting<float>& distanceSetting, FloatSetting<float>& scaleSetting) {
668+
DrawSettingRow(label, [&]() {
669+
auto applyValues = [&](float distance, float scale) {
670+
distanceSetting.Set(distance);
671+
scaleSetting.Set(scale);
672+
};
673+
674+
float distance = distanceSetting.Get();
675+
float scale = scaleSetting.Get();
676+
std::string distanceIdStr = std::format("##{}_Distance", label);
677+
std::string scaleIdStr = std::format("##{}_Scale", label);
678+
679+
float totalWidth = ImGui::GetContentRegionAvail().x;
680+
float resetWidth = 45.0f;
681+
float itemSpacing = ImGui::GetStyle().ItemSpacing.x;
682+
float sliderWidth = (totalWidth - resetWidth - itemSpacing * 2.0f) * 0.5f;
683+
684+
ImGui::PushItemWidth(sliderWidth);
685+
if (ImGui::SliderFloat(distanceIdStr.c_str(), &distance, distanceSetting.min, distanceSetting.max, formatDistance(distance).c_str())) {
686+
applyValues(std::clamp(distance, distanceSetting.min, distanceSetting.max), scaleSetting.Get());
687+
*changed = true;
688+
}
689+
ImGui::PopItemWidth();
690+
ImGui::SameLine();
691+
692+
ImGui::PushItemWidth(sliderWidth);
693+
if (ImGui::SliderFloat(scaleIdStr.c_str(), &scale, scaleSetting.min, scaleSetting.max, "%.2fx scale")) {
694+
applyValues(distanceSetting.Get(), std::clamp(scale, scaleSetting.min, scaleSetting.max));
695+
*changed = true;
696+
}
697+
ImGui::PopItemWidth();
698+
ImGui::SameLine();
699+
700+
std::string resetIdStr = std::format("Reset##{}", label);
701+
if (ImGui::Button(resetIdStr.c_str())) {
702+
distanceSetting.Reset();
703+
scaleSetting.Reset();
704+
*changed = true;
705+
}
706+
});
707+
};
708+
660709
ImGui::SetNextWindowPos(fullWindowWidth * 0.5f, ImGuiCond_Always, ImVec2(0.5f, 0.5f));
661710
ImGui::SetNextWindowSize(windowWidth, ImGuiCond_Always);
662711
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
@@ -745,11 +794,14 @@ void RND_Renderer::ImGuiOverlay::DrawHelpMenu() {
745794
});
746795

747796
ImGui::Spacing();
748-
ImGui::Separator();
749-
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyleColorVec4(ImGuiCol_HeaderActive));
750-
ImGui::Text("Input");
751-
ImGui::PopStyleColor();
797+
DrawLayerSettingsRow("Menu/HUD Distance & Size", &changed, settings.hudDistance, settings.hudSize);
798+
799+
ImGui::Spacing();
752800
if (cameraMode == CameraMode::FIRST_PERSON) {
801+
ImGui::Separator();
802+
ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyleColorVec4(ImGuiCol_HeaderActive));
803+
ImGui::Text("Input");
804+
ImGui::PopStyleColor();
753805
DrawSettingRow("Thumbstick Deadzone", [&]() {
754806
settings.stickDeadzone.AddToGUI(&changed, windowWidth.x, 0.0f, 0.5f);
755807
});

0 commit comments

Comments
 (0)