private void Activate_Click(object sender, RoutedEventArgs e) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } bool WasPlaying = RussLibraryAudio.AudioServer.Current.IsPlaying; if (WasPlaying) { RussLibraryAudio.AudioServer.Current.Stop(); } Button btn = sender as Button; if (btn != null) { ModConfiguration mod = btn.CommandParameter as ModConfiguration; if (mod != null) { ModManagement.Activate(mod); } } if (WasPlaying) { RussLibraryAudio.AudioServer.Current.PlayNextInQueue(); } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
private void InstallFromWeb_Click(object sender, RoutedEventArgs e) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } Button btn = sender as Button; if (btn != null) { ModConfiguration mod = btn.CommandParameter as ModConfiguration; if (mod != null) { bool NeedPackageSpecified = true; if (!string.IsNullOrEmpty(mod.Download.Source)) { StartDownload(mod); } else if (NeedPackageSpecified) { BrowseForPackage(mod); } } } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
public override void Entry() { Configuration = ModConfiguration.Load <ModConfig>(ModSettings.ConfigurationFile); if (Configuration != null) { //Log.IsVerbose = Configuration.UseVerboseLogging; } Farmhand.Events.GameEvents.OnBeforeGameInitialised += OnGameInitialising; Farmhand.Events.GameEvents.OnAfterGameInitialised += OnGameInitialised; Farmhand.Events.GameEvents.OnBeforeLoadContent += GameEvents_OnBeforeLoadContent; Farmhand.Events.GameEvents.OnAfterLoadedContent += GameEvents_OnAfterLoadedContent; Farmhand.Events.GameEvents.OnBeforeUpdateTick += GameEvents_OnBeforeUpdateTick; Farmhand.Events.GameEvents.OnAfterUpdateTick += GameEvents_OnAfterUpdateTick; Farmhand.Events.GraphicsEvents.OnResize += GraphicsEvents_OnResize; Farmhand.Events.GraphicsEvents.OnBeforeDraw += GraphicsEvents_OnBeforeDraw; Farmhand.Events.GraphicsEvents.OnAfterDraw += GraphicsEvents_OnAfterDraw; Farmhand.Events.LocationEvents.OnLocationsChanged += LocationEvents_OnLocationsChanged; Farmhand.Events.LocationEvents.OnCurrentLocationChanged += LocationEvents_OnCurrentLocationChanged; Farmhand.Events.LocationEvents.OnLocationObjectsChanged += LocationEvents_OnLocationObjectsChanged; Farmhand.Events.PlayerEvents.OnBeforePlayerTakesDamage += PlayerEvents_OnBeforePlayerTakesDamage; Farmhand.Events.UiEvents.OnAfterIClickableMenuInitialized += UiEvents_OnAfterIClickableMenuInitialized; Farmhand.Events.LocationEvents.OnBeforeLocationLoadObjects += LocationEvents_OnBeforeLocationLoadObjects; Farmhand.Events.LocationEvents.OnAfterLocationLoadObjects += LocationEvents_OnAfterLocationLoadObjects; Farmhand.Events.SaveEvents.OnBeforeSave += SaveEvents_OnBeforeSave; Farmhand.Events.SaveEvents.OnAfterSave += SaveEvents_OnAfterSave; Farmhand.Events.SaveEvents.OnBeforeLoad += SaveEvents_OnBeforeLoad; Farmhand.Events.SaveEvents.OnAfterLoad += SaveEvents_OnAfterLoad; Farmhand.Events.SerializerEvents.UnknownNode += SerializerEvents_UnknownNode; Farmhand.Events.SerializerEvents.UnknownElement += SerializerEvents_UnknownElement; Farmhand.Events.SerializerEvents.UnknownAttribute += SerializerEvents_UnknownAttribute; Farmhand.Events.SerializerEvents.UnreferencedObject += SerializerEvents_UnreferencedObject; }
void ModManagement_DownloadFailed(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } CleanupDownload(); Locations.MessageBoxShow("Download Failed:\r\n\r\n" + e.Error.ToString() + "\r\n\r\nPlease manually download the file and select it.", MessageBoxButton.OK, MessageBoxImage.Error); ModConfiguration mod = e.UserState as ModConfiguration; if (string.IsNullOrEmpty(mod.Download.Source)) { System.Diagnostics.Process.Start(mod.Download.Source); } else { System.Diagnostics.Process.Start(mod.Download.Webpage); } BrowseForPackage(mod); if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
/// <summary> /// Locates the expected file in mod. /// </summary> /// <param name="fileName">Name of the file.</param> /// <param name="config">The config.</param> /// <returns></returns> public static string LocateExpectedFileInMod(string fileName, ModConfiguration config) { string retVal = string.Empty; if (config != null) { foreach (FileMap fm in config.BaseFiles.Files) { if (fm.Target.EndsWith(fileName, StringComparison.OrdinalIgnoreCase)) { if (File.Exists(Path.Combine(config.InstalledPath, fm.Source))) { retVal = Path.Combine(config.InstalledPath, fm.Source); } break; } } if (string.IsNullOrEmpty(retVal)) { if (File.Exists(Path.Combine(config.InstalledPath, fileName))) { retVal = Path.Combine(config.InstalledPath, fileName); } } } return(retVal); }
private void ToAndroid_Click(object sender, RoutedEventArgs e) { Button btn = sender as Button; if (btn != null) { ModConfiguration config = btn.CommandParameter as ModConfiguration; if (config != null) { Locations.MessageBoxShow(AMLResources.Properties.Resources.AttachAndroid, MessageBoxButton.OK, MessageBoxImage.Information); using (System.Windows.Forms.FolderBrowserDialog diag = new System.Windows.Forms.FolderBrowserDialog()) { diag.Description = AMLResources.Properties.Resources.BrowseToFolder; if (diag.ShowDialog() == System.Windows.Forms.DialogResult.OK) { FileHelper.CopyFiles(new System.IO.DirectoryInfo(config.InstalledPath), diag.SelectedPath, "*.snt", null); FileHelper.CopyFiles(new System.IO.DirectoryInfo(config.InstalledPath), diag.SelectedPath, "*.xml", null); Locations.MessageBoxShow( AMLResources.Properties.Resources.CopyComplete + DataStrings.CRCR + AMLResources.Properties.Resources.ApplyToAndroid, MessageBoxButton.OK, MessageBoxImage.Information); } } } } }
public static void SetupConfig() { //QuickLogger.DebugLogsEnabled = QModManager.Utility.Logger.DebugLogsEnabled; // Logger.Log(Logger.Level.Debug, "Debug logs enabled"); QuickLogger.Info("Loading config.json settings"); ModConfiguration.Initialize(); }
private Mock <IXmlFileSystem <ModConfiguration> > SetModConfig(ModConfiguration modConfig) { var fileSystemWrapper = fixture.Freeze <Mock <IXmlFileSystem <ModConfiguration> > >(); fileSystemWrapper.Setup(x => x.FileExists(It.IsAny <FileInfo>())).Returns(true); fileSystemWrapper.Setup(x => x.GetFileAsObject(It.IsAny <FileInfo>())).Returns(modConfig); return(fileSystemWrapper); }
void ModManagement_DownloadFailed(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { if (e != null) { ModConfiguration mod = e.UserState as ModConfiguration; MessageBox.Show(mod.Title + " failed to download"); UpdateTestConfigs(mod); } }
void UpdateTestConfigs(ModConfiguration mod) { if (TestConfigs.Contains(mod)) { TestConfigs.Remove(mod); } if (TestConfigs.Count < 1) { MessageBox.Show("done"); } }
private void ModUninstalled(object sender, RoutedEventArgs e) { //if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } //Only if a pre-defined mod. ModConfiguration mod = e.OriginalSource as ModConfiguration; if (ModManagement.GetPredefinedMods().ContainsKey(mod.ID)) { predefinedMods.AppendConfig(mod); } //if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
public ModDefinitionSetup() { Configuration = new ModConfiguration(); Configuration.AcceptChanges(); InitializeComponent(); ImageBrush brsh = ArtemisModLoader.Helpers.FileHelper.GetRandomSkybox(); if (brsh != null) { this.Background = brsh; } }
void ModManagement_Downloaded(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { if (e != null) { ModConfiguration mod = e.UserState as ModConfiguration; if (!FileHelper.IsValidCompressedFile(mod.PackagePath)) { MessageBox.Show(mod.Title + " had invalid compressed file."); } UpdateTestConfigs(mod); } }
void StartDownload(ModConfiguration config) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } ModManagement.Downloaded += new EventHandler <System.ComponentModel.AsyncCompletedEventArgs>(ModManagement_Downloaded); ModManagement.DownloadFailed += new EventHandler <System.ComponentModel.AsyncCompletedEventArgs>(ModManagement_DownloadFailed); ModManagement.StartDownload(config); if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
public void AppendConfig(ModConfiguration config) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } if (config != null && !ModManagement.IsInstalled(config.ID)) { Definitions.Add(config); } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
private void DoOpen() { //Open installed if (InstalledModConfigurations.Current.Configurations.Configurations.Count > 1) { ResetData(); ModSelector win = new ModSelector(); if (win.ShowDialog() == true) { Configuration = win.SelectedConfiguration; } } else { Locations.MessageBoxShow(AMLResources.Properties.Resources.NoModsInstalled, MessageBoxButton.OK, MessageBoxImage.Exclamation); } }
void ModManagement_Downloaded(object sender, System.ComponentModel.AsyncCompletedEventArgs e) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } CleanupDownload(); if (e != null) { ModConfiguration mod = e.UserState as ModConfiguration; ModManagement.InstallComplete += new EventHandler <ProcessEventArgs>(ModManagement_InstallComplete); ModManagement.BeginInstall(mod, mod.PackagePath); } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
public static void Patch() { QuickLogger.Info("Started patching. Version: " + QuickLogger.GetAssemblyVersion()); #if DEBUG QuickLogger.DebugLogsEnabled = true; QuickLogger.Debug("Debug logs enabled"); #endif ModConfiguration.Initialize(); CubeGeneratorBuildable.PatchSMLHelper(); var harmony = new Harmony("com.ioncubegenerator.psmod"); harmony.PatchAll(Assembly.GetExecutingAssembly()); QuickLogger.Info("Finished patching"); }
private void Browse_Click(object sender, RoutedEventArgs e) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } Button btn = sender as Button; if (btn != null) { ModConfiguration mod = btn.CommandParameter as ModConfiguration; if (mod != null) { System.Diagnostics.Process.Start(mod.Download.Webpage); } } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
void BrowseForPackage(ModConfiguration mod) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } OpenFileDialog diag = new OpenFileDialog(); diag.Filter = AMLResources.Properties.Resources.SupportedCompressedFiles + DataStrings.SupportedCompressedFilesFilter + "|" + AMLResources.Properties.Resources.AllFiles + DataStrings.AllFilesFilter; diag.Title = GeneralHelper.AssemblyTitle; if (diag.ShowDialog() == true) { ModManagement.InstallComplete += new EventHandler <ProcessEventArgs>(ModManagement_InstallComplete2); ModManagement.BeginInstall(mod, diag.FileName); } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
private void InstallFromPC_Click(object sender, RoutedEventArgs e) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } Button btn = sender as Button; if (btn != null) { ModConfiguration mod = btn.CommandParameter as ModConfiguration; if (mod != null) { BrowseForPackage(mod); } } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
public static void Patch() { Configuration = Mod.LoadConfiguration(); var assembly = Assembly.GetExecutingAssembly(); QuickLogger.Info("Started patching. Version: " + QuickLogger.GetAssemblyVersion(assembly)); #if DEBUG QuickLogger.DebugLogsEnabled = true; QuickLogger.Debug("Debug logs enabled"); #endif try { LoadAssetBundle(); OptionsPanelHandler.RegisterModOptions(new Options()); GlobalBundle = FcAssetBundlesService.PublicAPI.GetAssetBundleByName(FcAssetBundlesService.PublicAPI.GlobalBundleName); AddTechFabricatorItems(); ARSSeaBreezeFCS32Buildable.PatchHelper(); var harmony = HarmonyInstance.Create("com.arsseabreezefcs32.fcstudios"); harmony.PatchAll(assembly); QuickLogger.Info("Finished patching"); QuickLogger.Debug($"{Configuration.StorageLimit}"); } catch (Exception ex) { QuickLogger.Error(ex); } }
private void Uninstall_Click(object sender, RoutedEventArgs e) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } Button btn = sender as Button; if (btn != null) { ModConfiguration mod = btn.CommandParameter as ModConfiguration; if (mod != null) { ModManagement.Uninstall(mod); this.RaiseEvent(new RoutedEventArgs(ModUninstalledEvent, mod)); } } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
private void Deactivate_Click(object sender, RoutedEventArgs e) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } Button btn = sender as Button; if (btn != null) { ModConfiguration mod = btn.CommandParameter as ModConfiguration; if (mod != null) { ModManagement.BackgroundDeactivateLastMod(); } } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
public static void Patch() { var version = QuickLogger.GetAssemblyVersion(Assembly.GetExecutingAssembly()); QuickLogger.Info($"Started patching. Version: {version}"); #if DEBUG QuickLogger.DebugLogsEnabled = true; QuickLogger.Debug("Debug logs enabled"); #endif try { GlobalBundle = FcAssetBundlesService.PublicAPI.GetAssetBundleByName(FcAssetBundlesService.PublicAPI.GlobalBundleName); if (GlobalBundle == null) { QuickLogger.Error("Global Bundle has returned null stopping patching"); throw new FileNotFoundException("Bundle failed to load"); } Configuration = Mod.LoadConfiguration(); AddItemsToTechFabricator(); QuantumTeleporterBuildable.PatchSMLHelper(); var harmony = HarmonyInstance.Create("com.quantumteleporter.fcstudios"); harmony.PatchAll(Assembly.GetExecutingAssembly()); QuickLogger.Info("Finished patching"); } catch (Exception ex) { QuickLogger.Error(ex); } }
private void ActivateStock_Click(object sender, RoutedEventArgs e) { bool WasPlaying = RussLibraryAudio.AudioServer.Current.IsPlaying; if (WasPlaying) { RussLibraryAudio.AudioServer.Current.Stop(); } if (!ModManagement.IsInstalled(DataStrings.StockID)) { if (!Directory.Exists(System.IO.Path.Combine(Locations.InstalledModsPath, DataStrings.StockID))) { Locations.MessageBoxShow("Stock Mod is not installed and Stock Mod install folder does not exist--cannot continue.", MessageBoxButton.OK, MessageBoxImage.Error); } else { ModConfiguration configuration = new ModConfiguration(DataStrings.ModStockFile); configuration.InstalledPath = System.IO.Path.Combine(Locations.InstalledModsPath, DataStrings.StockID); InstalledModConfigurations.Current.Configurations.Configurations.Insert(0, configuration); InstalledModConfigurations.Current.Save(); } } foreach (ModConfiguration configuration in InstalledModConfigurations.Current.Configurations.Configurations) { if (configuration.ID == DataStrings.StockID) { ModManagement.Activate(configuration); Locations.MessageBoxShow("Activated stock.", MessageBoxButton.OK, MessageBoxImage.Information); } } if (WasPlaying) { RussLibraryAudio.AudioServer.Current.PlayNextInQueue(); } Locations.MessageBoxShow("done.", MessageBoxButton.OK, MessageBoxImage.Information); }
public ProcessEventArgs(bool result, ModConfiguration config) { Result = result; Configuration = config; }
public ModDefiner() { InitializeComponent(); Configuration = new ModConfiguration(); }
public static void FileSelectionControl_InvalidFilePath(object sender, RoutedEventArgs e, ModConfiguration configuration) { if (_log.IsDebugEnabled) { _log.DebugFormat("Starting {0}", MethodBase.GetCurrentMethod().ToString()); } if (e != null) { KeyValuePair <string, string> result = ArtemisModLoader.Helpers.FileHelper.ProcessNotInModFile(e.OriginalSource as string, configuration); e.Source = result.Key; if (e.Source == null) { e.Handled = true; } else { if (!string.IsNullOrEmpty(result.Value)) { FileSelectionControl fsc = sender as FileSelectionControl; fsc.AlternatePrefix = result.Value; } } } if (_log.IsDebugEnabled) { _log.DebugFormat("Ending {0}", MethodBase.GetCurrentMethod().ToString()); } }
private static KeyValuePair <string, string> ProcessNotInModFile(string source, ModConfiguration mod) { // When selecting file items, no issue if within mod prefix. //If within Artemis copy, test if dependent mods and only dependent mods are active: no issue. //Otherwise auto copy selected file into current mod. string retVal = source; string alternatePrefix = null; if (mod != null && !string.IsNullOrEmpty(source)) { alternatePrefix = ModManagement.IsInModPathOrDependencyPath(source, mod); if (alternatePrefix != null) { retVal = source; //Need a way to pass back temporary alternate prefix for this. //Need what InstalledPath of matching Mod to get prefix. } else { //If not among dependent list, copy file in as below. retVal = DoFileDialog(source, mod.InstalledPath); } } return(new KeyValuePair <string, string>(retVal, alternatePrefix)); }