From 470ae984784dc682b8a13569b6217a049ba376a2 Mon Sep 17 00:00:00 2001 From: Miepee <38186597+Miepee@users.noreply.github.com> Date: Sun, 12 Jun 2022 16:16:34 +0200 Subject: [PATCH] Get rid of GraphViz functionality --- .../Editors/UndertaleCodeEditor.xaml | 15 ++-- .../Editors/UndertaleCodeEditor.xaml.cs | 76 +------------------ UndertaleModTool/Settings.cs | 3 +- UndertaleModTool/UndertaleModTool.csproj | 1 - UndertaleModTool/Windows/SettingsWindow.xaml | 3 - .../Windows/SettingsWindow.xaml.cs | 10 --- 6 files changed, 7 insertions(+), 101 deletions(-) diff --git a/UndertaleModTool/Editors/UndertaleCodeEditor.xaml b/UndertaleModTool/Editors/UndertaleCodeEditor.xaml index 97cbad05e..d22a14074 100644 --- a/UndertaleModTool/Editors/UndertaleCodeEditor.xaml +++ b/UndertaleModTool/Editors/UndertaleCodeEditor.xaml @@ -1,11 +1,11 @@  @@ -44,7 +44,7 @@ - - - - - diff --git a/UndertaleModTool/Editors/UndertaleCodeEditor.xaml.cs b/UndertaleModTool/Editors/UndertaleCodeEditor.xaml.cs index 7165283a9..26b041157 100644 --- a/UndertaleModTool/Editors/UndertaleCodeEditor.xaml.cs +++ b/UndertaleModTool/Editors/UndertaleCodeEditor.xaml.cs @@ -1,7 +1,4 @@ -using GraphVizWrapper; -using GraphVizWrapper.Commands; -using GraphVizWrapper.Queries; -using ICSharpCode.AvalonEdit; +using ICSharpCode.AvalonEdit; using ICSharpCode.AvalonEdit.Document; using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Folding; @@ -50,7 +47,6 @@ public partial class UndertaleCodeEditor : DataUserControl public UndertaleCode CurrentDisassembled = null; public UndertaleCode CurrentDecompiled = null; public List CurrentLocals = null; - public UndertaleCode CurrentGraphed = null; public string ProfileHash = mainWindow.ProfileHash; public string MainPath = Path.Combine(Settings.ProfilesFolder, mainWindow.ProfileHash, "Main"); public string TempPath = Path.Combine(Settings.ProfilesFolder, mainWindow.ProfileHash, "Temp"); @@ -199,10 +195,6 @@ private async void TabControl_SelectionChanged(object sender, SelectionChangedEv _ = DecompileCode(code, !DecompiledYet); DecompiledYet = true; } - if (GraphTab.IsSelected && code != CurrentGraphed) - { - GraphCode(code); - } } private async void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) @@ -259,10 +251,6 @@ private async void UserControl_DataContextChanged(object sender, DependencyPrope { _ = DecompileCode(code, true); } - if (GraphTab.IsSelected && code != CurrentGraphed) - { - GraphCode(code); - } } } @@ -556,66 +544,6 @@ private async Task DecompileCode(UndertaleCode code, bool first, LoaderDialog ex } } - private async void GraphCode(UndertaleCode code) - { - if (code.ParentEntry != null) - { - GraphView.Source = null; - CurrentGraphed = code; - return; - } - - LoaderDialog dialog = new LoaderDialog("Generating graph", "Generating graph, please wait..."); - dialog.Owner = Window.GetWindow(this); - Task t = Task.Run(() => - { - ImageSource image = null; - try - { - code.UpdateAddresses(); - List entryPoints = new List(); - entryPoints.Add(0); - foreach (UndertaleCode duplicate in code.ChildEntries) - entryPoints.Add(duplicate.Offset / 4); - var blocks = Decompiler.DecompileFlowGraph(code, entryPoints); - string dot = Decompiler.ExportFlowGraph(blocks); - - try - { - var getStartProcessQuery = new GetStartProcessQuery(); - var getProcessStartInfoQuery = new GetProcessStartInfoQuery(); - var registerLayoutPluginCommand = new RegisterLayoutPluginCommand(getProcessStartInfoQuery, getStartProcessQuery); - var wrapper = new GraphGeneration(getStartProcessQuery, getProcessStartInfoQuery, registerLayoutPluginCommand); - wrapper.GraphvizPath = Settings.Instance.GraphVizPath; - - byte[] output = wrapper.GenerateGraph(dot, Enums.GraphReturnType.Png); // TODO: Use SVG instead - - image = new ImageSourceConverter().ConvertFrom(output) as ImageSource; - } - catch (Exception e) - { - Debug.WriteLine(e.ToString()); - if (mainWindow.ShowQuestion("Unable to execute GraphViz: " + e.Message + "\nMake sure you have downloaded it and set the path in settings.\nDo you want to open the download page now?", MessageBoxImage.Error) == MessageBoxResult.Yes) - MainWindow.OpenBrowser("https://graphviz.gitlab.io/_pages/Download/Download_windows.html"); - } - } - catch (Exception e) - { - Debug.WriteLine(e.ToString()); - mainWindow.ShowError(e.Message, "Graph generation failed"); - } - - Dispatcher.Invoke(() => - { - GraphView.Source = image; - CurrentGraphed = code; - dialog.Hide(); - }); - }); - dialog.ShowDialog(); - await t; - } - private void DecompiledEditor_GotFocus(object sender, RoutedEventArgs e) { if (DecompiledEditor.IsReadOnly) @@ -744,7 +672,6 @@ private async Task DecompiledLostFocusBody(object sender, RoutedEventArgs e) // Show new code, decompiled. CurrentDisassembled = null; CurrentDecompiled = null; - CurrentGraphed = null; // Tab switch if (e == null) @@ -822,7 +749,6 @@ private void DisassemblyEditor_LostFocus(object sender, RoutedEventArgs e) // Get rid of old code CurrentDisassembled = null; CurrentDecompiled = null; - CurrentGraphed = null; // Tab switch if (e == null) diff --git a/UndertaleModTool/Settings.cs b/UndertaleModTool/Settings.cs index f02ba9742..a235af3e6 100644 --- a/UndertaleModTool/Settings.cs +++ b/UndertaleModTool/Settings.cs @@ -16,7 +16,6 @@ public class Settings public static string ProfilesFolder = Path.Combine(AppDataFolder, "Profiles"); public string Version { get; set; } = MainWindow.Version; - public string GraphVizPath { get; set; } = ".\\graphviz\\bin"; public string GameMakerStudioPath { get; set; } = "%appdata%\\GameMaker-Studio"; public string GameMakerStudio2RuntimesPath { get; set; } = "%systemdrive%\\ProgramData\\GameMakerStudio2\\Cache\\runtimes"; /* Using %systemdrive% here fixes the runtimes not being found when the system drive is not C:\\ */ public bool AssetOrderSwappingEnabled { get; set; } = false; @@ -37,7 +36,7 @@ public class Settings // old backups only after 20 is reached (in the family tree, other unrelated mod families don't count) // starting with the oldest, with which one to clear determined from a parenting ledger file // (whose implementation does not exist yet). - // + // // This comment should be cleared in the event that the remedies described are implemented. public bool DeleteOldProfileOnSave { get; set; } = false; diff --git a/UndertaleModTool/UndertaleModTool.csproj b/UndertaleModTool/UndertaleModTool.csproj index 64df11a35..a38f7e5ac 100644 --- a/UndertaleModTool/UndertaleModTool.csproj +++ b/UndertaleModTool/UndertaleModTool.csproj @@ -3551,7 +3551,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - 1.1.4 diff --git a/UndertaleModTool/Windows/SettingsWindow.xaml b/UndertaleModTool/Windows/SettingsWindow.xaml index 5e3e7b842..31c41c499 100644 --- a/UndertaleModTool/Windows/SettingsWindow.xaml +++ b/UndertaleModTool/Windows/SettingsWindow.xaml @@ -30,9 +30,6 @@ - - - diff --git a/UndertaleModTool/Windows/SettingsWindow.xaml.cs b/UndertaleModTool/Windows/SettingsWindow.xaml.cs index 707c211ad..122c5145b 100644 --- a/UndertaleModTool/Windows/SettingsWindow.xaml.cs +++ b/UndertaleModTool/Windows/SettingsWindow.xaml.cs @@ -21,16 +21,6 @@ namespace UndertaleModTool /// public partial class SettingsWindow : Window { - public static string GraphVizPath - { - get => Settings.Instance.GraphVizPath; - set - { - Settings.Instance.GraphVizPath = value; - Settings.Save(); - } - } - public static string GameMakerStudioPath { get => Settings.Instance.GameMakerStudioPath;