Skip to content

Commit 7f34bd8

Browse files
committed
added optional DT text popup
1 parent ae0237a commit 7f34bd8

File tree

4 files changed

+77
-22
lines changed

4 files changed

+77
-22
lines changed

nael/nael/Configuration.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ public class Configuration : IPluginConfiguration
1414
public string Dive { get; set; } = "DIVE";
1515
public string MeteorStream { get; set; } = "SPREAD";
1616
public string Separator { get; set; } = ">";
17+
public bool GimmickText { get; set; }
18+
public int GimmickDuration { get; set; } = 5;
1719

1820

1921
private IDalamudPluginInterface pluginInterface;

nael/nael/NaelPlugin.cs

Lines changed: 66 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
namespace nael
22
{
3+
using System;
34
using System.Collections.Generic;
45
using System.IO;
6+
using System.Linq;
57
using System.Reflection;
68
using System.Text.Json;
79
using Dalamud.Game;
8-
using Dalamud.Game.Text;
910
using Dalamud.Game.Command;
11+
using Dalamud.Game.Text;
1012
using Dalamud.Game.Text.SeStringHandling;
1113
using Dalamud.Game.Text.SeStringHandling.Payloads;
1214
using Dalamud.IoC;
1315
using Dalamud.Plugin;
1416
using Dalamud.Plugin.Services;
17+
using FFXIVClientStructs.FFXIV.Client.UI;
1518
using FuzzySharp;
1619
using ImGuiNET;
1720

@@ -33,6 +36,9 @@ public class NaelPlugin : IDalamudPlugin
3336
private string configDive;
3437
private string configMeteorStream;
3538
private string configSeparator;
39+
40+
private bool gimmickText;
41+
private int gimmickDuration;
3642

3743
private readonly NaelQuotes naelQuotes;
3844
private Dictionary<string, string> naelQuotesDictionary;
@@ -48,10 +54,11 @@ public NaelPlugin(IDalamudPluginInterface dalamudPluginInterface, IChatGui chatG
4854

4955
dalamudPluginInterface.UiBuilder.Draw += DrawConfiguration;
5056
dalamudPluginInterface.UiBuilder.OpenConfigUi += OpenConfig;
57+
dalamudPluginInterface.UiBuilder.OpenMainUi += OpenConfig;
5158

5259
commandManager.AddHandler(commandName, new CommandInfo(NaelCommand)
5360
{
54-
HelpMessage = "toggle the plugin\n/nael test → print test quotes\n/nael cfg → open the configuration window",
61+
HelpMessage = "toggle the translation\n/nael test → print test quotes\n/nael random → print random quote\n/nael cfg → open the configuration window",
5562
ShowInHelp = true
5663
});
5764

@@ -73,26 +80,48 @@ private void NaelCommand(string command, string args)
7380
OpenConfig();
7481
break;
7582
case "test":
76-
TestPlugin();
83+
PrintAllQuotes();
84+
break;
85+
case "random":
86+
PrintRandomQuote();
7787
break;
7888
default:
7989
{
8090
configuration.Enabled = !configuration.Enabled;
8191
configuration.Save();
8292

83-
var pluginStatus = configuration.Enabled ? "enabled" : "disabled";
93+
var pluginStatus = configuration.Enabled ? "translation enabled" : "translation disabled";
8494
chatGui.Print($"{Name} {pluginStatus}");
8595
break;
8696
}
8797
}
8898
}
8999

90-
private void TestPlugin()
100+
private void PrintAllQuotes()
91101
{
92102
foreach (var quote in naelQuotes.Quotes)
93103
chatGui.Print(NaelMessage($"{GetQuote(quote.ID)}"));
94104
}
95105

106+
private void PrintRandomQuote()
107+
{
108+
var number = new Random().Next(0, naelQuotes.Quotes.Count);
109+
var quote = naelQuotes.Quotes[number].ID;
110+
chatGui.Print(NaelMessage($"{GetQuote(quote)}"));
111+
}
112+
113+
private static bool CheckForNael(string name)
114+
{
115+
var names = new string[]
116+
{
117+
"Nael deus Darnus", //EN/DE/FR
118+
"ネール・デウス・ダーナス", //JA
119+
"奈尔·神·达纳斯", //CN
120+
};
121+
122+
return names.Contains(name);
123+
}
124+
96125
private static XivChatEntry NaelMessage(string message)
97126
{
98127
var entry = new XivChatEntry
@@ -107,19 +136,25 @@ private static XivChatEntry NaelMessage(string message)
107136

108137
private void OnChatMessage(XivChatType type, int timestamp, ref SeString sender, ref SeString message, ref bool handled)
109138
{
110-
if (!configuration.Enabled)
111-
return;
112-
113139
if (type != XivChatType.NPCDialogueAnnouncements)
114140
return;
115141

116142
foreach (var payload in message.Payloads)
117143
if (payload is TextPayload { Text: not null } textPayload)
118-
{
119-
textPayload.Text = NaelIt(textPayload.Text);
144+
{
145+
if (configuration.Enabled)
146+
textPayload.Text = NaelIt(textPayload.Text);
147+
148+
if (gimmickText && CheckForNael(sender.TextValue))
149+
ShowTextGimmick(textPayload.Text, gimmickDuration);
120150
}
121151
}
122152

153+
private static unsafe void ShowTextGimmick(string message, int durationInSeconds)
154+
{
155+
RaptureAtkModule.Instance()->ShowTextGimmickHint(message, RaptureAtkModule.TextGimmickHintStyle.Warning, durationInSeconds * 10);
156+
}
157+
123158
/// <summary>
124159
/// checks the chat message for any Nael quote and replaces it with the mechanics
125160
/// </summary>
@@ -197,7 +232,23 @@ private void DrawConfiguration()
197232
ImGui.Text($"Nael deus Darnus: {configBeam} {configSeparator} {configChariot}");
198233
ImGui.Text($"Nael deus Darnus: {configDynamo} {configSeparator} {configDive} {configSeparator} {configMeteorStream}");
199234

200-
ImGui.Separator();
235+
ImGui.Separator();
236+
237+
ImGui.Checkbox("Show Dawntrail Mechanic Text", ref gimmickText);
238+
ImGui.SliderInt("Display Duration", ref gimmickDuration, 1, 10);
239+
240+
ImGui.Separator();
241+
242+
if (ImGui.Button("Test random quote"))
243+
PrintRandomQuote();
244+
245+
ImGui.SameLine();
246+
247+
if (ImGui.Button("Test all quotes"))
248+
PrintAllQuotes();
249+
250+
251+
ImGui.Separator();
201252

202253
if (ImGui.Button("Save and Close"))
203254
{
@@ -206,12 +257,6 @@ private void DrawConfiguration()
206257
drawConfiguration = false;
207258
}
208259

209-
ImGui.SameLine();
210-
211-
if (ImGui.Button("Test all quotes"))
212-
{
213-
TestPlugin();
214-
}
215260

216261
ImGui.End();
217262
}
@@ -229,6 +274,8 @@ private void LoadConfiguration()
229274
configDive = configuration.Dive;
230275
configMeteorStream = configuration.MeteorStream;
231276
configSeparator = configuration.Separator;
277+
gimmickText = configuration.GimmickText;
278+
gimmickDuration = configuration.GimmickDuration;
232279
}
233280

234281
private void SaveConfiguration()
@@ -239,6 +286,8 @@ private void SaveConfiguration()
239286
configuration.Dive = configDive;
240287
configuration.MeteorStream = configMeteorStream;
241288
configuration.Separator = configSeparator;
289+
configuration.GimmickText = gimmickText;
290+
configuration.GimmickDuration = gimmickDuration;
242291

243292
PluginInterface.SavePluginConfig(configuration);
244293
}

nael/nael/NaelPlugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"Name": "Nael'd it for UCOB",
44
"Description": "Translates Nael's quotes into mechanics.",
55
"Punchline": "because reading chat is not a mechanic",
6-
"Changelog": "- updated for Dalamud api11",
6+
"Changelog": "- added optional Dawntrail Text popup",
77
"InternalName": "NaelPlugin",
88
"Tags": ["ui"],
99
"RepoUrl": "https://github.com/Eisenhuth/dalamud-nael",

nael/nael/nael.csproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
1010
<OutputPath>$(AppData)\Eisenhuth\DalamudDevPlugins\NaelPlugin\</OutputPath>
1111
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
12-
<AssemblyVersion>1.4.6.0</AssemblyVersion>
12+
<AssemblyVersion>1.5.0.0</AssemblyVersion>
1313
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
1414
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
1515
<PackageProjectUrl>https://github.com/Eisenhuth/dalamud-nael</PackageProjectUrl>
@@ -41,16 +41,20 @@
4141
</ItemGroup>
4242

4343
<PropertyGroup>
44-
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
44+
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev</DalamudLibPath>
4545
</PropertyGroup>
4646

4747
<ItemGroup>
4848
<Reference Include="Dalamud">
49-
<HintPath>$(DalamudLibPath)Dalamud.dll</HintPath>
49+
<HintPath>$(DalamudLibPath)\Dalamud.dll</HintPath>
5050
<Private>false</Private>
5151
</Reference>
5252
<Reference Include="ImGui">
53-
<HintPath>$(DalamudLibPath)ImGui.NET.dll</HintPath>
53+
<HintPath>$(DalamudLibPath)\ImGui.NET.dll</HintPath>
54+
<Private>false</Private>
55+
</Reference>
56+
<Reference Include="FFXIVClientStructs">
57+
<HintPath>$(DalamudLibPath)\FFXIVClientStructs.dll</HintPath>
5458
<Private>false</Private>
5559
</Reference>
5660
</ItemGroup>

0 commit comments

Comments
 (0)