public override bool MouseUp(int x, int y) { bool result = false; if (_previousFleet.MouseUp(x, y)) { int index = _selectedFleetGroup.Fleets.IndexOf(_selectedFleet); index--; if (index < 0) { index = _selectedFleetGroup.Fleets.Count - 1; } _selectedFleetGroup.SelectFleet(index); _selectedFleet = _selectedFleetGroup.SelectedFleet; LoadShips(); result = true; } if (_nextFleet.MouseUp(x, y)) { int index = _selectedFleetGroup.Fleets.IndexOf(_selectedFleet); index++; if (index >= _selectedFleetGroup.Fleets.Count) { index = 0; } _selectedFleetGroup.SelectFleet(index); _selectedFleet = _selectedFleetGroup.SelectedFleet; LoadShips(); result = true; } if (!_isTransports) { for (int i = 0; i < _maxVisible; i++) { if (_shipSliders[i].MouseUp(x, y)) { Ship ship = _selectedFleet.OrderedShips[i]; _selectedFleetGroup.FleetToSplit.Ships[ship] = _shipSliders[i].TopIndex; _shipLabels[i].SetText(_shipSliders[i].TopIndex + " x " + ship.Name); result = true; } } } return(base.MouseUp(x, y) || result); }
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)); }
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); }