Esempio n. 1
0
        public override void DoWindowContents(Rect canvas)
        {
            var rows      = new Grid(canvas).Rows(HEADER_HEIGHT, FIELD_HEIGHT, BUTTON_HEIGHT);
            var titleRect = rows[0].Rect;
            var nameRect  = rows[1].Column(9);
            var iconRect  = rows[1].Column(3);

            rows[2].Column(4);
            var cancelRect = rows[2].Column(4);
            var okRect     = rows[2].Column(4);

            // title and a little text
            Widgets.Label(titleRect, "Fluffy.WorkTab.CreateFavouritesDialogTitle".Translate(), font: GameFont.Medium);

            // favourites label
            var valid = FavouriteManager.IsValidLabel(label);

            GUI.color = valid ? Color.white : Color.red;
            label     = GUI.TextField(nameRect, label);
            GUI.color = Color.white;

            // icon tumbler
            textureChooser.DrawAt(iconRect);

            // ok/cancel button.
            if (Verse.Widgets.ButtonText(cancelRect, "CancelButton".Translate()))
            {
                Close();
            }
            if (Verse.Widgets.ButtonText(okRect, "AcceptButton".Translate()))
            {
                ApplyAndClose();
            }
        }
Esempio n. 2
0
 public override void PostClose()
 {
     base.PostClose();
     if (favourite.Label.NullOrEmpty() || favourite.Icon == null)
     {
         FavouriteManager.Remove(favourite);
     }
 }
Esempio n. 3
0
        public void DeleteAndClose()
        {
            var options = new List <FloatMenuOption>();

            options.Add(new FloatMenuOption("Fluffy.WorkTab.UnloadFavourite".Translate(),
                                            () => { FavouriteManager.Remove(favourite); Close(); }));
            options.Add(new FloatMenuOption("Fluffy.WorkTab.DeleteFavourite".Translate(),
                                            () => { FavouriteManager.Delete(favourite, true); Close(); }));
            Find.WindowStack.Add(new FloatMenu(options));
        }
Esempio n. 4
0
        public void ApplyAndClose()
        {
            var valid = FavouriteManager.IsValidLabel(label, favourite.Label);

            if (!valid)
            {
                Messages.Message(valid.Reason, MessageTypeDefOf.RejectInput, false);
                return;
            }

            favourite.Icon  = textureChooser.Choice;
            favourite.Label = label;

            FavouriteManager.Favourites.Add(favourite);
            FavouriteManager.Get[pawn] = favourite;
            FavouriteManager.Save(favourite);

            Close();
        }
Esempio n. 5
0
 public FavouriteManager()
 {
     _instance = this;
 }
Esempio n. 6
0
 protected override void ClickedIcon(Pawn pawn)
 {
     FavouriteManager.FavouriteFloatMenuFor(pawn);
 }