aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui/ThemeNew.cpp72
-rw-r--r--gui/newgui.cpp4
-rw-r--r--gui/theme.h15
-rw-r--r--gui/themes/modern.ini6
-rw-r--r--gui/themes/modern.zipbin34689 -> 34898 bytes
5 files changed, 94 insertions, 3 deletions
diff --git a/gui/ThemeNew.cpp b/gui/ThemeNew.cpp
index 96d3e49745..8caaa1dd59 100644
--- a/gui/ThemeNew.cpp
+++ b/gui/ThemeNew.cpp
@@ -38,7 +38,7 @@
#define kShadowTr3 64
#define kShadowTr4 128
-#define THEME_VERSION 9
+#define THEME_VERSION 10
using Graphics::Surface;
@@ -216,6 +216,8 @@ _lastUsedBitMask(0), _forceRedraw(false), _fonts(), _imageHandles(0), _images(0)
_configFile.getKey("popupwidget_top", "pixmaps", imageHandlesTable[kPopUpWidgetBkgdTop]);
_configFile.getKey("popupwidget_left", "pixmaps", imageHandlesTable[kPopUpWidgetBkgdLeft]);
_configFile.getKey("popupwidget_bkgd", "pixmaps", imageHandlesTable[kPopUpWidgetBkgd]);
+
+ _configFile.getKey("cursor_image", "pixmaps", imageHandlesTable[kGUICursor]);
// load the gradient factors from the config file
getFactorFromConfig(_configFile, "main_dialog", _gradientFactors[kMainDialogFactor]);
@@ -242,6 +244,9 @@ _lastUsedBitMask(0), _forceRedraw(false), _fonts(), _imageHandles(0), _images(0)
getExtraValueFromConfig(_configFile, "shadow_right_width", _shadowRightWidth, 4);
getExtraValueFromConfig(_configFile, "shadow_top_height", _shadowTopHeight, 2);
getExtraValueFromConfig(_configFile, "shadow_bottom_height", _shadowBottomHeight, 4);
+
+ getExtraValueFromConfig(_configFile, "cursor_hotspot_x", _cursorHotspotX, 0);
+ getExtraValueFromConfig(_configFile, "cursor_hotspot_y", _cursorHotspotY, 0);
// inactive dialog shading stuff
_dialogShadingCallback = 0;
@@ -293,12 +298,16 @@ _lastUsedBitMask(0), _forceRedraw(false), _fonts(), _imageHandles(0), _images(0)
}
_lastUsedBitMask = gBitFormat;
+
+ // creats the cursor image
+ createCursor();
}
ThemeNew::~ThemeNew() {
deleteFonts();
deinit();
delete [] _images;
+ delete [] _cursor;
_images = 0;
if (_imageHandles) {
for (int i = 0; i < kImageHandlesMax; ++i) {
@@ -353,10 +362,12 @@ void ThemeNew::enable() {
resetDrawArea();
_system->showOverlay();
clearAll();
+ setUpCursor();
}
void ThemeNew::disable() {
_system->hideOverlay();
+ _system->setPalette(_backUpCols, 0, MAX_CURS_COLORS);
}
void ThemeNew::openDialog(bool topDialog) {
@@ -1487,6 +1498,65 @@ OverlayColor ThemeNew::calcDimColor(OverlayColor col) {
#pragma mark -
+void ThemeNew::setUpCursor() {
+ _system->grabPalette(_backUpCols, 0, MAX_CURS_COLORS);
+ _system->setPalette(_cursorPal, 0, MAX_CURS_COLORS);
+
+ _system->setMouseCursor(_cursor, _cursorWidth, _cursorHeight, _cursorHotspotX, _cursorHotspotY);
+}
+
+void ThemeNew::createCursor() {
+ const Surface *cursor = _images[kGUICursor];
+
+ _cursorWidth = cursor->w;
+ _cursorHeight = cursor->h;
+
+ uint colorsFound = 0;
+ const OverlayColor *src = (const OverlayColor*)cursor->pixels;
+
+ byte *table = new byte[65536];
+ assert(table);
+ memset(table, 0, sizeof(byte)*65536);
+
+ byte r, g, b;
+
+ _system->colorToRGB(_colors[kColorTransparency], r, g, b);
+ uint16 transparency = RGBToColor<ColorMasks<565> >(r, g, b);
+
+ _cursor = new byte[_cursorWidth * _cursorHeight];
+ assert(_cursor);
+ memset(_cursor, 255, sizeof(byte)*_cursorWidth*_cursorHeight);
+
+ for (uint y = 0; y < _cursorHeight; ++y) {
+ for (uint x = 0; x < _cursorWidth; ++x) {
+ _system->colorToRGB(src[x], r, g, b);
+ uint16 col = RGBToColor<ColorMasks<565> >(r, g, b);
+ if (!table[col] && col != transparency) {
+ table[col] = colorsFound++;
+
+ uint index = table[col];
+ _cursorPal[index * 4 + 0] = r;
+ _cursorPal[index * 4 + 1] = g;
+ _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 (col != transparency) {
+ uint index = table[col];
+ _cursor[y * _cursorWidth + x] = index;
+ }
+ }
+ src += _cursorWidth;
+ }
+
+ delete [] table;
+}
+
+#pragma mark -
+
template<class T>
inline OverlayColor getColorAlphaImpl(OverlayColor col1, OverlayColor col2, int alpha) {
OverlayColor output = 0;
diff --git a/gui/newgui.cpp b/gui/newgui.cpp
index 024dde3657..d54d85be53 100644
--- a/gui/newgui.cpp
+++ b/gui/newgui.cpp
@@ -144,6 +144,7 @@ void NewGui::runLoop() {
}
int i;
+ bool useStandardCurs = !_theme->ownCursor();
while (!_dialogStack.empty() && activeDialog == _dialogStack.top()) {
activeDialog->handleTickle();
@@ -172,7 +173,8 @@ void NewGui::runLoop() {
_needRedraw = false;
}
- animateCursor();
+ if (useStandardCurs)
+ animateCursor();
_theme->drawAll();
_system->updateScreen();
diff --git a/gui/theme.h b/gui/theme.h
index 1c2f941135..cd191ac2d8 100644
--- a/gui/theme.h
+++ b/gui/theme.h
@@ -106,6 +106,8 @@ public:
virtual void refresh() = 0;
+ virtual bool ownCursor() { return false; }
+
virtual void enable() = 0;
virtual void disable() = 0;
@@ -281,6 +283,8 @@ public:
void refresh();
+ bool ownCursor() { return true; }
+
void enable();
void disable();
@@ -428,6 +432,8 @@ public:
kPopUpWidgetBkgdTop = 41,
kPopUpWidgetBkgdLeft = 42,
kPopUpWidgetBkgd = 43,
+
+ kGUICursor = 44,
kImageHandlesMax
};
@@ -441,6 +447,15 @@ private:
OverlayColor calcLuminance(OverlayColor col);
OverlayColor calcDimColor(OverlayColor col);
+ void setUpCursor();
+ void createCursor();
+ int _cursorHotspotX, _cursorHotspotY;
+#define MAX_CURS_COLORS 255
+ byte *_cursor;
+ uint _cursorWidth, _cursorHeight;
+ byte _cursorPal[4*MAX_CURS_COLORS];
+ byte _backUpCols[4*MAX_CURS_COLORS];
+
private:
const String *_imageHandles;
const Graphics::Surface **_images;
diff --git a/gui/themes/modern.ini b/gui/themes/modern.ini
index 84e08b9fd9..c0ec6dee68 100644
--- a/gui/themes/modern.ini
+++ b/gui/themes/modern.ini
@@ -1,7 +1,7 @@
# $URL$
# $Id$
[theme]
-version=9
+version=10
[pixmaps]
dialog_corner=dialog_bkgd_corner.bmp
@@ -61,6 +61,8 @@ popupwidget_bkgd=widget_small_bkgd.bmp
theme_logo=logo.bmp
+cursor_image=cursor.bmp
+
[colors]
main_dialog_start=210 114 10
main_dialog_end=239 196 24
@@ -146,6 +148,8 @@ shadow_bottom_height=4
inactive_dialog_shading=dim
shading_dim_percent=30
fontfile_normal=helvr12-l1.bdf
+cursor_hotspot_x=0
+cursor_hotspot_y=0
[640xY]
def_launcherX=23
diff --git a/gui/themes/modern.zip b/gui/themes/modern.zip
index 1817123542..bfc40abca4 100644
--- a/gui/themes/modern.zip
+++ b/gui/themes/modern.zip
Binary files differ