aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicola Mettifogo2008-11-09 03:53:06 +0000
committerNicola Mettifogo2008-11-09 03:53:06 +0000
commit27a5d8bd5b0ad2d84f6c4f223ce6271876301eeb (patch)
treedff3e93121270dbdf790e7143d4b9523e2c2a2c7
parentf076b5e0348b34f0dff1b2fe30b7aabcf00c13b8 (diff)
downloadscummvm-rg350-27a5d8bd5b0ad2d84f6c4f223ce6271876301eeb.tar.gz
scummvm-rg350-27a5d8bd5b0ad2d84f6c4f223ce6271876301eeb.tar.bz2
scummvm-rg350-27a5d8bd5b0ad2d84f6c4f223ce6271876301eeb.zip
Better cleanup and handling of mouse when changing location in NS.
svn-id: r34942
-rw-r--r--engines/parallaction/callables_ns.cpp2
-rw-r--r--engines/parallaction/parallaction.cpp103
-rw-r--r--engines/parallaction/parallaction.h33
-rw-r--r--engines/parallaction/parallaction_br.cpp2
-rw-r--r--engines/parallaction/parallaction_ns.cpp20
5 files changed, 111 insertions, 49 deletions
diff --git a/engines/parallaction/callables_ns.cpp b/engines/parallaction/callables_ns.cpp
index ae949826d9..444f0e580c 100644
--- a/engines/parallaction/callables_ns.cpp
+++ b/engines/parallaction/callables_ns.cpp
@@ -411,10 +411,12 @@ void Parallaction_ns::_c_startIntro(void *parm) {
}
_input->setMouseState(MOUSE_DISABLED);
+ _intro = true;
}
void Parallaction_ns::_c_endIntro(void *parm) {
startCreditSequence();
+ _intro = false;
}
void Parallaction_ns::_c_moveSheet(void *parm) {
diff --git a/engines/parallaction/parallaction.cpp b/engines/parallaction/parallaction.cpp
index cb4122dac8..7623025d7f 100644
--- a/engines/parallaction/parallaction.cpp
+++ b/engines/parallaction/parallaction.cpp
@@ -869,9 +869,6 @@ WalkFrames _char24WalkFrames = {
{ 2, 2, 4, 4 }
};
-const char Character::_prefixMini[] = "mini";
-const char Character::_suffixTras[] = "tras";
-const char Character::_empty[] = "\0";
Character::Character(Parallaction *vm) : _vm(vm), _ani(new Animation) {
@@ -882,8 +879,6 @@ Character::Character(Parallaction *vm) : _vm(vm), _ani(new Animation) {
_direction = WALK_DOWN;
_step = 0;
- _dummy = false;
-
_ani->setX(150);
_ani->setY(100);
_ani->setZ(10);
@@ -965,6 +960,49 @@ void Character::free() {
}
+void Character::setName(const char *name) {
+ _name.bind(name);
+}
+
+const char *Character::getName() const {
+ return _name.getName();
+}
+
+const char *Character::getBaseName() const {
+ return _name.getBaseName();
+}
+
+const char *Character::getFullName() const {
+ return _name.getFullName();
+}
+
+bool Character::dummy() const {
+ return _name.dummy();
+}
+
+void Character::updateDirection(const Common::Point& pos, const Common::Point& to) {
+
+ Common::Point dist(to.x - pos.x, to.y - pos.y);
+ WalkFrames *frames = (_ani->getFrameNum() == 20) ? &_char20WalkFrames : &_char24WalkFrames;
+
+ _step++;
+
+ if (dist.x == 0 && dist.y == 0) {
+ _ani->setF(frames->stillFrame[_direction]);
+ return;
+ }
+
+ if (dist.x < 0)
+ dist.x = -dist.x;
+ if (dist.y < 0)
+ dist.y = -dist.y;
+
+ _direction = (dist.x > dist.y) ? ((to.x > pos.x) ? WALK_LEFT : WALK_RIGHT) : ((to.y > pos.y) ? WALK_DOWN : WALK_UP);
+ _ani->setF(frames->firstWalkFrame[_direction] + (_step / frames->frameRepeat[_direction]) % frames->numWalkFrames[_direction]);
+}
+
+
+
// Various ways of detecting character modes used to exist
// inside the engine, so they have been unified in the two
// following macros.
@@ -976,7 +1014,26 @@ void Character::free() {
#define IS_MINI_CHARACTER(s) (((s)[0] == 'm'))
#define IS_DUMMY_CHARACTER(s) (((s)[0] == 'D'))
-void Character::setName(const char *name) {
+const char CharacterName::_prefixMini[] = "mini";
+const char CharacterName::_suffixTras[] = "tras";
+const char CharacterName::_empty[] = "\0";
+
+void CharacterName::dummify() {
+ _dummy = true;
+ _baseName[0] = '\0';
+ _name[0] = '\0';
+ _fullName[0] = '\0';
+}
+
+CharacterName::CharacterName() {
+ dummify();
+}
+
+CharacterName::CharacterName(const char *name) {
+ bind(name);
+}
+
+void CharacterName::bind(const char *name) {
const char *begin = name;
const char *end = begin + strlen(name);
@@ -1011,22 +1068,23 @@ void Character::setName(const char *name) {
sprintf(_fullName, "%s%s%s", _prefix, _baseName, _suffix);
}
-const char *Character::getName() const {
+const char *CharacterName::getName() const {
return _name;
}
-const char *Character::getBaseName() const {
+const char *CharacterName::getBaseName() const {
return _baseName;
}
-const char *Character::getFullName() const {
+const char *CharacterName::getFullName() const {
return _fullName;
}
-bool Character::dummy() const {
+bool CharacterName::dummy() const {
return _dummy;
}
+
void Parallaction::beep() {
_soundMan->playSfx("beep", 3, false);
}
@@ -1038,29 +1096,4 @@ void Parallaction::scheduleLocationSwitch(const char *location) {
}
-
-
-
-void Character::updateDirection(const Common::Point& pos, const Common::Point& to) {
-
- Common::Point dist(to.x - pos.x, to.y - pos.y);
- WalkFrames *frames = (_ani->getFrameNum() == 20) ? &_char20WalkFrames : &_char24WalkFrames;
-
- _step++;
-
- if (dist.x == 0 && dist.y == 0) {
- _ani->setF(frames->stillFrame[_direction]);
- return;
- }
-
- if (dist.x < 0)
- dist.x = -dist.x;
- if (dist.y < 0)
- dist.y = -dist.y;
-
- _direction = (dist.x > dist.y) ? ((to.x > pos.x) ? WALK_LEFT : WALK_RIGHT) : ((to.y > pos.y) ? WALK_DOWN : WALK_UP);
- _ani->setF(frames->firstWalkFrame[_direction] + (_step / frames->frameRepeat[_direction]) % frames->numWalkFrames[_direction]);
-}
-
-
} // namespace Parallaction
diff --git a/engines/parallaction/parallaction.h b/engines/parallaction/parallaction.h
index f8e775c51f..d63b62cea4 100644
--- a/engines/parallaction/parallaction.h
+++ b/engines/parallaction/parallaction.h
@@ -166,6 +166,26 @@ public:
};
+class CharacterName {
+ const char *_prefix;
+ const char *_suffix;
+ bool _dummy;
+ char _name[30];
+ char _baseName[30];
+ char _fullName[30];
+ static const char _prefixMini[];
+ static const char _suffixTras[];
+ static const char _empty[];
+ void dummify();
+public:
+ CharacterName();
+ CharacterName(const char *name);
+ void bind(const char *name);
+ const char *getName() const;
+ const char *getBaseName() const;
+ const char *getFullName() const;
+ bool dummy() const;
+};
struct Character {
@@ -190,17 +210,7 @@ struct Character {
void free();
protected:
- const char *_prefix;
- const char *_suffix;
-
- bool _dummy;
-
- char _name[30];
- char _baseName[30];
- char _fullName[30];
- static const char _prefixMini[];
- static const char _suffixTras[];
- static const char _empty[];
+ CharacterName _name;
int16 _direction, _step;
@@ -408,6 +418,7 @@ private:
ZonePtr _moveSarcZones[5];
ZonePtr _moveSarcExaZones[5];
AnimationPtr _rightHandAnim;
+ bool _intro;
static const Callable _dosCallables[25];
static const Callable _amigaCallables[25];
diff --git a/engines/parallaction/parallaction_br.cpp b/engines/parallaction/parallaction_br.cpp
index 9c71303aeb..b7138cbba0 100644
--- a/engines/parallaction/parallaction_br.cpp
+++ b/engines/parallaction/parallaction_br.cpp
@@ -202,6 +202,8 @@ void Parallaction_br::cleanupGame() {
void Parallaction_br::changeLocation(char *location) {
char *partStr = strrchr(location, '.');
if (partStr) {
+ cleanupGame();
+
int n = partStr - location;
strncpy(_location._name, location, n);
_location._name[n] = '\0';
diff --git a/engines/parallaction/parallaction_ns.cpp b/engines/parallaction/parallaction_ns.cpp
index daa4975220..31b27c4d5f 100644
--- a/engines/parallaction/parallaction_ns.cpp
+++ b/engines/parallaction/parallaction_ns.cpp
@@ -186,6 +186,7 @@ Common::Error Parallaction_ns::init() {
num_foglie = 0;
+ _intro = false;
_inTestResult = false;
_location._animations.push_front(_char._ani);
@@ -296,11 +297,22 @@ void Parallaction_ns::changeLocation(char *location) {
_gfx->showGfxObj(_char._ani->gfxobj, false);
- freeLocation(false);
-
LocationName locname;
locname.bind(location);
+ bool fullCleanup = false;
+ if (locname.hasCharacter()) {
+ CharacterName newName(locname.character());
+ fullCleanup = (strcmp(newName.getBaseName(), _char.getBaseName()));
+ }
+
+ if (fullCleanup) {
+ cleanupGame();
+ } else {
+ freeLocation(false);
+ }
+
+
if (locname.hasSlide()) {
showSlide(locname.slide());
uint id = _gfx->createLabel(_menuFont, _location._slideText[0], 1);
@@ -346,7 +358,9 @@ void Parallaction_ns::changeLocation(char *location) {
if (_location._hasSound)
_soundMan->playSfx(_location._soundFile, 0, true);
- _input->setMouseState(oldMouseState);
+ if (!_intro) {
+ _input->setMouseState(oldMouseState);
+ }
debugC(1, kDebugExec, "changeLocation() done");
}