public CityRenamePanel(CityPanel parent, City city) : base(686, 126, "What Shall We Rename This City?", 38, 46) { _parent = parent; _city = city; // Add DrawPanel from base control Controls.Add(DrawPanel); DrawPanel.Paint += DrawPanel_Paint; //Textbox for renaming city _renameTextBox = new TextBox { Location = new Point(163, 2), Size = new Size(225, 30), Text = _city.Name, Font = new Font("Times New Roman", 11) }; DrawPanel.Controls.Add(_renameTextBox); // OK button var _OKButton = new Civ2button { Location = new Point(9, 84), Size = new Size(333, 36), Text = "OK" }; Controls.Add(_OKButton); _OKButton.Click += OKButton_Click; // Cancel button var _cancelButton = new Civ2button { Location = new Point(344, 84), Size = new Size(333, 36), Text = "Cancel" }; Controls.Add(_cancelButton); _cancelButton.Click += CancelButton_Click; }
public CityBuyPanel(CityPanel parent, City city) : base(814, 212, "", 38, 46) { _parent = parent; _city = city; this.Paint += CityBuyPanel_Paint; // Add DrawPanel from base control Controls.Add(DrawPanel); DrawPanel.Paint += DrawPanel_Paint; // OK button var _OKButton = new Civ2button { Location = new Point(9, 170), Size = new Size(796, 36), Text = "OK" }; Controls.Add(_OKButton); _OKButton.Click += OKButton_Click; // Radio button 1 _completeitButton = new Civ2radioBtn { Text = "Complete it.", Location = new Point(140, 69), }; DrawPanel.Controls.Add(_completeitButton); // Radio button 2 _nevermindButton = new Civ2radioBtn { Text = "Never mind.", Location = new Point(140, 98), }; DrawPanel.Controls.Add(_nevermindButton); _nevermindButton.Checked = true; }
public CityChangePanel(CityPanel parent, City city) : base(686, 389, $"What shall we build in {city.Name}?", 38, 46) { _parent = parent; _city = city; // Initial states _totalNoUnits = 62; // TO-DO: Calculate total number of units+improvements for CityChangePanel _totalNoImprov = 66; // BarValue should always be so that the chosen item is in the center. But the BarValue should be corrected once you are at the edges. _barValue = Math.Max(0, _city.ItemInProduction - 8); // Correction for the lower value _barValue = Math.Min(_totalNoUnits + _totalNoImprov - 16, _barValue); // Correction for the upper value // Add DrawPanel from base control Controls.Add(DrawPanel); DrawPanel.Paint += DrawPanel_Paint; // Choice panel _choicePanel = new DoubleBufferedPanel { Location = new Point(2, 2), Size = new Size(DrawPanel.Width - 4, DrawPanel.Height - 4), BackColor = Color.FromArgb(207, 207, 207), BorderStyle = BorderStyle.None }; DrawPanel.Controls.Add(_choicePanel); _choicePanel.Paint += ChoicePanel_Paint; _choicePanel.MouseDown += ChoicePanel_MouseDown; // Vertical bar for choosing production _verticalBar = new VScrollBar() { Location = new Point(643, 0), Size = new Size(18, 301), Maximum = _totalNoUnits + _totalNoImprov - 7 // 16 can be shown }; _choicePanel.Controls.Add(_verticalBar); _verticalBar.ValueChanged += VerticalBarValueChanged; // Auto button var _autoButton = new Civ2button { Location = new Point(9, 347), Size = new Size(165, 36), Text = "Auto" }; Controls.Add(_autoButton); _autoButton.Click += AutoButton_Click; // Help button var _helpButton = new Civ2button { Location = new Point(177, 347), Size = new Size(165, 36), Text = "Help" }; Controls.Add(_helpButton); _helpButton.Click += HelpButton_Click; // Cheat! button var _cheatButton = new Civ2button { Location = new Point(344, 347), Size = new Size(165, 36), Text = "Cheat!" }; Controls.Add(_cheatButton); _cheatButton.Click += CheatButton_Click; // OK button var _OKButton = new Civ2button { Location = new Point(512, 347), Size = new Size(165, 36), Text = "OK" }; Controls.Add(_OKButton); _OKButton.Click += OKButton_Click; }
private void DrawPanel_MouseClick(object sender, MouseEventArgs e) { // If clicked location is beyond map limits --> exit method if (e.Location.X < mapDest.X || e.Location.X > mapDest.X + mapSrc1.Width || e.Location.Y < mapDest.Y || e.Location.Y > mapDest.Y + mapSrc1.Height) { return; } // Else you clicked within the map int clickedX = e.Location.X - mapDest.X; int clickedY = e.Location.Y - mapDest.Y; clickedXY = PxToCoords(clickedX, clickedY, Game.Zoom); clickedXY[0] += mapStartXY[0]; clickedXY[1] += mapStartXY[1]; Debug.WriteLine($"clickedXY={clickedXY[0]},{clickedXY[1]}"); // TODO: Make sure that edge black tiles are also ignored! //clickedXY = new int[] { (MapPanel_offset[0] + coords[0]) % (2 * Map.Xdim), MapPanel_offset[1] + coords[1] }; // Coordinates of clicked square if (e.Button == MouseButtons.Left) { // City clicked if (Game.GetCities.Any(city => city.X == clickedXY[0] && city.Y == clickedXY[1])) { if (_main.ViewPieceMode) { Game.ActiveXY = clickedXY; } var cityPanel = new CityPanel(_main, Game.GetCities.Find(city => city.X == clickedXY[0] && city.Y == clickedXY[1]), 658, 459); // For normal zoom _main.Controls.Add(cityPanel); cityPanel.Location = new Point((ClientSize.Width / 2) - (cityPanel.Size.Width / 2), (ClientSize.Height / 2) - (cityPanel.Size.Height / 2)); cityPanel.Show(); cityPanel.BringToFront(); } // Unit clicked else if (Game.GetUnits.Any(unit => unit.X == clickedXY[0] && unit.Y == clickedXY[1])) { int clickedUnitIndex = Game.GetUnits.FindIndex(a => a.X == clickedXY[0] && a.Y == clickedXY[1]); if (!Game.GetUnits[clickedUnitIndex].TurnEnded) { Game.ActiveUnit = Game.GetUnits[clickedUnitIndex]; _main.ViewPieceMode = false; OnMapEvent?.Invoke(null, new MapEventArgs(MapEventType.SwitchViewMovePiece)); StartAnimation(AnimationType.UnitWaiting); } else { //TODO: determine what happens if unit has ended turn... } MapViewChange(clickedXY); } else // Something else clicked { if (_main.ViewPieceMode) { Game.ActiveXY = clickedXY; } MapViewChange(clickedXY); } } else // Right click { _main.ViewPieceMode = true; OnMapEvent?.Invoke(null, new MapEventArgs(MapEventType.SwitchViewMovePiece)); Game.ActiveXY = clickedXY; MapViewChange(clickedXY); StartAnimation(AnimationType.ViewPiece); } }