aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/xmlparser.cpp56
-rw-r--r--common/xmlparser.h6
-rw-r--r--gui/theme.h2
-rw-r--r--gui/themes/default.inc3
-rw-r--r--gui/themes/scummclassic.zipbin43280 -> 43354 bytes
-rw-r--r--gui/themes/scummclassic/THEMERC2
-rw-r--r--gui/themes/scummclassic/classic_gfx.stx2
-rw-r--r--gui/themes/scummclassic/classic_layout.stx2
-rw-r--r--gui/themes/scummclassic/classic_layout_320.stx2
-rw-r--r--gui/themes/scummmodern.zipbin143567 -> 143656 bytes
-rw-r--r--gui/themes/scummmodern/THEMERC2
-rw-r--r--gui/themes/scummmodern/scummodern_gfx.stx2
-rw-r--r--gui/themes/scummmodern/scummodern_layout.stx2
-rw-r--r--gui/themes/scummmodern/scummodern_layout_320.stx2
14 files changed, 64 insertions, 19 deletions
diff --git a/common/xmlparser.cpp b/common/xmlparser.cpp
index b3fb2e3cc5..2440a08803 100644
--- a/common/xmlparser.cpp
+++ b/common/xmlparser.cpp
@@ -54,7 +54,7 @@ bool XMLParser::parserError(const char *errorString, ...) {
lineCount++;
}
- _stream->seek(-middle, SEEK_CUR);
+ _stream->seek(-MIN(middle, startPosition), SEEK_CUR);
for (int i = 0, j = 0; i < kErrorMessageWidth; ++i, ++j) {
c = _stream->readByte();
@@ -105,11 +105,32 @@ bool XMLParser::parserError(const char *errorString, ...) {
return false;
}
+bool XMLParser::parseXMLHeader(ParserNode *node) {
+ assert(node->header);
+
+ if (_activeKey.size() != 1)
+ return parserError("XML Header is expected in the global scope.");
+
+ if (!node->values.contains("version"))
+ return parserError("Missing XML version in XML header.");
+
+ if (node->values["version"] != "1.0")
+ return parserError("Unsupported XML version.");
+
+ return true;
+}
+
bool XMLParser::parseActiveKey(bool closed) {
bool ignore = false;
assert(_activeKey.empty() == false);
ParserNode *key = _activeKey.top();
+
+ if (key->name == "xml" && key->header == true) {
+ assert(closed);
+ return parseXMLHeader(key) && closeKey();
+ }
+
XMLKeyLayout *layout = (_activeKey.size() == 1) ? _XMLkeys : getParentNode(key)->layout;
if (layout->children.contains(key->name)) {
@@ -217,9 +238,10 @@ bool XMLParser::parse() {
cleanup();
bool activeClosure = false;
- bool selfClosure = false;
+ bool activeHeader = false;
+ bool selfClosure;
- _state = kParserNeedKey;
+ _state = kParserNeedHeader;
_activeKey.clear();
_char = _stream->readByte();
@@ -232,6 +254,7 @@ bool XMLParser::parse() {
continue;
switch (_state) {
+ case kParserNeedHeader:
case kParserNeedKey:
if (_char != '<') {
parserError("Parser expecting key start.");
@@ -243,7 +266,15 @@ bool XMLParser::parse() {
break;
}
- if (_char == '/') { // FIXME: What if it's a comment start
+ if (_state == kParserNeedHeader) {
+ if (_char != '?') {
+ parserError("Expecting XML header.");
+ break;
+ }
+
+ _char = _stream->readByte();
+ activeHeader = true;
+ } else if (_char == '/') {
_char = _stream->readByte();
activeClosure = true;
}
@@ -266,6 +297,7 @@ bool XMLParser::parse() {
ParserNode *node = allocNode(); //new ParserNode;
node->name = _token;
node->ignore = false;
+ node->header = activeHeader;
node->depth = _activeKey.size();
node->layout = 0;
_activeKey.push(node);
@@ -291,23 +323,29 @@ bool XMLParser::parse() {
_char = _stream->readByte();
break;
}
-
+
selfClosure = false;
- if (_char == '/') { // FIXME: comment start?
+ if (_char == '/' || (_char == '?' && activeHeader)) {
selfClosure = true;
_char = _stream->readByte();
}
if (_char == '>') {
- if (parseActiveKey(selfClosure)) {
+ if (activeHeader && !selfClosure) {
+ parserError("XML Header must be self-closed.");
+ } else if (parseActiveKey(selfClosure)) {
_char = _stream->readByte();
_state = kParserNeedKey;
}
+
+ activeHeader = false;
break;
}
-
- if (!parseToken())
+
+ if (selfClosure)
+ parserError("Expecting key closure after '/' symbol.");
+ else if (!parseToken())
parserError("Error when parsing key value.");
else
_state = kParserNeedPropertyOperator;
diff --git a/common/xmlparser.h b/common/xmlparser.h
index f7a3c664e9..fd4788a426 100644
--- a/common/xmlparser.h
+++ b/common/xmlparser.h
@@ -129,6 +129,7 @@ public:
/** Active state for the parser */
enum ParserState {
+ kParserNeedHeader,
kParserNeedKey,
kParserNeedKeyName,
@@ -166,6 +167,7 @@ public:
Common::String name;
Common::StringMap values;
bool ignore;
+ bool header;
int depth;
XMLKeyLayout *layout;
};
@@ -404,7 +406,7 @@ protected:
_char = _stream->readByte();
}
- return isspace(_char) != 0 || _char == '>' || _char == '=' || _char == '/';
+ return isspace(_char) != 0 || _char == '>' || _char == '=' || _char == '/' || _char == '?';
}
/**
@@ -451,6 +453,8 @@ protected:
va_end(args);
return (*key == 0);
}
+
+ bool parseXMLHeader(ParserNode *node);
/**
* Overload if your parser needs to support parsing the same file
diff --git a/gui/theme.h b/gui/theme.h
index 45c81a06cf..0b20613fe4 100644
--- a/gui/theme.h
+++ b/gui/theme.h
@@ -35,7 +35,7 @@
#include "graphics/fontman.h"
#define THEME_VERSION 24
-#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.2"
+#define SCUMMVM_THEME_VERSION_STR "SCUMMVM_STX0.3"
namespace GUI {
diff --git a/gui/themes/default.inc b/gui/themes/default.inc
index 348d013141..a7adc49d7f 100644
--- a/gui/themes/default.inc
+++ b/gui/themes/default.inc
@@ -1,3 +1,4 @@
+"<?xml version = '1.0'?> "
"<render_info> "
"<palette> "
"<color name = 'black' "
@@ -304,6 +305,7 @@
"/> "
"</drawdata> "
"</render_info> "
+"<?xml version = '1.0'?> "
"<layout_info resolution = '-320xY, -256x240'> "
"<globals> "
"<def var = 'Line.Height' value = '16' /> "
@@ -907,6 +909,7 @@
"</layout> "
"</dialog> "
"</layout_info> "
+"<?xml version = '1.0'?> "
"<layout_info resolution = '320xY, 256x240'> "
"<globals> "
"<def var = 'Line.Height' value = '12' /> "
diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip
index 2df5573a4e..3ee5730303 100644
--- a/gui/themes/scummclassic.zip
+++ b/gui/themes/scummclassic.zip
Binary files differ
diff --git a/gui/themes/scummclassic/THEMERC b/gui/themes/scummclassic/THEMERC
index 96f0528ddb..ea13cb21b0 100644
--- a/gui/themes/scummclassic/THEMERC
+++ b/gui/themes/scummclassic/THEMERC
@@ -1 +1 @@
-[SCUMMVM_STX0.2:ScummVM Classic Theme:No Author] \ No newline at end of file
+[SCUMMVM_STX0.3:ScummVM Classic Theme:No Author] \ No newline at end of file
diff --git a/gui/themes/scummclassic/classic_gfx.stx b/gui/themes/scummclassic/classic_gfx.stx
index a566e83e45..7ec136c03d 100644
--- a/gui/themes/scummclassic/classic_gfx.stx
+++ b/gui/themes/scummclassic/classic_gfx.stx
@@ -22,7 +22,7 @@
- $Id$
-
-->
-
+<?xml version = "1.0"?>
<render_info>
<palette>
<color name = 'black'
diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx
index fec2632119..42e6eaebd7 100644
--- a/gui/themes/scummclassic/classic_layout.stx
+++ b/gui/themes/scummclassic/classic_layout.stx
@@ -22,7 +22,7 @@
- $Id$
-
-->
-
+<?xml version = "1.0"?>
<layout_info resolution = '-320xY, -256x240'>
<globals>
<def var = 'Line.Height' value = '16' />
diff --git a/gui/themes/scummclassic/classic_layout_320.stx b/gui/themes/scummclassic/classic_layout_320.stx
index 792f54e45e..7d925be9cb 100644
--- a/gui/themes/scummclassic/classic_layout_320.stx
+++ b/gui/themes/scummclassic/classic_layout_320.stx
@@ -22,7 +22,7 @@
- $Id$
-
-->
-
+<?xml version = "1.0"?>
<layout_info resolution = "320xY, 256x240">
<globals>
<def var = 'Line.Height' value = '12' />
diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip
index d1700259db..0de77c92fc 100644
--- a/gui/themes/scummmodern.zip
+++ b/gui/themes/scummmodern.zip
Binary files differ
diff --git a/gui/themes/scummmodern/THEMERC b/gui/themes/scummmodern/THEMERC
index 66e46315a9..7dc80e8c64 100644
--- a/gui/themes/scummmodern/THEMERC
+++ b/gui/themes/scummmodern/THEMERC
@@ -1 +1 @@
-[SCUMMVM_STX0.2:ScummVM Modern Theme:No Author] \ No newline at end of file
+[SCUMMVM_STX0.3:ScummVM Modern Theme:No Author] \ No newline at end of file
diff --git a/gui/themes/scummmodern/scummodern_gfx.stx b/gui/themes/scummmodern/scummodern_gfx.stx
index 148f1cb522..4c592bf3ac 100644
--- a/gui/themes/scummmodern/scummodern_gfx.stx
+++ b/gui/themes/scummmodern/scummodern_gfx.stx
@@ -22,7 +22,7 @@
- $Id$
-
-->
-
+<?xml version = "1.0"?>
<render_info>
<palette>
<color name = 'darkred'
diff --git a/gui/themes/scummmodern/scummodern_layout.stx b/gui/themes/scummmodern/scummodern_layout.stx
index 92de9dda46..ebf273ccf5 100644
--- a/gui/themes/scummmodern/scummodern_layout.stx
+++ b/gui/themes/scummmodern/scummodern_layout.stx
@@ -22,7 +22,7 @@
- $Id$
-
-->
-
+<?xml version = "1.0"?>
<layout_info resolution = '-320xY, -256x240'>
<globals>
<def var = 'Line.Height' value = '16' />
diff --git a/gui/themes/scummmodern/scummodern_layout_320.stx b/gui/themes/scummmodern/scummodern_layout_320.stx
index 8c755b4ca2..c135d7e03a 100644
--- a/gui/themes/scummmodern/scummodern_layout_320.stx
+++ b/gui/themes/scummmodern/scummodern_layout_320.stx
@@ -22,7 +22,7 @@
- $Id$
-
-->
-
+<?xml version = "1.0"?>
<layout_info resolution = "320xY, 256x240">
<globals>
<def var = 'Line.Height' value = '12' />