[Scummvm-cvs-logs] CVS: scummvm/sword2 controls.cpp,1.64,1.65 controls.h,1.12,1.13 resman.cpp,1.87,1.88 save_rest.cpp,1.48,1.49 sword2.cpp,1.104,1.105 sword2.h,1.50,1.51
Torbj?rn Andersson
eriktorbjorn at users.sourceforge.net
Thu Mar 4 00:25:02 CET 2004
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sword2 controls.cpp,1.62.2.2,1.62.2.3 controls.h,1.12,1.12.2.1 resman.cpp,1.87,1.87.2.1 save_rest.cpp,1.48,1.48.2.1 sword2.cpp,1.104,1.104.2.1 sword2.h,1.50,1.50.2.1
- Next message: [Scummvm-cvs-logs] CVS: scummvm/dists/msevc4/scumm scumm.vcp,1.5,1.5.2.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/sword2
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10862
Modified Files:
controls.cpp controls.h resman.cpp save_rest.cpp sword2.cpp
sword2.h
Log Message:
If the user has previous savegames, display a restart/restore dialog when
the game starts. (I know it could look prettier, but I don't have much to
work with here...)
Index: controls.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/controls.cpp,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- controls.cpp 1 Mar 2004 07:56:33 -0000 1.64
+++ controls.cpp 4 Mar 2004 08:03:32 -0000 1.65
@@ -148,16 +148,16 @@
FontRendererGui(Gui *gui, int fontId);
~FontRendererGui();
- void fetchText(int textId, uint8 *buf);
+ void fetchText(uint32 textId, uint8 *buf);
int getCharWidth(uint8 c);
int getCharHeight(uint8 c);
int getTextWidth(uint8 *text);
- int getTextWidth(int textId);
+ int getTextWidth(uint32 textId);
void drawText(uint8 *text, int x, int y, int alignment = kAlignLeft);
- void drawText(int textId, int x, int y, int alignment = kAlignLeft);
+ void drawText(uint32 textId, int x, int y, int alignment = kAlignLeft);
};
FontRendererGui::FontRendererGui(Gui *gui, int fontId)
@@ -186,7 +186,7 @@
_gui->_vm->_graphics->deleteSurface(_glyph[i]._data);
}
-void FontRendererGui::fetchText(int textId, uint8 *buf) {
+void FontRendererGui::fetchText(uint32 textId, uint8 *buf) {
uint8 *data = _gui->_vm->fetchTextLine(_gui->_vm->_resman->openResource(textId / SIZE), textId & 0xffff);
int i;
@@ -220,7 +220,7 @@
return textWidth;
}
-int FontRendererGui::getTextWidth(int textId) {
+int FontRendererGui::getTextWidth(uint32 textId) {
uint8 text[MAX_STRING_LEN];
fetchText(textId, text);
@@ -259,7 +259,7 @@
}
}
-void FontRendererGui::drawText(int textId, int x, int y, int alignment) {
+void FontRendererGui::drawText(uint32 textId, int x, int y, int alignment) {
uint8 text[MAX_STRING_LEN];
fetchText(textId, text);
@@ -784,20 +784,23 @@
};
/**
- * A "mini" dialog is basically a yes/no question.
+ * A "mini" dialog is usually a yes/no question, but also used for the
+ * restart/restore dialog at the beginning of the game.
*/
class MiniDialog : public Dialog {
private:
- int _textId;
+ uint32 _headerTextId;
+ uint32 _okTextId;
+ uint32 _cancelTextId;
FontRendererGui *_fr;
Widget *_panel;
Button *_okButton;
Button *_cancelButton;
public:
- MiniDialog(Gui *gui, uint32 textId)
- : Dialog(gui), _textId(textId) {
+ MiniDialog(Gui *gui, uint32 headerTextId, uint32 okTextId = 149618688, uint32 cancelTextId = 149618689)
+ : Dialog(gui), _headerTextId(headerTextId), _okTextId(okTextId), _cancelTextId(cancelTextId) {
_fr = new FontRendererGui(_gui, _gui->_vm->_controlsFontId);
_panel = new Widget(this, 1);
@@ -821,9 +824,10 @@
virtual void paint() {
Dialog::paint();
- _fr->drawText(_textId, 310, 134, FontRendererGui::kAlignCenter);
- _fr->drawText(149618688, 270, 214); // ok
- _fr->drawText(149618689, 270, 276); // cancel
+ if (_headerTextId)
+ _fr->drawText(_headerTextId, 310, 134, FontRendererGui::kAlignCenter);
+ _fr->drawText(_okTextId, 270, 214);
+ _fr->drawText(_cancelTextId, 270, 276);
}
virtual void onAction(Widget *widget, int result = 0) {
@@ -938,7 +942,7 @@
int maxWidth = 0;
int width;
- int alignTextIds[] = {
+ uint32 alignTextIds[] = {
149618700, // object labels
149618702, // music volume
149618703, // speech volume
@@ -1572,6 +1576,26 @@
_vm->_system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false);
}
+bool Gui::startControl(void) {
+ while (1) {
+ MiniDialog startDialog(this, 0, 149618693, 149618690);
+
+ if (startDialog.run())
+ return true;
+
+ if (_vm->_quit)
+ return false;
+
+ if (restoreControl())
+ return false;
+
+ if (_vm->_quit)
+ return false;
+ }
+
+ return true;
+}
+
void Gui::quitControl(void) {
MiniDialog quitDialog(this, 149618692);
Index: controls.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/controls.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- controls.h 6 Jan 2004 13:44:17 -0000 1.12
+++ controls.h 4 Mar 2004 08:03:32 -0000 1.13
@@ -43,6 +43,7 @@
uint32 restoreControl(void);
void saveControl(void);
+ bool startControl(void);
void quitControl(void);
void restartControl(void);
void optionControl(void);
Index: resman.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/resman.cpp,v
retrieving revision 1.87
retrieving revision 1.88
diff -u -d -r1.87 -r1.88
--- resman.cpp 5 Feb 2004 14:19:04 -0000 1.87
+++ resman.cpp 4 Mar 2004 08:03:32 -0000 1.88
@@ -65,6 +65,10 @@
ResourceManager::ResourceManager(Sword2Engine *vm) {
_vm = vm;
+ // Until proven differently, assume we're on CD 1. This is so the start
+ // dialog will be able to play any music at all.
+ _curCd = 1;
+
// We read in the resource info which tells us the names of the
// resource cluster files ultimately, although there might be groups
// within the clusters at this point it makes no difference. We only
@@ -99,7 +103,7 @@
// all the files now extract the filenames
do {
// item must have an #0d0a
- while(temp->ad[j] != 13) {
+ while (temp->ad[j] != 13) {
_resourceFiles[_totalClusters][pos] = temp->ad[j];
j++;
pos++;
Index: save_rest.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/save_rest.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- save_rest.cpp 5 Feb 2004 14:19:05 -0000 1.48
+++ save_rest.cpp 4 Mar 2004 08:03:32 -0000 1.49
@@ -438,6 +438,13 @@
return SR_OK;
}
+bool Sword2Engine::saveExists(void) {
+ for (int i = 0; i <= 99; i++)
+ if (saveExists(i))
+ return true;
+ return false;
+}
+
bool Sword2Engine::saveExists(uint16 slotNo) {
char saveFileName[MAX_FILENAME_LEN];
SaveFileManager *mgr = _system->get_savefile_manager();
Index: sword2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sword2.cpp,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- sword2.cpp 5 Feb 2004 14:19:05 -0000 1.104
+++ sword2.cpp 4 Mar 2004 08:03:32 -0000 1.105
@@ -312,11 +312,25 @@
if (_saveSlot != -1) {
if (saveExists(_saveSlot))
restoreGame(_saveSlot);
- else { // show restore menu
+ else {
setMouse(NORMAL_MOUSE_ID);
if (!_gui->restoreControl())
startGame();
}
+ } else if (saveExists()) {
+ int32 pars[2] = { 221, FX_LOOP };
+ bool result;
+
+ setMouse(NORMAL_MOUSE_ID);
+ _logic->fnPlayMusic(pars);
+ result = _gui->startControl();
+ _logic->fnStopMusic(NULL);
+
+ if (_quit)
+ return;
+
+ if (result)
+ startGame();
} else
startGame();
Index: sword2.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sword2.h,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- sword2.h 5 Feb 2004 14:19:05 -0000 1.50
+++ sword2.h 4 Mar 2004 08:03:32 -0000 1.51
@@ -314,6 +314,7 @@
uint32 saveGame(uint16 slotNo, uint8 *description);
uint32 restoreGame(uint16 slotNo);
uint32 getSaveDescription(uint16 slotNo, uint8 *description);
+ bool saveExists(void);
bool saveExists(uint16 slotNo);
void fillSaveBuffer(Memory *buffer, uint32 size, uint8 *desc);
uint32 restoreFromBuffer(Memory *buffer, uint32 size);
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/sword2 controls.cpp,1.62.2.2,1.62.2.3 controls.h,1.12,1.12.2.1 resman.cpp,1.87,1.87.2.1 save_rest.cpp,1.48,1.48.2.1 sword2.cpp,1.104,1.104.2.1 sword2.h,1.50,1.50.2.1
- Next message: [Scummvm-cvs-logs] CVS: scummvm/dists/msevc4/scumm scumm.vcp,1.5,1.5.2.1
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list