Add icons to background themes; allow to hide themes explicitly by adding “hidden” key to theme.cfg
authorWuzzy <Wuzzy2@mail.ru>
Thu, 22 Mar 2018 16:52:04 +0100
changeset 13272 48b23e6f26d9
parent 13271 df1db657bbb4
child 13273 825f558c51b8
Add icons to background themes; allow to hide themes explicitly by adding “hidden” key to theme.cfg
ChangeLog.txt
QTfrontend/model/ThemeModel.cpp
QTfrontend/model/ThemeModel.h
share/hedgewars/Data/Themes/Blox/icon.png
share/hedgewars/Data/Themes/Blox/icon@2x.png
share/hedgewars/Data/Themes/Blox/theme.cfg
share/hedgewars/Data/Themes/CrazyMission/icon.png
share/hedgewars/Data/Themes/CrazyMission/icon@2x.png
share/hedgewars/Data/Themes/CrazyMission/theme.cfg
share/hedgewars/Data/Themes/Deepspace/icon.png
share/hedgewars/Data/Themes/Deepspace/icon@2x.png
share/hedgewars/Data/Themes/Deepspace/theme.cfg
share/hedgewars/Data/Themes/Eyes/icon.png
share/hedgewars/Data/Themes/Eyes/icon@2x.png
share/hedgewars/Data/Themes/Eyes/theme.cfg
share/hedgewars/Data/Themes/Planes/icon.png
share/hedgewars/Data/Themes/Planes/icon@2x.png
share/hedgewars/Data/Themes/Planes/theme.cfg
--- a/ChangeLog.txt	Thu Mar 22 16:08:33 2018 +0100
+++ b/ChangeLog.txt	Thu Mar 22 16:52:04 2018 +0100
@@ -36,6 +36,7 @@
  + New flag: uk_scotland
  + New voice: Default_pl (Polish)
  + New voice: Russian_pl (Polish with a Russian accent)
+ + Add theme icons for: Blox, CrazyMission, Deepspace, Eyes, Planes
 
 Styles and game modes:
  + Various styles: Add current score/time next to team bars (where applicable)
@@ -95,8 +96,9 @@
  + Target Practice: Re-center camera to hog when projectile is destroyed or drowns
 
 Theme customization:
- + Add fallback music with fallback-music and fallback-sd-music
- * Fix green color channel on themes with sd-tint
+ + Add fallback music with new keys “fallback-music” and “fallback-sd-music”
+ + Allow to hide themes explicitly with new key “hidden”. Using this key it's possible for hidden themes to have icons
+ * Fix green color channel on themes with key “sd-tint”
 
 Lua API:
  + New library: SimpleMission: Allows to create missions more easily
--- a/QTfrontend/model/ThemeModel.cpp	Thu Mar 22 16:08:33 2018 +0100
+++ b/QTfrontend/model/ThemeModel.cpp	Thu Mar 22 16:52:04 2018 +0100
@@ -128,7 +128,33 @@
         QString iconpath = QString("physfs://Themes/%1/icon.png").arg(theme);
 
         if (!QFile::exists(iconpath))
+        {
             dataset.insert(IsHiddenRole, true);
+        }
+        else
+        {
+            // themes with the key “hidden” in theme.cfg are hidden, too
+            QFile themeCfgFile(QString("physfs://Themes/%1/theme.cfg").arg(theme));
+            if (themeCfgFile.open(QFile::ReadOnly))
+            {
+                QTextStream stream(&themeCfgFile);
+                QString line = stream.readLine();
+                QString key;
+                while (!line.isNull())
+                {
+                    key = QString(line);
+                    int equalsPos = line.indexOf('=');
+                    key.truncate(equalsPos - 1);
+                    key = key.simplified();
+                    if (!line.startsWith(';') && key == "hidden")
+                    {
+                        dataset.insert(IsHiddenRole, true);
+                        break;
+                    }
+                    line = stream.readLine();
+                }
+            }
+        }
 
         // detect if theme is dlc
         QString themeDir = PHYSFS_getRealDir(QString("Themes/%1").arg(theme).toLocal8Bit().data());
--- a/QTfrontend/model/ThemeModel.h	Thu Mar 22 16:08:33 2018 +0100
+++ b/QTfrontend/model/ThemeModel.h	Thu Mar 22 16:52:04 2018 +0100
@@ -28,6 +28,7 @@
 #include <QStringList>
 #include <QMap>
 #include <QIcon>
+#include <QTextStream>
 
 #include "ThemeFilterProxyModel.h"
 #include "DataManager.h"
Binary file share/hedgewars/Data/Themes/Blox/icon.png has changed
Binary file share/hedgewars/Data/Themes/Blox/icon@2x.png has changed
--- a/share/hedgewars/Data/Themes/Blox/theme.cfg	Thu Mar 22 16:08:33 2018 +0100
+++ b/share/hedgewars/Data/Themes/Blox/theme.cfg	Thu Mar 22 16:52:04 2018 +0100
@@ -1,3 +1,4 @@
+hidden = true
 sky = 179, 243, 243
 border = 128, 128, 128
 music = Nature.ogg
Binary file share/hedgewars/Data/Themes/CrazyMission/icon.png has changed
Binary file share/hedgewars/Data/Themes/CrazyMission/icon@2x.png has changed
--- a/share/hedgewars/Data/Themes/CrazyMission/theme.cfg	Thu Mar 22 16:08:33 2018 +0100
+++ b/share/hedgewars/Data/Themes/CrazyMission/theme.cfg	Thu Mar 22 16:52:04 2018 +0100
@@ -1,3 +1,4 @@
+hidden = true
 sky = 20, 23, 24
 border = 20, 23, 24
 water-top = 21, 57, 76
Binary file share/hedgewars/Data/Themes/Deepspace/icon.png has changed
Binary file share/hedgewars/Data/Themes/Deepspace/icon@2x.png has changed
--- a/share/hedgewars/Data/Themes/Deepspace/theme.cfg	Thu Mar 22 16:08:33 2018 +0100
+++ b/share/hedgewars/Data/Themes/Deepspace/theme.cfg	Thu Mar 22 16:52:04 2018 +0100
@@ -1,3 +1,4 @@
+hidden = true
 sky = 0, 0, 0
 border = 175, 177, 75
 water-top = $2B, $2B, $2B
Binary file share/hedgewars/Data/Themes/Eyes/icon.png has changed
Binary file share/hedgewars/Data/Themes/Eyes/icon@2x.png has changed
--- a/share/hedgewars/Data/Themes/Eyes/theme.cfg	Thu Mar 22 16:08:33 2018 +0100
+++ b/share/hedgewars/Data/Themes/Eyes/theme.cfg	Thu Mar 22 16:52:04 2018 +0100
@@ -1,3 +1,4 @@
+hidden = true
 sky = 0, 0, 0
 border = 175, 177, 75
 water-top = $2B, $2B, $2B
Binary file share/hedgewars/Data/Themes/Planes/icon.png has changed
Binary file share/hedgewars/Data/Themes/Planes/icon@2x.png has changed
--- a/share/hedgewars/Data/Themes/Planes/theme.cfg	Thu Mar 22 16:08:33 2018 +0100
+++ b/share/hedgewars/Data/Themes/Planes/theme.cfg	Thu Mar 22 16:52:04 2018 +0100
@@ -1,3 +1,4 @@
+hidden = true
 sky = 21, 20, 38
 border = 177, 175, 49
 music = City.ogg