private static void FixMechLabLocationWidgetLayouts(MechLabLayoutFinder finder) { foreach (Transform container in finder.ObjMech) { { var go = container.gameObject; EnableLayout(go); var component = go.GetComponent <ContentSizeFitter>() ?? go.AddComponent <ContentSizeFitter>(); component.verticalFit = ContentSizeFitter.FitMode.PreferredSize; component.enabled = true; { var clg = go.GetComponent <VerticalLayoutGroup>(); clg.padding = new RectOffset(0, 0, 0, 0); clg.spacing = 56; } } foreach (Transform widget in container) { var widgetComponent = widget.GetComponent <MechLabLocationWidget>(); if (widgetComponent == null || CustomWidgetsFixMechLab.IsCustomWidget(widgetComponent)) { continue; } EnableLayout(widget.gameObject); EnableLayout(widget.Find("layout_slots").gameObject); // fix different distances for lower bracket var rect = widget .Find("layout_bg") .Find("bracket_btm") .GetComponent <RectTransform>(); rect.anchoredPosition = new Vector2(0, 0); rect.offsetMin = new Vector2(0, -2); rect.offsetMax = new Vector2(0, 2); // put repair upper border ONTO widget lower border, since both color it fits and looks attached perfectly // saves pixels widget.Find("layout_repair") .GetComponent <RectTransform>() .anchoredPosition = new(0, -41); } } { var go = finder.ObjMech.gameObject; EnableLayout(go); var component = go.GetComponent <ContentSizeFitter>() ?? go.AddComponent <ContentSizeFitter>(); component.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; component.verticalFit = ContentSizeFitter.FitMode.PreferredSize; component.enabled = true; } }
public static void Prefix(MechLabLocationWidget __instance, IMechLabDraggableItem item) { try { CustomWidgetsFixMechLab.RefreshDropHighlights(__instance, item); } catch (Exception e) { Control.Logger.Error.Log(e); } }
public static bool Prefix(MechLabLocationWidget __instance, bool isOriginalLocation, ref MechComponentRef cRef) { try { return(CustomWidgetsFixMechLab.ShowHighlightFrame(__instance, isOriginalLocation, ref cRef)); } catch (Exception e) { Control.Logger.Error.Log(e); } return(false); }
public static void Postfix(MechLabPanel __instance) { try { MechLabLayoutUtils.FixMechLabLayouts(__instance); CustomWidgetsFixMechLab.Setup(__instance); MechLabMoveUIElements.MoveMechUIElements(__instance); } catch (Exception e) { Control.Logger.Error.Log(e); } }
public static bool Prefix(MechLabLocationWidget __instance, PointerEventData eventData) { try { if (CustomWidgetsFixMechLab.OnDrop(__instance, eventData)) { return(false); } } catch (Exception e) { Control.Logger.Error.Log(e); } return(true); }