public override Widget GetHeader(Context context) { if (context.compact) { HBox header = new HBox(false, 0); header.PackStart(new Label(name), false, false, 0); header.PackStart(Graphics.GetIcon(Threat.C, Graphics.GetColor(affiliation), Graphics.textSize), false, false, (uint)(Graphics.textSize / 5)); return(new InspectableBox(header, this, context)); } else { VBox headerBox = new VBox(false, 5); InspectableBox namebox = new InspectableBox(new Label(name), this, context); Gtk.Alignment align = new Gtk.Alignment(0.5f, 0.5f, 0, 0) { Child = namebox, WidthRequest = 200 }; headerBox.PackStart(align, false, false, 0); if (parent != null) { headerBox.PackStart(UIFactory.Align(Graphics.GetSmartHeader(context.butCompact, parent), 0.5f, 0.5f, 0, 0)); } return(headerBox); } }
InspectableBox GetAgentIcon(IAgent agent) { Image icon = Graphics.GetIcon(agent.threat, Graphics.GetColor(agent), Graphics.textSize); InspectableBox inspectable = new InspectableBox(icon, agent, new Context(null)) { HasTooltip = true, TooltipText = agent.name, VisibleWindow = false }; return(inspectable); }
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. }
//IGUIComplete stuff public virtual Widget GetHeader(Context context) { if (context.compact) { return(new InspectableBox(new Label(name), this, context)); } else { VBox headerBox = new VBox(false, 5); InspectableBox namebox = new InspectableBox(new Label(name), this, context); Gtk.Alignment align = new Gtk.Alignment(0.5f, 0.5f, 0, 0) { Child = namebox, WidthRequest = 200 }; headerBox.PackStart(align, false, false, 0); if (parent != null) { headerBox.PackStart(UIFactory.Align(Graphics.GetSmartHeader(context.butCompact, parent), 0.5f, 0.5f, 0, 0)); } return(headerBox); } }
public Cell(Context context, IGUIComplete obj) : base(obj, context) { //Basic setup this.obj = obj; frame = new Frame(); Child = frame; prelight = false; MyDragDrop.SourceSet(this, obj); // "Removing by dragging away to nothing" functionality should be implemented manually when the Cell is created. // It should be implemented via MyDragDrop.SourceSetFailAction // The object should generally be removed from the parent list ONLY in this case. // Rationale for removing only if drag had no target: // - If cellObject is dragged from an aggregative list to another aggregative list, // the Add() function on the second automatically removes it from the first, so calling Remove() is unnecessary. // - If cellObject is dragged from an associative list to an aggregative list or vice versa, // We reasonably assume that user doesn't want it removed from the first list since the concept of "moving" doesn't apply in this context. // - Only if the user has dragged cellObject from any list to *nothing* can it be assumed that they need it manually removed by us. frame.Add(obj.GetCellContents(this.context)); frame.LabelWidget = obj.GetHeader(this.context); InspectableBox inspectableBox = frame.LabelWidget as InspectableBox; ShowAll(); }
public void Reload() { uint spacing = (uint)(Graphics.textSize / 5); Gdk.Color black = new Gdk.Color(0, 0, 0); //Destroy previous displays for top bar while (textBar.Children.Length > 0) { textBar.Children[0].Destroy(); } while (numbersBar.Children.Length > 0) { numbersBar.Children[0].Destroy(); } //Create display for active agent (player) textBar.PackStart(new Label("Playing as: "), false, false, spacing); InspectableBox player = (InspectableBox)Game.player.GetHeader(new Context(null, Game.player, false, true)); if (Game.omnipotent) { MyDragDrop.DestSet(player, "Active IAgent"); MyDragDrop.DestSetDropAction(player, delegate(object obj) { if (GameObject.TryCast(obj, out IAgent agent)) { Game.SetPlayer(agent); } }); } textBar.PackStart(player, false, false, 0); //Create phase indicator and "next" arrow Image nextPhaseArrow = Graphics.GetIcon(IconTemplate.RightArrow, black, (int)(Graphics.textSize * 0.75)); ClickableEventBox nextPhaseButton = new ClickableEventBox { Child = nextPhaseArrow, BorderWidth = (uint)(Graphics.textSize * 0.25), Sensitive = Game.CanNext() }; nextPhaseButton.Clicked += (o, a) => Game.Next(); textBar.PackEnd(nextPhaseButton, false, false, spacing); textBar.PackEnd(new Label(Game.phase + " Phase"), false, false, spacing); //Update resource and reputation displays if (GameObject.TryCast(Game.player, out Faction faction)) { numbersBar.PackStart(Graphics.GetIcon(StructureType.Economic, black, Graphics.textSize), false, false, spacing); numbersBar.PackStart(new Label(faction.resources.ToString()), false, false, spacing); numbersBar.PackStart(Graphics.GetIcon(StructureType.Aesthetic, black, Graphics.textSize), false, false, spacing); numbersBar.PackStart(new Label(faction.reputation.ToString()), false, false, spacing); } else if (GameObject.TryCast(Game.player, out Team team)) { numbersBar.PackStart(Graphics.GetIcon(StructureType.Aesthetic, black, Graphics.textSize), false, false, spacing); numbersBar.PackStart(new Label(team.reputation.ToString()), false, false, spacing); } else if (GameObject.TryCast(Game.player, out Parahuman parahuman)) { numbersBar.PackStart(Graphics.GetIcon(StructureType.Aesthetic, black, Graphics.textSize), false, false, spacing); numbersBar.PackStart(new Label(parahuman.reputation.ToString()), false, false, spacing); } //Create the icons for each agent and frame the current turn-taker if ((Game.phase & (Phase.Resolution | Phase.Event)) == Phase.None) { for (int i = Game.turnOrder.Count - 1; i >= 0; i--) { InspectableBox icon = GetAgentIcon(Game.turnOrder[i]); if (i == Game.turn) { numbersBar.PackEnd(new Frame { Child = icon }, false, false, 0); } else { numbersBar.PackEnd(icon, false, false, 0); } } } ShowAll(); }