56 InputStr: TChatLine; |
56 InputStr: TChatLine; |
57 InputStrL: array[0..260] of char; // for full str + 4-byte utf-8 char |
57 InputStrL: array[0..260] of char; // for full str + 4-byte utf-8 char |
58 ChatReady: boolean; |
58 ChatReady: boolean; |
59 showAll: boolean; |
59 showAll: boolean; |
60 liveLua: boolean; |
60 liveLua: boolean; |
|
61 ChatHidden: boolean; |
61 |
62 |
62 const |
63 const |
63 colors: array[#0..#6] of TSDL_Color = ( |
64 colors: array[#0..#6] of TSDL_Color = ( |
64 (r:$FF; g:$FF; b:$FF; a:$FF), // unused, feel free to take it for anything |
65 (r:$FF; g:$FF; b:$FF; a:$FF), // unused, feel free to take it for anything |
65 (r:$FF; g:$FF; b:$FF; a:$FF), // chat message [White] |
66 (r:$FF; g:$FF; b:$FF; a:$FF), // chat message [White] |
202 |
203 |
203 inc(visibleCount) |
204 inc(visibleCount) |
204 end; |
205 end; |
205 |
206 |
206 procedure DrawChat; |
207 procedure DrawChat; |
207 var i, t, left, top, cnt: Longword; |
208 var i, t, left, top, cnt: LongInt; |
208 begin |
209 begin |
209 ChatReady:= true; // maybe move to somewhere else? |
210 ChatReady:= true; // maybe move to somewhere else? |
210 |
211 |
|
212 if ChatHidden and (not showAll) then |
|
213 visibleCount:= 0; |
|
214 |
|
215 // draw chat lines with some distance from screen border |
211 left:= 4 - cScreenWidth div 2; |
216 left:= 4 - cScreenWidth div 2; |
212 top := 10; |
217 top := 10 + visibleCount * ClHeight; // we start with input line (if any) |
213 |
218 |
|
219 // draw chat input line first and under all other lines |
214 if (GameState = gsChat) and (InputStr.Tex <> nil) then |
220 if (GameState = gsChat) and (InputStr.Tex <> nil) then |
215 begin |
221 DrawTexture(left, top, InputStr.Tex); |
216 // draw under all other lines |
222 |
217 DrawTexture(left, top + visibleCount * ClHeight, InputStr.Tex); |
223 if ((not ChatHidden) or showAll) and (UIDisplay <> uiNone) then |
218 end; |
|
219 |
|
220 if UIDisplay <> uiNone then |
|
221 begin |
224 begin |
222 if MissedCount <> 0 then // there are chat strings we missed, so print them now |
225 if MissedCount <> 0 then // there are chat strings we missed, so print them now |
223 begin |
226 begin |
224 for i:= 0 to MissedCount - 1 do |
227 for i:= 0 to MissedCount - 1 do |
225 AddChatString(MStrs[i]); |
228 AddChatString(MStrs[i]); |
229 |
232 |
230 cnt:= 0; // count of lines displayed |
233 cnt:= 0; // count of lines displayed |
231 t := 1; // # of current line processed |
234 t := 1; // # of current line processed |
232 |
235 |
233 // draw lines in reverse order |
236 // draw lines in reverse order |
234 while (((t < 7) and (Strs[i].Time > RealTicks)) or ((t < MaxStrIndex) and showAll)) |
237 while (((t < 7) and (Strs[i].Time > RealTicks)) or ((t <= MaxStrIndex + 1) and showAll)) |
235 and (Strs[i].Tex <> nil) do |
238 and (Strs[i].Tex <> nil) do |
236 begin |
239 begin |
237 // draw lines 4px away from left screen border and 2px away from top |
240 top:= top - ClHeight; |
238 DrawTexture(left, top + (visibleCount - t) * ClHeight, Strs[i].Tex); |
241 // draw chatline only if not offscreen |
|
242 if top > 0 then |
|
243 DrawTexture(left, top, Strs[i].Tex); |
239 |
244 |
240 if i = 0 then |
245 if i = 0 then |
241 i:= MaxStrIndex |
246 i:= MaxStrIndex |
242 else |
247 else |
243 dec(i); |
248 dec(i); |
293 exit |
305 exit |
294 end; |
306 end; |
295 |
307 |
296 if (s[1] = '/') then |
308 if (s[1] = '/') then |
297 begin |
309 begin |
298 // put in input history |
|
299 localLastStr:= (localLastStr + 1) mod MaxStrIndex; |
|
300 LocalStrs[localLastStr]:= s; |
|
301 |
|
302 // These 3 are same as above, only are to make the hedgehog say it on next attack |
310 // These 3 are same as above, only are to make the hedgehog say it on next attack |
303 if (copy(s, 2, 4) = 'hsa ') then |
311 if (copy(s, 2, 4) = 'hsa ') then |
304 begin |
312 begin |
305 if CurrentTeam^.ExtDriven then |
313 if CurrentTeam^.ExtDriven then |
306 ParseCommand('/say ' + copy(s, 6, Length(s)-5), true) |
314 ParseCommand('/say ' + copy(s, 6, Length(s)-5), true) |
334 end; |
342 end; |
335 |
343 |
336 if (copy(s, 2, 3) = 'me ') then |
344 if (copy(s, 2, 3) = 'me ') then |
337 begin |
345 begin |
338 ParseCommand('/say ' + s, true); |
346 ParseCommand('/say ' + s, true); |
|
347 exit |
|
348 end; |
|
349 |
|
350 if (copy(s, 2, 10) = 'togglechat') then |
|
351 begin |
|
352 ChatHidden:= (not ChatHidden); |
|
353 if ChatHidden then |
|
354 showAll:= false; |
339 exit |
355 exit |
340 end; |
356 end; |
341 |
357 |
342 // debugging commands |
358 // debugging commands |
343 if (copy(s, 2, 7) = 'debugvl') then |
359 if (copy(s, 2, 7) = 'debugvl') then |
496 SendIPC('s' + s); |
512 SendIPC('s' + s); |
497 |
513 |
498 if copy(s, 1, 4) = '/me ' then |
514 if copy(s, 1, 4) = '/me ' then |
499 s:= #2 + '* ' + UserNick + ' ' + copy(s, 5, Length(s) - 4) |
515 s:= #2 + '* ' + UserNick + ' ' + copy(s, 5, Length(s) - 4) |
500 else |
516 else |
501 begin |
|
502 localLastStr:= (localLastStr + 1) mod MaxStrIndex; |
|
503 LocalStrs[localLastStr]:= s; |
|
504 s:= #1 + UserNick + ': ' + s; |
517 s:= #1 + UserNick + ': ' + s; |
505 end; |
|
506 |
518 |
507 AddChatString(s) |
519 AddChatString(s) |
508 end; |
520 end; |
509 |
521 |
510 procedure chTeamSay(var s: shortstring); |
522 procedure chTeamSay(var s: shortstring); |
515 |
527 |
516 AddChatString(s) |
528 AddChatString(s) |
517 end; |
529 end; |
518 |
530 |
519 procedure chHistory(var s: shortstring); |
531 procedure chHistory(var s: shortstring); |
|
532 var i: LongInt; |
520 begin |
533 begin |
521 s:= s; // avoid compiler hint |
534 s:= s; // avoid compiler hint |
522 showAll:= not showAll |
535 showAll:= not showAll; |
|
536 // immediatly recount |
|
537 visibleCount:= 0; |
|
538 if showAll or (not ChatHidden) then |
|
539 for i:= 0 to MaxStrIndex do |
|
540 begin |
|
541 if (Strs[i].Tex <> nil) and (showAll or (Strs[i].Time > RealTicks)) then |
|
542 inc(visibleCount); |
|
543 end; |
523 end; |
544 end; |
524 |
545 |
525 procedure chChat(var s: shortstring); |
546 procedure chChat(var s: shortstring); |
526 begin |
547 begin |
527 s:= s; // avoid compiler hint |
548 s:= s; // avoid compiler hint |