diff options
author | Andrew Kurushin | 2005-05-28 11:06:55 +0000 |
---|---|---|
committer | Andrew Kurushin | 2005-05-28 11:06:55 +0000 |
commit | 3d1c9693777cc5d75016b2442d7f13297cbba9a5 (patch) | |
tree | bc4aa26b374d49b42bbb965decb5763700a004a8 | |
parent | 9543d99fc403af22d2c6ec73d6ce1dfb29dbe0c6 (diff) | |
download | scummvm-rg350-3d1c9693777cc5d75016b2442d7f13297cbba9a5.tar.gz scummvm-rg350-3d1c9693777cc5d75016b2442d7f13297cbba9a5.tar.bz2 scummvm-rg350-3d1c9693777cc5d75016b2442d7f13297cbba9a5.zip |
game options WIP2
svn-id: r18282
-rw-r--r-- | saga/game.cpp | 81 | ||||
-rw-r--r-- | saga/input.cpp | 2 | ||||
-rw-r--r-- | saga/interface.cpp | 245 | ||||
-rw-r--r-- | saga/interface.h | 26 | ||||
-rw-r--r-- | saga/puzzle.cpp | 2 | ||||
-rw-r--r-- | saga/saga.h | 35 | ||||
-rw-r--r-- | saga/saveload.cpp | 20 |
7 files changed, 360 insertions, 51 deletions
diff --git a/saga/game.cpp b/saga/game.cpp index a9384ed387..e310f15577 100644 --- a/saga/game.cpp +++ b/saga/game.cpp @@ -74,15 +74,32 @@ static PanelButton ITE_ConversePanelButtons[] = { }; static PanelButton ITE_OptionPanelButtons[] = { - {kPanelButtonSlider, 284,19, 13,75, 0,'-',0, 0,0,0}, //slider-scroller - {kPanelButtonOption, 113,18, 45,17, 13,'r',0, 0,0,0}, //read speed - {kPanelButtonOption, 113,37, 45,17, 16,'m',0, 0,0,0}, //music - {kPanelButtonOption, 113,56, 45,17, 16,'n',0, 0,0,0}, //sound-noise - {kPanelButtonOption, 13,79, 135,17, 12,'q',0, 0,0,0}, //quit - {kPanelButtonOption, 13,98, 135,17, 17,'c',0, 0,0,0}, //continue - {kPanelButtonOption, 164,98, 57,17, 18,'l',0, 0,0,0}, //load - {kPanelButtonOption, 241,98, 57,17, 19,'s',0, 0,0,0}, //save - {kPanelButtonOption, 166,20, 112,74, 0,'-',0, 0,0,0}, //slider + {kPanelButtonOptionSlider, 284,19, 13,75, 0,'-',0, 0,0,0}, //slider-scroller + {kPanelButtonOption, 113,18, 45,17, kTextReadingSpeed,'r',0, 0,0,0}, //read speed + {kPanelButtonOption, 113,37, 45,17, kTextMusic,'m',0, 0,0,0}, //music + {kPanelButtonOption, 113,56, 45,17, kTextSound,'n',0, 0,0,0}, //sound-noise + {kPanelButtonOption, 13,79, 135,17, kTextQuitGame,'q',0, 0,0,0}, //quit + {kPanelButtonOption, 13,98, 135,17, kTextContinuePlaying,'c',0, 0,0,0}, //continue + {kPanelButtonOption, 164,98, 57,17, kTextLoad,'l',0, 0,0,0}, //load + {kPanelButtonOption, 241,98, 57,17, kTextSave,'s',0, 0,0,0}, //save + {kPanelButtonOptionSaveFiles, 166,20, 112,74, 0,'-',0, 0,0,0}, //savefiles + + {kPanelButtonOptionText,114,4, 0,0, kTextGameOptions,'-',0, 0,0,0}, // text: game options + {kPanelButtonOptionText,10,22, 0,0, kTextReadingSpeed,'-',0, 0,0,0}, // text: read speed + {kPanelButtonOptionText,73,41, 0,0, kTextMusic,'-',0, 0,0,0}, // text: music + {kPanelButtonOptionText,69,60, 0,0, kTextSound,'-',0, 0,0,0}, // text: noise +}; + +static PanelButton ITE_QuitPanelButtons[] = { + {kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO +}; + +static PanelButton ITE_LoadPanelButtons[] = { + {kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO +}; + +static PanelButton ITE_SavePanelButtons[] = { + {kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO }; static GameDisplayInfo ITE_DisplayInfo = { @@ -117,14 +134,27 @@ static GameDisplayInfo ITE_DisplayInfo = { ITE_MainPanelButtons, 4, 5, // converse Up & Down button indexies - 0, 149, // converse panel offsets ARRAYSIZE(ITE_ConversePanelButtons), ITE_ConversePanelButtons, + 8, 0, // save file index + 8, // optionSaveFileVisible 8, 8, // option panel offsets ARRAYSIZE(ITE_OptionPanelButtons), - ITE_OptionPanelButtons + ITE_OptionPanelButtons, + + 0, 0, // quit panel offsets + ARRAYSIZE(ITE_QuitPanelButtons), + ITE_QuitPanelButtons, + + 0, 0, // load panel offsets + ARRAYSIZE(ITE_LoadPanelButtons), + ITE_LoadPanelButtons, + + 0, 0, // save panel offsets + ARRAYSIZE(ITE_SavePanelButtons), + ITE_SavePanelButtons }; static GameResourceDescription ITE_Resources = { @@ -254,6 +284,19 @@ static PanelButton IHNM_OptionPanelButtons[] = { {kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO }; +static PanelButton IHNM_QuitPanelButtons[] = { + {kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO +}; + +static PanelButton IHNM_LoadPanelButtons[] = { + {kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO +}; + +static PanelButton IHNM_SavePanelButtons[] = { + {kPanelButtonArrow, 0,0, 0,0, 0,'-',0, 0,0,0}, //TODO +}; + + static GameDisplayInfo IHNM_DisplayInfo = { //TODO: fill it all 640, 480, // logical width&height @@ -291,9 +334,23 @@ static GameDisplayInfo IHNM_DisplayInfo = { //TODO: fill it all ARRAYSIZE(IHNM_ConversePanelButtons), IHNM_ConversePanelButtons, + -1, -1, // save file index + 0, // optionSaveFileVisible 0, 0, // option panel offsets ARRAYSIZE(IHNM_OptionPanelButtons), - IHNM_OptionPanelButtons + IHNM_OptionPanelButtons, + + 0, 0, // quit panel offsets + ARRAYSIZE(IHNM_QuitPanelButtons), + IHNM_QuitPanelButtons, + + 0, 0, // load panel offsets + ARRAYSIZE(IHNM_LoadPanelButtons), + IHNM_LoadPanelButtons, + + 0, 0, // save panel offsets + ARRAYSIZE(IHNM_SavePanelButtons), + IHNM_SavePanelButtons }; static GameResourceDescription IHNM_Resources = { diff --git a/saga/input.cpp b/saga/input.cpp index 608a10463b..c28292f083 100644 --- a/saga/input.cpp +++ b/saga/input.cpp @@ -104,7 +104,7 @@ int SagaEngine::processInput() { _render->toggleFlag(RF_RENDERPAUSE); break; default: - _interface->processKeyCode(event.kbd.keycode); + _interface->processAscii(event.kbd.ascii); break; } break; diff --git a/saga/interface.cpp b/saga/interface.cpp index 8a65268933..4bf5af9265 100644 --- a/saga/interface.cpp +++ b/saga/interface.cpp @@ -148,6 +148,8 @@ Interface::Interface(SagaEngine *vm) : _vm(vm), _initialized(false) { _optionPanel.x = _vm->getDisplayInfo().optionPanelXOffset; _optionPanel.y = _vm->getDisplayInfo().optionPanelYOffset; _optionPanel.currentButton = NULL; + _optionSaveFileSlider = _optionPanel.getButton(_vm->getDisplayInfo().optionSaveFileSliderIndex); + _optionSaveFilePanel = _optionPanel.getButton(_vm->getDisplayInfo().optionSaveFilePanelIndex); _active = false; _panelMode = _lockedMode = kPanelNull; @@ -164,6 +166,8 @@ Interface::Interface(SagaEngine *vm) : _vm(vm), _initialized(false) { _inventorySize = ITE_INVENTORY_SIZE; _saveReminderState = 0; + _optionSaveFileTop = 0; + _inventory = (uint16 *)calloc(_inventorySize, sizeof(uint16)); if (_inventory == NULL) { error("Interface::Interface(): not enough memory"); @@ -225,7 +229,7 @@ void Interface::restoreMode() { void Interface::setMode(int mode, bool force) { // TODO: Is this where we should hide/show the mouse cursor? - + debug(0, "Interface::setMode %i", mode); if (mode == kPanelMain) { _inMainMode = true; _saveReminderState = 1; //TODO: blinking timeout @@ -255,6 +259,8 @@ void Interface::setMode(int mode, bool force) { if (_panelMode == kPanelOption) { _optionPanel.currentButton = NULL; _vm->fillSaveList(); + calcOptionSaveSlider(); + _optionSaveFileTitleNumber = 0; } } } @@ -262,12 +268,12 @@ void Interface::setMode(int mode, bool force) { draw(); } -bool Interface::processKeyCode(int keyCode) { +bool Interface::processAscii(uint16 ascii) { int i; PanelButton *panelButton; switch (_panelMode) { case kPanelNull: - if (keyCode == 27) {// Esc + if (ascii == 27) {// Esc if (_vm->_scene->isInDemo()) { _vm->_scene->skipScene(); } else { @@ -278,10 +284,13 @@ bool Interface::processKeyCode(int keyCode) { break; case kPanelOption: //TODO: check input dialog keys + if (ascii == 27) {// Esc + ascii = 'c'; //continue + } for (i = 0; i < _optionPanel.buttonsCount; i++) { panelButton = &_optionPanel.buttons[i]; if(panelButton->type == kPanelButtonOption) { - if (panelButton->keyChar == keyCode) { + if (panelButton->ascii == ascii) { setOption(panelButton); return true; } @@ -291,7 +300,7 @@ bool Interface::processKeyCode(int keyCode) { case kPanelMain: for (i = 0; i < _mainPanel.buttonsCount; i++) { panelButton = &_mainPanel.buttons[i]; - if (panelButton->keyChar == keyCode) { + if (panelButton->ascii == ascii) { if (panelButton->type == kPanelButtonVerb) { _vm->_script->setVerb(panelButton->id); } @@ -301,9 +310,16 @@ bool Interface::processKeyCode(int keyCode) { return true; } } + if (ascii == 15) // ctrl-o + { + if (_saveReminderState > 0) { + setMode(kPanelOption); + return true; + } + } break; case kPanelConverse: - switch (keyCode) { + switch (ascii) { case 'x': setMode(kPanelMain); if (_vm->_puzzle->isActive()) @@ -322,7 +338,7 @@ bool Interface::processKeyCode(int keyCode) { case '2': case '3': case '4': - converseSetPos(keyCode); + converseSetPos(ascii); break; } @@ -444,10 +460,52 @@ void Interface::draw() { drawInventory(backBuffer); } +void Interface::calcOptionSaveSlider() { + int totalFiles = _vm->getSaveFileNameCount(); + int visibleFiles = _vm->getDisplayInfo().optionSaveFileVisible; + int height = _optionSaveFileSlider->height; + int sliderHeight; + int pos; + + if (totalFiles < visibleFiles) { + totalFiles = visibleFiles; + } + + sliderHeight = visibleFiles * height / totalFiles; + if (sliderHeight < 7) { + sliderHeight = 7; + } + + if (totalFiles - visibleFiles <= 0) { + pos = 0; + } else { + pos = _optionSaveFileTop * (height - sliderHeight) / (totalFiles - visibleFiles); + } + _optionPanel.calcPanelButtonRect(_optionSaveFileSlider, _optionSaveRectTop); + _optionSaveRectBottom = _optionSaveRectSlider = _optionSaveRectTop; + + _optionSaveRectTop.bottom = _optionSaveRectTop.top + pos; + _optionSaveRectTop.top++; + _optionSaveRectTop.right--; + + _optionSaveRectSlider.top = _optionSaveRectTop.bottom; + _optionSaveRectSlider.bottom = _optionSaveRectSlider.top + sliderHeight; + + _optionSaveRectBottom.top = _optionSaveRectSlider.bottom; + _optionSaveRectBottom.right--; +} + void Interface::drawOption() { + const char *text; SURFACE *backBuffer; int i; + int fontHeight; + uint j, idx; + int fgColor; + int bgColor; Point origin; + Rect rect; + Rect rect2; PanelButton *panelButton; backBuffer = _vm->_gfx->getBackBuffer(); @@ -461,20 +519,82 @@ void Interface::drawOption() { if(panelButton->type == kPanelButtonOption) { drawOptionPanelButtonText(backBuffer, panelButton); } + if (panelButton->type == kPanelButtonOptionText) { + text = _vm->getTextString(panelButton->id); + _optionPanel.calcPanelButtonRect(panelButton, rect); + _vm->_font->draw(MEDIUM_FONT_ID, backBuffer, text, 0, rect.left , rect.top, + _vm->getDisplayInfo().verbTextColor, _vm->getDisplayInfo().verbTextShadowColor, FONT_SHADOW); //TODO: create Option button colors constant + } + } + + if(_optionSaveRectTop.height() > 0) { + drawRect(backBuffer, _optionSaveRectTop, kITEColorDarkGrey); } + + drawButtonBox(backBuffer, _optionSaveRectSlider, true, _optionSaveFileSlider->state > 0); + + if(_optionSaveRectBottom.height() > 0) { + drawRect(backBuffer, _optionSaveRectBottom, kITEColorDarkGrey); + } + + _optionPanel.calcPanelButtonRect(_optionSaveFilePanel, rect); + rect2 = rect; + fontHeight = _vm->_font->getHeight(SMALL_FONT_ID); + for (j = 0; j < _vm->getDisplayInfo().optionSaveFileVisible; j++) { + bgColor = kITEColorDarkGrey0C; + fgColor = kITEColorBrightWhite; + + idx = j + _optionSaveFileTop; + if (idx == _optionSaveFileTitleNumber) { + SWAP(bgColor, fgColor); + } + if (idx < _vm->getSaveFileNameCount()) { + rect2.top = rect.top + j * (fontHeight + 1); + rect2.bottom = rect2.top + fontHeight; + backBuffer->fillRect(rect2, bgColor); + text = _vm->getSaveFileName(idx); + _vm->_font->draw(SMALL_FONT_ID, backBuffer, text, 0, + rect.left + 1, rect2.top, fgColor, 0, 0); + } + } + } void Interface::handleOptionUpdate(const Point& mousePoint) { int i; + int16 mouseY; + Rect rect; + int totalFiles = _vm->getSaveFileNameCount(); + int visibleFiles = _vm->getDisplayInfo().optionSaveFileVisible; + + if (_vm->mouseButtonPressed()) { + if (_optionSaveFileSlider->state > 0) { + _optionPanel.calcPanelButtonRect(_optionSaveFileSlider, rect); + + mouseY = mousePoint.y - rect.top -_optionSaveFileMouseOff; + + if (totalFiles - visibleFiles <= 0) { + _optionSaveFileTop = 0; + } else { + _optionSaveFileTop = mouseY * (totalFiles - visibleFiles) / + (_optionSaveFileSlider->height - _optionSaveRectSlider.height()); + } + + _optionSaveFileTop = clamp(0, _optionSaveFileTop, _vm->getSaveFileNameCount() - _vm->getDisplayInfo().optionSaveFileVisible); + calcOptionSaveSlider(); + } + } + _optionPanel.currentButton = optionHitTest(mousePoint); - bool released = (_optionPanel.currentButton != NULL) && (_optionPanel.currentButton->state > 0) && (!_vm->mouseButtonPressed()); + bool releasedButton = (_optionPanel.currentButton != NULL) && (_optionPanel.currentButton->state > 0) && (!_vm->mouseButtonPressed()); + if (!_vm->mouseButtonPressed()) { for (i = 0; i < _optionPanel.buttonsCount; i++) { _optionPanel.buttons[i].state = 0; } } - if (released) { + if (releasedButton) { setOption(_optionPanel.currentButton); } @@ -483,6 +603,7 @@ void Interface::handleOptionUpdate(const Point& mousePoint) { void Interface::handleOptionClick(const Point& mousePoint) { int i; + Rect rect; _optionPanel.currentButton = optionHitTest(mousePoint); for (i = 0; i < _optionPanel.buttonsCount; i++) { @@ -492,18 +613,50 @@ void Interface::handleOptionClick(const Point& mousePoint) { if (_optionPanel.currentButton == NULL) { return; } + + if (_optionPanel.currentButton == _optionSaveFileSlider) { + if ((_optionSaveRectTop.height() > 0) && (mousePoint.y < _optionSaveRectTop.bottom)) { + _optionSaveFileTop -= _vm->getDisplayInfo().optionSaveFileVisible; + } else { + if ((_optionSaveRectBottom.height() > 0) && (mousePoint.y >= _optionSaveRectBottom.top)) { + _optionSaveFileTop += _vm->getDisplayInfo().optionSaveFileVisible; + } else { + if (_vm->getDisplayInfo().optionSaveFileVisible < _vm->getSaveFileNameCount()) { + _optionSaveFileMouseOff = mousePoint.y - _optionSaveRectSlider.top; + _optionPanel.currentButton->state = 1; + } + } + } - _optionPanel.currentButton->state = 1; - + _optionSaveFileTop = clamp(0, _optionSaveFileTop, _vm->getSaveFileNameCount() - _vm->getDisplayInfo().optionSaveFileVisible); + calcOptionSaveSlider(); + } else { + if (_optionPanel.currentButton == _optionSaveFilePanel) { + _optionPanel.calcPanelButtonRect(_optionSaveFilePanel, rect); + _optionSaveFileTitleNumber = (mousePoint.y - rect.top) / (_vm->_font->getHeight(SMALL_FONT_ID) + 1); + if (_optionSaveFileTitleNumber < 0) { + _optionSaveFileTitleNumber = 0; + } + if (_optionSaveFileTitleNumber >= _vm->getDisplayInfo().optionSaveFileVisible) { + _optionSaveFileTitleNumber = _vm->getDisplayInfo().optionSaveFileVisible - 1; + } + _optionSaveFileTitleNumber += _optionSaveFileTop; + if (_optionSaveFileTitleNumber >= _vm->getSaveFileNameCount()) { + _optionSaveFileTitleNumber = _vm->getSaveFileNameCount() - 1; + } + } else { + _optionPanel.currentButton->state = 1; + } + } } void Interface::setOption(PanelButton *panelButton) { - switch (panelButton->keyChar) { - case 'c': + switch (panelButton->id) { + case kTextContinuePlaying: setMode(kPanelMain); break; - case 'q': + case kTextQuitGame: _vm->shutDown(); break; } @@ -511,7 +664,7 @@ void Interface::setOption(PanelButton *panelButton) { void Interface::update(const Point& mousePoint, int updateFlag) { - if (_vm->_scene->isInDemo() || _panelMode == kPanelFade) { + if (_vm->_scene->isInDemo() || _panelMode == kPanelFade || !_active) { return; } @@ -842,11 +995,37 @@ void Interface::setVerbState(int verb, int state) { draw(); } -void Interface::drawButtonBox(SURFACE *ds, const Rect& rect, bool down) { - byte cornerColor = 0x8b; - byte frameColor = 0x0f; - byte fillColor = 0x96; - byte odl = 0x8a, our = 0x94, idl = 0x97, iur = 0x95; +void Interface::drawButtonBox(SURFACE *ds, const Rect& rect, bool slider, bool down) { + byte cornerColor; + byte frameColor; + byte fillColor; + byte solidColor; + byte odl, our, idl, iur; + + if (slider) { + cornerColor = 0x8b; + frameColor = kITEColorBlack; + fillColor = kITEColorLightBlue96; + odl = kITEColorDarkBlue8a; + our = kITEColorLightBlue92; + idl = 0x89; + iur = 0x94; + solidColor = down ? kITEColorLightBlue94 : kITEColorLightBlue96; + } else { + cornerColor = 0x8b; + frameColor = kITEColorBlack; + solidColor = fillColor = kITEColorLightBlue96; + odl = kITEColorDarkBlue8a; + our = kITEColorLightBlue94; + idl = 0x97; + iur = 0x95; + if (down) { + SWAP(odl, our); + SWAP(idl, iur); + } + + } + int x = rect.left; int y = rect.top; int w = rect.width(); @@ -863,10 +1042,6 @@ void Interface::drawButtonBox(SURFACE *ds, const Rect& rect, bool down) { ds->vLine(x, y + 1, y + 1 + h - 2, frameColor); ds->vLine(xe, y + 1, y + 1 + h - 2, frameColor); - if (down) { - SWAP(odl, our); - SWAP(idl, iur); - } x++; y++; xe--; @@ -895,19 +1070,31 @@ void Interface::drawButtonBox(SURFACE *ds, const Rect& rect, bool down) { w -= 2; h -= 2; Common::Rect fill(x, y, x + w, y + h); - ds->fillRect(fill, fillColor); + ds->fillRect(fill, solidColor); } void Interface::drawOptionPanelButtonText(SURFACE *ds, PanelButton *panelButton) { const char *text; + int textId; int textWidth; int textHeight; Point point; int textColor; Rect rect; -//TODO: draw box! - text = _vm->getTextString(panelButton->id); + textId = panelButton->id; + switch(panelButton->id) { + case(kTextReadingSpeed): + textId = kTextFast; + break; + case(kTextMusic): + textId = kTextOn; + break; + case(kTextSound): + textId = kTextOn; + break; + } + text = _vm->getTextString(textId); textWidth = _vm->_font->getStringWidth(MEDIUM_FONT_ID, text, 0, 0); textHeight = _vm->_font->getHeight(MEDIUM_FONT_ID); @@ -922,7 +1109,7 @@ void Interface::drawOptionPanelButtonText(SURFACE *ds, PanelButton *panelButton) } _optionPanel.calcPanelButtonRect(panelButton, rect); - drawButtonBox(ds, rect, panelButton->state > 0); + drawButtonBox(ds, rect, false, panelButton->state > 0); _vm->_font->draw(MEDIUM_FONT_ID, ds, text, 0, point.x , point.y, textColor, _vm->getDisplayInfo().verbTextShadowColor, FONT_SHADOW); //TODO: create Option button colors constant } @@ -1207,7 +1394,7 @@ void Interface::handleConverseClick(const Point& mousePoint) { } if (_conversePanel.currentButton->type == kPanelButtonConverseText) { - converseSetPos(_conversePanel.currentButton->keyChar); + converseSetPos(_conversePanel.currentButton->ascii); } if (_conversePanel.currentButton->type == kPanelButtonArrow) { diff --git a/saga/interface.h b/saga/interface.h index 8690d1a1ee..72c6805a2d 100644 --- a/saga/interface.h +++ b/saga/interface.h @@ -134,10 +134,16 @@ enum ITEColors { kITEColorLightGrey = 0x04, kITEColorGrey = 0x0a, kITEColorDarkGrey = 0x0b, + kITEColorDarkGrey0C = 0x0C, kITEColorGreen = 0xba, kITEColorBlack = 0x0f, kITEColorRed = 0x65, - kITEColorBlue = 0x93 + kITEColorDarkBlue8a = 0x8a, + kITEColorBlue89 = 0x89, + kITEColorLightBlue92 = 0x92, + kITEColorBlue = 0x93, + kITEColorLightBlue94 = 0x94, + kITEColorLightBlue96 = 0x96 }; @@ -175,7 +181,7 @@ public: void drawStatusBar(); void setVerbState(int verb, int state); - bool processKeyCode(int keyCode); + bool processAscii(uint16 ascii); private: void drawInventory(SURFACE *backBuffer); @@ -219,7 +225,7 @@ private: void handleConverseClick(const Point& mousePoint); // converse panel click PanelButton *optionHitTest(const Point& mousePoint) { - return _optionPanel.hitTest(mousePoint, kPanelAllButtons); + return _optionPanel.hitTest(mousePoint, kPanelButtonOptionSaveFiles | kPanelButtonOption | kPanelButtonOptionSlider); } void handleOptionUpdate(const Point& mousePoint); // option panel update void handleOptionClick(const Point& mousePoint); // option panel click @@ -230,11 +236,11 @@ private: void setOption(PanelButton *panelButton); void drawOptionPanelButtonText(SURFACE *ds, PanelButton *panelButton); - void drawButtonBox(SURFACE *ds, const Rect& rect, bool down); + void drawButtonBox(SURFACE *ds, const Rect &rect, bool slider, bool down); void drawPanelButtonArrow(SURFACE *ds, InterfacePanel *panel, PanelButton *panelButton); void drawVerbPanelText(SURFACE *ds, PanelButton *panelButton, int textColor, int textShadowColor); void drawVerbPanel(SURFACE *backBuffer, PanelButton* panelButton); - + void calcOptionSaveSlider(); public: void converseInit(void); void converseClear(void); @@ -267,6 +273,8 @@ private: SpriteList _scenePortraits; PanelButton *_verbTypeToPanelButton[kVerbTypesMax]; InterfacePanel _optionPanel; + PanelButton * _optionSaveFileSlider; + PanelButton * _optionSaveFilePanel; int _saveReminderState; bool _active; @@ -296,6 +304,14 @@ private: int _converseStartPos; int _converseEndPos; int _conversePos; + + uint _optionSaveFileTop; + uint _optionSaveFileTitleNumber; + int16 _optionSaveFileMouseOff; + Rect _optionSaveRectTop; + Rect _optionSaveRectSlider; + Rect _optionSaveRectBottom; + }; } // End of namespace Saga diff --git a/saga/puzzle.cpp b/saga/puzzle.cpp index 1a0a96c130..aeab8e3354 100644 --- a/saga/puzzle.cpp +++ b/saga/puzzle.cpp @@ -351,7 +351,7 @@ void Puzzle::giveHint(void) { if (_hintCount < 3) { _vm->_actor->nonActorSpeech(&hintStr[_lang][_hintCount], 1, 0 ); } else { - int piece; + int piece = 0; for (i = PUZZLE_PIECES - 1; i >= 0; i--) { piece = _piecePriority[i]; diff --git a/saga/saga.h b/saga/saga.h index b482cd0e4f..3e219f7bbd 100644 --- a/saga/saga.h +++ b/saga/saga.h @@ -151,8 +151,13 @@ enum PanelButtonType { kPanelButtonArrow = 2, kPanelButtonConverseText = 4, kPanelButtonInventory = 8, + kPanelButtonOption = 0x10, - kPanelButtonSlider = 0x20, + kPanelButtonOptionSlider = 0x20, + kPanelButtonOptionSaveFiles = 0x40, + kPanelButtonOptionText = 0x80, + + kPanelButtonReserved = 0x100, kPanelAllButtons = 0xFFFFF }; @@ -328,7 +333,7 @@ struct PanelButton { int width; int height; int id; - int keyChar; + uint16 ascii; int state; int upSpriteNumber; int downSpriteNumber; @@ -384,10 +389,29 @@ struct GameDisplayInfo { int conversePanelButtonsCount; PanelButton *conversePanelButtons; + int optionSaveFilePanelIndex; + int optionSaveFileSliderIndex; + uint optionSaveFileVisible; + int optionPanelXOffset; int optionPanelYOffset; int optionPanelButtonsCount; PanelButton *optionPanelButtons; + + int quitPanelXOffset; + int quitPanelYOffset; + int quitPanelButtonsCount; + PanelButton *quitPanelButtons; + + int loadPanelXOffset; + int loadPanelYOffset; + int loadPanelButtonsCount; + PanelButton *loadPanelButtons; + + int savePanelXOffset; + int savePanelYOffset; + int savePanelButtonsCount; + PanelButton *savePanelButtons; }; @@ -470,6 +494,12 @@ public: void fillSaveList(); char *calcSaveFileName(uint slotNumber); char *getSaveFileName(uint idx); + bool saveListFull() const { + return _saveFileNamesMaxCount == _saveFileNamesCount; + } + uint getSaveFileNameCount() const { + return saveListFull() ? _saveFileNamesCount : _saveFileNamesCount + 1; + } int _soundEnabled; int _musicEnabled; @@ -545,6 +575,7 @@ public: private: Common::String _targetName; + uint _saveFileNamesMaxCount; uint _saveFileNamesCount; char _saveFileNames[MAX_SAVES][SAVE_TITLE_SIZE]; Point _mousePos; diff --git a/saga/saveload.cpp b/saga/saveload.cpp index 9c1f009291..18ed8d0f9b 100644 --- a/saga/saveload.cpp +++ b/saga/saveload.cpp @@ -48,6 +48,8 @@ struct SaveGameHeader { char name[SAVE_TITLE_SIZE]; }; +static char emptySlot[] = "[New Save Game]"; + //TODO: // - delete savegame @@ -61,7 +63,11 @@ char *SagaEngine::getSaveFileName(uint idx) { if (idx >= MAX_SAVES) { error("getSaveFileName wrong idx"); } - return _saveFileNames[idx]; + if (saveListFull()) { + return _saveFileNames[idx]; + } else { + return (idx == 0) ? emptySlot : _saveFileNames[idx - 1]; + } } @@ -76,11 +82,16 @@ void SagaEngine::fillSaveList() { name[strlen(name) - 2] = 0; _saveFileMan->listSavefiles(name, marks, MAX_SAVES); + _saveFileNamesMaxCount = 0; for (i = 0; i < MAX_SAVES; i++) { + if (marks[i]) { + _saveFileNamesMaxCount++; + } _saveFileNames[i][0] = 0; } _saveFileNamesCount = 0; + i = 0; while (i < MAX_SAVES) { if (marks[i]) { @@ -99,6 +110,13 @@ void SagaEngine::fillSaveList() { } i++; } + + for (i = 0; i < MAX_SAVES; i++) { + sprintf(_saveFileNames[i], "test%i",i); + } + + _saveFileNamesCount = 14; + } |