2022-08-27 15:35:26 +02:00
|
|
|
|
//#define TESTPK
|
|
|
|
|
using System;
|
2021-03-17 18:14:48 +01:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
|
|
namespace DutyContent.Tab
|
|
|
|
|
{
|
|
|
|
|
public partial class DutyForm : Form, Interface.ISuppLocale, Interface.IPacketHandler, Interface.ISuppActPlugin
|
|
|
|
|
{
|
|
|
|
|
private static DutyForm _self;
|
|
|
|
|
public static DutyForm Self => _self;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private bool _is_lock_fate;
|
2021-06-20 14:31:05 +02:00
|
|
|
|
private ushort _last_fate = 0;
|
2021-12-14 05:43:07 +01:00
|
|
|
|
private ushort _last_zone = 0;
|
2021-06-19 14:07:01 +02:00
|
|
|
|
|
|
|
|
|
//
|
2021-03-17 18:14:48 +01:00
|
|
|
|
private bool _is_packet_finder;
|
2021-05-26 12:39:25 +02:00
|
|
|
|
private DcContent.SaveTheQueenType _stq_type = DcContent.SaveTheQueenType.No;
|
2021-03-17 18:14:48 +01:00
|
|
|
|
private DcConfig.PacketConfig _new_packet;
|
2021-06-19 14:07:01 +02:00
|
|
|
|
|
|
|
|
|
//
|
2021-06-18 14:08:43 +02:00
|
|
|
|
private Dictionary<string, string> _packet_list = new Dictionary<string, string>();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-06-18 14:08:43 +02:00
|
|
|
|
//
|
2021-03-17 18:14:48 +01:00
|
|
|
|
private Overlay.DutyOvForm _overlay;
|
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
//
|
2021-03-17 18:14:48 +01:00
|
|
|
|
public DutyForm()
|
|
|
|
|
{
|
|
|
|
|
_self = this;
|
|
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
_overlay = new Overlay.DutyOvForm();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DutyTabForm_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
|
|
{
|
2021-03-20 19:43:05 +01:00
|
|
|
|
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PluginInitialize()
|
|
|
|
|
{
|
|
|
|
|
//
|
2021-06-10 16:31:15 +02:00
|
|
|
|
lblCurrentDataSet.Text = DcContent.DisplayLanguage;
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
|
|
|
|
//
|
2021-06-18 14:08:43 +02:00
|
|
|
|
RefreshDatasetList();
|
|
|
|
|
RefreshPacketList();
|
2021-06-14 11:45:49 +02:00
|
|
|
|
|
2021-03-17 18:14:48 +01:00
|
|
|
|
//
|
|
|
|
|
chkEnableOverlay.Checked = DcConfig.Duty.EnableOverlay;
|
|
|
|
|
|
|
|
|
|
progbOverlayTransparent.Enabled = DcConfig.Duty.EnableOverlay;
|
|
|
|
|
btnOverlayDimming.Enabled = DcConfig.Duty.EnableOverlay;
|
2021-03-20 19:43:05 +01:00
|
|
|
|
chkOverlayClickThru.Checked = DcConfig.Duty.OverlayClickThru;
|
2022-08-21 04:07:09 +02:00
|
|
|
|
chkOverlayAutoHide.Checked = DcConfig.Duty.OverlayAutoHide;
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
|
|
|
|
//
|
2021-08-14 16:35:53 +02:00
|
|
|
|
_overlay.SetText(Locale.Text(99, DcConfig.PluginVersion.ToString()));
|
2021-03-17 18:14:48 +01:00
|
|
|
|
_overlay.Location = DcConfig.Duty.OverlayLocation;
|
|
|
|
|
|
|
|
|
|
if (DcConfig.Duty.EnableOverlay)
|
|
|
|
|
_overlay.Show();
|
|
|
|
|
else
|
|
|
|
|
_overlay.Hide();
|
2021-06-05 22:58:56 +02:00
|
|
|
|
if (DcConfig.Duty.OverlayClickThru)
|
2021-06-14 11:45:49 +02:00
|
|
|
|
_overlay.SetClickThruStatus(true);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
chkEnableSound.Checked = DcConfig.Duty.EnableSound;
|
|
|
|
|
|
|
|
|
|
txtSoundInstance.Text = DcConfig.Duty.SoundInstanceFile;
|
|
|
|
|
txtSoundInstance.Enabled = DcConfig.Duty.EnableSound;
|
|
|
|
|
btnSoundFindInstance.Enabled = DcConfig.Duty.EnableSound;
|
|
|
|
|
btnSoundPlayInstance.Enabled = DcConfig.Duty.EnableSound;
|
|
|
|
|
|
|
|
|
|
txtSoundFate.Text = DcConfig.Duty.SoundFateFile;
|
|
|
|
|
txtSoundFate.Enabled = DcConfig.Duty.EnableSound;
|
|
|
|
|
btnSoundFindFate.Enabled = DcConfig.Duty.EnableSound;
|
|
|
|
|
btnSoundPlayFate.Enabled = DcConfig.Duty.EnableSound;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
chkUseNotifyLine.Checked = DcConfig.Duty.UseNotifyLine;
|
|
|
|
|
txtLineToken.Text = DcConfig.Duty.NotifyLineToken;
|
|
|
|
|
|
|
|
|
|
chkUseNotifyTelegram.Checked = DcConfig.Duty.UseNotifyTelegram;
|
|
|
|
|
txtTelegramId.Text = DcConfig.Duty.NotifyTelegramId;
|
|
|
|
|
txtTelegramToken.Text = DcConfig.Duty.NotifyTelegramToken;
|
2021-06-20 14:31:05 +02:00
|
|
|
|
|
|
|
|
|
chkUseNotifyDiscowk.Checked = DcConfig.Duty.UseNotifyDiscordWebhook;
|
|
|
|
|
txtDiscowkUrl.Text = DcConfig.Duty.NotifyDiscordWebhookUrl;
|
|
|
|
|
chkDiscowkTts.Checked = DcConfig.Duty.NotifyDiscordWebhookTts;
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
|
|
|
|
btnTestNotify.Enabled = DcConfig.Duty.EnableNotify;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
switch (DcConfig.Duty.ActiveFate)
|
|
|
|
|
{
|
|
|
|
|
case 0: rdoFatePreset1.Checked = true; break;
|
|
|
|
|
case 1: rdoFatePreset2.Checked = true; break;
|
|
|
|
|
case 2: rdoFatePreset3.Checked = true; break;
|
|
|
|
|
case 3: rdoFatePreset4.Checked = true; break;
|
|
|
|
|
}
|
|
|
|
|
UpdateFates();
|
2021-06-14 18:16:06 +02:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
if (cboPacketset.SelectedIndex >= 0)
|
2021-06-18 14:08:43 +02:00
|
|
|
|
{
|
|
|
|
|
var p = _packet_list.ElementAt(cboPacketset.SelectedIndex);
|
|
|
|
|
RemotePacketUpdate(p.Key);
|
|
|
|
|
}
|
2022-10-05 18:53:22 +02:00
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
#if TESTPK
|
|
|
|
|
Logger.Write(Color.Red, "[TEST PK MODE]");
|
|
|
|
|
#endif
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PluginDeinitialize()
|
|
|
|
|
{
|
|
|
|
|
_overlay.Hide();
|
|
|
|
|
_overlay = null;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-20 19:43:05 +01:00
|
|
|
|
private void SaveConfig(int interval = 5000)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2021-03-20 19:43:05 +01:00
|
|
|
|
DcControl.Self.RefreshSaveConfig(interval);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void RefreshLocale()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateUiLocale()
|
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
tabPageContent.Text = Locale.Text(301);
|
|
|
|
|
tabPageSetting.Text = Locale.Text(302);
|
|
|
|
|
tabPagePacket.Text = Locale.Text(337);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
lblDataSet.Text = Locale.Text(304);
|
|
|
|
|
lblPacketSet.Text = Locale.Text(336);
|
2021-08-15 16:38:36 +02:00
|
|
|
|
btnResetContentList.Text = Locale.Text(347);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
chkEnableOverlay.Text = Locale.Text(306);
|
|
|
|
|
lblOverlayTransparent.Text = Locale.Text(307);
|
|
|
|
|
chkOverlayClickThru.Text = Locale.Text(104);
|
2022-08-21 04:07:09 +02:00
|
|
|
|
chkOverlayAutoHide.Text = Locale.Text(105);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
chkEnableSound.Text = Locale.Text(308);
|
|
|
|
|
lblSoundInstance.Text = Locale.Text(309);
|
|
|
|
|
lblSoundFate.Text = Locale.Text(310);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
chkUseNotifyLine.Text = Locale.Text(311);
|
|
|
|
|
lblLineToken.Text = Locale.Text(312);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
chkUseNotifyTelegram.Text = Locale.Text(313);
|
|
|
|
|
lblTelegramId.Text = Locale.Text(314);
|
|
|
|
|
lblTelegramToken.Text = Locale.Text(315);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
chkUseNotifyDiscowk.Text = Locale.Text(338);
|
|
|
|
|
chkDiscowkTts.Text = Locale.Text(341);
|
|
|
|
|
lblDiscowkUrl.Text = Locale.Text(339);
|
2021-06-20 14:31:05 +02:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
btnTestNotify.Text = Locale.Text(340);
|
2021-06-20 14:31:05 +02:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
lblPacketFinder.Text = Locale.Text(316);
|
|
|
|
|
lblPacketDesc.Text = Locale.Text(317);
|
|
|
|
|
lblPacketBozja.Text = Locale.Text(318);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
lstPacketInfo.Columns[0].Text = Locale.Text(319);
|
|
|
|
|
lstPacketInfo.Columns[1].Text = Locale.Text(320);
|
|
|
|
|
lstPacketInfo.Columns[2].Text = Locale.Text(321);
|
|
|
|
|
lstPacketInfo.Columns[3].Text = Locale.Text(322);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
lstBozjaInfo.Columns[0].Text = Locale.Text(323);
|
|
|
|
|
lstBozjaInfo.Columns[1].Text = Locale.Text(324);
|
|
|
|
|
lstBozjaInfo.Columns[2].Text = Locale.Text(325);
|
|
|
|
|
lstBozjaInfo.Columns[3].Text = Locale.Text(326);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
btnPacketStart.Text = Locale.Text(10007);
|
|
|
|
|
btnPacketApply.Text = Locale.Text(10009);
|
2021-06-19 14:07:01 +02:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
// content reset
|
2021-08-15 16:38:36 +02:00
|
|
|
|
lstContents.InitializeContentList(
|
|
|
|
|
Locale.Text(343), // ID
|
|
|
|
|
Locale.Text(344), // Type
|
|
|
|
|
Locale.Text(345), // %
|
|
|
|
|
Locale.Text(346)); // Name
|
|
|
|
|
|
|
|
|
|
Image im_r = Properties.Resources.pix_rdrt_red;
|
|
|
|
|
Image im_g = Properties.Resources.pix_rdrt_green;
|
|
|
|
|
Image im_p = Properties.Resources.pix_rdrt_puple;
|
|
|
|
|
Image im_b = Properties.Resources.pix_rdrt_bline;
|
|
|
|
|
|
|
|
|
|
lstContents.ClearImages();
|
|
|
|
|
lstContents.AddCategoryImage(im_b, Locale.Text(27), Brushes.Black); // 0, none
|
|
|
|
|
lstContents.AddCategoryImage(im_g, Locale.Text(21)); // 1, roulette
|
|
|
|
|
lstContents.AddCategoryImage(im_g, Locale.Text(22)); // 2, instance
|
|
|
|
|
lstContents.AddCategoryImage(im_r, Locale.Text(23)); // 3, FATE
|
|
|
|
|
lstContents.AddCategoryImage(im_r, Locale.Text(24)); // 4, skirmish
|
|
|
|
|
lstContents.AddCategoryImage(im_p, Locale.Text(25)); // 5, CE
|
|
|
|
|
lstContents.AddCategoryImage(im_p, Locale.Text(38)); // 6, Match
|
|
|
|
|
lstContents.AddCategoryImage(im_g, Locale.Text(39)); // 7, Entry
|
|
|
|
|
|
|
|
|
|
lstContents.AddContentItem(0, Locale.Text(27));
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void PacketHandler(string pid, byte[] message)
|
|
|
|
|
{
|
|
|
|
|
if (_is_packet_finder)
|
|
|
|
|
PacketFinderHandler(message);
|
|
|
|
|
|
|
|
|
|
var opcode = BitConverter.ToUInt16(message, 18);
|
|
|
|
|
|
|
|
|
|
if (opcode != DcConfig.Packet.OpFate &&
|
|
|
|
|
opcode != DcConfig.Packet.OpDuty &&
|
|
|
|
|
opcode != DcConfig.Packet.OpMatch &&
|
|
|
|
|
opcode != DcConfig.Packet.OpInstance &&
|
2021-08-16 19:04:55 +02:00
|
|
|
|
opcode != DcConfig.Packet.OpZone &&
|
2021-08-14 16:35:53 +02:00
|
|
|
|
opcode != DcConfig.Packet.OpCe)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var data = message.Skip(32).ToArray();
|
|
|
|
|
|
|
|
|
|
// FATE
|
|
|
|
|
if (opcode == DcConfig.Packet.OpFate)
|
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
var fcode = BitConverter.ToUInt16(data, 4);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
if (fcode > 100)
|
|
|
|
|
{
|
|
|
|
|
// 53=begin, 54=end, 62=progress
|
|
|
|
|
if (data[0] == 53)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
|
|
|
|
var fate = DcContent.GetFate(fcode);
|
2021-08-14 16:35:53 +02:00
|
|
|
|
TraceFate(fcode, true, fate, 0);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
|
|
|
|
if (DcConfig.Duty.Fates[DcConfig.Duty.ActiveFate].Selected.Contains(fcode))
|
|
|
|
|
{
|
|
|
|
|
PlayEffectSoundFate();
|
|
|
|
|
NotifyFate(fate);
|
|
|
|
|
_overlay.PlayFate(fate);
|
|
|
|
|
}
|
2021-06-19 14:07:01 +02:00
|
|
|
|
|
2021-06-20 14:31:05 +02:00
|
|
|
|
_last_fate = fcode;
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
2021-08-14 16:35:53 +02:00
|
|
|
|
else if (data[0] == 62 && data[8] > 0) // more than 0%
|
|
|
|
|
{
|
|
|
|
|
var fate = DcContent.TryFate(fcode);
|
2021-05-26 12:39:25 +02:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
if (fate != null)
|
|
|
|
|
TraceFate(fcode, false, fate, data[8]);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (DcConfig.DebugEnable)
|
|
|
|
|
{
|
|
|
|
|
WriteLog(Color.Magenta, 37, 12, fcode);
|
|
|
|
|
_last_fate = fcode;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (data[0] == 54)
|
2021-05-26 12:39:25 +02:00
|
|
|
|
{
|
|
|
|
|
var fate = DcContent.TryFate(fcode);
|
2021-06-19 14:07:01 +02:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
if (fate != null)
|
|
|
|
|
TraceFate(fcode, false, fate);
|
2021-05-26 12:39:25 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Duty
|
|
|
|
|
else if (opcode == DcConfig.Packet.OpDuty)
|
|
|
|
|
{
|
2022-08-27 15:35:26 +02:00
|
|
|
|
if (DcConfig.Duty.PacketForLocal)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2022-08-27 15:35:26 +02:00
|
|
|
|
// for ACTOZ/Korea
|
2022-09-13 06:52:28 +02:00
|
|
|
|
if (data[11] == 0)
|
2022-08-27 15:35:26 +02:00
|
|
|
|
{
|
2022-09-13 06:52:28 +02:00
|
|
|
|
var rcode = data[8];
|
|
|
|
|
|
|
|
|
|
if (rcode != 0)
|
2022-08-27 15:35:26 +02:00
|
|
|
|
{
|
2022-09-13 06:52:28 +02:00
|
|
|
|
var roulette = DcContent.GetRoulette(rcode);
|
|
|
|
|
TraceEntryRoulette(roulette);
|
|
|
|
|
_overlay.PlayQueue(roulette.Name);
|
2022-08-27 15:35:26 +02:00
|
|
|
|
}
|
2022-09-13 06:52:28 +02:00
|
|
|
|
else
|
2022-08-27 15:35:26 +02:00
|
|
|
|
{
|
2022-09-13 06:52:28 +02:00
|
|
|
|
var insts = new List<int>();
|
|
|
|
|
for (var i = 0; i < 5; i++)
|
|
|
|
|
{
|
|
|
|
|
var icode = BitConverter.ToUInt16(data, 12 + (i * 4));
|
|
|
|
|
if (icode == 0)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (insts.Any())
|
|
|
|
|
{
|
|
|
|
|
TraceEntryInstance(insts);
|
|
|
|
|
_overlay.PlayQueue(Locale.Text(10006, $"#{insts.Count}"));
|
|
|
|
|
}
|
2022-08-27 15:35:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-13 06:52:28 +02:00
|
|
|
|
DcContent.Missions.Clear();
|
|
|
|
|
}
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
2022-09-13 06:52:28 +02:00
|
|
|
|
else
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2022-09-13 06:52:28 +02:00
|
|
|
|
if (data[19] == 0) // duty packet comes twice, index 19 is 0 and 1
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2022-09-13 06:52:28 +02:00
|
|
|
|
// for global
|
|
|
|
|
var rcode = data[16];
|
|
|
|
|
|
|
|
|
|
if (rcode != 0)
|
2022-08-27 15:35:26 +02:00
|
|
|
|
{
|
2022-09-13 06:52:28 +02:00
|
|
|
|
var roulette = DcContent.GetRoulette(rcode);
|
|
|
|
|
TraceEntryRoulette(roulette);
|
|
|
|
|
_overlay.PlayQueue(roulette.Name);
|
2022-08-27 15:35:26 +02:00
|
|
|
|
}
|
2022-09-13 06:52:28 +02:00
|
|
|
|
else
|
2022-08-27 15:35:26 +02:00
|
|
|
|
{
|
2022-09-13 06:52:28 +02:00
|
|
|
|
var insts = new List<int>();
|
|
|
|
|
for (var i = 0; i < 5; i++)
|
|
|
|
|
{
|
|
|
|
|
var icode = BitConverter.ToUInt16(data, 20 + (i * 4));
|
|
|
|
|
if (icode == 0)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (insts.Any())
|
|
|
|
|
{
|
|
|
|
|
TraceEntryInstance(insts);
|
|
|
|
|
_overlay.PlayQueue(Locale.Text(10006, $"#{insts.Count}"));
|
|
|
|
|
}
|
2022-08-27 15:35:26 +02:00
|
|
|
|
}
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2022-09-13 06:52:28 +02:00
|
|
|
|
DcContent.Missions.Clear();
|
|
|
|
|
}
|
2022-08-27 15:35:26 +02:00
|
|
|
|
}
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// match
|
|
|
|
|
else if (opcode == DcConfig.Packet.OpMatch)
|
|
|
|
|
{
|
2022-08-27 15:35:26 +02:00
|
|
|
|
string name = null;
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2022-08-27 15:35:26 +02:00
|
|
|
|
if (DcConfig.Duty.PacketForLocal)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2022-08-27 15:35:26 +02:00
|
|
|
|
// For ACTOZ/Korea
|
|
|
|
|
var rcode = BitConverter.ToUInt16(data, 2);
|
|
|
|
|
var icode = BitConverter.ToUInt16(data, 20);
|
|
|
|
|
|
|
|
|
|
if (icode == 0 && rcode != 0)
|
|
|
|
|
{
|
|
|
|
|
var roulette = DcContent.GetRoulette(rcode);
|
|
|
|
|
TraceMatchRoulette(roulette);
|
|
|
|
|
name = roulette.Name;
|
|
|
|
|
}
|
|
|
|
|
else if (icode != 0)
|
|
|
|
|
{
|
|
|
|
|
var instance = DcContent.GetInstance(icode);
|
|
|
|
|
TraceMatchInstance(instance);
|
|
|
|
|
name = instance.Name;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// ???
|
|
|
|
|
name = Locale.Text(10003, icode);
|
|
|
|
|
}
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-08-27 15:35:26 +02:00
|
|
|
|
// For global
|
|
|
|
|
var rcode = BitConverter.ToUInt16(data, 2);
|
|
|
|
|
var icode = BitConverter.ToUInt16(data, 28);
|
|
|
|
|
|
|
|
|
|
if (icode == 0 && rcode != 0)
|
|
|
|
|
{
|
|
|
|
|
var roulette = DcContent.GetRoulette(rcode);
|
|
|
|
|
TraceMatchRoulette(roulette);
|
|
|
|
|
name = roulette.Name;
|
|
|
|
|
}
|
|
|
|
|
else if (icode != 0)
|
|
|
|
|
{
|
|
|
|
|
var instance = DcContent.GetInstance(icode);
|
|
|
|
|
TraceMatchInstance(instance);
|
|
|
|
|
name = instance.Name;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// ???
|
|
|
|
|
name = Locale.Text(10003, icode);
|
|
|
|
|
}
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-08-27 15:35:26 +02:00
|
|
|
|
if (!string.IsNullOrEmpty(name))
|
|
|
|
|
{
|
|
|
|
|
PlayEffecSoundInstance();
|
|
|
|
|
NotifyMatch(name);
|
|
|
|
|
_overlay.PlayMatch(name);
|
|
|
|
|
}
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// instance
|
2021-08-16 19:04:55 +02:00
|
|
|
|
else if (DcConfig.Packet.OpInstance != 0 && opcode == DcConfig.Packet.OpInstance)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
|
|
|
|
// 0[2] instance number
|
|
|
|
|
// 2[2] ?
|
|
|
|
|
// 4[1] 0=enter, 4=enter, 5=leave
|
|
|
|
|
|
|
|
|
|
if (data[4] == 0)
|
|
|
|
|
{
|
|
|
|
|
var icode = BitConverter.ToUInt16(data, 0);
|
|
|
|
|
var instance = DcContent.GetInstance(icode);
|
2021-08-14 16:35:53 +02:00
|
|
|
|
TraceEnterInstance(instance);
|
|
|
|
|
_overlay.PlayMatch(Locale.Text(10004, instance.Name));
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
|
|
|
|
DcContent.Missions.Clear();
|
2021-08-16 19:04:55 +02:00
|
|
|
|
ResetContentItems(); // frankly no meaning to here
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
else if (data[4] != 4)
|
|
|
|
|
{
|
|
|
|
|
_overlay.PlayNone();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-20 14:31:05 +02:00
|
|
|
|
|
2021-08-16 19:04:55 +02:00
|
|
|
|
// zone
|
|
|
|
|
else if (DcConfig.Packet.OpZone != 0 && opcode == DcConfig.Packet.OpZone)
|
|
|
|
|
{
|
|
|
|
|
var zone = BitConverter.ToUInt16(data, 4);
|
|
|
|
|
|
2021-12-14 05:43:07 +01:00
|
|
|
|
if (zone != _last_zone)
|
|
|
|
|
{
|
|
|
|
|
_last_zone = zone;
|
|
|
|
|
ResetContentItems();
|
|
|
|
|
}
|
2021-08-16 19:04:55 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
// save the queen critical engagement
|
2021-12-14 05:43:07 +01:00
|
|
|
|
else if (DcConfig.Packet.OpCe != 0 && opcode == DcConfig.Packet.OpCe)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
|
|
|
|
// 0[4] timestamp
|
|
|
|
|
// 4[2] mmss
|
|
|
|
|
// 6[2] ?
|
|
|
|
|
// 8[1] code
|
2021-12-14 05:43:07 +01:00
|
|
|
|
// 9[1] members
|
2021-03-17 18:14:48 +01:00
|
|
|
|
// 10[1] status 0=end, 1=register, 2=entry, 3=progress
|
|
|
|
|
// 12[1] progress percentage
|
|
|
|
|
|
2021-06-19 14:07:01 +02:00
|
|
|
|
if (_stq_type == DcContent.SaveTheQueenType.No)
|
|
|
|
|
{
|
|
|
|
|
if (IsFateForSouthernBozja(_last_fate))
|
|
|
|
|
_stq_type = DcContent.SaveTheQueenType.Bozja;
|
|
|
|
|
else if (IsFateForZadnor(_last_fate))
|
|
|
|
|
_stq_type = DcContent.SaveTheQueenType.Zadnor;
|
|
|
|
|
else
|
|
|
|
|
_stq_type = DcContent.SaveTheQueenType.Zadnor;
|
|
|
|
|
}
|
2021-05-26 12:39:25 +02:00
|
|
|
|
|
2021-06-19 14:07:01 +02:00
|
|
|
|
var ce = data[8] + DcContent.SaveTheQueenTypeToCeBase(_stq_type);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
var stat = data[10];
|
2021-08-14 16:35:53 +02:00
|
|
|
|
var fate = DcContent.GetFate(ce);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
|
|
|
|
if (stat == 0 /* || data[10] == 3 */)
|
|
|
|
|
{
|
|
|
|
|
if (DcContent.Missions.ContainsKey(ce))
|
|
|
|
|
DcContent.Missions.Remove(ce);
|
2021-08-14 16:35:53 +02:00
|
|
|
|
|
|
|
|
|
TraceCe(ce, false, fate);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
else if (stat == 1 || stat == 2)
|
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
var withlog = false;
|
|
|
|
|
|
2021-03-17 18:14:48 +01:00
|
|
|
|
if (!DcContent.Missions.ContainsKey(ce))
|
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
withlog = true;
|
2021-03-17 18:14:48 +01:00
|
|
|
|
DcContent.Missions.Add(ce, 0);
|
|
|
|
|
|
|
|
|
|
if (DcConfig.Duty.Fates[DcConfig.Duty.ActiveFate].Selected.Contains(ce))
|
|
|
|
|
{
|
|
|
|
|
PlayEffectSoundFate();
|
|
|
|
|
NotifyFate(fate);
|
|
|
|
|
_overlay.PlayFate(fate);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-14 16:35:53 +02:00
|
|
|
|
|
|
|
|
|
TraceCe(ce, withlog, fate, stat == 1 ? "R" : "E");
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
else if (stat == 3)
|
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
if (!DcContent.Missions.ContainsKey(ce))
|
2021-03-17 18:14:48 +01:00
|
|
|
|
DcContent.Missions.Add(ce, 0);
|
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
TraceCe(ce, false, fate, data[12].ToString());
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
public void ZoneChanged(uint zone_id, string zone_name)
|
|
|
|
|
{
|
|
|
|
|
//_overlay.PlayNone();
|
|
|
|
|
|
2021-05-26 12:39:25 +02:00
|
|
|
|
_stq_type =
|
|
|
|
|
(zone_id == 920) ? DcContent.SaveTheQueenType.Bozja :
|
2021-06-07 01:48:23 +02:00
|
|
|
|
(zone_id == 921) ? DcContent.SaveTheQueenType.Zadnor :
|
2021-05-26 12:39:25 +02:00
|
|
|
|
DcContent.SaveTheQueenType.No;
|
|
|
|
|
|
2021-06-23 14:07:40 +02:00
|
|
|
|
#if false
|
2021-06-20 14:31:05 +02:00
|
|
|
|
LogInstance(10025, $"{zone_name} ({zone_id})");
|
2021-06-19 14:07:01 +02:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
if (DcConfig.DebugEnable)
|
2021-06-19 14:07:01 +02:00
|
|
|
|
LogDebug("Zone: {0}", zone_id);
|
2021-06-23 14:07:40 +02:00
|
|
|
|
#endif
|
2021-08-14 16:35:53 +02:00
|
|
|
|
|
2021-08-15 16:38:36 +02:00
|
|
|
|
// Probably receive FATE auto end command before changing zone
|
|
|
|
|
// No end data found: logout, critical engagement -> have to reset
|
2021-08-16 19:04:55 +02:00
|
|
|
|
if (DcConfig.Packet.OpZone == 0)
|
|
|
|
|
ResetContentItems();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
2021-08-14 16:35:53 +02:00
|
|
|
|
private void WriteLog(Color color, int catkey, int fmtkey, params object[] prms)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
string category = Locale.Text(catkey);
|
|
|
|
|
string format = Locale.Text(fmtkey);
|
|
|
|
|
Logger.WriteCategory(color, category, format, prms);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private void TraceFate(ushort code, bool withlog, DcContent.Fate fate, int progress = -1)
|
|
|
|
|
{
|
2021-08-15 16:38:36 +02:00
|
|
|
|
// TODO: check area
|
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
int key, subs;
|
|
|
|
|
|
|
|
|
|
if (_stq_type != DcContent.SaveTheQueenType.No || IsSkirmishFate(code))
|
|
|
|
|
{
|
|
|
|
|
key = 24;
|
|
|
|
|
subs = 4;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
key = 23;
|
|
|
|
|
subs = 3;
|
|
|
|
|
}
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
if (withlog)
|
|
|
|
|
WriteLog(Color.Black, key, 10001, fate.Name);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-08-15 16:38:36 +02:00
|
|
|
|
WorkerAct.Invoker(() => lstContents.TreatItemFate(code, subs, progress, fate.Name));
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
//
|
|
|
|
|
private void TraceCe(int code, bool withlog, DcContent.Fate fate, string progress = null)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
if (withlog)
|
|
|
|
|
WriteLog(Color.Black, 25, 10001, fate.Name);
|
|
|
|
|
|
2021-08-15 16:38:36 +02:00
|
|
|
|
WorkerAct.Invoker(() => lstContents.TreatItemCe(code, 5, progress, fate.Name));
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-05-26 12:39:25 +02:00
|
|
|
|
//
|
2021-08-15 16:38:36 +02:00
|
|
|
|
private void UpdateTraceInstance(int imageindex, int count, string insname)
|
2021-05-26 12:39:25 +02:00
|
|
|
|
{
|
2021-08-15 16:38:36 +02:00
|
|
|
|
WorkerAct.Invoker(() => lstContents.TreatItemInstance(imageindex, count, insname));
|
2021-05-26 12:39:25 +02:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-17 18:14:48 +01:00
|
|
|
|
//
|
2021-08-14 16:35:53 +02:00
|
|
|
|
private void TraceMatchInstance(DcContent.Instance instance)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
WriteLog(Color.Black, 22, 10003, instance.Name);
|
|
|
|
|
|
2021-08-15 16:38:36 +02:00
|
|
|
|
UpdateTraceInstance(6, 0, instance.Name);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
2021-08-14 16:35:53 +02:00
|
|
|
|
private void TraceEnterInstance(DcContent.Instance instance)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
WriteLog(Color.Black, 22, 10004, instance.Name);
|
|
|
|
|
|
2021-08-15 16:38:36 +02:00
|
|
|
|
UpdateTraceInstance(2, 0, instance.Name);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
2021-08-14 16:35:53 +02:00
|
|
|
|
private void TraceEntryInstance(List<int> instances)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2021-08-15 16:38:36 +02:00
|
|
|
|
var insnames = string.Join("/", instances.ToArray());
|
2021-08-14 16:35:53 +02:00
|
|
|
|
|
2021-08-15 16:38:36 +02:00
|
|
|
|
WriteLog(Color.Black, 22, 10002, insnames);
|
2021-08-14 16:35:53 +02:00
|
|
|
|
|
2021-08-15 16:38:36 +02:00
|
|
|
|
UpdateTraceInstance(7, instances.Count, insnames);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
2021-08-14 16:35:53 +02:00
|
|
|
|
private void TraceMatchRoulette(DcContent.Roulette roulette)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
WriteLog(Color.Black, 22, 10003, roulette.Name);
|
|
|
|
|
|
2021-08-15 16:38:36 +02:00
|
|
|
|
UpdateTraceInstance(6, 0, roulette.Name);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
2021-08-14 16:35:53 +02:00
|
|
|
|
private void TraceEntryRoulette(DcContent.Roulette roulette)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
WriteLog(Color.Black, 22, 10002, roulette.Name);
|
|
|
|
|
|
2021-08-15 16:38:36 +02:00
|
|
|
|
UpdateTraceInstance(1, 0, roulette.Name);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
public void UpdateFates()
|
|
|
|
|
{
|
|
|
|
|
var fs = DcConfig.Duty.Fates[DcConfig.Duty.ActiveFate];
|
|
|
|
|
|
|
|
|
|
treeFates.Nodes.Clear();
|
|
|
|
|
fs.MakeSelects(true);
|
|
|
|
|
|
|
|
|
|
_is_lock_fate = true;
|
|
|
|
|
|
|
|
|
|
foreach (var a in DcContent.Areas)
|
|
|
|
|
{
|
|
|
|
|
var n = treeFates.Nodes.Add(a.Value.Name);
|
|
|
|
|
n.Tag = a.Key + 100000;
|
|
|
|
|
|
|
|
|
|
if (fs.Selected.Contains((int)n.Tag))
|
|
|
|
|
{
|
|
|
|
|
n.Checked = true;
|
|
|
|
|
n.Expand();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var f in a.Value.Fates)
|
|
|
|
|
{
|
|
|
|
|
var name = f.Value.Name;
|
|
|
|
|
var node = n.Nodes.Add(name);
|
|
|
|
|
node.Tag = f.Key;
|
|
|
|
|
|
|
|
|
|
if (fs.Selected.Contains((int)node.Tag))
|
|
|
|
|
{
|
|
|
|
|
node.Checked = true;
|
|
|
|
|
|
|
|
|
|
if (!n.IsExpanded)
|
|
|
|
|
n.Expand();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MakeFatesSelection();
|
|
|
|
|
|
|
|
|
|
_is_lock_fate = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private void MakeFatesSelection(bool makeline = false)
|
|
|
|
|
{
|
|
|
|
|
var fs = DcConfig.Duty.Fates[DcConfig.Duty.ActiveFate];
|
|
|
|
|
|
|
|
|
|
fs.Selected.Clear();
|
|
|
|
|
FateSelectionMakingLoop(treeFates.Nodes);
|
|
|
|
|
|
|
|
|
|
if (makeline)
|
|
|
|
|
fs.MakeLine();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private void FateSelectionMakingLoop(TreeNodeCollection nodes)
|
|
|
|
|
{
|
|
|
|
|
var fs = DcConfig.Duty.Fates[DcConfig.Duty.ActiveFate];
|
|
|
|
|
|
|
|
|
|
foreach (TreeNode n in nodes)
|
|
|
|
|
{
|
|
|
|
|
if (n.Checked)
|
|
|
|
|
fs.Selected.Add((int)n.Tag);
|
|
|
|
|
FateSelectionMakingLoop(n.Nodes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void CboDataset_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var l = (string)cboDataset.SelectedItem;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(l) && !l.Equals(DcConfig.Duty.Language) && DcContent.ReadContent(l))
|
|
|
|
|
{
|
|
|
|
|
|
2021-06-10 16:31:15 +02:00
|
|
|
|
lblCurrentDataSet.Text = DcContent.DisplayLanguage;
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-03-20 19:43:05 +01:00
|
|
|
|
SaveConfig();
|
2021-06-10 16:31:15 +02:00
|
|
|
|
|
2021-06-14 18:16:06 +02:00
|
|
|
|
if (DcConfig.DataRemoteUpdate)
|
|
|
|
|
Updater.CheckNewVersion();
|
2021-06-10 16:31:15 +02:00
|
|
|
|
|
|
|
|
|
UpdateFates();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-14 11:45:49 +02:00
|
|
|
|
private void CboPacketset_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
2021-06-18 14:08:43 +02:00
|
|
|
|
if (cboPacketset.SelectedIndex >= _packet_list.Count)
|
2021-06-14 18:16:06 +02:00
|
|
|
|
return;
|
|
|
|
|
|
2021-06-18 14:08:43 +02:00
|
|
|
|
var p = _packet_list.ElementAt(cboPacketset.SelectedIndex);
|
|
|
|
|
var n = p.Key;
|
2021-06-14 11:45:49 +02:00
|
|
|
|
|
2021-06-18 14:08:43 +02:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(n) && !n.Equals(DcConfig.Duty.PacketSet) && DcConfig.ReadPacket(n))
|
2021-06-14 11:45:49 +02:00
|
|
|
|
{
|
|
|
|
|
SaveConfig();
|
|
|
|
|
|
2021-06-18 14:08:43 +02:00
|
|
|
|
if (!n.Equals(DcConfig.PacketConfig.DefaultSetNameCustom))
|
2021-06-14 11:45:49 +02:00
|
|
|
|
{
|
2021-06-14 18:16:06 +02:00
|
|
|
|
// check update and save
|
2021-06-18 14:08:43 +02:00
|
|
|
|
RemotePacketUpdate(n);
|
2021-06-14 11:45:49 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-17 18:14:48 +01:00
|
|
|
|
private void TreeFates_AfterCheck(object sender, TreeViewEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (_is_lock_fate)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
_is_lock_fate = true;
|
|
|
|
|
|
|
|
|
|
if (((int)e.Node.Tag) > 100000)
|
|
|
|
|
{
|
|
|
|
|
foreach (TreeNode n in e.Node.Nodes)
|
|
|
|
|
n.Checked = e.Node.Checked;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (!e.Node.Checked)
|
|
|
|
|
e.Node.Parent.Checked = false;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var f = true;
|
|
|
|
|
foreach (TreeNode n in e.Node.Parent.Nodes)
|
|
|
|
|
f &= n.Checked;
|
|
|
|
|
e.Node.Parent.Checked = f;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MakeFatesSelection(true);
|
2021-03-20 19:43:05 +01:00
|
|
|
|
SaveConfig();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
|
|
|
|
_is_lock_fate = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private void ChangeFatePreset(int index)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (index >= 0 && index < 4)
|
|
|
|
|
{
|
|
|
|
|
DcConfig.Duty.ActiveFate = index;
|
|
|
|
|
UpdateFates();
|
|
|
|
|
|
2021-03-20 19:43:05 +01:00
|
|
|
|
SaveConfig();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RdoFatePreset1_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ChangeFatePreset(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RdoFatePreset2_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ChangeFatePreset(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RdoFatePreset3_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ChangeFatePreset(2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RdoFatePreset4_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
ChangeFatePreset(3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ChkEnableOverlay_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
progbOverlayTransparent.Enabled = chkEnableOverlay.Checked;
|
|
|
|
|
btnOverlayDimming.Enabled = chkEnableOverlay.Checked;
|
|
|
|
|
|
|
|
|
|
if (chkEnableOverlay.Checked)
|
|
|
|
|
_overlay.Show();
|
|
|
|
|
else
|
|
|
|
|
_overlay.Hide();
|
|
|
|
|
|
|
|
|
|
DcConfig.Duty.EnableOverlay = chkEnableOverlay.Checked;
|
|
|
|
|
|
2021-03-20 19:43:05 +01:00
|
|
|
|
SaveConfig();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ProgbOverlayTransparent_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnOverlayDimming_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2022-08-21 04:07:09 +02:00
|
|
|
|
_overlay.ResetAutoHide();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
_overlay.StartBlink();
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-20 19:43:05 +01:00
|
|
|
|
private void ChkOverlayClickThru_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
DcConfig.Duty.OverlayClickThru = chkOverlayClickThru.Checked;
|
2021-06-14 11:45:49 +02:00
|
|
|
|
_overlay.SetClickThruStatus(chkOverlayClickThru.Checked);
|
2021-03-20 19:43:05 +01:00
|
|
|
|
|
|
|
|
|
SaveConfig();
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-21 04:07:09 +02:00
|
|
|
|
private void ChkOverlayAutoHide_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
DcConfig.Duty.OverlayAutoHide = chkOverlayAutoHide.Checked;
|
|
|
|
|
|
|
|
|
|
SaveConfig();
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-17 18:14:48 +01:00
|
|
|
|
private void ChkEnableSound_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
txtSoundInstance.Enabled = chkEnableSound.Checked;
|
|
|
|
|
btnSoundFindInstance.Enabled = chkEnableSound.Checked;
|
|
|
|
|
btnSoundPlayInstance.Enabled = chkEnableSound.Checked;
|
|
|
|
|
txtSoundFate.Enabled = chkEnableSound.Checked;
|
|
|
|
|
btnSoundFindFate.Enabled = chkEnableSound.Checked;
|
|
|
|
|
btnSoundPlayFate.Enabled = chkEnableSound.Checked;
|
|
|
|
|
|
|
|
|
|
DcConfig.Duty.EnableSound = chkEnableSound.Checked;
|
|
|
|
|
|
2021-03-20 19:43:05 +01:00
|
|
|
|
SaveConfig();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private void PlayEffectSoundFate()
|
|
|
|
|
{
|
|
|
|
|
if (DcConfig.Duty.EnableSound)
|
|
|
|
|
WorkerAct.PlayEffectSound(DcConfig.Duty.SoundFateFile, DcConfig.Duty.SoundFateVolume);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private void PlayEffecSoundInstance()
|
|
|
|
|
{
|
|
|
|
|
if (DcConfig.Duty.EnableSound)
|
|
|
|
|
WorkerAct.PlayEffectSound(DcConfig.Duty.SoundInstanceFile, DcConfig.Duty.SoundInstanceVolume);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnSoundPlayInstance_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
PlayEffecSoundInstance();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnSoundPlayFate_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
PlayEffectSoundFate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private string SoundFileOpenDialog()
|
|
|
|
|
{
|
|
|
|
|
string filename = (string)WorkerAct.Invoker(new WorkerAct.ObjectReturnerDelegate(() =>
|
|
|
|
|
{
|
|
|
|
|
var dg = new OpenFileDialog
|
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
Title = Locale.Text(101),
|
2021-03-17 18:14:48 +01:00
|
|
|
|
DefaultExt = "wav",
|
2021-08-14 16:35:53 +02:00
|
|
|
|
Filter = Locale.Text(102)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (dg.ShowDialog() == DialogResult.OK) ? dg.FileName : null;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
return filename;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnSoundFindInstance_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
string filename = SoundFileOpenDialog();
|
|
|
|
|
|
|
|
|
|
DcConfig.Duty.SoundInstanceFile = string.IsNullOrEmpty(filename) ? string.Empty : filename;
|
|
|
|
|
txtSoundInstance.Text = DcConfig.Duty.SoundInstanceFile;
|
|
|
|
|
|
2021-03-20 19:43:05 +01:00
|
|
|
|
SaveConfig();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnSoundFindFate_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
string filename = SoundFileOpenDialog();
|
|
|
|
|
|
|
|
|
|
DcConfig.Duty.SoundFateFile = string.IsNullOrEmpty(filename) ? string.Empty : filename;
|
|
|
|
|
txtSoundFate.Text = DcConfig.Duty.SoundFateFile;
|
|
|
|
|
|
2021-03-20 19:43:05 +01:00
|
|
|
|
SaveConfig();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async void BtnTestNotify_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
string s = Locale.Text(103);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
|
|
|
|
if (DcConfig.Duty.UseNotifyLine)
|
|
|
|
|
await NotifyUsingLine(s);
|
|
|
|
|
|
|
|
|
|
if (DcConfig.Duty.UseNotifyTelegram)
|
|
|
|
|
NotifyUsingTelegram(s);
|
2021-06-20 14:31:05 +02:00
|
|
|
|
|
|
|
|
|
if (DcConfig.Duty.UseNotifyDiscordWebhook)
|
|
|
|
|
await NotifyUsingDiscordWebhook(s);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private void SendNotify(string s)
|
|
|
|
|
{
|
|
|
|
|
if (DcConfig.Duty.UseNotifyLine)
|
|
|
|
|
NotifyUsingLine(s).Wait();
|
|
|
|
|
|
|
|
|
|
if (DcConfig.Duty.UseNotifyTelegram)
|
|
|
|
|
NotifyUsingTelegram(s);
|
2021-06-20 14:31:05 +02:00
|
|
|
|
|
|
|
|
|
if (DcConfig.Duty.UseNotifyDiscordWebhook)
|
|
|
|
|
NotifyUsingDiscordWebhook(s).Wait();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private void NotifyFate(DcContent.Fate f)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.Duty.EnableNotify)
|
|
|
|
|
return;
|
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
string s = Locale.Text(10005, f.Name);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
SendNotify(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private void NotifyMatch(string name)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.Duty.EnableNotify)
|
|
|
|
|
return;
|
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
string s = Locale.Text(10003, name);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
SendNotify(s);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ChkUseNotifyLine_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
DcConfig.Duty.UseNotifyLine = chkUseNotifyLine.Checked;
|
|
|
|
|
txtLineToken.Enabled = chkUseNotifyLine.Checked;
|
|
|
|
|
|
|
|
|
|
btnTestNotify.Enabled = DcConfig.Duty.EnableNotify;
|
|
|
|
|
|
2021-03-20 19:43:05 +01:00
|
|
|
|
SaveConfig();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LblLineNotifyBotLink_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Process.Start(lblLineNotifyBotLink.Text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TxtLineToken_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (e.KeyCode == Keys.Enter)
|
|
|
|
|
{
|
|
|
|
|
DcConfig.Duty.NotifyLineToken = txtLineToken.Text;
|
2021-03-20 19:43:05 +01:00
|
|
|
|
SaveConfig();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
2021-06-20 14:31:05 +02:00
|
|
|
|
|
|
|
|
|
btnTestNotify.Enabled = true;
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
internal async Task NotifyUsingLine(string mesg)
|
|
|
|
|
{
|
|
|
|
|
if (txtLineToken.TextLength == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!txtLineToken.Text.Equals(DcConfig.Duty.NotifyLineToken))
|
|
|
|
|
{
|
|
|
|
|
DcConfig.Duty.NotifyLineToken = txtLineToken.Text;
|
2021-03-20 19:43:05 +01:00
|
|
|
|
SaveConfig();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var hc = new HttpClient();
|
|
|
|
|
hc.DefaultRequestHeaders.Add("Authorization", $"Bearer {DcConfig.Duty.NotifyLineToken}");
|
|
|
|
|
|
|
|
|
|
var param = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "message", mesg }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await hc.PostAsync("https://notify-api.line.me/api/notify",
|
|
|
|
|
new FormUrlEncodedContent(param)).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private void ChkUseNotifyTelegram_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
DcConfig.Duty.UseNotifyTelegram = chkUseNotifyTelegram.Checked;
|
|
|
|
|
txtTelegramId.Enabled = chkUseNotifyTelegram.Checked;
|
|
|
|
|
txtTelegramToken.Enabled = chkUseNotifyTelegram.Checked;
|
|
|
|
|
|
|
|
|
|
btnTestNotify.Enabled = DcConfig.Duty.EnableNotify;
|
|
|
|
|
|
2021-03-20 19:43:05 +01:00
|
|
|
|
SaveConfig();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TxtTelegramId_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (e.KeyCode == Keys.Enter)
|
|
|
|
|
{
|
|
|
|
|
DcConfig.Duty.NotifyTelegramId = txtTelegramId.Text;
|
2021-03-20 19:43:05 +01:00
|
|
|
|
SaveConfig();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
2021-06-20 14:31:05 +02:00
|
|
|
|
|
|
|
|
|
btnTestNotify.Enabled = true;
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TxtTelegramToken_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (e.KeyCode == Keys.Enter)
|
|
|
|
|
{
|
|
|
|
|
DcConfig.Duty.NotifyTelegramToken = txtTelegramToken.Text;
|
2021-03-20 19:43:05 +01:00
|
|
|
|
SaveConfig();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
2021-06-20 14:31:05 +02:00
|
|
|
|
|
|
|
|
|
btnTestNotify.Enabled = true;
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private static string EncodeJsonChars(string text)
|
|
|
|
|
{
|
|
|
|
|
return text.Replace("\b", "\\\b")
|
|
|
|
|
.Replace("\f", "\\\f")
|
|
|
|
|
.Replace("\n", "\\\n")
|
|
|
|
|
.Replace("\r", "\\\r")
|
|
|
|
|
.Replace("\t", "\\\t")
|
|
|
|
|
.Replace("\"", "\\\"")
|
|
|
|
|
.Replace("\\", "\\\\");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private bool NotifyUsingTelegram(string mesg)
|
|
|
|
|
{
|
|
|
|
|
if (txtTelegramId.TextLength == 0 || txtTelegramToken.TextLength == 0)
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (!txtTelegramId.Text.Equals(DcConfig.Duty.NotifyTelegramId))
|
|
|
|
|
{
|
|
|
|
|
DcConfig.Duty.NotifyTelegramId = txtTelegramId.Text;
|
2021-03-20 19:43:05 +01:00
|
|
|
|
SaveConfig();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!txtTelegramToken.Text.Equals(DcConfig.Duty.NotifyTelegramToken))
|
|
|
|
|
{
|
|
|
|
|
DcConfig.Duty.NotifyTelegramToken = txtTelegramToken.Text;
|
2021-03-20 19:43:05 +01:00
|
|
|
|
SaveConfig();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// https://codingman.tistory.com/41
|
|
|
|
|
|
|
|
|
|
var json = string.Format("{{\"chat_id\":\"{0}\", \"text\":\"{1}\"}}",
|
|
|
|
|
DcConfig.Duty.NotifyTelegramId, EncodeJsonChars(mesg));
|
|
|
|
|
var jbin = Encoding.UTF8.GetBytes(json);
|
|
|
|
|
|
|
|
|
|
var url = string.Format("https://api.telegram.org/bot{0}/sendMessage", DcConfig.Duty.NotifyTelegramToken);
|
|
|
|
|
HttpWebRequest req = WebRequest.Create(new Uri(url)) as HttpWebRequest;
|
|
|
|
|
req.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
|
|
|
|
|
req.Timeout = 30 * 1000;
|
|
|
|
|
req.Method = "POST";
|
|
|
|
|
req.ContentType = "application/json";
|
|
|
|
|
|
|
|
|
|
using (var st = req.GetRequestStream())
|
|
|
|
|
{
|
|
|
|
|
st.Write(jbin, 0, jbin.Length);
|
|
|
|
|
st.Flush();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HttpWebResponse res = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
res = req.GetResponse() as HttpWebResponse;
|
|
|
|
|
if (res.StatusCode == HttpStatusCode.OK)
|
|
|
|
|
{
|
|
|
|
|
string ss = null;
|
|
|
|
|
using (var st = res.GetResponseStream())
|
|
|
|
|
{
|
|
|
|
|
using (var rdr = new StreamReader(st, Encoding.UTF8))
|
|
|
|
|
ss = rdr.ReadToEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (0 < ss.IndexOf("\"ok\":true"))
|
|
|
|
|
return true;
|
|
|
|
|
else
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// http status is not ok
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
// ???
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
if (res != null)
|
|
|
|
|
res.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-20 14:31:05 +02:00
|
|
|
|
private void ChkUseNotifyDiscowk_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
DcConfig.Duty.UseNotifyDiscordWebhook = chkUseNotifyDiscowk.Checked;
|
|
|
|
|
txtDiscowkUrl.Enabled = chkUseNotifyDiscowk.Checked;
|
|
|
|
|
|
|
|
|
|
btnTestNotify.Enabled = DcConfig.Duty.EnableNotify;
|
|
|
|
|
|
|
|
|
|
SaveConfig();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void TxtDiscowkUrl_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (e.KeyCode == Keys.Enter)
|
|
|
|
|
{
|
|
|
|
|
if (!IsValidDiscwkUrl(txtDiscowkUrl.Text))
|
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
Logger.E(342);
|
2021-06-20 14:31:05 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DcConfig.Duty.NotifyDiscordWebhookUrl = txtDiscowkUrl.Text;
|
|
|
|
|
SaveConfig();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
btnTestNotify.Enabled = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ChkDiscowkTts_CheckedChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!DcConfig.PluginEnable)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
DcConfig.Duty.NotifyDiscordWebhookTts = chkDiscowkTts.Checked;
|
|
|
|
|
|
|
|
|
|
btnTestNotify.Enabled = DcConfig.Duty.EnableNotify;
|
|
|
|
|
|
|
|
|
|
SaveConfig();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static bool IsValidDiscwkUrl(string url)
|
|
|
|
|
{
|
|
|
|
|
url = url.ToLower();
|
|
|
|
|
return url.StartsWith("https://discord.com/api/webhooks/");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
internal async Task NotifyUsingDiscordWebhook(string mesg)
|
|
|
|
|
{
|
|
|
|
|
if (txtDiscowkUrl.TextLength == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (!IsValidDiscwkUrl(txtDiscowkUrl.Text))
|
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
Logger.E(342);
|
2021-06-20 14:31:05 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!txtDiscowkUrl.Text.Equals(DcConfig.Duty.NotifyDiscordWebhookUrl))
|
|
|
|
|
{
|
|
|
|
|
DcConfig.Duty.NotifyDiscordWebhookUrl = txtDiscowkUrl.Text;
|
|
|
|
|
SaveConfig();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var hc = new HttpClient();
|
|
|
|
|
var param = new Dictionary<string, string>
|
|
|
|
|
{
|
|
|
|
|
{ "content", mesg },
|
|
|
|
|
{ "tts", DcConfig.Duty.NotifyDiscordWebhookTts.ToString() },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
await hc.PostAsync(DcConfig.Duty.NotifyDiscordWebhookUrl,
|
|
|
|
|
new FormUrlEncodedContent(param)).ConfigureAwait(false);
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-17 18:14:48 +01:00
|
|
|
|
//
|
|
|
|
|
private void PacketFinderResetUi(bool is_enable)
|
|
|
|
|
{
|
|
|
|
|
if (!is_enable)
|
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
btnPacketStart.Text = Locale.Text(10007);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
btnPacketStart.BackColor = Color.Transparent;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
btnPacketStart.Text = Locale.Text(10008);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
btnPacketStart.BackColor = Color.Salmon;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
btnPacketApply.Visible = is_enable;
|
|
|
|
|
btnPacketApply.Enabled = is_enable;
|
|
|
|
|
lstPacketInfo.Enabled = is_enable;
|
|
|
|
|
txtPacketInfo.Enabled = is_enable;
|
|
|
|
|
txtPacketDescription.Enabled = is_enable;
|
|
|
|
|
lstBozjaInfo.Enabled = is_enable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private void PacketFindClearUi(DcConfig.PacketConfig newpk)
|
|
|
|
|
{
|
|
|
|
|
//
|
2021-06-14 18:16:06 +02:00
|
|
|
|
lblPacketVersion.Text = newpk.Version.ToString();
|
2021-06-14 11:45:49 +02:00
|
|
|
|
txtPacketDescription.Text = newpk.Description;
|
2021-03-17 18:14:48 +01:00
|
|
|
|
lstBozjaInfo.Items.Clear();
|
|
|
|
|
|
|
|
|
|
// FATE
|
|
|
|
|
lstPacketInfo.Items[0].SubItems[1].Text = DcConfig.Packet.OpFate.ToString();
|
|
|
|
|
lstPacketInfo.Items[0].SubItems[2].Text = "";
|
|
|
|
|
lstPacketInfo.Items[0].SubItems[3].Text = newpk.OpFate.ToString();
|
|
|
|
|
|
|
|
|
|
// Duty
|
|
|
|
|
lstPacketInfo.Items[1].SubItems[1].Text = DcConfig.Packet.OpDuty.ToString();
|
|
|
|
|
lstPacketInfo.Items[1].SubItems[2].Text = "";
|
|
|
|
|
lstPacketInfo.Items[1].SubItems[3].Text = newpk.OpDuty.ToString();
|
|
|
|
|
|
|
|
|
|
// Match
|
|
|
|
|
lstPacketInfo.Items[2].SubItems[1].Text = DcConfig.Packet.OpMatch.ToString();
|
|
|
|
|
lstPacketInfo.Items[2].SubItems[2].Text = "";
|
|
|
|
|
lstPacketInfo.Items[2].SubItems[3].Text = newpk.OpMatch.ToString();
|
|
|
|
|
|
|
|
|
|
// Instance
|
|
|
|
|
lstPacketInfo.Items[3].SubItems[1].Text = DcConfig.Packet.OpInstance.ToString();
|
|
|
|
|
lstPacketInfo.Items[3].SubItems[2].Text = "";
|
|
|
|
|
lstPacketInfo.Items[3].SubItems[3].Text = newpk.OpInstance.ToString();
|
|
|
|
|
|
2021-08-16 19:04:55 +02:00
|
|
|
|
// Zone
|
|
|
|
|
lstPacketInfo.Items[4].SubItems[1].Text = DcConfig.Packet.OpZone.ToString();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
lstPacketInfo.Items[4].SubItems[2].Text = "";
|
2021-08-16 19:04:55 +02:00
|
|
|
|
lstPacketInfo.Items[4].SubItems[3].Text = newpk.OpZone.ToString();
|
|
|
|
|
|
|
|
|
|
// Bozja
|
|
|
|
|
lstPacketInfo.Items[5].SubItems[1].Text = DcConfig.Packet.OpCe.ToString();
|
|
|
|
|
lstPacketInfo.Items[5].SubItems[2].Text = "";
|
|
|
|
|
lstPacketInfo.Items[5].SubItems[3].Text = newpk.OpCe.ToString();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnPacketStart_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!_is_packet_finder)
|
|
|
|
|
{
|
2021-06-14 11:45:49 +02:00
|
|
|
|
_new_packet = new DcConfig.PacketConfig(DateTime.Now);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
PacketFindClearUi(_new_packet);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
_is_packet_finder = !_is_packet_finder;
|
|
|
|
|
PacketFinderResetUi(_is_packet_finder);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnPacketApply_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
var ret = (DialogResult)WorkerAct.Invoker(new WorkerAct.ObjectReturnerDelegate(() =>
|
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
var r = MessageBox.Show(Locale.Text(10022), Locale.Text(0), MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
return r;
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
if (ret == DialogResult.Yes)
|
|
|
|
|
{
|
2021-06-14 11:45:49 +02:00
|
|
|
|
var newfilename = DcConfig.BuildPacketFileName(DcConfig.PacketConfig.DefaultSetNameCustom);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-06-14 11:45:49 +02:00
|
|
|
|
_new_packet.Description = txtPacketDescription.Text;
|
|
|
|
|
_new_packet.Save(newfilename);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
|
|
|
|
_is_packet_finder = false;
|
|
|
|
|
PacketFinderResetUi(false);
|
2021-06-14 11:45:49 +02:00
|
|
|
|
|
2021-06-19 14:07:01 +02:00
|
|
|
|
// select custom
|
|
|
|
|
DcConfig.Duty.PacketSet = DcConfig.PacketConfig.DefaultSetNameCustom;
|
|
|
|
|
RefreshPacketList();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LstPacketInfo_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstPacketInfo.SelectedIndices.Count != 1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
int m;
|
|
|
|
|
|
|
|
|
|
switch (lstPacketInfo.SelectedIndices[0])
|
|
|
|
|
{
|
|
|
|
|
case 0: m = 10010; break;
|
|
|
|
|
case 1: m = 10011; break;
|
|
|
|
|
case 2: m = 10011; break;
|
|
|
|
|
case 3: m = 10011; break;
|
2021-08-16 19:04:55 +02:00
|
|
|
|
case 4: m = 10026; break;
|
|
|
|
|
case 5: m = 10014; break;
|
2021-03-17 18:14:48 +01:00
|
|
|
|
default: m = 10015; break;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
txtPacketInfo.Text = Locale.Text(m);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-14 11:45:49 +02:00
|
|
|
|
private void LstPacketInfo_MouseDoubleClick(object sender, MouseEventArgs e)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2021-06-14 11:45:49 +02:00
|
|
|
|
if (lstPacketInfo.SelectedIndices.Count != 1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var v = int.MaxValue;
|
|
|
|
|
|
|
|
|
|
switch (lstPacketInfo.SelectedIndices[0])
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
v = _new_packet.OpFate = DcConfig.Packet.OpFate;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
v = _new_packet.OpDuty = DcConfig.Packet.OpDuty;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
v = _new_packet.OpMatch = DcConfig.Packet.OpMatch;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
v = _new_packet.OpInstance = DcConfig.Packet.OpInstance;
|
|
|
|
|
break;
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-06-14 11:45:49 +02:00
|
|
|
|
case 4:
|
2021-08-16 19:04:55 +02:00
|
|
|
|
v = _new_packet.OpZone = DcConfig.Packet.OpZone;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 5:
|
2021-08-14 16:35:53 +02:00
|
|
|
|
v = _new_packet.OpCe = DcConfig.Packet.OpCe;
|
2021-06-14 11:45:49 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (v != int.MaxValue)
|
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
lstPacketInfo.SelectedItems[0].SubItems[2].Text = Locale.Text(10024);
|
2021-06-14 11:45:49 +02:00
|
|
|
|
lstPacketInfo.SelectedItems[0].SubItems[3].Text = v.ToString();
|
|
|
|
|
}
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void LstBozjaInfo_SelectedIndexChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lstBozjaInfo.SelectedItems.Count != 1)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
ushort opcode = (ushort)lstBozjaInfo.SelectedItems[0].Tag;
|
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
_new_packet.OpCe = opcode;
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-08-16 19:04:55 +02:00
|
|
|
|
lstPacketInfo.Items[5].SubItems[2].Text = Locale.Text(10023);
|
|
|
|
|
lstPacketInfo.Items[5].SubItems[3].Text = _new_packet.OpCe.ToString();
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
|
2021-06-14 11:45:49 +02:00
|
|
|
|
private void LstBozjaInfo_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-19 14:07:01 +02:00
|
|
|
|
// middle la noscea
|
2021-06-20 14:31:05 +02:00
|
|
|
|
private static readonly ushort[] _fates_middle_la_noscea =
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
|
|
|
|
553, 649, 687, 688, 693, 717,
|
|
|
|
|
220, 221, 222, 223, 225, 226, 227, 229, 231, 233, 235, 237, 238, 239, 240,
|
|
|
|
|
1387,
|
2021-06-19 14:07:01 +02:00
|
|
|
|
};
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2021-06-19 14:07:01 +02:00
|
|
|
|
// southern bozja front
|
2021-06-20 14:31:05 +02:00
|
|
|
|
private static readonly ushort[] _fates_southern_bojza =
|
2021-06-19 14:07:01 +02:00
|
|
|
|
{
|
2021-03-17 18:14:48 +01:00
|
|
|
|
1597, 1598, 1599,
|
|
|
|
|
1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609,
|
|
|
|
|
1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619,
|
2021-06-03 13:54:27 +02:00
|
|
|
|
1620, 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1628,
|
2021-06-19 14:07:01 +02:00
|
|
|
|
};
|
2021-06-03 13:54:27 +02:00
|
|
|
|
|
2021-06-19 14:07:01 +02:00
|
|
|
|
// zadnor
|
2021-06-20 14:31:05 +02:00
|
|
|
|
private static readonly ushort[] _fates_zadnor =
|
2021-06-19 14:07:01 +02:00
|
|
|
|
{
|
2021-06-03 13:54:27 +02:00
|
|
|
|
1717, 1718, 1719, 1720, 1721, 1722, 1723, 1724,
|
|
|
|
|
1725, 1726, 1727, 1728, 1729, 1730, 1731, 1732,
|
|
|
|
|
1733, 1734, 1735, 1736, 1737, 1738, 1739, 1740, 1741, 1742,
|
2021-03-17 18:14:48 +01:00
|
|
|
|
};
|
|
|
|
|
|
2021-06-19 14:07:01 +02:00
|
|
|
|
//
|
2021-06-20 14:31:05 +02:00
|
|
|
|
private bool IsFateInFindList(ushort code)
|
2021-06-19 14:07:01 +02:00
|
|
|
|
{
|
|
|
|
|
return
|
|
|
|
|
_fates_middle_la_noscea.Contains(code) ||
|
|
|
|
|
_fates_southern_bojza.Contains(code) ||
|
|
|
|
|
_fates_zadnor.Contains(code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
2021-06-20 14:31:05 +02:00
|
|
|
|
private bool IsSkirmishFate(ushort code)
|
|
|
|
|
{
|
|
|
|
|
return
|
|
|
|
|
_fates_southern_bojza.Contains(code) ||
|
|
|
|
|
_fates_zadnor.Contains(code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
private bool IsFateForSouthernBozja(ushort code)
|
2021-06-19 14:07:01 +02:00
|
|
|
|
{
|
|
|
|
|
return _fates_southern_bojza.Contains(code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
2021-06-20 14:31:05 +02:00
|
|
|
|
private bool IsFateForZadnor(ushort code)
|
2021-06-19 14:07:01 +02:00
|
|
|
|
{
|
|
|
|
|
return _fates_zadnor.Contains(code);
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-27 15:35:26 +02:00
|
|
|
|
#if TESTPK
|
|
|
|
|
private static string DataToByteString(byte[] be)
|
|
|
|
|
{
|
|
|
|
|
const string HexAlphabet = "0123456789ABCDEF";
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
foreach (var b in be)
|
|
|
|
|
sb.Append(HexAlphabet[(int)(b >> 4)]).Append(HexAlphabet[(int)(b & 0xF)]).Append(' ');
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static string DataToUshortString(byte[] data, int index)
|
|
|
|
|
{
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
|
|
|
|
|
for (int i = index; i < data.Length; i += 2)
|
|
|
|
|
{
|
|
|
|
|
sb.Append(BitConverter.ToInt16(data, i));
|
|
|
|
|
sb.Append(' ');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static int IndexOfData(byte[] data, int index, ushort value)
|
|
|
|
|
{
|
|
|
|
|
int len = data.Length;
|
|
|
|
|
|
|
|
|
|
for (int i = index; i < len; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i + 1 >= len)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
ushort n = BitConverter.ToUInt16(data, i);
|
|
|
|
|
if (value == n)
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static int IndexOfData(byte[] data, int index, ushort[] values)
|
|
|
|
|
{
|
|
|
|
|
int len = data.Length;
|
|
|
|
|
|
|
|
|
|
for (int i = index; i < len; i++)
|
|
|
|
|
{
|
|
|
|
|
if (i + 1 >= len)
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
ushort n = BitConverter.ToUInt16(data, i);
|
|
|
|
|
for (int u = 0; u < values.Length; u++)
|
|
|
|
|
{
|
|
|
|
|
if (values[u] == n)
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-03-17 18:14:48 +01:00
|
|
|
|
//
|
|
|
|
|
private void PacketFinderHandler(byte[] message)
|
|
|
|
|
{
|
|
|
|
|
var opcode = BitConverter.ToUInt16(message, 18);
|
|
|
|
|
var data = message.Skip(32).ToArray();
|
|
|
|
|
|
2022-08-27 15:35:26 +02:00
|
|
|
|
#if TESTPK
|
2022-10-05 18:53:22 +02:00
|
|
|
|
#if false
|
2022-08-27 15:35:26 +02:00
|
|
|
|
// 파이날 스텝으로 오는거 전부 얻기
|
|
|
|
|
var t = IndexOfData(data, 0, new ushort[] { 169, 134, 183, 223, 637 }); // final, P1, S1, Z1, Snake
|
|
|
|
|
if (t > 0)
|
|
|
|
|
{
|
|
|
|
|
var s = DataToByteString(data);
|
|
|
|
|
Logger.L("{0}({1},{2}) => {3}", opcode, data.Length, t, s);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
#endif
|
|
|
|
|
// 매칭 관련
|
2022-10-05 18:53:22 +02:00
|
|
|
|
if (opcode == 548 || opcode == 288 || opcode == 880 || opcode == 460)
|
2022-08-27 15:35:26 +02:00
|
|
|
|
{
|
|
|
|
|
var s = DataToByteString(data);
|
|
|
|
|
Logger.L("{0}({1}) => {2}", opcode, data.Length, s);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2021-03-17 18:14:48 +01:00
|
|
|
|
// fate
|
2021-03-20 19:43:05 +01:00
|
|
|
|
if (_new_packet.OpFate == 0 && data.Length > 4 && data[0] == 0x3E)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2021-06-20 14:31:05 +02:00
|
|
|
|
var cc = BitConverter.ToUInt16(data, 4);
|
2021-06-19 14:07:01 +02:00
|
|
|
|
if (IsFateInFindList(cc) && _new_packet.OpFate != opcode)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
|
|
|
|
_new_packet.OpFate = opcode;
|
|
|
|
|
|
|
|
|
|
WorkerAct.Invoker(() =>
|
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
lstPacketInfo.Items[0].SubItems[2].Text = Locale.Text(10016);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
lstPacketInfo.Items[0].SubItems[3].Text = _new_packet.OpFate.ToString();
|
|
|
|
|
});
|
|
|
|
|
|
2021-06-19 14:07:01 +02:00
|
|
|
|
_last_fate = cc;
|
|
|
|
|
|
2021-03-17 18:14:48 +01:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-27 15:35:26 +02:00
|
|
|
|
// duty & packet
|
2022-09-13 06:52:28 +02:00
|
|
|
|
if (DcConfig.Duty.PacketForLocal)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2022-08-27 15:35:26 +02:00
|
|
|
|
// for ACTOZ/Korean service
|
|
|
|
|
|
|
|
|
|
// duty
|
|
|
|
|
if (_new_packet.OpDuty == 0 && data.Length > 12)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2022-08-27 15:35:26 +02:00
|
|
|
|
var rcode = data[8];
|
|
|
|
|
if (rcode == 0)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2022-08-27 15:35:26 +02:00
|
|
|
|
// The Final Steps of Faith (169)
|
|
|
|
|
short m = BitConverter.ToInt16(data, 12);
|
|
|
|
|
if (m == 169 && _new_packet.OpDuty != opcode)
|
|
|
|
|
{
|
|
|
|
|
_new_packet.OpDuty = opcode;
|
|
|
|
|
|
|
|
|
|
WorkerAct.Invoker(() =>
|
|
|
|
|
{
|
|
|
|
|
lstPacketInfo.Items[1].SubItems[2].Text = Locale.Text(10016);
|
|
|
|
|
lstPacketInfo.Items[1].SubItems[3].Text = _new_packet.OpDuty.ToString();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2022-08-27 15:35:26 +02:00
|
|
|
|
// match
|
|
|
|
|
if (_new_packet.OpMatch == 0 && data.Length > 20)
|
|
|
|
|
{
|
|
|
|
|
var rcode = data[2];
|
|
|
|
|
if (rcode == 0)
|
|
|
|
|
{
|
|
|
|
|
// The Final Steps of Faith (169)
|
|
|
|
|
short m = BitConverter.ToInt16(data, 20);
|
|
|
|
|
if (m == 169 && _new_packet.OpMatch != opcode)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2022-08-27 15:35:26 +02:00
|
|
|
|
_new_packet.OpMatch = opcode;
|
|
|
|
|
|
|
|
|
|
WorkerAct.Invoker(() =>
|
|
|
|
|
{
|
|
|
|
|
lstPacketInfo.Items[2].SubItems[2].Text = Locale.Text(10016);
|
|
|
|
|
lstPacketInfo.Items[2].SubItems[3].Text = _new_packet.OpMatch.ToString();
|
|
|
|
|
});
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2022-08-27 15:35:26 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-27 15:35:26 +02:00
|
|
|
|
else
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2022-08-27 15:35:26 +02:00
|
|
|
|
// for common
|
|
|
|
|
|
|
|
|
|
// duty
|
|
|
|
|
if (_new_packet.OpDuty == 0 && data.Length > 20) // real size is 40
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2022-08-27 15:35:26 +02:00
|
|
|
|
var rcode = data[16];
|
|
|
|
|
var scode = data[19];
|
|
|
|
|
if (rcode == 0 && scode == 0)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2022-08-27 15:35:26 +02:00
|
|
|
|
// The Final Steps of Faith (169)
|
|
|
|
|
short m = BitConverter.ToInt16(data, 20);
|
|
|
|
|
if (m == 169 && _new_packet.OpDuty != opcode)
|
|
|
|
|
{
|
|
|
|
|
_new_packet.OpDuty = opcode;
|
|
|
|
|
|
|
|
|
|
WorkerAct.Invoker(() =>
|
|
|
|
|
{
|
|
|
|
|
lstPacketInfo.Items[1].SubItems[2].Text = Locale.Text(10016);
|
|
|
|
|
lstPacketInfo.Items[1].SubItems[3].Text = _new_packet.OpDuty.ToString();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2022-08-27 15:35:26 +02:00
|
|
|
|
// match
|
|
|
|
|
if (_new_packet.OpMatch == 0 && data.Length > 20) // real size is 40
|
|
|
|
|
{
|
|
|
|
|
var rcode = data[2];
|
|
|
|
|
if (rcode == 0)
|
|
|
|
|
{
|
|
|
|
|
// The Final Steps of Faith (169)
|
|
|
|
|
short m = BitConverter.ToInt16(data, 28);
|
|
|
|
|
if (m == 169 && _new_packet.OpMatch != opcode)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2022-08-27 15:35:26 +02:00
|
|
|
|
_new_packet.OpMatch = opcode;
|
|
|
|
|
|
|
|
|
|
WorkerAct.Invoker(() =>
|
|
|
|
|
{
|
|
|
|
|
lstPacketInfo.Items[2].SubItems[2].Text = Locale.Text(10016);
|
|
|
|
|
lstPacketInfo.Items[2].SubItems[3].Text = _new_packet.OpMatch.ToString();
|
|
|
|
|
});
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
2022-08-27 15:35:26 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// instance
|
2021-03-20 19:43:05 +01:00
|
|
|
|
if (_new_packet.OpInstance == 0 && data.Length >= 16)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
2022-08-27 15:35:26 +02:00
|
|
|
|
// The Final Steps of Faith (169)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
short m = BitConverter.ToInt16(data, 0);
|
|
|
|
|
short u = BitConverter.ToInt16(data, 2);
|
2022-08-27 15:35:26 +02:00
|
|
|
|
if (m == 169 && u == 0 && _new_packet.OpInstance != opcode)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
|
|
|
|
_new_packet.OpInstance = opcode;
|
|
|
|
|
|
|
|
|
|
WorkerAct.Invoker(() =>
|
|
|
|
|
{
|
2021-08-14 16:35:53 +02:00
|
|
|
|
lstPacketInfo.Items[3].SubItems[2].Text = Locale.Text(10016);
|
2021-03-17 18:14:48 +01:00
|
|
|
|
lstPacketInfo.Items[3].SubItems[3].Text = _new_packet.OpInstance.ToString();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-16 19:04:55 +02:00
|
|
|
|
// zone
|
|
|
|
|
if (_new_packet.OpZone == 0 && data.Length == 16)
|
|
|
|
|
{
|
|
|
|
|
// Middle La Noscea (134)
|
|
|
|
|
var h = BitConverter.ToUInt32(data, 0);
|
|
|
|
|
var z = BitConverter.ToUInt16(data, 4);
|
2021-12-08 06:20:51 +01:00
|
|
|
|
if (h == 0 && z == 134)
|
2021-08-16 19:04:55 +02:00
|
|
|
|
{
|
|
|
|
|
_new_packet.OpZone = opcode;
|
|
|
|
|
|
|
|
|
|
WorkerAct.Invoker(() =>
|
|
|
|
|
{
|
|
|
|
|
lstPacketInfo.Items[4].SubItems[2].Text = Locale.Text(10016);
|
|
|
|
|
lstPacketInfo.Items[4].SubItems[3].Text = _new_packet.OpZone.ToString();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-17 18:14:48 +01:00
|
|
|
|
// critical engagement
|
2021-06-03 13:54:27 +02:00
|
|
|
|
if (data.Length >= 12 && _stq_type != DcContent.SaveTheQueenType.No)
|
2021-03-17 18:14:48 +01:00
|
|
|
|
{
|
|
|
|
|
// 0[4] timestamp
|
|
|
|
|
// 4[2] mmss
|
|
|
|
|
// 6[2] ?
|
|
|
|
|
// 8[1] code
|
|
|
|
|
// 9[1] members
|
|
|
|
|
// 10[1] status 0=end, 1=register, 2=entry, 3=progress
|
|
|
|
|
// 12[1] progress percentage
|
|
|
|
|
|
|
|
|
|
var code = data[8];
|
|
|
|
|
|
|
|
|
|
if (code < 0 || code > 15)
|
|
|
|
|
{
|
|
|
|
|
// not ce
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-14 05:43:07 +01:00
|
|
|
|
var ok = false;
|
|
|
|
|
var mem = data[9];
|
2021-03-17 18:14:48 +01:00
|
|
|
|
var stat = data[10];
|
|
|
|
|
var prg = data[12];
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
if (stat == 0)
|
|
|
|
|
{
|
|
|
|
|
// end. other conditions unknown
|
|
|
|
|
ok = true;
|
|
|
|
|
}
|
|
|
|
|
else*/
|
|
|
|
|
if (stat == 1)
|
|
|
|
|
{
|
|
|
|
|
// register. progress must be 0
|
|
|
|
|
if (mem >= 0 && mem <= 48 && prg == 0)
|
|
|
|
|
ok = true;
|
|
|
|
|
}
|
|
|
|
|
else if (stat == 2)
|
|
|
|
|
{
|
|
|
|
|
// entry. progress must be 0
|
|
|
|
|
if (mem >= 0 && mem <= 48 && prg == 0)
|
|
|
|
|
ok = true;
|
|
|
|
|
}
|
|
|
|
|
else if (stat == 3)
|
|
|
|
|
{
|
|
|
|
|
// progress. progress must be in 1~99
|
|
|
|
|
if (mem > 0 && mem <= 48 && prg >= 1 && prg < 100)
|
|
|
|
|
ok = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ok)
|
|
|
|
|
{
|
2021-06-19 14:07:01 +02:00
|
|
|
|
if (_stq_type == DcContent.SaveTheQueenType.No)
|
|
|
|
|
{
|
|
|
|
|
if (IsFateForSouthernBozja(_last_fate))
|
|
|
|
|
_stq_type = DcContent.SaveTheQueenType.Bozja;
|
|
|
|
|
else if (IsFateForZadnor(_last_fate))
|
|
|
|
|
_stq_type = DcContent.SaveTheQueenType.Zadnor;
|
|
|
|
|
else
|
|
|
|
|
_stq_type = DcContent.SaveTheQueenType.Zadnor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ce = DcContent.GetFate(code + DcContent.SaveTheQueenTypeToCeBase(_stq_type));
|
2021-03-17 18:14:48 +01:00
|
|
|
|
|
|
|
|
|
var li = new ListViewItem(new string[]
|
|
|
|
|
{
|
|
|
|
|
ce.Name,
|
|
|
|
|
DcContent.CeStatusToString(stat),
|
|
|
|
|
mem.ToString(),
|
|
|
|
|
prg.ToString()
|
|
|
|
|
})
|
|
|
|
|
{
|
|
|
|
|
Tag = opcode
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
WorkerAct.Invoker(() =>
|
|
|
|
|
{
|
|
|
|
|
lstBozjaInfo.Items.Add(li);
|
|
|
|
|
lstBozjaInfo.EnsureVisible(lstBozjaInfo.Items.Count - 1);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-14 18:16:06 +02:00
|
|
|
|
|
|
|
|
|
private void RemotePacketUpdate(string name)
|
|
|
|
|
{
|
|
|
|
|
// need to resign using thread -> blocked by network troubles
|
|
|
|
|
if (!DcConfig.DataRemoteUpdate)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
var ns = Updater.CheckNewPacket(name);
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(ns))
|
|
|
|
|
{
|
|
|
|
|
var pk = DcConfig.PacketConfig.ParseString(ns);
|
|
|
|
|
|
|
|
|
|
if (pk.Version > DcConfig.Packet.Version)
|
|
|
|
|
{
|
|
|
|
|
DcConfig.Packet.Version = pk.Version;
|
|
|
|
|
DcConfig.Packet.Description = pk.Description;
|
|
|
|
|
DcConfig.Packet.OpFate = pk.OpFate;
|
|
|
|
|
DcConfig.Packet.OpDuty = pk.OpDuty;
|
|
|
|
|
DcConfig.Packet.OpMatch = pk.OpMatch;
|
|
|
|
|
DcConfig.Packet.OpInstance = pk.OpInstance;
|
2021-08-16 19:04:55 +02:00
|
|
|
|
DcConfig.Packet.OpZone = pk.OpZone;
|
2021-08-14 16:35:53 +02:00
|
|
|
|
DcConfig.Packet.OpCe = pk.OpCe;
|
2021-06-14 18:16:06 +02:00
|
|
|
|
|
|
|
|
|
var nfn = DcConfig.BuildPacketFileName(name);
|
|
|
|
|
pk.Save(nfn);
|
|
|
|
|
|
2021-08-14 16:35:53 +02:00
|
|
|
|
Logger.I(33, pk.Version, pk.Description);
|
2021-06-14 18:16:06 +02:00
|
|
|
|
|
2021-06-18 14:08:43 +02:00
|
|
|
|
//
|
|
|
|
|
_packet_list.Remove(name);
|
|
|
|
|
_packet_list.Add(name, pk.Description);
|
|
|
|
|
|
|
|
|
|
RefreshPacketList(false);
|
2021-06-14 18:16:06 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-06-18 14:08:43 +02:00
|
|
|
|
|
|
|
|
|
private void RefreshDatasetList()
|
|
|
|
|
{
|
|
|
|
|
// quick description read?
|
|
|
|
|
|
|
|
|
|
cboDataset.Items.Clear();
|
|
|
|
|
|
|
|
|
|
DirectoryInfo di = new DirectoryInfo(DcConfig.DataPath);
|
|
|
|
|
|
|
|
|
|
foreach (var fi in di.GetFiles("DcDuty-*.json"))
|
|
|
|
|
{
|
|
|
|
|
var s = fi.Name.Substring(7, fi.Name.Length - 7 - 5);
|
|
|
|
|
var n = cboDataset.Items.Add(s);
|
|
|
|
|
|
|
|
|
|
if (s.Equals(DcConfig.Duty.Language))
|
|
|
|
|
cboDataset.SelectedIndex = n;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RefreshPacketList(bool reload_file_info = true)
|
|
|
|
|
{
|
|
|
|
|
if (reload_file_info)
|
|
|
|
|
{
|
|
|
|
|
_packet_list.Clear();
|
|
|
|
|
|
|
|
|
|
DirectoryInfo di = new DirectoryInfo(DcConfig.DataPath);
|
|
|
|
|
|
|
|
|
|
foreach (var fi in di.GetFiles("DcPacket-*.config"))
|
|
|
|
|
{
|
|
|
|
|
var name = fi.Name.Substring(9, fi.Name.Length - 9 - 7);
|
|
|
|
|
|
|
|
|
|
var db = new ThirdParty.LineDb(fi.FullName, Encoding.UTF8, false);
|
|
|
|
|
var desc = db.Get("Description", null);
|
|
|
|
|
|
|
|
|
|
if (desc == null)
|
|
|
|
|
{
|
|
|
|
|
// config file was for below version 9
|
|
|
|
|
_packet_list.Add(name, name);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_packet_list.Add(name, desc);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cboPacketset.Items.Clear();
|
|
|
|
|
|
|
|
|
|
foreach (var i in _packet_list)
|
|
|
|
|
{
|
|
|
|
|
var n = cboPacketset.Items.Add(i.Value);
|
|
|
|
|
|
|
|
|
|
if (i.Key.Equals(DcConfig.Duty.PacketSet))
|
|
|
|
|
cboPacketset.SelectedIndex = n;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-14 16:35:53 +02:00
|
|
|
|
|
2021-08-15 16:38:36 +02:00
|
|
|
|
private void BtnResetContentList_Click(object sender, EventArgs e)
|
2021-08-14 16:35:53 +02:00
|
|
|
|
{
|
2021-08-15 16:38:36 +02:00
|
|
|
|
lstContents.ResetContentItems();
|
2021-08-14 16:35:53 +02:00
|
|
|
|
}
|
2021-08-16 19:04:55 +02:00
|
|
|
|
|
|
|
|
|
public void ResetContentItems()
|
|
|
|
|
{
|
|
|
|
|
WorkerAct.Invoker(() => lstContents.ResetContentItems());
|
|
|
|
|
}
|
2021-03-17 18:14:48 +01:00
|
|
|
|
}
|
|
|
|
|
}
|