GUI: Add JSON output support
This commit is contained in:
@@ -366,7 +366,7 @@
|
||||
<!-- IDAPython script -->
|
||||
<RadioButton GroupName="grpOutputType" Name="rdoOutputIDA" VerticalContentAlignment="Center" FontSize="18" Foreground="{StaticResource MicrosoftGreen}">IDAPython script</RadioButton>
|
||||
<DockPanel>
|
||||
<ComboBox Name="cboUnityVersion" DockPanel.Dock="Right" Margin="4"></ComboBox>
|
||||
<ComboBox Name="cboIdaUnityVersion" DockPanel.Dock="Right" Margin="4"></ComboBox>
|
||||
<Label DockPanel.Dock="Left" Width="170" VerticalAlignment="Center" HorizontalAlignment="Left">Unity version (if known):</Label>
|
||||
</DockPanel>
|
||||
|
||||
@@ -385,6 +385,16 @@
|
||||
</ComboBox>
|
||||
<Label DockPanel.Dock="Left" Width="250" VerticalAlignment="Center" HorizontalAlignment="Left">Target C++ compiler for output:</Label>
|
||||
</DockPanel>
|
||||
|
||||
<Separator Margin="5,15,5,15"/>
|
||||
|
||||
<!-- JSON metadata -->
|
||||
<RadioButton GroupName="grpOutputType" Name="rdoOutputJSON" VerticalContentAlignment="Center" FontSize="18" Foreground="{StaticResource MicrosoftGreen}">JSON metadata</RadioButton>
|
||||
<DockPanel>
|
||||
<ComboBox Name="cboJsonUnityVersion" DockPanel.Dock="Right" Margin="4"></ComboBox>
|
||||
<Label DockPanel.Dock="Left" Width="170" VerticalAlignment="Center" HorizontalAlignment="Left">Unity version (if known):</Label>
|
||||
</DockPanel>
|
||||
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</DockPanel>
|
||||
|
||||
@@ -215,19 +215,24 @@ namespace Il2CppInspectorGUI
|
||||
trvNamespaces.ItemsSource = namespaceTree;
|
||||
|
||||
// Populate Unity version combo boxes
|
||||
var prevSelection = cboUnityVersion.SelectedItem;
|
||||
var prevIdaSelection = cboIdaUnityVersion.SelectedItem;
|
||||
var prevCppSelection = cboCppUnityVersion.SelectedItem;
|
||||
cboUnityVersion.Items.Clear();
|
||||
var prevJsonSelection = cboJsonUnityVersion.SelectedItem;
|
||||
cboIdaUnityVersion.Items.Clear();
|
||||
cboCppUnityVersion.Items.Clear();
|
||||
cboJsonUnityVersion.Items.Clear();
|
||||
foreach (var version in UnityHeaders.GuessHeadersForBinary(model.Package.Binary)) {
|
||||
cboUnityVersion.Items.Add(version);
|
||||
cboIdaUnityVersion.Items.Add(version);
|
||||
cboCppUnityVersion.Items.Add(version);
|
||||
cboJsonUnityVersion.Items.Add(version);
|
||||
}
|
||||
cboUnityVersion.SelectedIndex = cboUnityVersion.Items.Count - 1;
|
||||
cboIdaUnityVersion.SelectedIndex = cboIdaUnityVersion.Items.Count - 1;
|
||||
cboCppUnityVersion.SelectedIndex = cboCppUnityVersion.Items.Count - 1;
|
||||
if (prevSelection != null) {
|
||||
cboUnityVersion.SelectedItem = prevSelection;
|
||||
cboJsonUnityVersion.SelectedIndex = cboJsonUnityVersion.Items.Count - 1;
|
||||
if (prevIdaSelection != null) {
|
||||
cboIdaUnityVersion.SelectedItem = prevIdaSelection;
|
||||
cboCppUnityVersion.SelectedItem = prevCppSelection;
|
||||
cboJsonUnityVersion.SelectedItem = prevJsonSelection;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -407,26 +412,26 @@ namespace Il2CppInspectorGUI
|
||||
// IDA Python script
|
||||
case { rdoOutputIDA: var r } when r.IsChecked == true:
|
||||
|
||||
var scriptSaveFileDialog = new SaveFileDialog {
|
||||
var idaSaveFileDialog = new SaveFileDialog {
|
||||
Filter = "Python scripts (*.py)|*.py|All files (*.*)|*.*",
|
||||
FileName = "ida.py",
|
||||
CheckFileExists = false,
|
||||
OverwritePrompt = true
|
||||
};
|
||||
|
||||
if (scriptSaveFileDialog.ShowDialog() == false)
|
||||
if (idaSaveFileDialog.ShowDialog() == false)
|
||||
return;
|
||||
|
||||
var outFile = scriptSaveFileDialog.FileName;
|
||||
var idaOutFile = idaSaveFileDialog.FileName;
|
||||
|
||||
areaBusyIndicator.Visibility = Visibility.Visible;
|
||||
var selectedVersion = ((UnityHeaders) cboUnityVersion.SelectedItem)?.VersionRange.Min;
|
||||
var selectedIdaUnityVersion = ((UnityHeaders) cboIdaUnityVersion.SelectedItem)?.VersionRange.Min;
|
||||
await Task.Run(() => {
|
||||
OnStatusUpdate(this, "Building C++ application model");
|
||||
model.Build(selectedVersion, CppCompilerType.GCC);
|
||||
model.Build(selectedIdaUnityVersion, CppCompilerType.GCC);
|
||||
|
||||
OnStatusUpdate(this, "Generating IDAPython script");
|
||||
new IDAPythonScript(model).WriteScriptToFile(outFile);
|
||||
new IDAPythonScript(model).WriteScriptToFile(idaOutFile);
|
||||
});
|
||||
break;
|
||||
|
||||
@@ -454,6 +459,32 @@ namespace Il2CppInspectorGUI
|
||||
new CppScaffolding(model).Write(cppOutPath);
|
||||
});
|
||||
break;
|
||||
|
||||
// JSON metadata
|
||||
case { rdoOutputJSON: var r } when r.IsChecked == true:
|
||||
|
||||
var jsonSaveFileDialog = new SaveFileDialog {
|
||||
Filter = "JSON files (*.json)|*.json|All files (*.*)|*.*",
|
||||
FileName = "metadata.json",
|
||||
CheckFileExists = false,
|
||||
OverwritePrompt = true
|
||||
};
|
||||
|
||||
if (jsonSaveFileDialog.ShowDialog() == false)
|
||||
return;
|
||||
|
||||
var jsonOutFile = jsonSaveFileDialog.FileName;
|
||||
|
||||
areaBusyIndicator.Visibility = Visibility.Visible;
|
||||
var selectedJsonUnityVersion = ((UnityHeaders) cboJsonUnityVersion.SelectedItem)?.VersionRange.Min;
|
||||
await Task.Run(() => {
|
||||
OnStatusUpdate(this, "Building C++ application model");
|
||||
model.Build(selectedJsonUnityVersion, CppCompilerType.GCC);
|
||||
|
||||
OnStatusUpdate(this, "Generating JSON metadata file");
|
||||
new JSONMetadata(model).Write(jsonOutFile);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
areaBusyIndicator.Visibility = Visibility.Hidden;
|
||||
|
||||
Reference in New Issue
Block a user