Esempio n. 1
0
 public void FormLoaded()
 {
     if (!Directory.Exists(ModelsFolder))
     {
         Directory.CreateDirectory(ModelsFolder);
     }
     if (!File.Exists($"{GameFolder}Data/Objflow.byaml"))
     {
         MessageBox.Show($"Can't open {GameFolder}Data/Objflow.byaml models and object names won't be shown");
     }
     else
     {
         ObjIDNameList.Clear();
         var byml = ByamlFile.LoadN($"{GameFolder}Data/Objflow.byaml", true).RootNode;
         foreach (var item in byml)
         {
             int           ID    = item["ObjId"];
             List <string> files = ((IList <object>)item["ResName"]).Cast <string>().ToList();
             if (/*files.Count > 1 || */ files.Count == 0)
             {
                 Debugger.Break();
             }
             ObjIDNameList.Add(ID, files[0]);
         }
         byml = null;
         GC.Collect();
     }
 }
Esempio n. 2
0
        public StageList(string input)
        {
            Filename = input;

            BymlFileData Input;
            SarcData     Data = SARC.UnpackRamN(YAZ0.Decompress(input));

            if (Data.Files.ContainsKey("StageList.byml"))
            {
                Input = ByamlFile.LoadN(new MemoryStream(Data.Files["StageList.byml"]), true, ByteOrder.BigEndian);
            }
            else
            {
                throw new Exception("Failed to find the StageList");
            }

            List <dynamic> temp = Input.RootNode["WorldList"];

            for (int i = 0; i < temp.Count; i++)
            {
                Worlds.Add(new World(temp[i]));
            }

            //File.WriteAllBytes("Original.byml",Data.Files["StageList.byml"]);
        }
Esempio n. 3
0
        public void LoadObjList()
        {
            if (PluginRuntime.Mk8GamePath == "")
            {
                FolderSelectDialog dlg = new FolderSelectDialog();

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    PluginRuntime.Mk8GamePath = dlg.SelectedPath;
                }
            }

            var byml = ByamlFile.LoadN($"{PluginRuntime.Mk8GamePath}/Data/Objflow.byaml", true).RootNode;

            foreach (var item in byml)
            {
                int           ID    = item["ObjId"];
                List <string> files = ((IList <object>)item["ResName"]).Cast <string>().ToList();
                ObjIDNameList.Add(ID, files[0]);

                Console.WriteLine(ID + " " + files[0]);
            }
            byml = null;
            GC.Collect();
        }
Esempio n. 4
0
        public static bool TryOpen(string filename, out StageList stageList)
        {
            stageList = null;

            SarcData sarc = SARC.UnpackRamN(YAZ0.Decompress(filename));

            BymlFileData byml;

            if (sarc.Files.ContainsKey("StageList.byml"))
            {
                byml = ByamlFile.LoadN(new MemoryStream(sarc.Files["StageList.byml"]), true, ByteOrder.BigEndian);
            }
            else
            {
                throw new Exception("Failed to find the StageList");
            }


            if (!byml.RootNode.TryGetValue("WorldList", out dynamic worldList))
            {
                return(false);
            }


            List <World> worlds = new List <World>();

            for (int i = 0; i < worldList.Count; i++)
            {
                worlds.Add(new World(worldList[i]));
            }

            stageList = new StageList(filename, worlds, byml.byteOrder);

            return(true);
        }
Esempio n. 5
0
        void LoadObjects(int scenarioIndex = -1)
        {
            Stream s = new MemoryStream(SzsFiles[Path.GetFileNameWithoutExtension(Filename) + ".byml"]);

            LoadedByml = ByamlFile.LoadN(s, false, Syroot.BinaryData.ByteOrder.LittleEndian).RootNode;

            if (scenarioIndex == -1)
            {
                string res = "0";
                InputDialog.Show("Select scenario", $"enter scenario value [0,{LoadedByml.Count- 1}]", ref res);
                if (!int.TryParse(res, out scenarioIndex))
                {
                    scenarioIndex = 0;
                }
            }

            _ScenarioIndex = scenarioIndex;
            var Scenario = (Dictionary <string, dynamic>)LoadedByml[scenarioIndex];

            if (Scenario.Keys.Count == 0)
            {
                Scenario.Add("ObjectList", new List <dynamic>());
            }
            foreach (string k in Scenario.Keys)
            {
                objs.Add(k, new ObjList(k, Scenario[k]));
            }
        }
        /// <summary>
        /// Loads part data from the given suffix and model name.
        /// This will attach the part to a joint of the current actor model and add to the PartActors list.
        /// </summary>
        public void LoadPart(string suffix, string modelName)
        {
            string path = $"{GlobalSettings.GamePath}\\ObjectData\\{modelName}.szs";

            if (!File.Exists(path))
            {
                Console.WriteLine($"Failed to find part at path {path}!");
                return;
            }

            //Init parameter data
            var partParams = Files[$"InitPartsFixInfo{suffix}.byml"];
            var partModel  = new PartsModel(ByamlFile.LoadN(partParams.FileData).RootNode);

            var actor = new ActorBase();

            actor.LoadActor(path);
            PartActors.Add(modelName, actor);

            if (actor.ModelFile == null)
            {
                Console.WriteLine($"Failed to find model for {modelName}!");
                return;
            }
            //Parts attach to joints of the current model from the part model
            AttachJoint(partModel, actor.ModelFile);
        }
Esempio n. 7
0
        public static void OpenByml(Stream file, BYAML byaml, string FileName, bool?paths, Stream saveStream, bool AsDialog)
        {
            bool _paths = paths == null?SupportPaths() : paths.Value;

            var byml = ByamlFile.LoadN(file, _paths);

            OpenByml(byml, byaml, saveStream, AsDialog);
        }
Esempio n. 8
0
        public void Load(Stream stream)
        {
            CanSave = true;

            IsDialog = IFileInfo != null && IFileInfo.InArchive;

            data = ByamlFile.LoadN(stream);
        }
Esempio n. 9
0
        private static void ParseYML(string FileName)
        {
            BymlFileData data = ByamlFile.LoadN(FileName, true);

            var serializer = new SharpYaml.Serialization.Serializer();
            var text       = serializer.Serialize(data);

            Console.WriteLine(text);
        }
Esempio n. 10
0
        public void Load(Stream stream)
        {
            CanSave = true;

            //Keep the stream open.
            //This is for the file to optionally be reloaded for different encoding types
            IsDialog = IFileInfo != null && IFileInfo.InArchive;

            BymlData = ByamlFile.LoadN(stream);
        }
Esempio n. 11
0
        /// <summary>
        /// Loads the actor from an archive file given an IArchiveFile.
        /// </summary>
        public void LoadActor(IArchiveFile fileArchive)
        {
            //Add files to a lookup for quick searching
            foreach (var file in fileArchive.Files)
            {
                Files.Add(file.FileName, file);

                //Initalize sub actor data to determine how to display part information
                if (file.FileName == "InitSubActor.byml")
                {
                    InitSubActor = new InitSubActor(ByamlFile.LoadN(file.FileData).RootNode);
                }
                if (file.FileName == "InitModel.byml")
                {
                    InitModel = new InitModel(ByamlFile.LoadN(file.FileData).RootNode);
                }
                if (file.FileName.EndsWith(".bfres")) //Note there should only be one model file
                {
                    ModelFile = file.OpenFile() as IRenderableFile;
                }
            }
        }
Esempio n. 12
0
        public void ReloadEncoding(Encoding encoding)
        {
            BymlFileData.Encoding = encoding;

            //Reopen and reload the byml data
            if (IFileInfo.ArchiveParent != null)
            {
                foreach (var file in IFileInfo.ArchiveParent.Files)
                {
                    var name = Path.GetFileName(file.FileName);
                    if (name == FileName)
                    {
                        BymlData = ByamlFile.LoadN(new MemoryStream(file.FileData));
                    }
                }
            }
            else if (File.Exists(FilePath))
            {
                var file = File.OpenRead(FilePath);
                BymlData = ByamlFile.LoadN(file);
                file.Close();
            }
        }
Esempio n. 13
0
 public static BymlFileData GetByml(this Stream stream)
 {
     return(ByamlFile.LoadN(stream));
 }
Esempio n. 14
0
 public static BymlFileData GetBymlFileData(this FileInfo file)
 {
     return(ByamlFile.LoadN(file.FullName));
 }
Esempio n. 15
0
 public static Task <BymlFileData> GetBymlAsync(this Stream stream)
 {
     return(Task.Run(() => ByamlFile.LoadN(stream)));
 }