more stuff for future Command class

svn-id: r10987
This commit is contained in:
Gregory Montoir 2003-10-27 15:00:25 +00:00
parent dde1fde95e
commit 26a873a2e4
5 changed files with 130 additions and 84 deletions

View File

@ -57,10 +57,11 @@ enum Direction {
enum {
INK_BG_PANEL = 0xE2,
INK_SELECT = 17,
INK_BG_PANEL = 226,
INK_JOURNAL = 16,
INK_NORMAL = 1,
INK_CMD_SELECT = 17,
INK_CMD_NORMAL = 1,
INK_CMD_LOCK = 234,
INK_TALK_NORMAL = 1,
INK_JOE = 17,
INK_OUTLINED_TEXT = 16

View File

@ -26,6 +26,7 @@
#include "queen/display.h"
#include "queen/graphics.h"
#include "queen/input.h"
#include "queen/talk.h"
#include "queen/walk.h"
@ -167,6 +168,57 @@ void State::alterDefaultVerb(uint16 *objState, Verb v) {
}
void Command_::readAllCommandsFrom(byte *&ptr) {
uint16 i;
// Command List Data
_numCmdList = READ_BE_UINT16(ptr); ptr += 2;
_cmdList = new CmdListData[_numCmdList + 1];
memset(&_cmdList[0], 0, sizeof(CmdListData));
for (i = 1; i <= _numCmdList; i++) {
_cmdList[i].readFrom(ptr);
}
// Command AREA
_numCmdArea = READ_BE_UINT16(ptr); ptr += 2;
_cmdArea = new CmdArea[_numCmdArea + 1];
memset(&_cmdArea[0], 0, sizeof(CmdArea));
for (i = 1; i <= _numCmdArea; i++) {
_cmdArea[i].readFrom(ptr);
}
// Command OBJECT
_numCmdObject = READ_BE_UINT16(ptr); ptr += 2;
_cmdObject = new CmdObject[_numCmdObject + 1];
memset(&_cmdObject[0], 0, sizeof(CmdObject));
for (i = 1; i <= _numCmdObject; i++) {
_cmdObject[i].readFrom(ptr);
}
// Command INVENTORY
_numCmdInventory = READ_BE_UINT16(ptr); ptr += 2;
_cmdInventory = new CmdInventory[_numCmdInventory + 1];
memset(&_cmdInventory[0], 0, sizeof(CmdInventory));
for (i = 1; i <= _numCmdInventory; i++) {
_cmdInventory[i].readFrom(ptr);
}
// Command GAMESTATE
_numCmdGameState = READ_BE_UINT16(ptr); ptr += 2;
_cmdGameState = new CmdGameState[_numCmdGameState + 1];
memset(&_cmdGameState[0], 0, sizeof(CmdGameState));
for (i = 1; i <= _numCmdGameState; i++) {
_cmdGameState[i].readFrom(ptr);
}
}
Logic::Logic(Resource *resource, Graphics *graphics, Display *theDisplay, Input *input, Sound *sound)
: _resource(resource), _graphics(graphics), _display(theDisplay),
_input(input), _sound(sound) {
@ -280,49 +332,7 @@ void Logic::initialise() {
_objectDescription[i].readFrom(ptr);
}
// Command List Data
_numCmdList = READ_BE_UINT16(ptr); ptr += 2;
_cmdList = new CmdListData[_numCmdList + 1];
memset(&_cmdList[0], 0, sizeof(CmdListData));
for (i = 1; i <= _numCmdList; i++) {
_cmdList[i].readFrom(ptr);
}
// Command AREA
_numCmdArea = READ_BE_UINT16(ptr); ptr += 2;
_cmdArea = new CmdArea[_numCmdArea + 1];
memset(&_cmdArea[0], 0, sizeof(CmdArea));
for (i = 1; i <= _numCmdArea; i++) {
_cmdArea[i].readFrom(ptr);
}
// Command OBJECT
_numCmdObject = READ_BE_UINT16(ptr); ptr += 2;
_cmdObject = new CmdObject[_numCmdObject + 1];
memset(&_cmdObject[0], 0, sizeof(CmdObject));
for (i = 1; i <= _numCmdObject; i++) {
_cmdObject[i].readFrom(ptr);
}
// Command INVENTORY
_numCmdInventory = READ_BE_UINT16(ptr); ptr += 2;
_cmdInventory = new CmdInventory[_numCmdInventory + 1];
memset(&_cmdInventory[0], 0, sizeof(CmdInventory));
for (i = 1; i <= _numCmdInventory; i++) {
_cmdInventory[i].readFrom(ptr);
}
// Command GAMESTATE
_numCmdGameState = READ_BE_UINT16(ptr); ptr += 2;
_cmdGameState = new CmdGameState[_numCmdGameState + 1];
memset(&_cmdGameState[0], 0, sizeof(CmdGameState));
for (i = 1; i <= _numCmdGameState; i++) {
_cmdGameState[i].readFrom(ptr);
}
Command_ cmd; cmd.readAllCommandsFrom(ptr); // TEMP
_entryObj = READ_BE_UINT16(ptr); ptr += 2;
@ -1911,6 +1921,20 @@ void Logic::playCutaway(const char* cutFile) {
}
void Logic::joeSpeak(uint16 descNum, bool objectType) {
// joeSpeak(k, false) == SPEAK(JOE_RESPstr[k],"JOE",find_cd_desc(k))
// joeSpeak(k, true) == SPEAK(OBJECT_DESCRstr[k],"JOE",find_cd_desc(JOERESPMAX+k))
const char *text = objectType ? _objDescription[descNum] : _joeResponse[descNum];
if (objectType) {
descNum += JOE_RESPONSE_MAX;
}
char descFilePrefix[10];
sprintf(descFilePrefix, "JOE%04i", descNum);
Talk::speak(text, NULL, descFilePrefix, _graphics, _input, this, _resource, _sound);
}
const char* Logic::objectOrItemName(int16 obj) const {
uint16 name;
@ -1925,12 +1949,23 @@ const char* Logic::objectOrItemName(int16 obj) const {
}
Verb Logic::findVerb(int16 cursorx, int16 cursory) const {
Verb Logic::findVerbUnderCursor(int16 cursorx, int16 cursory) const {
return PANEL_VERBS[zoneIn(ZONE_PANEL, cursorx, cursory)];
}
uint16 Logic::findObjectUnderCursor(int16 cursorx, int16 cursory) const {
uint16 roomObj = 0;
if (cursory < ROOM_ZONE_HEIGHT) {
int16 x = cursorx + _display->horizontalScroll();
roomObj = zoneIn(ZONE_ROOM, x, cursory);
}
return roomObj;
}
uint16 Logic::findObjectRoomNumber(uint16 zoneNum) const {
// l.316-327 select.c
@ -1956,6 +1991,7 @@ uint16 Logic::findObjectGlobalNumber(uint16 zoneNum) const {
const char *Logic::verbName(Verb v) const {
// FIXME: rewrite this test with future VerbCommand methods
if (v != VERB_NONE && v < 13) {
return _verbName[v];
}

View File

@ -40,9 +40,27 @@ struct ZoneSlot {
Box box;
};
// Temporary class
struct Command_ {
Verb action, action2;
uint16 noun, noun2;
CmdListData *_cmdList;
uint16 _numCmdList; //COM_LIST_MAX
CmdArea *_cmdArea;
uint16 _numCmdArea; //COM_A_MAX
CmdObject *_cmdObject;
uint16 _numCmdObject; //COM_O_MAX
CmdInventory *_cmdInventory;
uint16 _numCmdInventory; //COM_I_MAX
CmdGameState *_cmdGameState;
uint16 _numCmdGameState; //COM_G_MAX
void readAllCommandsFrom(byte *&ptr);
};
struct GameSettings {
@ -137,6 +155,7 @@ public:
uint16 roomData(int room);
uint16 objMax(int room);
GraphicData *graphicData(int index);
ItemData *itemData(int index) const { return &_itemData[index]; }
uint16 findBob(uint16 obj);
uint16 findFrame(uint16 obj);
@ -150,6 +169,9 @@ public:
uint16 walkOffCount();
WalkOffData *walkOffData(int index);
uint16 currentRoomObjMax() const { return _objMax[_currentRoom]; }
uint16 currentRoomData() const { return _roomData[_currentRoom]; }
ObjectDescription *objectDescription(uint16 objNum) const { return &_objectDescription[objNum]; }
uint16 objectDescriptionCount() const { return _numDescriptions; }
uint16 joeFacing() { return _joe.facing; }
uint16 joeX() { return _joe.x; }
@ -168,8 +190,9 @@ public:
int16 gameState(int index);
void gameState(int index, int16 newValue);
const char *roomName(uint16 roomNum) { return _roomName[roomNum] ; }
const char *objectName(uint16 objNum) { return _objName[objNum]; }
const char *roomName(uint16 roomNum) const { return _roomName[roomNum] ; }
const char *objectName(uint16 objNum) const { return _objName[objNum]; }
const char *objectTextualDescription(uint16 objNum) const { return _objDescription[objNum]; }
uint16 numFrames() { return _numFrames; }
@ -233,12 +256,14 @@ public:
//! USE_UNDERWEAR
void joeUseUnderwear();
void joeSpeak(uint16 descNum, bool objectType = false);
void playCutaway(const char* cutFile);
const char* objectOrItemName(int16 obj) const;
//! return selected verb in panel
Verb findVerb(int16 cursorx, int16 cursory) const;
Verb findVerbUnderCursor(int16 cursorx, int16 cursory) const;
uint16 findObjectUnderCursor(int16 cursorx, int16 cursory) const;
Walk *walk() { return _walk; }
Display *display() { return _display; }
@ -247,6 +272,7 @@ public:
uint16 findObjectGlobalNumber(uint16 zoneNum) const;
const char *verbName(Verb v) const;
const char *lockedVerbPrefix() const { return _joeResponse[39]; }
void update();
@ -312,21 +338,6 @@ protected:
WalkOffData *_walkOffData;
uint16 _numWalkOffs;
CmdListData *_cmdList;
uint16 _numCmdList; //COM_LIST_MAX
CmdArea *_cmdArea;
uint16 _numCmdArea; //COM_A_MAX
CmdObject *_cmdObject;
uint16 _numCmdObject; //COM_O_MAX
CmdInventory *_cmdInventory;
uint16 _numCmdInventory; //COM_I_MAX
CmdGameState *_cmdGameState;
uint16 _numCmdGameState; //COM_G_MAX
FurnitureData *_furnitureData;
uint16 _numFurniture; //FURN_DATA_MAX
@ -403,8 +414,6 @@ protected:
//! Verbs (in order) available in panel
static const Verb PANEL_VERBS[];
friend class Command; // TEMP
};
} // End of namespace Queen

View File

@ -336,7 +336,7 @@ int16 Walk::joeMove(int direction, uint16 endx, uint16 endy, bool inCutaway) {
}
else {
// path has been blocked, make Joe say so
// XXX SPEAK(JOE_RESPstr[4],"JOE",find_cd_desc(4));
_logic->joeSpeak(4);
can = -1;
}

View File

@ -16,12 +16,13 @@ COMMAND
=======
ALTER_DEFAULT() Command::alterDefault
CLEAR_COMMAND() Command::clear
CHECK_PLAYER() Command::checkPlayer
EXECUTE_ACTION() Command::executeCurrentAction
FIND_DEFAULT() Command::findDefault
LOOK()
LOOK_ICON()
LOOK() Command::look
LOOK_ICON() Command::lookCurrentIcon
LOOK_ITEM() Command::lookCurrentItem
LOOK_ROOM()
LOOK_ROOM() Command::lookCurrentRoom
OPEN_CLOSE_OTHER() Command::openOrCloseAssociatedObject
P1_SET_CONDITIONS() Command::setConditions
P2_SET_AREAS() Command::setAreas
@ -34,16 +35,16 @@ SELECT_VERB() Command::grabSelectedVerb
-
ACTION,ACTION2 Command::_action*
CLEVEL Command::_commandLevel
COM_A Logic::_cmdArea
COM_A_MAX Logic::_numCmdArea
COM_O Logic::_cmdObject
COM_O_MAX Logic::_numCmdObject
COM_G Logic::_cmdGameState
COM_G_MAX Logic::_numCmdGameState
COM_I Logic::_cmdInventory
COM_I_MAX Logic::_numCmdInventory
COM_LIST Logic::_cmdList
COM_LIST_MAX Logic::_numCmdList
COM_A Command::_cmdArea
COM_A_MAX Command::_numCmdArea
COM_O Command::_cmdObject
COM_O_MAX Command::_numCmdObject
COM_G Command::_cmdGameState
COM_G_MAX Command::_numCmdGameState
COM_I Command::_cmdInventory
COM_I_MAX Command::_numCmdInventory
COM_LIST Command::_cmdList
COM_LIST_MAX Command::_numCmdList
COMMANDstr Command::_command
DEFCOMM Command::_defaultVerb
OLDVERB,VERB Command::_*verb*
@ -418,9 +419,8 @@ zones Logic::_zones
(UNSORTED)
==========
in() defs.h InRange() macro
CHECK_PLAYER()
find_cd_cut() findCdCut
find_cd_desc()
find_cd_desc() *not needed, see Logic::joeSpeak()*
-
Kstr
bank9