Moved more GfxObj management to Gfx object.
svn-id: r35466
This commit is contained in:
parent
74b251d45d
commit
e11c17a005
11 changed files with 81 additions and 68 deletions
|
@ -309,7 +309,7 @@ void DialogueManager::runQuestion() {
|
|||
debugC(9, kDebugDialogue, "runQuestion\n");
|
||||
|
||||
if (_mouseButtons == kMouseLeftUp) {
|
||||
_vm->hideDialogueStuff();
|
||||
_vm->_gfx->freeDialogueObjects();
|
||||
_state = NEXT_ANSWER;
|
||||
}
|
||||
|
||||
|
@ -347,7 +347,7 @@ void DialogueManager::runAnswer() {
|
|||
|
||||
if (_answerId != -1) {
|
||||
_cmdList = &_q->_answers[_answerId]->_commands;
|
||||
_vm->hideDialogueStuff();
|
||||
_vm->_gfx->freeDialogueObjects();
|
||||
_state = NEXT_QUESTION;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -103,6 +103,12 @@ GfxObj* Gfx::loadAnim(const char *name) {
|
|||
return obj;
|
||||
}
|
||||
|
||||
GfxObj* Gfx::loadCharacterAnim(const char *name) {
|
||||
GfxObj *obj = loadAnim(name);
|
||||
obj->setFlags(kGfxObjCharacter);
|
||||
obj->clearFlags(kGfxObjNormal);
|
||||
return obj;
|
||||
}
|
||||
|
||||
GfxObj* Gfx::loadGet(const char *name) {
|
||||
GfxObj *obj = _disk->loadStatic(name);
|
||||
|
@ -140,6 +146,18 @@ void Gfx::clearGfxObjects(uint filter) {
|
|||
|
||||
}
|
||||
|
||||
void Gfx::freeLocationObjects() {
|
||||
freeDialogueObjects();
|
||||
clearGfxObjects(kGfxObjNormal);
|
||||
freeLabels();
|
||||
}
|
||||
|
||||
void Gfx::freeCharacterObjects() {
|
||||
freeDialogueObjects();
|
||||
clearGfxObjects(kGfxObjCharacter);
|
||||
}
|
||||
|
||||
|
||||
void Gfx::loadGfxObjMask(const char *name, GfxObj *obj) {
|
||||
Common::Rect rect;
|
||||
obj->getRect(0, rect);
|
||||
|
|
|
@ -775,6 +775,11 @@ void Gfx::destroyBalloons() {
|
|||
_balloons.clear();
|
||||
}
|
||||
|
||||
void Gfx::freeDialogueObjects() {
|
||||
freeItems();
|
||||
_vm->_balloonMan->freeBalloons();
|
||||
}
|
||||
|
||||
void Gfx::freeItems() {
|
||||
_items.clear();
|
||||
}
|
||||
|
|
|
@ -507,6 +507,9 @@ public:
|
|||
GfxObj* loadAnim(const char *name);
|
||||
GfxObj* loadGet(const char *name);
|
||||
GfxObj* loadDoor(const char *name);
|
||||
GfxObj* loadCharacterAnim(const char *name);
|
||||
void freeCharacterObjects();
|
||||
void freeLocationObjects();
|
||||
void showGfxObj(GfxObj* obj, bool visible);
|
||||
void clearGfxObjects(uint filter);
|
||||
void sortScene();
|
||||
|
@ -526,6 +529,8 @@ public:
|
|||
GfxObj* registerBalloon(Frames *frames, const char *text);
|
||||
void destroyBalloons();
|
||||
|
||||
void freeDialogueObjects();
|
||||
|
||||
// other items
|
||||
int setItem(GfxObj* obj, uint16 x, uint16 y, byte transparentColor = 0);
|
||||
void setItemFrame(uint item, uint16 f);
|
||||
|
|
|
@ -160,7 +160,7 @@ class MainMenuInputState_BR : public MenuInputState {
|
|||
|
||||
void cleanup() {
|
||||
_vm->_system->showMouse(false);
|
||||
_vm->hideDialogueStuff();
|
||||
_vm->_gfx->freeDialogueObjects();
|
||||
|
||||
for (int i = 0; i < _availItems; i++) {
|
||||
delete _lines[i];
|
||||
|
|
|
@ -216,7 +216,7 @@ void InventoryRenderer::drawItem(ItemPosition pos, ItemName name) {
|
|||
}
|
||||
|
||||
void InventoryRenderer::drawItem(ItemName name, byte *buffer, uint pitch) {
|
||||
byte* s = _vm->_char._objs->getData(name);
|
||||
byte* s = _vm->_objects->getData(name);
|
||||
byte* d = buffer;
|
||||
for (uint i = 0; i < _props->_itemHeight; i++) {
|
||||
memcpy(d, s, _props->_itemWidth);
|
||||
|
|
|
@ -83,11 +83,10 @@ Parallaction::~Parallaction() {
|
|||
delete _programExec;
|
||||
delete _saveLoad;
|
||||
|
||||
_gfx->clearGfxObjects(kGfxObjCharacter | kGfxObjNormal);
|
||||
hideDialogueStuff();
|
||||
_gfx->freeCharacterObjects();
|
||||
_gfx->freeLocationObjects();
|
||||
delete _balloonMan;
|
||||
|
||||
freeCharacter();
|
||||
destroyInventory();
|
||||
|
||||
cleanupGui();
|
||||
|
@ -110,6 +109,7 @@ Common::Error Parallaction::init() {
|
|||
_location._startPosition.x = -1000;
|
||||
_location._startPosition.y = -1000;
|
||||
_location._startFrame = 0;
|
||||
_objects = 0;
|
||||
|
||||
_screenSize = _screenWidth * _screenHeight;
|
||||
|
||||
|
@ -173,25 +173,6 @@ void Parallaction::updateView() {
|
|||
}
|
||||
|
||||
|
||||
void Parallaction::hideDialogueStuff() {
|
||||
_gfx->freeItems();
|
||||
_balloonMan->freeBalloons();
|
||||
}
|
||||
|
||||
|
||||
void Parallaction::freeCharacter() {
|
||||
debugC(1, kDebugExec, "freeCharacter()");
|
||||
|
||||
delete _objectsNames;
|
||||
_objectsNames = 0;
|
||||
|
||||
_gfx->clearGfxObjects(kGfxObjCharacter);
|
||||
|
||||
_char.free();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void Parallaction::pauseJobs() {
|
||||
debugC(9, kDebugExec, "pausing jobs execution");
|
||||
|
@ -571,7 +552,7 @@ void Parallaction::enterCommentMode(ZonePtr z) {
|
|||
void Parallaction::exitCommentMode() {
|
||||
_input->_inputMode = Input::kInputModeGame;
|
||||
|
||||
hideDialogueStuff();
|
||||
_gfx->freeDialogueObjects();
|
||||
_gfx->setHalfbriteMode(false);
|
||||
|
||||
_cmdExec->run(_commentZone->_commands, _commentZone);
|
||||
|
@ -848,7 +829,6 @@ WalkFrames _char24WalkFrames = {
|
|||
Character::Character(Parallaction *vm) : _vm(vm), _ani(new Animation) {
|
||||
_talk = NULL;
|
||||
_head = NULL;
|
||||
_objs = NULL;
|
||||
|
||||
_direction = WALK_DOWN;
|
||||
_step = 0;
|
||||
|
@ -877,8 +857,6 @@ Character::~Character() {
|
|||
|
||||
delete _walker;
|
||||
_walker = 0;
|
||||
|
||||
free();
|
||||
}
|
||||
|
||||
void Character::getFoot(Common::Point &foot) {
|
||||
|
@ -918,21 +896,6 @@ void Character::scheduleWalk(int16 x, int16 y) {
|
|||
_engineFlags |= kEngineWalking;
|
||||
}
|
||||
|
||||
void Character::free() {
|
||||
|
||||
delete _talk;
|
||||
delete _head;
|
||||
delete _objs;
|
||||
delete _ani->gfxobj;
|
||||
|
||||
_talk = NULL;
|
||||
_head = NULL;
|
||||
_objs = NULL;
|
||||
_ani->gfxobj = NULL;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void Character::setName(const char *name) {
|
||||
_name.bind(name);
|
||||
|
|
|
@ -198,7 +198,6 @@ struct Character {
|
|||
AnimationPtr _ani;
|
||||
GfxObj *_head;
|
||||
GfxObj *_talk;
|
||||
GfxObj *_objs;
|
||||
PathBuilder *_builder;
|
||||
PathWalker *_walker;
|
||||
PointList _walkPath;
|
||||
|
@ -210,8 +209,6 @@ struct Character {
|
|||
void setFoot(const Common::Point &foot);
|
||||
void scheduleWalk(int16 x, int16 y);
|
||||
|
||||
void free();
|
||||
|
||||
protected:
|
||||
CharacterName _name;
|
||||
|
||||
|
@ -281,6 +278,7 @@ public:
|
|||
// game utilities
|
||||
Table *_globalFlagsNames;
|
||||
Table *_objectsNames;
|
||||
GfxObj *_objects;
|
||||
Table *_callableNames;
|
||||
Table *_localFlagNames;
|
||||
CommandExec *_cmdExec;
|
||||
|
@ -314,7 +312,6 @@ protected:
|
|||
void exitCommentMode();
|
||||
void updateView();
|
||||
void drawAnimations();
|
||||
void freeCharacter();
|
||||
void doLocationEnterTransition();
|
||||
void allocateLocationSlot(const char *name);
|
||||
void finalizeLocationParsing();
|
||||
|
@ -325,7 +322,6 @@ public:
|
|||
void beep();
|
||||
void pauseJobs();
|
||||
void resumeJobs();
|
||||
void hideDialogueStuff();
|
||||
uint getInternLanguage();
|
||||
void setInternLanguage(uint id);
|
||||
void enterDialogueMode(ZonePtr z);
|
||||
|
@ -388,7 +384,6 @@ public:
|
|||
virtual void runPendingZones();
|
||||
virtual void cleanupGame();
|
||||
|
||||
|
||||
void switchBackground(const char* background, const char* mask);
|
||||
|
||||
private:
|
||||
|
@ -405,6 +400,7 @@ private:
|
|||
void startEndPartSequence();
|
||||
void loadProgram(AnimationPtr a, const char *filename);
|
||||
void freeLocation(bool removeAll);
|
||||
void freeCharacter();
|
||||
|
||||
|
||||
// callables data
|
||||
|
@ -478,7 +474,6 @@ public:
|
|||
virtual void runPendingZones();
|
||||
virtual void cleanupGame();
|
||||
|
||||
|
||||
void setupSubtitles(char *s, char *s2, int y);
|
||||
void clearSubtitles();
|
||||
|
||||
|
@ -509,6 +504,7 @@ private:
|
|||
void freeLocation(bool removeAll);
|
||||
void loadProgram(AnimationPtr a, const char *filename);
|
||||
void startGui(bool showSplash);
|
||||
void freeCharacter();
|
||||
|
||||
typedef void (Parallaction_br::*Callable)(void*);
|
||||
const Callable *_callables;
|
||||
|
|
|
@ -100,6 +100,7 @@ Common::Error Parallaction_br::init() {
|
|||
|
||||
Parallaction_br::~Parallaction_br() {
|
||||
freeFonts();
|
||||
freeCharacter();
|
||||
|
||||
delete _locationParser;
|
||||
delete _programParser;
|
||||
|
@ -178,14 +179,24 @@ void Parallaction_br::runPendingZones() {
|
|||
}
|
||||
}
|
||||
|
||||
void Parallaction_br::freeCharacter() {
|
||||
_gfx->freeCharacterObjects();
|
||||
|
||||
delete _char._talk;
|
||||
delete _char._ani->gfxobj;
|
||||
|
||||
_char._talk = 0;
|
||||
_char._ani->gfxobj = 0;
|
||||
}
|
||||
|
||||
void Parallaction_br::freeLocation(bool removeAll) {
|
||||
|
||||
// free open location stuff
|
||||
clearSubtitles();
|
||||
_gfx->clearGfxObjects(kGfxObjNormal);
|
||||
_gfx->freeLabels();
|
||||
_subtitle[0] = _subtitle[1] = -1;
|
||||
|
||||
_gfx->freeLocationObjects();
|
||||
|
||||
_location._animations.remove(_char._ani);
|
||||
_location.cleanup(removeAll);
|
||||
_location._animations.push_front(_char._ani);
|
||||
|
@ -195,7 +206,7 @@ void Parallaction_br::freeLocation(bool removeAll) {
|
|||
void Parallaction_br::cleanupGame() {
|
||||
freeLocation(true);
|
||||
|
||||
// freeCharacter();
|
||||
freeCharacter();
|
||||
|
||||
delete _globalFlagsNames;
|
||||
delete _objectsNames;
|
||||
|
@ -233,9 +244,9 @@ void Parallaction_br::changeLocation(char *location) {
|
|||
|
||||
// TODO: maybe handle this into Disk
|
||||
if (getPlatform() == Common::kPlatformPC) {
|
||||
_char._objs = _disk->loadObjects("icone.ico");
|
||||
_objects = _disk->loadObjects("icone.ico");
|
||||
} else {
|
||||
_char._objs = _disk->loadObjects("icons.ico");
|
||||
_objects = _disk->loadObjects("icons.ico");
|
||||
}
|
||||
|
||||
parseLocation("common.slf");
|
||||
|
@ -299,15 +310,16 @@ void Parallaction_br::loadProgram(AnimationPtr a, const char *filename) {
|
|||
|
||||
|
||||
void Parallaction_br::changeCharacter(const char *name) {
|
||||
|
||||
const char *charName = _char.getName();
|
||||
|
||||
if (scumm_stricmp(charName, name)) {
|
||||
freeCharacter();
|
||||
|
||||
debugC(1, kDebugExec, "changeCharacter(%s)", name);
|
||||
|
||||
_char.setName(name);
|
||||
_char._ani->gfxobj = _gfx->loadAnim(name);
|
||||
_char._ani->gfxobj->setFlags(kGfxObjCharacter);
|
||||
_char._ani->gfxobj->clearFlags(kGfxObjNormal);
|
||||
_char._ani->gfxobj = _gfx->loadCharacterAnim(name);
|
||||
_char._talk = _disk->loadTalk(name);
|
||||
}
|
||||
|
||||
|
|
|
@ -202,13 +202,13 @@ Common::Error Parallaction_ns::init() {
|
|||
|
||||
Parallaction_ns::~Parallaction_ns() {
|
||||
freeFonts();
|
||||
freeCharacter();
|
||||
|
||||
delete _locationParser;
|
||||
delete _programParser;
|
||||
freeLocation(true);
|
||||
|
||||
_location._animations.remove(_char._ani);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -405,18 +405,14 @@ void Parallaction_ns::changeCharacter(const char *name) {
|
|||
return;
|
||||
}
|
||||
|
||||
// freeCharacter takes responsibility for checking
|
||||
// character for sanity before memory is freed
|
||||
freeCharacter();
|
||||
|
||||
_char._ani->gfxobj = _gfx->loadAnim(_char.getFullName());
|
||||
_char._ani->gfxobj->setFlags(kGfxObjCharacter);
|
||||
_char._ani->gfxobj->clearFlags(kGfxObjNormal);
|
||||
_char._ani->gfxobj = _gfx->loadCharacterAnim(_char.getFullName());
|
||||
|
||||
if (!_char.dummy()) {
|
||||
_char._head = _disk->loadHead(_char.getBaseName());
|
||||
_char._talk = _disk->loadTalk(_char.getBaseName());
|
||||
_char._objs = _disk->loadObjects(_char.getBaseName());
|
||||
_objects = _disk->loadObjects(_char.getBaseName());
|
||||
_objectsNames = _disk->loadTable(_char.getBaseName());
|
||||
|
||||
_soundMan->playCharacterMusic(_char.getBaseName());
|
||||
|
@ -437,6 +433,23 @@ void Parallaction_ns::changeCharacter(const char *name) {
|
|||
return;
|
||||
}
|
||||
|
||||
void Parallaction_ns::freeCharacter() {
|
||||
_gfx->freeCharacterObjects();
|
||||
|
||||
delete _char._talk;
|
||||
delete _char._head;
|
||||
delete _char._ani->gfxobj;
|
||||
delete _objects;
|
||||
delete _objectsNames;
|
||||
|
||||
_char._talk = 0;
|
||||
_char._head = 0;
|
||||
_char._ani->gfxobj = 0;
|
||||
|
||||
_objects = 0;
|
||||
_objectsNames = 0;
|
||||
}
|
||||
|
||||
void Parallaction_ns::freeLocation(bool removeAll) {
|
||||
debugC(2, kDebugExec, "freeLocation");
|
||||
|
||||
|
@ -447,7 +460,7 @@ void Parallaction_ns::freeLocation(bool removeAll) {
|
|||
|
||||
_localFlagNames->clear();
|
||||
|
||||
_gfx->clearGfxObjects(kGfxObjNormal);
|
||||
_gfx->freeLocationObjects();
|
||||
|
||||
_location._animations.remove(_char._ani);
|
||||
_location.cleanup(removeAll);
|
||||
|
|
|
@ -190,6 +190,7 @@ protected:
|
|||
Dialogue *parseDialogue();
|
||||
void resolveDialogueForwards(Dialogue *dialogue, uint numQuestions, Table &forwards);
|
||||
Answer *parseAnswer();
|
||||
void parseAnswerVariants(Answer *answer);
|
||||
Question *parseQuestion();
|
||||
|
||||
void parseZone(ZoneList &list, char *name);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue