public BattleInterface(Battle battle) { this.battle = battle; Destroyed += (o, a) => DependencyManager.Destroy(this); DependencyManager.Connect(battle, this); DependencyManager.Connect(Game.UIKey, this); Reload(); }
public Listing(IGUIComplete obj, bool lazy) { this.obj = obj; this.lazy = lazy; DependencyManager.Connect(obj, this); DependencyManager.Connect(Game.UIKey, this); Destroyed += (o, a) => DependencyManager.DisconnectAll(this); SetSizeRequest(1, 300); LabelXalign = 1; Reload(); }
public override void AddRange <T> (IEnumerable <T> objs) { foreach (object obj in objs) { Trait trait = (Trait)obj; traits.Add(trait); trait.parent = this; DependencyManager.Flag(trait); DependencyManager.Connect(trait, this); } traits.Sort((a, b) => a.secrecy.CompareTo(b.secrecy)); DependencyManager.Flag(this); }
public AssetsBottomBar() : base("Parahuman resources") { Spacing = 5; ScrolledWindow scroller = new ScrolledWindow { VscrollbarPolicy = PolicyType.Never }; mainBox = new HBox(false, 10); scroller.AddWithViewport(mainBox); Add(scroller); DependencyManager.Connect(Game.city, this); DependencyManager.Connect(Game.UIKey, this); Activated += OnActivated; Reload(); }
public SmartCell(Context context, IGUIComplete obj, bool lazy) : base(obj, context) { //Basic setup this.obj = obj; this.lazy = lazy; frame = new Frame(); Child = frame; prelight = false; MyDragDrop.SourceSet(this, obj); // "Removing by dragging away to nothing" functionality should be... [see Cell comment] DependencyManager.Connect(obj, this); DependencyManager.Connect(Game.UIKey, this); Destroyed += (o, a) => DependencyManager.DisconnectAll(this); Reload(); }
public static Widget GetSmartHeader(Context context, IGUIComplete obj) { DependableShell shell = new DependableShell(obj.order + 1); shell.ReloadEvent += delegate { if (shell.Child != null) { shell.Child.Destroy(); } shell.Add(obj.GetHeader(context)); shell.ShowAll(); }; shell.Reload(); DependencyManager.Connect(obj, shell); return(shell); }
public override void AddRange <T> (IEnumerable <T> objs) { foreach (object element in objs) { GameObject obj = (GameObject)element; if (obj.parent != null) { obj.parent.Remove(obj); } obj.parent = this; structures.Add((Structure)obj); DependencyManager.Connect(obj, this); DependencyManager.Flag(obj); } DependencyManager.Flag(this); }
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") }; }
public ObjectField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(0, 0, 1, 1) { this.property = property; this.obj = (IGUIComplete)property.GetValue(obj); this.context = context; title = attribute.overrideLabel ?? UIFactory.ToReadable(property.Name); if (this.obj != null) { DependencyManager.Connect(this.obj, this); Destroyed += (o, a) => DependencyManager.DisconnectAll(this); Reload(); } else { Label label = new Label(title + ": None"); label.SetAlignment(0, 0); Add(label); } }
public void AddRange <T> (IEnumerable <T> objs) { foreach (object obj in objs) { GameObject newGO = (GameObject)obj; gameObjects.Add(newGO); foreach (IAgent agent in activeAgents) { if (agent.knowledge != null) { agent.knowledge.Add(newGO, 0); } } if (GameObject.TryCast(obj, out MapMarked mapMarked)) { Map.Register(mapMarked); } DependencyManager.Connect(newGO, this); DependencyManager.Flag(newGO); } DependencyManager.Flag(this); }
public void Inspect(IGUIComplete obj) { // Clean up prior attachments if (Child != null) { Child.Destroy(); } DependencyManager.DisconnectAll(this); ShowAll(); // Handle inspection request this.obj = obj; if (obj == null) { Hide(); } else { DependencyManager.Connect(obj, this); DependencyManager.Connect(Game.UIKey, this); if (Child != null) { Child.Destroy(); } VBox mainbox = new VBox(false, 0); mainbox.PackStart(obj.GetHeader(new Context(obj)), false, false, 10); mainbox.PackStart(new HSeparator(), false, false, 0); mainbox.PackStart(UIFactory.GenerateVertical(obj), true, true, 5); AddWithViewport(mainbox); if (!Visible) { Unhidden.Invoke(this, new EventArgs()); } ShowAll(); } }
public MainInterface() { DependencyManager.Connect(Game.city, this); DependencyManager.Connect(Game.UIKey, this); textBar = new HBox(); numbersBar = new HBox(); VBox topBars = new VBox(false, 2) { BorderWidth = 5 }; topBars.PackStart(textBar); topBars.PackStart(numbersBar); PackStart(new HSeparator(), false, false, 0); PackStart(topBars, false, false, 0); PackStart(new HSeparator(), false, false, 0); HBox mainHBox = new HBox(); PackStart(mainHBox, true, true, 0); //Set up the containers VBox leftVBox = new VBox(); mainNotebook = new Notebook(); leftVBox.PackStart(mainNotebook, true, true, 0); mainHBox.PackStart(leftVBox, true, true, 0); ////Notebook /// //Map tab map = new Map(); //Profiler called inside Map constructor mainNotebook.AppendPage(map, new Label("Map")); Profiler.Log(); //Search tab Search search = new Search(null, (obj) => Inspector.InspectInNearestInspector(obj, this)); mainNotebook.AppendPage(search, new Label("Search")); //My domain Search domain = new Search((obj) => (obj is Territory || obj is Structure) && ((IAffiliated)obj).affiliation == Game.player, (obj) => Inspector.InspectInNearestInspector(obj, this)); domain.typesButton.State = StateType.Insensitive; domain.toplevelOnlyButton.State = StateType.Insensitive; mainNotebook.AppendPage(domain, new Label("Domain")); //Event log tab eventLogLabel = new ClickableEventBox { Child = new Label("Logs"), prelight = false, depress = false }; eventLogLabel.DoubleClicked += (o, a) => WindowizeEventLog(); eventLogLabel.ShowAll(); eventLogsScroller = new ScrolledWindow(); eventLogsScroller.SetSizeRequest(200, -1); eventLogsDisplay = new VBox { BorderWidth = 10 }; eventLogsScroller.AddWithViewport(eventLogsDisplay); mainNotebook.AppendPage(eventLogsScroller, eventLogLabel); //Agents bottom bar assetsBar = new AssetsBottomBar { BorderWidth = 10 }; leftVBox.PackStart(assetsBar, false, false, 0); //Inspector Inspector inspector = new Inspector() { BorderWidth = 10 }; mainHBox.PackStart(inspector, false, false, 0); Profiler.Log(ref Profiler.searchCreateTime); MainWindow.main.inspector = inspector; Destroyed += (o, a) => DependencyManager.Destroy(this); Reload(); mainNotebook.CurrentPage = 0; }
public Search(Func <GameObject, bool> Filter = null, Action <GameObject> OnClicked = null, bool lazy = true) { DependencyManager.Connect(Game.city, this); DependencyManager.Connect(Game.UIKey, this); Destroyed += (o, a) => DependencyManager.Destroy(this); this.Filter = Filter ?? delegate { return(true); }; this.OnClicked = OnClicked ?? delegate { }; this.lazy = lazy; //Search bar searchBar = new Toolbar(); PackStart(searchBar, false, false, 0); //Search results resultsWindow = new ScrolledWindow(); PackStart(resultsWindow, true, true, 0); lister = new CachingLister <GameObject>(SetupListing); tesselator = new CachingTesselator <GameObject>(SetupCell, resultsWindow); headerer = new CachingLister <GameObject>(SetupHeader); //Search searchText = new Entry(); searchText.Activated += (o, a) => Reload(); searchBar.Insert(new ToolItem() { Child = searchText }, -1); //Types typesButton = new ToggleButton("All types"); typesMenu = new TogglePopup(typesButton); typesMenu.Hidden += delegate { TypeChanged(); Reload(); }; types = new Checklist(true, new string[] { "Parahuman", "Team", "Faction" }, new object[] { typeof(Parahuman), typeof(Team), typeof(Faction) }) { BorderWidth = 2 }; typesMenu.Add(types); searchBar.Insert(new SeparatorToolItem() { }, 1); searchBar.Insert(new ToolItem { Child = new Label("Scope: ") }, -1); searchBar.Insert(new ToolItem { Child = typesButton }, -1); //Toplevel only toplevelOnlyButton = new CheckButton("Toplevel only"); toplevelOnlyButton.Toggled += (o, a) => Reload(); searchBar.Insert(new SeparatorToolItem(), -1); searchBar.Insert(new ToolItem { Child = toplevelOnlyButton }, -1); searchBar.Insert(new SeparatorToolItem(), -1); //Traits traitsButton = new ToggleButton("More Filters"); traitsMenu = new TogglePopup(traitsButton); traitsMenu.Hidden += (o, a) => Reload(); HBox columns = new HBox(false, 5) { BorderWidth = 2 }; alignments = new Checklist(true, new string[] { "Hero", "Vigilante", "Rogue", "Mercenary", "Villain" }, new object[] { Alignment.Hero, Alignment.Vigilante, Alignment.Rogue, Alignment.Mercenary, Alignment.Villain }); threats = new Checklist(true, new string[] { "C", "B", "A", "S", "X" }, new object[] { Threat.C, Threat.B, Threat.A, Threat.S, Threat.X }); columns.PackStart(alignments, false, false, 0); columns.PackStart(threats, false, false, 5); traitsMenu.Add(columns); searchBar.Insert(new ToolItem { Child = traitsButton }, -1); //Presentation presentation = new ComboBox(new string[] { "Listings", "Cells", "Headers" }); presentation.Changed += (o, args) => PresentationChanged(); presentation.Active = 0; searchBar.Insert(new SeparatorToolItem(), -1); searchBar.Insert(new ToolItem { Child = presentation }, -1); Reload(); }