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); |
337 end; |
342 end; |
338 |
343 |
339 if (copy(s, 2, 3) = 'me ') then |
344 if (copy(s, 2, 3) = 'me ') then |
340 begin |
345 begin |
341 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; |
342 exit |
355 exit |
343 end; |
356 end; |
344 |
357 |
345 // debugging commands |
358 // debugging commands |
346 if (copy(s, 2, 7) = 'debugvl') then |
359 if (copy(s, 2, 7) = 'debugvl') then |
514 |
527 |
515 AddChatString(s) |
528 AddChatString(s) |
516 end; |
529 end; |
517 |
530 |
518 procedure chHistory(var s: shortstring); |
531 procedure chHistory(var s: shortstring); |
|
532 var i: LongInt; |
519 begin |
533 begin |
520 s:= s; // avoid compiler hint |
534 s:= s; // avoid compiler hint |
521 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; |
522 end; |
544 end; |
523 |
545 |
524 procedure chChat(var s: shortstring); |
546 procedure chChat(var s: shortstring); |
525 begin |
547 begin |
526 s:= s; // avoid compiler hint |
548 s:= s; // avoid compiler hint |