예제 #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();
            }
        }
예제 #2
0
 public override void PostClose()
 {
     base.PostClose();
     if (favourite.Label.NullOrEmpty() || favourite.Icon == null)
     {
         FavouriteManager.Remove(favourite);
     }
 }
예제 #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));
        }
예제 #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();
        }
예제 #5
0
 public FavouriteManager()
 {
     _instance = this;
 }
예제 #6
0
 protected override void ClickedIcon(Pawn pawn)
 {
     FavouriteManager.FavouriteFloatMenuFor(pawn);
 }