Пример #1
0
 public static bool ButtonTextSubtle(Rect rect, string label, float barPercent = 0f, float textLeftMargin = -1f, SoundDef mouseoverSound = null)
 {
     var mouseOver = false;
     if (Mouse.IsOver(rect))
     {
         mouseOver = true;
         GUI.color = GenUI.MouseoverColor;
     }
     if (mouseoverSound != null)
     {
         MouseoverSounds.DoRegion(rect, mouseoverSound);
     }
     Widgets.DrawAtlas(rect, ButtonSubtleAtlas);
     GUI.color = Color.white;
     if (barPercent > 0.001f)
     {
         var rect2 = rect.ContractedBy(1f);
         Widgets.FillableBar(rect2, barPercent, ButtonBarTex, null, false);
     }
     var innerRect = new Rect(rect);
     if (mouseOver)
     {
         innerRect.x += 2f;
         innerRect.y -= 2f;
     }
     Text.Anchor = TextAnchor.MiddleCenter;
     Text.Font = GameFont.Small;
     Text.WordWrap = false;
     Widgets.Label(innerRect, label);
     Text.Anchor = TextAnchor.UpperLeft;
     Text.WordWrap = true;
     return Widgets.ButtonInvisible(rect);
 }
 protected override void FillWindow(Rect inRect)
 {
     Vector2 vector = new Vector2(inRect.width - 16f, 36f);
     Vector2 vector2 = new Vector2(100f, vector.y - 2f);
     inRect.height -= 45f;
     float num = vector.y + 3f;
     List<FileInfo> list = BlueprintFiles.AllFiles.ToList();
     float height = (float)list.Count * num;
     Rect viewRect = new Rect(0f, 0f, inRect.width - 16f, height);
     Rect outRect = new Rect(inRect.AtZero());
     outRect.height -= this.bottomAreaHeight;
     Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect);
     float num2 = 0f;
     int num3 = 0;
     foreach (FileInfo current in list)
     {
         Rect rect = new Rect(0f, num2, vector.x, vector.y);
         if (num3 % 2 == 0)
         {
             Widgets.DrawAltRect(rect);
         }
         Rect position = rect.ContractedBy(1f);
         GUI.BeginGroup(position);
         string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(current.Name);
         GUI.color = Dialog_Blueprint.ManualSaveTextColor;
         Rect rect2 = new Rect(15f, 0f, position.width, position.height);
         Text.Anchor = TextAnchor.MiddleLeft;
         Text.Font = GameFont.Small;
         Widgets.Label(rect2, fileNameWithoutExtension);
         GUI.color = Color.white;
         Rect rect3 = new Rect(270f, 0f, 200f, position.height);
         GUI.color = Color.white;
         Text.Anchor = TextAnchor.UpperLeft;
         Text.Font = GameFont.Small;
         float num4 = vector.x - 2f - vector2.x - vector2.y;
         Rect rect4 = new Rect(num4, 0f, vector2.x, vector2.y);
         if (Widgets.TextButton(rect4, this.interactButLabel, true, false))
         {
             this.DoMapEntryInteraction(Path.GetFileNameWithoutExtension(current.Name));
         }
         Rect rect5 = new Rect(num4 + vector2.x + 5f, 0f, vector2.y, vector2.y);
         if (Widgets.ImageButton(rect5, TexButton.DeleteX))
         {
             FileInfo localFile = current;
             Find.LayerStack.Add(new Dialog_Confirm("ConfirmDelete".Translate(new object[]
             {
                 fileNameWithoutExtension
             }), delegate
             {
                 localFile.Delete();
             }, true));
         }
         TooltipHandler.TipRegion(rect5, "DeleteThisSavegame".Translate());
         GUI.EndGroup();
         num2 += vector.y + 3f;
         num3++;
     }
     Widgets.EndScrollView();
     this.DoSpecialSaveLoadGUI(inRect.AtZero());
 }
        public override void DoWindowContents(Rect inRect)
        {
            base.DoWindowContents(inRect);

            Rect infoPaneRect = new Rect(0, currentY, inRect.width, 60f);
            Rect infoLabelRect = infoPaneRect.ContractedBy(4f);

            base.currentY += infoPaneRect.yMax + 10f;
            Widgets.DrawMenuSection(infoPaneRect);
            //Hardcoded because I can't think how to do it :L
            string info = string.Concat(new object[]{
                parent.Speed.Label,
                ": ",
                (parent.Speed.Value).ToString("0.0"),
                "x\n",
                parent.Efficiency.Label,
                ": ",
                (parent.Efficiency.Value).ToString("0.0"),
                "x"
            });

            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(infoLabelRect, info);
            Text.Anchor = TextAnchor.UpperLeft;

            Rect rect = new Rect(0, base.currentY, inRect.width, inRect.height - base.currentY - (CloseButSize.y + padding));
            base.currentY += rect.yMax;
            parent.UpgradeManager.OnGUI(rect);

            base.ResetVariables();
        }
Пример #4
0
        public override void OTabOnGUI(Rect rect)
        {
            Text.Font = GameFont.Small;

            Rect inRect = rect.ContractedBy(Margin);
            try
            {
                GUI.BeginGroup(inRect);

                SelectionRect = new Rect(0f, 0f, 300f, inRect.height);
                DisplayRect = new Rect(SelectionRect.width + Margin, 0f, inRect.width - SelectionRect.width - Margin,
                    inRect.height);

                DrawSelectionArea(SelectionRect);
                DrawDisplayArea(DisplayRect);
                Widgets.DrawLineVertical(SelectionRect.xMax + Margin / 2f, 0f, inRect.height);

            }
            catch (Exception e)
            {
                Log.Error("Exception while drawing Help OTab: \n" + e.ToString());
            }
            finally
            {
                GUI.EndGroup();
            }
        }
Пример #5
0
 // RimWorld.AreaAllowedGUI
 private static void DoAreaSelector( Rect rect, ref Area areaAllowed, Area area )
 {
     rect = rect.ContractedBy( 1f );
     GUI.DrawTexture( rect, area == null ? BaseContent.GreyTex : area.ColorTexture );
     Text.Anchor = TextAnchor.MiddleLeft;
     string text = AreaUtility.AreaAllowedLabel_Area( area );
     Rect rect2 = rect;
     rect2.xMin += 3f;
     rect2.yMin += 2f;
     Widgets.Label( rect2, text );
     if ( areaAllowed == area )
     {
         Widgets.DrawBox( rect, 2 );
     }
     if ( Mouse.IsOver( rect ) )
     {
         if ( area != null )
         {
             area.MarkForDraw();
         }
         if ( Input.GetMouseButton( 0 ) &&
              areaAllowed != area )
         {
             areaAllowed = area;
             SoundDefOf.DesignateDragStandardChanged.PlayOneShotOnCamera();
         }
     }
     TooltipHandler.TipRegion( rect, text );
 }
Пример #6
0
 // RimWorld.AreaAllowedGUI
 private static void DoZoneSelector( Rect rect, ref Zone_Stockpile zoneAllowed, Zone_Stockpile zone, Texture2D tex)
 {
     rect = rect.ContractedBy( 1f );
     GUI.DrawTexture( rect, tex );
     Text.Anchor = TextAnchor.MiddleLeft;
     string label = zone?.label ?? "Any stockpile";
     Rect innerRect = rect;
     innerRect.xMin += 3f;
     innerRect.yMin += 2f;
     Widgets.Label( innerRect, label );
     if( zoneAllowed == zone )
     {
         Widgets.DrawBox( rect, 2 );
     }
     if( Mouse.IsOver( rect ) )
     {
         if( zone != null )
         {
             if ( zone.AllSlotCellsList() != null && zone.AllSlotCellsList().Count > 0 )
                 Find.CameraDriver.JumpTo( zone.AllSlotCellsList().FirstOrDefault() );
         }
         if( Input.GetMouseButton( 0 ) &&
              zoneAllowed != zone )
         {
             zoneAllowed = zone;
             SoundDefOf.DesignateDragStandardChanged.PlayOneShotOnCamera();
         }
     }
     TooltipHandler.TipRegion( rect, label );
     Text.Anchor = TextAnchor.UpperLeft;
 }
Пример #7
0
 public override void OTabOnGUI(Rect fillRect)
 {
     Rect position = fillRect.ContractedBy(10f);
     GUI.BeginGroup(position);
     Rect position2 = new Rect(0f, 0f, position.width, 40f);
     GUI.BeginGroup(position2);
     Text.Font = GameFont.Small;
     GUI.color = Color.white;
     Text.Anchor = TextAnchor.UpperLeft;
     Rect rect = new Rect(5f, 5f, 140f, 30f);
     Widgets.LabelCheckbox(rect, "ManualPriorities".Translate(), ref Find.Map.playSettings.useWorkPriorities, false);
     float num = position2.width / 3f;
     float num2 = position2.width * 2f / 3f;
     Rect rect2 = new Rect(num - 50f, 5f, 160f, 30f);
     Rect rect3 = new Rect(num2 - 50f, 5f, 160f, 30f);
     GUI.color = new Color(1f, 1f, 1f, 0.5f);
     Text.Anchor = TextAnchor.UpperCenter;
     Text.Font = GameFont.Tiny;
     Widgets.Label(rect2, "<= " + "HigherPriority".Translate());
     Widgets.Label(rect3, "LowerPriority".Translate() + " =>");
     Text.Font = GameFont.Small;
     Text.Anchor = TextAnchor.UpperLeft;
     GUI.EndGroup();
     Rect position3 = new Rect(0f, 40f, position.width, position.height - 40f);
     GUI.BeginGroup(position3);
     Text.Font = GameFont.Small;
     GUI.color = Color.white;
     Rect outRect = new Rect(0f, 50f, position3.width, position3.height - 50f);
     this.workColumnSpacing = (position3.width - 16f - 175f) / (float)OTab_Droid_Work.VisibleWorkTypeDefsInPriorityOrder.Count;
     float num3 = 175f;
     int num4 = 0;
     foreach (WorkTypeDef current in OTab_Droid_Work.VisibleWorkTypeDefsInPriorityOrder)
     {
         Vector2 vector = Text.CalcSize(current.labelShort);
         float num5 = num3 + 15f;
         Rect rect4 = new Rect(num5 - vector.x / 2f, 0f, vector.x, vector.y);
         if (num4 % 2 == 1)
         {
             rect4.y += 20f;
         }
         if (rect4.Contains(Event.current.mousePosition))
         {
             Widgets.DrawHighlight(rect4);
         }
         Text.Anchor = TextAnchor.MiddleCenter;
         Widgets.Label(rect4, current.labelShort);
         WorkTypeDef localDef = current;
         TooltipHandler.TipRegion(rect4, new TipSignal(() => localDef.gerundLabel + "\n\n" + localDef.description, localDef.GetHashCode()));
         GUI.color = new Color(1f, 1f, 1f, 0.3f);
         Widgets.DrawLineVertical(num5, rect4.yMax - 3f, 50f - rect4.yMax + 3f);
         Widgets.DrawLineVertical(num5 + 1f, rect4.yMax - 3f, 50f - rect4.yMax + 3f);
         GUI.color = Color.white;
         num3 += this.workColumnSpacing;
         num4++;
     }
     DrawRows(outRect);
     GUI.EndGroup();
     GUI.EndGroup();
 }
Пример #8
0
        public override GizmoResult GizmoOnGUI(Vector2 topLeft)
        {
            var gizmoRect = new Rect(topLeft.x, topLeft.y, Width, Height);
            Widgets.DrawWindowBackground(gizmoRect);

            var gizmoRect_margined = gizmoRect.ContractedBy(5f);

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

            // header text
            var headerTextRect = gizmoRect_margined;
            headerTextRect.height = gizmoRect_margined.height / 3;
            headerTextRect.width = headerTextRect.height + 40;
            Widgets.Label(headerTextRect, "Block:");

            // melee block icon
            // NOTE: mouse over texture shows description
            //TooltipHandler.TipRegion(buttonRect, "gdfgdfgdfgdfgdfgf");
            var meleeBlock_IconRect = headerTextRect;
            meleeBlock_IconRect.y += headerTextRect.height;
            meleeBlock_IconRect.width = meleeBlock_IconRect.height;
            Widgets.DrawTextureFitted(meleeBlock_IconRect, meleeBlock_Icon, 0.9f);

            Text.Anchor = TextAnchor.MiddleLeft;

            // melee block hit chance label
            var meleeBlock_LabelRect = meleeBlock_IconRect;
            meleeBlock_LabelRect.x += meleeBlock_IconRect.width;
            meleeBlock_LabelRect.width = 40;
            Widgets.Label(meleeBlock_LabelRect, " " + (25 + shield.wearer.skills.GetSkill(SkillDefOf.Melee).level * 2) + "%");

            // ranged block icon
            var rangedBlock_IconRect = meleeBlock_IconRect;
            rangedBlock_IconRect.y += meleeBlock_IconRect.height;
            Widgets.DrawTextureFitted(rangedBlock_IconRect, rangedBlock_Icon, 0.9f);

            // ranged block hit chance label
            var rangedBlock_LabelRect = meleeBlock_LabelRect;
            rangedBlock_LabelRect.y += meleeBlock_LabelRect.height;
            Widgets.Label(rangedBlock_LabelRect, " " + (50 + shield.wearer.skills.GetSkill(SkillDefOf.Melee).level * 2) + "%");

            var healthMeterRect = rangedBlock_IconRect;
            healthMeterRect.x += rangedBlock_IconRect.width + rangedBlock_LabelRect.width;
            healthMeterRect.width = gizmoRect_margined.xMax - healthMeterRect.x;
            var fillPercent = shield.HitPoints / Mathf.Max(1f, shield.MaxHitPoints);
            // NOTE: Widgets.FillableBarLabeled?
            Widgets.FillableBar(healthMeterRect, fillPercent, FullTex, EmptyTex, false);

            var iconRect = new Rect(healthMeterRect.xMax - (healthMeterRect.xMax - healthMeterRect.x) / 2 - ShieldIcon_Size/2, gizmoRect_margined.y - ShieldIcon_Size / 5, ShieldIcon_Size, ShieldIcon_Size);
            Widgets.ThingIcon(iconRect, shield);

            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(healthMeterRect, shield.HitPoints + " / " + shield.MaxHitPoints);

            Text.Anchor = TextAnchor.UpperLeft;
            return new GizmoResult(GizmoState.Clear);
        }
        public override void DoWindowContents( Rect inRect )
        {
            // set up rects
            Rect filterRect = new Rect( inRect.ContractedBy( 6f ) );
            filterRect.height -= 2 * (Utilities.ListEntryHeight + Utilities.Margin);
            Rect zoneRect = new Rect(filterRect.xMin, filterRect.yMax + Utilities.Margin, filterRect.width, Utilities.ListEntryHeight);
            Rect buttonRect = new Rect( filterRect.xMin, zoneRect.yMax + Utilities.Margin, ( filterRect.width - Utilities.Margin ) / 2f, Utilities.ListEntryHeight );

            // draw thingfilter
            filterUI.DoThingFilterConfigWindow( filterRect, ref FilterScrollPosition, Trigger.ThresholdFilter );

            // draw zone selector
            StockpileGUI.DoStockpileSelectors(zoneRect, ref Trigger.stockpile);

            // draw operator button
            if ( Widgets.TextButton( buttonRect, Trigger.OpString ) )
            {
                List<FloatMenuOption> list = new List<FloatMenuOption>
                {
                    new FloatMenuOption( "Lower than", delegate { Trigger.Op = Trigger_Threshold.Ops.LowerThan; } ),
                    new FloatMenuOption( "Equal to", delegate { Trigger.Op = Trigger_Threshold.Ops.Equals; } ),
                    new FloatMenuOption( "Greater than", delegate { Trigger.Op = Trigger_Threshold.Ops.HigherThan; } )
                };
                Find.WindowStack.Add( new FloatMenu( list ) );
            }
            

            // move operator button canvas for count input
            buttonRect.x = buttonRect.xMax + Utilities.Margin;

            // if current input is invalid color the element red
            Color oldColor = GUI.color;
            if ( !Input.IsInt() )
            {
                GUI.color = new Color( 1f, 0f, 0f );
            }
            else
            {
                Trigger.Count = int.Parse( Input );
                if ( Trigger.Count > Trigger.MaxUpperThreshold )
                {
                    Trigger.MaxUpperThreshold = Trigger.Count;
                }
            }

            // draw the input field
            Input = Widgets.TextField( buttonRect, Input );
            GUI.color = oldColor;

            // close on enter
            if ( Event.current.type == EventType.KeyDown &&
                 Event.current.keyCode == KeyCode.Return )
            {
                Event.current.Use();
                Find.WindowStack.TryRemove( this );
            }
        }
        public override GizmoResult GizmoOnGUI(Vector2 topLeft)
        {
            var result = base.GizmoOnGUI(topLeft);

            Rect all = new Rect(topLeft.x, topLeft.y, this.Width, Gizmo.Height);
            Rect middle = all.ContractedBy(5f);
            GUI.color = Color.white;
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label(middle, parentContainer.Priority.Label());
            Text.Anchor = TextAnchor.UpperLeft;

            return result;
        }
        public override GizmoResult GizmoOnGUI(Vector2 topLeft)
        {
            var result = base.GizmoOnGUI(topLeft);

            Rect all = new Rect(topLeft.x, topLeft.y, this.Width, Gizmo.Height);
            Rect middle = all.ContractedBy(5f);
            GUI.color = Color.white;
            Text.Anchor = TextAnchor.MiddleCenter;
            Text.Font = GameFont.Medium;
            Widgets.Label(middle, string.Format("{0}%", parentContainer.ManualFillToPercent));
            Text.Font = GameFont.Tiny;
            Text.Anchor = TextAnchor.UpperLeft;

            return result;
        }
        protected override void FillTab()
        {
            Rect mainRect = new Rect(0, 0, size.x, size.y);
            Rect useRect = mainRect.ContractedBy(borderMargin);
            currentY = 0f;
            List<CrematoriusTarget> targets = ((Crematorius)SelPawn).GetTargets.OrderBy((CrematoriusTarget t) => t.NaturalPriority).ThenBy((CrematoriusTarget t) => t.Label).ToList();

            try
            {
                GUI.BeginGroup(useRect);
                foreach (var target in targets)
                {
                    DrawItemRow(target, currentY);
                    currentY += ItemSize.y + itemMargin;
                }
            }
            finally
            {
                GUI.EndGroup();
            }
        }
Пример #13
0
        public void DrawGUIOverlay()
        {
            if (!this.droid.SpawnedInWorld || Find.FogGrid.IsFogged(this.droid.Position))
            {
                return;
            }

            Vector3 vector = GenWorldUI.LabelDrawPosFor(this.droid, -0.6f);
            float num = vector.y;
            if (DroidUIOverlay.ShouldDrawOverlayOnMap(this.droid))
            {
                Text.Font = GameFont.Tiny;
                float num2 = Text.CalcSize(this.droid.Nickname).x;
                if (num2 < 20f)
                {
                    num2 = 20f;
                }
                Rect rect = new Rect(vector.x - num2 / 2f - 4f, vector.y, num2 + 8f, 12f);
                GUI.DrawTexture(rect, TexUI.GrayTextBG);
                if (this.droid.health.summaryHealth.SummaryHealthPercent < 0.999f)
                {
                    Rect screenRect = rect.ContractedBy(1f);
                    Widgets.FillableBar(screenRect, this.droid.health.summaryHealth.SummaryHealthPercent, PawnUIOverlay.HealthTex, BaseContent.ClearTex, false);
                }
                GUI.color = PawnNameColorUtility.PawnNameColorOf(this.droid);
                Text.Anchor = TextAnchor.UpperCenter;
                Widgets.Label(new Rect(vector.x - num2 / 2f, vector.y - 2f, num2, 999f), this.droid.Nickname);
                if (this.droid.playerController != null && this.droid.playerController.Drafted)
                {
                    Widgets.DrawLineHorizontal(vector.x - num2 / 2f, vector.y + 11f, num2);
                }
                GUI.color = Color.white;
                Text.Anchor = TextAnchor.UpperLeft;
                num += 12f;
            }
        }
 public override void DoWindowContents(Rect inRect)
 {
     Rect filterRect = new Rect(inRect.ContractedBy(6f));
     filterRect.height -= 30f;
     ThingFilterUiSearchable filterUi = new ThingFilterUiSearchable();
     filterUi.DoThingFilterConfigWindow(filterRect, ref FilterScrollPosition, Trigger.ThresholdFilter, null, 4);
     Rect buttonRect = new Rect(filterRect.xMin, filterRect.yMax + 3, (filterRect.width - 6) / 2, 25f);
     if (Widgets.TextButton(buttonRect, Trigger.OpString))
     {
         List<FloatMenuOption> list = new List<FloatMenuOption>
         {
             new FloatMenuOption("Lower than", delegate { Trigger.Op = TriggerThreshold.Ops.LowerThan; }),
             new FloatMenuOption("Equal to", delegate { Trigger.Op = TriggerThreshold.Ops.Equals; }),
             new FloatMenuOption("Greater than", delegate { Trigger.Op = TriggerThreshold.Ops.HigherThan; })
         };
         Find.WindowStack.Add(new FloatMenu(list));
     }
     buttonRect.x = buttonRect.xMax + 3f;
     Color oldColor = GUI.color;
     if (!Input.IsInt())
     {
         GUI.color = new Color(1f, 0f, 0f);
     }
     else
     {
         Trigger.Count = int.Parse(Input);
         if (Trigger.Count > Trigger.MaxUpperThreshold) Trigger.MaxUpperThreshold = Trigger.Count;
     }
     Input = Widgets.TextField(buttonRect, Input);
     GUI.color = oldColor;
     if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Return)
     {
         Event.current.Use();
         Find.WindowStack.TryRemove(this);
     }
 }
        protected override void DrawPawnRow( Rect rect, Pawn p )
        {
            // sizes for stuff

            float heightOffset = ( rect.height - iconSize ) / 2;
            float widthOffset = ( 50 - iconSize ) / 2;

            GUI.BeginGroup( rect );
            var curX = 175f;

            if ( p.training.IsCompleted( TrainableDefOf.Obedience ) )
            {
                var rect2 = new Rect( curX, 0f, 90f, rect.height );
                Rect rect3 = rect2.ContractedBy( 2f );
                string label = p.playerSettings.master == null
                                   ? "NoneLower".Translate()
                                   : p.playerSettings.master.LabelShort;
                Text.Font = GameFont.Small;
                if ( Widgets.ButtonText( rect3, label ) )
                {
                    TrainableUtility.OpenMasterSelectMenu( p );
                }
            }
            curX += 90f;

            if ( Widgets_PetFollow.PetFollowAvailable )
            {
                Rect draftedRect = new Rect( curX, 0f, 25f, 30f );
                Rect hunterRect = new Rect( curX + 25f, 0f, 25f, 30f );
                curX += 50f;

                if ( p.CanFollow() )
                {
                    Rect draftedIconRect =
                        new Rect( 0f, 0f, iconSize, iconSize ).CenteredOnYIn( draftedRect ).CenteredOnXIn( draftedRect );
                    Rect hunterIconRect =
                        new Rect( 0f, 0f, iconSize, iconSize ).CenteredOnYIn( hunterRect ).CenteredOnXIn( hunterRect );

                    // handle drafted follow
                    bool followDrafted = p.FollowsDrafted();
                    string draftedTip = followDrafted
                                            ? "Fluffy.PetFollow.FollowingDrafted".Translate()
                                            : "Fluffy.PetFollow.NotFollowingDrafted".Translate();
                    TooltipHandler.TipRegion( draftedRect, draftedTip );

                    if ( followDrafted )
                        GUI.DrawTexture( draftedIconRect, WorkBoxCheckTex );

                    if ( Mouse.IsOver( draftedRect ) )
                        Widgets.DrawHighlight( draftedIconRect );

                    if ( Widgets.ButtonInvisible( draftedRect ) )
                    {
                        p.FollowsDrafted( !followDrafted );
                        if ( followDrafted )
                            SoundDefOf.CheckboxTurnedOff.PlayOneShotOnCamera();
                        else
                            SoundDefOf.CheckboxTurnedOn.PlayOneShotOnCamera();
                    }

                    // handle hunter follow
                    bool followHunter = p.FollowsHunter();
                    string hunterTip = followHunter
                                           ? "Fluffy.PetFollow.FollowingHunter".Translate()
                                           : "Fluffy.PetFollow.NotFollowingHunter".Translate();
                    TooltipHandler.TipRegion( hunterRect, hunterTip );

                    if ( followHunter )
                        GUI.DrawTexture( hunterIconRect, WorkBoxCheckTex );

                    if ( Mouse.IsOver( hunterRect ) )
                        Widgets.DrawHighlight( hunterIconRect );

                    if ( Widgets.ButtonInvisible( hunterRect ) )
                    {
                        p.FollowsHunter( !followHunter );
                        if ( followHunter )
                            SoundDefOf.CheckboxTurnedOff.PlayOneShotOnCamera();
                        else
                            SoundDefOf.CheckboxTurnedOn.PlayOneShotOnCamera();
                    }
                }
            }

            var recta = new Rect( curX + widthOffset, heightOffset, iconSize, iconSize );
            Texture2D labelSex = GenderTextures[(int) p.gender];
            TipSignal tipSex = p.gender.ToString();
            GUI.DrawTexture( recta, labelSex );
            TooltipHandler.TipRegion( recta, tipSex );
            curX += 50f;

            var rectb = new Rect( curX + widthOffset, heightOffset, iconSize, iconSize );
            Texture2D labelAge = p.RaceProps.lifeStageAges.Count > 3
                                     ? LifeStageTextures[3]
                                     : LifeStageTextures[p.ageTracker.CurLifeStageIndex];
            TipSignal tipAge = p.ageTracker.CurLifeStage.LabelCap + ", " + p.ageTracker.AgeBiologicalYears;
            GUI.DrawTexture( rectb, labelAge );
            TooltipHandler.TipRegion( rectb, tipAge );
            curX += 50f;

            var pregnantRect = new Rect( curX + widthOffset, heightOffset, iconSize, iconSize );
            if ( p.Pregnant() )
            {
                GUI.DrawTexture( pregnantRect, PregnantTex );
                TooltipHandler.TipRegion( pregnantRect, "Fluffy.Pregnant".Translate( p.NameStringShort ));
            }
            curX += 50f;

            var rectc = new Rect( curX, 0f, 50f, 30f );
            var rectc1 = new Rect( curX + 17f, heightOffset, iconSize, iconSize );
            bool slaughter = Find.DesignationManager.DesignationOn( p, DesignationDefOf.Slaughter ) != null;

            if ( slaughter )
            {
                GUI.DrawTexture( rectc1, WorkBoxCheckTex );
                TooltipHandler.TipRegion( rectc, "Fluffy.StopSlaughter".Translate() );
            }
            else
            {
                TooltipHandler.TipRegion( rectc, "Fluffy.MarkSlaughter".Translate() );
            }
            if ( Widgets.ButtonInvisible( rectc ) )
            {
                if ( slaughter )
                {
                    Widgets_Animals.UnSlaughterAnimal( p );
                    SoundDefOf.CheckboxTurnedOff.PlayOneShotOnCamera();
                }
                else
                {
                    Widgets_Animals.SlaughterAnimal( p );
                    SoundDefOf.CheckboxTurnedOn.PlayOneShotOnCamera();
                }
            }
            if ( Mouse.IsOver( rectc ) )
            {
                GUI.DrawTexture( rectc1, TexUI.HighlightTex );
            }

            curX += 50f;

            var trainingRect = new Rect( curX, 0f, 80f, 30f );
            Widgets_Animals.DoTrainingRow( trainingRect, p );

            curX += 90f;

            var rect4 = new Rect( curX, 0f, 350f, rect.height );
            AreaAllowedGUI.DoAllowedAreaSelectors( rect4, p, AllowedAreaMode.Animal );
            GUI.EndGroup();
        }
        void DrawDisplayArea( Rect rect )
        {
            Widgets.DrawMenuSection( rect );

            if( SelectedHelpDef == null )
            {
                return;
            }

            Text.Font = GameFont.Medium;
            Text.WordWrap = false;
            float titleWidth = Text.CalcSize( SelectedHelpDef.LabelCap ).x;
            var titleRect = new Rect( rect.xMin + WindowMargin, rect.yMin + WindowMargin, titleWidth, 60f );
            if(
                ( SelectedHelpDef.keyDef != null )&&
                ( SelectedHelpDef.keyDef.IconTexture() != null )
            )
            {
                var iconRect = new Rect( titleRect.xMin + WindowMargin, rect.yMin + WindowMargin, 60f - 2 * WindowMargin, 60f - 2 * WindowMargin );
                titleRect.x += 60f;
                SelectedHelpDef.keyDef.DrawColouredIcon( iconRect );
            }
            Text.Anchor = TextAnchor.MiddleCenter;
            Widgets.Label( titleRect, SelectedHelpDef.LabelCap );
            Text.Font = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            Text.WordWrap = true;

            Rect outRect = rect.ContractedBy(WindowMargin);
            outRect.yMin += 60f;
            Rect viewRect = outRect;
            viewRect.width -= 16f;
            viewRect.height = ContentHeight;

            GUI.BeginGroup( outRect );
            Widgets.BeginScrollView( outRect.AtZero(), ref DisplayScrollPos, viewRect.AtZero() );

            Vector2 cur = Vector2.zero;

            HelpDetailSectionHelper.DrawText( ref cur, viewRect.width, SelectedHelpDef.description );

            cur.y += ParagraphMargin;

            foreach ( HelpDetailSection section in SelectedHelpDef.HelpDetailSections )
            {
                section.Draw( ref cur, viewRect.width, this );
            }

            ContentHeight = cur.y;

            Widgets.EndScrollView();
            GUI.EndGroup();
        }
Пример #17
0
        private void PreDrawPawnRow(Rect rect, Pawn p)
        {
            Rect rect2 = new Rect(0f, rect.y, rect.width, 30f);
            if (Mouse.IsOver(rect2) || MainTabWindow_Work.Copied == p)
            {
                GUI.DrawTexture(rect2, TexUI.HighlightTex);
            }
            Rect rect3 = new Rect(0f, rect.y, 175f, 30f);
            Rect position = rect3.ContractedBy(3f);
            if (p.health.summaryHealth.SummaryHealthPercent < 0.99f)
            {
                Rect rect4 = new Rect(rect3);
                rect4.xMin -= 4f;
                rect4.yMin += 4f;
                rect4.yMax -= 6f;
                Widgets.FillableBar(rect4, p.health.summaryHealth.SummaryHealthPercent, PawnUIOverlay.OverlayHealthTex, BaseContent.ClearTex, false);
            }
            if (Mouse.IsOver(rect3))
            {
                GUI.DrawTexture(position, TexUI.HighlightTex);
            }
            string label;
            if (!p.RaceProps.Humanlike && p.Name != null && !p.Name.Numerical)
            {
                label = p.Name.ToStringShort.CapitalizeFirst() + ", " + p.KindLabel;
            }
            else
            {
                label = p.LabelCap;
            }
            Text.Font = GameFont.Small;
            Text.Anchor = TextAnchor.MiddleLeft;
            Text.WordWrap = false;
            Rect rect5 = new Rect(rect3);
            rect5.xMin += 15f;
            Widgets.Label(rect5, label);
            Text.WordWrap = true;
            if (Event.current.type == EventType.MouseDown && Mouse.IsOver(rect3))
            {
                if (Event.current.button == 0)
                {
                    Find.MainTabsRoot.EscapeCurrentTab();
                    Find.CameraMap.JumpTo(p.PositionHeld);
                    Find.Selector.ClearSelection();
                    if (p.Spawned)
                    {
                        Find.Selector.Select(p);
                    }
                }
                if (Event.current.button == 1 && !p.RaceProps.Humanlike && p.Name != null && !p.Name.Numerical)
                {
                    Find.WindowStack.Add(new Dialog_RenamePet(p));
                }
                Event.current.Use();
            }

            TipSignal tooltip = p.GetTooltip();
            string temp = tooltip.text;
            tooltip.text = "Fluffy.ClickToJump".Translate();
            if (!p.RaceProps.Humanlike && p.Name != null && !p.Name.Numerical)
            {
                tooltip.text += "\n" + "Fluffy.RightClickToRename".Translate();
            }
            tooltip.text += "\n\n" + temp;
            TooltipHandler.TipRegion(rect3, tooltip);
        }
Пример #18
0
        protected override void DrawPawnRow(Rect rect, Pawn p)
        {
            // sizes for stuff
            float x = 16f;

            float heightOffset = (rect.height - x) / 2;
            float widthOffset = (50 - x) / 2;
            
            GUI.BeginGroup(rect);
            float num = 175f;

            if (p.training.IsCompleted(TrainableDefOf.Obedience))
            {
                Rect rect2 = new Rect(num, 0f, 90f, rect.height);
                Rect rect3 = rect2.ContractedBy(2f);
                string label = (p.playerSettings.master == null) ? "NoneLower".Translate() : p.playerSettings.master.LabelBaseShort;
                Text.Font = GameFont.Small;
                if (Widgets.TextButton(rect3, label))
                {
                    TrainableUtility.OpenMasterSelectMenu(p);
                }
            }
            num += 90f;
            
            Rect recta = new Rect(num + widthOffset, heightOffset, x, x);
            Texture2D labelSex = GenderTextures[(int)p.gender];
            TipSignal tipSex = p.gender.ToString();
            GUI.DrawTexture(recta, labelSex);
            TooltipHandler.TipRegion(recta, tipSex);
            num += 50f;

            Rect rectb = new Rect(num + widthOffset, heightOffset, x, x);
            var labelAge = p.RaceProps.lifeStageAges.Count > 3 ? LifeStageTextures[3] : LifeStageTextures[p.ageTracker.CurLifeStageIndex];
            TipSignal tipAge = p.ageTracker.CurLifeStage.LabelCap + ", " + p.ageTracker.AgeBiologicalYears;
            GUI.DrawTexture(rectb, labelAge);
            TooltipHandler.TipRegion(rectb, tipAge);
            num += 50f;

            Rect rectc = new Rect(num, 0f, 50f, 30f);
            Rect rectc1 = new Rect(num + 17f, heightOffset, x, x);
            bool slaughter = Find.DesignationManager.DesignationOn(p, DesignationDefOf.Slaughter) != null;

            if (slaughter)
            {
                GUI.DrawTexture(rectc1, WorkBoxCheckTex);
                TooltipHandler.TipRegion(rectc, "Fluffy.StopSlaughter".Translate());
            } else
            {
                TooltipHandler.TipRegion(rectc, "Fluffy.MarkSlaughter".Translate());
            }
            if (Widgets.InvisibleButton(rectc))
            {
                if (slaughter)
                {
                    Widgets_Animals.UnSlaughterAnimal(p);
                    SoundDefOf.CheckboxTurnedOff.PlayOneShotOnCamera();
                }
                else
                {
                    Widgets_Animals.SlaughterAnimal(p);
                    SoundDefOf.CheckboxTurnedOn.PlayOneShotOnCamera();
                }
            }
            if (Mouse.IsOver(rectc))
            {
                GUI.DrawTexture(rectc1, TexUI.HighlightTex);
            }

            num += 50f;

            Rect trainingRect = new Rect(num, 0f, 80f, 30f);
            Widgets_Animals.DoTrainingRow(trainingRect, p);

            num += 90f;

            Rect rect4 = new Rect(num, 0f, 350f, rect.height);
            AreaAllowedGUI.DoAllowedAreaSelectors(rect4, p, AllowedAreaMode.Animal);
            GUI.EndGroup();
        }
        public override void DoWindowContents(Rect windowRect)
        {
            MapComponent_AutoEquip mapComponent = MapComponent_AutoEquip.Get;
            PawnCalcForApparel pawnAutoEquip = new PawnCalcForApparel(mapComponent.GetCache(this.pawn));
            List<Apparel> allApparels = new List<Apparel>(Find.ListerThings.ThingsInGroup(ThingRequestGroup.Apparel).OfType<Apparel>());
            foreach (Pawn pawn in Find.ListerPawns.FreeColonists)
            {
                foreach (Apparel pawnApparel in pawn.apparel.WornApparel)
                    if (pawn.outfits.forcedHandler.AllowedToAutomaticallyDrop(pawnApparel))
                        allApparels.Add(pawnApparel);
            }

            allApparels = allApparels.Where(i => !ApparelUtility.CanWearTogether(this.apparel.def, i.def)).ToList();

            Rect groupRect = windowRect.ContractedBy(10f);
            groupRect.height -= 100;
            GUI.BeginGroup(groupRect);

            float apparelScoreWidth = 100f;
            float apparelGainWidth = 100f;
            float apparelLabelWidth = (groupRect.width - apparelScoreWidth - apparelGainWidth) / 3 - 8f - 8f;
            float apparelEquipedWidth = apparelLabelWidth;
            float apparelOwnerWidth = apparelLabelWidth;

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

            this.DrawLine(ref itemRect,
                null, "Apparel", apparelLabelWidth,
                null, "Equiped", apparelEquipedWidth,
                null, "Target", apparelOwnerWidth,
                "Score", apparelScoreWidth,
                "Gain", apparelGainWidth);

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

            Rect viewRect = new Rect(groupRect.xMin, groupRect.yMin, groupRect.width - 16f, allApparels.Count() * 28f + 16f);
            if (viewRect.height < groupRect.height)
                groupRect.height = viewRect.height;

            Rect listRect = viewRect.ContractedBy(4f);

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

            allApparels = allApparels.OrderByDescending(i => { float g; if (pawnAutoEquip.CalculateApparelScoreGain(i, out g)) return g; return -1000f; }).ToList();

            foreach (Apparel currentAppel in allApparels)
            {
                itemRect = new Rect(listRect.xMin, listRect.yMin, listRect.width, 28f);
                if (Mouse.IsOver(itemRect))
                {
                    GUI.color = ITab_Pawn_AutoEquip.HighlightColor;
                    GUI.DrawTexture(itemRect, TexUI.HighlightTex);
                    GUI.color = Color.white;
                }

                Pawn equiped = null;
                Pawn target = null;

                foreach (Pawn pawn in Find.ListerPawns.FreeColonists)
                {
                    foreach (Apparel a in pawn.apparel.WornApparel)
                        if (a == currentAppel)
                        {
                            equiped = pawn;
                            break;
                        }

                    foreach (Apparel a in mapComponent.GetCache(pawn).targetApparel)
                        if (a == currentAppel)
                        {
                            target = pawn;
                            break;
                        }

                    if ((equiped != null) &&
                        (target != null))
                        break;
                }

                float gain;
                if (pawnAutoEquip.CalculateApparelScoreGain(currentAppel, out gain))
                    this.DrawLine(ref itemRect,
                        currentAppel, currentAppel.LabelCap, apparelLabelWidth,
                        equiped, equiped == null ? null : equiped.LabelCap, apparelEquipedWidth,
                        target, target == null ? null : target.LabelCap, apparelOwnerWidth,
                        pawnAutoEquip.CalculateApparelScoreRaw(currentAppel).ToString("N5"), apparelScoreWidth,
                        gain.ToString("N5"), apparelGainWidth);
                else
                    this.DrawLine(ref itemRect,
                        currentAppel, currentAppel.LabelCap, apparelLabelWidth,
                        equiped, equiped == null ? null : equiped.LabelCap, apparelEquipedWidth,
                        target, target == null ? null : target.LabelCap, apparelOwnerWidth,
                        pawnAutoEquip.CalculateApparelScoreRaw(currentAppel).ToString("N5"), apparelScoreWidth,
                        "No Allow", apparelGainWidth);

                listRect.yMin = itemRect.yMax;
            }

            Widgets.EndScrollView();

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

            GUI.color = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.EndGroup();
        }
Пример #20
0
        public void DrawDetailedLegend( Rect canvas, ref Vector2 scrollPos, int? max, bool positiveOnly = false, bool negativeOnly = false )
        {
            // set sign
            int sign = negativeOnly ? -1 : 1;

            List<Chapter> ChaptersOrdered = _chapters
                .Where( chapter => !positiveOnly || chapter.pages[periodShown].Any( i => i > 0 ) )
                .Where( chapter => !negativeOnly || chapter.pages[periodShown].Any( i => i < 0 ) )
                .OrderByDescending( chapter => chapter.Last( periodShown ) * sign ).ToList();

            // get out early if no chapters.
            if( ChaptersOrdered.Count == 0 )
            {
                GUI.DrawTexture( canvas.ContractedBy( Utilities.Margin ), _plotBG );
                Utilities.Label( canvas, "FM.HistoryNoChapters".Translate(), null, TextAnchor.MiddleCenter, color: Color.grey );
                return;
            }

            // max 
            float _max = max ?? ( DrawMaxMarkers
                                 ? ChaptersOrdered.Max( chapter => (int)chapter.TrueMax ) 
                                 : ChaptersOrdered.FirstOrDefault()?.Last( periodShown ) * sign )
                             ?? 0;
            
            // cell height
            float height = 30f;
            float barHeight = 18f;

            // n rows
            int n = ChaptersOrdered.Count;

            // scrolling region
            Rect viewRect = canvas;
            viewRect.height = n * height;
            if ( viewRect.height > canvas.height )
            {
                viewRect.width -= 16f + Utilities.Margin;
                canvas.width -= Utilities.Margin;
                canvas.height -= 1f;
            }
            Widgets.BeginScrollView( canvas, ref scrollPos, viewRect);
            for ( int i = 0; i < n; i++ )
            {
                // set up rects
                Rect row      = new Rect( 0f, height * i, viewRect.width, height );
                Rect icon     = new Rect( Utilities.Margin, height * i, height, height ).ContractedBy( Utilities.Margin / 2f ); // icon is square, size defined by height.
                Rect bar      = new Rect( Utilities.Margin + height, height * i, viewRect.width - height - Utilities.Margin, height );

                // if icons should not be drawn make the bar full size.
                if (!DrawIcons) bar.xMin -= height + Utilities.Margin;

                // bar details.
                Rect barBox   = bar.ContractedBy( ( height - barHeight ) / 2f );
                Rect barFill  = barBox.ContractedBy( 2f );
                float maxWidth = barFill.width;
                if ( MaxPerChapter )
                {
                    barFill.width *= ChaptersOrdered[i].Last( periodShown ) * sign / (float)ChaptersOrdered[i].TrueMax;
                }
                else
                {
                    barFill.width *= ChaptersOrdered[i].Last( periodShown ) * sign / _max;
                }
                
                GUI.BeginGroup( viewRect );

                // if DrawIcons and a thing is set, draw the icon.
                ThingDef thing = ChaptersOrdered[i].ThingCount?.thingDef;
                if( DrawIcons && thing != null )
                {
                    // draw the icon in correct proportions
                    float proportion = GenUI.IconDrawScale( thing );
                    Widgets.DrawTextureFitted( icon, thing.uiIcon, proportion );

                    // draw counts in upper left corner
                    if ( DrawCounts )
                    {
                        Utilities.LabelOutline( icon, ChaptersOrdered[i].ThingCount.count.ToString(), null,
                                         TextAnchor.UpperLeft, 0f, 0f, GameFont.Tiny, Color.white, Color.black );
                    }
                }

                // if desired, draw ghost bar
                if( DrawMaxMarkers )
                {
                    Rect ghostBarFill = barFill;
                    ghostBarFill.width = MaxPerChapter ? maxWidth : maxWidth * ( ChaptersOrdered[i].TrueMax / _max );
                    GUI.color = new Color( 1f, 1f, 1f, .2f );
                    GUI.DrawTexture( ghostBarFill, ChaptersOrdered[i].Texture ); // coloured texture
                    GUI.color = Color.white;
                }

                // draw the main bar.
                GUI.DrawTexture( barBox, Resources.SlightlyDarkBackground );
                GUI.DrawTexture( barFill, ChaptersOrdered[i].Texture ); // coloured texture
                GUI.DrawTexture( barFill, Resources.BarShader ); // slightly fancy overlay (emboss).
                
                // draw on bar info
                if ( DrawInfoInBar )
                {
                    string info = ChaptersOrdered[i].label + ": " +
                                  FormatCount( ChaptersOrdered[i].Last( periodShown ) * sign );

                    if ( DrawMaxMarkers )
                    {
                        info += " / " + FormatCount( ChaptersOrdered[i].TrueMax );
                    }

                    // offset label a bit downwards and to the right
                    Rect rowInfoRect = row;
                    rowInfoRect.y += 3f;
                    rowInfoRect.x += Utilities.Margin * 2;

                    // x offset
                    float xOffset = DrawIcons && thing != null ? height + Utilities.Margin * 2 : Utilities.Margin * 2;

                    Utilities.LabelOutline( rowInfoRect, info, null, TextAnchor.MiddleLeft, xOffset, 0f, GameFont.Tiny, Color.white, Color.black );
                }

                // are we currently showing this line?
                bool shown = _chaptersShown.Contains( ChaptersOrdered[i] );

                // tooltip on entire row
                string tooltip = ChaptersOrdered[i].label + ": " + FormatCount( Mathf.Abs( ChaptersOrdered[i].Last( periodShown ) ) );
                tooltip += "FM.HistoryClickToEnable".Translate( shown ? "hide" : "show", ChaptersOrdered[i].label );
                TooltipHandler.TipRegion( row, tooltip);

                // handle input
                if ( Widgets.InvisibleButton( row ) )
                {
                    if ( Event.current.button == 0 )
                    {
                        if ( shown )
                        {
                            _chaptersShown.Remove( ChaptersOrdered[i] );
                        }
                        else
                        {
                            _chaptersShown.Add( ChaptersOrdered[i] );
                        }
                    } else if ( Event.current.button == 1 )
                    {
                        _chaptersShown.Clear();
                        _chaptersShown.Add( ChaptersOrdered[i] );
                    }
                }

                // UI feedback for disabled row
                if ( !shown )
                {
                    GUI.DrawTexture( row, Resources.SlightlyDarkBackground );
                }

                GUI.EndGroup();
            }
            Widgets.EndScrollView();
        }
        protected override void FillTab()
        {
            if(Droid==null)
            {
                Log.Error("Cremation control ITab tried to display on a non droid");
                return;
            }

            Rect mainRect = new Rect(0, 0, size.x, size.y);
            Rect useRect = mainRect.ContractedBy(borderMargin);
            currentY = 0f;
            CremationWorker worker = Droid.work.specialist.GetWorker<CremationWorker>();
            List<CremationTarget> targets = worker.AllTargets.OrderBy((CremationTarget t) => t.NaturalPriority).ThenBy((CremationTarget t) => t.Label).ToList();

            try
            {
                GUI.BeginGroup(useRect);
                foreach (var target in targets)
                {
                    DrawItemRow(target, currentY);
                    currentY += ItemSize.y + itemMargin;
                }
            }
            finally
            {
                GUI.EndGroup();
            }
        }
        /// <summary>
        ///     Draw billgivers info + details button
        /// </summary>
        public void DrawBillGiverConfig( ref Vector2 cur, float width, float entryHeight, bool alt = false )
        {
            // target threshold
            string potentialString = string.Join( "\n", PotentialBillGivers.Select( b => b.LabelCap ).ToArray() );
            string selectedString = string.Join( "\n", SelectedBillGivers.Select( b => b.LabelCap ).ToArray() );
            string assignedString = string.Join( "\n", AssignedBillGivers.Select( b => b.LabelCap ).ToArray() );
            string billgiverTooltip = "FMP.BillGiversTooltip".Translate( potentialString, selectedString, assignedString );

            var billgiverLabelRect = new Rect( cur.x, cur.y, width, entryHeight );
            if ( alt )
            {
                Widgets.DrawAltRect( billgiverLabelRect );
            }
            Widgets.DrawHighlightIfMouseover( billgiverLabelRect );
            Utilities.Label( billgiverLabelRect,
                             "FMP.BillGiversCount".Translate( PotentialBillGivers.Count, SelectedBillGivers.Count,
                                                              AssignedBillGivers.Count ),
                             billgiverTooltip,
                             TextAnchor.MiddleLeft,
                             Utilities.Margin );
            if ( Widgets.ButtonInvisible( billgiverLabelRect ) )
            {
                Find.WindowStack.Add( DetailsWindow );
            }

            // add a little icon to mark interactivity
            var searchIconRect = new Rect( billgiverLabelRect.xMax - Utilities.Margin - entryHeight, cur.y, entryHeight,
                                           entryHeight );
            if ( searchIconRect.height > Utilities.SmallIconSize )
            {
                // center it.
                searchIconRect = searchIconRect.ContractedBy( ( searchIconRect.height - Utilities.SmallIconSize ) / 2 );
            }
            GUI.DrawTexture( searchIconRect, Resources.Search );

            cur.y += entryHeight;
        }
Пример #23
0
        public void DrawPlot( Rect rect, int target = 0, string label = "", bool positiveOnly = false, bool negativeOnly = false )
        {
            // set sign
            int sign = negativeOnly ? -1 : 1;

            // subset chapters
            List<Chapter> chapters = _chaptersShown.Where( chapter => !positiveOnly || chapter.pages[periodShown].Any( i => i > 0 ) )
                               .Where( chapter => !negativeOnly || chapter.pages[periodShown].Any( i => i < 0 ) )
                               .ToList();

            // get out early if no chapters.
            if ( chapters.Count == 0 )
            {
                GUI.DrawTexture( rect.ContractedBy(Utilities.Margin), _plotBG );
                Utilities.Label( rect, "FM.HistoryNoChapters".Translate(), null, TextAnchor.MiddleCenter, color: Color.grey );
                return;
            }


            // stuff we need
            Rect plot = rect.ContractedBy( Utilities.Margin );
            plot.xMin += _yAxisMargin;

            // maximum of all chapters.
            int max = CeilToPrecision( Math.Max( chapters.Select( c => c.Max( periodShown, !negativeOnly ) ).Max(), target ) * 1.2f );

            // size, and pixels per node.
            float w = plot.width;
            float h = plot.height;
            float wu = w / Size; // width per section
            float hu = h / max; // height per count
            int bi = max / ( Breaks + 1 ); // count per break
            float bu = hu * bi; // height per break

            // plot the line(s)
            GUI.DrawTexture( plot, _plotBG );
            GUI.BeginGroup( plot );
            foreach ( Chapter chapter in chapters )
            {
                chapter.Plot( periodShown, plot.AtZero(), wu, hu, sign );
            }

            // handle mouseover events
            if ( Mouse.IsOver( plot.AtZero() ) )
            {
                // very conveniently this is the position within the current group.
                Vector2 pos = Event.current.mousePosition;
                Vector2 upos = new Vector2(pos.x / wu, (plot.height - pos.y) / hu);

                // get distances
                float[] distances = chapters.Select( c => Math.Abs( c.ValueAt( periodShown, (int)upos.x, sign ) - upos.y ) ).ToArray();
                
                // get the minimum index
                float min = int.MaxValue;
                int minIndex = 0;
                for ( int i = 0; i < distances.Count(); i++ )
                {
                    if ( distances[i] < min )
                    {
                        minIndex = i;
                        min = distances[i];
                    }
                }

                // closest line
                Chapter closest = chapters[minIndex];

                // do minimum stuff.
                Vector2 realpos = new Vector2( pos.x, plot.height - closest.ValueAt( periodShown, (int)upos.x, sign ) * hu );
                Rect blipRect = new Rect(realpos.x - Utilities.SmallIconSize / 2f, realpos.y - Utilities.SmallIconSize / 2f, Utilities.SmallIconSize, Utilities.SmallIconSize );
                GUI.color = closest.lineColor;
                GUI.DrawTexture( blipRect, Resources.StageB );
                GUI.color = DefaultLineColor;

                // get orientation of tooltip
                Vector2 tippos = realpos + new Vector2( Utilities.Margin, Utilities.Margin );
                string tip = chapters[minIndex].label + ": " + FormatCount( chapters[minIndex].ValueAt( periodShown, (int)upos.x, sign ));
                Vector2 tipsize = Text.CalcSize( tip );
                bool up = false, left = false;
                if ( tippos.x + tipsize.x > plot.width )
                {
                    left = true;
                    tippos.x -= tipsize.x + 2 * + Utilities.Margin;
                }
                if ( tippos.y + tipsize.y > plot.height )
                {
                    up = true;
                    tippos.y -= tipsize.y + 2 * Utilities.Margin;
                }

                TextAnchor anchor = TextAnchor.UpperLeft;
                if (up && left) anchor = TextAnchor.LowerRight;
                if ( up && !left ) anchor = TextAnchor.LowerLeft;
                if ( !up && left ) anchor = TextAnchor.UpperRight;
                Rect tooltipRect = new Rect( tippos.x, tippos.y, tipsize.x, tipsize.y );
                Utilities.Label( tooltipRect, tip, anchor: anchor, font: GameFont.Tiny );
            }

            // draw target line
            if ( DrawTargetLine )
            {
                GUI.color = Color.gray;
                for ( int i = 0; i < plot.width / DashLength; i += 2 )
                {
                    Widgets.DrawLineHorizontal( i * DashLength, plot.height - target * hu, DashLength );
                }
            }

            // draw legend
            int lineCount = _chapters.Count;
            if ( AllowTogglingLegend && lineCount > 1 && DrawInlineLegend )
            {
                float rowHeight = 20f;
                float lineLength = 30f;
                float labelWidth = 100f;

                Vector2 cur = Vector2.zero;
                foreach ( Chapter chapter in _chapters )
                {
                    GUI.color = chapter.lineColor;
                    Widgets.DrawLineHorizontal(cur.x, cur.y + rowHeight / 2f, lineLength);
                    cur.x += lineLength;
                    Utilities.Label( ref cur, labelWidth, rowHeight, chapter.label, font: GameFont.Tiny );
                    cur.x = 0f;
                }
                GUI.color = Color.white;
            }

            GUI.EndGroup();

            // plot axis
            GUI.BeginGroup( rect );
            Text.Anchor = TextAnchor.MiddleRight;
            Text.Font = GameFont.Tiny;

            // draw ticks + labels
            for ( int i = 1; i < Breaks + 1; i++ )
            {
                Widgets.DrawLineHorizontal( _yAxisMargin + Margin / 2, plot.height - i * bu, Margin );
                Rect labRect = new Rect( 0f, plot.height - i * bu - 4f, _yAxisMargin, 20f );
                Widgets.Label( labRect, FormatCount(  i * bi ) );
            }

            Text.Font = GameFont.Small;
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.color = Color.white;

            rect = rect.AtZero(); // ugh, I'm tired, just work.

            // period / variables picker
            if ( DrawOptions )
            {
                Rect switchRect = new Rect( rect.xMax - Utilities.SmallIconSize - Utilities.Margin,
                                            rect.yMin + Utilities.Margin, Utilities.SmallIconSize,
                                            Utilities.SmallIconSize );

                Widgets.DrawHighlightIfMouseover( switchRect );
                if ( Widgets.ImageButton( switchRect, Resources.Cog ) )
                {
                    List<FloatMenuOption> options =
                        periods.Select(
                            p =>
                                new FloatMenuOption( "FM.HistoryPeriod".Translate() + ": " + p.ToString(),
                                                     delegate { periodShown = p; } ) ).ToList();
                    if ( AllowTogglingLegend && _chapters.Count > 1 ) // add option to show/hide legend if appropriate.
                    {
                        options.Add( new FloatMenuOption( "FM.HistoryShowHideLegend".Translate(),
                                                          delegate { DrawInlineLegend = !DrawInlineLegend; } ) );
                    }
                    Find.WindowStack.Add( new FloatMenu( options ) );
                }
            }

            GUI.EndGroup();
        }
        protected override void FillWindow(Rect inRect)
        {
            Rect innerRect = inRect.ContractedBy(Margin);
            try
            {
                GUI.BeginGroup(innerRect);
                float midPoint = innerRect.width / 2f;
                Vector2 labelSize = new Vector2(innerRect.width / 2 - 40f, 30f);
                Vector2 menuSize = new Vector2(innerRect.width / 2 - 40f, innerRect.height - 30f - 10f - labelSize.y - 4f);

                Rect availableLabelRect = new Rect(0f, 0f, labelSize.x, labelSize.y);
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(availableLabelRect, "AvailablePackages".Translate());

                Rect selectedLabelRect = new Rect(midPoint + 40f, 0f, labelSize.x, labelSize.y);
                Widgets.Label(selectedLabelRect, "SelectedPackages".Translate());
                Text.Anchor = TextAnchor.UpperLeft;

                Rect availableRect = new Rect(0f, labelSize.y + 4f, menuSize.x, menuSize.y);
                _entrySize = new Vector2(availableRect.width - 16f, 30f);
                float availableHeight = (from t in DefDatabase<WorkPackageDef>.AllDefs
                                         where t.displayInMenu && _displayableFunc(t) && !_bp.WorkPackages.Contains(t)
                                         select t).Count() * _entrySize.y;
                Rect availableViewRect = new Rect(0f, availableRect.y, menuSize.x - 16f, availableHeight);
                float availableY = availableRect.y;
                bool alternate = false;
                Widgets.DrawMenuSection(availableRect);
                Widgets.BeginScrollView(availableRect, ref _availableScrollPosition, availableViewRect);
                foreach (var p in (from t in DefDatabase<WorkPackageDef>.AllDefs
                                   where t.displayInMenu && _displayableFunc(t) && !_bp.WorkPackages.Contains(t)
                                   orderby t.label
                                   select t))
                {
                    Rect entryRect = new Rect(0f, availableY, _entrySize.x, _entrySize.y);
                    DrawAvailableEntry(p, entryRect, alternate);
                    availableY += _entrySize.y;
                    alternate = !alternate;
                }
                Widgets.EndScrollView();

                Rect selectedRect = new Rect(midPoint + 40f, labelSize.y + 4f, menuSize.x, menuSize.y);
                float selectedHeight = (from t in _bp.WorkPackages
                                        where t.displayInMenu && _displayableFunc(t)
                                        orderby t.label
                                        select t).Count() * _entrySize.y;
                availableY = selectedRect.y;
                alternate = false;
                Rect selectedViewRect = new Rect(selectedRect.x, selectedRect.y, menuSize.x - 16f, selectedHeight);
                Widgets.DrawMenuSection(selectedRect);

                Widgets.BeginScrollView(selectedRect, ref _selectedScrollPosition, selectedViewRect);
                foreach (var p in (from t in _bp.WorkPackages
                                   where t.displayInMenu && _displayableFunc(t)
                                   select t).ToList())
                {
                    Rect entryRect = new Rect(selectedRect.x, availableY, _entrySize.x, _entrySize.y);
                    DrawSelectedEntry(p, entryRect, alternate);
                    availableY += _entrySize.y;
                    alternate = !alternate;
                }
                Widgets.EndScrollView();

                Rect buttonRect = new Rect(midPoint - 60f, innerRect.height - 30f, 120f, 30f);
                if (Widgets.TextButton(buttonRect, "Accept".Translate()))
                {
                    Close();
                }

                string powerUsage = "PowerRequirement".Translate((from t in _bp.WorkPackages
                    select t.PowerRequirement).Sum().ToString("0.#"));
                Vector2 powerRequirementSize = Text.CalcSize(powerUsage);
                Rect powerUsageRect = new Rect(innerRect.width - powerRequirementSize.x,
                    innerRect.height - powerRequirementSize.y, powerRequirementSize.x, powerRequirementSize.y);
                Widgets.Label(powerUsageRect, powerUsage);
            }
            finally
            {
                GUI.EndGroup();
                Text.Anchor = TextAnchor.UpperLeft;
            }
        }
Пример #25
0
        public override void DoWindowContents(Rect windowRect)
        {
            PawnCalcForApparel conf = new PawnCalcForApparel(this.pawn);

            Rect groupRect = windowRect.ContractedBy(10f);
            groupRect.height -= 100;
            GUI.BeginGroup(groupRect);

            float baseValue = 100f;
            float multiplierWidth = 100f;
            float finalValue = 120f;
            float labelWidth = groupRect.width - baseValue - multiplierWidth - finalValue - 8f - 8f;

            Rect itemRect = new Rect(groupRect.xMin + 4f, groupRect.yMin, groupRect.width - 8f, Text.LineHeight * 1.2f);

            this.DrawLine(ref itemRect,
                "Status", labelWidth,
                "Base", baseValue,
                "Strengh", multiplierWidth,
                "Final", finalValue);

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

            Saveable_StatDef[] stats = conf.Stats.ToArray();
            Rect viewRect = new Rect(groupRect.xMin, groupRect.yMin, groupRect.width - 16f, stats.Length * Text.LineHeight * 1.2f + 16f);
            if (viewRect.height < groupRect.height)
                groupRect.height = viewRect.height;

            Rect listRect = viewRect.ContractedBy(4f);

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

            float sumValue = 0;
            foreach (Saveable_StatDef stat in stats)
            {
                itemRect = new Rect(listRect.xMin, listRect.yMin, listRect.width, Text.LineHeight * 1.2f);
                if (Mouse.IsOver(itemRect))
                {
                    GUI.color = ITab_Pawn_AutoEquip.HighlightColor;
                    GUI.DrawTexture(itemRect, TexUI.HighlightTex);
                    GUI.color = Color.white;
                }

                float value = conf.GetStatValue(apparel, stat);
                sumValue += value;

                this.DrawLine(ref itemRect,
                    stat.statDef.label, labelWidth,
                    value.ToString("N3"), baseValue,
                    stat.strength.ToString("N2"), multiplierWidth,
                    (value * stat.strength).ToString("N5"), finalValue);

                listRect.yMin = itemRect.yMax;
            }

            Widgets.EndScrollView();

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

            itemRect = new Rect(listRect.xMin, groupRect.yMax, listRect.width, Text.LineHeight * 1.2f);
            this.DrawLine(ref itemRect,
                "AverageStat".Translate(), labelWidth,
                (sumValue / stats.Length).ToString("N3"), baseValue,
                "", multiplierWidth,
                conf.CalculateApparelScoreRawStats(apparel).ToString("N5"), finalValue);

            itemRect.yMax += 5;

            itemRect = new Rect(listRect.xMin, itemRect.yMax, listRect.width, Text.LineHeight * 1.2f);
            this.DrawLine(ref itemRect,
                "AutoEquipHitPoints".Translate(), labelWidth,
                conf.CalculateApparelScoreRawHitPointAjust(apparel).ToString("N3"), baseValue,
                "", multiplierWidth,
                "", finalValue);

            itemRect = new Rect(listRect.xMin, itemRect.yMax, listRect.width, Text.LineHeight * 1.2f);
            this.DrawLine(ref itemRect,
                "AutoEquipTemperature".Translate(), labelWidth,
                conf.CalculateApparelScoreRawInsulationColdAjust(apparel).ToString("N3"), baseValue,
                "", multiplierWidth,
                "", finalValue);

            itemRect = new Rect(listRect.xMin, itemRect.yMax, listRect.width, Text.LineHeight * 1.2f);
            this.DrawLine(ref itemRect,
                "AutoEquipTotal".Translate(), labelWidth,
                conf.CalculateApparelModifierRaw(apparel).ToString("N3"), baseValue,
                "", multiplierWidth,
                conf.CalculateApparelScoreRaw(apparel).ToString("N5"), finalValue);

            GUI.color = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
            GUI.EndGroup();
        }
            public override GizmoResult GizmoOnGUI(UnityEngine.Vector2 topLeft)
            {
                Rect overRect = new Rect(topLeft.x, topLeft.y, Width, Height);
                Widgets.DrawWindowBackground(overRect);

                Rect inRect = overRect.ContractedBy(6);

                //Item label
                {
                    Rect textRect = inRect;
                    textRect.height = overRect.height / 2;
                    Text.Font = GameFont.Tiny;
                    Widgets.Label(textRect, shield.LabelCap);
                }

                //Bar
                {
                    Rect barRect = inRect;
                    barRect.yMin = overRect.y + overRect.height / 2f;
                    //float ePct = shield.Energy / Mathf.Max(1f, shield.GetStatValue(StatDefOf.PersonalShieldEnergyMax));
                    float ePct = shield.Energy / Mathf.Max(1f, shield.maxEnergy);
                    Widgets.FillableBar(barRect, ePct, FullTex, EmptyTex, false);
                    Text.Font = GameFont.Small;
                    Text.Anchor = TextAnchor.MiddleCenter;
                    //Widgets.Label(barRect, (shield.Energy * 100).ToString("F0") + " / " + (shield.GetStatValue(StatDefOf.PersonalShieldEnergyMax) * 100).ToString("F0"));
                    Widgets.Label(barRect, (shield.Energy).ToString("F0") + " / " + (shield.maxEnergy).ToString("F0"));
                    Text.Anchor = TextAnchor.UpperLeft;
                }

                return new GizmoResult(GizmoState.Clear);
            }
Пример #27
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);
 }
Пример #28
0
        protected override void FillTab()
        {
            burner = SelThing.TryGetComp<CompFueled>();

            const float MarginSize = 5f;
            const float TextHeight = 25f;

            // height is the total count of used text field heights and margins
            size = new Vector2(432f, TextHeight * 6 + MarginSize * 3);

            // make smaller rect with margin size borders
            var innerRect = new Rect(0f, 0f, size.x, size.y).ContractedBy(MarginSize);
            Text.Anchor = TextAnchor.MiddleCenter;
            GUI.BeginGroup(innerRect);
            {
                // allowed fuel types filter button
                var filterRect = new Rect(0f, 0f, innerRect.width / 2, TextHeight);
                {
                    if (Widgets.ButtonText(filterRect, "Fuel filter"))
                    {
                        Find.WindowStack.Add(new Window_ThingFilter(burner, 105f));
                    }
                }

                // fuel container info
                var fuelRect = new Rect(0f, filterRect.height + MarginSize, filterRect.width, innerRect.height - (filterRect.height + MarginSize));
                // fuel container background
                Widgets.DrawMenuSection(fuelRect);
                // contract actual size after drawing BG
                fuelRect = fuelRect.ContractedBy(MarginSize);
                // if fuel tank not empty
                if (burner.fuelContainer.Count > 0)
                {
                    if (Widgets.ButtonInvisible(fuelRect))
                    {
                        var options = new List<FloatMenuOption>
                        {
                            new FloatMenuOption("Fuel Info",
                                () => { Find.WindowStack.Add(new Dialog_InfoCard(burner.fuelContainer[0])); }),
                            new FloatMenuOption("Fuel Drop".Translate(),
                                () => { burner.fuelContainer.TryDropAll(burner.parent.Position, ThingPlaceMode.Near); })
                        };

                        Find.WindowStack.Add(new FloatMenu(options, string.Empty));
                    }

                    GUI.BeginGroup(fuelRect);
                    {
                        var fuel = burner.fuelContainer[0];

                        // current fuel type icon
                        var fuelIconRect = new Rect(0f, 0f, TextHeight * 2, TextHeight * 2);
                        Widgets.DrawTextureFitted(fuelIconRect, IconBGTex, 1);
                        Widgets.ThingIcon(fuelIconRect.ContractedBy(2f), fuel);

                        // burning fillable bar
                        var burningLabelRect = new Rect(fuelIconRect.width + MarginSize, 0f, fuelRect.width - (fuelIconRect.width + MarginSize), fuelIconRect.height / 2);
                        Widgets.Label(burningLabelRect, "Burning progress:");
                        var burningBarRect = new Rect(burningLabelRect.x, burningLabelRect.height, burningLabelRect.width, burningLabelRect.height);
                        
                        var percentBurnDuration = burner.currentFuelBurnDuration / (fuel.GetStatValue(StatDef.Named("BurnDurationHours")) * GenDate.TicksPerHour);
                        Widgets.FillableBar(burningBarRect, percentBurnDuration, FullTexFuel, EmptyTex, false);

                        // fuel count fillable bar
                        var fuelCountBarRect = new Rect(0f, burningBarRect.yMax + MarginSize, fuelRect.width, 20f);
                        var fillPercentFuelCount = fuel.stackCount / (float)fuel.def.stackLimit;
                        Widgets.FillableBar(fuelCountBarRect, fillPercentFuelCount, FullTexFuelCount, EmptyTex, false);
                        Widgets.Label(fuelCountBarRect, string.Format("Fuel amount: {0}/{1}", fuel.stackCount, fuel.def.stackLimit));

                        Text.Anchor = TextAnchor.MiddleLeft;
                        // current fuel type info
                        var fuelEstimatedTimeRect = new Rect(0f, fuelCountBarRect.yMax + MarginSize / 2, fuelRect.width, 20f);
                        Widgets.Label(fuelEstimatedTimeRect, string.Format("Depletes after:\t{0}", TimeInfo(fuel.stackCount * (int)fuel.GetStatValue(StatDef.Named("BurnDurationHours")) * GenDate.TicksPerHour)));
                        // current fuel type info
                        var fuelMaxTempRect = new Rect(0f, fuelEstimatedTimeRect.yMax, fuelRect.width, fuelEstimatedTimeRect.height);
                        Widgets.Label(fuelMaxTempRect, string.Format("Max tempertarure:\t{0} °C", fuel.GetStatValue(StatDef.Named("MaxBurningTempCelsius"))));
                    }
                    GUI.EndGroup();
                }
                // no fuel
                else
                {
                    Text.Anchor = TextAnchor.MiddleCenter;
                    Text.Font = GameFont.Medium;
                    Widgets.Label(fuelRect, "No fuel");
                    Text.Font = GameFont.Small;
                }

                // burner info
                var burnerRect = new Rect(filterRect.width + MarginSize, 0f, innerRect.width - (fuelRect.width + MarginSize * 3), innerRect.height);
                GUI.BeginGroup(burnerRect);
                {
                    Text.Anchor = TextAnchor.MiddleCenter;

                    // refuel percent slider
                    var sliderLabelRect = new Rect(0f, 0f, burnerRect.width, TextHeight);
                    Widgets.Label(sliderLabelRect, "Refuel at " + burner.fuelStackRefuelPercent.ToStringPercent());
                    var sliderRect = new Rect(0f, sliderLabelRect.height - 2.5f, burnerRect.width, TextHeight / 2);
                    burner.fuelStackRefuelPercent = GUI.HorizontalSlider(sliderRect, burner.fuelStackRefuelPercent, 0f, 1f);

                    // burner fillable bar
                    var burnerLabelRect = new Rect(0f, sliderRect.yMax, burnerRect.width, TextHeight);
                    Widgets.Label(burnerLabelRect, "Internal temperature:");
                    var burnerBarRect = new Rect(0f, burnerLabelRect.yMax, burnerRect.width, TextHeight);
                    var percentRequiredHeat = Mathf.Min(burner.internalTemp / burner.compFueled.Properties.operatingTemp, 1f);
                    Widgets.FillableBar(burnerBarRect, percentRequiredHeat, percentRequiredHeat == 1 ? FullTexBurnerHight : FullTexBurnerLow, EmptyTex, false);
                    // line, indiciting operating temp, when internal is above that
                    if (percentRequiredHeat == 1)
                        Widgets.DrawLineVertical(burnerBarRect.x + burnerBarRect.width * (1 -burner.compFueled.Properties.operatingTemp / burner.internalTemp), burnerBarRect.y, burnerBarRect.height);
                    Widgets.Label(burnerBarRect, burner.internalTemp.ToString("F1") + " °C");

                    // burner operating temp label
                    var burnerOpLabelRect = new Rect(0f, burnerBarRect.yMax, burnerRect.width, TextHeight);
                    Widgets.Label(burnerOpLabelRect, "Operating temperature: " + burner.compFueled.Properties.operatingTemp +" °C");

                    // burner current condition label
                    var burnerConditionLabelRect = new Rect(0f, burnerOpLabelRect.yMax, burnerRect.width * 0.55f, burnerRect.height - burnerOpLabelRect.yMax);
                    Text.Anchor = TextAnchor.MiddleRight;
                    Widgets.Label(burnerConditionLabelRect, "Current status:");
                    // burner current condition status
                    var burnerConditionStatusRect = new Rect(burnerConditionLabelRect.xMax, burnerConditionLabelRect.y, burnerRect.width - burnerConditionLabelRect.width, burnerConditionLabelRect.height);
                    string status;
                    if (burner.internalTemp >= burner.compFueled.Properties.operatingTemp)
                    {
                        status = " working";
                        GUI.color = Color.green;
                    }
                    else
                    {
                        status = " low temp";
                        GUI.color = Color.red;
                    }
                    Text.Anchor = TextAnchor.MiddleLeft;
                    Widgets.Label(burnerConditionStatusRect, status);
                    GUI.color = Color.white;
                }
                GUI.EndGroup();
            }
            GUI.EndGroup();
            // resets text anchor to upper left (game default)
            GenUI.ResetLabelAlign();
        }
        public void DrawSlots(Rect inventoryRect)
        {
            // draw text message if no contents inside
            if (slotsComp.slots.Count == 0)
            {
                Text.Font = GameFont.Medium;
                Text.Anchor = TextAnchor.MiddleCenter;
                Widgets.Label(inventoryRect, "No Items");
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font = GameFont.Tiny;
            }
            // draw slots
            else
            {
                var slotRect = new Rect(inventoryRect.x, inventoryRect.y, Height, Height);
                for (var currentSlotInd = 0; currentSlotInd < slotsComp.Properties.maxSlots; currentSlotInd++)
                {
                    // draw occupied slots
                    if (currentSlotInd < slotsComp.slots.Count)
                    {
                        // draws greyish slot background
                        Widgets.DrawTextureFitted(slotRect.ContractedBy(3f), texOccupiedSlotBG, 1f);
                        // highlights slot if mouse over
                        Widgets.DrawHighlightIfMouseover(slotRect.ContractedBy(3f));

                        var currentThing = slotsComp.slots[currentSlotInd];

                        // draw thing texture
                        Widgets.ThingIcon(slotRect, currentThing);

                        // interaction with slots
                        if (Widgets.ButtonInvisible(slotRect))
                        {
                            // mouse button pressed
                            if (Event.current.button == 0)
                            {
                                // equip weapon in slot
                                if (currentThing.def.equipmentType == EquipmentType.Primary)
                                {
                                    slotsComp.SwapEquipment(currentThing as ThingWithComps);
                                }
                            }
                            // mouse button released
                            else if (Event.current.button == 1)
                            {
                                var options = new List<FloatMenuOption>
                                {
                                    new FloatMenuOption("Info",
                                        () => { Find.WindowStack.Add(new Dialog_InfoCard(currentThing)); }),
                                    new FloatMenuOption("Drop", () =>
                                    {
                                        Thing resultThing;
                                        slotsComp.slots.TryDrop(currentThing, slotsComp.owner.Position,
                                            ThingPlaceMode.Near, out resultThing);
                                    })
                                };
                                // get thing info card
                                // drop thing
                                Find.WindowStack.Add(new FloatMenu(options, currentThing.LabelCap));
                            }

                            // plays click sound on each click
                            SoundDefOf.Click.PlayOneShotOnCamera();
                        }
                    }

                    slotRect.x += Height;
                }
            }
        }
Пример #30
0
 private static bool DoAreaSelector( Rect rect, Area area, bool status )
 {
     rect = rect.ContractedBy( 1f );
     GUI.DrawTexture( rect, area == null ? BaseContent.GreyTex : area.ColorTexture );
     Text.Anchor = TextAnchor.MiddleLeft;
     string text = AreaUtility.AreaAllowedLabel_Area( area );
     Rect rect2 = rect;
     rect2.xMin += 3f;
     rect2.yMin += 2f;
     Widgets.Label( rect2, text );
     if ( status )
         Widgets.DrawBox( rect, 2 );
     if ( Mouse.IsOver( rect ) )
     {
         if ( area != null )
             area.MarkForDraw();
         if ( Widgets.ButtonInvisible( rect ) )
         {
             SoundDefOf.DesignateDragStandardChanged.PlayOneShotOnCamera();
             return !status;
         }
     }
     TooltipHandler.TipRegion( rect, text );
     return status;
 }