hedgewars/uChat.pas
branchui-scaling
changeset 13389 24b531dcebe7
parent 13388 32a1696ca93a
child 15304 c4fd2813b127
equal deleted inserted replaced
13388:32a1696ca93a 13389:24b531dcebe7
    33 procedure SendHogSpeech(s: shortstring);
    33 procedure SendHogSpeech(s: shortstring);
    34 procedure CopyToClipboard(var newContent: shortstring);
    34 procedure CopyToClipboard(var newContent: shortstring);
    35 procedure TextInput(var event: TSDL_TextInputEvent);
    35 procedure TextInput(var event: TSDL_TextInputEvent);
    36 
    36 
    37 implementation
    37 implementation
    38 uses uConsts, uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO, uScript, uRenderUtils, uStore, Math;
    38 uses uConsts, uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO, uScript, uRenderUtils, uStore;
    39 
    39 
    40 const MaxStrIndex = 27;
    40 const MaxStrIndex = 27;
    41       MaxInputStrLen = 200;
    41       MaxInputStrLen = 200;
    42 
    42 
    43 type TChatLine = record
    43 type TChatLine = record
   127         exit;
   127         exit;
   128 
   128 
   129     LastChatScaleValue:= ChatScaleValue;
   129     LastChatScaleValue:= ChatScaleValue;
   130     LastUIScaleValue:= UIScaleValue;
   130     LastUIScaleValue:= UIScaleValue;
   131 
   131 
   132     // determine font size - note: +0.001 to because I don't trust float inaccuracy combined with floor
   132     // determine font size - note: +0.001 to because I don't trust float inaccuracy combined with trunc
   133     fntSize:= max(1, floor(UIScaleValue * ChatScaleValue * cBaseChatFontHeight + 0.001));
   133     fntSize:= max(1, trunc(UIScaleValue * ChatScaleValue * cBaseChatFontHeight + 0.001));
   134 
   134 
   135     if Fontz[fntChat].Height <> fntSize then
   135     if Fontz[fntChat].Height <> fntSize then
   136         begin
   136         begin
   137         // adjust associated heights
   137         // adjust associated heights
   138         Fontz[fntChat].Height:= fntSize;
   138         Fontz[fntChat].Height:= fntSize;
   143         if Fontz[CJKfntChat].Handle <> nil then
   143         if Fontz[CJKfntChat].Handle <> nil then
   144             LoadFont(CJKfntChat);
   144             LoadFont(CJKfntChat);
   145         end;
   145         end;
   146 
   146 
   147     // adjust line height etc.
   147     // adjust line height etc.
   148     Padding:= max(1, floor(PaddingFactor * fntSize + 0.1));
   148     Padding:= max(1, trunc(PaddingFactor * fntSize + 0.1));
   149     ClHeight:= 2 * Padding + fntSize;
   149     ClHeight:= 2 * Padding + fntSize;
   150 
   150 
   151     // clear cache of already rendered lines
   151     // clear cache of already rendered lines
   152     ReloadLines();
   152     ReloadLines();
   153     UpdateInputLinePrefix();
   153     UpdateInputLinePrefix();
   186 AdjustToUIScale();
   186 AdjustToUIScale();
   187 end;
   187 end;
   188 
   188 
   189 procedure chatSizeReset();
   189 procedure chatSizeReset();
   190 begin
   190 begin
   191 ChatScaleValue:= cDefaultChatScaleLevel;
   191 ChatScaleValue:= cDefaultChatScale;
   192 AdjustToUIScale();
   192 AdjustToUIScale();
   193 end;
   193 end;
   194 
   194 
   195 function GetChatFont(str: shortstring): THWFONT;
   195 function GetChatFont(str: shortstring): THWFONT;
   196 begin
   196 begin