예제 #1
0
 public void MouseUp(int x, int y, int whichButton)
 {
     if (whichButton != 1)
     {
         return;
     }
     if (_generatingGalaxy)
     {
         return;
     }
     if (_showingSelection)
     {
         _raceSelection.MouseUp(x, y);
         return;
     }
     _playerEmperorName.MouseUp(x, y);
     _playerHomeworldName.MouseUp(x, y);
     _numericUpDownAI.MouseUp(x, y);
     _difficultyComboBox.MouseUp(x, y);
     if (_playerRaceDescription.MouseUp(x, y))
     {
         return;
     }
     if (_galaxyComboBox.MouseUp(x, y))
     {
         if (!_galaxyComboBox.Dropped)
         {
             //Update galaxy here
             _generatingGalaxy = true;
             _busyText.MoveTo((int)((_gameMain.ScreenWidth / 2) - (_busyText.GetWidth() / 2)), (int)((_gameMain.ScreenHeight / 2) - (_busyText.GetHeight() / 2)));
             _gameMain.Galaxy.OnGenerateComplete += OnGalaxyGenerated;
             string reason;
             if (!_gameMain.Galaxy.GenerateGalaxy((GALAXYTYPE)_galaxyComboBox.SelectedIndex, 1, 1, _gameMain.Random, out reason))
             {
                 _generatingGalaxy = false;
             }
         }
     }
     if (_playerRaceButton.MouseUp(x, y))
     {
         _showingSelection = true;
         _raceSelection.SetCurrentPlayerInfo(0, _playerRaces[0], _playerColors[0]);
     }
     for (int i = 0; i < _numericUpDownAI.Value; i++)
     {
         if (_AIRaceButtons[i].MouseUp(x, y))
         {
             _showingSelection = true;
             _raceSelection.SetCurrentPlayerInfo(i + 1, _playerRaces[i + 1], _playerColors[i + 1]);
         }
     }
     if (_cancelButton.MouseUp(x, y))
     {
         _gameMain.ChangeToScreen(Screen.MainMenu);
     }
     if (_okButton.MouseUp(x, y))
     {
         //See if the galaxy is generated.  If not, generate it now, then proceed to player setup
         if (_gameMain.Galaxy.GetAllStars().Count == 0)
         {
             SetUpGalaxy();
         }
         else
         {
             SetUpEmpiresAndStart();
         }
     }
 }
예제 #2
0
 public override bool MouseUp(int x, int y)
 {
     if (!_isOwnedSystem)
     {
         return(base.MouseUp(x, y));
     }
     if (IsTransferring)
     {
         if (_popTransferSlider.MouseUp(x, y))
         {
             _transferLabel.SetText("Moving " + _popTransferSlider.TopIndex + " Population");
             return(true);
         }
         if (_transferToButton.MouseUp(x, y))
         {
             if (TransferSystem != null && TransferSystem.IsValid)
             {
                 if (TransferSystem.StarSystem == _currentSystem)
                 {
                     _currentSystem.Planets[0].TransferSystem = new KeyValuePair <TravelNode, int>(new TravelNode(), 0);
                 }
                 else
                 {
                     _currentSystem.Planets[0].TransferSystem = new KeyValuePair <TravelNode, int>(TransferSystem, _popTransferSlider.TopIndex);
                 }
                 _transferLabel.SetText("Moving " + _currentSystem.Planets[0].TransferSystem.Value + " Pop");
                 _transferLabel.MoveTo(_xPos + 10, _yPos + 440);
                 TransferSystem = null;
                 //Done setting transfer
             }
             IsTransferring = false;
             return(true);
         }
     }
     if (IsRelocating)
     {
         if (_relocateToButton.MouseUp(x, y))
         {
             if (RelocateSystem.IsValid)
             {
                 _currentSystem.Planets[0].RelocateToSystem = RelocateSystem;
                 IsRelocating   = false;
                 RelocateSystem = null;
             }
         }
     }
     if (_name.MouseUp(x, y))
     {
         return(true);
     }
     if (_infrastructureSlider.MouseUp(x, y))
     {
         _currentSystem.Planets[0].SetOutputAmount(OUTPUT_TYPE.INFRASTRUCTURE, _infrastructureSlider.TopIndex, false);
         Refresh();
         return(true);
     }
     if (_researchSlider.MouseUp(x, y))
     {
         _currentSystem.Planets[0].SetOutputAmount(OUTPUT_TYPE.RESEARCH, _researchSlider.TopIndex, false);
         Refresh();
         return(true);
     }
     if (_environmentSlider.MouseUp(x, y))
     {
         _currentSystem.Planets[0].SetOutputAmount(OUTPUT_TYPE.ENVIRONMENT, _environmentSlider.TopIndex, false);
         Refresh();
         return(true);
     }
     if (_defenseSlider.MouseUp(x, y))
     {
         _currentSystem.Planets[0].SetOutputAmount(OUTPUT_TYPE.DEFENSE, _defenseSlider.TopIndex, false);
         Refresh();
         return(true);
     }
     if (_constructionSlider.MouseUp(x, y))
     {
         _currentSystem.Planets[0].SetOutputAmount(OUTPUT_TYPE.CONSTRUCTION, _constructionSlider.TopIndex, false);
         Refresh();
         return(true);
     }
     if (_infrastructureLockButton.MouseUp(x, y))
     {
         _currentSystem.Planets[0].InfrastructureLocked = !_currentSystem.Planets[0].InfrastructureLocked;
         _infrastructureSlider.SetEnabledState(!_currentSystem.Planets[0].InfrastructureLocked);
         _infrastructureLockButton.Selected = _currentSystem.Planets[0].InfrastructureLocked;
         return(true);
     }
     if (_researchLockButton.MouseUp(x, y))
     {
         _currentSystem.Planets[0].ResearchLocked = !_currentSystem.Planets[0].ResearchLocked;
         _researchSlider.SetEnabledState(!_currentSystem.Planets[0].ResearchLocked);
         _researchLockButton.Selected = _currentSystem.Planets[0].ResearchLocked;
         return(true);
     }
     if (_environmentLockButton.MouseUp(x, y))
     {
         _currentSystem.Planets[0].EnvironmentLocked = !_currentSystem.Planets[0].EnvironmentLocked;
         _environmentSlider.SetEnabledState(!_currentSystem.Planets[0].EnvironmentLocked);
         _environmentLockButton.Selected = _currentSystem.Planets[0].EnvironmentLocked;
         return(true);
     }
     if (_defenseLockButton.MouseUp(x, y))
     {
         _currentSystem.Planets[0].DefenseLocked = !_currentSystem.Planets[0].DefenseLocked;
         _defenseSlider.SetEnabledState(!_currentSystem.Planets[0].DefenseLocked);
         _defenseLockButton.Selected = _currentSystem.Planets[0].DefenseLocked;
         return(true);
     }
     if (_constructionLockButton.MouseUp(x, y))
     {
         _currentSystem.Planets[0].ConstructionLocked = !_currentSystem.Planets[0].ConstructionLocked;
         _constructionSlider.SetEnabledState(!_currentSystem.Planets[0].ConstructionLocked);
         _constructionLockButton.Selected = _currentSystem.Planets[0].ConstructionLocked;
         return(true);
     }
     if (_relocateToButton.MouseUp(x, y))
     {
         IsRelocating = true;
         _generalPurposeText.SetText("Select a friendly system to send newly built ships");
         _relocateToButton.Active = false;
         return(true);
     }
     if (_transferToButton.MouseUp(x, y))
     {
         IsTransferring = true;
         _transferLabel.MoveTo(_xPos + 20, _yPos + 370);
         _transferLabel.SetText("Moving 0 Population");
         _popTransferSlider.SetAmountOfItems((int)(_currentSystem.Planets[0].TotalPopulation / 2));
         _generalPurposeText.SetText("Select a colonized planet to send population");
         return(true);
     }
     if (_constructionProjectButton.MouseUp(x, y))
     {
         _currentSystem.Planets[0].ShipBeingBuilt = _currentEmpire.FleetManager.GetNextShipDesign(_currentSystem.Planets[0].ShipBeingBuilt);
         Refresh();
     }
     return(base.MouseUp(x, y));
 }
예제 #3
0
        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);
        }
예제 #4
0
 public override bool MouseUp(int x, int y)
 {
     if (!_colonizing)
     {
         for (int i = 0; i < _maxShips; i++)
         {
             if (_shipButtons[i].MouseUp(x, y))
             {
                 foreach (var button in _shipButtons)
                 {
                     button.Selected = false;
                 }
                 _shipButtons[i].Selected = true;
             }
         }
         if (_cancelButton.MouseUp(x, y))
         {
             if (Completed != null)
             {
                 Completed();
             }
         }
         if (_colonizeButton.MouseDown(x, y))
         {
             int whichShip = 0;
             for (int i = 0; i < _maxShips; i++)
             {
                 if (_shipButtons[i].Selected)
                 {
                     whichShip = i;
                     break;
                 }
             }
             var ship = _colonyShips[whichShip];
             _colonizingFleet.ColonizePlanet(ship);
             _nameTextBox.SetText(_starSystem.Name);
             //Select the textbox so it'd capture the keypresses
             _nameTextBox.MouseDown(_gameMain.ScreenWidth / 2, _gameMain.ScreenHeight / 2);
             _nameTextBox.MouseUp(_gameMain.ScreenWidth / 2, _gameMain.ScreenHeight / 2);
             _landingShipPos = _gameMain.ScreenHeight / 2 - 300;
             _groundView     = _starSystem.Planets[0].GroundSprite;
             _landingShip    = _colonizingFleet.Empire.EmpireRace.LandingShip;
             _showingText    = false;
             _colonizing     = true;
         }
     }
     else
     {
         if (!_showingText)
         {
             _showingText    = true;
             _landingShipPos = _gameMain.ScreenHeight / 2 + 50;
         }
         else
         {
             if (!_nameTextBox.MouseUp(x, y) && !string.IsNullOrEmpty(_nameTextBox.Text))
             {
                 _starSystem.Name = _nameTextBox.Text;
                 _colonizing      = false;
                 _showingText     = false;
                 //Done
                 if (Completed != null)
                 {
                     Completed();
                 }
             }
         }
     }
     return(false);
 }