Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick Export #136 #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Il2CppInspector.GUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,19 @@
</Style>
</DockPanel.Style>

<!-- Quick Export button -->
<Button Name="btnQuickExport" Click="BtnQuickExport_OnClick" DockPanel.Dock="Bottom" Margin="2" HorizontalAlignment="Right" VerticalAlignment="Bottom" FontSize="18" Width="120" Content="Quick Export">
<Button.Style>
<Style BasedOn="{StaticResource LightBoxButton}" TargetType="{x:Type Button}">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=areaBusyIndicator, Path=Visibility}" Value="Visible">
<Setter Property="Button.IsEnabled" Value="False"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>

<!-- Export button -->
<Button Name="btnExport" Click="BtnExport_OnClick" DockPanel.Dock="Bottom" Margin="2" HorizontalAlignment="Right" VerticalAlignment="Bottom" FontSize="18" Width="120" Content="Export">
<Button.Style>
Expand Down
62 changes: 48 additions & 14 deletions Il2CppInspector.GUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public partial class MainWindow : Window
+ "If you believe this is a bug in Il2CppInspector, please use the CLI version to generate the complete output and paste it when filing a bug report."
+ " Do not send a screenshot of this error!";

private string outputDirectory;

public MainWindow() {
InitializeComponent();

Expand Down Expand Up @@ -114,6 +116,9 @@ private async void BtnSelectMetadataFile_OnClick(object sender, RoutedEventArgs
private async Task LoadMetadataAsync(string filename) {
var app = (App) Application.Current;

//Save path to variables
outputDirectory = Path.GetDirectoryName(filename) + @"\";

areaBusyIndicator.Visibility = Visibility.Visible;
grdFirstPage.Visibility = Visibility.Hidden;

Expand Down Expand Up @@ -148,6 +153,9 @@ private async void BtnSelectBinaryFile_OnClick(object sender, RoutedEventArgs e)
private async Task LoadBinaryAsync(string filename) {
var app = (App) Application.Current;

//Save path to variables
outputDirectory = Path.GetDirectoryName(filename) + @"\";

areaBusyIndicator.Visibility = Visibility.Visible;
btnSelectBinaryFile.Visibility = Visibility.Hidden;

Expand Down Expand Up @@ -187,6 +195,9 @@ private async void BtnSelectPackageFile_OnClick(object sender, RoutedEventArgs e
private async Task LoadPackageAsync(IEnumerable<string> filenames) {
var app = (App) Application.Current;

//Save path to variables
outputDirectory = Path.GetDirectoryName(filenames.First()) + @"\" + Path.GetFileNameWithoutExtension(filenames.First()) + " ";

areaBusyIndicator.Visibility = Visibility.Visible;
grdFirstPage.Visibility = Visibility.Hidden;

Expand Down Expand Up @@ -423,20 +434,30 @@ private async void BtnSaveBinary_OnClick(object sender, RoutedEventArgs e) {
/// <summary>
/// Perform export
/// </summary>

private async void BtnQuickExport_OnClick(object sender, RoutedEventArgs e) {
Export(true);
}

private async void BtnExport_OnClick(object sender, RoutedEventArgs e) {
var model = (AppModel) lstImages.SelectedItem;
Export(false);
}

private async void Export(bool quickExport)
{
var model = (AppModel)lstImages.SelectedItem;

var unityPath = txtUnityPath.Text;
var unityAssembliesPath = txtUnityScriptPath.Text;

var sortOrder = rdoSortIndex.IsChecked == true ? "index" :
rdoSortName.IsChecked == true ? "name" :
"unknown";
var layout = rdoLayoutSingle.IsChecked == true? "single" :
rdoLayoutAssembly.IsChecked == true? "assembly" :
rdoLayoutNamespace.IsChecked == true? "namespace" :
rdoLayoutClass.IsChecked == true? "class" :
rdoLayoutTree.IsChecked == true? "tree" :
var layout = rdoLayoutSingle.IsChecked == true ? "single" :
rdoLayoutAssembly.IsChecked == true ? "assembly" :
rdoLayoutNamespace.IsChecked == true ? "namespace" :
rdoLayoutClass.IsChecked == true ? "class" :
rdoLayoutTree.IsChecked == true ? "tree" :
"unknown";

switch (this) {
Expand Down Expand Up @@ -478,16 +499,17 @@ private async void BtnExport_OnClick(object sender, RoutedEventArgs e) {
OverwritePrompt = true
};

if (needsFolder && saveFolderDialog.ShowDialog() == false)
if (!quickExport && needsFolder && saveFolderDialog.ShowDialog() == false)
return;
if (!needsFolder && saveFileDialog.ShowDialog() == false)
if (!quickExport && !needsFolder && saveFileDialog.ShowDialog() == false)
return;


txtBusyStatus.Text = createSolution ? "Creating Visual Studio solution..." : "Exporting C# type definitions...";
areaBusyIndicator.Visibility = Visibility.Visible;

var outPath = needsFolder ? saveFolderDialog.SelectedPath : saveFileDialog.FileName;
if (quickExport)
outPath = outputDirectory + (needsFolder ? "VS solution" : saveFileDialog.FileName);

await Task.Run(() => {
if (createSolution)
Expand Down Expand Up @@ -536,10 +558,12 @@ await Task.Run(() => {
OverwritePrompt = true
};

if (pySaveFileDialog.ShowDialog() == false)
if (!quickExport && pySaveFileDialog.ShowDialog() == false)
return;

var pyOutFile = pySaveFileDialog.FileName;
if (quickExport)
pyOutFile = outputDirectory + pySaveFileDialog.FileName;

areaBusyIndicator.Visibility = Visibility.Visible;
var selectedPyUnityVersion = ((UnityHeaders) cboPyUnityVersion.SelectedItem)?.VersionRange.Min;
Expand All @@ -561,10 +585,12 @@ await Task.Run(() => {
UseDescriptionForTitle = true
};

if (cppSaveFolderDialog.ShowDialog() == false)
if (!quickExport && cppSaveFolderDialog.ShowDialog() == false)
return;

var cppOutPath = cppSaveFolderDialog.SelectedPath;
if (quickExport)
cppOutPath = outputDirectory + "C++ scaffolding";

areaBusyIndicator.Visibility = Visibility.Visible;
var selectedCppUnityVersion = ((UnityHeaders) cboCppUnityVersion.SelectedItem)?.VersionRange.Min;
Expand All @@ -588,10 +614,12 @@ await Task.Run(() => {
OverwritePrompt = true
};

if (jsonSaveFileDialog.ShowDialog() == false)
if (!quickExport && jsonSaveFileDialog.ShowDialog() == false)
return;

var jsonOutFile = jsonSaveFileDialog.FileName;
if (quickExport)
jsonOutFile = outputDirectory + jsonSaveFileDialog.FileName;

areaBusyIndicator.Visibility = Visibility.Visible;
var selectedJsonUnityVersion = ((UnityHeaders) cboJsonUnityVersion.SelectedItem)?.VersionRange.Min;
Expand All @@ -612,10 +640,13 @@ await Task.Run(() => {
UseDescriptionForTitle = true
};

if (dllSaveFolderDialog.ShowDialog() == false)
if (!quickExport && dllSaveFolderDialog.ShowDialog() == false)
return;

var dllOutPath = dllSaveFolderDialog.SelectedPath;
if (quickExport)
dllOutPath = outputDirectory + "DLLs";

var suppressMetadata = cbSuppressDllMetadata.IsChecked == true;

areaBusyIndicator.Visibility = Visibility.Visible;
Expand All @@ -630,7 +661,10 @@ await Task.Run(() => {
}

areaBusyIndicator.Visibility = Visibility.Hidden;
MessageBox.Show(this, "Export completed successfully", "Export complete", MessageBoxButton.OK, MessageBoxImage.Information);
if (quickExport)
MessageBox.Show(this, "Export completed successfully to: " + outputDirectory, "Export complete", MessageBoxButton.OK, MessageBoxImage.Information);
else
MessageBox.Show(this, "Export completed successfully", "Export complete", MessageBoxButton.OK, MessageBoxImage.Information);
}

private IEnumerable<string> constructExcludedNamespaces(IEnumerable<CheckboxNode> nodes) {
Expand Down