private void DrawFileEntry(Rect rect, SaveFileInfo file)
        {
            GUI.BeginGroup(rect);

            // set up rects
            Rect nameRect = rect.AtZero();

            nameRect.width -= 200f + _iconSize + 4 * _margin;
            nameRect.xMin  += _margin;
            var timeRect   = new Rect(nameRect.xMax + _margin, 0f, 100f, rect.height);
            var buttonRect = new Rect(timeRect.xMax + _margin, 1f, 100f, rect.height - 2f);
            var deleteRect = new Rect(buttonRect.xMax + _margin, (rect.height - _iconSize) / 2, _iconSize, _iconSize);

            // name
            Text.Anchor = TextAnchor.MiddleLeft;
            Widgets.Label(nameRect, Path.GetFileNameWithoutExtension(file.FileInfo.Name));
            Text.Anchor = TextAnchor.UpperLeft;

            // timestamp
            GUI.color = Color.gray;
            Dialog_FileList.DrawDateAndVersion(file, timeRect);
            Text.Font = GameFont.Small;
            GUI.color = Color.white;

            // load button
            if (Widgets.ButtonText(buttonRect, "FM.Import".Translate()))
            {
                TryImport(file);
            }

            // delete button
            if (Widgets.ButtonImage(deleteRect, Resources.DeleteX))
            {
                Find.WindowStack.Add(new Dialog_Confirm("ConfirmDelete".Translate(file.FileInfo.Name), delegate
                {
                    file
                    .FileInfo
                    .Delete
                        ();
                    Refresh
                        ();
                }, true));
            }

            GUI.EndGroup();
        }
예제 #2
0
        /// <summary>
        /// Draws the window contents
        /// </summary>
        /// <param name="rect">The rect to draw into</param>
        public override void DoWindowContents(Rect rect)
        {
            // Title
            Text.Font = GameFont.Medium;
            Widgets.Label(new Rect(0f, 0f, rect.width, titleHeight), "Dialog_Import_Title".Translate());
            Text.Font = GameFont.Small;


            Rect inRect = rect;

            // Description
            Rect DescRect = inRect;

            DescRect.y      = titleHeight + paddingSize;
            DescRect.height = labelDescriptionHeight;
            Widgets.Label(DescRect, "Dialog_Import_Desc".Translate());

            // File list
            Vector2 vector2_1 = new Vector2(inRect.width - 16f, 36f);

            Text.Font = GameFont.Small;
            Vector2 vector2_2 = new Vector2(100f, vector2_1.y - 2f);

            inRect.height = listViewHeight;
            float height   = (float)this.files.Count * (vector2_1.y + 3f);
            Rect  viewRect = new Rect(0.0f, 0.0f, inRect.width - 800f, height);
            Rect  outRect  = inRect.AtZero();

            outRect.y = DescRect.yMax + paddingSize;
            Widgets.BeginScrollView(outRect, ref this.scrollPosition, viewRect);
            float y   = 0.0f;
            int   num = 0;

            using (List <SaveFileInfo> .Enumerator enumerator = this.files.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    SaveFileInfo current = enumerator.Current;
                    Rect         rect1   = new Rect(0.0f, y, vector2_1.x, vector2_1.y);
                    if (num % 2 == 0)
                    {
                        Widgets.DrawAltRect(rect1);
                    }
                    Rect position = rect1.ContractedBy(1f);
                    GUI.BeginGroup(position);
                    string withoutExtension = Path.GetFileNameWithoutExtension(current.FileInfo.Name);
                    GUI.color = this.FileNameColor(current);
                    Rect rect2 = new Rect(15f, 0.0f, position.width, position.height);
                    Text.Anchor = TextAnchor.MiddleLeft;
                    Text.Font   = GameFont.Small;
                    Widgets.Label(rect2, withoutExtension);
                    GUI.color = Color.white;
                    Rect rect3 = new Rect(270f, 0.0f, 200f, position.height);
                    Dialog_FileList.DrawDateAndVersion(current, rect3);

                    // Mod count label
                    GUI.color = SaveFileInfo.UnimportantTextColor;
                    Rect countLabel = new Rect(430, 10f, 150f, position.height);
                    Widgets.Label(countLabel, GetModsCountString(current));

                    GUI.color   = Color.white;
                    Text.Anchor = TextAnchor.UpperLeft;
                    Text.Font   = GameFont.Small;
                    float x = vector2_1.x - 2f - vector2_2.x;
                    TooltipHandler.TipRegion(new Rect(x, 0.0f, vector2_2.x, vector2_2.y), "Button_Select_Tooltip".Translate());
                    if (Widgets.ButtonText(new Rect(x, 0.0f, vector2_2.x, vector2_2.y), this.interactButLabel, true, false, true))
                    {
                        this.DoFileInteraction(Path.GetFileNameWithoutExtension(current.FileInfo.Name));
                    }
                    GUI.EndGroup();
                    y += vector2_1.y + 3f;
                    ++num;
                }
            }
            Widgets.EndScrollView();
        }