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