77
88namespace EntWatchSharp . Helpers
99{
10- static class UI
11- {
10+ static class UI
11+ {
1212 public static void EWChatActivity ( string sMessage , string sColor , Item ItemTest , CCSPlayerController player , Ability AbilityTest = null )
1313 {
14- string [ ] sPlayerInfoFormat = PlayerInfoFormat ( player ) ;
14+ string [ ] sPlayerInfoFormat = PlayerInfoFormat ( player ) ;
1515 using ( new WithTemporaryCulture ( CultureInfo . GetCultureInfo ( CoreConfig . ServerLanguage ) ) )
1616 {
17- PrintToConsole ( $ "{ sPlayerInfoFormat [ 3 ] } { sColor } { EntWatchSharp . Strlocalizer [ sMessage ] } { ItemTest . Color } { ItemTest . Name } { ( ( AbilityTest != null && ! string . IsNullOrEmpty ( AbilityTest . Name ) ) ? $ " ({ AbilityTest . Name } )" : "" ) } ") ;
17+ PrintToConsole ( $ "{ sPlayerInfoFormat [ 3 ] } { sColor } { EntWatchSharp . Strlocalizer [ sMessage ] } { ItemTest . Color } { ItemTest . Name } { ( ( AbilityTest != null && ! string . IsNullOrEmpty ( AbilityTest . Name ) ) ? $ " ({ AbilityTest . Name } )" : "" ) } ") ;
1818 }
1919
20- LogManager . ItemAction ( sMessage , sPlayerInfoFormat [ 3 ] , $ "{ ItemTest . Name } { ( ( AbilityTest != null && ! string . IsNullOrEmpty ( AbilityTest . Name ) ) ? $ " ({ AbilityTest . Name } )" : "" ) } ") ;
20+ LogManager . ItemAction ( sMessage , sPlayerInfoFormat [ 3 ] , $ "{ ItemTest . Name } { ( ( AbilityTest != null && ! string . IsNullOrEmpty ( AbilityTest . Name ) ) ? $ " ({ AbilityTest . Name } )" : "" ) } ") ;
2121
2222 if ( ! ( AbilityTest == null || ItemTest . Chat || AbilityTest . Chat_Uses ) ) return ;
2323
@@ -41,25 +41,25 @@ public static void EWChatAdminBan(string[] sPIF_admin, string[] sPIF_player, str
4141 Server . NextFrame ( ( ) =>
4242 {
4343 using ( new WithTemporaryCulture ( CultureInfo . GetCultureInfo ( CoreConfig . ServerLanguage ) ) )
44- {
45- PrintToConsole ( EntWatchSharp . Strlocalizer [ bAction ? "Chat.Admin.Restricted" : "Chat.Admin.Unrestricted" , EW . g_Scheme . color_warning , sPIF_admin [ 3 ] , bAction ? EW . g_Scheme . color_disabled : EW . g_Scheme . color_enabled , sPIF_player [ 3 ] ] , 2 ) ;
46- PrintToConsole ( EntWatchSharp . Strlocalizer [ "Chat.Admin.Reason" , EW . g_Scheme . color_warning , sReason ] , 2 ) ;
47- }
44+ {
45+ PrintToConsole ( EntWatchSharp . Strlocalizer [ bAction ? "Chat.Admin.Restricted" : "Chat.Admin.Unrestricted" , EW . g_Scheme . color_warning , sPIF_admin [ 3 ] , bAction ? EW . g_Scheme . color_disabled : EW . g_Scheme . color_enabled , sPIF_player [ 3 ] ] , 2 ) ;
46+ PrintToConsole ( EntWatchSharp . Strlocalizer [ "Chat.Admin.Reason" , EW . g_Scheme . color_warning , sReason ] , 2 ) ;
47+ }
4848
49- LogManager . AdminAction ( bAction ? "Chat.Admin.Restricted" : "Chat.Admin.Unrestricted" , EW . g_Scheme . color_warning , sPIF_admin [ 3 ] , bAction ? EW . g_Scheme . color_disabled : EW . g_Scheme . color_enabled , sPIF_player [ 3 ] ) ;
49+ LogManager . AdminAction ( bAction ? "Chat.Admin.Restricted" : "Chat.Admin.Unrestricted" , EW . g_Scheme . color_warning , sPIF_admin [ 3 ] , bAction ? EW . g_Scheme . color_disabled : EW . g_Scheme . color_enabled , sPIF_player [ 3 ] ) ;
5050 LogManager . AdminAction ( "Chat.Admin.Reason" , EW . g_Scheme . color_warning , sReason ) ;
5151
5252 Utilities . GetPlayers ( ) . Where ( p => p is { IsValid : true , IsBot : false , IsHLTV : false } ) . ToList ( ) . ForEach ( pl =>
53- {
54- Server . NextFrame ( ( ) =>
55- {
56- using ( new WithTemporaryCulture ( pl . GetLanguage ( ) ) )
57- {
58- pl . PrintToChat ( EWChatMessage ( EntWatchSharp . Strlocalizer [ bAction ? "Chat.Admin.Restricted" : "Chat.Admin.Unrestricted" , EW . g_Scheme . color_warning , PlayerInfo ( pl , sPIF_admin ) , bAction ? EW . g_Scheme . color_disabled : EW . g_Scheme . color_enabled , PlayerInfo ( pl , sPIF_player ) ] ) ) ;
53+ {
54+ Server . NextFrame ( ( ) =>
55+ {
56+ using ( new WithTemporaryCulture ( pl . GetLanguage ( ) ) )
57+ {
58+ pl . PrintToChat ( EWChatMessage ( EntWatchSharp . Strlocalizer [ bAction ? "Chat.Admin.Restricted" : "Chat.Admin.Unrestricted" , EW . g_Scheme . color_warning , PlayerInfo ( pl , sPIF_admin ) , bAction ? EW . g_Scheme . color_disabled : EW . g_Scheme . color_enabled , PlayerInfo ( pl , sPIF_player ) ] ) ) ;
5959 pl . PrintToChat ( EWChatMessage ( EntWatchSharp . Strlocalizer [ "Chat.Admin.Reason" , EW . g_Scheme . color_warning , sReason ] ) ) ;
6060 }
61- } ) ;
62- } ) ;
61+ } ) ;
62+ } ) ;
6363 } ) ;
6464 }
6565 public static void EWChatAdminSpawn ( string [ ] sPIF_admin , string [ ] sPIF_receiver , string sItem )
@@ -109,156 +109,156 @@ public static void EWChatAdminTransfer(string[] sPIF_admin, string[] sPIF_receiv
109109 }
110110
111111 public static void EWSysInfo ( string sMessage , int iColor = 15 , params object [ ] arg )
112- {
113- using ( new WithTemporaryCulture ( CultureInfo . GetCultureInfo ( CoreConfig . ServerLanguage ) ) )
114- {
115- PrintToConsole ( EntWatchSharp . Strlocalizer [ sMessage , arg ] , iColor ) ;
116- }
112+ {
113+ using ( new WithTemporaryCulture ( CultureInfo . GetCultureInfo ( CoreConfig . ServerLanguage ) ) )
114+ {
115+ PrintToConsole ( EntWatchSharp . Strlocalizer [ sMessage , arg ] , iColor ) ;
116+ }
117117 LogManager . SystemAction ( sMessage , arg ) ;
118118 }
119119
120- public static void EWReplyInfo ( CCSPlayerController player , string sMessage , bool bConsole , params object [ ] arg )
121- {
122- using ( new WithTemporaryCulture ( player . GetLanguage ( ) ) )
123- {
124- ReplyToCommand ( player , $ "{ EW . g_Scheme . color_warning } { EntWatchSharp . Strlocalizer [ sMessage , arg ] } ", bConsole ) ;
125- }
126- }
120+ public static void EWReplyInfo ( CCSPlayerController player , string sMessage , bool bConsole , params object [ ] arg )
121+ {
122+ using ( new WithTemporaryCulture ( player . GetLanguage ( ) ) )
123+ {
124+ ReplyToCommand ( player , $ "{ EW . g_Scheme . color_warning } { EntWatchSharp . Strlocalizer [ sMessage , arg ] } ", bConsole ) ;
125+ }
126+ }
127127
128- public static void CvarChangeNotify ( string sCvarName , string sCvarValue , bool bClientNotify )
129- {
128+ public static void CvarChangeNotify ( string sCvarName , string sCvarValue , bool bClientNotify )
129+ {
130130 using ( new WithTemporaryCulture ( CultureInfo . GetCultureInfo ( CoreConfig . ServerLanguage ) ) )
131131 {
132132 PrintToConsole ( EntWatchSharp . Strlocalizer [ "Cvar.Notify" , sCvarName , sCvarValue ] , 3 ) ;
133133 }
134134
135- LogManager . CvarAction ( sCvarName , sCvarValue ) ;
135+ LogManager . CvarAction ( sCvarName , sCvarValue ) ;
136136
137137 if ( bClientNotify )
138- {
139- Utilities . GetPlayers ( ) . Where ( p => p is { IsValid : true , IsBot : false , IsHLTV : false } ) . ToList ( ) . ForEach ( pl =>
140- {
141- Server . NextFrame ( ( ) =>
142- {
143- using ( new WithTemporaryCulture ( pl . GetLanguage ( ) ) )
144- {
145- pl . PrintToChat ( EWChatMessage ( $ "{ EW . g_Scheme . color_warning } { EntWatchSharp . Strlocalizer [ "Cvar.Notify" , sCvarName , sCvarValue ] } ") ) ;
146- }
147- } ) ;
148- } ) ;
149- }
138+ {
139+ Utilities . GetPlayers ( ) . Where ( p => p is { IsValid : true , IsBot : false , IsHLTV : false } ) . ToList ( ) . ForEach ( pl =>
140+ {
141+ Server . NextFrame ( ( ) =>
142+ {
143+ using ( new WithTemporaryCulture ( pl . GetLanguage ( ) ) )
144+ {
145+ pl . PrintToChat ( EWChatMessage ( $ "{ EW . g_Scheme . color_warning } { EntWatchSharp . Strlocalizer [ "Cvar.Notify" , sCvarName , sCvarValue ] } ") ) ;
146+ }
147+ } ) ;
148+ } ) ;
149+ }
150150 }
151151
152- public static void PrintToConsole ( string sMessage , int iColor = 1 )
153- {
154- Console . ForegroundColor = ( ConsoleColor ) 8 ;
155- Console . Write ( "[" ) ;
156- Console . ForegroundColor = ( ConsoleColor ) 6 ;
157- Console . Write ( "EntWatch" ) ;
158- Console . ForegroundColor = ( ConsoleColor ) 8 ;
159- Console . Write ( "] " ) ;
160- Console . ForegroundColor = ( ConsoleColor ) iColor ;
161- Console . WriteLine ( ReplaceColorTags ( sMessage , false ) ) ;
162- Console . ResetColor ( ) ;
163- /* Colors:
152+ public static void PrintToConsole ( string sMessage , int iColor = 1 )
153+ {
154+ Console . ForegroundColor = ( ConsoleColor ) 8 ;
155+ Console . Write ( "[" ) ;
156+ Console . ForegroundColor = ( ConsoleColor ) 6 ;
157+ Console . Write ( "EntWatch" ) ;
158+ Console . ForegroundColor = ( ConsoleColor ) 8 ;
159+ Console . Write ( "] " ) ;
160+ Console . ForegroundColor = ( ConsoleColor ) iColor ;
161+ Console . WriteLine ( ReplaceColorTags ( sMessage , false ) ) ;
162+ Console . ResetColor ( ) ;
163+ /* Colors:
164164 * 0 - No color 1 - White 2 - Red-Orange 3 - Orange
165165 * 4 - Yellow 5 - Dark Green 6 - Green 7 - Light Green
166166 * 8 - Cyan 9 - Sky 10 - Light Blue 11 - Blue
167167 * 12 - Violet 13 - Pink 14 - Light Red 15 - Red */
168- }
168+ }
169169
170170 public static void ReplyToCommand ( CCSPlayerController player , string sMessage , bool bConsole = false )
171- {
172- Server . NextFrame ( ( ) =>
173- {
174- if ( player is { IsValid : true , IsBot : false , IsHLTV : false } )
175- {
176- using ( new WithTemporaryCulture ( player . GetLanguage ( ) ) )
177- {
178- if ( ! bConsole ) player . PrintToChat ( EWChatMessage ( sMessage ) ) ;
179- else player . PrintToConsole ( EWChatMessage ( sMessage ) ) ;
171+ {
172+ Server . NextFrame ( ( ) =>
173+ {
174+ if ( player is { IsValid : true , IsBot : false , IsHLTV : false } )
175+ {
176+ using ( new WithTemporaryCulture ( player . GetLanguage ( ) ) )
177+ {
178+ if ( ! bConsole ) player . PrintToChat ( EWChatMessage ( sMessage ) ) ;
179+ else player . PrintToConsole ( EWChatMessage ( sMessage ) ) ;
180180 }
181- }
182- else
183- {
184- using ( new WithTemporaryCulture ( CultureInfo . GetCultureInfo ( CoreConfig . ServerLanguage ) ) )
185- {
186- PrintToConsole ( sMessage , 13 ) ;
187- }
188- }
189- } ) ;
181+ }
182+ else
183+ {
184+ using ( new WithTemporaryCulture ( CultureInfo . GetCultureInfo ( CoreConfig . ServerLanguage ) ) )
185+ {
186+ PrintToConsole ( sMessage , 13 ) ;
187+ }
188+ }
189+ } ) ;
190190 }
191191
192- public static string ReplaceSpecial ( string input )
193- {
194- input = input . Replace ( "{" , "[" ) ;
195- input = input . Replace ( "}" , "]" ) ;
192+ public static string ReplaceSpecial ( string input )
193+ {
194+ input = input . Replace ( "{" , "[" ) ;
195+ input = input . Replace ( "}" , "]" ) ;
196196
197- return input ;
198- }
199- public static string ReplaceColorTags ( string input , bool bChat = true )
200- {
201- for ( var i = 0 ; i < colorPatterns . Length ; i ++ )
202- input = input . Replace ( colorPatterns [ i ] , bChat ? colorReplacements [ i ] : "" ) ;
197+ return input ;
198+ }
199+ public static string ReplaceColorTags ( string input , bool bChat = true )
200+ {
201+ for ( var i = 0 ; i < colorPatterns . Length ; i ++ )
202+ input = input . Replace ( colorPatterns [ i ] , bChat ? colorReplacements [ i ] : "" ) ;
203203
204- return input ;
205- }
204+ return input ;
205+ }
206206
207- static string EWChatMessage ( string sMessage )
208- {
209- sMessage = $ "{ Tag ( ) } { sMessage } ";
210- sMessage = ReplaceColorTags ( sMessage ) ;
211- return sMessage ;
212- }
207+ static string EWChatMessage ( string sMessage )
208+ {
209+ sMessage = $ "{ Tag ( ) } { sMessage } ";
210+ sMessage = ReplaceColorTags ( sMessage ) ;
211+ return sMessage ;
212+ }
213213
214- public static string Tag ( )
215- {
216- return $ " { EW . g_Scheme . color_tag } [EntWatch] ";
217- }
214+ public static string Tag ( )
215+ {
216+ return $ " { EW . g_Scheme . color_tag } [EntWatch] ";
217+ }
218218#nullable enable
219219 public static string PlayerInfo ( CCSPlayerController ? player , string [ ] sPlayerInfoFormat )
220220#nullable disable
221221 {
222222 if ( player != null )
223- {
224- if ( EW . g_EWPlayer [ player ] . PFormatPlayer < 0 || EW . g_EWPlayer [ player ] . PFormatPlayer > 3 ) return sPlayerInfoFormat [ Cvar . PlayerFormat ] ;
225- return sPlayerInfoFormat [ EW . g_EWPlayer [ player ] . PFormatPlayer ] ;
223+ {
224+ if ( EW . g_EWPlayer [ player ] . PFormatPlayer < 0 || EW . g_EWPlayer [ player ] . PFormatPlayer > 3 ) return sPlayerInfoFormat [ Cvar . PlayerFormat ] ;
225+ return sPlayerInfoFormat [ EW . g_EWPlayer [ player ] . PFormatPlayer ] ;
226226 }
227- return sPlayerInfoFormat [ 3 ] ;
227+ return sPlayerInfoFormat [ 3 ] ;
228228 }
229229 public static string [ ] PlayerInfoFormat ( CCSPlayerController player )
230- {
231- if ( player != null )
232- {
233- string [ ] sResult = new string [ 4 ] ;
234- sResult [ 0 ] = $ "{ EW . g_Scheme . color_name } { player . PlayerName } { EW . g_Scheme . color_warning } ";
235- sResult [ 1 ] = $ "{ sResult [ 0 ] } [{ EW . g_Scheme . color_steamid } #{ player . UserId } { EW . g_Scheme . color_warning } ]";
236- sResult [ 2 ] = $ "{ sResult [ 0 ] } [{ EW . g_Scheme . color_steamid } #{ EW . ConvertSteamID64ToSteamID ( player . SteamID . ToString ( ) ) } { EW . g_Scheme . color_warning } ]";
237- sResult [ 3 ] = $ "{ sResult [ 0 ] } [{ EW . g_Scheme . color_steamid } #{ player . UserId } { EW . g_Scheme . color_warning } |{ EW . g_Scheme . color_steamid } #{ EW . ConvertSteamID64ToSteamID ( player . SteamID . ToString ( ) ) } { EW . g_Scheme . color_warning } ]";
238- return sResult ;
239- }
230+ {
231+ if ( player != null )
232+ {
233+ string [ ] sResult = new string [ 4 ] ;
234+ sResult [ 0 ] = $ "{ EW . g_Scheme . color_name } { player . PlayerName } { EW . g_Scheme . color_warning } ";
235+ sResult [ 1 ] = $ "{ sResult [ 0 ] } [{ EW . g_Scheme . color_steamid } #{ player . UserId } { EW . g_Scheme . color_warning } ]";
236+ sResult [ 2 ] = $ "{ sResult [ 0 ] } [{ EW . g_Scheme . color_steamid } #{ EW . ConvertSteamID64ToSteamID ( player . SteamID . ToString ( ) ) } { EW . g_Scheme . color_warning } ]";
237+ sResult [ 3 ] = $ "{ sResult [ 0 ] } [{ EW . g_Scheme . color_steamid } #{ player . UserId } { EW . g_Scheme . color_warning } |{ EW . g_Scheme . color_steamid } #{ EW . ConvertSteamID64ToSteamID ( player . SteamID . ToString ( ) ) } { EW . g_Scheme . color_warning } ]";
238+ return sResult ;
239+ }
240240 return PlayerInfoFormat ( "Console" , "Server" ) ;
241241 }
242- public static string [ ] PlayerInfoFormat ( string sName , string sSteamID )
243- {
244- string [ ] sResult = new string [ 4 ] ;
245- sResult [ 0 ] = $ "{ EW . g_Scheme . color_name } { sName } { EW . g_Scheme . color_warning } ";
246- sResult [ 1 ] = sResult [ 0 ] ;
247- sResult [ 2 ] = $ "{ EW . g_Scheme . color_name } { sName } { EW . g_Scheme . color_warning } [{ EW . g_Scheme . color_steamid } { sSteamID } { EW . g_Scheme . color_warning } ]";
248- sResult [ 3 ] = sResult [ 2 ] ;
249- return sResult ;
250- }
251- readonly static string [ ] colorPatterns =
252- [
253- "{default}" , "{darkred}" , "{purple}" , "{green}" , "{lightgreen}" , "{lime}" , "{red}" , "{grey}" , "{team}" , "{red2}" ,
242+ public static string [ ] PlayerInfoFormat ( string sName , string sSteamID )
243+ {
244+ string [ ] sResult = new string [ 4 ] ;
245+ sResult [ 0 ] = $ "{ EW . g_Scheme . color_name } { sName } { EW . g_Scheme . color_warning } ";
246+ sResult [ 1 ] = sResult [ 0 ] ;
247+ sResult [ 2 ] = $ "{ EW . g_Scheme . color_name } { sName } { EW . g_Scheme . color_warning } [{ EW . g_Scheme . color_steamid } { sSteamID } { EW . g_Scheme . color_warning } ]";
248+ sResult [ 3 ] = sResult [ 2 ] ;
249+ return sResult ;
250+ }
251+ readonly static string [ ] colorPatterns =
252+ [
253+ "{default}" , "{darkred}" , "{purple}" , "{green}" , "{lightgreen}" , "{lime}" , "{red}" , "{grey}" , "{team}" , "{red2}" ,
254254 "{olive}" , "{a}" , "{lightblue}" , "{blue}" , "{d}" , "{pink}" , "{darkorange}" , "{orange}" , "{darkblue}" , "{gold}" ,
255255 "{white}" , "{yellow}" , "{magenta}" , "{silver}" , "{bluegrey}" , "{lightred}" , "{cyan}" , "{gray}" , "{lightyellow}" ,
256256 ] ;
257257 readonly static string [ ] colorReplacements =
258- [
259- "\x01 " , "\x02 " , "\x03 " , "\x04 " , "\x05 " , "\x06 " , "\x07 " , "\x08 " , "\x03 " , "\x0F " ,
260- "\x06 " , "\x0A " , "\x0B " , "\x0C " , "\x0D " , "\x0E " , "\x0F " , "\x10 " , "\x0C " , "\x10 " ,
258+ [
259+ "\x01 " , "\x02 " , "\x03 " , "\x04 " , "\x05 " , "\x06 " , "\x07 " , "\x08 " , "\x03 " , "\x0F " ,
260+ "\x06 " , "\x0A " , "\x0B " , "\x0C " , "\x0D " , "\x0E " , "\x0F " , "\x10 " , "\x0C " , "\x10 " ,
261261 "\x01 " , "\x09 " , "\x0E " , "\x0A " , "\x0D " , "\x0F " , "\x03 " , "\x08 " , "\x06 "
262262 ] ;
263- }
263+ }
264264}
0 commit comments