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());
            }
        }
예제 #2
0
        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());
            }
        }
예제 #3
0
        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;
        }
예제 #4
0
        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());
            }
        }
예제 #5
0
        /// <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);
        }
예제 #6
0
        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);
                        }
                    }
                }
            }
        }
예제 #7
0
        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);
        }
예제 #9
0
 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);
     }
 }
예제 #10
0
 void UpdateTestConfigs(ModConfiguration mod)
 {
     if (TestConfigs.Contains(mod))
     {
         TestConfigs.Remove(mod);
     }
     if (TestConfigs.Count < 1)
     {
         MessageBox.Show("done");
     }
 }
예제 #11
0
        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;
            }
        }
예제 #13
0
        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);
            }
        }
예제 #14
0
        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());
            }
        }
예제 #15
0
        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);
     }
 }
예제 #17
0
 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());
     }
 }
예제 #18
0
        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());
            }
        }
예제 #20
0
        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());
            }
        }
예제 #21
0
        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());
            }
        }
예제 #22
0
        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());
            }
        }
예제 #24
0
        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);
            }
        }
예제 #26
0
        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);
        }
예제 #27
0
 public ProcessEventArgs(bool result, ModConfiguration config)
 {
     Result        = result;
     Configuration = config;
 }
예제 #28
0
 public ModDefiner()
 {
     InitializeComponent();
     Configuration = new ModConfiguration();
 }
예제 #29
0
        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());
            }
        }
예제 #30
0
        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));
        }