Пример #1
0
        private void BtnMapBrowse_Click(object sender, RoutedEventArgs e)
        {
            var filepath = string.Empty;

            VistaOpenFileDialog dialog = new VistaOpenFileDialog();

            dialog.Title = "Select a folder";

            if ((bool)dialog.ShowDialog())
            {
                filepath = dialog.FileName;
            }

            if (!string.IsNullOrEmpty(filepath))
            {
                CardArtDb.Read(filepath);
                _fileList.UpdateBars();
                LoadFile(_fileList.Current);
                LblMapFile.Content = filepath;
                _mapFile           = filepath;
            }
        }
Пример #2
0
        public static void Extract(CardArtExtractorOptions opts)
        {
            ValidateDirectories(opts.OutputDir, opts.HearthstoneDir);

            // Init set and type filters
            List <CardSet>  includeSets  = CardEnumConverter.SetIds(opts.Sets);
            List <CardType> includeTypes = CardEnumConverter.TypeIds(opts.Types);

            // Load card data from hearthstonejson
            LoadCardData(GetPatchVersion(opts.HearthstoneDir));

            // If a map file was supplied, use that instead of parsing cards files
            CardArtDefs defs = null;

            if (File.Exists(opts.MapFile))
            {
                Logger.Log(LogLevel.INFO, "using map file: {0}", opts.MapFile);
                CardArtDb.Read(opts.MapFile);
                var loadedPatch  = CardArtDb.GamePatch;
                var currentPatch = GetPatchVersion(opts.HearthstoneDir).ToString();
                if (loadedPatch != currentPatch)
                {
                    Console.WriteLine("Map file patch mismatch, attempting merge: {0} != {1}",
                                      loadedPatch, currentPatch);

                    var current = LoadCardDefs(opts.HearthstoneDir);
                    var loaded  = CardArtDb.Defs;
                    foreach (var item in current.Cards)
                    {
                        // replace any missing coords, from map defs if possible
                        if (!item.HasBarCoords() && CardArtDb.All.ContainsKey(item.Id))
                        {
                            var bar = CardArtDb.All[item.Id].GetMaterial(MaterialType.CardBar);
                            if (bar != null)
                            {
                                item.AddMaterial(
                                    bar.GetTransform(TransformType.Standard),
                                    bar.GetTransform(TransformType.Shader),
                                    MaterialType.CardBar);
                            }
                        }
                    }
                    defs = current;
                }
                else
                {
                    defs = CardArtDb.Defs;
                }
            }
            else
            {
                // map file not found, using default method
                Logger.Log(LogLevel.WARN, "map file not found: {0}", opts.MapFile);
                defs = LoadCardDefs(opts.HearthstoneDir);
            }

            // Create the list of cards we want to output
            List <ArtCard> filteredCards = null;

            if (opts.NoFiltering)
            {
                // don't use default filter, or option filters, just return all
                filteredCards = defs.Cards.Where(x => CardDb.All.ContainsKey(x.Id)).ToList();
            }
            else if (includeSets.Count > 0 || includeTypes.Count > 0)
            {
                // filter db list using options
                var filteredDb = CardDb.FilterBy(includeSets, includeTypes);
                // filter art card defs by only including those in filteredDb
                filteredCards = defs.Cards.Where(x => filteredDb.ContainsKey(x.Id)).ToList();
            }
            else
            {
                // filter art card defs by only including those that are in the default filtered db
                filteredCards = defs.Cards.Where(x => CardDb.Filtered.ContainsKey(x.Id)).ToList();
            }
            Logger.Log("Filtered art cards: " + filteredCards.Count);

            // get all textures (cardtextures<n>.unity3d)
            var textureFiles = new List <string>(Directory.GetFiles(_hsDataPath, "cardtextures?.unity3d"));
            // First pass over texture bundles, collect texture path data
            var textureRefs = LoadTextureInfo(textureFiles);

            // Add shared bundles to texture list (shared<n>.unity3d)
            textureFiles.AddRange(Directory.GetFiles(_hsDataPath, "shared?.unity3d"));
            // Extract all the texture files using the refs and required cards
            var tb        = new TexturesBundle(textureFiles, opts);
            var bundleMap = tb.Extract(textureRefs, filteredCards);

            // Update the cardartdb with found bundle names, and save
            if (opts.SaveMapFile)
            {
                UpdateAndSaveCardArtDefs(bundleMap, defs, opts.OutputDir);
            }
        }
Пример #3
0
 public static void ClassInitialize(TestContext testContext)
 {
     CardArtDb.Read(@"Data\cardartdefs.xml");
     _db      = CardArtDb.All;
     _tempXml = @"Data\writetest.xml";
 }