Beispiel #1
0
        private void FindSceneTable()
        {
            Scenes = new List <ISceneTableEntry>();

            if (IsMajora || !HasZ64TablesHack)
            {
                int increment = (IsMajora ? 16 : 20);

                DMATableEntry dma = Files.OrderBy(x => x.VStart).FirstOrDefault(x => x.FileType == DMATableEntry.FileTypes.Scene);

                for (int i = CodeData.Length - (increment * 2); i > 0; i -= 4)
                {
                    ISceneTableEntry entry = !IsMajora ? new SceneTableEntryOcarina(this, i, true) : (ISceneTableEntry) new SceneTableEntryMajora(this, i, true);
                    if (entry.GetSceneStartAddress() == dma.VStart && entry.GetSceneEndAddress() == dma.VEnd)
                    {
                        SceneTableAddress = i;
                        break;
                    }
                }

                if (SceneTableAddress != -1)
                {
                    for (int i = SceneTableAddress, j = 0; i < CodeData.Length - (16 * 16); i += increment)
                    {
                        ISceneTableEntry scn1 = !IsMajora ? new SceneTableEntryOcarina(this, i, true) : (ISceneTableEntry) new SceneTableEntryMajora(this, i, true);

                        if (!scn1.IsValid() && !scn1.IsAllZero())
                        {
                            break;
                        }

                        scn1.SetNumber((ushort)j);
                        if (!scn1.IsAllZero())
                        {
                            Scenes.Add(scn1);
                        }
                        j++;
                    }
                }
            }
            else
            {
                SceneTableAddress = Endian.SwapInt32(BitConverter.ToInt32(Data, Z64TablesAdrOffset));
                int cnt = Endian.SwapInt32(BitConverter.ToInt32(Data, Z64TablesAdrOffset + 4));
                for (int i = 0; i < cnt; i++)
                {
                    Scenes.Add(new SceneTableEntryOcarina(this, SceneTableAddress + (i * 20), false));
                }
            }

            SceneNameACStrings = new AutoCompleteStringCollection();
            foreach (ISceneTableEntry ste in Scenes)
            {
                ste.ReadScene();
                SceneNameACStrings.Add(ste.GetName());
            }
        }
Beispiel #2
0
        public Generic(ROMHandler.ROMHandler rom, IHeaderParent parent, byte seg, ref int ofs)
        {
            ROM     = rom;
            Command = (HeaderLoader.CommandTypeIDs)((byte[])rom.SegmentMapping[seg])[ofs];
            Offset  = ofs;
            Data    = Endian.SwapUInt64(BitConverter.ToUInt64(((byte[])rom.SegmentMapping[seg]), ofs));
            Parent  = parent;
            ofs    += 8;

            if (parent is HeaderCommands.Rooms.RoomInfoClass && (parent as HeaderCommands.Rooms.RoomInfoClass).Parent is SceneTableEntryOcarina)
            {
                ISceneTableEntry ste = ((parent as HeaderCommands.Rooms.RoomInfoClass).Parent as ISceneTableEntry);
                InROM = ste.IsInROM();
            }
            else if (parent is ISceneTableEntry)
            {
                InROM = (parent as ISceneTableEntry).IsInROM();
            }
        }
Beispiel #3
0
        private void tvScenes_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Tag is ROMHandler.ROMHandler)
                ResetCurrentData();
            if (e.Node.Tag is ISceneTableEntry)
            {
                if (currentScene != (e.Node.Tag as ISceneTableEntry))
                {
                    currentScene = (e.Node.Tag as ISceneTableEntry);
                    currentScene.SetCurrentSceneHeader(currentScene.GetSceneHeaders()[0]);
                    currentEnvSettings = currentScene.GetActiveEnvSettings().EnvSettingList.First();
                }
                currentRoom = null;
                currentRoomTriangle = null;
                currentRoomVertex = null;
            }
            else if (e.Node.Tag is HeaderLoader.HeaderPair)
            {
                HeaderLoader.HeaderPair hp = (e.Node.Tag as HeaderLoader.HeaderPair);

                if (hp.SceneHeader.Parent != currentScene) currentScene = (hp.SceneHeader.Parent as ISceneTableEntry);
                currentScene.SetCurrentSceneHeader(hp.SceneHeader);
                currentEnvSettings = currentScene.GetActiveEnvSettings().EnvSettingList.First();

                currentRoom = null;
                currentRoomTriangle = null;
                currentRoomVertex = null;
            }
            else if (e.Node.Tag is HeaderCommands.Rooms.RoomInfoClass)
            {
                HeaderLoader.HeaderPair hp = (e.Node.Parent.Tag as HeaderLoader.HeaderPair);

                if (hp.SceneHeader.Parent != currentScene) currentScene = (hp.SceneHeader.Parent as ISceneTableEntry);
                currentScene.SetCurrentSceneHeader(hp.SceneHeader);
                currentEnvSettings = currentScene.GetActiveEnvSettings().EnvSettingList.First();

                currentRoom = (e.Node.Tag as HeaderCommands.Rooms.RoomInfoClass);
                if (hp.SceneHeader.Number < currentRoom.Headers.Count)
                    currentRoom.CurrentRoomHeader = currentRoom.Headers[hp.SceneHeader.Number];

                currentRoomTriangle = null;
                currentRoomVertex = null;
            }

            RefreshCurrentData();
        }
Beispiel #4
0
        private void ResetCurrentData(bool norefresh = false)
        {
            currentScene = null;
            currentRoom = null;
            currentRoomTriangle = null;
            currentRoomVertex = null;
            currentEnvSettings = null;

            if (!norefresh) RefreshCurrentData();
        }
Beispiel #5
0
        private void openSceneToolStripMenuItem_Click(object sender, EventArgs e)
        {
            /* Get last scene and room */
            if (Configuration.LastSceneFile != string.Empty)
            {
                ofdOpenScene.InitialDirectory = Path.GetDirectoryName(Configuration.LastSceneFile);
                ofdOpenScene.FileName = Path.GetFileName(Configuration.LastSceneFile);
            }

            if (Configuration.LastRoomFile != string.Empty)
            {
                ofdOpenRoom.InitialDirectory = Path.GetDirectoryName(Configuration.LastRoomFile);
                ofdOpenRoom.FileName = Path.GetFileName(Configuration.LastRoomFile);
            }

            if (ofdOpenScene.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                Configuration.LastSceneFile = ofdOpenScene.FileName;

                if ((tempScene = (!rom.IsMajora ? (ISceneTableEntry)new SceneTableEntryOcarina(rom, ofdOpenScene.FileName) : (ISceneTableEntry)new SceneTableEntryMajora(rom, ofdOpenScene.FileName))) != null)
                {
                    if (ofdOpenRoom.ShowDialog() != System.Windows.Forms.DialogResult.OK) return;

                    Configuration.LastRoomFile = ofdOpenRoom.FileName;

                    individualFileMode = true;
                    displayListsDirty = collisionDirty = waterboxesDirty = true;

                    ResetCurrentData(true);
                    tempScene.ReadScene((tempRooms = new HeaderCommands.Rooms(rom, tempScene, ofdOpenRoom.FileName)));
                    CreateSceneTree();

                    SetFormTitle();

                    openSceneToolStripMenuItem.Enabled = false;
                    closeSceneToolStripMenuItem.Enabled = true;
                }
            }
        }