public CheckboxPanel(int width, int height, string title, string[] _checkboxNames, string[] buttonTexts) : base(width, height, 38, 46, title) { checkboxNames = _checkboxNames; // Buttons Button = new Civ2button[buttonTexts.Length]; int btnW = (this.Width - 2 * 9 - 3 * (buttonTexts.Length - 1)) / buttonTexts.Length; // Determine width of one button for (int i = 0; i < buttonTexts.Length; i++) { Button[i] = new Civ2button(buttonTexts[i], btnW, 36, new Font("Times new roman", 11)); MainPanelLayout.Add(Button[i], 9 + btnW * i + 3 * i, Height - 46); } var InnerPanelLayout = new PixelLayout(); InnerPanelLayout.Size = new Size(width, height); // Make checkbox fields for each option CheckboxFields = new List <Panel>(); for (int i = 0; i < checkboxNames.Length; i++) { var panel = new Panel { BackgroundColor = Colors.Transparent }; InnerPanelLayout.Add(panel, 10, 32 * i + 4); panel.MouseDown += CheckboxFields_Click; CheckboxFields.Add(panel); } InnerPanel.Paint += InnerPanel_Paint; InnerPanel.Content = InnerPanelLayout; }
public MinimapPanel(Main parent, int width, int height) : base(width, height, 38, 10, "World") { this.Main = parent; MapPanel.OnMapEvent += MapEventHappened; //Main.OnMapEvent += MapEventHappened; drawPanel = new Drawable() { Size = new Size(MainPanel.Width - 2 * 11, MainPanel.Height - 38 - 10), BackgroundColor = Colors.Black }; drawPanel.Paint += DrawPanel_Paint; drawPanel.MouseEnter += DrawPanel_MouseHover; drawPanel.MouseDown += DrawPanel_MouseClick; MainPanelLayout.Add(drawPanel, 11, 38); MainPanel.Content = MainPanelLayout; //MinimapCursor = new Cursor(new MemoryStream(Properties.Resources.MinimapCursor)); // Determine the offset of minimap from panel edges Offset = new int[] { (drawPanel.Width - 2 * Map.Xdim) / 2, (drawPanel.Height - Map.Ydim) / 2 }; CentrXY = new int[] { 0, 0 }; CentrOffset = new int[] { 0, 0 }; ActiveOffset = new int[] { 0, 0 }; PanelMap_offset = new int[] { 0, 0 }; MapPanel_offset = new int[] { 0, 0 }; }
public RadioButtonPanel(int width, int height, string title, string[] choiceNames, string[] buttonTexts) : base(width, height, 38, 46, title) { // Buttons Button = new Civ2button[buttonTexts.Length]; int btnW = (this.Width - 2 * 9 - 3 * (buttonTexts.Length - 1)) / buttonTexts.Length; // Determine width of one button for (int i = 0; i < buttonTexts.Length; i++) { Button[i] = new Civ2button(buttonTexts[i], btnW, 36, new Font("Times new roman", 11)); MainPanelLayout.Add(Button[i], 9 + btnW * i + 3 * i, Height - 46); } // Radio buttons var layout2 = new PixelLayout(); var controller = new RadioButton(); RadioBtn = new RadioButton[choiceNames.Length]; for (int row = 0; row < choiceNames.Length; row++) { RadioBtn[row] = new RadioButton(controller) { Text = choiceNames[row], Font = new Font("Times new roman", 18), Size = new Size(InnerPanel.Width, 33), TextColor = Color.FromArgb(51, 51, 51) }; layout2.Add(RadioBtn[row], 10, row * 33); } layout2.Size = new Size(InnerPanel.Width, InnerPanel.Height); InnerPanel.Content = layout2; MainPanel.Content = MainPanelLayout; }
public MapPanel(Main parent, int width, int height) : base(width, height, 38, 10) { main = parent; drawPanel = new Drawable() { Size = new Size(MainPanel.Width - 2 * 11, MainPanel.Height - 38 - 10), BackgroundColor = Colors.Black }; drawPanel.Paint += DrawPanel_Paint; MainPanelLayout.Add(drawPanel, 11, 38); MainPanel.Content = MainPanelLayout; MainPanel.Paint += MainPanel_Paint; drawPanel.Paint += DrawPanel_Paint; drawPanel.MouseUp += DrawPanel_MouseClick; Game.OnWaitAtTurnEnd += InitiateWaitAtTurnEnd; Game.OnUnitEvent += UnitEventHappened; Game.OnPlayerEvent += PlayerEventHappened; //MinimapPanel.OnMapEvent += MapEventHappened; StatusPanel.OnMapEvent += MapEventHappened; //Main.OnMapEvent += MapEventHappened; //Main.OnCheckIfCityCanBeViewed += CheckIfCityCanBeViewed; //var ZoomINButton = new NoSelectButton //{ // Location = new Point(11, 9), // Size = new Size(23, 23), // FlatStyle = FlatStyle.Flat, // BackgroundImage = Images.ZoomIN.Resize(4) //}; //ZoomINButton.FlatAppearance.BorderSize = 0; //Controls.Add(ZoomINButton); //ZoomINButton.Click += ZoomINclicked; //var ZoomOUTButton = new NoSelectButton //{ // Location = new Point(36, 9), // Size = new Size(23, 23), // FlatStyle = FlatStyle.Flat, // BackgroundImage = Images.ZoomOUT.Resize(4), //}; //ZoomOUTButton.FlatAppearance.BorderSize = 0; //Controls.Add(ZoomOUTButton); //ZoomOUTButton.Click += ZoomOUTclicked; // Timer for waiting unit/ viewing piece animationTimer = new UITimer(); animationTimer.Elapsed += OnAnimationElapsedEvent; // Center the map view and draw map //activeOffsetXY = new int[] { 0, 0 }; // Just initialize MapViewChange(Map.StartingClickedXY); }
public MinimapPanel(Main parent, int width, int height, Game game) : base(width, height, 38, 10, "World") { _game = game; _main = parent; _drawPanel = new Drawable() { Size = new Size(MainPanel.Width - 2 * 11, MainPanel.Height - 38 - 10), BackgroundColor = Colors.Black, Cursor = new Cursor(MakeCursor(), new Point(7, 7)) }; _drawPanel.Paint += DrawPanel_Paint; _drawPanel.MouseDown += DrawPanel_MouseClick; MainPanelLayout.Add(_drawPanel, 11, 38); MainPanel.Content = MainPanelLayout; // Determine the offset of minimap from panel edges var currentMap = game.CurrentMap; offset = new[] { (_drawPanel.Width - 2 * currentMap.XDim) / 2, (_drawPanel.Height - currentMap.YDim) / 2 }; }
public MinimapPanel(Main parent, int width, int height) : base(width, height, 38, 10, "World") { this.Main = parent; MapPanel.OnMapEvent += MapEventHappened; //Main.OnMapEvent += MapEventHappened; drawPanel = new Drawable() { Size = new Size(MainPanel.Width - 2 * 11, MainPanel.Height - 38 - 10), BackgroundColor = Colors.Black, Cursor = new Cursor(MakeCursor(), new Point(7, 7)) }; drawPanel.Paint += DrawPanel_Paint; drawPanel.MouseDown += DrawPanel_MouseClick; MainPanelLayout.Add(drawPanel, 11, 38); MainPanel.Content = MainPanelLayout; // Determine the offset of minimap from panel edges offset = new int[] { (drawPanel.Width - 2 * Map.XDim) / 2, (drawPanel.Height - Map.YDim) / 2 }; mapDrawSq = mapStartXY = new int[] { 0, 0 }; }
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 = (int)e.Location.X - mapDest.X; int clickedY = (int)e.Location.Y - mapDest.Y; clickedXY = PxToCoords(clickedX, clickedY, Map.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.Buttons == MouseButtons.Primary) // Left button { // City clicked if (Game.GetCities.Any(city => city.X == clickedXY[0] && city.Y == clickedXY[1])) { if (Map.ViewPieceMode) { Map.ActiveXY = clickedXY; } var cityPanel = new CityPanel(main, Game.GetCities.Find(city => city.X == clickedXY[0] && city.Y == clickedXY[1]), 658, 459); // For normal zoom MainPanelLayout.Add(cityPanel, (drawPanel.Width / 2) - (cityPanel.Width / 2), (drawPanel.Height / 2) - (cityPanel.Height / 2)); MainPanel.Content = MainPanelLayout; } // 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.SetActiveUnit(Game.GetUnits[clickedUnitIndex]); Map.ViewPieceMode = false; OnMapEvent?.Invoke(null, new MapEventArgs(MapEventType.SwitchViewMovePiece)); StartAnimation(AnimationType.Waiting); } else { //TODO: determine what happens if unit has ended turn... } MapViewChange(clickedXY); } // Something else clicked else { if (Map.ViewPieceMode) { Map.ActiveXY = clickedXY; } MapViewChange(clickedXY); OnMapEvent?.Invoke(null, new MapEventArgs(MapEventType.MapViewChanged)); } } else // Right click { Map.ViewPieceMode = true; Map.ActiveXY = clickedXY; if (!Map.ViewPieceMode) { OnMapEvent?.Invoke(null, new MapEventArgs(MapEventType.SwitchViewMovePiece)); } else { OnMapEvent?.Invoke(null, new MapEventArgs(MapEventType.MapViewChanged)); } MapViewChange(clickedXY); StartAnimation(AnimationType.Waiting); } }