Inheritance: WindowInterface
        public bool Initialize(GameMain gameMain, out string reason)
        {
            _gameMain = gameMain;

            _x = (gameMain.ScreenWidth / 2) - 500;
            _y = (gameMain.ScreenHeight / 2) - 305;
            if (!Initialize((gameMain.ScreenWidth / 2) - 520, (gameMain.ScreenHeight / 2) - 320, 1040, 640, StretchableImageType.MediumBorder, gameMain, false, gameMain.Random, out reason))
            {
                return false;
            }

            _shipNames = new BBStretchButton[6];
            for (int i = 0; i < _shipNames.Length; i++)
            {
                _shipNames[i] = new BBStretchButton();
                if (!_shipNames[i].Initialize(string.Empty, ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _x + 80 + (150 * i), _y, 150, 40, _gameMain.Random, out reason))
                {
                    return false;
                }
            }

            _planetBackgrounds = new BBStretchButton[10];
            _planetNames = new BBLabel[10];
            _statusLabels = new BBLabel[11];
            _scrollBar = new BBScrollBar();

            _statusLabels[0] = new BBLabel();
            if (!_statusLabels[0].Initialize(_x, _y + 10, "Status", Color.White, out reason))
            {
                return false;
            }

            for (int i = 0; i < 10; i++)
            {
                _planetBackgrounds[i] = new BBStretchButton();
                if (!_planetBackgrounds[i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _x, _y + 40 + (50 * i), 980, 50, _gameMain.Random, out reason))
                {
                    return false;
                }
                _planetNames[i] = new BBLabel();
                if (!_planetNames[i].Initialize(_x + 5, _y + 65 + (50 * i), string.Empty, Color.GreenYellow, out reason))
                {
                    return false;
                }
                _statusLabels[i + 1] = new BBLabel();
                if (!_statusLabels[i + 1].Initialize(_x + 5, _y + 45 + (50 * i), string.Empty, Color.Orange, out reason))
                {
                    return false;
                }
            }

            _shipAmountLabels = new BBStretchButton[10][];
            for (int i = 0; i < _shipAmountLabels.Length; i++)
            {
                _shipAmountLabels[i] = new BBStretchButton[6];
                for (int j = 0; j < 6; j++)
                {
                    _shipAmountLabels[i][j] = new BBStretchButton();
                    if (!_shipAmountLabels[i][j].Initialize(string.Empty, ButtonTextAlignment.CENTER, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, _x + 80 + (150 * j), _y + 43 + (i * 50), 150, 25, _gameMain.Random, out reason))
                    {
                        return false;
                    }
                }
            }

            if (!_scrollBar.Initialize(_x + 980, _y + 40, 500, 10, 10, false, false, _gameMain.Random, out reason))
            {
                return false;
            }

            _maintenanceCostBackground = new BBStretchableImage();
            _maintenanceLabel = new BBLabel();
            _maintenanceAmountLabel = new BBLabel();
            _scrapButtons = new BBButton[6];
            for (int i = 0; i < _scrapButtons.Length; i++)
            {
                _scrapButtons[i] = new BBButton();
                if (!_scrapButtons[i].Initialize("ScrapShipBG", "ScrapShipFG", string.Empty, ButtonTextAlignment.LEFT, _x + 112 + (150 * i), _y + 540, 75, 35, gameMain.Random, out reason))
                {
                    return false;
                }
            }

            if (!_maintenanceCostBackground.Initialize(_x + 220, _y + 577, 280, 35, StretchableImageType.TinyButtonBG, gameMain.Random, out reason))
            {
                return false;
            }
            if (!_maintenanceLabel.Initialize(_x + 225, _y + 585, "Maintenance Cost:", Color.Orange, out reason))
            {
                return false;
            }
            if (!_maintenanceAmountLabel.Initialize(_x + 495, _y + 585, string.Empty, Color.White, out reason))
            {
                return false;
            }
            _maintenanceAmountLabel.SetAlignment(true);

            _viewSpecsButton = new BBStretchButton();
            if (!_viewSpecsButton.Initialize("View Ship Specifications", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _x + 500, _y + 577, 280, 35, gameMain.Random, out reason))
            {
                return false;
            }

            _fleetSpecsWindow = new FleetSpecsWindow();
            if (!_fleetSpecsWindow.Initialize(gameMain, "FleetList", out reason))
            {
                return false;
            }
            _fleetSpecsShowing = false;

            reason = null;
            return true;
        }
示例#2
0
        public bool Initialize(GameMain gameMain, out string reason)
        {
            _gameMain = gameMain;

            _x = (gameMain.ScreenWidth / 2) - 500;
            _y = (gameMain.ScreenHeight / 2) - 305;
            if (!Initialize((gameMain.ScreenWidth / 2) - 520, (gameMain.ScreenHeight / 2) - 320, 1040, 640, StretchableImageType.MediumBorder, gameMain, false, gameMain.Random, out reason))
            {
                return(false);
            }

            _shipNames = new BBStretchButton[6];
            for (int i = 0; i < _shipNames.Length; i++)
            {
                _shipNames[i] = new BBStretchButton();
                if (!_shipNames[i].Initialize(string.Empty, ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _x + 80 + (150 * i), _y, 150, 40, _gameMain.Random, out reason))
                {
                    return(false);
                }
            }

            _planetBackgrounds = new BBStretchButton[10];
            _planetNames       = new BBLabel[10];
            _statusLabels      = new BBLabel[11];
            _scrollBar         = new BBScrollBar();

            _statusLabels[0] = new BBLabel();
            if (!_statusLabels[0].Initialize(_x, _y + 10, "Status", Color.White, out reason))
            {
                return(false);
            }

            for (int i = 0; i < 10; i++)
            {
                _planetBackgrounds[i] = new BBStretchButton();
                if (!_planetBackgrounds[i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _x, _y + 40 + (50 * i), 980, 50, _gameMain.Random, out reason))
                {
                    return(false);
                }
                _planetNames[i] = new BBLabel();
                if (!_planetNames[i].Initialize(_x + 5, _y + 65 + (50 * i), string.Empty, Color.GreenYellow, out reason))
                {
                    return(false);
                }
                _statusLabels[i + 1] = new BBLabel();
                if (!_statusLabels[i + 1].Initialize(_x + 5, _y + 45 + (50 * i), string.Empty, Color.Orange, out reason))
                {
                    return(false);
                }
            }

            _shipAmountLabels = new BBStretchButton[10][];
            for (int i = 0; i < _shipAmountLabels.Length; i++)
            {
                _shipAmountLabels[i] = new BBStretchButton[6];
                for (int j = 0; j < 6; j++)
                {
                    _shipAmountLabels[i][j] = new BBStretchButton();
                    if (!_shipAmountLabels[i][j].Initialize(string.Empty, ButtonTextAlignment.CENTER, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, _x + 80 + (150 * j), _y + 43 + (i * 50), 150, 25, _gameMain.Random, out reason))
                    {
                        return(false);
                    }
                }
            }

            if (!_scrollBar.Initialize(_x + 980, _y + 40, 500, 10, 10, false, false, _gameMain.Random, out reason))
            {
                return(false);
            }

            _maintenanceCostBackground = new BBStretchableImage();
            _maintenanceLabel          = new BBLabel();
            _maintenanceAmountLabel    = new BBLabel();
            _scrapButtons = new BBButton[6];
            for (int i = 0; i < _scrapButtons.Length; i++)
            {
                _scrapButtons[i] = new BBButton();
                if (!_scrapButtons[i].Initialize("ScrapShipBG", "ScrapShipFG", string.Empty, ButtonTextAlignment.LEFT, _x + 112 + (150 * i), _y + 540, 75, 35, gameMain.Random, out reason))
                {
                    return(false);
                }
            }

            if (!_maintenanceCostBackground.Initialize(_x + 220, _y + 577, 280, 35, StretchableImageType.TinyButtonBG, gameMain.Random, out reason))
            {
                return(false);
            }
            if (!_maintenanceLabel.Initialize(_x + 225, _y + 585, "Maintenance Cost:", Color.Orange, out reason))
            {
                return(false);
            }
            if (!_maintenanceAmountLabel.Initialize(_x + 495, _y + 585, string.Empty, Color.White, out reason))
            {
                return(false);
            }
            _maintenanceAmountLabel.SetAlignment(true);

            _viewSpecsButton = new BBStretchButton();
            if (!_viewSpecsButton.Initialize("View Ship Specifications", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _x + 500, _y + 577, 280, 35, gameMain.Random, out reason))
            {
                return(false);
            }

            _fleetSpecsWindow = new FleetSpecsWindow();
            if (!_fleetSpecsWindow.Initialize(gameMain, "FleetList", out reason))
            {
                return(false);
            }
            _fleetSpecsShowing = false;

            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;
        }