multiselect apply mag preset; remove bullet apply mag preset

This commit is contained in:
Tyfon
2024-07-02 03:20:39 -07:00
parent 30ecbc333d
commit d21d981125
4 changed files with 110 additions and 8 deletions

View File

@@ -76,6 +76,8 @@ namespace UIFixes
new ChangeInteractionButtonCreationPatch().Enable();
new EnableInsureInnerItemsPatch().Enable();
new DisableLoadPresetOnBulletsPatch().Enable();
}
public class ContextMenuNamesPatch : ModulePatch
@@ -137,6 +139,14 @@ namespace UIFixes
____text.text += " (x" + count + ")";
}
}
else if (caption == EItemInfoButton.ApplyMagPreset.ToString())
{
int count = MultiSelect.InteractionCount(EItemInfoButton.ApplyMagPreset, ItemUiContext.Instance);
if (count > 0)
{
____text.text += " (x" + count + ")";
}
}
else if (caption == EItemInfoButton.Unpack.ToString())
{
int count = MultiSelect.InteractionCount(EItemInfoButton.Unpack, ItemUiContext.Instance);
@@ -384,6 +394,31 @@ namespace UIFixes
}
}
public class DisableLoadPresetOnBulletsPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(MagazineBuildClass), nameof(MagazineBuildClass.TryFindPresetSource));
}
[PatchPrefix]
public static bool Prefix(Item selectedItem, ref GStruct416<Item> __result)
{
if (Settings.LoadMagPresetOnBullets.Value)
{
return true;
}
if (selectedItem is BulletClass)
{
__result = new MagazineBuildClass.Class3135(selectedItem);
return false;
}
return true;
}
}
private static int GetPlayerRubles(ItemUiContext itemUiContext)
{
StashClass stash = itemUiContext.R().InventoryController.Inventory.Stash;