mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-22 01:39:57 +00:00
SHERLOCK: Implemented UserInterface::handleInput
This commit is contained in:
parent
73085bf570
commit
73de00b72f
@ -311,4 +311,8 @@ void People::walkToCoords(const Common::Point &destPos, int destDir) {
|
||||
warning("TODO: walkToCoords");
|
||||
}
|
||||
|
||||
void People::goAllTheWay() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
} // End of namespace Sherlock
|
||||
|
@ -59,7 +59,6 @@ private:
|
||||
Sprite &_player;
|
||||
bool _walkLoaded;
|
||||
int _oldWalkSequence;
|
||||
bool _allowWalkAbort;
|
||||
public:
|
||||
Common::Point _walkDest;
|
||||
Common::Stack<Common::Point> _walkTo;
|
||||
@ -67,6 +66,7 @@ public:
|
||||
bool _portraitLoaded;
|
||||
Object _portrait;
|
||||
bool _clearingThePortrait;
|
||||
bool _allowWalkAbort;
|
||||
public:
|
||||
People(SherlockEngine *vm);
|
||||
~People();
|
||||
@ -86,6 +86,8 @@ public:
|
||||
void gotoStand(Sprite &sprite);
|
||||
|
||||
void walkToCoords(const Common::Point &destPos, int destDir);
|
||||
|
||||
void goAllTheWay();
|
||||
};
|
||||
|
||||
} // End of namespace Sherlock
|
||||
|
@ -1427,5 +1427,27 @@ int Scene::findBgShape(const Common::Rect &r) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
int Scene::checkForZones(const Common::Point &pt, int zoneType) {
|
||||
int matches = 0;
|
||||
|
||||
for (uint idx = 0; idx < _bgShapes.size(); ++idx) {
|
||||
Object &o = _bgShapes[idx];
|
||||
if ((o._aType == zoneType && o._type != INVALID) && o._type != HIDDEN) {
|
||||
Common::Rect r = o._type == NO_SHAPE ? o.getNoShapeBounds() : o.getNewBounds();
|
||||
|
||||
if (r.contains(pt)) {
|
||||
++matches;
|
||||
o.setFlagsAndToggles();
|
||||
_vm->_talk->talkTo(o._use[0]._target);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
} // End of namespace Sherlock
|
||||
|
@ -177,6 +177,8 @@ public:
|
||||
void clearInfo();
|
||||
|
||||
int findBgShape(const Common::Rect &r);
|
||||
|
||||
int checkForZones(const Common::Point &pt, int zoneType);
|
||||
};
|
||||
|
||||
} // End of namespace Sherlock
|
||||
|
@ -138,8 +138,6 @@ void SherlockEngine::sceneLoop() {
|
||||
* Handle all player input
|
||||
*/
|
||||
void SherlockEngine::handleInput() {
|
||||
bool personFound;
|
||||
|
||||
_events->pollEventsAndWait();
|
||||
|
||||
// See if a key or mouse button is pressed
|
||||
|
@ -34,6 +34,10 @@ void Talk::talkTo(const Common::String &name) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void Talk::talk(int objNum) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear loaded talk data
|
||||
*/
|
||||
|
@ -51,6 +51,8 @@ public:
|
||||
|
||||
void talkTo(const Common::String &name);
|
||||
|
||||
void talk(int objNum);
|
||||
|
||||
void freeTalkVars();
|
||||
};
|
||||
|
||||
|
@ -72,6 +72,8 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) {
|
||||
_windowOpen = false;
|
||||
_oldLook = false;
|
||||
_keyboardInput = false;
|
||||
_invMode = 0;
|
||||
_pause = false;
|
||||
|
||||
_controls = nullptr; // new ImageFile("menu.all");
|
||||
}
|
||||
@ -82,8 +84,10 @@ UserInterface::~UserInterface() {
|
||||
|
||||
void UserInterface::handleInput() {
|
||||
Events &events = *_vm->_events;
|
||||
People &people = *_vm->_people;
|
||||
Scene &scene = *_vm->_scene;
|
||||
Screen &screen = *_vm->_screen;
|
||||
Talk &talk = *_vm->_talk;
|
||||
|
||||
if (_menuCounter)
|
||||
whileMenuCounter();
|
||||
@ -190,7 +194,146 @@ void UserInterface::handleInput() {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO
|
||||
// Reset the old bgshape number if the mouse button is released, so that
|
||||
// it can e re-highlighted when we come back here
|
||||
if ((events._rightReleased && _helpStyle) || (events._released && !_helpStyle))
|
||||
_oldBgFound = -1;
|
||||
|
||||
// Do routines that should be done before input processing
|
||||
switch (_menuMode) {
|
||||
case LOOK_MODE:
|
||||
if (!_windowOpen) {
|
||||
if (events._released && _bgFound >= 0 && _bgFound < 1000) {
|
||||
if (!scene._bgShapes[_bgFound]._examine.empty())
|
||||
examine();
|
||||
} else {
|
||||
lookScreen(pt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MOVE_MODE:
|
||||
case OPEN_MODE:
|
||||
case CLOSE_MODE:
|
||||
case PICKUP_MODE:
|
||||
lookScreen(pt);
|
||||
break;
|
||||
|
||||
case TALK_MODE:
|
||||
if (!_windowOpen) {
|
||||
bool personFound;
|
||||
|
||||
if (_bgFound >= 1000) {
|
||||
personFound = false;
|
||||
if (!events._released)
|
||||
lookScreen(pt);
|
||||
} else {
|
||||
personFound = scene._bgShapes[_bgFound]._aType == PERSON && _bgFound != -1;
|
||||
}
|
||||
|
||||
if (events._released && personFound)
|
||||
talk.talk(_bgFound);
|
||||
else if (personFound)
|
||||
lookScreen(pt);
|
||||
else if (_bgFound < 1000)
|
||||
clearInfo();
|
||||
}
|
||||
break;
|
||||
|
||||
case USE_MODE:
|
||||
case GIVE_MODE:
|
||||
case INV_MODE:
|
||||
if (_invMode == 1 || _invMode == 2 || _invMode == 3) {
|
||||
if (pt.y < CONTROLS_Y)
|
||||
lookInv();
|
||||
else
|
||||
lookScreen(pt);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
// Do input processing
|
||||
//
|
||||
if (events._pressed || events._released || events._rightPressed ||
|
||||
_keycode != Common::KEYCODE_INVALID || _pause) {
|
||||
if (((events._released && (_helpStyle || _help == -1)) || (events._rightReleased && !_helpStyle)) &&
|
||||
(pt.y <= CONTROLS_Y) && (_menuMode == STD_MODE)) {
|
||||
// The mouse was clicked in the playing area with no action buttons down.
|
||||
// Check if the mouse was clicked in a script zone. If it was,
|
||||
// then execute the script. Otherwise, walk to the given position
|
||||
if (scene.checkForZones(pt, SCRIPT_ZONE) != 0) {
|
||||
// Mouse clicked in script zone
|
||||
events._pressed = events._released = false;
|
||||
} else {
|
||||
people._walkDest = pt;
|
||||
people._allowWalkAbort = false;
|
||||
people.goAllTheWay();
|
||||
}
|
||||
|
||||
if (_oldKey != -1) {
|
||||
restoreButton(_oldTemp);
|
||||
_oldKey = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// Handle action depending on selected mode
|
||||
switch (_menuMode) {
|
||||
case LOOK_MODE:
|
||||
if (_windowOpen)
|
||||
doLookControl();
|
||||
break;
|
||||
|
||||
case MOVE_MODE:
|
||||
doMiscControl(ALLOW_MOVEMENT);
|
||||
break;
|
||||
|
||||
case TALK_MODE:
|
||||
if (_windowOpen)
|
||||
doTalkControl();
|
||||
break;
|
||||
|
||||
case OPEN_MODE:
|
||||
doMiscControl(ALLOW_OPEN);
|
||||
break;
|
||||
|
||||
case CLOSE_MODE:
|
||||
doMiscControl(ALLOW_CLOSE);
|
||||
break;
|
||||
|
||||
case PICKUP_MODE:
|
||||
doPickControl();
|
||||
break;
|
||||
|
||||
case USE_MODE:
|
||||
case GIVE_MODE:
|
||||
case INV_MODE:
|
||||
doInvControl();
|
||||
break;
|
||||
|
||||
case FILES_MODE:
|
||||
doEnvControl();
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// As long as there isn't an open window, do main input processing.
|
||||
// Windows are opened when in TALK, USE, INV, and GIVE modes
|
||||
if ((!_windowOpen && !_menuCounter && pt.y > CONTROLS_Y) ||
|
||||
_keycode != Common::KEYCODE_INVALID) {
|
||||
if (events._pressed || events._released || _pause ||
|
||||
_keycode != Common::KEYCODE_INVALID)
|
||||
doMainControl();
|
||||
}
|
||||
|
||||
if (pt.y < CONTROLS_Y && events._pressed && _oldTemp != (_menuMode - 1) && _oldKey != -1)
|
||||
restoreButton(_oldTemp);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -303,4 +446,44 @@ void UserInterface::whileMenuCounter() {
|
||||
}
|
||||
}
|
||||
|
||||
void UserInterface::examine() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void UserInterface::lookScreen(const Common::Point &pt) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void UserInterface::lookInv() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void UserInterface::doEnvControl() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void UserInterface::doInvControl() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void UserInterface::doLookControl() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void UserInterface::doMainControl() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void UserInterface::doMiscControl(int allowed) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void UserInterface::doPickControl() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
void UserInterface::doTalkControl() {
|
||||
// TODO
|
||||
}
|
||||
|
||||
} // End of namespace Sherlock
|
||||
|
@ -62,6 +62,8 @@ private:
|
||||
ImageFile *_controls;
|
||||
int _oldLook;
|
||||
bool _keyboardInput;
|
||||
int _invMode;
|
||||
bool _pause;
|
||||
private:
|
||||
void depressButton(int num);
|
||||
|
||||
@ -70,6 +72,20 @@ private:
|
||||
void pushButton(int num);
|
||||
|
||||
void toggleButton(int num);
|
||||
|
||||
void examine();
|
||||
|
||||
void lookScreen(const Common::Point &pt);
|
||||
|
||||
void lookInv();
|
||||
|
||||
void doEnvControl();
|
||||
void doInvControl();
|
||||
void doLookControl();
|
||||
void doMainControl();
|
||||
void doMiscControl(int allowed);
|
||||
void doPickControl();
|
||||
void doTalkControl();
|
||||
public:
|
||||
MenuMode _menuMode;
|
||||
int _menuCounter;
|
||||
|
Loading…
Reference in New Issue
Block a user