From 9ed4da85e64cb78b4eb55f12cac11e2dca9610a7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 1 May 2013 16:30:34 +0300 Subject: 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. --- src/gui/theme.cpp | 43 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 7 deletions(-) (limited to 'src/gui/theme.cpp') 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() -- cgit v1.2.3-70-g09d2