private void Application_Startup(object sender, StartupEventArgs e) { //Winforms interop System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Integration.WindowsFormsHost.EnableWindowsFormsInterop(); //set up AppData Folder if (!Directory.Exists(AppDataFolder)) { Directory.CreateDirectory(AppDataFolder); } //load in data files ME3TalkFiles.LoadSavedTlkList(); ME2Explorer.ME2TalkFiles.LoadSavedTlkList(); ME1UnrealObjectInfo.loadfromJSON(); ME2UnrealObjectInfo.loadfromJSON(); ME3UnrealObjectInfo.loadfromJSON(); //static class setup Tools.Initialize(); MEPackageHandler.Initialize(); int exitCode = 0; if (HandleCommandLineArgs(Environment.GetCommandLineArgs(), out exitCode)) { Shutdown(exitCode); } else { (new MainWindow()).Show(); } }
public static void Startup() { if (!Booted) { ME1UnrealObjectInfo.loadfromJSON(); ME2UnrealObjectInfo.loadfromJSON(); ME3UnrealObjectInfo.loadfromJSON(); UDKUnrealObjectInfo.loadfromJSON(); ME1Directory.LoadGamePath(); ME2Directory.LoadGamePath(); ME3Directory.LoadGamePath(); MEPackageHandler.Initialize(); Booted = true; } }
private void Application_Startup(object sender, StartupEventArgs e) { //Winforms interop System.Windows.Forms.Application.EnableVisualStyles(); System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false); System.Windows.Forms.Integration.WindowsFormsHost.EnableWindowsFormsInterop(); //set up AppData Folder if (!Directory.Exists(AppDataFolder)) { Directory.CreateDirectory(AppDataFolder); } //load in data files ME3TalkFiles.LoadSavedTlkList(); ME2Explorer.ME2TalkFiles.LoadSavedTlkList(); ME1UnrealObjectInfo.loadfromJSON(); ME2UnrealObjectInfo.loadfromJSON(); ME3UnrealObjectInfo.loadfromJSON(); //static class setup Tools.Initialize(); MEPackageHandler.Initialize(); //load kismet font SequenceObjects.SText.LoadFont(); splashScreen.Close(TimeSpan.FromMilliseconds(1)); if (HandleCommandLineJumplistCall(Environment.GetCommandLineArgs(), out int exitCode) != 1) { Shutdown(exitCode); } else { this.Dispatcher.UnhandledException += OnDispatcherUnhandledException; //only start handling them after bootup (new MainWindow()).Show(); } }
public MeshExporter(string pccPath) { MEPackageHandler.Initialize(); Pcc = MEPackageHandler.OpenMEPackage(pccPath); }
public App() : base() { // var f = Assembly.GetCallingAssembly().GetManifestResourceNames(); ExecutableLocation = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; Utilities.ExtractInternalFile("MassEffectModManagerCore.bundleddlls.sevenzipwrapper.dll", Path.Combine(Utilities.GetDllDirectory(), "sevenzipwrapper.dll"), false); Utilities.ExtractInternalFile("MassEffectModManagerCore.bundleddlls.lzo2wrapper.dll", Path.Combine(Utilities.GetDllDirectory(), "lzo2wrapper.dll"), false); Utilities.ExtractInternalFile("MassEffectModManagerCore.bundleddlls.zlibwrapper.dll", Path.Combine(Utilities.GetDllDirectory(), "zlibwrapper.dll"), false); SetDllDirectory(Utilities.GetDllDirectory()); Directory.SetCurrentDirectory(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)); Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; try { string exeFolder = Directory.GetParent(ExecutableLocation).ToString(); Log.Logger = new LoggerConfiguration().WriteTo.SizeRollingFile(Path.Combine(App.LogDir, "modmanagerlog.txt"), retainedFileDurationLimit: TimeSpan.FromDays(14), fileSizeLimitBytes: 1024 * 1024 * 10) // 10MB #if DEBUG .WriteTo.Debug() #endif .CreateLogger(); string[] args = Environment.GetCommandLineArgs(); //Parsed<Options> parsedCommandLineArgs = null; string updateDestinationPath = null; #region Command line if (args.Length > 1) { var result = Parser.Default.ParseArguments <Options>(args); if (result is Parsed <Options> parsedCommandLineArgs) { //Parsing completed if (parsedCommandLineArgs.Value.UpdateBoot) { //Update unpacked and process was run. Environment.Exit(0); } if (parsedCommandLineArgs.Value.UpdateDest != null) { if (File.Exists(parsedCommandLineArgs.Value.UpdateDest)) { updateDestinationPath = parsedCommandLineArgs.Value.UpdateDest; } //if (parsedCommandLineArgs.Value.BootingNewUpdate) //{ // Thread.Sleep(1000); //Delay boot to ensure update executable finishes // try // { // string updateFile = Path.Combine(exeFolder, "ME3TweaksModManager-Update.exe"); // if (File.Exists(updateFile)) // { // File.Delete(updateFile); // Log.Information("Deleted staged update"); // } // } // catch (Exception e) // { // Log.Warning("Unable to delete staged update: " + e.ToString()); // } //} } if (parsedCommandLineArgs.Value.UpdateFromBuild != 0) { App.UpdatedFrom = parsedCommandLineArgs.Value.UpdateFromBuild; } if (parsedCommandLineArgs.Value.BootingNewUpdate) { App.BootingUpdate = true; } } } #endregion this.Dispatcher.UnhandledException += OnDispatcherUnhandledException; POST_STARTUP = true; ToolTipService.ShowDurationProperty.OverrideMetadata( typeof(DependencyObject), new FrameworkPropertyMetadata(Int32.MaxValue)); Log.Information("==========================================================================="); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(ExecutableLocation); string version = fvi.FileVersion; Log.Information("ME3Tweaks Mod Manager " + version); Log.Information("Application boot: " + DateTime.UtcNow.ToString()); Log.Information("Executable location: " + ExecutableLocation); #region Update mode boot if (updateDestinationPath != null) { Log.Information(" >> In update mode. Update destination: " + updateDestinationPath); int i = 0; while (i < 8) { i++; try { Log.Information($"Applying update: {ExecutableLocation} -> {updateDestinationPath}"); File.Copy(ExecutableLocation, updateDestinationPath, true); Log.Information("Update applied, restarting..."); break; } catch (Exception e) { Log.Error("Error applying update: " + e.Message); if (i < 8) { Thread.Sleep(1000); Log.Warning("Attempt #" + (i + 1)); } else { Log.Fatal("Unable to apply update after 8 attempts. We are giving up."); MessageBox.Show("Update was unable to apply. See the application log for more information. If this continues to happen please come to the ME3Tweaks discord, or download a new copy from GitHub."); Environment.Exit(1); } } } ProcessStartInfo psi = new ProcessStartInfo(updateDestinationPath); psi.WorkingDirectory = Directory.GetParent(updateDestinationPath).FullName; psi.Arguments = "--completing-update"; if (App.UpdatedFrom > 0) { psi.Arguments += " --update-from " + App.UpdatedFrom; } Log.Information($"Booting new update: {updateDestinationPath} {psi.Arguments}"); Process.Start(psi); Environment.Exit(0); Current.Shutdown(); } #endregion System.Windows.Controls.ToolTipService.ShowOnDisabledProperty.OverrideMetadata(typeof(Control), new FrameworkPropertyMetadata(true)); Log.Information("Standardized ME3Tweaks startup has completed. Now beginning Mod Manager startup"); Log.Information("Loading settings"); Settings.Load(); if (!Settings.EnableTelemetry) { Log.Warning("Telemetry is disabled :("); Analytics.SetEnabledAsync(false); Crashes.SetEnabledAsync(false); } Log.Information("Ensuring mod directories"); Utilities.DeleteFilesAndFoldersRecursively(Utilities.GetTempPath()); MEPackageHandler.Initialize(); Log.Information("Mod Manager pre-UI startup has completed"); } catch (Exception e) { OnFatalCrash(e); throw e; } }
public TreeNode BuildPccTree(string pcc) { if (!_isPackageHandlerInitialized) { MEPackageHandler.Initialize(); _isPackageHandlerInitialized = true;; } // check first if this pcc has already been added in the tree bool IsPccAlreadyInTree = PccList.Find(ptn => ptn.pcc.FileName == pcc) != null; if (IsPccAlreadyInTree) { return(null); } var Pcc = MEPackageHandler.OpenMEPackage(pcc); /* * ME3Package me3Pcc = Pcc as ME3Package; * * if (me3Pcc == null) * { * // supports only ME3 for the time being * throw new ArgumentException("This is not a ME3 package. The tool only supports ME3 at this time."); * } * */ PccTreeNode pccRootNode = null; var MorphExpIndexes = Pcc.Exports.Select((value, index) => new { value, index }) .Where(z => z.value.ClassName == "BioMorphFace") .Select(z => z.index); if (MorphExpIndexes.Count() > 0) { pccRootNode = new PccTreeNode(Pcc); // Morphs TreeNode ParentMorphNode = new TreeNode(); ParentMorphNode.Text = "BioMorphFace"; foreach (int morphIndex in MorphExpIndexes) { var morph = new Unreal.BioMorphFace(Pcc, morphIndex); MorphTreeNode morphNode = new MorphTreeNode(morph); ParentMorphNode.Nodes.Add(morphNode); } // Meshes TreeNode ParentMeshNode = new TreeNode(); ParentMeshNode.Text = "SkeletalMesh"; var MeshExpIndexes = Pcc.Exports.Select((value, index) => new { value, index }) .Where(z => z.value.ClassName == "SkeletalMesh") .Select(z => z.index); foreach (int meshIndex in MeshExpIndexes) { IExportEntry exp = Pcc.Exports[meshIndex]; //SkeletalMesh skMesh = new SkeletalMesh((ME3Package)Pcc, meshIndex); var skMesh = new Unreal.MESkeletalMesh(Pcc, meshIndex); MeshTreeNode meshNode = new MeshTreeNode(skMesh, exp); ParentMeshNode.Nodes.Add(meshNode); } // build hierarchy pccRootNode.Nodes.Add(ParentMeshNode); pccRootNode.Nodes.Add(ParentMorphNode); // add in the list PccList.Add(pccRootNode); } else { Pcc = null; } return(pccRootNode); }