예제 #1
0
        public bool LoadWzFile(string name)
        {
            try
            {
                WzFile wzf = new WzFile(Path.Combine(baseDir, Capitalize(name) + ".wz"), version);

                WzFileParseStatus parseStatus = wzf.ParseWzFile();
                if (parseStatus != WzFileParseStatus.Success)
                {
                    MessageBox.Show("Error parsing " + name + ".wz (" + parseStatus.GetErrorDescription() + ")");
                    return(false);
                }

                name                = name.ToLower();
                wzFiles[name]       = wzf;
                wzFilesUpdated[wzf] = false;
                wzDirs[name]        = new WzMainDirectory(wzf);
                return(true);
            }
            catch (Exception)
            {
                //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);
            }
        }
        /// <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);


                        WzFileParseStatus parseStatus = File.ParseWzFile();
                        if (parseStatus == WzFileParseStatus.Success)
                        {
                            this.Files.Add(Info.Name, File);

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

                    return(true);
                }
            }
            return(false);
        }
        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);
                }
                WzFileParseStatus parseStatus = f.ParseWzFile();
                if (parseStatus != WzFileParseStatus.Success)
                {
                    file = null;
                    Warning.Error("Error initializing " + Path.GetFileName(path) + " (" + parseStatus.GetErrorDescription() + ").");
                    return(false);
                }

                file = f;
                return(true);
            }
            catch (Exception e)
            {
                Warning.Error("Error initializing " + Path.GetFileName(path) + " (" + e.Message + ").\r\nAlso, check that the directory is valid and the file is not in use.");
                file = null;
                return(false);
            }
        }