aboutsummaryrefslogtreecommitdiff
path: root/engines/hugo
diff options
context:
space:
mode:
authorArnaud Boutonné2011-01-08 16:56:52 +0000
committerArnaud Boutonné2011-01-08 16:56:52 +0000
commit2665194e6feb99af15937003d2e89e9e0f87b446 (patch)
treeb8aa548ffa7e87356b47be87e8b26b39826c2538 /engines/hugo
parentb24aab30527feb67f32e0f7a43dc8be4eb0fc0da (diff)
downloadscummvm-rg350-2665194e6feb99af15937003d2e89e9e0f87b446.tar.gz
scummvm-rg350-2665194e6feb99af15937003d2e89e9e0f87b446.tar.bz2
scummvm-rg350-2665194e6feb99af15937003d2e89e9e0f87b446.zip
HUGO: Merge inventory object and mouse cursor when selected
- Merge inventory object and mouse cursor into a new mouse cursor (looks better) - Use 16 color mouse pointer - Clean-up svn-id: r55167
Diffstat (limited to 'engines/hugo')
-rw-r--r--engines/hugo/display.cpp48
-rw-r--r--engines/hugo/display.h86
-rw-r--r--engines/hugo/hugo.cpp9
-rw-r--r--engines/hugo/mouse.cpp32
-rw-r--r--engines/hugo/object.cpp6
-rw-r--r--engines/hugo/parser.cpp2
6 files changed, 103 insertions, 80 deletions
diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp
index ad0e1f2d4c..c3223c70c5 100644
--- a/engines/hugo/display.cpp
+++ b/engines/hugo/display.cpp
@@ -33,9 +33,11 @@
// Display.c - DIB related code for HUGOWIN
#include "common/system.h"
+#include "graphics/cursorman.h"
#include "hugo/hugo.h"
#include "hugo/display.h"
+#include "hugo/inventory.h"
#include "hugo/util.h"
namespace Hugo {
@@ -66,6 +68,10 @@ void Screen::createPal() {
g_system->setPalette(_mainPalette, 0, NUM_COLORS);
}
+void Screen::setCursorPal() {
+ CursorMan.replaceCursorPalette(_curPalette, 0, _paletteSize / 4);
+}
+
/**
* Create logical palette
*/
@@ -543,5 +549,47 @@ void Screen::freeFonts() {
free(_arrayFont[i]);
}
}
+
+void Screen::selectInventoryObjId(int16 objId) {
+
+ status_t &gameStatus = _vm->getGameStatus();
+
+ gameStatus.inventoryObjId = objId; // Select new object
+
+ // Find index of icon
+ int16 iconId; // Find index of dragged icon
+ for (iconId = 0; iconId < _vm->_maxInvent; iconId++) {
+ if (gameStatus.inventoryObjId == _vm->_invent[iconId])
+ break;
+ }
+
+ // Compute source coordinates in dib_u
+ int16 ux = (iconId + NUM_ARROWS) * INV_DX % XPIX;
+ int16 uy = (iconId + NUM_ARROWS) * INV_DX / XPIX * INV_DY;
+
+ // Copy the icon and add to display list
+ moveImage(getGUIBuffer(), ux, uy, INV_DX, INV_DY, XPIX, _iconImage, 0, 0, 32);
+
+ for (int i = 0; i < stdMouseCursorHeight; i++) {
+ for (int j = 0; j < stdMouseCursorWidth; j++) {
+ _iconImage[(i * INV_DX) + j] = (stdMouseCursor[(i * stdMouseCursorWidth) + j] == 1) ? _iconImage[(i * INV_DX) + j] : stdMouseCursor[(i * stdMouseCursorWidth) + j];
+ }
+ }
+
+ CursorMan.replaceCursor(_iconImage, INV_DX, INV_DY, 1, 1, 1);
+}
+
+void Screen::resetInventoryObjId() {
+ _vm->getGameStatus().inventoryObjId = -1; // Unselect object
+ CursorMan.replaceCursor(stdMouseCursor, stdMouseCursorWidth, stdMouseCursorHeight, 1, 1, 1);
+}
+
+void Screen::showCursor() {
+ CursorMan.showMouse(true);
+}
+
+void Screen::hideCursor() {
+ CursorMan.showMouse(false);
+}
} // End of namespace Hugo
diff --git a/engines/hugo/display.h b/engines/hugo/display.h
index 61f812a0f2..b042ac35fb 100644
--- a/engines/hugo/display.h
+++ b/engines/hugo/display.h
@@ -46,45 +46,36 @@ struct rect_t { // Rectangle used in Display
/**
* A black and white Windows-style arrow cursor (12x20).
- * 0 = Transparent.
- * 1 = Black (#000000 in 24-bit RGB).
- * 2 = White (#FFFFFF in 24-bit RGB).
+ * 0 = Black (#000000 in 24-bit RGB).
+ * 1 = Transparent.
+ * 15 = White (#FFFFFF in 24-bit RGB).
* This cursor comes from Mohawk engine.
*/
-static const byte stdMouseCursor[] = {
- 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0,
- 1, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0,
- 1, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0,
- 1, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0,
- 1, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0, 0,
- 1, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 0,
- 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0,
- 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1,
- 1, 2, 2, 2, 1, 2, 2, 1, 0, 0, 0, 0,
- 1, 2, 2, 1, 1, 2, 2, 1, 0, 0, 0, 0,
- 1, 2, 1, 0, 1, 1, 2, 2, 1, 0, 0, 0,
- 1, 1, 0, 0, 0, 1, 2, 2, 1, 0, 0, 0,
- 1, 0, 0, 0, 0, 0, 1, 2, 2, 1, 0, 0,
- 0, 0, 0, 0, 0, 0, 1, 2, 2, 1, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 1, 0,
- 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0
-};
-
-static const byte stdMousrCursorHeight = 20;
-static const byte stdMousrCursorWidth = 12;
-/**
- * RGBA-palette for the black and white arrow cursor.
- * This palette comes from AGI engine.
- */
-static const byte stdMouseCursorPalette[] = {
- 0x00, 0x00, 0x00, 0x00, // Black
- 0xFF, 0xFF, 0xFF, 0x00 // White
+static const byte stdMouseCursor[] = {
+ 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 15, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 15, 15, 0, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 15, 15, 15, 0, 1, 1, 1, 1, 1, 1, 1,
+ 0, 15, 15, 15, 15, 0, 1, 1, 1, 1, 1, 1,
+ 0, 15, 15, 15, 15, 15, 0, 1, 1, 1, 1, 1,
+ 0, 15, 15, 15, 15, 15, 15, 0, 1, 1, 1, 1,
+ 0, 15, 15, 15, 15, 15, 15, 15, 0, 1, 1, 1,
+ 0, 15, 15, 15, 15, 15, 15, 15, 15, 0, 1, 1,
+ 0, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 1,
+ 0, 15, 15, 15, 15, 15, 15, 0, 0, 0, 0, 0,
+ 0, 15, 15, 15, 0, 15, 15, 0, 1, 1, 1, 1,
+ 0, 15, 15, 0, 0, 15, 15, 0, 1, 1, 1, 1,
+ 0, 15, 0, 1, 0, 0, 15, 15, 0, 1, 1, 1,
+ 0, 0, 1, 1, 1, 0, 15, 15, 0, 1, 1, 1,
+ 0, 1, 1, 1, 1, 1, 0, 15, 15, 0, 1, 1,
+ 1, 1, 1, 1, 1, 1, 0, 15, 15, 0, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 0, 15, 15, 0, 1,
+ 1, 1, 1, 1, 1, 1, 1, 0, 15, 15, 0, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1
};
+static const byte stdMouseCursorHeight = 20;
+static const byte stdMouseCursorWidth = 12;
class Screen {
public:
@@ -106,17 +97,21 @@ public:
void drawStatusText();
void freeFonts();
void freePalette();
+ void hideCursor();
void initDisplay();
void initNewScreenDisplay();
void loadPalette(Common::File &in);
void moveImage(image_pt srcImage, uint16 x1, uint16 y1, uint16 dx, uint16 dy, uint16 width1, image_pt dstImage, uint16 x2, uint16 y2, uint16 width2);
void remapPal(uint16 oldIndex, uint16 newIndex);
+ void resetInventoryObjId();
void restorePal(Common::SeekableReadStream *f);
void savePal(Common::WriteStream *f);
void setBackgroundColor(long color);
+ void setCursorPal();
+ void selectInventoryObjId(int16 objId);
void shadowStr(int16 sx, int16 sy, const char *s, byte color);
+ void showCursor();
void userHelp();
- void writeChr(int sx, int sy, byte color, char *local_fontdata);
void writeStr(int16 sx, int16 sy, const char *s, byte color);
icondib_t &getIconBuffer() {
@@ -150,23 +145,28 @@ protected:
byte _fontdata[NUM_FONTS][FONTSIZE]; // Font data
byte *_font[NUM_FONTS][FONT_LEN]; // Ptrs to each char
byte *_mainPalette;
- byte *_curPalette;
- byte _paletteSize;
-
int16 _arrayFontSize[NUM_FONTS];
private:
+ byte *_curPalette;
+ byte _iconImage[INV_DX * INV_DY];
+ byte _paletteSize;
+
+ icondib_t _iconBuffer; // Inventory icon DIB
+
+ int16 mergeLists(rect_t *list, rect_t *blist, int16 len, int16 blen, int16 bmax);
+ int16 center(const char *s);
+
+ overlayState_t findOvl(seq_t *seq_p, image_pt dst_p, uint16 y);
+
viewdib_t _frontBuffer;
viewdib_t _backBuffer;
viewdib_t _GUIBuffer; // User interface images
viewdib_t _backBufferBackup; // Backup _backBuffer during inventory
- icondib_t _iconBuffer; // Inventory icon DIB
void createPal();
- overlayState_t findOvl(seq_t *seq_p, image_pt dst_p, uint16 y);
void merge(rect_t *rectA, rect_t *rectB);
- int16 mergeLists(rect_t *list, rect_t *blist, int16 len, int16 blen, int16 bmax);
- int16 center(const char *s);
+ void writeChr(int sx, int sy, byte color, char *local_fontdata);
};
class Screen_v1d : public Screen {
diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp
index db0d7d5995..c583cb2bad 100644
--- a/engines/hugo/hugo.cpp
+++ b/engines/hugo/hugo.cpp
@@ -28,7 +28,6 @@
#include "common/events.h"
#include "common/EventRecorder.h"
#include "common/debug-channels.h"
-#include "graphics/cursorman.h"
#include "hugo/hugo.h"
#include "hugo/global.h"
@@ -261,8 +260,8 @@ Common::Error HugoEngine::run() {
return Common::kUnknownError;
/* Use Windows-looking mouse cursor */
- CursorMan.replaceCursorPalette(stdMouseCursorPalette, 1, ARRAYSIZE(stdMouseCursorPalette) / 4);
- CursorMan.replaceCursor(stdMouseCursor, stdMousrCursorWidth, stdMousrCursorHeight, 1, 1, 0);
+ _screen->setCursorPal();
+ _screen->resetInventoryObjId();
initStatus(); // Initialize game status
initConfig(INSTALL); // Initialize user's config
@@ -355,7 +354,7 @@ void HugoEngine::runMachine() {
switch (gameStatus.viewState) {
case V_IDLE: // Not processing state machine
- CursorMan.showMouse(false);
+ _screen->hideCursor();
_intro->preNewGame(); // Any processing before New Game selected
break;
case V_INTROINIT: // Initialization before intro begins
@@ -369,7 +368,7 @@ void HugoEngine::runMachine() {
}
break;
case V_PLAY: // Playing game
- CursorMan.showMouse(true);
+ _screen->showCursor();
_parser->charHandler(); // Process user cmd input
_object->moveObjects(); // Process object movement
_scheduler->runScheduler(); // Process any actions
diff --git a/engines/hugo/mouse.cpp b/engines/hugo/mouse.cpp
index 4ed6384b2a..0855832ab2 100644
--- a/engines/hugo/mouse.cpp
+++ b/engines/hugo/mouse.cpp
@@ -114,9 +114,9 @@ void MouseHandler::processRightClick(int16 objId, int16 cx, int16 cy) {
// Check if this was over iconbar
if (gameStatus.inventoryState == I_ACTIVE && cy < INV_DY + DIBOFF_Y) { // Clicked over iconbar object
if (gameStatus.inventoryObjId == -1)
- gameStatus.inventoryObjId = objId; // Not using so select new object
+ _vm->_screen->selectInventoryObjId(objId);
else if (gameStatus.inventoryObjId == objId)
- gameStatus.inventoryObjId = -1; // Same icon - deselect it
+ _vm->_screen->resetInventoryObjId();
else
_vm->_object->useObject(objId); // Use status.objid on object
} else { // Clicked over viewport object
@@ -195,7 +195,7 @@ void MouseHandler::processLeftClick(int16 objId, int16 cx, int16 cy) {
}
// Get rid of any attached icon
- gameStatus.inventoryObjId = -1;
+ _vm->_screen->resetInventoryObjId();
}
break;
default: // Look at an icon or object
@@ -248,32 +248,6 @@ void MouseHandler::mouseHandler() {
if (cx < 0 || cx > XPIX || cy < DIBOFF_Y || cy > VIEW_DY + DIBOFF_Y)
return;
- // Display dragged inventory icon if one currently selected
- if (gameStatus.inventoryObjId != -1) {
- // Find index of icon
- int16 iconId; // Find index of dragged icon
- for (iconId = 0; iconId < _vm->_maxInvent; iconId++) {
- if (gameStatus.inventoryObjId == _vm->_invent[iconId])
- break;
- }
-
- // Compute source coordinates in dib_u
- int16 ux = (iconId + NUM_ARROWS) * INV_DX % XPIX;
- int16 uy = (iconId + NUM_ARROWS) * INV_DX / XPIX * INV_DY;
-
- // Compute destination coordinates in dib_a
- int iconx = cx + IX_OFF;
- int icony = cy + IY_OFF;
- iconx = MAX(iconx, 0); // Keep within dib_a bounds
- iconx = MIN(iconx, XPIX - INV_DX);
- icony = MAX(icony, 0);
- icony = MIN(icony, YPIX - INV_DY);
-
- // Copy the icon and add to display list
- _vm->_screen->moveImage(_vm->_screen->getGUIBuffer(), ux, uy, INV_DX, INV_DY, XPIX, _vm->_screen->getFrontBuffer(), iconx, icony, XPIX);
- _vm->_screen->displayList(D_ADD, iconx, icony, INV_DX, INV_DY);
- }
-
int16 objId = -1; // Current source object
// Process cursor over an object or icon
if (gameStatus.inventoryState == I_ACTIVE) { // Check inventory icon bar first
diff --git a/engines/hugo/object.cpp b/engines/hugo/object.cpp
index 58f9774b1d..1e422ca460 100644
--- a/engines/hugo/object.cpp
+++ b/engines/hugo/object.cpp
@@ -131,7 +131,7 @@ void ObjectHandler::useObject(int16 objId) {
if (!foundFl) {
// Deselect dragged icon if inventory not active
if (_vm->getGameStatus().inventoryState != I_ACTIVE)
- _vm->getGameStatus().inventoryObjId = -1;
+ _vm->_screen->resetInventoryObjId();
Utils::Box(BOX_ANY, "%s", _vm->_textData[use->dataIndex]);
return;
}
@@ -141,7 +141,9 @@ void ObjectHandler::useObject(int16 objId) {
if (_vm->getGameStatus().inventoryState == I_ACTIVE) // If inventory active, remove it
_vm->getGameStatus().inventoryState = I_UP;
- _vm->getGameStatus().inventoryObjId = -1; // Deselect any dragged icon
+
+ _vm->_screen->resetInventoryObjId();
+
_vm->_parser->lineHandler(); // and process command
}
diff --git a/engines/hugo/parser.cpp b/engines/hugo/parser.cpp
index 8db43e7ef3..dbd0adab55 100644
--- a/engines/hugo/parser.cpp
+++ b/engines/hugo/parser.cpp
@@ -139,7 +139,7 @@ void Parser::keyHandler(Common::Event event) {
case Common::KEYCODE_ESCAPE: // Escape key, may want to QUIT
if (gameStatus.inventoryState == I_ACTIVE) // Remove inventory, if displayed
gameStatus.inventoryState = I_UP;
- gameStatus.inventoryObjId = -1; // Deselect any dragged icon
+ _vm->_screen->resetInventoryObjId();
break;
case Common::KEYCODE_END:
case Common::KEYCODE_HOME: