public static ContentConfiguration Load(FontConfigFile localization, string patternsFile,
                                                string mapFile, string InputPattern, string outputPattern)
        {
            var converter = new InibinConverter(ConversionMap.Load(mapFile));
            var patterns  = LoadPatterns(patternsFile);

            return(new ContentConfiguration(localization, converter, patterns,
                                            new Regex(InputPattern, RegexOptions.IgnoreCase), outputPattern));
        }
 public ContentConfiguration(FontConfigFile localization, InibinConverter converter,
                             List <Regex> patterns, Regex inputPattern, string outputPattern)
 {
     Localization     = localization;
     Converter        = converter;
     ResourcePatterns = patterns;
     InputPattern     = inputPattern;
     OutputPattern    = outputPattern;
 }
        public static ContentFile FromInibin(Inibin source, InibinConverter converter)
        {
            var result = new ContentFile();

            result.Values               = result.Values = converter.Convert(source);
            result.Id                   = 0;
            result.Name                 = "";
            result.ResourcePath         = source.FilePath;
            result.ContentFormatVersion = 4;
            return(result);
        }
        public void ExportData(string directory)
        {
            Directory.CreateDirectory(directory);
            var converter = new InibinConverter(ConversionMap.FromHashCollection(_draft));

            foreach (var file in _files)
            {
                var inibin  = _manager.ReadInibin(file.FullName);
                var item    = ContentFile.FromInibin(inibin, converter);
                var orgPath = Path.GetDirectoryName(file.FullName);
                var orgName = Path.GetFileNameWithoutExtension(file.FullName);
                Directory.CreateDirectory(directory + "/" + orgPath);
                var savePath = directory + "/" + orgPath + "/" + orgName + ".json";
                File.WriteAllText(savePath, item.Serialize());
            }
        }
Beispiel #5
0
        static void ExportData(ArchiveFileManager manager, InibinConverter converter)
        {
            var itemFiles = manager.GetFileEntriesFrom("DATA/Items", true);

            foreach (var entry in itemFiles)
            {
                var saveDirectory = Path.GetDirectoryName(string.Format("Content/{0}", entry.FullName));
                if (!Directory.Exists(saveDirectory))
                {
                    Directory.CreateDirectory(saveDirectory);
                }
                var compressedFile = manager.ReadFile(entry.FullName, true);
                if (compressedFile == null)
                {
                    continue;
                }
                var file = compressedFile.Uncompress();

                if (entry.FullName.Contains(".inibin") || entry.FullName.Contains(".troybin"))
                {
                    var inibin = Inibin.DeserializeInibin(file, entry.FullName);
                    foreach (var kvp in inibin.Content)
                    {
                        converter.AddByHash(kvp.Key, kvp.Value);
                    }
                    var itemContent     = converter.Deserialize();
                    var itemContentJson = JsonConvert.SerializeObject(itemContent, Formatting.Indented);

                    var savePath = string.Format("Content/{0}", entry.FullName.Replace(".inibin", ".json"));
                    if (entry.FullName.Contains(".troybin"))
                    {
                        savePath = string.Format("Content/{0}", entry.FullName.Replace(".troybin", ".troybin.json"));
                    }

                    File.WriteAllText(savePath, itemContentJson);
                    converter.Clear();
                }
                else
                {
                    var savePath = string.Format("Content/{0}", entry.FullName);
                    File.WriteAllBytes(savePath, file);
                }
            }
        }