public bool Initialize(GameMain gameMain, out string reason) { _gameMain = gameMain; _chatBackground = new BBStretchableImage(); _playerListBackground = new BBStretchableImage(); _chatText = new BBTextBox(); _messageTextBox = new BBSingleLineTextBox(); _playerList = new BBTextBox(); _startGame = new BBStretchButton(); _leaveLobby = new BBStretchButton(); int chatWidth = _gameMain.ScreenSize.X - 250; int chatHeight = _gameMain.ScreenSize.Y - 80; if (!_chatBackground.Initialize(20, 20, chatWidth, chatHeight, StretchableImageType.ThinBorderBG, _gameMain.Random, out reason)) { return false; } if (!_chatText.Initialize(25, 25, chatWidth - 10, chatHeight - 10, true, true, "PreGameChatTextBox", _gameMain.Random, out reason)) { return false; } if (!_messageTextBox.Initialize("Chat Message", 20, 20 + chatHeight, chatWidth, 40, false, _gameMain.Random, out reason)) { return false; } if (!_playerListBackground.Initialize(chatWidth + 30, 20, 200, chatHeight - 45, StretchableImageType.ThinBorderBG, _gameMain.Random, out reason)) { return false; } if (!_playerList.Initialize(chatWidth + 35, 25, 190, chatHeight - 255, false, true, "PlayerListTextBox", _gameMain.Random, out reason)) { return false; } if (!_startGame.Initialize("Start Game", ButtonTextAlignment.CENTER, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, chatWidth + 30, chatHeight - 15, 200, 35, _gameMain.Random, out reason)) { return false; } if (!_leaveLobby.Initialize("Leave", ButtonTextAlignment.CENTER, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, chatWidth + 30, chatHeight + 25, 200, 35, _gameMain.Random, out reason)) { return false; } _messageTextBox.Select(); return true; }
public override bool MouseUp(int x, int y) { if (_promptShowing) { if (!_saveGameNameField.MouseUp(x, y) && !string.IsNullOrEmpty(_saveGameNameField.Text)) { _promptShowing = false; _gameMain.SaveGame(_saveGameNameField.Text); GetSaveList(); //Refresh the list after saving } } if (_scrollBar.MouseUp(x, y)) { RefreshSaveButtons(); return(true); } if (_buttons[0].MouseUp(x, y)) { var func = CloseWindow; if (func != null) { func(); } _gameMain.ClearAll(); _gameMain.ChangeToScreen(Screen.NewGame); return(true); } if (_buttons[1].MouseUp(x, y)) { _promptShowing = true; if (_selectedGame >= 0) { _saveGameNameField.SetText(_files[_selectedGame].Name.Substring(0, _files[_selectedGame].Name.Length - _files[_selectedGame].Extension.Length)); } else { _saveGameNameField.SetText(string.Empty); } _saveGameNameField.Select(); return(true); } if (_buttons[2].MouseUp(x, y)) { var func = CloseWindow; if (func != null) { func(); } _gameMain.LoadGame(_files[_selectedGame].Name); return(true); } if (_buttons[3].MouseUp(x, y)) { //TODO: Add prompt to ensure user really want to exit _gameMain.ExitGame(); return(true); } for (int i = 0; i < _maxVisible; i++) { if (_saveGameButtons[i].MouseUp(x, y)) { foreach (var button in _saveGameButtons) { button.Selected = false; } _saveGameButtons[i].Selected = true; _selectedGame = i + _scrollBar.TopIndex; _buttons[2].Enabled = true; return(true); } } if (!base.MouseUp(x, y)) { //Clicked outside the window, close this window if (CloseWindow != null) { CloseWindow(); } } else { //Clicked inside window, clear save game selection, if any _selectedGame = -1; foreach (var button in _saveGameButtons) { button.Selected = false; } _buttons[2].Enabled = false; } return(false); }
public bool Initialize(GameMain gameMain, out string reason) { _gameMain = gameMain; int x = _gameMain.ScreenSize.X / 2 - 400; int y = _gameMain.ScreenSize.Y / 2 - 300; _background = new BBStretchableImage(); _energyUpgradeBackground = new BBStretchableImage(); _engineUpgradeBackground = new BBStretchableImage(); _weaponUpgradeBackground = new BBStretchableImage(); _shieldUpgradeBackground = new BBStretchableImage(); _playerStatusBackground = new BBStretchableImage(); _chatBackground = new BBStretchableImage(); _playerStatusTextBox = new BBTextBox(); _chatTextBox = new BBTextBox(); _messageTextBox = new BBSingleLineTextBox(); _readyButton = new BBButton(); _energyButtons = new BBStretchButton[3]; _energyLabels = new BBLabel[3]; for (int i = 0; i < 3; i++) { _energyButtons[i] = new BBStretchButton(); _energyLabels[i] = new BBLabel(); } _engineButtons = new BBStretchButton[4]; _engineLabels = new BBLabel[4]; for (int i = 0; i < 4; i++) { _engineButtons[i] = new BBStretchButton(); _engineLabels[i] = new BBLabel(); } _weaponButtons = new BBStretchButton[8]; _weaponLabels = new BBLabel[8]; for (int i = 0; i < 8; i++) { _weaponButtons[i] = new BBStretchButton(); _weaponLabels[i] = new BBLabel(); } _shieldButtons = new BBStretchButton[4]; _shieldLabels = new BBLabel[4]; for (int i = 0; i < 4; i++) { _shieldButtons[i] = new BBStretchButton(); _shieldLabels[i] = new BBLabel(); } _upgradeLabels = new BBLabel[4]; for (int i = 0; i < 4; i++) { _upgradeLabels[i] = new BBLabel(); } if (!_background.Initialize(x - 30, y - 30, 860, 660, StretchableImageType.ThickBorder, _gameMain.Random, out reason)) { return false; } if (!_energyUpgradeBackground.Initialize(x, y, 400, 150, StretchableImageType.ThinBorderBG, _gameMain.Random, out reason)) { return false; } if (!_engineUpgradeBackground.Initialize(x, y + 150, 400, 190, StretchableImageType.ThinBorderBG, _gameMain.Random, out reason)) { return false; } if (!_weaponUpgradeBackground.Initialize(x + 400, y, 400, 340, StretchableImageType.ThinBorderBG, _gameMain.Random, out reason)) { return false; } if (!_shieldUpgradeBackground.Initialize(x, y + 340, 800, 110, StretchableImageType.ThinBorderBG, _gameMain.Random, out reason)) { return false; } if (!_playerStatusBackground.Initialize(x, y + 450, 400, 150, StretchableImageType.ThinBorderBG, _gameMain.Random, out reason)) { return false; } if (!_chatBackground.Initialize(x + 400, y + 450, 400, 150, StretchableImageType.ThinBorderBG, _gameMain.Random, out reason)) { return false; } if (!_playerStatusTextBox.Initialize(x + 410, y + 460, 380, 95, false, true, "PlayerStatusTextBox", _gameMain.Random, out reason)) { return false; } if (!_chatTextBox.Initialize(x + 10, y + 460, 380, 100, true, true, "UpgradeChatTextBox", _gameMain.Random, out reason)) { return false; } if (!_messageTextBox.Initialize(string.Empty, x + 10, y + 560, 380, 30, false, _gameMain.Random, out reason)) { return false; } if (!_energyButtons[0].Initialize("Upgrade Recharge Rate", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 10, y + 32, 380, 35, _gameMain.Random, out reason)) { return false; } if (!_energyButtons[1].Initialize("Upgrade Capacity", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 10, y + 69, 380, 35, _gameMain.Random, out reason)) { return false; } if (!_energyButtons[2].Initialize("Buy Emergency Battery", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 10, y + 106, 380, 35, _gameMain.Random, out reason)) { return false; } for (int i = 0; i < 3; i++) { if (!_energyLabels[i].Initialize(x + 375, y + 40 + (i * 37), string.Empty, Color.GreenYellow, out reason)) { return false; } _energyLabels[i].SetAlignment(true); } if (!_engineButtons[0].Initialize("Upgrade Acceleration", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 10, y + 182, 380, 35, _gameMain.Random, out reason)) { return false; } if (!_engineButtons[1].Initialize("Upgrade Rotation Speed", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 10, y + 219, 380, 35, _gameMain.Random, out reason)) { return false; } if (!_engineButtons[2].Initialize("Upgrade Reverse Thrusters", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 10, y + 256, 380, 35, _gameMain.Random, out reason)) { return false; } if (!_engineButtons[3].Initialize("Upgrade Boosters", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 10, y + 293, 380, 35, _gameMain.Random, out reason)) { return false; } for (int i = 0; i < 4; i++) { if (!_engineLabels[i].Initialize(x + 375, y + 190 + (i * 37), string.Empty, Color.GreenYellow, out reason)) { return false; } _engineLabels[i].SetAlignment(true); } if (!_weaponButtons[0].Initialize("Reduce Cooldown", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 410, y + 32, 380, 35, _gameMain.Random, out reason)) { return false; } if (!_weaponButtons[1].Initialize("Reduce Energy Consumption", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 410, y + 69, 380, 35, _gameMain.Random, out reason)) { return false; } if (!_weaponButtons[2].Initialize("Upgrade Damage", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 410, y + 106, 380, 35, _gameMain.Random, out reason)) { return false; } if (!_weaponButtons[3].Initialize("Upgrade Velocity", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 410, y + 143, 380, 35, _gameMain.Random, out reason)) { return false; } if (!_weaponButtons[4].Initialize("Upgrade Penetration", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 410, y + 180, 380, 35, _gameMain.Random, out reason)) { return false; } if (!_weaponButtons[5].Initialize("Buy Additional Mount", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 410, y + 217, 380, 35, _gameMain.Random, out reason)) { return false; } if (!_weaponButtons[6].Initialize("Add Shrapnel", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 410, y + 252, 380, 35, _gameMain.Random, out reason)) { return false; } if (!_weaponButtons[7].Initialize("Buy Nuclear Missile", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 410, y + 287, 380, 35, _gameMain.Random, out reason)) { return false; } for (int i = 0; i < 8; i++) { if (!_weaponLabels[i].Initialize(x + 775, y + 40 + (i * 37), string.Empty, Color.GreenYellow, out reason)) { return false; } _weaponLabels[i].SetAlignment(true); } if (!_shieldButtons[0].Initialize("Upgrade Shredding", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 10, y + 372, 390, 35, _gameMain.Random, out reason)) { return false; } if (!_shieldButtons[1].Initialize("Upgrade Hardness", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 10, y + 409, 390, 35, _gameMain.Random, out reason)) { return false; } if (!_shieldButtons[2].Initialize("Upgrade Inertial Stabilizer", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 400, y + 372, 390, 35, _gameMain.Random, out reason)) { return false; } if (!_shieldButtons[3].Initialize("Buy Phasing Cloak", ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 400, y + 409, 390, 35, _gameMain.Random, out reason)) { return false; } for (int i = 0; i < 4; i++) { if (!_shieldLabels[i].Initialize(x + 385 + ((i / 2) * 390), y + 380 + ((i % 2) * 37), string.Empty, Color.GreenYellow, out reason)) { return false; } _shieldLabels[i].SetAlignment(true); } if (!_readyButton.Initialize("ConfirmBG", "ConfirmFG", string.Empty, ButtonTextAlignment.CENTER, x + 715, y + 555, 75, 35, _gameMain.Random, out reason)) { return false; } _messageTextBox.Select(); _showingShipSelection = false; return true; }