private static void CloseCategoryPanelWrapper(PlanScreen instance, bool playSound) { if (Options.Opts.BuildMenu == Options.ClickNum.One) { instance.CloseCategoryPanel(playSound); } }
protected override void OnSpawn() { base.OnSpawn(); initTime = KTime.Instance.UnscaledGameTime; if (BuildMenu.UseHotkeyBuildMenu()) { base.gameObject.SetActive(false); } else { Instance = this; base.onSelect += OnClickCategory; Refresh(); foreach (KToggle toggle in toggles) { toggle.group = GetComponent <ToggleGroup>(); } GetBuildableStates(true); Game.Instance.Subscribe(288942073, OnUIClear); } copyBuildingButton.GetComponent <MultiToggle>().onClick = delegate { OnClickCopyBuilding(); }; RefreshCopyBuildingButton(null); Game.Instance.Subscribe(-1503271301, RefreshCopyBuildingButton); copyBuildingButton.GetComponent <ToolTip>().SetSimpleTooltip(GameUtil.ReplaceHotkeyString(UI.COPY_BUILDING_TOOLTIP, Action.CopyBuilding)); }
private static void CloseRecipeWrapper(PlanScreen instance, bool playSound) { if (Options.Opts.Reselect == Options.ReselectMode.Close) { instance.CloseRecipe(playSound); } }
static void Postfix(PlanScreen __instance, int ___buildGrid_maxRowsBeforeScroll) { bool shouldShowScroll = rows >= ___buildGrid_maxRowsBeforeScroll + 1; __instance.BuildingGroupContentsRect.GetComponent <ScrollRect>().vertical = shouldShowScroll; if (!shouldShowScroll) { // Couldn't find any relevant numbers in the source so I guess I too get to use magic numbers... __instance.buildingGroupsRoot.sizeDelta += new Vector2(-13f, 0f); } }
public static bool Prefix(PlanScreen __instance, bool __state) { BuildingDef def = null; KToggle currentlySelectedToggle = Traverse.Create(__instance).Field("currentlySelectedToggle").GetValue <KToggle>(); foreach (KeyValuePair <BuildingDef, KToggle> kvp in __instance.ActiveToggles) { if (kvp.Value == currentlySelectedToggle) { def = kvp.Key; break; } } if (def.name.Contains(Mod.TILE_POSTFIX)) { ProductInfoScreen productInfoScreen = Traverse.Create(__instance).Field("productInfoScreen").GetValue <ProductInfoScreen>(); IList <Tag> elements = productInfoScreen.materialSelectionPanel.GetSelectedElementAsList; string newID = Mod.MOD_PREFIX + elements[0].ToString() + Mod.TILE_POSTFIX; BuildingDef newDef = Assets.GetBuildingDef(newID); if (newDef == null) { newDef = Assets.GetBuildingDef(StainedGlassTileConfig.ID); } InterfaceTool tool = PlayerController.Instance.ActiveTool; if (tool != null) { Type tool_type = tool.GetType(); if (tool_type == typeof(BuildTool) || typeof(BaseUtilityBuildTool).IsAssignableFrom(tool_type)) { tool.DeactivateTool(null); } } BuildTool.Instance.Activate(newDef, productInfoScreen.materialSelectionPanel.GetSelectedElementAsList, null); return(false); } return(true); }
protected override void OnSpawn() { base.OnSpawn(); if ((UnityEngine.Object)BuildingGroupScreen.Instance != (UnityEngine.Object)null) { BuildingGroupScreen instance = BuildingGroupScreen.Instance; instance.pointerEnterActions = (PointerEnterActions)Delegate.Combine(instance.pointerEnterActions, new PointerEnterActions(CheckMouseOver)); BuildingGroupScreen instance2 = BuildingGroupScreen.Instance; instance2.pointerExitActions = (PointerExitActions)Delegate.Combine(instance2.pointerExitActions, new PointerExitActions(CheckMouseOver)); } if ((UnityEngine.Object)PlanScreen.Instance != (UnityEngine.Object)null) { PlanScreen instance3 = PlanScreen.Instance; instance3.pointerEnterActions = (PointerEnterActions)Delegate.Combine(instance3.pointerEnterActions, new PointerEnterActions(CheckMouseOver)); PlanScreen instance4 = PlanScreen.Instance; instance4.pointerExitActions = (PointerExitActions)Delegate.Combine(instance4.pointerExitActions, new PointerExitActions(CheckMouseOver)); } if ((UnityEngine.Object)BuildMenu.Instance != (UnityEngine.Object)null) { BuildMenu instance5 = BuildMenu.Instance; instance5.pointerEnterActions = (PointerEnterActions)Delegate.Combine(instance5.pointerEnterActions, new PointerEnterActions(CheckMouseOver)); BuildMenu instance6 = BuildMenu.Instance; instance6.pointerExitActions = (PointerExitActions)Delegate.Combine(instance6.pointerExitActions, new PointerExitActions(CheckMouseOver)); } pointerEnterActions = (PointerEnterActions)Delegate.Combine(pointerEnterActions, new PointerEnterActions(CheckMouseOver)); pointerExitActions = (PointerExitActions)Delegate.Combine(pointerExitActions, new PointerExitActions(CheckMouseOver)); ConsumeMouseScroll = true; sandboxInstantBuildToggle.ChangeState(SandboxToolParameterMenu.instance.settings.InstantBuild ? 1 : 0); MultiToggle multiToggle = sandboxInstantBuildToggle; multiToggle.onClick = (System.Action)Delegate.Combine(multiToggle.onClick, (System.Action) delegate { SandboxToolParameterMenu.instance.settings.InstantBuild = !SandboxToolParameterMenu.instance.settings.InstantBuild; sandboxInstantBuildToggle.ChangeState(SandboxToolParameterMenu.instance.settings.InstantBuild ? 1 : 0); }); sandboxInstantBuildToggle.gameObject.SetActive(Game.Instance.SandboxModeActive); Game.Instance.Subscribe(-1948169901, delegate { sandboxInstantBuildToggle.gameObject.SetActive(Game.Instance.SandboxModeActive); }); }
static bool Prefix(PlanScreen __instance, KButtonEvent e, KIconToggleMenu.ToggleInfo ___activeCategoryInfo) { bool isActiveMenu = ___activeCategoryInfo != null; bool isActiveOverlay = OverlayScreen.Instance.GetMode() != OverlayModes.None.ID; // The first click, when something is selected, doesn't get processed here. // It goes through ToolMenu and gets processed by PlanScreen.OnActiveToolChanged. // If both are active, check if they're supposed to be closed on the second click, and close. if (isActiveMenu && isActiveOverlay && TryConsumeRightClick()) { if (Options.Opts.BuildMenu == Options.ClickNum.Two) { CloseMenu(); } if (Options.Opts.Overlay == Options.ClickNum.Two) { CloseOverlay(); } } // If either the menu or overlay is active, close it. else if ((isActiveMenu ^ isActiveOverlay) && TryConsumeRightClick()) { if (isActiveMenu) { CloseMenu(); } if (isActiveOverlay) { CloseOverlay(); } } return(false); bool TryConsumeRightClick() => PlayerController.Instance.ConsumeIfNotDragging(e, Action.MouseRight); void CloseMenu() => __instance.OnClickCategory(___activeCategoryInfo); void CloseOverlay() => OverlayScreen.Instance.ToggleOverlay(OverlayModes.None.ID, true); }
public static void Postfix(PlanScreen __instance) { var ps = Traverse.Create(__instance).Field("buildGrid_maxRowsBeforeScroll").SetValue(6); }
public static void Prefix(PlanScreen __instance) { Traverse.Create(__instance).Field("buildGrid_maxRowsBeforeScroll").SetValue(_configManager.Config.Height); }
public static void Postfix(PlanScreen __instance) { AccessTools.Field(typeof(PlanScreen), "buildGrid_maxRowsBeforeScroll").SetValue(__instance, 8); }
public static void DestroyInstance() { Instance = null; }