public static void Initialize() { PatcherEditorLegacy window = GetWindow <PatcherEditorLegacy>(); window.titleContent = new GUIContent("Patcher"); window.minSize = new Vector2(300f, 355f); window.c_Name = PatchUtils.IsProjectNameValid(Application.productName) ? Application.productName : "MyProject"; window.c_Version = Application.version; window.Show(); }
private void OnGUI() { scrollPosition = GUILayout.BeginScrollView(scrollPosition); GUILayout.BeginVertical(); GUILayout.Space(5f); EditorGUI.BeginChangeCheck(); projectRootPath = PathField("Project directory: ", projectRootPath, true); if (EditorGUI.EndChangeCheck()) { CheckProjectExists(); } GUILayout.Space(5f); GUI.enabled = (project == null || !project.IsRunning) && projectExists.HasValue && !projectExists.Value; if (GUILayout.Button("Create Project", GUILayout.Height(30))) { project = new ProjectManager(projectRootPath); project.CreateProject(); ProjectInfo projectInfo = PatchUtils.GetProjectInfoFromPath(project.projectInfoPath); projectInfo.IgnoredPaths.Add("*output_log.txt"); PatchUtils.SerializeProjectInfoToXML(projectInfo, project.projectInfoPath); SecurityUtils.CreateRSAKeyPairInDirectory(project.utilitiesPath); EditorApplication.update -= OnUpdate; EditorApplication.update += OnUpdate; CheckProjectExists(); } GUI.enabled = (project == null || !project.IsRunning) && projectExists.HasValue && projectExists.Value; if (GUILayout.Button("Generate Patch", GUILayout.Height(30))) { project = new ProjectManager(projectRootPath); if (project.GeneratePatch()) { Debug.Log("<b>Operation started</b>"); EditorApplication.update -= OnUpdate; EditorApplication.update += OnUpdate; } else { Debug.LogWarning("<b>Couldn't start the operation. Maybe it is already running?</b>"); } } DrawHorizontalLine(); if (GUILayout.Button("Update Download Links", GUILayout.Height(30))) { project = new ProjectManager(projectRootPath); project.UpdateDownloadLinks(); EditorApplication.update -= OnUpdate; EditorApplication.update += OnUpdate; } DrawHorizontalLine(); if (GUILayout.Button("Sign XMLs", GUILayout.Height(30))) { ProjectManager project = new ProjectManager(projectRootPath); SecurityUtils.SignXMLsWithKeysInDirectory(project.GetXMLFiles(true, true), project.utilitiesPath); EditorUtility.DisplayDialog("Security", "Don't share your private key with unknown parties!", "Got it!"); Debug.Log("<b>Operation successful...</b>"); } if (GUILayout.Button("Verify Signed XMLs", GUILayout.Height(30))) { string[] invalidXmls; ProjectManager project = new ProjectManager(projectRootPath); if (!SecurityUtils.VerifyXMLsWithKeysInDirectory(project.GetXMLFiles(true, true), project.utilitiesPath, out invalidXmls)) { Debug.Log("<b>The following XMLs could not be verified:</b>"); for (int i = 0; i < invalidXmls.Length; i++) { Debug.Log(invalidXmls[i]); } } else { Debug.Log("<b>All XMLs are verified...</b>"); } } GUI.enabled = true; DrawHorizontalLine(); if (GUILayout.Button("Help", GUILayout.Height(25))) { Application.OpenURL("https://github.com/yasirkula/SimplePatchTool/wiki"); } if (GUILayout.Button("Open Legacy Window", GUILayout.Height(25))) { PatcherEditorLegacy.Initialize(); } GUILayout.EndVertical(); GUILayout.EndScrollView(); }