Skip to content

Commit

Permalink
- Allow customization of MechBay 'Configure' button; defaults to 'Val…
Browse files Browse the repository at this point in the history
…diate' now for ME compatibility

- Allow disabling the Store button in MechBay; prevents some corruption issues
  • Loading branch information
IceRaptor committed Jan 20, 2021
1 parent a21b585 commit 95aa6dd
Showing 1 changed file with 67 additions and 1 deletion.
68 changes: 67 additions & 1 deletion IRTweaks/IRTweaks/Modules/UI/MechBayChanges.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
using BattleTech.UI;
using BattleTech;
using BattleTech.Data;
using BattleTech.UI;
using BattleTech.UI.TMProWrapper;
using Harmony;
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

namespace IRTweaks.Modules.UI
{
Expand Down Expand Up @@ -37,4 +43,64 @@ static void Postfix(MechLabPanel __instance, MechLabDismountWidget ___dismountWi
}
}
}

[HarmonyPatch(typeof(MechLabPanel), "SetData")]
[HarmonyPatch(new Type[] { typeof(MechDef), typeof(MechBayPanel), typeof(SimGameState), typeof(List<MechComponentRef>), typeof(WorkOrderEntry_MechLab), typeof(UnityAction<List<WorkOrderEntry>, string, int>), typeof(UnityAction) })]
static class MechLabPanel_SetData_1
{
static bool Prepare() => Mod.Config.Fixes.MechbayLayout;

static void Postfix(MechLabPanel __instance)
{
try
{
// Change the label on the confirm button
Mod.Log.Info?.Write($"MLP:SD - walking transforms of GO: {__instance.gameObject.name}");

Transform cancelConfirmT = __instance.gameObject.transform.Find("Representation/OBJ_cancelconfirm");
if (cancelConfirmT == null) Mod.Log.Error?.Write("Failed to find OBJ_cancelconfirm!");

Transform readyTextT = cancelConfirmT.Find("uixPrfBttn_BASE_button2-MANAGED-confirm/bttn2_contentLayout/ready_Text-optional");
if (readyTextT == null) Mod.Log.Error?.Write("Failed to find ready_Text-optional!");

LocalizableText buttonText = readyTextT.gameObject.GetComponent<LocalizableText>();
if (buttonText == null) Mod.Log.Error?.Write("Failed to find LocalizableText!");
buttonText.SetText("VALIDATE");

// Disable the store button
Transform storeButtonT = __instance.gameObject.transform.Find("Representation/OBJ_storeButton");
if (storeButtonT == null) Mod.Log.Error?.Write("Failed to find OBJ_storeButton!");
storeButtonT.gameObject.SetActive(false);
}
catch (Exception e)
{
Mod.Log.Warn?.Write(e, $"Failed to set MechLab confirm button to new text");
}


}
}

//[HarmonyPatch(typeof(MechLabPanel), "SetData")]
//[HarmonyPatch(new Type[] { typeof(MechDef), typeof(DataManager), typeof(UnityAction), typeof(UnityAction), typeof(bool)})]
//static class MechLabPanel_SetData_2
//{
// static bool Prepare() => Mod.Config.Fixes.MechbayLayout;

// static void Postfix(MechLabPanel __instance)
// {
// try
// {
// Transform cancelConfirmT = __instance.gameObject.transform.Find("uixPrfBttn_BASE_button2-MANAGED-confirm");
// Transform readyTextT = cancelConfirmT.Find("ready_Text-optional");
// LocalizableText buttonText = readyTextT.gameObject.GetComponent<LocalizableText>();
// buttonText.SetText("VALIDATE");
// }
// catch (Exception e)
// {
// Mod.Log.Warn?.Write(e, $"Failed to set MechLab confirm button to new text");
// }
// }
//}

}

0 comments on commit 95aa6dd

Please sign in to comment.