Пример #1
0
        public static void Label( Rect canvas, string text, Color color, GameFont font, TextAnchor anchor, string tip = "" )
        {
            // cache old font settings
            Color oldColor = GUI.color;
            GameFont oldFont = Text.Font;
            TextAnchor oldAnchor = Text.Anchor;

            // set new ones
            GUI.color = color;
            Text.Font = font;
            Text.Anchor = anchor;

            // draw label and tip
            Verse.Widgets.Label( canvas, text );
            if ( !tip.NullOrEmpty() )
                TooltipHandler.TipRegion( canvas, tip );

            // reset settings
            GUI.color = oldColor;
            Text.Font = oldFont;
            Text.Anchor = oldAnchor;
        }
Пример #2
0
        public override void DoWindowContents(Rect inRect)
        {
            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;

            //top label
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleCenter;

            //build outline
            Widgets.DrawMenuSection(eventsBox);


            //loop through each event
            //GoTo Here if change
            int i = 0;

            Text.Anchor = TextAnchor.MiddleCenter;
            foreach (FCEvent evt in events)
            {
                i++;
                Rect name      = new Rect();
                Rect desc      = new Rect();
                Rect location  = new Rect();
                Rect time      = new Rect();
                Rect highlight = new Rect();


                name     = eventNameBase;
                desc     = eventDescBase;
                location = eventLocationBase;
                time     = eventTimeRemaining;

                name.y     = scroll + eventHeight * i;
                desc.y     = scroll + eventHeight * i;
                location.y = scroll + eventHeight * i;
                time.y     = scroll + eventHeight * i;

                highlight = new Rect(name.x, name.y, time.x + time.width, eventHeight);



                if (i % 2 == 0)
                {
                    Widgets.DrawHighlight(highlight);
                }
                Widgets.Label(name, evt.def.label);
                //
                if (Widgets.ButtonText(desc, "Desc"))
                {
                    if (evt.hasCustomDescription == false)
                    {
                        //If desc button clicked

                        string settlementString = evt.settlementTraitLocations.Join((settlement) => $" {settlement.name}", "\n");
                        if (!settlementString.NullOrEmpty())
                        {
                            Log.Message(evt.settlementTraitLocations.Count + "");
                            Find.WindowStack.Add(new DescWindowFc($"{evt.def.desc}\n{"EventAffectingSettlements".Translate()}\n{settlementString}"));
                        }
                        else
                        {
                            Find.WindowStack.Add(new DescWindowFc(evt.def.desc));
                        }
                    }
                    else
                    {
                        //has custom description
                        Find.WindowStack.Add(new DescWindowFc(evt.customDescription));
                    }
                }
                //
                if (Widgets.ButtonText(location, "Location".Translate().CapitalizeFirst()))
                {
                    if (evt.hasDestination == true)
                    {
                        Find.WindowStack.Add(new SettlementWindowFc(faction.returnSettlementByLocation(evt.location, evt.planetName)));
                    }
                    else
                    {
                        if (evt.settlementTraitLocations.Count() > 0)
                        {
                            //if event affecting colonies
                            List <FloatMenuOption> list = new List <FloatMenuOption>();
                            foreach (SettlementFC settlement in evt.settlementTraitLocations)
                            {
                                if (settlement != null)
                                {
                                    list.Add(new FloatMenuOption(settlement.name, delegate { Find.WindowStack.Add(new SettlementWindowFc(settlement)); }));
                                }
                            }
                            if (list.Count == 0)
                            {
                                list.Add(new FloatMenuOption("Null", null));
                            }
                            Find.WindowStack.Add(new FloatMenu(list));
                        }
                        else
                        {
                            if (evt.def == FCEventDefOf.taxColony && evt.source != -1)
                            {
                                Find.WindowStack.Add(new SettlementWindowFc(faction.returnSettlementByLocation(evt.source, evt.planetName)));
                            }
                        }
                    }
                }
                Widgets.Label(time, (evt.timeTillTrigger - Find.TickManager.TicksGame).ToTimeString());
            }



            //Top label
            Widgets.ButtonTextSubtle(eventNameBase, "Name".Translate());
            Widgets.ButtonTextSubtle(eventDescBase, "Description".Translate());
            Widgets.ButtonTextSubtle(eventLocationBase, "Source".Translate());
            Widgets.ButtonTextSubtle(eventTimeRemaining, "TimeRemaining".Translate());

            //Menu Outline
            Widgets.DrawBox(eventsBox);


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


            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y);
            }
        }
 // Token: 0x06001C19 RID: 7193 RVA: 0x000AC7E5 File Offset: 0x000AA9E5
 public Listing_StandardExpanding(GameFont font)
 {
     this.font = font;
 }
Пример #4
0
        public static void Paragraph( ref Vector2 curPos, float width, string label, Color color, GameFont font = GameFont.Small, TextAnchor anchor = TextAnchor.UpperLeft, string tip = "", float marginBottom = 6f )
        {
            var oldFont = Text.Font;
            Text.Font = font;
            float height = Text.CalcHeight( label, width );

            Label( new Rect( curPos.x, curPos.y, width, height ), label, color, font, anchor, tip );
            Text.Font = oldFont;
            curPos.y += height + marginBottom;
        }
Пример #5
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="Base" /> class.
 /// </summary>
 /// <param name="renderer">Renderer to use.</param>
 protected Base(Renderer.Base renderer)
 {
     mDefaultFont = null;
     mRenderer    = renderer;
 }
Пример #6
0
 public ButtonTextRenderer(Func <Flow, string> exprLabel, Action <Flow> onClick, GameFont font = GameFont.Small, float width = -1)
 {
     this.exprLabel = exprLabel;
     this.label     = null;
     this.onClick   = onClick;
     this.font      = font;
     this.width     = width;
 }
Пример #7
0
        public override void DoWindowContents(Rect inRect)
        {
            if (Event.current.type == EventType.Layout)
            {
                return;
            }

            GameFont original = Text.Font;

            Text.Font = GameFont.Small;
            float adjustedHeight = inRect.height - 55f - Margin;

            if (inRect.height > adjustedHeight)
            {
                inRect.height = adjustedHeight;
            }

            // Rect regions
            Rect newBtnRegion     = new Rect(0f, 0f, inRect.width * 0.4f, Text.LineHeight);
            Rect ledgerMenuRegion = new Rect(
                0f,
                newBtnRegion.height + 5f,
                newBtnRegion.width,
                inRect.height - newBtnRegion.height + 5f
                );
            Rect ledgerSettingsRegion = new Rect(
                ledgerMenuRegion.width + 5f,
                0f,
                inRect.width - ledgerMenuRegion.width - 5f,
                inRect.height
                );
            Rect ledgerMenuCanvas   = new Rect(4f, 4f, ledgerMenuRegion.width - 8f, ledgerMenuRegion.height - 8f);
            Rect ledgerMenuViewport = new Rect(
                0f,
                0f,
                ledgerMenuCanvas.width - 16f,
                Text.LineHeight * Ledgers.Instance.All.Count
                );


            if (Widgets.ButtonText(newBtnRegion, "New Ledger"))
            {
                Ledger _ = Ledger.NewLedger();
            }

            Listing_Standard listing = new Listing_Standard(GameFont.Small);

            Widgets.DrawMenuSection(ledgerMenuRegion);

            GUI.BeginGroup(ledgerMenuRegion);
            listing.BeginScrollView(ledgerMenuCanvas, ref scrollPosition, ref ledgerMenuViewport);

            foreach (Ledger ledger in Ledgers.Instance.All)
            {
                Rect lineRect       = listing.GetRect(Text.LineHeight);
                Rect iconRect       = new Rect(0f, lineRect.y, 24f, lineRect.height);
                Rect ledgerRect     = new Rect(26f, lineRect.y, lineRect.width - 26f, lineRect.height);
                bool isActiveLedger = ledger.Id.Equals(ToolkitPointsSettings.currentActiveLedgerId);

                if (!lineRect.IsRegionVisible(ledgerMenuViewport, scrollPosition))
                {
                    continue;
                }

                if (selectedLedger == ledger)
                {
                    Widgets.DrawLightHighlight(ledgerRect);
                }

                Widgets.DrawHighlightIfMouseover(ledgerRect);


                if (isActiveLedger)
                {
                    GUI.DrawTexture(iconRect, Widgets.CheckboxOnTex);
                    TooltipHandler.TipRegion(iconRect, $"{ledger.Name} is currently active");
                }
                else
                {
                    if (Mouse.IsOver(iconRect))
                    {
                        Widgets.CheckboxOnTex.DrawColored(iconRect, new Color(1f, 1f, 1f, 0.38f));
                    }

                    TooltipHandler.TipRegion(iconRect, $@"Set ""{ledger.Name}"" as the current active ledger");

                    if (Widgets.ButtonInvisible(iconRect))
                    {
                        activeLedger = ledger;
                        ToolkitPointsSettings.currentActiveLedgerId = ledger.Id;
                    }
                }

                DoLedgerRow(ledgerRect, ledger);
            }

            GUI.EndGroup();
            listing.EndScrollView(ref ledgerMenuViewport);


            GUI.BeginGroup(ledgerSettingsRegion);
            DrawLedgerOptions(new Rect(0f, 0f, ledgerSettingsRegion.width, ledgerSettingsRegion.height));
            GUI.EndGroup();

            Text.Font = original;
        }
Пример #8
0
        public static void DrawPawnLabel(Pawn pawn, Vector2 pos, float alpha = 1f, float truncateToWidth = 9999f, Dictionary <string, string> truncatedLabelsCache = null, GameFont font = GameFont.Tiny, bool alwaysDrawBg = true, bool alignCenter = true)
        {
            float pawnLabelNameWidth = GenMapUI.GetPawnLabelNameWidth(pawn, truncateToWidth, truncatedLabelsCache, font);
            Rect  bgRect             = new Rect((float)(pos.x - pawnLabelNameWidth / 2.0 - 4.0), pos.y, (float)(pawnLabelNameWidth + 8.0), 12f);

            if (!pawn.RaceProps.Humanlike)
            {
                bgRect.y -= 4f;
            }
            GenMapUI.DrawPawnLabel(pawn, bgRect, alpha, truncateToWidth, truncatedLabelsCache, font, alwaysDrawBg, alignCenter);
        }
Пример #9
0
        public override void DoWindowContents(Rect rect)
        {
            if (Find.World.GetComponent <FactionFC>().militaryCustomizationUtil.DeployedSquads.Count() == 0)
            {
                this.Close();
            }

            GameFont   oldFont   = Text.Font;
            TextAnchor oldAnchor = Text.Anchor;

            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleCenter;

            Rect selectSquad   = new Rect(0, 0, 160, 40);
            Rect commandAttack = new Rect(0, 40, 160, 40);
            Rect commandMove   = new Rect(0, 80, 160, 40);
            Rect commandHeal   = new Rect(0, 120, 160, 40);


            if (selectedSquad == null)
            {
                squadText = "Select Deployed Squad";
            }
            else
            {
                squadText = selectedSquad.getSettlement.name + "'s " + selectedSquad.outfit.name;
            }

            //Select a squad
            if (Widgets.ButtonText(selectSquad, squadText))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (MercenarySquadFC squad in Find.World.GetComponent <FactionFC>().militaryCustomizationUtil.DeployedSquads)
                {
                    list.Add(new FloatMenuOption(squad.getSettlement.name + "'s " + squad.outfit.name, delegate
                    {
                        selectedSquad = squad;
                    }));
                }
                if (list.Count() == 0)
                {
                    list.Add(new FloatMenuOption("No squads available", null));
                }

                Find.WindowStack.Add(new FloatMenu(list));
            }



            if (Widgets.ButtonTextSubtle(commandAttack, "Attack"))
            {
                if (selectedSquad != null)
                {
                    selectedSquad.order = MilitaryOrders.Attack;
                    Messages.Message(selectedSquad.outfit.name + " are now charging the enemy.", MessageTypeDefOf.NeutralEvent);
                    //selectedSquad.orderLocation = Position;
                }
            }
            if (Widgets.ButtonTextSubtle(commandMove, "Move"))
            {
                if (selectedSquad != null)
                {
                    DebugTool tool = null;
                    IntVec3   Position;
                    tool = new DebugTool("Select Move Position", delegate()
                    {
                        Position = UI.MouseCell();

                        selectedSquad.order         = MilitaryOrders.Standby;
                        selectedSquad.orderLocation = Position;
                        Messages.Message(selectedSquad.outfit.name + " are moving to the position and standing by.", MessageTypeDefOf.NeutralEvent);

                        DebugTools.curTool = null;
                    });
                    DebugTools.curTool = tool;
                }
            }
            if (Widgets.ButtonTextSubtle(commandHeal, "Leave"))
            {
                if (selectedSquad != null)
                {
                    Messages.Message(selectedSquad.outfit.name + " are now leaving the map.", MessageTypeDefOf.NeutralEvent);
                    selectedSquad.order = MilitaryOrders.RecoverWounded;
                }
            }

            //Example command:

            //DebugTool tool = null;
            //IntVec3 Position;
            //tool = new DebugTool("Select Drop Position", delegate ()
            //{
            //   Position = UI.MouseCell();

            //    selectedSquad.order = MilitaryOrders.Standby;
            //    selectedSquad.orderLocation = Position;

            //    DebugTools.curTool = null;
            //});
            //DebugTools.curTool = tool;


            Text.Font   = oldFont;
            Text.Anchor = oldAnchor;
        }
Пример #10
0
        static Text()
        {
            Font font  = (Font)Resources.Load("Fonts/Calibri_tiny");
            Font font2 = (Font)Resources.Load("Fonts/Arial_small");
            Font font3 = (Font)Resources.Load("Fonts/Arial_medium");

            Text.fontStyles[0]               = new GUIStyle(GUI.skin.label);
            Text.fontStyles[0].font          = font;
            Text.fontStyles[1]               = new GUIStyle(GUI.skin.label);
            Text.fontStyles[1].font          = font2;
            Text.fontStyles[1].contentOffset = new Vector2(0f, -1f);
            Text.fontStyles[2]               = new GUIStyle(GUI.skin.label);
            Text.fontStyles[2].font          = font3;
            for (int i = 0; i < Text.textFieldStyles.Length; i++)
            {
                Text.textFieldStyles[i]           = new GUIStyle(GUI.skin.textField);
                Text.textFieldStyles[i].alignment = TextAnchor.MiddleLeft;
            }
            Text.textFieldStyles[0].font = font;
            Text.textFieldStyles[1].font = font2;
            Text.textFieldStyles[2].font = font3;
            for (int j = 0; j < Text.textAreaStyles.Length; j++)
            {
                Text.textAreaStyles[j]           = new GUIStyle(Text.textFieldStyles[j]);
                Text.textAreaStyles[j].alignment = TextAnchor.UpperLeft;
                Text.textAreaStyles[j].wordWrap  = true;
            }
            for (int k = 0; k < Text.textAreaReadOnlyStyles.Length; k++)
            {
                Text.textAreaReadOnlyStyles[k] = new GUIStyle(Text.textAreaStyles[k]);
                GUIStyle guistyle = Text.textAreaReadOnlyStyles[k];
                guistyle.normal.background    = null;
                guistyle.active.background    = null;
                guistyle.onHover.background   = null;
                guistyle.hover.background     = null;
                guistyle.onFocused.background = null;
                guistyle.focused.background   = null;
            }
            GUI.skin.settings.doubleClickSelectsWord = true;
            int         num        = 0;
            IEnumerator enumerator = Enum.GetValues(typeof(GameFont)).GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    object   obj   = enumerator.Current;
                    GameFont font4 = (GameFont)obj;
                    Text.Font                   = font4;
                    Text.lineHeights[num]       = Text.CalcHeight("W", 999f);
                    Text.spaceBetweenLines[num] = Text.CalcHeight("W\nW", 999f) - Text.CalcHeight("W", 999f) * 2f;
                    num++;
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
            Text.Font = GameFont.Small;
        }
Пример #11
0
        public static string CapString(string text, float width, string suffix, out bool wasCapped, GameFont font, TextAnchor anchor = TextAnchor.UpperLeft)
        {
            if (text == null)
            {
                wasCapped = false;
                return(null);
            }
            float widthForText = CalcSize(text, font, anchor, false).x;

            if (width >= widthForText)
            {
                wasCapped = false;
                return(text);
            }
            float widthForSuffix;

            if (suffix.NullOrEmpty())
            {
                widthForSuffix = 0;
            }
            else
            {
                widthForSuffix = CalcSize(suffix, font, anchor, false).x;
            }
            int charsToKeep = (int)_GUIStyleGetNumCharactersThatFitWithinWidth.Invoke(FontStyle(font, anchor, false), new object[] { text, Mathf.Max(0, width - widthForSuffix) });

            wasCapped = text.Length != charsToKeep;
            if (widthForSuffix > 0)
            {
                return(text.Substring(0, charsToKeep) + suffix);
            }
            else
            {
                return(text.Substring(0, charsToKeep));
            }
        }
Пример #12
0
 public static Vector2 CalcSize(string text, GameFont font, TextAnchor anchor = TextAnchor.UpperLeft, bool wordWrap = true)
 {
     tmpTextGUIContent.text = text;
     return(FontStyle(font, anchor, wordWrap).CalcSize(tmpTextGUIContent));
 }
Пример #13
0
 public static float LineHeight(GameFont font)
 {
     return(lineHeights[(int)font]);
 }
Пример #14
0
        private static float GetPawnLabelNameWidth(Pawn pawn, float truncateToWidth, Dictionary <string, string> truncatedLabelsCache, GameFont font)
        {
            GameFont font2 = Text.Font;

            Text.Font = font;
            string pawnLabel = GenMapUI.GetPawnLabel(pawn, truncateToWidth, truncatedLabelsCache, font);
            float  num;

            if (font == GameFont.Tiny)
            {
                num = pawnLabel.GetWidthCached();
            }
            else
            {
                Vector2 vector = Text.CalcSize(pawnLabel);
                num = vector.x;
            }
            if (num < 20.0)
            {
                num = 20f;
            }
            Text.Font = font2;
            return(num);
        }
Пример #15
0
        public static void Settings_Header(this Listing_Standard lister, string header, Color highlight, GameFont fontSize = GameFont.Medium, TextAnchor anchor = TextAnchor.MiddleLeft)
        {
            var textSize = Text.Font;

            Text.Font = fontSize;

            Rect rect = lister.GetRect(Text.CalcHeight(header, lister.ColumnWidth));

            GUI.color = highlight;
            GUI.DrawTexture(rect, BaseContent.WhiteTex);
            GUI.color = textColor;

            var anchorTmp = Text.Anchor;

            Text.Anchor = anchor;
            Widgets.Label(rect, header);
            Text.Font   = textSize;
            Text.Anchor = anchorTmp;
            lister.Gap(12f);
        }
Пример #16
0
        private static string GetPawnLabel(Pawn pawn, float truncateToWidth, Dictionary <string, string> truncatedLabelsCache, GameFont font)
        {
            GameFont font2 = Text.Font;

            Text.Font = font;
            string result = pawn.NameStringShort.CapitalizeFirst().Truncate(truncateToWidth, truncatedLabelsCache);

            Text.Font = font2;
            return(result);
        }
Пример #17
0
        public static void Draw_Label(Rect rect, string label, Color highlight, Color textColor, GameFont fontSize = GameFont.Medium, TextAnchor anchor = TextAnchor.MiddleLeft)
        {
            var textSize = Text.Font;

            Text.Font = fontSize;
            GUI.color = highlight;
            GUI.DrawTexture(rect, BaseContent.WhiteTex);
            GUI.color = textColor;

            var anchorTmp = Text.Anchor;

            Text.Anchor = anchor;
            Widgets.Label(rect, label);
            Text.Font   = textSize;
            Text.Anchor = anchorTmp;
        }
Пример #18
0
        public static void DrawPawnLabel(Pawn pawn, Rect bgRect, float alpha = 1f, float truncateToWidth = 9999f, Dictionary <string, string> truncatedLabelsCache = null, GameFont font = GameFont.Tiny, bool alwaysDrawBg = true, bool alignCenter = true)
        {
            GUI.color = new Color(1f, 1f, 1f, alpha);
            Text.Font = font;
            string pawnLabel            = GenMapUI.GetPawnLabel(pawn, truncateToWidth, truncatedLabelsCache, font);
            float  pawnLabelNameWidth   = GenMapUI.GetPawnLabelNameWidth(pawn, truncateToWidth, truncatedLabelsCache, font);
            float  summaryHealthPercent = pawn.health.summaryHealth.SummaryHealthPercent;

            if (alwaysDrawBg || summaryHealthPercent < 0.99900001287460327)
            {
                GUI.DrawTexture(bgRect, TexUI.GrayTextBG);
            }
            if (summaryHealthPercent < 0.99900001287460327)
            {
                Rect rect = bgRect.ContractedBy(1f);
                Widgets.FillableBar(rect, summaryHealthPercent, GenMapUI.OverlayHealthTex, BaseContent.ClearTex, false);
            }
            Color color = PawnNameColorUtility.PawnNameColorOf(pawn);

            color.a   = alpha;
            GUI.color = color;
            Rect rect2 = default(Rect);

            if (alignCenter)
            {
                Text.Anchor = TextAnchor.UpperCenter;
                Vector2 center = bgRect.center;
                rect2 = new Rect((float)(center.x - pawnLabelNameWidth / 2.0), (float)(bgRect.y - 2.0), pawnLabelNameWidth, 100f);
            }
            else
            {
                Text.Anchor = TextAnchor.UpperLeft;
                double  x       = bgRect.x + 2.0;
                Vector2 center2 = bgRect.center;
                float   y       = center2.y;
                Vector2 vector  = Text.CalcSize(pawnLabel);
                rect2 = new Rect((float)x, (float)(y - vector.y / 2.0), pawnLabelNameWidth, 100f);
            }
            Widgets.Label(rect2, pawnLabel);
            if (pawn.Drafted)
            {
                Vector2 center3 = bgRect.center;
                Widgets.DrawLineHorizontal((float)(center3.x - pawnLabelNameWidth / 2.0), (float)(bgRect.y + 11.0), pawnLabelNameWidth);
            }
            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
        }
Пример #19
0
 public void setFont(GameFont font)
 {
     throw new System.NotImplementedException();
 }
Пример #20
0
        public override void DoWindowContents(Rect inRect)
        {
            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;

            //Buildings
            for (int i = 0; i < buildingList.Count; i++)
            {
                BuildingFCDef building = buildingList[i];
                newBuildingWindow = new Rect(BaseBuildingWindow.x, BaseBuildingWindow.y + (i * (rowHeight)) + scroll, BaseBuildingWindow.width, BaseBuildingWindow.height);
                newBuildingIcon   = new Rect(BaseBuildingIcon.x, BaseBuildingIcon.y + (i * (rowHeight)) + scroll, BaseBuildingIcon.width, BaseBuildingIcon.height);
                newBuildingLabel  = new Rect(BaseBuildingLabel.x, BaseBuildingLabel.y + (i * (rowHeight)) + scroll, BaseBuildingLabel.width, BaseBuildingLabel.height);
                newBuildingDesc   = new Rect(BaseBuildingDesc.x, BaseBuildingDesc.y + (i * (rowHeight)) + scroll, BaseBuildingDesc.width, BaseBuildingDesc.height);

                if (Widgets.ButtonInvisible(newBuildingWindow))
                {
                    //If click on building
                    List <FloatMenuOption> list = new List <FloatMenuOption>();

                    if (building == buildingDef)
                    {
                        //if the same building
                        list.Add(new FloatMenuOption("Destroy".Translate(), delegate
                        {
                            settlement.deconstructBuilding(buildingSlot);
                            Find.WindowStack.TryRemove(this);
                            Find.WindowStack.WindowOfType <SettlementWindowFc>().windowUpdateFc();
                        }));
                    }
                    else
                    {
                        //if not the same building
                        list.Add(new FloatMenuOption("Build".Translate(), delegate
                        {
                            if (!settlement.validConstructBuilding(building, buildingSlot, settlement))
                            {
                                return;
                            }
                            FCEvent tmpEvt = new FCEvent(true)
                            {
                                def          = FCEventDefOf.constructBuilding,
                                source       = settlement.mapLocation,
                                planetName   = settlement.planetName,
                                building     = building,
                                buildingSlot = buildingSlot
                            };


                            int triggerTime = building.constructionDuration;
                            if (factionfc.hasPolicy(FCPolicyDefOf.isolationist))
                            {
                                triggerTime /= 2;
                            }

                            tmpEvt.timeTillTrigger = Find.TickManager.TicksGame + triggerTime;
                            Find.World.GetComponent <FactionFC>().addEvent(tmpEvt);

                            PaymentUtil.paySilver(Convert.ToInt32(building.cost));
                            settlement.deconstructBuilding(buildingSlot);
                            Messages.Message(building.label + " " + "WillBeConstructedIn".Translate() + " " + (tmpEvt.timeTillTrigger - Find.TickManager.TicksGame).ToTimeString(), MessageTypeDefOf.PositiveEvent);
                            settlement.buildings[buildingSlot] = BuildingFCDefOf.Construction;
                            Find.WindowStack.TryRemove(this);
                            Find.WindowStack.WindowOfType <SettlementWindowFc>().windowUpdateFc();
                        }));
                    }



                    FloatMenu menu = new FloatMenu(list);
                    Find.WindowStack.Add(menu);
                }


                Widgets.DrawMenuSection(newBuildingWindow);
                Widgets.DrawMenuSection(newBuildingIcon);
                Widgets.DrawLightHighlight(newBuildingIcon);
                Widgets.ButtonImage(newBuildingIcon, building.icon);

                Text.Font = GameFont.Small;
                Widgets.ButtonTextSubtle(newBuildingLabel, "");
                Widgets.Label(newBuildingLabel, "  " + building.LabelCap + " - " + "Cost".Translate() + ": " + building.cost);

                Text.Font = GameFont.Tiny;
                Widgets.Label(newBuildingDesc, building.desc);
            }


            //Top Window
            Widgets.DrawMenuSection(TopWindow);
            Widgets.DrawHighlight(TopWindow);
            Widgets.DrawMenuSection(TopIcon);
            Widgets.DrawLightHighlight(TopIcon);

            Widgets.DrawBox(new Rect(0, 0, 400, 500));
            Widgets.ButtonImage(TopIcon, buildingDef.icon);

            Widgets.ButtonTextSubtle(TopName, "");
            Text.Font   = GameFont.Medium;
            Text.Anchor = TextAnchor.UpperLeft;
            Widgets.Label(new Rect(TopName.x + 5, TopName.y, TopName.width, TopName.height), buildingDef.LabelCap);

            Widgets.DrawMenuSection(new Rect(TopDescription.x - 5, TopDescription.y - 5, TopDescription.width, TopDescription.height));
            Text.Font = GameFont.Small;
            Widgets.Label(TopDescription, buildingDef.desc);

            Widgets.DrawLineHorizontal(0, TopWindow.y + TopWindow.height, 400);

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

            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y);
            }
        }
Пример #21
0
        private static float GetPawnLabelNameWidth(Pawn pawn, float truncateToWidth, Dictionary <string, string> truncatedLabelsCache, GameFont font)
        {
            GameFont font2 = Text.Font;

            Text.Font = font;
            string pawnLabel = GetPawnLabel(pawn, truncateToWidth, truncatedLabelsCache, font);
            float  num       = ((font != 0) ? Text.CalcSize(pawnLabel).x : pawnLabel.GetWidthCached());

            if (Math.Abs(Math.Round(Prefs.UIScale) - (double)Prefs.UIScale) > 1.4012984643248171E-45)
            {
                num += 0.5f;
            }
            if (num < 20f)
            {
                num = 20f;
            }
            Text.Font = font2;
            return(num);
        }
        public override void DoWindowContents(Rect inRect)
        {
            if (searchQuery != lastSearch)
            {
                GetTradeables();
            }


            GUI.BeginGroup(inRect);
            Rect     rect2 = new Rect(inRect.width - 590f, 0f, 590f, 58f);
            GameFont old   = Text.Font;

            Text.Font = GameFont.Medium;
            Widgets.Label(rect2, "Store Items");
            Text.Font = old;

            Rect searchBar = new Rect(0f, 30f, 300f, 26f);

            searchQuery = Widgets.TextEntryLabeled(searchBar, "Search:", searchQuery);

            Rect resetButton = new Rect(inRect.width - 150f, 0f, 100f, 26f);

            if (Widgets.ButtonText(resetButton, "Reset Items"))
            {
                Store_ItemEditor.ResetItemsToDefault();
                GetTradeables(false);
            }

            Rect sortLabel  = new Rect(inRect.width - 470f, 32f, 100f, 24f);
            Rect sortButton = new Rect(inRect.width - 370f, 28f, 100f, 28f);

            Color defaultColor = GUI.color;

            GUI.color = ColorLibrary.Grey;
            Widgets.Label(sortLabel, "Sort items by:");
            GUI.color = defaultColor;

            if (Widgets.ButtonText(sortButton, "category"))
            {
                if (ascending)
                {
                    ascending        = false;
                    cachedTradeables = cachedTradeables.OrderBy(s => s.FirstThingCategory.LabelCap).ToList();
                }
                else
                {
                    ascending        = true;
                    cachedTradeables = cachedTradeables.OrderByDescending(s => s.FirstThingCategory.LabelCap).ToList();
                }

                GetTradeablesPrices();
            }

            sortButton.x += 110f;

            if (Widgets.ButtonText(sortButton, "price"))
            {
                if (ascending)
                {
                    ascending        = false;
                    cachedTradeables = cachedTradeables.OrderBy(s => s.BaseMarketValue).ToList();
                }
                else
                {
                    ascending        = true;
                    cachedTradeables = cachedTradeables.OrderByDescending(s => s.BaseMarketValue).ToList();
                }

                GetTradeablesPrices();
            }

            sortButton.x += 110f;

            if (Widgets.ButtonText(sortButton, "name"))
            {
                if (ascending)
                {
                    ascending        = false;
                    cachedTradeables = cachedTradeables.OrderBy(s => s.LabelCap).ToList();
                }
                else
                {
                    ascending        = true;
                    cachedTradeables = cachedTradeables.OrderByDescending(s => s.LabelCap).ToList();
                }

                GetTradeablesPrices();
            }

            Rect mainRect = new Rect(0f, 58f, inRect.width, inRect.height - 58f - 38f - 20f);

            this.FillMainRect(mainRect);

            GUI.EndGroup();
        }
Пример #23
0
        public static void DrawPawnLabel(Pawn pawn, Rect bgRect, float alpha = 1f, float truncateToWidth = 9999f, Dictionary <string, string> truncatedLabelsCache = null, GameFont font = GameFont.Tiny, bool alwaysDrawBg = true, bool alignCenter = true)
        {
            GUI.color = new Color(1f, 1f, 1f, alpha);
            Text.Font = font;
            string pawnLabel            = GetPawnLabel(pawn, truncateToWidth, truncatedLabelsCache, font);
            float  pawnLabelNameWidth   = GetPawnLabelNameWidth(pawn, truncateToWidth, truncatedLabelsCache, font);
            float  summaryHealthPercent = pawn.health.summaryHealth.SummaryHealthPercent;

            if (alwaysDrawBg || summaryHealthPercent < 0.999f)
            {
                GUI.DrawTexture(bgRect, TexUI.GrayTextBG);
            }
            if (summaryHealthPercent < 0.999f)
            {
                Widgets.FillableBar(bgRect.ContractedBy(1f), summaryHealthPercent, OverlayHealthTex, BaseContent.ClearTex, doBorder: false);
            }
            Color color = PawnNameColorUtility.PawnNameColorOf(pawn);

            color.a   = alpha;
            GUI.color = color;
            Rect rect;

            if (alignCenter)
            {
                Text.Anchor = TextAnchor.UpperCenter;
                rect        = new Rect(bgRect.center.x - pawnLabelNameWidth / 2f, bgRect.y - 2f, pawnLabelNameWidth, 100f);
            }
            else
            {
                Text.Anchor = TextAnchor.UpperLeft;
                rect        = new Rect(bgRect.x + 2f, bgRect.center.y - Text.CalcSize(pawnLabel).y / 2f, pawnLabelNameWidth, 100f);
            }
            Widgets.Label(rect, pawnLabel);
            if (pawn.Drafted)
            {
                Widgets.DrawLineHorizontal(bgRect.center.x - pawnLabelNameWidth / 2f, bgRect.y + 11f, pawnLabelNameWidth);
            }
            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
        }
Пример #24
0
 public static void Label( Rect canvas, string text, GameFont font, string tip = "" )
 {
     Label( canvas, text, Color.white, font, TextAnchor.UpperLeft, tip );
 }
Пример #25
0
        public void BeginScrollView(Rect rect, ref Vector2 scrollPosition, Rect viewRect, GameFont font = GameFont.Small)
        {
            //Widgets.BeginScrollView(rect, ref scrollPosition, viewRect, true);
            //rect.height = 100000f;
            //rect.width -= 20f;
            //this.Begin(rect.AtZero());

            //Need BeginGroup before ScrollView, listingRect needs rect.width-=20 but the group doesn't

            Widgets.BeginGroup(rect);
            Widgets.BeginScrollView(rect.AtZero(), ref scrollPosition, viewRect, true);

            maxOneColumn = true;

            rect.width -= 20f;
            listingRect = rect;
            ColumnWidth = listingRect.width;

            curX = 0f;
            curY = 0f;

            Text.Font = font;
        }
Пример #26
0
 /// <summary>
 /// Private constructor for singleton pattern.
 /// </summary>
 private FPSMonitor()
 {
     font = FontMap.getInstance().getFont(FontEnum.Kootenay14);
 }
Пример #27
0
        public override void DoWindowContents(Rect inRect)
        {
            //grab before anchor/font
            GameFont   fontBefore   = Text.Font;
            TextAnchor anchorBefore = Text.Anchor;


            //Settlement Tax Collection Header
            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font   = GameFont.Small;

            Widgets.DrawMenuSection(menuSectionHeader);
            Widgets.DrawBox(menuSectionHeader);
            //Icon button
            if (Widgets.ButtonImage(headerFactionIcon, faction.factionIcon))
            {
            }

            Text.Anchor = TextAnchor.MiddleLeft;
            Text.Font   = GameFont.Medium;
            Widgets.Label(headerFactionName, faction.name);

            Text.Font = GameFont.Small;
            Widgets.Label(headerFactionTitle, faction.title);

            //Settings button
            if (Widgets.ButtonImage(headerSettings, TexLoad.iconCustomize))
            {
                Faction fact = FactionColonies.getPlayerColonyFaction();
                if (fact != null)
                {
                    Find.WindowStack.Add(new FactionCustomizeWindowFc(faction));
                }
            }


            //Progress bar

            Widgets.FillableBar(progressBarLevelUp, faction.factionXPCurrent / faction.factionXPGoal, foreground,
                                background, true);
            Widgets.DrawShadowAround(progressBarLevelUp);
            Text.Font   = GameFont.Tiny;
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(progressBarLevelUp, Math.Round(faction.factionXPCurrent) + "/" + faction.factionXPGoal);
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.DrawBox(progressBarLevelUp);

            Text.Font = GameFont.Small;
            Widgets.Label(factionLevel, "FCLevel".Translate(faction.factionLevel));


            //Policies
            if (faction.policies.Count() == 2)
            {
                Widgets.ButtonImage(policy_1, faction.policies[0].def.IconLight);
                if (policy_1.Contains(Event.current.mousePosition))
                {
                    TooltipHandler.TipRegion(policy_1, returnPolicyText(faction.policies[0].def));
                }

                //Widgets.Label(policy_2, new GUIContent("test", "test test test"));
                Widgets.ButtonImage(policy_2, faction.policies[1].def.IconLight);
                if (policy_2.Contains(Event.current.mousePosition))
                {
                    TooltipHandler.TipRegion(policy_2, returnPolicyText(faction.policies[1].def));
                }
            }
            else
            {
                Widgets.Label(new Rect(policy_1.x, policy_1.y, 200, 50), "FCSelectYourTraits".Translate());
            }


            List <FloatMenuOption> list      = new List <FloatMenuOption>();
            List <FCPolicyDef>     available = availableTraitsList();

            //Trait)

            //TraitSlot
            if (Widgets.ButtonTextSubtle(trait_1, returnTraitAvailibility(1, faction.factionTraits[0]))) //CHANGE THIS
            {
                if (canChangeTrait(1, faction.factionTraits[0]))
                {
                    foreach (FCPolicyDef trait in available)
                    {
                        list.Add(new FloatMenuOption(trait.label, delegate
                        {
                            List <FloatMenuOption> confirm = new List <FloatMenuOption>();
                            confirm.Add(new FloatMenuOption("FCConfirmTrait".Translate(trait.label),
                                                            delegate { faction.factionTraits[0] = new FCPolicy(trait); }));
                            Find.WindowStack.Add(new FloatMenu(confirm));
                        },
                                                     mouseoverGuiAction: delegate
                        {
                            TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(100, 200)),
                                                     returnPolicyText(trait));
                        }));
                    }

                    Find.WindowStack.Add(new FloatMenu(list));
                }
            }

            if (Mouse.IsOver(trait_1) && faction.factionTraits[0].def != FCPolicyDefOf.empty)
            {
                TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(100, 200)),
                                         returnPolicyText(faction.factionTraits[0].def));
            }
            //End Trait Slot

            //TraitSlot
            if (Widgets.ButtonTextSubtle(trait_2, returnTraitAvailibility(2, faction.factionTraits[1]))) //CHANGE THIS
            {
                if (canChangeTrait(2, faction.factionTraits[1]))
                {
                    foreach (FCPolicyDef trait in available)
                    {
                        list.Add(new FloatMenuOption(trait.label, delegate
                        {
                            List <FloatMenuOption> confirm = new List <FloatMenuOption>();
                            confirm.Add(new FloatMenuOption("FCConfirmTrait".Translate(trait.label),
                                                            delegate { faction.factionTraits[1] = new FCPolicy(trait); }));
                            Find.WindowStack.Add(new FloatMenu(confirm));
                        },
                                                     mouseoverGuiAction: delegate
                        {
                            TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(200, 200)),
                                                     returnPolicyText(trait));
                        }));
                    }

                    Find.WindowStack.Add(new FloatMenu(list));
                }
            }

            if (Mouse.IsOver(trait_2) && faction.factionTraits[1].def != FCPolicyDefOf.empty)
            {
                TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(200, 200)),
                                         returnPolicyText(faction.factionTraits[1].def));
            }
            //End Trait Slot

            //TraitSlot
            if (Widgets.ButtonTextSubtle(trait_3, returnTraitAvailibility(3, faction.factionTraits[2]))) //CHANGE THIS
            {
                if (canChangeTrait(3, faction.factionTraits[2]))
                {
                    foreach (FCPolicyDef trait in available)
                    {
                        list.Add(new FloatMenuOption(trait.label, delegate
                        {
                            List <FloatMenuOption> confirm = new List <FloatMenuOption>();
                            confirm.Add(new FloatMenuOption("FCConfirmTrait".Translate(trait.label),
                                                            delegate { faction.factionTraits[2] = new FCPolicy(trait); }));
                            Find.WindowStack.Add(new FloatMenu(confirm));
                        },
                                                     mouseoverGuiAction: delegate
                        {
                            TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(300, 200)),
                                                     returnPolicyText(trait));
                        }));
                    }

                    Find.WindowStack.Add(new FloatMenu(list));
                }
            }

            if (Mouse.IsOver(trait_3) && faction.factionTraits[2].def != FCPolicyDefOf.empty)
            {
                TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(300, 200)),
                                         returnPolicyText(faction.factionTraits[2].def));
            }
            //End Trait Slot

            //TraitSlot
            if (Widgets.ButtonTextSubtle(trait_4, returnTraitAvailibility(4, faction.factionTraits[3]))) //CHANGE THIS
            {
                if (canChangeTrait(4, faction.factionTraits[3]))
                {
                    foreach (FCPolicyDef trait in available)
                    {
                        list.Add(new FloatMenuOption(trait.label, delegate
                        {
                            List <FloatMenuOption> confirm = new List <FloatMenuOption>();
                            confirm.Add(new FloatMenuOption("FCConfirmTrait".Translate(trait.label),
                                                            delegate { faction.factionTraits[3] = new FCPolicy(trait); }));
                            Find.WindowStack.Add(new FloatMenu(confirm));
                        },
                                                     mouseoverGuiAction: delegate
                        {
                            TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(400, 200)),
                                                     returnPolicyText(trait));
                        }));
                    }

                    Find.WindowStack.Add(new FloatMenu(list));
                }
            }

            if (Mouse.IsOver(trait_4) && faction.factionTraits[3].def != FCPolicyDefOf.empty)
            {
                TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(400, 200)),
                                         returnPolicyText(faction.factionTraits[3].def));
            }
            //End Trait Slot

            //TraitSlot
            if (Widgets.ButtonTextSubtle(trait_5, returnTraitAvailibility(5, faction.factionTraits[4]))) //CHANGE THIS
            {
                if (canChangeTrait(5, faction.factionTraits[4]))
                {
                    foreach (FCPolicyDef trait in available)
                    {
                        list.Add(new FloatMenuOption(trait.label, delegate
                        {
                            List <FloatMenuOption> confirm = new List <FloatMenuOption>();
                            confirm.Add(new FloatMenuOption("FCConfirmTrait".Translate(trait.label),
                                                            delegate { faction.factionTraits[4] = new FCPolicy(trait); }));
                            Find.WindowStack.Add(new FloatMenu(confirm));
                        },
                                                     mouseoverGuiAction: delegate
                        {
                            TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(500, 200)),
                                                     returnPolicyText(trait));
                        }));
                    }

                    Find.WindowStack.Add(new FloatMenu(list));
                }
            }

            if (Mouse.IsOver(trait_5) && faction.factionTraits[4].def != FCPolicyDefOf.empty)
            {
                TooltipHandler.TipRegion(new Rect(Event.current.mousePosition, new Vector2(500, 200)),
                                         returnPolicyText(faction.factionTraits[4].def));
            }
            //End Trait Slot

            FactionFC fc = Find.World.GetComponent <FactionFC>();

            Widgets.Label(roadBuilding, "FCBuildRoads".Translate());
            Widgets.Checkbox(roadBuilding.x + roadBuilding.width + 5, roadBuilding.y,
                             ref fc.roadBuilder.roadBuildingEnabled);

            //SettlementBox


            Widgets.DrawMenuSection(settlementsBox);
            Text.Font   = GameFont.Tiny;
            Text.Anchor = TextAnchor.MiddleCenter;
            GUI.BeginGroup(settlementsBoxLabels);
            Widgets.DrawMenuSection(new Rect(0, 0, settlementsBox.width, 20));
            Widgets.DrawLightHighlight(new Rect(0, 0, settlementsBox.width, 20));
            Widgets.Label(settlement_1, "Name");
            if (Widgets.ButtonInvisible(settlement_1))
            {
                faction.settlements.Sort(FactionColonies.CompareSettlementName);
            }

            Widgets.Label(settlement_2, "Level");
            if (Widgets.ButtonInvisible(settlement_2))
            {
                faction.settlements.Sort(FactionColonies.CompareSettlementLevel);
            }

            Widgets.Label(settlement_3, "Mil Level");
            if (Widgets.ButtonInvisible(settlement_3))
            {
                faction.settlements.Sort(FactionColonies.CompareSettlementMilitaryLevel);
            }

            Widgets.Label(settlement_4, "Profit");
            if (Widgets.ButtonInvisible(settlement_4))
            {
                faction.settlements.Sort(FactionColonies.CompareSettlementProfit);
            }

            Widgets.Label(settlement_5, "Free Workers");
            if (Widgets.ButtonInvisible(settlement_5))
            {
                faction.settlements.Sort(FactionColonies.CompareSettlementFreeWorkers);
            }

            Widgets.Label(settlement_6, "Happiness");
            if (Widgets.ButtonInvisible(settlement_6))
            {
                faction.settlements.Sort(FactionColonies.CompareSettlementHappiness);
            }

            Widgets.Label(settlement_7, "Loyalty");
            if (Widgets.ButtonInvisible(settlement_7))
            {
                faction.settlements.Sort(FactionColonies.CompareSettlementLoyalty);
            }

            Widgets.Label(settlement_8, "Unrest");
            if (Widgets.ButtonInvisible(settlement_8))
            {
                faction.settlements.Sort(FactionColonies.CompareSettlementUnrest);
            }


            GUI.EndGroup();


            GUI.BeginGroup(settlementsBox);

            for (int i = 0; i < faction.settlements.Count(); i++)
            {
                SettlementFC settlement = faction.settlements[i];

                //settlement name
                if (Widgets.ButtonTextSubtle(AdjustRect(settlement_1, i), settlement.name))
                {
                    Find.WindowStack.Add(new SettlementWindowFc(settlement));
                }

                Text.Font   = GameFont.Tiny;
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(AdjustRect(settlement_2, i), settlement.settlementLevel.ToString());
                Widgets.Label(AdjustRect(settlement_3, i), settlement.settlementMilitaryLevel.ToString());
                Widgets.Label(AdjustRect(settlement_4, i), settlement.getTotalProfit().ToString());
                Widgets.Label(AdjustRect(settlement_5, i),
                              (settlement.workersUltraMax - settlement.getTotalWorkers()).ToString());
                Widgets.Label(AdjustRect(settlement_6, i), settlement.Happiness.ToString());
                Widgets.Label(AdjustRect(settlement_7, i), settlement.Loyalty.ToString());
                Widgets.Label(AdjustRect(settlement_8, i), settlement.Unrest.ToString());
            }

            GUI.EndGroup();


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

            if (Event.current.type == EventType.ScrollWheel)
            {
                scrollWindow(Event.current.delta.y);
            }
        }