aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTorbjörn Andersson2005-02-21 08:16:50 +0000
committerTorbjörn Andersson2005-02-21 08:16:50 +0000
commit8edce85e04a75907e668db286818ad868e3feed2 (patch)
treef594c90a1ab17231a4d1293fcd993466bf9eb5e9
parent224e0b7aa48ba8c5a68b4c8fa89e45a0cb5899c4 (diff)
downloadscummvm-rg350-8edce85e04a75907e668db286818ad868e3feed2.tar.gz
scummvm-rg350-8edce85e04a75907e668db286818ad868e3feed2.tar.bz2
scummvm-rg350-8edce85e04a75907e668db286818ad868e3feed2.zip
Some cleanup and renaming. (It was confusing to see "load" sometimes and
"restore" other times.) The save/restore dialog now has two separate classes, though they both inherit from the old combined class of course. svn-id: r16848
-rw-r--r--sword2/controls.cpp29
-rw-r--r--sword2/controls.h18
-rw-r--r--sword2/mouse.cpp4
-rw-r--r--sword2/resman.h4
-rw-r--r--sword2/sword2.cpp7
5 files changed, 36 insertions, 26 deletions
diff --git a/sword2/controls.cpp b/sword2/controls.cpp
index ece196e6c8..5d80b8ca8c 100644
--- a/sword2/controls.cpp
+++ b/sword2/controls.cpp
@@ -251,6 +251,9 @@ Dialog::Dialog(Sword2Engine *vm)
_vm->_screen->setFullPalette(CONTROL_PANEL_PALETTE);
_vm->_screen->clearScene();
+ // Usually the mouse pointer will already be "normal", but not always.
+ _vm->_mouse->setMouse(NORMAL_MOUSE_ID);
+
// HACK: Since the dialogs don't do normal scene updates we need to
// trigger a full redraw manually.
@@ -829,9 +832,9 @@ int StartDialog::runModal() {
if (_vm->_quit)
return 0;
- SaveLoadDialog loadDialog(_vm, kLoadDialog);
+ RestoreDialog restoreDialog(_vm);
- if (loadDialog.runModal())
+ if (restoreDialog.runModal())
return 0;
if (_vm->_quit)
@@ -1097,7 +1100,7 @@ public:
_parent->onAction(this, kSelectSlot);
if (_mode == kSaveDialog)
_parent->onAction(this, kStartEditing);
- } else if (_mode == kLoadDialog) {
+ } else if (_mode == kRestoreDialog) {
setState(0);
_parent->onAction(this, kDeselectSlot);
}
@@ -1141,7 +1144,7 @@ public:
}
};
-SaveLoadDialog::SaveLoadDialog(Sword2Engine *vm, int mode) : Dialog(vm) {
+SaveRestoreDialog::SaveRestoreDialog(Sword2Engine *vm, int mode) : Dialog(vm) {
int i;
_mode = mode;
@@ -1198,7 +1201,7 @@ SaveLoadDialog::SaveLoadDialog(Sword2Engine *vm, int mode) : Dialog(vm) {
registerWidget(_cancelButton);
}
-SaveLoadDialog::~SaveLoadDialog() {
+SaveRestoreDialog::~SaveRestoreDialog() {
delete _fr1;
delete _fr2;
}
@@ -1206,7 +1209,7 @@ SaveLoadDialog::~SaveLoadDialog() {
// There aren't really a hundred different button objects of course, there are
// only eight. Re-arrange them to simulate scrolling.
-void SaveLoadDialog::updateSlots() {
+void SaveRestoreDialog::updateSlots() {
for (int i = 0; i < 8; i++) {
Slot *slot = _slotButton[(baseSlot + i) % 8];
FontRendererGui *fr;
@@ -1239,7 +1242,7 @@ void SaveLoadDialog::updateSlots() {
}
}
-void SaveLoadDialog::drawEditBuffer(Slot *slot) {
+void SaveRestoreDialog::drawEditBuffer(Slot *slot) {
if (_selectedSlot == -1)
return;
@@ -1250,7 +1253,7 @@ void SaveLoadDialog::drawEditBuffer(Slot *slot) {
_fr2->drawText(_editBuffer, 130, 78 + (_selectedSlot - baseSlot) * 36);
}
-void SaveLoadDialog::onAction(Widget *widget, int result) {
+void SaveRestoreDialog::onAction(Widget *widget, int result) {
if (widget == _zupButton) {
if (baseSlot > 0) {
if (baseSlot >= 8)
@@ -1362,14 +1365,14 @@ void SaveLoadDialog::onAction(Widget *widget, int result) {
}
}
-void SaveLoadDialog::paint() {
+void SaveRestoreDialog::paint() {
Dialog::paint();
- _fr1->drawText((_mode == kLoadDialog) ? TEXT_RESTORE : TEXT_SAVE, 165, 377);
+ _fr1->drawText((_mode == kRestoreDialog) ? TEXT_RESTORE : TEXT_SAVE, 165, 377);
_fr1->drawText(TEXT_CANCEL, 382, 377);
}
-void SaveLoadDialog::setResult(int result) {
+void SaveRestoreDialog::setResult(int result) {
if (result) {
if (_selectedSlot == -1)
return;
@@ -1385,7 +1388,7 @@ void SaveLoadDialog::setResult(int result) {
Dialog::setResult(result);
}
-int SaveLoadDialog::runModal() {
+int SaveRestoreDialog::runModal() {
if (_mode == kSaveDialog)
_vm->_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true);
@@ -1400,7 +1403,7 @@ int SaveLoadDialog::runModal() {
if (_vm->saveGame(_selectedSlot, (byte *) &_editBuffer[_firstPos]) != SR_OK)
result = 0;
break;
- case kLoadDialog:
+ case kRestoreDialog:
if (_vm->restoreGame(_selectedSlot) != SR_OK)
result = 0;
break;
diff --git a/sword2/controls.h b/sword2/controls.h
index 9fa95a6b85..986b739961 100644
--- a/sword2/controls.h
+++ b/sword2/controls.h
@@ -38,7 +38,7 @@ class Slot;
enum {
kSaveDialog,
- kLoadDialog
+ kRestoreDialog
};
/**
@@ -96,7 +96,7 @@ public:
virtual void onAction(Widget *widget, int result = 0);
};
-class SaveLoadDialog : public Dialog {
+class SaveRestoreDialog : public Dialog {
private:
int _mode, _selectedSlot;
byte _editBuffer[SAVE_DESCRIPTION_LEN];
@@ -115,8 +115,8 @@ private:
Button *_cancelButton;
public:
- SaveLoadDialog(Sword2Engine *vm, int mode);
- ~SaveLoadDialog();
+ SaveRestoreDialog(Sword2Engine *vm, int mode);
+ ~SaveRestoreDialog();
void updateSlots();
void drawEditBuffer(Slot *slot);
@@ -166,6 +166,16 @@ public:
QuitDialog(Sword2Engine *vm);
virtual int runModal();
};
+
+class SaveDialog : public SaveRestoreDialog {
+public:
+ SaveDialog(Sword2Engine *vm) : SaveRestoreDialog(vm, kSaveDialog) {}
+};
+
+class RestoreDialog : public SaveRestoreDialog {
+public:
+ RestoreDialog(Sword2Engine *vm) : SaveRestoreDialog(vm, kRestoreDialog) {}
+};
} // End of namespace Sword2
diff --git a/sword2/mouse.cpp b/sword2/mouse.cpp
index a0ee7361ac..c2484e89cb 100644
--- a/sword2/mouse.cpp
+++ b/sword2/mouse.cpp
@@ -339,13 +339,13 @@ void Mouse::systemMenuMouse(void) {
break;
case 2:
{
- SaveLoadDialog dialog(_vm, kSaveDialog);
+ SaveDialog dialog(_vm);
dialog.runModal();
}
break;
case 3:
{
- SaveLoadDialog dialog(_vm, kLoadDialog);
+ RestoreDialog dialog(_vm);
dialog.runModal();
}
break;
diff --git a/sword2/resman.h b/sword2/resman.h
index 990e7f54eb..aca64e9627 100644
--- a/sword2/resman.h
+++ b/sword2/resman.h
@@ -26,7 +26,7 @@ class File;
namespace Sword2 {
#define MAX_MEM_CACHE (8 * 1024 * 1024) // we keep up to 8 megs of resource data files in memory
-#define MAX_res_files 20
+#define MAX_res_files 20
class Sword2Engine;
@@ -90,7 +90,7 @@ private:
ResourceFile _resFiles[MAX_res_files];
Resource *_resList;
- Resource *_cacheStart, *_cacheEnd;
+ Resource *_cacheStart, *_cacheEnd;
uint32 _usedMem; // amount of used memory in bytes
};
diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp
index d023ebdfb5..347b11beaa 100644
--- a/sword2/sword2.cpp
+++ b/sword2/sword2.cpp
@@ -235,7 +235,7 @@ int Sword2Engine::init(GameDetector &detector) {
_system->endGFXTransaction();
// Create the debugger as early as possible (but not before the
- // graphics object!) so that errors can be displayed in it. In
+ // screen object!) so that errors can be displayed in it. In
// particular, we want errors about missing files to be clearly
// visible to the user.
@@ -273,10 +273,7 @@ int Sword2Engine::init(GameDetector &detector) {
if (saveExists(_saveSlot))
restoreGame(_saveSlot);
else {
- SaveLoadDialog dialog(this, kLoadDialog);
-
- _mouse->setMouse(NORMAL_MOUSE_ID);
-
+ RestoreDialog dialog(this);
if (!dialog.runModal())
startGame();
}