示例#1
0
        public static BasicAssetConfig Extract(FullAssetConfig full)
        {
            var min = new BasicAssetConfig();

            foreach (var kvp in full.Xlds)
            {
                var old    = kvp.Value;
                var newXld = new BasicXldInfo(old);

                foreach (var asset in old.Assets.Values)
                {
                    var newAsset = new BasicAssetInfo(asset)
                    {
                        Parent = newXld
                    };
                    if (newAsset.ContainsData)
                    {
                        newXld.Assets[asset.Id] = newAsset;
                    }
                }

                min.Xlds[kvp.Key] = newXld;
            }

            return(min);
        }
示例#2
0
        public static BasicAssetConfig Load(string basePath)
        {
            var configPath          = Path.Combine(basePath, "data", Filename);
            BasicAssetConfig config = new BasicAssetConfig();

            if (File.Exists(configPath))
            {
                var configText = File.ReadAllText(configPath);
                var xlds       = JsonConvert.DeserializeObject <Dictionary <string, BasicXldInfo> >(configText);

                foreach (var xld in xlds)
                {
                    xld.Value.Name = xld.Key;
                    foreach (var o in xld.Value.Assets)
                    {
                        o.Value.Parent = xld.Value;
                        o.Value.Id     = o.Key;
                    }

                    config.Xlds[xld.Key] = xld.Value;
                }
            }

            return(config);
        }
示例#3
0
        public void Save(string basePath)
        {
            foreach (var xld in Xlds)
            {
                if (xld.Value.Transposed == false)
                {
                    xld.Value.Transposed = null;
                }
                foreach (var asset in xld.Value.Assets)
                {
                    if (string.IsNullOrWhiteSpace(asset.Value.Name))
                    {
                        asset.Value.Name = null;
                    }

                    if (asset.Value.PaletteHints != null && !asset.Value.PaletteHints.Any())
                    {
                        asset.Value.PaletteHints = null;
                    }
                }
            }

            var configPath         = Path.Combine(basePath, "data", Filename);
            var serializerSettings = new JsonSerializerSettings {
                Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Ignore
            };
            var json = JsonConvert.SerializeObject(Xlds, serializerSettings);

            File.WriteAllText(configPath, json);

            var basicConfig = BasicAssetConfig.Extract(this);

            basicConfig.Save(basePath);

            foreach (var xld in Xlds)
            {
                foreach (var asset in xld.Value.Assets)
                {
                    if (asset.Value.PaletteHints == null)
                    {
                        asset.Value.PaletteHints = new List <int>();
                    }
                }
            }
        }