From 3bc06610659079e9320e4a0835af103a2fab11a5 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Mon, 12 Feb 2007 00:04:56 +0000 Subject: Merged the "palette manager" into the cursor manager. It was only used to manage *cursor* palettes, so the name was misleading. svn-id: r25500 --- graphics/cursorman.h | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 2 deletions(-) (limited to 'graphics/cursorman.h') diff --git a/graphics/cursorman.h b/graphics/cursorman.h index f86883f1e1..af5021e5d4 100644 --- a/graphics/cursorman.h +++ b/graphics/cursorman.h @@ -74,6 +74,49 @@ public: */ void replaceCursor(const byte *buf, uint w, uint h, int hotspotX, int hotspotY, byte keycolor = 255, int targetScale = 1); + /** + * Enable/Disable the current cursor palette. + * + * @param disable + */ + void disableCursorPalette(bool disable); + + /** + * Push a new cursor palette onto the stack, and set it in the backend. + * The palette entries from 'start' till (start+num-1) will be replaced + * so a full palette updated is accomplished via start=0, num=256. + * + * The palette data is specified in the same interleaved RGBA format as + * used by all backends. + * + * @param colors the new palette data, in interleaved RGB format + * @param start the first palette entry to be updated + * @param num the number of palette entries to be updated + * + * @note If num is zero, the cursor palette is disabled. + */ + void pushCursorPalette(const byte *colors, uint start, uint num); + + /** + * Pop a cursor palette from the stack, and restore the previous one to + * the backend. If there is no previous palette, the cursor palette is + * disabled instead. + */ + void popCursorPalette(); + + /** + * Replace the current cursor palette on the stack. If the stack is + * empty, the palette is pushed instead. It's a slightly more optimized + * way of popping the old palette before pushing the new one. + * + * @param colors the new palette data, in interleaved RGB format + * @param start the first palette entry to be updated + * @param num the number of palette entries to be updated + * + * @note If num is zero, the cursor palette is disabled. + */ + void replaceCursorPalette(const byte *colors, uint start, uint num); + private: friend class Common::Singleton; CursorManager(); @@ -108,13 +151,40 @@ private: } }; + struct Palette { + byte *_data; + uint _start; + uint _num; + uint _size; + + bool _disabled; + + Palette(const byte *colors, uint start, uint num) { + _start = start; + _num = num; + _size = 4 * num; + + if (num) { + _data = new byte[_size]; + memcpy(_data, colors, _size); + } else { + _data = NULL; + } + + _disabled = false; + } + + ~Palette() { + delete [] _data; + } + }; + Common::Stack _cursorStack; + Common::Stack _cursorPaletteStack; }; - } // End of namespace Graphics -/** Shortcut for accessing the cursor manager. */ #define CursorMan (::Graphics::CursorManager::instance()) #endif -- cgit v1.2.3