Skip to content

Commit

Permalink
Standardized filepaths to EXE directory. Will help a lot when launchi…
Browse files Browse the repository at this point in the history
…ng from Mod Manager for Mass Effect 3
  • Loading branch information
Mgamerz committed Dec 26, 2017
1 parent f2e6002 commit fa16fcb
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 21 deletions.
2 changes: 2 additions & 0 deletions AlotAddOnGUI/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public App() : base()
}
Log.Information("Command line arguments: " + commandlineargs);
}
Log.Information("Working directory: " + Directory.GetCurrentDirectory());

//Update Mode
if (updateDestinationPath != null)
{
Expand Down
52 changes: 35 additions & 17 deletions AlotAddOnGUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public partial class MainWindow : MetroWindow, INotifyPropertyChanged
public const string INCREMENT_COMPLETION_EXTRACTION = "INCREMENT_COMPLETION_EXTRACTION";
public const string SHOW_DIALOG = "SHOW_DIALOG";
public const string ERROR_OCCURED = "ERROR_OCCURED";
public const string BINARY_DIRECTORY = "bin\\";
public static string EXE_DIRECTORY = System.AppDomain.CurrentDomain.BaseDirectory;
public static string BINARY_DIRECTORY = EXE_DIRECTORY + "bin\\";
private bool errorOccured = false;
private bool UsingBundledManifest = false;
private List<string> BlockingMods;
Expand Down Expand Up @@ -92,7 +93,6 @@ protected virtual void OnPropertyChanged([CallerMemberName] string propertyName
private const string ADDON_STAGING_DIR = "ADDON_STAGING";
private const string USER_STAGING_DIR = "USER_STAGING";

public static string EXE_DIRECTORY = System.AppDomain.CurrentDomain.BaseDirectory;
private string ADDON_FULL_STAGING_DIRECTORY = System.AppDomain.CurrentDomain.BaseDirectory + ADDON_STAGING_DIR + "\\";
private string USER_FULL_STAGING_DIRECTORY = System.AppDomain.CurrentDomain.BaseDirectory + USER_STAGING_DIR + "\\";

Expand Down Expand Up @@ -409,17 +409,16 @@ private void UnzipSelfUpdate(object sender, AsyncCompletedEventArgs e)
kp.Key.SetIndeterminate();
kp.Key.SetTitle("Extracting ALOT Installer update");
string path = BINARY_DIRECTORY + "7z.exe";
string args = "x \"" + kp.Value + "\" -aoa -r -o\"" + System.AppDomain.CurrentDomain.BaseDirectory + "Update\"";
string args = "x \"" + kp.Value + "\" -aoa -r -o\"" + EXE_DIRECTORY + "Update\"";
Log.Information("Extracting update...");
Utilities.runProcess(path, args);

File.Delete((string)kp.Value);
kp.Key.CloseAsync();

Log.Information("Update Extracted - rebooting to update mode");
string exe = System.AppDomain.CurrentDomain.BaseDirectory + "Update\\" + System.AppDomain.CurrentDomain.FriendlyName;
string currentDirNoSlash = System.AppDomain.CurrentDomain.BaseDirectory;
currentDirNoSlash = currentDirNoSlash.Substring(0, currentDirNoSlash.Length - 1);
string exe = EXE_DIRECTORY + "Update\\" + System.AppDomain.CurrentDomain.FriendlyName;
string currentDirNoSlash = EXE_DIRECTORY.Substring(0, EXE_DIRECTORY.Length - 1);
args = "--update-dest \"" + currentDirNoSlash + "\"";
Utilities.runProcess(exe, args, true);
Environment.Exit(0);
Expand All @@ -438,7 +437,7 @@ private void UnzipProgramUpdate(object sender, AsyncCompletedEventArgs e)
//Extract 7z
string path = BINARY_DIRECTORY + "7z.exe";

string args = "x \"" + kp.Value + "\" -aoa -r -o\"" + System.AppDomain.CurrentDomain.BaseDirectory + "bin\"";
string args = "x \"" + kp.Value + "\" -aoa -r -o\"" + EXE_DIRECTORY + "bin\"";
Log.Information("Extracting Tool update...");
Utilities.runProcess(path, args);
Log.Information("Extraction complete.");
Expand All @@ -457,7 +456,7 @@ private void UnzipMEMGUIUpdate(object sender, AsyncCompletedEventArgs e)
//Extract 7z
string path = BINARY_DIRECTORY + "7z.exe";

string args = "x \"" + e.UserState + "\" -aoa -r -o\"" + System.AppDomain.CurrentDomain.BaseDirectory + "bin\"";
string args = "x \"" + e.UserState + "\" -aoa -r -o\"" + EXE_DIRECTORY + "bin\"";
Log.Information("Extracting MEMGUI update...");
Utilities.runProcess(path, args);
Log.Information("Extraction complete.");
Expand Down Expand Up @@ -933,10 +932,29 @@ private async Task FetchManifest()
url = "https://raw.githubusercontent.com/Mgamerz/AlotAddOnGUI/master/manifest-beta.xml";
Title += " BETA MODE ";
}
await webClient.DownloadFileTaskAsync(url, @"manifest-new.xml");
File.Delete(EXE_DIRECTORY + @"manifest.xml");
File.Move(EXE_DIRECTORY + @"manifest-new.xml", EXE_DIRECTORY + @"manifest.xml");
Log.Information("Manifest fetched.");
await webClient.DownloadFileTaskAsync(url, EXE_DIRECTORY + @"manifest-new.xml");
if (File.Exists(EXE_DIRECTORY + @"manifest-new.xml"))
{
File.Delete(EXE_DIRECTORY + @"manifest.xml");
File.Move(EXE_DIRECTORY + @"manifest-new.xml", EXE_DIRECTORY + @"manifest.xml");
Log.Information("Manifest fetched.");
}
else
{
File.Delete(EXE_DIRECTORY + @"manifest-new.xml");
Log.Error("manifest-new.xml does not exist. Using local bundled version instead...");
if (!File.Exists(EXE_DIRECTORY + @"manifest.xml") && File.Exists(EXE_DIRECTORY + @"manifest-bundled.xml"))
{
Log.Information("Reading bundled manifest instead.");
File.Delete(EXE_DIRECTORY + @"manifest.xml");
File.Copy(EXE_DIRECTORY + @"manifest-bundled.xml", EXE_DIRECTORY + @"manifest.xml");
UsingBundledManifest = true;
}
else
{
Log.Error("Local manifest also doesn't exist! No manifest is available.");
}
}
}
catch (WebException e)
{
Expand Down Expand Up @@ -1215,7 +1233,7 @@ private async void readManifest()
List<AddonFile> linqlist = null;
try
{
XElement rootElement = XElement.Load(@"manifest.xml");
XElement rootElement = XElement.Load(EXE_DIRECTORY + @"manifest.xml");
string version = (string)rootElement.Attribute("version") ?? "";
var elemn1 = rootElement.Elements();
linqlist = (from e in rootElement.Elements("addonfile")
Expand Down Expand Up @@ -1756,7 +1774,7 @@ private async Task<bool> InitBuild(int game)
AddonFilesLabel.Text = "Preparing to build texture packages...";
Build_ProgressBar.IsIndeterminate = true;
Log.Information("Deleting any pre-existing Extracted_Mods folder.");
string destinationpath = System.AppDomain.CurrentDomain.BaseDirectory + @"Extracted_Mods\";
string destinationpath = EXE_DIRECTORY + @"Extracted_Mods\";
try
{
if (Directory.Exists(destinationpath))
Expand Down Expand Up @@ -1812,14 +1830,14 @@ private void File_Drop_BackgroundThread(object sender, System.Windows.DragEventA
}
}

private async void PerformImportOperation(string[] files, bool acceptUserFiles = true)
private void PerformImportOperation(string[] files, bool acceptUserFiles = true)
{
if (files.Count() > 0)
{
//don't know how you can drop less than 1 files but whatever
//This code is for failsafe in case somehow library file exists but is not detect properly, like user moved file but something is running
string file = files[0];
string basepath = System.AppDomain.CurrentDomain.BaseDirectory + @"Downloaded_Mods\";
string basepath = EXE_DIRECTORY + @"Downloaded_Mods\";

if (file.ToLower().StartsWith(basepath))
{
Expand Down Expand Up @@ -1880,7 +1898,7 @@ private async void PerformImportOperation(string[] files, bool acceptUserFiles =
if (af.Ready == false)
{
//Copy file to directory
string basepath = System.AppDomain.CurrentDomain.BaseDirectory + @"Downloaded_Mods\";
string basepath = EXE_DIRECTORY + @"Downloaded_Mods\";
string destination = basepath + ((isUnpackedSingleFile) ? af.UnpackedSingleFilename : af.Filename);
//Log.Information("Copying dragged file to downloaded mods directory: " + file);
//File.Copy(file, destination, true);
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("2.0.131.1404")]
[assembly: AssemblyFileVersion("2.0.131.1404")]
[assembly: AssemblyVersion("2.0.139.1412")]
[assembly: AssemblyFileVersion("2.0.139.1412")]
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]

4 changes: 2 additions & 2 deletions AlotAddOnGUI/ui/ALOT_ThreadedTasks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public partial class MainWindow : MetroWindow

private bool ExtractAddon(AddonFile af)
{
string stagingdirectory = System.AppDomain.CurrentDomain.BaseDirectory + ADDON_STAGING_DIR + "\\";
string stagingdirectory = EXE_DIRECTORY + ADDON_STAGING_DIR + "\\";

string fileToUse = af.Filename;
bool isSingleFileMode = false;
Expand Down Expand Up @@ -375,7 +375,7 @@ private bool ExtractAddon(AddonFile af)

private bool ExtractAddons(int game)
{
string stagingdirectory = System.AppDomain.CurrentDomain.BaseDirectory + ADDON_STAGING_DIR + "\\";
string stagingdirectory = EXE_DIRECTORY + ADDON_STAGING_DIR + "\\";
PREBUILT_MEM_INDEX = 9;
SHOULD_HAVE_OUTPUT_FILE = false; //will set to true later
Log.Information("Extracting Addons for Mass Effect " + game);
Expand Down

0 comments on commit fa16fcb

Please sign in to comment.