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(); }
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); } }