ASYLUM: Implement Encounter::init and update Encounter::messageHandler
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@583 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
This commit is contained in:
parent
7c179d025e
commit
a02af8db05
5 changed files with 106 additions and 27 deletions
|
@ -45,10 +45,10 @@ struct AsylumEvent : public Common::Event {
|
|||
}
|
||||
};
|
||||
|
||||
typedef Common::Functor1<const AsylumEvent &, void> MessageHandler;
|
||||
typedef Common::Functor1<const AsylumEvent &, bool> MessageHandler;
|
||||
|
||||
#define MESSAGE_HANDLER(class, name, inst) \
|
||||
Common::Functor1Mem<const AsylumEvent&, void, class>(inst, &class::name)
|
||||
Common::Functor1Mem<const AsylumEvent&, bool, class>(inst, &class::name)
|
||||
|
||||
} // End of namespace Asylum
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "asylum/system/cursor.h"
|
||||
#include "asylum/system/speech.h"
|
||||
#include "asylum/system/text.h"
|
||||
|
||||
#include "asylum/views/scene.h"
|
||||
|
||||
|
@ -46,6 +47,8 @@ Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
|
|||
_index(NULL), _keywordIndex(0), _item(NULL), _objectId1(kObjectNone), _objectId2(kObjectNone), _actorIndex(kActorInvalid),
|
||||
_flag1(false), _flag2(false) {
|
||||
|
||||
// TODO init rest of members
|
||||
|
||||
_messageHandler = new MESSAGE_HANDLER(Encounter, messageHandler, this);
|
||||
|
||||
load();
|
||||
|
@ -54,6 +57,7 @@ Encounter::Encounter(AsylumEngine *engine) : _vm(engine),
|
|||
Encounter::~Encounter() {
|
||||
delete _messageHandler;
|
||||
|
||||
// Pointing to existing data
|
||||
_item = NULL;
|
||||
|
||||
// Zero-out passed pointers
|
||||
|
@ -100,6 +104,22 @@ void Encounter::load() {
|
|||
file.close();
|
||||
}
|
||||
|
||||
void Encounter::initData() {
|
||||
error("[Encounter::initData] Not implemented!");
|
||||
}
|
||||
|
||||
void Encounter::initCoordinates(){
|
||||
error("[Encounter::initData] Not implemented!");
|
||||
}
|
||||
|
||||
void Encounter::initPortrait(){
|
||||
error("[Encounter::initData] Not implemented!");
|
||||
}
|
||||
|
||||
void Encounter::initDrawStructs(){
|
||||
error("[Encounter::initData] Not implemented!");
|
||||
}
|
||||
|
||||
uint32 Encounter::findKeyword(EncounterItem *item, int16 keyword) {
|
||||
for (uint i = 0; i < ARRAYSIZE(item->keywords); i++) {
|
||||
if ((item->keywords[i] & 0xFFF) == keyword)
|
||||
|
@ -156,51 +176,85 @@ void Encounter::run(int32 encounterIndex, ObjectId objectId1, ObjectId objectId2
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
// Message handler
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Encounter::messageHandler(const AsylumEvent &evt) {
|
||||
bool Encounter::messageHandler(const AsylumEvent &evt) {
|
||||
switch ((uint32)evt.type) {
|
||||
default:
|
||||
break;
|
||||
|
||||
case EVENT_ASYLUM_INIT:
|
||||
init();
|
||||
return init();
|
||||
break;
|
||||
|
||||
case EVENT_ASYLUM_UPDATE:
|
||||
update();
|
||||
return update();
|
||||
break;
|
||||
|
||||
case Common::EVENT_KEYDOWN:
|
||||
key(evt);
|
||||
return key(evt);
|
||||
break;
|
||||
|
||||
case Common::EVENT_LBUTTONDOWN:
|
||||
case Common::EVENT_LBUTTONUP:
|
||||
case Common::EVENT_RBUTTONDOWN:
|
||||
case Common::EVENT_RBUTTONUP:
|
||||
mouse(evt);
|
||||
return mouse(evt);
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Encounter::init() {
|
||||
bool Encounter::init() {
|
||||
if (getSound()->getMusicVolume() != Config.musicVolume - 500)
|
||||
getSound()->setMusicVolume(Config.musicVolume - 500);
|
||||
|
||||
error("[Encounter::init] Not implemented!");
|
||||
if (!getSharedData()->getMatteBarHeight()) {
|
||||
_flag6 = true;
|
||||
_data_455BD4 = 0;
|
||||
_data_455BD8 = 0;
|
||||
_data_455BDC = 0;
|
||||
_data_455BE0 = 0;
|
||||
_data_455BE4 = 0;
|
||||
_data_455BCC = 0;
|
||||
_data_455B3C = 1;
|
||||
_rectIndex = -1;
|
||||
_value1 = 0;
|
||||
_data_455BF4 = 0;
|
||||
_data_455BF8 = 0;
|
||||
_data_455B14 = -1;
|
||||
|
||||
getSpeech()->resetTextData();
|
||||
|
||||
initData();
|
||||
|
||||
getText()->loadFont(getWorld()->font1);
|
||||
|
||||
initCoordinates();
|
||||
initPortrait();
|
||||
initDrawStructs();
|
||||
}
|
||||
|
||||
_data_455BD0 = 0;
|
||||
getCursor()->set(getWorld()->curTalkNPC, -1, 2);
|
||||
|
||||
if (!getSharedData()->getMatteBarHeight())
|
||||
initScript(_item->scriptResourceId);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Encounter::update() {
|
||||
bool Encounter::update() {
|
||||
if (getSound()->getMusicVolume() != Config.musicVolume - 500)
|
||||
getSound()->setMusicVolume(Config.musicVolume - 500);
|
||||
|
||||
error("[Encounter::update] Not implemented!");
|
||||
}
|
||||
|
||||
void Encounter::key(const AsylumEvent &evt) {
|
||||
bool Encounter::key(const AsylumEvent &evt) {
|
||||
error("[Encounter::key] Not implemented!");
|
||||
}
|
||||
|
||||
void Encounter::mouse(const AsylumEvent &evt) {
|
||||
bool Encounter::mouse(const AsylumEvent &evt) {
|
||||
error("[Encounter::mouse] Not implemented!");
|
||||
}
|
||||
|
||||
|
@ -254,8 +308,8 @@ bool Encounter::isSpeaking() {
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
// Scripts
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void Encounter::initScript() {
|
||||
_scriptData.reset();
|
||||
void Encounter::initScript(ResourceId resourceId) {
|
||||
_scriptData.reset(resourceId);
|
||||
_flag3 = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,11 +89,21 @@ private:
|
|||
ActorIndex _actorIndex;
|
||||
|
||||
uint32 _value1;
|
||||
int32 _rectIndex;
|
||||
|
||||
// Internal data
|
||||
int32 _data_455B14;
|
||||
bool _data_455B3C;
|
||||
bool _data_455BCC;
|
||||
bool _data_455BD0;
|
||||
bool _data_455BD4;
|
||||
bool _data_455BD8;
|
||||
bool _data_455BDC;
|
||||
bool _data_455BE0;
|
||||
bool _data_455BE4;
|
||||
bool _data_455BE8;
|
||||
uint32 _data_455BF4;
|
||||
bool _data_455BD4;
|
||||
bool _data_455BF8;
|
||||
|
||||
// Internal flags
|
||||
bool _flag1;
|
||||
|
@ -106,16 +116,21 @@ private:
|
|||
//////////////////////////////////////////////////////////////////////////
|
||||
// Data
|
||||
void load();
|
||||
uint32 findKeyword(EncounterItem *item, int16 keyword);
|
||||
void initData();
|
||||
void initCoordinates();
|
||||
void initPortrait();
|
||||
void initDrawStructs();
|
||||
|
||||
uint32 findKeyword(EncounterItem *item, int16 keyword);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Message handling
|
||||
Common::Functor1Mem<const AsylumEvent &, void, Encounter> *_messageHandler;
|
||||
void messageHandler(const AsylumEvent &evt);
|
||||
void init();
|
||||
void update();
|
||||
void key(const AsylumEvent &evt);
|
||||
void mouse(const AsylumEvent &evt);
|
||||
Common::Functor1Mem<const AsylumEvent &, bool, Encounter> *_messageHandler;
|
||||
bool messageHandler(const AsylumEvent &evt);
|
||||
bool init();
|
||||
bool update();
|
||||
bool key(const AsylumEvent &evt);
|
||||
bool mouse(const AsylumEvent &evt);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Variables
|
||||
|
@ -151,23 +166,23 @@ private:
|
|||
int32 vars[10];
|
||||
uint32 offset;
|
||||
int32 counter;
|
||||
uint32 resourceId;
|
||||
ResourceId resourceId;
|
||||
|
||||
ScriptData() {
|
||||
reset();
|
||||
reset(kResourceNone);
|
||||
}
|
||||
|
||||
void reset() {
|
||||
void reset(ResourceId resourceId) {
|
||||
memset(&vars, 0, sizeof(vars));
|
||||
offset = 0;
|
||||
counter = 0;
|
||||
resourceId = kResourceNone;
|
||||
resourceId = resourceId;
|
||||
}
|
||||
};
|
||||
|
||||
ScriptData _scriptData;
|
||||
|
||||
void initScript();
|
||||
void initScript(ResourceId resourceId);
|
||||
ScriptEntry getScriptEntry(ResourceId resourceId, uint32 offset);
|
||||
void runScript();
|
||||
|
||||
|
|
|
@ -222,6 +222,11 @@ void Speech::resetResourceIds() {
|
|||
_textResourceId = kResourceNone;
|
||||
}
|
||||
|
||||
void Speech::resetTextData() {
|
||||
_textData = NULL;
|
||||
_textDataPos = NULL;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Private methods
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -86,6 +86,11 @@ public:
|
|||
*/
|
||||
void resetResourceIds();
|
||||
|
||||
/**
|
||||
* Resets text data
|
||||
*/
|
||||
void resetTextData();
|
||||
|
||||
/**
|
||||
* Gets the sound resource identifier.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue