Esempio n. 1
0
 public void RemoveCollision(CollisionControl ctrl, TabPage page)
 {
     if (ctrl == null)
     {
         return;
     }
     tabImports.TabPages.Remove(page);
     collisionMaps.Remove(ctrl);
 }
Esempio n. 2
0
 static Main()
 {
     CollisionControl.Init();
 }
Esempio n. 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();
        }
Esempio n. 4
0
 void AddCollision(CollisionControl ctrl)
 {
     AddTabPage(ctrl, "Collision");
     collisionMaps.Add(ctrl);
 }