chore: initial commit

This commit is contained in:
Anna 2021-12-29 14:31:45 -05:00
commit f17a913405
29 changed files with 2677 additions and 0 deletions

365
.gitignore vendored Normal file
View File

@ -0,0 +1,365 @@
## 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
# Packaging
pack/
# User-specific files
*.rsuser
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Mono auto generated files
mono_crash.*
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
[Ww][Ii][Nn]32/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
# 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
nunit-*.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/
# ASP.NET Scaffolding
ScaffoldingReadMe.txt
# 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
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# AxoCover is a Code Coverage Tool
.axoCover/*
!.axoCover/settings.json
# Coverlet is a free, cross platform Code Coverage Tool
coverage*.json
coverage*.xml
coverage*.info
# 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
# NuGet Symbol Packages
*.snupkg
# 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
*.appxbundle
*.appxupload
# 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
*- [Bb]ackup.rdl
*- [Bb]ackup ([0-9]).rdl
*- [Bb]ackup ([0-9][0-9]).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/
# 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
# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
# Ionide (cross platform F# VS Code tools) working folder
.ionide/
# Fody - auto-generated XML schema
FodyWeavers.xsd

16
ChatTwo.sln Executable file
View File

@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChatTwo", "ChatTwo\ChatTwo.csproj", "{739F75E6-B65F-41EF-9D90-F7BC519E4875}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{739F75E6-B65F-41EF-9D90-F7BC519E4875}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{739F75E6-B65F-41EF-9D90-F7BC519E4875}.Debug|Any CPU.Build.0 = Debug|Any CPU
{739F75E6-B65F-41EF-9D90-F7BC519E4875}.Release|Any CPU.ActiveCfg = Release|Any CPU
{739F75E6-B65F-41EF-9D90-F7BC519E4875}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

59
ChatTwo/ChatTwo.csproj Executable file
View File

@ -0,0 +1,59 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.0.0</Version>
<TargetFramework>net5.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<PropertyGroup>
<Dalamud>$(AppData)\XIVLauncher\addon\Hooks\dev</Dalamud>
</PropertyGroup>
<PropertyGroup Condition="'$(IsCI)' == 'true'">
<Dalamud>$(HOME)/dalamud</Dalamud>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dalamud">
<HintPath>$(Dalamud)\Dalamud.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="FFXIVClientStructs">
<HintPath>$(Dalamud)\FFXIVClientStructs.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="ImGui.NET">
<HintPath>$(Dalamud)\ImGui.NET.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="ImGuiScene">
<HintPath>$(Dalamud)\ImGuiScene.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Lumina">
<HintPath>$(Dalamud)\Lumina.dll</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="Lumina.Excel">
<HintPath>$(Dalamud)\Lumina.Excel.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="XivCommon" Version="4.0.0-alpha.2" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="fonts\NotoSans-Italic.ttf" />
<EmbeddedResource Include="fonts\NotoSans-Regular.ttf" />
<EmbeddedResource Include="fonts\NotoSansJP-Regular.otf" />
</ItemGroup>
</Project>

35
ChatTwo/Chunk.cs Executable file
View File

@ -0,0 +1,35 @@
using ChatTwo.Code;
using Dalamud.Game.Text.SeStringHandling;
namespace ChatTwo;
internal abstract class Chunk {
}
internal class TextChunk : Chunk {
internal ChatType? FallbackColour { get; set; }
internal uint? Foreground { get; set; }
internal uint? Glow { get; set; }
internal bool Italic { get; set; }
internal string Content { get; set; }
internal TextChunk(string content) {
this.Content = content;
}
internal TextChunk(ChatType? fallbackColour, uint? foreground, uint? glow, bool italic, string content) {
this.FallbackColour = fallbackColour;
this.Foreground = foreground;
this.Glow = glow;
this.Italic = italic;
this.Content = content;
}
}
internal class IconChunk : Chunk {
internal BitmapFontIcon Icon;
public IconChunk(BitmapFontIcon icon) {
this.Icon = icon;
}
}

91
ChatTwo/Code/ChatCode.cs Executable file
View File

@ -0,0 +1,91 @@
namespace ChatTwo.Code;
internal class ChatCode {
private const ushort Clear7 = ~(~0 << 7);
internal ushort Raw { get; }
internal ChatType Type => (ChatType) (this.Raw & Clear7);
internal ChatSource Source => this.SourceFrom(11);
internal ChatSource Target => this.SourceFrom(7);
private ChatSource SourceFrom(ushort shift) => (ChatSource) (1 << ((this.Raw >> shift) & 0xF));
internal ChatCode(ushort raw) {
this.Raw = raw;
}
internal ChatType Parent() => this.Type switch {
ChatType.Say => ChatType.Say,
ChatType.GmSay => ChatType.Say,
ChatType.Shout => ChatType.Shout,
ChatType.GmShout => ChatType.Shout,
ChatType.TellOutgoing => ChatType.TellOutgoing,
ChatType.TellIncoming => ChatType.TellOutgoing,
ChatType.GmTell => ChatType.TellOutgoing,
ChatType.Party => ChatType.Party,
ChatType.CrossParty => ChatType.Party,
ChatType.GmParty => ChatType.Party,
ChatType.Linkshell1 => ChatType.Linkshell1,
ChatType.GmLinkshell1 => ChatType.Linkshell1,
ChatType.Linkshell2 => ChatType.Linkshell2,
ChatType.GmLinkshell2 => ChatType.Linkshell2,
ChatType.Linkshell3 => ChatType.Linkshell3,
ChatType.GmLinkshell3 => ChatType.Linkshell3,
ChatType.Linkshell4 => ChatType.Linkshell4,
ChatType.GmLinkshell4 => ChatType.Linkshell4,
ChatType.Linkshell5 => ChatType.Linkshell5,
ChatType.GmLinkshell5 => ChatType.Linkshell5,
ChatType.Linkshell6 => ChatType.Linkshell6,
ChatType.GmLinkshell6 => ChatType.Linkshell6,
ChatType.Linkshell7 => ChatType.Linkshell7,
ChatType.GmLinkshell7 => ChatType.Linkshell7,
ChatType.Linkshell8 => ChatType.Linkshell8,
ChatType.GmLinkshell8 => ChatType.Linkshell8,
ChatType.FreeCompany => ChatType.FreeCompany,
ChatType.GmFreeCompany => ChatType.FreeCompany,
ChatType.NoviceNetwork => ChatType.NoviceNetwork,
ChatType.GmNoviceNetwork => ChatType.NoviceNetwork,
ChatType.CustomEmote => ChatType.CustomEmote,
ChatType.StandardEmote => ChatType.StandardEmote,
ChatType.Yell => ChatType.Yell,
ChatType.GmYell => ChatType.Yell,
ChatType.GainBuff => ChatType.GainBuff,
ChatType.LoseBuff => ChatType.GainBuff,
ChatType.GainDebuff => ChatType.GainDebuff,
ChatType.LoseDebuff => ChatType.GainDebuff,
ChatType.System => ChatType.System,
ChatType.Alarm => ChatType.System,
ChatType.RetainerSale => ChatType.System,
ChatType.PeriodicRecruitmentNotification => ChatType.System,
ChatType.Sign => ChatType.System,
ChatType.Orchestrion => ChatType.System,
ChatType.MessageBook => ChatType.System,
ChatType.NpcDialogue => ChatType.NpcDialogue,
ChatType.NpcAnnouncement => ChatType.NpcDialogue,
ChatType.LootRoll => ChatType.LootRoll,
ChatType.RandomNumber => ChatType.LootRoll,
ChatType.FreeCompanyAnnouncement => ChatType.FreeCompanyAnnouncement,
ChatType.FreeCompanyLoginLogout => ChatType.FreeCompanyAnnouncement,
ChatType.PvpTeamAnnouncement => ChatType.PvpTeamAnnouncement,
ChatType.PvpTeamLoginLogout => ChatType.PvpTeamAnnouncement,
_ => this.Type,
};
internal bool IsBattle() {
switch (this.Type) {
case ChatType.Damage:
case ChatType.Miss:
case ChatType.Action:
case ChatType.Item:
case ChatType.Healing:
case ChatType.GainBuff:
case ChatType.LoseBuff:
case ChatType.GainDebuff:
case ChatType.LoseDebuff:
case ChatType.BattleSystem:
return true;
default:
return false;
}
}
}

17
ChatTwo/Code/ChatSource.cs Executable file
View File

@ -0,0 +1,17 @@
namespace ChatTwo.Code;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1028:Enum Storage should be Int32")]
[Flags]
internal enum ChatSource : ushort {
Self = 2,
PartyMember = 4,
AllianceMember = 8,
Other = 16,
EngagedEnemy = 32,
UnengagedEnemy = 64,
FriendlyNpc = 128,
SelfPet = 256,
PartyPet = 512,
AlliancePet = 1024,
OtherPet = 2048,
}

16
ChatTwo/Code/ChatSourceExt.cs Executable file
View File

@ -0,0 +1,16 @@
namespace ChatTwo.Code;
internal static class ChatSourceExt {
internal const ChatSource All =
ChatSource.Self
| ChatSource.PartyMember
| ChatSource.AllianceMember
| ChatSource.Other
| ChatSource.EngagedEnemy
| ChatSource.UnengagedEnemy
| ChatSource.FriendlyNpc
| ChatSource.SelfPet
| ChatSource.PartyPet
| ChatSource.AlliancePet
| ChatSource.OtherPet;
}

87
ChatTwo/Code/ChatType.cs Executable file
View File

@ -0,0 +1,87 @@
namespace ChatTwo.Code;
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1028:Enum Storage should be Int32")]
internal enum ChatType : ushort {
Debug = 1,
Urgent = 2,
Notice = 3,
Say = 10,
Shout = 11,
TellOutgoing = 12,
TellIncoming = 13,
Party = 14,
Alliance = 15,
Linkshell1 = 16,
Linkshell2 = 17,
Linkshell3 = 18,
Linkshell4 = 19,
Linkshell5 = 20,
Linkshell6 = 21,
Linkshell7 = 22,
Linkshell8 = 23,
FreeCompany = 24,
NoviceNetwork = 27,
CustomEmote = 28,
StandardEmote = 29,
Yell = 30,
// 31 - also party?
CrossParty = 32,
PvpTeam = 36,
CrossLinkshell1 = 37,
Damage = 41,
Miss = 42,
Action = 43,
Item = 44,
Healing = 45,
GainBuff = 46,
GainDebuff = 47,
LoseBuff = 48,
LoseDebuff = 49,
Alarm = 55,
Echo = 56,
System = 57,
BattleSystem = 58,
GatheringSystem = 59,
Error = 60,
NpcDialogue = 61,
LootNotice = 62,
Progress = 64,
LootRoll = 65,
Crafting = 66,
Gathering = 67,
NpcAnnouncement = 68,
FreeCompanyAnnouncement = 69,
FreeCompanyLoginLogout = 70,
RetainerSale = 71,
PeriodicRecruitmentNotification = 72,
Sign = 73,
RandomNumber = 74,
NoviceNetworkSystem = 75,
Orchestrion = 76,
PvpTeamAnnouncement = 77,
PvpTeamLoginLogout = 78,
MessageBook = 79,
GmTell = 80,
GmSay = 81,
GmShout = 82,
GmYell = 83,
GmParty = 84,
GmFreeCompany = 85,
GmLinkshell1 = 86,
GmLinkshell2 = 87,
GmLinkshell3 = 88,
GmLinkshell4 = 89,
GmLinkshell5 = 90,
GmLinkshell6 = 91,
GmLinkshell7 = 92,
GmLinkshell8 = 93,
GmNoviceNetwork = 94,
CrossLinkshell2 = 101,
CrossLinkshell3 = 102,
CrossLinkshell4 = 103,
CrossLinkshell5 = 104,
CrossLinkshell6 = 105,
CrossLinkshell7 = 106,
CrossLinkshell8 = 107,
}

209
ChatTwo/Code/ChatTypeExt.cs Executable file
View File

@ -0,0 +1,209 @@
using ChatTwo.Util;
namespace ChatTwo.Code;
internal static class ChatTypeExt {
internal static string? Name(this ChatType type) {
return type switch {
ChatType.Debug => "Debug",
ChatType.Urgent => "Urgent",
ChatType.Notice => "Notice",
ChatType.Say => "Say",
ChatType.Shout => "Shout",
ChatType.TellOutgoing => "Tell (Outgoing)",
ChatType.TellIncoming => "Tell (Incoming)",
ChatType.Party => "Party",
ChatType.Alliance => "Alliance",
ChatType.Linkshell1 => "Linkshell [1]",
ChatType.Linkshell2 => "Linkshell [2]",
ChatType.Linkshell3 => "Linkshell [3]",
ChatType.Linkshell4 => "Linkshell [4]",
ChatType.Linkshell5 => "Linkshell [5]",
ChatType.Linkshell6 => "Linkshell [6]",
ChatType.Linkshell7 => "Linkshell [7]",
ChatType.Linkshell8 => "Linkshell [8]",
ChatType.FreeCompany => "Free Company",
ChatType.NoviceNetwork => "Novice Network",
ChatType.CustomEmote => "Custom Emotes",
ChatType.StandardEmote => "Standard Emotes",
ChatType.Yell => "Yell",
ChatType.CrossParty => "Cross-world Party",
ChatType.PvpTeam => "PvP Team",
ChatType.CrossLinkshell1 => "Cross-world Linkshell [1]",
ChatType.Damage => "Damage dealt",
ChatType.Miss => "Failed attacks",
ChatType.Action => "Actions used",
ChatType.Item => "Items used",
ChatType.Healing => "Healing",
ChatType.GainBuff => "Beneficial effects granted",
ChatType.GainDebuff => "Detrimental effects inflicted",
ChatType.LoseBuff => "Beneficial effects lost",
ChatType.LoseDebuff => "Detrimental effects cured",
ChatType.Alarm => "Alarm Notifications",
ChatType.Echo => "Echo",
ChatType.System => "System Messages",
ChatType.BattleSystem => "Battle System Messages",
ChatType.GatheringSystem => "Gathering System Messages",
ChatType.Error => "Error Messages",
ChatType.NpcDialogue => "NPC Dialogue",
ChatType.LootNotice => "Loot Notices",
ChatType.Progress => "Progression Messages",
ChatType.LootRoll => "Loot Messages",
ChatType.Crafting => "Synthesis Messages",
ChatType.Gathering => "Gathering Messages",
ChatType.NpcAnnouncement => "NPC Dialogue (Announcements)",
ChatType.FreeCompanyAnnouncement => "Free Company Announcements",
ChatType.FreeCompanyLoginLogout => "Free Company Member Login Notifications",
ChatType.RetainerSale => "Retainer Sale Notifications",
ChatType.PeriodicRecruitmentNotification => "Periodic Recruitment Notifications",
ChatType.Sign => "Sign Messages for PC Targets",
ChatType.RandomNumber => "Random Number Messages",
ChatType.NoviceNetworkSystem => "Novice Network Notifications",
ChatType.Orchestrion => "Current Orchestrion Track Messages",
ChatType.PvpTeamAnnouncement => "PvP Team Announcements",
ChatType.PvpTeamLoginLogout => "PvP Team Member Login Notifications",
ChatType.MessageBook => "Message Book Alert",
ChatType.GmTell => "Tell (GM)",
ChatType.GmSay => "Say (GM)",
ChatType.GmShout => "Shout (GM)",
ChatType.GmYell => "Yell (GM)",
ChatType.GmParty => "Party (GM)",
ChatType.GmFreeCompany => "Free Company (GM)",
ChatType.GmLinkshell1 => "Linkshell [1] (GM)",
ChatType.GmLinkshell2 => "Linkshell [2] (GM)",
ChatType.GmLinkshell3 => "Linkshell [3] (GM)",
ChatType.GmLinkshell4 => "Linkshell [4] (GM)",
ChatType.GmLinkshell5 => "Linkshell [5] (GM)",
ChatType.GmLinkshell6 => "Linkshell [6] (GM)",
ChatType.GmLinkshell7 => "Linkshell [7] (GM)",
ChatType.GmLinkshell8 => "Linkshell [8] (GM)",
ChatType.GmNoviceNetwork => "Novice Network (GM)",
ChatType.CrossLinkshell2 => "Cross-world Linkshell [2]",
ChatType.CrossLinkshell3 => "Cross-world Linkshell [3]",
ChatType.CrossLinkshell4 => "Cross-world Linkshell [4]",
ChatType.CrossLinkshell5 => "Cross-world Linkshell [5]",
ChatType.CrossLinkshell6 => "Cross-world Linkshell [6]",
ChatType.CrossLinkshell7 => "Cross-world Linkshell [7]",
ChatType.CrossLinkshell8 => "Cross-world Linkshell [8]",
_ => type.ToString(),
};
}
internal static uint? DefaultColour(this ChatType type) {
switch (type) {
case ChatType.Debug:
return ColourUtil.ComponentsToRgba(204, 204, 204);
case ChatType.Urgent:
return ColourUtil.ComponentsToRgba(255, 127, 127);
case ChatType.Notice:
return ColourUtil.ComponentsToRgba(179, 140, 255);
case ChatType.Say:
case ChatType.GmSay:
return ColourUtil.ComponentsToRgba(247, 247, 247);
case ChatType.Shout:
case ChatType.GmShout:
return ColourUtil.ComponentsToRgba(255, 166, 102);
case ChatType.TellIncoming:
case ChatType.TellOutgoing:
case ChatType.GmTell:
return ColourUtil.ComponentsToRgba(255, 184, 222);
case ChatType.Party:
case ChatType.CrossParty:
case ChatType.GmParty:
return ColourUtil.ComponentsToRgba(102, 229, 255);
case ChatType.Alliance:
return ColourUtil.ComponentsToRgba(255, 127, 0);
case ChatType.NoviceNetwork:
case ChatType.NoviceNetworkSystem:
case ChatType.GmNoviceNetwork:
return ColourUtil.ComponentsToRgba(212, 255, 125);
case ChatType.Linkshell1:
case ChatType.Linkshell2:
case ChatType.Linkshell3:
case ChatType.Linkshell4:
case ChatType.Linkshell5:
case ChatType.Linkshell6:
case ChatType.Linkshell7:
case ChatType.Linkshell8:
case ChatType.CrossLinkshell1:
case ChatType.CrossLinkshell2:
case ChatType.CrossLinkshell3:
case ChatType.CrossLinkshell4:
case ChatType.CrossLinkshell5:
case ChatType.CrossLinkshell6:
case ChatType.CrossLinkshell7:
case ChatType.CrossLinkshell8:
case ChatType.GmLinkshell1:
case ChatType.GmLinkshell2:
case ChatType.GmLinkshell3:
case ChatType.GmLinkshell4:
case ChatType.GmLinkshell5:
case ChatType.GmLinkshell6:
case ChatType.GmLinkshell7:
case ChatType.GmLinkshell8:
return ColourUtil.ComponentsToRgba(212, 255, 125);
case ChatType.StandardEmote:
return ColourUtil.ComponentsToRgba(186, 255, 240);
case ChatType.CustomEmote:
return ColourUtil.ComponentsToRgba(186, 255, 240);
case ChatType.Yell:
case ChatType.GmYell:
return ColourUtil.ComponentsToRgba(255, 255, 0);
case ChatType.Echo:
return ColourUtil.ComponentsToRgba(204, 204, 204);
case ChatType.System:
case ChatType.GatheringSystem:
case ChatType.PeriodicRecruitmentNotification:
case ChatType.Orchestrion:
case ChatType.Alarm:
case ChatType.RetainerSale:
case ChatType.Sign:
case ChatType.MessageBook:
return ColourUtil.ComponentsToRgba(204, 204, 204);
case ChatType.NpcAnnouncement:
case ChatType.NpcDialogue:
return ColourUtil.ComponentsToRgba(171, 214, 71);
case ChatType.Error:
return ColourUtil.ComponentsToRgba(255, 74, 74);
case ChatType.FreeCompany:
case ChatType.FreeCompanyAnnouncement:
case ChatType.FreeCompanyLoginLogout:
case ChatType.GmFreeCompany:
return ColourUtil.ComponentsToRgba(171, 219, 229);
case ChatType.PvpTeam:
return ColourUtil.ComponentsToRgba(171, 219, 229);
case ChatType.PvpTeamAnnouncement:
case ChatType.PvpTeamLoginLogout:
return ColourUtil.ComponentsToRgba(171, 219, 229);
case ChatType.Action:
case ChatType.Item:
case ChatType.LootNotice:
return ColourUtil.ComponentsToRgba(255, 255, 176);
case ChatType.Progress:
return ColourUtil.ComponentsToRgba(255, 222, 115);
case ChatType.LootRoll:
case ChatType.RandomNumber:
return ColourUtil.ComponentsToRgba(199, 191, 158);
case ChatType.Crafting:
case ChatType.Gathering:
return ColourUtil.ComponentsToRgba(222, 191, 247);
case ChatType.Damage:
return ColourUtil.ComponentsToRgba(255, 125, 125);
case ChatType.Miss:
return ColourUtil.ComponentsToRgba(204, 204, 204);
case ChatType.Healing:
return ColourUtil.ComponentsToRgba(212, 255, 125);
case ChatType.GainBuff:
case ChatType.LoseBuff:
return ColourUtil.ComponentsToRgba(148, 191, 255);
case ChatType.GainDebuff:
case ChatType.LoseDebuff:
return ColourUtil.ComponentsToRgba(255, 138, 196);
case ChatType.BattleSystem:
return ColourUtil.ComponentsToRgba(204, 204, 204);
default:
return null;
}
}
}

32
ChatTwo/Code/InputChannel.cs Executable file
View File

@ -0,0 +1,32 @@
namespace ChatTwo.Code;
internal enum InputChannel : uint {
Tell = 0,
Say = 1,
Party = 2,
Alliance = 3,
Yell = 4,
Shout = 5,
FreeCompany = 6,
PvpTeam = 7,
NoviceNetwork = 8,
CrossLinkshell1 = 9,
CrossLinkshell2 = 10,
CrossLinkshell3 = 11,
CrossLinkshell4 = 12,
CrossLinkshell5 = 13,
CrossLinkshell6 = 14,
CrossLinkshell7 = 15,
CrossLinkshell8 = 16,
// 17 - unused?
// 18 - unused?
Linkshell1 = 19,
Linkshell2 = 20,
Linkshell3 = 21,
Linkshell4 = 22,
Linkshell5 = 23,
Linkshell6 = 24,
Linkshell7 = 25,
Linkshell8 = 26,
}

34
ChatTwo/Code/InputChannelExt.cs Executable file
View File

@ -0,0 +1,34 @@
namespace ChatTwo.Code;
internal static class InputChannelExt {
internal static ChatType ToChatType(this InputChannel input) {
return input switch {
InputChannel.Tell => ChatType.TellOutgoing,
InputChannel.Say => ChatType.Say,
InputChannel.Party => ChatType.Party,
InputChannel.Alliance => ChatType.Alliance,
InputChannel.Yell => ChatType.Yell,
InputChannel.Shout => ChatType.Shout,
InputChannel.FreeCompany => ChatType.FreeCompany,
InputChannel.PvpTeam => ChatType.PvpTeam,
InputChannel.NoviceNetwork => ChatType.NoviceNetwork,
InputChannel.CrossLinkshell1 => ChatType.CrossLinkshell1,
InputChannel.CrossLinkshell2 => ChatType.CrossLinkshell2,
InputChannel.CrossLinkshell3 => ChatType.CrossLinkshell3,
InputChannel.CrossLinkshell4 => ChatType.CrossLinkshell4,
InputChannel.CrossLinkshell5 => ChatType.CrossLinkshell5,
InputChannel.CrossLinkshell6 => ChatType.CrossLinkshell6,
InputChannel.CrossLinkshell7 => ChatType.CrossLinkshell7,
InputChannel.CrossLinkshell8 => ChatType.CrossLinkshell8,
InputChannel.Linkshell1 => ChatType.Linkshell1,
InputChannel.Linkshell2 => ChatType.Linkshell2,
InputChannel.Linkshell3 => ChatType.Linkshell3,
InputChannel.Linkshell4 => ChatType.Linkshell4,
InputChannel.Linkshell5 => ChatType.Linkshell5,
InputChannel.Linkshell6 => ChatType.Linkshell6,
InputChannel.Linkshell7 => ChatType.Linkshell7,
InputChannel.Linkshell8 => ChatType.Linkshell8,
_ => throw new ArgumentOutOfRangeException(nameof(input), input, null),
};
}
}

59
ChatTwo/Configuration.cs Executable file
View File

@ -0,0 +1,59 @@
using ChatTwo.Code;
using Dalamud.Configuration;
namespace ChatTwo;
[Serializable]
internal class Configuration : IPluginConfiguration {
public int Version { get; set; } = 1;
public bool HideChat = true;
public float FontSize = 17f;
public Dictionary<ChatType, uint> ChatColours = new();
public List<Tab> Tabs = new();
}
[Serializable]
internal class Tab {
public string Name = "New tab";
public Dictionary<ChatType, ChatSource> ChatCodes = new();
public bool DisplayUnread = true;
public bool DisplayTimestamp = true;
[NonSerialized]
public uint Unread;
[NonSerialized]
public Mutex MessagesMutex = new();
[NonSerialized]
public List<Message> Messages = new();
~Tab() {
this.MessagesMutex.Dispose();
}
internal bool Matches(Message message) {
return this.ChatCodes.TryGetValue(message.Code.Type, out var sources) && (message.Code.Source is 0 or (ChatSource) 1 || sources.HasFlag(message.Code.Source));
}
internal void AddMessage(Message message) {
this.MessagesMutex.WaitOne();
this.Messages.Add(message);
if (this.Messages.Count > 1000) {
this.Messages.RemoveAt(0);
}
this.MessagesMutex.ReleaseMutex();
this.Unread += 1;
}
internal Tab Clone() {
return new Tab {
Name = this.Name,
ChatCodes = this.ChatCodes.ToDictionary(entry => entry.Key, entry => entry.Value),
DisplayUnread = this.DisplayUnread,
DisplayTimestamp = this.DisplayTimestamp,
};
}
}

171
ChatTwo/GameFunctions.cs Executable file
View File

@ -0,0 +1,171 @@
using ChatTwo.Code;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Hooking;
using Dalamud.Logging;
using Dalamud.Memory;
using FFXIVClientStructs.FFXIV.Client.System.Framework;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Component.GUI;
namespace ChatTwo;
internal unsafe class GameFunctions : IDisposable {
private static class Signatures {
internal const string ChatLogRefresh = "40 53 56 57 48 81 EC ?? ?? ?? ?? 48 8B 05 ?? ?? ?? ?? 48 33 C4 48 89 84 24 ?? ?? ?? ?? 49 8B F0 8B FA";
internal const string ChangeChannelName = "E8 ?? ?? ?? ?? BA ?? ?? ?? ?? 48 8D 4D B0 48 8B F8 E8 ?? ?? ?? ?? 41 8B D6";
}
private delegate byte ChatLogRefreshDelegate(IntPtr log, ushort eventId, AtkValue* value);
private delegate IntPtr ChangeChannelNameDelegate(IntPtr agent);
internal delegate void ChatActivatedEventDelegate(string? input);
private Plugin Plugin { get; }
private Hook<ChatLogRefreshDelegate>? ChatLogRefreshHook { get; }
private Hook<ChangeChannelNameDelegate>? ChangeChannelNameHook { get; }
internal event ChatActivatedEventDelegate? ChatActivated;
internal (InputChannel channel, string name) ChatChannel { get; private set; }
internal GameFunctions(Plugin plugin) {
this.Plugin = plugin;
if (this.Plugin.SigScanner.TryScanText(Signatures.ChatLogRefresh, out var chatLogPtr)) {
this.ChatLogRefreshHook = new Hook<ChatLogRefreshDelegate>(chatLogPtr, this.ChatLogRefreshDetour);
this.ChatLogRefreshHook.Enable();
}
if (this.Plugin.SigScanner.TryScanText(Signatures.ChangeChannelName, out var channelNamePtr)) {
this.ChangeChannelNameHook = new Hook<ChangeChannelNameDelegate>(channelNamePtr, this.ChangeChannelNameDetour);
this.ChangeChannelNameHook.Enable();
}
this.Plugin.ClientState.Login += this.Login;
this.Login(null, null);
}
public void Dispose() {
this.Plugin.ClientState.Login -= this.Login;
this.ChangeChannelNameHook?.Dispose();
this.ChatLogRefreshHook?.Dispose();
this.ChatActivated = null;
}
private void Login(object? sender, EventArgs? e) {
if (this.ChangeChannelNameHook == null) {
return;
}
var agent = Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.ChatLog);
if (agent == null) {
return;
}
this.ChangeChannelNameDetour((IntPtr) agent);
}
internal static void SetAddonInteractable(string name, bool interactable) {
var unitManager = AtkStage.GetSingleton()->RaptureAtkUnitManager;
var addon = (IntPtr) unitManager->GetAddonByName(name);
if (addon == IntPtr.Zero) {
return;
}
var flags = (uint*) (addon + 0x180);
if (interactable) {
*flags &= ~(1u << 22);
} else {
*flags |= 1 << 22;
}
}
internal void SetChatInteractable(bool interactable) {
for (var i = 0; i < 4; i++) {
SetAddonInteractable($"ChatLogPanel_{i}", interactable);
}
SetAddonInteractable("ChatLog", interactable);
}
internal static bool IsAddonInteractable(string name) {
var unitManager = AtkStage.GetSingleton()->RaptureAtkUnitManager;
var addon = (IntPtr) unitManager->GetAddonByName(name);
if (addon == IntPtr.Zero) {
return false;
}
var flags = (uint*) (addon + 0x180);
return (*flags & (1 << 22)) == 0;
}
private byte ChatLogRefreshDetour(IntPtr log, ushort eventId, AtkValue* value) {
if (eventId == 0x31 && value != null && value->UInt is 0x05 or 0x0C) {
string? eventInput = null;
var str = value + 2;
if (str != null && str->String != null) {
var input = MemoryHelper.ReadStringNullTerminated((IntPtr) str->String);
if (input.Length > 0) {
eventInput = input;
}
}
try {
this.ChatActivated?.Invoke(eventInput);
} catch (Exception ex) {
PluginLog.LogError(ex, "Error in ChatActivated event");
}
return 0;
}
return this.ChatLogRefreshHook!.Original(log, eventId, value);
}
private IntPtr ChangeChannelNameDetour(IntPtr agent) {
// Last ShB patch
// +0x40 = chat channel (byte or uint?)
// channel is 17 (maybe 18?) for tells
// +0x48 = pointer to channel name string
var ret = this.ChangeChannelNameHook!.Original(agent);
if (agent == IntPtr.Zero) {
return ret;
}
// E8 ?? ?? ?? ?? 8D 48 F7
// RaptureShellModule + 0xFD0
var shellModule = (IntPtr) Framework.Instance()->GetUiModule()->GetRaptureShellModule();
if (shellModule == IntPtr.Zero) {
return ret;
}
var channel = *(uint*) (shellModule + 0xFD0);
// var channel = *(uint*) (agent + 0x40);
if (channel is 17 or 18) {
channel = 0;
}
SeString? name = null;
var namePtrPtr = (byte**) (agent + 0x48);
if (namePtrPtr != null) {
var namePtr = *namePtrPtr;
name = MemoryHelper.ReadSeStringNullTerminated((IntPtr) namePtr);
if (name.Payloads.Count == 0) {
name = null;
}
}
if (name == null) {
return ret;
}
this.ChatChannel = ((InputChannel) channel, name.TextValue.TrimStart('\uE01E').Trim());
return ret;
}
}

17
ChatTwo/Message.cs Executable file
View File

@ -0,0 +1,17 @@
using ChatTwo.Code;
namespace ChatTwo;
internal class Message {
internal DateTime Date { get; }
internal ChatCode Code { get; }
internal List<Chunk> Sender { get; }
internal List<Chunk> Content { get; }
internal Message(ChatCode code, List<Chunk> sender, List<Chunk> content) {
this.Date = DateTime.UtcNow;
this.Code = code;
this.Sender = sender;
this.Content = content;
}
}

88
ChatTwo/Plugin.cs Executable file
View File

@ -0,0 +1,88 @@
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.IoC;
using Dalamud.Plugin;
using XivCommon;
namespace ChatTwo;
// ReSharper disable once ClassNeverInstantiated.Global
public sealed class Plugin : IDalamudPlugin {
public string Name => "Chat 2";
[PluginService]
internal DalamudPluginInterface Interface { get; init; }
[PluginService]
internal ChatGui ChatGui { get; init; }
[PluginService]
internal ClientState ClientState { get; init; }
[PluginService]
internal CommandManager CommandManager { get; init; }
[PluginService]
internal DataManager DataManager { get; init; }
[PluginService]
internal Framework Framework { get; init; }
[PluginService]
internal SigScanner SigScanner { get; init; }
internal Configuration Config { get; }
internal XivCommonBase Common { get; }
internal GameFunctions Functions { get; }
internal Store Store { get; }
internal PluginUi Ui { get; }
#pragma warning disable CS8618
public Plugin() {
this.Config = this.Interface!.GetPluginConfig() as Configuration ?? new Configuration();
this.Common = new XivCommonBase();
this.Functions = new GameFunctions(this);
this.Store = new Store(this);
this.Ui = new PluginUi(this);
this.Framework!.Update += this.FrameworkUpdate;
}
#pragma warning restore CS8618
public void Dispose() {
this.Framework.Update -= this.FrameworkUpdate;
this.Functions.SetChatInteractable(true);
this.Ui.Dispose();
this.Store.Dispose();
this.Functions.Dispose();
this.Common.Dispose();
}
internal void SaveConfig() {
this.Interface.SavePluginConfig(this.Config);
}
private static readonly string[] ChatAddonNames = {
"ChatLog",
"ChatLogPanel_0",
"ChatLogPanel_1",
"ChatLogPanel_2",
"ChatLogPanel_3",
};
private void FrameworkUpdate(Framework framework) {
if (!this.Config.HideChat) {
return;
}
foreach (var name in ChatAddonNames) {
if (GameFunctions.IsAddonInteractable(name)) {
GameFunctions.SetAddonInteractable(name, false);
}
}
}
}

187
ChatTwo/PluginUi.cs Executable file
View File

@ -0,0 +1,187 @@
using System.Runtime.InteropServices;
using ChatTwo.Ui;
using Dalamud.Interface;
using Dalamud.Logging;
using ImGuiNET;
namespace ChatTwo;
internal sealed class PluginUi : IDisposable {
internal Plugin Plugin { get; }
internal ImFontPtr? RegularFont { get; private set; }
internal ImFontPtr? ItalicFont { get; private set; }
private List<IUiComponent> Components { get; }
private ImFontConfigPtr _fontCfg;
private ImFontConfigPtr _fontCfgMerge;
private (GCHandle, int) _regularFont;
private (GCHandle, int) _italicFont;
private (GCHandle, int) _jpFont;
private (GCHandle, int) _gameSymFont;
private ImVector _ranges;
private GCHandle _jpRange = GCHandle.Alloc(
GlyphRangesJapanese.GlyphRanges,
GCHandleType.Pinned
);
private GCHandle _symRange = GCHandle.Alloc(
new ushort[] {
0xE020,
0xE0DB,
0,
},
GCHandleType.Pinned
);
internal unsafe PluginUi(Plugin plugin) {
this.Plugin = plugin;
this.Components = new List<IUiComponent> {
new Settings(this),
new ChatLog(this),
};
this._fontCfg = new ImFontConfigPtr(ImGuiNative.ImFontConfig_ImFontConfig()) {
FontDataOwnedByAtlas = false,
};
this._fontCfgMerge = new ImFontConfigPtr(ImGuiNative.ImFontConfig_ImFontConfig()) {
FontDataOwnedByAtlas = false,
MergeMode = true,
};
var builder = new ImFontGlyphRangesBuilderPtr(ImGuiNative.ImFontGlyphRangesBuilder_ImFontGlyphRangesBuilder());
builder.AddRanges(ImGui.GetIO().Fonts.GetGlyphRangesDefault());
builder.AddText("←→↑↓《》■※☀★★☆♥♡ヅツッシ☀☁☂℃℉°♀♂♠♣♦♣♧®©™€$£♯♭♪✓√◎◆◇♦■□〇●△▽▼▲‹›≤≥<«“”─");
builder.BuildRanges(out this._ranges);
var regular = this.GetResource("ChatTwo.fonts.NotoSans-Regular.ttf");
this._regularFont = (
GCHandle.Alloc(regular, GCHandleType.Pinned),
regular.Length
);
var italic = this.GetResource("ChatTwo.fonts.NotoSans-Italic.ttf");
this._italicFont = (
GCHandle.Alloc(italic, GCHandleType.Pinned),
italic.Length
);
var jp = this.GetResource("ChatTwo.fonts.NotoSansJP-Regular.otf");
this._jpFont = (
GCHandle.Alloc(jp, GCHandleType.Pinned),
jp.Length
);
var gameSym = File.ReadAllBytes(Path.Combine(this.Plugin.Interface.DalamudAssetDirectory.FullName, "UIRes", "gamesym.ttf"));
this._gameSymFont = (
GCHandle.Alloc(gameSym, GCHandleType.Pinned),
gameSym.Length
);
this.Plugin.Interface.UiBuilder.BuildFonts += this.BuildFonts;
this.Plugin.Interface.UiBuilder.Draw += this.Draw;
this.Plugin.Interface.UiBuilder.RebuildFonts();
}
public void Dispose() {
this.Plugin.Interface.UiBuilder.Draw -= this.Draw;
this.Plugin.Interface.UiBuilder.BuildFonts -= this.BuildFonts;
foreach (var component in this.Components) {
component.Dispose();
}
this._regularFont.Item1.Free();
this._italicFont.Item1.Free();
this._gameSymFont.Item1.Free();
this._symRange.Free();
this._jpRange.Free();
this._fontCfg.Destroy();
this._fontCfgMerge.Destroy();
}
private void Draw() {
var font = this.RegularFont.HasValue;
if (font) {
ImGui.PushFont(this.RegularFont!.Value);
}
foreach (var component in this.Components) {
try {
component.Draw();
} catch (Exception ex) {
PluginLog.LogError(ex, "Error drawing component");
}
}
if (font) {
ImGui.PopFont();
}
}
private byte[] GetResource(string name) {
var stream = this.GetType().Assembly.GetManifestResourceStream(name)!;
var memory = new MemoryStream();
stream.CopyTo(memory);
return memory.ToArray();
}
private void BuildFonts() {
this.RegularFont = null;
this.ItalicFont = null;
// load regular noto sans and merge in jp + game icons
this.RegularFont = ImGui.GetIO().Fonts.AddFontFromMemoryTTF(
this._regularFont.Item1.AddrOfPinnedObject(),
this._regularFont.Item2,
this.Plugin.Config.FontSize,
this._fontCfg,
this._ranges.Data
);
ImGui.GetIO().Fonts.AddFontFromMemoryTTF(
this._jpFont.Item1.AddrOfPinnedObject(),
this._jpFont.Item2,
this.Plugin.Config.FontSize,
this._fontCfgMerge,
this._jpRange.AddrOfPinnedObject()
);
ImGui.GetIO().Fonts.AddFontFromMemoryTTF(
this._gameSymFont.Item1.AddrOfPinnedObject(),
this._gameSymFont.Item2,
this.Plugin.Config.FontSize,
this._fontCfgMerge,
this._symRange.AddrOfPinnedObject()
);
// load italic noto sans and merge in jp + game icons
this.ItalicFont = ImGui.GetIO().Fonts.AddFontFromMemoryTTF(
this._italicFont.Item1.AddrOfPinnedObject(),
this._italicFont.Item2,
this.Plugin.Config.FontSize,
this._fontCfg,
this._ranges.Data
);
ImGui.GetIO().Fonts.AddFontFromMemoryTTF(
this._jpFont.Item1.AddrOfPinnedObject(),
this._jpFont.Item2,
this.Plugin.Config.FontSize,
this._fontCfgMerge,
this._jpRange.AddrOfPinnedObject()
);
ImGui.GetIO().Fonts.AddFontFromMemoryTTF(
this._gameSymFont.Item1.AddrOfPinnedObject(),
this._gameSymFont.Item2,
this.Plugin.Config.FontSize,
this._fontCfgMerge,
this._symRange.AddrOfPinnedObject()
);
}
}

168
ChatTwo/Store.cs Executable file
View File

@ -0,0 +1,168 @@
using ChatTwo.Code;
using ChatTwo.Util;
using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
using Lumina.Excel.GeneratedSheets;
namespace ChatTwo;
internal class Store : IDisposable {
internal sealed class MessagesLock : IDisposable {
private Mutex Mutex { get; }
internal List<Message> Messages { get; }
internal MessagesLock(List<Message> messages, Mutex mutex) {
this.Messages = messages;
this.Mutex = mutex;
this.Mutex.WaitOne();
}
public void Dispose() {
this.Mutex.ReleaseMutex();
}
}
private Plugin Plugin { get; }
private Mutex MessagesMutex { get; } = new();
private List<Message> Messages { get; } = new();
private Dictionary<ChatType, NameFormatting> Formats { get; } = new();
internal Store(Plugin plugin) {
this.Plugin = plugin;
this.Plugin.ChatGui.ChatMessageUnhandled += this.ChatMessage;
}
public void Dispose() {
this.Plugin.ChatGui.ChatMessageUnhandled -= this.ChatMessage;
this.MessagesMutex.Dispose();