static void Main() { #if !DEBUG Sentry.Initialise(); #endif Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainForm form = new MainForm(); Application.Run(form); }
internal static void Ex(Exception ex, string format, params object[] args) { #if DEBUG var message = ex.ToString(); #else var message = ex.Message; #endif message = Escape(message); E(string.Format("{0}: {1}", format, message), args); Sentry.ReportAsync(ex, new { LogMessage = string.Format(format, args) }); }
internal static void Ex(Exception ex, string key, params object[] args) { #if DEBUG throw ex; #else var format = Localization.GetText(key); var message = ex.Message; message = Escape(message); E($"{format}: {message}", args); Sentry.ReportAsync(ex, new { LogMessage = string.Format(format.ToString(), args) }); #endif }
internal static Roulette GetRoulette(int code) { if (Roulettes.ContainsKey(code)) { return(Roulettes[code]); } if (code != 0) { var @event = new SentryEvent("Missing Roulette code"); @event.Level = ErrorLevel.Warning; @event.Tags["code"] = code.ToString(); Sentry.ReportAsync(@event); } return(new Roulette(string.Format("알 수 없는 무작위 임무 ({0})", code))); }
internal static FATE GetFATE(int code) { if (FATEs.ContainsKey(code)) { return(FATEs[code]); } if (code != 0) { var @event = new SentryEvent("Missing FATE code"); @event.Level = ErrorLevel.Warning; @event.Tags["code"] = code.ToString(); Sentry.ReportAsync(@event); } return(new FATE(0, string.Format("알 수 없는 돌발 ({0})", code))); }
internal static Instance GetInstance(int code) { if (Areas.ContainsKey(code)) { return(Areas[code].Instance); } if (code != 0) { var @event = new SentryEvent("Missing instance code"); @event.Level = ErrorLevel.Warning; @event.Tags["code"] = code.ToString(); Sentry.ReportAsync(@event); } return(new Instance(string.Format("알 수 없는 임무 ({0})", code), 0, 0, 0)); }
public static string GetAreaName(int key) { if (Areas.ContainsKey(key)) { return(Areas[key].Name); } else { if (key != 0) { var @event = new SentryEvent("Missing area code"); @event.Level = ErrorLevel.Warning; @event.Tags["code"] = key.ToString(); Sentry.ReportAsync(@event); } return(string.Format("알 수 없는 지역 ({0})", key)); } }
internal static Instance GetInstance(int code) { if (Instances.TryGetValue(code, out var instance)) { return(instance); } if (code != 0) { var @event = new SentryEvent("Missing instance code"); @event.Level = ErrorLevel.Warning; @event.Tags["code"] = code.ToString(); Sentry.ReportAsync(@event); } return(new Instance { Name = Localization.GetText("unknown-instance", code) }); }
internal static FATE GetFATE(int code) { if (FATEs.ContainsKey(code)) { return(FATEs[code]); } if (code != 0) { var @event = new SentryEvent("Missing FATE code"); @event.Level = ErrorLevel.Warning; @event.Tags["code"] = code.ToString(); Sentry.ReportAsync(@event); } return(new FATE { Name = Localization.GetText("unknown-fate", code) }); }
internal static Area GetArea(int code) { if (Areas.TryGetValue(code, out var area)) { return(area); } if (code != 0) { var @event = new SentryEvent("Missing area code"); @event.Level = ErrorLevel.Warning; @event.Tags["code"] = code.ToString(); Sentry.ReportAsync(@event); } return(new Area { Name = Localization.GetText("unknown-area", code) }); }
internal static Roulette GetRoulette(int code) { if (Roulettes.TryGetValue(code, out var roulette)) { return(roulette); } if (code != 0) { var @event = new SentryEvent("Missing Roulette code"); @event.Level = ErrorLevel.Warning; @event.Tags["code"] = code.ToString(); Sentry.ReportAsync(@event); } return(new Roulette { Name = Localization.GetText("unknown-roulette", code) }); }
private void MainForm_Load(object sender, EventArgs e) { Localization.Initialize(Settings.Language); Data.Initialize(Settings.Language); ApplyLanguage(); overlayForm.Show(); networkWorker = new Network(this); label_AboutTitle.Text = $@"DFA {Global.VERSION}"; FindFFXIVProcess(); if (!Settings.ShowOverlay) { overlayForm.Hide(); checkBox_Overlay.Checked = false; } Task.Factory.StartNew(() => { while (true) { Updater.CheckNewVersion(this); Thread.Sleep(30 * 60 * 1000); } }); comboBox_Language.DataSource = new[] { new Language { Name = "한국어", Code = "ko-kr" }, new Language { Name = "English", Code = "en-us" }, new Language { Name = "Français", Code = "fr-fr" }, new Language { Name = "日本語", Code = "ja-jp" }, }; comboBox_Language.DisplayMember = "Name"; comboBox_Language.ValueMember = "Code"; comboBox_Language.SelectedValue = Settings.Language; comboBox_Language.SelectedValueChanged += comboBox_Language_SelectedValueChanged; checkBox_StartupShow.Checked = Settings.StartupShowMainForm; checkBox_AutoOverlayHide.Checked = Settings.AutoOverlayHide; checkBox_FlashWindow.Checked = Settings.FlashWindow; checkBox_PlaySound.Checked = Settings.PlaySound; if (System.IO.File.Exists(Settings.SoundLocation) == false) { checkBox_PlaySound.Checked = false; label_SoundLocation.Text = ""; } else { label_SoundLocation.Text = System.IO.Path.GetFileName(Settings.SoundLocation); } if (checkBox_PlaySound.Checked == false) { button_SoundLocation.Enabled = false; } checkBox_ShowAnnouncement.Checked = Settings.ShowAnnouncement; checkBox_Twitter.Checked = Settings.TwitterEnabled; textBox_Twitter.Enabled = Settings.TwitterEnabled; textBox_Twitter.Text = Settings.TwitterAccount; foreach (var area in Data.Areas) { triStateTreeView_FATEs.Nodes.Add(area.Key.ToString(), area.Value.Name); foreach (var fate in area.Value.FATEs) { var node = triStateTreeView_FATEs.Nodes[area.Key.ToString()].Nodes.Add(fate.Key.ToString(), fate.Value.Name); node.Checked = Settings.FATEs.Contains(fate.Key); nodes.Add(node); } } Task.Factory.StartNew(() => { while (true) { Thread.Sleep(30 * 1000); if (FFXIVProcess == null || FFXIVProcess.HasExited) { FFXIVProcess = null; overlayForm.SetStatus(false); this.Invoke(FindFFXIVProcess); } else { // FFXIVProcess is alive if (networkWorker.IsRunning) { networkWorker.UpdateGameConnections(FFXIVProcess); } else { networkWorker.StartCapture(FFXIVProcess); } } } }); if (Settings.Updated) { Settings.Updated = false; Settings.Save(); ShowNotification("notification-app-updated", Global.VERSION); } Sentry.ReportAsync("App started"); }
internal static void CheckNewVersion(MainForm mainForm) { Task.Factory.StartNew(() => { var tempdir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Global.APPNAME, Global.UPDATE_TEMP_DIRPATH); var batchpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), Global.APPNAME, "update.bat"); if (Directory.Exists(tempdir)) { Directory.Delete(tempdir, true); } Directory.CreateDirectory(tempdir); var resp = WebApi.Request($"https://api.github.com/repos/{Global.GITHUB_REPO}/releases/latest"); if (resp == null) { Log.E("l-updater-error-check"); return; } try { var api = JsonConvert.DeserializeObject <dynamic>(resp); var latest = api.tag_name.ToObject <string>(); Log.I("l-updater-current-version", Global.VERSION); Log.I("l-updater-latest-version", latest); if (decimal.Parse(Global.VERSION.Substring(1)) >= decimal.Parse(latest.Substring(1))) { Log.S("l-updater-is-latest"); } else { Log.S("l-updater-new-version"); string url = null; foreach (var asset in api.assets) { if (asset.name == string.Format("DFAssist.{0}.zip", latest)) { url = asset.browser_download_url; break; } } if (url == null) { Log.E("l-updater-error-no-url"); return; } mainForm.Invoke(() => { mainForm.Hide(); mainForm.overlayForm.Hide(); }); Task.Factory.StartNew(() => { var updaterForm = new UpdaterForm(); updaterForm.SetVersion(latest); updaterForm.ShowDialog(); }); Sentry.Report("Update started"); var stream = GetDownloadStreamByUrl(url); using (var zip = ZipStorer.Open(stream, FileAccess.Read)) { var dir = zip.ReadCentralDir(); foreach (var entry in dir) { if (entry.FilenameInZip == "README.txt") { continue; } zip.ExtractFile(entry, Path.Combine(tempdir, entry.FilenameInZip)); } } var exepath = Process.GetCurrentProcess().MainModule.FileName; var currentdir = Path.GetDirectoryName(exepath); File.WriteAllText(batchpath, "@echo off\r\n" + "title DFAssist Updater\r\n" + "echo Updating DFAssist...\r\n" + "ping 127.0.0.1 -n 3 > nul\r\n" + $"move /y \"{tempdir}\\*\" \"{currentdir}\" > nul\r\n" + $"\"{exepath}\"\r\n" + "echo Running DFAssist...\r\n", Encoding.Default); var si = new ProcessStartInfo(); si.FileName = batchpath; si.CreateNoWindow = true; si.UseShellExecute = false; si.WindowStyle = ProcessWindowStyle.Hidden; Process.Start(si); Settings.Updated = true; Settings.Save(); Application.Exit(); } } catch (Exception ex) { Log.Ex(ex, "l-updater-error-general"); } try { var json = WebApi.Request($"https://raw.githubusercontent.com/{Global.GITHUB_REPO}/master/App/Resources/Data/{Settings.Language}.json"); Data.Fill(json); } catch (Exception ex) { Log.Ex(ex, "l-updater-error-data"); } }); }
private void MainForm_Load(object sender, EventArgs e) { Data.Initializer(); overlayForm.Show(); networkWorker = new Network(this); label_AboutTitle.Text = string.Format("DFA {0}", Global.VERSION); FindFFXIVProcess(); if (!Settings.ShowOverlay) { overlayForm.Hide(); checkBox_Overlay.Checked = false; } Task.Factory.StartNew(() => { while (true) { Updater.CheckNewVersion(this); Thread.Sleep(30 * 60 * 1000); } }); checkBox_StartupShow.Checked = Settings.StartupShowMainForm; checkBox_AutoOverlayHide.Checked = Settings.AutoOverlayHide; checkBox_FlashWindow.Checked = Settings.FlashWindow; SetCheatRoulleteCheckBox(Settings.CheatRoulette); checkBox_Twitter.Checked = Settings.TwitterEnabled; textBox_Twitter.Enabled = Settings.TwitterEnabled; textBox_Twitter.Text = Settings.TwitterAccount; foreach (var zone in Data.Areas) { if (!zone.Value.isDuty && zone.Value.FATEList.Count > 0) { triStateTreeView_FATEs.Nodes.Add(zone.Key.ToString(), zone.Value.Name); } } foreach (var fate in Data.GetFATEs()) { var node = triStateTreeView_FATEs.Nodes[fate.Value.Zone.ToString()].Nodes.Add(fate.Key.ToString(), fate.Value.Name); node.Checked = Settings.FATEs.Contains(fate.Key); nodes.Add(node); } Task.Factory.StartNew(() => { while (true) { Thread.Sleep(30 * 1000); if ((FFXIVProcess == null) || FFXIVProcess.HasExited) { FFXIVProcess = null; overlayForm.SetStatus(false); this.Invoke(() => FindFFXIVProcess()); } else { // FFXIVProcess is alive if (networkWorker.IsRunning) { networkWorker.UpdateGameConnections(FFXIVProcess); } else { networkWorker.StartCapture(FFXIVProcess); } } } }); if (Settings.Updated) { Settings.Updated = false; Settings.Save(); ShowNotification("버전 {0} 업데이트됨", Global.VERSION); } Sentry.ReportAsync("App started"); }