Add settings.ini setting and hwengine param to disable holiday silliness (hat changes, etc.)
authorWuzzy <Wuzzy2@mail.ru>
Fri, 25 Jan 2019 06:46:13 +0100
changeset 14691 56831f466d1d
parent 14690 fd22b6d474e7
child 14692 455865ccd36c
Add settings.ini setting and hwengine param to disable holiday silliness (hat changes, etc.) settings.ini: In section [misc], add "holidaySilliness=false" hwengine: Add --no-holiday-silliness to command-line
QTfrontend/game.cpp
QTfrontend/gameuiconfig.cpp
QTfrontend/gameuiconfig.h
QTfrontend/hwform.cpp
QTfrontend/main.cpp
hedgewars/ArgParsers.pas
hedgewars/uStore.pas
hedgewars/uVariables.pas
--- a/QTfrontend/game.cpp	Wed Jan 23 03:46:32 2019 +0100
+++ b/QTfrontend/game.cpp	Fri Jan 25 06:46:13 2019 +0100
@@ -467,6 +467,8 @@
         arguments << "--no-healthtag";
     if (config->Form->ui.pageOptions->CBTagOpacity->isChecked())
         arguments << "--translucent-tags";
+    if (!config->isHolidaySillinessEnabled())
+        arguments << "--no-holiday-silliness";
 
     return arguments;
 }
--- a/QTfrontend/gameuiconfig.cpp	Wed Jan 23 03:46:32 2019 +0100
+++ b/QTfrontend/gameuiconfig.cpp	Fri Jan 25 06:46:13 2019 +0100
@@ -441,6 +441,11 @@
     return Form->ui.pageOptions->CBFrontendFullscreen->isChecked();
 }
 
+bool GameUIConfig::isHolidaySillinessEnabled() const
+{
+    return value("misc/holidaySilliness", true).toBool();
+}
+
 bool GameUIConfig::isSoundEnabled()
 {
     return Form->ui.pageOptions->CBSound->isChecked();
--- a/QTfrontend/gameuiconfig.h	Wed Jan 23 03:46:32 2019 +0100
+++ b/QTfrontend/gameuiconfig.h	Fri Jan 25 06:46:13 2019 +0100
@@ -66,6 +66,7 @@
         bool isReducedQuality() const;
         bool isFrontendEffects() const;
         bool isFrontendFullscreen() const;
+        bool isHolidaySillinessEnabled() const;
         void resizeToConfigValues();
         quint32 stereoMode() const;
         void setValue(const QString & key, const QVariant & value);
--- a/QTfrontend/hwform.cpp	Wed Jan 23 03:46:32 2019 +0100
+++ b/QTfrontend/hwform.cpp	Fri Jan 25 06:46:13 2019 +0100
@@ -2266,7 +2266,8 @@
                    + (!config->Form->ui.pageOptions->CBTeamTag->isChecked() ? " --no-teamtag" : "")
                    + (!config->Form->ui.pageOptions->CBHogTag->isChecked() ? " --no-hogtag" : "")
                    + (!config->Form->ui.pageOptions->CBHealthTag->isChecked() ? " --no-healthtag" : "")
-                   + (config->Form->ui.pageOptions->CBTagOpacity->isChecked() ? " --translucent-tags" : "");
+                   + (config->Form->ui.pageOptions->CBTagOpacity->isChecked() ? " --translucent-tags" : "")
+                   + (!config->isHolidaySillinessEnabled() ? " --no-holiday-silliness" : "");
 }
 
 void HWForm::AssociateFiles()
--- a/QTfrontend/main.cpp	Wed Jan 23 03:46:32 2019 +0100
+++ b/QTfrontend/main.cpp	Fri Jan 25 06:46:13 2019 +0100
@@ -395,10 +395,9 @@
 
     QTranslator TranslatorHedgewars;
     QTranslator TranslatorQt;
+    QSettings settings(DataManager::instance().settingsFileName(), QSettings::IniFormat);
+    settings.setIniCodec("UTF-8");
     {
-        QSettings settings(DataManager::instance().settingsFileName(), QSettings::IniFormat);
-        settings.setIniCodec("UTF-8");
-
         QString cc = settings.value("misc/locale", QString()).toString();
         if (cc.isEmpty())
         {
@@ -494,11 +493,16 @@
     QString style = "";
     QString fname;
 
-    checkSeason();
-    //For each season, there is an extra stylesheet
-    //Todo: change background for easter and birthday
-    //(simply replace res/BackgroundBirthday.png and res/BackgroundEaster.png
-    //with an appropriate background
+    bool holidaySilliness = settings.value("misc/holidaySilliness", true).toBool();
+    if(holidaySilliness)
+        checkSeason();
+    else
+        season = SEASON_NONE;
+
+    // For each season, there is an extra stylesheet.
+    // TODO: change background for easter
+    // (simply replace res/BackgroundEaster.png
+    // with an appropriate background).
     switch (season)
     {
         case SEASON_CHRISTMAS :
--- a/hedgewars/ArgParsers.pas	Wed Jan 23 03:46:32 2019 +0100
+++ b/hedgewars/ArgParsers.pas	Fri Jan 25 06:46:13 2019 +0100
@@ -239,13 +239,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..18] of string = ('--fullscreen-width','--fullscreen-height', '--width', '--height', '--depth','--volume','--nomusic','--nosound','--nodampen','--locale','--fullscreen','--showfps','--altdmg','--frame-interval','--low-quality','--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags');
-      reallyAll: array[0..37] of shortstring = (
+      reallyAll: array[0..38] of shortstring = (
                 '--prefix', '--user-prefix', '--locale', '--fullscreen-width', '--fullscreen-height', '--width',
                 '--height', '--frame-interval', '--volume','--nomusic', '--nosound', '--nodampen',
                 '--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','--protocol', '--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags','--lua-test');
+  {misc}        '--stats-only', '--gci', '--help','--protocol', '--no-teamtag','--no-hogtag','--no-healthtag','--translucent-tags','--lua-test','--no-holiday-silliness');
 var cmdIndex: byte;
 begin
     parseParameter:= false;
@@ -297,6 +297,7 @@
         {--no-healthtag}        35 : cTagsMask := cTagsMask and (not htHealth);
         {--translucent-tags}    36 : cTagsMask := cTagsMask or htTransparent;
         {--lua-test}            37 : begin cTestLua := true; SetSound(false); cScriptName := getstringParameter(arg, paramIndex, parseParameter); WriteLn(stdout, 'Lua test file specified: ' + cScriptName);end;
+        {--no-holiday-silliness} 38 : cHolidaySilliness:= false;
     else
         begin
         //Assume the first "non parameter" is the demo file, anything else is invalid
--- a/hedgewars/uStore.pas	Wed Jan 23 03:46:32 2019 +0100
+++ b/hedgewars/uStore.pas	Fri Jan 25 06:46:13 2019 +0100
@@ -278,19 +278,23 @@
                     if ExtDriven then
                          NameTagTex:= RenderStringTexLim(ansistring(Name), Clan^.Color, fnt16, cTeamHealthWidth)
                     else NameTagTex:= RenderStringTex(ansistring(Name), Clan^.Color, fnt16);
-                    if Hat = 'NoHat' then
+                    if cHolidaySilliness then
                         begin
-                        if (month = 4) and (md = 20) then
-                            Hat := 'eastertop'   // Easter
-                        else if (month = 12) and ((md = 24) or (md = 25) or (md = 26)) then
-                            Hat := 'Santa'       // Christmas Eve/Christmas/Boxing Day
-                        else if (month = 10) and (md = 31) then
-                            Hat := 'fr_pumpkin'; // Halloween/Hedgewars' birthday
-                        end;
-                    if (month = 4) and (md = 1) then
-                        begin
-                        AprilOne:= true;
-                        Hat := 'fr_tomato'; // avoid promoting violence to hedgehogs. see https://hedgewars.org/node/5818
+                        // Special hats on special days
+                        if Hat = 'NoHat' then
+                            begin
+                            if (month = 4) and (md = 20) then
+                                Hat := 'eastertop'   // Easter
+                            else if (month = 12) and ((md = 24) or (md = 25) or (md = 26)) then
+                                Hat := 'Santa'       // Christmas Eve/Christmas/Boxing Day
+                            else if (month = 10) and (md = 31) then
+                                Hat := 'fr_pumpkin'; // Halloween/Hedgewars' birthday
+                            end;
+                        if (month = 4) and (md = 1) then
+                            begin
+                            AprilOne:= true;
+                            Hat := 'fr_tomato'; // avoid promoting violence to hedgehogs. see https://hedgewars.org/node/5818
+                            end;
                         end;
 
                     if Hat <> 'NoHat' then
--- a/hedgewars/uVariables.pas	Wed Jan 23 03:46:32 2019 +0100
+++ b/hedgewars/uVariables.pas	Fri Jan 25 06:46:13 2019 +0100
@@ -55,6 +55,7 @@
 
     cAltDamage         : boolean;
     cReducedQuality    : LongWord;
+    cHolidaySilliness  : boolean;
     UserNick           : shortstring;
     recordFileName     : shortstring;
     cReadyDelay        : Longword;
@@ -2604,6 +2605,7 @@
 
     cShowFPS        := false;
     cAltDamage      := false;
+    cHolidaySilliness := true;
     cTimerInterval  := 8;
     cReducedQuality := rqNone;
     cLanguageFName  := 'en.txt';