private static void AddControls() { int btnRegenerateWidth = 360; int btnRegenerateHeight = 30; Vector2 btnRegeneratePosition = new Vector2((400 - btnRegenerateWidth - Statics.Padding) / 2, Statics.CanvasHeight - Statics.Padding * 3 - btnRegenerateHeight); win2d_Button btnRegenerate = new win2d_Button(_device, btnRegeneratePosition, btnRegenerateWidth, btnRegenerateHeight, "Regenerate"); btnRegenerate.Click += BtnRegenerate_Click; CustomizationPanel.AddControl(btnRegenerate); int btnAcceptWidth = 360; int btnAcceptHeight = 30; Vector2 btnAcceptPosition = new Vector2((400 - btnAcceptWidth - Statics.Padding) / 2, btnRegeneratePosition.Y - Statics.Padding - btnAcceptHeight); win2d_Button btnAccept = new win2d_Button(_device, btnAcceptPosition, btnAcceptWidth, btnAcceptHeight, "Accept"); btnAccept.Click += BtnAccept_Click; CustomizationPanel.AddControl(btnAccept); win2d_Checkbox chkDrawPaths = new win2d_Checkbox(_device, new Vector2(10, 200), "Draw Paths"); chkDrawPaths.CheckedValueChanged += ChkDrawPaths_CheckedValueChanged; CustomizationPanel.AddControl(chkDrawPaths); }
public static void Initialize(CanvasDevice device, World world) { _device = device; World = world; // START PANELS int panelLeftWidth = 300; int panelLeftHeight = Statics.CanvasHeight - Statics.Padding * 2; Vector2 panelLeftPosition = new Vector2(Statics.Padding, Statics.Padding); PanelLeft = new win2d_Panel(panelLeftPosition, panelLeftWidth, panelLeftHeight, Colors.Black); int panelRightWidth = 300; int panelRightHeight = Statics.CanvasHeight - Statics.Padding * 2; Vector2 panelRightPosition = new Vector2(Statics.CanvasWidth - panelRightWidth - Statics.Padding, Statics.Padding); PanelRight = new win2d_Panel(panelRightPosition, panelRightWidth, panelRightHeight, Colors.Black); int panelCenterWidth = Statics.CanvasWidth - panelLeftWidth - panelRightWidth - Statics.Padding * 4; int panelCenterHeight = Statics.CanvasHeight - Statics.Padding * 2; Vector2 panelCenterPosition = new Vector2(panelLeftWidth + Statics.Padding * 2, Statics.Padding); PanelCenter = new win2d_Panel(panelCenterPosition, panelCenterWidth, panelCenterHeight, Colors.Black); // END PANELS // note: controls in panels have positions relative to the panels // START MAP int mapWidth = panelRightWidth - Statics.Padding * 2; int mapHeight = 200; float mapPositionX = Statics.Padding; // panelRightWidth - mapWidth - Statics.Padding) / 2; float mapPositionY = Statics.Padding; // panelRightHeight - mapHeight - Statics.Padding; Map = new win2d_Map(new Vector2(mapPositionX, mapPositionY), mapWidth, mapHeight, World, drawCallout: true, drawStretched: false); PanelRight.AddControl(Map); // END MAP // START BUTTON int buttonSubmitInputWidth = 100; int buttonSubmitInputHeight = 36; // TODO: reconcile with height derivation in textbox constructor Vector2 buttonSubmitPosition = new Vector2(panelCenterWidth - Statics.Padding - buttonSubmitInputWidth, panelCenterHeight - Statics.Padding - buttonSubmitInputHeight); ButtonSubmitInput = new win2d_Button(_device, buttonSubmitPosition, buttonSubmitInputWidth, buttonSubmitInputHeight, "->"); ButtonSubmitInput.Click += ButtonSubmitInput_Click; PanelCenter.AddControl(ButtonSubmitInput); // END BUTTON // START TEXTBOX int textboxInputWidth = panelCenterWidth - Statics.Padding * 3 - buttonSubmitInputWidth; int textboxInputHeight = 36; // TODO: reconcile with height derivation in textbox constructor Vector2 textboxInputPosition = new Vector2(Statics.Padding, panelCenterHeight - Statics.Padding - textboxInputHeight); TextboxInput = new win2d_Textbox(_device, textboxInputPosition, textboxInputWidth); TextboxInput.GiveFocus(); PanelCenter.AddControl(TextboxInput); // END TEXTBOX // START TEXTBLOCK Vector2 textblockMainPosition = new Vector2(Statics.Padding, Statics.Padding); int textblockMainWidth = panelCenterWidth - Statics.Padding * 2; int textblockMainHeight = panelCenterHeight - textboxInputHeight - Statics.Padding * 3; TextblockMain = new win2d_Textblock(_device, textblockMainPosition, textblockMainWidth, textblockMainHeight, scrolltobottomonappend: true); PanelCenter.AddControl(TextblockMain); // END TEXTBLOCK // display initial room CurrentRoom = World.GetRandomRoom(); while (CurrentRoom.DirectionalRoomConnections.Count == 0) { CurrentRoom = World.GetRandomRoom(); } Map.CenterOnPoint(CurrentRoom.CoordinatesXY); AppendText(CurrentRoom.DisplayString); }