예제 #1
0
 public void SaveSettings(FileParser.Block block)
 {
     block.SetInt("Address X", (int)addressX, false);
     block.SetInt("Address Y", (int)addressY, false);
     block.SetIntArray("RAM Pointers", stRAMPointers);
     block.SetIntArray("ROM Pointers", stROMPointers);
 }
예제 #2
0
 public void SaveSettings(FileParser.Block block)
 {
     foreach (KeyValuePair <string, TextureImage> texture in textures)
     {
         block.SetString("Texture " + texture.Key, texture.Value.format.ToString() + ", " + texture.Value.bpp.ToString());
     }
 }
예제 #3
0
        public void SaveSettings(FileParser.Block block)
        {
            block.SetString("ROM", EmulationState.instance.ROMName);
            block.SetIntArray("Run level scripts", runLevelScripts.ToArray());
            block.SetInt("Base Offset", segmentedAddress);
            block.SetInt("Import Scale", (int)Settings.importScale);

            block.SetBlock("Globals", new FileParser.Block(globalsControl));

            block.SetBlock("Textures", new FileParser.Block(textureLibrary));

            //Write Display List data
            block.SetInt("NumDisplayLists", displayLists.Count, false);
            int i = 0;

            foreach (ReadWrite dl in displayLists)
            {
                block.SetBlock("DisplayList" + i++, new FileParser.Block(dl));
            }

            //Write Collision Map data
            block.SetInt("NumCollisionMaps", collisionMaps.Count, false);
            i = 0;
            foreach (ReadWrite dl in collisionMaps)
            {
                block.SetBlock("CollisionMap" + i++, new FileParser.Block(dl));
            }
        }
예제 #4
0
 public void LoadSettings(FileParser.Block block)
 {
     addressX      = (AddressMode)block.GetInt("Address X");
     addressY      = (AddressMode)block.GetInt("Address Y");
     stRAMPointers = block.GetIntArray("RAM Pointers", false);
     stROMPointers = block.GetIntArray("ROM Pointers", false);
 }
예제 #5
0
 public void SaveSettings(FileParser.Block block)
 {
     string[] names = Enum.GetNames(typeof(RenderStates.Parameter));
     for (int i = 0; i < names.Length; i++)
     {
         block.SetInt(names[i], globalParameters[i]);
     }
 }
예제 #6
0
        public void SaveSettings(FileParser.Block block)
        {
            block.SetBool("Use Custom Address", useCustomAddress);
            if (useCustomAddress)
            {
                block.SetInt("Custom Address", segmentOffset);
            }
            block.SetIntArray("ROM Pointers", pointerControl1.GetROMPointers());
            block.SetIntArray("RAM Pointers", pointerControl1.GetRAMPointers());

            SpecialPointer[] specialPointers = specialPointerControl1.GetPointers();
            StringBuilder    b = new StringBuilder();

            foreach (SpecialPointer p in specialPointers)
            {
                b.Append(p.ToString() + "; ");
            }
            if (b.Length > 0)
            {
                block.SetString("Special Pointers", b.ToString());
            }

            block.SetString("Obj File", sourceFileName);
            block.SetInt("Type Style", cmbTypeStyle.SelectedIndex, false);

            foreach (Control control in panelCollisionTypes.Controls)
            {
                CollisionTypeControl c = control as CollisionTypeControl;
                if (c != null)
                {
                    block.SetInt(c.patch.name, c.patch.type);
                    block.SetBool(c.patch.name + " enabled", c.enableImport);
                }
            }

            if (collision.specialBoxes != null)
            {
                int   num  = collision.specialBoxes.boxes.Count;
                int[] type = new int[num], x1 = new int[num], x2 = new int[num], z1 = new int[num], z2 = new int[num], y = new int[num];
                int   i    = 0;
                foreach (SpecialCollisionBox box in collision.specialBoxes.boxes)
                {
                    type[i] = box.type;
                    x1[i]   = box.x1;
                    x2[i]   = box.x2;
                    z1[i]   = box.z1;
                    z2[i]   = box.z2;
                    y[i]    = box.y;
                    i++;
                }
                block.SetIntArray("Special Boxes", type, true);
                block.SetIntArray("Special Boxes X1", x1, false);
                block.SetIntArray("Special Boxes X2", x2, false);
                block.SetIntArray("Special Boxes Z1", z1, false);
                block.SetIntArray("Special Boxes Z2", z2, false);
                block.SetIntArray("Special Boxes Height", y, false);
            }
        }
예제 #7
0
 public void LoadSettings(FileParser.Block block)
 {
     string[] names = Enum.GetNames(typeof(RenderStates.Parameter));
     for (int i = 0; i < names.Length; i++)
     {
         int fileValue = block.GetInt(names[i], false);
         globalParameters[i] = fileValue;
     }
     numFogIntensity.Value = (globalParameters[(int)RenderStates.Parameter.FogIntensity] >> 0x10) / (decimal)256;
     numFogOffset.Value    = (globalParameters[(int)RenderStates.Parameter.FogIntensity] & 0xFFFF) / (decimal)256;
 }
예제 #8
0
        private void btnLoadSettings_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter           = "Display List presets|*.sm64import";
            ofd.InitialDirectory = Path.GetFullPath("Presets/Levels");
            ofd.RestoreDirectory = false;
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            FileParser.Block b = new FileParser.Block(ofd.FileName);
            LoadSettings(b);
        }
예제 #9
0
 public int PrepareForImport()
 {
     try
     {
         FileParser.Block old_settings = new FileParser.Block(this); //Restore settings for collision after loading
         LoadObj();
         LoadSettings(old_settings);
     }
     catch (Exception ex)
     {
         return(-1);
     }
     return(0);
 }
예제 #10
0
        private void btnSaveSettings_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "Display List presets|*.sm64import";
            if (sfd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            System.IO.StreamWriter writer = new StreamWriter(sfd.FileName);
            FileParser.Block       root   = new FileParser.Block(this);
            SaveSettings(root);
            root.Write(writer);
            writer.Close();
        }
예제 #11
0
        private void btnSavePreset_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter           = "Display List presets|*.dl";
            sfd.RestoreDirectory = false;
            sfd.InitialDirectory = Path.GetFullPath("Presets/Display Lists");
            if (sfd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            System.IO.StreamWriter writer = new StreamWriter(sfd.FileName);
            FileParser.Block       root   = new FileParser.Block(this);
            SaveSettings(root);
            root.Write(writer);
            writer.Close();
        }
예제 #12
0
        public void SaveSettings(FileParser.Block block)
        {
            block.SetBool("Use Custom Address", useCustomAddress);
            if (useCustomAddress)
            {
                block.SetInt("Custom Address", segmentOffset);
            }
            block.SetIntArray("ROM Pointers", pointerControl.GetROMPointers());
            block.SetIntArray("RAM Pointers", pointerControl.GetRAMPointers());
            block.SetInt("Layer", (int)numLayer.Value);

            for (int i = 0; i < paramControls.Length; i++)
            {
                block.SetInt(paramControls[i].ParameterName, (int)paramControls[i].cmbType.SelectedIndex);
                if (paramControls[i].cmbType.SelectedIndex == paramControls[i].cmbType.Items.Count - 1)
                {
                    block.SetInt("Custom " + paramControls[i].ParameterName, paramControls[i].customValue);
                }
            }

            block.SetString("Obj File", sourceFileName);
            block.SetInt("Color Interpretation", (int)conversionSettings.colorInterpretation);
            if (displayList != null)
            {
                block.SetInt("Cycle Type", (int)displayList.renderstates.cycleType, false);
                block.SetInt("Blend modes", displayList.renderstates.blendMode);
                block.SetInt("Render states", displayList.renderstates.otherModesLow);
                block.SetInt("RCP Set", displayList.renderstates.RCPSet);
                block.SetInt("RCP Unset", displayList.renderstates.RCPUnset);
                block.SetInt("Combiner Low", (int)(displayList.renderstates.combiner.state & 0xFFFFFFFF));
                block.SetInt("Combiner High", (int)((displayList.renderstates.combiner.state >> 0x20) & 0xFFFFFF));
                block.SetDouble("Texture Scale X", displayList.renderstates.textureScaleX);
                block.SetDouble("Texture Scale Y", displayList.renderstates.textureScaleY);
            }
            if (this.textureControl.materialLibrary != null)
            {
                foreach (KeyValuePair <string, TextureInfo> tex in this.textureControl.materialLibrary)
                {
                    if (tex.Value.addressX != TextureInfo.AddressMode.G_TX_WRAP || tex.Value.addressY != TextureInfo.AddressMode.G_TX_WRAP || tex.Value.stRAMPointers.Length + tex.Value.stROMPointers.Length > 0)
                    {
                        block.SetBlock(tex.Key, new FileParser.Block(tex.Value));
                    }
                }
            }
        }
예제 #13
0
 public void LoadSettings(FileParser.Block block)
 {
     foreach (KeyValuePair <string, TextureImage> texture in textures)
     {
         string   settings = block.GetString("Texture " + texture.Key, false);
         string[] split    = settings.Split(',');
         try
         {
             texture.Value.format = (TextureImage.TextureFormat)Enum.Parse(typeof(TextureImage.TextureFormat), split[0].Trim(), true);
         }
         catch { }
         if (split.Length > 1)
         {
             try
             {
                 texture.Value.bpp = (TextureImage.BitsPerPixel)Enum.Parse(typeof(TextureImage.BitsPerPixel), split[1].Trim(), true);
             }
             catch { }
         }
     }
 }
예제 #14
0
        public void LoadSettings(FileParser.Block block)
        {
            string fileName = block.GetString("ROM");

            if (!System.IO.File.Exists(fileName))
            {
                string prompt = "File " + fileName + " does not exist anymore. Do you want to load another ROM?";
                if (fileName != "" && MessageBox.Show(prompt, "ROM not found.", MessageBoxButtons.YesNo) != System.Windows.Forms.DialogResult.Yes)
                {
                    return;
                }
                OpenFileDialog dlg = new OpenFileDialog();
                dlg.Filter = "z64 ROMs|*.z64";
                if (SM64RAM.EmulationState.instance.ROMName != "")
                {
                    fileName = SM64RAM.EmulationState.instance.ROMName;
                }
                else
                {
                    if (dlg.ShowDialog() != System.Windows.Forms.DialogResult.OK)
                    {
                        return;
                    }
                    fileName = dlg.FileName;
                }
            }
            RAMControl.LoadROM(fileName);
            runLevelScripts.Clear();
            if (SM64RAM.EmulationState.instance.ROM == null)
            {
                EmulationState.messages.AppendMessage("An error occured while loading the ROM. Make sure no other programs are using the ROM file right now and try again.", "Error");
                return;
            }

            segmentedAddress     = block.GetInt("Base Offset", false);
            txtBaseOffset.Text   = segmentedAddress.ToString("X8");
            Settings.importScale = block.GetInt("Import Scale", false);
            if (Settings.importScale == 0)
            {
                Settings.importScale = 1000;
            }
            numScale.Value = Math.Max((int)numScale.Minimum, Math.Min((int)numScale.Maximum, (int)Settings.importScale));

            FileParser.Block globalBlock = block.GetBlock("Globals", false);
            if (globalBlock != null)
            {
                globalsControl.LoadSettings(globalBlock);
            }

            //Apply patches if necessary / desired
            string patchString = block.GetString("Patches", false);

            if (patchString != "" && MessageBox.Show("Apply level patches?", "Patch ROM", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                PatchEngine.Run(patchString, Path.GetDirectoryName(block.fileName));
            }

            runLevelScripts.AddRange(block.GetIntArray("Run level scripts"));
            RunLevelScripts();

            textureLibrary.textures.Clear();
            displayLists.Clear();
            collisionMaps.Clear();
            SuspendLayout();
            tabImports.TabPages.Clear();
            tabImports.TabPages.Add(tabPagePlus);

            //Load Display List Data
            int numDls = block.GetInt("NumDisplayLists");

            for (int i = 0; i < numDls; i++)
            {
                DisplayListControl newControl = new DisplayListControl();
                newControl.PerformLayout();
                newControl.LoadSettings(block.GetBlock("DisplayList" + i));
                AddDisplayList(newControl);
            }

            textureLibrary.LoadSettings(block.GetBlock("Textures", false));

            //Load Collision Map Data
            int numCMaps = block.GetInt("NumCollisionMaps");

            for (int i = 0; i < numCMaps; i++)
            {
                CollisionControl newControl = new CollisionControl();
                newControl.PerformLayout();
                newControl.LoadSettings(block.GetBlock("CollisionMap" + i));
                AddCollision(newControl);
            }
            ResumeLayout();
        }
예제 #15
0
        public void LoadSettings(FileParser.Block block)
        {
            string oldSource = sourceFileName;

            sourceFileName = block.GetString("Obj File", false);
            if (sourceFileName == "")
            {
                sourceFileName = oldSource;
            }
            conversionSettings.colorInterpretation = (ConversionSettings.ColorInterpretation)block.GetInt("Color Interpretation", false);
            if (sourceFileName != "")
            {
                LoadObj();
            }
            pointerControl.SetROMPointers(block.GetIntArray("ROM Pointers"));
            pointerControl.SetRAMPointers(block.GetIntArray("RAM Pointers"));

            numLayer.Value = block.GetInt("Layer");
            for (int i = 0; i < paramControls.Length; i++)
            {
                paramControls[i].cmbType.SelectedIndex = block.GetInt(paramControls[i].ParameterName, false);
                if (paramControls[i].cmbType.SelectedIndex == paramControls[i].cmbType.Items.Count - 1)
                {
                    paramControls[i].customValue = block.GetInt("Custom " + paramControls[i].ParameterName, false);
                }
            }

            if (textureControl.materialLibrary != null)
            {
                foreach (KeyValuePair <string, TextureInfo> tex in textureControl.materialLibrary)
                {
                    FileParser.Block b = block.GetBlock(tex.Key, false);
                    if (b != null)
                    {
                        tex.Value.LoadSettings(b);
                    }
                }
            }


            if (displayList != null)
            {
                displayList.renderstates.cycleType      = (BlenderControl.CycleModes)block.GetInt("Cycle Type", false);
                displayList.renderstates.blendMode      = block.GetInt("Blend modes");
                displayList.renderstates.otherModesLow  = block.GetInt("Render states");
                displayList.renderstates.RCPSet         = block.GetInt("RCP Set", false);
                displayList.renderstates.RCPUnset       = block.GetInt("RCP Unset", false);
                displayList.renderstates.combiner.state = ((long)(block.GetInt("Combiner High") & 0xFFFFFFFF) << 0x20) | ((long)block.GetInt("Combiner Low") & 0xFFFFFFFF);
                displayList.renderstates.textureScaleX  = block.GetDouble("Texture Scale X");
                displayList.renderstates.textureScaleY  = block.GetDouble("Texture Scale Y");

                renderStateControl.Bind(displayList.renderstates);
                combinerStateControl.Bind(displayList.renderstates.combiner);
                blenderControl1.SetValues(displayList.renderstates.blendMode);
                blenderControl1.SetCycleType(displayList.renderstates.cycleType);
            }
            if (oldSource != sourceFileName)
            {
                updateImportEnable(null, null);
            }
        }
예제 #16
0
        public void LoadSettings(FileParser.Block block)
        {
            sourceFileName = block.GetString("Obj File");
            if (sourceFileName != "")
            {
                LoadFile();
            }
            if (block.GetBool("Use Custom Address"))
            {
                //Set a checkbox here
                segmentOffset = block.GetInt("Custom Address");
            }
            pointerControl1.SetROMPointers(block.GetIntArray("ROM Pointers"));
            pointerControl1.SetRAMPointers(block.GetIntArray("RAM Pointers"));

            string specialPointerString = block.GetString("Special Pointers", false);

            if (specialPointerString != null)
            {
                string[] split = specialPointerString.Split(';');
                List <SpecialPointer> validPointers = new List <SpecialPointer>();
                foreach (string s in split)
                {
                    SpecialPointer newPointer = specialPointerControl1.PointerByString(s.Trim());
                    if (newPointer != null)
                    {
                        validPointers.Add(newPointer);
                    }
                }
                specialPointerControl1.SetPointers(validPointers.ToArray());
            }

            cmbTypeStyle.SelectedIndex = block.GetInt("Type Style", false);

            foreach (Control control in panelCollisionTypes.Controls)
            {
                CollisionTypeControl c = control as CollisionTypeControl;
                if (c != null)
                {
                    c.SetType(block.GetInt(c.patch.name, false));
                    c.enableImport = block.GetBool(c.patch.name + " enabled", false);
                }
            }

            int[] specialBoxTypes = block.GetIntArray("Special Boxes", false);
            int[] specialBoxX1    = block.GetIntArray("Special Boxes X1", false);
            int[] specialBoxX2    = block.GetIntArray("Special Boxes X2", false);
            int[] specialBoxZ1    = block.GetIntArray("Special Boxes Z1", false);
            int[] specialBoxZ2    = block.GetIntArray("Special Boxes Z2", false);
            int[] specialBoxY     = block.GetIntArray("Special Boxes Height", false);
            if (specialBoxTypes.Length > 0)
            {
                collision.specialBoxes = new SpecialBoxes();
            }
            for (int i = 0; i < specialBoxTypes.Length; i++)
            {
                SpecialCollisionBox box = new SpecialCollisionBox();
                box.type = (short)specialBoxTypes[i];
                if (i < specialBoxX1.Length)
                {
                    box.x1 = (short)specialBoxX1[i];
                }
                if (i < specialBoxX2.Length)
                {
                    box.x2 = (short)specialBoxX2[i];
                }
                if (i < specialBoxZ1.Length)
                {
                    box.z1 = (short)specialBoxZ1[i];
                }
                if (i < specialBoxZ2.Length)
                {
                    box.z2 = (short)specialBoxZ2[i];
                }
                if (i < specialBoxY.Length)
                {
                    box.y = (short)specialBoxY[i];
                }
                collision.specialBoxes.boxes.Add(box);
            }
        }