2003-12-01 20:48:41 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
2006-01-18 17:39:49 +00:00
|
|
|
* Copyright (C) 2003-2006 The ScummVM project
|
2003-10-31 13:46:45 +00:00
|
|
|
*
|
|
|
|
* 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
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2003-10-31 13:46:45 +00:00
|
|
|
*
|
2006-02-11 10:07:12 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2003-10-31 13:46:45 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2006-11-12 17:47:16 +00:00
|
|
|
#ifndef QUEEN_COMMAND_H
|
|
|
|
#define QUEEN_COMMAND_H
|
2003-10-31 13:46:45 +00:00
|
|
|
|
2003-12-01 20:48:41 +00:00
|
|
|
#include "common/util.h"
|
|
|
|
#include "queen/structs.h"
|
2003-10-31 13:46:45 +00:00
|
|
|
|
|
|
|
namespace Queen {
|
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
class QueenEngine;
|
2003-10-31 13:46:45 +00:00
|
|
|
|
|
|
|
struct CmdText {
|
|
|
|
|
2006-11-12 17:47:16 +00:00
|
|
|
CmdText(uint8 y, QueenEngine *vm);
|
2004-04-03 17:58:58 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! reset the command sentence
|
2003-10-31 13:46:45 +00:00
|
|
|
void clear();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! display the command sentence using the specified color
|
2007-02-24 18:39:08 +00:00
|
|
|
void display(InkColor color);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! display a temporary command sentence using the specified parameters
|
2007-02-24 18:39:08 +00:00
|
|
|
void displayTemp(InkColor color, Verb v, const char *name = NULL, bool outlined = false);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! display a temporary command sentence using the specified parameters
|
2007-02-24 18:39:08 +00:00
|
|
|
void displayTemp(InkColor color, const char *name, bool outlined = false);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! set the verb for the command sentence
|
2003-12-12 10:33:34 +00:00
|
|
|
void setVerb(Verb v);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! set the link word (between verb and object) for the command sentence
|
2003-12-12 10:33:34 +00:00
|
|
|
void addLinkWord(Verb v);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! add an object name to the command sentence
|
2003-10-31 13:46:45 +00:00
|
|
|
void addObject(const char *objName);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! returns true if the command sentence is empty
|
2003-10-31 13:46:45 +00:00
|
|
|
bool isEmpty() const;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
MAX_COMMAND_LEN = 256,
|
|
|
|
COMMAND_Y_POS = 151
|
|
|
|
};
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-04-03 17:58:58 +00:00
|
|
|
uint8 _y;
|
2004-12-31 00:25:18 +00:00
|
|
|
|
|
|
|
//! flag indicating if the words in the sentence are reversed (hebrew version)
|
2004-02-13 22:33:21 +00:00
|
|
|
bool _isReversed;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! buffer containing the current command sentence
|
2003-10-31 13:46:45 +00:00
|
|
|
char _command[MAX_COMMAND_LEN];
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
QueenEngine *_vm;
|
2003-10-31 13:46:45 +00:00
|
|
|
};
|
|
|
|
|
2003-12-13 20:05:28 +00:00
|
|
|
struct CmdState {
|
2003-11-03 19:52:14 +00:00
|
|
|
|
|
|
|
void init();
|
|
|
|
|
2003-12-13 20:05:28 +00:00
|
|
|
Verb oldVerb, verb;
|
2003-11-03 19:52:14 +00:00
|
|
|
Verb action;
|
2003-12-13 20:05:28 +00:00
|
|
|
int16 oldNoun, noun;
|
2003-11-03 19:52:14 +00:00
|
|
|
int commandLevel;
|
2003-12-13 20:05:28 +00:00
|
|
|
int16 subject[2];
|
2003-11-03 19:52:14 +00:00
|
|
|
|
2003-12-13 20:05:28 +00:00
|
|
|
Verb selAction;
|
|
|
|
int16 selNoun;
|
2003-11-03 19:52:14 +00:00
|
|
|
};
|
|
|
|
|
2003-10-31 13:46:45 +00:00
|
|
|
class Command {
|
|
|
|
public:
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
Command(QueenEngine *vm);
|
2004-10-17 19:00:09 +00:00
|
|
|
~Command();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-11-03 19:52:14 +00:00
|
|
|
//! initialise command construction
|
2003-10-31 13:46:45 +00:00
|
|
|
void clear(bool clearTexts);
|
|
|
|
|
2003-11-03 19:52:14 +00:00
|
|
|
//! execute last constructed command
|
2003-12-13 20:05:28 +00:00
|
|
|
void executeCurrentAction();
|
2003-10-31 13:46:45 +00:00
|
|
|
|
2003-11-03 19:52:14 +00:00
|
|
|
//! get player input and construct command from it
|
2003-10-31 13:46:45 +00:00
|
|
|
void updatePlayer();
|
|
|
|
|
2003-11-03 19:52:14 +00:00
|
|
|
//! read all command arrays from stream
|
2003-10-31 13:46:45 +00:00
|
|
|
void readCommandsFrom(byte *&ptr);
|
|
|
|
|
2003-11-04 13:51:36 +00:00
|
|
|
enum {
|
|
|
|
MAX_MATCHING_CMDS = 50
|
|
|
|
};
|
2003-11-03 19:52:14 +00:00
|
|
|
|
2003-10-31 13:46:45 +00:00
|
|
|
private:
|
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! get a reference to the ObjectData for the specified room object
|
2003-12-13 20:05:28 +00:00
|
|
|
ObjectData *findObjectData(uint16 objRoomNum) const;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! get a reference to the ItemData for the specified inventory object
|
2003-12-13 20:05:28 +00:00
|
|
|
ItemData *findItemData(Verb invNum) const;
|
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! execute the current command
|
2003-12-02 19:58:31 +00:00
|
|
|
int16 executeCommand(uint16 comId, int16 condResult);
|
2003-12-02 16:49:56 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! move Joe to the specified position, handling new room switching
|
2003-12-12 10:33:34 +00:00
|
|
|
int16 makeJoeWalkTo(int16 x, int16 y, int16 objNum, Verb v, bool mustWalk);
|
2003-11-03 19:52:14 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! update command state with current selected action
|
2003-10-31 13:46:45 +00:00
|
|
|
void grabCurrentSelection();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! update command state with current selected object
|
2003-11-03 19:52:14 +00:00
|
|
|
void grabSelectedObject(int16 objNum, uint16 objState, uint16 objName);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! update command state with current selected inventory object
|
2003-10-31 13:46:45 +00:00
|
|
|
void grabSelectedItem();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! update command state with current selected room object
|
2003-10-31 13:46:45 +00:00
|
|
|
void grabSelectedNoun();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! update command state with current selected verb
|
2003-10-31 13:46:45 +00:00
|
|
|
void grabSelectedVerb();
|
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! if the description is a cutaway file, execute it
|
2003-11-03 14:47:22 +00:00
|
|
|
bool executeIfCutaway(const char *description);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! if the description is a dialog file, execute it
|
2003-11-03 14:47:22 +00:00
|
|
|
bool executeIfDialog(const char *description);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! handle a wrong/invalid user action
|
2003-12-13 20:05:28 +00:00
|
|
|
bool handleWrongAction();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! make Joe speak something for a wrong/invalid action
|
2003-12-13 20:05:28 +00:00
|
|
|
void sayInvalidAction(Verb action, int16 subj1, int16 subj2);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! update an object state
|
2003-12-12 10:33:34 +00:00
|
|
|
void changeObjectState(Verb action, int16 obj, int16 song, bool cutDone);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! reset current action
|
2003-10-31 13:46:45 +00:00
|
|
|
void cleanupCurrentAction();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-11-03 19:52:14 +00:00
|
|
|
//! OPEN_CLOSE_OTHER(OBJECT_DATA[S][4])
|
2003-12-12 10:33:34 +00:00
|
|
|
void openOrCloseAssociatedObject(Verb action, int16 obj);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-11-03 19:52:14 +00:00
|
|
|
//! update gamestates - P1_SET_CONDITIONS
|
2003-10-31 13:46:45 +00:00
|
|
|
int16 setConditions(uint16 command, bool lastCmd);
|
|
|
|
|
2003-11-03 19:52:14 +00:00
|
|
|
//! turn on/off areas - P2_SET_AREAS
|
2003-10-31 13:46:45 +00:00
|
|
|
void setAreas(uint16 command);
|
|
|
|
|
2003-11-03 19:52:14 +00:00
|
|
|
//! hide/show objects, redisplay if in the same room as Joe - P3_SET_OBJECTS
|
2003-10-31 13:46:45 +00:00
|
|
|
void setObjects(uint16 command);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-11-03 19:52:14 +00:00
|
|
|
//! inserts/deletes items (inventory) - P4_SET_ITEMS
|
2003-10-31 13:46:45 +00:00
|
|
|
void setItems(uint16 command);
|
|
|
|
|
2003-11-03 19:52:14 +00:00
|
|
|
//! update description for object and returns description number to use
|
2003-11-03 14:47:22 +00:00
|
|
|
uint16 nextObjectDescription(ObjectDescription *objDesc, uint16 firstDesc);
|
2003-10-31 13:46:45 +00:00
|
|
|
|
2003-12-13 20:05:28 +00:00
|
|
|
//! speak description of selected object
|
|
|
|
void lookAtSelectedObject();
|
2003-10-31 13:46:45 +00:00
|
|
|
|
2003-12-14 20:24:29 +00:00
|
|
|
//! get the current object under the cursor
|
2003-12-28 21:18:03 +00:00
|
|
|
void lookForCurrentObject(int16 cx, int16 cy);
|
2003-12-13 20:05:28 +00:00
|
|
|
|
|
|
|
//! get the current icon panel under the cursor (inventory item or verb)
|
2003-12-28 21:18:03 +00:00
|
|
|
void lookForCurrentIcon(int16 cx, int16 cy);
|
2003-12-13 20:05:28 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! returns true if the verb is an action verb
|
2003-12-13 20:05:28 +00:00
|
|
|
bool isVerbAction(Verb v) const { return (v >= VERB_PANEL_COMMAND_FIRST && v <= VERB_PANEL_COMMAND_LAST) || (v == VERB_WALK_TO); };
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! return true if the verb is an inventory item
|
2003-12-12 10:33:34 +00:00
|
|
|
bool isVerbInv(Verb v) const { return v >= VERB_INV_FIRST && v <= VERB_INV_LAST; }
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! returns true if the specified verb is an inventory scroll
|
2004-03-14 00:53:24 +00:00
|
|
|
bool isVerbInvScroll(Verb v) const { return v == VERB_SCROLL_UP || v == VERB_SCROLL_DOWN; }
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! commands list for each possible action
|
2003-10-31 13:46:45 +00:00
|
|
|
CmdListData *_cmdList;
|
|
|
|
uint16 _numCmdList;
|
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! commands list for areas
|
2003-10-31 13:46:45 +00:00
|
|
|
CmdArea *_cmdArea;
|
|
|
|
uint16 _numCmdArea;
|
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! commands list for objects
|
2003-10-31 13:46:45 +00:00
|
|
|
CmdObject *_cmdObject;
|
|
|
|
uint16 _numCmdObject;
|
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! commands list for inventory
|
2003-10-31 13:46:45 +00:00
|
|
|
CmdInventory *_cmdInventory;
|
|
|
|
uint16 _numCmdInventory;
|
|
|
|
|
2004-12-31 00:25:18 +00:00
|
|
|
//! commands list for gamestate
|
2003-10-31 13:46:45 +00:00
|
|
|
CmdGameState *_cmdGameState;
|
|
|
|
uint16 _numCmdGameState;
|
|
|
|
|
2003-11-03 19:52:14 +00:00
|
|
|
//! textual form of the command (displayed between room and panel areas)
|
2003-10-31 13:46:45 +00:00
|
|
|
CmdText _cmdText;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2003-11-03 19:52:14 +00:00
|
|
|
//! flag indicating that the current command is fully constructed
|
2003-10-31 13:46:45 +00:00
|
|
|
bool _parse;
|
|
|
|
|
2003-12-13 20:05:28 +00:00
|
|
|
//! state of current constructed command
|
|
|
|
CmdState _state;
|
2003-11-03 19:52:14 +00:00
|
|
|
|
|
|
|
//! last user selection
|
|
|
|
int _mouseKey, _selPosX, _selPosY;
|
2003-10-31 13:46:45 +00:00
|
|
|
|
2003-12-11 22:16:35 +00:00
|
|
|
QueenEngine *_vm;
|
2003-10-31 13:46:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Queen
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|