public override void Initialize() { base.Initialize(); gui_manager = game.GuiManager; form = new DForm(gui_manager, "test", null); form.Size = new Vector2(800, 600); form.Position = new Vector2(0, 0); form.Alpha = 0; form.Initialize(); gui_manager.AddControl(form); DLayoutFlow layout = new DLayoutFlow(2, 2, 60, 20, DLayoutFlow.DLayoutFlowStyle.Vertically); layout.Position = new Vector2(10, 10); button1 = new DButton(gui_manager); layout.Add(button1); button1.Text = "test"; button1.Initialize(); form.AddPanel(button1); button1.OnClick += new DButtonEventHandler(button_OnClick); check1 = new DCheckbox(gui_manager); layout.Add(check1); check1.Text = "Enable Fog"; check1.FontColor = Color.White; check1.FillColor = Color.Wheat; check1.Checked = true; check1.Initialize(); form.AddPanel(check1); check1.OnToggle += new CheckboxEventHandler(check_OnCheck); }
protected override void LoadContent() { base.LoadContent(); // init gundbound label gundboundLabel = new DText(guiManager); gundboundLabel.FontName = "Miramonte"; layout.Add(gundboundLabel); gundboundLabel.Initialize(); gundboundLabel.Text = "Gunbound"; gundboundLabel.Position = new Vector2(400, 200) - (gundboundLabel.Size / 2); gundboundLabel.HorizontalAlignment = DText.DHorizontalAlignment.Center; form.AddPanel(gundboundLabel); // init ip address textbox ipAddressTextBox = new DTextBox(guiManager); layout.Add(ipAddressTextBox); ipAddressTextBox.Initialize(); ipAddressTextBox.Text = "127.0.0.1"; ipAddressTextBox.Position = new Vector2(400, 250) - (ipAddressTextBox.Size / 2); form.AddPanel(ipAddressTextBox); // init username textbox usernameTextBox = new DTextBox(guiManager); layout.Add(usernameTextBox); usernameTextBox.Initialize(); usernameTextBox.Text = "username"; usernameTextBox.Position = new Vector2(400, 300) - (usernameTextBox.Size / 2); form.AddPanel(usernameTextBox); // init handshake button handshakeButton = new DButton(guiManager); layout.Add(handshakeButton); handshakeButton.Text = "Connect"; handshakeButton.Position = new Vector2(400, 350) - (handshakeButton.Size / 2); handshakeButton.Initialize(); form.AddPanel(handshakeButton); handshakeButton.OnClick += new DButtonEventHandler(handshakeButton_OnClick); }
void dropDownButton_OnToggle(DButton.DButtonState state) { if (state == DButton.DButtonState.On) { ShowList(); } else { HideList(); } }
protected override void LoadContent() { base.LoadContent(); // init room name label roomNameLabel = new DText(guiManager); roomNameLabel.FontName = "Miramonte"; layout.Add(roomNameLabel); roomNameLabel.Initialize(); roomNameLabel.Text = "Room "; roomNameLabel.Position = new Vector2(100, 100); roomNameLabel.HorizontalAlignment = DText.DHorizontalAlignment.Left; form.AddPanel(roomNameLabel); // init room creator label creatorLabel = new DText(guiManager); creatorLabel.FontName = "Miramonte"; layout.Add(creatorLabel); creatorLabel.Initialize(); creatorLabel.Text = "Creator: "; creatorLabel.Position = new Vector2(100, 125); creatorLabel.HorizontalAlignment = DText.DHorizontalAlignment.Left; form.AddPanel(creatorLabel); // init player label playersLabel = new DText(guiManager); playersLabel.FontName = "Miramonte"; layout.Add(playersLabel); playersLabel.Initialize(); playersLabel.Text = "Players: "; playersLabel.Position = new Vector2(100, 150); playersLabel.HorizontalAlignment = DText.DHorizontalAlignment.Left; form.AddPanel(playersLabel); // init player list box playerList = new DListBox(guiManager); layout.Add(playerList); playerList.Initialize(); playerList.Position = new Vector2(100, 175); form.AddPanel(playerList); // init quit room button quitRoomButton = new DButton(guiManager); layout.Add(quitRoomButton); quitRoomButton.Text = "Quit"; quitRoomButton.Position = new Vector2(quitRoomButton.Size.X + 100, 500) - quitRoomButton.Size; quitRoomButton.Initialize(); form.AddPanel(quitRoomButton); quitRoomButton.OnClick += new DButtonEventHandler(quitRoomButton_OnClick); // init start room button startRoomButton = new DButton(guiManager); layout.Add(startRoomButton); startRoomButton.Text = "Start"; startRoomButton.Position = new Vector2(800 - 100, 500) - startRoomButton.Size; startRoomButton.Enabled = false; startRoomButton.Initialize(); form.AddPanel(startRoomButton); startRoomButton.OnClick += new DButtonEventHandler(startRoomButton_OnClick); }
protected override void LoadContent() { base.LoadContent(); // init room name label roomNameLabel = new DText(guiManager); roomNameLabel.FontName = "Miramonte"; layout.Add(roomNameLabel); roomNameLabel.Initialize(); roomNameLabel.Text = "Room Name:"; roomNameLabel.Position = new Vector2(400, 100) - (roomNameLabel.Size / 2); roomNameLabel.HorizontalAlignment = DText.DHorizontalAlignment.Center; form.AddPanel(roomNameLabel); // init room name textbox roomNameTextBox = new DTextBox(guiManager); layout.Add(roomNameTextBox); roomNameTextBox.Initialize(); roomNameTextBox.Text = "asdasd"; roomNameTextBox.Position = new Vector2(400, 150) - (roomNameTextBox.Size / 2); form.AddPanel(roomNameTextBox); // init max players label maxPlayerLabel = new DText(guiManager); maxPlayerLabel.FontName = "Miramonte"; layout.Add(maxPlayerLabel); maxPlayerLabel.Initialize(); maxPlayerLabel.Text = "Max Players:"; maxPlayerLabel.Position = new Vector2(400, 200) - (maxPlayerLabel.Size / 2); maxPlayerLabel.HorizontalAlignment = DText.DHorizontalAlignment.Center; form.AddPanel(maxPlayerLabel); // init max player textbox maxPlayerTextBox = new DTextBox(guiManager); layout.Add(maxPlayerTextBox); maxPlayerTextBox.Initialize(); maxPlayerTextBox.Text = "8"; maxPlayerTextBox.Position = new Vector2(400, 250) - (maxPlayerTextBox.Size / 2); form.AddPanel(maxPlayerTextBox); // init cancel button cancelButton = new DButton(guiManager); layout.Add(cancelButton); cancelButton.Text = "Cancel"; cancelButton.Position = new Vector2(cancelButton.Size.X + 200, 400) - cancelButton.Size; cancelButton.Initialize(); form.AddPanel(cancelButton); cancelButton.OnClick += new DButtonEventHandler(cancelButton_OnClick); // init create button createRoomButton = new DButton(guiManager); layout.Add(createRoomButton); createRoomButton.Text = "Create"; createRoomButton.Position = new Vector2(600, 400) - createRoomButton.Size; createRoomButton.Initialize(); form.AddPanel(createRoomButton); createRoomButton.OnClick += new DButtonEventHandler(createRoomButton_OnClick); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> public override void Initialize() { base.Initialize(); _minButton = new DButton(_guiManager, 0, 0, "", SCROLLBAR_WIDTH, SCROLLBAR_WIDTH); if (_alignHorizontal) { _minButton.Text = "<"; Size = new Vector2(Size.X, SCROLLBAR_WIDTH); _maxButton = new DButton(_guiManager, Size.X - SCROLLBAR_WIDTH, 0, "", SCROLLBAR_WIDTH, SCROLLBAR_WIDTH); _scrollIndicator = new DPanel(_guiManager, SCROLLBAR_WIDTH, 0, SCROLLBAR_WIDTH, SCROLLBAR_WIDTH); _maxButton.Text = ">"; } else { _minButton.Text = "^"; Size = new Vector2(SCROLLBAR_WIDTH, Size.Y); _maxButton = new DButton(_guiManager, 0, Size.Y - SCROLLBAR_WIDTH, "", SCROLLBAR_WIDTH, SCROLLBAR_WIDTH); _scrollIndicator = new DPanel(_guiManager, 0, SCROLLBAR_WIDTH, SCROLLBAR_WIDTH, SCROLLBAR_WIDTH); _maxButton.Text = "v"; } //scrollIndicator.BorderColor = Color.SlateGray; //maxButton.Parent = this; //minButton.Parent = this; AddPanel(_minButton); AddPanel(_maxButton); AddPanel(_scrollIndicator); UpdateScrollIndicatorSize(); _minButton.OnLeftMouseDown += new DButtonEventHandler(minButton_OnLeftMouseDown); _minButton.OnLeftMouseUp += new DButtonEventHandler(minButton_OnLeftMouseUp); _maxButton.OnLeftMouseDown += new DButtonEventHandler(maxButton_OnLeftMouseDown); _maxButton.OnLeftMouseUp += new DButtonEventHandler(maxButton_OnLeftMouseUp); }
protected void CreateGrid() { _panelArray = new DPanel[_columns, _rows]; _cellWidths = new float[_columns]; _cellHeights = new float[_rows]; _columnLines = new Texture2D[_columns + 1]; _rowLines = new Texture2D[_rows + 1]; for (int i = 0; i < _columns; i++) { _cellWidths[i] = _cellWidth; } for (int i = 0; i < _rows; i++) { _cellHeights[i] = _cellHeight; } this.Size = new Vector2(_cellWidths.Length * (_cellWidth + _gridLineWidth), _cellHeights.Length * (_cellHeight + _gridLineWidth)); if (_gridLineWidth > 0) { for (int i = 0; i < _columnLines.Length; i++) { _columnLines[i] = DrawingSystem.DrawingHelper.CreateLineTexture(Game.GraphicsDevice, _gridLineWidth, (int)this.Size.Y, GridColor); } for (int i = 0; i < _rowLines.Length; i++) { _rowLines[i] = DrawingSystem.DrawingHelper.CreateLineTexture(Game.GraphicsDevice, (int)this.Size.X + _gridLineWidth, _gridLineWidth, GridColor); } } for (int x = 0; x < _columns; x++) { for (int y = 0; y < _rows; y++) { if (_fillType != DGridFillType.None) { Vector2 gridPosition = GridPosition(x,y); if (_fillType == DGridFillType.DButton) { DButton button = new DButton(_guiManager, gridPosition.X, gridPosition.Y, x.ToString() + ", " + y.ToString(), _cellWidth, _cellHeight); button.FontName = "Miramonte"; _panelArray[x, y] = button; this.AddPanel(button); } else if (_fillType == DGridFillType.DText) { DText text = new DText(_guiManager, gridPosition.X + (_cellWidth / 2), gridPosition.Y + (_cellHeight / 2), _cellWidth, _cellHeight, x.ToString() + ", " + y.ToString()); text.HorizontalAlignment = DText.DHorizontalAlignment.Center; text.VerticalAlignment = DText.DVerticalAlignment.Center; text.FontName = "Miramonte"; _panelArray[x, y] = text; this.AddPanel(text); } } } } }
protected override void LoadContent() { base.LoadContent(); // init lobby label lobbyLabel = new DText(guiManager); lobbyLabel.FontName = "Miramonte"; layout.Add(lobbyLabel); lobbyLabel.Initialize(); lobbyLabel.Text = "Room List"; lobbyLabel.Position = new Vector2(100, 100); lobbyLabel.HorizontalAlignment = DText.DHorizontalAlignment.Center; form.AddPanel(lobbyLabel); // init list box roomList = new DListBox(guiManager); layout.Add(roomList); roomList.Initialize(); roomList.Position = new Vector2(100, 150); form.AddPanel(roomList); // init join room button joinRoomButton = new DButton(guiManager); layout.Add(joinRoomButton); joinRoomButton.Text = "Join"; joinRoomButton.Position = new Vector2(joinRoomButton.Size.X + 100, 500) - joinRoomButton.Size; joinRoomButton.Initialize(); form.AddPanel(joinRoomButton); joinRoomButton.OnClick += new DButtonEventHandler(joinRoomButton_OnClick); // init create room button createRoomButton = new DButton(guiManager); layout.Add(createRoomButton); createRoomButton.Text = "Create"; createRoomButton.Position = new Vector2(800 - 100, 500) - createRoomButton.Size; createRoomButton.Initialize(); form.AddPanel(createRoomButton); createRoomButton.OnClick += new DButtonEventHandler(createRoomButton_OnClick); }