private void UploadLogToPastebinToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (!File.Exists(Strings.FileName.Log))
            {
                MsgBox.Error(StringLoader.GetText("exception_log_not_exist"));

                return;
            }
#if DEBUG
            Process.Start(Strings.FileName.Log);
#else
            string logTitle = $"{AssemblyAccessor.Version} ({GetSHA256(Application.ExecutablePath).Substring(0, 12)}) at {Methods.DateToString(DateTime.UtcNow)}";
            byte[] logBytes = File.ReadAllBytes(Strings.FileName.Log);
            logBytes = TrimArrayIfNecessary(logBytes);
            string logText  = BitConverter.ToString(logBytes).Replace("-", "");
            var    pasteUrl = UploadToPasteBin(logTitle, logText, PasteBinExpiration.OneHour, false, "text");

            if (!String.IsNullOrEmpty(pasteUrl))
            {
                Clipboard.SetText(pasteUrl);
                MsgBox.Success(StringLoader.GetText("success_log_file_upload", pasteUrl));
            }
            else
            {
                MsgBox.Error(StringLoader.GetText("exception_log_file_failed"));
            }
#endif
        }
示例#2
0
        private void ButtonChangePatcherDirectory_Click(object sender, EventArgs e)
        {
            using (var folderDialog = new FolderBrowserDialog
            {
                Description = StringLoader.GetText("dialog_folder_change_patcher_dir")
            })
            {
                DialogResult result = folderDialog.ShowDialog();

                if (result == DialogResult.OK)
                {
                    if (Methods.IsValidSwPatcherPath(folderDialog.SelectedPath))
                    {
                        this.TextBoxPatcherDirectory.Text = this.PatcherWorkingDirectory = folderDialog.SelectedPath;
                    }
                    else
                    {
                        DialogResult dialogResult = MsgBox.Question(StringLoader.GetText("question_folder_same_path_game"));

                        if (dialogResult == DialogResult.Yes)
                        {
                            this.TextBoxPatcherDirectory.Text = this.PatcherWorkingDirectory = folderDialog.SelectedPath;
                        }
                    }
                }
            }
        }
示例#3
0
        private void ApplyChanges()
        {
            try
            {
                if (UserSettings.PatcherPath != this.PatcherWorkingDirectory)
                {
                    MoveOldPatcherFolder(UserSettings.PatcherPath, this.PatcherWorkingDirectory, (this.Owner as MainForm).GetTranslationFolders());

                    UserSettings.PatcherPath = this.PatcherWorkingDirectory;
                }

                if (UserSettings.WantToPatchExe != this.WantToPatchSoulworkerExe)
                {
                    Region region             = (this.Owner as MainForm).GetSelectedRegion();
                    string gameExePatchedPath = Path.Combine(UserSettings.PatcherPath, region.Folder, Methods.GetGameExeName(region.Id));
                    if (File.Exists(gameExePatchedPath))
                    {
                        File.Delete(gameExePatchedPath);
                    }

                    UserSettings.WantToPatchExe = this.WantToPatchSoulworkerExe;
                }

                if (UserSettings.GameId != this.GameUserId)
                {
                    UserSettings.GameId = this.GameUserId;
                }

                if (this.GameUserPassword != MaskPassword(UserSettings.GamePw))
                {
                    using (var secure = Methods.ToSecureString(this.GameUserPassword))
                    {
                        UserSettings.GamePw = Methods.EncryptString(secure);
                    }
                }

                if (UserSettings.WantToLogin != this.WantToLogin)
                {
                    UserSettings.WantToLogin = this.WantToLogin;
                }

                if (UserSettings.UILanguageCode != this.UILanguage)
                {
                    UserSettings.UILanguageCode = this.UILanguage;
                    this.PendingRestart         = true;
                }

                this.ButtonApply.Enabled = false;

                if (this.PendingRestart)
                {
                    MsgBox.Notice(StringLoader.GetText("notice_pending_restart"));
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                MsgBox.Error(Methods.ExeptionParser(ex));
            }
        }
        private void OpenSWWebpageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Region region = (this.ComboBoxRegions.SelectedItem as Region);

            switch (region.Id)
            {
            case "jp":
                Process.Start(Urls.SoulworkerJPHangeHome);

                break;

            case "gjp":
                Process.Start(Urls.SoulworkerJPGamecomHome);

                break;

            case "kr":
                Process.Start(Urls.SoulworkerKRHome);

                break;

            case "nkr":
                Process.Start(Urls.SoulworkerNaverKRHome);

                break;

            case "gf":
                Process.Start(Urls.SoulworkerGFHome);

                break;

            default:
                throw new Exception(StringLoader.GetText("exception_region_unknown", region.Id));
            }
        }
示例#5
0
        private static string GetGameStartArgumentGamecomJP(MyWebClient client)
        {
            string response = client.DownloadString(Urls.SoulworkerJPGamecomGameStart);

            if (response.Length > 3)
            {
                return(response.Trim('"').Replace("\\", ""));
            }
            else
            {
                switch (response)
                {
                case "110":
                    throw new Exception("error login (110)");

                case "320":
                    throw new Exception(StringLoader.GetText("exception_game_maintenance"));

                case "340":
                    throw new Exception("error block (340)");

                default:
                    throw new Exception($"errCode=[{response}");
                }
            }
        }
示例#6
0
        private static string GetKRGameStartProtocol(MyWebClient client)
        {
            string response      = Encoding.UTF8.GetString(client.UploadData(Urls.SoulworkerKRGameStart, new byte[] { }));
            var    gameStartJSON = new { code = Int32.MaxValue, message = "", memberNo = Int64.MaxValue, gameAuthToken = "", maintenenceType = "", endTime = "", maintenenceTime = "" };
            var    jsonResponse  = JsonConvert.DeserializeAnonymousType(response, gameStartJSON);

            switch (jsonResponse.code)
            {
            case 0:
                return($"sgup://run/11/{jsonResponse.memberNo}/{jsonResponse.gameAuthToken ?? throw new Exception("unexpected null gameAuthToken")}");

            case -1:
                throw new Exception($"You are not logged in.");

            case -3:
                string maintType    = jsonResponse.maintenenceType ?? throw new Exception("unexpected null maintenenceType");
                string maintTime    = jsonResponse.maintenenceTime ?? throw new Exception("unexpected null maintenenceTime");
                string maintEndTime = jsonResponse.endTime ?? throw new Exception("unexpected null endTime");
                string message      = jsonResponse.message ?? throw new Exception("unexpected null message");

                throw new Exception(StringLoader.GetText("exception_game_stove_maintenance", maintType, maintTime, maintEndTime, message.Replace("<p>", "").Replace("</p>", "\n")));

            case -4:
            case -5:

                throw new Exception(StringLoader.GetText("exception_account_not_validated"));

            default:
                throw new Exception($"code=[{jsonResponse.code}]");
            }
        }
示例#7
0
        private static void StartupBackupCheck(Language language)
        {
            if (Directory.Exists(language.BackupPath))
            {
                if (Directory.GetFiles(language.BackupPath, "*", SearchOption.AllDirectories).Length > 0)
                {
                    DialogResult result = MsgBox.Question(StringLoader.GetText("question_backup_files_found", language.ToString()));

                    if (result == DialogResult.Yes)
                    {
                        RestoreBackup(language);
                    }
                    else
                    {
                        string[] filePaths = Directory.GetFiles(language.BackupPath, "*", SearchOption.AllDirectories);

                        foreach (var file in filePaths)
                        {
                            File.Delete(file);
                        }
                    }
                }
            }
            else
            {
                Directory.CreateDirectory(language.BackupPath);
            }
        }
示例#8
0
        private static MyWebClient GamecomLogin(MyWebClient client)
        {
            string id = UserSettings.GameId;
            string pw = UserSettings.GamePw;

            if (String.IsNullOrEmpty(id))
            {
                throw new Exception(StringLoader.GetText("exception_empty_id"));
            }

            var values = new NameValueCollection(2)
            {
                [Strings.Web.JP.Gamecom.PostId] = HttpUtility.UrlEncode(id),
            };

            using (System.Security.SecureString secure = Methods.DecryptString(pw))
            {
                if (String.IsNullOrEmpty(values[Strings.Web.JP.Gamecom.PostPw] = Methods.ToInsecureString(secure)))
                {
                    throw new Exception(StringLoader.GetText("exception_empty_pw"));
                }
            }
            byte[] byteResponse  = client.UploadValues(Urls.GamecomLogin, values);
            string loginResponse = Encoding.GetEncoding("shift-jis").GetString(byteResponse);

            client.DownloadString(Urls.SoulworkerJPGamecomHome);

            return(client);
        }
示例#9
0
 private void InitializeTextComponent()
 {
     this.Text                              = StringLoader.GetText("form_settings");
     this.ButtonOk.Text                     = StringLoader.GetText("button_ok");
     this.ButtonCancel.Text                 = StringLoader.GetText("button_cancel");
     this.ButtonApply.Text                  = StringLoader.GetText("button_apply");
     this.TabPageGame.Text                  = StringLoader.GetText("tab_game");
     this.GroupBoxGameDirectory.Text        = StringLoader.GetText("box_game_dir");
     this.ButtonOpenGameDirectory.Text      = StringLoader.GetText("button_open");
     this.CustomGamePathButton.Text         = StringLoader.GetText("button_change");
     this.ButtonChangePatcherDirectory.Text = StringLoader.GetText("button_change");
     this.GroupBoxPatchExe.Text             = StringLoader.GetText("box_patch_exe");
     this.CheckBoxPatchExe.Text             = StringLoader.GetText("check_patch_exe");
     this.TabPageCredentials.Text           = StringLoader.GetText("tab_credentials");
     this.GroupBoxGameUserId.Text           = StringLoader.GetText("box_id");
     this.GroupBoxGameUserPassword.Text     = StringLoader.GetText("box_pw");
     this.GroupBoxGameWantLogin.Text        = StringLoader.GetText("box_want_login");
     this.CheckBoxWantToLogin.Text          = StringLoader.GetText("check_want_login");
     this.TabPagePatcher.Text               = StringLoader.GetText("tab_patcher");
     this.GroupBoxPatcherDirectory.Text     = StringLoader.GetText("box_patcher_dir");
     this.GroupBoxUILanguagePicker.Text     = StringLoader.GetText("box_language");
     this.GroupBoxGameOptions.Text          = StringLoader.GetText("box_game_options");
     this.ButtonOpenGameOptions.Text        = StringLoader.GetText("button_game_options");
     this.CustomSourceWarnLabel.Text        = "NOTE: The translation source can be a url or a path.\nMake sure it has the correct format, otherwise it won't work.";
 }
示例#10
0
        private static void RestoreBackup(Language language)
        {
            if (!Directory.Exists(language.BackupPath))
            {
                return;
            }

            string regionId       = language.ApplyingRegionId;
            string backupFilePath = Path.Combine(language.BackupPath, Methods.GetGameExeName(regionId));

            if (File.Exists(backupFilePath))
            {
                string gameExePath        = Path.Combine(UserSettings.GamePath, Methods.GetGameExeName(regionId));
                string gameExePatchedPath = Path.Combine(UserSettings.PatcherPath, regionId, Methods.GetGameExeName(regionId));
                Logger.Info($"Restoring .exe original=[{gameExePath}] backup=[{gameExePatchedPath}]");

                if (File.Exists(gameExePath))
                {
                    if (File.Exists(gameExePatchedPath))
                    {
                        File.Delete(gameExePatchedPath);
                    }

                    File.Move(gameExePath, gameExePatchedPath);
                }

                File.Move(backupFilePath, gameExePath);
            }

            string[] filePaths = Directory.GetFiles(language.BackupPath, "*", SearchOption.AllDirectories);

            foreach (var file in filePaths)
            {
                string path = Path.Combine(UserSettings.GamePath, file.Substring(language.BackupPath.Length + 1));
                Logger.Info($"Restoring file original=[{path}] backup=[{file}]");

                if (File.Exists(path))
                {
                    string langPath = Path.Combine(language.Path, path.Substring(UserSettings.GamePath.Length + 1));

                    if (File.Exists(langPath))
                    {
                        File.Delete(langPath);
                    }

                    File.Move(path, langPath);
                }

                try
                {
                    File.Move(file, path);
                }
                catch (DirectoryNotFoundException)
                {
                    MsgBox.Error(StringLoader.GetText("exception_cannot_restore_file", Path.GetFullPath(file)));
                    Logger.Error($"Cannot restore file=[{file}]");
                    File.Delete(file);
                }
            }
        }
示例#11
0
        private void ButtonDownload_Click(object sender, EventArgs e)
        {
            switch (this.CurrentState)
            {
            case State.Idle:
                this.CurrentState = State.RTPatch;
                this._nextState   = NextState.Download;
                this.RTPatcher.Run(this.ComboBoxLanguages.SelectedItem as Language);

                break;

            case State.Download:
                this.ButtonDownload.Text = StringLoader.GetText("button_cancelling");
                this.Downloader.Cancel();

                break;

            case State.Patch:
                this.ButtonDownload.Text = StringLoader.GetText("button_cancelling");
                this.Patcher.Cancel();

                break;

            case State.RTPatch:
                this.ButtonDownload.Text = StringLoader.GetText("button_cancelling");
                this.RTPatcher.Cancel();

                break;
            }
        }
示例#12
0
 private void Downloader_DownloaderProgressChanged(object sender, DownloaderProgressChangedEventArgs e)
 {
     if (this.CurrentState == State.Download)
     {
         this.ToolStripStatusLabel.Text  = $"{StringLoader.GetText("form_status_download")} {e.FileName} ({e.FileNumber}/{e.FileCount})";
         this.ToolStripProgressBar.Value = e.Progress;
     }
 }
示例#13
0
        private void InitRegionsConfigData()
        {
            var    doc     = new XmlDocument();
            string xmlPath = Urls.TranslationGitHubHome + Strings.IniName.LanguagePack;

            Logger.Debug(Methods.MethodFullName(System.Reflection.MethodBase.GetCurrentMethod(), xmlPath));
            doc.Load(xmlPath);

            XmlElement configRoot  = doc.DocumentElement;
            XmlElement xmlRegions  = configRoot[Strings.Xml.Regions];
            int        regionCount = xmlRegions.ChildNodes.Count;

            Region[] regions = new Region[regionCount];

            for (int i = 0; i < regionCount; i++)
            {
                XmlNode regionNode = xmlRegions.ChildNodes[i];

                string     regionId        = regionNode.Name;
                string     regionName      = StringLoader.GetText(regionNode.Attributes[Strings.Xml.Attributes.Name].Value);
                XmlElement xmlLanguages    = regionNode[Strings.Xml.Languages];
                int        languageCount   = xmlLanguages.ChildNodes.Count;
                Language[] regionLanguages = new Language[languageCount];

                for (int j = 0; j < languageCount; j++)
                {
                    XmlNode languageNode = xmlLanguages.ChildNodes[j];

                    string   languageId         = languageNode.Name;
                    string   languageName       = languageNode.Attributes[Strings.Xml.Attributes.Name].Value;
                    string   languageDateString = languageNode[Strings.Xml.Value].InnerText;
                    DateTime languageDate       = Methods.ParseDate(languageDateString);

                    regionLanguages[j] = new Language(languageId, languageName, languageDate, regionId);
                }

                regions[i] = new Region(regionId, regionName, regionLanguages);
            }

            this.ComboBoxRegions.DataSource = regions.Length > 0 ? regions : null;

            if (this.ComboBoxRegions.DataSource != null)
            {
                if (String.IsNullOrEmpty(UserSettings.RegionId))
                {
                    UserSettings.RegionId = (this.ComboBoxRegions.SelectedItem as Region).Id;
                }
                else
                {
                    int index = this.ComboBoxRegions.Items.IndexOf(new Region(UserSettings.RegionId));
                    this.ComboBoxRegions.SelectedIndex = index == -1 ? 0 : index;
                }

                this.ComboBoxRegions_SelectionChangeCommitted(this, EventArgs.Empty);
            }
        }
示例#14
0
        private void CheckNaverKRVersion()
        {
            int serverVersion = Methods.GetKRServerVersion();
            int clientVersion = Convert.ToInt32(Methods.GetRegistryValue(Strings.Registry.NaverKR.RegistryKey, Strings.Registry.NaverKR.Key32Path, Strings.Registry.NaverKR.Version, 0));

            if (clientVersion != serverVersion)
            {
                throw new Exception(StringLoader.GetText("exception_game_not_latest"));
            }
        }
示例#15
0
 private void InitializeTextComponent()
 {
     this.ButtonOk.Text           = StringLoader.GetText("button_ok");
     this.Text                    = $"About {AssemblyAccessor.Title}";
     this.LabelProductName.Text   = AssemblyAccessor.Product;
     this.LabelVersion.Text       = $"Version {AssemblyAccessor.Version}";
     this.TextBoxDescription.Text = StringLoader.GetText("patcher_description");
     this.LinkLabelWebsite.Links.Add(0, this.LinkLabelWebsite.Text.Length, Urls.SoulworkerWebsite);
     this.LogoPictureBox.ImageLocation = $"https://raw.githubusercontent.com/Miyuyami/SWPatcher/master/Images/{(new Random()).Next(ImagesCount) + 1}.png";
 }
示例#16
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            Logger.Debug(Methods.MethodFullName("Downloader", Thread.CurrentThread.ManagedThreadId.ToString(), this.Language.ToString()));

            if (UserSettings.BypassTranslationDateCheck || Methods.HasNewTranslations(this.Language) || Methods.IsTranslationOutdated(this.Language))
            {
                SWFileManager.LoadFileConfiguration(this.Language);
            }
            else
            {
                throw new Exception(StringLoader.GetText("exception_already_latest_translation", Methods.DateToLocalString(this.Language.LastUpdate)));
            }
        }
示例#17
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            this.InitRegionsConfigData();

            StartupBackupCheck(this.ComboBoxLanguages.SelectedItem as Language);

            if (!Methods.IsValidSwPatcherPath(UserSettings.PatcherPath))
            {
                string error = StringLoader.GetText("exception_folder_same_path_game");

                Logger.Error(error);
                MsgBox.Error(error);
            }
        }
示例#18
0
        private static MyWebClient HangeLogin(MyWebClient client)
        {
            string id = UserSettings.GameId;
            string pw = UserSettings.GamePw;

            if (String.IsNullOrEmpty(id))
            {
                throw new Exception(StringLoader.GetText("exception_empty_id"));
            }

            var values = new NameValueCollection(5)
            {
                [Strings.Web.JP.Hange.PostEncodeId]   = HttpUtility.UrlEncode(id),
                [Strings.Web.JP.Hange.PostEncodeFlag] = Strings.Web.JP.Hange.PostEncodeFlagDefaultValue,
                [Strings.Web.JP.Hange.PostId]         = id,
            };

            using (System.Security.SecureString secure = Methods.DecryptString(pw))
            {
                if (String.IsNullOrEmpty(values[Strings.Web.JP.Hange.PostPw] = Methods.ToInsecureString(secure)))
                {
                    throw new Exception(StringLoader.GetText("exception_empty_pw"));
                }
            }
            values[Strings.Web.JP.Hange.PostClearFlag] = Strings.Web.JP.Hange.PostClearFlagDefaultValue;
            values[Strings.Web.JP.Hange.PostNextUrl]   = Strings.Web.JP.Hange.PostNextUrlDefaultValue;

            byte[] byteResponse  = client.UploadValues(Urls.HangeLogin, values);
            string loginResponse = Encoding.GetEncoding("shift-jis").GetString(byteResponse);

            if (loginResponse.Contains(Strings.Web.JP.Hange.CaptchaValidationText) || loginResponse.Contains(Strings.Web.JP.Hange.CaptchaValidationText2))
            {
                Process.Start(Strings.Web.JP.Hange.CaptchaUrl);
                throw new Exception(StringLoader.GetText("exception_captcha_validation"));
            }
            try
            {
                string[] messages = GetVariableValue(loginResponse, Strings.Web.JP.Hange.MessageVariable);

                if (messages[0].Length > 0)
                {
                    throw new Exception(StringLoader.GetText("exception_incorrect_id_pw"));
                }
            }
            catch (IndexOutOfRangeException)
            {
            }

            return(client);
        }
示例#19
0
 private void RTPatcher_DownloadProgressChanged(object sender, RTPatcherDownloadProgressChangedEventArgs e)
 {
     if (this.CurrentState == State.RTPatch)
     {
         if (e.Progress == -1)
         {
             this.ToolStripStatusLabel.Text  = $"{StringLoader.GetText("form_status_prepare")} {e.FileName}";
             this.ToolStripProgressBar.Style = ProgressBarStyle.Marquee;
         }
         else
         {
             this.ToolStripStatusLabel.Text  = $"{StringLoader.GetText("form_status_update_client")} {e.FileName} - {e.DownloadSpeed}";
             this.ToolStripProgressBar.Value = e.Progress;
         }
     }
 }
示例#20
0
 private void RTPatcher_ProgressChanged(object sender, RTPatcherProgressChangedEventArgs e)
 {
     if (CurrentState == State.RTPatch)
     {
         if (e.Progress == -1)
         {
             ToolStripStatusLabel.Text  = $"{StringLoader.GetText("form_status_prepare")} {e.FileName} ({e.FileNumber}/{e.FileCount})";
             ToolStripProgressBar.Style = ProgressBarStyle.Marquee;
         }
         else
         {
             ToolStripStatusLabel.Text  = $"{StringLoader.GetText("form_status_update_client")} {e.FileName} ({e.FileNumber}/{e.FileCount})";
             ToolStripProgressBar.Style = ProgressBarStyle.Blocks;
             ToolStripProgressBar.Value = e.Progress;
         }
     }
 }
示例#21
0
        private void CheckGlobalVersion()
        {
            var manifest = Methods.GetSoulworkerSteamManifest();

            if (manifest != null)
            {
                if (manifest.Elements.TryGetValue("StateFlags", out SteamManifestElement sme) &&
                    sme is SteamManifestEntry entry &&
                    Int32.TryParse(entry.Value, out int stateFlagInt) &&
                    (AppState)stateFlagInt == AppState.StateFullyInstalled)
                {
                    return;
                }
            }

            throw new Exception(StringLoader.GetText("exception_game_not_latest"));
        }
示例#22
0
        private void ComboBoxLanguages_SelectionChangeCommitted(object sender, EventArgs e)
        {
            if (this.ComboBoxLanguages.SelectedItem is Language language)
            {
                Logger.Info($"Selected language '{language}'");
                UserSettings.LanguageId = this.ComboBoxLanguages.SelectedIndex == -1 ? null : (this.ComboBoxLanguages.SelectedItem as Language).Id;

                if (Methods.HasNewTranslations(language))
                {
                    this.LabelNewTranslations.Text = StringLoader.GetText("form_label_new_translation", language, Methods.DateToLocalString(language.LastUpdate));
                }
                else
                {
                    this.LabelNewTranslations.Text = String.Empty;
                }
            }
        }
示例#23
0
        private void ButtonPlay_Click(object sender, EventArgs e)
        {
            switch (this.CurrentState)
            {
            case State.Idle:
                this.CurrentState = State.RTPatch;
                this._nextState   = NextState.Play;
                this.RTPatcher.Run(this.ComboBoxLanguages.SelectedItem as Language);

                break;

            case State.WaitClient:
                this.ButtonPlay.Text = StringLoader.GetText("button_cancelling");
                this.GameStarter.Cancel();

                break;
            }
        }
示例#24
0
 private void InitializeTextComponent()
 {
     this.MenuToolStripMenuItem.Text                = StringLoader.GetText("form_menu");
     this.ForceToolStripMenuItem.Text               = StringLoader.GetText("form_force_patch");
     this.OpenSWWebpageToolStripMenuItem.Text       = StringLoader.GetText("form_open_sw_webpage");
     this.UploadLogToPastebinToolStripMenuItem.Text = StringLoader.GetText("form_upload_log");
     this.SettingsToolStripMenuItem.Text            = StringLoader.GetText("form_settings");
     this.RefreshToolStripMenuItem.Text             = StringLoader.GetText("form_refresh");
     this.AboutToolStripMenuItem.Text               = StringLoader.GetText("form_about");
     this.LabelRegionPick.Text           = StringLoader.GetText("form_region_pick");
     this.LabelLanguagePick.Text         = StringLoader.GetText("form_language_pick");
     this.ButtonDownload.Text            = StringLoader.GetText("button_download_translation");
     this.ButtonPlay.Text                = StringLoader.GetText("button_play");
     this.ButtonExit.Text                = StringLoader.GetText("button_exit");
     this.NotifyIcon.BalloonTipText      = StringLoader.GetText("notify_balloon_text");
     this.NotifyIcon.BalloonTipTitle     = StringLoader.GetText("notify_balloon_title");
     this.NotifyIcon.Text                = StringLoader.GetText("notify_text");
     this.ToolStripMenuItemStartRaw.Text = StringLoader.GetText("button_play_raw");
     this.Text = AssemblyAccessor.Title + " " + AssemblyAccessor.Version;
 }
示例#25
0
        private void Patcher_PatcherCompleted(object sender, PatcherCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                Logger.Debug($"{sender.ToString()} cancelled");
                DeleteTmpFiles(e.Language);
            }
            else if (e.Error != null)
            {
                Logger.Error(e.Error);
                MsgBox.Error(Methods.ExeptionParser(e.Error));
                DeleteTmpFiles(e.Language);
            }
            else
            {
                Logger.Debug($"{sender.ToString()} successfuly completed");

                string clientIniPath = Path.Combine(UserSettings.GamePath, Strings.IniName.ClientVer);
                if (!Methods.LoadVerIni(out IniFile clientIni, clientIniPath))
                {
                    throw new Exception(StringLoader.GetText("exception_generic_read_error", clientIniPath));
                }
                IniSection clientVerSection = clientIni.Sections[Strings.IniName.Ver.Section];

                string translationIniPath = Path.Combine(e.Language.Path, Strings.IniName.Translation);
                var    translationIni     = new IniFile();

                IniKey     translationDateKey        = new IniKey(translationIni, Strings.IniName.Patcher.KeyDate, Methods.DateToString(e.Language.LastUpdate));
                IniSection translationPatcherSection = new IniSection(translationIni, Strings.IniName.Patcher.Section, translationDateKey);

                translationIni.Sections.Add(translationPatcherSection);
                translationIni.Sections.Add(clientVerSection.Copy(translationIni));
                Logger.Debug($"Saving translation config to [{translationIniPath}]");
                translationIni.Save(translationIniPath);
            }

            SWFileManager.DisposeFileData();
            GC.Collect();
            this.CurrentState = State.Idle;
        }
示例#26
0
        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (e.CloseReason.In(CloseReason.ApplicationExitCall, CloseReason.WindowsShutDown))
            {
                Logger.Info($"{this.Text} closing abnormally. Reason=[{e.CloseReason.ToString()}]");
                this.CurrentState = State.Idle;
                this.RTPatcher.Cancel();
                this.Downloader.Cancel();
                this.Patcher.Cancel();
                this.GameStarter.Cancel();
            }
            else if (!this.CurrentState.In(State.Idle, State.RegionNotInstalled))
            {
                MsgBox.Error(StringLoader.GetText("exception_cannot_close", AssemblyAccessor.Title));

                e.Cancel = true;
            }
            else
            {
                Logger.Info($"{this.Text} closing. Reason=[{e.CloseReason.ToString()}]");
            }
        }
示例#27
0
        private string UploadToPasteBin(string title, string text, PasteBinExpiration expiration, bool isPrivate, string format)
        {
            var client = new PasteBinClient(Strings.PasteBin.DevKey);

            try
            {
                client.Login(Strings.PasteBin.Username, Strings.PasteBin.Password);
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
            }

            var entry = new PasteBinEntry
            {
                Title      = title,
                Text       = text,
                Expiration = expiration,
                Private    = isPrivate,
                Format     = format
            };

            try
            {
                return(client.Paste(entry));
            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                MsgBox.Error(StringLoader.GetText("exception_log_file_failed"));
            }
            finally
            {
                client.Logout();
            }

            return(null);
        }
示例#28
0
 private void InitializeTextComponent()
 {
     this.Text                              = StringLoader.GetText("form_settings");
     this.ButtonOk.Text                     = StringLoader.GetText("button_ok");
     this.ButtonCancel.Text                 = StringLoader.GetText("button_cancel");
     this.ButtonApply.Text                  = StringLoader.GetText("button_apply");
     this.TabPageGame.Text                  = StringLoader.GetText("tab_game");
     this.GroupBoxGameDirectory.Text        = StringLoader.GetText("box_game_dir");
     this.ButtonOpenGameDirectory.Text      = StringLoader.GetText("button_open");
     this.ButtonChangePatcherDirectory.Text = StringLoader.GetText("button_change");
     this.GroupBoxPatchExe.Text             = StringLoader.GetText("box_patch_exe");
     this.CheckBoxPatchExe.Text             = StringLoader.GetText("check_patch_exe");
     this.TabPageCredentials.Text           = StringLoader.GetText("tab_credentials");
     this.GroupBoxGameUserId.Text           = StringLoader.GetText("box_id");
     this.GroupBoxGameUserPassword.Text     = StringLoader.GetText("box_pw");
     this.GroupBoxGameWantLogin.Text        = StringLoader.GetText("box_want_login");
     this.CheckBoxWantToLogin.Text          = StringLoader.GetText("check_want_login");
     this.TabPagePatcher.Text               = StringLoader.GetText("tab_patcher");
     this.GroupBoxPatcherDirectory.Text     = StringLoader.GetText("box_patcher_dir");
     this.GroupBoxUILanguagePicker.Text     = StringLoader.GetText("box_language");
     this.GroupBoxGameOptions.Text          = StringLoader.GetText("box_game_options");
     this.ButtonOpenGameOptions.Text        = StringLoader.GetText("button_game_options");
 }
示例#29
0
        private void GameStarter_GameStarterCompleted(object sender, GameStarterCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                Logger.Debug($"{sender.ToString()} cancelled.");
            }
            else if (e.Error != null)
            {
                Logger.Error(e.Error);
                MsgBox.Error(e.Error.Message);
            }
            else if (e.NeedsForcePatch)
            {
                MsgBox.Notice(StringLoader.GetText("notice_outdated_translation"));
                ResetTranslation(e.Language);

                this.CurrentState = State.RTPatch;
                this._nextState   = NextState.Download;
                this.RTPatcher.Run(e.Language);

                return;
            }
            else
            {
                Logger.Debug($"{sender.ToString()} successfuly completed");
                this.RestoreFromTray();
            }

            try
            {
                RestoreBackup(e.Language);
            }
            finally
            {
                this.CurrentState = State.Idle;
            }
        }
示例#30
0
        private void CheckGFLauncherVersion()
        {
            string gameforgeInstallPath;
            string metadataGameState;

            if (!Environment.Is64BitOperatingSystem)
            {
                gameforgeInstallPath = Methods.GetRegistryValue(Strings.Registry.Gameforge.RegistryKey, Strings.Registry.Gameforge.Key32Path, Strings.Registry.Gameforge.InstallPath);
                metadataGameState    = Methods.GetRegistryValue(Strings.Registry.Gameforge.RegistryKey, Strings.Registry.Gameforge.Metadata32Path, Strings.Registry.Gameforge.GameState);
            }
            else
            {
                gameforgeInstallPath = Methods.GetRegistryValue(Strings.Registry.Gameforge.RegistryKey, Strings.Registry.Gameforge.Key64Path, Strings.Registry.Gameforge.InstallPath);
                metadataGameState    = Methods.GetRegistryValue(Strings.Registry.Gameforge.RegistryKey, Strings.Registry.Gameforge.Metadata64Path, Strings.Registry.Gameforge.GameState);

                if (gameforgeInstallPath == String.Empty)
                {
                    gameforgeInstallPath = Methods.GetRegistryValue(Strings.Registry.Gameforge.RegistryKey, Strings.Registry.Gameforge.Key32Path, Strings.Registry.Gameforge.InstallPath);
                    metadataGameState    = Methods.GetRegistryValue(Strings.Registry.Gameforge.RegistryKey, Strings.Registry.Gameforge.Metadata32Path, Strings.Registry.Gameforge.GameState);
                }
            }

            if (gameforgeInstallPath == String.Empty)
            {
                throw new Exception(StringLoader.GetText("exception_game_not_latest"));
            }

            if (metadataGameState == String.Empty)
            {
                throw new Exception(StringLoader.GetText("exception_game_not_latest"));
            }

            if (metadataGameState != "1")
            {
                throw new Exception(StringLoader.GetText("exception_game_not_latest"));
            }
        }