void Initialize() { ffxiv_ = new FFXIVProcess(this); fight_tracker_ = new FightTracker(this); wipe_detector_ = new WipeDetector(this); dispatch_json_writer_ = new JsonTextWriter(new System.IO.StringWriter(dispatch_string_builder_)); dispatch_serializer_ = JsonSerializer.CreateDefault(); message_serializer_ = JsonSerializer.CreateDefault(); // Our own timer with a higher frequency than OverlayPlugin since we want to see // the effect of log messages quickly. fast_update_timer_ = new System.Timers.Timer(); fast_update_timer_.Elapsed += (o, args) => { // Hold this while we're in here to prevent the Renderer or Browser from disappearing from under us. fast_update_timer_semaphore_.Wait(); int timer_interval = kSlowTimerMilli; try { timer_interval = SendFastRateEvents(); } catch (Exception e) { // SendFastRateEvents holds this semaphore until it exits. LogError("Exception in SendFastRateEvents: " + e.Message); LogError("Stack: " + e.StackTrace); LogError("Source: " + e.Source); } fast_update_timer_semaphore_.Release(); fast_update_timer_.Interval = timer_interval; fast_update_timer_.Start(); }; fast_update_timer_.AutoReset = false; // Incoming events. Advanced_Combat_Tracker.ActGlobals.oFormActMain.OnLogLineRead += OnLogLineRead; // Outgoing JS events. OnGameExists += (e) => DispatchToJS(e); OnGameActiveChanged += (e) => DispatchToJS(e); OnZoneChanged += (e) => DispatchToJS(e); if (this.Config.LogUpdatesEnabled) { OnLogsChanged += (e) => DispatchToJS(e); } OnPlayerChanged += (e) => DispatchToJS(e); OnTargetChanged += (e) => DispatchToJS(e); OnTargetCasting += (e) => DispatchToJS(e); OnFocusChanged += (e) => DispatchToJS(e); OnFocusCasting += (e) => DispatchToJS(e); OnInCombatChanged += (e) => DispatchToJS(e); OnPlayerDied += (e) => DispatchToJS(e); OnPartyWipe += (e) => DispatchToJS(e); OnDataFilesRead += (e) => DispatchToJS(e); fast_update_timer_.Interval = kFastTimerMilli; fast_update_timer_.Start(); if (is_first_overlay_initialized_) { is_first_overlay_initialized_ = false; var versions = new VersionChecker(this); Version local = versions.GetLocalVersion(); Version remote = versions.GetRemoteVersion(); Version overlay = versions.GetOverlayPluginVersion(); Version ffxiv = versions.GetFFXIVPluginVersion(); Version act = versions.GetACTVersion(); // Print out version strings and locations to help users debug. LogInfo("cactbot: {0} {1}", local.ToString(), versions.GetCactbotLocation()); LogInfo("OverlayPlugin: {0} {1}", overlay.ToString(), versions.GetOverlayPluginLocation()); LogInfo("FFXIV Plugin: {0} {1}", ffxiv.ToString(), versions.GetFFXIVPluginLocation()); LogInfo("ACT: {0} {1}", act.ToString(), versions.GetACTLocation()); if (remote.Major == 0 && remote.Minor == 0) { var result = System.Windows.Forms.MessageBox.Show(Overlay, "Github error while checking Cactbot version. " + "Your current version is " + local + ".\n\n" + "Manually check for newer version now?", "Cactbot Manual Check", System.Windows.Forms.MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { System.Diagnostics.Process.Start(VersionChecker.kReleaseUrl); } } else if (local < remote) { Version remote_seen_before = new Version(Config.RemoteVersionSeen); Config.RemoteVersionSeen = remote.ToString(); string update_message = "There is a new version of Cactbot is available at: \n" + VersionChecker.kReleaseUrl + " \n\n" + "New version " + remote + " \n" + "Current version " + local; if (remote == remote_seen_before) { LogError(update_message); } else { var result = System.Windows.Forms.MessageBox.Show(Overlay, update_message + "\n\n" + "Get it now?", "Cactbot update available", System.Windows.Forms.MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) { System.Diagnostics.Process.Start(VersionChecker.kReleaseUrl); } } Config.RemoteVersionSeen = remote.ToString(); } } string net_version_str = System.Diagnostics.FileVersionInfo.GetVersionInfo(typeof(int).Assembly.Location).ProductVersion; string[] net_version = net_version_str.Split('.'); if (int.Parse(net_version[0]) < kRequiredNETVersionMajor || int.Parse(net_version[1]) < kRequiredNETVersionMinor) { LogError("Requires .NET 4.6 or above. Using " + net_version_str); } init_ = true; if (deferred_navigate_ != null) { this.Navigate(deferred_navigate_); } }
public BossFightListener(FightTracker tracker, List <BossFightPhaseDetails> fights) { tracker_ = tracker; fights_ = fights; }
public CactbotOverlay(CactbotOverlayConfig config) : base(config, config.Name) { main_thread_sync_ = System.Windows.Forms.WindowsFormsSynchronizationContext.Current; ffxiv_ = new FFXIVProcess(this); fight_tracker_ = new FightTracker(this); wipe_detector_ = new WipeDetector(this); dispatch_json_writer_ = new JsonTextWriter(new System.IO.StringWriter(dispatch_string_builder_)); dispatch_serializer_ = JsonSerializer.CreateDefault(); message_serializer_ = JsonSerializer.CreateDefault(); // Our own timer with a higher frequency than OverlayPlugin since we want to see // the effect of log messages quickly. fast_update_timer_ = new System.Timers.Timer(); fast_update_timer_.Elapsed += (o, args) => { try { SendFastRateEvents(); } catch (Exception e) { // SendFastRateEvents holds this semaphore until it exits. fast_update_timer_semaphore_.Release(); LogError("Exception in SendFastRateEvents: " + e.Message); LogError("Stack: " + e.StackTrace); LogError("Source: " + e.Source); fast_update_timer_.Interval = kSlowTimerMilli; fast_update_timer_.Start(); } }; fast_update_timer_.AutoReset = false; // Incoming events. Advanced_Combat_Tracker.ActGlobals.oFormActMain.OnLogLineRead += OnLogLineRead; // Outgoing JS events. OnGameExists += (e) => DispatchToJS(e); OnGameActiveChanged += (e) => DispatchToJS(e); OnZoneChanged += (e) => DispatchToJS(e); if (config.LogUpdatesEnabled) { OnLogsChanged += (e) => DispatchToJS(e); } OnPlayerChanged += (e) => DispatchToJS(e); OnTargetChanged += (e) => DispatchToJS(e); OnTargetCasting += (e) => DispatchToJS(e); OnFocusChanged += (e) => DispatchToJS(e); OnFocusCasting += (e) => DispatchToJS(e); OnInCombatChanged += (e) => DispatchToJS(e); OnPlayerDied += (e) => DispatchToJS(e); OnPartyWipe += (e) => DispatchToJS(e); OnDataFilesRead += (e) => DispatchToJS(e); fast_update_timer_.Interval = kFastTimerMilli; fast_update_timer_.Start(); if (check_version_) { check_version_ = false; var versions = new VersionChecker(this); Version local = versions.GetLocalVersion(); Version remote = versions.GetRemoteVersion(); if (local < remote) { Version remote_seen_before = new Version(Config.RemoteVersionSeen); Config.RemoteVersionSeen = remote.ToString(); string update_message = "There is a new version of Cactbot is available at: \n" + VersionChecker.kReleaseUrl + " \n\n" + "New version " + remote + " \n" + "Current version " + local; if (remote == remote_seen_before) { LogError(update_message); } else { var result = System.Windows.Forms.MessageBox.Show(Overlay, update_message + "\n\n" + "Get it now?", "Cactbot update available", System.Windows.Forms.MessageBoxButtons.YesNo); if (result == System.Windows.Forms.DialogResult.Yes) System.Diagnostics.Process.Start(VersionChecker.kReleaseUrl); } Config.RemoteVersionSeen = remote.ToString(); } } string net_version_str = System.Diagnostics.FileVersionInfo.GetVersionInfo(typeof(int).Assembly.Location).ProductVersion; string[] net_version = net_version_str.Split('.'); if (int.Parse(net_version[0]) < kRequiredNETVersionMajor || int.Parse(net_version[1]) < kRequiredNETVersionMinor) LogError("Requires .NET 4.6 or above. Using " + net_version_str); init_ = true; if (deferred_navigate_ != null) { this.Navigate(deferred_navigate_); } }
public GenericDungeonListener(FightTracker tracker) { this.tracker_ = tracker; }