adjust closed forest and starting age settings for edge cases (#2421)

This commit is contained in:
Adam Bird
2023-01-30 22:51:41 -05:00
committed by GitHub
parent 44f963e310
commit 4e08eca1b9
4 changed files with 37 additions and 23 deletions
+22 -1
View File
@@ -245,11 +245,17 @@ namespace UIWidgets {
}
}
bool EnhancementCombobox(const char* name, const char* ComboArray[], size_t arraySize, uint8_t FirstTimeValue) {
bool EnhancementCombobox(const char* name, const char* ComboArray[], size_t arraySize, uint8_t FirstTimeValue, bool disabled, const char* disabledTooltipText, uint8_t disabledValue) {
bool changed = false;
if (FirstTimeValue <= 0) {
FirstTimeValue = 0;
}
if (disabled) {
ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true);
ImGui::PushStyleVar(ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f);
}
uint8_t selected = CVarGetInteger(name, FirstTimeValue);
uint8_t DefaultValue = selected;
std::string comboName = std::string("##") + std::string(name);
@@ -266,6 +272,21 @@ namespace UIWidgets {
}
ImGui::EndCombo();
}
if (disabled) {
ImGui::PopStyleVar(1);
if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(disabledTooltipText, "") != 0) {
ImGui::SetTooltip("%s", disabledTooltipText);
}
ImGui::PopItemFlag();
if (disabledValue >= 0 && selected != disabledValue) {
CVarSetInteger(name, disabledValue);
changed = true;
SohImGui::RequestCvarSaveOnNextTick();
}
}
return changed;
}