예제 #1
0
        private bool LoadModelWithBase(string basePath, string modelName)
        {
            // Attempt to load the bfres that contains the model
            string modelPath = "Models\\" + modelName + ".bfres";

            if (File.Exists(modelPath))
            {
                // Load the bfres
                LoadBfres(modelPath);
                return(true);
            }

            // Check if the szs archive that contains the bfres exists
            string szsPath = basePath + modelName + ".szs";

            if (File.Exists(szsPath))
            {
                // Decompress the szs into a sarc archive
                string sarcPath      = basePath + modelName;
                SARC   sarc          = new SARC();
                var    unpackedmodel = sarc.unpackRam(YAZ0.Decompress(szsPath));
                if (!unpackedmodel.ContainsKey(modelName + ".bfres"))
                {
                    return(false);
                }

                File.WriteAllBytes(modelPath, unpackedmodel[modelName + ".bfres"]);
                // Load the bfres
                LoadBfres(modelPath);

                return(true);
            }

            return(false);
        }
예제 #2
0
        private void bymlViewerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog opn = new OpenFileDialog();

            opn.InitialDirectory = BASEPATH + "StageData";
            opn.Filter           = "byml files, szs files |*.byml;*.szs";
            if (opn.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            dynamic byml = null;

            if (opn.FileName.EndsWith("byml"))
            {
                byml = ByamlFile.Load(opn.FileName);
            }
            else if (opn.FileName.EndsWith("szs"))
            {
                SARC   sarc         = new SARC();
                var    unpackedsarc = sarc.unpackRam(YAZ0.Decompress(opn.FileName));
                string bymlName     = Path.GetFileNameWithoutExtension(opn.FileName) + ".byml";
                if (bymlName.EndsWith("Map1.byml"))  //the szs name always ends with 1, but the map byml doesn't, this seems to be true for every level
                {
                    bymlName = bymlName.Replace("Map1.byml", "Map.byml");
                }
                else if (bymlName.EndsWith("Design1.byml"))
                {
                    bymlName = bymlName.Replace("Design1.byml", "Design.byml");
                }
                else if (bymlName.EndsWith("Sound1.byml"))
                {
                    bymlName = bymlName.Replace("Sound1.byml", "Sound.byml");
                }
                byml = ByamlFile.Load(new MemoryStream(unpackedsarc[bymlName]));
            }
            else
            {
                throw new Exception("Not supported");
            }
            if (byml is Dictionary <string, dynamic> )
            {
                new ByamlViewer(byml).Show();
            }
            else
            {
                throw new Exception("Not supported");
            }
        }
예제 #3
0
        private void testSaveLevelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (LoadedByml == null)
            {
                return;
            }
            MemoryStream mem = new MemoryStream();

            ByamlFile.Save(mem, LoadedByml);
            LoadedSarc[loadedBymlFileName] = mem.ToArray();
            SaveFileDialog s = new SaveFileDialog();

            s.Filter = "szs file|*.szs";
            if (s.ShowDialog() == DialogResult.OK)
            {
                File.WriteAllBytes(s.FileName, YAZ0.Compress(SARC.pack(LoadedSarc)));
            }
        }
예제 #4
0
        public void LoadLevel(string filename)
        {
            DisposeCurrentLevel();
            //both yaz0 decompression and sarc unpacking are done in ram, this avoids useless wirtes to disk, faster level loading
            SARC sarc = new SARC();

            LoadedSarc = sarc.unpackRam(YAZ0.Decompress(filename)); //the current level files are now stored in LoadedSarc

            loadedSarcFileName = filename;

            /*Yaz0Compression.Decompress(BASEPATH + "StageData/" + "TitleDemo00StageDesign1" + ".szs", "stageDesign.sarc");
             * sarc.unpack("stageDesign");
             * Yaz0Compression.Decompress(BASEPATH + "ObjectData/" + "TitleDemoStepA" + ".szs", "stageModel.sarc");
             * sarc.unpack("stageModel"); Not needed for now*/

            //removed stage model loading, every stage include the model name in the byml

            // parse byaml
            parseBYML(Path.GetFileNameWithoutExtension(filename) + ".byml");

            btn_openBymlView.Enabled = true;
            // force render
            glControl1.Invalidate();
        }