diff options
author | Max Horn | 2002-10-19 01:22:41 +0000 |
---|---|---|
committer | Max Horn | 2002-10-19 01:22:41 +0000 |
commit | 7198181b093732592d678fc95c64698fe0470715 (patch) | |
tree | de94c24039a14ae90c575440fb47824ff887fd56 /scumm | |
parent | ee13e1638980f8503e8ea04cd676acf1f41197fc (diff) | |
download | scummvm-rg350-7198181b093732592d678fc95c64698fe0470715.tar.gz scummvm-rg350-7198181b093732592d678fc95c64698fe0470715.tar.bz2 scummvm-rg350-7198181b093732592d678fc95c64698fe0470715.zip |
reworked the way the save/load dialog works. yup, still not perfect, but we're hopefully getting closer. Feedback welcome
svn-id: r5189
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/dialogs.cpp | 100 | ||||
-rw-r--r-- | scumm/dialogs.h | 13 |
2 files changed, 88 insertions, 25 deletions
diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp index c1aec50393..3d846c60fc 100644 --- a/scumm/dialogs.cpp +++ b/scumm/dialogs.cpp @@ -307,47 +307,63 @@ SaveLoadDialog::SaveLoadDialog(NewGui *gui, Scumm *scumm) // addResText(10, 7, 240, 16, 2); // addResText(10, 7, 240, 16, 3); - addButton(200, 20, queryResString(4), kSaveCmd, 'S'); // Save - addButton(200, 40, queryResString(5), kLoadCmd, 'L'); // Load + _saveButton = (PushButtonWidget *)addPushButton(200, 20, queryResString(4), kSaveCmd, 'S'); + _loadButton = (PushButtonWidget *)addPushButton(200, 40, queryResString(5), kLoadCmd, 'L'); addButton(200, 60, queryResString(6), kPlayCmd, 'P'); // Play addButton(200, 80, queryCustomString(17), kOptionsCmd, 'O'); // Options addButton(200, 100, queryResString(8), kQuitCmd, 'Q'); // Quit _savegameList = new ListWidget(this, 10, 20, 180, 90); - _savegameList->setNumberingMode(kListNumberingZero); - - // Get savegame names - ScummVM::StringList l; - char name[32]; +} - for (int i = 0; i <= 80; i++) { // 80 - got this value from the old GUI - _scumm->getSavegameName(i, name); - l.push_back(name); - } +void SaveLoadDialog::open() +{ + _saveMode = false; + _saveButton->setState(false); + _loadButton->setState(true); + fillList(); - _savegameList->setList(l); + ScummDialog::open(); } void SaveLoadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { switch (cmd) { - case kListItemActivatedCmd: case kSaveCmd: - if (_savegameList->getSelected() >= 1 && !_savegameList->getSelectedString().isEmpty()) { - _scumm->_saveLoadSlot = _savegameList->getSelected(); - _scumm->_saveLoadCompatible = false; - _scumm->_saveLoadFlag = 1; // 1 for save, I assume (Painelf) - strcpy(_scumm->_saveLoadName, _savegameList->getSelectedString().c_str()); - close(); + if (!_saveMode) { + _saveMode = true; + _saveButton->setState(true); + _loadButton->setState(false); + fillList(); + draw(); } break; - case kListItemDoubleClickedCmd: case kLoadCmd: + if (_saveMode) { + _saveMode = false; + _saveButton->setState(false); + _loadButton->setState(true); + fillList(); + draw(); + } + break; + case kListItemDoubleClickedCmd: if (_savegameList->getSelected() >= 0 && !_savegameList->getSelectedString().isEmpty()) { - _scumm->_saveLoadSlot = _savegameList->getSelected(); - _scumm->_saveLoadCompatible = false; - _scumm->_saveLoadFlag = 2; // 2 for load. Magic number anyone? - close(); + if (_saveMode) { + // Start editing the selected item, for saving + _savegameList->startEditMode(); + } else { + load(); + } + } + break; + case kListItemActivatedCmd: + if (_savegameList->getSelected() >= 0 && !_savegameList->getSelectedString().isEmpty()) { + if (_saveMode) { + save(); + } else { + load(); + } } break; case kPlayCmd: @@ -364,9 +380,45 @@ void SaveLoadDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat } } +void SaveLoadDialog::fillList() +{ + // Get savegame names + ScummVM::StringList l; + char name[32]; + int i = _saveMode ? 1 : 0; + + for (; i <= 80; i++) { // 80 - got this value from the old GUI + _scumm->getSavegameName(i, name); + l.push_back(name); + } + + _savegameList->setList(l); + _savegameList->setNumberingMode(_saveMode ? kListNumberingOne : kListNumberingZero); +} + +void SaveLoadDialog::save() +{ + // Save the selected item + _scumm->_saveLoadSlot = _savegameList->getSelected() + 1; + _scumm->_saveLoadCompatible = false; + _scumm->_saveLoadFlag = 1; // 1 for save, I assume (Painelf) + strcpy(_scumm->_saveLoadName, _savegameList->getSelectedString().c_str()); + close(); +} + +void SaveLoadDialog::load() +{ + // Load the selected item + _scumm->_saveLoadSlot = _savegameList->getSelected(); + _scumm->_saveLoadCompatible = false; + _scumm->_saveLoadFlag = 2; // 2 for load. Magic number anyone? + close(); +} + #pragma mark - + enum { kMasterVolumeChanged = 'mavc', kMusicVolumeChanged = 'muvc', diff --git a/scumm/dialogs.h b/scumm/dialogs.h index 8f3f752148..2a3dde696f 100644 --- a/scumm/dialogs.h +++ b/scumm/dialogs.h @@ -51,10 +51,21 @@ class SaveLoadDialog : public ScummDialog { public: SaveLoadDialog(NewGui *gui, Scumm *scumm); + virtual void open(); + virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); protected: - ListWidget *_savegameList; + ListWidget *_savegameList; + + PushButtonWidget *_saveButton; + PushButtonWidget *_loadButton; + + bool _saveMode; + + void fillList(); + void save(); + void load(); }; |