aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/sherlock/events.cpp4
-rw-r--r--engines/sherlock/events.h1
-rw-r--r--engines/sherlock/fixed_text.cpp21
-rw-r--r--engines/sherlock/fixed_text.h7
-rw-r--r--engines/sherlock/module.mk1
-rw-r--r--engines/sherlock/tattoo/tattoo_user_interface.cpp24
-rw-r--r--engines/sherlock/tattoo/tattoo_user_interface.h60
-rw-r--r--engines/sherlock/tattoo/widget_base.cpp39
-rw-r--r--engines/sherlock/tattoo/widget_base.h55
-rw-r--r--engines/sherlock/tattoo/widget_tooltip.cpp2
-rw-r--r--engines/sherlock/tattoo/widget_tooltip.h8
-rw-r--r--engines/sherlock/tattoo/widget_verbs.cpp137
-rw-r--r--engines/sherlock/tattoo/widget_verbs.h16
-rw-r--r--engines/sherlock/user_interface.h10
14 files changed, 319 insertions, 66 deletions
diff --git a/engines/sherlock/events.cpp b/engines/sherlock/events.cpp
index ff928d81b2..354e2a1640 100644
--- a/engines/sherlock/events.cpp
+++ b/engines/sherlock/events.cpp
@@ -41,6 +41,7 @@ Events::Events(SherlockEngine *vm): _vm(vm) {
_pressed = _released = false;
_rightPressed = _rightReleased = false;
_oldButtons = _oldRightButton = false;
+ _firstPress = false;
if (_vm->_interactiveFl)
loadCursors("rmouse.vgs");
@@ -205,6 +206,7 @@ void Events::clearEvents() {
_pressed = _released = false;
_rightPressed = _rightReleased = false;
_oldButtons = _oldRightButton = false;
+ _firstPress = false;
}
void Events::clearKeyboard() {
@@ -246,6 +248,8 @@ bool Events::delay(uint32 time, bool interruptable) {
}
void Events::setButtonState() {
+ _firstPress = ((_mouseButtons & 1) && !_pressed) || ((_mouseButtons & 2) && !_rightPressed);
+
_released = _rightReleased = false;
if (_mouseButtons & LEFT_BUTTON)
_pressed = _oldButtons = true;
diff --git a/engines/sherlock/events.h b/engines/sherlock/events.h
index 6806cab3a6..c9ca041c13 100644
--- a/engines/sherlock/events.h
+++ b/engines/sherlock/events.h
@@ -57,6 +57,7 @@ public:
bool _rightReleased;
bool _oldButtons;
bool _oldRightButton;
+ bool _firstPress;
Common::Stack<Common::KeyState> _pendingKeys;
public:
Events(SherlockEngine *vm);
diff --git a/engines/sherlock/fixed_text.cpp b/engines/sherlock/fixed_text.cpp
index f69bd5caf8..aa14a5857b 100644
--- a/engines/sherlock/fixed_text.cpp
+++ b/engines/sherlock/fixed_text.cpp
@@ -65,7 +65,12 @@ static const char *const fixedTextEN[] = {
"A letter folded many times",
"Tarot Cards",
"An ornate key",
- "A pawn ticket"
+ "A pawn ticket",
+ // Verbs
+ "Open",
+ "Look",
+ "Talk",
+ "Journal"
};
// sharp-s : 0xE1 / octal 341
@@ -112,7 +117,12 @@ static const char *const fixedTextDE[] = {
"Ein mehrfach gefalteter Briefbogen",
"Ein Tarock-Kartenspiel", // [sic]
"Ein verzierter Schl\201ssel",
- "Ein Pfandschein"
+ "Ein Pfandschein",
+ // Verbs
+ "Open",
+ "Look",
+ "Talk",
+ "Journal"
};
// up-side down exclamation mark - 0xAD / octal 255
@@ -158,7 +168,12 @@ static const char *const fixedTextES[] = {
"Un carta muy plegada",
"Unas cartas de Tarot",
"Una llave muy vistosa",
- "Una papeleta de empe\244o"
+ "Una papeleta de empe\244o",
+ // Verbs
+ "Open",
+ "Look",
+ "Talk",
+ "Journal"
};
// =========================================
diff --git a/engines/sherlock/fixed_text.h b/engines/sherlock/fixed_text.h
index c4e39974b0..50b0d5b96d 100644
--- a/engines/sherlock/fixed_text.h
+++ b/engines/sherlock/fixed_text.h
@@ -68,7 +68,12 @@ enum FixedTextId {
kFixedText_InitInventory_Letter,
kFixedText_InitInventory_Tarot,
kFixedText_InitInventory_OrnateKey,
- kFixedText_InitInventory_PawnTicket
+ kFixedText_InitInventory_PawnTicket,
+ // Verbs
+ kFixedText_Verb_Open,
+ kFixedText_Verb_Look,
+ kFixedText_Verb_Talk,
+ kFixedText_Verb_Journal
};
enum FixedTextActionId {
diff --git a/engines/sherlock/module.mk b/engines/sherlock/module.mk
index bbbd2f5d09..414dabf429 100644
--- a/engines/sherlock/module.mk
+++ b/engines/sherlock/module.mk
@@ -21,6 +21,7 @@ MODULE_OBJS = \
tattoo/tattoo_scene.o \
tattoo/tattoo_talk.o \
tattoo/tattoo_user_interface.o \
+ tattoo/widget_base.o \
tattoo/widget_tooltip.o \
tattoo/widget_verbs.o \
animation.o \
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index 7d7d9420da..62781964bb 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -52,6 +52,14 @@ void TattooUserInterface::initScrollVars() {
_targetScroll.x = _targetScroll.y = 0;
}
+void TattooUserInterface::lookAtObject() {
+ // TODO
+}
+
+void TattooUserInterface::doJournal() {
+ // TODO
+}
+
void TattooUserInterface::handleInput() {
TattooEngine &vm = *(TattooEngine *)_vm;
Events &events = *_vm->_events;
@@ -365,7 +373,7 @@ if (!flag && events._released) {
if (events._rightReleased) {
// Show the verbs menu for the highlighted object
- activateVerbMenu(!noDesc);
+ _verbsWidget.activateVerbMenu(!noDesc);
} else if (_personFound || (_bgFound != -1 && _bgFound < 1000 && _bgShape->_aType == PERSON)) {
// The object found is a person (the default for people is TALK)
talk.talk(_bgFound);
@@ -455,10 +463,6 @@ void TattooUserInterface::turnTextOff() {
// TODO
}
-void TattooUserInterface::doJournal() {
- // TODO
-}
-
void TattooUserInterface::doInventory(int mode) {
// TODO
}
@@ -467,15 +471,11 @@ void TattooUserInterface::doControls() {
// TODO
}
-void TattooUserInterface::doQuitMenu() {
- // TODO
+void TattooUserInterface::pickUpObject(int objNum) {
+ // TOOD
}
-void TattooUserInterface::activateVerbMenu(bool objectsOn) {
- // TODO
-}
-
-void TattooUserInterface::lookAtObject() {
+void TattooUserInterface::doQuitMenu() {
// TODO
}
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h
index f88deaac8d..e2732c5ae2 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.h
+++ b/engines/sherlock/tattoo/tattoo_user_interface.h
@@ -45,14 +45,10 @@ private:
Surface *_invMenuBuffer;
Surface *_invGraphic;
Common::Array<Common::Rect> _grayAreas;
- Object *_bgShape;
- bool _personFound;
int _lockoutTimer;
- Common::KeyState _keyState;
SaveMode _fileMode;
int _exitZone;
int _scriptZone;
- int _activeObj;
WidgetTooltip _tooltipWidget;
WidgetVerbs _verbsWidget;
private:
@@ -119,41 +115,19 @@ private:
void turnTextOff();
/**
- * Handles displaying the journal
- */
- void doJournal();
-
- /**
- * Put the game in inventory mode by opening the inventory dialog
- */
- void doInventory(int mode);
-
- /**
- * Handle the display of the options/setup menu
- */
- void doControls();
-
- /**
* Handle displaying the quit menu
*/
void doQuitMenu();
-
- /**
- * Turn on the command menu showing available actions that can be done on a given item
- */
- void activateVerbMenu(bool objectsOn);
-
- /**
- * Display the long description for an object stored in it's _examine field, in a window that
- * will be shown at the bottom of the screen
- */
- void lookAtObject();
public:
Common::Point _currentScroll, _targetScroll;
int _scrollSize, _scrollSpeed;
bool _drawMenu;
int _bgFound, _oldBgFound;
int _arrowZone, _oldArrowZone;
+ Object *_bgShape;
+ bool _personFound;
+ int _activeObj;
+ Common::KeyState _keyState;
public:
TattooUserInterface(SherlockEngine *vm);
@@ -171,6 +145,32 @@ public:
* Initializes scroll variables
*/
void initScrollVars();
+
+ /**
+ * Display the long description for an object stored in it's _examine field, in a window that
+ * will be shown at the bottom of the screen
+ */
+ void lookAtObject();
+
+ /**
+ * Handles displaying the journal
+ */
+ void doJournal();
+
+ /**
+ * Put the game in inventory mode by opening the inventory dialog
+ */
+ void doInventory(int mode);
+
+ /**
+ * Handle the display of the options/setup menu
+ */
+ void doControls();
+
+ /**
+ * Pick up the selected object
+ */
+ void pickUpObject(int objNum);
public:
virtual ~TattooUserInterface() {}
diff --git a/engines/sherlock/tattoo/widget_base.cpp b/engines/sherlock/tattoo/widget_base.cpp
new file mode 100644
index 0000000000..0d46daca65
--- /dev/null
+++ b/engines/sherlock/tattoo/widget_base.cpp
@@ -0,0 +1,39 @@
+/* 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.
+ *
+ */
+
+#include "sherlock/tattoo/widget_base.h"
+#include "sherlock/tattoo/tattoo.h"
+
+namespace Sherlock {
+
+namespace Tattoo {
+
+WidgetBase::WidgetBase(SherlockEngine *vm) : _vm(vm) {
+}
+
+void WidgetBase::banishWindow() {
+ // TODO
+}
+
+} // End of namespace Tattoo
+
+} // End of namespace Sherlock
diff --git a/engines/sherlock/tattoo/widget_base.h b/engines/sherlock/tattoo/widget_base.h
new file mode 100644
index 0000000000..cf992b5571
--- /dev/null
+++ b/engines/sherlock/tattoo/widget_base.h
@@ -0,0 +1,55 @@
+/* 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.
+ *
+ */
+
+#ifndef SHERLOCK_TATTOO_WIDGET_BASE_H
+#define SHERLOCK_TATTOO_WIDGET_BASE_H
+
+#include "common/scummsys.h"
+#include "common/rect.h"
+#include "common/str-array.h"
+#include "sherlock/surface.h"
+
+namespace Sherlock {
+
+class SherlockEngine;
+
+namespace Tattoo {
+
+class WidgetBase {
+protected:
+ SherlockEngine *_vm;
+ Common::Rect _bounds, _oldBounds;
+ Surface _surface;
+public:
+ WidgetBase(SherlockEngine *vm);
+
+ /**
+ * Close a currently active menu
+ */
+ void banishWindow();
+};
+
+} // End of namespace Tattoo
+
+} // End of namespace Sherlock
+
+#endif
diff --git a/engines/sherlock/tattoo/widget_tooltip.cpp b/engines/sherlock/tattoo/widget_tooltip.cpp
index f089411185..ee4b3cee2a 100644
--- a/engines/sherlock/tattoo/widget_tooltip.cpp
+++ b/engines/sherlock/tattoo/widget_tooltip.cpp
@@ -28,7 +28,7 @@ namespace Sherlock {
namespace Tattoo {
-WidgetTooltip::WidgetTooltip(SherlockEngine *vm) : _vm(vm) {
+WidgetTooltip::WidgetTooltip(SherlockEngine *vm) : WidgetBase(vm) {
}
void WidgetTooltip::execute() {
diff --git a/engines/sherlock/tattoo/widget_tooltip.h b/engines/sherlock/tattoo/widget_tooltip.h
index b704c1eb55..429628fc39 100644
--- a/engines/sherlock/tattoo/widget_tooltip.h
+++ b/engines/sherlock/tattoo/widget_tooltip.h
@@ -25,7 +25,7 @@
#include "common/scummsys.h"
#include "common/rect.h"
-#include "sherlock/surface.h"
+#include "sherlock/tattoo/widget_base.h"
namespace Sherlock {
@@ -33,11 +33,7 @@ class SherlockEngine;
namespace Tattoo {
-class WidgetTooltip {
-private:
- SherlockEngine *_vm;
- Common::Rect _bounds, _oldBounds;
- Surface _surface;
+class WidgetTooltip: public WidgetBase {
public:
WidgetTooltip(SherlockEngine *vm);
diff --git a/engines/sherlock/tattoo/widget_verbs.cpp b/engines/sherlock/tattoo/widget_verbs.cpp
index a72d05f055..5d7f42111b 100644
--- a/engines/sherlock/tattoo/widget_verbs.cpp
+++ b/engines/sherlock/tattoo/widget_verbs.cpp
@@ -21,27 +21,158 @@
*/
#include "sherlock/tattoo/widget_verbs.h"
+#include "sherlock/tattoo/tattoo_scene.h"
+#include "sherlock/tattoo/tattoo_user_interface.h"
#include "sherlock/tattoo/tattoo.h"
namespace Sherlock {
namespace Tattoo {
-WidgetVerbs::WidgetVerbs(SherlockEngine *vm) : _vm(vm) {
+WidgetVerbs::WidgetVerbs(SherlockEngine *vm) : WidgetBase(vm) {
_selector = _oldSelector = -1;
+ _outsideMenu = false;
+}
+
+void WidgetVerbs::activateVerbMenu(bool objectsOn) {
+ // TODO
}
void WidgetVerbs::execute() {
+ Events &events = *_vm->_events;
+ FixedText &fixedText = *_vm->_fixedText;
+ People &people = *_vm->_people;
+ TattooScene &scene = *(TattooScene *)_vm->_scene;
+ Talk &talk = *_vm->_talk;
+ TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
+ Common::Point mousePos = events.mousePos();
+ Common::Point scenePos = mousePos + ui._currentScroll;
+ bool noDesc = false;
+
+ Common::String strLook = fixedText.getText(kFixedText_Verb_Look);
+ Common::String strTalk = fixedText.getText(kFixedText_Verb_Talk);
+ Common::String strJournal = fixedText.getText(kFixedText_Verb_Journal);
+
checkTabbingKeys(_verbCommands.size());
// Highlight verb display as necessary
highlightVerbControls();
- // TODO
+ // Flag if the user has started pressing the button with the cursor outsie the menu
+ if (events._firstPress && !_bounds.contains(mousePos))
+ _outsideMenu = true;
+
+ // See if they released the mouse button
+ if (events._released || events._released) {
+ // See if they want to close the menu (they clicked outside of the menu)
+ if (!_bounds.contains(mousePos)) {
+ if (_outsideMenu) {
+ // Free the current menu graphics & erase the menu
+ banishWindow();
+
+ if (events._rightReleased) {
+ // Reset the selected shape to what was clicked on
+ ui._bgFound = scene.findBgShape(scenePos);
+ ui._personFound = ui._bgFound >= 1000;
+ Object *_bgShape = ui._personFound ? nullptr : &scene._bgShapes[ui._bgFound];
+
+ if (ui._personFound) {
+ if (people[ui._bgFound - 1000]._description.empty() || people[ui._bgFound - 1000]._description.hasPrefix(" "))
+ noDesc = true;
+ } else if (ui._bgFound != -1) {
+ if (_bgShape->_description.empty() || _bgShape->_description.hasPrefix(" "))
+ noDesc = true;
+ } else {
+ noDesc = true;
+ }
+
+ // Call the Routine to turn on the Commands for this Object
+ activateVerbMenu(!noDesc);
+ } else {
+ // See if we're in a Lab Table Room
+ ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE;
+ }
+ }
+ } else if (_bounds.contains(mousePos)) {
+ // Mouse is within the menu
+ // Erase the menu
+ banishWindow();
+
+ // See if they are activating the Look Command
+ if (!_verbCommands[_selector].compareToIgnoreCase(strLook)) {
+ ui._bgFound = ui._activeObj;
+ if (ui._activeObj >= 1000) {
+ ui._personFound = true;
+ } else {
+ ui._personFound = false;
+ ui._bgShape = &scene._bgShapes[ui._activeObj];
+ }
+
+ ui.lookAtObject();
+
+ } else if (!_verbCommands[_selector].compareToIgnoreCase(strTalk)) {
+ // Talk command is being activated
+ talk.talk(ui._activeObj);
+ ui._activeObj = -1;
+
+ } else if (!_verbCommands[_selector].compareToIgnoreCase(strJournal)) {
+ ui.doJournal();
+
+ // See if we're in a Lab Table scene
+ ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE;
+ } else if (_selector >= ((int)_verbCommands.size() - 2)) {
+ switch (_selector - (int)_verbCommands.size() + 2) {
+ case 0:
+ // Inventory
+ ui.doInventory(2);
+ break;
+
+ case 1:
+ // Options
+ ui.doControls();
+ break;
+
+ default:
+ ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE;
+ break;
+ }
+ } else {
+ // If they have selected anything else, process it
+ people[HOLMES].gotoStand();
+
+ if (ui._activeObj < 1000) {
+ for (int idx = 0; idx < 6; ++idx) {
+ if (!_verbCommands[_selector].compareToIgnoreCase(scene._bgShapes[ui._activeObj]._use[idx]._verb)) {
+ // See if they are Picking this object up
+ if (!scene._bgShapes[ui._activeObj]._use[idx]._target.compareToIgnoreCase("*PICKUP"))
+ ui.pickUpObject(ui._activeObj);
+ else
+ ui.checkAction(scene._bgShapes[ui._activeObj]._use[idx], ui._activeObj);
+ }
+ }
+ } else {
+ for (int idx = 0; idx < 2; ++idx) {
+ if (!_verbCommands[_selector].compareToIgnoreCase(people[ui._activeObj - 1000]._use[idx]._verb))
+ ui.checkAction(people[ui._activeObj - 1000]._use[idx], ui._activeObj);
+ }
+ }
+
+ ui._activeObj = -1;
+ if (ui._menuMode != MESSAGE_MODE) {
+ // See if we're in a Lab Table Room
+ ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE;
+ }
+ }
+ }
+ } else if (ui._keyState.keycode == Common::KEYCODE_ESCAPE) {
+ // User closing the menu with the ESC key
+ banishWindow();
+ ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE;
+ }
}
void WidgetVerbs::checkTabbingKeys(int numOptions) {
-
+ // TODO
}
void WidgetVerbs::highlightVerbControls() {
diff --git a/engines/sherlock/tattoo/widget_verbs.h b/engines/sherlock/tattoo/widget_verbs.h
index 160df85366..318aeefcca 100644
--- a/engines/sherlock/tattoo/widget_verbs.h
+++ b/engines/sherlock/tattoo/widget_verbs.h
@@ -26,7 +26,7 @@
#include "common/scummsys.h"
#include "common/rect.h"
#include "common/str-array.h"
-#include "sherlock/surface.h"
+#include "sherlock/tattoo/widget_base.h"
namespace Sherlock {
@@ -34,12 +34,10 @@ class SherlockEngine;
namespace Tattoo {
-class WidgetVerbs {
+class WidgetVerbs: public WidgetBase {
private:
- SherlockEngine *_vm;
- Common::Rect _bounds;
- Surface _surface;
int _selector, _oldSelector;
+ bool _outsideMenu;
/**
* Highlights the controls for the verb list
@@ -50,6 +48,14 @@ public:
public:
WidgetVerbs(SherlockEngine *vm);
+ /**
+ * Turns on the menu with all the verbs that are available for the given object
+ */
+ void activateVerbMenu(bool objectsOn);
+
+ /**
+ * Process input for the dialog
+ */
void execute();
void checkTabbingKeys(int numOptions);
diff --git a/engines/sherlock/user_interface.h b/engines/sherlock/user_interface.h
index 541b632f2c..1fc876e91a 100644
--- a/engines/sherlock/user_interface.h
+++ b/engines/sherlock/user_interface.h
@@ -61,11 +61,6 @@ protected:
SherlockEngine *_vm;
UserInterface(SherlockEngine *vm);
-
- /**
- * Called for OPEN, CLOSE, and MOVE actions are being done
- */
- void checkAction(ActionType &action, int objNum, FixedTextActionId fixedTextActionId = kFixedTextAction_Invalid);
public:
MenuMode _menuMode;
int _menuCounter;
@@ -90,6 +85,11 @@ public:
virtual ~UserInterface() {}
/**
+ * Called for OPEN, CLOSE, and MOVE actions are being done
+ */
+ void checkAction(ActionType &action, int objNum, FixedTextActionId fixedTextActionId = kFixedTextAction_Invalid);
+public:
+ /**
* Resets the user interface
*/
virtual void reset() {}