CGE: Move 4 global to CGEEngine

This commit is contained in:
Strangerke 2011-09-17 10:08:24 +02:00
parent fba3fc3602
commit f5eca79658
6 changed files with 33 additions and 34 deletions

View File

@ -42,6 +42,9 @@ class Console;
class Sprite;
class Cluster;
class Vga;
class System;
class Keyboard;
class Mouse;
#define kSavegameVersion 2
#define kSavegameStrSize 11
@ -157,6 +160,10 @@ public:
Bar _barriers[kSceneMax + 1];
Font *_font;
Vga *_vga;
System *_sys;
Sprite *_pocLight;
Keyboard *_keyboard;
Mouse *_mouse;
Common::RandomSource _randomSource;
MusicPlayer _midiPlayer;

View File

@ -52,11 +52,7 @@ namespace CGE {
uint16 _stklen = (kStackSize * 2);
System *_sys;
Sprite *_pocLight;
EventManager *_eventManager;
Keyboard *_keyboard;
Mouse *_mouse;
Sprite *_pocket[kPocketNX];
Sprite *_sprite;
Sprite *_miniScene;
@ -784,7 +780,7 @@ void System::touch(uint16 mask, int x, int y) {
}
switch (x) {
case 'X':
if (_keyboard->_key[kKeyAlt])
if (_vm->_keyboard->_key[kKeyAlt])
_vm->quit();
break;
case '0':
@ -792,7 +788,7 @@ void System::touch(uint16 mask, int x, int y) {
case '2':
case '3':
case '4':
if (_keyboard->_key[kKeyAlt]) {
if (_vm->_keyboard->_key[kKeyAlt]) {
_snail->addCom(kSnLevel, -1, x - '0', NULL);
break;
}
@ -945,7 +941,7 @@ void CGEEngine::optionTouch(int opt, uint16 mask) {
#pragma argsused
void Sprite::touch(uint16 mask, int x, int y) {
_sys->funTouch();
_vm->_sys->funTouch();
if ((mask & kEventAttn) != 0)
return;
@ -970,7 +966,7 @@ void Sprite::touch(uint16 mask, int x, int y) {
}
if ((mask & kMouseRightUp) && _snail->idle()) {
Sprite *ps = (_pocLight->_seqPtr) ? _pocket[_vm->_pocPtr] : NULL;
Sprite *ps = (_vm->_pocLight->_seqPtr) ? _pocket[_vm->_pocPtr] : NULL;
if (ps) {
if (_flags._kept || _hero->distance(this) < kDistMax) {
if (works(ps)) {

View File

@ -109,10 +109,6 @@ private:
CGEEngine *_vm;
};
extern System *_sys;
extern Sprite *_pocLight;
extern Keyboard *_keyboard;
extern Mouse *_mouse;
extern EventManager *_eventManager;
extern Sprite *_pocket[];
extern Sprite *_sprite;

View File

@ -289,7 +289,7 @@ void EventManager::poll() {
case Common::EVENT_KEYDOWN:
case Common::EVENT_KEYUP:
// Handle keyboard events
_keyboard->newKeyboard(_event);
_vm->_keyboard->newKeyboard(_event);
handleEvents();
break;
case Common::EVENT_MOUSEMOVE:
@ -298,7 +298,7 @@ void EventManager::poll() {
case Common::EVENT_RBUTTONDOWN:
case Common::EVENT_RBUTTONUP:
// Handle mouse events
_mouse->newMouse(_event);
_vm->_mouse->newMouse(_event);
handleEvents();
break;
default:
@ -311,12 +311,12 @@ void EventManager::handleEvents() {
while (_eventQueueTail != _eventQueueHead) {
CGEEvent e = _eventQueue[_eventQueueTail];
if (e._mask) {
if (_mouse->_hold && e._spritePtr != _mouse->_hold)
_mouse->_hold->touch(e._mask | kEventAttn, e._x - _mouse->_hold->_x, e._y - _mouse->_hold->_y);
if (_vm->_mouse->_hold && e._spritePtr != _vm->_mouse->_hold)
_vm->_mouse->_hold->touch(e._mask | kEventAttn, e._x - _vm->_mouse->_hold->_x, e._y - _vm->_mouse->_hold->_y);
// update mouse cursor position
if (e._mask & kMouseRoll)
_mouse->gotoxy(e._x, e._y);
_vm->_mouse->gotoxy(e._x, e._y);
// activate current touched SPRITE
if (e._spritePtr) {
@ -324,25 +324,25 @@ void EventManager::handleEvents() {
e._spritePtr->touch(e._mask, e._x, e._y);
else
e._spritePtr->touch(e._mask, e._x - e._spritePtr->_x, e._y - e._spritePtr->_y);
} else if (_sys)
_sys->touch(e._mask, e._x, e._y);
} else if (_vm->_sys)
_vm->_sys->touch(e._mask, e._x, e._y);
if (e._mask & kMouseLeftDown) {
_mouse->_hold = e._spritePtr;
if (_mouse->_hold) {
_mouse->_hold->_flags._hold = true;
_vm->_mouse->_hold = e._spritePtr;
if (_vm->_mouse->_hold) {
_vm->_mouse->_hold->_flags._hold = true;
if (_mouse->_hold->_flags._drag) {
_mouse->_hx = e._x - _mouse->_hold->_x;
_mouse->_hy = e._y - _mouse->_hold->_y;
if (_vm->_mouse->_hold->_flags._drag) {
_vm->_mouse->_hx = e._x - _vm->_mouse->_hold->_x;
_vm->_mouse->_hy = e._y - _vm->_mouse->_hold->_y;
}
}
}
if (e._mask & kMouseLeftUp) {
if (_mouse->_hold) {
_mouse->_hold->_flags._hold = false;
_mouse->_hold = NULL;
if (_vm->_mouse->_hold) {
_vm->_mouse->_hold->_flags._hold = false;
_vm->_mouse->_hold = NULL;
}
}
///Touched = e.Ptr;
@ -353,9 +353,9 @@ void EventManager::handleEvents() {
}
_eventQueueTail = (_eventQueueTail + 1) % kEventMax;
}
if (_mouse->_hold) {
if (_mouse->_hold->_flags._drag)
_mouse->_hold->gotoxy(_mouse->_x - _mouse->_hx, _mouse->_y - _mouse->_hy);
if (_vm->_mouse->_hold) {
if (_vm->_mouse->_hold->_flags._drag)
_vm->_mouse->_hold->gotoxy(_vm->_mouse->_x - _vm->_mouse->_hx, _vm->_mouse->_y - _vm->_mouse->_hy);
}
}

View File

@ -995,13 +995,13 @@ void Snail::runCom() {
if (spr == _hero && spr->seqTest(-1))
spr->step(kSeqHTalk);
_text->say(_text->getText(snc->_val), spr);
_sys->_funDel = kHeroFun0;
_vm->_sys->_funDel = kHeroFun0;
}
break;
case kSnInf:
if (_talkEnable) {
_vm->inf(_text->getText(snc->_val));
_sys->_funDel = kHeroFun0;
_vm->_sys->_funDel = kHeroFun0;
}
break;
case kSnTime:

View File

@ -58,7 +58,7 @@ void Walk::tick() {
_here = _vm->XZ(_x + _w / 2, _y + _h);
if (_dir != kDirNone) {
_sys->funTouch();
_vm->_sys->funTouch();
for (Sprite *spr = _vm->_vga->_showQ->first(); spr; spr = spr->_next) {
if (distance(spr) < 2) {
if (!spr->_flags._near) {