Skip to content

Commit

Permalink
알림 받을 돌발 체크한뒤 언어 바꾸면 채크가 풀리는 버그 수정
Browse files Browse the repository at this point in the history
플러그인 로드시 서버에서 데이터를 갱신 받도록 수정
  • Loading branch information
Wana committed Dec 21, 2017
1 parent 0d868a5 commit 18a9cce
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 24 deletions.
99 changes: 75 additions & 24 deletions ACT_Fate/ACTFate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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:
Expand All @@ -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++;
Expand Down Expand Up @@ -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);
Expand All @@ -558,9 +577,40 @@ private class Language
private string telegramChkFates;
private ConcurrentStack<string> telegramSelectedFates = new ConcurrentStack<string>();

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<Language> languages = new List<Language>();
Expand Down Expand Up @@ -657,6 +707,7 @@ private void fateTreeView_AfterCheck(object sender, System.Windows.Forms.TreeVie
telegramSelectedFates.Clear();
updateSelectedFates(telegramFateTreeView.Nodes);

SaveSettings();

lockTreeEvent = false;
}
Expand Down
1 change: 1 addition & 0 deletions ACT_Fate/FFXIV_FATE_ACT_Plugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
</Reference>
<Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationFramework" />
<Reference Include="System">
Expand Down

0 comments on commit 18a9cce

Please sign in to comment.