32 var UserNick: shortstring = ''; |
32 var UserNick: shortstring = ''; |
33 ChatReady: boolean; |
33 ChatReady: boolean; |
34 showAll: boolean; |
34 showAll: boolean; |
35 |
35 |
36 implementation |
36 implementation |
37 uses SDLh, uKeys, uTypes, uVariables, uCommands, uUtils, uTextures, uRender; |
37 uses SDLh, uKeys, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO; |
38 |
38 |
39 const MaxStrIndex = 27; |
39 const MaxStrIndex = 27; |
40 |
40 |
41 type TChatLine = record |
41 type TChatLine = record |
42 Tex: PTexture; |
42 Tex: PTexture; |
306 InputStrL[byte(InputStr.s[0]) + btw]:= InputStr.s[0]; |
306 InputStrL[byte(InputStr.s[0]) + btw]:= InputStr.s[0]; |
307 SetLine(InputStr, InputStr.s + utf8, true) |
307 SetLine(InputStr, InputStr.s + utf8, true) |
308 end |
308 end |
309 end; |
309 end; |
310 |
310 |
|
311 procedure chSay(var s: shortstring); |
|
312 begin |
|
313 SendIPC('s' + s); |
|
314 |
|
315 if copy(s, 1, 4) = '/me ' then |
|
316 s:= #2'* ' + UserNick + ' ' + copy(s, 5, Length(s) - 4) |
|
317 else |
|
318 s:= #1 + UserNick + ': ' + s; |
|
319 |
|
320 AddChatString(s) |
|
321 end; |
|
322 |
|
323 procedure chTeamSay(var s: shortstring); |
|
324 begin |
|
325 SendIPC('b' + s); |
|
326 |
|
327 s:= #4 + '[Team] ' + UserNick + ': ' + s; |
|
328 |
|
329 AddChatString(s) |
|
330 end; |
|
331 |
|
332 procedure chHistory(var s: shortstring); |
|
333 begin |
|
334 s:= s; // avoid compiler hint |
|
335 uChat.showAll:= not uChat.showAll |
|
336 end; |
|
337 |
|
338 procedure chChat(var s: shortstring); |
|
339 begin |
|
340 s:= s; // avoid compiler hint |
|
341 GameState:= gsChat; |
|
342 if length(s) = 0 then |
|
343 KeyPressChat(27) |
|
344 else |
|
345 begin |
|
346 KeyPressChat(27); |
|
347 KeyPressChat(47); |
|
348 KeyPressChat(116); |
|
349 KeyPressChat(101); |
|
350 KeyPressChat(97); |
|
351 KeyPressChat(109); |
|
352 KeyPressChat(32) |
|
353 end |
|
354 end; |
|
355 |
311 procedure initModule; |
356 procedure initModule; |
312 begin |
357 begin |
|
358 RegisterVariable('say', vtCommand, @chSay, true); |
|
359 RegisterVariable('team', vtCommand, @chTeamSay, true); |
|
360 RegisterVariable('history', vtCommand, @chHistory, true ); |
|
361 RegisterVariable('chat', vtCommand, @chChat, true ); |
|
362 |
313 lastStr:= 0; |
363 lastStr:= 0; |
314 visibleCount:= 0; |
364 visibleCount:= 0; |
315 showAll:= false; |
365 showAll:= false; |
316 ChatReady:= false; |
366 ChatReady:= false; |
317 missedCount:= 0; |
367 missedCount:= 0; |