Пример #1
0
        public override BitmapBase Draw(Tank tank)
        {
            var filename = (Pattern ?? "")
                           .Replace("{tier}", tank.Tier.ToString())
                           .Replace("{country}", tank.Country.ToString().ToLower())
                           .Replace("{class}", tank.Class.ToString().ToLower())
                           .Replace("{category}", tank.Category.ToString().ToLower())
                           .Replace("{id}", tank.TankId);

            filename = Regex.Replace(filename, @"{([^}]+)}", match => tank[match.Groups[1].Value] ?? "");
            if (string.IsNullOrWhiteSpace(filename))
            {
                return(null);
            }

            var image = ImageCache.GetImage(new CompositePath(tank.Context, PathUtil.AppPath, filename));

            if (image == null)
            {
                image = ImageCache.GetImage(new CompositePath(tank.Context, tank.Context.Installation.Path, tank.Context.VersionConfig.PathMods, filename));
                if (image == null)
                {
                    image = ImageCache.GetImage(new CompositePath(tank.Context, tank.Context.Installation.Path, filename));
                }
            }
            if (image == null)
            {
                tank.AddWarning(App.Translation.FilenamePatternImageLayer.MissingImageWarning.Fmt(filename));
                return(null);
            }
            return(image);
        }
Пример #2
0
        public override BitmapBase Draw(Tank tank)
        {
            var filename = ImageFile.GetValue(tank);

            if (string.IsNullOrWhiteSpace(filename))
            {
                return(null);
            }

            var image = ImageCache.GetImage(new CompositePath(tank.Context, PathUtil.AppPath, filename));

            if (image == null)
            {
                image = ImageCache.GetImage(new CompositePath(tank.Context, tank.Context.Installation.Path, tank.Context.VersionConfig.PathMods, filename));
                if (image == null)
                {
                    image = ImageCache.GetImage(new CompositePath(tank.Context, tank.Context.Installation.Path, filename));
                }
            }
            if (image == null)
            {
                tank.AddWarning(App.Translation.CustomImageLayer.MissingImageWarning.Fmt(filename));
                return(null);
            }
            return(image);
        }
Пример #3
0
        public override BitmapBase Draw(Tank tank)
        {
            BitmapBase image;

            if (tank is TestTank)
            {
                image = (tank as TestTank).LoadedImage;
            }
            else
            {
                var installation = tank.Context.Installation;
                var config       = tank.Context.VersionConfig;
                var guiPackage   = config.GuiPackageName.Split(' ', ',', ';');
                image = ImageCache.GetImage(new CompositePath(tank.Context, installation.Path, config.PathDestination, tank.TankId + config.TankIconExtension));
                foreach (string items in guiPackage)
                {
                    image = image ?? ImageCache.GetImage(new CompositePath(tank.Context, installation.Path, config.PathSourceContour.Replace("\"GuiPackage\"", items), tank.TankId + config.TankIconExtension));
                    if (image != null)
                    {
                        break;
                    }
                }
            }

            if (image == null)
            {
                tank.AddWarning(App.Translation.CurrentImageLayer.MissingImageWarning);
                return(null);
            }
            return(image);
        }
Пример #4
0
        public override BitmapBase Draw(Tank tank)
        {
            BitmapBase image;
            if (tank is TestTank)
            {
                image = (tank as TestTank).LoadedImage;
            }
            else
            {
                var installation = tank.Context.Installation;
                var config = tank.Context.VersionConfig;
                image = ImageCache.GetImage(new CompositePath(tank.Context, installation.Path, config.PathDestination, tank.TankId + config.TankIconExtension))
                    ?? ImageCache.GetImage(new CompositePath(tank.Context, installation.Path, config.PathSourceContour, tank.TankId + config.TankIconExtension));
            }

            if (image == null)
            {
                tank.AddWarning(App.Translation.CurrentImageLayer.MissingImageWarning);
                return null;
            }
            return image;
        }
Пример #5
0
        public override BitmapBase Draw(Tank tank)
        {
            BitmapBase image;
            if (tank is TestTank)
            {
                image = (tank as TestTank).LoadedImage;
            }
            else
            {
                var installation = tank.Context.Installation;
                var config = tank.Context.VersionConfig;
                switch (Style)
                {
                    case ImageBuiltInStyle.Contour:
                        image = ImageCache.GetImage(new CompositePath(tank.Context, installation.Path, config.PathSourceContour, tank.TankId + config.TankIconExtension));
                        break;
                    case ImageBuiltInStyle.ThreeD:
                        image = ImageCache.GetImage(new CompositePath(tank.Context, installation.Path, config.PathSource3D, tank.TankId + config.TankIconExtension));
                        break;
                    case ImageBuiltInStyle.ThreeDLarge:
                        image = ImageCache.GetImage(new CompositePath(tank.Context, installation.Path, config.PathSource3DLarge, tank.TankId + config.TankIconExtension));
                        break;
                    case ImageBuiltInStyle.Country:
                        if (tank.Country == Country.None)
                            return null;
                        image = ImageCache.GetImage(new CompositePath(tank.Context, installation.Path, config.PathSourceCountry[tank.Country]));
                        break;
                    case ImageBuiltInStyle.Class:
                        if (tank.Class == Class.None)
                            return null;
                        image = ImageCache.GetImage(new CompositePath(tank.Context, installation.Path, config.PathSourceClass[tank.Class]));
                        break;
                    default:
                        throw new Exception("9174876");
                }
            }

            if (image == null)
            {
                tank.AddWarning(App.Translation.TankImageLayer.MissingImageWarning);
                return null;
            }
            return image;
        }
Пример #6
0
        public override BitmapBase Draw(Tank tank)
        {
            var filename = (Pattern ?? "")
                .Replace("{tier}", tank.Tier.ToString())
                .Replace("{country}", tank.Country.ToString().ToLower())
                .Replace("{class}", tank.Class.ToString().ToLower())
                .Replace("{category}", tank.Category.ToString().ToLower())
                .Replace("{id}", tank.TankId);
            filename = Regex.Replace(filename, @"{([^}]+)}", match => tank[match.Groups[1].Value] ?? "");
            if (string.IsNullOrWhiteSpace(filename))
                return null;

            var image = ImageCache.GetImage(new CompositePath(tank.Context, PathUtil.AppPath, filename));
            if (image == null)
            {
                image = ImageCache.GetImage(new CompositePath(tank.Context, tank.Context.Installation.Path, tank.Context.VersionConfig.PathMods, filename));
                if (image == null)
                    image = ImageCache.GetImage(new CompositePath(tank.Context, tank.Context.Installation.Path, filename));
            }
            if (image == null)
            {
                tank.AddWarning(App.Translation.FilenamePatternImageLayer.MissingImageWarning.Fmt(filename));
                return null;
            }
            return image;
        }
Пример #7
0
        public override BitmapBase Draw(Tank tank)
        {
            var filename = ImageFile.GetValue(tank);
            if (string.IsNullOrWhiteSpace(filename))
                return null;

            var image = ImageCache.GetImage(new CompositePath(tank.Context, PathUtil.AppPath, filename));
            if (image == null)
            {
                image = ImageCache.GetImage(new CompositePath(tank.Context, tank.Context.Installation.Path, tank.Context.VersionConfig.PathMods, filename));
                if (image == null)
                    image = ImageCache.GetImage(new CompositePath(tank.Context, tank.Context.Installation.Path, filename));
            }
            if (image == null)
            {
                tank.AddWarning(App.Translation.CustomImageLayer.MissingImageWarning.Fmt(filename));
                return null;
            }
            return image;
        }
Пример #8
0
        public override BitmapBase Draw(Tank tank)
        {
            BitmapBase image;

            if (tank is TestTank)
            {
                image = (tank as TestTank).LoadedImage;
            }
            else
            {
                var installation = tank.Context.Installation;
                var config       = tank.Context.VersionConfig;
                var guiPackage   = config.GuiPackageName.Split(' ', ',', ';');
                switch (Style)
                {
                case ImageBuiltInStyle.Contour:
                    image = null;
                    foreach (string items in guiPackage)
                    {
                        image = ImageCache.GetImage(new CompositePath(tank.Context, installation.Path, config.PathSourceContour.Replace("\"GuiPackage\"", items), tank.TankId + config.TankIconExtension));
                        if (image != null)
                        {
                            break;
                        }
                    }
                    break;

                case ImageBuiltInStyle.ThreeD:
                    image = null;
                    foreach (string items in guiPackage)
                    {
                        image = ImageCache.GetImage(new CompositePath(tank.Context, installation.Path, config.PathSource3D.Replace("\"GuiPackage\"", items), tank.TankId + config.TankIconExtension));
                        if (image != null)
                        {
                            break;
                        }
                    }
                    break;

                case ImageBuiltInStyle.ThreeDLarge:
                    image = null;
                    foreach (string items in guiPackage)
                    {
                        image = ImageCache.GetImage(new CompositePath(tank.Context, installation.Path, config.PathSource3DLarge.Replace("\"GuiPackage\"", items), tank.TankId + config.TankIconExtension));
                        if (image != null)
                        {
                            break;
                        }
                    }
                    break;

                case ImageBuiltInStyle.Country:
                    if (tank.Country == Country.None)
                    {
                        return(null);
                    }
                    image = null;
                    foreach (string items in guiPackage)
                    {
                        image = ImageCache.GetImage(new CompositePath(tank.Context, installation.Path, config.PathSourceCountry[tank.Country].Replace("\"GuiPackage\"", items)));
                        if (image != null)
                        {
                            break;
                        }
                    }
                    break;

                case ImageBuiltInStyle.Class:
                    if (tank.Class == Class.None)
                    {
                        return(null);
                    }
                    image = null;
                    foreach (string items in guiPackage)
                    {
                        image = ImageCache.GetImage(new CompositePath(tank.Context, installation.Path, config.PathSourceClass[tank.Class].Replace("\"GuiPackage\"", items)));
                        if (image != null)
                        {
                            break;
                        }
                    }
                    break;

                default:
                    throw new Exception("9174876");
                }
            }

            if (image == null)
            {
                if (tank.TankId != "unknown")
                {
                    tank.AddWarning(App.Translation.TankImageLayer.MissingImageWarning);
                }
                return(null);
            }
            return(image);
        }