Fixes the kyra GUI palette issues, implements background fading when the GUI's up,

and a couple of very minor optimizations.

svn-id: r20263
This commit is contained in:
Oystein Eftevaag 2006-01-28 05:09:39 +00:00
parent 3c867006fa
commit 3730bc19eb
4 changed files with 42 additions and 9 deletions

View File

@ -403,6 +403,7 @@ int KyraEngine::buttonMenuCallback(Button *caller) {
}
_screen->savePageToDisk("SEENPAGE.TMP", 0);
gui_fadePalette();
calcCoords(_menu[0]);
calcCoords(_menu[1]);
@ -425,6 +426,7 @@ int KyraEngine::buttonMenuCallback(Button *caller) {
}
if (_menuRestoreScreen) {
gui_restorePalette();
_screen->loadPageFromDisk("SEENPAGE.TMP", 0);
_animator->_updateScreen = true;
}
@ -715,6 +717,7 @@ int KyraEngine::gui_loadGameMenu(Button *button) {
initMenu(_menu[0]);
processAllMenuButtons();
} else {
gui_restorePalette();
loadGame(getSavegameFilename(_gameToLoad));
_displayMenu = false;
_menuRestoreScreen = false;
@ -724,7 +727,13 @@ int KyraEngine::gui_loadGameMenu(Button *button) {
void KyraEngine::gui_redrawTextfield() {
_screen->fillRect(38, 91, 287, 102, 250);
_text->printText(_savegameName, 38, 91, 30, 0, 0);
_text->printText(_savegameName, 38, 92, 253, 0, 0);
_screen->_charWidth = -2;
int width = _screen->getTextWidth(_savegameName);
_screen->fillRect(39 + width, 93, 45 + width, 100, 254);
_screen->_charWidth = 0;
_screen->updateScreen();
}
@ -830,8 +839,8 @@ int KyraEngine::gui_cancelSubMenu(Button *button) {
int KyraEngine::gui_quitPlaying(Button *button) {
debug(9, "KyraEngine::gui_quitPlaying()");
processMenuButton(button);
if (gui_quitConfirm("Are you sure you want to quit playing?"))
quitGame();
else {
@ -973,5 +982,29 @@ void KyraEngine::gui_redrawHighlight(Menu menu) {
_text->printText(menu.item[i].itemString, textX, textY, menu.item[i].highlightColor, 0, 0);
}
void KyraEngine::gui_fadePalette() {
static int16 menuPalIndexes[] = {248, 249, 250, 251, 252, 253, 254, -1};
int index = 0;
memcpy(_screen->getPalette(2), _screen->_currentPalette, 768);
for (int i = 0; i < 768; i++) {
_screen->_currentPalette[i] /= 2;
}
while( menuPalIndexes[index] != -1) {
memcpy(&_screen->_currentPalette[menuPalIndexes[index]*3], &_screen->getPalette(2)[menuPalIndexes[index]*3], 3);
index++;
}
_screen->fadePalette(_screen->_currentPalette, 2);
}
void KyraEngine::gui_restorePalette() {
memcpy(_screen->_currentPalette, _screen->getPalette(2), 768);
_screen->fadePalette(_screen->_currentPalette, 2);
}
} // end of namespace Kyra

View File

@ -730,8 +730,6 @@ void KyraEngine::mainLoop() {
processButtonList(_buttonList);
updateMousePointer();
updateGameTimers();
_sprites->updateSceneAnims();
_animator->updateAllObjectShapes();
updateTextFade();
_handleInput = true;

View File

@ -687,6 +687,8 @@ protected:
void gui_processHighlights(Menu &menu);
void gui_updateSavegameString();
void gui_redrawTextfield();
void gui_fadePalette();
void gui_restorePalette();
uint8 _game;
bool _fastMode;

View File

@ -129,6 +129,9 @@ void Sprites::updateSceneAnims() {
uint32 currTime = _system->getMillis();
uint8 *data;
bool endLoop;
uint16 rndNr;
uint16 anim;
uint16 sound;
for (int i = 0; i < MAX_NUM_ANIMS; i++) {
if (_anims[i].script == 0 || !_anims[i].play || _anims[i].nextRun != 0 && _anims[i].nextRun > currTime)
@ -145,9 +148,6 @@ void Sprites::updateSceneAnims() {
endLoop = false;
while (READ_LE_UINT16(data) != 0xFF87 && !endLoop) {
uint16 rndNr;
uint16 anim;
uint16 sound;
assert((data - _anims[i].script) < _anims[i].length);
switch (READ_LE_UINT16(data)) {
case 0xFF88:
@ -408,8 +408,8 @@ void Sprites::loadDAT(const char *filename, SceneExits &exits) {
_engine->_northExitHeight = READ_LE_UINT16(_dat + 0x15);
if (_engine->_northExitHeight & 1)
_engine->_northExitHeight += 1;
// XXX
memcpy(_screen->_currentPalette + 745 - 0x3D, _dat + 0x17, 0x3D);
// XXX
memcpy(_screen->_currentPalette + 744 - 60, _dat + 0x17, 60);
uint8 *data = _dat + 0x6B;
uint16 length = READ_LE_UINT16(data);