private void DoArchivableRow(Rect rect, IArchivable archivable, int index)
        {
            if (index % 2 == 1)
            {
                Widgets.DrawLightHighlight(rect);
            }
            Widgets.DrawHighlightIfMouseover(rect);
            Text.Font     = GameFont.Small;
            Text.Anchor   = TextAnchor.MiddleLeft;
            Text.WordWrap = false;
            Rect rect2 = rect;
            Rect rect3 = rect2;

            rect3.width = 30f;
            rect2.xMin += 40f;
            float num;

            if (Find.Archive.IsPinned(archivable))
            {
                num = 1f;
            }
            else if (Mouse.IsOver(rect3))
            {
                num = 0.25f;
            }
            else
            {
                num = 0f;
            }
            if (num > 0f)
            {
                GUI.color = new Color(1f, 1f, 1f, num);
                GUI.DrawTexture(new Rect(rect3.x + (rect3.width - 22f) / 2f, rect3.y + (rect3.height - 22f) / 2f, 22f, 22f).Rounded(), MainTabWindow_History.PinTex);
                GUI.color = Color.white;
            }
            Rect rect4     = rect2;
            Rect outerRect = rect2;

            outerRect.width = 30f;
            rect2.xMin     += 40f;
            Texture archivedIcon = archivable.ArchivedIcon;

            if (archivedIcon != null)
            {
                GUI.color = archivable.ArchivedIconColor;
                Widgets.DrawTextureFitted(outerRect, archivedIcon, 0.8f);
                GUI.color = Color.white;
            }
            Rect rect5 = rect2;

            rect5.width = 200f;
            rect2.xMin += 210f;
            Vector2 location = (Find.CurrentMap == null) ? default(Vector2) : Find.WorldGrid.LongLatOf(Find.CurrentMap.Tile);

            GUI.color = new Color(0.75f, 0.75f, 0.75f);
            int    num2 = GenDate.TickGameToAbs(archivable.CreatedTicksGame);
            string str  = string.Concat(new object[]
            {
                GenDate.DateFullStringAt((long)num2, location),
                ", ",
                GenDate.HourInteger((long)num2, location.x),
                "LetterHour".Translate()
            });

            Widgets.Label(rect5, str.Truncate(rect5.width, null));
            GUI.color = Color.white;
            Rect rect6 = rect2;

            Widgets.Label(rect6, archivable.ArchivedLabel.Truncate(rect6.width, null));
            GenUI.ResetLabelAlign();
            Text.WordWrap = true;
            TooltipHandler.TipRegion(rect3, "PinArchivableTip".Translate(200));
            if (Mouse.IsOver(rect4))
            {
                TooltipHandler.TipRegion(rect4, archivable.ArchivedTooltip);
            }
            if (Widgets.ButtonInvisible(rect3, false))
            {
                if (Find.Archive.IsPinned(archivable))
                {
                    Find.Archive.Unpin(archivable);
                    SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera(null);
                }
                else
                {
                    Find.Archive.Pin(archivable);
                    SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera(null);
                }
            }
            if (Widgets.ButtonInvisible(rect4, false))
            {
                if (Event.current.button == 1)
                {
                    LookTargets lookTargets = archivable.LookTargets;
                    if (CameraJumper.CanJump(lookTargets.TryGetPrimaryTarget()))
                    {
                        CameraJumper.TryJumpAndSelect(lookTargets.TryGetPrimaryTarget());
                        Find.MainTabsRoot.EscapeCurrentTab(true);
                    }
                }
                else
                {
                    archivable.OpenArchived();
                }
            }
        }
Ejemplo n.º 2
0
        private void DoArchivableRow(Rect rect, IArchivable archivable, int index)
        {
            if (index % 2 == 1)
            {
                Widgets.DrawLightHighlight(rect);
            }
            Widgets.DrawHighlightIfMouseover(rect);
            Text.Font     = GameFont.Small;
            Text.Anchor   = TextAnchor.MiddleLeft;
            Text.WordWrap = false;
            Rect rect2 = rect;
            Rect rect3 = rect2;

            rect3.width = 30f;
            rect2.xMin += 35f;
            float num      = Find.Archive.IsPinned(archivable) ? 1f : ((!Mouse.IsOver(rect3)) ? 0f : 0.25f);
            Rect  position = new Rect(rect3.x + (rect3.width - 22f) / 2f, rect3.y + (rect3.height - 22f) / 2f, 22f, 22f).Rounded();

            if (num > 0f)
            {
                GUI.color = new Color(1f, 1f, 1f, num);
                GUI.DrawTexture(position, PinTex);
            }
            else
            {
                GUI.color = PinOutlineColor;
                GUI.DrawTexture(position, PinOutlineTex);
            }
            GUI.color = Color.white;
            Rect rect4     = rect2;
            Rect outerRect = rect2;

            outerRect.width = 30f;
            rect2.xMin     += 35f;
            Texture archivedIcon = archivable.ArchivedIcon;

            if (archivedIcon != null)
            {
                GUI.color = archivable.ArchivedIconColor;
                Widgets.DrawTextureFitted(outerRect, archivedIcon, 0.8f);
                GUI.color = Color.white;
            }
            Rect rect5 = rect2;

            rect5.width = 80f;
            rect2.xMin += 85f;
            Vector2 location = (Find.CurrentMap != null) ? Find.WorldGrid.LongLatOf(Find.CurrentMap.Tile) : default(Vector2);

            GUI.color = new Color(0.75f, 0.75f, 0.75f);
            Widgets.Label(label: GenDate.DateShortStringAt(GenDate.TickGameToAbs(archivable.CreatedTicksGame), location).Truncate(rect5.width), rect: rect5);
            GUI.color = Color.white;
            Rect rect6 = rect2;

            Widgets.Label(rect6, archivable.ArchivedLabel.Truncate(rect6.width));
            GenUI.ResetLabelAlign();
            Text.WordWrap = true;
            TooltipHandler.TipRegionByKey(rect3, "PinArchivableTip", 200);
            if (Mouse.IsOver(rect4))
            {
                displayedMessageIndex = index;
            }
            if (Widgets.ButtonInvisible(rect3))
            {
                if (Find.Archive.IsPinned(archivable))
                {
                    Find.Archive.Unpin(archivable);
                    SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera();
                }
                else
                {
                    Find.Archive.Pin(archivable);
                    SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera();
                }
            }
            if (!Widgets.ButtonInvisible(rect4))
            {
                return;
            }
            if (Event.current.button == 1)
            {
                LookTargets lookTargets = archivable.LookTargets;
                if (CameraJumper.CanJump(lookTargets.TryGetPrimaryTarget()))
                {
                    CameraJumper.TryJumpAndSelect(lookTargets.TryGetPrimaryTarget());
                    Find.MainTabsRoot.EscapeCurrentTab();
                }
            }
            else
            {
                archivable.OpenArchived();
            }
        }