hedgewars/uChat.pas
changeset 11835 8f7e28428f3e
parent 11776 f2031643fe98
child 12102 51596d30a724
equal deleted inserted replaced
11834:16d6da04f7a2 11835:8f7e28428f3e
    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..#12] of TSDL_Color = (
    73     colors: array[#0..#9] 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]
       
    87             );
    84             );
    88     ChatCommandz: array [TChatCmd] of record
    85     ChatCommandz: array [TChatCmd] of record
    89             ChatCmd: string[31];
    86             ChatCmd: string[31];
    90             ProcedureCallChatCmd: string[31];
    87             ProcedureCallChatCmd: string[31];
    91             end = (
    88             end = (
   206 
   203 
   207 SDL_FreeSurface(resSurface)
   204 SDL_FreeSurface(resSurface)
   208 end;
   205 end;
   209 
   206 
   210 const ClDisplayDuration = 12500;
   207 const ClDisplayDuration = 12500;
   211       CreditsDisplayDur =  2500;
       
   212 
   208 
   213 procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean);
   209 procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean);
   214 var color  : TSDL_Color;
   210 var color  : TSDL_Color;
   215     credits: boolean;
   211 begin
   216 begin
       
   217 credits:= false;
       
   218 if isInput then
   212 if isInput then
   219     begin
   213     begin
   220     cl.s:= str;
   214     cl.s:= str;
   221     color:= colors[#6];
   215     color:= colors[#6];
   222     str:= str + ' ';
   216     str:= str + ' ';
   224 else
   218 else
   225     begin
   219     begin
   226     if str[1] <= High(colors) then
   220     if str[1] <= High(colors) then
   227         begin
   221         begin
   228         color:= colors[str[1]];
   222         color:= colors[str[1]];
   229         credits:= (str[1] >= #10) and (str[1] <= #12);
       
   230         delete(str, 1, 1);
   223         delete(str, 1, 1);
   231         end
   224         end
   232     // fallback if invalid color
   225     // fallback if invalid color
   233     else
   226     else
   234         color:= colors[Low(colors)];
   227         color:= colors[Low(colors)];
   239 cl.color:= color;
   232 cl.color:= color;
   240 
   233 
   241 // set texture, note: variables cl.s and str will be different here if isInput
   234 // set texture, note: variables cl.s and str will be different here if isInput
   242 RenderChatLineTex(cl, str);
   235 RenderChatLineTex(cl, str);
   243 
   236 
   244 if credits then
   237 cl.Time:= RealTicks + ClDisplayDuration;
   245     cl.Time:= RealTicks + CreditsDisplayDur
       
   246 else
       
   247     cl.Time:= RealTicks + ClDisplayDuration;
       
   248 end;
   238 end;
   249 
   239 
   250 // For uStore texture recreation
   240 // For uStore texture recreation
   251 procedure ReloadLines;
   241 procedure ReloadLines;
   252 var i: LongWord;
   242 var i: LongWord;