private void CreateUI() { Point windowSizes = new Point(600, 400); Style.PushStyle("moneyPanel"); Panel moneyPanel = new VerticalLayout().SetAnchor(AnchorX.Right, AnchorY.Top); moneyPanel.SetFixedWidth(300).SetLayoutSize(LayoutSize.FixedSize, LayoutSize.WrapContent); moneyPanel.sprite = Style.sprites["panel"]; moneyPanel.Padding = new Point(16, 8); moneyPanel.AddChild(new Text($"${simulator.playerCompany.displayMoney}").SetTextUpdateFunction(() => { return($"${simulator.playerCompany.displayMoney}"); }).SetAllignments(Allignment.Right, Allignment.Middle).SetFont(Style.fonts["textSmall"]).SetGetTranslation(false)); uiCanvas.AddChild(moneyPanel); Style.PopStyle(); Style.PushStyle("mainButtonPanel"); Panel mainButtonPanel = new VerticalLayout().SetAnchor(AnchorX.Left, AnchorY.Bottom); mainButtonPanel.SetMargin(8).SetLayoutSize(LayoutSize.WrapContent, LayoutSize.WrapContent); mainButtonPanel.sprite = Style.sprites["panel"]; mainButtonPanel.Padding = new Point(8, 8); foreach (GameState gs in Enum.GetValues(typeof(GameState))) { GameState state = gs; Button b = new Button(state.ToString()); b.OnMouseClick = () => ChangeGameState(state); mainButtonPanel.AddChild(b); } uiCanvas.AddChild(mainButtonPanel); Style.PopStyle(); Style.PushStyle("storeScreen"); playerStoreUIScreen = new StoreScreen(CreateAgent, FireAgent); Style.PushStyle("panelSpriteOn"); playerStoreWindow = new Window(playerStoreUIScreen, "Store", uiCanvas).SetIsDraggable(false); playerStoreWindow.SetAnchor(AnchorX.Middle, AnchorY.Middle); playerStoreWindow.Close(); Style.PopStyle("panelSpriteOn"); uiCanvas.AddChild(playerStoreWindow); CitiesScreen citiesScreen = new CitiesScreen(windowSizes, simulator.cities); Style.PushStyle("panelSpriteOn"); citiesWindow = new Window(citiesScreen, "Cities", uiCanvas).SetIsDraggable(false); citiesWindow.SetAnchor(AnchorX.Middle, AnchorY.Middle); citiesWindow.Close(); Style.PopStyle("panelSpriteOn"); uiCanvas.AddChild(citiesWindow); Style.PopStyle(); uiCanvas.AddChild(CreateTimeControlls()); uiCanvas.FinishCreation(); }
public TestScreen(Sprite houseSpr, Sprite frameSpr) { this.frameSpr = frameSpr; Padding = new Point(10, 10); Margin = 10; SetFixedSize(700, 500); HorizontalLayout mainHor = new HorizontalLayout(); mainHor.SetLayoutSizeForBoth(LayoutSize.MatchParent); VerticalLayout leftOverview = new VerticalLayout(); leftOverview.SetFixedSize(200, 300).SetLayoutSize(LayoutSize.FixedSize, LayoutSize.MatchParent); leftOverview.AddScrollbar(); leftOverview.Margin = 6; leftOverview.Padding = new Point(6, 2); int buildingsCount = 12; buildings = new VerticalLayout[buildingsCount]; for (int i = 0; i < buildingsCount; i++) { int index = i; VerticalLayout inner = new VerticalLayout(); inner.OnMouseEnter = () => { MouseOvered(index); }; buildings[i] = inner; inner.Padding = new Point(0, 4); inner.SetLayoutSize(LayoutSize.MatchParent, LayoutSize.WrapContent); Image im = new Image(houseSpr); inner.OnMouseClick = () => { SelectBuilding(index); }; inner.AddChild(im); inner.AddChild(new Text($"Name {i}").SetAllignments(Allignment.Middle, Allignment.Middle)); leftOverview.AddChild(inner); } selectedText = new KeyValueText("Selected Buildings:", selected.ToString()); selectedText.layoutSizeX = LayoutSize.WrapContent; VerticalLayout specifics = new VerticalLayout(); specifics.overwriteChildLayout = false; specifics.SetMargin(6); specifics.SetLayoutSizeForBoth(LayoutSize.MatchParent); //specifics.SetChildAllignment(Allignment.Bottom); specifics.childAllignX = AnchorX.Right; VerticalLayout buildingInfos = new VerticalLayout(); buildingInfos.Padding = new Point(10); //buildingInfos.GetStandardSprite(true); buildingInfos.SetLayoutSize(LayoutSize.MatchParent, LayoutSize.WrapContent); buildingName = new Text("Building Name"); buildingInfos.AddChild(buildingName); buildingStats = new KeyValueText[] { new KeyValueText("building info Test", "12"), new KeyValueText("and more", "13"), new KeyValueText("even more", "14"), new KeyValueText("even more", "15"), new KeyValueText("even more", "15") }; foreach (var el in buildingStats) { buildingInfos.AddChild(el); } specifics.AddChild(selectedText); specifics.AddChild(buildingInfos); mainHor.AddChild(leftOverview); mainHor.AddChild(specifics); HorizontalLayout buttons = new HorizontalLayout(); //buttons.SetChildAllignment(Allignment.Right).SetMargin(10); buttons.SetLayoutSize(LayoutSize.MatchParent, LayoutSize.WrapContent); finishButton = new Button("Finish Selection"); buttons.AddChild(finishButton); buttons.AddChild(new Button("Cancel")); specifics.AddChild(buttons); AddChild(mainHor); }