aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/ThemeParser.cpp20
-rw-r--r--gui/ThemeParser.h9
-rw-r--r--gui/ThemeRenderer.cpp28
-rw-r--r--gui/ThemeRenderer.h12
-rw-r--r--gui/themes/scummodern.stx (renamed from gui/themes/modern.stx)2
-rw-r--r--gui/themes/scummodern.zipbin29651 -> 30075 bytes
6 files changed, 57 insertions, 14 deletions
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
index df36ad6c7c..8fda7c2894 100644
--- a/gui/ThemeParser.cpp
+++ b/gui/ThemeParser.cpp
@@ -150,6 +150,26 @@ bool ThemeParser::parserCallback_fonts(ParserNode *node) {
return true;
}
+bool ThemeParser::parserCallback_cursor(ParserNode *node) {
+ if (resolutionCheck(node->values["resolution"])) {
+ node->ignore = true;
+ return true;
+ }
+
+ int spotx, spoty, scale;
+
+ if (!parseIntegerKey(node->values["hotspot"].c_str(), 2, &spotx, &spoty))
+ return parserError("Error when parsing cursor Hot Spot coordinates.");
+
+ if (!parseIntegerKey(node->values["scale"].c_str(), 1, &scale))
+ return parserError("Error when parsing cursor scale.");
+
+ if (!_theme->createCursor(node->values["file"], spotx, spoty, scale))
+ return parserError("Error when creating Bitmap Cursor.");
+
+ return true;
+}
+
bool ThemeParser::parserCallback_bitmap(ParserNode *node) {
if (resolutionCheck(node->values["resolution"])) {
node->ignore = true;
diff --git a/gui/ThemeParser.h b/gui/ThemeParser.h
index b9fa69179d..905795f8ed 100644
--- a/gui/ThemeParser.h
+++ b/gui/ThemeParser.h
@@ -361,6 +361,13 @@ protected:
XML_PROP(resolution, false)
KEY_END()
KEY_END()
+
+ XML_KEY(cursor)
+ XML_PROP(file, true)
+ XML_PROP(hotspot, true)
+ XML_PROP(scale, true)
+ XML_PROP(resolution, false)
+ KEY_END()
XML_KEY(defaults)
XML_PROP(stroke, false)
@@ -499,6 +506,8 @@ protected:
bool parserCallback_drawdata(ParserNode *node);
bool parserCallback_bitmaps(ParserNode *node) { return true; }
bool parserCallback_bitmap(ParserNode *node);
+ bool parserCallback_cursor(ParserNode *node);
+
/** Layout info callbacks */
bool parserCallback_layout_info(ParserNode *node);
diff --git a/gui/ThemeRenderer.cpp b/gui/ThemeRenderer.cpp
index 30fb371cd5..73043063a5 100644
--- a/gui/ThemeRenderer.cpp
+++ b/gui/ThemeRenderer.cpp
@@ -386,10 +386,6 @@ bool ThemeRenderer::loadTheme(Common::String fileName) {
}
}
- if (_system->hasFeature(OSystem::kFeatureCursorHasPalette)) {
- createCursor();
- }
-
_themeName = "DEBUG - A Theme name";
_themeOk = true;
return true;
@@ -913,16 +909,18 @@ void ThemeRenderer::setUpCursor() {
CursorMan.showMouse(true);
}
-void ThemeRenderer::createCursor() {
- const Surface *cursor = _bitmaps["cursor.bmp"];
+bool ThemeRenderer::createCursor(const Common::String &filename, int hotspotX, int hotspotY, int scale) {
+ if (!_system->hasFeature(OSystem::kFeatureCursorHasPalette))
+ return false;
+
+ const Surface *cursor = _bitmaps[filename];
if (!cursor)
- return;
+ return false;
- _cursorHotspotX = _themeEval->getVar("Cursor.Hotspot.X", 0);
- _cursorHotspotY = _themeEval->getVar("Cursor.Hotspot.Y", 0);
-
- _cursorTargetScale = _themeEval->getVar("Cursor.TargetScale", 3);
+ _cursorHotspotX = hotspotX;
+ _cursorHotspotY = hotspotY;
+ _cursorTargetScale = scale;
_cursorWidth = cursor->w;
_cursorHeight = cursor->h;
@@ -957,8 +955,10 @@ void ThemeRenderer::createCursor() {
_cursorPal[index * 4 + 2] = b;
_cursorPal[index * 4 + 3] = 0xFF;
- if (colorsFound > MAX_CURS_COLORS)
- error("Cursor contains too much colors (%d, but only %d are allowed)", colorsFound, MAX_CURS_COLORS);
+ if (colorsFound > MAX_CURS_COLORS) {
+ warning("Cursor contains too much colors (%d, but only %d are allowed)", colorsFound, MAX_CURS_COLORS);
+ return false;
+ }
}
if (col != transparency) {
@@ -971,6 +971,8 @@ void ThemeRenderer::createCursor() {
_useCursor = true;
delete[] table;
+
+ return true;
}
} // end of namespace GUI.
diff --git a/gui/ThemeRenderer.h b/gui/ThemeRenderer.h
index 0ddfe0d7c4..5ed5818f73 100644
--- a/gui/ThemeRenderer.h
+++ b/gui/ThemeRenderer.h
@@ -472,6 +472,17 @@ public:
return 0;
}
+
+ /**
+ * Interface for the Theme Parser: Creates a new cursor by loading the given
+ * bitmap and sets it as the active cursor.
+ *
+ * @param filename File name of the bitmap to load.
+ * @param hotspotX X Coordinate of the bitmap which does the cursor click.
+ * @param hotspotY Y Coordinate of the bitmap which does the cursor click.
+ * @param scale Scale at which the bitmap is supposed to be used.
+ */
+ bool createCursor(const Common::String &filename, int hotspotX, int hotspotY, int scale);
protected:
@@ -702,7 +713,6 @@ protected:
/** Custom Cursor Management */
void setUpCursor();
- void createCursor();
bool _useCursor;
int _cursorHotspotX, _cursorHotspotY;
diff --git a/gui/themes/modern.stx b/gui/themes/scummodern.stx
index 671e9d0856..965008a6e8 100644
--- a/gui/themes/modern.stx
+++ b/gui/themes/scummodern.stx
@@ -94,6 +94,8 @@
</fonts>
<defaults fill = 'gradient' fg_color = 'white' bevel_color = '237, 169, 72'/>
+
+ <cursor file = 'cursor.bmp' hotspot = '0, 0' scale = '3'/>
<drawdata id = 'text_selection' cache = false>
<drawstep func = 'square'
diff --git a/gui/themes/scummodern.zip b/gui/themes/scummodern.zip
index 67b89951ed..2a6f268eb9 100644
--- a/gui/themes/scummodern.zip
+++ b/gui/themes/scummodern.zip
Binary files differ