Skip to content

Commit

Permalink
CGE: Move _talk and _text to CGEEngine
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Sep 17, 2011
1 parent 3583c94 commit d574cfe
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 25 deletions.
1 change: 1 addition & 0 deletions engines/cge/cge.cpp
Expand Up @@ -90,6 +90,7 @@ void CGEEngine::init() {
// Initialise engine objects
_font = new Font(this, "CGE");
_text = new Text(this, "CGE");
_talk = NULL;
_vga = new Vga();
_sys = new System(this);
_pocLight = new PocLight(this);
Expand Down
5 changes: 5 additions & 0 deletions engines/cge/cge.h
Expand Up @@ -52,6 +52,8 @@ class Snail;
class EventManager;
class ResourceManager;
class Walk;
class Text;
class Talk;

#define kSavegameVersion 2
#define kSavegameStrSize 11
Expand Down Expand Up @@ -189,6 +191,9 @@ class CGEEngine : public Engine {
ResourceManager *_resman;
Sprite *_pocket[kPocketNX];
Walk *_hero;
Text *_text;
Talk *_talk;


Common::RandomSource _randomSource;
MusicPlayer *_midiPlayer;
Expand Down
4 changes: 2 additions & 2 deletions engines/cge/cge_main.cpp
Expand Up @@ -745,7 +745,7 @@ void System::setPal() {

void System::funTouch() {
uint16 n = (_vm->_flag[0]) ? kHeroFun1 : kHeroFun0; // PAIN flag
if (_talk == NULL || n > _funDel)
if (_vm->_talk == NULL || n > _funDel)
_funDel = n;
}

Expand Down Expand Up @@ -814,7 +814,7 @@ void System::touch(uint16 mask, int x, int y) {
_vm->setMapBrick(x1, z1);
}
} else {
if (!_talk && _vm->_snail->idle() && _vm->_hero
if (!_vm->_talk && _vm->_snail->idle() && _vm->_hero
&& y >= kMapTop && y < kMapTop + kMapHig && !_vm->_game) {
_vm->_hero->findWay(_vm->XZ(x, y));
}
Expand Down
2 changes: 0 additions & 2 deletions engines/cge/events.h
Expand Up @@ -102,8 +102,6 @@ class Keyboard {

/*----------------- MOUSE interface -----------------*/

extern Talk *_talk;

struct CGEEvent {
uint16 _mask;
uint16 _x;
Expand Down
10 changes: 5 additions & 5 deletions engines/cge/snail.cpp
Expand Up @@ -960,7 +960,7 @@ void Snail::runCom() {
_textDelay = false;
}
}
if (_talk && snc->_com != kSnPause)
if (_vm->_talk && snc->_com != kSnPause)
break;
}

Expand All @@ -970,7 +970,7 @@ void Snail::runCom() {
break;
case kSnPause :
_timerExpiry = g_system->getMillis() + snc->_val * kSnailFrameDelay;
if (_talk)
if (_vm->_talk)
_textDelay = true;
break;
case kSnWait:
Expand All @@ -994,21 +994,21 @@ void Snail::runCom() {
if (spr && _talkEnable) {
if (spr == _vm->_hero && spr->seqTest(-1))
spr->step(kSeqHTalk);
_text->say(_text->getText(snc->_val), spr);
_vm->_text->say(_vm->_text->getText(snc->_val), spr);
_vm->_sys->_funDel = kHeroFun0;
}
break;
case kSnInf:
if (_talkEnable) {
_vm->inf(_text->getText(snc->_val));
_vm->inf(_vm->_text->getText(snc->_val));
_vm->_sys->_funDel = kHeroFun0;
}
break;
case kSnTime:
if (spr && _talkEnable) {
if (spr == _vm->_hero && spr->seqTest(-1))
spr->step(kSeqHTalk);
_text->sayTime(spr);
_vm->_text->sayTime(spr);
}
break;
case kSnCave:
Expand Down
25 changes: 11 additions & 14 deletions engines/cge/text.cpp
Expand Up @@ -35,9 +35,6 @@

namespace CGE {

Text *_text;
Talk *_talk = NULL;

Text::Text(CGEEngine *vm, const char *fname) : _vm(vm) {
_vm->mergeExt(_fileName, fname, kSayExt);
if (!_vm->_resman->exist(_fileName))
Expand Down Expand Up @@ -138,8 +135,8 @@ char *Text::getText(int ref) {

void Text::say(const char *text, Sprite *spr) {
_vm->killText();
_talk = new Talk(_vm, text, kTBRound);
if (!_talk)
_vm->_talk = new Talk(_vm, text, kTBRound);
if (!_vm->_talk)
return;

bool east = spr->_flags._east;
Expand All @@ -159,22 +156,22 @@ void Text::say(const char *text, Sprite *spr) {
if (spr->_ref == 1)
x += ((east) ? -10 : 10); // Hero

_talk->_flags._kill = true;
_talk->_flags._bDel = true;
_talk->setName(_text->getText(kSayName));
_talk->gotoxy(x - (_talk->_w - sw) / 2 - 3 + 6 * east, y - spike->_h - _talk->_h + 1);
_talk->_z = 125;
_talk->_ref = kSayRef;
_vm->_talk->_flags._kill = true;
_vm->_talk->_flags._bDel = true;
_vm->_talk->setName(_vm->_text->getText(kSayName));
_vm->_talk->gotoxy(x - (_vm->_talk->_w - sw) / 2 - 3 + 6 * east, y - spike->_h - _vm->_talk->_h + 1);
_vm->_talk->_z = 125;
_vm->_talk->_ref = kSayRef;

spike->gotoxy(x, _talk->_y + _talk->_h - 1);
spike->gotoxy(x, _vm->_talk->_y + _vm->_talk->_h - 1);
spike->_z = 126;
spike->_flags._slav = true;
spike->_flags._kill = true;
spike->setName(_text->getText(kSayName));
spike->setName(_vm->_text->getText(kSayName));
spike->step(east);
spike->_ref = kSayRef;

_vm->_vga->_showQ->insert(_talk, _vm->_vga->_showQ->last());
_vm->_vga->_showQ->insert(_vm->_talk, _vm->_vga->_showQ->last());
_vm->_vga->_showQ->insert(spike, _vm->_vga->_showQ->last());
}

Expand Down
2 changes: 0 additions & 2 deletions engines/cge/text.h
Expand Up @@ -61,8 +61,6 @@ class Text {
CGEEngine *_vm;
};

extern Text *_text;

} // End of namespace CGE

#endif

0 comments on commit d574cfe

Please sign in to comment.