static bool Prefix(MainTabWindow_Inspect __instance, ref float __result)
        {
            List <object> things = Find.Selector.SelectedObjects.FindAll(thing => (thing as Zone_Growing) != null);

            if ((things.Count > 0) && (things.Count == Find.Selector.NumSelected))
            {
                __result = (float)UI.screenHeight - __instance.RequestedTabSize.y - 35f;
                return(false);
            }
            else
            {
                things = Find.Selector.SelectedObjects.FindAll(thing => (thing as Building_Storage) != null);
                if ((things.Count > 0) && (things.Count == Find.Selector.NumSelected))
                {
                    __result = (float)UI.screenHeight - __instance.RequestedTabSize.y - 35f;
                    return(false);
                }
                else
                {
                    things = Find.Selector.SelectedObjects.FindAll(thing => (thing as Building_PlantGrower) != null);
                    if ((things.Count > 0) && (things.Count == Find.Selector.NumSelected))
                    {
                        __result = (float)UI.screenHeight - __instance.RequestedTabSize.y - 35f;
                        return(false);
                    }
                }
            }

            return(true);
        }
        public static void Postfix(MainTabWindow_Inspect __instance, Rect rect, ref float lineEndWidth)
        {
            if (!Settings.Get().selectedItemsZoomButton)
            {
                return;
            }

            Rect buttonRect = new Rect(rect.width - lineEndWidth - 24, 0, 24, 24);

            if (Widgets.ButtonImage(buttonRect, Eye))
            {
                index++;
                if (index >= Find.Selector.NumSelected)
                {
                    index = 0;
                }

                object jumpTo = Find.Selector.SelectedObjectsListForReading[index];
                if (jumpTo is Thing jumpThing)
                {
                    CameraJumper.TryJump(jumpThing);
                }
                if (jumpTo is Zone jumpZone)
                {
                    CameraJumper.TryJump(new GlobalTargetInfo(jumpZone.Position, jumpZone.Map));
                }
            }
            TooltipHandler.TipRegion(buttonRect, Find.Selector.NumSelected == 1 ? "TD.JumpToThisObject".Translate() : "TD.CycleJumpingToTheseObjects".Translate());
            lineEndWidth += 24f;
        }
        private Vector2 CalculateCurInputDollyVect()
        {
            Vector2 vector = this.desiredDolly;
            bool    flag   = false;

            if ((UnityData.isEditor || Screen.fullScreen) && Prefs.EdgeScreenScroll && !this.mouseCoveredByUI)
            {
                Vector2 mousePositionOnUI = UI.MousePositionOnUI;
                Vector2 point             = mousePositionOnUI;
                point.y = (float)UI.screenHeight - point.y;
                Rect rect  = new Rect(0f, 0f, 200f, 200f);
                Rect rect2 = new Rect((float)(UI.screenWidth - 250), 0f, 255f, 255f);
                Rect rect3 = new Rect(0f, (float)(UI.screenHeight - 250), 225f, 255f);
                Rect rect4 = new Rect((float)(UI.screenWidth - 250), (float)(UI.screenHeight - 250), 255f, 255f);
                MainTabWindow_Inspect mainTabWindow_Inspect = (MainTabWindow_Inspect)MainButtonDefOf.Inspect.TabWindow;
                if (Find.MainTabsRoot.OpenTab == MainButtonDefOf.Inspect && mainTabWindow_Inspect.RecentHeight > rect3.height)
                {
                    rect3.yMin = (float)UI.screenHeight - mainTabWindow_Inspect.RecentHeight;
                }
                if (!rect.Contains(point) && !rect3.Contains(point) && !rect2.Contains(point) && !rect4.Contains(point))
                {
                    Vector2 b = new Vector2(0f, 0f);
                    if (mousePositionOnUI.x >= 0f && mousePositionOnUI.x < 20f)
                    {
                        b.x -= this.config.dollyRateScreenEdge;
                    }
                    if (mousePositionOnUI.x <= (float)UI.screenWidth && mousePositionOnUI.x > (float)UI.screenWidth - 20f)
                    {
                        b.x += this.config.dollyRateScreenEdge;
                    }
                    if (mousePositionOnUI.y <= (float)UI.screenHeight && mousePositionOnUI.y > (float)UI.screenHeight - 20f)
                    {
                        b.y += this.config.dollyRateScreenEdge;
                    }
                    if (mousePositionOnUI.y >= 0f && mousePositionOnUI.y < this.ScreenDollyEdgeWidthBottom)
                    {
                        if (this.mouseTouchingScreenBottomEdgeStartTime < 0f)
                        {
                            this.mouseTouchingScreenBottomEdgeStartTime = Time.realtimeSinceStartup;
                        }
                        if (Time.realtimeSinceStartup - this.mouseTouchingScreenBottomEdgeStartTime >= 0.28f)
                        {
                            b.y -= this.config.dollyRateScreenEdge;
                        }
                        flag = true;
                    }
                    vector += b;
                }
            }
            if (!flag)
            {
                this.mouseTouchingScreenBottomEdgeStartTime = -1f;
            }
            if (Input.GetKey(KeyCode.LeftShift))
            {
                vector *= 2.4f;
            }
            return(vector);
        }
        protected override void SetInitialSizeAndPosition()
        {
            MainTabWindow_Inspect inspectWorker = (MainTabWindow_Inspect)MainButtonDefOf.Inspect.TabWindow;

            this.windowRect = new Rect(
                770f,
                inspectWorker.PaneTopY - 30f - this.InitialSize.y, this.InitialSize.x, this.InitialSize.y).Rounded();
        }
Exemple #5
0
        private static bool Prefix_ExtraOnGui(MainTabWindow_Inspect __instance)
        {
            if (!State.HudDockedVisible)
            {
                return(true);
            }

            InspectPaneUtility.ExtraOnGUI(__instance);
            if (__instance.AnythingSelected && (Find.DesignatorManager.SelectedDesignator != null))
            {
                Find.DesignatorManager.SelectedDesignator.DoExtraGuiControls(0f, __instance.PaneTopY);
            }

            return(false);
        }
        private void ToggleTab()
        {
            MainTabWindow_Inspect mainTabWindow_Inspect = (MainTabWindow_Inspect)Find.MainTabsRoot.OpenTab.TabWindow;

            if (_tabType == mainTabWindow_Inspect.OpenTabType)
            {
                mainTabWindow_Inspect.OpenTabType = null;
                SoundDefOf.TabClose.PlayOneShotOnCamera();
            }
            else
            {
                InspectTabBase inspectTabBase = mainTabWindow_Inspect.CurTabs.Where((InspectTabBase t) => _tabType.IsAssignableFrom(t.GetType())).FirstOrDefault();
                inspectTabBase?.OnOpen();
                mainTabWindow_Inspect.OpenTabType = _tabType;
                SoundDefOf.TabOpen.PlayOneShotOnCamera();
            }
        }
Exemple #7
0
        public static void DoInspectPaneButtons(Rect rect, ref float lineEndWidth, MainTabWindow_Inspect __instance)
        {
            if (Find.Selector.NumSelected == 1)
            {
                Thing singleSelectedThing = Find.Selector.SingleSelectedThing;
                if (singleSelectedThing != null)
                {
                    Widgets.InfoCardButton(rect.width - 48f, 0f, Find.Selector.SingleSelectedThing);
                    lineEndWidth += 24f;
                    Pawn pawn = singleSelectedThing as Pawn;
                    if (pawn != null && pawn.playerSettings != null && pawn.playerSettings.UsesConfigurableHostilityResponse)
                    {
                        HostilityResponseModeUtility.DrawResponseButton(new Vector2(rect.width - 72f, 0f), pawn);
                        lineEndWidth += 24f;
                    }

                    if (pawn != null)
                    {
                        Need_Soul soul;
                        if ((soul = pawn.needs.TryGetNeed <Need_Soul>()) != null)
                        {
                            float num = rect.height - 48;
                            Widgets.ListSeparator(ref num, rect.width, "PawnAlignment".Translate());
                            ColorInt  colorInt  = new ColorInt(65, 25, 25);
                            Texture2D soultex   = SolidColorMaterials.NewSolidColorTexture(colorInt.ToColor);
                            ColorInt  colorInt2 = new ColorInt(10, 10, 10);
                            Texture2D bgtex     = SolidColorMaterials.NewSolidColorTexture(colorInt2.ToColor);
                            WidgetRow row       = new WidgetRow(0f, rect.height - 24f);
                            row.FillableBar(93f, 16f, soul.CurLevelPercentage, soul.CurCategory.ToString(), soultex, bgtex);
                            String desc = "PawnAlignmentButtonDescription".Translate();
                            if (row.ButtonIcon(HarmonyPatches.patronIcon, desc))
                            {
                                Find.WindowStack.Add(new MainTabWindow_Alignment());
                            }
                            string culturalTolerance = "Cultural Tolerance: " + soul.CulturalTolerance.ToString();
                            Widgets.Label(new Rect(rect.width / 2, rect.height - 24, rect.width / 2, 16f), culturalTolerance);
                        }
                    }
                }
            }
        }
        public static void Postfix(MainTabWindow_Inspect __instance)
        {
            if (!Main.Instance.ShouldExpandBillsTab())
            {
                return;
            }

            var tab = __instance.CurTabs?.FirstOrDefault();

            if (!(tab is ITab_Bills))
            {
                _lastSelectedThingId = null;
                return;
            }

            var selectedThing = Find.Selector.SingleSelectedThing;

            if (selectedThing == null)
            {
                _lastSelectedThingId = null;
                return;
            }

            if (_lastSelectedThingId != null && selectedThing.ThingID == _lastSelectedThingId)
            {
                return;
            }

            _lastSelectedThingId = selectedThing.ThingID;
            if (__instance.OpenTabType != null && __instance.OpenTabType == tab.GetType())
            {
                return;
            }

            tab.OnOpen();
            __instance.OpenTabType = tab.GetType();
        }
Exemple #9
0
 public static void Prefix(MainTabWindow_Inspect __instance, ref Rect rect)
 {
     rect.width = InspectPaneUtility.PaneWidthFor(__instance) - 72f;
 }
        public static void Postfix(MainTabWindow_Inspect __instance)
        {
            if (!Main.Instance.ShouldExpandBillsTab())
            {
                return;
            }

            var tab = __instance.CurTabs?.FirstOrDefault();

            if (tab == null)
            {
                return;
            }

            var tabIsBills = false;

            if (tab is ITab_Bills || Main.Instance.IsOfTypeRimFactoryBillsTab(tab))
            {
                tabIsBills = true;
            }
            else if (!(tab is ITab_Storage))
            {
                // No workbench or stockpile selected
                _lastSelectedThingId = null;
                return;
            }

            // We must make sure we only open the tab once, or we'll keep reopening
            // it even if the player wants to manually close it.
            string selectedThingId = null;

            if (tabIsBills)
            {
                // Workbench
                var selectedThing = Find.Selector.SingleSelectedThing;
                if (selectedThing != null)
                {
                    selectedThingId = selectedThing.ThingID;
                }
            }
            else
            {
                // Stockpile
                var selectedZone = Find.Selector.SelectedZone;
                if (selectedZone != null)
                {
                    selectedThingId = selectedZone.GetHashCode().ToString();
                }
            }

            if (selectedThingId == null)
            {
                _lastSelectedThingId = null;
                return;
            }

            if (_lastSelectedThingId != null && selectedThingId == _lastSelectedThingId)
            {
                return;
            }

            _lastSelectedThingId = selectedThingId;
            if (__instance.OpenTabType != null && __instance.OpenTabType == tab.GetType())
            {
                return;
            }

            tab.OnOpen();
            __instance.OpenTabType = tab.GetType();
        }
Exemple #11
0
        //private static Vector2 requestedSize;


        static void Postfix(MainTabWindow_Inspect __instance, Rect inRect)
        {
            SetHeightOffsets();

            if (Find.Selector.NumSelected == 1)
            {
                Zone_Stockpile   selStockpileZone = ((ISelectable)Find.Selector.SelectedZone) as Zone_Stockpile;
                Zone_Growing     selGrowingZone   = ((ISelectable)Find.Selector.SelectedZone) as Zone_Growing;
                Building_Storage storage          = ((ISelectable)Find.Selector.SingleSelectedObject) as Building_Storage;

                plantGrowingInspectPanelFiller.ResetData();

                //single selection
                if (selStockpileZone != null)
                {
                    zoneStockpileInspectPanelFiller.DoPaneContentsFor(selStockpileZone, inRect);
                    storageInspectPanelFiller.ResetData();
                    zoneGrowingInspectPanelFiller.ResetData();
                }
                else if (selGrowingZone != null)
                {
                    zoneGrowingInspectPanelFiller.DoPaneContentsFor(new List <Zone_Growing>()
                    {
                        selGrowingZone
                    }, inRect);
                    storageInspectPanelFiller.ResetData();
                    zoneStockpileInspectPanelFiller.ResetData();
                }
                else if (storage != null)
                {
                    storageInspectPanelFiller.DoPaneContentsFor(new List <Building_Storage>()
                    {
                        storage
                    }, inRect);
                    zoneStockpileInspectPanelFiller.ResetData();
                    zoneGrowingInspectPanelFiller.ResetData();
                }
                else
                {
                    zoneStockpileInspectPanelFiller.ResetData();
                    zoneGrowingInspectPanelFiller.ResetData();
                    storageInspectPanelFiller.ResetData();
                }
            }
            else if (Find.Selector.NumSelected > 1)
            {
                //multiple things selected, check if all are growing zones
                List <object> things = Find.Selector.SelectedObjects.FindAll(thing => (thing as Zone_Growing) != null);
                if (things.Count == Find.Selector.NumSelected)
                {
                    zoneGrowingInspectPanelFiller.DoPaneContentsFor(things.Cast <Zone_Growing>().ToList(), inRect);
                    storageInspectPanelFiller.ResetData();
                    zoneStockpileInspectPanelFiller.ResetData();
                    plantGrowingInspectPanelFiller.ResetData();
                }
                else
                {
                    things = Find.Selector.SelectedObjects.FindAll(thing => (thing as Building_Storage) != null);
                    if (things.Count == Find.Selector.NumSelected)
                    {
                        storageInspectPanelFiller.DoPaneContentsFor(things.Cast <Building_Storage>().ToList(), inRect);
                        zoneStockpileInspectPanelFiller.ResetData();
                        zoneGrowingInspectPanelFiller.ResetData();
                        plantGrowingInspectPanelFiller.ResetData();
                    }
                    else
                    {
                        things = Find.Selector.SelectedObjects.FindAll(thing => (thing as Building_PlantGrower) != null);
                        if (things.Count == Find.Selector.NumSelected)
                        {
                            plantGrowingInspectPanelFiller.DoPaneContentsFor(things.Cast <Building_PlantGrower>().ToList(), inRect);
                            storageInspectPanelFiller.ResetData();
                            zoneStockpileInspectPanelFiller.ResetData();
                            zoneGrowingInspectPanelFiller.ResetData();
                        }
                    }
                }
            }
            else
            {
                zoneStockpileInspectPanelFiller.ResetData();
                zoneGrowingInspectPanelFiller.ResetData();
                storageInspectPanelFiller.ResetData();
                plantGrowingInspectPanelFiller.ResetData();
            }
        }