public AboutPresenter(AboutView aboutView) { KaptureConfig = KaptureConfig.GetInstance(); Configuration = (Configuration)KaptureConfig.ConfigManager.Config; AboutView = aboutView; AboutView.Version = PluginService.GetInstance().Version; AboutView.UpdateClicked += CheckForUpdates; AboutView.LinkClicked += OpenLink; AboutView.ViewLogsClicked += OpenPluginLog; }
public HTTPPresenter(HTTPView httpView) { HTTPView = httpView; KaptureConfig = KaptureConfig.GetInstance(); Configuration = (Configuration)KaptureConfig.ConfigManager.Config; HTTPView.HTTPEnabled = Configuration.HTTP.HTTPEnabled; HTTPView.Endpoint = Configuration.HTTP.Endpoint; HTTPView.CustomJson = Configuration.HTTP.CustomJson; HTTPView.HTTPEnabledChanged += HTTPEnabledChanged; HTTPView.HTTPUpdated += HTTPUpdated; }
public DiscordPresenter(DiscordView discordView) { KaptureConfig = KaptureConfig.GetInstance(); Configuration = (Configuration)KaptureConfig.ConfigManager.Config; DiscordView = discordView; DiscordConfig = Configuration.Discord; DiscordView.DiscordEnabled = DiscordConfig.DiscordEnabled; DiscordView.Endpoint = DiscordConfig.Endpoint; DiscordView.DiscordEnabledChanged += DiscordEnabledChanged; DiscordView.DiscordUpdated += DiscordUpdated; }
public LoggingPresenter(LoggingView loggingView) { LoggingView = loggingView; KaptureConfig = KaptureConfig.GetInstance(); Configuration = (Configuration)KaptureConfig.ConfigManager.Config; LoggingConfig = Configuration.Logging; LoggingView.LoggingEnabled = LoggingConfig.LoggingEnabled; LoggingView.LogFormatList = LogFormat.LogFormats; LoggingView.LogFormat = LoggingConfig.LogFormat; LoggingView.LogLocation = LoggingConfig.LogLocation; LoggingView.LoggingEnabledChanged += LoggingEnabledChanged; LoggingView.LogFormatChanged += LogFormatChanged; LoggingView.LogLocationUpdated += LogLocationUpdated; }
public ItemsPresenter(ItemsView itemsView, ItemService itemService) { ItemsView = itemsView; KaptureConfig = KaptureConfig.GetInstance(); Configuration = (Configuration)KaptureConfig.ConfigManager.Config; _itemService = itemService; ItemsView.FilterByItems = Configuration.Items.FilterByItems; ItemsView.ItemPresetList = ItemPreset.ItemPresets; ItemsView.ItemPreset = Configuration.Items.ItemPreset; ItemsView.AddItem = itemService.GetItemNames(); SetFilterByPreset(); ItemsView.FilterByItemsChanged += FilterByItemsChanged; ItemsView.ItemPresentChanged += ItemPresetChanged; ItemsView.IncludeItemsEnabledChanged += IncludeItemsEnabledChanged; ItemsView.ExcludeItemsEnabledChanged += ExcludeItemsEnabledChanged; ItemsView.ItemsListChanged += ItemsListChanged; ItemsView.ItemsListAdded += ItemsListAdded; }
public EventsPresenter(EventsView eventsView) { EventsView = eventsView; KaptureConfig = KaptureConfig.GetInstance(); Configuration = (Configuration)KaptureConfig.ConfigManager.Config; EventsView.ItemAddedEnabled = Configuration.Events.ItemAddedEnabled; EventsView.ItemLostEnabled = Configuration.Events.ItemDroppedEnabled; EventsView.YouObtainedEnabled = Configuration.Events.YouObtainedEnabled; EventsView.TheyObtainedEnabled = Configuration.Events.TheyObtainedEnabled; EventsView.YouRolledEnabled = Configuration.Events.YouRolledEnabled; EventsView.TheyRolledEnabled = Configuration.Events.TheyRolledEnabled; EventsView.ItemAddedEnabledChanged += ItemAddedEnabledChanged; EventsView.ItemDroppedEnabledChanged += ItemDroppedEnabledChanged; EventsView.YouObtainedEnabledChanged += YouObtainedEnabledChanged; EventsView.TheyObtainedEnabledChanged += TheyObtainedEnabledChanged; EventsView.YouRolledEnabledChanged += YouRolledEnabledChanged; EventsView.TheyRolledEnabledChanged += TheyRolledEnabledChanged; }
public ZonesPresenter(ZonesView zonesView, ContentService contentService) { ZonesView = zonesView; _contentService = contentService; KaptureConfig = KaptureConfig.GetInstance(); Configuration = (Configuration)KaptureConfig.ConfigManager.Config; ZonesConfig = Configuration.Zones; ZonesView.FilterByZones = ZonesConfig.FilterByZones; ZonesView.ZonePresetList = ZonePreset.ZonePresets; ZonesView.ZonePreset = ZonesConfig.ZonePreset; ZonesView.AddZone = _contentService.GetContentNames(); SetFilterByPreset(); ZonesView.FilterByZonesChanged += FilterByZonesChanged; ZonesView.ZonePresentChanged += ZonePresetChanged; ZonesView.IncludeZonesEnabledChanged += IncludeZonesEnabledChanged; ZonesView.ExcludeZonesEnabledChanged += ExcludeZonesEnabledChanged; ZonesView.ZonesListChanged += ZonesListChanged; ZonesView.ZonesListAdded += ZonesListAdded; }
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; } }
private void ParseLootEvents(object sender, LogLineEvent logLineEvent) { try { // loot filter if (logLineEvent?.XIVEvent == null) { return; } if (logLineEvent.XIVEvent.XIVEventType != XIVEventTypeEnum.Loot) { return; } // set vars var lootEvent = logLineEvent.XIVEvent; Configuration = (Configuration)KaptureConfig.ConfigManager.Config; // general filter if (!Configuration.General.PluginEnabled) { return; } if (logLineEvent.ACTLogLineEvent.IsImport && !Configuration.General.LogImportsEnabled) { return; } // events filter if (lootEvent.XIVEventSubType == XIVEventSubTypeEnum.AddLoot) { if (!Configuration.Events.ItemAddedEnabled) { return; } } else if (lootEvent.XIVEventSubType == XIVEventSubTypeEnum.LostLoot) { if (!Configuration.Events.ItemDroppedEnabled) { return; } } else if (lootEvent.XIVEventSubType == XIVEventSubTypeEnum.ObtainLoot) { if (lootEvent.Actor.IsReporter) { if (!Configuration.Events.YouObtainedEnabled) { return; } } else if (!lootEvent.Actor.IsReporter) { if (!Configuration.Events.TheyObtainedEnabled) { return; } } else { return; } } else if (lootEvent.XIVEventSubType == XIVEventSubTypeEnum.NeedLoot || lootEvent.XIVEventSubType == XIVEventSubTypeEnum.GreedLoot) { if (lootEvent.Actor.IsReporter) { if (!Configuration.Events.YouRolledEnabled) { return; } } else if (!lootEvent.Actor.IsReporter) { if (!Configuration.Events.TheyRolledEnabled) { return; } } else { return; } } // items filter if (Configuration.Items.FilterByItems) { if (Configuration.Items.IncludeItems) { if (!Configuration.Items.ItemsList.Contains(lootEvent.Item.ProperName)) { return; } } else if (Configuration.Items.ExcludeItems) { if (Configuration.Items.ItemsList.Contains(lootEvent.Item.ProperName)) { return; } } } // zones filter if (Configuration.Zones.FilterByZones && !logLineEvent.ACTLogLineEvent.IsImport) { if (Configuration.Zones.IncludeZones) { if (!Configuration.Zones.ZonesList.Contains(lootEvent.Location.Zone.Name)) { return; } } else if (Configuration.Zones.ExcludeZones) { if (Configuration.Zones.ZonesList.Contains(lootEvent.Location.Zone.Name)) { return; } } } // log messages if (Configuration.Logging.LoggingEnabled) { if (Configuration.Logging.LogFormat.ToString().Equals(LogFormat.LogFile.ToString())) { LogSimpleFormat(logLineEvent); } else if (Configuration.Logging.LogFormat.ToString().Equals(LogFormat.CSV.ToString())) { LogCsvFormat(logLineEvent); } else if (Configuration.Logging.LogFormat.ToString().Equals(LogFormat.JSON.ToString())) { LogJsonFormat(logLineEvent); } } // send message to discord if (Configuration.Discord.DiscordEnabled) { SendToDiscordWebHook(logLineEvent); } // send message to rest endpoint if (Configuration.HTTP.HTTPEnabled) { SendRestCall(logLineEvent); } } catch (Exception ex) { _logger.Info("Failed on log line: " + logLineEvent?.LogMessage); _logger.Error(ex); } }