Skip to content

Commit

Permalink
Improve information shown in part tooltips and fix training course na…
Browse files Browse the repository at this point in the history
…mes (#2323)

The `name` field on a `Part` is not always the part name; in particular
when creating the tooltip in the editor for a part with upgrades, it is
not (it is instead "{partName}(Clone)").

Fixes an issue where the required crew training course name in the
tooltip does not match the course name in the RP-1 training window.

The tech name is changed to the tech's title;
The ECM names are left as-is since they don't have user-facing titles.
  • Loading branch information
Nazfib authored Jan 13, 2024
1 parent e538a26 commit d0eec4d
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions Source/RP0/PartModules/ModuleShowInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,21 @@ public class ModuleShowInfo : PartModule

public override string GetInfo()
{
AvailablePart ap = part.partInfo;
if (ap is null) return "";

string result = $"Part name: {ap.name}\nTech Required: {ResearchAndDevelopment.GetTechnologyTitle(ap.TechRequired)}";

if (part.CrewCapacity > 0)
result += $"\nTraining course: {(TrainingDatabase.SynonymReplace(ap.name, out string name) ? name : ap.title)}";

EntryCostDatabaseAccessor.Init();
EntryCostDatabaseAccessor.GetFields();

string data = null, apInfo = null;
string nm = RealFuels.Utilities.SanitizeName(part.name);
string nm = RealFuels.Utilities.SanitizeName(ap.name);
if (HighLogic.LoadedScene != GameScenes.LOADING && EntryCostDatabase.GetHolder(nm) is PartEntryCostHolder h)
data = $"Total cost: {EntryCostDatabaseAccessor.GetCost(h)}\n{EntryCostDatabaseAccessor.DisplayHolder(h, false)}";
if (part.partInfo is AvailablePart ap)
{
apInfo = $"Tech Required: {ap.TechRequired}";
if (part.CrewCapacity > 0)
apInfo = $"Training course: {(TrainingDatabase.SynonymReplace(part.name, out string name) ? name : ap.title)}\n{apInfo}";
}
string res = $"Part name: {part.name}\n{apInfo}\n{data}";
return res;
result += $"\nTotal cost: {EntryCostDatabaseAccessor.GetCost(h)}\n{EntryCostDatabaseAccessor.DisplayHolder(h, false)}";

return result;
}

public override void OnStart(StartState state)
Expand Down Expand Up @@ -185,4 +185,4 @@ private void BuildCubeData()
ZN = $"{cubes.WeightedArea[5]:F2} ({cubes.GetCubeAreaDir(DragCubeList.GetFaceDirection(DragCube.DragFace.ZN)):F2})";
}
}
}
}

0 comments on commit d0eec4d

Please sign in to comment.