aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/gui
diff options
context:
space:
mode:
authorMartin Kiewitz2009-10-07 12:47:53 +0000
committerMartin Kiewitz2009-10-07 12:47:53 +0000
commit77b549a0ad9e3a66f9a571e049c26a74231c2ce4 (patch)
treef9be159bc9aac4a8ffc8fdbbf5d630ac6f63ff61 /engines/sci/gui
parent23b39f5c459c9387012e63cde931c9b929b387cb (diff)
downloadscummvm-rg350-77b549a0ad9e3a66f9a571e049c26a74231c2ce4.tar.gz
scummvm-rg350-77b549a0ad9e3a66f9a571e049c26a74231c2ce4.tar.bz2
scummvm-rg350-77b549a0ad9e3a66f9a571e049c26a74231c2ce4.zip
SCI: SciGuiCursor class added, cleanup, OSystem removed from SciGui constructor
svn-id: r44730
Diffstat (limited to 'engines/sci/gui')
-rw-r--r--engines/sci/gui/gui.cpp31
-rw-r--r--engines/sci/gui/gui.h14
-rw-r--r--engines/sci/gui/gui_cursor.cpp53
-rw-r--r--engines/sci/gui/gui_cursor.h52
-rw-r--r--engines/sci/gui/gui_picture.cpp188
5 files changed, 316 insertions, 22 deletions
diff --git a/engines/sci/gui/gui.cpp b/engines/sci/gui/gui.cpp
index 3ca7794b0c..36e24a10fc 100644
--- a/engines/sci/gui/gui.cpp
+++ b/engines/sci/gui/gui.cpp
@@ -33,6 +33,7 @@
#include "sci/gui/gui.h"
#include "sci/gui/gui_screen.h"
#include "sci/gui/gui_palette.h"
+#include "sci/gui/gui_cursor.h"
#include "sci/gui/gui_gfx.h"
#include "sci/gui/gui_windowmgr.h"
#include "sci/gui/gui_view.h"
@@ -41,8 +42,8 @@
namespace Sci {
-SciGui::SciGui(OSystem *system, EngineState *state, SciGuiScreen *screen, SciGuiPalette *palette)
- : _system(system), _s(state), _screen(screen), _palette(palette) {
+SciGui::SciGui(EngineState *state, SciGuiScreen *screen, SciGuiPalette *palette, SciGuiCursor *cursor)
+ : _s(state), _screen(screen), _palette(palette), _cursor(cursor) {
_gfx = new SciGuiGfx(_s, _screen, _palette);
_windowMgr = new SciGuiWindowMgr(_s, _gfx);
@@ -460,24 +461,28 @@ void SciGui::setNowSeen(reg_t objectReference) {
_gfx->SetNowSeen(objectReference);
}
-void SciGui::moveCursor(int16 x, int16 y, int16 scaleFactor) {
- Common::Point newPos;
+void SciGui::setCursorPos(Common::Point pos) {
+ // FIXME: try to find out if we need to adjust position somehow, currently just forwarding to moveCursor()
+ moveCursor(pos);
+}
+
+void SciGui::moveCursor(Common::Point pos) {
+ pos.y += _windowMgr->_picWind->rect.top;
+ pos.x += _windowMgr->_picWind->rect.left;
- x += _windowMgr->_picWind->rect.left;
- y += _windowMgr->_picWind->rect.top;
- newPos.x = CLIP<int16>(x, _windowMgr->_picWind->rect.left, _windowMgr->_picWind->rect.right - 1);
- newPos.y = CLIP<int16>(y, _windowMgr->_picWind->rect.top, _windowMgr->_picWind->rect.bottom - 1);
+ pos.y = CLIP<int16>(pos.y, _windowMgr->_picWind->rect.top, _windowMgr->_picWind->rect.bottom - 1);
+ pos.x = CLIP<int16>(pos.x, _windowMgr->_picWind->rect.left, _windowMgr->_picWind->rect.right - 1);
- if (x > _screen->_width || y > _screen->_height) {
- debug("[GFX] Attempt to place pointer at invalid coordinates (%d, %d)\n", x, y);
+ if (pos.x > _screen->_width || pos.y > _screen->_height) {
+ warning("attempt to place cursor at invalid coordinates (%d, %d)", pos.y, pos.x);
return; // Not fatal
}
- g_system->warpMouse(x * scaleFactor, y * scaleFactor);
-
+ _cursor->setPosition(pos);
// Trigger event reading to make sure the mouse coordinates will
// actually have changed the next time we read them.
- gfxop_get_event(_s->gfx_state, SCI_EVT_PEEK);
+ //gfxop_get_event(_s->gfx_state, SCI_EVT_PEEK);
+ // FIXME!
}
} // End of namespace Sci
diff --git a/engines/sci/gui/gui.h b/engines/sci/gui/gui.h
index e84b199d16..4997d0ff03 100644
--- a/engines/sci/gui/gui.h
+++ b/engines/sci/gui/gui.h
@@ -32,18 +32,16 @@ namespace Sci {
class SciGuiScreen;
class SciGuiPalette;
+class SciGuiCursor;
class SciGuiGfx;
class SciGuiresources;
class SciGuiWindowMgr;
class SciGui {
public:
- SciGui(OSystem *system, EngineState *s, SciGuiScreen *screen, SciGuiPalette *palette);
+ SciGui(EngineState *s, SciGuiScreen *screen, SciGuiPalette *palette, SciGuiCursor *cursor);
SciGui();
virtual ~SciGui();
- // FIXME: Don't store EngineState
- virtual void resetEngineState(EngineState *s) { _s = s; }
-
virtual void init(bool usesOldGfxFunctions);
virtual void wait(int16 ticks);
@@ -86,16 +84,14 @@ public:
virtual void addToPicView(GuiResourceId viewId, GuiViewLoopNo loopNo, GuiViewCelNo celNo, int16 leftPos, int16 topPos, int16 priority, int16 control);
virtual void setNowSeen(reg_t objectReference);
- virtual void moveCursor(int16 x, int16 y, int16 scaleFactor = 1);
- void moveCursor(Common::Point p, int16 scaleFactor = 1) { moveCursor(p.x, p.y, scaleFactor); }
-
- SciGuiPalette *getPalette() { return _palette; }
+ virtual void setCursorPos(Common::Point pos);
+ virtual void moveCursor(Common::Point pos);
private:
- OSystem *_system;
EngineState *_s;
SciGuiScreen *_screen;
SciGuiPalette *_palette;
+ SciGuiCursor *_cursor;
SciGuiGfx *_gfx;
SciGuiresources *_resources;
SciGuiWindowMgr *_windowMgr;
diff --git a/engines/sci/gui/gui_cursor.cpp b/engines/sci/gui/gui_cursor.cpp
new file mode 100644
index 0000000000..c77c85968a
--- /dev/null
+++ b/engines/sci/gui/gui_cursor.cpp
@@ -0,0 +1,53 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "common/timer.h"
+#include "common/util.h"
+
+#include "sci/sci.h"
+#include "sci/engine/state.h"
+#include "sci/tools.h"
+#include "sci/gui/gui_palette.h"
+#include "sci/gui/gui_view.h"
+#include "sci/gui/gui_cursor.h"
+
+namespace Sci {
+
+SciGuiCursor::SciGuiCursor(EngineState *state, SciGuiPalette *palette)
+ : _s(state), _palette(palette) {
+ init();
+}
+
+SciGuiCursor::~SciGuiCursor() {
+}
+
+void SciGuiCursor::init() {
+}
+
+void SciGuiCursor::setPosition(Common::Point pos) {
+ g_system->warpMouse(pos.x, pos.y);
+}
+
+} // End of namespace Sci
diff --git a/engines/sci/gui/gui_cursor.h b/engines/sci/gui/gui_cursor.h
new file mode 100644
index 0000000000..bf2dad04e8
--- /dev/null
+++ b/engines/sci/gui/gui_cursor.h
@@ -0,0 +1,52 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef SCI_GUI_CURSOR_H
+#define SCI_GUI_CURSOR_H
+
+#include "sci/gui/gui.h"
+
+namespace Sci {
+
+class SciGuiView;
+class SciGuiPalette;
+class SciGuiCursor {
+public:
+ SciGuiCursor(EngineState *state, SciGuiPalette *palette);
+ ~SciGuiCursor();
+
+ void setPosition(Common::Point pos);
+
+private:
+ void init();
+
+ EngineState *_s;
+ SciGuiScreen *_screen;
+ SciGuiPalette *_palette;
+};
+
+} // End of namespace Sci
+
+#endif
diff --git a/engines/sci/gui/gui_picture.cpp b/engines/sci/gui/gui_picture.cpp
index 0678fdfb83..7fd46a20c9 100644
--- a/engines/sci/gui/gui_picture.cpp
+++ b/engines/sci/gui/gui_picture.cpp
@@ -556,4 +556,192 @@ void SciGuiPicture::vectorGetPatternTexture(byte *data, int &curPos, int16 patte
}
}
+#if 0
+void SciGuiGfx::Pic_Fill(int16 x, int16 y, byte color, byte prio, byte control) {
+
+void SciGuiPicture::vectorFloodFillRecursive(byte *data, int &curPos, int16 &x, int16 &y) {
+
+void FILL_FUNCTION_RECURSIVE(gfxr_pic_t *pic, int old_xl, int old_xr, int y, int dy, byte *bounds,
+ int legalcolor, int legalmask, int color, int priority, int drawenable, int sci_titlebar_size) {
+ int linewidth = pic->mode->scaleFactor * 320;
+ int miny = pic->mode->scaleFactor * sci_titlebar_size;
+ int maxy = pic->mode->scaleFactor * 200;
+ int xl, xr;
+ int oldytotal = y * linewidth;
+
+ do {
+ int ytotal = oldytotal + (linewidth * dy);
+ int xcont;
+ int state;
+
+ y += dy;
+
+ if (y < miny || y >= maxy) {
+ error("ABRT on failed initial assertion!");
+ return;
+ }
+# define proj_xl_bound 0
+# define proj_xr_bound 319
+
+ // Now we have the projected limits, get the real ones:
+
+ xl = (old_xl > proj_xl_bound) ? old_xl : proj_xl_bound;
+ if (!IS_BOUNDARY(xl, y + 1, bounds[ytotal + xl])) { // go left as far as possible
+ while (xl > proj_xl_bound && (!IS_BOUNDARY(xl - 1, y + 1, bounds[ytotal + xl - 1])))
+ --xl;
+ } else // go right until the fillable area starts
+ while (xl < proj_xr_bound && (IS_BOUNDARY(xl, y + 1, bounds[ytotal + xl])))
+ ++xl;
+
+
+ if ((xl > proj_xr_bound)
+ || (xl > old_xr)) {
+ error("ABRT because xl > xr_bound");
+ return;
+ }
+
+ xr = (xl > old_xl) ? xl : old_xl;
+ while (xr < proj_xr_bound && (!IS_BOUNDARY(xr + 1, y + 1, bounds[ytotal + xr + 1])))
+ ++xr;
+
+ PRINT_DEBUG1("%d> -> ", xr);
+
+ if (IS_BOUNDARY(xl, y + 1, bounds[ytotal + xl])) {
+ error("ABRT because xl illegal");
+ return;
+ }
+
+ if (drawenable & GFX_MASK_VISUAL)
+ memset(pic->visual_map->index_data + ytotal + xl, color, xr - xl + 1);
+
+ if (drawenable & GFX_MASK_PRIORITY)
+ memset(pic->priority_map->index_data + ytotal + xl, priority, xr - xl + 1);
+
+
+ // Check whether we need to recurse on branches in the same direction
+ state = 0;
+ xcont = xr + 1;
+ while (xcont <= old_xr) {
+ if (IS_BOUNDARY(xcont, y + 1, bounds[ytotal + xcont]))
+ state = xcont;
+ else if (state) { // recurse
+ vectorFloodFillRecursive(pic, state, xcont, y - dy, dy, bounds, legalcolor,
+ legalmask, color, priority, drawenable, sci_titlebar_size);
+ state = 0;
+ }
+ ++xcont;
+ }
+
+ // Check whether we need to recurse on backward branches:
+ // left
+ if (xl < old_xl - 1) {
+ state = 0;
+ for (xcont = old_xl - 1; xcont >= xl; xcont--) {
+ if (IS_BOUNDARY(xcont, y, bounds[oldytotal + xcont]))
+ state = xcont;
+ else if (state) { // recurse
+ vectorFloodFillRecursive(pic, xcont, state, y, -dy, bounds,
+ legalcolor, legalmask, color, priority, drawenable,
+ sci_titlebar_size);
+ state = 0;
+ }
+ }
+ }
+
+ // right
+ if (xr > old_xr + 1) {
+ state = 0;
+ for (xcont = old_xr + 1; xcont <= xr; xcont++) {
+ if (IS_BOUNDARY(xcont, y, bounds[oldytotal + xcont]))
+ state = xcont;
+ else if (state) { // recurse
+ vectorFloodFillRecursive(pic, state, xcont, y, -dy, bounds,
+ legalcolor, legalmask, color, priority, drawenable,
+ sci_titlebar_size);
+ state = 0;
+ }
+ }
+ }
+
+ oldytotal = ytotal;
+ old_xl = xl;
+ old_xr = xr;
+
+ } while (1);
+}
+
+void SciGuiPicture::vectorFloodFillRecursive(gfxr_pic_t *pic, int x_320, int y_200, int color, int priority, int control, int drawenable,
+ int sci_titlebar_size) {
+ int linewidth = pic->mode->scaleFactor * 320;
+ int x, y;
+ int xl, xr;
+ int ytotal;
+ int bitmask;
+ byte *bounds = NULL;
+ int legalcolor, legalmask;
+ int original_drawenable = drawenable; // Backup, since we need the unmodified value
+ // for filling the aux and control map
+
+ // Restrict drawenable not to restrict itself to zero
+ if (pic->control_map->index_data[y_200 * 320 + x_320] != 0)
+ drawenable &= ~GFX_MASK_CONTROL;
+
+ if (color == 0xff)
+ drawenable &= ~GFX_MASK_VISUAL;
+
+ if (priority == 0) {
+ drawenable &= ~GFX_MASK_PRIORITY;
+ original_drawenable &= ~GFX_MASK_PRIORITY;
+ }
+
+ AUXBUF_FILL(pic, x_320, y_200, original_drawenable, (drawenable & GFX_MASK_CONTROL) ? control : 0,
+ sci_titlebar_size);
+
+ x = x_320;
+ y = y_200;
+
+ ytotal = y * linewidth;
+
+ if (!drawenable)
+ return;
+
+ if (drawenable & GFX_MASK_VISUAL) {
+ bounds = pic->visual_map->index_data;
+ legalmask = 0x0ff0;
+ legalcolor = 0xff;
+ } else if (drawenable & GFX_MASK_PRIORITY) {
+ bounds = pic->priority_map->index_data;
+ legalcolor = 0;
+ legalmask = 0x0f0f;
+ } else {
+ legalcolor = 0;
+ legalmask = 0x0f0f;
+ }
+
+ if (!bounds || IS_BOUNDARY(x, y, bounds[ytotal + x]))
+ return;
+
+ if (bounds) {
+ xl = x;
+ while (xl > proj_xl_bound && (!IS_BOUNDARY(xl - 1, y, bounds[ytotal + xl -1])))
+ --xl;
+
+ while (x < proj_xr_bound && (!IS_BOUNDARY(x + 1, y, bounds[ytotal + x + 1])))
+ ++x;
+ xr = x;
+
+ if (drawenable & GFX_MASK_VISUAL)
+ memset(pic->visual_map->index_data + ytotal + xl, color, xr - xl + 1);
+
+ if (drawenable & GFX_MASK_PRIORITY)
+ memset(pic->priority_map->index_data + ytotal + xl, priority, xr - xl + 1);
+
+ vectorFloodFillRecursive(pic, xl, xr, y, -1, bounds, legalcolor, legalmask, color, priority, drawenable,
+ sci_titlebar_size);
+ vectorFloodFillRecursive(pic, xl, xr, y, + 1, bounds, legalcolor, legalmask, color, priority, drawenable,
+ sci_titlebar_size);
+ }
+}
+#endif
+
} // End of namespace Sci