private void LoadRARC(string Filename, bool IsRoom = true, bool IgnoreModels = false)
        {
            if (Filename != string.Empty)
            {
                ZeldaArc NewArc = new ZeldaArc(Filename, treeView1, IgnoreModels);

                if (IsRoom == true)
                {
                    GetRoomNumber(NewArc);
                    GetGlobalTranslation(NewArc);
                    GetGlobalRotation(NewArc);
                    Rooms.Add(NewArc);
                }
                else
                {
                    Stage = NewArc;
                }

                if (NewArc.Archive.IsCompressed == true)
                {
                    MessageBox.Show(string.Format("RARC archive '{0}' is compressed; changes cannot be saved!", Path.GetFileName(NewArc.Archive.Filename)), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    saveChangesToolStripMenuItem.Enabled = true;
                }
            }
        }
 private void GetGlobalTranslation(ZeldaArc A)
 {
     if (Stage != null)
     {
         foreach (DZx D in Stage.DZSs)
         {
             foreach (DZx.FileChunk Chunk in D.Chunks)
             {
                 foreach (IDZxChunkElement ChunkElement in Chunk.Data.Where(C => C is MULT && ((MULT)C).RoomNumber == A.RoomNumber))
                 {
                     A.GlobalTranslation = new Vector3(((MULT)ChunkElement).Translation.X, 0.0f, ((MULT)ChunkElement).Translation.Y);
                 }
             }
         }
     }
 }
 private void GetGlobalRotation(ZeldaArc A)
 {
     if (Stage != null)
     {
         foreach (DZx D in Stage.DZSs)
         {
             foreach (DZx.FileChunk Chunk in D.Chunks)
             {
                 foreach (IDZxChunkElement ChunkElement in Chunk.Data.Where(C => C is MULT && ((MULT)C).RoomNumber == A.RoomNumber))
                 {
                     A.GlobalRotation = ((MULT)ChunkElement).Rotation;
                 }
             }
         }
     }
 }
Esempio n. 4
0
        /// <summary>
        /// In a 'Stage', there is data that is indexed by Room number. The actual rooms don't store
        /// this data internally, it is only by file name. So we're going to strip apart the filename
        /// to get the room number.
        /// </summary>
        /// <param name="NewArc"></param>
        private void GetRoomNumber(ZeldaArc NewArc)
        {
            int roomNumber = 0;

            //We're going to trim the Filepath down to just name - ie: "Room0.arc / R00_00.arc"
            string fileName = Path.GetFileName(NewArc.Filename);

            //If it starts with "Room" then it's (probably) a Windwaker Archive.
            if (fileName.Substring(0, 4).ToLower() == "room")
            {
                //Use Regex here to grab what is between "Room" and ".arc", since it goes up to "Room23.arc"
                string[] numbers        = Regex.Split(fileName, @"\D+");
                string   trimmedNumbers = String.Join("", numbers);
                trimmedNumbers = trimmedNumbers.Trim();

                roomNumber = int.Parse(trimmedNumbers);
            }
            //If it starts with R ("Rxx_00, xx being Room Number"), it's Twlight Princess
            else if (fileName.Substring(0, 1).ToLower() == "r")
            {
                //I *think* these follow the Rxx_00 pattern, where xx is the room number. _00 can change, xx might be 1 or 3, who knows!

                //We're going to use RegEx here to make sure we only grab what is between R and _00 which could be multipl.e
                string[] numbers        = Regex.Split(fileName.Substring(0, fileName.Length - 6), @"\D+");
                string   trimmedNumbers = String.Join("", numbers);
                trimmedNumbers = trimmedNumbers.Trim();

                roomNumber = int.Parse(trimmedNumbers);
            }
            else
            {
                InvalidRoomNumber popup = new InvalidRoomNumber();
                popup.DescriptionLabel.Text =
                    "Failed to determine room number from file name." + Environment.NewLine + "Expected: Room<x>.arc or R<xx>_00, got: " +
                    fileName;
                popup.ShowDialog(this);

                roomNumber = (int)popup.roomNumberSelector.Value;
                Console.WriteLine("User chose: " + roomNumber);
            }

            NewArc.RoomNumber = roomNumber;
        }
Esempio n. 5
0
        private void UnloadAllRARCs()
        {
            foreach (ZeldaArc A in Rooms)
            {
                A.Clear();
            }
            if (Stage != null)
            {
                Stage.Clear();
            }

            Rooms = new List <ZeldaArc>();
            Stage = null;

            treeView1.BeginUpdate();
            treeView1.Nodes.Clear();
            treeView1.EndUpdate();

            saveChangesToolStripMenuItem.Enabled = false;

            toolStripStatusLabel1.Text = "Ready";
        }
        private void treeView1_AfterSelect(object sender, TreeViewEventArgs e)
        {
            object Selected = ((TreeView)sender).SelectedNode.Tag;

            if (SelectedDZRChunkElement != null)
            {
                SelectedDZRChunkElement.Highlight = false;
                if (SelectedDZRChunkElement.EditControl != null)
                {
                    SelectedDZRChunkElement.EditControl.Dispose();
                }
            }

            if (SelectedArc != null)
            {
                if (SelectedArc.EditControl != null)
                {
                    SelectedArc.EditControl.Dispose();
                }
            }

            Panel TargetPanel = (Selected is IDZxChunkElement && (IDZxChunkElement)Selected is Generic) ? panel2 : panel1;
            Panel OtherPanel  = (Selected is IDZxChunkElement && (IDZxChunkElement)Selected is Generic) ? panel1 : panel2;

            OtherPanel.Visible = false;

            TargetPanel.SuspendLayout();


            if (Selected is ZeldaArc)
            {
                if (((ZeldaArc)Selected).Filename.Contains("room") || ((ZeldaArc)Selected).Filename.Contains("Room"))
                {
                    SelectedArc = (ZeldaArc)Selected;
                    SelectedArc.ShowControl(TargetPanel);
                }
            }
            else if (Selected is IDZxChunkElement)
            {
                SelectedDZRChunkElement = (IDZxChunkElement)Selected;

                SelectedDZRChunkElement.Highlight = true;
                SelectedDZRChunkElement.ShowControl(TargetPanel);

                if (autoCenterCameraToolStripMenuItem.Checked && (SelectedDZRChunkElement is Generic) == false)
                {
                    Vector3 CamPos = Vector3.Zero;
                    if (SelectedDZRChunkElement is ACTR)
                    {
                        CamPos = (-((ACTR)SelectedDZRChunkElement).Position * 0.005f);
                    }
                    else if (SelectedDZRChunkElement is RPPN)
                    {
                        CamPos = (-((RPPN)SelectedDZRChunkElement).Position * 0.005f);
                    }
                    else if (SelectedDZRChunkElement is SHIP)
                    {
                        CamPos = (-((SHIP)SelectedDZRChunkElement).Position * 0.005f);
                    }
                    else if (SelectedDZRChunkElement is TGDR)
                    {
                        CamPos = (-((TGDR)SelectedDZRChunkElement).Position * 0.005f);
                    }
                    else if (SelectedDZRChunkElement is TRES)
                    {
                        CamPos = (-((TRES)SelectedDZRChunkElement).Position * 0.005f);
                    }
                    else if (SelectedDZRChunkElement is MULT)
                    {
                        CamPos = (-(new Vector3(((MULT)SelectedDZRChunkElement).Translation.X, 0.0f, ((MULT)SelectedDZRChunkElement).Translation.Y) * 0.005f));
                    }

                    Helpers.Camera.Initialize(CamPos - new Vector3(0, 0, 2.0f));
                }
            }
            else
            {
                TargetPanel.Visible = false;
            }

            TargetPanel.ResumeLayout();
        }
        private void GetRoomNumber(ZeldaArc NewArc)
        {
            /* Very shitty - hell, I even use the VB interaction stuff out of laziness! */

            int RNumb = 0;

start:
            /* Alright, let's try this! */
            try
            {
                /* First try to guess the roomnumber from the filename... */
                /* Hm, is it even a room? */
                if (Path.GetFileName(NewArc.Filename).Substring(0, 4).ToLower() != "room" &&    /* ...WW? */
                    Path.GetFileName(NewArc.Filename).Substring(0, 1) != "R")                   /* ...or maybe TP? */
                {
                    goto manual;
                }
                else
                {
                    /* Any numbers in there...? */
                    string[] numbers = Regex.Split(Path.GetFileName(NewArc.Filename), @"\D+");
                    foreach (string n in numbers)
                    {
                        if (n != string.Empty)
                        {
                            /* Yay, there's a number, f**k it let's use this! */
                            RNumb = int.Parse(n);
                            goto cont;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    goto manual;        /* Wha? Nothing found? Gotta let the user do his thing... */
                }
            }
            catch
            {
                goto manual;
            }

manual:
            {
                /* Alright VB interaction time! Get the inputbox up... */
                string Number = Microsoft.VisualBasic.Interaction.InputBox("Could not determine room number. Please enter the number manually.");
                if (Number == string.Empty)
                {
                    return;
                }

                try
                {
                    /* Trying to get the number from the string */
                    RNumb = int.Parse(Number);
                    goto cont;
                }
                catch (FormatException)
                {
                    /* Ah for f***s sake, the box is asking for a NUMBER */
                    goto start;
                }
            }

cont:
            /* We somehow got a number! But is it correct? Hell if I know */
            NewArc.RoomNumber = RNumb;
        }
Esempio n. 8
0
 private void GetGlobalTranslation(ZeldaArc A)
 {
     if (Stage != null)
     {
         foreach (DZx D in Stage.DZSs)
         {
             foreach (DZx.FileChunk Chunk in D.Chunks)
             {
                 foreach (IDZxChunkElement ChunkElement in Chunk.Data.Where(C => C is MULT && ((MULT)C).RoomNumber == A.RoomNumber))
                 {
                     A.GlobalTranslation = new Vector3(((MULT)ChunkElement).HVTranslation.X, 0.0f, ((MULT)ChunkElement).HVTranslation.Y);
                 }
             }
         }
     }
 }
Esempio n. 9
0
        private void UnloadAllRARCs()
        {
            foreach (ZeldaArc A in Rooms) A.Clear();
            if (Stage != null) Stage.Clear();

            Rooms = new List<ZeldaArc>();
            Stage = null;

            treeView1.BeginUpdate();
            treeView1.Nodes.Clear();
            treeView1.EndUpdate();

            saveChangesToolStripMenuItem.Enabled = false;

            this.Text = Application.ProductName;
            toolStripStatusLabel1.Text = "Ready";
        }
Esempio n. 10
0
        private void LoadRARC(string Filename, bool IsRoom = true, bool IgnoreModels = false)
        {
            if (Filename != string.Empty)
            {
                ZeldaArc NewArc = new ZeldaArc(Filename, treeView1, IgnoreModels);

                if (IsRoom == true)
                {
                    GetRoomNumber(NewArc);
                    GetGlobalTranslation(NewArc);
                    Rooms.Add(NewArc);
                }
                else
                    Stage = NewArc;

                if (NewArc.Archive.IsCompressed == true)
                    MessageBox.Show(string.Format("RARC archive '{0}' is compressed; changes cannot be saved!", Path.GetFileName(NewArc.Archive.Filename)), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                else
                    saveChangesToolStripMenuItem.Enabled = true;
            }
        }
Esempio n. 11
0
        private void GetRoomNumber(ZeldaArc NewArc)
        {
            /* Very shitty - hell, I even use the VB interaction stuff out of laziness! */

            int RNumb = 0;

            start:
            /* Alright, let's try this! */
            try
            {
                /* First try to guess the roomnumber from the filename... */
                /* Hm, is it even a room? */
                if (Path.GetFileName(NewArc.Filename).Substring(0, 4).ToLower() != "room" &&    /* ...WW? */
                    Path.GetFileName(NewArc.Filename).Substring(0, 1) != "R")                   /* ...or maybe TP? */
                    goto manual;
                else
                {
                    /* Any numbers in there...? */
                    string[] numbers = Regex.Split(Path.GetFileName(NewArc.Filename), @"\D+");
                    foreach (string n in numbers)
                    {
                        if (n != string.Empty)
                        {
                            /* Yay, there's a number, f**k it let's use this! */
                            RNumb = int.Parse(n);
                            goto cont;
                        }
                        else
                            continue;
                    }
                    goto manual;        /* Wha? Nothing found? Gotta let the user do his thing... */
                }
            }
            catch
            {
                goto manual;
            }

            manual:
            {
                /* Alright VB interaction time! Get the inputbox up... */
                string Number = Microsoft.VisualBasic.Interaction.InputBox("Could not determine room number. Please enter the number manually.");
                if (Number == string.Empty) return;

                try
                {
                    /* Trying to get the number from the string */
                    RNumb = int.Parse(Number);
                    goto cont;
                }
                catch (FormatException)
                {
                    /* Ah for f***s sake, the box is asking for a NUMBER */
                    goto start;
                }
            }

            cont:
            /* We somehow got a number! But is it correct? Hell if I know */
            NewArc.RoomNumber = RNumb;
        }
Esempio n. 12
0
        /// <summary>
        /// In a 'Stage', there is data that is indexed by Room number. The actual rooms don't store
        /// this data internally, it is only by file name. So we're going to strip apart the filename
        /// to get the room number.
        /// </summary>
        /// <param name="NewArc"></param>
        private void GetRoomNumber(ZeldaArc NewArc)
        {
            int roomNumber = 0;

            //We're going to trim the Filepath down to just name - ie: "Room0.arc / R00_00.arc"
            string fileName = Path.GetFileName(NewArc.Filename);

            //If it starts with "Room" then it's (probably) a Windwaker Archive.
            if (fileName.Substring(0, 4).ToLower() == "room")
            {
                //Use Regex here to grab what is between "Room" and ".arc", since it goes up to "Room23.arc"
                string[] numbers = Regex.Split(fileName, @"\D+");
                string trimmedNumbers = String.Join("", numbers);
                trimmedNumbers = trimmedNumbers.Trim();

                roomNumber = int.Parse(trimmedNumbers);
            }
            //If it starts with R ("Rxx_00, xx being Room Number"), it's Twlight Princess
            else if (fileName.Substring(0, 1).ToLower() == "r")
            {
                //I *think* these follow the Rxx_00 pattern, where xx is the room number. _00 can change, xx might be 1 or 3, who knows!

                //We're going to use RegEx here to make sure we only grab what is between R and _00 which could be multipl.e
                string[] numbers = Regex.Split(fileName.Substring(0, fileName.Length - 6), @"\D+");
                string trimmedNumbers = String.Join("", numbers);
                trimmedNumbers = trimmedNumbers.Trim();

                roomNumber = int.Parse(trimmedNumbers);
            }
            else
            {
                InvalidRoomNumber popup = new InvalidRoomNumber();
                popup.DescriptionLabel.Text =
                    "Failed to determine room number from file name." + Environment.NewLine + "Expected: Room<x>.arc or R<xx>_00, got: " +
                    fileName;
                popup.ShowDialog(this);

                roomNumber = (int) popup.roomNumberSelector.Value;
                Console.WriteLine("User chose: " + roomNumber);
            }

            NewArc.RoomNumber = roomNumber;
        }
Esempio n. 13
0
 private void GetGlobalRotation(ZeldaArc A)
 {
     if (Stage != null)
     {
         foreach (DZx D in Stage.DZSs)
         {
             foreach (DZx.FileChunk Chunk in D.Chunks)
             {
                 foreach (IDZxChunkElement ChunkElement in Chunk.Data.Where(C => C is MULT && ((MULT)C).RoomNumber == A.RoomNumber))
                 {
                     A.GlobalRotation = ((MULT)ChunkElement).Rotation;
                 }
             }
         }
     }
 }