Merge branch 1.0.0 into branch ui-scaling ui-scaling
authorsheepluva
Fri, 03 Jul 2020 23:51:47 +0200
branchui-scaling
changeset 15663 d92eeb468dad
parent 15283 c4fd2813b127 (diff)
parent 15471 9a76589e294e (current diff)
child 15664 0b99e220568a
Merge branch 1.0.0 into branch ui-scaling
ChangeLog.txt
QTfrontend/game.cpp
QTfrontend/gameuiconfig.cpp
QTfrontend/gameuiconfig.h
QTfrontend/ui/page/pageoptions.cpp
hedgewars/ArgParsers.pas
hedgewars/uConsts.pas
hedgewars/uStore.pas
hedgewars/uVariables.pas
misc/winutils/Hedgewars.lnk
misc/winutils/include/libavcodec/avcodec.h
misc/winutils/include/libavcodec/avfft.h
misc/winutils/include/libavcodec/dxva2.h
misc/winutils/include/libavcodec/old_codec_ids.h
misc/winutils/include/libavcodec/vaapi.h
misc/winutils/include/libavcodec/vda.h
misc/winutils/include/libavcodec/vdpau.h
misc/winutils/include/libavcodec/version.h
misc/winutils/include/libavcodec/xvmc.h
misc/winutils/include/libavformat/avformat.h
misc/winutils/include/libavformat/avio.h
misc/winutils/include/libavformat/version.h
misc/winutils/include/libavutil/adler32.h
misc/winutils/include/libavutil/aes.h
misc/winutils/include/libavutil/attributes.h
misc/winutils/include/libavutil/audio_fifo.h
misc/winutils/include/libavutil/audioconvert.h
misc/winutils/include/libavutil/avassert.h
misc/winutils/include/libavutil/avconfig.h
misc/winutils/include/libavutil/avstring.h
misc/winutils/include/libavutil/avutil.h
misc/winutils/include/libavutil/base64.h
misc/winutils/include/libavutil/blowfish.h
misc/winutils/include/libavutil/bswap.h
misc/winutils/include/libavutil/common.h
misc/winutils/include/libavutil/cpu.h
misc/winutils/include/libavutil/crc.h
misc/winutils/include/libavutil/dict.h
misc/winutils/include/libavutil/error.h
misc/winutils/include/libavutil/eval.h
misc/winutils/include/libavutil/fifo.h
misc/winutils/include/libavutil/file.h
misc/winutils/include/libavutil/imgutils.h
misc/winutils/include/libavutil/intfloat.h
misc/winutils/include/libavutil/intfloat_readwrite.h
misc/winutils/include/libavutil/intreadwrite.h
misc/winutils/include/libavutil/lfg.h
misc/winutils/include/libavutil/log.h
misc/winutils/include/libavutil/lzo.h
misc/winutils/include/libavutil/mathematics.h
misc/winutils/include/libavutil/md5.h
misc/winutils/include/libavutil/mem.h
misc/winutils/include/libavutil/old_pix_fmts.h
misc/winutils/include/libavutil/opt.h
misc/winutils/include/libavutil/parseutils.h
misc/winutils/include/libavutil/pixdesc.h
misc/winutils/include/libavutil/pixfmt.h
misc/winutils/include/libavutil/random_seed.h
misc/winutils/include/libavutil/rational.h
misc/winutils/include/libavutil/samplefmt.h
misc/winutils/include/libavutil/sha.h
misc/winutils/include/libavutil/time.h
misc/winutils/include/libavutil/version.h
misc/winutils/include/libavutil/xtea.h
misc/winutils/lib/libavcodec.dll.a
misc/winutils/lib/libavformat.dll.a
misc/winutils/lib/libavutil.dll.a
rust/lib-hedgewars-engine/src/ipc/queue.rs
share/hedgewars/Data/Music/Jungle.ogg
tools/CreateMacBundle.cmake.in
tools/build_vcpkg_basic.bat
--- a/ChangeLog.txt	Fri Oct 11 20:18:07 2019 +0200
+++ b/ChangeLog.txt	Fri Jul 03 23:51:47 2020 +0200
@@ -1,5 +1,10 @@
 + features
 * bugfixes
+======================= ??? ========================
+User Interface:
+ + In-Game chat size can now be adjusted. Hold Ctrl and press -, + or = while in chat input. Hold shift for finer control.
+ + The intial in-game chat size can be configured in the Frontend's "advanced" settings tab.
+
 ====================== 1.0.0 =======================
 Highlights:
  + Campaigns now respect your team identity instead of overwriting it
--- a/QTfrontend/game.cpp	Fri Oct 11 20:18:07 2019 +0200
+++ b/QTfrontend/game.cpp	Fri Jul 03 23:51:47 2020 +0200
@@ -657,6 +657,8 @@
         arguments << "--translucent-tags";
     if (!config->isHolidaySillinessEnabled())
         arguments << "--no-holiday-silliness";
+    arguments << "--chat-size";
+    arguments << QString::number(config->chatSize());
 
     return arguments;
 }
--- a/QTfrontend/gameuiconfig.cpp	Fri Oct 11 20:18:07 2019 +0200
+++ b/QTfrontend/gameuiconfig.cpp	Fri Jul 03 23:51:47 2020 +0200
@@ -178,6 +178,8 @@
             if (m_binds[i].strbind.isEmpty() || m_binds[i].strbind == "default") m_binds[i].strbind = cbinds[i].strbind;
         }
     }
+
+    Form->ui.pageOptions->sbChatSize->setValue(value("chat/size", 100).toInt());
 }
 
 void GameUIConfig::reloadVideosValues(void)
@@ -332,6 +334,8 @@
             setValue(QString("colors/color%1").arg(i), model->item(i)->data().value<QColor>().name());
     }
 
+    setValue("chat/size", Form->ui.pageOptions->sbChatSize->value());
+
     sync();
 }
 
@@ -647,6 +651,11 @@
     }
 }
 
+int GameUIConfig::chatSize()
+{
+    return Form->ui.pageOptions->sbChatSize->value();
+}
+
 quint8 GameUIConfig::volume()
 {
     return Form->ui.pageOptions->SLVolume->value() * 128 / 100;
--- a/QTfrontend/gameuiconfig.h	Fri Oct 11 20:18:07 2019 +0200
+++ b/QTfrontend/gameuiconfig.h	Fri Jul 03 23:51:47 2020 +0200
@@ -53,6 +53,7 @@
         bool isShowFPSEnabled();
         bool isAltDamageEnabled();
         bool appendDateTimeToRecordName();
+        int chatSize();
         quint8 volume();
         quint8 timerInterval();
         QString netNick();
--- a/QTfrontend/net/recorder.cpp	Fri Oct 11 20:18:07 2019 +0200
+++ b/QTfrontend/net/recorder.cpp	Fri Jul 03 23:51:47 2020 +0200
@@ -156,6 +156,8 @@
         arguments << config->audioCodec();
     else
         arguments << "no";
+    arguments << "--chat-size";
+    arguments << QString::number(config->chatSize());
 
     return arguments;
 }
--- a/QTfrontend/ui/page/pageoptions.cpp	Fri Oct 11 20:18:07 2019 +0200
+++ b/QTfrontend/ui/page/pageoptions.cpp	Fri Jul 03 23:51:47 2020 +0200
@@ -713,6 +713,22 @@
             BtnAssociateFiles->setText(QPushButton::tr("Associate file extensions"));
             BtnAssociateFiles->setVisible(!custom_data && !custom_config);
             groupMisc->layout()->addWidget(BtnAssociateFiles, 4, 0, 1, 2);
+
+            // Divider
+
+            groupMisc->addDivider(); // row 5
+
+            QLabel *labelChatSize = new QLabel(groupMisc);
+            labelChatSize->setText(QLabel::tr("Initial in-game chat size (%)"));
+            groupMisc->layout()->addWidget(labelChatSize, 6, 0);
+
+            // Chat size adjustment
+            sbChatSize = new QSpinBox(groupMisc);
+            sbChatSize->setMinimum(80);
+            sbChatSize->setMaximum(2000);
+            sbChatSize->setValue(100);
+            groupMisc->layout()->addWidget(sbChatSize, 6, 1);
+
         }
 
 #ifdef __APPLE__
--- a/QTfrontend/ui/page/pageoptions.h	Fri Oct 11 20:18:07 2019 +0200
+++ b/QTfrontend/ui/page/pageoptions.h	Fri Jul 03 23:51:47 2020 +0200
@@ -106,6 +106,7 @@
 
         FPSEdit *fpsedit;
         QLabel *labelNN;
+        QSpinBox * sbChatSize;
         QSlider *SLVolume;
         QLabel *lblVolumeLevel;
         QLineEdit *editNetNick;
--- a/hedgewars/ArgParsers.pas	Fri Oct 11 20:18:07 2019 +0200
+++ b/hedgewars/ArgParsers.pas	Fri Jul 03 23:51:47 2020 +0200
@@ -106,6 +106,7 @@
     WriteLn(stdout, '  --no-hogtag: Disable hedgehog name tags');
     WriteLn(stdout, '  --no-healthtag: Disable hedgehog health tags');
     WriteLn(stdout, '  --translucent-tags: Enable translucent name and health tags');
+    WriteLn(stdout, '  --chat-size [default chat size in percent]');
     WriteLn(stdout, '  --showfps: Show frames per second');
     WriteLn(stdout, '');
     WriteLn(stdout, 'Miscellaneous:');
@@ -243,13 +244,13 @@
 end;
 
 function parseParameter(cmd:string; arg:string; var paramIndex:LongInt): Boolean;
-const reallyAll: array[0..34] of shortstring = (
+const reallyAll: array[0..35] of shortstring = (
                 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width',
                 '--height', '--maximized', '--frame-interval', '--volume','--nomusic', '--nosound', '--nodampen',
                 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick',
                 '--zoom',
   {internal}    '--internal', '--port', '--recorder', '--landpreview',
-  {misc}        '--stats-only', '--gci', '--help','--protocol', '--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags','--lua-test','--no-holiday-silliness');
+  {misc}        '--stats-only', '--gci', '--help','--protocol', '--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags','--lua-test','--no-holiday-silliness','--chat-size');
 var cmdIndex: byte;
 begin
     parseParameter:= false;
@@ -297,6 +298,7 @@
         {--translucent-tags}    32 : cTagsMask := cTagsMask or htTransparent;
         {--lua-test}            33 : begin cTestLua := true; SetSound(false); cScriptName := getstringParameter(arg, paramIndex, parseParameter); WriteLn(stdout, 'Lua test file specified: ' + cScriptName);end;
         {--no-holiday-silliness} 34 : cHolidaySilliness:= false;
+        {--chat-size}           35 : cDefaultChatScale := 1.0 * getLongIntParameter(arg, paramIndex, parseParameter) / 100;
     else
         begin
         //Assume the first "non parameter" is the demo file, anything else is invalid
--- a/hedgewars/uChat.pas	Fri Oct 11 20:18:07 2019 +0200
+++ b/hedgewars/uChat.pas	Fri Jul 03 23:51:47 2020 +0200
@@ -35,7 +35,7 @@
 procedure TextInput(var event: TSDL_TextInputEvent);
 
 implementation
-uses uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO, uScript, uRenderUtils, uLocale
+uses uConsts, uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO, uScript, uRenderUtils, uStore, uLocale
      {$IFDEF USE_VIDEO_RECORDING}, uVideoRec{$ENDIF};
 
 const MaxStrIndex = 27;
@@ -94,8 +94,14 @@
             );
 
 
-const Padding  = 2;
-      ClHeight = 2 * Padding + 16; // font height
+const PaddingFactor = (1/6); // relative to font size
+
+var Padding, ClHeight: integer;
+    LastChatScaleValue, LastUIScaleValue: real;
+    SkipNextInput: boolean;
+
+procedure UpdateInputLinePrefix(); forward;
+procedure UpdateCursorCoords(); forward;
 
 // relevant for UTF-8 handling
 function IsFirstCharByte(c: char): boolean; inline;
@@ -114,26 +120,105 @@
     selectedPos:= -1;
 end;
 
+procedure AdjustToUIScale();
+var fntSize: integer;
+begin
+    // don't do anything if no change
+    if (ChatScaleValue = LastChatScaleValue) and (UIScaleValue = LastUIScaleValue) then
+        exit;
+
+    LastChatScaleValue:= ChatScaleValue;
+    LastUIScaleValue:= UIScaleValue;
+
+    // determine font size - note: +0.001 to because I don't trust float inaccuracy combined with trunc
+    fntSize:= max(1, trunc(UIScaleValue * ChatScaleValue * cBaseChatFontHeight + 0.001));
+
+    if Fontz[fntChat].Height <> fntSize then
+        begin
+        // adjust associated heights
+        Fontz[fntChat].Height:= fntSize;
+        Fontz[CJKfntChat].Height:= fntSize;
+        // reload if initialized already
+        if Fontz[fntChat].Handle <> nil then
+            LoadFont(fntChat);
+        if Fontz[CJKfntChat].Handle <> nil then
+            LoadFont(CJKfntChat);
+        end;
+
+    // adjust line height etc.
+    Padding:= max(1, trunc(PaddingFactor * fntSize + 0.1));
+    ClHeight:= 2 * Padding + fntSize;
+
+    // clear cache of already rendered lines
+    ReloadLines();
+    UpdateInputLinePrefix();
+    UpdateCursorCoords();
+end;
+
+procedure ChatSizeInc(pxprecise: boolean);
+var fntSize: integer;
+begin
+if pxprecise then
+    begin
+    fntSize:= Fontz[fntChat].Height;
+    inc(fntSize);
+    ChatScaleValue:= 1.0 * fntSize / cBaseChatFontHeight;
+    end
+else
+    ChatScaleValue:= ChatScaleValue * (1.0 + cChatScaleRelDelta);
+if ChatScaleValue > cMaxChatScaleValue then
+    ChatScaleValue:= cMaxChatScaleValue;
+AdjustToUIScale();
+end;
+
+procedure ChatSizeDec(pxprecise: boolean);
+var fntSize: integer;
+begin
+if pxprecise then
+    begin
+    fntSize:= Fontz[fntChat].Height;
+    dec(fntSize);
+    ChatScaleValue:= 1.0 * fntSize / cBaseChatFontHeight;
+    end
+else
+    ChatScaleValue:= ChatScaleValue / (1.0 + cChatScaleRelDelta);
+if ChatScaleValue < cMinChatScaleValue then
+    ChatScaleValue:= cMinChatScaleValue;
+AdjustToUIScale();
+end;
+
+procedure chatSizeReset();
+begin
+ChatScaleValue:= cDefaultChatScale;
+AdjustToUIScale();
+end;
+
+function GetChatFont(str: shortstring): THWFONT;
+begin
+    GetChatFont:= CheckCJKFont(ansistring(str), fntChat);
+end;
+
 procedure UpdateCursorCoords();
 var font: THWFont;
     str : shortstring;
     coff, soff: LongInt;
 begin
+    AdjustToUIScale();
+
     if cursorPos = selectedPos then
         ResetSelection();
 
     // calculate cursor offset
 
     str:= InputStr.s;
-    font:= CheckCJKFont(ansistring(str), fnt16);
+    font:= GetChatFont(str);
 
     // get only substring before cursor to determine length
     // SetLength(str, cursorPos); // makes pas2c unhappy
     str[0]:= char(cursorPos);
     // get render size of text
     TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(str), @coff, nil);
-
-    cursorX:= 2 + coff;
+    cursorX:= Padding + coff;
 
     // calculate selection width on screen
     if selectedPos >= 0 then
@@ -171,7 +256,7 @@
 
 FreeAndNilTexture(cl.Tex);
 
-font:= CheckCJKFont(ansistring(str), fnt16);
+font:= GetChatFont(str);
 
 // get render size of text
 TTF_SizeUTF8(Fontz[font].Handle, Str2PChar(str), @cl.Width, nil);
@@ -200,7 +285,7 @@
 if strSurface <> nil then tmpSurface:= SDL_ConvertSurface(strSurface, resSurface^.format, 0);
 SDL_FreeSurface(strSurface);
 //SDL_UpperBlit(strSurface, nil, resSurface, @dstrect);
-if tmpSurface <> nil then copyToXY(tmpSurface, resSurface, Padding, Padding);
+if tmpSurface <> nil then copyToXY(tmpSurface, resSurface, Padding, 2);
 SDL_FreeSurface(tmpSurface);
 
 cl.Tex:= Surface2Tex(resSurface, false);
@@ -245,8 +330,9 @@
 procedure ReloadLines;
 var i: LongWord;
 begin
-    if InputStr.s <> '' then
-        SetLine(InputStr, InputStr.s, true);
+    // also reload empty input line (as chat size/scaling might have changed)
+    //if InputStr.s <> '' then
+    SetLine(InputStr, InputStr.s, true);
     for i:= 0 to MaxStrIndex do
         if Strs[i].s <> '' then
             begin
@@ -294,6 +380,8 @@
     selRect: TSDL_Rect;
     c: char;
 begin
+AdjustToUIScale();
+
 ChatReady:= true; // maybe move to somewhere else?
 
 if ChatHidden and (not showAll) then
@@ -329,12 +417,12 @@
         begin
         // draw cursor
         if ((RealTicks - LastKeyPressTick) and 512) < 256 then
-            DrawLineOnScreen(left + cursorX, top + 2, left + cursorX, top + ClHeight - 2, 2.0, $00, $FF, $FF, $FF);
+            DrawLineOnScreen(left + cursorX, top + Padding, left + cursorX, top + ClHeight - Padding, 2.0, $00, $FF, $FF, $FF);
         end
     else // draw selection
         begin
-        selRect.y:= top + 2;
-        selRect.h:= clHeight - 4;
+        selRect.y:= top + Padding;
+        selRect.h:= clHeight - 2 * Padding;
         if selectionDx < 0 then
             begin
             selRect.x:= left + cursorX + selectionDx;
@@ -1066,7 +1154,7 @@
             // ignore me!!!
             end;
         // TODO: figure out how to determine those keys better
-        SDL_SCANCODE_a:
+        SDL_SCANCODE_b:
             begin
             // select all
             if ctrlonly then
@@ -1102,6 +1190,33 @@
                 DeleteSelected();
                 end
             end;
+            // make chat bigger
+        SDL_SCANCODE_KP_PLUS, SDL_SCANCODE_EQUALS:
+            begin
+            if ctrl then
+                begin
+                ChatSizeInc(selMode);
+                SkipNextInput:= true;
+                end;
+            end;
+            // make chat smaller
+        SDL_SCANCODE_KP_MINUS, SDL_SCANCODE_MINUS:
+            begin
+            if ctrl then
+                begin
+                ChatSizeDec(selMode);
+                SkipNextInput:= true;
+                end;
+            end;
+            // revert chat size to default
+        SDL_SCANCODE_KP_0, SDL_SCANCODE_0:
+            begin
+            if ctrl then
+                begin
+                ChatSizeReset();
+                SkipNextInput:= true;
+                end;
+            end;
         end;
 end;
 
@@ -1110,16 +1225,25 @@
     l: byte;
     isl: integer;
 begin
+    if SkipNextInput then
+        begin
+        SkipNextInput:= false;
+        exit;
+        end;
+
     DeleteSelected();
 
+    s:= '';
     l:= 0;
     // fetch all bytes of character/input
     while event.text[l] <> #0 do
         begin
-        s[l + 1]:= event.text[l];
-        inc(l)
+        if Length(s) < 255 then
+            begin
+            s[l + 1]:= event.text[l];
+            inc(l)
+            end
         end;
-
     if l > 0 then
         begin
         isl:= Length(InputStr.s);
@@ -1235,6 +1359,10 @@
     ChatHidden:= false;
     firstDraw:= true;
 
+    LastChatScaleValue:= 0;
+    LastUIScaleValue:= 0;
+    SkipNextInput:= false;
+
     InputLinePrefix.Tex:= nil;
     UpdateInputLinePrefix();
     inputStr.s:= '';
--- a/hedgewars/uConsts.pas	Fri Oct 11 20:18:07 2019 +0200
+++ b/hedgewars/uConsts.pas	Fri Jul 03 23:51:47 2020 +0200
@@ -230,6 +230,13 @@
     // do not change this value
     cDefaultZoomLevel = 2.0; // 100% zoom
 
+    cBaseChatFontHeight = 12;
+    cChatScaleRelDelta = 0.1;
+    cMinChatScaleValue = 0.8;
+    cMaxChatScaleValue = 20.0;
+
+    cDefaultUIScaleLevel = 1.0;
+
     // game flags
     gfAny                = $FFFFFFFF; // mask for all possible gameflags
     gfOneClanMode        = $00000001; // Game does not end if there's only one clan in play. For missions
--- a/hedgewars/uStore.pas	Fri Oct 11 20:18:07 2019 +0200
+++ b/hedgewars/uStore.pas	Fri Jul 03 23:51:47 2020 +0200
@@ -33,6 +33,7 @@
 function makeHealthBarTexture(w, h, Color: Longword): PTexture;
 procedure AddProgress;
 procedure FinishProgress;
+procedure LoadFont(font: THWFont);
 function  LoadImage(const filename: shortstring; imageFlags: LongInt): PSDL_Surface;
 
 // loads an image from the games data files
@@ -362,23 +363,35 @@
             end
 end;
 
-procedure LoadFonts();
+procedure LoadFont(font: THWFont);
 var s: shortstring;
-    fi: THWFont;
+begin
+    with Fontz[font] do
+        begin
+        if Handle <> nil then
+            begin
+            TTF_CloseFont(Handle);
+            Handle:= nil;
+            end;
+        s:= cPathz[ptFonts] + '/' + Name;
+        WriteToConsole(msgLoading + s + ' (' + inttostr(Height) + 'pt)... ');
+        Handle:= TTF_OpenFontRW(rwopsOpenRead(s), true, Height);
+        if SDLCheck(Handle <> nil, 'TTF_OpenFontRW', true) then exit;
+        TTF_SetFontStyle(Handle, style);
+        WriteLnToConsole(msgOK)
+        end;
+end;
+
+procedure LoadFonts();
+var fi: THWFont;
 begin
 AddFileLog('LoadFonts();');
 
 if (not cOnlyStats) then
     for fi:= Low(THWFont) to High(THWFont) do
-        with Fontz[fi] do
-            begin
-            s:= cPathz[ptFonts] + '/' + Name;
-            WriteToConsole(msgLoading + s + ' (' + inttostr(Height) + 'pt)... ');
-            Handle:= TTF_OpenFontRW(rwopsOpenRead(s), true, Height);
-            if SDLCheck(Handle <> nil, 'TTF_OpenFontRW', true) then exit;
-            TTF_SetFontStyle(Handle, style);
-            WriteLnToConsole(msgOK)
-            end;
+        begin
+        LoadFont(fi);
+        end;
 end;
 
 procedure StoreLoad(reload: boolean);
--- a/hedgewars/uTypes.pas	Fri Oct 11 20:18:07 2019 +0200
+++ b/hedgewars/uTypes.pas	Fri Jul 03 23:51:47 2020 +0200
@@ -177,7 +177,7 @@
     // Different kind of crates that e.g. hedgehogs can pick up
     TCrateType = (HealthCrate, AmmoCrate, UtilityCrate);
 
-    THWFont = (fnt16, fntBig, fntSmall {$IFNDEF MOBILE}, CJKfnt16, CJKfntBig, CJKfntSmall{$ENDIF});
+    THWFont = (fnt16, fntBig, fntSmall, fntChat {$IFNDEF MOBILE}, CJKfnt16, CJKfntBig, CJKfntSmall, CJKfntChat{$ENDIF});
 
     TCapGroup = (capgrpGameState, capgrpAmmoinfo, capgrpVolume,
             capgrpMessage, capgrpMessage2, capgrpAmmostate);
--- a/hedgewars/uVariables.pas	Fri Oct 11 20:18:07 2019 +0200
+++ b/hedgewars/uVariables.pas	Fri Jul 03 23:51:47 2020 +0200
@@ -140,6 +140,9 @@
     zoom             : GLfloat; // current zoom
     ZoomValue        : GLfloat; // aimed zoom
     UserZoom         : GLfloat; // user-chosen initial and default zoom
+    ChatScaleValue   : real;
+    cDefaultChatScale: real;
+    UIScaleValue     : real;
 
     cWaterLine       : LongInt;
     cGearScrEdgesDist: LongInt;
@@ -262,6 +265,8 @@
 
     // for tracking the limits of the visible grid based on cScaleFactor
     ViewLeftX, ViewRightX, ViewBottomY, ViewTopY, ViewWidth, ViewHeight: LongInt;
+    // for tracking the limits of the visible UI space based on cUIScaleFactor
+    UIWidth, UIHeight: LongInt;
 
     // for debugging the view limits visually
     cViewLimitsDebug: boolean;
@@ -358,6 +363,10 @@
             (Handle: nil;
             Height: 10*HDPIScaleFactor;
             style: TTF_STYLE_NORMAL;
+            Name: 'DejaVuSans-Bold.ttf'),
+            (Handle: nil; // fntChat
+            Height: 12*HDPIScaleFactor;
+            style: TTF_STYLE_NORMAL;
             Name: 'DejaVuSans-Bold.ttf')
             {$IFNDEF MOBILE}, // remove chinese fonts for now
             (Handle: nil;
@@ -371,6 +380,10 @@
             (Handle: nil;
             Height: 10*HDPIScaleFactor;
             style: TTF_STYLE_NORMAL;
+            Name: 'wqy-zenhei.ttc'),
+            (Handle: nil; // CJKfntChat
+            Height: 12*HDPIScaleFactor;
+            style: TTF_STYLE_NORMAL;
             Name: 'wqy-zenhei.ttc')
             {$ENDIF}
             );
@@ -2592,6 +2605,7 @@
     SyncTexture,
     ConfirmTexture: PTexture;
     cScaleFactor: GLfloat;
+    cUIScaleFactor: float;
     cStereoDepth: GLfloat;
     SupportNPOTT: Boolean;
     Step: LongInt;
@@ -2717,6 +2731,8 @@
     cAudioCodec        := '';
 {$ENDIF}
 
+    cDefaultChatScale:= 1.0;
+
     cTagsMask:= htTeamName or htName or htHealth;
     cPrevTagsMask:= cTagsMask;
 end;
@@ -2923,6 +2939,16 @@
     cExplosives     := 2;
 
     GameState       := Low(TGameState);
+    zoom            := cDefaultZoomLevel;
+    ZoomValue       := cDefaultZoomLevel;
+
+    if cDefaultChatScale < cMinChatScaleValue then
+        cDefaultChatScale := cMinChatScaleValue
+    else if cDefaultChatScale > cMaxChatScaleValue then
+        cDefaultChatScale := cMaxChatScaleValue;
+    ChatScaleValue  := cDefaultChatScale;
+    UIScaleValue    := cDefaultUIScaleLevel;
+
     WeaponTooltipTex:= nil;
     cLaserSighting  := false;
     cLaserSightingSniper := false;