GUI: Add C++ scaffolding output support
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
xmlns:local="clr-namespace:Il2CppInspectorGUI"
|
xmlns:local="clr-namespace:Il2CppInspectorGUI"
|
||||||
xmlns:gif="https://github.com/XamlAnimatedGif/XamlAnimatedGif"
|
xmlns:gif="https://github.com/XamlAnimatedGif/XamlAnimatedGif"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Il2CppInspector" Height="700" Width="990" Background="White"
|
Title="Il2CppInspector" Height="700" Width="1050" Background="White"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
ContentRendered="MainWindow_OnContentRendered">
|
ContentRendered="MainWindow_OnContentRendered">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
@@ -213,12 +213,14 @@
|
|||||||
|
|
||||||
<DockPanel DockPanel.Dock="Top">
|
<DockPanel DockPanel.Dock="Top">
|
||||||
<!-- List of namespaces to export -->
|
<!-- List of namespaces to export -->
|
||||||
<DockPanel DockPanel.Dock="Right">
|
<DockPanel DockPanel.Dock="Right" Width="230">
|
||||||
<Label DockPanel.Dock="Top" Foreground="{StaticResource WindowsBlue}" FontSize="18">Namespaces</Label>
|
<Label DockPanel.Dock="Top" Foreground="{StaticResource WindowsBlue}" FontSize="18">Namespaces</Label>
|
||||||
<TreeView DockPanel.Dock="Bottom" Name="trvNamespaces" ItemTemplate="{StaticResource NamespaceTreeItemTemplate}" Width="220" Margin="10,5,5,5"></TreeView>
|
<TextBlock DockPanel.Dock="Top" TextWrapping="WrapWithOverflow" Margin="10,0,5,5">This only applies to C# prototypes output</TextBlock>
|
||||||
|
<TreeView DockPanel.Dock="Bottom" Name="trvNamespaces" ItemTemplate="{StaticResource NamespaceTreeItemTemplate}" Width="210" Margin="10,5,5,5"></TreeView>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|
||||||
<!-- Settings -->
|
<!-- Settings -->
|
||||||
|
<ScrollViewer Padding="6">
|
||||||
<StackPanel DockPanel.Dock="Left">
|
<StackPanel DockPanel.Dock="Left">
|
||||||
<Label Foreground="{StaticResource WindowsBlue}" FontSize="18">Configure output</Label>
|
<Label Foreground="{StaticResource WindowsBlue}" FontSize="18">Configure output</Label>
|
||||||
|
|
||||||
@@ -340,7 +342,7 @@
|
|||||||
</DockPanel>
|
</DockPanel>
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<Button Name="btnUnityScriptPath" DockPanel.Dock="Right" Width="70" Margin="4" Click="BtnUnityScriptPath_OnClick">Browse</Button>
|
<Button Name="btnUnityScriptPath" DockPanel.Dock="Right" Width="70" Margin="4" Click="BtnUnityScriptPath_OnClick">Browse</Button>
|
||||||
<Label DockPanel.Dock="Left" Width="170" VerticalAlignment="Center">Unity script assemblies path:</Label>
|
<Label DockPanel.Dock="Left" Width="240" VerticalAlignment="Center">Unity script assemblies path:</Label>
|
||||||
<TextBlock Name="txtUnityScriptPath" DockPanel.Dock="Left" VerticalAlignment="Center" FlowDirection="RightToLeft" HorizontalAlignment="Right" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Text}"/>
|
<TextBlock Name="txtUnityScriptPath" DockPanel.Dock="Left" VerticalAlignment="Center" FlowDirection="RightToLeft" HorizontalAlignment="Right" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Text}"/>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|
||||||
@@ -352,7 +354,24 @@
|
|||||||
<ComboBox Name="cboUnityVersion" DockPanel.Dock="Right" Margin="4"></ComboBox>
|
<ComboBox Name="cboUnityVersion" DockPanel.Dock="Right" Margin="4"></ComboBox>
|
||||||
<Label DockPanel.Dock="Left" Width="170" VerticalAlignment="Center" HorizontalAlignment="Left">Unity version (if known):</Label>
|
<Label DockPanel.Dock="Left" Width="170" VerticalAlignment="Center" HorizontalAlignment="Left">Unity version (if known):</Label>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
|
|
||||||
|
<Separator Margin="5,15,5,15"/>
|
||||||
|
|
||||||
|
<!-- C++ scaffolding -->
|
||||||
|
<RadioButton GroupName="grpOutputType" Name="rdoOutputCpp" VerticalContentAlignment="Center" FontSize="18" Foreground="{StaticResource MicrosoftGreen}">C++ headers and scaffolding</RadioButton>
|
||||||
|
<DockPanel>
|
||||||
|
<ComboBox Name="cboCppUnityVersion" DockPanel.Dock="Right" Margin="4"></ComboBox>
|
||||||
|
<Label DockPanel.Dock="Left" Width="250" VerticalAlignment="Center" HorizontalAlignment="Left">Unity version (if known):</Label>
|
||||||
|
</DockPanel>
|
||||||
|
<DockPanel>
|
||||||
|
<ComboBox Name="cboCppCompiler" DockPanel.Dock="Right" Margin="4" Width="80">
|
||||||
|
<ComboBoxItem IsSelected="True">MSVC</ComboBoxItem>
|
||||||
|
<ComboBoxItem>GCC</ComboBoxItem>
|
||||||
|
</ComboBox>
|
||||||
|
<Label DockPanel.Dock="Left" Width="250" VerticalAlignment="Center" HorizontalAlignment="Left">Target C++ compiler for output:</Label>
|
||||||
|
</DockPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
</ScrollViewer>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</DockPanel>
|
</DockPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ using System.Windows.Navigation;
|
|||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using Il2CppInspector;
|
using Il2CppInspector;
|
||||||
|
using Il2CppInspector.Cpp;
|
||||||
using Il2CppInspector.GUI;
|
using Il2CppInspector.GUI;
|
||||||
using Il2CppInspector.Outputs;
|
using Il2CppInspector.Outputs;
|
||||||
using Il2CppInspector.Reflection;
|
using Il2CppInspector.Reflection;
|
||||||
@@ -198,13 +199,21 @@ namespace Il2CppInspectorGUI
|
|||||||
// Populate TreeView with namespace hierarchy
|
// Populate TreeView with namespace hierarchy
|
||||||
trvNamespaces.ItemsSource = namespaceTree;
|
trvNamespaces.ItemsSource = namespaceTree;
|
||||||
|
|
||||||
|
// Populate Unity version combo boxes
|
||||||
var prevSelection = cboUnityVersion.SelectedItem;
|
var prevSelection = cboUnityVersion.SelectedItem;
|
||||||
|
var prevCppSelection = cboCppUnityVersion.SelectedItem;
|
||||||
cboUnityVersion.Items.Clear();
|
cboUnityVersion.Items.Clear();
|
||||||
foreach (var version in UnityHeader.GuessHeadersForModel(model))
|
cboCppUnityVersion.Items.Clear();
|
||||||
|
foreach (var version in UnityHeader.GuessHeadersForModel(model)) {
|
||||||
cboUnityVersion.Items.Add(version);
|
cboUnityVersion.Items.Add(version);
|
||||||
|
cboCppUnityVersion.Items.Add(version);
|
||||||
|
}
|
||||||
cboUnityVersion.SelectedIndex = 0;
|
cboUnityVersion.SelectedIndex = 0;
|
||||||
if (prevSelection != null)
|
cboCppUnityVersion.SelectedIndex = 0;
|
||||||
|
if (prevSelection != null) {
|
||||||
cboUnityVersion.SelectedItem = prevSelection;
|
cboUnityVersion.SelectedItem = prevSelection;
|
||||||
|
cboCppUnityVersion.SelectedItem = prevCppSelection;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<CheckboxNode> deconstructNamespaces(IEnumerable<string> input) {
|
private IEnumerable<CheckboxNode> deconstructNamespaces(IEnumerable<string> input) {
|
||||||
@@ -405,6 +414,34 @@ namespace Il2CppInspectorGUI
|
|||||||
idaWriter.WriteScriptToFile(outFile);
|
idaWriter.WriteScriptToFile(outFile);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// C++ scaffolding
|
||||||
|
case { rdoOutputCpp: var r } when r.IsChecked == true:
|
||||||
|
|
||||||
|
var cppSaveFileDialog = new SaveFileDialog {
|
||||||
|
Filter = "C++ header file (*.h)|*.h|All files (*.*)|*.*",
|
||||||
|
FileName = "il2cpp-types.h",
|
||||||
|
CheckFileExists = false,
|
||||||
|
OverwritePrompt = true
|
||||||
|
};
|
||||||
|
|
||||||
|
if (cppSaveFileDialog.ShowDialog() == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var cppOutFile = cppSaveFileDialog.FileName;
|
||||||
|
|
||||||
|
txtBusyStatus.Text = "Generating C++ scaffolding...";
|
||||||
|
areaBusyIndicator.Visibility = Visibility.Visible;
|
||||||
|
var selectedCppUnityVersion = ((UnityHeader)cboCppUnityVersion.SelectedItem)?.MinVersion;
|
||||||
|
var cppCompiler = (CppCompiler.Type) Enum.Parse(typeof(CppCompiler.Type), cboCppCompiler.SelectionBoxItem.ToString());
|
||||||
|
await Task.Run(() => {
|
||||||
|
var cppWriter = new CppScaffolding(model) {
|
||||||
|
UnityVersion = selectedCppUnityVersion,
|
||||||
|
Compiler = cppCompiler
|
||||||
|
};
|
||||||
|
cppWriter.WriteCppToFile(cppOutFile);
|
||||||
|
});
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
areaBusyIndicator.Visibility = Visibility.Hidden;
|
areaBusyIndicator.Visibility = Visibility.Hidden;
|
||||||
|
|||||||
Reference in New Issue
Block a user