Exemple #1
0
 public VMIEditor(VMSFile data)
 {
     vmi = new VMIFile(data, "SADV_" + data.Identifier.ToString("D3"));
     vms = data;
     InitializeComponent();
     comboBoxWeekday.SelectedIndex = 0;
 }
Exemple #2
0
 public ObjectEditor(VMSFile meta, PuyoFile pvm)
 {
     editorMeta = meta;
     puyo       = pvm;
     InitializeComponent();
     InitializeMetadata();
 }
Exemple #3
0
 private void newToolStripMenuItem_Click(object sender, EventArgs e)
 {
     meta       = new VMSFile();
     meta.Icon  = new Bitmap(32, 32);
     metaBackup = new VMSFile(meta);
     UpdateGeneralInfo();
     UpdateMessage();
     UpdateModel();
     UpdateTextures();
     UpdateSound();
     UpdateSize();
 }
Exemple #4
0
        private void buttonEditObjects_Click(object sender, EventArgs e)
        {
            VMSFile      original = new VMSFile(meta);
            ObjectEditor obje     = new ObjectEditor(meta, puyo);
            DialogResult result   = obje.ShowDialog(this);

            switch (result)
            {
            case DialogResult.Yes:
                meta = obje.editorMeta;
                break;

            default:
                meta = new VMSFile(original);
                break;
            }
        }
Exemple #5
0
 private void importToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (OpenFileDialog op = new OpenFileDialog()
     {
         FileName = Path.ChangeExtension(Path.GetFileName(currentFilename), "ini"), Title = "Import an INI File", Filter = "INI Files|*.ini|All Files|*.*", DefaultExt = "ini"
     })
     {
         if (op.ShowDialog() == DialogResult.OK)
         {
             meta = VMSFile.LoadFile(op.FileName);
             // Add data for empty strings
             List <string> StringsJ = new List <string>(16);
             List <string> StringsE = new List <string>(16);
             List <string> StringsF = new List <string>(16);
             List <string> StringsG = new List <string>(16);
             List <string> StringsS = new List <string>(16);
             for (int i = 0; i < meta.JapaneseStrings.Length; i++)
             {
                 StringsJ.Add(meta.JapaneseStrings[i]);
                 StringsE.Add(meta.EnglishStrings[i]);
                 StringsF.Add(meta.FrenchStrings[i]);
                 StringsG.Add(meta.GermanStrings[i]);
                 StringsS.Add(meta.SpanishStrings[i]);
             }
             if (StringsJ.Count < 16)
             {
                 do
                 {
                     StringsJ.Add("");
                     StringsE.Add("");
                     StringsF.Add("");
                     StringsG.Add("");
                     StringsS.Add("");
                 }while (StringsJ.Count < 16);
             }
             meta.JapaneseStrings = StringsJ.ToArray();
             meta.EnglishStrings  = StringsE.ToArray();
             meta.FrenchStrings   = StringsF.ToArray();
             meta.GermanStrings   = StringsG.ToArray();
             meta.SpanishStrings  = StringsS.ToArray();
             // Add data for empty sections
             if (meta.TextureData == null)
             {
                 meta.TextureData = new byte[0];
             }
             if (meta.SoundData == null)
             {
                 meta.SoundData = new byte[0];
             }
             if (meta.ModelData == null)
             {
                 meta.ModelData = new byte[0];
             }
             UpdateGeneralInfo();
             UpdateMessage();
             UpdateModel();
             UpdateTextures();
             UpdateSound();
             UpdateSize();
             currentFilename = toolStripStatusFile.Text = Path.ChangeExtension(Path.GetFileName(op.FileName), ".VMS");
             currentFullPath = Path.ChangeExtension(op.FileName, ".VMS");
         }
     }
 }
Exemple #6
0
        public void LoadVMSFile(string filename)
        {
            byte[] file = File.ReadAllBytes(filename);
            // Get metadata and icon
            meta       = new VMSFile(file);
            metaBackup = new VMSFile(meta);
            meta.Icon  = GetIconFromFile(file);
            // Get PVM pointer
            uint pvm_pointer = BitConverter.ToUInt32(file, 0x290);
            int  pvm_value   = BitConverter.ToInt32(file, 0x294);
            int  pvm_count   = BitConverter.ToInt32(file, 0x298);

            if (pvm_value != 0)
            {
                Console.WriteLine("PVM at {0}, number of textures {1}", pvm_pointer.ToString("X"), pvm_count);
            }
            checkBoxEnableTextures.Checked = pvm_value != 0;
            // Get MLT pointer
            uint mlt_pointer = BitConverter.ToUInt32(file, 0x29C);
            int  mlt_value   = BitConverter.ToInt32(file, 0x2A0);

            if (mlt_value != 0)
            {
                Console.WriteLine("MLT at {0}", mlt_pointer.ToString("X"));
            }
            // Get PRS pointer
            uint prs_pointer = BitConverter.ToUInt32(file, 0x2A4);
            int  prs_value   = BitConverter.ToInt32(file, 0x2A8);

            if (prs_value != 0)
            {
                Console.WriteLine("PRS at {0}", prs_pointer.ToString("X"));
            }
            // Checksum
            uint crc = CalculateChecksum(ref file, 0x2C0, file.Length);

            Console.WriteLine("Checksum file / calculated: {0} ({1}) / {2} ({3})", BitConverter.ToInt32(file, 0x2AC).ToString("X"), BitConverter.ToInt32(file, 0x2AC), crc.ToString("X"), (int)crc);
            // Retrieve sections
            // Get PVM
            int pvm_size = (int)mlt_pointer - (int)pvm_pointer;

            if (pvm_size > 0 && pvm_size + pvm_pointer <= file.Length)
            {
                meta.TextureData = new byte[pvm_size];
                Array.Copy(file, pvm_pointer, meta.TextureData, 0, pvm_size);
                UpdateTextures();
            }
            // Get MLT
            int mlt_size = (int)prs_pointer - (int)mlt_pointer;

            if (mlt_size > 0 && mlt_pointer + mlt_size <= file.Length)
            {
                buttonLoadMLT.Enabled = buttonSaveMLT.Enabled = checkBoxEnableSound.Checked = true;
                meta.SoundData        = new byte[mlt_size];
                Array.Copy(file, mlt_pointer, meta.SoundData, 0, mlt_size);
                //File.WriteAllBytes(Path.Combine(dir, fname + ".mlt"), mltdata);
                labelSoundSectionSize.Text = "Section size: " + meta.SoundData.Length.ToString() + " bytes";
            }
            uint sectionsize = BitConverter.ToUInt32(file, 0x48);
            int  text_count  = BitConverter.ToInt32(file, 0x28C);
            int  item_count  = BitConverter.ToInt32(file, 0x284);
            int  item_size   = (item_count * 30 + 12); // 12-byte header

            do
            {
                item_size++;
            }while (item_size % 16 != 0);
            int prs_size = 0;

            if (prs_value != 0)
            {
                prs_size = file.Length - (int)prs_pointer;
            }
            Console.WriteLine("Headerless size {0}, item size {1}, text size {2}, PVM size {3}, MLT size {4}, PRS size {5}", sectionsize, item_size, text_count * 64, pvm_size, mlt_size, prs_size);
            // Get Model
            if (prs_size > 0 && prs_pointer + prs_size <= file.Length)
            {
                byte[] prsdata = new byte[prs_size];
                //Console.WriteLine("Copy from array of size {0} from {1} to array size {2}", file.Length, prs_pointer, prsdata.Length);
                Array.Copy(file, prs_pointer, prsdata, 0, prs_size);
                prsdata = FraGag.Compression.Prs.Decompress(prsdata);
                // Model pointer
                uint modelpointer = BitConverter.ToUInt32(prsdata, 0) - 0xCCA4000;
                //Console.WriteLine("Model pointer: {0}", modelpointer.ToString("X"));
                labelModelSectionSize.Text = "Section size: " + prsdata.Length.ToString() + " bytes";
                try
                {
                    NJS_OBJECT mdl = new NJS_OBJECT(prsdata, (int)modelpointer, 0xCCA4000, ModelFormat.Basic, null);
                    labelModelInfo.Text = GetModelInfo(mdl);
                }
                catch (Exception)
                {
                    labelModelInfo.Text = "Error getting model information.";
                }
                checkBoxEnableModel.Checked = true;
            }
            UpdateGeneralInfo();
            currentFilename = toolStripStatusFile.Text = Path.GetFileName(filename);
            currentFullPath = filename;
            saveToolStripMenuItem.Enabled = true;
            // Add data for empty strings
            for (int i = 0; i < 16; i++)
            {
                if (meta.JapaneseStrings[i] == null)
                {
                    meta.JapaneseStrings[i] = "";
                }
                if (meta.EnglishStrings[i] == null)
                {
                    meta.EnglishStrings[i] = "";
                }
                if (meta.FrenchStrings[i] == null)
                {
                    meta.FrenchStrings[i] = "";
                }
                if (meta.GermanStrings[i] == null)
                {
                    meta.GermanStrings[i] = "";
                }
                if (meta.SpanishStrings[i] == null)
                {
                    meta.SpanishStrings[i] = "";
                }
            }
            UpdateMessage();
            UpdateSize();
        }