1
1
namespace nael
2
2
{
3
+ using System ;
3
4
using System . Collections . Generic ;
4
5
using System . IO ;
6
+ using System . Linq ;
5
7
using System . Reflection ;
6
8
using System . Text . Json ;
7
9
using Dalamud . Game ;
8
- using Dalamud . Game . Text ;
9
10
using Dalamud . Game . Command ;
11
+ using Dalamud . Game . Text ;
10
12
using Dalamud . Game . Text . SeStringHandling ;
11
13
using Dalamud . Game . Text . SeStringHandling . Payloads ;
12
14
using Dalamud . IoC ;
13
15
using Dalamud . Plugin ;
14
16
using Dalamud . Plugin . Services ;
17
+ using FFXIVClientStructs . FFXIV . Client . UI ;
15
18
using FuzzySharp ;
16
19
using ImGuiNET ;
17
20
@@ -33,6 +36,9 @@ public class NaelPlugin : IDalamudPlugin
33
36
private string configDive ;
34
37
private string configMeteorStream ;
35
38
private string configSeparator ;
39
+
40
+ private bool gimmickText ;
41
+ private int gimmickDuration ;
36
42
37
43
private readonly NaelQuotes naelQuotes ;
38
44
private Dictionary < string , string > naelQuotesDictionary ;
@@ -48,10 +54,11 @@ public NaelPlugin(IDalamudPluginInterface dalamudPluginInterface, IChatGui chatG
48
54
49
55
dalamudPluginInterface . UiBuilder . Draw += DrawConfiguration ;
50
56
dalamudPluginInterface . UiBuilder . OpenConfigUi += OpenConfig ;
57
+ dalamudPluginInterface . UiBuilder . OpenMainUi += OpenConfig ;
51
58
52
59
commandManager . AddHandler ( commandName , new CommandInfo ( NaelCommand )
53
60
{
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" ,
55
62
ShowInHelp = true
56
63
} ) ;
57
64
@@ -73,26 +80,48 @@ private void NaelCommand(string command, string args)
73
80
OpenConfig ( ) ;
74
81
break ;
75
82
case "test" :
76
- TestPlugin ( ) ;
83
+ PrintAllQuotes ( ) ;
84
+ break ;
85
+ case "random" :
86
+ PrintRandomQuote ( ) ;
77
87
break ;
78
88
default :
79
89
{
80
90
configuration . Enabled = ! configuration . Enabled ;
81
91
configuration . Save ( ) ;
82
92
83
- var pluginStatus = configuration . Enabled ? "enabled" : "disabled" ;
93
+ var pluginStatus = configuration . Enabled ? "translation enabled" : "translation disabled" ;
84
94
chatGui . Print ( $ "{ Name } { pluginStatus } ") ;
85
95
break ;
86
96
}
87
97
}
88
98
}
89
99
90
- private void TestPlugin ( )
100
+ private void PrintAllQuotes ( )
91
101
{
92
102
foreach ( var quote in naelQuotes . Quotes )
93
103
chatGui . Print ( NaelMessage ( $ "{ GetQuote ( quote . ID ) } ") ) ;
94
104
}
95
105
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
+
96
125
private static XivChatEntry NaelMessage ( string message )
97
126
{
98
127
var entry = new XivChatEntry
@@ -107,19 +136,25 @@ private static XivChatEntry NaelMessage(string message)
107
136
108
137
private void OnChatMessage ( XivChatType type , int timestamp , ref SeString sender , ref SeString message , ref bool handled )
109
138
{
110
- if ( ! configuration . Enabled )
111
- return ;
112
-
113
139
if ( type != XivChatType . NPCDialogueAnnouncements )
114
140
return ;
115
141
116
142
foreach ( var payload in message . Payloads )
117
143
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 ) ;
120
150
}
121
151
}
122
152
153
+ private static unsafe void ShowTextGimmick ( string message , int durationInSeconds )
154
+ {
155
+ RaptureAtkModule . Instance ( ) ->ShowTextGimmickHint ( message , RaptureAtkModule . TextGimmickHintStyle . Warning , durationInSeconds * 10 ) ;
156
+ }
157
+
123
158
/// <summary>
124
159
/// checks the chat message for any Nael quote and replaces it with the mechanics
125
160
/// </summary>
@@ -197,7 +232,23 @@ private void DrawConfiguration()
197
232
ImGui . Text ( $ "Nael deus Darnus: { configBeam } { configSeparator } { configChariot } ") ;
198
233
ImGui . Text ( $ "Nael deus Darnus: { configDynamo } { configSeparator } { configDive } { configSeparator } { configMeteorStream } ") ;
199
234
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 ( ) ;
201
252
202
253
if ( ImGui . Button ( "Save and Close" ) )
203
254
{
@@ -206,12 +257,6 @@ private void DrawConfiguration()
206
257
drawConfiguration = false ;
207
258
}
208
259
209
- ImGui . SameLine ( ) ;
210
-
211
- if ( ImGui . Button ( "Test all quotes" ) )
212
- {
213
- TestPlugin ( ) ;
214
- }
215
260
216
261
ImGui . End ( ) ;
217
262
}
@@ -229,6 +274,8 @@ private void LoadConfiguration()
229
274
configDive = configuration . Dive ;
230
275
configMeteorStream = configuration . MeteorStream ;
231
276
configSeparator = configuration . Separator ;
277
+ gimmickText = configuration . GimmickText ;
278
+ gimmickDuration = configuration . GimmickDuration ;
232
279
}
233
280
234
281
private void SaveConfiguration ( )
@@ -239,6 +286,8 @@ private void SaveConfiguration()
239
286
configuration . Dive = configDive ;
240
287
configuration . MeteorStream = configMeteorStream ;
241
288
configuration . Separator = configSeparator ;
289
+ configuration . GimmickText = gimmickText ;
290
+ configuration . GimmickDuration = gimmickDuration ;
242
291
243
292
PluginInterface . SavePluginConfig ( configuration ) ;
244
293
}
0 commit comments