Esempio n. 1
0
        public SaveLoadDialog()
        {
            this.closeOnCancel           = true;
            this.doCloseButton           = true;
            this.doCloseX                = true;
            this.absorbInputAroundWindow = true;
            this.forcePause              = true;

            SaveLoader.LoadAll();
        }
Esempio n. 2
0
        public override void DoWindowContents(Rect inRect)
        {
            int     padding        = 16;
            int     scrollBarWidth = 20;
            Vector2 buttonSize     = new Vector2(150, 30);
            Vector2 rowSize        = new Vector2(inRect.width - buttonSize.x - padding - scrollBarWidth, 36);

            List <PawnFilter> list       = RandomSettings.pawnFilterList.ToList();
            float             listHeight = list.Count * rowSize.y;
            Rect listViewRect            = new Rect(0, 0, rowSize.x, listHeight);

            inRect.height -= 40;

            Rect outRect = new Rect(0, 0, inRect.width - buttonSize.x - padding, inRect.height - buttonSize.y - padding - 20);

            Widgets.BeginScrollView(outRect, ref this.scrollPosition, listViewRect);
            try
            {
                float num2 = 0;
                int   num3 = 0;
                for (int i = 0; i < list.Count; i++)
                {
                    PawnFilter current = list[i];
                    Rect       rect    = new Rect(0, num2, rowSize.x, rowSize.y);
                    if (selectedIndex == i)
                    {
                        GUI.DrawTexture(rect, Textures.TextureHighlightRow);
                    }
                    else if (num3 % 2 == 0)
                    {
                        GUI.DrawTexture(rect, Textures.TextureAlternateRow);
                    }

                    Color color = selectedIndex == i ? new Color(0.7f, 0.7f, 0.7f, 1) : Color.white;
                    if (Widgets.ButtonText(rect, "", false, true, color))
                    {
                        selectedIndex = i;
                        Filename      = current.name;
                    }

                    Rect innerRect = new Rect(rect.x + 3, rect.y + 3, rect.width - 6, rect.height - 6);

                    GUI.BeginGroup(innerRect);
                    try
                    {
                        GUI.color = ManualSaveTextColor;
                        Rect rect2 = new Rect(15, 0, rowSize.x, rowSize.y);
                        Text.Anchor = TextAnchor.MiddleLeft;
                        Text.Font   = GameFont.Small;
                        Widgets.Label(rect2, current.name);
                        GUI.color = Color.white;
                    }
                    finally
                    {
                        GUI.EndGroup();
                    }
                    num2 += rowSize.y;
                    num3++;
                }
            }
            finally
            {
                Widgets.EndScrollView();
                Text.Anchor = TextAnchor.UpperLeft;
                Text.Font   = GameFont.Small;
            }

            Rect buttonAreaRect = new Rect(listViewRect.x + listViewRect.width + padding + scrollBarWidth, 0, buttonSize.x, outRect.height);

            GUI.BeginGroup(buttonAreaRect);
            try
            {
                if (selectedIndex == -1)
                {
                    GUI.enabled = false;
                }

                Rect loadButtonRect = new Rect(0, 0, buttonSize.x, buttonSize.y);
                if (Widgets.ButtonText(loadButtonRect, "RandomPlus.SaveLoadDialog.LoadButton".Translate(), true, false, true))
                {
                    SaveLoader.Load(RandomSettings.pawnFilterList[selectedIndex]);
                    Close();
                }

                Rect deleteButtonRect = loadButtonRect.OffsetBy(new Vector2(0, buttonSize.y + padding));
                if (Widgets.ButtonText(deleteButtonRect, "RandomPlus.SaveLoadDialog.DeleteButton".Translate(), true, false, true))
                {
                    SaveLoader.Delete(RandomSettings.pawnFilterList[selectedIndex]);
                    selectedIndex = -1;
                }

                if (selectedIndex == -1)
                {
                    GUI.enabled = true;
                }
            }
            finally
            {
                GUI.EndGroup();
            }


            this.DrawFooter(inRect.AtZero());
        }