コード例 #1
0
 //public static void TipRegion(Rect rect, TipSignal tip)
 public static void NoTipRegion(Rect rect, TipSignal tip)
 {
     if (!Settings.Get().pawnTableClickSelect)
     {
         TooltipHandler.TipRegion(rect, tip);
     }
 }
コード例 #2
0
        /*[HarmonyPostfix]
         * public static void DrawCharacterCard_Postfix(Rect rect, Pawn pawn, Action randomizeCallback = null, Rect creationRect = default(Rect))
         * {
         *  float num = CharacterCardUtility.PawnCardSize.x - 182f;
         *  Rect rect0 = new Rect(num, 0f, 30f, 60f);
         *  IndividualityCardButton(rect0, pawn);
         * }*/

        public static void IndividualityCardButton(Rect rect, Pawn pawn, Rect creationRect)
        {
            if (pawn != null)
            {
                TipSignal tooltip = "IndividualityTooltip".Translate();
                float     num     = CharacterCardUtility.BasePawnCardSize.x - 160f;
                //Move if royalty title button is active
                if (pawn.IsFreeColonist && !pawn.IsQuestLodger() && pawn.royalty != null && pawn.royalty.AllTitlesForReading.Count > 0)
                {
                    num -= 40f;
                }
                Rect rectNew = new Rect(num, 1f, 24f, 24f);
                if (Current.ProgramState != ProgramState.Playing)
                {
                    rectNew = new Rect(creationRect.width - 24f, 80f, 24f, 24f);
                }
                Color old = GUI.color;
                if (rectNew.Contains(Event.current.mousePosition))
                {
                    GUI.color = new Color(0.25f, 0.59f, 0.75f);
                }
                else
                {
                    GUI.color = new Color(1f, 1f, 1f);
                }
                GUI.DrawTexture(rectNew, ContentFinder <Texture2D> .Get("Buttons/Individuality", true));
                TooltipHandler.TipRegion(rectNew, tooltip);
                if (Widgets.ButtonInvisible(rectNew))
                {
                    SoundDefOf.InfoCard_Open.PlayOneShotOnCamera(null);
                    Find.WindowStack.Add(new Dialog_ViewIndividuality(pawn));
                }
                GUI.color = old;
            }
        }
コード例 #3
0
        public void OnGUI(float positionX, ref float positionY, float width)
        {
            bool   disabled = this.Disabled;
            float  num      = (!this.Indent) ? 0f : Dialog_InterfaceOptions.IndentSize;
            string label    = this.Label;
            float  num2     = Text.CalcHeight(label, width - BooleanPreference.LabelMargin - num);
            Rect   rect     = new Rect(positionX - 4f + num, positionY - 3f, width + 6f - num, num2 + 5f);

            if (Mouse.IsOver(rect))
            {
                Widgets.DrawHighlight(rect);
            }
            Rect rect2 = new Rect(positionX + num, positionY, width - BooleanPreference.LabelMargin - num, num2);

            if (disabled)
            {
                GUI.color = Dialog_InterfaceOptions.DisabledControlColor;
            }
            GUI.Label(rect2, label);
            GUI.color = Color.white;
            if (this.Tooltip != null)
            {
                TipSignal tip = new TipSignal(() => this.Tooltip.Translate(), this.TooltipId);
                TooltipHandler.TipRegion(rect2, tip);
            }
            bool valueForDisplay = this.ValueForDisplay;

            Widgets.Checkbox(new Vector2(positionX + width - BooleanPreference.CheckboxWidth, positionY - 2f), ref valueForDisplay, 24f, disabled);
            this.Value = valueForDisplay;
            positionY += num2;
        }
コード例 #4
0
        public static void DrawText(Rect rect, string text, Color?color = null, TextStyle style = null, TextAnchor?alignment = null, TipSignal?tooltip = null)
        {
            if (text.NullOrEmpty())
            {
                return;
            }

            SetColor(color);
            var textRect  = rect;
            var textStyle = (style?.GUIStyle ?? Text.CurFontStyle).SetTo(alignment: alignment);

            var content = new GUIContent(text);

            if (textStyle.CalcSize(content).x > rect.width)
            {
                content.text = "...";
                var ellipsesLength = textStyle.CalcSize(content);
                textRect.width -= ellipsesLength.x;
                GUI.Label(new Rect(rect.RightPartPixels(ellipsesLength.x)), content.text, textStyle);
                if (tooltip == null)
                {
                    tooltip = new TipSignal(text.Size(textStyle.fontSize));
                }
            }

            GUI.Label(textRect, text, textStyle);
            DrawTooltip(rect, tooltip, false);
            ResetColor();
        }
コード例 #5
0
        private void DrawMorphTraitsList(ref Vector2 curPos, float width)
        {
            var aspectTracker = PawnToShowMutationsFor.GetAspectTracker();

            if (aspectTracker != null)
            {
                foreach (Aspect aspect in aspectTracker.Aspects)
                {
                    var  label = aspect.Label.CapitalizeFirst();
                    Rect rect  = new Rect(curPos.x, curPos.y, width, Text.CalcHeight(label, width));

                    if (Mouse.IsOver(rect))
                    {
                        Widgets.DrawHighlight(rect);
                    }

                    GUI.color = aspect.def.labelColor;
                    Widgets.Label(rect, label);
                    curPos.y += rect.height;
                    GUI.color = Color.white;

                    TipSignal tip = new TipSignal(() => aspect.TipString(PawnToShowMutationsFor), (int)curPos.y * 37);
                    TooltipHandler.TipRegion(rect, tip);
                }
            }
        }
        //public static string nameNick = "AIRobot_Basename_nick";
        //public static string nameLast = "AIRobot_Basename_last";

        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            if (Widgets.ButtonImage(rect, texRename))
            {
                // disabled if not active
                if (pawn == null || !pawn.Spawned)
                {
                    return;
                }

                if (pawn.Name == null)
                {
                    NameTriple name = new NameTriple(nameFirst.Translate(), pawn.Label, pawn.Label);
                    pawn.Name = name;
                }

                //Log.Error(pawn == null ? "pawn==null" : pawn.Label);
                //Log.Error(pawn.Name == null ? "pawn.Name==null" : pawn.Name as NameTriple == null ? "pawn.Name as NameTriple==null" : (pawn.Name as NameTriple).Nick);

                //Find.WindowStack.Add( new Dialog_ChangeNameTriple(pawn) );
                Find.WindowStack.Add(new X2_Dialog_ChangeNameTriple_Robots(pawn));
            }
            if (Mouse.IsOver(rect))
            {
                GUI.DrawTexture(rect, TexUI.HighlightTex);
            }
            TipSignal tooltip = pawn.Label;

            tooltip.text = "AIRobot_RenameRobot".Translate();
            TooltipHandler.TipRegion(rect, tooltip);
        }
コード例 #7
0
        public override TipSignal GetTooltip()
        {
            TipSignal tip = base.GetTooltip();

            tip.text += "\n" + DroidPawn.StoredEnergyText(this);
            return(tip);
        }
コード例 #8
0
        public bool DoGUI_Label(Rect rect)
        {
            bool    commandIsTriggered = false;
            KeyCode keyCode            = (gizmo.hotKey != null) ? gizmo.hotKey.MainKey : KeyCode.None;

            if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                Rect rect2 = new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f);
                Widgets.Label(rect2, keyCode.ToStringReadable());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (gizmo.hotKey.KeyDownEvent)
                {
                    commandIsTriggered = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(rect, false))
            {
                commandIsTriggered = true;
            }

            string labelCap = gizmo.LabelCap;

            if (!labelCap.NullOrEmpty())
            {
                float num   = Text.CalcHeight(labelCap, rect.width);
                Rect  rect3 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num);
                GUI.DrawTexture(rect3, TexUI.GrayTextBG);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect3, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
            }

            GUI.color = Color.white;
            if ((bool)Designator_Build_DoToolTip_PropertyInfo.GetValue(gizmo, null))
            {
                TipSignal tip = gizmo.Desc;
                if (gizmo.disabled && !gizmo.disabledReason.NullOrEmpty())
                {
                    string text = tip.text;
                    tip.text = string.Concat(new string[]
                    {
                        text,
                        "\n\n",
                        "DisabledCommand".Translate(),
                        ": ",
                        gizmo.disabledReason
                    });
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (!gizmo.HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null ||
                                                      !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, gizmo.HighlightTag);
            }
            return(commandIsTriggered);
        }
コード例 #9
0
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            Rect rect2 = new Rect(rect.x, rect.y, rect.width, Mathf.Min(rect.height, 30f));

            if (pawn.health.summaryHealth.SummaryHealthPercent < 0.99f)
            {
                Rect rect3 = new Rect(rect2);
                rect3.xMin -= 4f;
                rect3.yMin += 4f;
                rect3.yMax -= 6f;
                Widgets.FillableBar(rect3, pawn.health.summaryHealth.SummaryHealthPercent, GenMapUI.OverlayHealthTex, BaseContent.ClearTex, false);
            }
            if (Mouse.IsOver(rect2))
            {
                GUI.DrawTexture(rect2, TexUI.HighlightTex);
            }

            string str;

            if (!pawn.RaceProps.Humanlike && pawn.Name != null && !pawn.Name.Numerical)
            {
                str = pawn.Name.ToStringShort.CapitalizeFirst() + ", " + pawn.KindLabel;
            }
            else
            {
                str = pawn.LabelCap;
            }
            Rect rect4 = rect2;

            rect4.xMin += 3f;
            if (rect4.width != labelCacheForWidth)
            {
                labelCacheForWidth = rect4.width;
                labelCache.Clear();
            }
            Text.Font     = GameFont.Small;
            Text.Anchor   = TextAnchor.MiddleLeft;
            Text.WordWrap = false;
            Widgets.Label(rect4, str.Truncate(rect4.width, labelCache));
            Text.WordWrap = true;
            Text.Anchor   = TextAnchor.UpperLeft;
            if (Widgets.ButtonInvisible(rect2, false))
            {
                CameraJumper.TryJumpAndSelect(pawn);
                if (Current.ProgramState == ProgramState.Playing && Event.current.button == 0)
                {
                    Find.MainTabsRoot.EscapeCurrentTab(false);
                }
                return;
            }
            TipSignal tooltip = pawn.GetTooltip();

            tooltip.text = "ClickToJumpTo".Translate() + "\n\n" + tooltip.text;
            TooltipHandler.TipRegion(rect2, tooltip);
        }
コード例 #10
0
        public static void TipRegionAltMethod(Rect rect, TipSignal tip)
        {
            string text = tip.textGetter();

            if (accuracyInt >= 1)
            {
                text += "\nCurrent game tick: " + Find.TickManager.TicksGame;
            }
            tip.textGetter = () => text;
            TooltipHandler.TipRegion(rect, tip);
        }
コード例 #11
0
 public static void DrawFactionIconWithTooltip(Rect r, Faction faction)
 {
     GUI.color = faction.Color;
     GUI.DrawTexture(r, faction.def.FactionIcon);
     GUI.color = Color.white;
     if (Mouse.IsOver(r))
     {
         TipSignal tip = new TipSignal(() => faction.Name + "\n\n" + faction.def.description, faction.loadID ^ 0x738AC053);
         TooltipHandler.TipRegion(r, tip);
         Widgets.DrawHighlight(r);
     }
 }
コード例 #12
0
        private void DrawFleetMember(ref float curX, float curY, ShipBase ship)
        {
            Rect buttonRect = new Rect(curX, curY, 20f, 20f);

            GUI.DrawTexture(buttonRect, ship.compShip.fleetIconTexture);
            if (Mouse.IsOver(buttonRect))
            {
                Rect      rect = new Rect(buttonRect.x, buttonRect.y, 100f, 30f);
                TipSignal tip  = ship.LabelCap + " : " + ship.ShipNick;
                TooltipHandler.TipRegion(rect, tip);
            }
            curX += 30f;
        }
        public void OnGUI(float positionX, ref float positionY, float width)
        {
            bool disabled = this.Disabled;

            if (disabled)
            {
                GUI.color = Dialog_InterfaceOptions.DisabledControlColor;
            }
            if (!string.IsNullOrEmpty(this.Name))
            {
                string text = this.Name.Translate();
                float  num  = Text.CalcHeight(text, width);
                Rect   rect = new Rect(positionX, positionY, width, num);
                Widgets.Label(rect, text);
                if (this.Tooltip != null)
                {
                    TipSignal tip = new TipSignal(() => this.Tooltip.Translate(), this.TooltipId);
                    TooltipHandler.TipRegion(rect, tip);
                }
                positionY += num + Dialog_InterfaceOptions.PreferencePadding.y;
            }
            float num2 = (!this.Indent) ? 0f : Dialog_InterfaceOptions.IndentSize;

            foreach (string current in this.OptionValues)
            {
                string text2 = this.OptionTranslated(current);
                if (!string.IsNullOrEmpty(text2))
                {
                    float num3  = Text.CalcHeight(text2, width - MultipleSelectionStringOptionsPreference.LabelMargin - num2);
                    Rect  rect2 = new Rect(positionX - 4f + num2, positionY - 3f, width + 6f - num2, num3 + 5f);
                    if (Mouse.IsOver(rect2))
                    {
                        Widgets.DrawHighlight(rect2);
                    }
                    Rect rect3 = new Rect(positionX + num2, positionY, width - num2, num3);
                    bool flag  = this.IsOptionSelected(current);
                    bool flag2 = flag;
                    WidgetDrawer.DrawLabeledCheckbox(rect3, text2, ref flag);
                    if (flag != flag2)
                    {
                        this.UpdateOption(current, flag);
                    }
                    positionY += num3 + Dialog_InterfaceOptions.PreferencePadding.y;
                }
            }
            positionY -= Dialog_InterfaceOptions.PreferencePadding.y;
            GUI.color  = Color.white;
        }
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            TipSignal tooltip = pawn.Label;

            // normal mode
            if (pawn != null && !pawn.Destroyed && pawn.Spawned)
            {
                if (Widgets.ButtonImage(rect, texNotRecharging))
                {
                    X2_AIRobot robot = pawn as X2_AIRobot;
                    //if (robot != null && robot.rechargeStation != null)
                    //    robot.rechargeStation.Notify_CallBotForShutdown();

                    CameraJumper.TryJumpAndSelect(robot);
                }
            }
            // Is recharging
            else if (pawn != null && !pawn.Destroyed && !pawn.Spawned)
            {
                if (Widgets.ButtonImage(rect, texRecharging))
                {
                    X2_AIRobot robot = pawn as X2_AIRobot;
                    //if (robot != null && robot.rechargeStation != null)
                    //    robot.rechargeStation.Notify_SpawnBot();  <-- ERROR: Creates a NEW robot wich causes ERRORS!!!

                    if (robot != null && robot.rechargeStation != null)
                    {
                        if (Current.ProgramState == ProgramState.Playing && Event.current.button == 0)
                        {
                            Find.MainTabsRoot.EscapeCurrentTab(false);
                        }

                        CameraJumper.TryJumpAndSelect(robot.rechargeStation);
                    }
                }
                tooltip.text = "AIRobot_RobotIsRecharging".Translate() + "\n" + pawn.Label;
            }
            if (Mouse.IsOver(rect))
            {
                GUI.DrawTexture(rect, TexUI.HighlightTex);
            }

            TooltipHandler.TipRegion(rect, tooltip);
        }
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            if (Widgets.ButtonImage(rect, texShutDown))
            {
                X2_AIRobot robot = pawn as X2_AIRobot;
                if (robot != null && robot.rechargeStation != null)
                {
                    robot.rechargeStation.Notify_CallBotForShutdown();
                }
            }
            if (Mouse.IsOver(rect))
            {
                GUI.DrawTexture(rect, TexUI.HighlightTex);
            }
            TipSignal tooltip = pawn.Label;

            tooltip.text = "AIRobot_ShutDownRobot".Translate() + "\n" + pawn.Label;
            TooltipHandler.TipRegion(rect, tooltip);
        }
コード例 #16
0
        private void PreDrawPawnRow(Rect rect, Pawn p)
        {
            Rect position = new Rect(0f, rect.y, rect.width, 30f);

            if (position.Contains(Event.current.mousePosition))
            {
                GUI.DrawTexture(position, TexUI.HighlightTex);
            }
            Rect rect2     = new Rect(0f, rect.y, 175f, 30f);
            Rect position2 = rect2.ContractedBy(3f);

            if (p.health.summaryHealth.SummaryHealthPercent < 0.99f)
            {
                Rect screenRect = new Rect(rect2);
                screenRect.xMin -= 4f;
                screenRect.yMin += 4f;
                screenRect.yMax -= 6f;
                Widgets.FillableBar(screenRect, p.health.summaryHealth.SummaryHealthPercent, PawnUIOverlay.HealthTex, BaseContent.ClearTex, false);
            }
            if (rect2.Contains(Event.current.mousePosition))
            {
                GUI.DrawTexture(position2, TexUI.HighlightTex);
            }
            Text.Font   = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleLeft;
            Rect rect3 = new Rect(rect2);

            rect3.xMin += 15f;
            Widgets.Label(rect3, p.LabelCap);
            if (Widgets.InvisibleButton(rect2))
            {
                Find.LayerStack.TopLayerOfType <Dialog_Overview>().Close(true);
                Find.CameraMap.JumpTo(p.Position);
                Find.Selector.ClearSelection();
                Find.Selector.Select(p, true);
                return;
            }
            TipSignal tooltip = p.GetTooltip();

            tooltip.text = "ClickToJumpTo".Translate() + "\n\n" + tooltip.text;
            TooltipHandler.TipRegion(rect2, tooltip);
        }
コード例 #17
0
        public void DispenseAllThingTooltips(TooltipGiverList __instance)
        {
            if (Event.current.type != EventType.Repaint || Find.WindowStack.FloatMenu != null)
            {
                return;
            }

            CellRect currentViewRect = Find.CameraDriver.CurrentViewRect;
            float    cellSizePixels  = Find.CameraDriver.CellSizePixels;
            Vector2  vector          = new Vector2(cellSizePixels, cellSizePixels);
            Rect     rect            = new Rect(0f, 0f, vector.x, vector.y);
            int      num             = 0;

            for (int i = 0; i < givers(__instance).Count; i++)
            {
                Thing thing = givers(__instance)[i];
                if (!currentViewRect.Contains(thing.Position) || thing.Position.Fogged(thing.Map))
                {
                    continue;
                }

                Vector2 vector2 = thing.DrawPos.MapToUIPosition();
                rect.x = vector2.x - vector.x / 2f;
                rect.y = vector2.y - vector.y / 2f;
                if (rect.Contains(Event.current.mousePosition))
                {
                    string text = null;//ShouldShowShotReport(thing) ? TooltipUtility.ShotCalculationTipString(thing) : null;
                    if (thing.def.hasTooltip || !text.NullOrEmpty())
                    {
                        TipSignal tooltip = thing.GetTooltip();
                        if (!text.NullOrEmpty())
                        {
                            ref string text2 = ref tooltip.text;
                            text2 = text2 + "\n\n" + text;
                        }

                        TooltipHandler.TipRegion(rect, tooltip);
                    }
                }

                num++;
            }
コード例 #18
0
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            base.DoCell(rect, pawn, table);
            Rect rect2 = new Rect(rect.x, rect.y, rect.width, Mathf.Min(rect.height, 30f));

            if (Widgets.ButtonInvisible(rect2))
            {
                CameraJumper.TryJumpAndSelect(pawn);
                if (Current.ProgramState == ProgramState.Playing && Event.current.button == 0)
                {
                    Find.MainTabsRoot.EscapeCurrentTab(playSound: false);
                }
            }
            else
            {
                TipSignal tooltip = pawn.GetTooltip();
                tooltip.text = "ClickToJumpTo".Translate() + "\n\n" + tooltip.text;
                TooltipHandler.TipRegion(rect2, tooltip);
            }
        }
コード例 #19
0
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            if (Widgets.ButtonImage(rect, texShutDown))
            {
                List <X2_Building_AIRobotRechargeStation> buildings = pawn.Map.listerThings.AllThings.OfType <X2_Building_AIRobotRechargeStation>().ToList();
                for (int i = buildings.Count; i > 0; i--)
                {
                    X2_Building_AIRobotRechargeStation building = buildings[i - 1];
                    building.Notify_CallBotForShutdown();
                }
            }
            if (Mouse.IsOver(rect))
            {
                GUI.DrawTexture(rect, TexUI.HighlightTex);
            }
            TipSignal tooltip = pawn.Label;

            tooltip.text = "AIRobot_ShutDownAllRobots".Translate();
            TooltipHandler.TipRegion(rect, tooltip);
        }
コード例 #20
0
        public override void DoCell(Rect rect, Pawn pawn, PawnTable table)
        {
            Rect rect2 = new Rect(rect.x, rect.y, rect.width, Mathf.Min(rect.height, 30f));

            if (Mouse.IsOver(rect2))
            {
                GUI.DrawTexture(rect2, TexUI.HighlightTex);
            }
            var kind = pawn.kindDef as CustomPawnKindDef;

            string str   = kind.objectClass.GetObjectClassString();
            Rect   rect4 = rect2;

            rect4.xMin += 3f;
            if (rect4.width != labelCacheForWidth)
            {
                labelCacheForWidth = rect4.width;
                labelCache.Clear();
            }
            Text.Font     = GameFont.Small;
            Text.Anchor   = TextAnchor.MiddleLeft;
            Text.WordWrap = false;
            Widgets.Label(rect4, str.Truncate(rect4.width, labelCache));
            Text.WordWrap = true;
            Text.Anchor   = TextAnchor.UpperLeft;
            if (Widgets.ButtonInvisible(rect2))
            {
                CameraJumper.TryJumpAndSelect(pawn);
                if (Current.ProgramState == ProgramState.Playing && Event.current.button == 0)
                {
                    Find.MainTabsRoot.EscapeCurrentTab(playSound: false);
                }
            }
            else
            {
                TipSignal tooltip = pawn.GetTooltip();
                tooltip.text = kind.objectClass.GetObjectClassDesc();
                TooltipHandler.TipRegion(rect2, tooltip);
            }
        }
コード例 #21
0
        private void DoFactionInfo(Rect rect, Faction faction, ref float curX, ref float curY, ref int index)
        {
            if (index % 2 == 1)
            {
                Widgets.DrawLightHighlight(new Rect(curX, curY, rect.width, 45f));
            }
            FactionUIUtility.DrawFactionIconWithTooltip(new Rect(curX, curY + 5f, 35f, 35f), faction);
            curX += 45f;
            Rect rect2 = new Rect(curX, curY, 250f, 45f);

            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(rect2, faction.Name);
            Text.Anchor = TextAnchor.UpperLeft;
            curX       += 250f;
            if (Mouse.IsOver(rect2))
            {
                TipSignal tip = new TipSignal(() => faction.Name + "\n\n" + faction.def.description + "\n\n" + faction.PlayerRelationKind.GetLabel().Colorize(faction.PlayerRelationKind.GetColor()), faction.loadID ^ 0x4468077);
                TooltipHandler.TipRegion(rect2, tip);
                Widgets.DrawHighlight(rect2);
            }
            index++;
        }
コード例 #22
0
        // Token: 0x060043EB RID: 17387 RVA: 0x0016B798 File Offset: 0x00169998
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth, GizmoRenderParms parms)
        {
            Rect        rect   = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);
            GizmoResult result = base.GizmoOnGUI(topLeft, maxWidth, parms);

            if (this.comp.CooldownTicksRemaining > 0)
            {
                //	float num = Mathf.InverseLerp((float)this.comp.CooldownTicksTotal, 0f, (float)this.comp.CooldownTicksRemaining);
                float num  = Mathf.InverseLerp(0f, (float)this.comp.CooldownTicksTotal, (float)this.comp.CooldownTicksRemaining);
                var   math = (float)this.comp.CooldownTicksRemaining / (float)this.comp.CooldownTicksTotal;
                //	Widgets.FillableBar(rect, Mathf.Clamp01(num), Command_ApparelWargear.cooldownBarTex, null, false);
                AdeptusWidgets.VertFillableBar(rect, Mathf.Clamp01(num), AbilityButtons.FullTex, AbilityButtons.EmptyTex, false);

                /*
                 * if (this.comp.CooldownTicksRemaining > 0)
                 * {
                 *      Text.Font = GameFont.Tiny;
                 *      Text.Anchor = TextAnchor.UpperCenter;
                 * //	Widgets.Label(rect, num.ToStringPercent("F0"));
                 *      Widgets.Label(rect, this.comp.CooldownTicksRemaining.TicksToSeconds().ToString("F2"));
                 *      Text.Anchor = TextAnchor.UpperLeft;
                 * }
                 */
            }
            if (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    tip.text = tip.text + "AU_DISABLED".Translate() + ": " + disabledReason + "\n" + comp.CooldownTicksRemaining.ToStringSecondsFromTicks();
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (result.State == GizmoState.Interacted && this.comp.CanBeUsed)
            {
                return(result);
            }
            return(new GizmoResult(result.State));
        }
コード例 #23
0
ファイル: GUIPlus.cs プロジェクト: Jaxe-Dev/RimHUD
        public static void DrawTooltip(Rect rect, Func <string> tooltip, bool highlight, int uniqueId = TooltipId)
        {
            if (tooltip == null || !Mouse.IsOver(rect))
            {
                return;
            }

            var text = tooltip?.Invoke();

            if (text == null)
            {
                return;
            }

            var tipSignal = new TipSignal(text, uniqueId);

            if (highlight)
            {
                Widgets.DrawHighlight(rect);
            }
            TooltipHandler.TipRegion(rect, tipSignal);
        }
コード例 #24
0
        public static bool DrawToggle(Command command, Rect butRect, bool shrunk)
        {
            if (shrunk)
            {
                return(false);
            }
            if (!(command is Command_VerbTarget gizmo))
            {
                return(false);
            }
            var verb = gizmo.verb;
            var man  = gizmo.verb?.CasterPawn?.Manager()?.GetManagedVerbForVerb(verb, false);

            if (man?.Props == null || man.Props.separateToggle)
            {
                return(false);
            }
            var rect = command.TopRightLabel.NullOrEmpty()
                ? butRect.RightPart(0.35f).TopPart(0.35f)
                : butRect
                       .LeftPart(0.35f).TopPart(0.35f);

            if (Mouse.IsOver(rect))
            {
                TipSignal sig = "MVCF.ToggleAuto".Translate();
                TooltipHandler.TipRegion(rect, sig);
            }

            if (Widgets.ButtonImage(rect,
                                    man.Enabled ? Widgets.CheckboxOnTex : Widgets.CheckboxOffTex))
            {
                Event.current.Use();
                man.Enabled = !man.Enabled;
                return(true);
            }

            return(false);
        }
コード例 #25
0
        public void OnGUI(float positionX, ref float positionY, float width)
        {
            bool disabled = this.Disabled;

            if (disabled)
            {
                GUI.color = Dialog_InterfaceOptions.DisabledControlColor;
            }
            float num = (!this.Indent) ? 0f : Dialog_InterfaceOptions.IndentSize;

            foreach (string current in this.OptionValues)
            {
                string text = (this.OptionValuePrefix + "." + current).Translate();
                float  num2 = Text.CalcHeight(text, width - StringOptionsPreference.LabelMargin - num);
                Rect   rect = new Rect(positionX - 4f + num, positionY - 3f, width + 6f - num, num2 + 5f);
                if (Mouse.IsOver(rect))
                {
                    Widgets.DrawHighlight(rect);
                }
                Rect rect2 = new Rect(positionX + num, positionY, width - StringOptionsPreference.LabelMargin - num, num2);
                GUI.Label(rect2, text);
                if (this.Tooltip != null)
                {
                    TipSignal tip = new TipSignal(() => this.Tooltip.Translate(), this.TooltipId);
                    TooltipHandler.TipRegion(rect2, tip);
                }
                string valueForDisplay = this.ValueForDisplay;
                bool   chosen          = valueForDisplay == current;
                if (Widgets.RadioButton(new Vector2(positionX + width - StringOptionsPreference.RadioButtonWidth, positionY - 3f), chosen) && !disabled)
                {
                    this.Value = current;
                }
                positionY += num2 + Dialog_InterfaceOptions.PreferencePadding.y;
            }
            positionY -= Dialog_InterfaceOptions.PreferencePadding.y;
            GUI.color  = Color.white;
        }
コード例 #26
0
ファイル: PNC_Card.cs プロジェクト: keenkrozzy/Prophecy
        private void DoTraits()
        {
            // Shape Traits area
            float floSkillsX      = rectCard.width * .85f;
            float floSkillsY      = rectCard.height * .5f;
            float floSkillsWidth  = rectCard.width * .125f;
            float floSkillsHeight = rectCard.height * .25f;
            float floTextHeight   = floSkillsHeight / 4f;
            float floAdjustY      = 0f;

            Text.Font = GameFont.Medium;
            Rect rectTraits = new Rect(floSkillsX, floSkillsY, Text.CalcSize("Traits").x, floTextHeight);

            Widgets.Label(KrozzyUtilities.RectAddition(rectTraits, rectCard), "Traits".Translate());
            Text.Font   = GameFont.Small;
            floAdjustY += floTextHeight;

            Text.Anchor = TextAnchor.MiddleLeft;
            for (int i = 0; i < pawn.story.traits.allTraits.Count; i++)
            {
                Trait trait     = pawn.story.traits.allTraits[i];
                Rect  rectTrait = new Rect(floSkillsX, floSkillsY + floAdjustY, Text.CalcSize(trait.LabelCap).x, floTextHeight);
                if (Mouse.IsOver(KrozzyUtilities.RectAddition(rectTrait, rectCard)))
                {
                    Widgets.DrawHighlight(KrozzyUtilities.RectAddition(rectTrait, rectCard));
                }
                Widgets.Label(KrozzyUtilities.RectAddition(rectTrait, rectCard), trait.LabelCap);
                Trait     trLocal = trait;
                TipSignal tip     = new TipSignal(() => trLocal.TipString(pawn), (int)floAdjustY * 17);
                TooltipHandler.TipRegion(KrozzyUtilities.RectAddition(rectTrait, rectCard), tip);

                floAdjustY += floTextHeight;
            }

            Text.Anchor = TextAnchor.UpperLeft;
        }
コード例 #27
0
        public static void DrawCharacterCard(Rect rect, Pawn pawn, Action randomizeCallback = null, Rect creationRect = default(Rect))
        {
            bool creationMode = randomizeCallback != null;

            GUI.BeginGroup(creationMode ? creationRect : rect);
            Rect       rect2      = new Rect(0f, 0f, 300f, 30f);
            NameTriple nameTriple = pawn.Name as NameTriple;

            if (creationMode && nameTriple != null)
            {
                Rect rect3 = new Rect(rect2);
                rect3.width *= 0.333f;
                Rect rect4 = new Rect(rect2);
                rect4.width *= 0.333f;
                rect4.x     += rect4.width;
                Rect rect5 = new Rect(rect2);
                rect5.width *= 0.333f;
                rect5.x     += rect4.width * 2f;
                string name  = nameTriple.First;
                string name2 = nameTriple.Nick;
                string name3 = nameTriple.Last;
                DoNameInputRect(rect3, ref name, 12);
                if (nameTriple.Nick == nameTriple.First || nameTriple.Nick == nameTriple.Last)
                {
                    GUI.color = new Color(1f, 1f, 1f, 0.5f);
                }
                DoNameInputRect(rect4, ref name2, 16);
                GUI.color = Color.white;
                DoNameInputRect(rect5, ref name3, 12);
                if (nameTriple.First != name || nameTriple.Nick != name2 || nameTriple.Last != name3)
                {
                    pawn.Name = new NameTriple(name, string.IsNullOrEmpty(name2) ? name : name2, name3);
                }
                TooltipHandler.TipRegionByKey(rect3, "FirstNameDesc");
                TooltipHandler.TipRegionByKey(rect4, "ShortIdentifierDesc");
                TooltipHandler.TipRegionByKey(rect5, "LastNameDesc");
            }
            else
            {
                rect2.width = 999f;
                Text.Font   = GameFont.Medium;
                Widgets.Label(rect2, pawn.Name.ToStringFull);
                Text.Font = GameFont.Small;
            }
            if (randomizeCallback != null)
            {
                Rect rect6 = new Rect(creationRect.width - 24f - 100f, 0f, 100f, rect2.height);
                if (Widgets.ButtonText(rect6, "Randomize".Translate()))
                {
                    SoundDefOf.Tick_Tiny.PlayOneShotOnCamera();
                    randomizeCallback();
                }
                UIHighlighter.HighlightOpportunity(rect6, "RandomizePawn");
            }
            if (creationMode)
            {
                Widgets.InfoCardButton(creationRect.width - 24f, 0f, pawn);
            }
            else if (!pawn.health.Dead)
            {
                float num = PawnCardSize(pawn).x - 85f;
                if (pawn.IsFreeColonist && pawn.Spawned)
                {
                    Rect rect7 = new Rect(num, 0f, 30f, 30f);
                    if (Mouse.IsOver(rect7))
                    {
                        TooltipHandler.TipRegion(rect7, PawnBanishUtility.GetBanishButtonTip(pawn));
                    }
                    if (Widgets.ButtonImage(rect7, TexButton.Banish))
                    {
                        if (pawn.Downed)
                        {
                            Messages.Message("MessageCantBanishDownedPawn".Translate(pawn.LabelShort, pawn).AdjustedFor(pawn), pawn, MessageTypeDefOf.RejectInput, historical: false);
                        }
                        else
                        {
                            PawnBanishUtility.ShowBanishPawnConfirmationDialog(pawn);
                        }
                    }
                    num -= 40f;
                }
                if (pawn.IsColonist)
                {
                    Rect rect8 = new Rect(num, 0f, 30f, 30f);
                    TooltipHandler.TipRegionByKey(rect8, "RenameColonist");
                    if (Widgets.ButtonImage(rect8, TexButton.Rename))
                    {
                        Find.WindowStack.Add(new Dialog_NamePawn(pawn));
                    }
                    num -= 40f;
                }
                if (pawn.IsFreeColonist && !pawn.IsQuestLodger() && pawn.royalty != null && pawn.royalty.AllTitlesForReading.Count > 0)
                {
                    Rect rect9 = new Rect(num, 0f, 30f, 30f);
                    TooltipHandler.TipRegionByKey(rect9, "RenounceTitle");
                    if (Widgets.ButtonImage(rect9, TexButton.RenounceTitle))
                    {
                        FloatMenuUtility.MakeMenu(pawn.royalty.AllTitlesForReading, (RoyalTitle title) => "RenounceTitle".Translate() + ": " + "TitleOfFaction".Translate(title.def.GetLabelCapFor(pawn), title.faction.GetCallLabel()), (RoyalTitle title) => delegate
                        {
                            RoyalTitleUtility.FindLostAndGainedPermits(title.def, null, out List <RoyalTitlePermitDef> _, out List <RoyalTitlePermitDef> lostPermits);
                            StringBuilder stringBuilder = new StringBuilder();
                            if (lostPermits.Count > 0)
                            {
                                stringBuilder.AppendLine("RenounceTitleWillLoosePermits".Translate(pawn.Named("PAWN")) + ":");
                                foreach (RoyalTitlePermitDef item2 in lostPermits)
                                {
                                    stringBuilder.AppendLine("- " + item2.LabelCap + " (" + FirstTitleWithPermit(item2).GetLabelFor(pawn) + ")");
                                }
                                stringBuilder.AppendLine();
                            }
                            if (!title.faction.def.renounceTitleMessage.NullOrEmpty())
                            {
                                stringBuilder.AppendLine(title.faction.def.renounceTitleMessage);
                            }
                            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("RenounceTitleDescription".Translate(pawn.Named("PAWN"), "TitleOfFaction".Translate(title.def.GetLabelCapFor(pawn), title.faction.GetCallLabel()).Named("TITLE"), stringBuilder.ToString().TrimEndNewlines().Named("EFFECTS")), delegate
                            {
                                pawn.royalty.SetTitle(title.faction, null, grantRewards: false);
                            }, destructive: true));
                        });
                    }
                    num -= 40f;
                }
            }
            List <GenUI.AnonymousStackElement> stackElements = new List <GenUI.AnonymousStackElement>();

            Text.Font = GameFont.Small;
            string  text   = pawn.MainDesc(writeFaction: false);
            Vector2 vector = Text.CalcSize(text);
            Rect    rect10 = new Rect(0f, 45f, vector.x + 5f, 24f);

            Widgets.Label(rect10, text);
            float height = Text.CalcHeight(text, rect10.width);
            Rect  rect11 = new Rect(rect10.x, rect10.y, rect10.width, height);

            if (Mouse.IsOver(rect11))
            {
                TooltipHandler.TipRegion(rect11, () => pawn.ageTracker.AgeTooltipString, 6873641);
            }
            float num2 = 0f;

            if (pawn.Faction != null && !pawn.Faction.def.hidden)
            {
                float num3 = Text.CalcSize(pawn.Faction.Name).x + 22f + 15f;
                stackElements.Add(new GenUI.AnonymousStackElement
                {
                    drawer = delegate(Rect r)
                    {
                        Rect rect23  = new Rect(r.x, r.y, r.width, r.height);
                        Color color7 = GUI.color;
                        GUI.color    = StackElementBackground;
                        GUI.DrawTexture(rect23, BaseContent.WhiteTex);
                        GUI.color = color7;
                        Widgets.DrawHighlightIfMouseover(rect23);
                        Rect rect24    = new Rect(r.x, r.y, r.width, r.height);
                        Rect position4 = new Rect(r.x + 1f, r.y + 1f, 20f, 20f);
                        GUI.color      = pawn.Faction.Color;
                        GUI.DrawTexture(position4, pawn.Faction.def.FactionIcon);
                        GUI.color = color7;
                        Widgets.Label(new Rect(rect24.x + rect24.height + 5f, rect24.y, rect24.width - 10f, rect24.height), pawn.Faction.Name);
                        if (Widgets.ButtonInvisible(rect23))
                        {
                            if (creationMode)
                            {
                                Find.WindowStack.Add(new Dialog_FactionDuringLanding());
                            }
                            else
                            {
                                Find.MainTabsRoot.SetCurrentTab(MainButtonDefOf.Factions);
                            }
                        }
                        if (Mouse.IsOver(rect23))
                        {
                            TipSignal tip6 = new TipSignal(() => "Faction".Translate() + "\n\n" + "FactionDesc".Translate(pawn.Named("PAWN")) + "\n\n" + "ClickToViewFactions".Translate(), pawn.Faction.loadID * 37);
                            TooltipHandler.TipRegion(rect23, tip6);
                        }
                    },
                    width = num3
                });
                num2 += num3;
            }
            bool  flag = false;
            float num4 = rect.width - vector.x - 10f;

            tmpExtraFactions.Clear();
            QuestUtility.GetExtraFactionsFromQuestParts(pawn, tmpExtraFactions);
            foreach (ExtraFaction tmpExtraFaction in tmpExtraFactions)
            {
                ExtraFaction localExtraFaction    = tmpExtraFaction;
                string       factionName          = localExtraFaction.faction.Name;
                bool         drawExtraFactionIcon = localExtraFaction.factionType == ExtraFactionType.HomeFaction;
                float        num5 = ElementWidth();
                if (flag || num2 + num5 >= num4)
                {
                    factionName = "...";
                    num5        = ElementWidth();
                    flag        = true;
                }
                stackElements.Add(new GenUI.AnonymousStackElement
                {
                    drawer = delegate(Rect r)
                    {
                        Rect rect20  = new Rect(r.x, r.y, r.width, r.height);
                        Rect rect21  = drawExtraFactionIcon ? rect20 : r;
                        Color color6 = GUI.color;
                        GUI.color    = StackElementBackground;
                        GUI.DrawTexture(rect21, BaseContent.WhiteTex);
                        GUI.color = color6;
                        Widgets.DrawHighlightIfMouseover(rect21);
                        if (drawExtraFactionIcon)
                        {
                            Rect rect22    = new Rect(r.x, r.y, r.width, r.height);
                            Rect position3 = new Rect(r.x + 1f, r.y + 1f, 20f, 20f);
                            GUI.color      = localExtraFaction.faction.Color;
                            GUI.DrawTexture(position3, localExtraFaction.faction.def.FactionIcon);
                            GUI.color = color6;
                            Widgets.Label(new Rect(rect22.x + rect22.height + 5f, rect22.y, rect22.width - 10f, rect22.height), factionName);
                        }
                        else
                        {
                            Widgets.Label(new Rect(r.x + 5f, r.y, r.width - 10f, r.height), factionName);
                        }
                        if (Widgets.ButtonInvisible(rect20))
                        {
                            Find.MainTabsRoot.SetCurrentTab(MainButtonDefOf.Factions);
                        }
                        if (Mouse.IsOver(rect21))
                        {
                            TipSignal tip5 = new TipSignal(() => localExtraFaction.factionType.GetLabel().CapitalizeFirst() + "\n\n" + "ExtraFactionDesc".Translate(pawn.Named("PAWN")) + "\n\n" + "ClickToViewFactions".Translate(), localExtraFaction.faction.loadID ^ 0x738AC053);
                            TooltipHandler.TipRegion(rect21, tip5);
                        }
                    },
                    width = num5
                });
                num2 += num5;
                float ElementWidth()
                {
                    return(Text.CalcSize(factionName).x + (float)(drawExtraFactionIcon ? 22 : 0) + 15f);
                }
            }
            GenUI.DrawElementStack(new Rect(vector.x + 10f, 45f, 999f, 24f), 22f, stackElements, delegate(Rect r, GenUI.AnonymousStackElement obj)
            {
                obj.drawer(r);
            }, (GenUI.AnonymousStackElement obj) => obj.width, 4f, 5f, allowOrderOptimization: false);
            stackElements.Clear();
            float curY = 72f;

            if (pawn.royalty != null && pawn.royalty.AllTitlesForReading.Count > 0)
            {
                foreach (RoyalTitle title2 in pawn.royalty.AllTitlesForReading)
                {
                    RoyalTitle localTitle = title2;
                    string     titleLabel = localTitle.def.GetLabelCapFor(pawn) + " (" + pawn.royalty.GetFavor(localTitle.faction) + ")";
                    stackElements.Add(new GenUI.AnonymousStackElement
                    {
                        drawer = delegate(Rect r)
                        {
                            Color color5 = GUI.color;
                            Rect rect18  = new Rect(r.x, r.y, r.width + 22f, r.height);
                            GUI.color    = StackElementBackground;
                            GUI.DrawTexture(rect18, BaseContent.WhiteTex);
                            GUI.color = color5;
                            int favor = pawn.royalty.GetFavor(localTitle.faction);
                            if (Mouse.IsOver(rect18))
                            {
                                Widgets.DrawHighlight(rect18);
                            }
                            Rect rect19    = new Rect(r.x, r.y, r.width + 22f, r.height);
                            Rect position2 = new Rect(r.x + 1f, r.y + 1f, 20f, 20f);
                            GUI.color      = title2.faction.Color;
                            GUI.DrawTexture(position2, localTitle.faction.def.FactionIcon);
                            GUI.color = color5;
                            Widgets.Label(new Rect(rect19.x + rect19.height + 5f, rect19.y, rect19.width - 10f, rect19.height), titleLabel);
                            if (Widgets.ButtonInvisible(rect18))
                            {
                                Find.WindowStack.Add(new Dialog_InfoCard(localTitle.def, localTitle.faction));
                            }
                            if (Mouse.IsOver(rect18))
                            {
                                TipSignal tip4 = new TipSignal(() => GetTitleTipString(pawn, localTitle.faction, localTitle, favor), (int)curY * 37);
                                TooltipHandler.TipRegion(rect18, tip4);
                            }
                        },
                        width = Text.CalcSize(titleLabel).x + 15f
                    });
                }
            }
            QuestUtility.AppendInspectStringsFromQuestParts(delegate(string str, Quest quest)
            {
                stackElements.Add(new GenUI.AnonymousStackElement
                {
                    drawer = delegate(Rect r)
                    {
                        Color color4 = GUI.color;
                        GUI.color    = StackElementBackground;
                        GUI.DrawTexture(r, BaseContent.WhiteTex);
                        GUI.color = color4;
                        DoQuestLine(r, str, quest);
                    },
                    width = GetQuestLineSize(str, quest).x
                });
            }, pawn, out int _);
            curY += GenUI.DrawElementStack(new Rect(0f, curY, rect.width - 5f, 50f), 22f, stackElements, delegate(Rect r, GenUI.AnonymousStackElement obj)
            {
                obj.drawer(r);
            }, (GenUI.AnonymousStackElement obj) => obj.width).height;
            if (stackElements.Any())
            {
                curY += 10f;
            }
            Rect leftRect = new Rect(0f, curY, 250f, 355f);
            Rect position = new Rect(leftRect.xMax, curY, 258f, 355f);

            GUI.BeginGroup(leftRect);
            curY = 0f;
            Pawn           pawnLocal = pawn;
            List <Ability> abilities = (from a in pawn.abilities.abilities
                                        orderby a.def.level, a.def.EntropyGain
                                        select a).ToList();
            int   numSections = abilities.Any() ? 5 : 4;
            float num6        = (float)Enum.GetValues(typeof(BackstorySlot)).Length * 22f;

            if (pawn.story != null && pawn.story.title != null)
            {
                num6 += 22f;
            }
            List <LeftRectSection> list = new List <LeftRectSection>();
            LeftRectSection        item = new LeftRectSection
            {
                rect   = new Rect(0f, 0f, leftRect.width, num6),
                drawer = delegate(Rect sectionRect)
                {
                    float num12 = sectionRect.y;
                    Text.Font = GameFont.Small;
                    foreach (BackstorySlot value6 in Enum.GetValues(typeof(BackstorySlot)))
                    {
                        Backstory backstory = pawn.story.GetBackstory(value6);
                        if (backstory != null)
                        {
                            Rect rect14 = new Rect(sectionRect.x, num12, leftRect.width, 22f);
                            if (Mouse.IsOver(rect14))
                            {
                                Widgets.DrawHighlight(rect14);
                            }
                            if (Mouse.IsOver(rect14))
                            {
                                TooltipHandler.TipRegion(rect14, backstory.FullDescriptionFor(pawn).Resolve());
                            }
                            Text.Anchor = TextAnchor.MiddleLeft;
                            string str2 = (value6 == BackstorySlot.Adulthood) ? "Adulthood".Translate() : "Childhood".Translate();
                            Widgets.Label(rect14, str2 + ":");
                            Text.Anchor = TextAnchor.UpperLeft;
                            Rect rect15 = new Rect(rect14);
                            rect15.x     += 90f;
                            rect15.width -= 90f;
                            string str3 = backstory.TitleCapFor(pawn.gender);
                            Widgets.Label(rect15, str3.Truncate(rect15.width));
                            num12 += rect14.height;
                        }
                    }
                    if (pawn.story != null && pawn.story.title != null)
                    {
                        Rect rect16 = new Rect(sectionRect.x, num12, leftRect.width, 22f);
                        Text.Anchor = TextAnchor.MiddleLeft;
                        Widgets.Label(rect16, "Current".Translate() + ":");
                        Text.Anchor = TextAnchor.UpperLeft;
                        Rect rect17 = new Rect(rect16);
                        rect17.x     += 90f;
                        rect17.width -= 90f;
                        Widgets.Label(rect17, pawn.story.title);
                        num12 += rect16.height;
                    }
                }
            };

            list.Add(item);
            num6 = 30f;
            WorkTags        disabledTags               = pawn.CombinedDisabledWorkTags;
            List <WorkTags> disabledTagsList           = WorkTagsFrom(disabledTags).ToList();
            bool            allowWorkTagVerticalLayout = false;

            GenUI.StackElementWidthGetter <WorkTags> workTagWidthGetter = (WorkTags tag) => Text.CalcSize(tag.LabelTranslated().CapitalizeFirst()).x + 10f;
            if (disabledTags == WorkTags.None)
            {
                num6 += 22f;
            }
            else
            {
                disabledTagsList.Sort(delegate(WorkTags a, WorkTags b)
                {
                    int num11  = GetWorkTypeDisableCauses(pawn, a).Any((object c) => c is RoyalTitleDef) ? 1 : (-1);
                    int value5 = GetWorkTypeDisableCauses(pawn, b).Any((object c) => c is RoyalTitleDef) ? 1 : (-1);
                    return(num11.CompareTo(value5));
                });
                num6 += GenUI.DrawElementStack(new Rect(0f, 0f, leftRect.width - 5f, leftRect.height), 22f, disabledTagsList, delegate
                {
                }, workTagWidthGetter, 4f, 5f, allowOrderOptimization: false).height;
                num6 += 12f;
                allowWorkTagVerticalLayout = (GenUI.DrawElementStackVertical(new Rect(0f, 0f, rect.width, leftRect.height / (float)numSections), 22f, disabledTagsList, delegate
                {
                }, workTagWidthGetter).width <= leftRect.width);
            }
            item = new LeftRectSection
            {
                rect   = new Rect(0f, 0f, leftRect.width, num6),
                drawer = delegate(Rect sectionRect)
                {
                    Text.Font = GameFont.Medium;
                    float currentY3 = sectionRect.y;
                    Widgets.Label(new Rect(sectionRect.x, currentY3, 200f, 30f), "IncapableOf".Translate(pawn));
                    currentY3 += 30f;
                    Text.Font  = GameFont.Small;
                    if (disabledTags == WorkTags.None)
                    {
                        GUI.color = Color.gray;
                        Rect rect13 = new Rect(sectionRect.x, currentY3, leftRect.width, 24f);
                        if (Mouse.IsOver(rect13))
                        {
                            Widgets.DrawHighlight(rect13);
                        }
                        Widgets.Label(rect13, "None".Translate());
                        TooltipHandler.TipRegionByKey(rect13, "None");
                    }
                    else
                    {
                        GenUI.StackElementDrawer <WorkTags> drawer = delegate(Rect r, WorkTags tag)
                        {
                            Color color3 = GUI.color;
                            GUI.color = StackElementBackground;
                            GUI.DrawTexture(r, BaseContent.WhiteTex);
                            GUI.color = color3;
                            GUI.color = GetDisabledWorkTagLabelColor(pawn, tag);
                            if (Mouse.IsOver(r))
                            {
                                Widgets.DrawHighlight(r);
                            }
                            Widgets.Label(new Rect(r.x + 5f, r.y, r.width - 10f, r.height), tag.LabelTranslated().CapitalizeFirst());
                            if (Mouse.IsOver(r))
                            {
                                TooltipHandler.TipRegion(tip: new TipSignal(() => GetWorkTypeDisabledCausedBy(pawnLocal, tag) + "\n" + GetWorkTypesDisabledByWorkTag(tag), (int)currentY3 * 32), rect: r);
                            }
                        };
                        if (allowWorkTagVerticalLayout)
                        {
                            GenUI.DrawElementStackVertical(new Rect(sectionRect.x, currentY3, leftRect.width - 5f, leftRect.height / (float)numSections), 22f, disabledTagsList, drawer, workTagWidthGetter);
                        }
                        else
                        {
                            GenUI.DrawElementStack(new Rect(sectionRect.x, currentY3, leftRect.width - 5f, leftRect.height / (float)numSections), 22f, disabledTagsList, drawer, workTagWidthGetter, 5f);
                        }
                    }
                    GUI.color = Color.white;
                }
            };
            list.Add(item);
            num6 = 30f;
            List <Trait> traits = pawn.story.traits.allTraits;

            num6 = ((traits != null && traits.Count != 0) ? (num6 + GenUI.DrawElementStack(new Rect(0f, 0f, leftRect.width - 5f, leftRect.height), 22f, pawn.story.traits.allTraits, delegate
            {
            }, (Trait trait) => Text.CalcSize(trait.LabelCap).x + 10f).height) : (num6 + 22f));
            num6 += 12f;
            item  = new LeftRectSection
            {
                rect   = new Rect(0f, 0f, leftRect.width, num6),
                drawer = delegate(Rect sectionRect)
                {
                    Text.Font = GameFont.Medium;
                    float currentY2 = sectionRect.y;
                    Widgets.Label(new Rect(sectionRect.x, currentY2, 200f, 30f), "Traits".Translate());
                    currentY2 += 30f;
                    Text.Font  = GameFont.Small;
                    if (traits == null || traits.Count == 0)
                    {
                        Color color = GUI.color;
                        GUI.color = Color.gray;
                        Rect rect12 = new Rect(sectionRect.x, currentY2, leftRect.width, 24f);
                        if (Mouse.IsOver(rect12))
                        {
                            Widgets.DrawHighlight(rect12);
                        }
                        Widgets.Label(rect12, "None".Translate());
                        currentY2 += rect12.height + 2f;
                        TooltipHandler.TipRegionByKey(rect12, "None");
                        GUI.color = color;
                    }
                    else
                    {
                        GenUI.DrawElementStack(new Rect(sectionRect.x, currentY2, leftRect.width - 5f, leftRect.height / (float)numSections), 22f, pawn.story.traits.allTraits, delegate(Rect r, Trait trait)
                        {
                            Color color2 = GUI.color;
                            GUI.color    = StackElementBackground;
                            GUI.DrawTexture(r, BaseContent.WhiteTex);
                            GUI.color = color2;
                            if (Mouse.IsOver(r))
                            {
                                Widgets.DrawHighlight(r);
                            }
                            Widgets.Label(new Rect(r.x + 5f, r.y, r.width - 10f, r.height), trait.LabelCap);
                            if (Mouse.IsOver(r))
                            {
                                TooltipHandler.TipRegion(tip: new TipSignal(() => trait.TipString(pawn), (int)currentY2 * 37), rect: r);
                            }
                        }, (Trait trait) => Text.CalcSize(trait.LabelCap).x + 10f);
                    }
                }
            };
            list.Add(item);
            if (abilities.Any())
            {
                num6  = 30f;
                num6 += GenUI.DrawElementStack(new Rect(0f, 0f, leftRect.width - 5f, leftRect.height), 32f, abilities, delegate
                {
                }, (Ability abil) => 32f).height;
                item = new LeftRectSection
                {
                    rect   = new Rect(0f, 0f, leftRect.width, num6),
                    drawer = delegate(Rect sectionRect)
                    {
                        Text.Font = GameFont.Medium;
                        float currentY = sectionRect.y;
                        Widgets.Label(new Rect(sectionRect.x, currentY, 200f, 30f), "Abilities".Translate(pawn));
                        currentY += 30f;
                        Text.Font = GameFont.Small;
                        GenUI.DrawElementStack(new Rect(sectionRect.x, currentY, leftRect.width - 5f, leftRect.height), 32f, abilities, delegate(Rect r, Ability abil)
                        {
                            GUI.DrawTexture(r, BaseContent.ClearTex);
                            if (Mouse.IsOver(r))
                            {
                                Widgets.DrawHighlight(r);
                            }
                            if (Widgets.ButtonImage(r, abil.def.uiIcon, doMouseoverSound: false))
                            {
                                Find.WindowStack.Add(new Dialog_InfoCard(abil.def));
                            }
                            if (Mouse.IsOver(r))
                            {
                                TipSignal tip = new TipSignal(() => abil.def.GetTooltip() + "\n\n" + "ClickToLearnMore".Translate(), (int)currentY * 37);
                                TooltipHandler.TipRegion(r, tip);
                            }
                        }, (Ability abil) => 32f);
                        GUI.color = Color.white;
                    }
                };
                list.Add(item);
            }
            float num7 = leftRect.height / (float)list.Count;
            float num8 = 0f;

            for (int i = 0; i < list.Count; i++)
            {
                LeftRectSection value = list[i];
                if (value.rect.height > num7)
                {
                    num8 += value.rect.height - num7;
                    value.calculatedSize = value.rect.height;
                }
                else
                {
                    value.calculatedSize = num7;
                }
                list[i] = value;
            }
            bool  flag2 = false;
            float num9  = 0f;

            if (num8 > 0f)
            {
                LeftRectSection value2 = list[0];
                float           num10  = value2.rect.height + 12f;
                num8 -= value2.calculatedSize - num10;
                value2.calculatedSize = num10;
                list[0] = value2;
            }
            while (num8 > 0f)
            {
                bool flag3 = true;
                for (int j = 0; j < list.Count; j++)
                {
                    LeftRectSection value3 = list[j];
                    if (value3.calculatedSize - value3.rect.height > 0f)
                    {
                        value3.calculatedSize -= 1f;
                        num8 -= 1f;
                        flag3 = false;
                    }
                    list[j] = value3;
                }
                if (!flag3)
                {
                    continue;
                }
                for (int k = 0; k < list.Count; k++)
                {
                    LeftRectSection value4 = list[k];
                    if (k > 0)
                    {
                        value4.calculatedSize = Mathf.Max(value4.rect.height, num7);
                    }
                    else
                    {
                        value4.calculatedSize = value4.rect.height + 22f;
                    }
                    num9   += value4.calculatedSize;
                    list[k] = value4;
                }
                flag2 = true;
                break;
            }
            if (flag2)
            {
                Widgets.BeginScrollView(new Rect(0f, 0f, leftRect.width, leftRect.height), ref leftRectScrollPos, new Rect(0f, 0f, leftRect.width - 16f, num9));
            }
            curY = 0f;
            for (int l = 0; l < list.Count; l++)
            {
                LeftRectSection leftRectSection = list[l];
                leftRectSection.drawer(new Rect(0f, curY, leftRect.width, leftRectSection.rect.height));
                curY += leftRectSection.calculatedSize;
            }
            if (flag2)
            {
                Widgets.EndScrollView();
            }
            GUI.EndGroup();
            GUI.BeginGroup(position);
            SkillUI.DrawSkillsOf(mode: (Current.ProgramState != ProgramState.Playing) ? SkillUI.SkillDrawMode.Menu : SkillUI.SkillDrawMode.Gameplay, p: pawn, offset: new Vector2(0f, 0f));
            GUI.EndGroup();
            GUI.EndGroup();
            RoyalTitleDef FirstTitleWithPermit(RoyalTitlePermitDef permitDef)
            {
                //return title.faction.def.RoyalTitlesAwardableInSeniorityOrderForReading.First((RoyalTitleDef t) => t.permits != null && t.permits.Contains(permitDef));
                Log.Message("Todo:>>>>");
                return(default);
コード例 #28
0
        public static void DrawCharacterCard(Rect rect, Pawn pawn, Action randomizeCallback = null, Rect creationRect = default(Rect))
        {
            bool flag = randomizeCallback != null;

            GUI.BeginGroup((!flag) ? rect : creationRect);
            Rect       rect2      = new Rect(0f, 0f, 300f, 30f);
            NameTriple nameTriple = pawn.Name as NameTriple;

            if (flag && nameTriple != null)
            {
                Rect rect3 = new Rect(rect2);
                rect3.width *= 0.333f;
                Rect rect4 = new Rect(rect2);
                rect4.width *= 0.333f;
                rect4.x     += rect4.width;
                Rect rect5 = new Rect(rect2);
                rect5.width *= 0.333f;
                rect5.x     += rect4.width * 2f;
                string first = nameTriple.First;
                string nick  = nameTriple.Nick;
                string last  = nameTriple.Last;
                CharacterCardUtility.DoNameInputRect(rect3, ref first, 12);
                if (nameTriple.Nick == nameTriple.First || nameTriple.Nick == nameTriple.Last)
                {
                    GUI.color = new Color(1f, 1f, 1f, 0.5f);
                }
                CharacterCardUtility.DoNameInputRect(rect4, ref nick, 16);
                GUI.color = Color.white;
                CharacterCardUtility.DoNameInputRect(rect5, ref last, 12);
                if (nameTriple.First != first || nameTriple.Nick != nick || nameTriple.Last != last)
                {
                    pawn.Name = new NameTriple(first, nick, last);
                }
                TooltipHandler.TipRegion(rect3, "FirstNameDesc".Translate());
                TooltipHandler.TipRegion(rect4, "ShortIdentifierDesc".Translate());
                TooltipHandler.TipRegion(rect5, "LastNameDesc".Translate());
            }
            else
            {
                rect2.width = 999f;
                Text.Font   = GameFont.Medium;
                Widgets.Label(rect2, pawn.Name.ToStringFull);
                Text.Font = GameFont.Small;
            }
            if (randomizeCallback != null)
            {
                Rect rect6 = new Rect(creationRect.width - 24f - 100f, 0f, 100f, rect2.height);
                if (Widgets.ButtonText(rect6, "Randomize".Translate(), true, false, true))
                {
                    SoundDefOf.Tick_Tiny.PlayOneShotOnCamera(null);
                    randomizeCallback();
                }
                UIHighlighter.HighlightOpportunity(rect6, "RandomizePawn");
            }
            if (flag)
            {
                Widgets.InfoCardButton(creationRect.width - 24f, 0f, pawn);
            }
            else if (!pawn.health.Dead)
            {
                float num = CharacterCardUtility.PawnCardSize.x - 85f;
                if ((pawn.Faction == Faction.OfPlayer || pawn.IsPrisonerOfColony) && pawn.Spawned)
                {
                    Rect rect7 = new Rect(num, 0f, 30f, 30f);
                    TooltipHandler.TipRegion(rect7, PawnBanishUtility.GetBanishButtonTip(pawn));
                    if (Widgets.ButtonImage(rect7, TexButton.Banish))
                    {
                        if (pawn.Downed)
                        {
                            Messages.Message("MessageCantBanishDownedPawn".Translate(pawn.LabelShort, pawn).AdjustedFor(pawn, "PAWN"), pawn, MessageTypeDefOf.RejectInput, false);
                        }
                        else
                        {
                            PawnBanishUtility.ShowBanishPawnConfirmationDialog(pawn);
                        }
                    }
                    num -= 40f;
                }
                if (pawn.IsColonist)
                {
                    Rect rect8 = new Rect(num, 0f, 30f, 30f);
                    TooltipHandler.TipRegion(rect8, "RenameColonist".Translate());
                    if (Widgets.ButtonImage(rect8, TexButton.Rename))
                    {
                        Find.WindowStack.Add(new Dialog_NamePawn(pawn));
                    }
                    num -= 40f;
                }
            }
            string label = pawn.MainDesc(true);
            Rect   rect9 = new Rect(0f, 45f, rect.width, 60f);

            Widgets.Label(rect9, label);
            TooltipHandler.TipRegion(rect9, () => pawn.ageTracker.AgeTooltipString, 6873641);
            Rect position  = new Rect(0f, 100f, 250f, 450f);
            Rect position2 = new Rect(position.xMax, 100f, 258f, 450f);

            GUI.BeginGroup(position);
            float num2 = 0f;

            Text.Font = GameFont.Medium;
            Widgets.Label(new Rect(0f, 0f, 200f, 30f), "Backstory".Translate());
            num2     += 30f;
            Text.Font = GameFont.Small;
            foreach (BackstorySlot backstorySlot in Enum.GetValues(typeof(BackstorySlot)))
            {
                Backstory backstory = pawn.story.GetBackstory(backstorySlot);
                if (backstory != null)
                {
                    Rect rect10 = new Rect(0f, num2, position.width, 24f);
                    if (Mouse.IsOver(rect10))
                    {
                        Widgets.DrawHighlight(rect10);
                    }
                    TooltipHandler.TipRegion(rect10, backstory.FullDescriptionFor(pawn));
                    Text.Anchor = TextAnchor.MiddleLeft;
                    string str = (backstorySlot != BackstorySlot.Adulthood) ? "Childhood".Translate() : "Adulthood".Translate();
                    Widgets.Label(rect10, str + ":");
                    Text.Anchor = TextAnchor.UpperLeft;
                    Rect rect11 = new Rect(rect10);
                    rect11.x     += 90f;
                    rect11.width -= 90f;
                    string label2 = backstory.TitleCapFor(pawn.gender);
                    Widgets.Label(rect11, label2);
                    num2 += rect10.height + 2f;
                }
            }
            if (pawn.story != null && pawn.story.title != null)
            {
                Rect rect12 = new Rect(0f, num2, position.width, 24f);
                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(rect12, "Current".Translate() + ":");
                Text.Anchor = TextAnchor.UpperLeft;
                Rect rect13 = new Rect(rect12);
                rect13.x     += 90f;
                rect13.width -= 90f;
                Widgets.Label(rect13, pawn.story.title);
                num2 += rect12.height + 2f;
            }
            num2     += 25f;
            Text.Font = GameFont.Medium;
            Widgets.Label(new Rect(0f, num2, 200f, 30f), "IncapableOf".Translate());
            num2     += 30f;
            Text.Font = GameFont.Small;
            StringBuilder stringBuilder            = new StringBuilder();
            WorkTags      combinedDisabledWorkTags = pawn.story.CombinedDisabledWorkTags;

            if (combinedDisabledWorkTags == WorkTags.None)
            {
                stringBuilder.Append("(" + "NoneLower".Translate() + "), ");
            }
            else
            {
                List <WorkTags> list  = CharacterCardUtility.WorkTagsFrom(combinedDisabledWorkTags).ToList <WorkTags>();
                bool            flag2 = true;
                foreach (WorkTags current in list)
                {
                    if (flag2)
                    {
                        stringBuilder.Append(current.LabelTranslated().CapitalizeFirst());
                    }
                    else
                    {
                        stringBuilder.Append(current.LabelTranslated());
                    }
                    stringBuilder.Append(", ");
                    flag2 = false;
                }
            }
            string text = stringBuilder.ToString();

            text = text.Substring(0, text.Length - 2);
            Rect rect14 = new Rect(0f, num2, position.width, 999f);

            Widgets.Label(rect14, text);
            num2     += 100f;
            Text.Font = GameFont.Medium;
            Widgets.Label(new Rect(0f, num2, 200f, 30f), "Traits".Translate());
            num2     += 30f;
            Text.Font = GameFont.Small;
            for (int i = 0; i < pawn.story.traits.allTraits.Count; i++)
            {
                Trait trait  = pawn.story.traits.allTraits[i];
                Rect  rect15 = new Rect(0f, num2, position.width, 24f);
                if (Mouse.IsOver(rect15))
                {
                    Widgets.DrawHighlight(rect15);
                }
                Widgets.Label(rect15, trait.LabelCap);
                num2 += rect15.height + 2f;
                Trait     trLocal = trait;
                TipSignal tip     = new TipSignal(() => trLocal.TipString(pawn), (int)num2 * 37);
                TooltipHandler.TipRegion(rect15, tip);
            }
            GUI.EndGroup();
            GUI.BeginGroup(position2);
            Text.Font = GameFont.Medium;
            Widgets.Label(new Rect(0f, 0f, 200f, 30f), "Skills".Translate());
            SkillUI.SkillDrawMode mode;
            if (Current.ProgramState == ProgramState.Playing)
            {
                mode = SkillUI.SkillDrawMode.Gameplay;
            }
            else
            {
                mode = SkillUI.SkillDrawMode.Menu;
            }
            SkillUI.DrawSkillsOf(pawn, new Vector2(0f, 35f), mode);
            GUI.EndGroup();
            GUI.EndGroup();
        }
コード例 #29
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            Text.Font = GameFont.Tiny;
            Rect rect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), GizmoSize);
            bool flag = false;

            if (Mouse.IsOver(rect))
            {
                flag = true;
                if (!this.disabled)
                {
                    GUI.color = GenUI.MouseoverColor;
                }
            }
            Texture2D badTex = this.icon;

            if (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }
            Material material = (!this.disabled) ? null : TexUI.GrayscaleGUI;

            GenUI.DrawTextureWithMaterial(rect, Command.BGTex, material, default(Rect));
            MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
            Rect outerRect = rect;

            outerRect.position += new Vector2(this.iconOffset.x * outerRect.size.x, this.iconOffset.y * outerRect.size.y);
            GUI.color           = this.IconDrawColor;
            Widgets.DrawTextureFitted(outerRect, badTex, this.iconDrawScale * 0.85f, this.iconProportions, this.iconTexCoords, this.iconAngle, material);
            GUI.color = Color.white;
            bool    flag2   = false;
            KeyCode keyCode = (this.hotKey != null) ? this.hotKey.MainKey : KeyCode.None;

            if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                Rect rect2 = new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f);
                Widgets.Label(rect2, keyCode.ToStringReadable());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (this.hotKey.KeyDownEvent)
                {
                    flag2 = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(rect, false))
            {
                flag2 = true;
            }
            string labelCap = this.LabelCap;

            if (!labelCap.NullOrEmpty())
            {
                float num   = Text.CalcHeight(labelCap, rect.width);
                Rect  rect3 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num);
                GUI.DrawTexture(rect3, TexUI.GrayTextBG);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect3, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.color = Color.white;
            if (this.DoTooltip)
            {
                TipSignal tip = this.Desc;
                if (this.disabled && !this.disabledReason.NullOrEmpty())
                {
                    string text = tip.text;
                    tip.text = string.Concat(new string[]
                    {
                        text,
                        "\n\n",
                        "DisabledCommand".Translate(),
                        ": ",
                        this.disabledReason
                    });
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (this.cannon.cooldownTicks > 0)
            {
                float percent = (float)this.cannon.cooldownTicks / (float)this.cannon.MaxTicks;
                SPExtended.VerticalFillableBar(rect, percent, FillableBar, ClearBar);
            }
            if (!this.HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, this.HighlightTag);
            }
            Text.Font = GameFont.Small;
            if (flag2)
            {
                if (this.disabled)
                {
                    if (!this.disabledReason.NullOrEmpty())
                    {
                        Messages.Message(this.disabledReason, MessageTypeDefOf.RejectInput, false);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(this.TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                var result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(this.TutorTagSelect);
                return(result);
            }
            if (flag)
            {
                return(new GizmoResult(GizmoState.Mouseover, null));
            }
            return(new GizmoResult(GizmoState.Clear, null));
        }
コード例 #30
0
ファイル: LockGizmo.cs プロジェクト: JonnyNova/Locks
        public override GizmoResult GizmoOnGUI(Vector2 topLeft, float maxWidth)
        {
            Rect rect = new Rect(topLeft.x, topLeft.y, this.GetWidth(maxWidth), 75f);
            bool flag = false;

            if (Mouse.IsOver(rect))
            {
                flag      = true;
                GUI.color = GenUI.MouseoverColor;
            }
            Texture2D badTex = LockUtility.GetData(parent).WantedState.locked ? lockTexture : unlockTexture;

            if (badTex == null)
            {
                badTex = BaseContent.BadTex;
            }
            GUI.DrawTexture(rect, BGTex);
            GUI.DrawTexture(rect, badTex);
            MouseoverSounds.DoRegion(rect, SoundDefOf.Mouseover_Command);
            bool    flag2   = false;
            KeyCode keyCode = (this.hotKey != null) ? hotKey.MainKey : KeyCode.None;

            if (keyCode != KeyCode.None && !GizmoGridDrawer.drawnHotKeys.Contains(keyCode))
            {
                Rect rect2 = new Rect(rect.x + 5f, rect.y + 5f, rect.width - 10f, 18f);
                Widgets.Label(rect2, keyCode.ToStringReadable());
                GizmoGridDrawer.drawnHotKeys.Add(keyCode);
                if (hotKey.KeyDownEvent)
                {
                    flag2 = true;
                    Event.current.Use();
                }
            }
            if (Widgets.ButtonInvisible(rect, false))
            {
                flag2 = true;
            }
            string labelCap = LabelCap;

            if (!labelCap.NullOrEmpty())
            {
                float num   = Text.CalcHeight(labelCap, rect.width);
                Rect  rect3 = new Rect(rect.x, rect.yMax - num + 12f, rect.width, num);
                GUI.DrawTexture(rect3, TexUI.GrayTextBG);
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(rect3, labelCap);
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.color   = Color.white;
            }
            GUI.color = Color.white;
            if (DoTooltip)
            {
                TipSignal tip = Desc;
                if (disabled && !disabledReason.NullOrEmpty())
                {
                    string text = tip.text;
                    tip.text = string.Concat(new string[]
                    {
                        text,
                        "\n\n",
                        "DisabledCommand".Translate(),
                        ": ",
                        disabledReason
                    });
                }
                TooltipHandler.TipRegion(rect, tip);
            }
            if (!HighlightTag.NullOrEmpty() && (Find.WindowStack.FloatMenu == null || !Find.WindowStack.FloatMenu.windowRect.Overlaps(rect)))
            {
                UIHighlighter.HighlightOpportunity(rect, HighlightTag);
            }
            if (flag2)
            {
                if (disabled)
                {
                    if (!disabledReason.NullOrEmpty())
                    {
                        Messages.Message(disabledReason, MessageTypeDefOf.RejectInput);
                    }
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                if (!TutorSystem.AllowAction(TutorTagSelect))
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                GizmoResult result = new GizmoResult(GizmoState.Interacted, Event.current);
                TutorSystem.Notify_Event(TutorTagSelect);
                return(result);
            }
            else
            {
                if (flag)
                {
                    return(new GizmoResult(GizmoState.Mouseover, null));
                }
                return(new GizmoResult(GizmoState.Clear, null));
            }
        }
コード例 #31
0
        public void OnGUI(Rect rect)
        {
            float curY = 0f;
            float repeatModeButX = 0f;
            float adjustButHeight = 30f;
            try
            {
                GUI.BeginGroup(rect);
                //Do the top buttons. If the parent is not null, then do the suspend button.
                if (!setupStage)
                {
                    float suspendButRightEdge = rect.width / 2f - 5f;
                    Rect suspendButRect = new Rect(0f, 0f, suspendButRightEdge, buttonSize.y);
                    if (Suspended)
                    {
                        if (Widgets.TextButton(suspendButRect, "Suspended".Translate()))
                        {
                            Suspended = false;
                        }
                    }
                    else
                    {
                        if (Widgets.TextButton(suspendButRect, "NotSuspended".Translate()))
                        {
                            Suspended = true;
                        }
                    }
                    repeatModeButX = rect.width / 2f + 5f;
                }
                string label = "But";
                if (repeatMode == BillRepeatMode.RepeatCount)
                {
                    label = "DoXTimes".Translate();
                }
                if (repeatMode == BillRepeatMode.TargetCount)
                {
                    label = "DoUntilYouHaveX".Translate();
                }
                if (repeatMode == BillRepeatMode.Forever)
                {
                    label = "DoForever".Translate();
                }
                Vector2 repeatButSize = new Vector2(rect.width - repeatModeButX, buttonSize.y);
                Rect repeatButRect = new Rect(repeatModeButX, curY, repeatButSize.x, repeatButSize.y);
                if (Widgets.TextButton(repeatButRect, label))
                {
                    List<FloatMenuOption> list = new List<FloatMenuOption>();
                    list.Add(new FloatMenuOption("DoXTimes".Translate(), delegate
                        {
                            this.repeatMode = BillRepeatMode.RepeatCount;
                        }));
                    list.Add(new FloatMenuOption("DoUntilYouHaveX".Translate(), delegate
                        {
                            this.repeatMode = BillRepeatMode.TargetCount;
                        }));
                    list.Add(new FloatMenuOption("DoForever".Translate(), delegate
                        {
                            this.repeatMode = BillRepeatMode.Forever;
                        }));
                    Find.WindowStack.Add(new FloatMenu(list));
                }
                curY += repeatButSize.y + margin;

                //Do the target count label
                Rect countRect = new Rect(0, curY, rect.width, 30f);
                curY += countRect.height + margin;
                string text = string.Empty;
                if (this.repeatMode == BillRepeatMode.RepeatCount)
                {
                    text = "RepeatCount".Translate(new object[]{
                        Cycles.ToString()
                    });
                    float butPadding = 2f;
                    float butWidth = (rect.width - 8 * butPadding) / 5f;
                    float xPos = 0f;
                    Rect but1Rect = new Rect(xPos, curY, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but1Rect, "-25"))
                    {
                        if (Cycles == 0)
                            SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera());
                        else
                        {
                            Cycles -= 25;
                        }
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but2Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but2Rect, "-1"))
                    {
                        if (Cycles == 0)
                            SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera());
                        else
                        {
                            Cycles -= 1;
                        }
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but3Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but3Rect, "1"))
                    {
                        Cycles = 1;
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but4Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but4Rect, "+1"))
                    {
                        Cycles += 1;
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but5Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but5Rect, "+25"))
                    {
                        Cycles += 25;
                    }
                }
                else if (repeatMode == BillRepeatMode.TargetCount)
                {
                    text = "TargetCount".Translate(new object[]{
                        (TargetCount>=999999)?"Infinite".Translate() : TargetCount.ToString()
                    });
                    float butPadding = 2f;
                    float butWidth = (rect.width - 12 * butPadding) / 7f;
                    float xPos = 0f;
                    Rect but1Rect = new Rect(xPos, curY, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but1Rect, "-250"))
                    {
                        if (TargetCount == 0)
                            SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera());
                        else
                        {
                            TargetCount -= 250;
                        }
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but2Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but2Rect, "-25"))
                    {
                        if (TargetCount == 0)
                            SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera());
                        else
                        {
                            TargetCount -= 25;
                        }
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but3Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but3Rect, "-1"))
                    {
                        if (TargetCount == 0)
                            SoundStarter.PlayOneShot(SoundDefOf.ClickReject, SoundInfo.OnCamera());
                        else
                        {
                            TargetCount -= 1;
                        }
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but4Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but4Rect, "1"))
                    {
                        TargetCount = 1;
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but5Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but5Rect, "+1"))
                    {
                        TargetCount += 1;
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but6Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but6Rect, "+25"))
                    {
                        TargetCount += 25;
                    }
                    xPos += butWidth + butPadding * 2;
                    Rect but7Rect = new Rect(xPos, but1Rect.y, butWidth, adjustButHeight);
                    if (Widgets.TextButton(but7Rect, "+250"))
                    {
                        TargetCount += 250;
                    }
                }
                else if (repeatMode == BillRepeatMode.Forever)
                {
                    text = "Do Forever";
                }
                else
                {
                    throw new InvalidOperationException();
                }
                curY += adjustButHeight + margin + 6f;

                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(countRect, text);
                //Now for the ThingFilter box (shiver)
                Rect thingFilterLabelRect = new Rect(0f, curY, rect.width, 20f);
                curY += thingFilterLabelRect.height + margin;
                Widgets.Label(thingFilterLabelRect, "PermittedIngredients".Translate());
                Text.Anchor = TextAnchor.UpperLeft;

                float tfheight = rect.height - curY - adjustButHeight - margin;
                Rect thingFilterRect = new Rect(0f, curY, rect.width, tfheight);
                curY += tfheight + margin;
                ThingFilterUI.DoThingFilterConfigWindow(thingFilterRect, ref this.scrollPosition, this.ingredientsFilter, this.recipe.fixedIngredientFilter);
                //Well that wasn't so hard after all
                float checkWidth = rect.width / 2 - 30f;
                float checkXPos = rect.width / 2 - (checkWidth / 2);
                Rect checkRect = new Rect(checkXPos, curY, checkWidth, adjustButHeight);
                Widgets.LabelCheckbox(checkRect, "Complete all", ref this.completeAll);
                string s = "Activating this will set the Assembly line to send down the completed products once all cycles of the order have been completed, or when it has completed 15 cycles. This helps reduce the number of incoming drops when the completion time of the recipe is very quick.";
                if (RepeatMode == BillRepeatMode.TargetCount)
                {
                    s = "Activating this will set the Assembly line to send down the completed products once all cycles of the order have been completed, or when it has completed 5 cycles. This helps reduce the number of incoming drops when the completion time of the recipe is very quick.";
                }
                TipSignal tip = new TipSignal(s);
                TooltipHandler.TipRegion(checkRect, tip);
            }
            finally
            {
                GUI.EndGroup();
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font = GameFont.Small;
            }
        }