add chat size to misc settings. persist in settings.ini ui-scaling
authorsheepluva
Wed, 16 May 2018 18:09:13 +0200
branchui-scaling
changeset 13389 24b531dcebe7
parent 13388 32a1696ca93a
child 13390 0135e64c6c66
add chat size to misc settings. persist in settings.ini
QTfrontend/game.cpp
QTfrontend/gameuiconfig.cpp
QTfrontend/gameuiconfig.h
QTfrontend/net/recorder.cpp
QTfrontend/ui/page/pageoptions.cpp
QTfrontend/ui/page/pageoptions.h
hedgewars/ArgParsers.pas
hedgewars/uChat.pas
hedgewars/uConsts.pas
hedgewars/uVariables.pas
--- a/QTfrontend/game.cpp	Wed May 16 10:11:00 2018 +0200
+++ b/QTfrontend/game.cpp	Wed May 16 18:09:13 2018 +0200
@@ -427,6 +427,8 @@
         arguments << "--no-healthtag";
     if (config->Form->ui.pageOptions->CBTagOpacity->isChecked())
         arguments << "--translucent-tags";
+    arguments << "--chat-size";
+    arguments << QString::number(config->chatSize());
 
     return arguments;
 }
--- a/QTfrontend/gameuiconfig.cpp	Wed May 16 10:11:00 2018 +0200
+++ b/QTfrontend/gameuiconfig.cpp	Wed May 16 18:09:13 2018 +0200
@@ -175,6 +175,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)
@@ -321,6 +323,8 @@
             setValue(QString("colors/color%1").arg(i), model->item(i)->data().value<QColor>().name());
     }
 
+    setValue("chat/size", Form->ui.pageOptions->sbChatSize->value());
+
     sync();
 }
 
@@ -592,6 +596,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	Wed May 16 10:11:00 2018 +0200
+++ b/QTfrontend/gameuiconfig.h	Wed May 16 18:09:13 2018 +0200
@@ -50,6 +50,7 @@
         bool isShowFPSEnabled();
         bool isAltDamageEnabled();
         bool appendDateTimeToRecordName();
+        int chatSize();
         quint8 volume();
         quint8 timerInterval();
         QString netNick();
--- a/QTfrontend/net/recorder.cpp	Wed May 16 10:11:00 2018 +0200
+++ b/QTfrontend/net/recorder.cpp	Wed May 16 18:09:13 2018 +0200
@@ -141,6 +141,8 @@
 // The library does support using both at once after all.
     arguments << QString::number(config->rec_Bitrate()*1024);
     arguments << (config->recordAudio() ? config->audioCodec() : "no");
+    arguments << "--chat-size";
+    arguments << QString::number(config->chatSize());
 
     return arguments;
 }
--- a/QTfrontend/ui/page/pageoptions.cpp	Wed May 16 10:11:00 2018 +0200
+++ b/QTfrontend/ui/page/pageoptions.cpp	Wed May 16 18:09:13 2018 +0200
@@ -683,6 +683,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("Chat size in percent"));
+            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	Wed May 16 10:11:00 2018 +0200
+++ b/QTfrontend/ui/page/pageoptions.h	Wed May 16 18:09:13 2018 +0200
@@ -104,6 +104,7 @@
 
         FPSEdit *fpsedit;
         QLabel *labelNN;
+        QSpinBox * sbChatSize;
         QSlider *SLVolume;
         QLabel *lblVolumeLevel;
         QLineEdit *editNetNick;
--- a/hedgewars/ArgParsers.pas	Wed May 16 10:11:00 2018 +0200
+++ b/hedgewars/ArgParsers.pas	Wed May 16 18:09:13 2018 +0200
@@ -96,6 +96,7 @@
     WriteLn(stdout, ' --no-hogtag');
     WriteLn(stdout, ' --no-healthtag');
     WriteLn(stdout, ' --translucent-tags');
+    WriteLn(stdout, ' --chat-size [default chat size in percent]');
     WriteLn(stdout, ' --stats-only');
     WriteLn(stdout, ' --help');
     WriteLn(stdout, '');
@@ -215,13 +216,13 @@
       otherarray: array [0..2] of string = ('--locale','--fullscreen','--showfps');
       mediaarray: array [0..9] of string = ('--fullscreen-width', '--fullscreen-height', '--width', '--height', '--depth', '--volume','--nomusic','--nosound','--locale','--fullscreen');
       allarray: array [0..17] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags');
-      reallyAll: array[0..35] of shortstring = (
+      reallyAll: array[0..36] of shortstring = (
                 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width',
                 '--height', '--frame-interval', '--volume','--nomusic', '--nosound',
                 '--fullscreen', '--showfps', '--altdmg', '--low-quality', '--raw-quality', '--stereo', '--nick',
   {deprecated}  '--depth', '--set-video', '--set-audio', '--set-other', '--set-multimedia', '--set-everything',
   {internal}    '--internal', '--port', '--recorder', '--landpreview',
-  {misc}        '--stats-only', '--gci', '--help','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags','--lua-test');
+  {misc}        '--stats-only', '--gci', '--help','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags','--lua-test','--chat-size');
 var cmdIndex: byte;
 begin
     parseParameter:= false;
@@ -271,6 +272,7 @@
         {--no-healthtag}        33 : cTagsMask := cTagsMask and (not htHealth);
         {--translucent-tags}    34 : cTagsMask := cTagsMask or htTransparent;
         {--lua-test}            35 : begin cTestLua := true; SetSound(false); cScriptName := getstringParameter(arg, paramIndex, parseParameter); WriteLn(stdout, 'Lua test file specified: ' + cScriptName);end;
+        {--chat-size}           36 : cDefaultChatScale := 1.0 * getLongIntParameter(arg, paramIndex, parseParameter) / 100;
     else
         begin
         //Assume the first "non parameter" is the replay file, anything else is invalid
--- a/hedgewars/uChat.pas	Wed May 16 10:11:00 2018 +0200
+++ b/hedgewars/uChat.pas	Wed May 16 18:09:13 2018 +0200
@@ -35,7 +35,7 @@
 procedure TextInput(var event: TSDL_TextInputEvent);
 
 implementation
-uses uConsts, uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO, uScript, uRenderUtils, uStore, Math;
+uses uConsts, uInputHandler, uTypes, uVariables, uCommands, uUtils, uTextures, uRender, uIO, uScript, uRenderUtils, uStore;
 
 const MaxStrIndex = 27;
       MaxInputStrLen = 200;
@@ -129,8 +129,8 @@
     LastChatScaleValue:= ChatScaleValue;
     LastUIScaleValue:= UIScaleValue;
 
-    // determine font size - note: +0.001 to because I don't trust float inaccuracy combined with floor
-    fntSize:= max(1, floor(UIScaleValue * ChatScaleValue * cBaseChatFontHeight + 0.001));
+    // 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
@@ -145,7 +145,7 @@
         end;
 
     // adjust line height etc.
-    Padding:= max(1, floor(PaddingFactor * fntSize + 0.1));
+    Padding:= max(1, trunc(PaddingFactor * fntSize + 0.1));
     ClHeight:= 2 * Padding + fntSize;
 
     // clear cache of already rendered lines
@@ -188,7 +188,7 @@
 
 procedure chatSizeReset();
 begin
-ChatScaleValue:= cDefaultChatScaleLevel;
+ChatScaleValue:= cDefaultChatScale;
 AdjustToUIScale();
 end;
 
--- a/hedgewars/uConsts.pas	Wed May 16 10:11:00 2018 +0200
+++ b/hedgewars/uConsts.pas	Wed May 16 18:09:13 2018 +0200
@@ -196,10 +196,9 @@
     cDefaultZoomLevel = 2.0;
 
     cBaseChatFontHeight = 12;
-    cDefaultChatScaleLevel = 1.0;
     cChatScaleRelDelta = 0.1;
     cMinChatScaleValue = 0.8;
-    cMaxChatScaleValue = 20;
+    cMaxChatScaleValue = 20.0;
 
     cDefaultUIScaleLevel = 1.0;
 
--- a/hedgewars/uVariables.pas	Wed May 16 10:11:00 2018 +0200
+++ b/hedgewars/uVariables.pas	Wed May 16 18:09:13 2018 +0200
@@ -128,6 +128,7 @@
     zoom             : GLfloat;
     ZoomValue        : GLfloat;
     ChatScaleValue   : real;
+    cDefaultChatScale: real;
     UIScaleValue     : real;
 
     cWaterLine       : LongInt;
@@ -2641,6 +2642,8 @@
     cAudioCodec        := '';
 {$ENDIF}
 
+    cDefaultChatScale:= 1.0;
+
     cTagsMask:= htTeamName or htName or htHealth;
     cPrevTagsMask:= cTagsMask;
 end;
@@ -2835,8 +2838,14 @@
     GameState       := Low(TGameState);
     zoom            := cDefaultZoomLevel;
     ZoomValue       := cDefaultZoomLevel;
-    ChatScaleValue  := cDefaultChatScaleLevel;
+
+    if cDefaultChatScale < cMinChatScaleValue then
+        cDefaultChatScale := cMinChatScaleValue
+    else if cDefaultChatScale > cMaxChatScaleValue then
+        cDefaultChatScale := cMaxChatScaleValue;
+    ChatScaleValue  := cDefaultChatScale;
     UIScaleValue    := cDefaultUIScaleLevel;
+
     WeaponTooltipTex:= nil;
     cLaserSighting  := false;
     cLaserSightingSniper := false;