SHERLOCK: RT: Implemented handleInput method

This commit is contained in:
Paul Gilbert 2015-06-13 11:38:12 -04:00
parent cacf8fbcb0
commit debe270d6f
12 changed files with 164 additions and 8 deletions

View File

@ -149,7 +149,7 @@ void ScalpelUserInterface::handleInput() {
whileMenuCounter();
Common::Point pt = events.mousePos();
_bgFound = scene.findBgShape(Common::Rect(pt.x, pt.y, pt.x + 1, pt.y + 1));
_bgFound = scene.findBgShape(pt);
_keyPress = '\0';
// Check kbd and set the mouse released flag if Enter or space is pressed.

View File

@ -1205,6 +1205,10 @@ int Scene::findBgShape(const Common::Rect &r) {
return -1;
}
int Scene::findBgShape(const Common::Point &pt) {
return findBgShape(Common::Rect(pt.x, pt.y, pt.x + 1, pt.y + 1));
}
int Scene::checkForZones(const Common::Point &pt, int zoneType) {
int matches = 0;

View File

@ -264,6 +264,12 @@ public:
*/
int findBgShape(const Common::Rect &r);
/**
* Attempts to find a background shape within the passed bounds. If found,
* it will return the shape number, or -1 on failure.
*/
int findBgShape(const Common::Point &pt);
/**
* Checks to see if the given position in the scene belongs to a given zone type.
* If it is, the zone is activated and used just like a TAKL zone or aFLAG_SET zone.

View File

@ -50,7 +50,6 @@ SherlockEngine::SherlockEngine(OSystem *syst, const SherlockGameDescription *gam
_canLoadSave = false;
_showOriginalSavesDialog = false;
_interactiveFl = true;
_fastMode = false;
}
SherlockEngine::~SherlockEngine() {

View File

@ -126,7 +126,6 @@ public:
bool _canLoadSave;
bool _showOriginalSavesDialog;
bool _interactiveFl;
bool _fastMode;
public:
SherlockEngine(OSystem *syst, const SherlockGameDescription *gameDesc);
virtual ~SherlockEngine();

View File

@ -34,6 +34,8 @@ TattooEngine::TattooEngine(OSystem *syst, const SherlockGameDescription *gameDes
SherlockEngine(syst, gameDesc) {
_creditsActive = false;
_runningProlog = false;
_fastMode = false;
_allowFastMode = true;
}
void TattooEngine::showOpening() {

View File

@ -50,6 +50,7 @@ protected:
public:
bool _creditsActive;
bool _runningProlog;
bool _fastMode, _allowFastMode;
public:
TattooEngine(OSystem *syst, const SherlockGameDescription *gameDesc);
virtual ~TattooEngine() {}

View File

@ -890,7 +890,7 @@ int TattooScene::startCAnim(int cAnimNum, int playRate) {
if (keyState.keycode == Common::KEYCODE_ESCAPE && vm._runningProlog) {
_vm->setFlags(-76);
_vm->setFlags(396);
_goToScene = 1;
_goToScene = STARTING_GAME_SCENE;
talk._talkToAbort = true;
_activeCAnim.close();
}

View File

@ -31,7 +31,7 @@ namespace Sherlock {
namespace Tattoo {
enum {
STARTING_INTRO_SCENE = 91, OVERHEAD_MAP2 = 99, OVERHEAD_MAP = 100
STARTING_GAME_SCENE = 1, STARTING_INTRO_SCENE = 91, OVERHEAD_MAP2 = 99, OVERHEAD_MAP = 100
};
struct SceneTripEntry {

View File

@ -35,6 +35,10 @@ TattooUserInterface::TattooUserInterface(SherlockEngine *vm): UserInterface(vm)
_invGraphic = nullptr;
_scrollSize = _scrollSpeed = 0;
_drawMenu = false;
_bgFound = _oldBgFound = -1;
_bgShape = nullptr;
_personFound = false;
_lockoutTimer = 0;
}
void TattooUserInterface::initScrollVars() {
@ -44,8 +48,69 @@ void TattooUserInterface::initScrollVars() {
}
void TattooUserInterface::handleInput() {
// TODO
_vm->_events->pollEventsAndWait();
TattooEngine &vm = *(TattooEngine *)_vm;
Events &events = *_vm->_events;
TattooScene &scene = *(TattooScene *)_vm->_scene;
Common::Point mousePos = events.mousePos();
events.pollEventsAndWait();
_keyState.keycode = Common::KEYCODE_INVALID;
// Check the mouse positioning
if (events.isCursorVisible())
_bgFound = scene.findBgShape(mousePos);
_personFound = _bgFound >= 1000;
_bgShape = (_bgFound != -1 && _bgFound < 1000) ? &scene._bgShapes[_bgFound] : nullptr;
if (_lockoutTimer)
--_lockoutTimer;
// Key handling
if (events.kbHit()) {
_keyState = events.getKey();
if (_keyState.keycode == Common::KEYCODE_s && vm._allowFastMode)
vm._fastMode = !vm._fastMode;
else if (_keyState.keycode == Common::KEYCODE_ESCAPE && vm._runningProlog && !_lockoutTimer) {
vm.setFlags(-76);
vm.setFlags(396);
scene._goToScene = STARTING_GAME_SCENE;
}
}
if (!events.isCursorVisible())
_keyState.keycode = Common::KEYCODE_INVALID;
// Handle input depending on what mode we're in
switch (_menuMode) {
case STD_MODE:
doStandardControl();
break;
case LOOK_MODE:
doLookControl();
break;
case FILES_MODE:
doFileControl();
break;
case INV_MODE:
doInventoryControl();
break;
case VERB_MODE:
doVerbControl();
break;
case TALK_MODE:
doTalkControl();
break;
case MESSAGE_MODE:
doMessageControl();
break;
case LAB_MODE:
doLabControl();
break;
default:
break;
}
}
void TattooUserInterface::drawInterface(int bufferNum) {
@ -206,6 +271,38 @@ void TattooUserInterface::drawGrayAreas() {
// TODO
}
void TattooUserInterface::doStandardControl() {
warning("TODO: ui control");
}
void TattooUserInterface::doLookControl() {
warning("TODO: ui control");
}
void TattooUserInterface::doFileControl() {
warning("TODO: ui control");
}
void TattooUserInterface::doInventoryControl() {
warning("TODO: ui control");
}
void TattooUserInterface::doVerbControl() {
warning("TODO: ui control");
}
void TattooUserInterface::doTalkControl() {
warning("TODO: ui control");
}
void TattooUserInterface::doMessageControl() {
warning("TODO: ui control");
}
void TattooUserInterface::doLabControl() {
warning("TODO: ui control");
}
} // End of namespace Tattoo
} // End of namespace Sherlock

View File

@ -45,11 +45,57 @@ private:
Surface *_tagBuffer;
Surface *_invGraphic;
Common::Array<Common::Rect> _grayAreas;
int _bgFound, _oldBgFound;
Object *_bgShape;
bool _personFound;
int _lockoutTimer;
Common::KeyState _keyState;
private:
/**
* Draws designated areas of the screen that are meant to be grayed out using grayscale colors
*/
void drawGrayAreas();
/**
* Handle any input when we're in standard mode (with no windows open)
*/
void doStandardControl();
/**
* Handle input when in look mode
*/
void doLookControl();
/**
* Handle input when the File window is open
*/
void doFileControl();
/**
* Handle input if an inventory command (INVENT, LOOK, or USE) has an open window and is active
*/
void doInventoryControl();
/**
* Handle input while the verb menu is open
*/
void doVerbControl();
/**
* Handles input when in talk mode. It highlights the buttons and response statements,
* and handles any actions for clicking on the buttons or statements.
*/
void doTalkControl();
/**
* Handles input when a message window is open at the bottom of the screen
*/
void doMessageControl();
/**
* Handles input when the player is in the Lab Table scene
*/
void doLabControl();
public:
Common::Point _currentScroll, _targetScroll;
int _scrollSize, _scrollSpeed;

View File

@ -50,7 +50,9 @@ enum MenuMode {
SETUP_MODE = 12,
// Rose Tattoo specific
LAB_MODE = 20
LAB_MODE = 20,
MESSAGE_MODE = 21,
VERB_MODE = 22
};
class UserInterface {