private void LoadSettings() { KaptureConfig.Initialize(_kaptureData.GetAppDirectory()); _kaptureConfig = KaptureConfig.GetInstance(); _configuration = (Configuration)_kaptureConfig.ConfigManager.Config; if (_language.Id == _configuration.XIVPlugin.LanguageId) { _kaptureConfig.ConfigManager.LoadSettings(); _configuration.XIVPlugin.FreshInstall = false; _kaptureConfig.ConfigManager.SaveSettings(); } else { var newConfig = new Configuration { General = _configuration.General, Filters = _configuration.Filters, Items = new Items(), Zones = new Zones(), Logging = new Logging(), Discord = new Discord(), HTTP = new HTTP(), XIVPlugin = new XIVPlugin() }; newConfig.XIVPlugin.LanguageId = _language.Id; KaptureConfig.GetInstance().Config = newConfig; _configuration = newConfig; } }
public void SetUp() { var language = new Language(1, "English", "en"); _kaptureData = KaptureDataMock.GetInstance(); _kaptureData.ACTConfig.GameLanguageId = language.Id; _kaptureData.Initialize(language.Id); KaptureConfig.Initialize(AppDomain.CurrentDomain.BaseDirectory); _configuration = (Config.Model.Config)KaptureConfig.GetInstance().ConfigManager.Config; _configuration.General.PluginEnabled = true; _parser = new ENLogLineParser(new ENLogLineParserContext(_kaptureData)); }
public void SetUp() { var language = new Language(4, "Japanese", "ja"); _kaptureData = KaptureDataMock.GetInstance(); _kaptureData.ACTConfig.GameLanguageId = language.Id; _kaptureData.Initialize(language.Id); KaptureConfig.Initialize(AppDomain.CurrentDomain.BaseDirectory); _configuration = (Config.Model.Config)KaptureConfig.GetInstance().ConfigManager.Config; _configuration.General.PluginEnabled = true; _configuration.Filters.ItemRolledOn = true; _configuration.Filters.ItemLost = true; _configuration.Filters.ItemCastLot = true; _parser = new JALogLineParser(new JALogLineParserContext(_kaptureData)); }
public void InitPlugin(TabPage pluginScreenSpace, Label pluginStatusText) { try { // setup tab space _tabPage = pluginScreenSpace; _pluginStatus = pluginStatusText; _tabPage.Text = PluginConstants.TabLabel; // setup aetherbridge _aetherbridge = Aetherbridge.GetInstance(); // setup logger Logger.Initialize(_aetherbridge.GetAppDirectory(), PluginConstants.LogFileName); var logPath = Path.Combine(_aetherbridge.GetAppDirectory(), PluginConstants.LogFileName); _logger = Logger.GetInstance(); if (!File.Exists(logPath)) { _logger.Info("Log file initialized."); } // setup serializer for json logs/rest calls _serializer = new JsonSerializer { Options = new JsonSerializerOptions { TypeNameSerializationBehavior = TypeNameSerializationBehavior.Never } }; // setup config KaptureConfig.Initialize(_aetherbridge.GetAppDirectory()); KaptureConfig = KaptureConfig.GetInstance(); Configuration = (Configuration)KaptureConfig.ConfigManager.Config; // set language var language = _aetherbridge.LanguageService.GetCurrentLanguage(); SetLanguage(language); // load settings if (language.Id == Configuration.XIVPlugin.LanguageId) { KaptureConfig.ConfigManager.LoadSettings(); } else { var newConfig = new Configuration { General = Configuration.General, Events = Configuration.Events, Items = new Items(), Zones = new Zones(), Logging = new Logging(), Discord = new Discord(), HTTP = new HTTP(), XIVPlugin = new XIVPlugin() }; newConfig.XIVPlugin.LanguageId = language.Id; KaptureConfig.GetInstance().Config = newConfig; Configuration = newConfig; } // setup plugin service _httpClient = new HttpClient(); KaptureVersion = Assembly.GetExecutingAssembly() .GetCustomAttribute <AssemblyInformationalVersionAttribute>().InformationalVersion; PluginService.Initialize(_httpClient, KaptureVersion, ActGlobals.oFormActMain.PluginGetSelfData(this).pluginFile.DirectoryName, language.Abbreviation); PluginService.GetInstance().KaptureLog = Path.Combine(_aetherbridge.GetAppDirectory(), PluginConstants.LogFileName); // create log dir if empty if (Configuration.Logging.LogLocation == null) { var path = Path.Combine(_aetherbridge.GetAppDirectory(), "KaptureLogs"); Directory.CreateDirectory(path); Configuration.Logging.LogLocation = path; KaptureConfig.ConfigManager.Config = Configuration; KaptureConfig.ConfigManager.SaveSettings(); } // setup loot parser event handler _aetherbridge.EnableLogLineParser(); _aetherbridge.LogLineCaptured += ParseLootEvents; // setup user interface var mainView = new MainView { Dock = DockStyle.Fill }; _tabPage.Controls.Add(mainView); _ = new MainPresenter(mainView, _aetherbridge); // update plugin status _pluginStatus.Text = PluginConstants.PluginStatusEnabled; // add data based on language (async) Task.Run(() => _aetherbridge.AddLanguage(Configuration.XIVPlugin.LanguageId)); // kick off update check (async) Task.Run(() => PluginService.GetInstance().UpdatePlugin(Configuration.General.CheckForBetaEnabled, false)); } catch (Exception ex) { _logger?.Error(ex); MessageBox.Show(PluginConstants.CriticalFailureMsg + Environment.NewLine + PluginConstants.ErrorPrefix + ex.StackTrace); _pluginStatus.Text = PluginConstants.PluginStatusDisabledFailure; ActGlobals.oFormActMain.PluginGetSelfData(this).cbEnabled.Checked = false; } }