Example #1
0
        /// <summary>
        /// Begin loading WZ data corresponding to the selected tab
        /// </summary>
        private void BtnWzLoad_Click(object sender, EventArgs e)
        {
            string folderPath = TextWzPath.Text;

            if (folderPath.Length > 0)
            {
                if (!folderPath.Equals(Settings.Default.PathCache))
                {
                    Settings.Default.PathCache = folderPath;
                    Settings.Default.Save();
                }
                string         stringWzPath = folderPath + @"/String";
                WzMapleVersion mapleVersion;

                if (File.Exists(stringWzPath + Resources.FileExtension))
                {
                    if (ComboEncType.SelectedIndex == 0)
                    {
                        mapleVersion = WzTool.DetectMapleVersion(stringWzPath + Resources.FileExtension, out _);
                    }
                    else
                    {
                        mapleVersion = (WzMapleVersion)
                                       ComboEncType.SelectedIndex - 1;
                    }

                    StringWz = new WzFile(stringWzPath + Resources.FileExtension, mapleVersion);
                    StringWz.ParseWzFile();
                    short?version = StringWz.FileVersion;
                    if (WzTool.GetDecryptionSuccessRate(stringWzPath + Resources.FileExtension, mapleVersion, ref version) < 0.8)
                    {
                        MessageBox.Show(Resources.BadEncryption, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                }
                else if (Directory.Exists(stringWzPath))     // KMS
                {
                    mapleVersion = WzMapleVersion.EMS;
                    StringWz     = new WzFile(stringWzPath, mapleVersion);
                    WzDirectory dir = new WzDirectory("String", StringWz);
                    StringWz.WzDirectory = dir;
                    RecursivelyLoadDirectory(dir, stringWzPath, mapleVersion);
                }
                else
                {
                    MessageBox.Show(Resources.MissingStringFile, Resources.FIleNotFound, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    DisposeWzFiles();
                    return;
                }
                StringUtility = new WzStringUtility(StringWz);
                LoadWzData(mapleVersion, folderPath);
            }
            DisposeWzFiles();
        }