ScummVM API documentation
command.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef QUEEN_COMMAND_H
23#define QUEEN_COMMAND_H
24
25#include "common/util.h"
26#include "queen/structs.h"
27
28namespace Queen {
29
30class QueenEngine;
31
32class CmdText {
33public:
34
35 static CmdText *makeCmdTextInstance(uint8 y, QueenEngine *vm);
36
37 CmdText(uint8 y, QueenEngine *vm);
38 virtual ~CmdText() {}
39
41 void clear();
42
44 void display(InkColor color, const char *command = 0, bool outlined = false);
45
47 void displayTemp(InkColor color, Verb v);
48
50 virtual void displayTemp(InkColor color, const char *name, bool outlined);
51
53 void setVerb(Verb v);
54
56 virtual void addLinkWord(Verb v);
57
59 virtual void addObject(const char *objName);
60
62 bool isEmpty() const { return _command[0] == 0; }
63
64 enum {
65 MAX_COMMAND_LEN = 256,
66 COMMAND_Y_POS = 151
67 };
68
69protected:
70
72 char _command[MAX_COMMAND_LEN];
73
74 uint8 _y;
75
76 QueenEngine *_vm;
77};
78
79struct CmdState {
80
81 void init();
82
83 Verb oldVerb, verb;
84 Verb action;
85 int16 oldNoun, noun;
86 int commandLevel;
87 int16 subject[2];
88
89 Verb selAction;
90 int16 selNoun;
91};
92
93class Command {
94public:
95
97 ~Command();
98
100 void clear(bool clearTexts);
101
104
107
109 void readCommandsFrom(byte *&ptr);
110
111 enum {
112 MAX_MATCHING_CMDS = 50
113 };
114
115private:
116
118 ObjectData *findObjectData(uint16 objRoomNum) const;
119
121 ItemData *findItemData(Verb invNum) const;
122
124 int16 executeCommand(uint16 comId, int16 condResult);
125
127 int16 makeJoeWalkTo(int16 x, int16 y, int16 objNum, Verb v, bool mustWalk);
128
130 void grabCurrentSelection();
131
133 void grabSelectedObject(int16 objNum, uint16 objState, uint16 objName);
134
136 void grabSelectedItem();
137
139 void grabSelectedNoun();
140
142 void grabSelectedVerb();
143
145 bool executeIfCutaway(const char *description);
146
148 bool executeIfDialog(const char *description);
149
151 bool handleWrongAction();
152
154 void sayInvalidAction(Verb action, int16 subj1, int16 subj2);
155
157 void changeObjectState(Verb action, int16 obj, int16 song, bool cutDone);
158
160 void cleanupCurrentAction();
161
163 void openOrCloseAssociatedObject(Verb action, int16 obj);
164
166 int16 setConditions(uint16 command, bool lastCmd);
167
169 void setAreas(uint16 command);
170
172 void setObjects(uint16 command);
173
175 void setItems(uint16 command);
176
178 uint16 nextObjectDescription(ObjectDescription *objDesc, uint16 firstDesc);
179
181 void lookAtSelectedObject();
182
184 void lookForCurrentObject(int16 cx, int16 cy);
185
187 void lookForCurrentIcon(int16 cx, int16 cy);
188
190 bool isVerbAction(Verb v) const { return (v >= VERB_PANEL_COMMAND_FIRST && v <= VERB_PANEL_COMMAND_LAST) || (v == VERB_WALK_TO); }
191
193 bool isVerbInv(Verb v) const { return v >= VERB_INV_FIRST && v <= VERB_INV_LAST; }
194
196 bool isVerbInvScroll(Verb v) const { return v == VERB_SCROLL_UP || v == VERB_SCROLL_DOWN; }
197
199 CmdListData *_cmdList;
200 uint16 _numCmdList;
201
203 CmdArea *_cmdArea;
204 uint16 _numCmdArea;
205
207 CmdObject *_cmdObject;
208 uint16 _numCmdObject;
209
211 CmdInventory *_cmdInventory;
212 uint16 _numCmdInventory;
213
215 CmdGameState *_cmdGameState;
216 uint16 _numCmdGameState;
217
219 CmdText *_cmdText;
220
222 bool _parse;
223
225 CmdState _state;
226
228 int _mouseKey, _selPosX, _selPosY;
229
230 QueenEngine *_vm;
231};
232
233} // End of namespace Queen
234
235#endif
Definition: command.h:32
virtual void addLinkWord(Verb v)
set the link word (between verb and object) for the command sentence
void displayTemp(InkColor color, Verb v)
display a temporary command sentence using the specified parameters
void clear()
reset the command sentence
virtual void displayTemp(InkColor color, const char *name, bool outlined)
display a temporary command sentence using the specified parameters
bool isEmpty() const
returns true if the command sentence is empty
Definition: command.h:62
virtual void addObject(const char *objName)
add an object name to the command sentence
void setVerb(Verb v)
set the verb for the command sentence
char _command[MAX_COMMAND_LEN]
buffer containing the current command sentence
Definition: command.h:72
void display(InkColor color, const char *command=0, bool outlined=false)
display the command sentence using the specified color
Definition: command.h:93
void clear(bool clearTexts)
initialize command construction
void readCommandsFrom(byte *&ptr)
read all command arrays from stream
void executeCurrentAction()
execute last constructed command
void updatePlayer()
get player input and construct command from it
Definition: queen.h:87
Definition: bankman.h:28
Definition: command.h:79
Definition: structs.h:315
Definition: structs.h:185
Definition: structs.h:265