public bool Initialize(GameMain gameMain, out string reason) { this._gameMain = gameMain; _showingSelection = false; _background = new BBStretchableImage(); _playerBackground = new BBStretchableImage(); _playerInfoBackground = new BBStretchableImage(); _playerRaceButton = new BBStretchButton(); _playerRaceDescription = new BBTextBox(); _playerLabels = new BBLabel[3]; _playerEmperorName = new BBSingleLineTextBox(); _playerHomeworldName = new BBSingleLineTextBox(); _AIBackground = new BBStretchableImage(); _AIRaceButtons = new BBStretchButton[5]; _raceSprites = new BBSprite[6]; _playerRaces = new Race[6]; _playerColors = new Color[6]; _numberOfAILabel = new BBLabel(); _numericUpDownAI = new BBNumericUpDown(); _busyImage = new BBStretchableImage(); _busyText = new BBLabel(); _okButton = new BBStretchButton(); _cancelButton = new BBStretchButton(); _difficultyComboBox = new BBComboBox(); _difficultyLabel = new BBLabel(); _nebulaBackground = SpriteManager.GetSprite("TitleNebula", gameMain.Random); _playerColors[0] = Color.Blue; _playerColors[1] = Color.Red; _playerColors[2] = Color.Yellow; _playerColors[3] = Color.Green; _playerColors[4] = Color.Purple; _playerColors[5] = Color.Orange; _xPos = (gameMain.ScreenWidth / 2) - 440; _yPos = (gameMain.ScreenHeight / 2) - 340; if (_nebulaBackground == null) { reason = "TitleNebula sprite doesn't exist."; return(false); } if (!_background.Initialize(_xPos, _yPos, 880, 680, StretchableImageType.MediumBorder, gameMain.Random, out reason)) { return(false); } if (!_playerBackground.Initialize(_xPos + 30, _yPos + 30, 820, 170, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return(false); } if (!_playerInfoBackground.Initialize(_xPos + 40, _yPos + 60, 295, 130, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return(false); } if (!_playerRaceButton.Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 340, _yPos + 40, 500, 150, gameMain.Random, out reason)) { return(false); } if (!_playerRaceDescription.Initialize(_xPos + 485, _yPos + 51, 345, 130, true, true, "RaceDescriptionTextBox", gameMain.Random, out reason)) { return(false); } _playerLabels[0] = new BBLabel(); if (!_playerLabels[0].Initialize(_xPos + 90, _yPos + 36, "Player Race Information", Color.White, out reason)) { return(false); } _playerLabels[1] = new BBLabel(); if (!_playerLabels[1].Initialize(_xPos + 45, _yPos + 70, "Emperor Name:", Color.White, out reason)) { return(false); } if (!_playerEmperorName.Initialize(string.Empty, _xPos + 50, _yPos + 90, 275, 35, false, gameMain.Random, out reason)) { return(false); } _playerLabels[2] = new BBLabel(); if (!_playerLabels[2].Initialize(_xPos + 45, _yPos + 125, "Homeworld Name:", Color.White, out reason)) { return(false); } if (!_playerHomeworldName.Initialize(string.Empty, _xPos + 50, _yPos + 145, 275, 35, false, gameMain.Random, out reason)) { return(false); } _playerRaceDescription.SetText("A random race will be chosen. If the Emperor and/or Homeworld name fields are left blank, default race names for those will be used."); _randomRaceSprite = SpriteManager.GetSprite("RandomRace", gameMain.Random); if (_randomRaceSprite == null) { reason = "RandomRace sprite does not exist."; return(false); } for (int i = 0; i < _raceSprites.Length; i++) { _raceSprites[i] = _randomRaceSprite; } if (!_AIBackground.Initialize(_xPos + 30, _yPos + 205, 820, 220, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return(false); } if (!_difficultyLabel.Initialize(_xPos + 40, _yPos + 220, "Difficulty Level:", Color.White, out reason)) { return(false); } List <string> difficultyItems = new List <string> { "Simple", "Easy", "Medium", "Hard", "Impossible" }; if (!_difficultyComboBox.Initialize(difficultyItems, _xPos + 170, _yPos + 215, 200, 35, 5, gameMain.Random, out reason)) { return(false); } if (!_numberOfAILabel.Initialize(_xPos + 730, _yPos + 220, "Number of Computer Players:", Color.White, out reason)) { return(false); } _numberOfAILabel.SetAlignment(true); if (!_numericUpDownAI.Initialize(_xPos + 735, _yPos + 222, 75, 1, 5, 5, gameMain.Random, out reason)) { return(false); } for (int i = 0; i < _AIRaceButtons.Length; i++) { _AIRaceButtons[i] = new BBStretchButton(); if (!_AIRaceButtons[i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 40 + (i * 155), _yPos + 260, 150, 150, gameMain.Random, out reason)) { return(false); } } _galaxyBackground = new BBStretchableImage(); _galaxyComboBox = new BBComboBox(); List <string> items = new List <string>(); items.Add("Small Galaxy"); items.Add("Medium Galaxy"); items.Add("Large Galaxy"); items.Add("Huge Galaxy"); if (!_galaxyBackground.Initialize(_xPos + 30, _yPos + 430, 240, 235, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return(false); } if (!_galaxyComboBox.Initialize(items, _xPos + 30, _yPos + 430, 240, 35, 4, gameMain.Random, out reason)) { return(false); } _raceSelection = new RaceSelection(); if (!_raceSelection.Initialize(gameMain, out reason)) { return(false); } _raceSelection.OnOkClick = OnRaceSelectionOKClick; _generatingGalaxy = false; if (!_busyImage.Initialize(gameMain.ScreenWidth / 2 - 100, gameMain.ScreenHeight / 2 - 50, 200, 100, StretchableImageType.MediumBorder, gameMain.Random, out reason)) { return(false); } if (!_busyText.Initialize(gameMain.ScreenWidth / 2, gameMain.ScreenHeight / 2, "Generating Galaxy", Color.White, out reason)) { return(false); } if (!_okButton.Initialize("Start Game", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 660, _yPos + 610, 200, 50, gameMain.Random, out reason)) { return(false); } if (!_cancelButton.Initialize("Main Menu", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 450, _yPos + 610, 200, 50, gameMain.Random, out reason)) { return(false); } LoadLastSettings(); reason = null; return(true); }
public bool Initialize(GameMain gameMain, out string reason) { this._gameMain = gameMain; _showingSelection = false; _background = new BBStretchableImage(); _playerBackground = new BBStretchableImage(); _playerInfoBackground = new BBStretchableImage(); _playerRaceButton = new BBStretchButton(); _playerRaceDescription = new BBTextBox(); _playerLabels = new BBLabel[3]; _playerEmperorName = new BBSingleLineTextBox(); _playerHomeworldName = new BBSingleLineTextBox(); _AIBackground = new BBStretchableImage(); _AIRaceButtons = new BBStretchButton[5]; _raceSprites = new BBSprite[6]; _playerRaces = new Race[6]; _playerColors = new Color[6]; _numberOfAILabel = new BBLabel(); _numericUpDownAI = new BBNumericUpDown(); _busyImage = new BBStretchableImage(); _busyText = new BBLabel(); _okButton = new BBStretchButton(); _cancelButton = new BBStretchButton(); _difficultyComboBox = new BBComboBox(); _difficultyLabel = new BBLabel(); _nebulaBackground = SpriteManager.GetSprite("TitleNebula", gameMain.Random); _playerColors[0] = Color.Blue; _playerColors[1] = Color.Red; _playerColors[2] = Color.Yellow; _playerColors[3] = Color.Green; _playerColors[4] = Color.Purple; _playerColors[5] = Color.Orange; _xPos = (gameMain.ScreenWidth / 2) - 440; _yPos = (gameMain.ScreenHeight / 2) - 340; if (_nebulaBackground == null) { reason = "TitleNebula sprite doesn't exist."; return false; } if (!_background.Initialize(_xPos, _yPos, 880, 680, StretchableImageType.MediumBorder, gameMain.Random, out reason)) { return false; } if (!_playerBackground.Initialize(_xPos + 30, _yPos + 30, 820, 170, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return false; } if (!_playerInfoBackground.Initialize(_xPos + 40, _yPos + 60, 295, 130, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return false; } if (!_playerRaceButton.Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 340, _yPos + 40, 500, 150, gameMain.Random, out reason)) { return false; } if (!_playerRaceDescription.Initialize(_xPos + 485, _yPos + 51, 345, 130, true, true, "RaceDescriptionTextBox", gameMain.Random, out reason)) { return false; } _playerLabels[0] = new BBLabel(); if (!_playerLabels[0].Initialize(_xPos + 90, _yPos + 36, "Player Race Information", Color.White, out reason)) { return false; } _playerLabels[1] = new BBLabel(); if (!_playerLabels[1].Initialize(_xPos + 45, _yPos + 70, "Emperor Name:", Color.White, out reason)) { return false; } if (!_playerEmperorName.Initialize(string.Empty, _xPos + 50, _yPos + 90, 275, 35, false, gameMain.Random, out reason)) { return false; } _playerLabels[2] = new BBLabel(); if (!_playerLabels[2].Initialize(_xPos + 45, _yPos + 125, "Homeworld Name:", Color.White, out reason)) { return false; } if (!_playerHomeworldName.Initialize(string.Empty, _xPos + 50, _yPos + 145, 275, 35, false, gameMain.Random, out reason)) { return false; } _playerRaceDescription.SetText("A random race will be chosen. If the Emperor and/or Homeworld name fields are left blank, default race names for those will be used."); _randomRaceSprite = SpriteManager.GetSprite("RandomRace", gameMain.Random); if (_randomRaceSprite == null) { reason = "RandomRace sprite does not exist."; return false; } for (int i = 0; i < _raceSprites.Length; i++) { _raceSprites[i] = _randomRaceSprite; } if (!_AIBackground.Initialize(_xPos + 30, _yPos + 205, 820, 220, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return false; } if (!_difficultyLabel.Initialize(_xPos + 40, _yPos + 220, "Difficulty Level:", Color.White, out reason)) { return false; } List<string> difficultyItems = new List<string> { "Simple", "Easy", "Medium", "Hard", "Impossible" }; if (!_difficultyComboBox.Initialize(difficultyItems, _xPos + 170, _yPos + 215, 200, 35, 5, gameMain.Random, out reason)) { return false; } if (!_numberOfAILabel.Initialize(_xPos + 730, _yPos + 220, "Number of Computer Players:", Color.White, out reason)) { return false; } _numberOfAILabel.SetAlignment(true); if (!_numericUpDownAI.Initialize(_xPos + 735, _yPos + 222, 75, 1, 5, 5, gameMain.Random, out reason)) { return false; } for (int i = 0; i < _AIRaceButtons.Length; i++) { _AIRaceButtons[i] = new BBStretchButton(); if (!_AIRaceButtons[i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 40 + (i * 155), _yPos + 260, 150, 150, gameMain.Random, out reason)) { return false; } } _galaxyBackground = new BBStretchableImage(); _galaxyComboBox = new BBComboBox(); List<string> items = new List<string>(); items.Add("Small Galaxy"); items.Add("Medium Galaxy"); items.Add("Large Galaxy"); items.Add("Huge Galaxy"); if (!_galaxyBackground.Initialize(_xPos + 30, _yPos + 430, 240, 235, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return false; } if (!_galaxyComboBox.Initialize(items, _xPos + 30, _yPos + 430, 240, 35, 4, gameMain.Random, out reason)) { return false; } _raceSelection = new RaceSelection(); if (!_raceSelection.Initialize(gameMain, out reason)) { return false; } _raceSelection.OnOkClick = OnRaceSelectionOKClick; _generatingGalaxy = false; if (!_busyImage.Initialize(gameMain.ScreenWidth / 2 - 100, gameMain.ScreenHeight / 2 - 50, 200, 100, StretchableImageType.MediumBorder, gameMain.Random, out reason)) { return false; } if (!_busyText.Initialize(gameMain.ScreenWidth / 2, gameMain.ScreenHeight / 2, "Generating Galaxy", Color.White, out reason)) { return false; } if (!_okButton.Initialize("Start Game", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 660, _yPos + 610, 200, 50, gameMain.Random, out reason)) { return false; } if (!_cancelButton.Initialize("Main Menu", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 450, _yPos + 610, 200, 50, gameMain.Random, out reason)) { return false; } LoadLastSettings(); reason = null; return true; }
public bool Initialize(GameMain gameMain, out string reason) { int x = (gameMain.ScreenWidth / 2) - 400; int y = (gameMain.ScreenHeight / 2) - 300; if (!base.Initialize(x, y, 800, 600, StretchableImageType.MediumBorder, gameMain, false, gameMain.Random, out reason)) { return false; } _shipStyleBackground = new BBStretchableImage(); _shipSizeButtons = new BBStretchButton[4]; _prevShipStyleButton = new BBButton(); _nextShipStyleButton = new BBButton(); if (!_shipStyleBackground.Initialize(x + 15, y + 385, 220, 200, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return false; } if (!_prevShipStyleButton.Initialize("ScrollLeftBGButton", "ScrollLeftFGButton", string.Empty, ButtonTextAlignment.CENTER, x + 22, y + 477, 16, 16, gameMain.Random, out reason)) { return false; } if (!_nextShipStyleButton.Initialize("ScrollRightBGButton", "ScrollRightFGButton", string.Empty, ButtonTextAlignment.CENTER, x + 212, y + 477, 16, 16, gameMain.Random, out reason)) { return false; } for (int i = 0; i < _shipSizeButtons.Length; i++) { _shipSizeButtons[i] = new BBStretchButton(); } if (!_shipSizeButtons[0].Initialize("Small", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, x + 235, y + 385, 80, 50, gameMain.Random, out reason)) { return false; } if (!_shipSizeButtons[1].Initialize("Medium", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, x + 235, y + 435, 80, 50, gameMain.Random, out reason)) { return false; } if (!_shipSizeButtons[2].Initialize("Large", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, x + 235, y + 485, 80, 50, gameMain.Random, out reason)) { return false; } if (!_shipSizeButtons[3].Initialize("Huge", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, x + 235, y + 535, 80, 50, gameMain.Random, out reason)) { return false; } _engineBackground = new BBStretchableImage(); _engineButton = new BBStretchButton(); _maneuverButton = new BBStretchButton(); _engineSpeed = new BBLabel(); _combatSpeed = new BBLabel(); _costPerPowerLabel = new BBLabel(); _spacePerPowerLabel = new BBLabel(); _defenseRating = new BBLabel(); if (!_engineBackground.Initialize(x + 15, y + 15, 300, 180, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return false; } if (!_engineButton.Initialize(string.Empty, ButtonTextAlignment.CENTER, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 25, y + 25, 280, 35, gameMain.Random, out reason)) { return false; } if (!_maneuverButton.Initialize(string.Empty, ButtonTextAlignment.CENTER, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 25, y + 62, 280, 35, gameMain.Random, out reason)) { return false; } if (!_engineSpeed.Initialize(x + 25, y + 100, string.Empty, System.Drawing.Color.White, out reason)) { return false; } if (!_combatSpeed.Initialize(x + 165, y + 100, string.Empty, System.Drawing.Color.White, out reason)) { return false; } if (!_costPerPowerLabel.Initialize(x + 25, y + 120, string.Empty, System.Drawing.Color.White, out reason)) { return false; } if (!_spacePerPowerLabel.Initialize(x + 25, y + 140, string.Empty, System.Drawing.Color.White, out reason)) { return false; } if (!_defenseRating.Initialize(x + 25, y + 160, string.Empty, System.Drawing.Color.White, out reason)) { return false; } _defensiveEquipmentBackground = new BBStretchableImage(); _armorButton = new BBStretchButton(); _shieldButton = new BBStretchButton(); _ECMButton = new BBStretchButton(); _hitPointsLabel = new BBLabel(); _absorbtionLabel = new BBLabel(); _missileDefenseLabel = new BBLabel(); if (!_defensiveEquipmentBackground.Initialize(x + 15, y + 195, 300, 190, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return false; } if (!_armorButton.Initialize(string.Empty, ButtonTextAlignment.CENTER, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 25, y + 206, 280, 35, gameMain.Random, out reason)) { return false; } if (!_shieldButton.Initialize(string.Empty, ButtonTextAlignment.CENTER, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 25, y + 243, 280, 35, gameMain.Random, out reason)) { return false; } if (!_ECMButton.Initialize(string.Empty, ButtonTextAlignment.CENTER, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 25, y + 280, 280, 35, gameMain.Random, out reason)) { return false; } if (!_hitPointsLabel.Initialize(x + 25, y + 315, string.Empty, System.Drawing.Color.White, out reason)) { return false; } if (!_absorbtionLabel.Initialize(x + 25, y + 335, string.Empty, System.Drawing.Color.White, out reason)) { return false; } if (!_missileDefenseLabel.Initialize(x + 25, y + 355, string.Empty, System.Drawing.Color.White, out reason)) { return false; } _computerBackground = new BBStretchableImage(); _computerButton = new BBStretchButton(); _attackRating = new BBLabel(); if (!_computerBackground.Initialize(x + 315, y + 15, 470, 55, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return false; } if (!_computerButton.Initialize(string.Empty, ButtonTextAlignment.CENTER, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 325, y + 25, 280, 35, gameMain.Random, out reason)) { return false; } if (!_attackRating.Initialize(x + 610, y + 30, string.Empty, System.Drawing.Color.White, out reason)) { return false; } _weaponsBackground = new BBStretchableImage(); _weaponButtons = new BBStretchButton[4]; _weaponCountLabels = new BBLabel[4]; _weaponDescriptions = new BBLabel[4]; _weaponCounts = new BBNumericUpDown[4]; if (!_weaponsBackground.Initialize(x + 315, y + 70, 470, 220, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return false; } for (int i = 0; i < 4; i++) { _weaponButtons[i] = new BBStretchButton(); _weaponCountLabels[i] = new BBLabel(); _weaponDescriptions[i] = new BBLabel(); _weaponCounts[i] = new BBNumericUpDown(); if (!_weaponButtons[i].Initialize(string.Empty, ButtonTextAlignment.CENTER, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 325, y + 80 + (i * 50), 280, 30, gameMain.Random, out reason)) { return false; } if (!_weaponCountLabels[i].Initialize(x + 695, y + 85 + (i * 50), "Count:", System.Drawing.Color.White, out reason)) { return false; } _weaponCountLabels[i].SetAlignment(true); if (!_weaponCounts[i].Initialize(x + 700, y + 85 + (i * 50), 70, 1, 99, 1, 1, gameMain.Random, out reason)) { return false; } if (!_weaponDescriptions[i].Initialize(x + 325, y + 112 + (i * 50), string.Empty, System.Drawing.Color.White, out reason)) { return false; } } _specialsBackground = new BBStretchableImage(); _specialButtons = new BBStretchButton[3]; _specialDescriptions = new BBTextBox[3]; if (!_specialsBackground.Initialize(x + 315, y + 290, 470, 230, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return false; } for (int i = 0; i < 3; i++) { _specialButtons[i] = new BBStretchButton(); _specialDescriptions[i] = new BBTextBox(); if (!_specialButtons[i].Initialize(string.Empty, ButtonTextAlignment.CENTER, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, x + 325, y + 300 + (i * 70), 450, 30, gameMain.Random, out reason)) { return false; } if (!_specialDescriptions[i].Initialize(x + 325, y + 332 + (i * 70), 450, 38, true, true, "SpecialDesc" + i, gameMain.Random, out reason)) { return false; } } _statsBackground = new BBStretchableImage(); _spaceLabel = new BBLabel(); _costLabel = new BBLabel(); _nameField = new BBSingleLineTextBox(); if (!_statsBackground.Initialize(x + 315, y + 520, 470, 65, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return false; } if (!_spaceLabel.Initialize(x + 450, y + 559, string.Empty, System.Drawing.Color.White, out reason)) { return false; } if (!_costLabel.Initialize(x + 325, y + 559, string.Empty, System.Drawing.Color.White, out reason)) { return false; } if (!_nameField.Initialize(string.Empty, x + 325, y + 527, 150, 30, false, gameMain.Random, out reason)) { return false; } _clearButton = new BBButton(); _confirmButton = new BBButton(); if (!_clearButton.Initialize("CancelBG", "CancelFG", string.Empty, ButtonTextAlignment.CENTER, x + 595, y + 535, 75, 35, gameMain.Random, out reason)) { return false; } if (!_confirmButton.Initialize("ConfirmBG", "ConfirmFG", string.Empty, ButtonTextAlignment.CENTER, x + 685, y + 535, 75, 35, gameMain.Random, out reason)) { return false; } if (!_clearButton.SetToolTip("ClearDesign", "Clear Ship Design", gameMain.ScreenWidth, gameMain.ScreenHeight, gameMain.Random, out reason)) { return false; } if (!_confirmButton.SetToolTip("ConfirmDesign", "Add Ship Design", gameMain.ScreenWidth, gameMain.ScreenHeight, gameMain.Random, out reason)) { return false; } _equipmentSelection = new EquipmentSelection(); if (!_equipmentSelection.Initialize(gameMain, out reason)) { return false; } _equipmentSelection.OnSelectManeuver = OnSelectManeuver; _selectionShowing = false; _fleetSpecsWindow = new FleetSpecsWindow(); if (!_fleetSpecsWindow.Initialize(gameMain, "ShipDesign", out reason)) { return false; } _fleetSpecsWindow.ScrapAction = ScrapAction; _fleetSpecsShowing = false; return true; }