Skip to content

Commit

Permalink
Support hiding a part tooltip's Extended Info tab if the part tooltip…
Browse files Browse the repository at this point in the history
… is of a PartUpgrade not a part.
  • Loading branch information
NathanKell committed Apr 7, 2022
1 parent b7e0a6b commit cbf3858
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions GameData/KSPCommunityFixes/Settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,7 @@ KSP_COMMUNITY_FIXES
// the `CreateObjectFromConfig()`, `LoadObjectFromConfig()` and `CreateConfigFromObject()` methods.
// Disabled by default, you can enable it with a MM patch.
PersistentIConfigNode = false
// Hides the extended info on the part tooltip for PartUpgrades
HidePartUpgradeExtendedInfo = false
}
1 change: 1 addition & 0 deletions KSPCommunityFixes/KSPCommunityFixes.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<Compile Include="QoL\PAWCollapsedInventories.cs" />
<Compile Include="QoL\AltimeterHorizontalPosition.cs" />
<Compile Include="QoL\PAWStockGroups.cs" />
<Compile Include="QoL\HidePartUpgradeExtendedInfo.cs" />
<Compile Include="QoL\UIFloatEditNumericInput.cs" />
<Compile Include="Utility.cs" />
</ItemGroup>
Expand Down
33 changes: 33 additions & 0 deletions KSPCommunityFixes/QoL/HidePartUpgradeExtendedInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using HarmonyLib;
using KSP.UI.Screens.Editor;
using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;

namespace KSPCommunityFixes
{
public class HidePartUpgradeExtendedInfo : BasePatch
{
protected override Version VersionMin => new Version(1, 8, 0);

protected override void ApplyPatches(ref List<PatchInfo> patches)
{
patches.Add(new PatchInfo(
PatchMethodType.Prefix,
AccessTools.Method(typeof(PartListTooltip), "DisplayExtendedInfo"),
this));
}

static bool PartListTooltip_DisplayExtendedInfo_Prefix(PartListTooltip __instance)
{
if (__instance.upgrade != null && __instance.HasExtendedInfo)
{
__instance.panelExtended.SetActive(false);
return false;
}

return true;
}
}
}

0 comments on commit cbf3858

Please sign in to comment.