ASYLUM: Added a hack to stop the crashing with the credits icon animation (a limitation of the current resource manager) and moved the menu update code to a separate function
git-svn-id: http://asylumengine.googlecode.com/svn/trunk@72 0bfb4aae-4ea4-11de-8d8d-752d95cf3e3c
This commit is contained in:
parent
f077b4f1e7
commit
7fa648f9a3
2 changed files with 118 additions and 103 deletions
|
@ -93,11 +93,10 @@ Common::Error AsylumEngine::init() {
|
|||
}
|
||||
|
||||
Common::Error AsylumEngine::go() {
|
||||
int mouseX = 0, mouseY = 0;
|
||||
Audio::SoundHandle sfxHandle;
|
||||
int activeIcon = -1;
|
||||
int previousActiveIcon = -1;
|
||||
int curIconFrame = 0;
|
||||
_mouseX = 0, _mouseY = 0;
|
||||
_activeIcon = -1;
|
||||
_previousActiveIcon = -1;
|
||||
_curIconFrame = 0;
|
||||
|
||||
// Play intro movie
|
||||
// Disabled for quick testing
|
||||
|
@ -133,107 +132,12 @@ Common::Error AsylumEngine::go() {
|
|||
}
|
||||
//if (ev.kbd.keycode == Common::KEYCODE_RETURN)
|
||||
} else if (ev.type == Common::EVENT_MOUSEMOVE) {
|
||||
mouseX = ev.mouse.x;
|
||||
mouseY = ev.mouse.y;
|
||||
_mouseX = ev.mouse.x;
|
||||
_mouseY = ev.mouse.y;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Just some proof-of concept to change icons here for now
|
||||
if (mouseY >= 20 && mouseY <= 20 + 48) {
|
||||
// Top row
|
||||
for (int i = 0; i <= 5; i++) {
|
||||
int curX = 40 + i * 100;
|
||||
if (mouseX >= curX && mouseX <= curX + 55) {
|
||||
GraphicResource *res = _resMgr->getGraphic(1, i + 4, curIconFrame);
|
||||
_system->copyRectToScreen(res->data, res->width, curX, 20, res->width, res->height);
|
||||
|
||||
// Cycle icon frame
|
||||
// Icon animations have 15 frames, 0-14
|
||||
// FIXME: icon animations are way too quick
|
||||
curIconFrame++;
|
||||
if (curIconFrame == 15)
|
||||
curIconFrame = 0;
|
||||
|
||||
activeIcon = i;
|
||||
|
||||
// Play creepy voice
|
||||
if (!_mixer->isSoundHandleActive(sfxHandle) && activeIcon != previousActiveIcon) {
|
||||
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &sfxHandle, _resMgr->loadSFX(1, i + 44));
|
||||
previousActiveIcon = activeIcon;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (mouseY >= 400 && mouseY <= 400 + 48) {
|
||||
// Bottom row
|
||||
for (int i = 0; i <= 5; i++) {
|
||||
int curX = 40 + i * 100;
|
||||
if (mouseX >= curX && mouseX <= curX + 55) {
|
||||
int iconNum = i + 10;
|
||||
|
||||
// The last 2 icons are swapped
|
||||
if (iconNum == 14)
|
||||
iconNum = 15;
|
||||
else if (iconNum == 15)
|
||||
iconNum = 14;
|
||||
|
||||
GraphicResource *res = _resMgr->getGraphic(1, iconNum, curIconFrame);
|
||||
_system->copyRectToScreen(res->data, res->width, curX, 400, res->width, res->height);
|
||||
|
||||
// Cycle icon frame
|
||||
// Icon animations have 15 frames, 0-14
|
||||
// FIXME: icon animations are way too quick
|
||||
curIconFrame++;
|
||||
if (curIconFrame == 15)
|
||||
curIconFrame = 0;
|
||||
|
||||
activeIcon = i + 6;
|
||||
|
||||
// Play creepy voice
|
||||
if (!_mixer->isSoundHandleActive(sfxHandle) && activeIcon != previousActiveIcon) {
|
||||
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &sfxHandle, _resMgr->loadSFX(1, iconNum + 40));
|
||||
previousActiveIcon = activeIcon;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// No selection
|
||||
previousActiveIcon = activeIcon = -1;
|
||||
}
|
||||
|
||||
// Eyes animation
|
||||
// Get the appropriate eye resource depending on the mouse position
|
||||
int eyeResource = kEyesFront;
|
||||
|
||||
if (mouseX <= 200) {
|
||||
if (mouseY <= 160)
|
||||
eyeResource = kEyesTopLeft;
|
||||
else if (mouseY > 160 && mouseY <= 320)
|
||||
eyeResource = kEyesLeft;
|
||||
else
|
||||
eyeResource = kEyesBottomLeft;
|
||||
} else if (mouseX > 200 && mouseX <= 400) {
|
||||
if (mouseY <= 160)
|
||||
eyeResource = kEyesTop;
|
||||
else if (mouseY > 160 && mouseY <= 320)
|
||||
eyeResource = kEyesFront;
|
||||
else
|
||||
eyeResource = kEyesBottom;
|
||||
} else if (mouseX > 400) {
|
||||
if (mouseY <= 160)
|
||||
eyeResource = kEyesTopRight;
|
||||
else if (mouseY > 160 && mouseY <= 320)
|
||||
eyeResource = kEyesRight;
|
||||
else
|
||||
eyeResource = kEyesBottomRight;
|
||||
}
|
||||
// TODO: kEyesCrossed state
|
||||
|
||||
GraphicResource *res = _resMgr->getGraphic(1, 1, eyeResource);
|
||||
copyRectToScreenWithTransparency(res->data, 265, 230, res->width, res->height);
|
||||
updateMainMenu();
|
||||
|
||||
if (_system->getMillis() - lastUpdate > 50) {
|
||||
_system->updateScreen();
|
||||
|
@ -254,6 +158,110 @@ void AsylumEngine::showMainMenu() {
|
|||
_resMgr->loadMusic();
|
||||
}
|
||||
|
||||
void AsylumEngine::updateMainMenu() {
|
||||
// TODO: Just some proof-of concept to change icons here for now
|
||||
if (_mouseY >= 20 && _mouseY <= 20 + 48) {
|
||||
// Top row
|
||||
for (int i = 0; i <= 5; i++) {
|
||||
int curX = 40 + i * 100;
|
||||
if (_mouseX >= curX && _mouseX <= curX + 55) {
|
||||
GraphicResource *res = _resMgr->getGraphic(1, i + 4, _curIconFrame);
|
||||
_system->copyRectToScreen(res->data, res->width, curX, 20, res->width, res->height);
|
||||
|
||||
// Cycle icon frame
|
||||
// Icon animations have 15 frames, 0-14
|
||||
// FIXME: icon animations are way too quick
|
||||
_curIconFrame++;
|
||||
if (_curIconFrame == 15)
|
||||
_curIconFrame = 0;
|
||||
|
||||
_activeIcon = i;
|
||||
|
||||
// Play creepy voice
|
||||
if (!_mixer->isSoundHandleActive(_sfxHandle) && _activeIcon != _previousActiveIcon) {
|
||||
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, _resMgr->loadSFX(1, i + 44));
|
||||
_previousActiveIcon = _activeIcon;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (_mouseY >= 400 && _mouseY <= 400 + 48) {
|
||||
// Bottom row
|
||||
for (int i = 0; i <= 5; i++) {
|
||||
int curX = 40 + i * 100;
|
||||
if (_mouseX >= curX && _mouseX <= curX + 55) {
|
||||
int iconNum = i + 10;
|
||||
|
||||
// The last 2 icons are swapped
|
||||
if (iconNum == 14)
|
||||
iconNum = 15;
|
||||
else if (iconNum == 15)
|
||||
iconNum = 14;
|
||||
|
||||
GraphicResource *res = _resMgr->getGraphic(1, iconNum, _curIconFrame);
|
||||
_system->copyRectToScreen(res->data, res->width, curX, 400, res->width, res->height);
|
||||
|
||||
// Cycle icon frame
|
||||
// Icon animations have 15 frames, 0-14
|
||||
// FIXME: icon animations are way too quick
|
||||
_curIconFrame++;
|
||||
if (_curIconFrame == 15)
|
||||
_curIconFrame = 0;
|
||||
|
||||
_activeIcon = i + 6;
|
||||
|
||||
// HACK: the credits icon has less frames (0 - 9). Currently, there's no way to find the number
|
||||
// of frames with the current resource manager implementation, so we just hardcode it here
|
||||
if (_activeIcon == 10 && _curIconFrame == 10)
|
||||
_curIconFrame = 0;
|
||||
|
||||
// Play creepy voice
|
||||
if (!_mixer->isSoundHandleActive(_sfxHandle) && _activeIcon != _previousActiveIcon) {
|
||||
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, _resMgr->loadSFX(1, iconNum + 40));
|
||||
_previousActiveIcon = _activeIcon;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// No selection
|
||||
_previousActiveIcon = _activeIcon = -1;
|
||||
}
|
||||
|
||||
// Eyes animation
|
||||
// Get the appropriate eye resource depending on the mouse position
|
||||
int eyeResource = kEyesFront;
|
||||
|
||||
if (_mouseX <= 200) {
|
||||
if (_mouseY <= 160)
|
||||
eyeResource = kEyesTopLeft;
|
||||
else if (_mouseY > 160 && _mouseY <= 320)
|
||||
eyeResource = kEyesLeft;
|
||||
else
|
||||
eyeResource = kEyesBottomLeft;
|
||||
} else if (_mouseX > 200 && _mouseX <= 400) {
|
||||
if (_mouseY <= 160)
|
||||
eyeResource = kEyesTop;
|
||||
else if (_mouseY > 160 && _mouseY <= 320)
|
||||
eyeResource = kEyesFront;
|
||||
else
|
||||
eyeResource = kEyesBottom;
|
||||
} else if (_mouseX > 400) {
|
||||
if (_mouseY <= 160)
|
||||
eyeResource = kEyesTopRight;
|
||||
else if (_mouseY > 160 && _mouseY <= 320)
|
||||
eyeResource = kEyesRight;
|
||||
else
|
||||
eyeResource = kEyesBottomRight;
|
||||
}
|
||||
// TODO: kEyesCrossed state
|
||||
|
||||
GraphicResource *res = _resMgr->getGraphic(1, 1, eyeResource);
|
||||
copyRectToScreenWithTransparency(res->data, 265, 230, res->width, res->height);
|
||||
}
|
||||
|
||||
void AsylumEngine::copyToBackBuffer(byte *buffer, int x, int y, int width, int height) {
|
||||
int h = height;
|
||||
byte *dest = (byte *)_backBuffer.pixels;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue