hedgewars/uChat.pas
changeset 11776 f2031643fe98
parent 11697 446ce60700dd
child 11835 8f7e28428f3e
equal deleted inserted replaced
11775:ee85798d6974 11776:f2031643fe98
    68     cursorPos, cursorX, selectedPos, selectionDx: LongInt;
    68     cursorPos, cursorX, selectedPos, selectionDx: LongInt;
    69     LastKeyPressTick: LongWord;
    69     LastKeyPressTick: LongWord;
    70 
    70 
    71 
    71 
    72 const
    72 const
    73     colors: array[#0..#9] of TSDL_Color = (
    73     colors: array[#0..#12] of TSDL_Color = (
    74             (r:$FF; g:$FF; b:$FF; a:$FF), // #0 unused, feel free to take it for anything
    74             (r:$FF; g:$FF; b:$FF; a:$FF), // #0 unused, feel free to take it for anything
    75             (r:$FF; g:$FF; b:$FF; a:$FF), // #1 chat message [White]
    75             (r:$FF; g:$FF; b:$FF; a:$FF), // #1 chat message [White]
    76             (r:$FF; g:$00; b:$FF; a:$FF), // #2 action message [Purple]
    76             (r:$FF; g:$00; b:$FF; a:$FF), // #2 action message [Purple]
    77             (r:$90; g:$FF; b:$90; a:$FF), // #3 join/leave message [Lime]
    77             (r:$90; g:$FF; b:$90; a:$FF), // #3 join/leave message [Lime]
    78             (r:$FF; g:$FF; b:$A0; a:$FF), // #4 team message [Light Yellow]
    78             (r:$FF; g:$FF; b:$A0; a:$FF), // #4 team message [Light Yellow]
    79             (r:$FF; g:$00; b:$00; a:$FF), // #5 error messages [Red]
    79             (r:$FF; g:$00; b:$00; a:$FF), // #5 error messages [Red]
    80             (r:$00; g:$FF; b:$FF; a:$FF), // #6 input line [Light Blue]
    80             (r:$00; g:$FF; b:$FF; a:$FF), // #6 input line [Light Blue]
    81             (r:$FF; g:$80; b:$80; a:$FF), // #7 team gone [Light Red]
    81             (r:$FF; g:$80; b:$80; a:$FF), // #7 team gone [Light Red]
    82             (r:$FF; g:$D0; b:$80; a:$FF), // #8 team back [Light Orange]
    82             (r:$FF; g:$D0; b:$80; a:$FF), // #8 team back [Light Orange]
    83             (r:$DF; g:$DF; b:$DF; a:$FF)  // #9 hog speech [Light Gray]
    83             (r:$DF; g:$DF; b:$DF; a:$FF), // #9 hog speech [Light Gray]
       
    84             (r:$FF; g:$00; b:$FF; a:$AF), // #10 music credits [Purple]
       
    85             (r:$00; g:$FF; b:$FF; a:$AF), // #11 map credits [Light Blue]
       
    86             (r:$FF; g:$D0; b:$80; a:$AF)  // #12 theme credits [Light Orange]
    84             );
    87             );
    85     ChatCommandz: array [TChatCmd] of record
    88     ChatCommandz: array [TChatCmd] of record
    86             ChatCmd: string[31];
    89             ChatCmd: string[31];
    87             ProcedureCallChatCmd: string[31];
    90             ProcedureCallChatCmd: string[31];
    88             end = (
    91             end = (
   203 
   206 
   204 SDL_FreeSurface(resSurface)
   207 SDL_FreeSurface(resSurface)
   205 end;
   208 end;
   206 
   209 
   207 const ClDisplayDuration = 12500;
   210 const ClDisplayDuration = 12500;
       
   211       CreditsDisplayDur =  2500;
   208 
   212 
   209 procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean);
   213 procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean);
   210 var color  : TSDL_Color;
   214 var color  : TSDL_Color;
   211 begin
   215     credits: boolean;
       
   216 begin
       
   217 credits:= false;
   212 if isInput then
   218 if isInput then
   213     begin
   219     begin
   214     cl.s:= str;
   220     cl.s:= str;
   215     color:= colors[#6];
   221     color:= colors[#6];
   216     str:= str + ' ';
   222     str:= str + ' ';
   218 else
   224 else
   219     begin
   225     begin
   220     if str[1] <= High(colors) then
   226     if str[1] <= High(colors) then
   221         begin
   227         begin
   222         color:= colors[str[1]];
   228         color:= colors[str[1]];
       
   229         credits:= (str[1] >= #10) and (str[1] <= #12);
   223         delete(str, 1, 1);
   230         delete(str, 1, 1);
   224         end
   231         end
   225     // fallback if invalid color
   232     // fallback if invalid color
   226     else
   233     else
   227         color:= colors[Low(colors)];
   234         color:= colors[Low(colors)];
   232 cl.color:= color;
   239 cl.color:= color;
   233 
   240 
   234 // set texture, note: variables cl.s and str will be different here if isInput
   241 // set texture, note: variables cl.s and str will be different here if isInput
   235 RenderChatLineTex(cl, str);
   242 RenderChatLineTex(cl, str);
   236 
   243 
   237 cl.Time:= RealTicks + ClDisplayDuration;
   244 if credits then
       
   245     cl.Time:= RealTicks + CreditsDisplayDur
       
   246 else
       
   247     cl.Time:= RealTicks + ClDisplayDuration;
   238 end;
   248 end;
   239 
   249 
   240 // For uStore texture recreation
   250 // For uStore texture recreation
   241 procedure ReloadLines;
   251 procedure ReloadLines;
   242 var i: LongWord;
   252 var i: LongWord;