feat: update for 6.11

This commit is contained in:
Anna
2022-05-12 18:50:05 -04:00
parent 327a40f63c
commit f195f55274
11 changed files with 147 additions and 72 deletions
+4 -2
View File
@@ -9,6 +9,8 @@
<ProduceReferenceAssembly>false</ProduceReferenceAssembly> <ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies> <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<LangVersion>preview</LangVersion> <LangVersion>preview</LangVersion>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
@@ -47,10 +49,10 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.5"/> <PackageReference Include="DalamudPackager" Version="2.1.6"/>
<PackageReference Include="LiteDB" Version="5.0.11"/> <PackageReference Include="LiteDB" Version="5.0.11"/>
<PackageReference Include="SharpDX.Direct2D1" Version="4.2.0"/> <PackageReference Include="SharpDX.Direct2D1" Version="4.2.0"/>
<PackageReference Include="XivCommon" Version="5.0.0"/> <PackageReference Include="XivCommon" Version="5.0.1-alpha.1"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
+2
View File
@@ -34,6 +34,7 @@ internal class Configuration : IPluginConfiguration {
public bool FilterIncludePreviousSessions; public bool FilterIncludePreviousSessions;
public bool SharedMode; public bool SharedMode;
public bool FontsEnabled = true;
public float FontSize = 17f; public float FontSize = 17f;
public float JapaneseFontSize = 17f; public float JapaneseFontSize = 17f;
public float SymbolsFontSize = 17f; public float SymbolsFontSize = 17f;
@@ -66,6 +67,7 @@ internal class Configuration : IPluginConfiguration {
this.LoadPreviousSession = other.LoadPreviousSession; this.LoadPreviousSession = other.LoadPreviousSession;
this.FilterIncludePreviousSessions = other.FilterIncludePreviousSessions; this.FilterIncludePreviousSessions = other.FilterIncludePreviousSessions;
this.SharedMode = other.SharedMode; this.SharedMode = other.SharedMode;
this.FontsEnabled = other.FontsEnabled;
this.FontSize = other.FontSize; this.FontSize = other.FontSize;
this.JapaneseFontSize = other.JapaneseFontSize; this.JapaneseFontSize = other.JapaneseFontSize;
this.SymbolsFontSize = other.SymbolsFontSize; this.SymbolsFontSize = other.SymbolsFontSize;
+1 -1
View File
@@ -34,7 +34,7 @@ internal sealed unsafe class Chat : IDisposable {
[Signature("E8 ?? ?? ?? ?? 48 3B F0 74 35")] [Signature("E8 ?? ?? ?? ?? 48 3B F0 74 35")]
private readonly delegate* unmanaged<AtkStage*, IntPtr> _getFocus = null!; private readonly delegate* unmanaged<AtkStage*, IntPtr> _getFocus = null!;
[Signature("44 8B 89 ?? ?? ?? ?? 4C 8B C1")] [Signature("44 8B 89 ?? ?? ?? ?? 4C 8B C1 45 85 C9")]
private readonly delegate* unmanaged<void*, int, IntPtr> _getTellHistory = null!; private readonly delegate* unmanaged<void*, int, IntPtr> _getTellHistory = null!;
[Signature("E8 ?? ?? ?? ?? B8 ?? ?? ?? ?? 48 8D 4D 50")] [Signature("E8 ?? ?? ?? ?? B8 ?? ?? ?? ?? 48 8D 4D 50")]
+2 -2
View File
@@ -87,8 +87,8 @@ internal sealed unsafe class Context {
} }
var uiModule = Framework.Instance()->GetUiModule(); var uiModule = Framework.Instance()->GetUiModule();
var vf35 = (delegate* unmanaged<UIModule*, IntPtr>) uiModule->vfunc[35]; var vf36 = (delegate* unmanaged<UIModule*, IntPtr>) uiModule->vfunc[36];
var a1 = vf35(uiModule); var a1 = vf36(uiModule);
this._searchForRecipesUsingItem(a1, itemId); this._searchForRecipesUsingItem(a1, itemId);
} }
+13 -13
View File
@@ -30,7 +30,7 @@ internal unsafe class GameFunctions : IDisposable {
[Signature("48 89 5C 24 ?? 57 48 83 EC 20 48 8B FA 48 8B D9 E8 ?? ?? ?? ?? 48 8B 8B ?? ?? ?? ?? 48 85 C9", Fallibility = Fallibility.Fallible)] [Signature("48 89 5C 24 ?? 57 48 83 EC 20 48 8B FA 48 8B D9 E8 ?? ?? ?? ?? 48 8B 8B ?? ?? ?? ?? 48 85 C9", Fallibility = Fallibility.Fallible)]
private readonly delegate* unmanaged<AgentInterface*, ulong, byte> _openPartyFinder = null!; private readonly delegate* unmanaged<AgentInterface*, ulong, byte> _openPartyFinder = null!;
[Signature("E8 ?? ?? ?? ?? EB 42 48 8B 47 30", Fallibility = Fallibility.Fallible)] [Signature("E8 ?? ?? ?? ?? EB 20 48 8B 46 28", Fallibility = Fallibility.Fallible)]
private readonly delegate* unmanaged<AgentInterface*, uint, void> _openAchievement = null!; private readonly delegate* unmanaged<AgentInterface*, uint, void> _openAchievement = null!;
#endregion #endregion
@@ -164,27 +164,27 @@ internal unsafe class GameFunctions : IDisposable {
var agentPtr = (IntPtr) agent; var agentPtr = (IntPtr) agent;
// addresses mentioned here are 6.01 // addresses mentioned here are 6.11
// see the call near the end of AgentItemDetail.Update // see the call near the end of AgentItemDetail.Update
// offsets valid as of 6.01 // offsets valid as of 6.11
// 8BFC49: sets some shit // A54B19: sets some shit
*(uint*) (agentPtr + 0x20) = 22; *(uint*) (agentPtr + 0x20) = 22;
// 8C04C8: switch goes down to default, which is what we want // A55218: switch goes down to default, which is what we want
*(byte*) (agentPtr + 0x118) = 1; *(byte*) (agentPtr + 0x118) = 1;
// 8BFCF6: item id when hovering over item in chat // A54BE0: item id when hovering over item in chat
*(uint*) (agentPtr + 0x11C) = id; *(uint*) (agentPtr + 0x11C) = id;
// 8BFCE4: always 0 when hovering over item in chat // A54BCC: always 0 when hovering over item in chat
*(uint*) (agentPtr + 0x120) = 0; *(uint*) (agentPtr + 0x120) = 0;
// 8C0B55: skips a check to do with inventory // A558A5: skips a check to do with inventory
*(byte*) (agentPtr + 0x128) &= 0xEF; *(byte*) (agentPtr + 0x128) &= 0xEF;
// 8BFC7C: when set to 1, lets everything continue (one frame) // A54B3F: when set to 1, lets everything continue (one frame)
*(byte*) (agentPtr + 0x146) = 1; *(byte*) (agentPtr + 0x14A) = 1;
// 8BFC89: skips early return // A54B59: skips early return
*(byte*) (agentPtr + 0x14A) = 0; *(byte*) (agentPtr + 0x14E) = 0;
// this just probably needs to be set // this just probably needs to be set
agent->AddonId = (uint) addon->ID; agent->AddonId = addon->ID;
// vcall from E8 ?? ?? ?? ?? 0F B7 C0 48 83 C4 60 // vcall from E8 ?? ?? ?? ?? 0F B7 C0 48 83 C4 60
var vf5 = (delegate* unmanaged<AtkUnitBase*, byte, uint, void>*) ((IntPtr) addon->VTable + 40); var vf5 = (delegate* unmanaged<AtkUnitBase*, byte, uint, void>*) ((IntPtr) addon->VTable + 40);
+2 -2
View File
@@ -31,7 +31,7 @@ internal sealed unsafe class Party {
return; return;
} }
// 6.05: 20D722 // 6.11: 214A55
var a1 = this.Plugin.Functions.GetInfoProxyByIndex(1); var a1 = this.Plugin.Functions.GetInfoProxyByIndex(1);
fixed (byte* namePtr = name.ToTerminatedBytes()) { fixed (byte* namePtr = name.ToTerminatedBytes()) {
// this only works if target is on the same world // this only works if target is on the same world
@@ -44,7 +44,7 @@ internal sealed unsafe class Party {
return; return;
} }
// 6.05: 20D722 // 6.11: 214A55
var a1 = this.Plugin.Functions.GetInfoProxyByIndex(1); var a1 = this.Plugin.Functions.GetInfoProxyByIndex(1);
if (contentId != 0) { if (contentId != 0) {
// third param is world, but it requires a specific world // third param is world, but it requires a specific world
+20 -3
View File
@@ -2,6 +2,7 @@ using System.Numerics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ChatTwo.Ui; using ChatTwo.Ui;
using Dalamud.Interface; using Dalamud.Interface;
using Dalamud.Interface.GameFonts;
using Dalamud.Logging; using Dalamud.Logging;
using ImGuiNET; using ImGuiNET;
@@ -14,6 +15,9 @@ internal sealed class PluginUi : IDisposable {
internal bool ScreenshotMode; internal bool ScreenshotMode;
internal string Salt { get; } internal string Salt { get; }
internal GameFontHandle Axis { get; private set; }
internal GameFontHandle AxisItalic { get; private set; }
internal ImFontPtr? RegularFont { get; private set; } internal ImFontPtr? RegularFont { get; private set; }
internal ImFontPtr? ItalicFont { get; private set; } internal ImFontPtr? ItalicFont { get; private set; }
internal Vector4 DefaultText { get; private set; } internal Vector4 DefaultText { get; private set; }
@@ -112,7 +116,11 @@ internal sealed class PluginUi : IDisposable {
BuildRange(out this._jpRange, GlyphRangesJapanese.GlyphRanges); BuildRange(out this._jpRange, GlyphRangesJapanese.GlyphRanges);
this.SetUpUserFonts(); this.SetUpUserFonts();
var gameSym = File.ReadAllBytes(Path.Combine(this.Plugin.Interface.DalamudAssetDirectory.FullName, "UIRes", "gamesym.ttf")); var gameSym = new HttpClient().GetAsync("https://img.finalfantasyxiv.com/lds/pc/global/fonts/FFXIV_Lodestone_SSF.ttf")
.Result
.Content
.ReadAsByteArrayAsync()
.Result;
this._gameSymFont = ( this._gameSymFont = (
GCHandle.Alloc(gameSym, GCHandleType.Pinned), GCHandle.Alloc(gameSym, GCHandleType.Pinned),
gameSym.Length gameSym.Length
@@ -165,9 +173,13 @@ internal sealed class PluginUi : IDisposable {
this.DefaultText = ImGui.GetStyle().Colors[(int) ImGuiCol.Text]; this.DefaultText = ImGui.GetStyle().Colors[(int) ImGuiCol.Text];
var font = this.RegularFont.HasValue; var font = this.RegularFont.HasValue;
var pushed = font && this.Plugin.Config.FontsEnabled;
var axis = !this.Plugin.Config.FontsEnabled && this.Axis.Available;
if (font) { if (pushed) {
ImGui.PushFont(this.RegularFont!.Value); ImGui.PushFont(this.RegularFont!.Value);
} else if (axis) {
ImGui.PushFont(this.Axis.ImFont);
} }
foreach (var component in this.Components) { foreach (var component in this.Components) {
@@ -178,7 +190,7 @@ internal sealed class PluginUi : IDisposable {
} }
} }
if (font) { if (pushed || axis) {
ImGui.PopFont(); ImGui.PopFont();
} }
} }
@@ -274,6 +286,11 @@ internal sealed class PluginUi : IDisposable {
this.SetUpUserFonts(); this.SetUpUserFonts();
this.Axis = this.Plugin.Interface.UiBuilder.GetGameFontHandle(new GameFontStyle(GameFontFamily.Axis, this.Plugin.Config.FontSize));
this.AxisItalic = this.Plugin.Interface.UiBuilder.GetGameFontHandle(new GameFontStyle(GameFontFamily.Axis, this.Plugin.Config.FontSize) {
SkewStrength = this.Plugin.Config.FontSize / 6,
});
// load regular noto sans and merge in jp + game icons // load regular noto sans and merge in jp + game icons
this.RegularFont = ImGui.GetIO().Fonts.AddFontFromMemoryTTF( this.RegularFont = ImGui.GetIO().Fonts.AddFontFromMemoryTTF(
this._regularFont.Item1.AddrOfPinnedObject(), this._regularFont.Item1.AddrOfPinnedObject(),
+9
View File
@@ -519,6 +519,15 @@ namespace ChatTwo.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to Enable custom fonts.
/// </summary>
internal static string Options_FontsEnabled {
get {
return ResourceManager.GetString("Options_FontsEnabled", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Font size. /// Looks up a localized string similar to Font size.
/// </summary> /// </summary>
+3
View File
@@ -494,4 +494,7 @@
<data name="Options_Tabs_Opacity" xml:space="preserve"> <data name="Options_Tabs_Opacity" xml:space="preserve">
<value>Opacity</value> <value>Opacity</value>
</data> </data>
<data name="Options_FontsEnabled" xml:space="preserve">
<value>Enable custom fonts</value>
</data>
</root> </root>
+39 -2
View File
@@ -39,12 +39,14 @@ internal sealed class ChatLog : IUiComponent {
private PayloadHandler PayloadHandler { get; } private PayloadHandler PayloadHandler { get; }
private Dictionary<string, ChatType> TextCommandChannels { get; } = new(); private Dictionary<string, ChatType> TextCommandChannels { get; } = new();
private HashSet<string> AllCommands { get; } = new();
internal ChatLog(PluginUi ui) { internal ChatLog(PluginUi ui) {
this.Ui = ui; this.Ui = ui;
this.PayloadHandler = new PayloadHandler(this.Ui, this); this.PayloadHandler = new PayloadHandler(this.Ui, this);
this.SetUpTextCommandChannels(); this.SetUpTextCommandChannels();
this.SetUpAllCommands();
this.Ui.Plugin.Commands.Register("/clearlog2", "Clear the Chat 2 chat log").Execute += this.ClearLog; this.Ui.Plugin.Commands.Register("/clearlog2", "Clear the Chat 2 chat log").Execute += this.ClearLog;
this.Ui.Plugin.Commands.Register("/chat2").Execute += this.ToggleChat; this.Ui.Plugin.Commands.Register("/chat2").Execute += this.ToggleChat;
@@ -137,6 +139,11 @@ internal sealed class ChatLog : IUiComponent {
} }
} }
private bool IsValidCommand(string command) {
return this.Ui.Plugin.CommandManager.Commands.ContainsKey(command)
|| this.AllCommands.Contains(command);
}
private void ClearLog(string command, string arguments) { private void ClearLog(string command, string arguments) {
switch (arguments) { switch (arguments) {
case "all": case "all":
@@ -213,6 +220,23 @@ internal sealed class ChatLog : IUiComponent {
this.TextCommandChannels[command.ShortAlias] = type; this.TextCommandChannels[command.ShortAlias] = type;
} }
private void SetUpAllCommands() {
if (this.Ui.Plugin.DataManager.GetExcelSheet<TextCommand>() is not { } commands) {
return;
}
var commandNames = commands.SelectMany(cmd => new[] {
cmd.Command.RawString,
cmd.ShortCommand.RawString,
cmd.Alias.RawString,
cmd.ShortAlias.RawString,
});
foreach (var command in commandNames) {
this.AllCommands.Add(command);
}
}
private void AddBacklog(string message) { private void AddBacklog(string message) {
for (var i = 0; i < this._inputBacklog.Count; i++) { for (var i = 0; i < this._inputBacklog.Count; i++) {
if (this._inputBacklog[i] != message) { if (this._inputBacklog[i] != message) {
@@ -479,6 +503,10 @@ internal sealed class ChatLog : IUiComponent {
if (this.TextCommandChannels.TryGetValue(command, out var channel)) { if (this.TextCommandChannels.TryGetValue(command, out var channel)) {
inputType = channel; inputType = channel;
} }
if (!this.IsValidCommand(command)) {
inputType = ChatType.Error;
}
} }
var normalColour = *ImGui.GetStyleColorVec4(ImGuiCol.Text); var normalColour = *ImGui.GetStyleColorVec4(ImGuiCol.Text);
@@ -1040,8 +1068,17 @@ internal sealed class ChatLog : IUiComponent {
ImGui.PushStyleColor(ImGuiCol.Text, colour.Value); ImGui.PushStyleColor(ImGuiCol.Text, colour.Value);
} }
if (text.Italic && this.Ui.ItalicFont.HasValue) { var pushed = false;
if (text.Italic) {
if (this.Ui.ItalicFont.HasValue && this.Ui.Plugin.Config.FontsEnabled) {
ImGui.PushFont(this.Ui.ItalicFont.Value); ImGui.PushFont(this.Ui.ItalicFont.Value);
pushed = true;
}
if (!this.Ui.Plugin.Config.FontsEnabled && this.Ui.AxisItalic.Available) {
ImGui.PushFont(this.Ui.AxisItalic.ImFont);
pushed = true;
}
} }
var content = text.Content; var content = text.Content;
@@ -1062,7 +1099,7 @@ internal sealed class ChatLog : IUiComponent {
ImGuiUtil.PostPayload(chunk, handler); ImGuiUtil.PostPayload(chunk, handler);
} }
if (text.Italic && this.Ui.ItalicFont.HasValue) { if (pushed) {
ImGui.PopFont(); ImGui.PopFont();
} }
+5
View File
@@ -28,6 +28,10 @@ public class Fonts : ISettingsTab {
ImGui.PushTextWrapPos(); ImGui.PushTextWrapPos();
ImGui.Checkbox(Language.Options_FontsEnabled, ref this.Mutable.FontsEnabled);
ImGui.Spacing();
if (this.Mutable.FontsEnabled) {
if (ImGuiUtil.BeginComboVertical(Language.Options_Font_Name, this.Mutable.GlobalFont)) { if (ImGuiUtil.BeginComboVertical(Language.Options_Font_Name, this.Mutable.GlobalFont)) {
foreach (var font in Ui.Fonts.GlobalFonts) { foreach (var font in Ui.Fonts.GlobalFonts) {
if (ImGui.Selectable(font.Name, this.Mutable.GlobalFont == font.Name)) { if (ImGui.Selectable(font.Name, this.Mutable.GlobalFont == font.Name)) {
@@ -86,6 +90,7 @@ public class Fonts : ISettingsTab {
ImGuiUtil.HelpText(string.Format(Language.Options_JapaneseFont_Description, Plugin.PluginName)); ImGuiUtil.HelpText(string.Format(Language.Options_JapaneseFont_Description, Plugin.PluginName));
ImGui.Spacing(); ImGui.Spacing();
}
const float speed = .0125f; const float speed = .0125f;
const float min = 8f; const float min = 8f;