Add adventurer plate context option

This commit is contained in:
Infi
2024-04-06 03:01:32 +02:00
parent 5ceb327f3a
commit 40fd726519
7 changed files with 2178 additions and 1364 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.19.2</Version>
<Version>1.19.3</Version>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
+14
View File
@@ -273,6 +273,20 @@ internal unsafe class GameFunctions : IDisposable {
return this._inInstance() != 0;
}
internal bool TryOpenAdventurerPlate(ulong playerId)
{
try
{
AgentCharaCard.Instance()->OpenCharaCard(playerId);
return true;
}
catch (Exception e)
{
Plugin.Log.Warning(e, "Unable to open adventurer plate");
return false;
}
}
internal void ClickNoviceNetworkButton() {
var agent = Framework.Instance()->GetUiModule()->GetAgentModule()->GetAgentByInternalId(AgentId.ChatLog);
// case 3
+99 -91
View File
@@ -7,6 +7,7 @@ using Dalamud.Game.ClientState.Objects.SubKinds;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Game.Text.SeStringHandling.Payloads;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Internal.Notifications;
using Dalamud.Interface.Utility;
using Dalamud.Utility;
using ImGuiNET;
@@ -31,30 +32,30 @@ internal sealed class PayloadHandler {
private uint _lastHoverCounter;
internal PayloadHandler(PluginUi ui, ChatLog log) {
this.Ui = ui;
this.Log = log;
Ui = ui;
Log = log;
}
internal void Draw() {
this.DrawPopups();
DrawPopups();
if (this._handleTooltips && ++this._hoverCounter - this._lastHoverCounter > 1) {
if (_handleTooltips && ++_hoverCounter - _lastHoverCounter > 1) {
GameFunctions.GameFunctions.CloseItemTooltip();
this._hoveredItem = 0;
this._hoverCounter = this._lastHoverCounter = 0;
this._handleTooltips = false;
_hoveredItem = 0;
_hoverCounter = _lastHoverCounter = 0;
_handleTooltips = false;
}
}
private void DrawPopups() {
if (this.Popup == null) {
if (Popup == null) {
return;
}
var (chunk, payload) = this.Popup.Value;
var (chunk, payload) = Popup.Value;
if (!ImGui.BeginPopup(PopupId)) {
this.Popup = null;
Popup = null;
return;
}
@@ -63,26 +64,26 @@ internal sealed class PayloadHandler {
var drawn = false;
switch (payload) {
case PlayerPayload player: {
this.DrawPlayerPopup(chunk, player);
DrawPlayerPopup(chunk, player);
drawn = true;
break;
}
case ItemPayload item: {
this.DrawItemPopup(item);
DrawItemPopup(item);
drawn = true;
break;
}
}
this.ContextFooter(drawn, chunk);
this.Integrations(chunk, payload);
ContextFooter(drawn, chunk);
Integrations(chunk, payload);
ImGui.PopID();
ImGui.EndPopup();
}
private void Integrations(Chunk chunk, Payload? payload) {
var registered = this.Ui.Plugin.Ipc.Registered;
var registered = Ui.Plugin.Ipc.Registered;
if (registered.Count == 0) {
return;
}
@@ -97,7 +98,7 @@ internal sealed class PayloadHandler {
foreach (var id in registered) {
try {
this.Ui.Plugin.Ipc.Invoke(id, sender, contentId, payload, chunk.Message?.SenderSource, chunk.Message?.ContentSource);
Ui.Plugin.Ipc.Invoke(id, sender, contentId, payload, chunk.Message?.SenderSource, chunk.Message?.ContentSource);
} catch (Exception ex) {
Plugin.Log.Error(ex, "Error executing integration");
}
@@ -122,10 +123,10 @@ internal sealed class PayloadHandler {
return;
}
ImGui.Checkbox(Language.Context_ScreenshotMode, ref this.Ui.ScreenshotMode);
ImGui.Checkbox(Language.Context_ScreenshotMode, ref Ui.ScreenshotMode);
if (ImGui.Selectable(Language.Context_HideChat)) {
this.Log.UserHide();
Log.UserHide();
}
if (chunk.Message is { } message) {
@@ -148,9 +149,12 @@ internal sealed class PayloadHandler {
var col = ImGui.GetStyle().Colors[(int) ImGuiCol.TextDisabled];
ImGui.PushStyleColor(ImGuiCol.Text, col);
try {
try
{
ImGui.TextUnformatted(message.Code.Type.Name());
} finally {
}
finally
{
ImGui.PopStyleColor();
}
}
@@ -161,10 +165,10 @@ internal sealed class PayloadHandler {
internal void Click(Chunk chunk, Payload? payload, ImGuiMouseButton button) {
switch (button) {
case ImGuiMouseButton.Left:
this.LeftClickPayload(chunk, payload);
LeftClickPayload(chunk, payload);
break;
case ImGuiMouseButton.Right:
this.RightClickPayload(chunk, payload);
RightClickPayload(chunk, payload);
break;
}
}
@@ -174,25 +178,25 @@ internal sealed class PayloadHandler {
switch (payload) {
case StatusPayload status: {
this.DoHover(() => this.HoverStatus(status), hoverSize);
DoHover(() => HoverStatus(status), hoverSize);
break;
}
case ItemPayload item: {
if (this.Ui.Plugin.Config.NativeItemTooltips) {
if (Ui.Plugin.Config.NativeItemTooltips) {
GameFunctions.GameFunctions.OpenItemTooltip(item.RawItemId);
this._handleTooltips = true;
if (this._hoveredItem != item.RawItemId) {
this._hoveredItem = item.RawItemId;
this._hoverCounter = this._lastHoverCounter = 0;
_handleTooltips = true;
if (_hoveredItem != item.RawItemId) {
_hoveredItem = item.RawItemId;
_hoverCounter = _lastHoverCounter = 0;
} else {
this._lastHoverCounter = this._hoverCounter;
_lastHoverCounter = _hoverCounter;
}
break;
}
this.DoHover(() => this.HoverItem(item), hoverSize);
DoHover(() => HoverItem(item), hoverSize);
break;
}
}
@@ -203,11 +207,14 @@ internal sealed class PayloadHandler {
ImGui.BeginTooltip();
ImGui.PushTextWrapPos();
ImGui.PushStyleColor(ImGuiCol.Text, Ui.DefaultText);
ImGui.PushStyleColor(ImGuiCol.Text, this.Ui.DefaultText);
try {
try
{
inside();
} finally {
}
finally
{
ImGui.PopStyleColor();
ImGui.PopTextWrapPos();
ImGui.EndTooltip();
@@ -225,21 +232,21 @@ internal sealed class PayloadHandler {
}
private void HoverStatus(StatusPayload status) {
if (this.Ui.Plugin.TextureCache.GetStatus(status.Status) is { } icon) {
if (Ui.Plugin.TextureCache.GetStatus(status.Status) is { } icon) {
InlineIcon(icon);
}
var name = ChunkUtil.ToChunks(status.Status.Name.ToDalamudString(), ChunkSource.None, null);
this.Log.DrawChunks(name.ToList());
Log.DrawChunks(name.ToList());
ImGui.Separator();
var desc = ChunkUtil.ToChunks(status.Status.Description.ToDalamudString(), ChunkSource.None, null);
this.Log.DrawChunks(desc.ToList());
Log.DrawChunks(desc.ToList());
}
private void HoverItem(ItemPayload item) {
if (item.Kind == ItemPayload.ItemKind.EventItem) {
this.HoverEventItem(item);
HoverEventItem(item);
return;
}
@@ -247,16 +254,16 @@ internal sealed class PayloadHandler {
return;
}
if (this.Ui.Plugin.TextureCache.GetItem(item.Item, item.IsHQ) is { } icon) {
if (Ui.Plugin.TextureCache.GetItem(item.Item, item.IsHQ) is { } icon) {
InlineIcon(icon);
}
var name = ChunkUtil.ToChunks(item.Item.Name.ToDalamudString(), ChunkSource.None, null);
this.Log.DrawChunks(name.ToList());
Log.DrawChunks(name.ToList());
ImGui.Separator();
var desc = ChunkUtil.ToChunks(item.Item.Description.ToDalamudString(), ChunkSource.None, null);
this.Log.DrawChunks(desc.ToList());
Log.DrawChunks(desc.ToList());
}
private void HoverEventItem(ItemPayload payload) {
@@ -265,18 +272,18 @@ internal sealed class PayloadHandler {
return;
}
if (this.Ui.Plugin.TextureCache.GetEventItem(item) is { } icon) {
if (Ui.Plugin.TextureCache.GetEventItem(item) is { } icon) {
InlineIcon(icon);
}
var name = ChunkUtil.ToChunks(item.Name.ToDalamudString(), ChunkSource.None, null);
this.Log.DrawChunks(name.ToList());
Log.DrawChunks(name.ToList());
ImGui.Separator();
var help = Plugin.DataManager.GetExcelSheet<EventItemHelp>()?.GetRow(payload.RawItemId);
if (help != null) {
var desc = ChunkUtil.ToChunks(help.Description.ToDalamudString(), ChunkSource.None, null);
this.Log.DrawChunks(desc.ToList());
Log.DrawChunks(desc.ToList());
}
}
@@ -287,28 +294,28 @@ internal sealed class PayloadHandler {
break;
}
case QuestPayload quest: {
this.Ui.Plugin.Common.Functions.Journal.OpenQuest(quest.Quest);
Ui.Plugin.Common.Functions.Journal.OpenQuest(quest.Quest);
break;
}
case DalamudLinkPayload link: {
this.ClickLinkPayload(chunk, payload, link);
ClickLinkPayload(chunk, payload, link);
break;
}
case DalamudPartyFinderPayload pf: {
if (pf.LinkType == DalamudPartyFinderPayload.PartyFinderLinkType.PartyFinderNotification) {
GameFunctions.GameFunctions.OpenPartyFinder();
} else {
this.Ui.Plugin.Functions.OpenPartyFinder(pf.ListingId);
Ui.Plugin.Functions.OpenPartyFinder(pf.ListingId);
}
break;
}
case ChatTwoPartyFinderPayload pf: {
this.Ui.Plugin.Functions.OpenPartyFinder(pf.Id);
Ui.Plugin.Functions.OpenPartyFinder(pf.Id);
break;
}
case AchievementPayload achievement: {
this.Ui.Plugin.Functions.OpenAchievement(achievement.Id);
Ui.Plugin.Functions.OpenAchievement(achievement.Id);
break;
}
case RawPayload raw: {
@@ -335,7 +342,7 @@ internal sealed class PayloadHandler {
var payloads = source.Payloads.Skip(start).Take(end - start + 1).ToList();
if (!Plugin.ChatGui.RegisteredLinkHandlers.TryGetValue((link.Plugin, link.CommandId), out var value))
{
Plugin.Log.Warning("could not find dalamudLinkHandlers");
Plugin.Log.Warning("Could not find DalamudLinkHandlers");
return;
}
@@ -349,13 +356,13 @@ internal sealed class PayloadHandler {
}
private void RightClickPayload(Chunk chunk, Payload? payload) {
this.Popup = (chunk, payload);
Popup = (chunk, payload);
ImGui.OpenPopup(PopupId);
}
private void DrawItemPopup(ItemPayload payload) {
if (payload.Kind == ItemPayload.ItemKind.EventItem) {
this.DrawEventItemPopup(payload);
DrawEventItemPopup(payload);
return;
}
@@ -366,7 +373,7 @@ internal sealed class PayloadHandler {
var hq = payload.Kind == ItemPayload.ItemKind.Hq;
if (this.Ui.Plugin.TextureCache.GetItem(item, hq) is { } icon) {
if (Ui.Plugin.TextureCache.GetItem(item, hq) is { } icon) {
InlineIcon(icon);
}
@@ -378,33 +385,32 @@ internal sealed class PayloadHandler {
name.Payloads.Add(new TextPayload(" "));
}
this.Log.DrawChunks(ChunkUtil.ToChunks(name, ChunkSource.None, null).ToList(), false);
Log.DrawChunks(ChunkUtil.ToChunks(name, ChunkSource.None, null).ToList(), false);
ImGui.Separator();
var realItemId = payload.RawItemId;
if (item.EquipSlotCategory.Row != 0) {
if (ImGui.Selectable(Language.Context_TryOn)) {
this.Ui.Plugin.Functions.Context.TryOn(realItemId, 0);
Ui.Plugin.Functions.Context.TryOn(realItemId, 0);
}
if (ImGui.Selectable(Language.Context_ItemComparison)) {
this.Ui.Plugin.Functions.Context.OpenItemComparison(realItemId);
Ui.Plugin.Functions.Context.OpenItemComparison(realItemId);
}
}
if (item.ItemSearchCategory.Value?.Category == 3) {
if (ImGui.Selectable(Language.Context_SearchRecipes)) {
this.Ui.Plugin.Functions.Context.SearchForRecipesUsingItem(payload.ItemId);
Ui.Plugin.Functions.Context.SearchForRecipesUsingItem(payload.ItemId);
}
}
if (ImGui.Selectable(Language.Context_SearchForItem)) {
this.Ui.Plugin.Functions.Context.SearchForItem(realItemId);
Ui.Plugin.Functions.Context.SearchForItem(realItemId);
}
if (ImGui.Selectable(Language.Context_Link)) {
this.Ui.Plugin.Functions.Context.LinkItem(realItemId);
Ui.Plugin.Functions.Context.LinkItem(realItemId);
}
if (ImGui.Selectable(Language.Context_CopyItemName)) {
@@ -422,18 +428,17 @@ internal sealed class PayloadHandler {
return;
}
if (this.Ui.Plugin.TextureCache.GetEventItem(item) is { } icon) {
if (Ui.Plugin.TextureCache.GetEventItem(item) is { } icon) {
InlineIcon(icon);
}
var name = item.Name.ToDalamudString();
this.Log.DrawChunks(ChunkUtil.ToChunks(name, ChunkSource.None, null).ToList(), false);
Log.DrawChunks(ChunkUtil.ToChunks(name, ChunkSource.None, null).ToList(), false);
ImGui.Separator();
var realItemId = payload.RawItemId;
if (ImGui.Selectable(Language.Context_Link)) {
this.Ui.Plugin.Functions.Context.LinkItem(realItemId);
Ui.Plugin.Functions.Context.LinkItem(realItemId);
}
if (ImGui.Selectable(Language.Context_CopyItemName)) {
@@ -448,7 +453,6 @@ internal sealed class PayloadHandler {
return;
var world = player.World;
if (chunk.Message?.Code.Type == ChatType.FreeCompanyLoginLogout) {
if (Plugin.ClientState.LocalPlayer?.HomeWorld.GameData is { } homeWorld) {
world = homeWorld;
@@ -463,40 +467,41 @@ internal sealed class PayloadHandler {
});
}
this.Log.DrawChunks(name, false);
Log.DrawChunks(name, false);
ImGui.Separator();
if (ImGui.Selectable(Language.Context_SendTell)) {
this.Log.Chat = $"/tell {player.PlayerName}";
Log.Chat = $"/tell {player.PlayerName}";
if (world.IsPublic) {
this.Log.Chat += $"@{world.Name}";
Log.Chat += $"@{world.Name}";
}
this.Log.Chat += " ";
this.Log.Activate = true;
Log.Chat += " ";
Log.Activate = true;
}
var validContentId = chunk.Message?.ContentId is not (null or 0);
if (world.IsPublic) {
var party = Plugin.PartyList;
var leader = (ulong?) party[(int) party.PartyLeaderIndex]?.ContentId;
var isLeader = party.Length == 0 || Plugin.ClientState.LocalContentId == leader;
var member = party.FirstOrDefault(member => member.Name.TextValue == player.PlayerName && member.World.Id == world.RowId);
var isInParty = member != default;
var inInstance = this.Ui.Plugin.Functions.IsInInstance();
var inInstance = Ui.Plugin.Functions.IsInInstance();
var inPartyInstance = Plugin.DataManager.GetExcelSheet<TerritoryType>()!.GetRow(Plugin.ClientState.TerritoryType)?.TerritoryIntendedUse is (41 or 47 or 48 or 52 or 53);
if (isLeader) {
if (!isInParty) {
if (inInstance && inPartyInstance) {
if (chunk.Message?.ContentId is not (null or 0) && ImGui.Selectable(Language.Context_InviteToParty)) {
this.Ui.Plugin.Functions.Party.InviteInInstance(chunk.Message!.ContentId);
if (validContentId && ImGui.Selectable(Language.Context_InviteToParty)) {
Ui.Plugin.Functions.Party.InviteInInstance(chunk.Message!.ContentId);
}
} else if (!inInstance && ImGui.BeginMenu(Language.Context_InviteToParty)) {
if (ImGui.Selectable(Language.Context_InviteToParty_SameWorld)) {
this.Ui.Plugin.Functions.Party.InviteSameWorld(player.PlayerName, (ushort) world.RowId, chunk.Message?.ContentId ?? 0);
Ui.Plugin.Functions.Party.InviteSameWorld(player.PlayerName, (ushort) world.RowId, chunk.Message?.ContentId ?? 0);
}
if (chunk.Message?.ContentId is not (null or 0) && ImGui.Selectable(Language.Context_InviteToParty_DifferentWorld)) {
this.Ui.Plugin.Functions.Party.InviteOtherWorld(chunk.Message!.ContentId);
if (validContentId && ImGui.Selectable(Language.Context_InviteToParty_DifferentWorld)) {
Ui.Plugin.Functions.Party.InviteOtherWorld(chunk.Message!.ContentId);
}
ImGui.EndMenu();
@@ -505,55 +510,58 @@ internal sealed class PayloadHandler {
if (isInParty && member != null && (!inInstance || (inInstance && inPartyInstance))) {
if (ImGui.Selectable(Language.Context_Promote)) {
this.Ui.Plugin.Functions.Party.Promote(player.PlayerName, (ulong) member.ContentId);
Ui.Plugin.Functions.Party.Promote(player.PlayerName, (ulong) member.ContentId);
}
if (ImGui.Selectable(Language.Context_KickFromParty)) {
this.Ui.Plugin.Functions.Party.Kick(player.PlayerName, (ulong) member.ContentId);
Ui.Plugin.Functions.Party.Kick(player.PlayerName, (ulong) member.ContentId);
}
}
}
var isFriend = this.Ui.Plugin.Common.Functions.FriendList.List.Any(friend => friend.Name.TextValue == player.PlayerName && friend.HomeWorld == world.RowId);
var isFriend = Ui.Plugin.Common.Functions.FriendList.List.Any(friend => friend.Name.TextValue == player.PlayerName && friend.HomeWorld == world.RowId);
if (!isFriend && ImGui.Selectable(Language.Context_SendFriendRequest)) {
this.Ui.Plugin.Functions.SendFriendRequest(player.PlayerName, (ushort) world.RowId);
Ui.Plugin.Functions.SendFriendRequest(player.PlayerName, (ushort) world.RowId);
}
if (ImGui.Selectable(Language.Context_AddToBlacklist)) {
this.Ui.Plugin.Functions.AddToBlacklist(player.PlayerName, (ushort) world.RowId);
Ui.Plugin.Functions.AddToBlacklist(player.PlayerName, (ushort) world.RowId);
}
if (this.Ui.Plugin.Functions.IsMentor() && ImGui.Selectable(Language.Context_InviteToNoviceNetwork)) {
this.Ui.Plugin.Functions.Context.InviteToNoviceNetwork(player.PlayerName, (ushort) world.RowId);
if (Ui.Plugin.Functions.IsMentor() && ImGui.Selectable(Language.Context_InviteToNoviceNetwork)) {
Ui.Plugin.Functions.Context.InviteToNoviceNetwork(player.PlayerName, (ushort) world.RowId);
}
}
var inputChannel = chunk.Message?.Code.Type.ToInputChannel();
if (inputChannel != null && ImGui.Selectable(Language.Context_ReplyInSelectedChatMode)) {
this.Ui.Plugin.Functions.Chat.SetChannel(inputChannel.Value);
this.Log.Activate = true;
Ui.Plugin.Functions.Chat.SetChannel(inputChannel.Value);
Log.Activate = true;
}
if (ImGui.Selectable(Language.Context_Target) && this.FindCharacterForPayload(player) is { } obj) {
if (ImGui.Selectable(Language.Context_Target) && FindCharacterForPayload(player) is { } obj) {
Plugin.TargetManager.Target = obj;
}
if (validContentId && ImGui.Selectable(Language.Context_AdventurerPlate))
{
if (!Ui.Plugin.Functions.TryOpenAdventurerPlate(chunk.Message!.ContentId))
WrapperUtil.AddNotification(Language.Context_AdventurerPlateError, NotificationType.Warning);
}
// View Party Finder 0x2E
}
private PlayerCharacter? FindCharacterForPayload(PlayerPayload payload) {
foreach (var obj in Plugin.ObjectTable) {
if (obj is not PlayerCharacter character) {
if (obj is not PlayerCharacter character)
continue;
}
if (character.Name.TextValue != payload.PlayerName) {
if (character.Name.TextValue != payload.PlayerName)
continue;
}
if (payload.World.IsPublic && character.HomeWorld.Id != payload.World.RowId) {
if (payload.World.IsPublic && character.HomeWorld.Id != payload.World.RowId)
continue;
}
return character;
}
+1
View File
@@ -31,6 +31,7 @@ public sealed class Plugin : IDalamudPlugin {
[PluginService] internal static ITextureProvider TextureProvider { get; private set; } = null!;
[PluginService] internal static IGameInteropProvider GameInteropProvider { get; private set; } = null!;
[PluginService] internal static IGameConfig GameConfig { get; private set; } = null!;
[PluginService] internal static INotificationManager Notification { get; private set; } = null!;
internal Configuration Config { get; }
internal Commands Commands { get; }
+2017 -1244
View File
File diff suppressed because it is too large Load Diff
+6
View File
@@ -862,4 +862,10 @@
<data name="Migration_Line4">
<value>Do not close FFXIV, unload Dalamud, or turn off your computer during this time.</value>
</data>
<data name="Context_AdventurerPlate" xml:space="preserve">
<value>View Adventurer Plate</value>
</data>
<data name="Context_AdventurerPlateError" xml:space="preserve">
<value>Unable to open adventurer plate at this moment</value>
</data>
</root>
+12
View File
@@ -0,0 +1,12 @@
using Dalamud.Interface.ImGuiNotification;
using Dalamud.Interface.Internal.Notifications;
namespace ChatTwo.Util;
public static class WrapperUtil
{
public static void AddNotification(string content, NotificationType type, bool minimized = true)
{
Plugin.Notification.AddNotification(new Notification { Content = content, Type = type, Minimized = minimized });
}
}