hedgewars/uChat.pas
branchqmlfrontend
changeset 10817 48a53259fad8
parent 10737 408803ca951a
child 10834 2e83f33dfe5b
equal deleted inserted replaced
10757:f71275973737 10817:48a53259fad8
    30 procedure DrawChat;
    30 procedure DrawChat;
    31 procedure KeyPressChat(Key, Sym: Longword);
    31 procedure KeyPressChat(Key, Sym: Longword);
    32 procedure SendHogSpeech(s: shortstring);
    32 procedure SendHogSpeech(s: shortstring);
    33 
    33 
    34 implementation
    34 implementation
    35 uses SDLh, uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO, uScript;
    35 uses SDLh, uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO, uScript, uRenderUtils;
    36 
    36 
    37 const MaxStrIndex = 27;
    37 const MaxStrIndex = 27;
    38 
    38 
    39 type TChatLine = record
    39 type TChatLine = record
    40     Tex: PTexture;
    40     Tex: PTexture;
    89 var strSurface,
    89 var strSurface,
    90     resSurface: PSDL_Surface;
    90     resSurface: PSDL_Surface;
    91     dstrect   : TSDL_Rect; // destination rectangle for blitting
    91     dstrect   : TSDL_Rect; // destination rectangle for blitting
    92     font      : THWFont;
    92     font      : THWFont;
    93 const
    93 const
    94     shadowcolor: TSDL_Color = (r:$00; g:$00; b:$00; a:$FF);
       
    95     //shadowcolor: TSDL_Color = (r:$00; g:$00; b:$00; a:$80);
       
    96     shadowint  = $80 shl AShift;
    94     shadowint  = $80 shl AShift;
    97 begin
    95 begin
    98 
    96 
    99 font:= CheckCJKFont(ansistring(str), fnt16);
    97 font:= CheckCJKFont(ansistring(str), fnt16);
   100 
    98 
   115 dstrect.w:= cl.Width;
   113 dstrect.w:= cl.Width;
   116 dstrect.h:= ClHeight;
   114 dstrect.h:= ClHeight;
   117 
   115 
   118 // draw background
   116 // draw background
   119 SDL_FillRect(resSurface, @dstrect, shadowint);
   117 SDL_FillRect(resSurface, @dstrect, shadowint);
   120 dstrect.x:= Padding + 1;
       
   121 dstrect.y:= Padding + 1;
       
   122 // doesn't matter if .w and .h still include padding, SDL_UpperBlit will clip
       
   123 
       
   124 
       
   125 // create and blit text shadow
       
   126 strSurface:= TTF_RenderUTF8_Solid(Fontz[font].Handle, Str2PChar(str), shadowcolor);
       
   127 SDL_UpperBlit(strSurface, nil, resSurface, @dstrect);
       
   128 SDL_FreeSurface(strSurface);
       
   129 
       
   130 // non-shadow text starts at padding
       
   131 dstrect.x:= Padding;
       
   132 dstrect.y:= Padding;
       
   133 
   118 
   134 // create and blit text
   119 // create and blit text
   135 strSurface:= TTF_RenderUTF8_Blended(Fontz[font].Handle, Str2PChar(str), cl.color);
   120 strSurface:= TTF_RenderUTF8_Blended(Fontz[font].Handle, Str2PChar(str), cl.color);
   136 SDL_UpperBlit(strSurface, nil, resSurface, @dstrect);
   121 //SDL_UpperBlit(strSurface, nil, resSurface, @dstrect);
       
   122 if strSurface <> nil then copyTOXY(strSurface, resSurface, Padding, Padding);
   137 SDL_FreeSurface(strSurface);
   123 SDL_FreeSurface(strSurface);
   138 
   124 
   139 cl.Tex:= Surface2Tex(resSurface, false);
   125 cl.Tex:= Surface2Tex(resSurface, false);
   140 
   126 
   141 SDL_FreeSurface(resSurface)
   127 SDL_FreeSurface(resSurface)