private void gameFolderPathTextBox_Pasting(object sender, DataObjectPastingEventArgs e) { var isText = e.SourceDataObject.GetDataPresent(DataFormats.UnicodeText, true); if (!isText) { return; } var text = e.SourceDataObject.GetData(DataFormats.UnicodeText) as string; if (text.Last() != '\\') { e.CancelCommand(); gameFolderPathTextBox.Text = text + '\\'; return; } if (UnityL10nToolCppManaged.DetermineProjectGamePath(text, GameName, MakerName)) { ErrorMessageTextBlock.Visibility = Visibility.Hidden; } else { gameFolderPathTextBox.Text += text + DataFolderName + "_Data\\"; return; } }
private void gameFolderPathTextBox_TextChanged(object sender, TextChangedEventArgs e) { string tempPath = gameFolderPathTextBox.Text; if (gameFolderPathTextBox.Text.Last() != '\\') { gameFolderPathTextBox.Text += '\\'; return; } if (UnityL10nToolCppManaged.DetermineProjectGamePath(gameFolderPathTextBox.Text, GameName, MakerName)) { ErrorMessageTextBlock.Visibility = Visibility.Hidden; } else { string tempStr = gameFolderPathTextBox.Text + DataFolderName + "_Data\\"; if (UnityL10nToolCppManaged.DetermineProjectGamePath(tempStr, GameName, MakerName)) { gameFolderPathTextBox.Text += DataFolderName + "_Data\\"; ErrorMessageTextBlock.Visibility = Visibility.Hidden; } else { ErrorMessageTextBlock.Visibility = Visibility.Visible; } return; } }
public MainWindow() { DataContext = this; InitializeComponent(); string jsonStr = System.IO.File.ReadAllText("setting.json"); patcherJson = JObject.Parse(jsonStr); DataFolderName = (string)patcherJson["DataFolderName"]; GameName = (string)patcherJson["GameName"]; MakerName = (string)patcherJson["MakerName"]; Title = GameName + " Patcher"; gameFolderPathTextBox.Text = UnityL10nToolCppManaged.FindUnityGameFolderFromDataFolderName(DataFolderName, GameName, MakerName); if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "customMain.png")) { Uri uri = new Uri(AppDomain.CurrentDomain.BaseDirectory + "customMain.png", UriKind.RelativeOrAbsolute); MainImage.Source = BitmapFrame.Create(uri); } else { } }
private async void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e) { string gamePath = (string)e.Argument; if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Loading patcher configuration..."); } unityL10nToolCppManaged = new UnityL10nToolCppManaged(".\\", gamePath); if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Downloading resources..."); } List <Task> downloadTasksQuery = new List <Task>(); foreach (OnlineResourcePairCLI onlineResourcePairCLI in OnlineResourcePairCLIs) { WebClient webClient = new WebClient(); // https://stackoverflow.com/questions/47576074/get-releases-github-api-v3 webClient.Headers.Add("User-Agent", "UnityL10nTool"); downloadTasksQuery.Add(webClient.DownloadFileTaskAsync(onlineResourcePairCLI.URL, "temp\\" + onlineResourcePairCLI.filePath)); } Task[] downloadTasks = downloadTasksQuery.ToArray(); if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Loading globalgamemanagers..."); } unityL10nToolCppManaged.LoadGlobalgamemanagersFile(); if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Loading Resource and MonoManager..."); } unityL10nToolCppManaged.ProcessResourceAndMonoManger(); if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Loading mono ClassDatabase..."); } unityL10nToolCppManaged.LoadMonoClassDatabase(); if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Loading UnityL10nTool API..."); } unityL10nToolCppManaged.LoadUnityL10nToolAPI(); await Task.WhenAll(downloadTasks); if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Downloading resources..."); } //unityL10nToolCppManaged.GetOnlineResourcePairs(); //unityL10nToolCppManaged.DownloadResourcesFromInternetToTempFolder(); if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Loading font plugins..."); } List <string> loadedFontPlugins = unityL10nToolCppManaged.LoadFontPlugins(); if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Setting patcher configuration..."); } unityL10nToolCppManaged.SetPacherConfigJson(); if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Loading font assets replacers..."); } unityL10nToolCppManaged.LoadAssetsReplacer(); if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Loading text plugins..."); } unityL10nToolCppManaged.LoadTextPlugins(); if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Loading text asset maps..."); } unityL10nToolCppManaged.GetTextAssetMaps(); if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Loading translated text assets from file..."); } unityL10nToolCppManaged.GetTranslatedTextAssetsFromFile(); if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Loading text assets replacers..."); } unityL10nToolCppManaged.GetAssetReplacerFromTextAssets(); if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Making modified assets files..."); } unityL10nToolCppManaged.MakeModifiedAssetsFile(); if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Copying resource files to game folder..."); } unityL10nToolCppManaged.CopyResourceFileToGameFolder(); unityL10nToolCppManaged.GetCopyResourcesManualPairs(); unityL10nToolCppManaged.CopyResourcesManualPairsForPatcher(); if (sender != null) { PatchBackgroundWorker.ReportProgress(1, "Done..."); } }