public override void Construct() { Font = "font10"; Title = AddChild(new Widget() { Font = "font16", Text = "Finance", AutoLayout = AutoLayout.DockTop }); InfoWidget = AddChild(new Widget() { Font = "font10", Text = "", MinimumSize = new Point(640, 300), AutoLayout = AutoLayout.DockTop }); OnUpdate = (sender, time) => { numrows = 0; InfoWidget.Clear(); AddRow("Corporate Liquid Assets:", World.Overworld.PlayerCorporationFunds.ToString()); AddRow("Corporate Material Assets:", new DwarfBux(World.Overworld.PlayerCorporationResources.Enumerate().Sum(r => r.MoneyValue)).ToString()); AddRow("Liquid assets:", Faction.Economy.Funds.ToString()); var resources = World.EnumerateResourcesIncludingMinions(); AddRow("Material assets:", String.Format("{0} goods valued at ${1}", resources.Count(), resources.Sum(r => r.MoneyValue))); var payPerDay = (DwarfBux)Faction.Minions.Select(m => m.Stats.CurrentLevel.Pay.Value).Sum(); AddRow("Employees:", String.Format("{0} at {1} per day.", Faction.Minions.Count, payPerDay)); AddRow("Runway:", String.Format("{0} day(s).\n", (int)(Faction.Economy.Funds / Math.Max(payPerDay, (decimal)0.01)))); var freeStockPile = World.ComputeRemainingStockpileSpace(); var totalStockPile = Math.Max(World.ComputeTotalStockpileSpace(), 1); AddRow("Stockpile space:", String.Format("{0} used of {1} ({2:00.00}%)\n", totalStockPile - freeStockPile, totalStockPile, (float)(totalStockPile - freeStockPile) / (float)totalStockPile * 100.0f)); AddRow("Average dwarf happiness:", String.Format("{0}%", (int)(float)Faction.Minions.Sum(m => m.Stats.Happiness.Percentage) / Math.Max(Faction.Minions.Count, 1))); InfoWidget.Layout(); }; var selector = AddChild(new ComboBox() { Items = Faction.World.Stats.GameStats.Keys.ToList(), AutoLayout = AutoLayout.DockTop }) as ComboBox; var graph = AddChild(new Graph() { AutoLayout = AutoLayout.DockFill, GraphStyle = Graph.Style.LineChart }) as Graph; graph.SetFont("font10"); graph.Values = Faction.World.Stats.GameStats["Money"].Values.Select(v => v.Value).ToList(); selector.OnSelectedIndexChanged = (sender) => { var values = Faction.World.Stats.GameStats[selector.SelectedItem].Values; graph.Values = Faction.World.Stats.GameStats[selector.SelectedItem].Values.Select(v => v.Value).ToList(); if (values.Count > 0) { graph.XLabelMin = "\n" + TextGenerator.AgeToString(Faction.World.Time.CurrentDate - values.First().Date); graph.XLabelMax = "\nNow"; } graph.Invalidate(); }; selector.OnSelectedIndexChanged.Invoke(selector); Layout(); Root.RegisterForUpdate(this); }
public override void Construct() { MinimumSize = new Point(1024, 128 + 6); ScreenshotWidget = AddChild(new Widget() { MinimumSize = new Point(128, 128), AutoLayout = AutoLayout.DockLeft, Text = Item.Screenshot == null ? "No image" : "", Font = "font8", Border = "border-one" }); var rightContent = AddChild(new Widget() { AutoLayout = AutoLayout.DockLeft, MinimumSize = new Point(1024, 128), InteriorMargin = new Margin(10, 10, 10, 10) }); var title = rightContent.AddChild(new Widget() { Text = Item.Name, Font = "font16", AutoLayout = AutoLayout.DockTop, }); rightContent.AddChild(new Widget() { Text = TextGenerator.AgeToString(Item.Age), Font = "font8", AutoLayout = AutoLayout.DockTop }); if (!String.IsNullOrEmpty(Item.Valid)) { rightContent.AddChild(new Widget() { Text = String.Format("(Invalid save: {0})", Item.Valid), Font = "font8", AutoLayout = AutoLayout.DockTop }); } var buttonContainer = rightContent.AddChild(new Widget() { MinimumSize = new Point(64, 32), AutoLayout = AutoLayout.DockBottom }); if (String.IsNullOrEmpty(Item.Valid)) { LoadButton = buttonContainer.AddChild(new Gui.Widgets.Button() { Text = "Load", AutoLayout = AutoLayout.DockLeft, Border = "border-thin", InteriorMargin = new Margin(0, 0, 3, 3), Tooltip = "Click to load this save file" }); } DeleteButton = buttonContainer.AddChild(new Gui.Widgets.Button() { Text = "Delete", AutoLayout = AutoLayout.DockLeft, Border = "border-thin", InteriorMargin = new Margin(0, 0, 3, 3), Tooltip = "Click to delete this save file" }); InteriorMargin = new Margin(3, 3, 3, 3); base.Construct(); }