示例#1
0
        private void DrawSaveList(List <SaveFile> saves, float width, ref float y)
        {
            for (int i = 0; i < saves.Count; i++)
            {
                var  saveFile  = saves[i];
                Rect entryRect = new Rect(0, y, width, 40);

                if (saveFile == selectedFile)
                {
                    Widgets.DrawRectFast(entryRect, new Color(1f, 1f, 0.7f, 0.1f));

                    var lineColor = new Color(1, 1, 1, 0.3f);
                    Widgets.DrawLine(entryRect.min, entryRect.TopRightCorner(), lineColor, 2f);
                    Widgets.DrawLine(entryRect.min + new Vector2(2, 1), entryRect.BottomLeftCorner() + new Vector2(2, -1), lineColor, 2f);
                    Widgets.DrawLine(entryRect.BottomLeftCorner(), entryRect.max, lineColor, 2f);
                    Widgets.DrawLine(entryRect.TopRightCorner() - new Vector2(2, -1), entryRect.max - new Vector2(2, 1), lineColor, 2f);
                }
                else if (i % 2 == 0)
                {
                    Widgets.DrawAltRect(entryRect);
                }

                Text.Anchor = TextAnchor.MiddleLeft;
                Widgets.Label(entryRect.Right(10), saveFile.displayName);
                Text.Anchor = TextAnchor.UpperLeft;

                GUI.color = new Color(0.6f, 0.6f, 0.6f);
                Text.Font = GameFont.Tiny;

                var infoText = new Rect(entryRect.xMax - 120, entryRect.yMin + 3, 120, entryRect.height);
                Widgets.Label(infoText, saveFile.file.LastWriteTime.ToString("g"));

                if (saveFile.gameName != null)
                {
                    Widgets.Label(infoText.Down(16), saveFile.gameName.Truncate(110));
                }
                else
                {
                    GUI.color = saveFile.VersionColor;
                    Widgets.Label(infoText.Down(16), (saveFile.rwVersion ?? "???").Truncate(110));
                }

                if (saveFile.replay && saveFile.protocol != MpVersion.Protocol)
                {
                    bool autosave = saveFile.replaySections > 1;

                    GUI.color = autosave ? new Color(0.8f, 0.8f, 0, 0.6f) : new Color(0.8f, 0.8f, 0);
                    var outdated = new Rect(infoText.x - 80, infoText.y + 8f, 80, 24f);
                    Widgets.Label(outdated, "MpReplayOutdated".Translate());

                    string text = "MpReplayOutdatedDesc1".Translate(saveFile.protocol, MpVersion.Protocol) + "\n\n" + "MpReplayOutdatedDesc2".Translate() + "\n" + "MpReplayOutdatedDesc3".Translate();
                    if (autosave)
                    {
                        text += "\n\n" + "MpReplayOutdatedDesc4".Translate();
                    }

                    TooltipHandler.TipRegion(outdated, text);
                }

                Text.Font = GameFont.Small;
                GUI.color = Color.white;

                if (Widgets.ButtonInvisible(entryRect))
                {
                    if (Event.current.button == 0)
                    {
                        selectedFile = saveFile;
                    }
                    else
                    {
                        Find.WindowStack.Add(new FloatMenu(SaveFloatMenu(saveFile).ToList()));
                    }
                }

                y += 40;
            }
        }