aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Sandulenko2015-11-06 15:14:42 +0100
committerEugene Sandulenko2015-11-07 13:26:56 +0100
commit7d58a50c46ecb7001702a696a3c92eb5ab3d0a36 (patch)
tree6739aabdac263bfe2eb4c7f35189fa6415245748
parent51750206aaffdfd77a94a31af1a9490fa8f84d82 (diff)
downloadscummvm-rg350-7d58a50c46ecb7001702a696a3c92eb5ab3d0a36.tar.gz
scummvm-rg350-7d58a50c46ecb7001702a696a3c92eb5ab3d0a36.tar.bz2
scummvm-rg350-7d58a50c46ecb7001702a696a3c92eb5ab3d0a36.zip
GUI: Removed 64k limit on built-in theme XML size
-rw-r--r--gui/ThemeEngine.cpp18
-rw-r--r--gui/themes/default.inc13
-rwxr-xr-xgui/themes/scummtheme.py30
3 files changed, 43 insertions, 18 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index ed01204180..016cfc136d 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -739,12 +739,24 @@ bool ThemeEngine::loadDefaultXML() {
// Use the Python script "makedeftheme.py" to convert a normal XML theme
// into the "default.inc" file, which is ready to be included in the code.
#ifndef DISABLE_GUI_BUILTIN_THEME
- const char *defaultXML =
#include "themes/default.inc"
- ;
+ int xmllen = 0;
+
+ for (int i = 0; i < ARRAYSIZE(defaultXML); i++)
+ xmllen += strlen(defaultXML[i]);
+
+ byte *tmpXML = (byte *)malloc(xmllen + 1);
+
+ for (int i = 0; i < ARRAYSIZE(defaultXML); i++)
+ strncat((char *)tmpXML, defaultXML[i], xmllen);
+
+ if (!_parser->loadBuffer(tmpXML, xmllen)) {
+ free(tmpXML);
- if (!_parser->loadBuffer((const byte *)defaultXML, strlen(defaultXML)))
return false;
+ }
+
+ free(tmpXML);
_themeName = "ScummVM Classic Theme (Builtin Version)";
_themeId = "builtin";
diff --git a/gui/themes/default.inc b/gui/themes/default.inc
index 33aac29835..90d7967bc0 100644
--- a/gui/themes/default.inc
+++ b/gui/themes/default.inc
@@ -1,5 +1,6 @@
- "<?xml version = '1.0'?>"
-"<render_info>"
+const char *defaultXML1 = "<?xml version = '1.0'?>"
+;
+ const char *defaultXML2 = "<render_info>"
"<palette>"
"<color name='black' "
"rgb='0,0,0' "
@@ -610,7 +611,8 @@
"/>"
"</drawdata>"
"</render_info>"
-"<layout_info resolution='y>399'>"
+;
+ const char *defaultXML3 = "<layout_info resolution='y>399'>"
"<globals>"
"<def var='Line.Height' value='16' />"
"<def var='Font.Height' value='16' />"
@@ -1895,7 +1897,8 @@
"</layout>"
"</dialog>"
"</layout_info>"
-"<layout_info resolution='y<400'>"
+;
+ const char *defaultXML4 = "<layout_info resolution='y<400'>"
"<globals>"
"<def var='Line.Height' value='12' />"
"<def var='Font.Height' value='10' />"
@@ -3149,3 +3152,5 @@
"</layout>"
"</dialog>"
"</layout_info>"
+;
+const char *defaultXML[] = { defaultXML1, defaultXML2, defaultXML3, defaultXML4 };
diff --git a/gui/themes/scummtheme.py b/gui/themes/scummtheme.py
index 94dc08f1ef..d5fa4dfca7 100755
--- a/gui/themes/scummtheme.py
+++ b/gui/themes/scummtheme.py
@@ -35,11 +35,15 @@ def buildAllThemes():
if os.path.isdir(os.path.join('.', f)) and not f[0] == '.':
buildTheme(f)
-def parseSTX(theme_file, def_file):
+def parseSTX(theme_file, def_file, subcount):
comm = re.compile("<!--(.*?)-->", re.DOTALL)
head = re.compile("<\?(.*?)\?>")
strlitcount = 0
+ subcount += 1
+
+ def_file.write(";\n const char *defaultXML" + str(subcount) + " = ")
+
output = ""
for line in theme_file:
output += line.rstrip("\r\n\t ").lstrip()
@@ -55,8 +59,12 @@ def parseSTX(theme_file, def_file):
for line in output.splitlines():
if line and not line.isspace():
strlitcount += len(line)
+ if strlitcount > 65535:
+ subcount += 1
+ def_file.write(";\n const char *defaultXML" + str(subcount) + " = ")
+ strlitcount = len(line)
def_file.write("\"" + line + "\"\n")
- return strlitcount
+ return subcount
def buildDefTheme(themeName):
def_file = open("default.inc", "w")
@@ -64,8 +72,8 @@ def buildDefTheme(themeName):
if not os.path.isdir(themeName):
print ("Cannot open default theme dir.")
- def_file.write(""" "<?xml version = '1.0'?>"\n""")
- strlitcount = 24
+ def_file.write("""const char *defaultXML1 = "<?xml version = '1.0'?>"\n""")
+ subcount = 1
filenames = os.listdir(themeName)
filenames.sort()
@@ -73,16 +81,16 @@ def buildDefTheme(themeName):
filename = os.path.join(themeName, filename)
if os.path.isfile(filename) and filename.endswith(".stx"):
theme_file = open(filename, "r")
- strlitcount += parseSTX(theme_file, def_file)
+ subcount = parseSTX(theme_file, def_file, subcount)
theme_file.close()
- def_file.close()
+ def_file.write(";\nconst char *defaultXML[] = { defaultXML1")
+ for sub in range(2, subcount + 1):
+ def_file.write(", defaultXML" + str(sub))
- if strlitcount > 65535:
- print("WARNING: default.inc string literal is of length %d which exceeds the" % strlitcount)
- print(" maximum length of 65536 that C++ compilers are required to support.")
- print(" It is likely that bugs will occur dependent on compiler behaviour.")
- print(" To avoid this, reduce the size of the theme.")
+ def_file.write(" };\n")
+
+ def_file.close()
def printUsage():
print ("===============================")