SHERLOCK: RT: Implemented WidgetVerbs execute

This commit is contained in:
Paul Gilbert 2015-06-16 21:13:34 -04:00
parent 3e5e63fa4a
commit 09bd10c6cb
14 changed files with 320 additions and 67 deletions

View file

@ -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;

View file

@ -57,6 +57,7 @@ public:
bool _rightReleased;
bool _oldButtons;
bool _oldRightButton;
bool _firstPress;
Common::Stack<Common::KeyState> _pendingKeys;
public:
Events(SherlockEngine *vm);

View file

@ -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"
};
// =========================================

View file

@ -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 {

View file

@ -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 \

View file

@ -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,18 +471,14 @@ void TattooUserInterface::doControls() {
// TODO
}
void TattooUserInterface::pickUpObject(int objNum) {
// TOOD
}
void TattooUserInterface::doQuitMenu() {
// TODO
}
void TattooUserInterface::activateVerbMenu(bool objectsOn) {
// TODO
}
void TattooUserInterface::lookAtObject() {
// TODO
}
} // End of namespace Tattoo
} // End of namespace Sherlock

View file

@ -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:
@ -118,42 +114,20 @@ 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() {}

View file

@ -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

View file

@ -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

View file

@ -28,7 +28,7 @@ namespace Sherlock {
namespace Tattoo {
WidgetTooltip::WidgetTooltip(SherlockEngine *vm) : _vm(vm) {
WidgetTooltip::WidgetTooltip(SherlockEngine *vm) : WidgetBase(vm) {
}
void WidgetTooltip::execute() {

View file

@ -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);

View file

@ -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() {

View file

@ -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);

View file

@ -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;
@ -89,6 +84,11 @@ public:
static UserInterface *init(SherlockEngine *vm);
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
*/