added the instance of EventManager returned by OSystem::getEventManager as a member of the Engine base class. This allows to simply the code a bit and should more efficient too (ie. less virtual function chain calls, obj->getA()->getB()). Also updated several engines to make use of it.

svn-id: r26357
This commit is contained in:
Gregory Montoir 2007-04-01 17:36:13 +00:00
parent 852971cfe6
commit 5aca9dce8c
17 changed files with 23 additions and 36 deletions

View File

@ -61,8 +61,7 @@ void AgiEngine::processEvents() {
Common::Event event;
int key = 0;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_QUIT:
_gfx->deinitVideo();

View File

@ -309,7 +309,7 @@ void AGOSEngine::handleMouseMoved() {
}
CursorMan.showMouse(true);
_mouse = _system->getEventManager()->getMousePos();
_mouse = _eventMan->getMousePos();
if (_defaultVerb) {
uint id = 101;

View File

@ -332,8 +332,7 @@ void AGOSEngine::delay(uint amount) {
_inCallBack = false;
}
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode >= '0' && event.kbd.keycode <='9'

View File

@ -48,6 +48,7 @@ Engine::Engine(OSystem *syst)
: _system(syst),
_mixer(_system->getMixer()),
_timer(_system->getTimerManager()),
_eventMan(_system->getEventManager()),
_saveFileMan(_system->getSavefileManager()),
_targetName(ConfMan.getActiveDomainName()),
_gameDataPath(ConfMan.get("path")) {

View File

@ -31,6 +31,7 @@ namespace Audio {
class Mixer;
}
namespace Common {
class EventManager;
class SaveFileManager;
class TimerManager;
}
@ -45,6 +46,7 @@ public:
Common::TimerManager * _timer;
protected:
Common::EventManager *_eventMan;
Common::SaveFileManager *_saveFileMan;
const Common::String _targetName; // target name for saves

View File

@ -811,8 +811,7 @@ void KyraEngine::gui_getInput() {
uint32 now = _system->getMillis();
_mouseWheel = 0;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_QUIT:
quitGame();
@ -1487,8 +1486,7 @@ void KyraEngine::gui_updateMainMenuAnimation() {
bool KyraEngine::gui_mainMenuGetInput() {
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_QUIT:
quitGame();

View File

@ -608,8 +608,7 @@ void KyraEngine::delay(uint32 amount, bool update, bool isMainLoop) {
uint32 start = _system->getMillis();
do {
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode >= '1' && event.kbd.keycode <= '9' &&
@ -690,7 +689,7 @@ void KyraEngine::delay(uint32 amount, bool update, bool isMainLoop) {
}
Common::Point KyraEngine::getMousePos() const {
Common::Point mouse = g_system->getEventManager()->getMousePos();
Common::Point mouse = _eventMan->getMousePos();
if (_flags.useHiResOverlay) {
mouse.x >>= 1;
mouse.y >>= 1;
@ -702,8 +701,7 @@ void KyraEngine::waitForEvent() {
bool finished = false;
Common::Event event;
while (!finished && !_quitFlag) {
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
finished = true;

View File

@ -1171,8 +1171,7 @@ void KyraEngine::seq_playCredits() {
_screen->updateScreen();
}
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
finished = true;

View File

@ -118,8 +118,7 @@ void KyraEngine::waitForChatToFinish(int vocFile, int16 chatDuration, const char
uint32 nextTime = loopStart + _tickLength;
while (_system->getMillis() < nextTime) {
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
if (event.kbd.keycode == '.')

View File

@ -40,8 +40,7 @@ namespace Saga {
int SagaEngine::processInput() {
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
if (event.kbd.flags == Common::KBD_CTRL) {
@ -153,7 +152,7 @@ int SagaEngine::processInput() {
}
Point SagaEngine::mousePos() const {
return _system->getEventManager()->getMousePos();
return _eventMan->getMousePos();
}
} // End of namespace Saga

View File

@ -57,8 +57,7 @@ enum MouseButtonStatus {
void ScummEngine::parseEvents() {
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:

View File

@ -851,8 +851,7 @@ int ScummEngine_vCUPhe::go() {
void ScummEngine_vCUPhe::parseEvents() {
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_QUIT:
_quit = true;

View File

@ -511,7 +511,6 @@ void SkyEngine::gotTimerTick(void) {
void SkyEngine::delay(int32 amount) {
Common::EventManager *eventMan = _system->getEventManager();
Common::Event event;
uint32 start = _system->getMillis();
@ -521,7 +520,7 @@ void SkyEngine::delay(int32 amount) {
amount = 0;
do {
while (eventMan->pollEvent(event)) {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
_keyFlags = event.kbd.flags;

View File

@ -706,8 +706,7 @@ void SwordEngine::delay(int32 amount) { //copied and mutilated from sky.cpp
uint32 start = _system->getMillis();
do {
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
// Make sure backspace works right (this fixes a small issue on OS X)

View File

@ -534,8 +534,7 @@ uint32 Sword2Engine::setInputEventFilter(uint32 filter) {
void Sword2Engine::parseInputEvents() {
Common::Event event;
Common::EventManager *eventMan = _system->getEventManager();
while (eventMan->pollEvent(event)) {
while (_eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
if (event.kbd.flags == Common::KBD_CTRL) {

View File

@ -237,10 +237,8 @@ void ToucheEngine::writeConfigurationSettings() {
ConfMan.flushToDisk();
}
Common::Point ToucheEngine::getMousePos() {
Common::EventManager *eventMan = _system->getEventManager();
return eventMan->getMousePos();
Common::Point ToucheEngine::getMousePos() const {
return _eventMan->getMousePos();
}
void ToucheEngine::mainLoop() {

View File

@ -611,7 +611,7 @@ protected:
int displayQuitDialog();
void displayTextMode(int str);
Common::Point getMousePos();
Common::Point getMousePos() const;
MidiPlayer *_midiPlayer;