public RatingsListField(PropertyInfo property, object obj, Context context, DisplayableAttribute attribute) : base(0, 0, 1, 1) { RatingsProfile profile = ((Func <Context, RatingsProfile>)property.GetValue(obj))(context); float[,] values = profile.values; int[,] o_vals = profile.o_vals; Gtk.Alignment alignment = new Gtk.Alignment(0, 0, 1, 0); if (context.vertical && !context.compact) { Frame frame = new Frame(UIFactory.ToReadable(property.Name)); VBox box = new VBox(false, 4) { BorderWidth = 5 }; frame.Add(box); alignment.Add(frame); for (int i = 1; i <= 8; i++) { if (o_vals[0, i] != Ratings.O_NULL) { Label ratingLabel = new Label(Ratings.PrintSingle(i, values[0, i])); ratingLabel.SetAlignment(0, 0); box.PackStart(ratingLabel); } } for (int k = 1; k <= 3; k++) { if (o_vals[k, 0] != Ratings.O_NULL) { Label wrapperLabel = new Label(Ratings.PrintSingle(k + 8, values[k, 0])); wrapperLabel.SetAlignment(0, 0); VBox ratingBox = new VBox(false, 5) { BorderWidth = 5 }; Frame ratingFrame = new Frame { LabelWidget = wrapperLabel, Child = ratingBox }; for (int i = 1; i <= 8; i++) { if (o_vals[k, i] != Ratings.O_NULL) { Label ratingLabel = new Label(Ratings.PrintSingle(i, values[k, i])); ratingLabel.SetAlignment(0, 0); ratingBox.PackStart(ratingLabel, false, false, 0); } } box.PackStart(ratingFrame); } } } else { Box box; if (context.compact) { box = new VBox(false, 0) { BorderWidth = 5 }; } else { box = new HBox(false, 0) { BorderWidth = 5 }; } alignment.Add(box); for (int i = 1; i <= 8; i++) { if (o_vals[0, i] != Ratings.O_NULL) { bool comma = !context.compact && box.Children.Length > 0; Label ratingLabel = new Label((comma ? ", " : "") //Commas to delimit ratings + Ratings.PrintSingle(i, values[0, i])); ratingLabel.SetAlignment(0, 0); box.PackStart(ratingLabel, false, false, 0); } } for (int k = 1; k <= 3; k++) { if (o_vals[k, 0] != Ratings.O_NULL) { bool comma = !context.compact && box.Children.Length > 0; Label ratingLabel = new Label((comma ? ", " : "") //Commas to delimit ratings + Ratings.PrintSingle(k + 8, values[k, 0], true)); ratingLabel.SetAlignment(0, 0); List <String> subratings = new List <String>(); for (int i = 1; i <= 8; i++) { if (o_vals[k, i] != Ratings.O_NULL) { subratings.Add(Ratings.PrintSingle(i, values[k, i])); } } ratingLabel.TooltipText = String.Join("\n", subratings); box.PackStart(ratingLabel, false, false, 0); } } } if (attribute.EditAuthorized(obj)) { ClickableEventBox clickableEventBox = new ClickableEventBox { Child = alignment }; clickableEventBox.DoubleClicked += delegate { // The property this is attached to gets the *current ratings*, not the *base ratings*, which are // what we logically want to let the user manipulate. Hence, the optional arg supplied is the name // of the base profile. PropertyInfo baseProfileProperty = obj.GetType().GetProperty((string)attribute.arg); TextEditingDialog dialog = new TextEditingDialog( "Edit ratings", (Window)Toplevel, delegate { RatingsProfile baseProfile = (RatingsProfile)baseProfileProperty.GetValue(obj); return(Ratings.Print(baseProfile.values, baseProfile.o_vals)); }, delegate(string input) { if (Ratings.TryParse(input, out RatingsProfile? newRatings)) { baseProfileProperty.SetValue(obj, (RatingsProfile)newRatings); IDependable dependable = obj as IDependable; if (dependable != null) { DependencyManager.Flag(dependable); DependencyManager.TriggerAllFlags(); } return(true); } return(false); } ); }; Add(clickableEventBox); } else { Add(alignment); } }
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(); }
void Submit(object entry, EventArgs args) { SetValueFromString(((Entry)entry).Text); DependencyManager.Flag(obj); DependencyManager.TriggerAllFlags(); }
public DependableShell(int order) : base(0, 0, 1, 1) { this.order = order; Destroyed += (o, a) => DependencyManager.DisconnectAll(this); //Theoretically we could Delete(obj), but that's unnecessary }