7
7
using System ;
8
8
using System . Collections . Generic ;
9
9
using System . Globalization ;
10
+ using System . Linq ;
10
11
using UnityEngine ;
11
12
12
13
namespace Oxide . Plugins
@@ -166,7 +167,8 @@ protected override void LoadDefaultMessages()
166
167
lang . RegisterMessages ( new Dictionary < string , string >
167
168
{
168
169
{ "Help" , "Usage:\n {0}" } ,
169
- { "Description" , "Automatically set the code on code locks you place.\n \n Code: {0}\n Guest Code: {1}\n Quiet Mode: {2}" } ,
170
+ { "Description" , "Automatically set the code on code locks you place." } ,
171
+ { "Info" , "Code: {0}\n Guest Code: {1}\n Quiet Mode: {2}" } ,
170
172
{ "NoPermission" , "You don't have permission." } ,
171
173
{ "CodeAutoLocked" , "Code lock placed with code {0}." } ,
172
174
{ "CodeAutoLockedWithGuest" , "Code lock placed with code {0} and guest code {1}." } ,
@@ -185,10 +187,21 @@ protected override void LoadDefaultMessages()
185
187
{ "ErrorMoreThanOnePlayerFound" , "Error: More than one player found." } ,
186
188
{ "ResettingAllLockOuts" , "Resetting lock outs for all players." } ,
187
189
{ "ResettingLockOut" , "Resetting lock outs for {0}." } ,
188
- { "QuietModeEnable" , "Quiet mode now enabled.\n Less messages will be shown and your auto-code will be hidden. " } ,
190
+ { "QuietModeEnable" , "Quiet mode now enabled." } ,
189
191
{ "QuietModeDisable" , "Quiet mode now disabled." } ,
190
192
{ "Enabled" , "Enabled" } ,
191
- { "Disabled" , "Disabled" }
193
+ { "Disabled" , "Disabled" } ,
194
+ { "HelpExtendedCoreCommands" , "Core Commands:" } ,
195
+ { "HelpExtendedOtherCommands" , "Other Commands:" } ,
196
+ { "HelpExtendedInfo" , "Show your settings:\n {0}" } ,
197
+ { "HelpExtendedSetCode" , "Set your auto-code to 1234:\n {0}" } ,
198
+ { "HelpExtendedPickCode" , "Open the code lock interface to set your auto-code:\n {0}" } ,
199
+ { "HelpExtendedRandomCode" , "Set your auto-code to a randomly generated code:\n {0}" } ,
200
+ { "HelpExtendedRemoveCode" , "Remove your set auto-code:\n {0}" } ,
201
+ { "HelpExtendedCoreGuestCommands" , "Each core command is also avalibale in a guest code version. e.g.\n {0}" } ,
202
+ { "HelpExtendedQuietMode" , "Toggles on/off quiet mode:\n {0}" } ,
203
+ { "HelpExtendedQuietModeDetails" , "Less messages will be shown and your auto-code will be hidden." } ,
204
+ { "HelpExtendedHelp" , "Displays this help message:\n {0}" } ,
192
205
} , this ) ;
193
206
}
194
207
@@ -314,7 +327,7 @@ public void SetCode(BasePlayer player, string code, bool guest = false, bool qui
314
327
? lang . GetMessage ( guest ? "GuestCodeUpdatedHidden" : "CodeUpdatedHidden" , this , player . UserIDString )
315
328
: string . Format (
316
329
lang . GetMessage ( guest ? "GuestCodeUpdated" : "CodeUpdated" , this , player . UserIDString ) ,
317
- code
330
+ Formatter . Value ( code )
318
331
)
319
332
) ;
320
333
}
@@ -465,10 +478,24 @@ public void ToggleQuietMode(BasePlayer player, bool quiet = false)
465
478
466
479
if ( ! quiet )
467
480
{
468
- Message (
469
- player ,
470
- lang . GetMessage ( settings . quietMode ? "QuietModeEnable" : "QuietModeDisable" , this , player . UserIDString )
471
- ) ;
481
+ if ( settings . quietMode )
482
+ {
483
+ Message (
484
+ player ,
485
+ string . Format (
486
+ "{0}\n " + Formatter . SmallLineGap + "{1}" ,
487
+ lang . GetMessage ( "QuietModeEnable" , this , player . UserIDString ) ,
488
+ lang . GetMessage ( "HelpExtendedQuietModeDetails" , this , player . UserIDString )
489
+ )
490
+ ) ;
491
+ }
492
+ else
493
+ {
494
+ Message (
495
+ player ,
496
+ lang . GetMessage ( "QuietModeDisable" , this , player . UserIDString )
497
+ ) ;
498
+ }
472
499
}
473
500
}
474
501
@@ -820,6 +847,7 @@ private class Commands
820
847
public string RemoveCode = "remove" ;
821
848
public string SetCode = "set" ;
822
849
public string QuietMode = "quiet" ;
850
+ public string Help = "help" ;
823
851
824
852
public Commands ( AutoCode plugin )
825
853
{
@@ -975,6 +1003,13 @@ private void HandleUse(BasePlayer player, string label, string[] args)
975
1003
argsRemainingCount -- ;
976
1004
}
977
1005
1006
+ // Help.
1007
+ if ( operation == Help )
1008
+ {
1009
+ plugin . Message ( player , GetHelpExtended ( player , label ) ) ;
1010
+ return ;
1011
+ }
1012
+
978
1013
// Pick code.
979
1014
if ( operation == PickCode )
980
1015
{
@@ -1096,12 +1131,13 @@ private void ShowInfo(BasePlayer player, string label, string[] args)
1096
1131
plugin . Message (
1097
1132
player ,
1098
1133
string . Format (
1099
- "{0}\n \n {1}" ,
1134
+ "{0}\n " + Formatter . SmallLineGap + "{1}\n " + Formatter . SmallLineGap + "{2}" ,
1135
+ Formatter . H2 ( plugin . lang . GetMessage ( "Description" , plugin , player . UserIDString ) ) ,
1100
1136
string . Format (
1101
- plugin . lang . GetMessage ( "Description " , plugin , player . UserIDString ) ,
1102
- code ?? plugin . lang . GetMessage ( "NotSet" , plugin , player . UserIDString ) ,
1103
- guestCode ?? plugin . lang . GetMessage ( "NotSet" , plugin , player . UserIDString ) ,
1104
- plugin . lang . GetMessage ( quietMode ? "Enabled" : "Disabled" , plugin , player . UserIDString )
1137
+ plugin . lang . GetMessage ( "Info " , plugin , player . UserIDString ) ,
1138
+ code != null ? Formatter . Value ( code ) : Formatter . NoValue ( plugin . lang . GetMessage ( "NotSet" , plugin , player . UserIDString ) ) ,
1139
+ guestCode != null ? Formatter . Value ( guestCode ) : Formatter . NoValue ( plugin . lang . GetMessage ( "NotSet" , plugin , player . UserIDString ) ) ,
1140
+ quietMode ? Formatter . Value ( plugin . lang . GetMessage ( "Enabled" , plugin , player . UserIDString ) ) : Formatter . NoValue ( plugin . lang . GetMessage ( "Disabled" , plugin , player . UserIDString ) )
1105
1141
) ,
1106
1142
GetHelp ( player , label )
1107
1143
)
@@ -1138,27 +1174,87 @@ public string GetHelp(BasePlayer player, string label)
1138
1174
/// </summary>
1139
1175
/// <returns></returns>
1140
1176
private string GetUsage ( string label )
1177
+ {
1178
+ return Formatter . Command (
1179
+ string . Format (
1180
+ "{0} [<{1}>]" ,
1181
+ label ,
1182
+ string . Join ( "|" , new string [ ] {
1183
+ string . Format (
1184
+ "[{0}] <{1}>" ,
1185
+ Guest ,
1186
+ string . Join ( "|" , new string [ ] {
1187
+ string . Format (
1188
+ "[{0}] {1}" ,
1189
+ SetCode ,
1190
+ "1234"
1191
+ ) ,
1192
+ PickCode ,
1193
+ RandomCode ,
1194
+ RemoveCode
1195
+ } )
1196
+ ) ,
1197
+ QuietMode ,
1198
+ Help
1199
+ } )
1200
+ )
1201
+ ) ;
1202
+ }
1203
+
1204
+ /// <summary>
1205
+ /// Display an extended help messsage to the player.
1206
+ /// </summary>
1207
+ public string GetHelpExtended ( BasePlayer player , string label )
1141
1208
{
1142
1209
return string . Format (
1143
- "{0} <{1}>" ,
1144
- label ,
1145
- string . Join ( "|" , new string [ ] {
1146
- string . Format (
1147
- "[{0}] <{1}>" ,
1148
- Guest ,
1149
- string . Join ( "|" , new string [ ] {
1210
+ "{0}" ,
1211
+ string . Join (
1212
+ "\n " + Formatter . SmallLineGap ,
1213
+ string . Join (
1214
+ "\n " + Formatter . SmallLineGap ,
1215
+ Formatter . H2 ( plugin . lang . GetMessage ( "HelpExtendedCoreCommands" , plugin , player . UserIDString ) ) ,
1216
+ Formatter . UL (
1217
+ string . Format (
1218
+ plugin . lang . GetMessage ( "HelpExtendedInfo" , plugin , player . UserIDString ) ,
1219
+ Formatter . Indent ( Formatter . Command ( string . Format ( "{0}" , label ) ) )
1220
+ ) ,
1150
1221
string . Format (
1151
- "[{0}] {1}" ,
1152
- SetCode ,
1153
- "1234"
1222
+ plugin . lang . GetMessage ( "HelpExtendedSetCode" , plugin , player . UserIDString ) ,
1223
+ Formatter . Indent ( Formatter . Command ( string . Format ( "{0} {1}" , label , "1234" ) ) )
1154
1224
) ,
1155
- PickCode ,
1156
- RandomCode ,
1157
- RemoveCode
1158
- } )
1225
+ string . Format (
1226
+ plugin . lang . GetMessage ( "HelpExtendedPickCode" , plugin , player . UserIDString ) ,
1227
+ Formatter . Indent ( Formatter . Command ( string . Format ( "{0} {1}" , label , PickCode ) ) )
1228
+ ) ,
1229
+ string . Format (
1230
+ plugin . lang . GetMessage ( "HelpExtendedRandomCode" , plugin , player . UserIDString ) ,
1231
+ Formatter . Indent ( Formatter . Command ( string . Format ( "{0} {1}" , label , RandomCode ) ) )
1232
+ ) ,
1233
+ string . Format (
1234
+ plugin . lang . GetMessage ( "HelpExtendedRemoveCode" , plugin , player . UserIDString ) ,
1235
+ Formatter . Indent ( Formatter . Command ( string . Format ( "{0} {1}" , label , RemoveCode ) ) )
1236
+ )
1237
+ ) ,
1238
+ string . Format (
1239
+ plugin . lang . GetMessage ( "HelpExtendedCoreGuestCommands" , plugin , player . UserIDString ) ,
1240
+ Formatter . Indent ( Formatter . Command ( string . Format ( "{0} {1} {2}" , label , Guest , "5678" ) ) )
1241
+ )
1159
1242
) ,
1160
- QuietMode
1161
- } )
1243
+ string . Join (
1244
+ "\n " + Formatter . SmallLineGap ,
1245
+ Formatter . H2 ( plugin . lang . GetMessage ( "HelpExtendedOtherCommands" , plugin , player . UserIDString ) ) ,
1246
+ Formatter . UL (
1247
+ string . Format (
1248
+ plugin . lang . GetMessage ( "HelpExtendedQuietMode" , plugin , player . UserIDString ) ,
1249
+ Formatter . Indent ( Formatter . Command ( string . Format ( "{0} {1}" , label , QuietMode ) ) )
1250
+ ) ,
1251
+ string . Format (
1252
+ plugin . lang . GetMessage ( "HelpExtendedHelp" , plugin , player . UserIDString ) ,
1253
+ Formatter . Indent ( Formatter . Command ( string . Format ( "{0} {1}" , label , Help ) ) )
1254
+ )
1255
+ )
1256
+ )
1257
+ )
1162
1258
) ;
1163
1259
}
1164
1260
}
@@ -1183,6 +1279,83 @@ public static bool ShouldHideCode(BasePlayer player, Data.Structure.PlayerSettin
1183
1279
}
1184
1280
}
1185
1281
1282
+ /// <summary>
1283
+ /// Text formatting functions for in-game chat.
1284
+ /// </summary>
1285
+ private static class Formatter
1286
+ {
1287
+ /// <summary>
1288
+ /// A line break in a very small font.
1289
+ /// </summary>
1290
+ public const string SmallestLineGap = "<size=6>\n </size>" ;
1291
+
1292
+ /// <summary>
1293
+ /// A line break in a small font.
1294
+ /// </summary>
1295
+ public const string SmallLineGap = "<size=9>\n </size>" ;
1296
+
1297
+ /// <summary>
1298
+ /// Format the given text as a header level 1.
1299
+ /// </summary>
1300
+ public static string H1 ( string text )
1301
+ {
1302
+ return string . Format ( "<size=20>{0}</size>" , text ) ;
1303
+ }
1304
+
1305
+ /// <summary>
1306
+ /// Format the given text as a header level 2.
1307
+ /// </summary>
1308
+ public static string H2 ( string text )
1309
+ {
1310
+ return string . Format ( "<size=16>{0}</size>" , text ) ;
1311
+ }
1312
+
1313
+ /// <summary>
1314
+ /// Small text.
1315
+ /// </summary>
1316
+ public static string Small ( string text )
1317
+ {
1318
+ return string . Format ( "<size=12>{0}</size>" , text ) ;
1319
+ }
1320
+
1321
+ /// <summary>
1322
+ /// Format the items as an unordered list.
1323
+ /// </summary>
1324
+ public static string UL ( params string [ ] items )
1325
+ {
1326
+ return string . Join (
1327
+ "\n " + SmallestLineGap ,
1328
+ items . Select ( item => string . Format ( " - {0}" , item ) )
1329
+ ) ;
1330
+ }
1331
+
1332
+ /// <summary>
1333
+ /// Indent the given text.
1334
+ /// </summary>
1335
+ public static string Indent ( string text )
1336
+ {
1337
+ return string . Format ( " {0}" , text ) ;
1338
+ }
1339
+
1340
+ /// <summary>
1341
+ /// Format the given text as a command.
1342
+ /// </summary>
1343
+ public static string Command ( string text )
1344
+ {
1345
+ return string . Format ( "<color=#e0e0e0>{0}</color>" , text ) ;
1346
+ }
1347
+
1348
+ public static string Value ( string text )
1349
+ {
1350
+ return string . Format ( "<color=#bfff75>{0}</color>" , text ) ;
1351
+ }
1352
+
1353
+ public static string NoValue ( string text )
1354
+ {
1355
+ return string . Format ( "<color=#ff7771>{0}</color>" , text ) ;
1356
+ }
1357
+ }
1358
+
1186
1359
/// <summary>
1187
1360
/// The data stored for temp code locks.
1188
1361
/// </summary>
0 commit comments