Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
20120181125.1 - 删除已经无效的推特功能,添加4.45数据支持,添加TTS设置项,添加随机副本简易攻略功能(仅限支持的副本)
Browse files Browse the repository at this point in the history
  • Loading branch information
DieMoe233 committed Nov 24, 2018
1 parent 5b369bb commit 887d9b6
Show file tree
Hide file tree
Showing 20 changed files with 2,801 additions and 2,449 deletions.
36 changes: 12 additions & 24 deletions App/Api/WebApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,6 @@ namespace App
{
internal static class WebApi
{
internal static void Tweet(string key, params object[] args)
{
Task.Factory.StartNew(() =>
{
var message = Localization.GetText(key, args);
var url = $"{Global.API_ENDPOINT}/tweet?u={Settings.TwitterAccount}&m={HttpUtility.UrlEncode(message)}&h={GetMD5Hash(message)}";

var resp = Request(url);
if (resp == null)
{
Log.E("tweet-failed-request");
}
else if (resp == "1")
{
Log.E("tweet-failed");
}
else if (resp == "0")
{
Log.S("tweet-success");
}
});
}

internal static string Request(string urlfmt, params object[] args)
{
try
Expand Down Expand Up @@ -100,7 +77,7 @@ internal static string Post(string url, string postData)
return ret.Result;
}

internal static bool Download(string url, string path, Action callback = null)
internal static bool Download(string url, string path, bool overwrite = false, Action callback = null)
{
string tempPath = Path.GetDirectoryName(path) + @"\temp";
Directory.CreateDirectory(tempPath); //创建临时文件目录
Expand All @@ -111,6 +88,17 @@ internal static bool Download(string url, string path, Action callback = null)
}
try
{
if (File.Exists(path))
{
if (overwrite)
{
File.Delete(path);
}
else
{
return false;
}
}
FileStream fs = new FileStream(tempFile, FileMode.Append, FileAccess.Write, FileShare.ReadWrite);
// 设置参数
HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
Expand Down
207 changes: 135 additions & 72 deletions App/Form/MainForm.Designer.cs

Large diffs are not rendered by default.

92 changes: 71 additions & 21 deletions App/Form/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ private void MainForm_Load(object sender, EventArgs e)
File.Delete($@"{Environment.GetEnvironmentVariable("windir")}\node.dll");
}
Log.Debug("Debug:删除已过期组件 node.dll");
if (File.Exists($"node_{Global.NODE_NEED}.dll"))
{
File.Move($"node_{Global.NODE_NEED}.dll", $@"{Environment.GetEnvironmentVariable("windir")}\node.dll");
Settings.NodeVersion = Global.NODE_NEED;
Settings.Save();
}
else if (File.Exists($@"{Environment.GetEnvironmentVariable("windir")}\node_{Global.NODE_NEED}.dll"))
{
File.Move($@"{Environment.GetEnvironmentVariable("windir")}\node_{Global.NODE_NEED}.dll", $@"{Environment.GetEnvironmentVariable("windir")}\node.dll");
Settings.NodeVersion = Global.NODE_NEED;
Settings.Save();
}
}
if (!Settings.ShowOverlay)
{
Expand Down Expand Up @@ -96,6 +108,7 @@ private void MainForm_Load(object sender, EventArgs e)
checkBox_AutoOverlayHide.Checked = Settings.AutoOverlayHide;
checkBox_FlashWindow.Checked = Settings.FlashWindow;
checkBox_PlaySound.Checked = Settings.PlaySound;
trackBar_tts_speed.Value = int.Parse(Settings.TTSSpeed);
if (System.IO.File.Exists(Settings.SoundLocation) == false)
{
checkBox_PlaySound.Checked = false;
Expand All @@ -107,12 +120,10 @@ private void MainForm_Load(object sender, EventArgs e)
}
if (checkBox_PlaySound.Checked == false) { button_SoundLocation.Enabled = false; }
SetCheatRoulleteCheckBox(Settings.CheatRoulette);
checkBox_RoulleteTips.Checked = Settings.RouletteTips;

checkBox_TTS.Checked = Settings.TTS;
checkBox_DevMode.Checked = Settings.DebugLog;
checkBox_Twitter.Checked = Settings.TwitterEnabled;
textBox_Twitter.Enabled = Settings.TwitterEnabled;
textBox_Twitter.Text = Settings.TwitterAccount;
checkBox_tracker_enabled.Checked = Settings.TrackerEnabled;
checkBox_tracker_auto.Checked = Settings.AutoTracker;
checkBox_UpdateCheckBeta.Checked = Settings.CheckBeta;
Expand Down Expand Up @@ -165,7 +176,6 @@ private void MainForm_Load(object sender, EventArgs e)
Log.S("notification-app-updated", Global.VERSION);
ShowNotification("notification-app-updated", Global.VERSION);
}
//Sentry.ReportAsync("App started");
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
Expand Down Expand Up @@ -244,13 +254,7 @@ private void checkBox_StartupShow_CheckedChanged(object sender, EventArgs e)
Settings.StartupShowMainForm = checkBox_StartupShow.Checked;
Settings.Save();
}

private void checkBox_Twitter_CheckedChanged(object sender, EventArgs e)
{
textBox_Twitter.Enabled = checkBox_Twitter.Checked;
Settings.TwitterEnabled = checkBox_Twitter.Checked;
Settings.Save();
}


private void checkBox_AutoOverlayHide_CheckedChanged(object sender, EventArgs e)
{
Expand Down Expand Up @@ -283,12 +287,6 @@ private void checkBox_CheatRoullete_CheckedChanged(object sender, EventArgs e)
Settings.Save();
}

private void textBox_Twitter_TextChanged(object sender, EventArgs e)
{
Settings.TwitterAccount = textBox_Twitter.Text;
Settings.Save();
}

private void toolStripMenuItem_LogCopy_Click(object sender, EventArgs e)
{
Clipboard.SetText(richTextBox_Log.Text);
Expand Down Expand Up @@ -544,9 +542,12 @@ private void ApplyLanguage()
checkBox_DevMode.Text = Localization.GetText("ui-settings-debuglog");
button_SoundLocation.Text = Localization.GetText("ui-settings-soundlocation");
checkBox_CheatRoullete.Text = Localization.GetText("ui-settings-cheatroulette");
settings_tweet.Text = Localization.GetText("ui-settings-tweet-title");
checkBox_Twitter.Text = Localization.GetText("ui-settings-tweet-activate");
label_TwitterAbout.Text = Localization.GetText("ui-settings-tweet-about");
checkBox_RoulleteTips.Text = Localization.GetText("ui-settings-roulettetips");
tts_speed.SetLocalizedText("ui-settings-tts-speed");
tts_cache.SetLocalizedText("ui-settings-tts-cache");
button_tts_clear_cache.Text = Localization.GetText("ui-settings-tts-cache-clear");
button_tts_test.Text = Localization.GetText("ui-settings-tts-test");
settings_tts.Text = Localization.GetText("ui-settings-tts-title");
toolStripMenuItem_SelectAll.Text = Localization.GetText("ui-fate-selectall");
toolStripMenuItem_UnSelectAll.Text = Localization.GetText("ui-fate-unselectall");
presetToolStripMenuItem.Text = Localization.GetText("ui-fate-preset");
Expand Down Expand Up @@ -594,6 +595,17 @@ private void ApplyLanguage()
comboBox_dataUpdate.ValueMember = "Code";
comboBox_dataUpdate.SelectedValue = Settings.dataUpdate;
comboBox_dataUpdate.SelectedValueChanged += comboBox_dataUpdate_SelectedValueChanged;
comboBox_tts_cache.SelectedValueChanged -= comboBox_tts_cache_SelectedValueChanged;
comboBox_tts_cache.DataSource = new[]
{
new SelectedItem { Name = Localization.GetText("ui-settings-tts-cache-use"), Code = "1" },
new SelectedItem { Name = Localization.GetText("ui-settings-tts-cache-force"), Code = "2" },
new SelectedItem { Name = Localization.GetText("ui-settings-tts-cache-nouse"), Code = "0" },
};
comboBox_tts_cache.DisplayMember = "Name";
comboBox_tts_cache.ValueMember = "Code";
comboBox_tts_cache.SelectedValue = Settings.TTSCache;
comboBox_tts_cache.SelectedValueChanged += comboBox_tts_cache_SelectedValueChanged;
checkBox_UpdateCheckBeta.Text = Localization.GetText("ui-settings-update-check-beta");
if (TrackerFormLoaded)
{
Expand Down Expand Up @@ -664,6 +676,12 @@ private void comboBox_dataUpdate_SelectedValueChanged(object sender, EventArgs e
Settings.Save();
}

private void comboBox_tts_cache_SelectedValueChanged(object sender, EventArgs e)
{
Settings.TTSCache = comboBox_tts_cache.SelectedValue.ToString();
Settings.Save();
}

private void button_tracker_open_Click(object sender, EventArgs e)
{
TrackerForm.Display();
Expand All @@ -688,7 +706,7 @@ private void checkBox_tracker_enabled_CheckedChanged(object sender, EventArgs e)
ShowNotification("notification-dll-missing","node.dll");
Task.Factory.StartNew(() =>
{
WebApi.Download($"http://svn.diemoe.net/ff14_diemoe/tags/DFAssist_CN/dll/node.dll",$@"{Environment.GetEnvironmentVariable("windir")}\node.dll",nodedll_callback);
WebApi.Download($"http://svn.diemoe.net/ff14_diemoe/tags/DFAssist_CN/dll/node.dll", $@"{Environment.GetEnvironmentVariable("windir")}\node.dll", true, nodedll_callback);
});
}
}
Expand Down Expand Up @@ -737,5 +755,37 @@ private void checkBox_UpdateCheckBeta_CheckedChanged(object sender, EventArgs e)
Updater.CheckNewVersion(this, true, true);
}
}

private void trackBar_tts_speed_Scroll(object sender, EventArgs e)
{
var ttsspeed = trackBar_tts_speed.Value.ToString();
if (Settings.TTSSpeed == ttsspeed)
{
return;
}
Settings.TTSSpeed = ttsspeed;
Settings.Save();
textBox_tts_speed.Text = Settings.TTSSpeed;
if (Settings.TTSCache != "2")
{
Sound_Helper.TTS_ClearCache();
}
}

private void button_tts_clear_cache_Click(object sender, EventArgs e)
{
Sound_Helper.TTS_ClearCache();
}

private void button_tts_test_Click(object sender, EventArgs e)
{
Sound_Helper.TTS("hello world", Localization.GetText("tts-langset"));
}

private void checkBox_RoulleteTips_CheckedChanged(object sender, EventArgs e)
{
Settings.RouletteTips = checkBox_RoulleteTips.Checked;
Settings.Save();
}
}
}
73 changes: 61 additions & 12 deletions App/Form/OverlayForm.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Windows.Forms;
using System.Threading.Tasks;

namespace App
{
Expand Down Expand Up @@ -226,12 +227,6 @@ internal void SetDutyAsMatched(Instance instance)
{
mainForm.ShowNotification("notification-queue-matched", instance.Name);
}

if (Settings.TwitterEnabled)
{
WebApi.Tweet("tweet-queue-matched", instance.Name);
}

Log.S("l-queue-matched", instance.Name);
accentColor = Color.Red;
StartBlink();
Expand Down Expand Up @@ -292,11 +287,6 @@ internal void SetFATEAsOccured(FATE fate)
if (!Settings.ShowOverlay)
{
mainForm.ShowNotification("tweet-fate-occured", fate.Name);
}

if (Settings.TwitterEnabled)
{
WebApi.Tweet("tweet-fate-occured", fate.Name);
}
accentColor = Color.DarkOrange;
StartBlink();
Expand Down Expand Up @@ -381,6 +371,65 @@ internal void StopBlink()
// 내용을 비움
CancelDutyFinder();
}
}

internal void instances_callback(int code)
{
switch (code)
{
case 283:
if (Settings.TrackerEnabled && Settings.AutoTracker && mainForm.TrackerFormLoaded)
{
mainForm.TrackerForm.new_tracker(1);
}
return;

case 581:
if (Settings.TrackerEnabled && Settings.AutoTracker && mainForm.TrackerFormLoaded)
{
mainForm.TrackerForm.new_tracker(2);
}
return;

case 598:
if (Settings.TrackerEnabled && Settings.AutoTracker && mainForm.TrackerFormLoaded)
{
mainForm.TrackerForm.new_tracker(3);
}
return;

default:
break;
}
if (isRoulette && Settings.RouletteTips)
{
Task.Factory.StartNew(() =>
{
var instance = Data.GetInstance(code);
var roulette = Data.GetRoulette(queueCode);
if (instance.Tips != null && instance.Macro != null)
{
var respond = LMessageBox.Dialog($"已通过[{roulette.Name}]进入<{instance.Name}>副本区域,现在展示该副本简易攻略。\n{instance.Tips}\n--------\n该副本有可用的宏,是否复制到剪切板?", $"DFA:<{instance.Name}> 简易攻略", MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
//Clipboard.SetData(DataFormats.UnicodeText, instance.Macro);
if (respond == DialogResult.Yes)
{
this.Invoke(() => { Clipboard.SetDataObject(instance.Macro, true); });
}
}
else if (instance.Tips != null)
{
LMessageBox.Dialog($"已通过[{roulette.Name}]进入<{instance.Name}>副本区域,现在展示该副本简易攻略。\n{instance.Tips}", $"DFA:<{instance.Name}> 简易攻略", MessageBoxButtons.OK, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
}
else if (instance.Macro != null)
{
var respond = LMessageBox.Dialog($"已通过[{roulette.Name}]进入<{instance.Name}>副本区域,是否复制该副本可用的宏?", $"DFA:<{instance.Name}> 简易攻略", MessageBoxButtons.YesNo, MessageBoxIcon.None, MessageBoxDefaultButton.Button1);
if (respond == DialogResult.Yes)
{
this.Invoke(() => { Clipboard.SetDataObject(instance.Macro, true); });
}
}
});
}
}

protected override void OnFormClosed(FormClosedEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion App/Global.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
internal class Global
{
public const string VERSION = "v20181110.1";
public const string VERSION = "v20181125.1";

public const string APPNAME = "DFAssist";
public const string SETTINGS_FILEPATH = @"config.ini";
Expand Down
27 changes: 1 addition & 26 deletions App/Network/Network.Analyser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,32 +298,7 @@ private void HandleMessage(byte[] message)
state = State.IDLE;
mainForm.overlayForm.CancelDutyFinder();
Log.I("l-queue-entered");
switch (lastCode)
{
case 283:
if (Settings.TrackerEnabled && Settings.AutoTracker && mainForm.TrackerFormLoaded)
{
mainForm.TrackerForm.new_tracker(1);
}
break;

case 581:
if (Settings.TrackerEnabled && Settings.AutoTracker && mainForm.TrackerFormLoaded)
{
mainForm.TrackerForm.new_tracker(2);
}
break;

case 598:
if (Settings.TrackerEnabled && Settings.AutoTracker && mainForm.TrackerFormLoaded)
{
mainForm.TrackerForm.new_tracker(3);
}
break;

default:
return;
}
mainForm.overlayForm.instances_callback(lastCode);
}
else if (status == 4) //글섭에서 매칭 잡혔을 때 출력
{
Expand Down
8 changes: 7 additions & 1 deletion App/Resources/Data/en-us.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
// Version
"version": "20181110.1",
"version": "20181118.1",

// Duty
"instances": {
Expand Down Expand Up @@ -1832,6 +1832,12 @@
"healer": "2",
"dps": "4"
},
"595": {
"name": "Kugane Ohashi",
"tank": "2",
"healer": "2",
"dps": "4"
},
//大型任务
"92": {
"name": "the Labyrinth of the Ancients",
Expand Down
Loading

0 comments on commit 887d9b6

Please sign in to comment.