public static void Postfix(MechLabLocationWidget __instance, int ___maxSlots) { try { var widgetLayout = new WidgetLayout(__instance); MechLabSlotsFixer.FixSlots(widgetLayout, ___maxSlots); DynamicSlotsFeature.PrepareWidget(widgetLayout); } catch (Exception e) { Control.mod.Logger.LogError(e); } }
public static void Postfix(MechLabLocationWidget __instance, int ___maxSlots, ref LocationLoadoutDef loadout) { try { var widget = __instance; var widgetLayout = new WidgetLayout(widget); MechLabSlotsFixer.FixSlots(widgetLayout, ___maxSlots); DynamicSlotsFeature.PrepareWidget(widgetLayout); AdjustMechLabLocationNaming(widget, loadout.Location); } catch (Exception e) { Control.Logger.Error.Log(e); } }
internal static void SetupWidget( string id, ref MechLabLocationWidget?topWidget, MechLabPanel mechLabPanel, MechLabLocationWidget armWidget, MechLabSlotsSettings.WidgetSettings settings ) { GameObject go; if (topWidget == null) { var template = mechLabPanel.centerTorsoWidget; go = Object.Instantiate(template.gameObject, null); go.name = id; go.SetActive(settings.Enabled); { var vlg = go.GetComponent <VerticalLayoutGroup>(); vlg.padding = new RectOffset(0, 0, 0, 3); vlg.spacing = 4; } go.transform.Find("layout_armor").gameObject.SetActive(false); go.transform.Find("layout_hardpoints").gameObject.SetActive(false); go.transform.Find("layout_locationText/txt_structure").gameObject.SetActive(false); go.transform.Find("layout_locationText/txt_location").GetComponent <TextMeshProUGUI>().text = settings.Label; topWidget = go.GetComponent <MechLabLocationWidget>(); } else { go = topWidget.gameObject; } var parent = armWidget.transform.parent; go.transform.SetParent(parent, false); go.transform.SetAsFirstSibling(); go.GetComponent <LayoutElement>().ignoreLayout = true; { var rect = go.GetComponent <RectTransform>(); rect.localPosition = new Vector3(0, 0); rect.pivot = new Vector2(0, 0); rect.anchoredPosition = new Vector2(0, -MechLabSlotsFeature.settings.MechLabArmTopPadding + 20); } { var clg = parent.GetComponent <VerticalLayoutGroup>(); clg.padding = new RectOffset(0, 0, MechLabSlotsFeature.settings.MechLabArmTopPadding, 0); } topWidget.Init(mechLabPanel); var layout = new WidgetLayout(topWidget); MechLabSlotsFixer.ModifyLayoutSlotCount(layout, settings.Slots); { var mechRectTransform = parent.parent.GetComponent <RectTransform>(); LayoutRebuilder.ForceRebuildLayoutImmediate(mechRectTransform); } }