aboutsummaryrefslogtreecommitdiff
path: root/engines/wage
diff options
context:
space:
mode:
authorEugene Sandulenko2016-01-03 21:59:57 +0100
committerEugene Sandulenko2016-01-03 21:59:57 +0100
commit0b361b94dc303f95a636e8d183aca7f3854f00e4 (patch)
tree44c1525f8ff6d2a9ad5a2e95abd59a5e84699b7e /engines/wage
parent562355e62dddedaddb40555b0e5dff5468322bb4 (diff)
downloadscummvm-rg350-0b361b94dc303f95a636e8d183aca7f3854f00e4.tar.gz
scummvm-rg350-0b361b94dc303f95a636e8d183aca7f3854f00e4.tar.bz2
scummvm-rg350-0b361b94dc303f95a636e8d183aca7f3854f00e4.zip
WAGE: Initial cursor drawing code
Diffstat (limited to 'engines/wage')
-rw-r--r--engines/wage/gui.cpp38
-rw-r--r--engines/wage/gui.h8
2 files changed, 43 insertions, 3 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index dd398b5c1f..e3c98de351 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -46,6 +46,7 @@
*/
#include "common/system.h"
+#include "common/timer.h"
#include "common/unzip.h"
#include "graphics/cursorman.h"
#include "graphics/fonts/bdf.h"
@@ -115,6 +116,28 @@ static const byte macCursorBeam[] = {
0, 0, 3, 3, 3, 0, 0, 3, 3, 3, 3,
};
+static void cursor_timer_handler(void *refCon) {
+ Gui *gui = (Gui *)refCon;
+
+ int x = gui->_cursorX;
+ int y = gui->_cursorY;
+
+ if (x == 0 && y == 0)
+ return;
+
+ if (!gui->_screen.getPixels())
+ return;
+
+ x += gui->_consoleTextArea.left;
+ y += gui->_consoleTextArea.top;
+
+ gui->_screen.vLine(x, y, y + 8, gui->_cursorState ? kColorBlack : kColorWhite);
+ gui->_cursorState = !gui->_cursorState;
+
+ g_system->copyRectToScreen(gui->_screen.getPixels(), gui->_screen.pitch, x, y, 1, 8);
+ g_system->updateScreen();
+}
+
Gui::Gui(WageEngine *engine) {
_engine = engine;
_scene = NULL;
@@ -134,6 +157,10 @@ Gui::Gui(WageEngine *engine) {
_builtInFonts = false;
_sceneIsActive = false;
+ _cursorX = 0;
+ _cursorY = 0;
+ _cursorState = false;
+
g_system->getPaletteManager()->setPalette(palette, 0, 4);
CursorMan.replaceCursorPalette(palette, 0, 4);
@@ -146,9 +173,12 @@ Gui::Gui(WageEngine *engine) {
Design::drawFilledRoundRect(&_screen, r, kDesktopArc, kColorBlack, p, 1);
loadFonts();
+
+ g_system->getTimerManager()->installTimerProc(&cursor_timer_handler, 500000, this, "wageCursor");
}
Gui::~Gui() {
+ g_system->getTimerManager()->removeTimerProc(&cursor_timer_handler);
}
const Graphics::Font *Gui::getFont(const char *name, Graphics::FontManager::FontUsage fallback) {
@@ -243,7 +273,6 @@ void Gui::draw() {
if (_scene && (_bordersDirty || _sceneDirty))
paintBorder(&_screen, _sceneArea, kWindowScene);
-
// Render console
if (_consoleDirty)
renderConsole(&_screen, _consoleTextArea);
@@ -398,6 +427,13 @@ void Gui::flowText(String &str) {
int pos = _scrollPos;
_scrollPos = MAX<int>(0, (_lines.size() - _consoleNumLines) * _consoleLineHeight);
+ _cursorX = 0;
+
+ if (_scrollPos)
+ _cursorY = (_consoleNumLines + 1) * _consoleLineHeight;
+ else
+ _cursorY = (_lines.size() + 1) * _consoleLineHeight;
+
if (pos != _scrollPos)
_consoleFullRedraw = true;
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 4f2815b18e..1a82c8f713 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -85,9 +85,14 @@ private:
const Graphics::Font *getTitleFont();
const Graphics::Font *getFont(const char *name, Graphics::FontManager::FontUsage fallback);
+public:
+ Graphics::Surface _screen;
+ int _cursorX, _cursorY;
+ bool _cursorState;
+ Common::Rect _consoleTextArea;
+
private:
WageEngine *_engine;
- Graphics::Surface _screen;
Graphics::Surface _console;
Scene *_scene;
bool _sceneDirty;
@@ -104,7 +109,6 @@ private:
bool _builtInFonts;
- Common::Rect _consoleTextArea;
Common::Rect _sceneArea;
bool _sceneIsActive;
bool _cursorIsArrow;