From 18a9ccedbfb298e024001a3f48f3682b9820fce3 Mon Sep 17 00:00:00 2001 From: Wana Date: Thu, 21 Dec 2017 18:22:58 +0900 Subject: [PATCH] =?UTF-8?q?=EC=95=8C=EB=A6=BC=20=EB=B0=9B=EC=9D=84=20?= =?UTF-8?q?=EB=8F=8C=EB=B0=9C=20=EC=B2=B4=ED=81=AC=ED=95=9C=EB=92=A4=20?= =?UTF-8?q?=EC=96=B8=EC=96=B4=20=EB=B0=94=EA=BE=B8=EB=A9=B4=20=EC=B1=84?= =?UTF-8?q?=ED=81=AC=EA=B0=80=20=ED=92=80=EB=A6=AC=EB=8A=94=20=EB=B2=84?= =?UTF-8?q?=EA=B7=B8=20=EC=88=98=EC=A0=95=20=ED=94=8C=EB=9F=AC=EA=B7=B8?= =?UTF-8?q?=EC=9D=B8=20=EB=A1=9C=EB=93=9C=EC=8B=9C=20=EC=84=9C=EB=B2=84?= =?UTF-8?q?=EC=97=90=EC=84=9C=20=EB=8D=B0=EC=9D=B4=ED=84=B0=EB=A5=BC=20?= =?UTF-8?q?=EA=B0=B1=EC=8B=A0=20=EB=B0=9B=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ACT_Fate/ACTFate.cs | 99 ++++++++++++++++++++------- ACT_Fate/FFXIV_FATE_ACT_Plugin.csproj | 1 + 2 files changed, 76 insertions(+), 24 deletions(-) diff --git a/ACT_Fate/ACTFate.cs b/ACT_Fate/ACTFate.cs index 5d08b0e..0fad7a9 100644 --- a/ACT_Fate/ACTFate.cs +++ b/ACT_Fate/ACTFate.cs @@ -14,6 +14,7 @@ using System.Net; using System.Collections.Specialized; using System.Linq; +using System.Threading.Tasks; [assembly: AssemblyTitle("FFXIV F.A.T.E")] //[assembly: AssemblyDescription("FATE Log")] @@ -70,34 +71,46 @@ public void InitPlugin(System.Windows.Forms.TabPage pluginScreenSpace, System.Wi this.lblStatus.Text = "FFXIV F.A.T.E Plugin Started."; pluginScreenSpace.Text = "FATE Parser"; - pluginScreenSpace.Controls.Add(this); - xmlSettings = new SettingsSerializer(this); - - foreach (ActPluginData plugin in ActGlobals.oFormActMain.ActPlugins) + Task.Factory.StartNew(() => { - if (plugin.pluginObj != this) continue; - fileInfo = plugin.pluginFile; - break; - } + this.lblStatus.Text = "Downloading Data.json"; + loadJSONData(); + this.lblStatus.Text = "Downloaded Data.json"; - if (timer == null) - { - timer = new System.Windows.Forms.Timer(); - timer.Interval = 30 * 1000; - timer.Tick += Timer_Tick; - } - timer.Enabled = true; + pluginStatusText.Invoke(new Action(delegate () + { + this.lblStatus.Text = "FFXIV F.A.T.E Plugin Started."; - updateFFXIVProcesses(); + pluginScreenSpace.Controls.Add(this); + xmlSettings = new SettingsSerializer(this); + foreach (ActPluginData plugin in ActGlobals.oFormActMain.ActPlugins) + { + if (plugin.pluginObj != this) continue; + fileInfo = plugin.pluginFile; + break; + } - loadJSONData(); - LoadSettings(); - this.comboBoxLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - selLng = (string)this.comboBoxLanguage.SelectedValue; - loadFates(); + if (timer == null) + { + timer = new System.Windows.Forms.Timer(); + timer.Interval = 30 * 1000; + timer.Tick += Timer_Tick; + } + timer.Enabled = true; + + updateFFXIVProcesses(); + + + LoadSettings(); + this.comboBoxLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + selLng = (string)this.comboBoxLanguage.SelectedValue; + loadFates(); + + })); + }); } void LoadSettings() @@ -484,7 +497,7 @@ private void Network_onReceiveEvent(int pid, App.Network.EventType eventType, in string text = pid + "|" + server + "|" + eventType + "|"; - int pos = 0; + int pos = 0; bool isFate = false; switch (eventType) { case App.Network.EventType.INSTANCE_ENTER: @@ -497,7 +510,8 @@ private void Network_onReceiveEvent(int pid, App.Network.EventType eventType, in case App.Network.EventType.FATE_BEGIN: case App.Network.EventType.FATE_PROGRESS: case App.Network.EventType.FATE_END: - text += getTextFate(args[0]) + "|" + getTextFateArea(args[0]) + "|";pos++; + isFate = true; + text += getTextFate(args[0]) + "|" + getTextFateArea(args[0]) + "|"; pos++; break; case App.Network.EventType.MATCH_BEGIN: text += (App.Network.MatchType)args[0] + "|"; pos++; @@ -534,6 +548,11 @@ private void Network_onReceiveEvent(int pid, App.Network.EventType eventType, in text += args[i] + "|"; } + if (isFate) + { + text += args[0] + "|"; + } + sendToACT(text); postToToastWindowsNotificationIfNeeded(server, eventType, args); @@ -558,9 +577,40 @@ private class Language private string telegramChkFates; private ConcurrentStack telegramSelectedFates = new ConcurrentStack(); + private string downloadData(string url) + { + WebClient webClient = new WebClient(); + webClient.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.BypassCache); + StringBuilder stringBuilder = new StringBuilder(); + try + { + using (Stream stream = webClient.OpenRead(url + new Random().Next())) + { + using (StreamReader streamReader = new StreamReader(stream)) + { + for (; ; ) + { + string text3 = streamReader.ReadLine(); + if (text3 == null) + { + break; + } + stringBuilder.Append(text3); + } + } + } + return stringBuilder.ToString(); + } + catch (Exception) + { + return null; + } + } + private void loadJSONData() { - string jsonString = File.ReadAllText(fileInfo.Directory.FullName + "/data.json"); + string jsonString = downloadData("https://raw.githubusercontent.com/wanaff14/ACTFate/update/data.json?_=" + System.DateTimeOffset.Now.Ticks); + if (jsonString == null) jsonString = File.ReadAllText(fileInfo.Directory.FullName + "/data.json"); var json = JObject.Parse(jsonString); List languages = new List(); @@ -657,6 +707,7 @@ private void fateTreeView_AfterCheck(object sender, System.Windows.Forms.TreeVie telegramSelectedFates.Clear(); updateSelectedFates(telegramFateTreeView.Nodes); + SaveSettings(); lockTreeEvent = false; } diff --git a/ACT_Fate/FFXIV_FATE_ACT_Plugin.csproj b/ACT_Fate/FFXIV_FATE_ACT_Plugin.csproj index 76c8a54..93ac0f1 100644 --- a/ACT_Fate/FFXIV_FATE_ACT_Plugin.csproj +++ b/ACT_Fate/FFXIV_FATE_ACT_Plugin.csproj @@ -58,6 +58,7 @@ packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll + True