Beispiel #1
0
        public PARAMDEF GetParamdefForParam(string paramType)
        {
            PARAMDEF pd = PARAMDEF.XmlDeserialize($@"{GetParamdefDir()}\{paramType}.xml");

            MsbEditor.ParamMetaData meta = MsbEditor.ParamMetaData.XmlDeserialize($@"{GetParammetaDir()}\{paramType}.xml", pd);
            return(pd);
        }
Beispiel #2
0
        private static void LoadParamdefs()
        {
            _paramdefs = new Dictionary <string, PARAMDEF>();
            var dir   = AssetLocator.GetParamdefDir();
            var files = Directory.GetFiles(dir, "*.xml");

            foreach (var f in files)
            {
                var pdef = PARAMDEF.XmlDeserialize(f);
                _paramdefs.Add(pdef.ParamType, pdef);
            }
        }
Beispiel #3
0
        public static void Run(Game game, FileInfo paramdexPath, Regex typeFilter)
        {
            var paramdefPaths = Directory.GetFiles($"{paramdexPath.FullName}/{game}/Defs", "*.xml");

            foreach (var paramdefPath in paramdefPaths)
            {
                var paramdef = PARAMDEF.XmlDeserialize(paramdefPath);
                if (!typeFilter.IsMatch(paramdef.ParamType))
                {
                    continue;
                }

                Console.WriteLine($"struct {paramdef.ParamType} {{");

                foreach (var field in paramdef.Fields)
                {
                    var ctype = field.DisplayType switch
                    {
                        PARAMDEF.DefType _ when field.BitSize == 1 => "bool",
                             PARAMDEF.DefType.s8 => "char",
                             PARAMDEF.DefType.u8 => "unsigned char",
                             PARAMDEF.DefType.s16 => "short",
                             PARAMDEF.DefType.u16 => "unsigned short",
                             PARAMDEF.DefType.s32 => "int",
                             PARAMDEF.DefType.u32 => "unsigned int",
                             PARAMDEF.DefType.f32 => "float",
                             PARAMDEF.DefType.dummy8 => "char",
                             PARAMDEF.DefType.fixstr => "char*",
                             PARAMDEF.DefType.fixstrW => "wchar_t*",
                             _ => throw new ArgumentOutOfRangeException()
                    };

                    Console.Write($"    {ctype} {field.DisplayName}");

                    if (field.BitSize != -1 && field.BitSize % 8 != 0)
                    {
                        Console.Write($" : {field.BitSize}");
                    }
                    else if (field.ArrayLength > 1)
                    {
                        Console.Write($"[{field.ArrayLength}]");
                    }

                    Console.WriteLine(";");
                }

                Console.WriteLine("};");
            }
        }
    }
Beispiel #4
0
        private static List <(string, PARAMDEF)> LoadParamdefs()
        {
            _paramdefs = new Dictionary <string, PARAMDEF>();
            var dir   = AssetLocator.GetParamdefDir();
            var files = Directory.GetFiles(dir, "*.xml");
            List <(string, PARAMDEF)> defPairs = new List <(string, PARAMDEF)>();

            foreach (var f in files)
            {
                var pdef = PARAMDEF.XmlDeserialize(f);
                _paramdefs.Add(pdef.ParamType, pdef);
                defPairs.Add((f, pdef));
            }
            return(defPairs);
        }
Beispiel #5
0
        private static void LoadParamdefs()
        {
            _paramdefs = new Dictionary <string, PARAMDEF>();
            var dir   = AssetLocator.GetParamdefDir();
            var files = Directory.GetFiles(dir, "*.xml");
            var mdir  = AssetLocator.GetParammetaDir();

            foreach (var f in files)
            {
                var pdef  = PARAMDEF.XmlDeserialize(f);
                var fName = f.Substring(f.LastIndexOf('\\') + 1);
                ParamMetaData.XmlDeserialize($@"{mdir}\{fName}", pdef);
                _paramdefs.Add(pdef.ParamType, pdef);
            }
        }
Beispiel #6
0
        public PARAMDEF GetParamdefForParam(string paramType)
        {
            string game;

            switch (Type)
            {
            case GameType.DemonsSouls:
                game = "DES";
                break;

            case GameType.DarkSoulsPTDE:
                game = "DS1";
                break;

            case GameType.DarkSoulsRemastered:
                game = "DS1R";
                break;

            case GameType.DarkSoulsIISOTFS:
                game = "DS2S";
                break;

            case GameType.Bloodborne:
                game = "BB";
                break;

            case GameType.DarkSoulsIII:
                game = "DS3";
                break;

            case GameType.Sekiro:
                game = "SDT";
                break;

            default:
                throw new Exception("Game type not set");
            }

            return(PARAMDEF.XmlDeserialize($@"Assets\Paramdex\{game}\Defs\{paramType}.xml"));
        }
        public static void Run(
            Game game,
            ParamFormat inputFormat,
            FileInfo inputPath,
            ParamFormat outputFormat,
            FileInfo outputPath,
            FileInfo paramdexPath,
            Regex typeFilter)
        {
            using var reader = inputFormat.CreateReader(game, inputPath);
            using var writer = outputFormat.CreateWriter(game, outputPath);

            foreach (var paramRef in reader.List())
            {
                var paramName = paramRef.Name;
                var paramType = paramRef.Type;

                if (!typeFilter.IsMatch(paramName) && !typeFilter.IsMatch(paramType))
                {
                    continue;
                }

                Console.WriteLine($"Reading {paramName} with type {paramType}");

                var paramDefPath = $"{paramdexPath.FullName}/{game}/Defs/{paramType}.xml";
                if (!File.Exists(paramDefPath))
                {
                    Console.WriteLine($"No paramdef for {paramName}, {paramType}. Skipping.");
                    continue;
                }

                var paramDef = PARAMDEF.XmlDeserialize(paramDefPath);
                var param    = reader.Read(paramName, paramDef);

                /* the same names.txt parsing code from yapped */
                var paramRowNames = new Dictionary <long, string>();

                var paramNamesPath = $@"{paramdexPath.FullName}/{game}/Names/{paramName}.txt";
                if (File.Exists(paramNamesPath))
                {
                    var paramNamesText = File.ReadAllText(paramNamesPath);

                    foreach (var line in Regex.Split(paramNamesText, @"\s*[\r\n]+\s*"))
                    {
                        if (line.Length <= 0)
                        {
                            continue;
                        }
                        var match = Regex.Match(line, @"^(\d+) (.+)$");
                        var id    = long.Parse(match.Groups[1].Value);
                        var name  = match.Groups[2].Value;

                        paramRowNames[id] = name;
                    }
                }

                foreach (var row in param.Rows.Where(row => paramRowNames.ContainsKey(row.ID)))
                {
                    row.Name = paramRowNames[row.ID];
                }

                writer.Write(paramName, param);
            }
        }