Beispiel #1
0
        /// <summary>
        /// Finds the offset of a texture name
        /// </summary>
        /// <param name="textureName">Name of the texture to find the offset for</param>
        public FindOffset(string textureName)
        {
            if (textureName.Contains(".tex") || textureName.Contains(".mdl"))
            {
                fileCRC = crc.text(textureName).PadLeft(8, '0');
            }
            else
            {
                fileCRC = textureName;
            }

            using (BinaryReader br = new BinaryReader(File.OpenRead(Properties.Settings.Default.DefaultDir + "/040000.win32.index")))
            {
                br.BaseStream.Seek(1036, SeekOrigin.Begin);
                int totalFiles = br.ReadInt32();

                br.BaseStream.Seek(2048, SeekOrigin.Begin);
                for (int i = 0; i < totalFiles; br.ReadBytes(4), i += 16)
                {
                    string tempOffset = br.ReadInt32().ToString("X").PadLeft(8, '0');

                    if (tempOffset.Equals(fileCRC))
                    {
                        br.ReadBytes(4);
                        byte[] offset = br.ReadBytes(4);
                        fileOffset = (BitConverter.ToInt32(offset, 0) * 8).ToString("X").PadLeft(8, '0');
                        break;
                    }
                    else
                    {
                        br.ReadBytes(8);
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Modifies the offset for a particular texture in the .index file
        /// </summary>
        /// <param name="newOffset">The new offset to be writen</param>
        /// <param name="texName">Name of the currently selected texture</param>
        /// <param name="mFolderHex">the Folder Name CRC</param>
        public void modifyIndexOffset(int newOffset, string texName, string mFolderHex)
        {
            FFCRC  crc = new FFCRC();
            string fileCRC;

            fileCRC = crc.text(texName).PadLeft(8, '0');

            using (FileStream fs = new FileStream(Properties.Settings.Default.DefaultDir + "/040000.win32.index", FileMode.Open, FileAccess.ReadWrite))
            {
                using (BinaryReader b = new BinaryReader(fs))
                {
                    using (BinaryWriter bw = new BinaryWriter(fs))
                    {
                        b.BaseStream.Seek(1036, SeekOrigin.Begin);
                        int totalFiles = b.ReadInt32();


                        b.BaseStream.Seek(2048, SeekOrigin.Begin);
                        for (int i = 0; i < totalFiles; b.ReadBytes(4), i += 16)
                        {
                            int    fileHex1 = b.ReadInt32();
                            string fHex     = fileHex1.ToString("X").PadLeft(8, '0');

                            if (fHex.Equals(fileCRC))
                            {
                                if (!texName.Contains("mt_"))
                                {
                                    bw.BaseStream.Seek(2056 + i, SeekOrigin.Begin);
                                    bw.Write(newOffset / 8);
                                    break;
                                }
                                else
                                {
                                    int    folderHex = b.ReadInt32();
                                    string fohex     = folderHex.ToString("X").PadLeft(8, '0');

                                    if (fohex.Equals(mFolderHex))
                                    {
                                        bw.BaseStream.Seek(2056 + i, SeekOrigin.Begin);
                                        bw.Write(newOffset / 8);
                                        break;
                                    }
                                    b.ReadBytes(4);
                                }
                            }
                            else
                            {
                                b.ReadBytes(8);
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Dialog for Mod List
        /// </summary>
        public ModListForm()
        {
            InitializeComponent();
            listView1.View      = View.Details;
            listView1.GridLines = true;
            FFCRC crc = new FFCRC();

            Dictionary <string, string> raceIDDict = new Dictionary <string, string>();

            raceIDDict.Add("0101", Resources.strings.Hyur + " " + Resources.strings.Midlander + " " + Resources.strings.Male);
            raceIDDict.Add("0104", Resources.strings.Hyur + " " + Resources.strings.Male + " NPC");
            raceIDDict.Add("0201", Resources.strings.Hyur + " " + Resources.strings.Midlander + " " + Resources.strings.Female);
            raceIDDict.Add("0204", Resources.strings.Hyur + " " + Resources.strings.Female + " NPC");
            raceIDDict.Add("0301", Resources.strings.Hyur + " " + Resources.strings.Midlander + " " + Resources.strings.Male);
            raceIDDict.Add("0401", Resources.strings.Hyur + " " + Resources.strings.Midlander + " " + Resources.strings.Female);
            raceIDDict.Add("0501", Resources.strings.Elezen + " " + Resources.strings.Male);
            raceIDDict.Add("0504", Resources.strings.Elezen + " " + Resources.strings.Male + " NPC");
            raceIDDict.Add("0601", Resources.strings.Elezen + " " + Resources.strings.Female);
            raceIDDict.Add("0604", Resources.strings.Elezen + " " + Resources.strings.Female + " NPC");
            raceIDDict.Add("0701", Resources.strings.Miqote + " " + Resources.strings.Male);
            raceIDDict.Add("0801", Resources.strings.Miqote + " " + Resources.strings.Female);
            raceIDDict.Add("0804", Resources.strings.Miqote + " " + Resources.strings.Female + " NPC");
            raceIDDict.Add("0901", Resources.strings.Roegadyn + " " + Resources.strings.Male);
            raceIDDict.Add("1001", Resources.strings.Roegadyn + " " + Resources.strings.Female);
            raceIDDict.Add("1101", Resources.strings.Lalafell + " " + Resources.strings.Male);
            raceIDDict.Add("1201", Resources.strings.Lalafell + " " + Resources.strings.Female);
            raceIDDict.Add("1301", Resources.strings.Au_Ra + " " + Resources.strings.Male);
            raceIDDict.Add("1401", Resources.strings.Au_Ra + " " + Resources.strings.Female);
            raceIDDict.Add("9104", "NPC " + Resources.strings.Male);
            raceIDDict.Add("9204", "NPC " + Resources.strings.Female);

            string isActive, partName = "", partNum = "", race;

            listView1.Columns.Add("Name", -2, HorizontalAlignment.Left);
            listView1.Columns.Add("Race", -2, HorizontalAlignment.Left);
            listView1.Columns.Add("Map", -2, HorizontalAlignment.Left);
            listView1.Columns.Add("Part", -2, HorizontalAlignment.Left);
            listView1.Columns.Add("Part 2", -2, HorizontalAlignment.Left);
            listView1.Columns.Add("Active", -2, HorizontalAlignment.Left);

            foreach (string line in File.ReadLines(Properties.Settings.Default.DefaultDir + "/040000.modlist"))
            {
                jModEntry modEntry = JsonConvert.DeserializeObject <jModEntry>(line);
                modList.Add(modEntry);

                if (!modEntry.name.Contains("decal") && !modEntry.name.Contains("mt_m") && !modEntry.name.Contains("1_m") && !modEntry.name.Contains("2_m") &&
                    !modEntry.name.Contains("1_d"))
                {
                    string sName = modEntry.name;
                    race = raceIDDict[sName.Substring(sName.IndexOf('c') + 1, 4)];
                    if (race == null && sName.Contains("_w"))
                    {
                        race = "ALL";
                    }
                }
                else if (modEntry.name.Contains("decal"))
                {
                    race = "ALL";
                }
                else
                {
                    race = "Monsters";
                }

                if (modEntry.textureName == null)
                {
                    isActive = "Unknown";
                }
                else
                {
                    IOHelper ioHelper = new IOHelper();
                    if (!modEntry.name.Contains("mt_"))
                    {
                        isActive = ioHelper.isActive(crc.text(modEntry.name + ".tex"), modEntry.folder, modEntry.modOffset).ToString();
                    }
                    else
                    {
                        isActive = ioHelper.isActive(crc.text(modEntry.name + ".mtrl"), modEntry.folder, modEntry.modOffset).ToString();
                    }
                }

                if (modEntry.textureName == null)
                {
                    canGo = false;
                    modEntry.textureName = modEntry.name;
                }
                else
                {
                    canGo = true;
                }

                if (modEntry.name.Contains("f0"))
                {
                    string sName = modEntry.name;
                    int    val   = int.Parse(sName.Substring(sName.IndexOf('f') + 1, 4));
                    partName = val.ToString();;
                }
                else if (modEntry.name.Contains("b0"))
                {
                    string sName = modEntry.name;
                    int    val   = int.Parse(sName.Substring(sName.IndexOf('b') + 1, 4));
                    partName = val.ToString();;
                }
                else if (modEntry.name.Contains("h0"))
                {
                    string sName = modEntry.name;
                    int    val   = int.Parse(sName.Substring(sName.IndexOf('h') + 1, 4));
                    partName = val.ToString();;
                }
                else if (modEntry.name.Contains("t0"))
                {
                    string sName = modEntry.name;
                    int    val   = int.Parse(sName.Substring(sName.IndexOf('t') + 1, 4));
                    partName = val.ToString();;
                }
                else if (modEntry.name.Contains("decal"))
                {
                    string sName = modEntry.name;
                    int    val   = int.Parse(sName.Substring(sName.LastIndexOf('_') + 1));
                    partName = val.ToString();;
                }
                else if (modEntry.name.Contains("mt"))
                {
                    string sName = modEntry.name;
                    partName = sName.Substring(sName.LastIndexOf('_') + 1);
                }
                else if (modEntry.name.Contains("1_d"))
                {
                    string sName = modEntry.name;
                    partName = sName.Substring(sName.LastIndexOf('_') - 3, 3);
                }
                else
                {
                    partName = "a";
                }

                if (modEntry.name.Contains("f0"))
                {
                    if (modEntry.name.Contains("_fac"))
                    {
                        partNum = "Face";
                    }
                    else if (modEntry.name.Contains("_iri"))
                    {
                        partNum = "Iris";
                    }
                    else if (modEntry.name.Contains("_etc"))
                    {
                        partNum = "Etc";
                    }
                }
                else if (modEntry.name.Contains("h0"))
                {
                    if (modEntry.name.Contains("_hir"))
                    {
                        partNum = "Hair";
                    }
                    if (modEntry.name.Contains("_acc"))
                    {
                        partNum = "Accessory";
                    }
                }
                else
                {
                    partNum = "";
                }

                ListViewItem itemsList = new ListViewItem(modEntry.textureName);
                itemsList.SubItems.Add(race);
                itemsList.SubItems.Add(texMap(modEntry.name));
                itemsList.SubItems.Add(partName);
                itemsList.SubItems.Add(partNum);
                itemsList.SubItems.Add(isActive);

                listView1.Items.Add(itemsList);
            }
            modGoToButton.Enabled = false;
            switchButton.Enabled  = false;
        }