Skip to content

Commit 249ab42

Browse files
authored
Merge pull request #15 from KSP2Community/dev
0.1.1
2 parents 2e3ca3c + 192902b commit 249ab42

4 files changed

Lines changed: 27 additions & 5 deletions

File tree

CommunityResources.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ Global
1313
Release|Any CPU = Release|Any CPU
1414
EndGlobalSection
1515
GlobalSection(ProjectConfigurationPlatforms) = postSolution
16-
{2A62527B-B543-4E5A-A197-D28C37F282D8}.Debug|Any CPU.ActiveCfg = Release|Any CPU
17-
{2A62527B-B543-4E5A-A197-D28C37F282D8}.Debug|Any CPU.Build.0 = Release|Any CPU
16+
{2A62527B-B543-4E5A-A197-D28C37F282D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17+
{2A62527B-B543-4E5A-A197-D28C37F282D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
1818
{2A62527B-B543-4E5A-A197-D28C37F282D8}.Deploy|Any CPU.ActiveCfg = Deploy|Any CPU
1919
{2A62527B-B543-4E5A-A197-D28C37F282D8}.Deploy|Any CPU.Build.0 = Deploy|Any CPU
2020
{2A62527B-B543-4E5A-A197-D28C37F282D8}.DeployAndRun|Any CPU.ActiveCfg = DeployAndRun|Any CPU
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@new()
22
:resource_units {
3-
Water: "l";
4-
WasteWater: "l";
3+
Water: "L";
4+
WasteWater: "L";
55
}

plugin_template/swinfo.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"name": "Community Resources",
66
"description": "Adds generic resources for mods to use",
77
"source": "https://github.com/KSP2Community/CommunityResources",
8-
"version": "0.1.0",
8+
"version": "0.1.1",
99
"version_check": "https://raw.githubusercontent.com/KSP2Community/CommunityResources/main/plugin_template/swinfo.json",
1010
"ksp2_version": {
1111
"min": "0.1.5",

src/CommunityResources/Patches.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using HarmonyLib;
2+
using KSP;
23
using KSP.Game;
4+
using KSP.Iteration.UI.Binding;
35
using KSP.Modules;
6+
using KSP.OAB;
47
using KSP.Sim.Definitions;
58
using KSP.Sim.ResourceSystem;
69
using KSP.UI;
@@ -60,4 +63,23 @@ private static void ResourceCapacities_GetUnits(Module_ResourceCapacities __inst
6063
}
6164
}
6265
}
66+
67+
[HarmonyPrefix]
68+
[HarmonyPatch(typeof(PartInfoOverlay), nameof(PartInfoOverlay.PopulateResourceInfoFromPart))]
69+
private static bool PopulateResourceInfoFromPart(List<KeyValuePair<string, string>> dict,
70+
IObjectAssemblyResource[] resourceArray)
71+
{
72+
foreach (var resource in resourceArray)
73+
{
74+
if (!ResourceUnits.TryGetValue(resource.Name, out var unitName))
75+
{
76+
unitName = resource.Name == "ElectricCharge" ? Units.SymbolUnits : Units.SymbolTonne;
77+
}
78+
79+
dict.Add(new KeyValuePair<string, string>(PartInfoOverlay.LocalizeVABTooltipString(resource.Name),
80+
$"{resource.Count} {PartInfoOverlay.LocalizeVABTooltipString(unitName)}"));
81+
}
82+
83+
return false;
84+
}
6385
}

0 commit comments

Comments
 (0)