Ejemplo n.º 1
0
        public CityPanel(Main parent, City city, int _width, int _height) : base(_width, _height, "", 27, 11)   // TODO: correct padding for max/min zoom
        {
            _main     = parent;
            _thisCity = city;

            // Add DrawPanel from base control
            Controls.Add(DrawPanel);
            DrawPanel.BackgroundImage = Images.CityWallpaper;
            DrawPanel.Paint          += DrawPanel_Paint;

            this.Paint += CityPanel_Paint;

            // Faces panel
            var _faces = new DoubleBufferedPanel
            {
                Location  = new Point(3, 2),
                Size      = new Size(433, 44),
                BackColor = Color.Transparent
            };

            DrawPanel.Controls.Add(_faces);
            _faces.Paint += Faces_Paint;

            // Resource map panel
            _resourceMap = new DoubleBufferedPanel
            {
                Location  = new Point(3, 61),
                Size      = new Size(196, 145),
                BackColor = Color.Transparent
            };
            DrawPanel.Controls.Add(_resourceMap);
            _resourceMap.Paint += ResourceMap_Paint;

            // City resources panel
            _cityResources = new DoubleBufferedPanel
            {
                Location  = new Point(205, 61),
                Size      = new Size(226, 151),
                BackColor = Color.Transparent
            };
            DrawPanel.Controls.Add(_cityResources);
            _cityResources.Paint += CityResources_Paint;

            // Units from city panel
            _unitsFromCity = new DoubleBufferedPanel
            {
                Location  = new Point(7, 216),
                Size      = new Size(181, 69),
                BackColor = Color.Transparent
            };
            DrawPanel.Controls.Add(_unitsFromCity);
            _unitsFromCity.Paint += UnitsFromCity_Paint;

            // Units in city panel
            _unitsInCity = new DoubleBufferedPanel
            {
                Location  = new Point(193, 212),
                Size      = new Size(242, 206),
                BackColor = Color.Transparent
            };
            DrawPanel.Controls.Add(_unitsInCity);
            _unitsInCity.Paint += UnitsInCity_Paint;

            // Food storage panel
            _foodStorage = new DoubleBufferedPanel
            {
                Location  = new Point(437, 15),
                Size      = new Size(195, 146),
                BackColor = Color.Transparent
            };
            DrawPanel.Controls.Add(_foodStorage);
            _foodStorage.Paint += FoodStorage_Paint;

            // Production panel
            _productionPanel = new DoubleBufferedPanel
            {
                Location  = new Point(437, 165),
                Size      = new Size(195, 191),
                BackColor = Color.Transparent
            };
            DrawPanel.Controls.Add(_productionPanel);
            _productionPanel.Paint += ProductionPanel_Paint;

            // Buy button
            var _buyButton = new Civ2button
            {
                Location = new Point(5, 16),
                Size     = new Size(68, 24),
                Font     = new Font("Arial", 9),
                Text     = "Buy"
            };

            _productionPanel.Controls.Add(_buyButton);
            _buyButton.Click += BuyButton_Click;

            // Change button
            var _changeButton = new Civ2button
            {
                Location = new Point(120, 16),
                Size     = new Size(68, 24),
                Font     = new Font("Arial", 9),
                Text     = "Change"
            };

            _productionPanel.Controls.Add(_changeButton);
            _changeButton.Click += ChangeButton_Click;

            // Improvements list panel
            _improvListPanel = new DoubleBufferedPanel()
            {
                Location  = new Point(6, 306),
                Size      = new Size(166, 108),
                BackColor = Color.Transparent
            };
            DrawPanel.Controls.Add(_improvListPanel);
            _improvListPanel.Paint += ImprovementsList_Paint;

            // Improvements vertical scrollbar
            _improvementsBar = new VScrollBar()
            {
                Location = new Point(174, 291),
                Size     = new Size(17, 128),
                Maximum  = 66 - 9 + 9   // Max improvements=66, 9 can be shown, because of slider size it's 9 elements smaller
            };
            DrawPanel.Controls.Add(_improvementsBar);
            _improvementsBar.ValueChanged += ImprovementsBarValueChanged;

            // Info button
            var _infoButton = new Civ2button
            {
                Location = new Point(461, 364), // norm=(461,364), big=(692,549)
                Size     = new Size(57, 24),    // norm=(57,24), big=(86,36)
                Font     = new Font("Arial", 9),
                Text     = "Info"
            };

            DrawPanel.Controls.Add(_infoButton);
            _infoButton.Click += InfoButton_Click;

            // Map button
            var _mapButton = new Civ2button
            {
                Location = new Point(_infoButton.Location.X + 58, _infoButton.Location.Y),
                Size     = new Size(57, 24), // norm=(57,24), big=(86,36)
                Font     = new Font("Arial", 9),
                Text     = "Map"
            };

            DrawPanel.Controls.Add(_mapButton);
            _mapButton.Click += MapButton_Click;

            // Rename button
            var _renameButton = new Civ2button
            {
                Location = new Point(_infoButton.Location.X + 116, _infoButton.Location.Y),
                Size     = new Size(57, 24), // norm=(57,24), big=(86,36)
                Font     = new Font("Arial", 9),
                Text     = "Rename"
            };

            DrawPanel.Controls.Add(_renameButton);
            _renameButton.Click += RenameButton_Click;

            // Happy button
            var _happyButton = new Civ2button
            {
                Location = new Point(_infoButton.Location.X, _infoButton.Location.Y + 25),
                Size     = new Size(57, 24), // norm=(57,24), big=(86,36)
                Font     = new Font("Arial", 9),
                Text     = "Happy"
            };

            DrawPanel.Controls.Add(_happyButton);
            _happyButton.Click += HappyButton_Click;

            // View button
            var _viewButton = new Civ2button
            {
                Location = new Point(_infoButton.Location.X + 58, _infoButton.Location.Y + 25),
                Size     = new Size(57, 24), // norm=(57,24), big=(86,36)
                Font     = new Font("Arial", 9),
                Text     = "View"
            };

            DrawPanel.Controls.Add(_viewButton);
            _viewButton.Click += ViewButton_Click;

            // Exit button
            var _exitButton = new Civ2button
            {
                Location = new Point(_infoButton.Location.X + 116, _infoButton.Location.Y + 25),
                Size     = new Size(57, 24), // norm=(57,24), big=(86,36)
                Font     = new Font("Arial", 9),
                Text     = "Exit"
            };

            DrawPanel.Controls.Add(_exitButton);
            _exitButton.Click += ExitButton_Click;

            // Next city (UP) button
            var _nextCityButton = new NoSelectButton
            {
                Location  = new Point(440, 364), // norm=(440,364), big=(660,550)
                Size      = new Size(21, 24),    // norm=(21,24), big=(32,36)
                BackColor = Color.FromArgb(107, 107, 107)
            };

            _nextCityButton.FlatStyle = FlatStyle.Flat;
            DrawPanel.Controls.Add(_nextCityButton);
            _nextCityButton.Click += NextCityButton_Click;
            _nextCityButton.Paint += NextCityButton_Paint;

            // Previous city (DOWN) button
            var _prevCityButton = new NoSelectButton
            {
                Location  = new Point(440, 389), // norm=(440,389), big=(660,550)
                Size      = new Size(21, 24),    // norm=(21,24), big=(32,36)
                BackColor = Color.FromArgb(107, 107, 107)
            };

            _prevCityButton.FlatStyle = FlatStyle.Flat;
            DrawPanel.Controls.Add(_prevCityButton);
            _prevCityButton.Click += PrevCityButton_Click;
            _prevCityButton.Paint += PrevCityButton_Paint;
        }
Ejemplo n.º 2
0
        public MapPanel(Main parent, int _width, int _height) : base(_width, _height, "", 38, 10)
        {
            _main = parent;

            Paint += MapPanel_Paint;

            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;

            // Add DrawPanel from base control
            Controls.Add(DrawPanel);
            DrawPanel.BackgroundImage = null;
            DrawPanel.BackColor       = Color.Black;
            DrawPanel.Paint          += DrawPanel_Paint;
            DrawPanel.MouseClick     += DrawPanel_MouseClick;

            // Center the map view and draw map
            AnimType       = AnimationType.UpdateMap;
            activeOffsetXY = new int[] { 0, 0 };    // Just initialize
            MapViewChange(Game.StartingClickedXY);

            if (_main.ViewPieceMode)
            {
                AnimType = AnimationType.ViewPiece;
            }
            else
            {
                AnimType = AnimationType.UnitWaiting;
            }

            // Timer for waiting unit/ viewing piece
            animationTimer       = new System.Windows.Forms.Timer();
            animationTimer.Tick += Animation_Tick;
            StartAnimation(AnimType);
        }