Exemple #1
0
        private void StatsPanel_Paint(object sender, PaintEventArgs e)
        {
            // Paint wallpaper
            var imgSize = MapImages.PanelInnerWallpaper.Size;

            for (int row = 0; row < this.Height / imgSize.Height + 1; row++)
            {
                for (int col = 0; col < this.Width / imgSize.Width + 1; col++)
                {
                    e.Graphics.DrawImage(MapImages.PanelInnerWallpaper, col * imgSize.Width, row * imgSize.Height);
                }
            }

            using var _font = new Font("Times New Roman", 12, FontStyle.Bold);
            Draw.Text(e.Graphics,
                      Game.GetPlayerCiv.Population.ToString("###,###",
                                                            new NumberFormatInfo()
            {
                NumberDecimalSeparator = ","
            }) + " People", _font,
                      Color.FromArgb(51, 51, 51), new Point(5, 2), false, false, Color.FromArgb(191, 191, 191), 1, 1);
            Draw.Text(e.Graphics, Game.GetGameYearString, _font, Color.FromArgb(51, 51, 51), new Point(5, 20), false,
                      false, Color.FromArgb(191, 191, 191), 1, 1);
            Draw.Text(e.Graphics, $"{Game.GetPlayerCiv.Money} Gold 5.0.5", _font, Color.FromArgb(51, 51, 51),
                      new Point(5, 38), false, false, Color.FromArgb(191, 191, 191), 1, 1);
        }
Exemple #2
0
        private void ImprovementsList_Paint(object sender, PaintEventArgs e)
        {
            // Draw city improvements
            int x = 2;
            int y = 1;
            //int starting = _improvementsBar.Value;   // Starting improvement to draw (changes with slider)
            int starting = 0;   // Starting improvement to draw (changes with slider)
            int zoom;

            using var font = new Font("Arial", 9, FontStyle.Bold);
            for (int i = 0; i < 9; i++)
            {
                if ((i + starting) >= _thisCity.Improvements.Length)
                {
                    break;                                                   // Break if no of improvements+wonders
                }
                // Draw improvements
                zoom = -4;  // For normal
                using var improvPic = Images.Improvements[(int)_thisCity.Improvements[i + starting].Type].Resize(zoom);
                e.Graphics.DrawImage(improvPic, new Point(2, 1 + 12 * i));
                // Sell icons
                zoom = -1;                                               // For normal
                if ((int)_thisCity.Improvements[i + starting].Type < 39) // Wonders don't have a sell icon
                {
                    using var iconPic = Images.SellIcon.Resize(zoom);
                    e.Graphics.DrawImage(iconPic, new Point(148, 1 + 12 * i));
                }
                // Improvements text
                Draw.Text(e.Graphics, _thisCity.Improvements[i + starting].Name, font, Colors.White, new Point(x + 26, 2 + 12 * i), false, false, Colors.Black, 1, 0);
            }
        }
Exemple #3
0
        private void ProductionPanel_Paint(object sender, PaintEventArgs e)
        {
            // Show item currently in production (ProductionItem=0...61 are units, 62...127 are improvements)
            // zoom: Units=-1(norm), Improvements=0(norm)
            using var font = new Font("Arial", 9, FontStyle.Bold);
            // Units
            int zoom;

            if (_thisCity.ItemInProduction < 62)
            {
                zoom = -1;
                Draw.UnitSprite(e.Graphics, (UnitType)_thisCity.ItemInProduction, false, false, zoom, new Point(64, 0));
            }
            // Improvements
            else
            {
                Draw.Text(e.Graphics, Game.Rules.ImprovementName[_thisCity.ItemInProduction - 62 + 1], font, Color.FromArgb(63, 79, 167), new Point(98, 5), true, true, Colors.Black, 1, 1);
                zoom = 0;
                using var improvPic = Images.Improvements[_thisCity.ItemInProduction - 62 + 1].Resize(zoom);
                e.Graphics.DrawImage(improvPic, new Point(79, 18));
            }

            using var cityProdPic = Draw.CityProduction(_thisCity);
            e.Graphics.DrawImage(cityProdPic, new Point(0, 0));  // Draw production shields and sqare around them
        }
Exemple #4
0
        private void MainPanel_Paint(object sender, PaintEventArgs e)
        {
            // Paint wallpaper
            var imgSize = MapImages.PanelOuterWallpaper.Size;

            for (int row = 0; row < this.Height / imgSize.Height + 1; row++)
            {
                for (int col = 0; col < this.Width / imgSize.Width + 1; col++)
                {
                    e.Graphics.DrawImage(MapImages.PanelOuterWallpaper, col * imgSize.Width, row * imgSize.Height);
                }
            }

            // Paint panel borders
            // Outer border
            using var _pen1 = new Pen(Color.FromArgb(227, 227, 227));
            using var _pen2 = new Pen(Color.FromArgb(105, 105, 105));
            using var _pen3 = new Pen(Color.FromArgb(255, 255, 255));
            using var _pen4 = new Pen(Color.FromArgb(160, 160, 160));
            using var _pen5 = new Pen(Color.FromArgb(240, 240, 240));
            using var _pen6 = new Pen(Color.FromArgb(223, 223, 223));
            using var _pen7 = new Pen(Color.FromArgb(67, 67, 67));
            e.Graphics.DrawLine(_pen1, 0, 0, this.Width - 2, 0);   // 1st layer of border
            e.Graphics.DrawLine(_pen1, 0, 0, 0, this.Height - 2);
            e.Graphics.DrawLine(_pen2, this.Width - 1, 0, this.Width - 1, this.Height - 1);
            e.Graphics.DrawLine(_pen2, 0, this.Height - 1, this.Width - 1, this.Height - 1);
            e.Graphics.DrawLine(_pen3, 1, 1, this.Width - 3, 1);   // 2nd layer of border
            e.Graphics.DrawLine(_pen3, 1, 1, 1, this.Height - 3);
            e.Graphics.DrawLine(_pen4, this.Width - 2, 1, this.Width - 2, this.Height - 2);
            e.Graphics.DrawLine(_pen4, 1, this.Height - 2, this.Width - 2, this.Height - 2);
            e.Graphics.DrawLine(_pen5, 2, 2, this.Width - 4, 2);   // 3rd layer of border
            e.Graphics.DrawLine(_pen5, 2, 2, 2, this.Height - 4);
            e.Graphics.DrawLine(_pen5, this.Width - 3, 2, this.Width - 3, this.Height - 3);
            e.Graphics.DrawLine(_pen5, 2, this.Height - 3, this.Width - 3, this.Height - 3);
            e.Graphics.DrawLine(_pen6, 3, 3, this.Width - 5, 3);   // 4th layer of border
            e.Graphics.DrawLine(_pen6, 3, 3, 3, this.Height - 5);
            e.Graphics.DrawLine(_pen7, this.Width - 4, 3, this.Width - 4, this.Height - 4);
            e.Graphics.DrawLine(_pen7, 3, this.Height - 4, this.Width - 4, this.Height - 4);
            e.Graphics.DrawLine(_pen6, 4, 4, this.Width - 6, 4);   // 5th layer of border
            e.Graphics.DrawLine(_pen6, 4, 4, 4, this.Height - 6);
            e.Graphics.DrawLine(_pen7, this.Width - 5, 4, this.Width - 5, this.Height - 5);
            e.Graphics.DrawLine(_pen7, 4, this.Height - 5, this.Width - 5, this.Height - 5);

            // Inner panel
            e.Graphics.DrawLine(_pen7, 9, _paddingTop - 1, 9 + (Width - 18 - 1), _paddingTop - 1);   // 1st layer of border
            e.Graphics.DrawLine(_pen7, 10, _paddingTop - 1, 10, Height - _paddingBtm - 1);
            e.Graphics.DrawLine(_pen6, Width - 11, _paddingTop - 1, Width - 11, Height - _paddingBtm - 1);
            e.Graphics.DrawLine(_pen6, 9, Height - _paddingBtm, Width - 9 - 1, Height - _paddingBtm);
            e.Graphics.DrawLine(_pen7, 10, _paddingTop - 2, 9 + (Width - 18 - 2), _paddingTop - 2);   // 2nd layer of border
            e.Graphics.DrawLine(_pen7, 9, _paddingTop - 2, 9, Height - _paddingBtm);
            e.Graphics.DrawLine(_pen6, Width - 10, _paddingTop - 2, Width - 10, Height - _paddingBtm);
            e.Graphics.DrawLine(_pen6, 9, Height - _paddingBtm + 1, Width - 9 - 1, Height - _paddingBtm + 1);

            // Paint title (if it exists)
            if (_title != null)
            {
                Draw.Text(e.Graphics, _title, new Font("Times new roman", 17, FontStyle.Bold), Color.FromArgb(135, 135, 135), new Point(this.Width / 2, _paddingTop / 2), true, true, Colors.Black, 1, 1);
            }
        }
Exemple #5
0
        private void MainPanel_Paint(object sender, PaintEventArgs e)
        {
            string bcad = (Game.GetGameYear < 0) ? "B.C." : "A.D.";
            string text = String.Format($"City of {_thisCity.Name}, {Math.Abs(Game.GetGameYear)} {bcad}, Population {_thisCity.Population:n0} (Treasury: {_thisCity.Owner.Money} Gold)");

            using var font = new Font("Times New Roman", 14);
            Draw.Text(e.Graphics, text, font, Color.FromArgb(135, 135, 135), new Point(Width / 2, 15), true, true, Colors.Black, 1, 0);
        }
Exemple #6
0
        private void Surface_Paint(object sender, PaintEventArgs e)
        {
            Color warningColor       = maxWarn ? Color.FromArgb(243, 0, 0) : Color.FromArgb(223, 223, 223);
            Color warningColorShadow = maxWarn ? Colors.Black : Color.FromArgb(67, 67, 67);

            e.Graphics.DrawImage(Images.ExtractBitmap(DLLs.Tiles, "taxRateWallpaper").CropImage(new Rectangle(0, 0, 600, 385)),
                                 new Rectangle(11, 38, 600, 385));

            var font1 = new Font("Times New Roman", 18);

            Draw.Text(e.Graphics, $"Government: {Game.GetActiveCiv.Government}", font1, warningColor,
                      new Point(17, 47), false, false, warningColorShadow, 1, 1);
            Draw.Text(e.Graphics, $"Maximum Rate: {maxRate}%", font1, warningColor,
                      new Point(327, 47), false, false, warningColorShadow, 1, 1);

            int totalIncome = Game.GetActiveCiv.Cities.Sum(c => c.Tax);

            Draw.Text(e.Graphics, $"Total Income: {totalIncome}", font1, Color.FromArgb(223, 223, 223),
                      new Point(91, 101), false, false, Color.FromArgb(67, 67, 67), 1, 1);

            int totalCost = Game.GetActiveCiv.Cities.Sum(c => c.Improvements.Sum(i => i.Upkeep));

            Draw.Text(e.Graphics, $"Total Cost: {totalCost}", font1, Color.FromArgb(223, 223, 223),
                      new Point(295, 101), false, false, Color.FromArgb(67, 67, 67), 1, 1);

            int discoveries = 0;    // TODO: determine discoveries

            Draw.Text(e.Graphics, $"Discoveries: {discoveries}", font1, Color.FromArgb(223, 223, 223),
                      new Point(278, 128), true, false, Color.FromArgb(67, 67, 67), 1, 1);

            Draw.Text(e.Graphics, "0%", font1, Color.FromArgb(223, 223, 223),
                      new Point(22, 182), false, false, Color.FromArgb(67, 67, 67), 1, 1);
            Draw.Text(e.Graphics, "0%", font1, Color.FromArgb(223, 223, 223),
                      new Point(22, 243), false, false, Color.FromArgb(67, 67, 67), 1, 1);
            Draw.Text(e.Graphics, "0%", font1, Color.FromArgb(223, 223, 223),
                      new Point(22, 304), false, false, Color.FromArgb(67, 67, 67), 1, 1);

            Draw.Text(e.Graphics, $"Taxes: {taxRate}%", font1,
                      Color.FromArgb(223, 223, 223), new Point(278, 182), true, false, Color.FromArgb(67, 67, 67), 1, 1);
            Draw.Text(e.Graphics, $"Science: {sciRate}%", font1,
                      Color.FromArgb(223, 223, 223), new Point(278, 243), true, false, Color.FromArgb(67, 67, 67), 1, 1);
            Draw.Text(e.Graphics, $"Luxuries: {luxRate}%", font1,
                      Color.FromArgb(223, 223, 223), new Point(278, 304), true, false, Color.FromArgb(67, 67, 67), 1, 1);

            Draw.Text(e.Graphics, "100%", font1, Color.FromArgb(223, 223, 223),
                      new Point(472, 182), false, false, Color.FromArgb(67, 67, 67), 1, 1);
            Draw.Text(e.Graphics, "100%", font1, Color.FromArgb(223, 223, 223),
                      new Point(472, 243), false, false, Color.FromArgb(67, 67, 67), 1, 1);
            Draw.Text(e.Graphics, "100%", font1, Color.FromArgb(223, 223, 223),
                      new Point(472, 304), false, false, Color.FromArgb(67, 67, 67), 1, 1);

            Draw.Text(e.Graphics, "Lock", font1, Color.FromArgb(223, 223, 223),
                      new Point(573, 182), true, false, Color.FromArgb(67, 67, 67), 1, 1);
            Draw.Checkbox(e.Graphics, taxCheckbox.Checked == true, new Point(563, 209));
            Draw.Checkbox(e.Graphics, sciCheckbox.Checked == true, new Point(563, 270));
            Draw.Checkbox(e.Graphics, luxCheckbox.Checked == true, new Point(563, 331));
        }
Exemple #7
0
 private void InnerPanel_Paint(object sender, PaintEventArgs e)
 {
     // Background wallpaper
     e.Graphics.DrawImage(Images.CityWallpaper, 0, 0);
     // Texts
     using var font = new Font("Arial", 9, FontStyle.Bold);
     Draw.Text(e.Graphics, "Citizens", font, Color.FromArgb(223, 187, 63), new Point(101, 53), true, true, Color.FromArgb(67, 67, 67), 1, 1);
     Draw.Text(e.Graphics, "City Resources", font, Color.FromArgb(223, 187, 63), new Point(317, 52), true, true, Color.FromArgb(67, 67, 67), 1, 1);
     Draw.Text(e.Graphics, "Food Storage", font, Color.FromArgb(75, 155, 35), new Point(535, 7), true, true, Colors.Black, 1, 1);
     Draw.Text(e.Graphics, "City Improvements", font, Color.FromArgb(223, 187, 63), new Point(96, 296), true, true, Color.FromArgb(67, 67, 67), 1, 1);
 }
Exemple #8
0
        private void UnitPanel_Paint(object sender, PaintEventArgs e)
        {
            // Paint wallpaper
            var imgSize = MapImages.PanelInnerWallpaper.Size;

            for (int row = 0; row < this.Height / imgSize.Height + 1; row++)
            {
                for (int col = 0; col < this.Width / imgSize.Width + 1; col++)
                {
                    e.Graphics.DrawImage(MapImages.PanelInnerWallpaper, col * imgSize.Width, row * imgSize.Height);
                }
            }

            // AI turn civ indicator
            if (Game.GetActiveCiv != Game.GetPlayerCiv)
            {
                e.Graphics.FillRectangle(MapImages.PlayerColours[Game.GetActiveCiv.Id].LightColour,
                                         new Rectangle(unitPanel.Width - 8, unitPanel.Height - 6, 8, 6));
            }

            // Don't update the panel if it's enemy turn
            if (Game.GetActiveCiv != Game.GetPlayerCiv)
            {
                return;
            }

            using var font = new Font("Times new roman", 12, FontStyle.Bold);

            var panelStyle = new PanelStyle(font);

            main.CurrentGameMode.DrawStatusPanel(e.Graphics, panelStyle, unitPanel.Height);


            // Blinking "end of turn" message
            if (WaitingAtEndOfTurn)
            {
                using var _font2 = new Font("Times New Roman", 12, FontStyle.Bold);
                Color _EoTcolor = eotWhite ? Colors.White : Color.FromArgb(135, 135, 135);
                Draw.Text(e.Graphics, "End of Turn", _font2, _EoTcolor, new Point(5, unitPanel.Height - 51), false,
                          false, Colors.Black, 1, 0);
                Draw.Text(e.Graphics, "(Press ENTER)", _font2, _EoTcolor, new Point(10, unitPanel.Height - 33), false,
                          false, Colors.Black, 1, 0);
                eotWhite = !eotWhite;
            }
        }
Exemple #9
0
        private void UnitsInCity_Paint(object sender, PaintEventArgs e)
        {
            int count = 0;
            int row;
            int col;
            int zoom = -2;  // zoom=-2(norm), 1(big)

            using var font = new Font("Arial", 9, FontStyle.Bold);
            foreach (IUnit unit in _thisCity.UnitsInCity)
            {
                col = count % 5;
                row = count / 5;
                Draw.Unit(e.Graphics, unit, false, zoom, new Point(8 * (8 + zoom) * col, 6 * (8 + zoom) * row + 5 * row));
                Draw.Text(e.Graphics, unit.HomeCity.Name.Substring(0, 3), font, Colors.Black, new Point(8 * (8 + zoom) * col + 8 * (8 + zoom) / 2, 6 * (8 + zoom) * row + 5 * row + 6 * (8 + zoom)), true, true, Color.FromArgb(135, 135, 135), 1, 1);  // TODO: doesn't work for <3 characters in city name
                count++;
            }

            // Trade text
            Draw.Text(e.Graphics, $"Supplies: {_thisCity.CommoditySupplied[0]}, {_thisCity.CommoditySupplied[2]}, {_thisCity.CommoditySupplied[2]}", font, Color.FromArgb(227, 83, 15), new Point(6, 135), false, false, Color.FromArgb(67, 67, 67), 1, 1);
            Draw.Text(e.Graphics, $"Demands: {_thisCity.CommodityDemanded[0]}, {_thisCity.CommodityDemanded[2]}, {_thisCity.CommodityDemanded[2]}", font, Color.FromArgb(227, 83, 15), new Point(6, 148), false, false, Color.FromArgb(67, 67, 67), 1, 1);
            Draw.Text(e.Graphics, $"{Game.GetCities[_thisCity.TradeRoutePartnerCity[0]].Name} {_thisCity.CommodityInRoute[0]}: +1", font, Color.FromArgb(227, 83, 15), new Point(6, 163), false, false, Color.FromArgb(67, 67, 67), 1, 1);
        }
Exemple #10
0
        // Draw icons in city resources (surplus < 0 is hunger)
        public static void CityResources(Graphics g, City city, int cityZoom, Point dest)
        {
            var fontSize = cityZoom == -1 ? 4 : (cityZoom == 0 ? 9 : 13);

            using var _font = new Font("Arial", fontSize, FontStyle.Bold);

            // Get normal zoom from city zoom (-1/0/1)
            int zoom = cityZoom * 4;

            // FOOD
            // Text
            var _txtFrame = new Rectangle(dest.X + 203.ZoomScale(4 * cityZoom), dest.Y + 61.ZoomScale(4 * cityZoom), 228.ZoomScale(4 * cityZoom), 12.ZoomScale(4 * cityZoom));

            Draw.Text(g, $"Food: {city.Food}", _font, Color.FromArgb(87, 171, 39), _txtFrame, FormattedTextAlignment.Left, Colors.Black, 1, 1);
            Draw.Text(g, $"Surplus: {city.SurplusHunger}", _font, Color.FromArgb(63, 139, 31), _txtFrame, FormattedTextAlignment.Right, Colors.Black, 1, 1);
            // Number of food+surplus/hunger icons determines spacing between icons
            int spacing;

            switch (city.Food + Math.Abs(city.SurplusHunger))
            {
            case int n when(n >= 1 && n <= 15): spacing = 15; break;         // norm=15, big=23, gap=1px

            case int n when(n == 16 || n == 17): spacing = 13; break;        // norm=13, big=20, overlap=1px

            case int n when(n == 18 || n == 19): spacing = 11; break;        // norm=11, big=17, overlap=3px

            case int n when(n == 20 || n == 21): spacing = 10; break;        // norm=10, big=15, overlap=4px

            case int n when(n == 22 || n == 23): spacing = 9; break;         // norm=9, big=14, overlap=5px

            case int n when(n == 24 || n == 25): spacing = 8; break;         // norm=8, big=12, overlap=6px

            case int n when(n >= 26 && n <= 29): spacing = 7; break;         // norm=7, big=11, overlap=7px

            case int n when(n >= 30 && n <= 33): spacing = 6; break;         // norm=6, big=9, overlap=8px

            case int n when(n >= 34 && n <= 37): spacing = 5; break;         // norm=5, big=8, overlap=9px

            case int n when(n >= 38 && n <= 49): spacing = 4; break;         // norm=4, big=6, overlap=10px

            case int n when(n >= 50 && n <= 65): spacing = 3; break;         // norm=3, big=5, overlap=11px

            case int n when(n >= 66): spacing = 2; break;                    // norm=2, big=3, overlap=12px

            default: spacing = 2; break;
            }
            spacing = (int)(spacing * (1 + ((float)zoom / 8.0)));   // Make spacing city zoom dependent
            // TODO: Draw background rectangle
            //g.FillRectangle(new SolidBrush(Color.FromArgb(71, 147, 31)), 0, 0, spacing * city.Food + 21 - spacing + 6, 23); // Background square for food
            //g.FillRectangle(new SolidBrush(Color.FromArgb(55, 123, 23)), x_size - (spacing * Math.Abs(city.SurplusHunger) + 21 - spacing + 3),
            //    0, spacing * Math.Abs(city.SurplusHunger) + 21 - spacing + 6, 23); // Background square for surplus/hunger
            // Icons
            for (int i = 0; i < city.Food; i++)
            {
                g.DrawImage(CityImages.FoodBig.Resize(zoom), dest.X + 206 * (2 + cityZoom) / 2 + i * spacing, dest.Y + 76 * (2 + cityZoom) / 2);
            }
            for (int i = 0; i < Math.Abs(city.SurplusHunger); i++)
            {
                if (city.SurplusHunger < 0)
                {
                    g.DrawImage(CityImages.HungerBig.Resize(zoom), dest.X + (431 - (spacing * Math.Abs(city.SurplusHunger) + 14 - spacing) + i * spacing) * (2 + cityZoom) / 2, dest.Y + 76 * (2 + cityZoom) / 2);                         // Hunger
                }
                else
                {
                    g.DrawImage(CityImages.FoodBig.Resize(zoom), dest.X + (431 - (spacing * Math.Abs(city.SurplusHunger) + 14 - spacing) + i * spacing) * (2 + cityZoom) / 2, dest.Y + 76 * (2 + cityZoom) / 2);  // Surplus
                }
            }

            // TRADE
            // Text
            _txtFrame = new Rectangle(dest.X + 203 * (2 + cityZoom) / 2, dest.Y + 102 * (2 + cityZoom) / 2, 228 * (2 + cityZoom) / 2, 12 * (2 + cityZoom) / 2);
            Draw.Text(g, $"Trade: {city.Trade}", _font, Color.FromArgb(239, 159, 7), _txtFrame, FormattedTextAlignment.Left, Colors.Black, 1, 1);
            Draw.Text(g, $"Corruption: {city.Corruption}", _font, Color.FromArgb(227, 83, 15), _txtFrame, FormattedTextAlignment.Right, Colors.Black, 1, 1);
            // Spacing between icons
            switch (city.Trade + city.Corruption)
            {
            case int n when(n >= 1 && n <= 15): spacing = 15; break;         // norm=15, big=23, gap=1px

            case int n when(n == 16 || n == 17): spacing = 13; break;        // norm=13, big=20, overlap=1px

            case int n when(n == 18 || n == 19): spacing = 11; break;        // norm=11, big=17, overlap=3px

            case int n when(n == 20 || n == 21): spacing = 10; break;        // norm=10, big=15, overlap=4px

            case int n when(n == 22 || n == 23): spacing = 9; break;         // norm=9, big=14, overlap=5px

            case int n when(n == 24 || n == 25): spacing = 8; break;         // norm=8, big=12, overlap=6px

            case int n when(n >= 26 && n <= 29): spacing = 7; break;         // norm=7, big=11, overlap=7px

            case int n when(n >= 30 && n <= 33): spacing = 6; break;         // norm=6, big=9, overlap=8px

            case int n when(n >= 34 && n <= 37): spacing = 5; break;         // norm=5, big=8, overlap=9px

            case int n when(n >= 38 && n <= 49): spacing = 4; break;         // norm=4, big=6, overlap=10px

            case int n when(n >= 50 && n <= 65): spacing = 3; break;         // norm=3, big=5, overlap=11px

            case int n when(n >= 66): spacing = 2; break;                    // norm=2, big=3, overlap=12px

            default: spacing = 2; break;
            }
            spacing = (int)(spacing * (1 + ((float)zoom / 8.0)));   // Make spacing city zoom dependent
            // TODO: Draw background rectangle
            //g.FillRectangle(new SolidBrush(Color.FromArgb(71, 147, 31)), 0, 0, spacing * foodIcons + 21 - spacing + 6, 23); //background square for food
            //g.FillRectangle(new SolidBrush(Color.FromArgb(55, 123, 23)), x_size - (spacing * Math.Abs(surplusIcons) + 21 - spacing + 3), 0, spacing * Math.Abs(surplusIcons) + 21 - spacing + 6, 23); //background square for surplus/hunger
            // Icons
            for (int i = 0; i < city.Trade; i++)
            {
                g.DrawImage(CityImages.TradeBig.Resize(zoom), dest.X + 206 * (2 + cityZoom) / 2 + i * spacing, dest.Y + 117 * (2 + cityZoom) / 2);
            }
            for (int i = 0; i < city.Corruption; i++)
            {
                g.DrawImage(CityImages.CorruptBig.Resize(zoom), dest.X + (431 - (spacing * city.Corruption + 14 - spacing) + i * spacing) * (2 + cityZoom) / 2, dest.Y + 117 * (2 + cityZoom) / 2);
            }

            // TAX+LUX+SCI
            // Text
            _txtFrame = new Rectangle(dest.X + 204 * (2 + cityZoom) / 2, dest.Y + 156 * (2 + cityZoom) / 2, 228 * (2 + cityZoom) / 2, 12 * (2 + cityZoom) / 2);
            Draw.Text(g, $"50% Tax: {city.Tax}", _font, Color.FromArgb(239, 159, 7), _txtFrame, FormattedTextAlignment.Left, Colors.Black, 1, 1);
            Draw.Text(g, $"0% Lux: {city.Lux}", _font, Colors.White, _txtFrame, FormattedTextAlignment.Center, Colors.Black, 1, 1);
            Draw.Text(g, $"50% Sci: {city.Science}", _font, Color.FromArgb(63, 187, 199), _txtFrame, FormattedTextAlignment.Right, Colors.Black, 1, 1);
            // Spacing between icons
            switch (city.Tax + city.Lux + city.Science)
            {
            case int n when(n >= 1 && n <= 15): spacing = 15; break;         // norm=15, big=23, gap=1px

            case int n when(n == 16 || n == 17): spacing = 13; break;        // norm=13, big=20, overlap=1px

            case int n when(n == 18 || n == 19): spacing = 11; break;        // norm=11, big=17, overlap=3px

            case int n when(n == 20 || n == 21): spacing = 10; break;        // norm=10, big=15, overlap=4px

            case int n when(n == 22 || n == 23): spacing = 9; break;         // norm=9, big=14, overlap=5px

            case int n when(n == 24 || n == 25): spacing = 8; break;         // norm=8, big=12, overlap=6px

            case int n when(n >= 26 && n <= 29): spacing = 7; break;         // norm=7, big=11, overlap=7px

            case int n when(n >= 30 && n <= 33): spacing = 6; break;         // norm=6, big=9, overlap=8px

            case int n when(n >= 34 && n <= 37): spacing = 5; break;         // norm=5, big=8, overlap=9px

            case int n when(n >= 38 && n <= 49): spacing = 4; break;         // norm=4, big=6, overlap=10px

            case int n when(n >= 50 && n <= 65): spacing = 3; break;         // norm=3, big=5, overlap=11px

            case int n when(n >= 66): spacing = 2; break;                    // norm=2, big=3, overlap=12px

            default: spacing = 2; break;
            }
            spacing = (int)(spacing * (1 + ((float)zoom / 8.0)));   // Make spacing city zoom dependent
            // TODO: Draw background rectangle
            //g.FillRectangle(new SolidBrush(Color.FromArgb(71, 147, 31)), 0, 0, spacing * foodIcons + 21 - spacing + 6, 23); //background square for food
            //g.FillRectangle(new SolidBrush(Color.FromArgb(55, 123, 23)), x_size - (spacing * Math.Abs(surplusIcons) + 21 - spacing + 3), 0, spacing * Math.Abs(surplusIcons) + 21 - spacing + 6, 23); //background square for surplus/hunger
            // Icons
            for (int i = 0; i < city.Tax; i++)
            {
                g.DrawImage(CityImages.TaxBig.Resize(zoom), dest.X + 206 * (2 + cityZoom) / 2 + i * spacing, dest.Y + 141 * (2 + cityZoom) / 2);
            }
            for (int i = 0; i < city.Lux; i++)
            {
                g.DrawImage(CityImages.LuxBig.Resize(zoom), dest.X + 290 * (2 + cityZoom) / 2 + i * spacing, dest.Y + 141 * (2 + cityZoom) / 2);
            }
            for (int i = 0; i < city.Science; i++)
            {
                g.DrawImage(CityImages.SciBig.Resize(zoom), dest.X + (431 - (spacing * city.Science + 14 - spacing) + i * spacing) * (2 + cityZoom) / 2, dest.Y + 141 * (2 + cityZoom) / 2);
            }

            // SUPPORT+PRODUCTION
            // Text
            _txtFrame = new Rectangle(dest.X + 204 * (2 + cityZoom) / 2, dest.Y + 196 * (2 + cityZoom) / 2, 228 * (2 + cityZoom) / 2, 12 * (2 + cityZoom) / 2);
            Draw.Text(g, $"Support: {city.Support}", _font, Color.FromArgb(63, 79, 167), _txtFrame, FormattedTextAlignment.Left, Colors.Black, 1, 1);
            Draw.Text(g, $"Production: {city.Production}", _font, Color.FromArgb(7, 11, 103), _txtFrame, FormattedTextAlignment.Right, Colors.Black, 1, 1);
            // Spacing between icons
            switch (city.Support + city.Production)
            {
            case int n when(n >= 1 && n <= 15): spacing = 15; break;         // norm=15, big=23, gap=1px

            case int n when(n == 16 || n == 17): spacing = 13; break;        // norm=13, big=20, overlap=1px

            case int n when(n == 18 || n == 19): spacing = 11; break;        // norm=11, big=17, overlap=3px

            case int n when(n == 20 || n == 21): spacing = 10; break;        // norm=10, big=15, overlap=4px

            case int n when(n == 22 || n == 23): spacing = 9; break;         // norm=9, big=14, overlap=5px

            case int n when(n == 24 || n == 25): spacing = 8; break;         // norm=8, big=12, overlap=6px

            case int n when(n >= 26 && n <= 29): spacing = 7; break;         // norm=7, big=11, overlap=7px

            case int n when(n >= 30 && n <= 33): spacing = 6; break;         // norm=6, big=9, overlap=8px

            case int n when(n >= 34 && n <= 37): spacing = 5; break;         // norm=5, big=8, overlap=9px

            case int n when(n >= 38 && n <= 49): spacing = 4; break;         // norm=4, big=6, overlap=10px

            case int n when(n >= 50 && n <= 65): spacing = 3; break;         // norm=3, big=5, overlap=11px

            case int n when(n >= 66): spacing = 2; break;                    // norm=2, big=3, overlap=12px

            default: spacing = 2; break;
            }
            spacing = (int)(spacing * (1 + ((float)zoom / 8.0)));   // Make spacing city zoom dependent
            // TODO: Draw background rectangle
            //g.FillRectangle(new SolidBrush(Color.FromArgb(71, 147, 31)), 0, 0, spacing * foodIcons + 21 - spacing + 6, 23); //background square for food
            //g.FillRectangle(new SolidBrush(Color.FromArgb(55, 123, 23)), x_size - (spacing * Math.Abs(surplusIcons) + 21 - spacing + 3), 0, spacing * Math.Abs(surplusIcons) + 21 - spacing + 6, 23); //background square for surplus/hunger
            // Icons
            for (int i = 0; i < city.Support; i++)
            {
                g.DrawImage(CityImages.SupportBig.Resize(zoom), dest.X + 206 * (2 + cityZoom) / 2 + i * spacing, dest.Y + 181 * (2 + cityZoom) / 2);
            }
            for (int i = 0; i < city.Production; i++)
            {
                g.DrawImage(CityImages.SupportBig.Resize(zoom), dest.X + (431 - (spacing * city.Production + 14 - spacing) + i * spacing) * (2 + cityZoom) / 2, dest.Y + 181 * (2 + cityZoom) / 2);
            }
        }
Exemple #11
0
        private void Surface_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.AntiAlias = false;

            // Inner wallpaper
            e.Graphics.DrawImage(Images.ExtractBitmap(DLLs.Tiles, "defenseMinWallpaper").CropImage(new Rectangle(0, 0, 600, 400)),
                                 new Rectangle(11, 11, 600, 400));

            // Text
            var font1     = new Font("Times New Roman", 14);
            var cycleText = showCasualties ? "Casualties" : "Statistics";

            Draw.Text(e.Graphics, $"DEFENSE MINISTER: {cycleText}", font1, Color.FromArgb(223, 223, 223),
                      new Point(300, 24), true, true, Color.FromArgb(67, 67, 67), 2, 1);
            Draw.Text(e.Graphics, $"Holy Empire of the {Game.GetActiveCiv.Adjective}", font1, Color.FromArgb(223, 223, 223),
                      new Point(300, 45), true, true, Color.FromArgb(67, 67, 67), 2, 1);
            Draw.Text(e.Graphics, $"{Game.GetActiveCiv.LeaderTitle} {Game.GetActiveCiv.LeaderName}: {Game.GetGameYearString}",
                      font1, Color.FromArgb(223, 223, 223), new Point(300, 66), true, true, Color.FromArgb(67, 67, 67), 2, 1);

            if (!showCasualties)
            {
                // Unit types
                var drawnUnits = unitStatDefs.Skip(barVal0).Take(12).ToList();
                for (int i = 0; i < drawnUnits.Count; i++)
                {
                    var unitDef = drawnUnits[i];
                    var font    = new Font("Times New Roman", 11, FontStyle.Bold);

                    // Unit image
                    Draw.UnitShield(e.Graphics, unitDef.Type, Game.GetActiveCiv.Id, OrderType.NoOrders, false, 100, 100, 0,
                                    new Point(13 + 64 * ((barVal0 + i + 1) % 2), 78 + 24 * i));
                    Draw.UnitSprite(e.Graphics, unitDef.Type, false, false, 0, new Point(13 + 64 * ((barVal0 + i + 1) % 2), 78 + 24 * i));

                    // Unit name
                    Draw.Text(e.Graphics, unitDef.Name, font, Color.FromArgb(223, 223, 223),
                              new Point(149, 95 + 24 * i), false, false, Color.FromArgb(67, 67, 67), 1, 1);

                    // Stats
                    Draw.Text(e.Graphics, $"{unitDef.Attack}/{unitDef.Defense}/{unitDef.Move / 3}", font, Color.FromArgb(223, 223, 223),
                              new Point(245, 95 + 24 * i), false, false, Color.FromArgb(67, 67, 67), 1, 1);
                    Draw.Text(e.Graphics, $"{unitDef.Hitp / 10}/{unitDef.Firepwr}", font, Color.FromArgb(223, 223, 223),
                              new Point(300, 95 + 24 * i), false, false, Color.FromArgb(67, 67, 67), 1, 1);

                    var unitNo = Game.GetActiveCiv.Units.Where(u => u.Type == unitDef.Type).Count();
                    Draw.Text(e.Graphics, $"{unitNo} active", font, Color.FromArgb(255, 223, 79),
                              new Point(332, 95 + 24 * i), false, false, Colors.Black, 1, 1);

                    var unitInProdNo = Game.GetActiveCiv.Cities.Where(c => c.ItemInProduction.Type == ItemType.Unit &&
                                                                      Game.Rules.UnitTypes[c.ItemInProduction.ImageIndex].Type == unitDef.Type).Count();
                    if (unitInProdNo > 0)
                    {
                        Draw.Text(e.Graphics, $"{unitInProdNo} in prod", font, Color.FromArgb(63, 187, 199),
                                  new Point(393, 95 + 24 * i), false, false, Colors.Black, 1, 1);
                    }

                    // TODO: Add extra flags description
                }
            }
            else
            {
            }
        }
        private void Surface_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.AntiAlias = false;

            // Inner wallpaper
            e.Graphics.DrawImage(Images.ExtractBitmap(DLLs.Tiles, "attitudeAdvWallpaper").CropImage(new Rectangle(0, 0, 600, 400)), new Rectangle(11, 11, 600, 400));

            // Text
            var font1 = new Font("Times New Roman", 14);

            Draw.Text(e.Graphics, "ATTITUDE ADVISOR", font1, Color.FromArgb(223, 223, 223), new Point(300, 24), true, true, Color.FromArgb(67, 67, 67), 2, 1);
            Draw.Text(e.Graphics, $"Holy Empire of the {Game.GetActiveCiv.Adjective}", font1, Color.FromArgb(223, 223, 223),
                      new Point(300, 45), true, true, Color.FromArgb(67, 67, 67), 2, 1);
            Draw.Text(e.Graphics, $"{Game.GetActiveCiv.LeaderTitle} {Game.GetActiveCiv.LeaderName}: {Game.GetGameYearString}", font1, Color.FromArgb(223, 223, 223),
                      new Point(300, 66), true, true, Color.FromArgb(67, 67, 67), 2, 1);


            // Cities
            var drawnCities = Game.GetActiveCiv.Cities.Skip(barVal0).Take(9).ToList();

            for (int i = 0; i < drawnCities.Count; i++)
            {
                var city = drawnCities[i];
                var font = new Font("Times New Roman", 11, FontStyle.Bold);

                // City image
                Draw.City(e.Graphics, city, true, 0, new Point(13 + 64 * ((barVal0 + i + 1) % 2), 78 + 32 * i));

                // City name
                Draw.Text(e.Graphics, city.Name, font, Color.FromArgb(223, 223, 223),
                          new Point(149, 87 + 32 * i), false, false, Color.FromArgb(67, 67, 67), 1, 1);

                // People
                var spacing = city.Size switch
                {
                    int n when(n <= 10) => 28,
                    int n when(n == 11) => 27,
                    int n when(n == 12) => 25,
                    int n when(n == 13) => 23,
                    int n when(n == 14) => 21,
                    int n when(n == 15) => 19,
                    int n when(n == 16) => 18,
                    int n when(n == 17) => 17,
                    int n when(n == 18 || n == 19) => 15,
                    int n when(n == 20) => 14,
                    int n when(n == 21 || n == 22) => 13,
                    int n when(n == 23 || n == 24) => 12,
                    int n when(n == 25 || n == 26) => 11,
                    int n when(n == 27 || n == 28) => 10,
                    int n when(n >= 29 && n <= 31) => 9,
                    int n when(n >= 32 && n <= 35) => 8,
                    int n when(n >= 36 && n <= 40) => 7,
                    int n when(n >= 41 && n <= 47) => 6,
                    int n when(n >= 48 && n <= 56) => 5,
                    int n when(n >= 57 && n <= 70) => 4,
                    int n when(n >= 71 && n <= 93) => 3,
                    int n when(n >= 94) => 2,
                    _ => 28,
                };

                PeopleType[] peoples = city.People;
                var          offsetX = 254;
                int          drawIndex;
                for (int p = 0; p < city.Size; p++)
                {
                    drawIndex = (int)peoples[p];
                    if (p % 2 == 1 && (drawIndex == 0 || drawIndex == 2 || drawIndex == 4 || drawIndex == 6))
                    {
                        drawIndex++;  // Change men/woman appearance
                    }
                    var plpPic = CityImages.PeopleLarge[drawIndex, (int)city.Owner.Epoch];
                    e.Graphics.DrawImage(plpPic, offsetX + 5 + p * spacing, 81 + 32 * i);
                }
            }
        }
Exemple #13
0
 private void MainPanel_Paint(object sender, PaintEventArgs e)
 {
     Draw.Text(e.Graphics, $"{Game.GetActiveCiv.Adjective} map", new Font("Times new roman", 17, FontStyle.Bold), Color.FromArgb(135, 135, 135), new Point(MainPanel.Width / 2, 38 / 2), true, true, Colors.Black, 1, 1);
 }
Exemple #14
0
        private void PaintPanel(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawImage(baseTile, new Point(0, 0));

            // Tiles
            for (int id = 0; id < 56; id++)
            {
                if (_city.IsNextToOcean && id > 49)
                {
                    continue;
                }
                if (_city.IsNextToRiver && id > 49 && id < 54)
                {
                    continue;
                }

                if (_city.ImprovementExists(improvements[id].Type))
                {
                    DrawImprovement(e.Graphics, id);
                }
                else
                {
                    DrawAlternativeTile(e.Graphics, improvements[id].AlternativeTileId);
                }
            }

            // City walls
            if (_city.ImprovementExists(ImprovementType.CityWalls))
            {
                DrawImprovement(e.Graphics, 56);
            }

            // Offshore platrofrm
            if (_city.ImprovementExists(ImprovementType.OffshorePlat))
            {
                DrawImprovement(e.Graphics, 57);
            }

            // Harbor/port fac.
            if (_city.ImprovementExists(ImprovementType.PortFacil))
            {
                DrawImprovement(e.Graphics, 59);
            }
            else if (_city.ImprovementExists(ImprovementType.Harbour))
            {
                DrawImprovement(e.Graphics, 58);
            }

            // Colossus
            if (_city.ImprovementExists(ImprovementType.Colossus))
            {
                if (_city.IsNextToRiver)
                {
                    DrawImprovement(e.Graphics, 61);
                }
                else
                {
                    DrawImprovement(e.Graphics, 60);
                }
            }

            // Lighthouse
            if (_city.ImprovementExists(ImprovementType.Lighthouse))
            {
                if (_city.IsNextToRiver)
                {
                    DrawImprovement(e.Graphics, 63);
                }
                else
                {
                    DrawImprovement(e.Graphics, 62);
                }
            }

            // Statue liberty
            // TODO: find out where to draw statue of liberty in city view

            // Great wall
            if (_city.ImprovementExists(ImprovementType.GreatWall))
            {
                DrawImprovement(e.Graphics, 64);
            }

            Draw.Text(e.Graphics, $"{_city.Name}: {Game.GetGameYearString}", new Font("Times new roman", 26, FontStyle.Bold), Color.FromArgb(132, 132, 132), new Point(790, 10), false, false, Colors.Black, 1, 1);
        }
        private void UnitPanel_Paint(object sender, PaintEventArgs e)
        {
            // Paint wallpaper
            var imgSize = Images.PanelInnerWallpaper.Size;

            for (int row = 0; row < this.Height / imgSize.Height + 1; row++)
            {
                for (int col = 0; col < this.Width / imgSize.Width + 1; col++)
                {
                    e.Graphics.DrawImage(Images.PanelInnerWallpaper, col * imgSize.Width, row * imgSize.Height);
                }
            }
            using var _font = new Font("Times new roman", 12, FontStyle.Bold);
            var          _frontColor      = Color.FromArgb(51, 51, 51);
            var          _backColor       = Color.FromArgb(191, 191, 191);
            List <IUnit> _unitsOnThisTile = Game.UnitsHere(Map.ActiveXY[0], Map.ActiveXY[1]);

            string _cityName, _wholeText, _roadText, _irrigText, _airbaseText;
            int    _column;

            // View piece mode
            if (Map.ViewPieceMode)
            {
                Draw.Text(e.Graphics, "Viewing Pieces", _font, Colors.White, new Point(119, 10), true, true, Colors.Black, 1, 0);

                // Draw location & tile type on active square
                Draw.Text(e.Graphics, $"Loc: ({Map.ActiveXY[0]}, {Map.ActiveXY[1]}) {Map.Tile[(Map.ActiveXY[0] - Map.ActiveXY[1] % 2) / 2, Map.ActiveXY[1]].Island}", _font, _frontColor, new Point(5, 27), false, false, _backColor, 1, 1);
                Draw.Text(e.Graphics, $"({Map.Tile[(Map.ActiveXY[0] - Map.ActiveXY[1] % 2) / 2, Map.ActiveXY[1]].Type})", _font, _frontColor, new Point(5, 45), false, false, _backColor, 1, 1);

                //int count;
                //for (count = 0; count < Math.Min(_unitsOnThisTile.Count, maxUnitsToDraw); count++)
                //{
                //    //e.Graphics.DrawImage(ModifyImage.Resize(Draw.Unit(UnitsOnThisTile[count], false, 0), (int)Math.Round(64 * 1.15), (int)Math.Round(48 * 1.15)), 6, 70 + count * 56);
                //    //e.Graphics.DrawImage(ModifyImage.Resize(Draw.Unit(UnitsOnThisTile[count], false, 0), 0), 6, 70 + count * 56);  // TODO: do this again!!!
                //    Draw.Text(e.Graphics, _unitsOnThisTile[count].HomeCity.Name, _font, StringAlignment.Near, StringAlignment.Near, _frontColor, new Point(79, 70 + count * 56), _backColor, 1, 1);
                //    Draw.Text(e.Graphics, _unitsOnThisTile[count].Order.ToString(), _font, StringAlignment.Near, StringAlignment.Near, _frontColor, new Point(79, 88 + count * 56), _backColor, 1, 1); // TODO: give proper conversion of orders to string
                //    Draw.Text(e.Graphics, _unitsOnThisTile[count].Name, _font, StringAlignment.Near, StringAlignment.Near, _frontColor, new Point(79, 106 + count * 56), _backColor, 1, 1);
                //}
                //if (count < _unitsOnThisTile.Count)
                //{
                //    string _moreUnits = (_unitsOnThisTile.Count - count == 1) ? "More Unit" : "More Units";
                //    Draw.Text(e.Graphics, $"({_unitsOnThisTile.Count() - count} {_moreUnits})", _font, StringAlignment.Near, StringAlignment.Near, _frontColor, new Point(5, UnitPanel.Height - 27), _backColor, 1, 1);
                //}
            }
            // Moving units mode
            else
            {
                Draw.Text(e.Graphics, "Moving Units", _font, Colors.White, new Point(119, 10), true, true, Colors.Black, 1, 0);

                // Show active unit info
                Draw.Unit(e.Graphics, Game.GetActiveUnit, false, 1, new Point(7, 27));
                // Show move points correctly
                int    _fullMovPts = Game.GetActiveUnit.MovePoints / 3;
                int    _remMovPts  = Game.GetActiveUnit.MovePoints % 3;
                string _text       = $"Moves: {_fullMovPts} {_remMovPts}/3";
                if (_remMovPts == 0)
                {
                    _text = $"Moves: {_fullMovPts}";
                }
                Draw.Text(e.Graphics, _text, _font, _frontColor, new Point(79, 25), false, false, _backColor, 1, 1);
                // Show other unit info
                _cityName = (Game.GetActiveUnit.HomeCity == null) ? "NONE" : Game.GetActiveUnit.HomeCity.Name;
                Draw.Text(e.Graphics, _cityName, _font, _frontColor, new Point(79, 43), false, false, _backColor, 1, 1);
                Draw.Text(e.Graphics, Game.GetActiveCiv.Adjective, _font, _frontColor, new Point(79, 61), false, false, _backColor, 1, 1);
                _column = 83;
                Draw.Text(e.Graphics, Game.GetActiveUnit.Name, _font, _frontColor, new Point(5, _column), false, false, _backColor, 1, 1);
                _column += 18;
                Draw.Text(e.Graphics, $"({Map.TileC2(Map.ActiveXY[0], Map.ActiveXY[1]).Type})", _font, _frontColor, new Point(5, _column), false, false, _backColor, 1, 1);
                // If road/railroad/irrigation/farmland/mine present
                _wholeText = null;
                _roadText  = null;
                _irrigText = null;
                if (Map.TileC2(Map.ActiveXY[0], Map.ActiveXY[1]).Road || Map.TileC2(Map.ActiveXY[0], Map.ActiveXY[1]).Railroad || Map.TileC2(Map.ActiveXY[0], Map.ActiveXY[1]).Irrigation || Map.TileC2(Map.ActiveXY[0], Map.ActiveXY[1]).Farmland || Map.TileC2(Map.ActiveXY[0], Map.ActiveXY[1]).Mining)
                {
                    _column += 18;
                    if (Map.TileC2(Map.ActiveXY[0], Map.ActiveXY[1]).Road)
                    {
                        _roadText = "Road";
                    }
                    if (Map.TileC2(Map.ActiveXY[0], Map.ActiveXY[1]).Railroad)
                    {
                        _roadText = "Railroad";
                    }
                    if (Map.TileC2(Map.ActiveXY[0], Map.ActiveXY[1]).Irrigation)
                    {
                        _irrigText = "Irrigation";
                    }
                    if (Map.TileC2(Map.ActiveXY[0], Map.ActiveXY[1]).Farmland)
                    {
                        _irrigText = "Farmland";
                    }
                    if (Map.TileC2(Map.ActiveXY[0], Map.ActiveXY[1]).Mining)
                    {
                        _irrigText = "Mining";
                    }
                    if (_roadText != null && _irrigText == null)
                    {
                        _wholeText = $"({_roadText})";
                    }
                    else if (_roadText == null && _irrigText != null)
                    {
                        _wholeText = $"({_irrigText})";
                    }
                    else if (_roadText != null && _irrigText != null)
                    {
                        _wholeText = $"({_roadText}, {_irrigText})";
                    }
                    Draw.Text(e.Graphics, _wholeText, _font, _frontColor, new Point(5, _column), false, false, _backColor, 1, 1);
                }
                // If airbase/fortress present
                _airbaseText = null;
                if (Map.TileC2(Map.ActiveXY[0], Map.ActiveXY[1]).Airbase || Map.TileC2(Map.ActiveXY[0], Map.ActiveXY[1]).Fortress)
                {
                    _column += 18;
                    if (Map.TileC2(Map.ActiveXY[0], Map.ActiveXY[1]).Fortress)
                    {
                        _airbaseText = "Fortress";
                    }
                    if (Map.TileC2(Map.ActiveXY[0], Map.ActiveXY[1]).Airbase)
                    {
                        _airbaseText = "Airbase";
                    }
                    Draw.Text(e.Graphics, $"({_airbaseText})", _font, _frontColor, new Point(5, _column), false, false, _backColor, 1, 1);
                }
                // If pollution present
                if (Map.TileC2(Map.ActiveXY[0], Map.ActiveXY[1]).Pollution)
                {
                    _column += 18;
                    Draw.Text(e.Graphics, "(Pollution)", _font, _frontColor, new Point(5, _column), false, false, _backColor, 1, 1);
                }
                _column += 5;

                // Show info for other units on the tile
                int drawCount = 0;
                foreach (IUnit unit in _unitsOnThisTile.Where(u => u != Game.GetActiveUnit))
                {
                    // First check if there is vertical space still left for drawing in panel
                    if (_column + 69 > unitPanel.Height)
                    {
                        break;
                    }

                    // Draw unit
                    Draw.Unit(e.Graphics, unit, false, 1, new Point(7, _column + 27));
                    // Show other unit info
                    _column  += 20;
                    _cityName = (unit.HomeCity == null) ? "NONE" : Game.GetActiveUnit.HomeCity.Name;
                    Draw.Text(e.Graphics, _cityName, _font, _frontColor, new Point(80, _column), false, false, _backColor, 1, 1);
                    _column += 18;
                    Draw.Text(e.Graphics, Order2string(unit.Order), _font, _frontColor, new Point(80, _column), false, false, _backColor, 1, 1);
                    _column += 18;
                    Draw.Text(e.Graphics, unit.Name, _font, _frontColor, new Point(80, _column), false, false, _backColor, 1, 1);

                    //System.Diagnostics.Debug.WriteLine($"{unit.Name} drawn");

                    drawCount++;
                }

                // If not all units were drawn print a message
                if (_unitsOnThisTile.Count - 1 != drawCount)    // -1 because you must not count in active unit
                {
                    _column += 22;
                    _text    = _unitsOnThisTile.Count - 1 - drawCount == 1 ? "Unit" : "Units";
                    Draw.Text(e.Graphics, $"({_unitsOnThisTile.Count - 1 - drawCount} More {_text})", _font, _frontColor, new Point(9, _column), false, false, _backColor, 1, 1);
                }
            }

            //// Blinking "end of turn" message
            //if (WaitingAtEndOfTurn)
            //{
            //    using var _font2 = new Font("Times New Roman", 12, FontStyle.Bold);
            //    Color _EoTcolor = BoolSwitcher ? Color.White : Color.FromArgb(135, 135, 135);
            //    Draw.Text(e.Graphics, "End of Turn", _font2, StringAlignment.Near, StringAlignment.Near, _EoTcolor, new Point(5, UnitPanel.Height - 51), Color.Black, 1, 0);
            //    Draw.Text(e.Graphics, "(Press ENTER)", _font2, StringAlignment.Near, StringAlignment.Near, _EoTcolor, new Point(10, UnitPanel.Height - 33), Color.Black, 1, 0);
            //}
        }
Exemple #16
0
        public SelectUnitDialog(Main parent, List <Unit> units) : base(parent, 514 + 2 * 11, 46 * Math.Min(units.Count, 9) + 38 + 46, 38, 46, "Select Unit To Activate")
        {
            var shownUnits = units.Take(9).ToList();

            radioBtnList = new RadioButtonList()
            {
                DataStore   = shownUnits,
                Orientation = Orientation.Vertical
            };
            radioBtnList.SelectedIndexChanged += (sender, e) => innerPanel.Invalidate();
            radioBtnList.GotFocus             += (sender, e) => innerPanel.Invalidate();
            Layout.Add(radioBtnList, 11 + 10, 40);

            innerPanel = new Drawable()
            {
                Size = new Size(514, 46 * shownUnits.Count)
            };
            innerPanel.Paint += (sender, e) =>
            {
                e.Graphics.AntiAlias = false;

                // Background
                var imgSize = MapImages.PanelInnerWallpaper.Size;
                for (int row = 0; row < this.Height / imgSize.Height + 1; row++)
                {
                    for (int col = 0; col < this.Width / imgSize.Width + 1; col++)
                    {
                        e.Graphics.DrawImage(MapImages.PanelInnerWallpaper, col * imgSize.Width, row * imgSize.Height);
                    }
                }

                // Draw units, unit outline, text
                for (int row = 0; row < shownUnits.Count; row++)
                {
                    Draw.Unit(e.Graphics, shownUnits[row], false, -1, new Point(2, 2 + 46 * row));

                    string _homeCity = shownUnits[row].HomeCity == null ? "NONE" : shownUnits[row].HomeCity.Name;
                    Draw.Text(e.Graphics, $"{shownUnits[row].Owner.Adjective} {shownUnits[row].Name} ({_homeCity})", new Font("Times New Roman", 18), Color.FromArgb(51, 51, 51), new Point(61, 9 + 46 * row), false, false, Color.FromArgb(191, 191, 191), 1, 1);

                    using var _pen = new Pen(Color.FromArgb(223, 223, 223));
                    if (radioBtnList.SelectedIndex == row)
                    {
                        e.Graphics.DrawRectangle(_pen, new Rectangle(1, 1 + 46 * row, 57, 42));
                    }
                }
            };
            innerPanel.MouseDown += (sender, e) =>
            {
                int clickedRow = ((int)e.Location.Y - 1) / 46;

                shownUnits[clickedRow].Order = OrderType.NoOrders;

                radioBtnList.SelectedIndex = clickedRow;
                innerPanel.Invalidate();
            };
            Layout.Add(innerPanel, 11, 38);

            // Buttons
            DefaultButton = new Civ2button("OK", 258, 36, new Font("Times new roman", 11));
            AbortButton   = new Civ2button("Cancel", 258, 36, new Font("Times new roman", 11));
            Layout.Add(DefaultButton, 9, 42 + innerPanel.Height);
            Layout.Add(AbortButton, 11 + DefaultButton.Width, 42 + innerPanel.Height);

            DefaultButton.Click += (sender, e) =>
            {
                foreach (MenuItem item in parent.Menu.Items)
                {
                    item.Enabled = true;
                }
                SelectedIndex = radioBtnList.SelectedIndex;
                Close();
            };

            AbortButton.Click += (sender, e) =>
            {
                foreach (MenuItem item in parent.Menu.Items)
                {
                    item.Enabled = true;
                }
                SelectedIndex = int.MinValue;
                Close();
            };

            Content = Layout;
        }
        private void Surface_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.AntiAlias = false;

            // Inner wallpaper
            e.Graphics.DrawImage(Images.ExtractBitmap(DLLs.Tiles, "cityStatusWallpaper").CropImage(new Rectangle(0, 0, 600, 400)), new Rectangle(11, 11, 600, 400));

            // Text
            var font1 = new Font("Times New Roman", 14);

            Draw.Text(e.Graphics, "CITY STATUS", font1, Color.FromArgb(223, 223, 223), new Point(300, 24), true, true, Color.FromArgb(67, 67, 67), 2, 1);
            Draw.Text(e.Graphics, $"Holy Empire of the {Game.GetActiveCiv.Adjective}", font1, Color.FromArgb(223, 223, 223),
                      new Point(300, 45), true, true, Color.FromArgb(67, 67, 67), 2, 1);
            Draw.Text(e.Graphics, $"{Game.GetActiveCiv.LeaderTitle} {Game.GetActiveCiv.LeaderName}: {Game.GetGameYearString}", font1, Color.FromArgb(223, 223, 223),
                      new Point(300, 66), true, true, Color.FromArgb(67, 67, 67), 2, 1);

            // Cities
            var drawnCities = Game.GetActiveCiv.Cities.Skip(barVal0).Take(12).ToList();

            for (int i = 0; i < drawnCities.Count; i++)
            {
                var city = drawnCities[i];
                var font = new Font("Times New Roman", 11, FontStyle.Bold);

                // City image
                Draw.City(e.Graphics, city, true, 0, new Point(13 + 64 * ((barVal0 + i + 1) % 2), 78 + 24 * i));

                // City name
                Draw.Text(e.Graphics, city.Name, font, Color.FromArgb(223, 223, 223),
                          new Point(149, 87 + 24 * i), false, false, Color.FromArgb(67, 67, 67), 1, 1);

                // Food
                var offsetX  = 254;
                var foodProd = new FormattedText()
                {
                    Font            = font,
                    Text            = city.FoodProduction.ToString(),
                    ForegroundBrush = new SolidBrush(Color.FromArgb(223, 223, 223))
                };
                var foodProdShadow = new FormattedText()
                {
                    Font            = font,
                    Text            = city.FoodProduction.ToString(),
                    ForegroundBrush = new SolidBrush(Color.FromArgb(67, 67, 67))
                };
                e.Graphics.DrawText(foodProdShadow, new Point(offsetX + 1, 87 + 24 * i + 1));
                e.Graphics.DrawText(foodProd, new Point(offsetX, 87 + 24 * i));
                offsetX += (int)foodProd.Measure().Width + 1;
                e.Graphics.DrawImage(CityImages.FoodBig, new Point(offsetX +  +1, 87 + 24 * i));

                // Production
                var prod = new FormattedText()
                {
                    Font            = font,
                    Text            = city.TotalProduction.ToString(),
                    ForegroundBrush = new SolidBrush(Color.FromArgb(223, 223, 223))
                };
                var prodShadow = new FormattedText()
                {
                    Font            = font,
                    Text            = city.TotalProduction.ToString(),
                    ForegroundBrush = new SolidBrush(Color.FromArgb(67, 67, 67))
                };
                offsetX += 16;
                e.Graphics.DrawText(prodShadow, new Point(offsetX + 1, 87 + 24 * i + 1));
                e.Graphics.DrawText(prod, new Point(offsetX, 87 + 24 * i));
                offsetX += (int)prod.Measure().Width + 1;
                e.Graphics.DrawImage(CityImages.SupportBig, new Point(offsetX, 87 + 24 * i));

                // Trade
                var trade = new FormattedText()
                {
                    Font            = font,
                    Text            = city.Trade.ToString(),
                    ForegroundBrush = new SolidBrush(Color.FromArgb(223, 223, 223))
                };
                var tradeShadow = new FormattedText()
                {
                    Font            = font,
                    Text            = city.Trade.ToString(),
                    ForegroundBrush = new SolidBrush(Color.FromArgb(67, 67, 67))
                };
                offsetX += 16;
                e.Graphics.DrawText(tradeShadow, new Point(offsetX + 1, 87 + 24 * i + 1));
                e.Graphics.DrawText(trade, new Point(offsetX, 87 + 24 * i));
                offsetX += (int)trade.Measure().Width + 1;
                e.Graphics.DrawImage(CityImages.TradeBig, new Point(offsetX, 87 + 24 * i));

                // Item in production
                var item     = drawnCities[i].ItemInProduction;
                var itemText = new FormattedText()
                {
                    Font            = font,
                    Text            = item.GetDescription(),
                    ForegroundBrush = new SolidBrush(item.Type == ItemType.Unit ? Color.FromArgb(255, 223, 79) : Color.FromArgb(223, 223, 223))
                };
                var itemShadowText = new FormattedText()
                {
                    Font            = font,
                    Text            = item.GetDescription(),
                    ForegroundBrush = new SolidBrush(item.Type == ItemType.Unit ? Colors.Black : Color.FromArgb(67, 67, 67))
                };
                offsetX = 374;
                e.Graphics.DrawText(itemShadowText, new Point(offsetX + 1, 87 + 24 * i + 1));
                e.Graphics.DrawText(itemText, new Point(offsetX, 87 + 24 * i));
                offsetX += (int)itemText.Measure().Width + 3;
                var progressText = "(" + city.ShieldsProgress.ToString() + "/" + (10 * item.Cost).ToString() + ")";
                Draw.Text(e.Graphics, progressText, font, Color.FromArgb(191, 191, 191),
                          new Point(offsetX, 87 + 24 * i), false, false, Color.FromArgb(67, 67, 67), 1, 1);
            }
        }
        private void MainPanel_Paint(object sender, PaintEventArgs e)
        {
            // Paint wallpaper
            var imgSize = Images.PanelOuterWallpaper.Size;

            for (int row = 0; row < this.Height / imgSize.Height + 1; row++)
            {
                for (int col = 0; col < this.Width / imgSize.Width + 1; col++)
                {
                    e.Graphics.DrawImage(Images.PanelOuterWallpaper, col * imgSize.Width, row * imgSize.Height);
                }
            }
            // Paint title
            Draw.Text(e.Graphics, "Status", new Font("Times new roman", 17, FontStyle.Bold), Color.FromArgb(135, 135, 135), new Point(this.Width / 2, 38 / 2), true, true, Colors.Black, 1, 1);
            // Paint panel borders
            // Outer border
            using var _pen1 = new Pen(Color.FromArgb(227, 227, 227));
            using var _pen2 = new Pen(Color.FromArgb(105, 105, 105));
            using var _pen3 = new Pen(Color.FromArgb(255, 255, 255));
            using var _pen4 = new Pen(Color.FromArgb(160, 160, 160));
            using var _pen5 = new Pen(Color.FromArgb(240, 240, 240));
            using var _pen6 = new Pen(Color.FromArgb(223, 223, 223));
            using var _pen7 = new Pen(Color.FromArgb(67, 67, 67));
            e.Graphics.DrawLine(_pen1, 0, 0, this.Width - 2, 0);   // 1st layer of border
            e.Graphics.DrawLine(_pen1, 0, 0, 0, this.Height - 2);
            e.Graphics.DrawLine(_pen2, this.Width - 1, 0, this.Width - 1, this.Height - 1);
            e.Graphics.DrawLine(_pen2, 0, this.Height - 1, this.Width - 1, this.Height - 1);
            e.Graphics.DrawLine(_pen3, 1, 1, this.Width - 3, 1);   // 2nd layer of border
            e.Graphics.DrawLine(_pen3, 1, 1, 1, this.Height - 3);
            e.Graphics.DrawLine(_pen4, this.Width - 2, 1, this.Width - 2, this.Height - 2);
            e.Graphics.DrawLine(_pen4, 1, this.Height - 2, this.Width - 2, this.Height - 2);
            e.Graphics.DrawLine(_pen5, 2, 2, this.Width - 4, 2);   // 3rd layer of border
            e.Graphics.DrawLine(_pen5, 2, 2, 2, this.Height - 4);
            e.Graphics.DrawLine(_pen5, this.Width - 3, 2, this.Width - 3, this.Height - 3);
            e.Graphics.DrawLine(_pen5, 2, this.Height - 3, this.Width - 3, this.Height - 3);
            e.Graphics.DrawLine(_pen6, 3, 3, this.Width - 5, 3);   // 4th layer of border
            e.Graphics.DrawLine(_pen6, 3, 3, 3, this.Height - 5);
            e.Graphics.DrawLine(_pen7, this.Width - 4, 3, this.Width - 4, this.Height - 4);
            e.Graphics.DrawLine(_pen7, 3, this.Height - 4, this.Width - 4, this.Height - 4);
            e.Graphics.DrawLine(_pen6, 4, 4, this.Width - 6, 4);   // 5th layer of border
            e.Graphics.DrawLine(_pen6, 4, 4, 4, this.Height - 6);
            e.Graphics.DrawLine(_pen7, this.Width - 5, 4, this.Width - 5, this.Height - 5);
            e.Graphics.DrawLine(_pen7, 4, this.Height - 5, this.Width - 5, this.Height - 5);
            // Draw line borders of stats panel
            e.Graphics.DrawLine(_pen7, 9, 36, 252, 36);   // 1st layer of border
            e.Graphics.DrawLine(_pen7, 9, 36, 9, 98);
            e.Graphics.DrawLine(_pen6, 9, 99, 252, 99);
            e.Graphics.DrawLine(_pen6, 252, 36, 252, 99);
            e.Graphics.DrawLine(_pen7, 10, 37, 250, 37);   // 2nd layer of border
            e.Graphics.DrawLine(_pen7, 10, 38, 10, 97);
            e.Graphics.DrawLine(_pen6, 10, 98, 251, 98);
            e.Graphics.DrawLine(_pen6, 251, 37, 251, 98);
            // Draw line borders of unit panel
            e.Graphics.DrawLine(_pen7, 9, 104, 252, 104);   // 1st layer of border
            e.Graphics.DrawLine(_pen7, 9, 104, 9, 106 + unitPanel.Height);
            e.Graphics.DrawLine(_pen6, 9, 107 + unitPanel.Height, 252, 107 + unitPanel.Height);
            e.Graphics.DrawLine(_pen6, 252, 104, 252, 105 + unitPanel.Height);
            e.Graphics.DrawLine(_pen7, 9, 105, 250, 105);   // 2nd layer of border
            e.Graphics.DrawLine(_pen7, 10, 104, 10, 105 + unitPanel.Height);
            e.Graphics.DrawLine(_pen6, 10, 106 + unitPanel.Height, 252, 106 + unitPanel.Height);
            e.Graphics.DrawLine(_pen6, 251, 105, 251, 105 + unitPanel.Height);
        }