コード例 #1
0
ファイル: WzFileManager.cs プロジェクト: Aeopp/Github
 public bool LoadWzFile(string name)
 {
     try
     {
         WzFile wzf = new WzFile(Path.Combine(baseDir, Capitalize(name) + ".wz"), version);
         wzf.ParseWzFile();
         name                = name.ToLower();
         wzFiles[name]       = wzf;
         wzFilesUpdated[wzf] = false;
         wzDirs[name]        = new WzMainDirectory(wzf);
         return(true);
     }
     catch (Exception e)
     {
         HaRepackerLib.Warning.Error("Error initializing " + name + ".wz (" + e.Message + ").\r\nCheck that the directory is valid and the file is not in use.");
         return(false);
     }
 }
コード例 #2
0
        /// <summary>
        /// Open Base.WZ maplestory data
        /// </summary>
        public bool OpenBaseWZFile(out string LoadedVersion)
        {
            LoadedVersion = string.Empty;

            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Filter = "MapleStory Base.wz | Base.wz";
                if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string Dir = ofd.FileName.Replace("\\Base.wz", "");
                    foreach (string Name in Directory.GetFiles(Dir))
                    {
                        FileInfo Info = new FileInfo(Name);
                        if (Info.Extension != ".wz")
                        {
                            continue;
                        }
                        WzFile File = new WzFile(Name, WzMapleVersion);

                        string parseErrorMessage = string.Empty;
                        bool   parseSuccess      = File.ParseWzFile(out parseErrorMessage);

                        if (parseSuccess)
                        {
                            this.Files.Add(Info.Name, File);

                            if (LoadedVersion == string.Empty)
                            {
                                LoadedVersion = "MapleStory v." + File.Version + " WZ version: " + File.MapleVersion.ToString();
                            }
                        }
                        else
                        {
                            MessageBox.Show(parseErrorMessage, Properties.Resources.Error);
                        }
                    }
                    ParseWZFiles();

                    return(true);
                }
            }
            return(false);
        }
コード例 #3
0
 private bool OpenWzFile(string path, WzMapleVersion encVersion, short version, out WzFile file)
 {
     try
     {
         WzFile f = new WzFile(path, version, encVersion);
         lock (wzFiles)
         {
             wzFiles.Add(f);
         }
         f.ParseWzFile();
         file = f;
         return(true);
     }
     catch (Exception e)
     {
         Warning.Error("Error initializing " + Path.GetFileName(path) + " (" + e.Message + ").\r\nCheck that the directory is valid and the file is not in use.");
         file = null;
         return(false);
     }
 }
コード例 #4
0
 private bool LoadWzFileIfAbsent(ref WzFile wzFile, string fileName, WzMapleVersion mapleVersion)
 {
     if (wzFile != null)
     {
         return(false);
     }
     if (File.Exists(fileName + Resources.FileExtension))
     {
         wzFile = new WzFile(fileName + Resources.FileExtension, mapleVersion);
         wzFile.ParseWzFile();
         return(true);
     }
     else     // KMS
     {
         wzFile = new WzFile(fileName, mapleVersion);
         WzDirectory dir = new WzDirectory(fileName, wzFile);
         wzFile.WzDirectory = dir;
         RecursivelyLoadDirectory(dir, fileName, mapleVersion);
         return(true);
     }
 }
コード例 #5
0
        private static uint getItemIMGCRC(int itemID, bool isRaw)
        {
            uint             linesum = 0;
            WzCanvasProperty image   = null;
            string           type    = Database.getItemType(itemID);

            if (type != "Equip")
            {
                while (Utilities.IsFileLocked(new FileInfo(@"WZFiles/Item.wz")))
                {
                    Thread.Sleep(1000);
                }
                WzFile wzFile = new WzFile(@"WZFiles/Item.wz", Constants.WzType);
                wzFile.ParseWzFile();
                if (wzFile.WzDirectory != null)
                {
                    WzDirectory dir = null;
                    dir = wzFile.WzDirectory.GetDirectoryByName(type);
                    if (dir == null)
                    {
                        return(linesum);
                    }
                    image = Database.getItemBitMap(dir, wzFile, itemID, isRaw);
                    if (image != null)
                    {
                        linesum = image.PngProperty.getLineSum();
                        wzFile.Dispose();
                    }
                    else
                    {
                        wzFile.Dispose();
                        linesum = getItemIMGCRC(Database.crcID, isRaw);
                    }
                }
            }
            else
            {
            }
            return(linesum);
        }
コード例 #6
0
ファイル: WzFileManager.cs プロジェクト: Aeopp/Github
 public bool LoadDataWzFile(string name)
 {
     try
     {
         WzFile wzf = new WzFile(Path.Combine(baseDir, Capitalize(name) + ".wz"), version);
         wzf.ParseWzFile();
         name                = name.ToLower();
         wzFiles[name]       = wzf;
         wzFilesUpdated[wzf] = false;
         wzDirs[name]        = new WzMainDirectory(wzf);
         foreach (WzDirectory mainDir in wzf.WzDirectory.WzDirectories)
         {
             wzDirs[mainDir.Name.ToLower()] = new WzMainDirectory(wzf, mainDir);
         }
         return(true);
     }
     catch (Exception e)
     {
         MessageBox.Show("Error initializing " + name + ".wz (" + e.Message + ").\r\nCheck that the directory is valid and the file is not in use.");
         return(false);
     }
 }
コード例 #7
0
        /// <summary>
        /// Loads data given the path of a file or directory
        /// </summary>
        public static WzFile LoadFile(this Wz wz, string filePath, WzMapleVersion encryption, bool force = true)
        {
            WzFile file = null;

            if (!force)
            {
                if ((file = GetFile(wz)) != null)
                {
                    return(file);
                }
            }

            if (File.Exists(filePath))
            {
                file = new WzFile(filePath, encryption);
                file.ParseWzFile();
            }
            else if (File.Exists(filePath + Resources.FileExtensionWZ))
            {
                file = new WzFile(filePath + Resources.FileExtensionWZ, encryption);
                file.ParseWzFile();
            }
            else if (Directory.Exists(filePath))
            {
                file = new WzFile(filePath, encryption);
                WzDirectory dir = new WzDirectory(filePath, file);
                file.WzDirectory = dir;
                LoadFilesImg(dir, filePath, encryption);
            }

            if (wz == Wz.String)
            {
                StringWz.Load(file);
            }

            return(WzCache[(int)wz] = file);
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: xiejiashu/quest_optimizer
        static void Main(string[] args)
        {
            Console.Title = $"{General.Name} (v{General.Version.ToString("0.0")})";

            if (!File.Exists("Quest.wz"))
            {
                Console.WriteLine("Quest.wz is missing.");
                Console.ReadLine();

                return;
            }

            bool silent     = false;
            bool autoupdate = true;

            foreach (string arg in args)
            {
                switch (arg)
                {
                case "-silent":
                {
                    silent = true;
                    break;
                }

                case "-noupdate":
                {
                    autoupdate = false;
                    break;
                }

                case "-searchmode":
                {
                    SearchMode();
                    return;
                }
                }
            }

            if (!silent)
            {
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine($"Welcome to {Console.Title}!" + Environment.NewLine);
                Console.ForegroundColor = ConsoleColor.White;
            }

            if (autoupdate)
            {
                AutoUpdater.StartUpdate();
            }

            if (File.Exists("Quest.wz.patched"))
            {
                File.Delete("Quest.wz.patched");
            }

            var exclusions = ReadExclusions();

            if (!silent)
            {
                if (exclusions.Count == 0)
                {
                    Console.WriteLine("--- No quests will be excluded.");
                }

                else
                {
                    if (exclusions.Count > 50)
                    {
                        var fifty = exclusions.ToList();
                        fifty.RemoveRange(50, fifty.Count - 50);

                        Console.WriteLine($"--- Excluded quests: {string.Join(", ", fifty)}... and {exclusions.Count - 50} more!");
                    }

                    else
                    {
                        Console.WriteLine($"--- Excluded quests: {string.Join(", ", exclusions)}.");
                    }
                }

                Console.WriteLine(Environment.NewLine + "About to iterate through Quest.wz now." + Environment.NewLine);
            }

            var delete = new List <string>
            {
                "Act.img",
                "Check.img",
                "Exclusive.img",
                "QuestDestination.img",
                "QuestExpByLevel.img",
                "QuestInfo.img",
                "QuestPerformByDay.img",
                "Say.img",
                "SQuest.img"
            };

            using (var questwz = new WzFile("Quest.wz", WzMapleVersion.BMS)) // for some reason GMS uses the BMS format..?
            {
                questwz.ParseWzFile();

                foreach (string image in delete)
                {
                    var img      = questwz.WzDirectory.GetImageByName(image);
                    var original = img.WzProperties.ToList();

                    foreach (var prop in original)
                    {
                        if (!exclusions.Contains(int.Parse(prop.Name)))
                        {
                            img.WzProperties.Remove(prop);

                            if (!img.Changed)
                            {
                                img.Changed = true;
                            }
                        }
                    }

                    if (!silent && img.Changed)
                    {
                        Console.WriteLine($"--- Cleaned {image} (entries: {original.Count - img.WzProperties.Count})");
                    }
                }

                questwz.WzDirectory.ParseImages();

                if (File.Exists("Quest.wz.bak"))
                {
                    File.Delete("Quest.wz.bak");
                }

                File.Copy("Quest.wz", "Quest.wz.bak");
                questwz.SaveToDisk("Quest.wz.patched");

                if (!silent)
                {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine(Environment.NewLine + "--- Saved patched file to Quest.wz.patched.");
                }
            }

            if (!silent)
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.Write(Environment.NewLine + "Finished patching!");
                Console.ReadLine();
            }
        }
コード例 #9
0
 public ItemWz(WzFile itemWZ)
 {
     itemWZ.ParseWzFile();
     ConsumeDirectory = itemWZ.WzDirectory.GetDirectoryByName("Consume");
     ConsumeImage     = ConsumeDirectory.GetImageByName("0286.img");
 }
コード例 #10
0
        private void InitThread(string fileName, string dumpFolder, WzMapleVersion selectedValue)
        {
            WzListFile listFile = null;
            WzFile     regFile  = null;
            var        message  = String.Empty;

            try {
                if (fileName.EndsWith("List.wz", StringComparison.CurrentCultureIgnoreCase))
                {
                    listFile = new WzListFile(fileName, selectedValue);
                    listFile.ParseWzFile();
                }
                else
                {
                    List <WzFile> s = new List <WzFile>();
                    getWzExtensionFiles(fileName, s);
                    regFile = new WzFile(fileName, selectedValue, s);
                    regFile.ParseWzFile();
                }
            } catch (IOException ex) {
                if (regFile != null)
                {
                    regFile.Dispose();
                }
                message = "發生IO錯誤: " + ex.Message;
            } catch (UnauthorizedAccessException) {
                if (regFile != null)
                {
                    regFile.Dispose();
                }
                message = "請以管理員權限重啟此程式";
            } catch (Exception ex) {
                if (regFile != null)
                {
                    regFile.Dispose();
                }
                message = "處理檔案中發生問題: " + ex.Message;
            }
            if (!String.IsNullOrEmpty(message))
            {
                UpdateTextBoxInfo(Info, "處理文件時發生錯誤 " + Path.GetFileName(fileName) + "\r\n訊息: " + message + "\r\nContinuing...", true);
                IsError = true;
                return;
            }
            if (regFile == null && listFile == null)
            {
                return;
            }
            var wzName  = Path.GetFileName(fileName);
            var nFolder = Path.Combine(dumpFolder, wzName);

            if (listFile == null && includeVersionInFolderBox.Checked)
            {
                nFolder += "_v" + regFile.Version;
            }
            nFolder = GetValidFolderName(nFolder, false);
            if (!Directory.Exists(nFolder))
            {
                Directory.CreateDirectory(nFolder);
            }
            if (listFile == null)
            {
                UpdateTextBoxInfo(versionBox, regFile.Version.ToString(CultureInfo.CurrentCulture), false);
            }
            if (listFile != null)
            {
                UpdateTextBoxInfo(Info, "提取資料從 " + wzName + " 到 " + nFolder + "...", true);
            }
            else if (includePngMp3Box.Checked)
            {
                UpdateTextBoxInfo(Info, "提取 MP3, PNG 和 XML 從 " + wzName + " 到 " + nFolder + "...", true);
            }
            else
            {
                UpdateTextBoxInfo(Info, "提取 XML 從 " + wzName + " 到 " + nFolder + "...", true);
            }
            if (listFile != null)
            {
                DumpListWz(listFile, wzName, nFolder, DateTime.Now);
                listFile.Dispose();
            }
            else
            {
                DirectoryDumperThread(regFile, new WzXml(this, dumpFolder, new DirectoryInfo(nFolder).Name, includePngMp3Box.Checked, SelectedLinkType));
            }
        }
コード例 #11
0
        private void DumpFile(object sender, EventArgs e)
        {
            UpdateToolstripStatus("處理中...");
            DisableButtons();
            var            filePath = WZFileTB.Text;
            FileAttributes attr     = File.GetAttributes(filePath);

            if (!attr.HasFlag(FileAttributes.Directory))
            {
                var ext = Path.GetExtension(filePath);
                if (ext != null && String.Compare(ext, ".img", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    DumpXmlFromWzImage(filePath);
                    return;
                }
                WzListFile listFile = null;
                WzFile     regFile  = null;
                try {
                    if (filePath.EndsWith("List.wz", StringComparison.CurrentCultureIgnoreCase))
                    {
                        listFile = new WzListFile(filePath, SelectedVersion);
                        listFile.ParseWzFile();
                    }
                    else
                    {
                        List <WzFile> s = new List <WzFile>();
                        getWzExtensionFiles(filePath, s);
                        regFile = new WzFile(filePath, SelectedVersion, s);
                        regFile.ParseWzFile();
                    }
                } catch (UnauthorizedAccessException) {
                    if (regFile != null)
                    {
                        regFile.Dispose();
                    }
                    MessageBox.Show("請使用管理員權限重新開啟此程式.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    UpdateToolstripStatus("");
                    EnableButtons();
                    return;
                } catch (Exception ex) {
                    if (regFile != null)
                    {
                        regFile.Dispose();
                    }
                    MessageBox.Show("發生錯誤,訊息: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    UpdateToolstripStatus("");
                    EnableButtons();
                    return;
                }
                if (listFile == null)
                {
                    versionBox.Text = regFile.Version.ToString(CultureInfo.CurrentCulture);
                }
                var fileName      = Path.GetFileName(filePath);
                var extractDir    = outputFolderTB.Text;
                var extractFolder = Path.Combine(extractDir, fileName);
                if (listFile == null && includeVersionInFolderBox.Checked)
                {
                    extractFolder += "_v" + regFile.Version;
                }
                if (File.Exists(extractFolder))
                {
                    extractFolder = GetValidFolderName(extractFolder, true);
                }
                if (Directory.Exists(extractFolder))
                {
                    var result = MessageBox.Show(extractFolder + " 已經存在.\r\n是否要覆蓋資料夾?\r\n提示: 點選 No 將會創建新資料夾.", "Folder Already Exists", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                    if (result == DialogResult.Cancel)
                    {
                        if (regFile != null)
                        {
                            regFile.Dispose();
                        }
                        UpdateToolstripStatus("");
                        EnableButtons();
                        return;
                    }
                    if (result != DialogResult.Yes)
                    {
                        extractFolder = GetValidFolderName(extractFolder, false);
                    }
                }
                if (!Directory.Exists(extractFolder))
                {
                    Directory.CreateDirectory(extractFolder);
                }
                if (listFile != null)
                {
                    Info.AppendText("提取資料從 " + fileName + " 到 " + extractFolder + "...\r\n");
                }
                else if (includePngMp3Box.Checked)
                {
                    Info.AppendText("提取 MP3s, PNGs 和XMLs 從檔案 " + fileName + " 到 " + extractFolder + "...\r\n");
                }
                else
                {
                    Info.AppendText("提取 XML 從 " + fileName + " 到 " + extractFolder + "...\r\n");
                }
                if (listFile != null)
                {
                    DumpListWz(listFile, fileName, extractFolder, DateTime.Now);
                    listFile.Dispose();
                    EnableButtons();
                }
                else
                {
                    UpdateToolstripStatus("準備中...");
                    CancelSource = new CancellationTokenSource();
                    CreateSingleDumperThread(regFile, new WzXml(this, extractDir, new DirectoryInfo(extractFolder).Name, includePngMp3Box.Checked, SelectedLinkType), fileName);
                }
            }
            else
            {
                var allFiles = Directory.GetFiles(filePath, "*.wz");
                if (allFiles.Length != 0)
                {
                    string filesFound = "未找到WZ文件: ";
                    foreach (var fileName in allFiles)
                    {
                        filesFound += Path.GetFileName(fileName) + ", ";
                    }
                    Info.AppendText(filesFound.Substring(0, filesFound.Length - 2) + "\r\n");
                    // allFiles = allFiles.Where(fileName => !Regex.IsMatch(fileName, "[0-9]{3}.wz$", RegexOptions.IgnoreCase)).ToArray(); ;
                    Array.Sort(allFiles, Compare);
                    CreateMultipleDumperThreads(filePath, allFiles, outputFolderTB.Text);
                }
                else
                {
                    MessageBox.Show("所選擇的資料夾不包含Wz檔案. 請選擇其他資料夾.", "No WZ Files Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    UpdateToolstripStatus("");
                    EnableButtons();
                }
            }
        }
コード例 #12
0
        private void DumpFile(object sender, EventArgs e)
        {
            CheckOutputPath();
            UpdateToolstripStatus("Parsing...");
            DisableButtons();
            var            filePath = WZFileTB.Text;
            FileAttributes attr     = File.GetAttributes(filePath);

            if (!attr.HasFlag(FileAttributes.Directory))
            {
                var ext = Path.GetExtension(filePath);
                if (ext != null && String.Compare(ext, ".img", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    DumpXmlFromWzImage(filePath);
                    return;
                }
                WzListFile listFile = null;
                WzFile     regFile  = null;
                try {
                    if (filePath.EndsWith("List.wz", StringComparison.CurrentCultureIgnoreCase))
                    {
                        listFile = new WzListFile(filePath, SelectedVersion);
                        listFile.ParseWzFile();
                    }
                    else
                    {
                        List <WzFile> s = new List <WzFile>();
                        getWzExtensionFiles(filePath, s);
                        regFile = new WzFile(filePath, SelectedVersion, s);
                        regFile.ParseWzFile();
                    }
                } catch (UnauthorizedAccessException) {
                    if (regFile != null)
                    {
                        regFile.Dispose();
                    }
                    MessageBox.Show("Please re-run this program as an administrator.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                    UpdateToolstripStatus("");
                    EnableButtons();
                    return;
                } catch (Exception ex) {
                    if (regFile != null)
                    {
                        regFile.Dispose();
                    }
                    MessageBox.Show("An error occurred while parsing this file: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    UpdateToolstripStatus("");
                    EnableButtons();
                    return;
                }
                if (listFile == null)
                {
                    versionBox.Text = regFile.Version.ToString(CultureInfo.CurrentCulture);
                }
                var fileName      = Path.GetFileName(filePath);
                var extractDir    = outputFolderTB.Text;
                var extractFolder = Path.Combine(extractDir, fileName);
                if (listFile == null && includeVersionInFolderBox.Checked)
                {
                    extractFolder += "_v" + regFile.Version;
                }
                if (File.Exists(extractFolder))
                {
                    extractFolder = GetValidFolderName(extractFolder, true);
                }
                if (Directory.Exists(extractFolder))
                {
                    var result = MessageBox.Show(extractFolder + " already exists.\r\nDo you want to overwrite that folder?\r\nNote: Clicking No will make a new folder.", "Folder Already Exists", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                    if (result == DialogResult.Cancel)
                    {
                        if (regFile != null)
                        {
                            regFile.Dispose();
                        }
                        UpdateToolstripStatus("");
                        EnableButtons();
                        return;
                    }
                    if (result != DialogResult.Yes)
                    {
                        extractFolder = GetValidFolderName(extractFolder, false);
                    }
                }
                if (!Directory.Exists(extractFolder))
                {
                    Directory.CreateDirectory(extractFolder);
                }
                if (listFile != null)
                {
                    Info.AppendText("Dumping data from " + fileName + " to " + extractFolder + "...\r\n");
                }
                else if (includePngMp3Box.Checked)
                {
                    Info.AppendText("Dumping MP3s, PNGs and XMLs from " + fileName + " to " + extractFolder + "...\r\n");
                }
                else
                {
                    Info.AppendText("Dumping XMLs from " + fileName + " to " + extractFolder + "...\r\n");
                }
                if (listFile != null)
                {
                    DumpListWz(listFile, fileName, extractFolder, DateTime.Now);
                    listFile.Dispose();
                    EnableButtons();
                }
                else
                {
                    UpdateToolstripStatus("Preparing...");
                    CancelSource = new CancellationTokenSource();
                    CreateSingleDumperThread(regFile, new WzXml(this, extractDir, new DirectoryInfo(extractFolder).Name, includePngMp3Box.Checked, SelectedLinkType), fileName);
                }
            }
            else
            {
                var allFiles = Directory.GetFiles(filePath, "*.wz");
                if (allFiles.Length != 0)
                {
                    string filesFound = "WZ Files Found: ";
                    foreach (var fileName in allFiles)
                    {
                        filesFound += Path.GetFileName(fileName) + ", ";
                    }
                    Info.AppendText(filesFound.Substring(0, filesFound.Length - 2) + "\r\n");
                    allFiles = allFiles.Where(fileName => !Regex.IsMatch(fileName, "[0-9]{3}.wz$", RegexOptions.IgnoreCase)).ToArray();;
                    Array.Sort(allFiles, Compare);
                    CreateMultipleDumperThreads(filePath, allFiles, outputFolderTB.Text);
                }
                else
                {
                    MessageBox.Show("There are no WZ Files located in the selected folder. Please choose a different folder.", "No WZ Files Found", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    UpdateToolstripStatus("");
                    EnableButtons();
                }
            }
        }
コード例 #13
0
ファイル: CharacterWz.cs プロジェクト: Rudigus/HeavenBase
 public CharacterWz(WzFile characterWZ)
 {
     characterWZ.ParseWzFile();
     FamiliarDirectory = characterWZ.WzDirectory.GetDirectoryByName("Familiar");
 }
コード例 #14
0
ファイル: CharacterWz.cs プロジェクト: Rudigus/HeavenBase
 public CharacterWz(WzFile characterWZ, string category)
 {
     characterWZ.ParseWzFile();
     EquipDirectory = characterWZ.WzDirectory.GetDirectoryByName(category);
 }
コード例 #15
0
ファイル: Skill001Wz.cs プロジェクト: Rudigus/HeavenBase
 public Skill001Wz(WzFile skill001WZ)
 {
     skill001WZ.ParseWzFile();
     FamiliarImage = skill001WZ.WzDirectory.GetImageByName("FamiliarSkill.img");
 }
コード例 #16
0
ファイル: Form1.cs プロジェクト: odasm/WzPatcher
        public void patch(Dictionary <String, List <String> > patches, string dir, int patchNum)
        {
            WzMapleVersion vrs = WzMapleVersion.GMS;

            foreach (String wzName in patches.Keys)
            {
                WzFile wzFile = null;
                foreach (WzFile patching in toPatch)
                {
                    if (patching.Name == wzName)
                    {
                        Console.WriteLine("Currently patching: {0}, nextToPatch: {1}", patching.Name, wzName);
                        wzFile = patching;
                        break;
                    }
                }
                if (wzFile == null)
                {
                    wzFile = new WzFile(wzName, vrs);
                    wzFile.ParseWzFile();
                }
                foreach (string img in patches[wzName])
                {
                    WzImage     patchedImg    = null;
                    string[]    subdirs       = img.Split(new char[] { '/' });
                    WzDirectory targetDir     = wzFile.WzDirectory;
                    string      targetImgName = null;
                    foreach (string subdir in subdirs)
                    {
                        Console.WriteLine("subdir: {0}", subdir);
                        if (!subdir.EndsWith(".img")) // if this isn't the img
                        {
                            targetDir = targetDir.GetDirectoryByName(subdir);
                            if (targetDir == null)
                            {
                                Console.WriteLine("ERROR: {0} is not a valid directory.", subdir);
                                return;
                            }
                        }
                        else
                        {
                            targetImgName = subdir;
                        }
                    }
                    patchedImg = new WzImage(targetImgName, File.OpenRead(dir + "-" + patchNum + targetImgName), vrs);
                    patchedImg.ParseImage();
                    WzImage targetImg = targetDir.GetImageByName(targetImgName);
                    if (targetImg != null) // patching an existing .img
                    {
                        targetDir.RemoveImage(targetImg);
                        targetDir.AddImage(patchedImg);
                        patchedImg.changed = true;
                        Console.WriteLine("Existing wz img found for name: {0} and successfully applied patch.", img);
                    }
                    else
                    {
                        targetDir.AddImage(patchedImg);
                        patchedImg.changed = true;
                        Console.WriteLine("Added new wz img with name: {0} in dir: {1} and sucessfully applied patch.", patchedImg.Name, targetDir.Name);
                    }
                }
                if (!toPatch.Contains(wzFile))
                {
                    toPatch.Add(wzFile);
                }
            }
        }
コード例 #17
0
ファイル: EtcWz.cs プロジェクト: Rudigus/HeavenBase
 public EtcWz(WzFile EtcWZ)
 {
     EtcWZ.ParseWzFile();
     familiarInfoImage = EtcWZ.WzDirectory.GetImageByName("FamiliarInfo.img");
 }
コード例 #18
0
        private void InitThread(string fileName, string dumpFolder, WzMapleVersion selectedValue)
        {
            WzListFile listFile = null;
            WzFile     regFile  = null;
            var        message  = String.Empty;

            try {
                if (fileName.EndsWith("List.wz", StringComparison.CurrentCultureIgnoreCase))
                {
                    listFile = new WzListFile(fileName, selectedValue);
                    listFile.ParseWzFile();
                }
                else
                {
                    List <WzFile> s = new List <WzFile>();
                    getWzExtensionFiles(fileName, s);
                    regFile = new WzFile(fileName, selectedValue, s);
                    regFile.ParseWzFile();
                }
            } catch (IOException ex) {
                if (regFile != null)
                {
                    regFile.Dispose();
                }
                message = "An IO error occurred: " + ex.Message;
            } catch (UnauthorizedAccessException) {
                if (regFile != null)
                {
                    regFile.Dispose();
                }
                message = "Please re-run this program as an administrator.";
            } catch (Exception ex) {
                if (regFile != null)
                {
                    regFile.Dispose();
                }
                message = "An error occurred while parsing this file: " + ex.Message;
            }
            if (!String.IsNullOrEmpty(message))
            {
                UpdateTextBoxInfo(Info, "Error while parsing file " + Path.GetFileName(fileName) + "\r\nMessage: " + message + "\r\nContinuing...", true);
                if (!fileName.EndsWith("List.wz"))
                {
                    IsError = true;
                }
                return;
            }
            if (regFile == null && listFile == null)
            {
                return;
            }
            var wzName  = Path.GetFileName(fileName);
            var nFolder = Path.Combine(dumpFolder, wzName);

            if (listFile == null && includeVersionInFolderBox.Checked)
            {
                nFolder += "_v" + regFile.Version;
            }
            nFolder = GetValidFolderName(nFolder, false);
            if (!Directory.Exists(nFolder))
            {
                Directory.CreateDirectory(nFolder);
            }
            if (listFile == null)
            {
                UpdateTextBoxInfo(versionBox, regFile.Version.ToString(CultureInfo.CurrentCulture), false);
            }
            if (listFile != null)
            {
                UpdateTextBoxInfo(Info, "Dumping data from " + wzName + " to " + nFolder + "...", true);
            }
            else if (includePngMp3Box.Checked)
            {
                UpdateTextBoxInfo(Info, "Dumping MP3s, PNGs and XMLs from " + wzName + " to " + nFolder + "...", true);
            }
            else
            {
                UpdateTextBoxInfo(Info, "Dumping XMLs from " + wzName + " to " + nFolder + "...", true);
            }
            if (listFile != null)
            {
                DumpListWz(listFile, wzName, nFolder, DateTime.Now);
                listFile.Dispose();
            }
            else
            {
                DirectoryDumperThread(regFile, new WzXml(this, dumpFolder, new DirectoryInfo(nFolder).Name, includePngMp3Box.Checked, SelectedLinkType));
            }
        }
コード例 #19
0
ファイル: Program.cs プロジェクト: xiejiashu/quest_optimizer
        static void SearchMode()
        {
            Console.WriteLine("Loading Quest.wz ...");

            using (var questwz = new WzFile("Quest.wz", WzMapleVersion.BMS))
            {
                questwz.ParseWzFile();
                var all = questwz.WzDirectory.GetImageByName("QuestInfo.img").WzProperties;

                while (true)
                {
                    Console.Write(Environment.NewLine + "Enter the quest's ID or Name that you want to search for (enter 'qq' to quit): ");
                    string searchStr = Console.ReadLine().ToLower();
                    Console.WriteLine();

                    if (string.IsNullOrEmpty(searchStr) || string.IsNullOrWhiteSpace(searchStr))
                    {
                        continue;
                    }

                    if (searchStr.Length < 2)
                    {
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine($"--- ERROR: Make sure your keyword is longer than 2 letters!");
                        Console.ForegroundColor = ConsoleColor.White;
                        continue;
                    }

                    if ("qq".Equals(searchStr))
                    {
                        break;
                    }

                    var results = new List <Tuple <int, string> >();

                    foreach (var item in all)
                    {
                        string id   = item.Name;
                        string name = ((WzStringProperty)item["name"])?.GetString();

                        if (name == null)
                        {
                            continue;
                        }

                        if (name.ToLower().Contains(searchStr) || id.Contains(searchStr))
                        {
                            results.Add(new Tuple <int, string>(int.Parse(id), name));
                        }
                    }

                    foreach (var item in results)
                    {
                        Console.WriteLine(item.Item1 + " // " + item.Item2);
                    }

                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine($"--- Found Quests: {results.Count}" + Environment.NewLine);
                    Console.ForegroundColor = ConsoleColor.White;

                    if (results.Count > 0)
                    {
                        Console.Write("Save the results into a file?" + Environment.NewLine +
                                      "('y' for simple, 'd' for detail, otherwise nothing): ");
                        string save = Console.ReadLine().ToLower();

                        if ("y".Equals(save))
                        {
                            SaveSearchResult(searchStr, results, true);
                        }
                        if ("d".Equals(save))
                        {
                            SaveSearchResult(searchStr, results, false);
                        }
                    }
                }
            }
        }
コード例 #20
0
 public MobWz(WzFile mobWZ)
 {
     mobWZ.ParseWzFile();
     MobDirectory = mobWZ.WzDirectory;
 }
コード例 #21
0
 public UIWz(WzFile UIWZ)
 {
     UIWZ.ParseWzFile();
     familiarCardImage = UIWZ.WzDirectory.GetImageByName("FamiliarCard.img");
 }