public bool Initialize(GameMain gameMain, out string reason) { if (!this.Initialize(gameMain.ScreenWidth / 2 - 230, gameMain.ScreenHeight / 2 - 180, 460, 360, StretchableImageType.MediumBorder, gameMain, false, gameMain.Random, out reason)) { return(false); } _discoveredTechs = new List <Technology>(); _fieldsNeedingNewTopics = new List <TechField>(); _availableTopics = new Dictionary <TechField, List <Technology> >(); _techDescriptionBackground = new BBStretchableImage(); _availableTechsToResearchBackground = new BBStretchableImage(); _instructionLabel = new BBLabel(); _techDescription = new BBTextBox(); _scrollBar = new BBScrollBar(); _availableTechsToResearchButtons = new BBInvisibleStretchButton[4]; _researchCosts = new BBLabel[4]; if (!_techDescriptionBackground.Initialize(_xPos + 20, _yPos + 20, 420, 170, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return(false); } if (!_availableTechsToResearchBackground.Initialize(_xPos + 20, _yPos + 220, 420, 120, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return(false); } if (!_instructionLabel.Initialize(_xPos + 20, _yPos + 195, "Please select an item to research", System.Drawing.Color.White, out reason)) { return(false); } if (!_techDescription.Initialize(_xPos + 165, _yPos + 33, 265, 150, true, true, "TechDescriptionTextBox", gameMain.Random, out reason)) { return(false); } if (!_scrollBar.Initialize(_xPos + 415, _yPos + 230, 100, 4, 4, false, false, gameMain.Random, out reason)) { return(false); } for (int i = 0; i < _availableTechsToResearchButtons.Length; i++) { _availableTechsToResearchButtons[i] = new BBInvisibleStretchButton(); _researchCosts[i] = new BBLabel(); if (!_availableTechsToResearchButtons[i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, _xPos + 30, _yPos + 230 + (i * 25), 385, 25, gameMain.Random, out reason)) { return(false); } if (!_availableTechsToResearchButtons[i].SetToolTip("ItemToResearch" + i + "ToolTip", string.Empty, gameMain.ScreenWidth, gameMain.ScreenHeight, gameMain.Random, out reason)) { return(false); } if (!_researchCosts[i].Initialize(_xPos + 405, _yPos + 232 + (i * 25), string.Empty, System.Drawing.Color.White, out reason)) { return(false); } _researchCosts[i].SetAlignment(true); } return(true); }
public bool Initialize(GameMain gameMain, out string reason) { this._gameMain = gameMain; _buttons = new BBButton[4]; _x = (gameMain.ScreenWidth / 2) - 130; _y = (gameMain.ScreenHeight / 2); for (int i = 0; i < _buttons.Length; i++) { _buttons[i] = new BBButton(); } if (!_buttons[0].Initialize("MainButtonBG", "MainButtonFG", "Continue", "LargeComputerFont", ButtonTextAlignment.CENTER, _x, _y, 260, 40, gameMain.Random, out reason, 20, -1)) { return false; } if (!_buttons[1].Initialize("MainButtonBG", "MainButtonFG", "New Game", "LargeComputerFont", ButtonTextAlignment.CENTER, _x, _y + 50, 260, 40, gameMain.Random, out reason, 20, -1)) { return false; } if (!_buttons[2].Initialize("MainButtonBG", "MainButtonFG", "Load Game", "LargeComputerFont", ButtonTextAlignment.CENTER, _x, _y + 100, 260, 40, gameMain.Random, out reason, 20, -1)) { return false; } if (!_buttons[3].Initialize("MainButtonBG", "MainButtonFG", "Exit", "LargeComputerFont", ButtonTextAlignment.CENTER, _x, _y + 150, 260, 40, gameMain.Random, out reason, 20, -1)) { return false; } for (int i = 0; i < _buttons.Length; i++) { _buttons[i].SetTextColor(System.Drawing.Color.Gold, System.Drawing.Color.Black); } _versionLabel = new BBLabel(); if (!_versionLabel.Initialize(10, _gameMain.ScreenHeight - 30, "Version 0.59", System.Drawing.Color.White, out reason)) { return false; } _background = SpriteManager.GetSprite("MainBackground", gameMain.Random); _planet = SpriteManager.GetSprite("MainPlanetBackground", gameMain.Random); _title = SpriteManager.GetSprite("Title", gameMain.Random); _x = (gameMain.ScreenWidth / 2) - 512; _y = (gameMain.ScreenHeight / 2) - 300; _files = Utility.GetSaveGames(gameMain.GameDataSet.FullName); if (_files.Count == 0) { _buttons[0].Active = false; //Disabled Continue and Load buttons since there's no games to load _buttons[2].Active = false; } _loadBackground = new BBStretchableImage(); if (!_loadBackground.Initialize((gameMain.ScreenWidth / 2) - 225, (gameMain.ScreenHeight / 2) - 175, 450, 350, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return false; } _saveGameButtons = new BBInvisibleStretchButton[10]; for (int i = 0; i < _saveGameButtons.Length; i++) { _saveGameButtons[i] = new BBInvisibleStretchButton(); if (!_saveGameButtons[i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, (gameMain.ScreenWidth / 2) - 220, (gameMain.ScreenHeight / 2) - 160 + (i * 32), 420, 32, gameMain.Random, out reason)) { return false; } } _scrollBar = new BBScrollBar(); if (!_scrollBar.Initialize((gameMain.ScreenWidth / 2) + 200, (gameMain.ScreenHeight / 2) - 160, 320, 10, 10, false, false, gameMain.Random, out reason)) { return false; } _maxVisible = _files.Count > _saveGameButtons.Length ? _saveGameButtons.Length : _files.Count; if (_maxVisible < _saveGameButtons.Length) { //Disable the scrollbar _scrollBar.SetEnabledState(false); } else { _scrollBar.SetEnabledState(true); _scrollBar.SetAmountOfItems(_files.Count); } RefreshSaves(); _showingLoadMenu = false; reason = null; return true; }
public bool Initialize(GameMain gameMain, out string reason) { if (!base.Initialize((gameMain.ScreenWidth / 2) - 250, (gameMain.ScreenHeight / 2) - 200, 500, 400, StretchableImageType.MediumBorder, gameMain, false, gameMain.Random, out reason)) { return false; } int x = (gameMain.ScreenWidth / 2) - 150; int y = (gameMain.ScreenHeight / 2) - 50; _saveGameNamePromptBackground = new BBStretchableImage(); if (!_saveGameNamePromptBackground.Initialize(x, y, 300, 100, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return false; } _saveGameNamePromptInstructionLabel = new BBLabel(); if (!_saveGameNamePromptInstructionLabel.Initialize(x + 20, y + 10, "Please input name for the save:", Color.White, out reason)) { return false; } _saveGameNameField = new BBSingleLineTextBox(); if (!_saveGameNameField.Initialize(string.Empty, x + 20, y + 40, 250, 40, false, gameMain.Random, out reason)) { return false; } _buttons = new BBStretchButton[4]; _buttons[0] = new BBStretchButton(); if (!_buttons[0].Initialize("New Game", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 30, _yPos + 350, 200, 35, gameMain.Random, out reason)) { return false; } _buttons[1] = new BBStretchButton(); if (!_buttons[1].Initialize("Save Game", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 270, _yPos + 300, 200, 35, gameMain.Random, out reason)) { return false; } _buttons[2] = new BBStretchButton(); if (!_buttons[2].Initialize("Load Game", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 30, _yPos + 300, 200, 35, gameMain.Random, out reason)) { return false; } _buttons[2].Enabled = false; _buttons[3] = new BBStretchButton(); if (!_buttons[3].Initialize("Exit Game", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 270, _yPos + 350, 200, 35, gameMain.Random, out reason)) { return false; } _saveGameListBackground = new BBStretchableImage(); if (!_saveGameListBackground.Initialize(_xPos + 20, _yPos + 20, 460, 325, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return false; } _saveGameButtons = new BBInvisibleStretchButton[8]; for (int i = 0; i < _saveGameButtons.Length; i++) { _saveGameButtons[i] = new BBInvisibleStretchButton(); if (!_saveGameButtons[i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, _xPos + 30, _yPos + 35 + (i * 32), 420, 32, gameMain.Random, out reason)) { return false; } } _scrollBar = new BBScrollBar(); if (!_scrollBar.Initialize(_xPos + 455, _yPos + 37, 256, _saveGameButtons.Length, _saveGameButtons.Length, false, false, gameMain.Random, out reason)) { return false; } _maxVisible = 0; _scrollBar.SetEnabledState(false); _selectedGame = -1; _files = new List<FileInfo>(); _promptShowing = false; return true; }
public bool Initialize(GameMain gameMain, out string reason) { if (!base.Initialize((gameMain.ScreenWidth / 2) - 250, (gameMain.ScreenHeight / 2) - 200, 500, 400, StretchableImageType.MediumBorder, gameMain, false, gameMain.Random, out reason)) { return(false); } int x = (gameMain.ScreenWidth / 2) - 150; int y = (gameMain.ScreenHeight / 2) - 50; _saveGameNamePromptBackground = new BBStretchableImage(); if (!_saveGameNamePromptBackground.Initialize(x, y, 300, 100, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return(false); } _saveGameNamePromptInstructionLabel = new BBLabel(); if (!_saveGameNamePromptInstructionLabel.Initialize(x + 20, y + 10, "Please input name for the save:", Color.White, out reason)) { return(false); } _saveGameNameField = new BBSingleLineTextBox(); if (!_saveGameNameField.Initialize(string.Empty, x + 20, y + 40, 250, 40, false, gameMain.Random, out reason)) { return(false); } _buttons = new BBStretchButton[4]; _buttons[0] = new BBStretchButton(); if (!_buttons[0].Initialize("New Game", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 30, _yPos + 350, 200, 35, gameMain.Random, out reason)) { return(false); } _buttons[1] = new BBStretchButton(); if (!_buttons[1].Initialize("Save Game", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 270, _yPos + 300, 200, 35, gameMain.Random, out reason)) { return(false); } _buttons[2] = new BBStretchButton(); if (!_buttons[2].Initialize("Load Game", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 30, _yPos + 300, 200, 35, gameMain.Random, out reason)) { return(false); } _buttons[2].Enabled = false; _buttons[3] = new BBStretchButton(); if (!_buttons[3].Initialize("Exit Game", ButtonTextAlignment.CENTER, StretchableImageType.ThinBorderBG, StretchableImageType.ThinBorderFG, _xPos + 270, _yPos + 350, 200, 35, gameMain.Random, out reason)) { return(false); } _saveGameListBackground = new BBStretchableImage(); if (!_saveGameListBackground.Initialize(_xPos + 20, _yPos + 20, 460, 325, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return(false); } _saveGameButtons = new BBInvisibleStretchButton[8]; for (int i = 0; i < _saveGameButtons.Length; i++) { _saveGameButtons[i] = new BBInvisibleStretchButton(); if (!_saveGameButtons[i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, _xPos + 30, _yPos + 35 + (i * 32), 420, 32, gameMain.Random, out reason)) { return(false); } } _scrollBar = new BBScrollBar(); if (!_scrollBar.Initialize(_xPos + 455, _yPos + 37, 256, _saveGameButtons.Length, _saveGameButtons.Length, false, false, gameMain.Random, out reason)) { return(false); } _maxVisible = 0; _scrollBar.SetEnabledState(false); _selectedGame = -1; _files = new List <FileInfo>(); _promptShowing = false; return(true); }
public bool Initialize(GameMain gameMain, out string reason) { this._gameMain = gameMain; _buttons = new BBButton[4]; _x = (gameMain.ScreenWidth / 2) - 130; _y = (gameMain.ScreenHeight / 2); for (int i = 0; i < _buttons.Length; i++) { _buttons[i] = new BBButton(); } if (!_buttons[0].Initialize("MainButtonBG", "MainButtonFG", "Continue", "LargeComputerFont", ButtonTextAlignment.CENTER, _x, _y, 260, 40, gameMain.Random, out reason, 20, -1)) { return(false); } if (!_buttons[1].Initialize("MainButtonBG", "MainButtonFG", "New Game", "LargeComputerFont", ButtonTextAlignment.CENTER, _x, _y + 50, 260, 40, gameMain.Random, out reason, 20, -1)) { return(false); } if (!_buttons[2].Initialize("MainButtonBG", "MainButtonFG", "Load Game", "LargeComputerFont", ButtonTextAlignment.CENTER, _x, _y + 100, 260, 40, gameMain.Random, out reason, 20, -1)) { return(false); } if (!_buttons[3].Initialize("MainButtonBG", "MainButtonFG", "Exit", "LargeComputerFont", ButtonTextAlignment.CENTER, _x, _y + 150, 260, 40, gameMain.Random, out reason, 20, -1)) { return(false); } for (int i = 0; i < _buttons.Length; i++) { _buttons[i].SetTextColor(System.Drawing.Color.Gold, System.Drawing.Color.Black); } _versionLabel = new BBLabel(); if (!_versionLabel.Initialize(10, _gameMain.ScreenHeight - 30, "Version 0.59", System.Drawing.Color.White, out reason)) { return(false); } _background = SpriteManager.GetSprite("MainBackground", gameMain.Random); _planet = SpriteManager.GetSprite("MainPlanetBackground", gameMain.Random); _title = SpriteManager.GetSprite("Title", gameMain.Random); _x = (gameMain.ScreenWidth / 2) - 512; _y = (gameMain.ScreenHeight / 2) - 300; _files = Utility.GetSaveGames(gameMain.GameDataSet.FullName); if (_files.Count == 0) { _buttons[0].Active = false; //Disabled Continue and Load buttons since there's no games to load _buttons[2].Active = false; } _loadBackground = new BBStretchableImage(); if (!_loadBackground.Initialize((gameMain.ScreenWidth / 2) - 225, (gameMain.ScreenHeight / 2) - 175, 450, 350, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return(false); } _saveGameButtons = new BBInvisibleStretchButton[10]; for (int i = 0; i < _saveGameButtons.Length; i++) { _saveGameButtons[i] = new BBInvisibleStretchButton(); if (!_saveGameButtons[i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, (gameMain.ScreenWidth / 2) - 220, (gameMain.ScreenHeight / 2) - 160 + (i * 32), 420, 32, gameMain.Random, out reason)) { return(false); } } _scrollBar = new BBScrollBar(); if (!_scrollBar.Initialize((gameMain.ScreenWidth / 2) + 200, (gameMain.ScreenHeight / 2) - 160, 320, 10, 10, false, false, gameMain.Random, out reason)) { return(false); } _maxVisible = _files.Count > _saveGameButtons.Length ? _saveGameButtons.Length : _files.Count; if (_maxVisible < _saveGameButtons.Length) { //Disable the scrollbar _scrollBar.SetEnabledState(false); } else { _scrollBar.SetEnabledState(true); _scrollBar.SetAmountOfItems(_files.Count); } RefreshSaves(); _showingLoadMenu = false; reason = null; return(true); }
public bool Initialize(GameMain gameMain, out string reason) { if (!this.Initialize(gameMain.ScreenWidth / 2 - 230, gameMain.ScreenHeight / 2 - 180, 460, 360, StretchableImageType.MediumBorder, gameMain, false, gameMain.Random, out reason)) { return false; } _discoveredTechs = new List<Technology>(); _fieldsNeedingNewTopics = new List<TechField>(); _availableTopics = new Dictionary<TechField, List<Technology>>(); _techDescriptionBackground = new BBStretchableImage(); _availableTechsToResearchBackground = new BBStretchableImage(); _instructionLabel = new BBLabel(); _techDescription = new BBTextBox(); _scrollBar = new BBScrollBar(); _availableTechsToResearchButtons = new BBInvisibleStretchButton[4]; _researchCosts = new BBLabel[4]; if (!_techDescriptionBackground.Initialize(_xPos + 20, _yPos + 20, 420, 170, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return false; } if (!_availableTechsToResearchBackground.Initialize(_xPos + 20, _yPos + 220, 420, 120, StretchableImageType.ThinBorderBG, gameMain.Random, out reason)) { return false; } if (!_instructionLabel.Initialize(_xPos + 20, _yPos + 195, "Please select an item to research", System.Drawing.Color.White, out reason)) { return false; } if (!_techDescription.Initialize(_xPos + 165, _yPos + 33, 265, 150, true, true, "TechDescriptionTextBox", gameMain.Random, out reason)) { return false; } if (!_scrollBar.Initialize(_xPos + 415, _yPos + 230, 100, 4, 4, false, false, gameMain.Random, out reason)) { return false; } for (int i = 0; i < _availableTechsToResearchButtons.Length; i++) { _availableTechsToResearchButtons[i] = new BBInvisibleStretchButton(); _researchCosts[i] = new BBLabel(); if (!_availableTechsToResearchButtons[i].Initialize(string.Empty, ButtonTextAlignment.LEFT, StretchableImageType.TinyButtonBG, StretchableImageType.TinyButtonFG, _xPos + 30, _yPos + 230 + (i * 25), 385, 25, gameMain.Random, out reason)) { return false; } if (!_availableTechsToResearchButtons[i].SetToolTip("ItemToResearch" + i + "ToolTip", string.Empty, gameMain.ScreenWidth, gameMain.ScreenHeight, gameMain.Random, out reason)) { return false; } if (!_researchCosts[i].Initialize(_xPos + 405, _yPos + 232 + (i * 25), string.Empty, System.Drawing.Color.White, out reason)) { return false; } _researchCosts[i].SetAlignment(true); } return true; }