diff options
author | Benjamin Haisch | 2010-10-31 19:38:22 +0000 |
---|---|---|
committer | Willem Jan Palenstijn | 2011-11-20 22:43:10 +0100 |
commit | ce7f9a088c03e502eaf0709b18c6c02937673f9f (patch) | |
tree | 5f5aa4231001aee99e59672c5a4da615c16c2364 /engines | |
parent | 5e154f634a47524fe5d2d260c25812d40802fbc9 (diff) | |
download | scummvm-rg350-ce7f9a088c03e502eaf0709b18c6c02937673f9f.tar.gz scummvm-rg350-ce7f9a088c03e502eaf0709b18c6c02937673f9f.tar.bz2 scummvm-rg350-ce7f9a088c03e502eaf0709b18c6c02937673f9f.zip |
TOLTECS: - Work on the menu system (use strings from resources instead of hardcoded ones)
- ...and load the system strings from the resource on startup
- Only redraw menu screen when required
- Change parameters for some text functions from byte* to const byte*
- Rename some mouse vars
Diffstat (limited to 'engines')
-rw-r--r-- | engines/toltecs/menu.cpp | 155 | ||||
-rw-r--r-- | engines/toltecs/menu.h | 7 | ||||
-rw-r--r-- | engines/toltecs/screen.cpp | 14 | ||||
-rw-r--r-- | engines/toltecs/screen.h | 4 | ||||
-rw-r--r-- | engines/toltecs/toltecs.cpp | 40 | ||||
-rw-r--r-- | engines/toltecs/toltecs.h | 38 |
6 files changed, 158 insertions, 100 deletions
diff --git a/engines/toltecs/menu.cpp b/engines/toltecs/menu.cpp index 648f4290cc..2747858fd6 100644 --- a/engines/toltecs/menu.cpp +++ b/engines/toltecs/menu.cpp @@ -47,6 +47,7 @@ MenuSystem::MenuSystem(ToltecsEngine *vm) : _vm(vm) { _newMenuID = kMenuIdLoad; _currItemID = kItemIdNone; _editingDescription = false; + _needRedraw = false; _cfgText = true; _cfgVoices = true; _cfgMasterVolume = 10; @@ -65,6 +66,7 @@ int MenuSystem::run() { _background->create(640, 400, 1); _top = 30 - _vm->_guiHeight / 2; + _needRedraw = false; memset(_vm->_screen->_frontScreen, 250, 640 * 400); @@ -73,14 +75,17 @@ int MenuSystem::run() { _vm->_palette->buildColorTransTable(0, 16, 7); shadeRect(60, 39, 520, 246, 30, 94); - + + _vm->_system->copyRectToScreen((const byte *)_vm->_screen->_frontScreen, 640, 0, 0, 640, 400); + while (1) { update(); _vm->updateScreen(); } delete _background; - + + return 0; } void MenuSystem::update() { @@ -93,8 +98,11 @@ void MenuSystem::update() { handleEvents(); - _vm->_system->copyRectToScreen((const byte *)_vm->_screen->_frontScreen, - 640, 0, 0, 640, 400); + if (_needRedraw) { + _vm->_system->copyRectToScreen((const byte *)_vm->_screen->_frontScreen + 39 * 640 + 60, 640, 60, 39, 520, 247); + debug("redraw"); + _needRedraw = false; + } _vm->_system->delayMillis(5); @@ -125,7 +133,7 @@ void MenuSystem::handleEvents() { } -void MenuSystem::addClickTextItem(ItemID id, int x, int y, int w, uint fontNum, const byte *caption, byte defaultColor, byte activeColor) { +void MenuSystem::addClickTextItem(ItemID id, int x, int y, int w, uint fontNum, const char *caption, byte defaultColor, byte activeColor) { Item item; item.id = id; item.defaultColor = defaultColor; @@ -142,7 +150,7 @@ void MenuSystem::drawItem(ItemID itemID, bool active) { Item *item = getItem(itemID); if (item) { byte color = active ? item->activeColor : item->defaultColor; - drawString(item->rect.left, item->y, 0, item->fontNum, color, (byte*)item->caption.c_str()); + drawString(item->rect.left, item->y, 0, item->fontNum, color, item->caption.c_str()); } } @@ -170,13 +178,13 @@ void MenuSystem::handleKeyDown(const Common::KeyState& kbd) { _editingDescriptionItem->caption += kbd.ascii; restoreRect(_editingDescriptionItem->rect.left, _editingDescriptionItem->rect.top, _editingDescriptionItem->rect.width() + 1, _editingDescriptionItem->rect.height() - 2); - setItemCaption(_editingDescriptionItem, (const byte*)_editingDescriptionItem->caption.c_str()); + setItemCaption(_editingDescriptionItem, _editingDescriptionItem->caption.c_str()); drawItem(_editingDescriptionID, true); } else if (kbd.keycode == Common::KEYCODE_BACKSPACE) { _editingDescriptionItem->caption.deleteLastChar(); restoreRect(_editingDescriptionItem->rect.left, _editingDescriptionItem->rect.top, _editingDescriptionItem->rect.width() + 1, _editingDescriptionItem->rect.height() - 2); - setItemCaption(_editingDescriptionItem, (const byte*)_editingDescriptionItem->caption.c_str()); + setItemCaption(_editingDescriptionItem, _editingDescriptionItem->caption.c_str()); drawItem(_editingDescriptionID, true); } else if (kbd.keycode == Common::KEYCODE_RETURN) { _editingDescription = false; @@ -201,15 +209,15 @@ MenuSystem::Item *MenuSystem::getItem(ItemID id) { return NULL; } -void MenuSystem::setItemCaption(Item *item, const byte *caption) { +void MenuSystem::setItemCaption(Item *item, const char *caption) { Font font(_vm->_res->load(_vm->_screen->getFontResIndex(item->fontNum))->data); - int width = font.getTextWidth((byte*)caption); + int width = font.getTextWidth((const byte*)caption); int height = font.getHeight(); item->rect = Common::Rect(item->x, item->y - height, item->x + width, item->y); if (item->w) { item->rect.translate(item->w - width / 2, 0); } - item->caption = (const char*)caption; + item->caption = caption; } void MenuSystem::initMenu(MenuID menuID) { @@ -220,65 +228,65 @@ void MenuSystem::initMenu(MenuID menuID) { switch (menuID) { case kMenuIdMain: - drawString(0, 74, 320, 1, 229, (byte*)"What can I do for you?"); - addClickTextItem(kItemIdLoad, 0, 115, 320, 0, (const byte*)"LOAD", 229, 255); - addClickTextItem(kItemIdSave, 0, 135, 320, 0, (const byte*)"SAVE", 229, 255); - addClickTextItem(kItemIdToggleText, 0, 165, 320, 0, (const byte*)"TEXT ON", 229, 255); - addClickTextItem(kItemIdToggleVoices, 0, 185, 320, 0, (const byte*)"VOICES ON", 229, 255); - addClickTextItem(kItemIdVolumesMenu, 0, 215, 320, 0, (const byte*)"VOLUME", 229, 255); - addClickTextItem(kItemIdPlay, 0, 245, 320, 0, (const byte*)"PLAY", 229, 255); - addClickTextItem(kItemIdQuit, 0, 275, 320, 0, (const byte*)"QUIT GAME", 229, 255); + drawString(0, 74, 320, 1, 229, _vm->getSysString(kStrWhatCanIDoForYou)); + addClickTextItem(kItemIdLoad, 0, 115, 320, 0, _vm->getSysString(kStrLoad), 229, 255); + addClickTextItem(kItemIdSave, 0, 135, 320, 0, _vm->getSysString(kStrSave), 229, 255); + addClickTextItem(kItemIdToggleText, 0, 165, 320, 0, _vm->getSysString(kStrTextOn), 229, 255); + addClickTextItem(kItemIdToggleVoices, 0, 185, 320, 0, _vm->getSysString(kStrVoicesOn), 229, 255); + addClickTextItem(kItemIdVolumesMenu, 0, 215, 320, 0, _vm->getSysString(kStrVolume), 229, 255); + addClickTextItem(kItemIdPlay, 0, 245, 320, 0, _vm->getSysString(kStrPlay), 229, 255); + addClickTextItem(kItemIdQuit, 0, 275, 320, 0, _vm->getSysString(kStrQuit), 229, 255); break; case kMenuIdLoad: - drawString(0, 74, 320, 1, 229, (byte*)"Load game"); - addClickTextItem(kItemIdSavegameUp, 0, 155, 545, 1, (const byte*)"^", 255, 253); - addClickTextItem(kItemIdSavegameDown, 0, 195, 545, 1, (const byte*)"\\", 255, 253); - addClickTextItem(kItemIdCancel, 0, 275, 320, 0, (const byte*)"CANCEL", 255, 253); - addClickTextItem(kItemIdSavegame1, 0, 115 + 20 * 0, 300, 0, (const byte*)"SAVEGAME 1", 231, 234); - addClickTextItem(kItemIdSavegame2, 0, 115 + 20 * 1, 300, 0, (const byte*)"SAVEGAME 2", 231, 234); - addClickTextItem(kItemIdSavegame3, 0, 115 + 20 * 2, 300, 0, (const byte*)"SAVEGAME 3", 231, 234); - addClickTextItem(kItemIdSavegame4, 0, 115 + 20 * 3, 300, 0, (const byte*)"SAVEGAME 4", 231, 234); - addClickTextItem(kItemIdSavegame5, 0, 115 + 20 * 4, 300, 0, (const byte*)"SAVEGAME 5", 231, 234); - addClickTextItem(kItemIdSavegame6, 0, 115 + 20 * 5, 300, 0, (const byte*)"SAVEGAME 6", 231, 234); - addClickTextItem(kItemIdSavegame7, 0, 115 + 20 * 6, 300, 0, (const byte*)"SAVEGAME 7", 231, 234); + drawString(0, 74, 320, 1, 229, _vm->getSysString(kStrLoadGame)); + addClickTextItem(kItemIdSavegameUp, 0, 155, 545, 1, "^", 255, 253); + addClickTextItem(kItemIdSavegameDown, 0, 195, 545, 1, "\\", 255, 253); + addClickTextItem(kItemIdCancel, 0, 275, 320, 0, _vm->getSysString(kStrCancel), 255, 253); + addClickTextItem(kItemIdSavegame1, 0, 115 + 20 * 0, 300, 0, "SAVEGAME 1", 231, 234); + addClickTextItem(kItemIdSavegame2, 0, 115 + 20 * 1, 300, 0, "SAVEGAME 2", 231, 234); + addClickTextItem(kItemIdSavegame3, 0, 115 + 20 * 2, 300, 0, "SAVEGAME 3", 231, 234); + addClickTextItem(kItemIdSavegame4, 0, 115 + 20 * 3, 300, 0, "SAVEGAME 4", 231, 234); + addClickTextItem(kItemIdSavegame5, 0, 115 + 20 * 4, 300, 0, "SAVEGAME 5", 231, 234); + addClickTextItem(kItemIdSavegame6, 0, 115 + 20 * 5, 300, 0, "SAVEGAME 6", 231, 234); + addClickTextItem(kItemIdSavegame7, 0, 115 + 20 * 6, 300, 0, "SAVEGAME 7", 231, 234); initSavegames(); setSavegameCaptions(); break; case kMenuIdSave: - drawString(0, 74, 320, 1, 229, (byte*)"Save game"); - addClickTextItem(kItemIdSavegameUp, 0, 155, 545, 1, (const byte*)"^", 255, 253); - addClickTextItem(kItemIdSavegameDown, 0, 195, 545, 1, (const byte*)"\\", 255, 253); - addClickTextItem(kItemIdCancel, 0, 275, 320, 0, (const byte*)"CANCEL", 255, 253); - addClickTextItem(kItemIdSavegame1, 0, 115 + 20 * 0, 300, 0, (const byte*)"SAVEGAME 1", 231, 234); - addClickTextItem(kItemIdSavegame2, 0, 115 + 20 * 1, 300, 0, (const byte*)"SAVEGAME 2", 231, 234); - addClickTextItem(kItemIdSavegame3, 0, 115 + 20 * 2, 300, 0, (const byte*)"SAVEGAME 3", 231, 234); - addClickTextItem(kItemIdSavegame4, 0, 115 + 20 * 3, 300, 0, (const byte*)"SAVEGAME 4", 231, 234); - addClickTextItem(kItemIdSavegame5, 0, 115 + 20 * 4, 300, 0, (const byte*)"SAVEGAME 5", 231, 234); - addClickTextItem(kItemIdSavegame6, 0, 115 + 20 * 5, 300, 0, (const byte*)"SAVEGAME 6", 231, 234); - addClickTextItem(kItemIdSavegame7, 0, 115 + 20 * 6, 300, 0, (const byte*)"SAVEGAME 7", 231, 234); + drawString(0, 74, 320, 1, 229, _vm->getSysString(kStrSaveGame)); + addClickTextItem(kItemIdSavegameUp, 0, 155, 545, 1, "^", 255, 253); + addClickTextItem(kItemIdSavegameDown, 0, 195, 545, 1, "\\", 255, 253); + addClickTextItem(kItemIdCancel, 0, 275, 320, 0, _vm->getSysString(kStrCancel), 255, 253); + addClickTextItem(kItemIdSavegame1, 0, 115 + 20 * 0, 300, 0, "SAVEGAME 1", 231, 234); + addClickTextItem(kItemIdSavegame2, 0, 115 + 20 * 1, 300, 0, "SAVEGAME 2", 231, 234); + addClickTextItem(kItemIdSavegame3, 0, 115 + 20 * 2, 300, 0, "SAVEGAME 3", 231, 234); + addClickTextItem(kItemIdSavegame4, 0, 115 + 20 * 3, 300, 0, "SAVEGAME 4", 231, 234); + addClickTextItem(kItemIdSavegame5, 0, 115 + 20 * 4, 300, 0, "SAVEGAME 5", 231, 234); + addClickTextItem(kItemIdSavegame6, 0, 115 + 20 * 5, 300, 0, "SAVEGAME 6", 231, 234); + addClickTextItem(kItemIdSavegame7, 0, 115 + 20 * 6, 300, 0, "SAVEGAME 7", 231, 234); initSavegames(); _savegames.push_back(SavegameItem("", Common::String::printf("GAME %03d", _savegames.size() + 1))); setSavegameCaptions(); break; case kMenuIdVolumes: - drawString(0, 74, 320, 1, 229, (byte*)"Adjust volume"); - drawString(0, 130, 200, 0, 246, (byte*)"Master"); - drawString(0, 155, 200, 0, 244, (byte*)"Voices"); - drawString(0, 180, 200, 0, 244, (byte*)"Music"); - drawString(0, 205, 200, 0, 244, (byte*)"Sound FX"); - drawString(0, 230, 200, 0, 244, (byte*)"Background"); - addClickTextItem(kItemIdDone, 0, 275, 200, 0, (const byte*)"DONE", 229, 253); - addClickTextItem(kItemIdCancel, 0, 275, 440, 0, (const byte*)"CANCEL", 229, 253); - addClickTextItem(kItemIdMasterDown, 0, 130 + 25 * 0, 348, 1, (const byte*)"[", 229, 253); - addClickTextItem(kItemIdVoicesDown, 0, 130 + 25 * 1, 348, 1, (const byte*)"[", 229, 253); - addClickTextItem(kItemIdMusicDown, 0, 130 + 25 * 2, 348, 1, (const byte*)"[", 229, 253); - addClickTextItem(kItemIdSoundFXDown, 0, 130 + 25 * 3, 348, 1, (const byte*)"[", 229, 253); - addClickTextItem(kItemIdBackgroundDown, 0, 130 + 25 * 4, 348, 1, (const byte*)"[", 229, 253); - addClickTextItem(kItemIdMasterUp, 0, 130 + 25 * 0, 372, 1, (const byte*)"]", 229, 253); - addClickTextItem(kItemIdVoicesUp, 0, 130 + 25 * 1, 372, 1, (const byte*)"]", 229, 253); - addClickTextItem(kItemIdMusicUp, 0, 130 + 25 * 2, 372, 1, (const byte*)"]", 229, 253); - addClickTextItem(kItemIdSoundFXUp, 0, 130 + 25 * 3, 372, 1, (const byte*)"]", 229, 253); - addClickTextItem(kItemIdBackgroundUp, 0, 130 + 25 * 4, 372, 1, (const byte*)"]", 229, 253); + drawString(0, 74, 320, 1, 229, _vm->getSysString(kStrAdjustVolume)); + drawString(0, 130, 200, 0, 246, _vm->getSysString(kStrMaster)); + drawString(0, 155, 200, 0, 244, _vm->getSysString(kStrVoices)); + drawString(0, 180, 200, 0, 244, _vm->getSysString(kStrMusic)); + drawString(0, 205, 200, 0, 244, _vm->getSysString(kStrSoundFx)); + drawString(0, 230, 200, 0, 244, _vm->getSysString(kStrBackground)); + addClickTextItem(kItemIdDone, 0, 275, 200, 0, _vm->getSysString(kStrDone), 229, 253); + addClickTextItem(kItemIdCancel, 0, 275, 440, 0, _vm->getSysString(kStrCancel), 229, 253); + addClickTextItem(kItemIdMasterDown, 0, 130 + 25 * 0, 348, 1, "[", 229, 253); + addClickTextItem(kItemIdVoicesDown, 0, 130 + 25 * 1, 348, 1, "[", 229, 253); + addClickTextItem(kItemIdMusicDown, 0, 130 + 25 * 2, 348, 1, "[", 229, 253); + addClickTextItem(kItemIdSoundFXDown, 0, 130 + 25 * 3, 348, 1, "[", 229, 253); + addClickTextItem(kItemIdBackgroundDown, 0, 130 + 25 * 4, 348, 1, "[", 229, 253); + addClickTextItem(kItemIdMasterUp, 0, 130 + 25 * 0, 372, 1, "]", 229, 253); + addClickTextItem(kItemIdVoicesUp, 0, 130 + 25 * 1, 372, 1, "]", 229, 253); + addClickTextItem(kItemIdMusicUp, 0, 130 + 25 * 2, 372, 1, "]", 229, 253); + addClickTextItem(kItemIdSoundFXUp, 0, 130 + 25 * 3, 372, 1, "]", 229, 253); + addClickTextItem(kItemIdBackgroundUp, 0, 130 + 25 * 4, 372, 1, "]", 229, 253); drawVolumeBar(kItemIdMaster); drawVolumeBar(kItemIdVoices); drawVolumeBar(kItemIdMusic); @@ -420,13 +428,14 @@ void MenuSystem::shadeRect(int x, int y, int w, int h, byte color1, byte color2) } } -void MenuSystem::drawString(int16 x, int16 y, int w, uint fontNum, byte color, byte *text) { +void MenuSystem::drawString(int16 x, int16 y, int w, uint fontNum, byte color, const char *text) { fontNum = _vm->_screen->getFontResIndex(fontNum); Font font(_vm->_res->load(fontNum)->data); if (w) { - x = x + w - font.getTextWidth(text) / 2; + x = x + w - font.getTextWidth((const byte*)text) / 2; } - _vm->_screen->drawString(x, y - font.getHeight(), color, fontNum, text, -1, NULL, true); + _vm->_screen->drawString(x, y - font.getHeight(), color, fontNum, (const byte*)text, -1, NULL, true); + _needRedraw = true; } void MenuSystem::initSavegames() { @@ -474,13 +483,13 @@ void MenuSystem::initSavegames() { void MenuSystem::setSavegameCaptions() { uint index = _savegameListTopIndex; - setItemCaption(getItem(kItemIdSavegame1), index < _savegames.size() ? (const byte*)_savegames[index++]._description.c_str() : (const byte*)""); - setItemCaption(getItem(kItemIdSavegame2), index < _savegames.size() ? (const byte*)_savegames[index++]._description.c_str() : (const byte*)""); - setItemCaption(getItem(kItemIdSavegame3), index < _savegames.size() ? (const byte*)_savegames[index++]._description.c_str() : (const byte*)""); - setItemCaption(getItem(kItemIdSavegame4), index < _savegames.size() ? (const byte*)_savegames[index++]._description.c_str() : (const byte*)""); - setItemCaption(getItem(kItemIdSavegame5), index < _savegames.size() ? (const byte*)_savegames[index++]._description.c_str() : (const byte*)""); - setItemCaption(getItem(kItemIdSavegame6), index < _savegames.size() ? (const byte*)_savegames[index++]._description.c_str() : (const byte*)""); - setItemCaption(getItem(kItemIdSavegame7), index < _savegames.size() ? (const byte*)_savegames[index++]._description.c_str() : (const byte*)""); + setItemCaption(getItem(kItemIdSavegame1), index < _savegames.size() ? _savegames[index++]._description.c_str() : ""); + setItemCaption(getItem(kItemIdSavegame2), index < _savegames.size() ? _savegames[index++]._description.c_str() : ""); + setItemCaption(getItem(kItemIdSavegame3), index < _savegames.size() ? _savegames[index++]._description.c_str() : ""); + setItemCaption(getItem(kItemIdSavegame4), index < _savegames.size() ? _savegames[index++]._description.c_str() : ""); + setItemCaption(getItem(kItemIdSavegame5), index < _savegames.size() ? _savegames[index++]._description.c_str() : ""); + setItemCaption(getItem(kItemIdSavegame6), index < _savegames.size() ? _savegames[index++]._description.c_str() : ""); + setItemCaption(getItem(kItemIdSavegame7), index < _savegames.size() ? _savegames[index++]._description.c_str() : ""); } void MenuSystem::scrollSavegames(int delta) { @@ -540,8 +549,8 @@ void MenuSystem::setCfgText(bool value, bool active) { if (_cfgText != value) { Item *item = getItem(kItemIdToggleText); _cfgText = value; - restoreRect(item->rect.left, item->rect.top, item->rect.width() + 1, item->rect.height() - 2); - setItemCaption(item, _cfgText ? (const byte*)"TEXT ON" : (const byte*)"TEXT OFF"); + restoreRect(item->rect.left, item->rect.top, item->rect.width() + 1, item->rect.height() - 2); + setItemCaption(item, _vm->getSysString(_cfgText ? kStrTextOn : kStrTextOff)); drawItem(kItemIdToggleText, true); } } @@ -551,7 +560,7 @@ void MenuSystem::setCfgVoices(bool value, bool active) { Item *item = getItem(kItemIdToggleVoices); _cfgVoices = value; restoreRect(item->rect.left, item->rect.top, item->rect.width() + 1, item->rect.height() - 2); - setItemCaption(item, _cfgVoices ? (const byte*)"VOICES ON" : (const byte*)"VOICES OFF"); + setItemCaption(item, _vm->getSysString(_cfgVoices ? kStrVoicesOn : kStrVoicesOff)); drawItem(kItemIdToggleVoices, true); } } @@ -592,7 +601,7 @@ void MenuSystem::drawVolumeBar(ItemID itemID) { text[i] = '|'; text[volume] = 0; - drawString(0, y, w, 0, 246, (byte*)text); + drawString(0, y, w, 0, 246, text); } diff --git a/engines/toltecs/menu.h b/engines/toltecs/menu.h index 5860afd0b3..e71557e751 100644 --- a/engines/toltecs/menu.h +++ b/engines/toltecs/menu.h @@ -132,6 +132,7 @@ protected: bool _editingDescription; ItemID _editingDescriptionID; Item *_editingDescriptionItem; + bool _needRedraw; Common::Array<Item> _items; Common::Array<SavegameItem> _savegames; @@ -139,7 +140,7 @@ protected: bool _cfgText, _cfgVoices; int _cfgMasterVolume, _cfgVoicesVolume, _cfgMusicVolume, _cfgSoundFXVolume, _cfgBackgroundVolume; - void addClickTextItem(ItemID id, int x, int y, int w, uint fontNum, const byte *caption, byte defaultColor, byte activeColor); + void addClickTextItem(ItemID id, int x, int y, int w, uint fontNum, const char *caption, byte defaultColor, byte activeColor); void drawItem(ItemID itemID, bool active); void handleMouseMove(int x, int y); @@ -148,7 +149,7 @@ protected: ItemID findItemAt(int x, int y); Item *getItem(ItemID id); - void setItemCaption(Item *item, const byte *caption); + void setItemCaption(Item *item, const char *caption); void initMenu(MenuID menuID); @@ -158,7 +159,7 @@ protected: void restoreRect(int x, int y, int w, int h); void shadeRect(int x, int y, int w, int h, byte color1, byte color2); - void drawString(int16 x, int16 y, int w, uint fontNum, byte color, byte *text); + void drawString(int16 x, int16 y, int w, uint fontNum, byte color, const char *text); void initSavegames(); void setSavegameCaptions(); diff --git a/engines/toltecs/screen.cpp b/engines/toltecs/screen.cpp index 6ac916e24c..9f0ff51b5d 100644 --- a/engines/toltecs/screen.cpp +++ b/engines/toltecs/screen.cpp @@ -140,7 +140,7 @@ void Screen::drawGuiImage(int16 x, int16 y, uint resIndex) { byte *dest = _frontScreen + x + (y + _vm->_cameraHeight) * 640; - debug(0, "Screen::drawGuiImage() x = %d; y = %d; w = %d; h = %d; resIndex = %d", x, y, width, height, resIndex); + //debug(0, "Screen::drawGuiImage() x = %d; y = %d; w = %d; h = %d; resIndex = %d", x, y, width, height, resIndex); while (workHeight > 0) { int count = 1; @@ -202,7 +202,7 @@ void Screen::addStaticSprite(byte *spriteItem) { drawRequest.flags = READ_LE_UINT16(spriteItem + 8); drawRequest.scaling = 0; - debug(0, "Screen::addStaticSprite() x = %d; y = %d; baseColor = %d; resIndex = %d; flags = %04X", drawRequest.x, drawRequest.y, drawRequest.baseColor, drawRequest.resIndex, drawRequest.flags); + //debug(0, "Screen::addStaticSprite() x = %d; y = %d; baseColor = %d; resIndex = %d; flags = %04X", drawRequest.x, drawRequest.y, drawRequest.baseColor, drawRequest.resIndex, drawRequest.flags); addDrawRequest(drawRequest); @@ -210,7 +210,7 @@ void Screen::addStaticSprite(byte *spriteItem) { void Screen::addAnimatedSprite(int16 x, int16 y, int16 fragmentId, byte *data, int16 *spriteArray, bool loop, int mode) { - debug(0, "Screen::addAnimatedSprite(%d, %d, %d)", x, y, fragmentId); + //debug(0, "Screen::addAnimatedSprite(%d, %d, %d)", x, y, fragmentId); DrawRequest drawRequest; memset(&drawRequest, 0, sizeof(drawRequest)); @@ -227,7 +227,7 @@ void Screen::addAnimatedSprite(int16 x, int16 y, int16 fragmentId, byte *data, i int16 count = spriteArray[0]; - debug(0, "count = %d", count); + //debug(0, "count = %d", count); for (int16 index = 1; index <= count; index++) { @@ -581,14 +581,14 @@ void Screen::drawGuiText(int16 x, int16 y, byte fontColor1, byte fontColor2, uin } -int16 Screen::drawString(int16 x, int16 y, byte color, uint fontResIndex, byte *text, int len, int16 *ywobble, bool outline) { +int16 Screen::drawString(int16 x, int16 y, byte color, uint fontResIndex, const byte *text, int len, int16 *ywobble, bool outline) { - debug(0, "Screen::drawString(%d, %d, %d, %d)", x, y, color, fontResIndex); + //debug(0, "Screen::drawString(%d, %d, %d, %d)", x, y, color, fontResIndex); Font font(_vm->_res->load(fontResIndex)->data); if (len == -1) - len = strlen((char*)text); + len = strlen((const char*)text); int16 yadd = 0; if (ywobble) diff --git a/engines/toltecs/screen.h b/engines/toltecs/screen.h index 4aeeb78a01..bd332a9da3 100644 --- a/engines/toltecs/screen.h +++ b/engines/toltecs/screen.h @@ -98,7 +98,7 @@ public: byte *getCharData(byte ch) const { return _fontData + 0x298 + READ_LE_UINT16(&_fontData[0xE0 + (ch - 0x21) * 2]); } - int16 getTextWidth(byte *text) { + int16 getTextWidth(const byte *text) { int16 width = 0; while (*text && *text < 0xF0) { byte ch = *text++; @@ -201,7 +201,7 @@ public: int16 wrapGuiText(uint fontResIndex, int maxWidth, GuiTextWrapState &wrapState); void drawGuiText(int16 x, int16 y, byte fontColor1, byte fontColor2, uint fontResIndex, GuiTextWrapState &wrapState); - int16 drawString(int16 x, int16 y, byte color, uint fontResIndex, byte *text, int len = -1, int16 *ywobble = NULL, bool outline = false); + int16 drawString(int16 x, int16 y, byte color, uint fontResIndex, const byte *text, int len = -1, int16 *ywobble = NULL, bool outline = false); void drawChar(const Font &font, byte *dest, int16 x, int16 y, byte ch, byte color, bool outline); void drawSurface(int16 x, int16 y, Graphics::Surface *surface); diff --git a/engines/toltecs/toltecs.cpp b/engines/toltecs/toltecs.cpp index 0c8d5658b3..93d43250db 100644 --- a/engines/toltecs/toltecs.cpp +++ b/engines/toltecs/toltecs.cpp @@ -125,8 +125,8 @@ Common::Error ToltecsEngine::run() { _mouseX = 0; _mouseY = 0; - _mouseCounter = 0; - _mouseButtonPressedFlag = false; + _mouseDblClickTicks = 60; + _mouseWaitForRelease = false; _mouseButton = 0; _mouseDisabled = 0; _leftButtonDown = false; @@ -152,7 +152,9 @@ Common::Error ToltecsEngine::run() { syncSoundSettings(); -//#define TEST_MENU + setupSysStrings(); + +#define TEST_MENU #ifdef TEST_MENU _screen->registerFont(0, 0x0D); _screen->registerFont(1, 0x0E); @@ -199,6 +201,17 @@ Common::Error ToltecsEngine::run() { return Common::kNoError; } +void ToltecsEngine::setupSysStrings() { + Resource *sysStringsResource = _res->load(15); + const char *sysStrings = (const char*)sysStringsResource->data; + for (int i = 0; i < kSysStrCount; i++) { + debug(1, "sysStrings[%d] = [%s]", i, sysStrings); + _sysStrings[i] = sysStrings; + sysStrings += strlen(sysStrings) + 1; + } + // TODO: Set yes/no chars +} + void ToltecsEngine::loadScene(uint resIndex) { // TODO @@ -323,10 +336,10 @@ void ToltecsEngine::updateInput() { } } - if (_mouseDisabled == 0) { + if (!_mouseDisabled) { - if (_mouseCounter > 0) - _mouseCounter--; + if (_mouseDblClickTicks > 0) + _mouseDblClickTicks--; byte mouseButtons = 0; if (_leftButtonDown) @@ -335,17 +348,18 @@ void ToltecsEngine::updateInput() { mouseButtons |= 2; if (mouseButtons != 0) { - if (!_mouseButtonPressedFlag) { + if (!_mouseWaitForRelease) { _mouseButton = mouseButtons; - if (_mouseCounter != 0) - _mouseButton |= 0x80; - _mouseCounter = 30; // maybe TODO - _mouseButtonPressedFlag = true; + if (_mouseDblClickTicks > 0) + _mouseButton = 0x80; + //if (_mouseButton == 0x80) debug("DBL!"); + _mouseDblClickTicks = 30; // maybe TODO + _mouseWaitForRelease = true; } else { _mouseButton = 0; } } else { - _mouseButtonPressedFlag = false; + _mouseWaitForRelease = false; _mouseButton = 0; } @@ -429,7 +443,7 @@ void ToltecsEngine::updateCamera() { _screen->finishTalkTextItems(); } - debug(0, "ToltecsEngine::updateCamera() _cameraX = %d; _cameraY = %d", _cameraX, _cameraY); + //debug(0, "ToltecsEngine::updateCamera() _cameraX = %d; _cameraY = %d", _cameraX, _cameraY); } diff --git a/engines/toltecs/toltecs.h b/engines/toltecs/toltecs.h index bcd2c3d234..851e28c263 100644 --- a/engines/toltecs/toltecs.h +++ b/engines/toltecs/toltecs.h @@ -60,6 +60,34 @@ class Sound; // TODO/FIXME: The includes of the Toltecs engine need serious clean-up +enum SysString { + kStrLoadingPleaseWait, + kStrWhatCanIDoForYou, + kStrLoad, + kStrSave, + kStrTextOn, + kStrTextOff, + kStrVoicesOn, + kStrVoicesOff, + kStrVolume, + kStrPlay, + kStrQuit, + kStrLoadGame, + kStrSaveGame, + kStrAdjustVolume, + kStrMaster, + kStrVoices, + kStrMusic, + kStrSoundFx, + kStrBackground, + kStrCancel, + kStrDone, + kStrAreYouSure, + kStrYes, + kStrNo, + kSysStrCount +}; + class ToltecsEngine : public ::Engine { Common::KeyState _keyPressed; @@ -80,6 +108,8 @@ public: Common::Language getLanguage() const; const Common::String& getTargetName() const { return _targetName; } + void setupSysStrings(); + void loadScene(uint resIndex); void updateScreen(); @@ -115,6 +145,8 @@ public: SegmentMap *_segmap; Sound *_sound; + Common::String _sysStrings[kSysStrCount]; + uint _sceneResIndex; int16 _sceneWidth, _sceneHeight; @@ -133,12 +165,14 @@ public: Common::KeyState _keyState; int16 _mouseX, _mouseY; - int16 _mouseCounter; - bool _mouseButtonPressedFlag; + int16 _mouseDblClickTicks; + bool _mouseWaitForRelease; byte _mouseButton; int16 _mouseDisabled; bool _leftButtonDown, _rightButtonDown; + const char *getSysString(int index) const { return _sysStrings[index].c_str(); } + /* Save/load */ enum kReadSaveHeaderError { |