Ejemplo n.º 1
0
        public void DrawMissionMenu(Rect inRect)
        {
            //Draw Tabs
            Text.Font = GameFont.Small;
            Rect    tabRect  = new Rect(inRect.x + 10f, inRect.y - 20f, inRect.width - 30f, 20f);
            string  missions = "Missions_SMO".Translate();
            string  themes   = "Themes_SMO".Translate();
            string  locked   = "LockedTab_SMO".Translate();
            Vector2 v1       = Text.CalcSize(missions);
            Vector2 v2       = Text.CalcSize(themes);
            Vector2 v3       = Text.CalcSize(locked);

            v1.x += 6;
            v2.x += 6;
            v3.x += 6;
            Rect missionTab   = new Rect(new Vector2(tabRect.x, tabRect.y), v1);
            Rect themeTab     = new Rect(new Vector2(missionTab.xMax, missionTab.y), v2);
            Rect lockedButton = new Rect(new Vector2(themeTab.xMax, themeTab.y), v3);

            Text.Anchor = TextAnchor.MiddleCenter;
            StoryUtils.DrawMenuSectionColor(missionTab, 1, StoryMats.defaultFill, StoryMats.defaultBorder);
            Widgets.Label(missionTab, missions);
            StoryUtils.DrawMenuSectionColor(themeTab, 1, StoryMats.defaultFill, StoryMats.defaultBorder);
            Widgets.Label(themeTab, themes);
            float    opacity = Mouse.IsOver(lockedButton) ? 1f : 0.5f;
            ColorInt border  = showLocked ? new ColorInt(142, 200, 154, (int)(255f * opacity)) : new ColorInt(243, 153, 123, (int)(255f * opacity));

            StoryUtils.DrawMenuSectionColor(lockedButton, 1, StoryMats.defaultFill, border);
            if (Widgets.ButtonInvisible(lockedButton, true))
            {
                showLocked = !showLocked;
                if (!showLocked)
                {
                    SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null);
                    selectedLockedMission = null;
                }
                else
                {
                    SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null);
                }
            }
            Widgets.Label(lockedButton, locked);
            GUI.color = new Color(0.8f, 0.8f, 0.8f);
            if (Widgets.ButtonInvisible(missionTab))
            {
                SoundDefOf.Click.PlayOneShotOnCamera(null);
                TabFlag = true;
            }
            if (Mouse.IsOver(missionTab) || TabFlag)
            {
                Widgets.DrawBox(missionTab, 1);
            }
            if (Widgets.ButtonInvisible(themeTab))
            {
                SoundDefOf.Click.PlayOneShotOnCamera(null);
                TabFlag = false;
            }
            if (Mouse.IsOver(themeTab) || !TabFlag)
            {
                Widgets.DrawBox(themeTab, 1);
            }
            GUI.color = Color.white;

            StoryUtils.DrawMenuSectionColor(inRect, 1, new ColorInt(55, 55, 55), new ColorInt(135, 135, 135));
            Rect rect = inRect.ContractedBy(5f);

            float selectionHeight = 45f;
            float viewHeight      = 0f;
            float selectionYPos   = 0f;

            if (TabFlag)
            {
                //Mission Tab
                GUI.BeginGroup(rect);
                viewHeight = MissionTabHeight(selectionHeight);
                Rect outRect  = new Rect(0f, 0f, rect.width, rect.height);
                Rect viewRect = new Rect(0f, 0f, rect.width, viewHeight);
                Widgets.BeginScrollView(outRect, ref StoryManager.missionScrollPos, viewRect, false);
                for (int i = 0; i < StoryManager.ModFolder.Count; i++)
                {
                    ModContentPackWrapper MCPW = StoryManager.ModFolder[i];
                    if (MCPW.SCD != SCD.MainStoryControlDef)
                    {
                        List <Mission> Missions = MissionsForMod(MCPW.MCP);
                        //Identifier
                        string  appendix       = MCPW.Toggled ? "-" : "+";
                        string  identifier     = MCPW.SCD.label + " " + appendix;
                        Vector2 identifierSize = Text.CalcSize(identifier);
                        identifierSize.x += 6f;
                        Rect identifierRect = new Rect(new Vector2(0f, selectionYPos), identifierSize);
                        selectionYPos += identifierRect.height;
                        Widgets.DrawMenuSection(identifierRect);
                        Text.Font   = GameFont.Tiny;
                        Text.Anchor = TextAnchor.MiddleCenter;
                        Widgets.Label(identifierRect, identifier);
                        Text.Anchor = 0;
                        Text.Font   = GameFont.Small;
                        if (Widgets.ButtonInvisible(identifierRect) && MCPW.HasActiveMissions)
                        {
                            MCPW.Toggle();
                            if (MCPW.Toggled)
                            {
                                SoundDefOf.TabOpen.PlayOneShotOnCamera(null);
                            }
                            else
                            {
                                SoundDefOf.TabClose.PlayOneShotOnCamera(null);
                            }
                        }
                        if (Mouse.IsOver(identifierRect))
                        {
                            GUI.color = new Color(0.8f, 0.8f, 0.8f);
                            Widgets.DrawBox(identifierRect, 1);
                            GUI.color = Color.white;
                        }
                        UIHighlighter.HighlightOpportunity(identifierRect, MCPW.MCP.Identifier + "-StoryHighlight");

                        if (MCPW.Toggled)
                        {
                            //Group
                            float      lockedCount  = 0;
                            string     lockedLabel  = "";
                            Vector2    lockedSize   = Vector2.zero;
                            List <Def> cachedLocked = new List <Def>();
                            if (showLocked)
                            {
                                cachedLocked = MCPW.MCP.AllDefs.Where(d => d is MissionDef && !(d as MissionDef).HardLocked && (d as MissionDef).CurrentState == MOState.Inactive).ToList();
                                lockedCount  = cachedLocked.Count();
                                lockedLabel  = "Locked_SMO".Translate() + ":";
                                lockedSize   = Text.CalcSize(lockedLabel);
                            }
                            bool  lockedBool = lockedCount > 0;
                            float height     = (lockedCount + Missions.Count) * selectionHeight + (lockedBool ? lockedSize.y : 0f);
                            Rect  groupRect  = new Rect(0f, selectionYPos, rect.width, height);
                            StoryUtils.DrawMenuSectionColor(groupRect, 1, MCPW.SCD.color, MCPW.SCD.borderColor);
                            float missionTabY = groupRect.y;
                            for (int ii = 0; ii < Missions.Count; ii++)
                            {
                                Mission         mission = Missions[ii];
                                Rect            rect4   = new Rect(groupRect.x, missionTabY, groupRect.width, selectionHeight);
                                StoryControlDef scd     = StoryManager.Theme != null ? StoryManager.Theme.SCD : SCD.MainStoryControlDef;
                                DrawMissionTab(rect4, mission, scd, ii);
                                missionTabY += selectionHeight;
                            }
                            if (showLocked && lockedBool)
                            {
                                float h       = height - (Missions.Count * selectionHeight);
                                Rect  boxRect = new Rect(groupRect.x, groupRect.y + (height - h), groupRect.width, h);
                                Widgets.DrawBoxSolid(boxRect.ContractedBy(2f), new Color(0.2f, 0.2f, 0.2f, 0.2f));
                                GUI.color = MCPW.SCD.borderColor.ToColor;
                                Widgets.DrawLineHorizontal(boxRect.x, boxRect.y, boxRect.width);
                                GUI.color = Color.white;
                                Widgets.Label(new Rect(new Vector2(groupRect.x + 5f, missionTabY), lockedSize), lockedLabel);
                                missionTabY += lockedSize.y;
                                foreach (MissionDef def in cachedLocked)
                                {
                                    Rect rect4 = new Rect(groupRect.x, missionTabY, groupRect.width, selectionHeight);
                                    DrawLockedMissionTab(rect4, def, MCPW.SCD);
                                    missionTabY += selectionHeight;
                                }
                            }
                            selectionYPos += height;
                        }
                    }
                    selectionYPos += 5f;
                }
                Widgets.EndScrollView();
                GUI.EndGroup();
            }
            else
            {
                //Theme Tab
                GUI.BeginGroup(rect);
                viewHeight = selectionHeight * StoryManager.ModFolder.Count;
                Rect outRect  = new Rect(0f, 0f, rect.width, rect.height);
                Rect viewRect = new Rect(0f, 0f, rect.width, viewHeight);
                Widgets.BeginScrollView(outRect, ref StoryManager.missionScrollPos, viewRect, false);
                for (int i = 0; i < StoryManager.ModFolder.Count + 1; i++)
                {
                    Rect selection = new Rect(0f, selectionYPos, rect.width, selectionHeight).ContractedBy(5f);
                    Text.Anchor = TextAnchor.MiddleCenter;
                    if (i == 0)
                    {
                        Widgets.DrawMenuSection(selection);
                        Widgets.Label(selection, "None");
                        if (Mouse.IsOver(selection) || StoryManager.Theme == null)
                        {
                            GUI.color = new Color(0.8f, 0.8f, 0.8f);
                            Widgets.DrawBox(selection, 1);
                            GUI.color = Color.white;
                            if (Widgets.ButtonInvisible(selection))
                            {
                                UpdateTheme(null);
                                SoundDefOf.Click.PlayOneShotOnCamera(null);
                            }
                        }
                    }
                    else
                    {
                        ModContentPackWrapper mcp = StoryManager.ModFolder.ElementAt(i - 1);
                        if (mcp.SCD != SCD.MainStoryControlDef ? mcp.SCD.backGroundPath != SCD.MainStoryControlDef.backGroundPath : true)
                        {
                            Widgets.DrawMenuSection(selection);
                            Widgets.Label(selection, mcp.SCD.LabelCap);
                            if (Mouse.IsOver(selection) || StoryManager.Theme == mcp)
                            {
                                GUI.color = new Color(0.8f, 0.8f, 0.8f);
                                Widgets.DrawBox(selection, 1);
                                GUI.color = Color.white;
                                if (Widgets.ButtonInvisible(selection, true))
                                {
                                    UpdateTheme(mcp.MCP);
                                    SoundDefOf.Click.PlayOneShotOnCamera(null);
                                }
                            }
                        }
                    }
                    Text.Anchor    = 0;
                    selectionYPos += selectionHeight;
                }
                Widgets.EndScrollView();
                GUI.EndGroup();
            }
        }
 private static void DrawInfiniteHorizontalLine(Rect rect, Rect viewRect, float curveY)
 {
     Widgets.DrawLineHorizontal(-999f, SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(rect, viewRect, new Vector2(0f, curveY)).y, 9999f);
 }
Ejemplo n.º 3
0
        public override void DoWindowContents(Rect inRect)
        {
            TradeSession.deal.UpdateCurrencyCount();
            TransferableUIUtility.DoTransferableSorters(this.sorter1, this.sorter2, delegate(TransferableSorterDef x)
            {
                this.sorter1 = x;
                this.CacheTradeables();
            }, delegate(TransferableSorterDef x)
            {
                this.sorter2 = x;
                this.CacheTradeables();
            });
            float num  = inRect.width - 590f;
            Rect  rect = new Rect(num, 0f, inRect.width - num, this.TopAreaHeight);

            GUI.BeginGroup(rect);
            Text.Font = GameFont.Medium;
            Rect rect2 = new Rect(0f, 0f, rect.width / 2f, rect.height);

            Text.Anchor = TextAnchor.UpperLeft;
            Widgets.Label(rect2, Faction.OfPlayer.Name);
            Rect rect3 = new Rect(rect.width / 2f, 0f, rect.width / 2f, rect.height);

            Text.Anchor = TextAnchor.UpperRight;
            string text = TradeSession.trader.TraderName;

            if (Text.CalcSize(text).x > rect3.width)
            {
                Text.Font = GameFont.Small;
                text      = text.Truncate(rect3.width, null);
            }
            Widgets.Label(rect3, text);
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            Rect rect4 = new Rect(0f, 27f, rect.width / 2f, rect.height / 2f);

            Widgets.Label(rect4, "Negotiator".Translate() + ": " + TradeSession.playerNegotiator.LabelShort);
            Text.Anchor = TextAnchor.UpperRight;
            Rect rect5 = new Rect(rect.width / 2f, 27f, rect.width / 2f, rect.height / 2f);

            Widgets.Label(rect5, TradeSession.trader.TraderKind.LabelCap);
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.color   = new Color(1f, 1f, 1f, 0.6f);
            Text.Font   = GameFont.Tiny;
            Rect rect6 = new Rect(rect.width / 2f - 100f - 30f, 0f, 200f, rect.height);

            Text.Anchor = TextAnchor.LowerCenter;
            Widgets.Label(rect6, "PositiveBuysNegativeSells".Translate());
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.color   = Color.white;
            if (this.playerIsCaravan)
            {
                Text.Font = GameFont.Small;
                float massUsage    = this.MassUsage;
                float massCapacity = this.MassCapacity;
                Rect  rect7        = rect.AtZero();
                rect7.y = 45f;
                TransferableUIUtility.DrawMassInfo(rect7, massUsage, massCapacity, "TradeMassUsageTooltip".Translate(), -9999f, false);
                CaravanUIUtility.DrawDaysWorthOfFoodInfo(new Rect(rect7.x, rect7.y + 19f, rect7.width, rect7.height), this.DaysWorthOfFood.First, this.DaysWorthOfFood.Second, this.EnvironmentAllowsEatingVirtualPlantsNow, false, 200f);
            }
            GUI.EndGroup();
            float num2 = 0f;

            if (this.cachedCurrencyTradeable != null)
            {
                float num3  = inRect.width - 16f;
                Rect  rect8 = new Rect(0f, this.TopAreaHeight, num3, 30f);
                TradeUI.DrawTradeableRow(rect8, this.cachedCurrencyTradeable, 1);
                GUI.color = Color.gray;
                Widgets.DrawLineHorizontal(0f, this.TopAreaHeight + 30f - 1f, num3);
                GUI.color = Color.white;
                num2      = 30f;
            }
            Rect mainRect = new Rect(0f, this.TopAreaHeight + num2, inRect.width, inRect.height - this.TopAreaHeight - 38f - num2 - 20f);

            this.FillMainRect(mainRect);
            Rect rect9 = new Rect(inRect.width / 2f - this.AcceptButtonSize.x / 2f, inRect.height - 55f, this.AcceptButtonSize.x, this.AcceptButtonSize.y);

            if (Widgets.ButtonText(rect9, "AcceptButton".Translate(), true, false, true))
            {
                Action action = delegate
                {
                    bool flag;
                    if (TradeSession.deal.TryExecute(out flag))
                    {
                        if (flag)
                        {
                            SoundDefOf.ExecuteTrade.PlayOneShotOnCamera(null);
                            Pawn pawn = TradeSession.trader as Pawn;
                            if (pawn != null)
                            {
                                TaleRecorder.RecordTale(TaleDefOf.TradedWith, new object[]
                                {
                                    TradeSession.playerNegotiator,
                                    pawn
                                });
                            }
                            TradeSession.playerNegotiator.mindState.inspirationHandler.EndInspiration(InspirationDefOf.InspiredTrade);
                            this.Close(false);
                        }
                        else
                        {
                            this.Close(true);
                        }
                    }
                };
                if (TradeSession.deal.DoesTraderHaveEnoughSilver())
                {
                    action();
                }
                else
                {
                    this.FlashSilver();
                    SoundDefOf.ClickReject.PlayOneShotOnCamera(null);
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmTraderShortFunds".Translate(), action, false, null));
                }
                Event.current.Use();
            }
            Rect rect10 = new Rect(rect9.x - 10f - this.OtherBottomButtonSize.x, rect9.y, this.OtherBottomButtonSize.x, this.OtherBottomButtonSize.y);

            if (Widgets.ButtonText(rect10, "ResetButton".Translate(), true, false, true))
            {
                SoundDefOf.TickLow.PlayOneShotOnCamera(null);
                TradeSession.deal.Reset();
                this.CacheTradeables();
                this.CountToTransferChanged();
                Event.current.Use();
            }
            Rect rect11 = new Rect(rect9.xMax + 10f, rect9.y, this.OtherBottomButtonSize.x, this.OtherBottomButtonSize.y);

            if (Widgets.ButtonText(rect11, "CancelButton".Translate(), true, false, true))
            {
                this.Close(true);
                Event.current.Use();
            }
        }
Ejemplo n.º 4
0
        public override void DoWindowContents(Rect canvas)
        {
            if (Event.current.type == EventType.Layout)
            {
                return;
            }

            //  canvas.y += 35;
            //   canvas.height -= 35f;

            // Widgets.DrawMenuSection(canvas);

            // TabDrawer.DrawTabs(canvas, MainTabs, 150f);

            var ListerBox = canvas.LeftPart(0.30f);

            ListerBox.width -= 10f;
            Widgets.DrawMenuSection(ListerBox);
            ListerBox = ListerBox.ContractedBy(4f);
            var innyrek = ListerBox.AtZero();

            innyrek.width -= 16f;
            innyrek.height = moaner;
            var goat = 0f;

            Text.Anchor = TextAnchor.MiddleLeft;
            Text.Font   = GameFont.Tiny;
            Widgets.BeginScrollView(ListerBox, ref scrolpostabs, innyrek);
            GUI.BeginGroup(innyrek);
            listing.Begin(innyrek);
            // var row = listing.getr

            foreach (var maintab in MainTabs)
            {
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.UpperLeft;
                goat       += 40f;
                var row = listing.GetRect(30f);
                if (maintab.Selected)
                {
                    Widgets.DrawOptionSelected(row);
                }
                if (Widgets.ButtonInvisible(row))
                {
                    maintab.clickedAction();
                }
                row.x += 5f;
                Widgets.Label(row, maintab.label);

                TooltipHandler.TipRegion(row, maintab.Tip);

                Text.Anchor = TextAnchor.MiddleLeft;
                Text.Font   = GameFont.Tiny;

                foreach (var mode in maintab.Modes)
                {
                    if (!mode.Key.Basics && !Analyzer.Settings.AdvancedMode)
                    {
                        continue;
                    }
                    row = listing.GetRect(30f);
                    Widgets.DrawHighlightIfMouseover(row);
                    if (Analyzer.SelectedMode == mode.Key)
                    {
                        Widgets.DrawOptionSelected(row);
                    }
                    row.x += 20f;
                    goat  += 30f;
                    Widgets.Label(row, mode.Key.name);
                    if (Widgets.ButtonInvisible(row))
                    {
                        if (ShowSettings)
                        {
                            ShowSettings = false;
                            Analyzer.Settings.Write();
                        }
                        if (Analyzer.SelectedMode != null)
                        {
                            AccessTools.Field(Analyzer.SelectedMode.typeRef, "Active").SetValue(null, false);
                        }
                        AccessTools.Field(mode.Value, "Active").SetValue(null, true);
                        Analyzer.SelectedMode = mode.Key;
                        Analyzer.Reset();

                        if (!mode.Key.IsPatched)
                        {
                            mode.Key.ProfilePatch();
                        }
                    }
                    TooltipHandler.TipRegion(row, mode.Key.tip);

                    if (Analyzer.SelectedMode == mode.Key)
                    {
                        var doo = 0;
                        foreach (var keySetting in mode.Key.Settings)
                        {
                            if (keySetting.Key.FieldType == typeof(bool))
                            {
                                row       = listing.GetRect(30f);
                                row.x    += 20f;
                                GUI.color = Widgets.OptionSelectedBGBorderColor;
                                Widgets.DrawLineVertical(row.x, row.y, 15f);
                                if (doo != 0)
                                {
                                    Widgets.DrawLineVertical(row.x, row.y - 15f, 15f);
                                }
                                row.x += 10f;
                                Widgets.DrawLineHorizontal(row.x - 10f, row.y + 15f, 10f);
                                GUI.color = Color.white;
                                goat     += 30f;
                                bool cur = (bool)keySetting.Key.GetValue(null);
                                if (DubGUI.Checkbox(row, keySetting.Value.name, ref cur))
                                {
                                    keySetting.Key.SetValue(null, cur);
                                    Analyzer.Reset();
                                }
                            }
                            if (keySetting.Key.FieldType == typeof(float) || keySetting.Key.FieldType == typeof(int))
                            {
                            }

                            doo++;
                        }
                    }
                }
            }

            listing.End();
            moaner = goat;
            GUI.EndGroup();

            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            Widgets.EndScrollView();


            var inner = canvas.RightPart(0.70f).Rounded();

            if (ShowSettings)
            {
                Analyzer.Settings.DoSettings(inner);
            }
            else
            {
                try
                {
                    if (PatchedEverything)
                    {
                        if (Dialog_Graph.key != string.Empty)
                        {
                            Rect blurg = inner.TopPart(0.75f).Rounded();
                            Widgets.DrawMenuSection(blurg);
                            blurg = blurg.ContractedBy(6f);
                            DoThingTab(blurg);
                            blurg = inner.BottomPart(0.25f).Rounded();
                            //blurg = blurg.BottomPartPixels(inner.height - 10f);
                            Dialog_Graph.DoGraph(blurg);
                        }
                        else
                        {
                            Widgets.DrawMenuSection(inner);
                            DoThingTab(inner.ContractedBy(6f));
                        }
                    }
                    else
                    {
                        Widgets.DrawMenuSection(inner);
                        Text.Font   = GameFont.Medium;
                        Text.Anchor = TextAnchor.MiddleCenter;
                        Widgets.Label(inner, $"Loading{GenText.MarchingEllipsis(0f)}");
                        Text.Font   = GameFont.Small;
                        Text.Anchor = TextAnchor.UpperLeft;
                    }
                }
                catch (Exception e)
                {
                    // Console.WriteLine(e);
                    //  throw;
                }
            }
        }
        private static void _Draw(Rect rect, Pawn pawn)
        {
            Policy policy = pawn.GetPolicyAssignedTo();

            Text.Anchor = TextAnchor.MiddleLeft;

            // -------------------- Top left --------------------------

            Rect topRect = new Rect(rect.position.x + horizontalMargin, rect.position.y + verticalMargin, topRectSize.x - horizontalMargin * 2, topRectSize.y);

            Listing_Standard listing = new Listing_Standard();

            listing.Begin(topRect);
            listing.ColumnWidth     = topRect.width / 2;
            listing.verticalSpacing = 4;

            Text.Anchor = TextAnchor.MiddleCenter;
            //listingLeft.Label("PawnPolicyCard_Policy".Translate());

            string readable = pawn.GetPolicyAssignedTo().label;

            var flag = pawn.HasHardcodedPolicy();

            if (flag)
            {
                listing.Label(string.Format("{0} ({1})", "PawnPolicyCard_CannotSetPolicy".Translate(), policy.label));
            }
            else
            {
                if (listing.ButtonTextLabeled("PawnPolicyCard_Policy".Translate(), readable))
                {
                    var floatOptions = new List <FloatMenuOption>();
                    var policies     = Policies.GetAllPoliciesForPawn(pawn)
#if !DEBUG
                                       .Where(arg => arg.Visible)
#endif
                    ;
                    foreach (var item in policies)
                    {
                        floatOptions.Add(new FloatMenuOption(item.label, () => WorldDataStore_PawnPolicies.SetPolicyForPawn(pawn, item), MenuOptionPriority.Default,
                                                             delegate
                        {
                            //TODO: policy tooltip
                        }));
                    }
                    Find.WindowStack.Add(new FloatMenu(floatOptions));
                }
            }
            listing.NewColumn();

            // -------------------- Top right --------------------------

            Thing    bestFood;
            ThingDef bestFoodDef;

            string bestFoodInfo;

            if (FoodUtility.TryFindBestFoodSourceFor(pawn, pawn, true, out bestFood, out bestFoodDef))
            {
                bestFoodInfo = bestFood.Label;
                if (pawn.inventory != null && pawn.inventory.innerContainer.Contains(bestFood))
                {
                    bestFoodInfo += " " + "PawnPolicyCard_Inventory".Translate();
                }
            }
            else
            {
                bestFoodInfo = "PawnPolicyCard_NoFoodFound".Translate();
            }

            listing.Label(string.Format("PawnPolicyCard_CurrentBestFood".Translate(), bestFoodInfo));

            //var mask = PawnMask.MakeCompleteMaskFromPawn(pawn);
            //listing.Label(mask.ToString());
            listing.End();

            // -------------------- Top end --------------------------

            Widgets.DrawLineHorizontal(rect.x + horizontalMargin, rect.y + topRectSize.y - verticalMargin, rect.width - horizontalMargin * 2);

            // ---------------------------- Middle -------------------------------

            Rect policyRectMiddle = new Rect(rect.x + horizontalMargin, rect.y + topRectSize.y, middleRectSize.x - horizontalMargin, middleRectSize.y);

            // ---------------------------- Middle left -------------------------------

            Listing_Standard listingMiddleLeft = new Listing_Standard(GameFont.Small);

            listingMiddleLeft.Begin(policyRectMiddle.LeftPart(middleLeftColumnSize / policyRectMiddle.width));

            listingMiddleLeft.verticalSpacing = verticalMargin;

            //listingMiddleLeft.ColumnWidth = middleLeftColumnSize;

            //Rect policyRectMiddleLeft = policyRectMiddle.LeftHalf();

            //string policyDesc = "";


            //Rect policyRectMiddleLeft_inner = new Rect(0, 0, policyRectMiddleLeft.width, policyRectMiddleLeft.height * 2);
            //Widgets.BeginScrollView(policyRectMiddleLeft, ref scrollposition, policyRectMiddleLeft_inner);

            //var listingMiddleLeft_inner = new Listing_Standard(policyRectMiddleLeft);

            Text.Anchor = TextAnchor.UpperLeft;
            if (policy.description != null && policy.description.Any())
            {
                listingMiddleLeft.Label(policy.description);
            }
            else
            {
                listingMiddleLeft.Label("(No description)");                 //TODO: lang file
            }
            {
                var font = Text.Font;
                Text.Font = GameFont.Tiny;
                listingMiddleLeft.Label(policy.GetDietForPawn(pawn).ToString());
                Text.Font = font;
            }

            listingMiddleLeft.End();

            //Widgets.EndScrollView();

            // ----------------------------- Middle right ----------------------------------

            var rectMiddleRight = policyRectMiddle.RightPart((middleRightColumnSize - horizontalMargin * 4) / policyRectMiddle.width);

            rectMiddleRight.x -= horizontalMargin;
            Listing_Standard listingMiddleRight = new Listing_Standard();

            listingMiddleRight.Begin(rectMiddleRight);

            listingMiddleRight.verticalSpacing = verticalMargin;

            if (!flag)
            {
                Text.Anchor = TextAnchor.MiddleCenter;

                listingMiddleRight.verticalSpacing = verticalMargin;

                if (listingMiddleRight.ButtonText("PawnPolicyCard_ResetPolicy".Translate()))
                {
                    WorldDataStore_PawnPolicies.SetPolicyForPawn(pawn, null);
                }
                //if (listingRight.ButtonText(string.Format("PawnPolicyCard_AssignToAll".Translate(), pawn.def.label)))
                //{
                //	WorldDataStore_PawnPolicies.AssignToAllPawnsOfRaces(policy,pawn.def);
                //}
                {
                    string            targetGroupName = "";
                    Func <Pawn, bool> validator       = null;

                    if (pawn.IsColonist)
                    {
                        validator       = (arg) => arg.IsColonist;
                        targetGroupName = "colonists".Translate();
                    }
                    else if (pawn.IsPrisonerOfColony)
                    {
                        validator       = (arg) => arg.IsPrisonerOfColony;
                        targetGroupName = "prisoners".Translate();
                    }
                    //TODO: setter for rescued pawns
                    //else if (pawn.HostFaction != null && pawn.HostFaction.IsPlayer)
                    //{
                    //	validator = (arg) => (pawn.HostFaction != null && pawn.HostFaction.IsPlayer);
                    //	targetGroupName = "guests".Translate();
                    //}
                    else if (pawn.Faction.IsPlayer && pawn.RaceProps.Animal)
                    {
                        validator       = (arg) => (pawn.Faction.IsPlayer && arg.RaceProps.Animal && arg.def == pawn.def);
                        targetGroupName = pawn.def.label;
                    }

                    if (validator != null)
                    {
                        if (listingMiddleRight.ButtonText(string.Format("PawnPolicyCard_AssignToAllOnMap".Translate(), targetGroupName)))
                        {
                            WorldDataStore_PawnPolicies.AssignToAllPawnsMatchingOnMap(policy, validator);
                        }
                        if (listingMiddleRight.ButtonText(string.Format("PawnPolicyCard_ResetAllOnMap".Translate(), targetGroupName)))
                        {
                            WorldDataStore_PawnPolicies.AssignToAllPawnsMatchingOnMap(null, validator);
                        }
                    }
                }
            }

            listingMiddleRight.End();
        }
Ejemplo n.º 6
0
        internal static void DrawStorytellerSelectionInterface(Rect rect, ref StorytellerDef chosenStoryteller, ref DifficultyDef difficulty, Listing_Standard selectedStorytellerInfoListing)
        {
            GUI.BeginGroup(rect);
            if (chosenStoryteller != null && chosenStoryteller.listVisible)
            {
                float   height            = rect.height;
                Vector2 portraitSizeLarge = Storyteller.PortraitSizeLarge;
                double  y = height - portraitSizeLarge.y - 1.0;
                Vector2 portraitSizeLarge2 = Storyteller.PortraitSizeLarge;
                float   x = portraitSizeLarge2.x;
                Vector2 portraitSizeLarge3 = Storyteller.PortraitSizeLarge;
                Rect    position           = new Rect(390f, (float)y, x, portraitSizeLarge3.y);
                GUI.DrawTexture(position, chosenStoryteller.portraitLargeTex);
                Widgets.DrawLineHorizontal(0f, rect.height, rect.width);
            }
            Vector2 portraitSizeTiny  = Storyteller.PortraitSizeTiny;
            Rect    outRect           = new Rect(0f, 0f, (float)(portraitSizeTiny.x + 16.0), rect.height);
            Vector2 portraitSizeTiny2 = Storyteller.PortraitSizeTiny;
            float   x2  = portraitSizeTiny2.x;
            float   num = (float)DefDatabase <StorytellerDef> .AllDefs.Count();

            Vector2 portraitSizeTiny3 = Storyteller.PortraitSizeTiny;
            Rect    viewRect          = new Rect(0f, 0f, x2, (float)(num * (portraitSizeTiny3.y + 10.0)));

            Widgets.BeginScrollView(outRect, ref StorytellerUI.scrollPosition, viewRect, true);
            Vector2 portraitSizeTiny4 = Storyteller.PortraitSizeTiny;
            float   x3 = portraitSizeTiny4.x;
            Vector2 portraitSizeTiny5 = Storyteller.PortraitSizeTiny;
            Rect    rect2             = new Rect(0f, 0f, x3, portraitSizeTiny5.y);

            foreach (StorytellerDef item in from tel in DefDatabase <StorytellerDef> .AllDefs
                     orderby tel.listOrder
                     select tel)
            {
                if (item.listVisible)
                {
                    if (Widgets.ButtonImage(rect2, item.portraitTinyTex))
                    {
                        TutorSystem.Notify_Event("ChooseStoryteller");
                        chosenStoryteller = item;
                    }
                    if (chosenStoryteller == item)
                    {
                        GUI.DrawTexture(rect2, StorytellerUI.StorytellerHighlightTex);
                    }
                    rect2.y += (float)(rect2.height + 8.0);
                }
            }
            Widgets.EndScrollView();
            Text.Font = GameFont.Small;
            Rect rect3 = new Rect((float)(outRect.xMax + 8.0), 0f, 240f, 999f);

            Widgets.Label(rect3, "HowStorytellersWork".Translate());
            if (chosenStoryteller != null && chosenStoryteller.listVisible)
            {
                Rect rect4 = new Rect((float)(outRect.xMax + 8.0), (float)(outRect.yMin + 200.0), 290f, 0f);
                rect4.height = rect.height - rect4.y;
                Text.Font    = GameFont.Medium;
                Rect rect5 = new Rect((float)(rect4.x + 15.0), (float)(rect4.y - 40.0), 9999f, 40f);
                Widgets.Label(rect5, chosenStoryteller.label);
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;
                selectedStorytellerInfoListing.Begin(rect4);
                selectedStorytellerInfoListing.Label(chosenStoryteller.description, 120f);
                selectedStorytellerInfoListing.Gap(6f);
                foreach (DifficultyDef allDef in DefDatabase <DifficultyDef> .AllDefs)
                {
                    Rect rect6 = selectedStorytellerInfoListing.GetRect(30f);
                    if (Mouse.IsOver(rect6))
                    {
                        Widgets.DrawHighlight(rect6);
                    }
                    TooltipHandler.TipRegion(rect6, allDef.description);
                    if (Widgets.RadioButtonLabeled(rect6, allDef.LabelCap, difficulty == allDef))
                    {
                        difficulty = allDef;
                    }
                }
                selectedStorytellerInfoListing.Gap(30f);
                if (Current.ProgramState == ProgramState.Entry)
                {
                    selectedStorytellerInfoListing.CheckboxLabeled("PermadeathMode".Translate(), ref Find.GameInitData.permadeath, "PermadeathModeInfo".Translate());
                }
                selectedStorytellerInfoListing.End();
            }
            GUI.EndGroup();
        }
 public void LearningReadoutOnGUI()
 {
     if (!TutorSystem.TutorialMode && TutorSystem.AdaptiveTrainingEnabled)
     {
         if (Find.PlaySettings.showLearningHelper || this.activeConcepts.Count != 0)
         {
             if (!Find.WindowStack.IsOpen <Screen_Credits>())
             {
                 float b        = (float)UI.screenHeight / 2f;
                 float a        = this.contentHeight + 14f;
                 Rect  outRect  = new Rect((float)UI.screenWidth - 8f - 200f, 8f, 200f, Mathf.Min(a, b));
                 Rect  outRect2 = outRect;
                 Find.WindowStack.ImmediateWindow(76136312, outRect, WindowLayer.Super, delegate
                 {
                     outRect       = outRect.AtZero();
                     Rect rect     = outRect.ContractedBy(7f);
                     Rect viewRect = rect.AtZero();
                     bool flag     = this.contentHeight > rect.height;
                     Widgets.DrawWindowBackgroundTutor(outRect);
                     if (flag)
                     {
                         viewRect.height     = this.contentHeight + 40f;
                         viewRect.width     -= 20f;
                         this.scrollPosition = GUI.BeginScrollView(rect, this.scrollPosition, viewRect);
                     }
                     else
                     {
                         GUI.BeginGroup(rect);
                     }
                     float num2 = 0f;
                     Text.Font  = GameFont.Small;
                     Rect rect2 = new Rect(0f, 0f, viewRect.width - 24f, 24f);
                     Widgets.Label(rect2, "LearningHelper".Translate());
                     num2         = rect2.yMax;
                     Rect butRect = new Rect(rect2.xMax, rect2.y, 24f, 24f);
                     if (Widgets.ButtonImage(butRect, this.showAllMode ? TexButton.Minus : TexButton.Plus))
                     {
                         this.showAllMode = !this.showAllMode;
                         if (this.showAllMode)
                         {
                             SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                         }
                         else
                         {
                             SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                         }
                     }
                     if (this.showAllMode)
                     {
                         Rect rect3        = new Rect(0f, num2, viewRect.width - 20f - 2f, 28f);
                         this.searchString = this.FilterSearchStringInput(Widgets.TextField(rect3, this.searchString));
                         if (this.searchString == "")
                         {
                             GUI.color   = new Color(0.6f, 0.6f, 0.6f, 1f);
                             Text.Anchor = TextAnchor.MiddleLeft;
                             Rect rect4  = rect3;
                             rect4.xMin += 7f;
                             Widgets.Label(rect4, "Filter".Translate() + "...");
                             Text.Anchor = TextAnchor.UpperLeft;
                             GUI.color   = Color.white;
                         }
                         Rect butRect2 = new Rect(viewRect.width - 20f, num2 + 14f - 10f, 20f, 20f);
                         if (Widgets.ButtonImage(butRect2, TexButton.CloseXSmall))
                         {
                             this.searchString = "";
                             SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(null);
                         }
                         num2 = rect3.yMax + 4f;
                     }
                     IEnumerable <ConceptDef> enumerable = this.showAllMode ? DefDatabase <ConceptDef> .AllDefs : this.activeConcepts;
                     if (enumerable.Any <ConceptDef>())
                     {
                         GUI.color = new Color(1f, 1f, 1f, 0.5f);
                         Widgets.DrawLineHorizontal(0f, num2, viewRect.width);
                         GUI.color = Color.white;
                         num2     += 4f;
                     }
                     if (this.showAllMode)
                     {
                         enumerable = from c in enumerable
                                      orderby this.DisplayPriority(c) descending, c.label
                         select c;
                     }
                     foreach (ConceptDef conceptDef2 in enumerable)
                     {
                         if (!conceptDef2.TriggeredDirect)
                         {
                             num2 = this.DrawConceptListRow(0f, num2, viewRect.width, conceptDef2).yMax;
                         }
                     }
                     this.contentHeight = num2;
                     if (flag)
                     {
                         GUI.EndScrollView();
                     }
                     else
                     {
                         GUI.EndGroup();
                     }
                 }, false, false, 1f);
                 float num = Time.realtimeSinceStartup - this.lastConceptActivateRealTime;
                 if (num < 1f && num > 0f)
                 {
                     GenUI.DrawFlash(outRect2.x, outRect2.center.y, (float)UI.screenWidth * 0.6f, Pulser.PulseBrightness(1f, 1f, num) * 0.85f, new Color(0.8f, 0.77f, 0.53f));
                 }
                 ConceptDef conceptDef = (this.selectedConcept == null) ? this.mouseoverConcept : this.selectedConcept;
                 if (conceptDef != null)
                 {
                     this.DrawInfoPane(conceptDef);
                     conceptDef.HighlightAllTags();
                 }
                 this.mouseoverConcept = null;
             }
         }
     }
 }
Ejemplo n.º 8
0
        public void Append(string item)
        {
            //Insert html formatting
            item = item
                   .Replace("[b]", "<b>")
                   .Replace("[/b]", "</b>");

            Text.Font = ItemFont;

            // Draw title
            if (item.StartsWith("[title]"))
            {
                Text.Font = TitleFont;
                Widgets.Label(viewRect, item.Substring(7));
                viewRect.y += Text.CalcHeight(item, viewRect.width) + Spacing;

                // Draw line gap
                Color color = GUI.color;
                GUI.color = GUI.color * new Color(1f, 1f, 1f, 0.4f);
                Widgets.DrawLineHorizontal(viewRect.x, viewRect.y + +GapHeight * 0.5f, viewRect.width);
                GUI.color   = color;
                viewRect.y += GapHeight;
            }
            // Draw Image with Text
            else if (item.StartsWith("[img]"))
            {
                int imgLength   = item.IndexOf("[/img]");
                var imageString = item.Substring(5, imgLength - 5);
                var textToDraw  = item.Substring(imgLength + 6);

                var content = new GUIContent();
                content.image = ContentFinder <Texture2D> .Get(imageString, false);

                content.text = textToDraw;
                Widgets.Label(viewRect, content);

                viewRect.y += GuiStyle(Text.Font).CalcHeight(content, viewRect.width);
            }
            // Draw Gap
            else if (item.StartsWith("[gap]"))
            {
                Color color = GUI.color;
                GUI.color = GUI.color * new Color(1f, 1f, 1f, 0.4f);
                Widgets.DrawLineHorizontal(viewRect.x, viewRect.y + +GapHeight * 0.5f, viewRect.width);
                GUI.color   = color;
                viewRect.y += GapHeight;
            }
            // Draw Subtitle (without margin, old)
            else if (item.StartsWith("[subtitle]"))
            {
                Widgets.Label(viewRect, item.Substring(10));
                viewRect.y += Text.CalcHeight(item.Substring(10), viewRect.width) + Spacing;
            }
            // Draw Video
            else if (item.StartsWith("[video]"))
            {
                int imgLength  = item.IndexOf("[/video]");
                var framesSrc  = item.Substring(7, imgLength - 7);
                var dimensions = item.Substring(imgLength + 8).Split('x');

                Vector2 videoSize       = dimensions.Length >= 2 ? new Vector2(int.Parse(dimensions[0]), int.Parse(dimensions[1])) : new Vector2(100, 100);
                int     framesPerSecond = dimensions.Length >= 3 ? int.Parse(dimensions[2]) : 10;

                new SimpleVideo(framesSrc, framesPerSecond).OnGui(new Rect((viewRect.x - videoSize.x) / 2, viewRect.y, videoSize.x, videoSize.y));

                viewRect.y += videoSize.y;
            }
            // List point (with margin)
            else if (item.StartsWith("[-]"))
            {
                viewRect.width -= MarginWidth;
                Widgets.Label(viewRect, MarginText);
                viewRect.x += MarginWidth;
                Widgets.Label(viewRect, item.Substring(3));
                viewRect.x     -= MarginWidth;
                viewRect.y     += Text.CalcHeight(item.Substring(3), viewRect.width) + Spacing;
                viewRect.width += MarginWidth;
            }
            // Draw Text
            else
            {
                Widgets.Label(viewRect, item);
                viewRect.y += Text.CalcHeight(item, viewRect.width) + Spacing;
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Draws the description boxes.
        /// </summary>
        /// <param name="inRect">The in rect.</param>
        public void DrawDescriptionBoxes(Rect inRect)
        {
            // Build the modification summary string.


            foreach (MutationData entry in addedMutations.mutationData)
            {
                if (entry.removing)
                {
                    summaryBuilder.AppendLine(REMOVING_MUTATION_DESC.Translate(entry.mutation.Named("MUTATION"), pawn.Named("PAWN"), entry.part.Named("PART")));
                }
                else
                {
                    string isHaltedTxt = (entry.isHalted ? HALTED_MUTATION_DESC.Translate().RawText : "");

                    var addStr = ADDING_MUTATION_DESC.Translate(entry.mutation.Named("MUTATION"), entry.part.Named("PART"), pawn.Named("PAWN"),
                                                                entry.severity.ToString("n2").Named("SEVERITY"))
                                 + "."
                                 + isHaltedTxt;

                    summaryBuilder.AppendLine(addStr);
                }
                summaryBuilder.AppendLine();
            }



            // Draw modification summary description.
            Rect  summaryMenuSectionRect = new Rect(inRect.x, inRect.y, inRect.width, (inRect.height - SPACER_SIZE) / 2);
            Rect  summaryOutRect         = summaryMenuSectionRect.ContractedBy(MENU_SECTION_CONSTRICTION_SIZE);
            Rect  summaryViewRect        = new Rect(summaryOutRect.x, summaryOutRect.y, summaryScrollSize.x, summaryScrollSize.y);
            float summaryCurY            = summaryOutRect.y;

            Widgets.DrawMenuSection(summaryMenuSectionRect);
            Widgets.BeginScrollView(summaryOutRect, ref summaryScrollPos, summaryViewRect);
            Widgets.Label(new Rect(summaryViewRect.x, summaryCurY, summaryViewRect.width, Text.CalcHeight(SUMMARY_TITLE_LOC_STRING.Translate(), summaryViewRect.width)), SUMMARY_TITLE_LOC_STRING.Translate());
            summaryCurY += Text.CalcHeight(SUMMARY_TITLE_LOC_STRING.Translate(), summaryViewRect.width);
            GUI.color    = new Color(0.5f, 0.5f, 0.5f, 1f);
            Widgets.DrawLineHorizontal(summaryViewRect.x, summaryCurY, summaryOutRect.width);
            summaryCurY += 1f;
            GUI.color    = Color.white;
            string summaryText = summaryBuilder.ToString();

            Widgets.Label(new Rect(summaryViewRect.x, summaryCurY, summaryViewRect.width, Text.CalcHeight(summaryText, summaryViewRect.width)), summaryText);
            summaryCurY += Text.CalcHeight(summaryText, summaryViewRect.width);
            if (Event.current.type == EventType.Layout)
            {
                summaryScrollSize.y = summaryCurY - summaryViewRect.y;
                summaryScrollSize.x = summaryOutRect.width - (summaryScrollSize.y > summaryOutRect.height ? 16f : 0f);
            }
            Widgets.EndScrollView();
            summaryBuilder.Clear();

            // Draw mutation description.
            Rect  descMenuSectionRect = new Rect(inRect.x, (inRect.height + SPACER_SIZE) / 2 + inRect.y, inRect.width, (inRect.height - SPACER_SIZE) / 2);
            Rect  descOutRect         = descMenuSectionRect.ContractedBy(MENU_SECTION_CONSTRICTION_SIZE);
            Rect  descViewRect        = new Rect(descOutRect.x, descOutRect.y, descScrollSize.x, descScrollSize.y);
            float descCurY            = descOutRect.y;

            Widgets.DrawMenuSection(descMenuSectionRect);
            Widgets.BeginScrollView(descOutRect, ref descScrollPos, descViewRect);
            Widgets.Label(new Rect(descViewRect.x, descCurY, descViewRect.width, Text.CalcHeight(PART_DESCRIPTION_TITLE_LOC_STRING.Translate(), descViewRect.width)), PART_DESCRIPTION_TITLE_LOC_STRING.Translate());
            descCurY += Text.CalcHeight(PART_DESCRIPTION_TITLE_LOC_STRING.Translate(), descViewRect.width);
            GUI.color = new Color(0.5f, 0.5f, 0.5f, 1f);
            Widgets.DrawLineHorizontal(descViewRect.x, descCurY, descOutRect.width);
            descCurY += 1f;
            GUI.color = Color.white;
            Widgets.Label(new Rect(descViewRect.x, descCurY, descViewRect.width, Text.CalcHeight(partDescBuilder.ToString(), descViewRect.width)), partDescBuilder.ToString());
            descCurY += Text.CalcHeight(partDescBuilder.ToString(), descViewRect.width);
            if (Event.current.type == EventType.Layout)
            {
                descScrollSize.y = descCurY - descViewRect.y;
                descScrollSize.x = descOutRect.width - (descScrollSize.y > descOutRect.height ? 16f : 0f);
            }
            Widgets.EndScrollView();
            partDescBuilder.Clear();
        }
Ejemplo n.º 10
0
 public static void SeparatorHorizontal(float x, float y, float len)
 {
     GUI.color = Color.grey;
     Widgets.DrawLineHorizontal(x, y, len);
     GUI.color = Color.white;
 }
Ejemplo n.º 11
0
        public override void DoSettingsWindowContents(Rect inRect)
        {
            GUI.BeginGroup(inRect);

            float ymax = UIUtil.DrawSectionLabel(inRect.x, inRect.y, "SettingsMMCategory".Translate(), inRect.xMax);

            string text   = "SettingsMMTipLabel".Translate();
            float  width  = inRect.width / 2 - UIUtil.MarginLarge - UIUtil.MarginHorizontal * 4;
            float  height = Text.CalcHeight(text, width);

            #region MemMon

            Rect rectMemMon = new Rect(inRect.x + UIUtil.MarginLarge + UIUtil.MarginHorizontal, ymax, inRect.width - UIUtil.MarginLarge * 2 - UIUtil.MarginHorizontal * 2, height * 4 + UIUtil.MarginVertical * 3 + (Prefs.DevMode ? height + UIUtil.MarginVertical : 0));
            GUI.BeginGroup(rectMemMon);

            #region MMLeft
            Rect rectCheck = new Rect(0f, 0f, width + UIUtil.MarginHorizontal, height);
            bool flag      = Settings.EnableMemoryMonitorTip;
            Widgets.CheckboxLabeled(rectCheck, text, ref flag);
            Settings.EnableMemoryMonitorTip = flag;
            TooltipHandler.TipRegion(rectCheck, "SettingsMMTipTip".Translate());
            rectCheck = new Rect(rectCheck.x, rectCheck.yMax + UIUtil.MarginVertical, width + UIUtil.MarginHorizontal, height);
            flag      = Settings.EnableMemoryMonitorBar;
            Widgets.CheckboxLabeled(rectCheck, "SettingsMMBarLabel".Translate(), ref flag);
            Settings.EnableMemoryMonitorBar = flag;
            TooltipHandler.TipRegion(rectCheck, "SettingsMMBarTip".Translate());

            if (Settings.EnableMemoryMonitorBar)
            {
                Rect rectRangeLabel = new Rect(UIUtil.MarginHorizontal, rectCheck.yMax + UIUtil.MarginVertical, width, height);
                Widgets.Label(rectRangeLabel, "SettingsMMRangeLabel".Translate());
                TooltipHandler.TipRegion(rectRangeLabel, "SettingsMMRangeTip".Translate());

                float w       = Text.CalcSize("x32").x;
                Rect  rectx32 = new Rect(rectRangeLabel.xMax - w * 2 - 5f - UIUtil.MarginHorizontal, rectRangeLabel.y, w, height);
                if (Mouse.IsOver(rectx32))
                {
                    GUI.color = Color.cyan;
                }
                else
                {
                    GUI.color = Color.gray;
                }
                Widgets.Label(rectx32, "x32");
                Widgets.DrawLineHorizontal(rectx32.x, rectx32.yMax - 1f, rectx32.width);
                GUI.color = Color.white;
                if (Widgets.ButtonInvisible(rectx32, true))
                {
                    Settings.MemoryMonitorBarLowerBoundMb = 0;
                    Settings.MemoryMonitorBarUpperBoundMb = 1024;
                }

                Rect rectx64 = new Rect(rectRangeLabel.xMax - w - UIUtil.MarginHorizontal, rectRangeLabel.y, w, height);
                if (Mouse.IsOver(rectx64) && IntPtr.Size == 8)
                {
                    GUI.color = Color.cyan;
                }
                else
                {
                    GUI.color = Color.gray;
                }
                Widgets.Label(rectx64, "x64");
                if (IntPtr.Size == 8)
                {
                    Widgets.DrawLineHorizontal(rectx64.x, rectx64.yMax - 1f, rectx64.width);

                    if (Widgets.ButtonInvisible(rectx64, true))
                    {
                        Settings.MemoryMonitorBarLowerBoundMb = 0;
                        Settings.MemoryMonitorBarUpperBoundMb = 2048;
                    }
                }
                else
                {
                    Widgets.DrawLine(new Vector2(rectx64.x, rectx64.y), new Vector2(rectx64.xMax, rectx64.yMax), Color.gray, 1f);
                }
                GUI.color = Color.white;

                Rect     rectDualSlider = new Rect(rectRangeLabel.x, rectRangeLabel.yMax + UIUtil.MarginVertical, width, height);
                IntRange range          = new IntRange(Settings.MemoryMonitorBarLowerBoundMb, Settings.MemoryMonitorBarUpperBoundMb);
                Widgets.IntRange(rectDualSlider, 233, ref range, 0, 1024 * 8);
                Settings.MemoryMonitorBarLowerBoundMb = range.min;
                Settings.MemoryMonitorBarUpperBoundMb = range.max;
            }
            #endregion

            Rect rectMainButton = new Rect(rectMemMon.width / 2 + (rectMemMon.width / 2 - 130f) / 2, (height * 2 + UIUtil.MarginVertical - 35f) / 2, 130f, 35f);
            UIUtil.MainButtonWorker.DoButton(rectMainButton);

            Rect rectIntervalLabel = new Rect(rectMemMon.width / 2 + UIUtil.MarginHorizontal * 2, height * 2 + UIUtil.MarginVertical * 2 + (35f - height) / 2, rectMemMon.width / 2 - UIUtil.MarginHorizontal - 125f, height);
            Widgets.Label(rectIntervalLabel, "SettingsMMIntervalLabel".Translate());
            TooltipHandler.TipRegion(rectIntervalLabel, "SettingsMMIntervalTip".Translate());

            Rect rectIntervalButton = new Rect(rectMemMon.xMax - 125f - UIUtil.MarginHorizontal * 2, height * 2 + UIUtil.MarginVertical * 2, 125f, 35f);

            if (Widgets.ButtonText(rectIntervalButton, UIUtil.MMIntervalButtonLabelCache))
            {
                FloatMenuUtil.GenerateFloatMenuGroup(FloatMenuUtil.GroupMMUpdateMode);
            }

            if (Prefs.DevMode)
            {
                Rect rectDevOnScreenMem = new Rect(rectMemMon.width / 2 + UIUtil.MarginHorizontal * 2, rectIntervalButton.yMax + UIUtil.MarginVertical, rectMemMon.width / 2 - UIUtil.MarginHorizontal * 3, height);
                flag = RuntimeGC.Settings.DevOnScreenMemoryUsage;
                Widgets.CheckboxLabeled(rectDevOnScreenMem, "SettingsDevOnScreenMemoryUsageLabel".Translate(), ref flag);
                if (flag != RuntimeGC.Settings.DevOnScreenMemoryUsage)
                {
                    RuntimeGC.Settings.DevOnScreenMemoryUsage = flag;
                    RuntimeGC.Settings.UpdateCache();
                }
            }

            GUI.EndGroup();

            #endregion

            UIUtil.BeginRestartCheck();

            ymax = UIUtil.DrawSectionLabel(inRect.x, rectMemMon.yMax + height, "SettingsAutoCleanupCategory".Translate(), inRect.width / 2 - UIUtil.MarginHorizontal);

            Rect rectAutoCleanup = new Rect(rectMemMon.x, ymax, width, height * 3 + UIUtil.MarginVertical * 2);
            GUI.BeginGroup(rectAutoCleanup);
            rectCheck = new Rect(0, 0, width, height);
            UIUtil.DrawCheckboxRestartIfApplied(rectCheck, "SettingsACModMetaDataLabel".Translate(), "SettingsACModMetaDataTip".Translate(), ref Settings.AutoCleanModMetaData);
            rectCheck = new Rect(0, height + UIUtil.MarginVertical, width, height);
            UIUtil.DrawCheckboxRestartIfApplied(rectCheck, "SettingsACLanguageDataLabel".Translate(), "SettingsACLanguageDataTip".Translate(), ref Settings.AutoCleanLanguageData);
            rectCheck = new Rect(0, height * 2 + UIUtil.MarginVertical * 2, width, height);
            UIUtil.DrawCheckboxRestartIfApplied(rectCheck, "SettingsACDefPackageLabel".Translate(), "SettingsACDefPackageTip".Translate(), ref Settings.AutoCleanDefPackage);
            GUI.EndGroup();

            ymax = UIUtil.DrawSectionLabel(rectMemMon.x + rectMemMon.width / 2 + UIUtil.MarginHorizontal, rectMemMon.yMax + height, "SettingsMuteCategory".Translate(), inRect.xMax);

            Rect rectMute = new Rect(rectMemMon.x + rectMemMon.width / 2 + UIUtil.MarginHorizontal * 2, ymax, width, height * 2 + UIUtil.MarginVertical);
            GUI.BeginGroup(rectMute);
            rectCheck = new Rect(0, 0, width, height);
            UIUtil.DrawCheckboxRestartIfApplied(rectCheck, "SettingsMuteGCLabel".Translate(), "SettingsMuteGCTip".Translate(), ref Settings.DoMuteGC);
            rectCheck = new Rect(0, height + UIUtil.MarginVertical, width, height);
            UIUtil.DrawCheckboxRestartIfApplied(rectCheck, "SettingsMuteBLLabel".Translate(), "SettingsMuteBLTip".Translate(), ref Settings.DoMuteBL);
            GUI.EndGroup();


            ymax = UIUtil.DrawSectionLabel(inRect.x, rectAutoCleanup.yMax + height + (Prefs.DevMode ? height + UIUtil.MarginVertical : 0), "SettingsGeneralCategory".Translate(), inRect.width / 2 - UIUtil.MarginHorizontal);

            Rect rectGeneral = new Rect(rectMemMon.x, ymax, width, height * 3 + UIUtil.MarginVertical * 2);
            GUI.BeginGroup(rectGeneral);
            rectCheck = new Rect(0, 0, width, height);
            Widgets.CheckboxLabeled(rectCheck, "SettingsArchiveGCLabel".Translate(), ref Settings.ArchiveGCDialog);
            TooltipHandler.TipRegion(rectCheck, "SettingsArchiveGCTip".Translate());
            rectCheck = new Rect(0, height + UIUtil.MarginVertical, width, height);
            Widgets.CheckboxLabeled(rectCheck, "SettingsArchiveGeneralLabel".Translate(), ref Settings.ArchiveMessageGeneral);
            TooltipHandler.TipRegion(rectCheck, "SettingsArchiveGeneralTip".Translate());
            GUI.EndGroup();


            Rect rectReset = new Rect(inRect.xMax - UIUtil.MarginHorizontal - 135f - 50f, inRect.yMax - 35f - 65f, 135f, 35f);
            if (Widgets.ButtonText(rectReset, "SettingsReset".Translate()))
            {
                Settings.ResetToDefault();
            }


            GUI.EndGroup();
        }
Ejemplo n.º 12
0
        public static void DrawTempleCard(Rect rect, Building_SacrificialAltar altar)
        {
            GUI.BeginGroup(rect);

            if (CultTracker.Get.PlayerCult != null)
            {
                var cultLabelWidth = Text.CalcSize(CultTracker.Get.PlayerCult.name).x + 15;

                //Headings
                _ = new Rect(rect);
                var rect1 = rect.ContractedBy(14f);
                rect1.height = 30f;

                //Unnamed Temple
                Text.Font = GameFont.Medium;
                Widgets.Label(rect1, altar.RoomName);
                Text.Font = GameFont.Small;

                //Rename Icon
                ITab_AltarCardUtility.DrawRename(altar);
                var rect2 = new Rect(rect1)
                {
                    yMin   = rect1.yMax + 10,
                    height = 25f,
                    width  = cultLabelWidth + 5
                };

                //Esoteric Order of Dagon
                Widgets.Label(rect2, CultTracker.Get.PlayerCult.name);
                if (Mouse.IsOver(rect2))
                {
                    Widgets.DrawHighlight(rect2);
                }

                if (Mouse.IsOver(rect2) && Event.current.type == EventType.MouseDown)
                {
                    Find.WindowStack.Add(new Dialog_RenameCult(altar.Map));
                }

                Widgets.DrawLineHorizontal(rect2.x - 10, rect2.yMax, rect.width - 15f);
                //---------------------------------------------------------------------

                var rectMain = new Rect(0 + 15f, 0 + 30f, TempleCardSize.x,
                                        ITab_AltarSacrificesCardUtility.ButtonSize * 1.15f);

                //Deity -> Cthulhu
                var rect4 = rectMain;
                rect4.yMin   = rectMain.yMax + 5f;
                rect4.y      = rectMain.yMax + 20f;
                rect4.x     += 5f;
                rect4.width  = ITab_AltarSacrificesCardUtility.ColumnSize;
                rect4.height = ITab_AltarSacrificesCardUtility.ButtonSize;
                Widgets.Label(rect4, "Deity".Translate() + ": ");
                rect4.xMin = rect4.center.x;
                var label4 = DeityLabel(altar);
                if (Widgets.ButtonText(rect4, label4, true, false))
                {
                    OpenDeitySelectMenu(altar);
                }

                TooltipHandler.TipRegion(rect4, "DeityDesc".Translate());

                //Cthulhu - He who waits dreaming.
                ITab_AltarCardUtility.DrawDeity(altar.tempCurrentWorshipDeity, rect4, null, -30f);

                //Preacher
                var rect5 = rect4;
                rect5.y += ITab_AltarSacrificesCardUtility.ButtonSize + 15f;
                //rect5.y = rect4.yMax + 30f;
                rect5.x    -= rect4.x - 5;
                rect5.x    += 15f;
                rect5.width = ITab_AltarSacrificesCardUtility.ColumnSize;
                Widgets.Label(rect5, "Preacher".Translate() + ": ");
                rect5.xMin = rect5.center.x;
                var label2 = PreacherLabel(altar);
                if (Widgets.ButtonText(rect5, label2, true, false))
                {
                    OpenPreacherSelectMenu(altar);
                }

                TooltipHandler.TipRegion(rect5, "PreacherDesc".Translate());

                var rect6 = rect5;
                rect6.y     += ITab_AltarSacrificesCardUtility.ButtonSize + ITab_AltarSacrificesCardUtility.SpacingOffset;
                rect6.height = ITab_AltarSacrificesCardUtility.ButtonSize * 2;
                rect6.width  = ITab_AltarSacrificesCardUtility.ColumnSize;
                rect6.x     -= rect5.x - 5;
                rect6.x     += 15f;
                if (altar.tempCurrentWorshipDeity != null)
                {
                    Widgets.Label(rect6.BottomHalf(), "Cults_SeasonDays".Translate());

                    Text.Font = GameFont.Tiny;
                    //Text.Anchor = TextAnchor.LowerLeft;
                    var num       = 15f;
                    var num2      = 270f;
                    var hourWidth = 20.833334f;
                    for (var day = 0; day <= 14; day++)
                    {
                        var rect9 = new Rect(num + 4f, num2 + 0f, hourWidth, 20f);
                        Widgets.Label(rect9, (day + 1).ToString());
                        var rect10 = new Rect(num, num2 + 20f, hourWidth, 30f);
                        rect10 = rect10.ContractedBy(1f);
                        var texture = TimeAssignmentDefOf.Anything.ColorTexture;
                        switch (altar.seasonSchedule[day])
                        {
                        case 1:
                            texture = SolidColorMaterials.NewSolidColorTexture(Color.red);
                            break;

                        case 2:
                            texture = SolidColorMaterials.NewSolidColorTexture(Color.blue);
                            break;

                        case 3:
                            texture = SolidColorMaterials.NewSolidColorTexture(Color.magenta);
                            break;
                        }

                        GUI.DrawTexture(rect10, texture);
                        if (Mouse.IsOver(rect10))
                        {
                            Widgets.DrawBox(rect10, 2);
                            //if (Input.GetMouseButton(0))
                            if (Widgets.ButtonInvisible(rect10))
                            {
                                altar.seasonSchedule[day] = (altar.seasonSchedule[day] % 4) + 1;
                                SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera();
                                //p.timetable.SetAssignment(hour, this.selectedAssignment);
                            }
                        }

                        num += hourWidth;
                    }

                    num2 += 60f;
                    var rect11 = new Rect(15f, num2 + 3, hourWidth / 2, hourWidth / 2);
                    rect11 = rect11.ContractedBy(1f);
                    GUI.DrawTexture(rect11, TimeAssignmentDefOf.Anything.ColorTexture);
                    var rect12 = new Rect(15f + hourWidth, num2, 150f, (hourWidth / 2) + 6);
                    Widgets.Label(rect12, "NoSermonLabel".Translate());

                    var rect13 = new Rect(15f + 170f, num2 + 3, hourWidth / 2, hourWidth / 2);
                    rect13 = rect13.ContractedBy(1f);
                    GUI.DrawTexture(rect13, SolidColorMaterials.NewSolidColorTexture(Color.magenta));
                    var rect14 = new Rect(15f + hourWidth + 170f, num2, 150f, (hourWidth / 2) + 6);
                    Widgets.Label(rect14, "BothSermonLabel".Translate());

                    num2 += 30f;
                    var rect15 = new Rect(15f, num2 + 3, hourWidth / 2, hourWidth / 2);
                    rect15 = rect15.ContractedBy(1f);
                    GUI.DrawTexture(rect15, SolidColorMaterials.NewSolidColorTexture(Color.red));
                    var rect16 = new Rect(15f + hourWidth, num2, 150f, (hourWidth / 2) + 6);
                    Widgets.Label(rect16, "MorningSermonLabel".Translate());

                    var rect17 = new Rect(15f + 170f, num2 + 3, hourWidth / 2, hourWidth / 2);
                    rect17 = rect17.ContractedBy(1f);
                    GUI.DrawTexture(rect17, SolidColorMaterials.NewSolidColorTexture(Color.blue));
                    var rect18 = new Rect(15f + hourWidth + 170f, num2, 150f, (hourWidth / 2) + 6);
                    Widgets.Label(rect18, "EveningSermonLabel".Translate());

                    num2 += 35f;
                    var rect19 = new Rect(15f, num2, 150f, (hourWidth / 2) + 6);
                    Widgets.Label(rect19, "Cults_SermonStartLabel".Translate());

                    var dist        = 5f;
                    var button3     = new Rect(rect6.x + dist, rect6.y + 215f, 140f, 30f);
                    var morningHour = altar.morningHour + ":00h";
                    if (Widgets.ButtonText(button3, "Cults_MorningSermonStart".Translate() + morningHour, true, false))
                    {
                        listHours(altar, true);
                    }

                    var button4     = new Rect(rect6.x + dist + 150f, rect6.y + 215f, 140f, 30f);
                    var eveningHour = altar.eveningHour + ":00h";
                    if (Widgets.ButtonText(button4, "Cults_EveningSermonStart".Translate() + eveningHour, true, false))
                    {
                        listHours(altar, false);
                    }
                }

                // Old code with only morning/evening setting

                //Widgets.CheckboxLabeled(rect6.BottomHalf(), "MorningSermons".Translate(), ref altar.OptionMorning, disabled);
                //if (Mouse.IsOver(rect6) && Event.current.type == EventType.MouseDown && !disabled)
                //{
                //    altar.TryChangeWorshipValues(Building_SacrificialAltar.ChangeWorshipType.MorningWorship, altar.OptionMorning);
                //}
                //Rect rect7 = rect6;
                //rect7.y += ITab_AltarSacrificesCardUtility.ButtonSize + ITab_AltarSacrificesCardUtility.SpacingOffset;
                //rect7.height = ITab_AltarSacrificesCardUtility.ButtonSize;
                //Widgets.CheckboxLabeled(rect7.TopHalf(), "EveningSermons".Translate(), ref altar.OptionEvening, disabled);
                //if (Mouse.IsOver(rect7) && Event.current.type == EventType.MouseDown && !disabled)
                //{
                //    altar.TryChangeWorshipValues(Building_SacrificialAltar.ChangeWorshipType.EveningWorship, altar.OptionEvening);
                //}

                //TooltipHandler.TipRegion(rect6, "MorningSermonsDesc".Translate());
                //TooltipHandler.TipRegion(rect7, "EveningSermonsDesc".Translate());
            }
            else
            {
                var newRect = new Rect(rect);
                newRect        = newRect.ContractedBy(14f);
                newRect.height = 30f;

                Text.Font = GameFont.Medium;
                Widgets.Label(newRect, "Cults_NoPlayerCultAvailable".Translate());
                Text.Font = GameFont.Small;
            }

            GUI.EndGroup();
        }
Ejemplo n.º 13
0
        public static void DrawTempleCard(Rect rect, Building_SacrificialAltar altar)
        {
            GUI.BeginGroup(rect);

            if (CultTracker.Get.PlayerCult != null)
            {
                float cultLabelWidth = Text.CalcSize(CultTracker.Get.PlayerCult.name).x + 15;

                //Headings
                Rect rect1 = new Rect(rect);
                rect1        = rect.ContractedBy(14f);
                rect1.height = 30f;

                //Unnamed Temple
                Text.Font = GameFont.Medium;
                Widgets.Label(rect1, altar.RoomName);
                Text.Font = GameFont.Small;

                //Rename Icon
                ITab_AltarCardUtility.DrawRename(altar);
                Rect rect2 = new Rect(rect1);
                rect2.yMin   = rect1.yMax + 10;
                rect2.height = 25f;
                rect2.width  = cultLabelWidth + 5;

                //Esoteric Order of Dagon
                Widgets.Label(rect2, CultTracker.Get.PlayerCult.name);
                if (Mouse.IsOver(rect2))
                {
                    Widgets.DrawHighlight(rect2);
                }
                if (Mouse.IsOver(rect2) && Event.current.type == EventType.MouseDown)
                {
                    Find.WindowStack.Add(new Dialog_RenameCult(altar.Map));
                }
                Widgets.DrawLineHorizontal(rect2.x - 10, rect2.yMax, rect.width - 15f);
                //---------------------------------------------------------------------

                Rect rectMain = new Rect(0 + 15f, 0 + 30f, TempleCardSize.x, ITab_AltarSacrificesCardUtility.ButtonSize * 1.15f);

                //Deity -> Cthulhu
                Rect rect4 = rectMain;
                rect4.yMin   = rectMain.yMax + 5f;
                rect4.y      = rectMain.yMax + 20f;
                rect4.x     += 5f;
                rect4.width  = ITab_AltarSacrificesCardUtility.ColumnSize;
                rect4.height = ITab_AltarSacrificesCardUtility.ButtonSize;
                Widgets.Label(rect4, "Deity".Translate() + ": ");
                rect4.xMin = rect4.center.x;
                string label4 = DeityLabel(altar);
                if (Widgets.ButtonText(rect4, label4, true, false, true))
                {
                    ITab_AltarWorshipCardUtility.OpenDeitySelectMenu(altar);
                }
                TooltipHandler.TipRegion(rect4, "DeityDesc".Translate());

                //Cthulhu - He who waits dreaming.
                ITab_AltarCardUtility.DrawDeity(altar.tempCurrentWorshipDeity, rect4, null, -30f);

                //Preacher
                Rect rect5 = rect4;
                rect5.y += ITab_AltarSacrificesCardUtility.ButtonSize + 15f;
                //rect5.y = rect4.yMax + 30f;
                rect5.x    -= (rect4.x - 5);
                rect5.x    += 15f;
                rect5.width = ITab_AltarSacrificesCardUtility.ColumnSize;
                Widgets.Label(rect5, "Preacher".Translate() + ": ");
                rect5.xMin = rect5.center.x;
                string label2 = PreacherLabel(altar);
                if (Widgets.ButtonText(rect5, label2, true, false, true))
                {
                    ITab_AltarWorshipCardUtility.OpenPreacherSelectMenu(altar);
                }
                TooltipHandler.TipRegion(rect5, "PreacherDesc".Translate());

                Rect rect6 = rect5;
                rect6.y     += ITab_AltarSacrificesCardUtility.ButtonSize + ITab_AltarSacrificesCardUtility.SpacingOffset;
                rect6.height = ITab_AltarSacrificesCardUtility.ButtonSize;
                rect6.width  = ITab_AltarSacrificesCardUtility.ColumnSize;
                rect6.x     -= (rect5.x - 5);
                rect6.x     += 15f;
                bool disabled = (altar.tempCurrentWorshipDeity == null);
                Widgets.CheckboxLabeled(rect6.BottomHalf(), "MorningSermons".Translate(), ref altar.OptionMorning, disabled);
                if (Mouse.IsOver(rect6) && Event.current.type == EventType.MouseDown && !disabled)
                {
                    altar.TryChangeWorshipValues(Building_SacrificialAltar.ChangeWorshipType.MorningWorship, altar.OptionMorning);
                }
                Rect rect7 = rect6;
                rect7.y     += ITab_AltarSacrificesCardUtility.ButtonSize + ITab_AltarSacrificesCardUtility.SpacingOffset;
                rect7.height = ITab_AltarSacrificesCardUtility.ButtonSize;
                Widgets.CheckboxLabeled(rect7.TopHalf(), "EveningSermons".Translate(), ref altar.OptionEvening, disabled);
                if (Mouse.IsOver(rect7) && Event.current.type == EventType.MouseDown && !disabled)
                {
                    altar.TryChangeWorshipValues(Building_SacrificialAltar.ChangeWorshipType.EveningWorship, altar.OptionEvening);
                }

                TooltipHandler.TipRegion(rect6, "MorningSermonsDesc".Translate());
                TooltipHandler.TipRegion(rect7, "EveningSermonsDesc".Translate());
            }
            else
            {
                Rect newRect = new Rect(rect);
                newRect        = newRect.ContractedBy(14f);
                newRect.height = 30f;

                Text.Font = GameFont.Medium;
                Widgets.Label(newRect, "Cults_NoPlayerCultAvailable".Translate());
                Text.Font = GameFont.Small;
            }

            GUI.EndGroup();
        }
Ejemplo n.º 14
0
        private static void DoRow(Rect rect, Thing thing, CompVehicle vehicle, ref Pawn specificNeedsTabForPawn, bool doNeeds)
        {
            GUI.BeginGroup(rect);
            Rect rect2 = rect.AtZero();
            Pawn pawn  = thing as Pawn;

            //if (listingUsesAbandonSpecificCountButtons)
            //{
            //    if (thing.stackCount != 1)
            //    {
            //        CaravanPeopleAndItemsTabUtility.DoAbandonSpecificCountButton(rect2, thing, caravan);
            //    }
            //    rect2.width -= 24f;
            //}
            //CaravanPeopleAndItemsTabUtility.DoAbandonButton(rect2, thing, caravan);
            rect2.width -= 24f;
            Widgets.InfoCardButton(rect2.width - 24f, (rect.height - 24f) / 2f, thing);
            rect2.width -= 24f;
            if (pawn != null && !pawn.Dead)
            {
                CaravanPeopleAndItemsTabUtility.DoOpenSpecificTabButton(rect2, pawn, ref specificNeedsTabForPawn);
                rect2.width -= 24f;
            }
            if (pawn == null)
            {
                Rect rect3 = rect2;
                rect3.xMin = rect3.xMax - 60f;
                CaravanPeopleAndItemsTabUtility.TryDrawMass(thing, rect3);
                rect2.width -= 60f;
            }
            if (Mouse.IsOver(rect2))
            {
                Widgets.DrawHighlight(rect2);
            }
            Rect rect4 = new Rect(4f, (rect.height - 27f) / 2f, 27f, 27f);

            Widgets.ThingIcon(rect4, thing, 1f);
            if (pawn != null)
            {
                Rect bgRect = new Rect(rect4.xMax + 4f, 16f, 100f, 18f);
                GenMapUI.DrawPawnLabel(pawn, bgRect, 1f, 100f, null, GameFont.Small, false, false);
                if (doNeeds)
                {
                    GetNeedsToDisplay(pawn, tmpNeeds);
                    float xMax = bgRect.xMax;
                    for (int i = 0; i < tmpNeeds.Count; i++)
                    {
                        Need need = tmpNeeds[i];
                        int  maxThresholdMarkers = 0;
                        bool doTooltip           = true;
                        Rect rect5 = new Rect(xMax, 0f, 100f, 50f);
#pragma warning disable IDE0019 // Use pattern matching
                        Need_Mood mood = need as Need_Mood;
#pragma warning restore IDE0019 // Use pattern matching
                        if (mood != null)
                        {
                            maxThresholdMarkers = 1;
                            doTooltip           = false;
                            //TooltipHandler.TipRegion(rect5, new TipSignal(() => CaravanPeopleAndItemsTabUtility.CustomMoodNeedTooltip(mood), rect5.GetHashCode()));
                        }
                        need.DrawOnGUI(rect5, maxThresholdMarkers, 10f, false, doTooltip);
                        xMax = rect5.xMax;
                    }
                }
                if (pawn.Downed)
                {
                    GUI.color = new Color(1f, 0f, 0f, 0.5f);
                    Widgets.DrawLineHorizontal(0f, rect.height / 2f, rect.width);
                    GUI.color = Color.white;
                }
            }
            else
            {
                Rect rect6 = new Rect(rect4.xMax + 4f, 0f, 300f, 30f);
                Text.Anchor   = TextAnchor.MiddleLeft;
                Text.WordWrap = false;
                Widgets.Label(rect6, thing.LabelCap);
                Text.Anchor   = TextAnchor.UpperLeft;
                Text.WordWrap = true;
            }
            GUI.EndGroup();
        }
        public override void DoWindowContents(Rect inRect)
        {
            var apparelStatCache = _pawn.GetApparelStatCache();
            var currentOutfit    = _pawn.outfits.CurrentOutfit;

            if (_dict == null || Find.TickManager.TicksGame % 60 == 0 || GUI.changed)
            {
                var ap = new List <Apparel>(_pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.Apparel)
                                            .OfType <Apparel>().Where(
                                                x => x.Map.haulDestinationManager.SlotGroupAt(x.Position) != null));

                foreach (var otherPawn in PawnsFinder.AllMaps_FreeColonists.Where(x => x.Map == _pawn.Map))
                {
                    foreach (var pawnApparel in otherPawn.apparel.WornApparel)
                    {
                        if (otherPawn.outfits.forcedHandler.AllowedToAutomaticallyDrop(pawnApparel))
                        {
                            ap.Add(pawnApparel);
                        }
                    }
                }

                ap = ap.Where(
                    i => !ApparelUtility.CanWearTogether(_apparel.def, i.def, _pawn.RaceProps.body) &&
                    currentOutfit.filter.Allows(i)).ToList();


                ap = ap.OrderByDescending(
                    i =>
                {
                    var g = _pawn.ApparelScoreGain(i);
                    return(g);
                }).ToList();

                _dict = new Dictionary <Apparel, float>();
                foreach (var currentAppel in ap)
                {
                    var gain = _pawn.ApparelScoreGain(currentAppel);
                    _dict.Add(currentAppel, gain);
                }
            }

            var groupRect = inRect.ContractedBy(10f);

            groupRect.height -= 100;
            GUI.BeginGroup(groupRect);


            var apparelLabelWidth    = ((groupRect.width - (2 * ScoreWidth)) / 3) - 8f - 8f;
            var apparelEquippedWidth = apparelLabelWidth;
            var apparelOwnerWidth    = apparelLabelWidth;

            var itemRect = new Rect(groupRect.xMin + 4f, groupRect.yMin, groupRect.width - 8f, 28f);

            DrawLine(
                ref itemRect,
                null,
                "Apparel",
                apparelLabelWidth,
                null,
                "Equiped",
                apparelEquippedWidth,
                null,
                "Target",
                apparelOwnerWidth,
                "Score",
                "Gain");

            groupRect.yMin += itemRect.height;
            Widgets.DrawLineHorizontal(groupRect.xMin, groupRect.yMin, groupRect.width);
            groupRect.yMin   += 4f;
            groupRect.height -= 4f;
            groupRect.height -= Text.LineHeight * 1.2f * 3f;

            var viewRect = new Rect(
                groupRect.xMin,
                groupRect.yMin,
                groupRect.width - 16f, (_dict.Count * 28f) + 16f);

            if (viewRect.height < groupRect.height)
            {
                groupRect.height = viewRect.height;
            }

            var listRect = viewRect.ContractedBy(4f);

            Widgets.BeginScrollView(groupRect, ref _scrollPosition, viewRect);


            foreach (var kvp in _dict)
            {
                var currentAppel = kvp.Key;
                var gain         = kvp.Value;

                itemRect = new Rect(listRect.xMin, listRect.yMin, listRect.width, 28f);
                if (Mouse.IsOver(itemRect))
                {
                    GUI.DrawTexture(itemRect, TexUI.HighlightTex);
                    GUI.color = Color.white;
                }

                var equipped = currentAppel.Wearer;

                var gainString = _pawn.outfits.forcedHandler.AllowedToAutomaticallyDrop(currentAppel)
                    ? gain.ToString("N3")
                    : "No Allow";

                DrawLine(
                    ref itemRect,
                    currentAppel,
                    currentAppel.LabelCap,
                    apparelLabelWidth,
                    equipped,
                    equipped?.LabelCap,
                    apparelEquippedWidth,
                    null,
                    null,
                    apparelOwnerWidth,
                    apparelStatCache.ApparelScoreRaw(currentAppel).ToString("N3"),
                    gainString
                    );

                listRect.yMin = itemRect.yMax;
            }

            Widgets.EndScrollView();

            Widgets.DrawLineHorizontal(groupRect.xMin, groupRect.yMax, groupRect.width);

            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.EndGroup();
        }
Ejemplo n.º 16
0
        public static bool Prefix(PawnTable __instance, Vector2 position)
        {
            if (Event.current.type == EventType.Layout)
            {
                return(false);
            }

            RecacheIfDirtyMethod.Invoke(__instance, null);

            // get fields
            var cachedSize              = __instance.Size;
            var columns                 = __instance.ColumnsListForReading;
            var cachedColumnWidths      = cachedColumnWidthsField.GetValue(__instance) as List <float>;
            var cachedHeaderHeight      = __instance.HeaderHeight;
            var cachedHeightNoScrollbar = __instance.HeightNoScrollbar;
            var scrollPosition          = (Vector2)scrollPositionField.GetValue(__instance);
            var headerScrollPosition    = new Vector2(scrollPosition.x, 0f);
            var cachedPawns             = __instance.PawnsListForReading;
            var cachedRowHeights        = cachedRowHeightsField.GetValue(__instance) as List <float>;
            var standardWindowMargin    = (float)standardMarginField.GetRawConstantValue();

            // this is the main change, vanilla hardcodes both outRect and viewRect to the cached size.
            // Instead, we want to limit outRect to the available view area, so a horizontal scrollbar can appear.
            var outWidth  = Mathf.Min(cachedSize.x, UI.screenWidth - standardWindowMargin * 2f);
            var viewWidth = cachedSize.x - 16f;

            Rect tableOutRect = new Rect(
                position.x,
                position.y + cachedHeaderHeight,
                outWidth,
                cachedSize.y - cachedHeaderHeight);
            Rect tableViewRect = new Rect(
                0f,
                0f,
                viewWidth,
                cachedHeightNoScrollbar - cachedHeaderHeight);

            Rect headerOutRect = new Rect(
                position.x,
                position.y,
                outWidth,
                cachedHeaderHeight);
            Rect headerViewRect = new Rect(
                0f,
                0f,
                viewWidth,
                cachedHeaderHeight);

            // increase height of table to accomodate scrollbar if necessary and possible.
            if (viewWidth > outWidth && (cachedSize.y + 16f) < UI.screenHeight) // NOTE: this is probably optimistic about the available height, but it appears to be what vanilla uses.
            {
                tableOutRect.height += 16f;
            }

            // we need to add a scroll area to the column headers to make sure they stay in sync with the rest of the table
            Widgets.BeginScrollView(headerOutRect, ref headerScrollPosition, headerViewRect, false);
            int x_pos = 0;

            for (int i = 0; i < columns.Count; i++)
            {
                int colWidth;
                if (i == columns.Count - 1)
                {
                    colWidth = (int)(viewWidth - x_pos);
                }
                else
                {
                    colWidth = (int)cachedColumnWidths[i];
                }
                Rect rect = new Rect(x_pos, 0f, colWidth, (int)cachedHeaderHeight);
                columns[i].Worker.DoHeader(rect, __instance);
                x_pos += colWidth;
            }
            Widgets.EndScrollView();


            Widgets.BeginScrollView(tableOutRect, ref scrollPosition, tableViewRect);
            scrollPositionField.SetValue(__instance, scrollPosition);
            int y_pos = 0;

            for (int j = 0; j < cachedPawns.Count; j++)
            {
                x_pos = 0;
                if ((float)y_pos - scrollPosition.y + (int)cachedRowHeights[j] >= 0f && (float)y_pos - scrollPosition.y <= tableOutRect.height)
                {
                    GUI.color = new Color(1f, 1f, 1f, 0.2f);
                    Widgets.DrawLineHorizontal(0f, y_pos, tableViewRect.width);
                    GUI.color = Color.white;
                    Rect rowRect = new Rect(0f, y_pos, tableViewRect.width, (int)cachedRowHeights[j]);
                    if (Mouse.IsOver(rowRect))
                    {
                        GUI.DrawTexture(rowRect, TexUI.HighlightTex);
                    }
                    for (int k = 0; k < columns.Count; k++)
                    {
                        int cellWidth;
                        if (k == columns.Count - 1)
                        {
                            cellWidth = (int)(viewWidth - x_pos);
                        }
                        else
                        {
                            cellWidth = (int)cachedColumnWidths[k];
                        }
                        Rect rect3 = new Rect(x_pos, y_pos, cellWidth, (int)cachedRowHeights[j]);
                        columns[k].Worker.DoCell(rect3, cachedPawns[j], __instance);
                        x_pos += cellWidth;
                    }
                    if (cachedPawns[j].Downed)
                    {
                        GUI.color = new Color(1f, 0f, 0f, 0.5f);
                        Widgets.DrawLineHorizontal(0f, rowRect.center.y, tableViewRect.width);
                        GUI.color = Color.white;
                    }
                }
                y_pos += (int)cachedRowHeights[j];
            }
            Widgets.EndScrollView();

            return(false);
        }
Ejemplo n.º 17
0
        private static void DrawEntry(ref Rect row, KeyValuePair <Entry, Type> entry)
        {
            row = listing.GetRect(30f);
            Widgets.DrawHighlightIfMouseover(row);

            if (GUIController.CurrentEntry == entry.Key)
            {
                Widgets.DrawOptionSelected(row);
            }

            row.x   += 20f;
            yOffset += 30f;

            Widgets.Label(row, entry.Key.name);

            if (Widgets.ButtonInvisible(row))
            {
                GUIController.SwapToEntry(entry.Key.name);
            }

            if (entry.Key.isClosable)
            {
                if (Input.GetMouseButtonDown(1) && row.Contains(Event.current.mousePosition))
                {
                    List <FloatMenuOption> options = new List <FloatMenuOption>()
                    {
                        new FloatMenuOption("Close", () => GUIController.RemoveEntry(entry.Key.name))
                    };
                    Find.WindowStack.Add(new FloatMenu(options));
                }
            }

            TooltipHandler.TipRegion(row, entry.Key.tip);

            if (GUIController.CurrentEntry == entry.Key)
            {
                bool firstEntry = true;
                foreach (KeyValuePair <FieldInfo, Setting> keySetting in entry.Key.Settings)
                {
                    if (keySetting.Key.FieldType == typeof(bool))
                    {
                        row       = listing.GetRect(30f);
                        row.x    += 20f;
                        GUI.color = Widgets.OptionSelectedBGBorderColor;
                        Widgets.DrawLineVertical(row.x, row.y, 15f);

                        if (!firstEntry)
                        {
                            Widgets.DrawLineVertical(row.x, row.y - 15f, 15f);
                        }

                        row.x += 10f;
                        Widgets.DrawLineHorizontal(row.x - 10f, row.y + 15f, 10f);
                        GUI.color = Color.white;
                        yOffset  += 30f;

                        bool cur = (bool)keySetting.Key.GetValue(null);

                        if (DubGUI.Checkbox(row, keySetting.Value.name, ref cur))
                        {
                            keySetting.Key.SetValue(null, cur);

                            GUIController.ResetProfilers();
                        }
                    }

                    if (keySetting.Value.tip != null)
                    {
                        TooltipHandler.TipRegion(row, keySetting.Value.tip);
                    }

                    firstEntry = false;
                }
            }
        }
Ejemplo n.º 18
0
        public override void DoWindowContents(Rect inRect)
        {
            Rect rect = new Rect(inRect.x, inRect.y, inRect.width, 45f);

            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font   = GameFont.Medium;
            if (isVirtual)
            {
                Widgets.Label(rect, VirtualTrader.TipString(1));
                TooltipHandler.TipRegion(rect, VirtualTrader.TipString(2));
            }
            else
            {
                Widgets.Label(rect, "AdjustPayment".Translate());
            }
            float height = rect.height;
            Color color  = GUI.color;

            GUI.color = Color.gray;
            Widgets.DrawLineHorizontal(inRect.x, height, inRect.width);
            GUI.color = color;
            height   += 2.5f;
            Rect rect2 = new Rect(inRect.x, height, inRect.width, 30f);

            DrawTradeableRow(rect2, silverTradeable, 1);
            int  countToTransfer  = notesTradeable.CountToTransfer;
            int  countToTransfer2 = silverTradeable.CountToTransfer;
            Rect rect3            = new Rect(inRect.x, height + 30f, inRect.width, 30f);

            DrawTradeableRow(rect3, notesTradeable, 2);
            if (countToTransfer != notesTradeable.CountToTransfer)
            {
                if (!isVirtual || !VirtualTrader.UniqueBalanceMethod)
                {
                    int countToTransfer3 = silverTradeable.CountToTransfer;
                    silverTradeable.ForceTo(countToTransfer3 + (countToTransfer - notesTradeable.CountToTransfer) * 1000);
                }
                else
                {
                    int notes  = notesTradeable.CountToTransfer;
                    int silver = silverTradeable.CountToTransfer;
                    VirtualTrader.BalanceMethod(countToTransfer2, countToTransfer, ref silver, ref notes);
                    notesTradeable.ForceTo(notes);
                    silverTradeable.ForceTo(silver);
                }
            }
            Rect rect4 = new Rect(rect2.x, rect2.y, 27f, 27f);

            if (Mouse.IsOver(rect4))
            {
                Widgets.DrawHighlight(rect4);
            }
            Widgets.ThingIcon(rect4, silverTradeable.AnyThing);
            Rect rect5 = new Rect(rect2.x, rect3.y, 27f, 27f);

            if (Mouse.IsOver(rect5))
            {
                Widgets.DrawHighlight(rect5);
            }
            Widgets.ThingIcon(rect5, notesTradeable.AnyThing);
            if (isVirtual)
            {
                TooltipHandler.TipRegion(rect4, VirtualTrader.TipString(3));
                TooltipHandler.TipRegion(rect5, VirtualTrader.TipString(4));
            }
            else
            {
                TooltipHandler.TipRegion(rect4, "SilverTip".Translate());
                TooltipHandler.TipRegion(rect5, "BankNoteTip".Translate());
            }
            float num     = 120f;
            float height2 = 40f;

            if (Widgets.ButtonText(new Rect(inRect.width * 9f / 16f, inRect.height - 55f, num, height2), "CancelButton".Translate()))
            {
                Event.current.Use();
                Close(doCloseSound: false);
            }
            if (Widgets.ButtonText(new Rect(inRect.width * 7f / 16f - num, inRect.height - 55f, num, height2), "AcceptButton".Translate()))
            {
                Action ExecuteTrade = delegate
                {
                    currencyfmt = new Pair <int, int>(notesTradeable.CountToTransfer, silverTradeable.CountToTransfer);
                    if (TradeSession.deal.DoExecute())
                    {
                        SoundDefOf.ExecuteTrade.PlayOneShotOnCamera();
                        if (TradeSession.trader is Pawn pawn)
                        {
                            TaleRecorder.RecordTale(TaleDefOf.TradedWith, TradeSession.playerNegotiator, pawn);
                        }
                        if (isVirtual)
                        {
                            VirtualTrader.CloseTradeUI();
                        }
                        else
                        {
                            Find.WindowStack.WindowOfType <Dialog_Trade>().Close(doCloseSound: false);
                        }
                    }
                    Close(doCloseSound: false);
                };
                Action ConfirmedExecuteTrade = delegate
                {
                    silverTradeable.ForceTo(silverTradeable.CountHeldBy(Transactor.Trader));
                    ExecuteTrade();
                };
                ((Action) delegate
                {
                    if (!TestPlayerSilver())
                    {
                        Messages.Message("NotEnoughSilverColony".Translate(), MessageTypeDefOf.RejectInput);
                    }
                    else if (isVirtual && VirtualTrader.CustomCheckViolation(silverTradeable, notesTradeable))
                    {
                        VirtualTrader.CustomViolationAction();
                    }
                    else if (!TestTraderSilver())
                    {
                        SoundDefOf.ClickReject.PlayOneShotOnCamera();
                        Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmTraderShortFunds".Translate(), ConfirmedExecuteTrade));
                    }
                    else
                    {
                        ExecuteTrade();
                    }
                })();
                Event.current.Use();
            }
        }
Ejemplo n.º 19
0
        public override void DoWindowContents(Rect inRect)
        {
            var font      = Text.Font;
            var anchor    = Text.Anchor;
            var iconRect  = new Rect(inRect.x, inRect.y, 50f, 50f);
            var titleRect = inRect.TakeTopPart(50f);

            titleRect.xMin += 60f;
            Text.Anchor     = TextAnchor.MiddleLeft;
            Text.Font       = GameFont.Medium;
            Widgets.Label(titleRect, "VEF.ContractTitle".Translate((contract.factionDef?.label ?? contract.hireable.Key).CapitalizeFirst()));
            if (contract.factionDef != null)
            {
                Widgets.DrawLightHighlight(iconRect);
                GUI.color = contract.factionDef.Color;
                Widgets.DrawTextureFitted(iconRect, contract.factionDef.Texture, 1f);
                GUI.color = Color.white;
            }

            var pawnsRect = inRect.LeftHalf().ContractedBy(3f);
            var infoRect  = inRect.RightHalf().ContractedBy(3f);

            infoRect.yMin += 20f;
            Text.Font      = GameFont.Small;
            Widgets.Label(pawnsRect.TakeTopPart(20f), "VEF.PawnsList".Translate());
            Widgets.DrawMenuSection(pawnsRect);
            pawnsRect = pawnsRect.ContractedBy(5f);
            var viewRect = new Rect(0, 0, pawnsRect.width - 20f, contract.pawns.Count * 40f);

            Widgets.BeginScrollView(pawnsRect, ref pawnsScrollPos, viewRect);
            foreach (var pawn in contract.pawns)
            {
                var pawnRect = viewRect.TakeTopPart(33f);
                if (pawn != contract.pawns[contract.pawns.Count - 1])
                {
                    Widgets.DrawLineHorizontal(pawnRect.x, pawnRect.yMax, pawnRect.width);
                }
                Widgets.DrawHighlightIfMouseover(pawnRect);
                if (Widgets.ButtonInvisible(pawnRect))
                {
                    Close(false);
                    CameraJumper.TryJumpAndSelect(pawn);
                }

                Widgets.ThingIcon(new Rect(pawnRect.x + 3f, pawnRect.y + 3f, 27f, 27f), pawn, 1f, Rot4.South);
                pawnRect.xMin += 35f;
                Widgets.Label(pawnRect.LeftHalf(), pawn.NameFullColored);
                Widgets.Label(pawnRect.RightHalf(), pawn.health.summaryHealth.SummaryHealthPercent.ToStringPercent());
            }

            Widgets.EndScrollView();

            Text.Anchor = TextAnchor.MiddleLeft;
            Text.Font   = GameFont.Small;
            var textRect = infoRect.TakeTopPart(30f);

            Widgets.Label(textRect.LeftHalf(), "VEF.Spent".Translate());
            Widgets.Label(textRect.RightHalf(), contract.price.ToStringMoney().Colorize(ColoredText.CurrencyColor));
            Widgets.DrawLineHorizontal(textRect.x, textRect.y + 30f, textRect.width);
            textRect.y    += 30;
            infoRect.yMin += 30;
            Widgets.Label(textRect.LeftHalf(), "VEF.TimeLeft".Translate());
            int remainingTicks = (this.contract.endTicks - Find.TickManager.TicksAbs);

            Widgets.Label(textRect.RightHalf(), (remainingTicks < 0 ? 0 : remainingTicks).ToStringTicksToPeriodVerbose().Colorize(ColoredText.DateTimeColor));
            if (Widgets.ButtonText(infoRect.TakeBottomPart(40f), "VEF.CancelContract".Translate()))
            {
                Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("VEF.NoRefund".Translate(), () =>
                {
                    Close();
                    this.contract.endTicks = Find.TickManager.TicksAbs;
                }, true, "VEF.CancelContract".Translate()));
            }
            Text.Anchor = anchor;
            Text.Font   = font;
        }
Ejemplo n.º 20
0
        public override void DoWindowContents(Rect inRect)
        {
            if (this.playerIsCaravan)
            {
                CaravanUIUtility.DrawCaravanInfo(new CaravanUIUtility.CaravanInfo(this.MassUsage, this.MassCapacity, this.cachedMassCapacityExplanation, this.TilesPerDay, this.cachedTilesPerDayExplanation, this.DaysWorthOfFood, this.ForagedFoodPerDay, this.cachedForagedFoodPerDayExplanation, this.Visibility, this.cachedVisibilityExplanation, -1f, -1f, null), null, this.Tile, null, -9999f, new Rect(12f, 0f, inRect.width - 24f, 40f), true, null, false);
                inRect.yMin += 52f;
            }
            TradeSession.deal.UpdateCurrencyCount();
            GUI.BeginGroup(inRect);
            inRect = inRect.AtZero();
            TransferableUIUtility.DoTransferableSorters(this.sorter1, this.sorter2, delegate(TransferableSorterDef x)
            {
                this.sorter1 = x;
                this.CacheTradeables();
            }, delegate(TransferableSorterDef x)
            {
                this.sorter2 = x;
                this.CacheTradeables();
            });
            float num      = inRect.width - 590f;
            Rect  position = new Rect(num, 0f, inRect.width - num, 58f);

            GUI.BeginGroup(position);
            Text.Font = GameFont.Medium;
            Rect rect = new Rect(0f, 0f, position.width / 2f, position.height);

            Text.Anchor = TextAnchor.UpperLeft;
            Widgets.Label(rect, Faction.OfPlayer.Name.Truncate(rect.width, null));
            Rect rect2 = new Rect(position.width / 2f, 0f, position.width / 2f, position.height);

            Text.Anchor = TextAnchor.UpperRight;
            string text = TradeSession.trader.TraderName;

            if (Text.CalcSize(text).x > rect2.width)
            {
                Text.Font = GameFont.Small;
                text      = text.Truncate(rect2.width, null);
            }
            Widgets.Label(rect2, text);
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            Rect rect3 = new Rect(0f, 27f, position.width / 2f, position.height / 2f);

            Widgets.Label(rect3, "Negotiator".Translate() + ": " + TradeSession.playerNegotiator.LabelShort);
            Text.Anchor = TextAnchor.UpperRight;
            Rect rect4 = new Rect(position.width / 2f, 27f, position.width / 2f, position.height / 2f);

            Widgets.Label(rect4, TradeSession.trader.TraderKind.LabelCap);
            Text.Anchor = TextAnchor.UpperLeft;
            if (!TradeSession.giftMode)
            {
                GUI.color = new Color(1f, 1f, 1f, 0.6f);
                Text.Font = GameFont.Tiny;
                Rect rect5 = new Rect(position.width / 2f - 100f - 30f, 0f, 200f, position.height);
                Text.Anchor = TextAnchor.LowerCenter;
                Widgets.Label(rect5, "PositiveBuysNegativeSells".Translate());
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.EndGroup();
            float num2 = 0f;

            if (this.cachedCurrencyTradeable != null)
            {
                float num3  = inRect.width - 16f;
                Rect  rect6 = new Rect(0f, 58f, num3, 30f);
                TradeUI.DrawTradeableRow(rect6, this.cachedCurrencyTradeable, 1);
                GUI.color = Color.gray;
                Widgets.DrawLineHorizontal(0f, 87f, num3);
                GUI.color = Color.white;
                num2      = 30f;
            }
            Rect mainRect = new Rect(0f, 58f + num2, inRect.width, inRect.height - 58f - 38f - num2 - 20f);

            this.FillMainRect(mainRect);
            Rect rect7 = new Rect(inRect.width / 2f - Dialog_Trade.AcceptButtonSize.x / 2f, inRect.height - 55f, Dialog_Trade.AcceptButtonSize.x, Dialog_Trade.AcceptButtonSize.y);

            if (Widgets.ButtonText(rect7, (!TradeSession.giftMode) ? "AcceptButton".Translate() : ("OfferGifts".Translate() + " (" + FactionGiftUtility.GetGoodwillChange(TradeSession.deal.AllTradeables, TradeSession.trader.Faction).ToStringWithSign() + ")"), true, false, true))
            {
                Action action = delegate
                {
                    bool flag;
                    if (TradeSession.deal.TryExecute(out flag))
                    {
                        if (flag)
                        {
                            SoundDefOf.ExecuteTrade.PlayOneShotOnCamera(null);
                            this.Close(false);
                        }
                        else
                        {
                            this.Close(true);
                        }
                    }
                };
                if (TradeSession.deal.DoesTraderHaveEnoughSilver())
                {
                    action();
                }
                else
                {
                    this.FlashSilver();
                    SoundDefOf.ClickReject.PlayOneShotOnCamera(null);
                    Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("ConfirmTraderShortFunds".Translate(), action, false, null));
                }
                Event.current.Use();
            }
            Rect rect8 = new Rect(rect7.x - 10f - Dialog_Trade.OtherBottomButtonSize.x, rect7.y, Dialog_Trade.OtherBottomButtonSize.x, Dialog_Trade.OtherBottomButtonSize.y);

            if (Widgets.ButtonText(rect8, "ResetButton".Translate(), true, false, true))
            {
                SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                TradeSession.deal.Reset();
                this.CacheTradeables();
                this.CountToTransferChanged();
            }
            Rect rect9 = new Rect(rect7.xMax + 10f, rect7.y, Dialog_Trade.OtherBottomButtonSize.x, Dialog_Trade.OtherBottomButtonSize.y);

            if (Widgets.ButtonText(rect9, "CancelButton".Translate(), true, false, true))
            {
                this.Close(true);
                Event.current.Use();
            }
            float y      = Dialog_Trade.OtherBottomButtonSize.y;
            Rect  rect10 = new Rect(inRect.width - y, rect7.y, y, y);

            if (Widgets.ButtonImageWithBG(rect10, Dialog_Trade.ShowSellableItemsIcon, new Vector2?(new Vector2(32f, 32f))))
            {
                Find.WindowStack.Add(new Dialog_SellableItems(TradeSession.trader.TraderKind));
            }
            TooltipHandler.TipRegion(rect10, "CommandShowSellableItemsDesc".Translate());
            Faction faction = TradeSession.trader.Faction;

            if (faction != null && !this.giftsOnly && !faction.def.permanentEnemy)
            {
                Rect rect11 = new Rect(rect10.x - y - 4f, rect7.y, y, y);
                if (TradeSession.giftMode)
                {
                    if (Widgets.ButtonImageWithBG(rect11, Dialog_Trade.TradeModeIcon, new Vector2?(new Vector2(32f, 32f))))
                    {
                        TradeSession.giftMode = false;
                        TradeSession.deal.Reset();
                        this.CacheTradeables();
                        this.CountToTransferChanged();
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    }
                    TooltipHandler.TipRegion(rect11, "TradeModeTip".Translate());
                }
                else
                {
                    if (Widgets.ButtonImageWithBG(rect11, Dialog_Trade.GiftModeIcon, new Vector2?(new Vector2(32f, 32f))))
                    {
                        TradeSession.giftMode = true;
                        TradeSession.deal.Reset();
                        this.CacheTradeables();
                        this.CountToTransferChanged();
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    }
                    TooltipHandler.TipRegion(rect11, "GiftModeTip".Translate(faction.Name));
                }
            }
            GUI.EndGroup();
        }
Ejemplo n.º 21
0
            internal void <> m__0()
            {
                this.outRect = this.outRect.AtZero();
                Rect rect     = this.outRect.ContractedBy(7f);
                Rect viewRect = rect.AtZero();
                bool flag     = this.$this.contentHeight > rect.height;

                Widgets.DrawWindowBackgroundTutor(this.outRect);
                if (flag)
                {
                    viewRect.height           = this.$this.contentHeight + 40f;
                    viewRect.width           -= 20f;
                    this.$this.scrollPosition = GUI.BeginScrollView(rect, this.$this.scrollPosition, viewRect);
                }
                else
                {
                    GUI.BeginGroup(rect);
                }
                float num = 0f;

                Text.Font = GameFont.Small;
                Rect rect2 = new Rect(0f, 0f, viewRect.width - 24f, 24f);

                Widgets.Label(rect2, "LearningHelper".Translate());
                num = rect2.yMax;
                Rect butRect = new Rect(rect2.xMax, rect2.y, 24f, 24f);

                if (Widgets.ButtonImage(butRect, this.$this.showAllMode ? TexButton.Minus : TexButton.Plus))
                {
                    this.$this.showAllMode = !this.$this.showAllMode;
                    if (this.$this.showAllMode)
                    {
                        SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                    }
                    else
                    {
                        SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                    }
                }
                if (this.$this.showAllMode)
                {
                    Rect rect3 = new Rect(0f, num, viewRect.width - 20f - 2f, 28f);
                    this.$this.searchString = this.$this.FilterSearchStringInput(Widgets.TextField(rect3, this.$this.searchString));
                    if (this.$this.searchString == "")
                    {
                        GUI.color   = new Color(0.6f, 0.6f, 0.6f, 1f);
                        Text.Anchor = TextAnchor.MiddleLeft;
                        Rect rect4 = rect3;
                        rect4.xMin += 7f;
                        Widgets.Label(rect4, "Filter".Translate() + "...");
                        Text.Anchor = TextAnchor.UpperLeft;
                        GUI.color   = Color.white;
                    }
                    Rect butRect2 = new Rect(viewRect.width - 20f, num + 14f - 10f, 20f, 20f);
                    if (Widgets.ButtonImage(butRect2, TexButton.CloseXSmall))
                    {
                        this.$this.searchString = "";
                        SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(null);
                    }
                    num = rect3.yMax + 4f;
                }
                IEnumerable <ConceptDef> enumerable = this.$this.showAllMode ? DefDatabase <ConceptDef> .AllDefs : this.$this.activeConcepts;

                if (enumerable.Any <ConceptDef>())
                {
                    GUI.color = new Color(1f, 1f, 1f, 0.5f);
                    Widgets.DrawLineHorizontal(0f, num, viewRect.width);
                    GUI.color = Color.white;
                    num      += 4f;
                }
                if (this.$this.showAllMode)
                {
                    enumerable = from c in enumerable
                                 orderby this.$this.DisplayPriority(c) descending, c.label
                    select c;
                }
                foreach (ConceptDef conceptDef in enumerable)
                {
                    if (!conceptDef.TriggeredDirect)
                    {
                        num = this.$this.DrawConceptListRow(0f, num, viewRect.width, conceptDef).yMax;
                    }
                }
                this.$this.contentHeight = num;
                if (flag)
                {
                    GUI.EndScrollView();
                }
                else
                {
                    GUI.EndGroup();
                }
            }
Ejemplo n.º 22
0
 // Token: 0x06000036 RID: 54 RVA: 0x00004651 File Offset: 0x00003651
 public void DrawLineHorizontalWithColor(float x, float y, float length, Color color)
 {
     GUI.color = color;
     Widgets.DrawLineHorizontal(x, y, length);
     GUI.color = this.oldColor;
 }
Ejemplo n.º 23
0
        //=====================================================================================================\\

        public override void DoSettingsWindowContents(Rect rect)
        {
            Color headerColor = new Color(
                r: 1.0f,
                g: 0.9725490f,
                b: 0.239215686f,
                a: 1.0f
                );
            GUIStyleState headerState = new GUIStyleState()
            {
                textColor = headerColor
            };
            GUIStyle headerStyle = new GUIStyle(Text.CurFontStyle);

            headerStyle.fontStyle = FontStyle.Bold;
            headerStyle.normal    = headerState;

            GUIStyle hdStyle = new GUIStyle(Text.CurFontStyle);

            hdStyle.alignment = TextAnchor.MiddleLeft;
            hdStyle.fontSize  = 11;
            hdStyle.fontStyle = FontStyle.Bold;
            hdStyle.normal    = new GUIStyleState()
            {
                textColor = new Color(
                    r: 1.0f,
                    g: 0.74117647f,
                    b: 0.2392156862f,
                    a: 1.0f
                    )
            };
            hdStyle.padding = new RectOffset(4, 0, 0, 0);

            Listing_Standard listing        = new Listing_Standard(GameFont.Small);
            Listing_Standard listingPresets = new Listing_Standard(GameFont.Small);
            List <KeyValuePair <string, int> > overrides = new IndividualOverrides().ViewInternalOverrides();

            // 3 headers
            // 2 table headers
            // 2 spacers
            // 23 ish listing.regulars
            // individualoverrides.count
            float height
                = (3 * (Verse.Text.LineHeight + 2))                 // include 2 for bottom border
                  + (2 * (hdStyle.lineHeight))                      // table headers
                  + (2 * 15)                                        // spacer hight 15
                  + (23 * (Verse.Text.LineHeight + 7))              // divider line is 7 in regular listing entries
                  + (overrides.Count * (Verse.Text.LineHeight + 3)) // divider line is 3 in overrides
                  + 40;                                             // for fudge making

            Rect mainRect = new Rect(
                x: 0,
                y: 0,
                width: rect.width - 25,                 //25 for scrollbar
                height: height
                );

            Widgets.BeginScrollView(rect, ref this.settings.ScrollPosition, mainRect, true);

            Rect mainLeft  = mainRect.LeftPart(0.78f);
            Rect mainRight = mainRect.RightPart(0.20f);


            // PRESETS
            listingPresets.ColumnWidth = mainRight.width;
            listingPresets.Begin(mainRight);
            Rect       section = listingPresets.GetRect(Verse.Text.LineHeight + 2);
            TextAnchor anchor  = Text.Anchor;

            Text.Anchor = TextAnchor.UpperLeft;
            GUI.Box(section, Translator.Translate("OgreStack.SectionHeader.Presets"), headerStyle);
            Text.Anchor = anchor;

            Color color = GUI.color;

            GUI.color = Color.grey;
            Widgets.DrawLineHorizontal(section.x, section.y + section.height - 1, section.width);
            Widgets.DrawLineHorizontal(section.x, section.y + section.height - 2, section.width);
            GUI.color = color;

            // Ogre
            section = listingPresets.GetRect(hdStyle.lineHeight);
            GUI.Box(section, Translator.Translate("OgreStack.Presets.Section.Ogre"), hdStyle);

            section   = listingPresets.GetRect(7);
            color     = GUI.color;
            GUI.color = Color.grey;
            Widgets.DrawLineHorizontal(section.x, section.y + 3, section.width);
            GUI.color = color;

            foreach (Preset p in Presets.GetOgrePresets())
            {
                section = listingPresets.GetRect(Verse.Text.LineHeight);
                GUI.SetNextControlName(p.NameKey);
                if (Widgets.ButtonText(section, Translator.Translate(p.NameKey)))
                {
                    p.Modify(this.settings);
                }

                section = listingPresets.GetRect(1);
            }

            listingPresets.GetRect(7);

            // Scalar
            section = listingPresets.GetRect(hdStyle.lineHeight);
            GUI.Box(section, Translator.Translate("OgreStack.Presets.Section.Scalar"), hdStyle);

            section   = listingPresets.GetRect(7);
            color     = GUI.color;
            GUI.color = Color.grey;
            Widgets.DrawLineHorizontal(section.x, section.y + 3, section.width);
            GUI.color = color;

            foreach (Preset p in Presets.GetScalarPresets())
            {
                section = listingPresets.GetRect(Verse.Text.LineHeight);
                GUI.SetNextControlName(p.NameKey);
                if (Widgets.ButtonText(section, Translator.Translate(p.NameKey)))
                {
                    p.Modify(this.settings);
                }

                section = listingPresets.GetRect(1);
            }

            listingPresets.End();


            // SETTINGS
            listing.ColumnWidth = mainLeft.width;
            listing.Begin(mainLeft);

            section     = listing.GetRect(Verse.Text.LineHeight + 2);
            anchor      = Text.Anchor;
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.Box(section, Translator.Translate("OgreStack.SectionHeader.Settings"), headerStyle);
            Text.Anchor = anchor;

            color     = GUI.color;
            GUI.color = Color.grey;
            Widgets.DrawLineHorizontal(section.x, section.y + section.height - 1, section.width);
            Widgets.DrawLineHorizontal(section.x, section.y + section.height - 2, section.width);
            GUI.color = color;

            Rect header = listing.GetRect(hdStyle.lineHeight);

            GUI.Box(GenUI.LeftPart(header, 0.6f), Translator.Translate("OgreStack.Settings.Category"), hdStyle);
            Rect headerInputs = GenUI.RightPart(header, 0.4f);
            Rect boxModeHd    = GenUI.LeftHalf(headerInputs);

            GUI.Box(boxModeHd, Translator.Translate("OgreStack.Settings.Mode"), hdStyle);
            GUI.Box(GenUI.RightHalf(headerInputs), Translator.Translate("OgreStack.Settings.Value"), hdStyle);

            TooltipHandler.TipRegion(boxModeHd, Translator.Translate("OgreStack.Settings.Mode.Desc"));

            List <Category> allCats = new List <Category>(OgreStackMod._PROCESSING_ORDER);

            allCats.Add(Category.Other);

            foreach (Category c in allCats)
            {
                // separator line
                Rect divider = listing.GetRect(7);
                color     = GUI.color;
                GUI.color = Color.grey;
                Widgets.DrawLineHorizontal(divider.x, divider.y + 3, divider.width);
                GUI.color = color;


                // Container for row
                Rect container = listing.GetRect(Verse.Text.LineHeight);
                Widgets.DrawHighlightIfMouseover(container);

                // Category
                Rect boxCategory = GenUI.LeftPart(container, 0.6f);
                anchor      = Text.Anchor;
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(boxCategory, Translator.Translate("OgreStack.Settings." + c.ToString() + ".Title"));
                Text.Anchor = anchor;

                TooltipHandler.TipRegion(boxCategory, Translator.Translate("OgreStack.Settings." + c.ToString() + ".Desc"));


                // MODE
                Rect boxInputs = GenUI.RightPart(container, 0.4f);
                //Rect boxMode = GenUI.LeftHalf(boxInputs);
                Rect boxMode  = GenUI.LeftPart(boxInputs, 0.49f);
                Rect boxValue = GenUI.Rounded(GenUI.RightHalf(boxInputs));

                Widgets.Dropdown <MultiplierMode, MultiplierMode>(
                    rect: boxMode,

                    // no idea what target
                    // and getPayload are for/do
                    target: MultiplierMode.Fixed,
                    getPayload: (s) => {
                    return(s);
                },

                    // This appears to update automatically
                    buttonLabel: Translator.Translate("OgreStack.Settings.Mode." + this.settings.Values[c].Mode.ToString()),
                    menuGenerator: (s) => {
                    List <Widgets.DropdownMenuElement <MultiplierMode> > rv = new List <Widgets.DropdownMenuElement <MultiplierMode> >();
                    rv.Add(new Widgets.DropdownMenuElement <MultiplierMode>()
                    {
                        option = new FloatMenuOption(Translator.Translate("OgreStack.Settings.Mode.Scalar"), () => {
                            this.settings.Values[c].Mode = MultiplierMode.Scalar;
                        }),
                        payload = MultiplierMode.Scalar
                    });

                    rv.Add(new Widgets.DropdownMenuElement <MultiplierMode>()
                    {
                        option = new FloatMenuOption(Translator.Translate("OgreStack.Settings.Mode.Fixed"), () => {
                            this.settings.Values[c].Mode = MultiplierMode.Fixed;
                        }),
                        payload = MultiplierMode.Fixed
                    });
                    return(rv);
                }
                    );

                // VALUE
                this.settings.Values[c].Buffer = Widgets.TextField(boxValue, this.settings.Values[c].Buffer);

                if (!this.settings.Values[c].ParseBuffer())
                {
                    color     = GUI.color;
                    GUI.color = new Color(0.662745f, 0f, 0f);
                    Widgets.DrawBox(GenUI.Rounded(boxValue), 2);
                    GUI.color = color;
                }
            }

            Rect space = listing.GetRect(15);

            section     = listing.GetRect(Verse.Text.LineHeight + 2);
            anchor      = Text.Anchor;
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.Box(section, Translator.Translate("OgreStack.SectionHeader.SingleThingDefTargeting"), headerStyle);
            Text.Anchor = anchor;

            color     = GUI.color;
            GUI.color = Color.grey;
            Widgets.DrawLineHorizontal(section.x, section.y + section.height - 1, section.width);
            Widgets.DrawLineHorizontal(section.x, section.y + section.height - 2, section.width);
            GUI.color = color;

            anchor      = Text.Anchor;
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(listing.GetRect(Verse.Text.LineHeight * 3), Translator.Translate("OgreStack.Settings.SingleThingDefTargeting.Desc", DataUtil.GenerateFilePath(DataUtil._OVERRIDES_FILE_NAME).Replace("/", "\\")));
            Text.Anchor = anchor;

            header      = listing.GetRect(hdStyle.lineHeight);
            anchor      = Text.Anchor;
            Text.Anchor = TextAnchor.MiddleLeft;

            GUI.Box(GenUI.LeftPart(header, 0.35f), Translator.Translate("OgreStack.Settings.DefName"), hdStyle);
            GUI.Box(GenUI.RightPart(header, 0.65f), Translator.Translate("OgreStack.Settings.StackLimit"), hdStyle);
            Text.Anchor = anchor;


            foreach (KeyValuePair <string, int> kvp in overrides)
            {
                string defName    = kvp.Key;
                int    stackLimit = kvp.Value;

                // separator line
                Rect divider = listing.GetRect(3);
                color     = GUI.color;
                GUI.color = Color.grey;
                Widgets.DrawLineHorizontal(divider.x, divider.y + 1, divider.width);
                GUI.color = color;

                // Container for row
                Rect container = listing.GetRect(Verse.Text.LineHeight);
                Widgets.DrawHighlightIfMouseover(container);

                // DefName
                Rect boxDefName = GenUI.LeftPart(container, 0.35f);
                anchor      = Text.Anchor;
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(boxDefName, defName);
                Text.Anchor = anchor;

                // StackLimit
                Rect boxStackLimit = GenUI.RightPart(container, 0.65f);
                anchor      = Text.Anchor;
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(boxStackLimit, stackLimit.ToString());
                Text.Anchor = anchor;

                // Show The Rule
                // * ends up text wrapping, so its not really
                // * very helpful IMO
                TooltipHandler.TipRegion(container, "From Rule:\n<item defName=\"" + defName + "\" stackLimit=\"" + stackLimit.ToString() + "\" />");
            }



            // DEBUG
            space       = listing.GetRect(15);
            section     = listing.GetRect(Verse.Text.LineHeight + 2);
            anchor      = Text.Anchor;
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.Box(section, Translator.Translate("OgreStack.SectionHeader.Debug"), headerStyle);
            Text.Anchor = anchor;

            color     = GUI.color;
            GUI.color = Color.grey;
            Widgets.DrawLineHorizontal(section.x, section.y + section.height - 1, section.width);
            Widgets.DrawLineHorizontal(section.x, section.y + section.height - 2, section.width);
            GUI.color = color;

            Rect oContainer = listing.GetRect(Verse.Text.LineHeight);

            Widgets.DrawHighlightIfMouseover(oContainer);
            Rect oLeft = GenUI.LeftPart(oContainer, 0.8f);

            anchor      = Text.Anchor;
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(oLeft, Translator.Translate("OgreStack.Settings.CSV.Title"));
            Text.Anchor = anchor;

            TooltipHandler.TipRegion(oLeft, Translator.Translate("OgreStack.Settings.CSV.Desc", DataUtil.GenerateFilePath("OgreStack_DefsList.csv").Replace("/", "\\")));

            Rect oRight = GenUI.RightPart(oContainer, 0.2f);

            Widgets.Checkbox(oRight.x + oRight.width - 26, oRight.y, ref this.settings.IsDebug);

            //oContainer = listing.GetRect(Verse.Text.LineHeight);
            //GUI.SetNextControlName("preset_test");
            //if (Widgets.ButtonText(oContainer, "Test"))
            //{
            //	this.settings.Values[Category.SmallVolumeResource].Buffer = "999";
            //	if (this.settings.Values[Category.SmallVolumeResource].Mode == MultiplierMode.Fixed)
            //	{
            //		this.settings.Values[Category.SmallVolumeResource].Mode = MultiplierMode.Scalar;
            //	}
            //	else
            //	{
            //		this.settings.Values[Category.SmallVolumeResource].Mode = MultiplierMode.Fixed;
            //	}
            //}

            //TooltipHandler.TipRegion(oContainer, "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed porttitor rhoncus lacus, sed condimentum odio pretium sed. Pellentesque luctus velit id magna efficitur interdum. Duis nec dictum ante. Morbi urna nibh, ullamcorper id blandit viverra, molestie et risus. In hac habitasse platea dictumst. Suspendisse ut dictum velit, in vestibulum erat. Proin vel ultrices ante, eget tristique lorem. Donec scelerisque rutrum fermentum. Vivamus pulvinar nec augue a convallis. Donec ut tellus lorem. Maecenas at pharetra libero, a iaculis risus. Sed dui tellus, euismod sit amet egestas vitae, convallis at eros. Quisque sed placerat quam, vel luctus erat. Suspendisse leo tellus, porta in laoreet in, feugiat quis mi. Suspendisse fermentum aliquam metus id sollicitudin. Curabitur consectetur lacus ac dolor scelerisque vestibulum.");
            listing.End();
            Widgets.EndScrollView();
        }
		private void WindowOnGUI()
		{
			Rect rect = windowRect.AtZero().ContractedBy(7f);
			Rect viewRect = rect.AtZero();
			bool flag = contentHeight > rect.height;
			Widgets.DrawWindowBackgroundTutor(windowRect.AtZero());
			if (flag)
			{
				viewRect.height = contentHeight + 40f;
				viewRect.width -= 20f;
				scrollPosition = GUI.BeginScrollView(rect, scrollPosition, viewRect);
			}
			else
			{
				GUI.BeginGroup(rect);
			}
			float num = 0f;
			Text.Font = GameFont.Small;
			Rect rect2 = new Rect(0f, 0f, viewRect.width - 24f, 24f);
			Widgets.Label(rect2, "LearningHelper".Translate());
			num = rect2.yMax;
			if (Widgets.ButtonImage(new Rect(rect2.xMax, rect2.y, 24f, 24f), (!showAllMode) ? TexButton.Plus : TexButton.Minus))
			{
				showAllMode = !showAllMode;
				if (showAllMode)
				{
					SoundDefOf.Tick_High.PlayOneShotOnCamera();
				}
				else
				{
					SoundDefOf.Tick_Low.PlayOneShotOnCamera();
				}
			}
			if (showAllMode)
			{
				Rect rect3 = new Rect(0f, num, viewRect.width - 20f - 2f, 28f);
				searchString = FilterSearchStringInput(Widgets.TextField(rect3, searchString));
				if (searchString == "")
				{
					GUI.color = new Color(0.6f, 0.6f, 0.6f, 1f);
					Text.Anchor = TextAnchor.MiddleLeft;
					Rect rect4 = rect3;
					rect4.xMin += 7f;
					Widgets.Label(rect4, "Filter".Translate() + "...");
					Text.Anchor = TextAnchor.UpperLeft;
					GUI.color = Color.white;
				}
				if (Widgets.ButtonImage(new Rect(viewRect.width - 20f, num + 14f - 10f, 20f, 20f), TexButton.CloseXSmall))
				{
					searchString = "";
					SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
				}
				num = rect3.yMax + 4f;
			}
			tmpConceptsToShow.Clear();
			if (showAllMode)
			{
				tmpConceptsToShow.AddRange(DefDatabase<ConceptDef>.AllDefsListForReading);
			}
			else
			{
				tmpConceptsToShow.AddRange(activeConcepts);
			}
			if (tmpConceptsToShow.Any())
			{
				GUI.color = new Color(1f, 1f, 1f, 0.5f);
				Widgets.DrawLineHorizontal(0f, num, viewRect.width);
				GUI.color = Color.white;
				num += 4f;
			}
			if (showAllMode)
			{
				tmpConceptsToShow.SortBy((ConceptDef x) => -DisplayPriority(x), (ConceptDef x) => x.label);
			}
			for (int i = 0; i < tmpConceptsToShow.Count; i++)
			{
				if (!tmpConceptsToShow[i].TriggeredDirect)
				{
					num = DrawConceptListRow(0f, num, viewRect.width, tmpConceptsToShow[i]).yMax;
				}
			}
			tmpConceptsToShow.Clear();
			contentHeight = num;
			if (flag)
			{
				GUI.EndScrollView();
			}
			else
			{
				GUI.EndGroup();
			}
		}
        public static void DrawCurveMeasures(Rect rect, Rect viewRect, Rect graphRect, int xLabelsCount, int yLabelsCount, bool xIntegersOnly, bool yIntegersOnly)
        {
            Text.Font = GameFont.Small;
            Color color  = new Color(0.45f, 0.45f, 0.45f);
            Color color2 = new Color(0.7f, 0.7f, 0.7f);

            GUI.BeginGroup(rect);
            float num;
            float num2;
            int   num3;

            SimpleCurveDrawer.CalculateMeasureStartAndInc(out num, out num2, out num3, viewRect.xMin, viewRect.xMax, xLabelsCount, xIntegersOnly);
            Text.Anchor = TextAnchor.UpperCenter;
            string b = string.Empty;

            for (int i = 0; i < num3; i++)
            {
                float  x    = num + num2 * (float)i;
                string text = x.ToString("F0");
                if (!(text == b))
                {
                    b = text;
                    float x2   = SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(graphRect, viewRect, new Vector2(x, 0f)).x;
                    float num4 = x2 + 60f;
                    float num5 = rect.height - 30f;
                    GUI.color = color;
                    Widgets.DrawLineVertical(num4, num5, 5f);
                    GUI.color = color2;
                    Rect rect2 = new Rect(num4 - 31f, num5 + 2f, 60f, 30f);
                    Text.Font = GameFont.Tiny;
                    Widgets.Label(rect2, text);
                    Text.Font = GameFont.Small;
                }
            }
            float num6;
            float num7;
            int   num8;

            SimpleCurveDrawer.CalculateMeasureStartAndInc(out num6, out num7, out num8, viewRect.yMin, viewRect.yMax, yLabelsCount, yIntegersOnly);
            string b2 = string.Empty;

            Text.Anchor = TextAnchor.UpperRight;
            for (int j = 0; j < num8; j++)
            {
                float  y     = num6 + num7 * (float)j;
                string text2 = y.ToString("F0");
                if (!(text2 == b2))
                {
                    b2 = text2;
                    float y2   = SimpleCurveDrawer.CurveToScreenCoordsInsideScreenRect(graphRect, viewRect, new Vector2(0f, y)).y;
                    float num9 = y2 + (graphRect.y - rect.y);
                    GUI.color = color;
                    Widgets.DrawLineHorizontal(55f, num9, 5f + graphRect.width);
                    GUI.color = color2;
                    Rect rect3 = new Rect(0f, num9 - 10f, 55f, 20f);
                    Text.Font = GameFont.Tiny;
                    Widgets.Label(rect3, text2);
                    Text.Font = GameFont.Small;
                }
            }
            GUI.EndGroup();
            GUI.color   = new Color(1f, 1f, 1f);
            Text.Anchor = TextAnchor.UpperLeft;
        }
Ejemplo n.º 26
0
        public static void DoTimeControlsGUI(Rect timerRect)
        {
            TickManager tickManager = Find.TickManager;

            GUI.BeginGroup(timerRect);
            Rect rect = new Rect(0f, 0f, TimeControls.TimeButSize.x, TimeControls.TimeButSize.y);

            for (int i = 0; i < TimeControls.CachedTimeSpeedValues.Length; i++)
            {
                TimeSpeed timeSpeed = TimeControls.CachedTimeSpeedValues[i];
                if (timeSpeed != TimeSpeed.Ultrafast)
                {
                    if (Widgets.ButtonImage(rect, TexButton.SpeedButtonTextures[(int)timeSpeed]))
                    {
                        if (timeSpeed == TimeSpeed.Paused)
                        {
                            tickManager.TogglePaused();
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction);
                        }
                        else
                        {
                            tickManager.CurTimeSpeed = timeSpeed;
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                        }
                        TimeControls.PlaySoundOf(tickManager.CurTimeSpeed);
                    }
                    if (tickManager.CurTimeSpeed == timeSpeed)
                    {
                        GUI.DrawTexture(rect, TexUI.HighlightTex);
                    }
                    rect.x += rect.width;
                }
            }
            if (Find.TickManager.slower.ForcedNormalSpeed)
            {
                Widgets.DrawLineHorizontal(rect.width * 2f, rect.height / 2f, rect.width * 2f);
            }
            GUI.EndGroup();
            GenUI.AbsorbClicksInRect(timerRect);
            UIHighlighter.HighlightOpportunity(timerRect, "TimeControls");
            if (Event.current.type == EventType.KeyDown)
            {
                if (KeyBindingDefOf.TogglePause.KeyDownEvent)
                {
                    Find.TickManager.TogglePaused();
                    TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction);
                    Event.current.Use();
                }
                if (KeyBindingDefOf.TimeSpeed_Normal.KeyDownEvent)
                {
                    Find.TickManager.CurTimeSpeed = TimeSpeed.Normal;
                    TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                    Event.current.Use();
                }
                if (KeyBindingDefOf.TimeSpeed_Fast.KeyDownEvent)
                {
                    Find.TickManager.CurTimeSpeed = TimeSpeed.Fast;
                    TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                    Event.current.Use();
                }
                if (KeyBindingDefOf.TimeSpeed_Superfast.KeyDownEvent)
                {
                    Find.TickManager.CurTimeSpeed = TimeSpeed.Superfast;
                    TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                    Event.current.Use();
                }
                if (Prefs.DevMode)
                {
                    if (KeyBindingDefOf.TimeSpeed_Ultrafast.KeyDownEvent)
                    {
                        Find.TickManager.CurTimeSpeed = TimeSpeed.Ultrafast;
                        TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed);
                        Event.current.Use();
                    }
                    if (KeyBindingDefOf.Dev_TickOnce.KeyDownEvent && tickManager.CurTimeSpeed == TimeSpeed.Paused)
                    {
                        tickManager.DoSingleTick();
                        SoundDefOf.Clock_Stop.PlayOneShotOnCamera(null);
                    }
                }
            }
        }
Ejemplo n.º 27
0
 public static void DrawLineHorizontal(float x, float y, float length, Color color)
 {
     GUI.color = color;
     Widgets.DrawLineHorizontal(x, y, length);
     GUI.color = Color.white;
 }
Ejemplo n.º 28
0
        public override void DoWindowContents(Rect inRect)
        {
            List <string> factions  = Settings.Instance.FactionFighterSettings.Keys.ToList();
            int           num       = 0;
            float         rowHeight = 28f;
            //GUI.BeginGroup(inRect);
            int scrollCount = 256;

            if (factions.Count > 8)
            {
                scrollCount = factions.Count * 32;
            }
            Rect sRect = new Rect(inRect.x, inRect.y, inRect.width - 36f, inRect.height + scrollCount);

            scrollPosition = GUI.BeginScrollView(inRect, scrollPosition, sRect, false, true);

            Text.Font = GameFont.Medium;
            float x          = Text.CalcSize("TM_FactionOptions".Translate()).x;
            Rect  headerRect = new Rect(inRect.width / 2f - (x / 2), inRect.y, inRect.width, EventOptionsWindow.HeaderSize);

            Widgets.Label(headerRect, "TM_FactionOptions".Translate());
            Text.Font = GameFont.Small;
            GUI.color = Color.white;
            Rect rect1 = new Rect(inRect);

            rect1.width /= 2.2f;
            num         += 2;
            Rect  labelRect;
            Rect  factionRowRect;
            Rect  factionRowRect_ShiftRight;
            float mage    = 1f;
            float fighter = 1f;

            for (int i = 0; i < factions.Count; i++)
            {
                labelRect = Controller.UIHelper.GetRowRect(rect1, rowHeight, num);
                Widgets.Label(labelRect, factions[i]);
                mage    = Settings.Instance.FactionMageSettings[factions[i]];
                fighter = Settings.Instance.FactionFighterSettings[factions[i]];
                num++;
                GUI.color                    = Color.magenta;
                factionRowRect               = Controller.UIHelper.GetRowRect(labelRect, rowHeight, num);
                mage                         = Widgets.HorizontalSlider(factionRowRect, Settings.Instance.FactionMageSettings[factions[i]], 0f, 5f, false, "Mages: " + Settings.Instance.FactionMageSettings[factions[i]].ToString("P0"), "0", "5", .1f);
                factionRowRect_ShiftRight    = Controller.UIHelper.GetRowRect(factionRowRect, rowHeight, num);
                factionRowRect_ShiftRight.x += rect1.width + 20f;
                GUI.color                    = Color.green;
                fighter                      = Widgets.HorizontalSlider(factionRowRect_ShiftRight, Settings.Instance.FactionFighterSettings[factions[i]], 0f, 5f, false, "Fighters: " + Settings.Instance.FactionFighterSettings[factions[i]].ToString("P0"), "0", "5", .1f);
                fDic.SetFactionSettings(factions[i], fighter, mage);
                GUI.color = Color.white;
                Widgets.DrawLineHorizontal(inRect.x - 10f, factionRowRect.yMax, inRect.width - 15f);
                num++;
            }
            num++;
            Rect rowRect99 = UIHelper.GetRowRect(rect1, rowHeight, num);

            rowRect99.width = 100f;
            reset           = Widgets.ButtonText(rowRect99, "Default", true, false, true);
            if (reset)
            {
                Settings.Instance.FactionFighterSettings.Clear();
                ModOptions.FactionDictionary.InitializeFactionSettings();
            }
            GUI.EndScrollView();
        }
        public override void DoSettingsWindowContents(Rect inRect)
        {
            this.Init();

            // Draw Contents
            // Global
            Text.Font = GameFont.Small;
            float y = 60;

            Widgets.Label(new Rect(0, y, 600, 40), "AdjustableTradeShips.Global".Translate());
            y += 40;

            Widgets.Label(new Rect(20, y, 600, 40), "AdjustableTradeShips.TradeShips".Translate());
            y += 40;


            NumberInput(40, y, ref Settings.GlobalOrbitalTrade.Instances, ref globalOtBuffers.Instances, MIN_ONOFF_VALUE, MAX_VALUE);

            Widgets.Label(new Rect(100, y, inRect.width - 200, 32), "AdjustableTradeShips.OTS".Translate());
            y += 40;

            NumberInput(40, y, ref Settings.GlobalOrbitalTrade.Days, ref globalOtBuffers.Days, MIN_ONOFF_VALUE, MAX_VALUE);

            Widgets.Label(new Rect(100, y, inRect.width - 200, 32), "AdjustableTradeShips.Days".Translate());
            y += 40;

            if (Widgets.ButtonText(new Rect(0, y, 100, 32), "AdjustableTradeShips.Default".Translate()))
            {
                OnOffIncident ooi = StoryTellerDefaultsUtil.GetGlobalDefault(IncidentDefOf.OrbitalTraderArrival);
                Settings.GlobalOrbitalTrade.Days      = ooi.Days;
                globalOtBuffers.Days                  = ooi.Days.ToString();
                Settings.GlobalOrbitalTrade.Instances = ooi.Instances;
                globalOtBuffers.Instances             = ooi.Instances.ToString();
            }

            if (Widgets.ButtonText(new Rect(200, y, 100, 32), "AdjustableTradeShips.Apply".Translate()))
            {
                StoryTellerUtil.ApplyOrbitalTrade(Settings.GlobalOrbitalTrade.Days, Settings.GlobalOrbitalTrade.Instances);
                Messages.Message("AdjustableTradeShips.GlobalSettingsApplied".Translate(), MessageTypeDefOf.PositiveEvent);
                this.globalOtBuffers = null;
            }
            y += 40;

            // Current Game
            if (Current.Game != null)
            {
                Widgets.DrawLineHorizontal(20, y, inRect.width - 40);
                y += 40;

                Widgets.Label(new Rect(0, y, 600, 40), "AdjustableTradeShips.CurrentGame".Translate());
                y += 40;

                if (StoryTellerUtil.HasOrbitalTraders() && Settings.GameOrbitalTrade != null)
                {
                    Widgets.Label(new Rect(20, y, 600, 40), "AdjustableTradeShips.TradeShips".Translate());
                    y += 40;

                    // Game Orbital Trade
                    NumberInput(40, y, ref Settings.GameOrbitalTrade.Instances, ref gameOtBuffers.Instances, MIN_ONOFF_VALUE, MAX_VALUE);

                    Widgets.Label(new Rect(100, y, inRect.width - 200, 32), "AdjustableTradeShips.OTS".Translate());
                    y += 40;

                    NumberInput(40, y, ref Settings.GameOrbitalTrade.Days, ref gameOtBuffers.Days, MIN_ONOFF_VALUE, MAX_VALUE);

                    Widgets.Label(new Rect(100, y, inRect.width - 200, 32), "AdjustableTradeShips.Days".Translate());
                    y += 40;

                    if (Widgets.ButtonText(new Rect(0, y, 100, 32), "AdjustableTradeShips.Default".Translate()))
                    {
                        if (StoryTellerDefaultsUtil.TryGetStoryTellerDefault(IncidentDefOf.OrbitalTraderArrival, out OnOffIncident ooi))
                        {
                            Settings.GameOrbitalTrade.Days      = ooi.Days;
                            gameOtBuffers.Days                  = ooi.Days.ToString();
                            Settings.GameOrbitalTrade.Instances = ooi.Instances;
                            gameOtBuffers.Instances             = ooi.Instances.ToString();
                        }
                        else
                        {
                            ooi = StoryTellerDefaultsUtil.GetGlobalDefault(IncidentDefOf.OrbitalTraderArrival);
                            Settings.GameOrbitalTrade.Days      = ooi.Days;
                            gameOtBuffers.Days                  = ooi.Days.ToString();
                            Settings.GameOrbitalTrade.Instances = ooi.Instances;
                            gameOtBuffers.Instances             = ooi.Instances.ToString();
                        }
                    }

                    if (Widgets.ButtonText(new Rect(200, y, 100, 32), "AdjustableTradeShips.Apply".Translate()))
                    {
                        StoryTellerUtil.ApplyOrbitalTrade(Settings.GameOrbitalTrade.Days, Settings.GameOrbitalTrade.Instances);
                        Messages.Message("AdjustableTradeShips.GameSettingsApplied".Translate(), MessageTypeDefOf.PositiveEvent);
                        this.gameOtBuffers = null;
                    }
                }
                else if (StoryTellerUtil.HasRandom())
                {
                    if (this.weightBuffer == null)
                    {
                        if (StoryTellerUtil.TryGetRandomWeight(IncidentCategoryDefOf.OrbitalVisitor, out float weight))
                        {
                            this.weight       = weight;
                            this.weightBuffer = weight.ToString();
                        }
                    }

                    NumberInput(20, y, "Orbital Visitor Weight", ref this.weight, ref this.weightBuffer, MIN_VALUE, MAX_VALUE);
                    y += 40;

                    if (Widgets.ButtonText(new Rect(0, y, 100, 32), "AdjustableTradeShips.Default".Translate()))
                    {
                        this.weight       = 1.0f;
                        this.weightBuffer = "1.0";
                    }

                    if (Widgets.ButtonText(new Rect(200, y, 100, 32), "AdjustableTradeShips.Apply".Translate()))
                    {
                        StoryTellerUtil.ApplyRandom(IncidentCategoryDefOf.OrbitalVisitor, this.weight);
                        Messages.Message("AdjustableTradeShips.GameSettingsApplied".Translate(), MessageTypeDefOf.PositiveEvent);
                        this.weightBuffer = this.weight.ToString();
                    }
                }
                else
                {
                    Widgets.Label(new Rect(20, y, 300, 32), Current.Game.storyteller.def.label + ": " + "AdjustableTradeShips.CannotModifyOrbitalTraderTimes".Translate());
                }
                y += 25;
            }
        }
Ejemplo n.º 30
0
        //Drawing
        public override void DoWindowContents(Rect inRect)
        {
            FactionFC faction = Find.World.GetComponent <FactionFC>();

            faction.roadBuilder.displayPaths();

            if (Find.WorldSelector.selectedTile != -1 && Find.WorldSelector.selectedTile != currentTileSelected)
            {
                currentTileSelected = Find.WorldSelector.selectedTile;
                //Log.Message("Current: " + currentTileSelected + ", Selected: " + Find.WorldSelector.selectedTile);
                currentBiomeSelected = DefDatabase <BiomeResourceDef> .GetNamed(Find.WorldGrid.tiles[currentTileSelected].biome.ToString(), false);

                //default biome
                if (currentBiomeSelected == default(BiomeResourceDef))
                {
                    //Log Modded Biome
                    currentBiomeSelected = BiomeResourceDefOf.defaultBiome;
                }
                currentHillinessSelected = DefDatabase <BiomeResourceDef> .GetNamed(Find.WorldGrid.tiles[currentTileSelected].hilliness.ToString());

                if (currentBiomeSelected.canSettle == true && currentHillinessSelected.canSettle == true && currentTileSelected != 1)
                {
                    timeToTravel = FactionColonies.ReturnTicksToArrive(Find.World.GetComponent <FactionFC>().capitalLocation, currentTileSelected);
                }
                else
                {
                    timeToTravel = 0;
                }
            }


            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;


            int silverToCreateSettlement = (int)(traitUtilsFC.cycleTraits(new double(), "createSettlementMultiplier", Find.World.GetComponent <FactionFC>().traits, "multiply") * (FactionColonies.silverToCreateSettlement + (500 * (Find.World.GetComponent <FactionFC>().settlements.Count() + Find.World.GetComponent <FactionFC>().settlementCaravansList.Count())) + (traitUtilsFC.cycleTraits(new double(), "createSettlementBaseCost", Find.World.GetComponent <FactionFC>().traits, "add"))));



            //Draw Label
            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(new Rect(0, 0, 268, 40), "SettleANewColony".Translate());

            //hori line
            Widgets.DrawLineHorizontal(0, 40, 300);


            //Upper menu
            Widgets.DrawMenuSection(new Rect(5, 45, 258, 220));

            DrawLabelBox(10, 50, 100, 100, "TravelTime".Translate(), GenDate.ToStringTicksToDays(timeToTravel));
            DrawLabelBox(153, 50, 100, 100, "InitialCost".Translate(), silverToCreateSettlement + " " + "Silver".Translate());


            //Lower Menu label
            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(new Rect(0, 270, 268, 40), "BaseProductionStats".Translate());


            //Lower menu
            Widgets.DrawMenuSection(new Rect(5, 310, 258, 220));


            //Draw production
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleCenter;

            //Production headers
            Widgets.Label(new Rect(40, 310, 60, 25), "Base".Translate());
            Widgets.Label(new Rect(110, 310, 60, 25), "Modifier".Translate());
            Widgets.Label(new Rect(180, 310, 60, 25), "Final".Translate());

            if (currentTileSelected != -1)
            {
                for (int i = 0; i < Find.World.GetComponent <FactionFC>().returnNumberResource(); i++)
                {
                    int height = 15;
                    if (Widgets.ButtonImage(new Rect(20, 335 + i * (5 + height), height, height), faction.returnResourceByInt(i).getIcon()))
                    {
                        Find.WindowStack.Add(new descWindowFC("SettlementProductionOf".Translate() + ": " + faction.returnResourceByInt(i).label, char.ToUpper(faction.returnResourceByInt(i).label[0]) + faction.returnResourceByInt(i).label.Substring(1)));
                    }
                    Widgets.Label(new Rect(40, 335 + i * (5 + height), 60, height + 2), (currentBiomeSelected.BaseProductionAdditive[i] + currentHillinessSelected.BaseProductionAdditive[i]).ToString());
                    Widgets.Label(new Rect(110, 335 + i * (5 + height), 60, height + 2), (currentBiomeSelected.BaseProductionMultiplicative[i] * currentHillinessSelected.BaseProductionMultiplicative[i]).ToString());
                    Widgets.Label(new Rect(180, 335 + i * (5 + height), 60, height + 2), ((currentBiomeSelected.BaseProductionAdditive[i] + currentHillinessSelected.BaseProductionAdditive[i]) * (currentBiomeSelected.BaseProductionMultiplicative[i] * currentHillinessSelected.BaseProductionMultiplicative[i])).ToString());
                }
            }



            //Settle button
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleCenter;
            int buttonLength = 130;

            if (Widgets.ButtonText(new Rect((InitialSize.x - 32 - buttonLength) / 2f, 535, buttonLength, 32), "Settle".Translate() + ": (" + silverToCreateSettlement + ")")) //add inital cost
            {                                                                                                                                                                 //if click button to settle
                if (PaymentUtil.getSilver() >= silverToCreateSettlement)                                                                                                      //if have enough monies to make new settlement
                {
                    StringBuilder reason = new StringBuilder();
                    if (!TileFinder.IsValidTileForNewSettlement(currentTileSelected, reason) || currentTileSelected == -1 || Find.World.GetComponent <FactionFC>().checkSettlementCaravansList(currentTileSelected.ToString()))
                    {
                        //Alert Error to User
                        Messages.Message(reason.ToString() ?? "CaravanOnWay".Translate() + "!", MessageTypeDefOf.NegativeEvent);
                    }
                    else
                    {   //Else if valid tile
                        PaymentUtil.paySilver(silverToCreateSettlement);
                        //if PROCESS MONEY HERE

                        //create settle event
                        FCEvent tmp = FCEventMaker.MakeEvent(FCEventDefOf.settleNewColony);
                        tmp.location        = currentTileSelected;
                        tmp.planetName      = Find.World.info.name;
                        tmp.timeTillTrigger = Find.TickManager.TicksGame + timeToTravel;
                        tmp.source          = Find.World.GetComponent <FactionFC>().capitalLocation;
                        Find.World.GetComponent <FactionFC>().addEvent(tmp);

                        Find.World.GetComponent <FactionFC>().settlementCaravansList.Add(tmp.location.ToString());
                        Messages.Message("CaravanSentToLocation".Translate() + " " + GenDate.ToStringTicksToDays((tmp.timeTillTrigger - Find.TickManager.TicksGame)) + "!", MessageTypeDefOf.PositiveEvent);
                        // when event activate FactionColonies.createPlayerColonySettlement(currentTileSelected);
                    }
                }
                else
                {  //if don't have enough monies to make settlement
                    Messages.Message("NotEnoughSilverToSettle".Translate() + "!", MessageTypeDefOf.NeutralEvent);
                }
            }



            //reset anchor/font
            Text.Font   = fontBefore;
            Text.Anchor = anchorBefore;
        }