Skip to content

Commit

Permalink
Don't show the implant level slider if the max level is one
Browse files Browse the repository at this point in the history
  • Loading branch information
edbmods committed May 11, 2024
1 parent 390d1a0 commit 1023ece
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Source/DialogManageImplants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@ public void SelectOption(DialogOption option) {
return;
}
option.Selected = true;
if (option.ImplantOption?.MaxSeverity == 1) {
UpdateSeverity(option, 1);
}
if (option.Parts.Count == 1) {
if (!option.Parts[0].Selected) {
option.Parts[0].Selected = true;
Expand Down Expand Up @@ -480,12 +483,12 @@ public void AddMissingDependencies() {
}

public bool NeedsDependencies(ref HashSet<DialogOption> missingDependencies) {
Logger.Debug("NeedsDependencies()");
//Logger.Debug("NeedsDependencies()");
if (missingDependencies == null) {
missingDependencies = new HashSet<DialogOption>();
}
HashSet<HediffDef> selected = new HashSet<HediffDef>(implantList.Select(i => i.Option?.HediffDef).Where(h => h != null));
Logger.Debug(" Selected implants: " + string.Join(", ", selected.Select(d => d.defName)));
//Logger.Debug(" Selected implants: " + string.Join(", ", selected.Select(d => d.defName)));
foreach (var implant in implantList) {
if (implant.Option?.Dependency != null && !selected.Contains(implant.Option.Dependency)) {
var optionToAdd = FindDialogOptionForHediff(implant.Option.Dependency);
Expand All @@ -494,7 +497,7 @@ public bool NeedsDependencies(ref HashSet<DialogOption> missingDependencies) {
}
}
}
Logger.Debug(" Needs dependencies: " + string.Join(", ", missingDependencies.Select(o => o.ImplantOption?.HediffDef?.defName)));
//Logger.Debug(" Needs dependencies: " + string.Join(", ", missingDependencies.Select(o => o.ImplantOption?.HediffDef?.defName)));
return missingDependencies.Count > 0;
}

Expand Down Expand Up @@ -523,7 +526,7 @@ public bool HasUnneededDependencies(ref HashSet<DialogOption> unneededDependenci
unneededDependencies.Add(option);
}
}
Logger.Debug("Unneeded dependencies: " + string.Join(", ", unneededDependencies.Select(o => o.ImplantOption?.HediffDef?.defName ?? "null")));
//Logger.Debug("Unneeded dependencies: " + string.Join(", ", unneededDependencies.Select(o => o.ImplantOption?.HediffDef?.defName ?? "null")));

return unneededDependencies.Count > 0;
}
Expand All @@ -537,7 +540,7 @@ public void DeselectOption(DialogOption option) {
option.Selected = false;
option.SelectedDependency = false;
if (option.Parts != null) {
Logger.Debug(" option.Parts = " + string.Join(", ", option.Parts.Select(p => p.UniquePart.Record.def.defName)));
//Logger.Debug(" option.Parts = " + string.Join(", ", option.Parts.Select(p => p.UniquePart.Record.def.defName)));
}
foreach (var part in option.Parts) {
if (part.Selected) {
Expand All @@ -556,10 +559,10 @@ public void UpdateSeverity(DialogOption option, float severity) {
Implant implant = implantList.FirstOrDefault(i => i.Option == option.ImplantOption);
if (implant != null) {
implant.Severity = option.Severity;
Logger.Debug("Updated implant severity");
//Logger.Debug("Updated implant severity");
}
else {
Logger.Debug("Didn't find implant to update");
//Logger.Debug("Didn't find implant to update");
}
}
protected void AddImplant(DialogOption option, ImplantBodyPart part) {
Expand Down Expand Up @@ -722,7 +725,7 @@ protected void Resize() {
if (option.Selected || option.SelectedDependency) {
float inset = 32;
float cursor = labelRect.yMax;
if (option.ImplantOption.MaxSeverity > 0) {
if (option.ImplantOption.MaxSeverity > 1) {
float rowWidth = rect.width - inset * 2;
float sliderWidth = rowWidth - LevelLabelSize.x - LevelValueSize.x - 12;
float sliderHeight = 12;
Expand Down Expand Up @@ -789,7 +792,7 @@ protected void Resize() {
if (option.Selected && option.Parts.Count > 1) {
height += LineHeight * option.Parts.Count;
}
if (option.Selected && option.ImplantOption.MaxSeverity > 0) {
if (option.Selected && option.ImplantOption.MaxSeverity > 1) {
height += LineHeight;
}
return height;
Expand Down

0 comments on commit 1023ece

Please sign in to comment.