Skip to content

Commit

Permalink
Implemented more backup stuff, updated settings pane
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgamerz committed Dec 9, 2017
1 parent 1871653 commit afae883
Show file tree
Hide file tree
Showing 10 changed files with 188 additions and 278 deletions.
6 changes: 2 additions & 4 deletions AlotAddOnGUI/AlotAddOnGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,15 @@
<Compile Include="classes\CopyDir.cs" />
<Compile Include="classes\FlashWindowHelper.cs" />
<Compile Include="classes\IniFile.cs" />
<Compile Include="classes\ME3Constants.cs" />
<Compile Include="classes\StreamIO.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>AssemblyInfo.tt</DependentUpon>
</Compile>
<Compile Include="ThreadCommandDialogOptions.cs" />
<Compile Include="Utilites.cs" />
<Compile Include="Updater\AnonymousPipes.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down Expand Up @@ -174,9 +175,6 @@
<Content Include="7z\7z.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Updater\GHUpdater.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Resource Include="images\info.ico" />
<Resource Include="images\greencheckmark.png" />
<Resource Include="images\orangedownload.png" />
Expand Down
33 changes: 18 additions & 15 deletions AlotAddOnGUI/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
xmlns:local="clr-namespace:AlotAddOnGUI"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
mc:Ignorable="d"
ResizeMode="NoResize"
BorderBrush="{DynamicResource AccentColorBrush}"
BorderThickness="1"
Title="ALOT Addon Builder" Height="600" Width="800"
Title="ALOT Addon Builder" MinHeight="600" MinWidth="800" Height="600" Width="800"
Loaded="Window_Loaded"
WindowButtonCommandsOverlayBehavior="Never"
Drop="File_Drop" AllowDrop="true">
Expand Down Expand Up @@ -170,26 +169,25 @@
<Controls:FlyoutsControl>
<Controls:Flyout x:Name="SettingsFlyout" Header="Settings" IsPinned="False" Theme="Accent" Position="Right" Width="300">
<!--<Label x:Name="ImportFailedLabel" FontSize="14" Content="An import failed!"></Label>-->
<StackPanel Margin="10">
<CheckBox Margin="5" x:Name="Checkbox_SpaceSaving" Content="Save Disk Space" ToolTip="Deletes files after each stage rather than the end. May save some intermediate disk space during build."/>
<StackPanel Margin="5">
<CheckBox Margin="5" x:Name="Checkbox_HideFiles" Content="Hide files for games not installed" Click="Checkbox_HideFiles_Click" ToolTip="Hide files that don't apply to games you don't have installed."/>
<CheckBox Margin="5" x:Name="Checkbox_BetaMode" Content="Beta Mode" Click="Checkbox_BetaMode_Click" ToolTip="Enable beta mode features. Require restart for full effect, may break application."/>
<Label FontSize="16" Margin="5,0,0,0" Content="Backup Status"/>
<Button x:Name="Button_ME1Backup" Margin="20,0,0,0" Content="ME1: Not Backed Up" Click="Button_ME1Backup_Click">
<Button x:Name="Button_ME1Backup" Margin="20,0,20,0" Padding="0,5,0,5" Content="ME1: Not Backed Up" Click="Button_ME1Backup_Click">
<!--<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>-->
</Button>
<Button x:Name="Button_ME2Backup" Margin="20,0,0,0" Content="ME2: Not Backed Up" Click="Button_ME2Backup_Click">
<Button x:Name="Button_ME2Backup" Margin="20,0,20,0" Padding="0,5,0,5" Content="ME2: Not Backed Up" Click="Button_ME2Backup_Click">
<!--<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
</ControlTemplate>
</Button.Template>-->
</Button>
<Button x:Name="Button_ME3Backup" Margin="20,0,0,0" Content="ME3: Not Backed Up" Click="Button_ME3Backup_Click">
<Button x:Name="Button_ME3Backup" Margin="20,0,20,0" Padding="0,5,0,5" Content="ME3: Not Backed Up" Click="Button_ME3Backup_Click">
<!--<Button.Template>
<ControlTemplate TargetType="{x:Type Button}">
<ContentPresenter />
Expand All @@ -198,18 +196,23 @@
</Button>

<Label FontSize="16" Margin="5,0,0,0" Content="ALOT Installation Status"/>
<Label Margin="20,0,0,0" x:Name="Label_ALOTStatus_ME1" Content="ME1: Not Installed"/>
<Label Margin="20,0,0,0" x:Name="Label_ALOTStatus_ME2" Content="ME2: Not Installed"/>
<Label Margin="20,0,0,0" x:Name="Label_ALOTStatus_ME3" Content="ME3: Not Installed"/>
<Label FontSize="16" Margin="5,0,0,0" Content="Internals"/>
<Label Margin="20,0,0,0" x:Name="Label_MEMVersion" Content="MEM Version: TBD"/>
<Button x:Name="Button_ViewLog" Margin="20,0,0,0" Content="View log" Click="Button_ViewLog_Click"/>
<Button x:Name="Button_ReportIssue" Margin="20,0,0,0" Content="Report an issue" Click="Button_ReportIssue_Click"/>
<Label Margin="20,0,0,0" Padding="0,0,0,5" x:Name="Label_ALOTStatus_ME1" Content="ME1: Not Installed"/>
<Label Margin="20,0,0,0" Padding="0,0,0,5" x:Name="Label_ALOTStatus_ME2" Content="ME2: Not Installed"/>
<Label Margin="20,0,0,0" Padding="0,0,0,5" x:Name="Label_ALOTStatus_ME3" Content="ME3: Not Installed"/>
<Label FontSize="16" Margin="5,0,0,0" Padding="0,0,0,5" Content="Internals"/>
<Button Margin="20,0,20,0" Padding="0,5,0,5" x:Name="Label_MEMVersion" Content="MEM Version: TBD" Click="Button_MEMVersion_Click"/>
<Button x:Name="Button_ViewLog" Margin="20,0,20,0" Padding="0,5,0,5" Content="View log" ToolTip="View log for this program. Helpful when diagnosing issues" Click="Button_ViewLog_Click"/>
<Button x:Name="Button_ReportIssue" Margin="20,0,20,0" Padding="0,5,0,5" Content="Report an issue" ToolTip="Go to the ALOT discord" Click="Button_ReportIssue_Click"/>
<Label FontSize="16" Margin="5,0,0,0" Content="Credits" Padding="0,0,0,5"/>
<Label Margin="20,0,0,0" Padding="0,0,0,2" Content="Brought to you by"/>
<Label Margin="20,0,0,0" Padding="10,0,0,2" Content="Aquadran" ToolTip="Developed MEM. One who made this all possible."/>
<Label Margin="20,0,0,0" Padding="10,0,0,2" Content="CreeperLava" ToolTip="Developed ALOT. Glued all the pieces together."/>
<Label Margin="20,0,0,0" Padding="10,0,0,2" Content="Mgamerz" ToolTip="Complained a bunch and then made a suave UI."/>

</StackPanel>
</Controls:Flyout>
<Controls:Flyout x:Name="ImportFailedFlyout" TitleVisibility="Hidden" IsAutoCloseEnabled="true" AutoCloseInterval="5000" Theme="Accent" CloseButtonVisibility="Hidden" Position="Bottom" Height="30">
<Label x:Name="ImportFailedLabel" FontSize="14" Content="An import failed!"></Label>
<Label x:Name="ImportFailedLabel" FontSize="14" Content="This is the statusbar. You should not see this text."></Label>
</Controls:Flyout>
</Controls:FlyoutsControl>
</Controls:MetroWindow.Flyouts>
Expand Down
110 changes: 91 additions & 19 deletions AlotAddOnGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ public partial class MainWindow : MetroWindow
private bool me3Installed;

private static readonly string SETTINGSTR_HIDENONRELEVANTFILES = "HideNonRelevantFiles";
private static readonly string SETTINGSTR_SAVEDISKSPACE = "SaveDiskSpace";
private BindingList<AddonFile> alladdonfiles;
private readonly string PRIMARY_HEADER = "Download the listed files, then drag and drop the files onto this window. Do not extract any of the files.\nOnce all files for your game are ready, you can build the addon.";
private bool SAVEDISKSPACE = false;
private string SETTINGSTR_BETAMODE = "BetaMode";
private bool HIDENONRELEVANTFILES = false;
private bool LOADINGSETTINGS = false;
private List<string> BACKGROUND_MEM_PROCESS_ERRORS;
private const string SHOW_DIALOG_YES_NO = "SHOW_DIALOG_YES_NO";
private bool CONTINUE_BACKUP_EVEN_IF_VERIFY_FAILS = false;

public bool USING_BETA { get; private set; }
public bool SpaceSaving { get; private set; }
Expand Down Expand Up @@ -1192,14 +1192,44 @@ private async void Button_ME3Backup_Click(object sender, RoutedEventArgs e)
}
else
{
//Addon-Precheck
List<string> folders = ME3Constants.getStandardDLCFolders();
string me3DLCPath = ME3Constants.GetDLCPath();
List<string> dlcFolders = new List<string>();
foreach (string s in Directory.GetDirectories(me3DLCPath))
{
dlcFolders.Add(s.Remove(0, me3DLCPath.Length + 1)); //+1 for the final \\
}
var hasCustomDLC = dlcFolders.Except(folders);
if (hasCustomDLC.Count() > 0)
{
//Game is modified
string message = "Additional folders in the DLC directory were detected:";
foreach (string str in hasCustomDLC)
{
message += "\n - " + str;
}

message += "\n\nThis installation cannot be used for backup as it has been modified.";
await this.ShowMessageAsync("Mass Effect 3 is modified", message);
return;
}
//MEM - VERIFY VANILLA FOR BACKUP

BackupGame(3);

}
}

private async void BackupGame(int game)
{
if (detectInstalledALOTVersion(game) != 0)
{
//Game is modified via ALOT flag
await this.ShowMessageAsync("ALOT is installed", "You cannot backup an installation that has ALOT already installed. You will need to redownload the game, then back it up.");
return;
}

var openFolder = new CommonOpenFileDialog();
openFolder.IsFolderPicker = true;
openFolder.Title = "Select backup destination";
Expand Down Expand Up @@ -1286,6 +1316,22 @@ private async void BackupWorker_ProgressChanged(object sender, ProgressChangedEv
KeyValuePair<string, string> messageStr = (KeyValuePair<string, string>)tc.Data;
await this.ShowMessageAsync(messageStr.Key, messageStr.Value);
break;
case SHOW_DIALOG_YES_NO:
ThreadCommandDialogOptions tcdo = (ThreadCommandDialogOptions)tc.Data;
MetroDialogSettings settings = new MetroDialogSettings();
settings.NegativeButtonText = tcdo.NegativeButtonText;
settings.AffirmativeButtonText = tcdo.AffirmativeButtonText;
MessageDialogResult result = await this.ShowMessageAsync(tcdo.title, tcdo.message, MessageDialogStyle.AffirmativeAndNegative, settings);
if (result == MessageDialogResult.Negative)
{
CONTINUE_BACKUP_EVEN_IF_VERIFY_FAILS = false;
}
else
{
CONTINUE_BACKUP_EVEN_IF_VERIFY_FAILS = true;
}
tcdo.signalHandler.Set();
break;
case INCREMENT_COMPLETION_EXTRACTION:
Interlocked.Increment(ref completed);
Install_ProgressBar.Value = (completed / (double)ADDONSTOINSTALL_COUNT) * 100;
Expand All @@ -1302,6 +1348,7 @@ private void BackupGame(object sender, DoWorkEventArgs e)
string args = "-check-game-data-only-vanilla " + BACKUP_THREAD_GAME + " -ipc";
List<string> acceptedIPC = new List<string>();
acceptedIPC.Add("OVERALL_PROGRESS");
acceptedIPC.Add("ERROR");
BackupWorker.ReportProgress(completed, new ThreadCommand(UPDATE_OPERATION_LABEL, "Verifying game data..."));

runMEM2(exe, args, BackupWorker, acceptedIPC);
Expand All @@ -1312,9 +1359,29 @@ private void BackupGame(object sender, DoWorkEventArgs e)
int buildresult = BACKGROUND_MEM_PROCESS.ExitCode ?? 1;
if (buildresult != 0)
{
BackupWorker.ReportProgress(completed, new ThreadCommand(SHOW_DIALOG, new KeyValuePair<string, string>("Game is modified", "Mass Effect" + getGameNumberSuffix(BACKUP_THREAD_GAME) + " has modified files and cannot serve as a backup.")));
e.Result = null;
return;
string modified = "";
string gameDir = Utilities.GetGamePath(BACKUP_THREAD_GAME);
foreach (String error in BACKGROUND_MEM_PROCESS_ERRORS)
{
modified += "\n - " + error.Remove(0, gameDir.Length + 1);
}
ThreadCommandDialogOptions tcdo = new ThreadCommandDialogOptions();
tcdo.signalHandler = new EventWaitHandle(false, EventResetMode.AutoReset);
tcdo.title = "Game is modified";
tcdo.message = "Mass Effect" + getGameNumberSuffix(BACKUP_THREAD_GAME) + " has files that do not match what is in the MEM database.\nYou can continue to back this installation up, but it may not be truly unmodified." + modified;
tcdo.NegativeButtonText = "Abort";
tcdo.AffirmativeButtonText = "Continue";
BackupWorker.ReportProgress(completed, new ThreadCommand(SHOW_DIALOG_YES_NO, tcdo));
tcdo.signalHandler.WaitOne();
//Thread resumes
if (!CONTINUE_BACKUP_EVEN_IF_VERIFY_FAILS)
{
e.Result = null;
return;
} else
{
CONTINUE_BACKUP_EVEN_IF_VERIFY_FAILS = false; //reset
}
}
string gamePath = Utilities.GetGamePath(BACKUP_THREAD_GAME);
string backupPath = (string)e.Argument;
Expand Down Expand Up @@ -1706,6 +1773,7 @@ private bool ExtractAddons(int game)

buildresult = BACKGROUND_MEM_PROCESS.ExitCode ?? 1;
BACKGROUND_MEM_PROCESS = null;
BACKGROUND_MEM_PROCESS_ERRORS = null;
if (buildresult != 1)
{
InstallWorker.ReportProgress(completed, new ThreadCommand(UPDATE_OPERATION_LABEL, "Cleaning up staging directories"));
Expand Down Expand Up @@ -1753,6 +1821,8 @@ private void runMEM2(string exe, string args, BackgroundWorker worker, List<stri
Debug.WriteLine("Running process: " + exe + " " + args);
Log.Information("Running process: " + exe + " " + args);
BACKGROUND_MEM_PROCESS = new ConsoleApp(exe, args);
BACKGROUND_MEM_PROCESS_ERRORS = new List<string>();

BACKGROUND_MEM_PROCESS.ConsoleOutput += (o, args2) =>
{
string str = args2.Line;
Expand All @@ -1774,12 +1844,17 @@ private void runMEM2(string exe, string args, BackgroundWorker worker, List<stri
case "PROCESSING_FILE":
worker.ReportProgress(completed, new ThreadCommand(UPDATE_OPERATION_LABEL, param));
break;
case "ERROR":
Log.Information("[ERROR] Realtime Process Output: " + param);
BACKGROUND_MEM_PROCESS_ERRORS.Add(param);
break;
default:
Log.Information("Unknown IPC command: " + command);
break;
}
}
} else
}
else
{
Log.Information("Realtime Process Output: " + str);
}
Expand Down Expand Up @@ -2213,12 +2288,6 @@ private void Checkbox_HideFiles_Click(object sender, RoutedEventArgs e)
Utilities.WriteRegistryKey(Registry.CurrentUser, REGISTRY_KEY, SETTINGSTR_HIDENONRELEVANTFILES, ((bool)Checkbox_HideFiles.IsChecked ? 1 : 0));
}

private void Checkbox_SaveDiskSpace_Click(object sender, RoutedEventArgs e)
{
SAVEDISKSPACE = (bool)Checkbox_SpaceSaving.IsChecked;
Utilities.WriteRegistryKey(Registry.CurrentUser, REGISTRY_KEY, SETTINGSTR_SAVEDISKSPACE, ((bool)Checkbox_SpaceSaving.IsChecked ? 1 : 0));
}

private void Button_ViewLog_Click(object sender, RoutedEventArgs e)
{
var directory = new DirectoryInfo("logs");
Expand All @@ -2233,17 +2302,11 @@ private void Button_ViewLog_Click(object sender, RoutedEventArgs e)

private void LoadSettings()
{
LOADINGSETTINGS = true;

SAVEDISKSPACE = Utilities.GetRegistrySettingBool(SETTINGSTR_SAVEDISKSPACE) ?? false;
USING_BETA = Utilities.GetRegistrySettingBool(SETTINGSTR_BETAMODE) ?? false;
HIDENONRELEVANTFILES = Utilities.GetRegistrySettingBool(SETTINGSTR_HIDENONRELEVANTFILES) ?? true;

Checkbox_SpaceSaving.IsChecked = SAVEDISKSPACE;
Checkbox_BetaMode.IsChecked = USING_BETA;
Checkbox_HideFiles.IsChecked = HIDENONRELEVANTFILES;

LOADINGSETTINGS = false;
}

private void Button_ReportIssue_Click(object sender, RoutedEventArgs e)
Expand Down Expand Up @@ -2290,5 +2353,14 @@ private void Checkbox_BetaMode_Click(object sender, RoutedEventArgs e)
Utilities.WriteRegistryKey(Registry.CurrentUser, REGISTRY_KEY, SETTINGSTR_BETAMODE, ((bool)Checkbox_BetaMode.IsChecked ? 1 : 0));
USING_BETA = (bool)Checkbox_BetaMode.IsChecked;
}

private void Button_MEMVersion_Click(object sender, RoutedEventArgs e)
{
ShowStatus("Starting MassEffectModder.exe",3000);
SettingsFlyout.IsOpen = false;
string exe = BINARY_DIRECTORY + "MassEffectModder.exe";
string args = "";// "-install-addon-file \""+path+"\" -game "+result;
runProcess(exe, args, true);
}
}
}
4 changes: 2 additions & 2 deletions AlotAddOnGUI/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
[assembly: AssemblyCulture("")]

// Version informationr(
[assembly: AssemblyVersion("2.0.41.352")]
[assembly: AssemblyFileVersion("2.0.41.352")]
[assembly: AssemblyVersion("2.0.41.371")]
[assembly: AssemblyFileVersion("2.0.41.371")]
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]

14 changes: 14 additions & 0 deletions AlotAddOnGUI/ThreadCommandDialogOptions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Threading;

namespace AlotAddOnGUI
{
internal class ThreadCommandDialogOptions
{
public EventWaitHandle signalHandler;
public string title;
public string message;
public string AffirmativeButtonText;
public string NegativeButtonText;

}
}
Loading

0 comments on commit afae883

Please sign in to comment.