コード例 #1
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 { }
         }
     }
 }
コード例 #2
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);
            }
        }
コード例 #3
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();
        }
コード例 #4
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);
            }
        }