Skip to content

Commit

Permalink
Fixed packagefile me2only/me3only not being applied. Automatically ca…
Browse files Browse the repository at this point in the history
…n update MEM now. More logging.
  • Loading branch information
Mgamerz committed Jun 19, 2017
1 parent 35ad173 commit c52ab1a
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 16 deletions.
2 changes: 1 addition & 1 deletion AlotAddOnGUI/AlotAddOnGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Updater\GHUpdater.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Resource Include="images\info.ico" />
<Resource Include="images\greencheckmark.png" />
Expand Down
178 changes: 165 additions & 13 deletions AlotAddOnGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ public MainWindow()

private void RunUpdater()
{

Log.Information("Running GHUpdater.");
AddonFilesLabel.Content = "Checking for application updates";
string updaterpath = EXE_DIRECTORY + BINARY_DIRECTORY + "GHUpdater.exe";
string temppath = Path.GetTempPath() + "GHUpdater.exe";
var versInfo = FileVersionInfo.GetVersionInfo(updaterpath);
String fileVersion = versInfo.FileVersion;
Log.Information("GHUpdater.exe version: " + fileVersion);

File.Copy(updaterpath, temppath, true);
pipe = new AnonymousPipes("GHUPDATE_SERVER.", temppath, "", delegate (String msg)
{
Expand All @@ -82,7 +85,7 @@ private void RunUpdater()
//updateprogresscontroller.SetTitle("Update ready to install");
//updateprogresscontroller.SetMessage("Update will install in 5 seconds.");
await this.ShowMessageAsync("ALOT Addon Builder update ready", "The program will close and update in the background, then reopen. It should only take a few seconds.");
string updatemessage = "EXECUTE_UPDATE \"" + System.AppDomain.CurrentDomain.FriendlyName + "\" \"" + EXE_DIRECTORY + "\"";
string updatemessage = "EXECUTE_UPDATE_AND_START_PROCESS \"" + System.AppDomain.CurrentDomain.FriendlyName + "\" \"" + EXE_DIRECTORY + "\"";
Log.Information("Executing update: " + updatemessage);
pipe.SendText(updatemessage);
Environment.Exit(0);
Expand Down Expand Up @@ -135,10 +138,21 @@ private void RunUpdater()
{
pipe.SendText("KILL_UPDATER");
pipe.Close();
Log.Information("User declined update, shutting down updater");
try
{
File.Delete(temppath);
}
catch (Exception e)
{
Log.Error("Error deleting TEMP GHUpdater.exe: " + e.ToString());
}

await FetchManifest();
}
break;
default:
Log.Error("Unknown message from updater client: " + msg);
break;
}
});
}, delegate ()
Expand All @@ -162,6 +176,128 @@ private void RunUpdater()
pipe.SendText("START_UPDATE_CHECK Mgamerz AlotAddOnGUI " + System.Reflection.Assembly.GetEntryAssembly().GetName().Version);
}

private void RunMEMUpdater()
{
Log.Information("Running GHUpdater for MEM.");
AddonFilesLabel.Content = "Checking for Mass Effect Modder updates";
string updaterpath = EXE_DIRECTORY + BINARY_DIRECTORY + "GHUpdater.exe";
string temppath = Path.GetTempPath() + "GHUpdater-MEM.exe";
File.Copy(updaterpath, temppath, true);
pipe = new AnonymousPipes("GHUPDATE_SERVER_MEM.", temppath, "", delegate (String msg)
{
Dispatcher.Invoke((MethodInvoker)async delegate ()
{
//UI THREAD
string[] clientmessage = msg.Split();
switch (clientmessage[0])
{
case "UPDATE_DOWNLOAD_COMPLETE":
if (updateprogresscontroller != null)
{
//updateprogresscontroller.SetTitle("Update ready to install");
//updateprogresscontroller.SetMessage("Update will install in 5 seconds.");
//await this.ShowMessageAsync("ALOT Addon Builder update ready", "The program will close and update in the background, then reopen. It should only take a few seconds.");
string updatemessage = "EXECUTE_UPDATE \"" + EXE_DIRECTORY + "bin\\\"";
Log.Information("Executing update: " + updatemessage);
pipe.SendText(updatemessage);
//Environment.Exit(0);
}
break;
case "UPDATE_DOWNLOAD_PROGRESS":
if (clientmessage.Length != 2)
{
Log.Warning("UPDATE_DOWNLOAD_PROGRESS message was not length 2 - ignoring message");
return;
}
if (updateprogresscontroller != null)
{
double value = Double.Parse(clientmessage[1]);
updateprogresscontroller.SetProgress(value);
}
break;
case "UP_TO_DATE":
Log.Information("GHUpdater reporting MEM is up to date");
Thread.Sleep(250);
try
{
File.Delete(temppath);
}
catch (Exception e)
{
Log.Error("Error deleting TEMP GHUpdater-MEM.exe: " + e.ToString());
}
//await FetchManifest();
break;
case "ERROR_CHECKING_FOR_UPDATES":
AddonFilesLabel.Content = "Error occured checking for MEM updates";
break;
case "UPDATE_AVAILABLE":
if (clientmessage.Length != 2)
{
Log.Warning("UPDATE_AVAILABLE message was not length 2 - ignoring message");
return;
}
Log.Information("Github Updater reports program update: " + clientmessage[1] + " is available.");
//MessageDialogResult result = await this.ShowMessageAsync("Update Available", "ALOT Addon Builder " + clientmessage[1] + " is available. Install the update?", MessageDialogStyle.AffirmativeAndNegative);
//if (result == MessageDialogResult.Affirmative)
//{
pipe.SendText("INITIATE_DOWNLOAD");
updateprogresscontroller = await this.ShowProgressAsync("Installing Update", "Mass Effect Modder is updating. Please wait...", true);
updateprogresscontroller.SetIndeterminate();
//}
//else
//{
// pipe.SendText("KILL_UPDATER");
// pipe.Close();
// Log.Information("User declined update, shutting down updater");
// await FetchManifest();
//}
break;
case "UPDATE_COMPLETED":
AddonFilesLabel.Content = "MassEffectModder has been updated.";
if (updateprogresscontroller != null)
{
await updateprogresscontroller.CloseAsync();
}
try
{
File.Delete(temppath);
}
catch (Exception e)
{
Log.Error("Error deleting TEMP GHUpdater-MEM.exe: " + e.ToString());
}
break;
default:
Log.Error("Unknown message from updater client: " + msg);
break;
}
});
}, delegate ()
{
// We're disconnected!
try
{

Dispatcher.Invoke((MethodInvoker)delegate ()
{
//UITHREAD
var source = PresentationSource.FromVisual(this);
if (source == null || source.IsDisposed)
{
AddonFilesLabel.Content = "Lost connection to update client";
}
});
}
catch (Exception) { }
});
Thread.Sleep(2000);
var versInfo = FileVersionInfo.GetVersionInfo(BINARY_DIRECTORY + "MassEffectModder.exe");
int fileVersion = versInfo.FileMajorPart;
Log.Information("Local Mass Effect Modder version: " + fileVersion);
pipe.SendText("START_UPDATE_CHECK MassEffectModder MassEffectModder " + fileVersion);
}

private async void InstallCompleted(object sender, RunWorkerCompletedEventArgs e)
{
Installing = false;
Expand All @@ -177,7 +313,7 @@ private async void InstallCompleted(object sender, RunWorkerCompletedEventArgs e
break;
case 2:
case 3:
HeaderLabel.Text = "Addon Created.\nThe MEM packages for the addon have been placed into the "+MEM_OUTPUT_DISPLAY_DIR+" directory.";
HeaderLabel.Text = "Addon Created.\nThe MEM packages for the addon have been placed into the " + MEM_OUTPUT_DISPLAY_DIR + " directory.";
AddonFilesLabel.Content = "MEM Packages placed in the " + MEM_OUTPUT_DISPLAY_DIR + " folder";
await this.ShowMessageAsync("ALOT Addon for Mass Effect " + result + " has been built", "You can install the Addon MEM files with Mass Effect Modder after you've installed the main ALOT MEM file.");
break;
Expand Down Expand Up @@ -355,12 +491,15 @@ private async Task FetchManifest()
}

readManifest();

Log.Information("Manifest read. Switching over to user control");

Install_ProgressBar.IsIndeterminate = false;
HeaderLabel.Text = "Download the listed files, then drag and drop the files onto this window.\nOnce all items are ready, build the addon.";
AddonFilesLabel.Content = "Scanning...";
timer_Tick(null, null);
RunMEMUpdater();

}
}
}
Expand Down Expand Up @@ -465,7 +604,8 @@ private void OnPropertyChanged(string propertyName)
handler(this, new PropertyChangedEventArgs(propertyName));
}

public override string ToString() {
public override string ToString()
{
return FriendlyName;
}
}
Expand Down Expand Up @@ -666,7 +806,7 @@ private async Task<bool> InstallPrecheck(int game)
{
oneisready = true;
}
}
}
}

if (nummissing == 0)
Expand Down Expand Up @@ -780,13 +920,16 @@ private bool ExtractAddons(int game)
{
foreach (PackageFile pf in af.PackageFiles)
{
Log.Information("Copying Package File: " + pf.SourceName + "->" + pf.DestinationName);
string extractedpath = basepath + Path.GetFileNameWithoutExtension(af.Filename) + "\\" + pf.SourceName;
string destination = stagingdirectory + pf.DestinationName;
File.Copy(extractedpath, destination, true);
numcompleted++;
int progress = (int)((float)numcompleted / (float)totalfiles * 100);
InstallWorker.ReportProgress(progress);
if (game == 2 && pf.ME2Only || game == 3 && pf.ME3Only || (!pf.ME3Only && !pf.ME2Only))
{
Log.Information("Copying Package File: " + pf.SourceName + "->" + pf.DestinationName);
string extractedpath = basepath + Path.GetFileNameWithoutExtension(af.Filename) + "\\" + pf.SourceName;
string destination = stagingdirectory + pf.DestinationName;
File.Copy(extractedpath, destination, true);
numcompleted++;
int progress = (int)((float)numcompleted / (float)totalfiles * 100);
InstallWorker.ReportProgress(progress);
}
// Thread.Sleep(1000);
}
}
Expand Down Expand Up @@ -885,6 +1028,11 @@ private async void File_Drop(object sender, System.Windows.DragEventArgs e)
{
// Note that you can have more than one file.
string[] files = (string[])e.Data.GetData(System.Windows.DataFormats.FileDrop);
Log.Information("Files dropped:");
foreach (String file in files)
{
Log.Information(" -" + file);
}
List<AddonFile> filesimported = new List<AddonFile>();
// Assuming you have one file that you care about, pass it off to whatever
// handling code you have defined.
Expand All @@ -904,6 +1052,10 @@ private async void File_Drop(object sender, System.Windows.DragEventArgs e)
timer_Tick(null, null);
break;
}
else
{
Log.Information("Dragged file does not match addonfile or file is already ready: " + af.Filename);
}
}
}
if (filesimported.Count > 0)
Expand Down
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("1.2.26.65")]
[assembly: AssemblyFileVersion("1.2.26.65")]
[assembly: AssemblyVersion("1.2.28.93")]
[assembly: AssemblyFileVersion("1.2.28.93")]
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]

Binary file modified AlotAddOnGUI/Updater/GHUpdater.exe
Binary file not shown.

0 comments on commit c52ab1a

Please sign in to comment.