This commit is contained in:
kshman 2021-03-18 02:14:48 +09:00
parent caf00e8d86
commit 92067339c8
54 changed files with 11624 additions and 0 deletions

63
.gitattributes vendored Normal file
View file

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

343
.gitignore vendored Normal file
View file

@ -0,0 +1,343 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# Visual Studio 2017 auto generated files
Generated\ Files/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# Benchmark Results
BenchmarkDotNet.Artifacts/
# .NET Core
project.lock.json
project.fragment.lock.json
artifacts/
# StyleCop
StyleCopReport.xml
# Files built by Visual Studio
*_i.c
*_p.c
*_h.h
*.ilk
*.meta
*.obj
*.iobj
*.pch
*.pdb
*.ipdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*_wpftmp.csproj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# Visual Studio Trace Files
*.e2e
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# Note: Comment the next line if you want to checkin your web deploy settings,
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/[Pp]ackages/*
# except build/, which is used as an MSBuild target.
!**/[Pp]ackages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/[Pp]ackages/repositories.config
# NuGet v3's project.json files produces more ignorable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
*.appx
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!?*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
orleans.codegen.cs
# Including strong name files can present a security risk
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
#*.snk
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
ServiceFabricBackup/
*.rptproj.bak
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
*.rptproj.rsuser
*- Backup*.rdl
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush personal settings
.cr/personal
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Tabs Studio
*.tss
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
# OpenCover UI analysis results
OpenCover/
# Azure Stream Analytics local run output
ASALocalRun/
# MSBuild Binary and Structured Log
*.binlog
# NVidia Nsight GPU debugger configuration file
*.nvuser
# MFractors (Xamarin productivity tool) working folder
.mfractor/
# Local History for Visual Studio
.localhistory/
# BeatPulse healthcheck temp database
healthchecksdb
# ACT
References/ACT/

1778
Data/DcDuty-English.json Normal file

File diff suppressed because it is too large Load diff

1778
Data/DcDuty-Japanese.json Normal file

File diff suppressed because it is too large Load diff

1754
Data/DcDuty-Korean.json Normal file

File diff suppressed because it is too large Load diff

87
Data/DcLang-Japanese.txt Normal file
View file

@ -0,0 +1,87 @@
# 日本語メッセージ
LANG=日本語
0=FFXIV dc
1=レディ
2=FFXIV プラグインが見つからないんです!
3=FFXIV プラグインを見つかりました!
4=FFXIV ドユーティー・コンテンツが起動しました!
5=ACT 情報: {0} ({1})
6=FFXIV プラグイン情報: {0} ({1})
7=データが壊れました: {0}
8=分析できません!
9=アンノウン・コンテンツ: {0}
10=アンノウン・インスタンス: {0}
11=アンノウン・地役: {0}
12=アンノウン・フェイト: {0}
13=データが読めないんです!
14=データ・ファイルが見つからないんです! {0}
20=ドユーティー・コンテンツ情報: {1}({0}) / A:{2} / R:{3} / I:{4} / F:{5} ({6})
21=ルーレット
22=インスタンス
23=フェイト
24=スカーミッシュ
25=クリティカル・エンゲージメント
26=基本
99=ドユーティー・コンテンツ・プラグイン {0}
101=WAVEファイルを選んでください
102=WAVファイル (*.wav)|*.wav|全て (*.*)|*.*
103=お知らせテストです!!
200=設定
201=表示言語
202=FFXIVがアクティブ状態じゃない場合、オーバレイを隠します
300=コンテンツ
301=コンテンツ
302=設定
303=パゲット
304=データ
305=ログフォント
306=オーバレイ・オン
307=透明度
308=サウンド・オン
309=インスタンス
310=フェイト
311=ラインお知らせ
312=トーケン
313=テレグラムお知らせ
314=ID
315=トーケン
316=パゲット探し
317=説明
318=ボズヤ情報
319=機能
320=現在
321=状態
322=探す
323=CEの名前
324=状態
325=人数
326=進行度
10001="{0}" 発生!
10002=待機: {0}
10003=マッチング: {0}
10004=入ります: {0}
10005={0} 発生!
10006=待機: {0}
10007=スタート
10008=キャンセル
10009=適用とセーブ
10010=中央ラノシアリーキまたは南方ボズヤで自動的に探します
10011=皇都イシュガルド防衛戦に解除で入って見てください
10012=マッチング
10013=インスタンス
10014=南方ボズヤでCEをまってください。右のリストにパゲットの候補が表示されたら項目をクリックしてください
10015=項目をクリックすると説明が出ます
10016=確認済
10017=終わり
10018=登録中
10019=入場中
10020=進行中
10021=アンノウン
10022=このパゲットデータを使いますか?セーブします
10023=選択

View file

@ -0,0 +1,87 @@
# 한국말 메시지, 한국어 서비스(액토즈)
LANG=한국어(액토즈)
0=FFXIV dc
1=준비됐습니다
2=FFXIV 플러그인이 없어요!
3=FFXIV 플러그인을 찾았어요!
4=FFXIV 듀티 콘텐츠 시작합니다!
5=ACT 정보: {0} ({1})
6=FFXIV 플러그인 정보: {0} ({1})
7=잘못된 데이터: {0}
8=분석할 수 없어요
9=알수없는 임무: {0}
10=알수없는 인스턴스: {0}
11=알수없는 지역: {0}
12=알수없는 돌발: {0}
13=데이터를 읽을 수가 없어요!
14=데이터 파일이 없어요! {0}
20=듀티 콘텐츠 정보: {1}({0}) / A:{2} / R:{3} / I:{4} / F:{5} ({6})
21=무작위 임무
22=인스턴스
23=돌발
24=돌발 교전
25=비상 교전
26=기본
99=듀티 콘텐츠 플러그인 {0}
101=소리 파일을 선택하세요
102=소리 파일 (*.wav)|*.wav|모든 파일 (*.*)|*.*
103=알림 테스트입니다!!
200=설정
201=표시 언어
202=FFXIV를 보고 있지 않을때 오버레이를 감춥니다
300=임무
301=콘텐츠
302=설정
303=패킷
304=데이터셋
305=로그 글꼴
306=오버레이 보기
307=투명도
308=소리 듣기
309=인스턴스
310=돌발
311=라인 알림
312=라인 토큰
313=텔레그램 알림
314=텔레그램 ID
315=텔레그램 토큰
316=패킷 찾기
317=설명
318=보즈야 찾기
319=기능
320=현재값
321=상태
322=찾은값
323=비상 교전 이름
324=상태
325=사람수
326=진행도
10001="{0}" 발생했어요!
10002=찾습니다: {0}
10003=매칭됐어요: {0}
10004=들어가요: {0}
10005={0} 발생했어요!
10006=대기 갯수: {0}
10007=시작
10008=취소
10009=적용 및 저장
10010=중부 라노시아로 가시면 값이 채워집니다. 또는 남부 보즈야 전선의 교전으로도 알 수 있습니다.
10011=토벌전 "성도 이슈가르드 방어전"에 해제로 입장해보세요.
10012=매치
10013=인스턴스
10014=남부 보즈야 전선으로 가서 비상 교전을 기다리세요. 오른쪽 보즈야 찾기에 후보 데이터가 뜨면 맞는 데이터를 선택하세요.
10015=설명을 볼 항목을 선택하세요
10016=확인됨
10017=끝남
10018=등록중
10019=입장하는중
10020=진행중
10021=알수없어요
10022=패킷 데이터를 적용하고 덮어쓰실거예요?
10023=선택함

305
DcConfig.cs Normal file
View file

@ -0,0 +1,305 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace DutyContent
{
class DcConfig
{
public static bool PluginEnable { get; set; }
public static string PluginPath { get; set; }
public static string DataPath { get; set; }
public static string PacketPath { get; set; }
public static string ConfigPath { get; set; }
//
public static PacketConfig Packet = new PacketConfig();
public static DutyConfig Duty = new DutyConfig();
//
public static ConnectionList Connections = new ConnectionList();
//
public static string Language { get; set; } = "";
//
public static void SaveConfig(string filename = null)
{
if (filename == null)
filename = ConfigPath;
using (var sw = new StreamWriter(filename, false, Encoding.UTF8))
{
sw.WriteLine("# DutyContent configuration: {0}", DateTime.Now.ToString());
sw.WriteLine();
sw.WriteLine("# config");
sw.WriteLine("Language={0}", Language);
sw.WriteLine();
Duty.InternalSaveStream(sw);
}
}
//
public static void LoadConfig(string filename = null)
{
if (filename == null)
filename = ConfigPath;
if (!File.Exists(filename))
SaveConfig(filename);
var db = new ThirdParty.LineDb(filename, Encoding.UTF8, false);
Language = db["Language"];
Duty.InternalReadFromDb(db);
}
//
public static void Load()
{
Packet.Load();
LoadConfig();
}
//
public static void ReadLanguage(bool is_in_init = false)
{
if (string.IsNullOrWhiteSpace(DcConfig.Language))
{
if (!is_in_init)
MesgLog.Initialize(Properties.Resources.DefaultMessage);
}
else
{
string filename = Path.Combine(DcConfig.DataPath, $"DcLang-{DcConfig.Language}.txt");
if (File.Exists(filename))
MesgLog.LoadFile(filename);
else
MesgLog.Initialize(Properties.Resources.DefaultMessage);
}
}
//
public class PacketConfig
{
// Packet
public string Version { get; set; } = "5.45 HotFix";
public ushort OpFate { get; set; } = 0x3D5;
public ushort OpDuty { get; set; } = 0x307;
public ushort OpMatch { get; set; } = 0x26E;
public ushort OpInstance { get; set; } = 0x10C;
public ushort OpSouthernBozja { get; set; } = 0x1F5;
//
public void Save(string filename = null)
{
if (filename == null)
filename = PacketPath;
using (var sw = new StreamWriter(filename, false, Encoding.UTF8))
{
sw.WriteLine("# DutyPacket configuration: {0}", DateTime.Now.ToString());
sw.WriteLine();
sw.WriteLine("# packet");
sw.WriteLine("Version={0}", Version);
sw.WriteLine("OpFate={0}", OpFate);
sw.WriteLine("OpDuty={0}", OpDuty);
sw.WriteLine("OpMatch={0}", OpMatch);
sw.WriteLine("OpInstance={0}", OpInstance);
sw.WriteLine("OpSouthernBozja={0}", OpSouthernBozja);
sw.WriteLine();
}
}
//
public void Load(string filename = null)
{
if (filename == null)
filename = PacketPath;
if (!File.Exists(filename))
Save(filename);
var db = new ThirdParty.LineDb(filename, Encoding.UTF8, false);
Version = db["Version"];
OpFate = ThirdParty.Converter.ToUshort(db["OpFate"], OpFate);
OpDuty = ThirdParty.Converter.ToUshort(db["OpDuty"], OpDuty);
OpMatch = ThirdParty.Converter.ToUshort(db["OpMatch"], OpMatch);
OpInstance = ThirdParty.Converter.ToUshort(db["OpInstance"], OpInstance);
OpSouthernBozja = ThirdParty.Converter.ToUshort(db["OpSouthernBozja"], OpSouthernBozja);
}
}
//
public class DutyConfig
{
public string Language { get; set; } = "English";
public int ActiveFate { get; set; } = 0;
public string LogFontFamily { get; set; } = "Microsoft Sans Serif";
public float LogFontSize { get; set; } = 12.0f;
public bool EnableOverlay { get; set; }
public bool EnableSound { get; set; }
public string SoundInstanceFile { get; set; }
public int SoundInstanceVolume { get; set; } = 100;
public string SoundFateFile { get; set; }
public int SoundFateVolume { get; set; } = 100;
public bool UseNotifyLine { get; set; }
public string NotifyLineToken { get; set; }
public bool UseNotifyTelegram { get; set; }
public string NotifyTelegramId { get; set; }
public string NotifyTelegramToken { get; set; }
public Point OverlayLocation { get; set; } = new Point(0, 0);
//
public bool EnableNotify => UseNotifyLine || UseNotifyTelegram;
//
public FateSelection[] Fates = new FateSelection[4]
{
new FateSelection(0),
new FateSelection(1),
new FateSelection(2),
new FateSelection(3),
};
//
internal void InternalSaveStream(StreamWriter sw)
{
sw.WriteLine("# duty");
sw.WriteLine("DutyLanguage={0}", Language);
sw.WriteLine("DutyActiveFate={0}", ActiveFate);
sw.WriteLine("DutyFate0={0}", Fates[0].Line);
sw.WriteLine("DutyFate1={0}", Fates[1].Line);
sw.WriteLine("DutyFate2={0}", Fates[2].Line);
sw.WriteLine("DutyFate3={0}", Fates[3].Line);
sw.WriteLine("DutyLogFontFamily={0}", LogFontFamily);
sw.WriteLine("DutyLogFontSize={0}", LogFontSize);
sw.WriteLine("DutyEnableOverlay={0}", EnableOverlay);
sw.WriteLine("DutyEnableSound={0}", EnableSound);
sw.WriteLine("DutySoundInstanceFile={0}", SoundInstanceFile);
sw.WriteLine("DutySoundInstanceVolume={0}", SoundInstanceVolume);
sw.WriteLine("DutySoundFateFile={0}", SoundFateFile);
sw.WriteLine("DutySoundFateVolume={0}", SoundFateVolume);
sw.WriteLine("DutyUseNotifyLine={0}", UseNotifyLine);
sw.WriteLine("DutyNotifyLineToken={0}", NotifyLineToken);
sw.WriteLine("DutyUseNotifyTelegram={0}", UseNotifyTelegram);
sw.WriteLine("DutyNotifyTelegramId={0}", NotifyTelegramId);
sw.WriteLine("DutyNotifyTelegramToken={0}", NotifyTelegramToken);
sw.WriteLine("DutyOverlayLocationX={0}", OverlayLocation.X);
sw.WriteLine("DutyOverlayLocationY={0}", OverlayLocation.Y);
sw.WriteLine();
}
//
internal void InternalReadFromDb(ThirdParty.LineDb db)
{
Language = db["DutyLanguage"];
ActiveFate = ThirdParty.Converter.ToInt(db["DutyActiveFate"]);
Fates[0].Line = db["DutyFate0"];
Fates[1].Line = db["DutyFate1"];
Fates[2].Line = db["DutyFate2"];
Fates[3].Line = db["DutyFate3"];
LogFontFamily = db["DutyLogFontFamily"];
LogFontSize = ThirdParty.Converter.ToFloat(db["DutyLogFontSize"], LogFontSize);
EnableOverlay = ThirdParty.Converter.ToBool(db["DutyEnableOverlay"]);
EnableSound = ThirdParty.Converter.ToBool(db["DutyEnableSound"]);
SoundInstanceFile = db["DutySoundInstanceFile"];
SoundFateFile = db["DutySoundFateFile"];
SoundInstanceVolume = ThirdParty.Converter.ToInt(db["DutySoundInstanceVolume"], 100);
SoundFateVolume = ThirdParty.Converter.ToInt(db["DutySoundFateVolume"], 100);
UseNotifyLine = ThirdParty.Converter.ToBool(db["DutyUseNotifyLine"]);
NotifyLineToken = db["DutyNotifyLineToken"];
UseNotifyTelegram = ThirdParty.Converter.ToBool(db["DutyUseNotifyTelegram"]);
NotifyTelegramId = db["DutyNotifyTelegramId"];
NotifyTelegramToken = db["DutyNotifyTelegramToken"];
OverlayLocation = new Point(ThirdParty.Converter.ToInt(db["DutyOverlayLocationX"]), ThirdParty.Converter.ToInt(db["DutyOverlayLocationY"]));
}
}
//
public class FateSelection
{
public HashSet<int> Selected { get; } = new HashSet<int>();
public string Line { get; set; }
public int Index { get; set; }
public FateSelection(int index)
{
Index = index;
}
public void MakeSelects(bool clear = false)
{
if (clear)
Selected.Clear();
var ss = Line.Split('|');
foreach (var s in ss)
{
if (!string.IsNullOrWhiteSpace(s) && ThirdParty.Converter.TryInt(s, out int i))
Selected.Add(i);
}
}
public void MakeLine()
{
Line = string.Join("|", Selected);
}
}
//
public class ConnectionList
{
public List<ThirdParty.NativeMethods.TcpRow> Conns = new List<ThirdParty.NativeMethods.TcpRow>();
public void GetConnections(Process process)
{
Conns.Clear();
var size = 0;
var ret = ThirdParty.NativeMethods.GetExtendedTcpTable(IntPtr.Zero, ref size, true, AddressFamily.InterNetwork, 4);
var buff = Marshal.AllocHGlobal(size);
try
{
ret = ThirdParty.NativeMethods.GetExtendedTcpTable(buff, ref size, true, AddressFamily.InterNetwork, 4);
if (ret == 0)
{
var tbl = Marshal.PtrToStructure<ThirdParty.NativeMethods.TcpTable>(buff);
var ptr = (IntPtr)((long)buff + Marshal.SizeOf(tbl.entries));
for (var i = 0; i < tbl.entries; i++)
{
var row = Marshal.PtrToStructure<ThirdParty.NativeMethods.TcpRow>(ptr);
if (!IPAddress.IsLoopback(row.RemoteAddress) &&
process.Id == row.owningPid)
Conns.Add(row);
ptr = (IntPtr)((long)ptr + Marshal.SizeOf(row));
}
}
}
finally
{
if (buff != null)
Marshal.FreeHGlobal(buff);
}
}
}
}
}

244
DcContent.cs Normal file
View file

@ -0,0 +1,244 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace DutyContent
{
public class DcContent
{
// roulette
public class Roulette
{
public string Name { get; set; }
public static explicit operator Roulette(string name)
{
return new Roulette { Name = name };
}
}
// instance
public class Instance
{
public string Name { get; set; }
public static explicit operator Instance(string name)
{
return new Instance { Name = name };
}
}
// area
public class Area
{
public string Name { get; set; }
public IReadOnlyDictionary<int, Fate> Fates { get; set; }
}
// fate
public class Fate
{
public Area Area { get; set; }
public string Name { get; set; }
public static explicit operator Fate(string name)
{
return new Fate { Name = name };
}
}
// group
public class Group
{
public string Version { get; set; }
public string Language { get; set; }
public Dictionary<int, Roulette> Roulettes { get; set; }
public Dictionary<int, Instance> Instances { get; set; }
public Dictionary<int, Area> Areas { get; set; }
}
//
public static string Version { get; private set; }
public static string Language { get; private set; }
public static IReadOnlyDictionary<int, Roulette> Roulettes { get; private set; } = new Dictionary<int, Roulette>();
public static IReadOnlyDictionary<int, Instance> Instances { get; private set; } = new Dictionary<int, Instance>();
public static IReadOnlyDictionary<int, Area> Areas { get; private set; } = new Dictionary<int, Area>();
public static IReadOnlyDictionary<int, Fate> Fates { get; private set; } = new Dictionary<int, Fate>();
public static Dictionary<int, int> Missions { get; private set; } = new Dictionary<int, int>();
//
public static bool Initialize(string json)
{
if (string.IsNullOrWhiteSpace(json))
return false;
bool ret;
try
{
ret = Fill(json);
}
catch
{
ret = false;
}
return ret;
}
// parse json
private static bool Fill(string json)
{
Group data = JsonConvert.DeserializeObject<Group>(json);
Dictionary<int, Fate> fates = new Dictionary<int, Fate>();
foreach (var area in data.Areas)
{
foreach (var fate in area.Value.Fates)
{
try
{
fate.Value.Area = area.Value;
fates.Add(fate.Key, fate.Value);
}
catch (NullReferenceException /*nex*/)
{
MesgLog.E(7, fate.Key);
return false;
}
catch (Exception ex)
{
MesgLog.Ex(ex, 8);
return false;
}
}
}
Version = data.Version;
Language = data.Language;
Roulettes = data.Roulettes;
Instances = data.Instances;
Areas = data.Areas;
Fates = fates;
return true;
}
//
public static Roulette TryRoulette(int code)
{
return Roulettes.TryGetValue(code, out Roulette roulette) ? roulette : null;
}
//
public static Instance TryInstance(int code)
{
return Instances.TryGetValue(code, out Instance instance) ? instance : null;
}
//
public static Area TryArea(int code)
{
return Areas.TryGetValue(code, out Area area) ? area : null;
}
//
public static Fate TryFate(int code)
{
return Fates.ContainsKey(code) ? Fates[code] : null;
}
//
public static Roulette GetRoulette(int code)
{
return Roulettes.TryGetValue(code, out Roulette roulette) ? roulette :
new Roulette { Name = MesgLog.Text(9, code) };
}
//
public static Instance GetInstance(int code)
{
return Instances.TryGetValue(code, out Instance instance) ? instance :
new Instance { Name = MesgLog.Text(10, code) };
}
//
public static Area GetArea(int code)
{
return Areas.TryGetValue(code, out Area area) ? area :
new Area { Name = MesgLog.Text(11, code) };
}
//
public static Fate GetFate(int code)
{
return Fates.ContainsKey(code) ? Fates[code] :
new Fate { Name = MesgLog.Text(12, code) };
}
//
public static bool ReadContent(string language = null)
{
if (language == null)
language = DcConfig.Duty.Language;
else if (!DcConfig.Duty.Language.Equals(language))
DcConfig.Duty.Language = language;
string filename = Path.Combine(DcConfig.DataPath, $"DcDuty-{language}.json");
if (!File.Exists(filename))
{
language = "English";
filename = Path.Combine(DcConfig.DataPath, $"DcDuty-{language}.json");
if (!File.Exists(filename))
{
MesgLog.E(14, filename);
return false;
}
if (!DcConfig.Duty.Language.Equals(language))
DcConfig.Duty.Language = language;
}
string json = File.ReadAllText(filename, Encoding.UTF8);
if (!Initialize(json))
{
MesgLog.E(13);
return false;
}
else
{
MesgLog.I(20,
Language,
Version,
Areas.Count,
Roulettes.Count,
Instances.Count,
Fates.Count,
filename);
return true;
}
}
public static string CeStatusToString(int s)
{
// 10[1] status 0=end, 1=wait, 2=??, 3=progress
switch (s)
{
case 0: return MesgLog.Text(10017);
case 1: return MesgLog.Text(10018);
case 2: return MesgLog.Text(10019);
case 3: return MesgLog.Text(10020);
default: return MesgLog.Text(10021);
}
}
}
}

148
DcControl.Designer.cs generated Normal file
View file

@ -0,0 +1,148 @@

namespace DutyContent
{
partial class DcControl
{
/// <summary>
/// 필수 디자이너 변수입니다.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 사용 중인 모든 리소스를 정리합니다.
/// </summary>
/// <param name="disposing">관리되는 리소스를 삭제해야 하면 true이고, 그렇지 않으면 false입니다.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region
/// <summary>
/// 디자이너 지원에 필요한 메서드입니다.
/// 이 메서드의 내용을 코드 편집기로 수정하지 마세요.
/// </summary>
private void InitializeComponent()
{
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.tabMain = new System.Windows.Forms.TabControl();
this.tabPageDuty = new System.Windows.Forms.TabPage();
this.tabPageConfig = new System.Windows.Forms.TabPage();
this.txtMesg = new System.Windows.Forms.RichTextBox();
this.btnClearMesg = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.tabMain.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.tabMain);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.txtMesg);
this.splitContainer1.Panel2.Controls.Add(this.btnClearMesg);
this.splitContainer1.Size = new System.Drawing.Size(792, 567);
this.splitContainer1.SplitterDistance = 497;
this.splitContainer1.TabIndex = 0;
//
// tabMain
//
this.tabMain.Alignment = System.Windows.Forms.TabAlignment.Left;
this.tabMain.Controls.Add(this.tabPageDuty);
this.tabMain.Controls.Add(this.tabPageConfig);
this.tabMain.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabMain.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;
this.tabMain.ItemSize = new System.Drawing.Size(30, 100);
this.tabMain.Location = new System.Drawing.Point(0, 0);
this.tabMain.Multiline = true;
this.tabMain.Name = "tabMain";
this.tabMain.SelectedIndex = 0;
this.tabMain.Size = new System.Drawing.Size(792, 497);
this.tabMain.SizeMode = System.Windows.Forms.TabSizeMode.Fixed;
this.tabMain.TabIndex = 0;
this.tabMain.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.TabMain_DrawItem);
//
// tabPageDuty
//
this.tabPageDuty.BackColor = System.Drawing.Color.Transparent;
this.tabPageDuty.Location = new System.Drawing.Point(104, 4);
this.tabPageDuty.Name = "tabPageDuty";
this.tabPageDuty.Padding = new System.Windows.Forms.Padding(3);
this.tabPageDuty.Size = new System.Drawing.Size(684, 489);
this.tabPageDuty.TabIndex = 0;
this.tabPageDuty.Text = "Duty";
//
// tabPageConfig
//
this.tabPageConfig.Location = new System.Drawing.Point(104, 4);
this.tabPageConfig.Name = "tabPageConfig";
this.tabPageConfig.Padding = new System.Windows.Forms.Padding(3);
this.tabPageConfig.Size = new System.Drawing.Size(684, 489);
this.tabPageConfig.TabIndex = 1;
this.tabPageConfig.Text = "Config";
this.tabPageConfig.UseVisualStyleBackColor = true;
//
// txtMesg
//
this.txtMesg.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtMesg.Location = new System.Drawing.Point(104, 3);
this.txtMesg.Name = "txtMesg";
this.txtMesg.ReadOnly = true;
this.txtMesg.ScrollBars = System.Windows.Forms.RichTextBoxScrollBars.Vertical;
this.txtMesg.Size = new System.Drawing.Size(685, 60);
this.txtMesg.TabIndex = 1;
this.txtMesg.Text = "";
//
// btnClearMesg
//
this.btnClearMesg.Location = new System.Drawing.Point(3, 3);
this.btnClearMesg.Name = "btnClearMesg";
this.btnClearMesg.Size = new System.Drawing.Size(95, 33);
this.btnClearMesg.TabIndex = 0;
this.btnClearMesg.Text = "Clear Mesg";
this.btnClearMesg.UseVisualStyleBackColor = true;
//
// DcControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.splitContainer1);
this.Name = "DcControl";
this.Size = new System.Drawing.Size(792, 567);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.tabMain.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Button btnClearMesg;
private System.Windows.Forms.TabControl tabMain;
private System.Windows.Forms.TabPage tabPageDuty;
private System.Windows.Forms.TabPage tabPageConfig;
private System.Windows.Forms.RichTextBox txtMesg;
}
}

299
DcControl.cs Normal file
View file

@ -0,0 +1,299 @@
using Advanced_Combat_Tracker;
using System;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Windows.Forms;
namespace DutyContent
{
public partial class DcControl : UserControl, IActPluginV1
{
public static string PluginName => "DutyContent";
private static DcControl _self;
public static DcControl Self => _self;
//
private ActPluginData _ffxiv_plugin_data;
private bool _is_form_loaded;
private bool _is_plugin_initializing;
private TabPage _act_tab;
private Label _act_label;
private Timer _update_and_check;
private ThirdParty.NativeMethods.ProcessHandle _game_process;
private bool _game_exist;
private bool _game_active;
private string _game_zone;
//
public DcControl()
{
_self = this;
//
RegisterActAssemblies();
InitializeComponent();
foreach (var f in Application.OpenForms)
{
if (f == ActGlobals.oFormActMain)
{
_is_form_loaded = true;
break;
}
}
//
Tab.DutyForm dutyform = new Tab.DutyForm();
tabPageDuty.Controls.Add(dutyform.Controls[0]);
Tab.ConfigForm configform = new Tab.ConfigForm();
tabPageConfig.Controls.Add(configform.Controls[0]);
}
//
public void RegisterActAssemblies()
{
var pin = ActGlobals.oFormActMain.ActPlugins.FirstOrDefault(x => x.pluginFile.Name.Equals("DutyContent.dll"));
DcConfig.PluginPath = pin?.pluginFile.DirectoryName;
DcConfig.DataPath = Path.Combine(DcConfig.PluginPath, "Data");
DcConfig.ConfigPath = Path.Combine(DcConfig.PluginPath, "DutyContent.config");
DcConfig.PacketPath = Path.Combine(DcConfig.PluginPath, "DutyPacket.config");
}
//
public void InitPlugin(TabPage tab, Label label)
{
_act_tab = tab;
_act_label = label;
if (_is_form_loaded)
ActPluginInitialize();
else
ActGlobals.oFormActMain.Shown += OFormActMain_Shown;
var actinfo = System.Reflection.Assembly.GetAssembly(typeof(ActGlobals));
MesgLog.I(5, actinfo.GetName().Version, actinfo.Location);
if (_ffxiv_plugin_data == null)
{
_ffxiv_plugin_data = ActGlobals.oFormActMain.ActPlugins.Where(x =>
x.pluginFile.Name.ToUpper().Contains("FFXIV_ACT_PLUGIN") &&
x.lblPluginStatus.Text.ToUpper().Contains("FFXIV PLUGIN STARTED."))
.Select(x => x)
.FirstOrDefault();
}
if (_ffxiv_plugin_data == null)
MesgLog.E(2); // FFXIV plugin is missing!
else
{
var ids = ((FFXIV_ACT_Plugin.FFXIV_ACT_Plugin)_ffxiv_plugin_data.pluginObj).DataSubscription;
ids.NetworkReceived -= FFXIVPlugin_NetworkReceived;
ids.NetworkReceived += FFXIVPlugin_NetworkReceived;
ids.ZoneChanged -= FFXIVPlugin_ZoneChanged;
ids.ZoneChanged += FFXIVPlugin_ZoneChanged;
MesgLog.I(6, System.Diagnostics.FileVersionInfo.GetVersionInfo(_ffxiv_plugin_data.pluginFile.FullName).FileVersion, _ffxiv_plugin_data.pluginFile.FullName);
}
_update_and_check = new Timer()
{
Interval = 300,
};
_update_and_check.Tick += (sender, e) =>
{
UpdateAndCheckProc();
_update_and_check.Interval = _game_exist ? _game_active ? 50 : 300 : 500;
};
_update_and_check.Start();
}
//
public void DeInitPlugin()
{
_update_and_check.Stop();
DcConfig.PluginEnable = false;
Tab.DutyForm.Self?.PluginDeinitialize();
Tab.ConfigForm.Self?.PluginDeinitialize();
DcConfig.SaveConfig();
MesgLog.SetTextBox(null);
_act_tab = null;
if (_act_label != null)
{
_act_label.Text = "Closed";
_act_label = null;
}
}
private void OFormActMain_Shown(object sender, EventArgs e)
{
_is_form_loaded = true;
ActPluginInitialize();
}
//
private void ActPluginInitialize()
{
if (_is_plugin_initializing)
return;
_is_plugin_initializing = true;
_act_label.Text = "Starting...";
//
MesgLog.SetTextBox(txtMesg);
MesgLog.Initialize(Properties.Resources.DefaultMessage);
DcConfig.Load();
DcConfig.ReadLanguage(true);
DcContent.ReadContent();
UpdateUiLocale();
MesgLog.C(Color.Aquamarine, 4);
//
Dock = DockStyle.Fill;
_act_label.Text = MesgLog.Text(1); // Duty ready
_act_tab.Text = MesgLog.Text(0); // FFXIV dc
_act_tab.Controls.Add(this);
//
Tab.ConfigForm.Self?.PluginInitialize();
Tab.DutyForm.Self?.PluginInitialize();
//
DcConfig.PluginEnable = true;
_is_plugin_initializing = false;
}
//
private void TabMain_DrawItem(object sender, DrawItemEventArgs e)
{
var g = e.Graphics;
TabPage p = tabMain.TabPages[e.Index];
Rectangle r = tabMain.GetTabRect(e.Index);
StringFormat s = new StringFormat()
{
Alignment = StringAlignment.Near,
LineAlignment = StringAlignment.Center,
};
Brush b, h;
Font f;
if (tabMain.SelectedIndex == e.Index)
{
f = new Font(tabMain.Font.FontFamily, 12.0f, FontStyle.Bold, GraphicsUnit.Pixel);
#if false
b = new SolidBrush(Color.Black);
h = SystemBrushes.Window;
#else
b = new SolidBrush(Color.White);
h = SystemBrushes.Highlight;
#endif
}
//else if (p.col)
else
{
f = new Font(tabMain.Font.FontFamily, 12.0f, FontStyle.Regular, GraphicsUnit.Pixel);
b = new SolidBrush(Color.DarkSlateGray);
h = SystemBrushes.Control;
}
g.FillRectangle(h, r);
g.DrawString(p.Text, f, b, r, new StringFormat(s));
}
//
private void UpdateAndCheckProc()
{
if (_game_process == null || _game_process.Process.HasExited)
{
_game_exist = false;
_game_active = false;
// will be update game status next time
var p = (from x in Process.GetProcessesByName("ffxiv_dx11") where !x.HasExited && x.MainModule != null && x.MainModule.ModuleName == "ffxiv_dx11.exe" select x).FirstOrDefault<Process>();
if (p != null && p.HasExited)
p = null;
if (((_game_process == null) != (p == null)) ||
(_game_process != null && p != null && _game_process.Process.Id != p.Id))
{
_game_process = p != null ? new ThirdParty.NativeMethods.ProcessHandle(p) : null;
}
if (_game_process != null)
{
//
DcConfig.Connections.GetConnections(_game_process.Process);
//MesgLog.L("count: {0}", DcConfig.Connections.Conns.Count);
}
}
else
{
_game_exist = true;
var fgw = ThirdParty.NativeMethods.GetForegroundWindow();
ThirdParty.NativeMethods.GetWindowThreadProcessId(fgw, out int id);
_game_active = _game_process.Process.Id == id;
}
var zone = ActGlobals.oFormActMain.CurrentZone;
if (_game_zone == null || !zone.Equals(_game_zone))
{
#if false
if (_game_zone != null)
MesgLog.I(1008, _game_zone);
_game_zone = zone;
MesgLog.I(1007, zone);
#else
_game_zone = zone;
#endif
}
}
//
private void FFXIVPlugin_NetworkReceived(string connection, long epoch, byte[] message)
{
if (message.Length < 32)
return;
Tab.DutyForm.Self?.PacketHandler(connection, message);
}
//
private void FFXIVPlugin_ZoneChanged(uint zone_id, string zone_name)
{
Tab.DutyForm.Self?.ZoneChanged(zone_id, zone_name);
}
//
public void UpdateUiLocale()
{
tabPageDuty.Text = MesgLog.Text(300);
Tab.DutyForm.Self?.UpdateUiLocale();
tabPageConfig.Text= MesgLog.Text(200);
Tab.ConfigForm.Self?.UpdateUiLocale();
}
}
}

120
DcControl.resx Normal file