feat: show pf description in chat after joining

This commit is contained in:
Anna 2021-05-01 23:06:28 -04:00
parent fc5228eec6
commit 8474835661
6 changed files with 56 additions and 8 deletions

View File

@ -9,7 +9,7 @@
<ItemGroup>
<Reference Include="Dalamud">
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\5.2.4.3\Dalamud.dll</HintPath>
<HintPath>$(AppData)\XIVLauncher\addon\Hooks\dev\Dalamud.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="ImGui.NET">
@ -35,10 +35,10 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="DalamudPackager" Version="1.2.1" />
<PackageReference Include="Fody" Version="6.5.1" PrivateAssets="all" />
<PackageReference Include="ILMerge.Fody" Version="1.16.0" PrivateAssets="all" />
<PackageReference Include="XivCommon" Version="1.3.0" />
<PackageReference Include="DalamudPackager" Version="1.2.1"/>
<PackageReference Include="Fody" Version="6.5.1" PrivateAssets="all"/>
<PackageReference Include="ILMerge.Fody" Version="1.16.0" PrivateAssets="all"/>
<PackageReference Include="XivCommon" Version="1.5.0"/>
</ItemGroup>
</Project>

View File

@ -28,7 +28,7 @@ namespace BetterPartyFinder {
}
private void OnCommand(string command, string args) {
if (args == "c" || args == "config") {
if (args is "c" or "config") {
this.Plugin.Ui.SettingsVisible = !this.Plugin.Ui.SettingsVisible;
} else {
this.Plugin.Ui.Visible = !this.Plugin.Ui.Visible;

View File

@ -15,6 +15,7 @@ namespace BetterPartyFinder {
public bool ShowWhenPfOpen { get; set; }
public WindowSide WindowSide { get; set; } = WindowSide.Left;
public bool ShowDescriptionOnJoin { get; set; } = true;
internal static Configuration? Load(Plugin plugin) {
return (Configuration?) plugin.Interface.GetPluginConfig();

View File

@ -0,0 +1,35 @@
using System;
using Dalamud.Game.Internal.Gui.Structs;
using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
namespace BetterPartyFinder {
public class JoinHandler : IDisposable {
private Plugin Plugin { get; }
internal JoinHandler(Plugin plugin) {
this.Plugin = plugin;
this.Plugin.Common.Functions.PartyFinder.JoinParty += this.OnJoin;
}
public void Dispose() {
this.Plugin.Common.Functions.PartyFinder.JoinParty -= this.OnJoin;
}
private void OnJoin(PartyFinderListing listing) {
if (!this.Plugin.Config.ShowDescriptionOnJoin) {
return;
}
SeString msg = "Party description: ";
msg.Payloads.AddRange(listing.Description.Payloads);
this.Plugin.Interface.Framework.Gui.Chat.PrintChat(new XivChatEntry {
Name = "Better Party Finder",
Type = XivChatType.SystemMessage,
MessageBytes = msg.Encode(),
});
}
}
}

View File

@ -2,15 +2,17 @@
using XivCommon;
namespace BetterPartyFinder {
// ReSharper disable once ClassNeverInstantiated.Global
public class Plugin : IDalamudPlugin {
public string Name => "Better Party Finder";
internal DalamudPluginInterface Interface { get; private set; } = null!;
internal Configuration Config { get; private set; } = null!;
private Filter Filter { get; set; } = null!;
internal PluginUi Ui { get; set; } = null!;
internal PluginUi Ui { get; private set; } = null!;
private Commands Commands { get; set; } = null!;
internal XivCommonBase Common { get; set; } = null!;
internal XivCommonBase Common { get; private set; } = null!;
private JoinHandler JoinHandler { get; set; } = null!;
public void Initialize(DalamudPluginInterface pluginInterface) {
this.Interface = pluginInterface;
@ -20,6 +22,7 @@ namespace BetterPartyFinder {
this.Common = new XivCommonBase(this.Interface, Hooks.PartyFinder);
this.Filter = new Filter(this);
this.JoinHandler = new JoinHandler(this);
this.Ui = new PluginUi(this);
this.Commands = new Commands(this);
@ -30,6 +33,7 @@ namespace BetterPartyFinder {
public void Dispose() {
this.Commands.Dispose();
this.Ui.Dispose();
this.JoinHandler.Dispose();
this.Filter.Dispose();
this.Common.Dispose();
}

View File

@ -114,6 +114,14 @@ namespace BetterPartyFinder {
this.Plugin.Config.Save();
}
ImGui.Separator();
var showDesc = this.Plugin.Config.ShowDescriptionOnJoin;
if (ImGui.Checkbox("Show PF description in chat after joining", ref showDesc)) {
this.Plugin.Config.ShowDescriptionOnJoin = showDesc;
this.Plugin.Config.Save();
}
ImGui.End();
}