public override void ContributeMemberRightClickMenu(object member, Menu rightClickMenu, Context context, Widget rightClickedWidget) { if (member is Trait && UIFactory.EditAuthorized(this, "traits")) { rightClickMenu.Append(new SeparatorMenuItem()); rightClickMenu.Append(MenuFactory.CreateRemoveButton(this, member)); } }
public override Widget GetCellContents(Context context) { bool editable = UIFactory.EditAuthorized(this, "structures"); //Creates the cell contents VBox structureBox = new VBox(false, 0) { BorderWidth = 3 }; foreach (Structure structure in structures) { InspectableBox header = (InspectableBox)structure.GetHeader(context.butInUIContext(this)); if (editable) { MyDragDrop.SetFailAction(header, delegate { Remove(structure); DependencyManager.TriggerAllFlags(); }); } structureBox.PackStart(header, false, false, 0); } if (editable) { //Set up dropping EventBox eventBox = new EventBox { Child = structureBox, VisibleWindow = false }; MyDragDrop.DestSet(eventBox, "Structure"); MyDragDrop.DestSetDropAction(eventBox, delegate { if (Accepts(MyDragDrop.currentDragged)) { Add(MyDragDrop.currentDragged); DependencyManager.TriggerAllFlags(); } }); return(new Gtk.Alignment(0, 0, 1, 0) { Child = eventBox, BorderWidth = 7 }); } else { structureBox.BorderWidth += 7; return(structureBox); } //For some reason drag/drop highlights include BorderWidth. //The Alignment makes the highlight actually appear at the 3:7 point in the margin. }
public Territory(TerritoryData data) { name = data.name; ID = data.ID; position = data.position; size = data.size; reputation = data.reputation; structures = data.structures.ConvertAll((structure) => Game.city.Get <Structure>(structure)); foreach (Structure structure in structures) { DependencyManager.Connect(structure, this); structure.parent = this; } traits = data.mechanics.ConvertAll((input) => Trait.Load(input)); foreach (Trait mechanic in traits) { DependencyManager.Connect(mechanic, this); mechanic.parent = this; } attack = new GameAction { name = "Attack", description = "Launch an attack on " + name, action = delegate(Context context) { attackers = new Attack(this); Game.city.activeBattlegrounds.Add(this); DependencyManager.Connect(this, attackers); DependencyManager.Flag(this); DependencyManager.TriggerAllFlags(); Inspector.InspectInNearestInspector(attackers, MainWindow.main); }, condition = (context) => attackers == null && UIFactory.EditAuthorized(this, "attack") }; defend = new GameAction { name = "Defend", description = "Mount a defense of " + name, action = delegate(Context context) { defenders = new Defense(this); DependencyManager.Connect(this, defenders); DependencyManager.Flag(this); DependencyManager.TriggerAllFlags(); Inspector.InspectInNearestInspector(defenders, MainWindow.main); }, condition = (context) => attackers != null && defenders == null && UIFactory.EditAuthorized(this, "defend") }; }