summaryrefslogtreecommitdiff
path: root/src/gui/theme.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-05-01 16:30:34 +0300
committerAndrei Karas <akaras@inbox.ru>2013-05-01 17:27:14 +0300
commit9ed4da85e64cb78b4eb55f12cac11e2dca9610a7 (patch)
treeb160762f520bc73f21c87cca4556ab046d313ae8 /src/gui/theme.cpp
parent097b17e588ed430482fa1e5e4938618db838e468 (diff)
downloadmv-9ed4da85e64cb78b4eb55f12cac11e2dca9610a7.tar.gz
mv-9ed4da85e64cb78b4eb55f12cac11e2dca9610a7.tar.bz2
mv-9ed4da85e64cb78b4eb55f12cac11e2dca9610a7.tar.xz
mv-9ed4da85e64cb78b4eb55f12cac11e2dca9610a7.zip
Add ability to load theme xml files depend on screen density.
Known densities: low medium tv high xhigh xxhigh Xml file name example with density: window_high.xml if file with density missing, will be loaded file without density.
Diffstat (limited to 'src/gui/theme.cpp')
-rw-r--r--src/gui/theme.cpp43
1 files changed, 36 insertions, 7 deletions
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp
index db3b247cb..56598ade1 100644
--- a/src/gui/theme.cpp
+++ b/src/gui/theme.cpp
@@ -26,6 +26,7 @@
#include "client.h"
#include "configuration.h"
+#include "graphicsmanager.h"
#include "resources/dye.h"
#include "resources/image.h"
@@ -43,6 +44,8 @@ static std::string defaultThemePath;
std::string Theme::mThemePath;
std::string Theme::mThemeName;
+std::string Theme::mScreenDensity;
+
Theme *Theme::mInstance = nullptr;
// Set the theme path...
@@ -273,13 +276,38 @@ Skin *Theme::load(const std::string &filename, const std::string &filename2,
return skinIterator->second;
}
- Skin *skin = readSkin(filename, full);
-
- if (!skin && !filename2.empty() && filename2 != filename)
- skin = readSkin(filename2, full);
-
- if (!skin && filename2 != "window.xml")
- skin = readSkin("window.xml", full);
+ Skin *skin = nullptr;
+ if (mScreenDensity.empty())
+ { // if no density detected
+ skin = readSkin(filename, full);
+ if (!skin && !filename2.empty() && filename2 != filename)
+ skin = readSkin(filename2, full);
+ if (!skin && filename2 != "window.xml")
+ skin = readSkin("window.xml", full);
+ }
+ else
+ { // first use correct density images
+ const std::string endStr = "_" + mScreenDensity + ".xml";
+ std::string name = filename;
+ if (findCutLast(name, ".xml"))
+ skin = readSkin(name + endStr, full);
+ if (!skin)
+ skin = readSkin(filename, full);
+ if (!skin && !filename2.empty() && filename2 != filename)
+ {
+ name = filename2;
+ if (findCutLast(name, ".xml"))
+ skin = readSkin(name + endStr, full);
+ if (!skin)
+ skin = readSkin(filename2, full);
+ }
+ if (!skin && filename2 != "window.xml")
+ {
+ skin = readSkin("window" + endStr, full);
+ if (!skin)
+ skin = readSkin("window.xml", full);
+ }
+ }
if (!skin)
{
@@ -663,6 +691,7 @@ void Theme::fillSoundsList(StringVect &list)
void Theme::selectSkin()
{
prepareThemePath();
+ mScreenDensity = graphicsManager.getDensityString();
}
void Theme::prepareThemePath()