mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-02 23:26:44 +00:00
Plop in some better disk switching code for CMI - I have no idea how well this will work transitioning from a disk1 room to a disk2
room in-game, but it works for bootparams and saved games.. svn-id: r6322
This commit is contained in:
parent
3c3c5bb574
commit
9df455ce38
@ -22,8 +22,13 @@
|
||||
#include "message.h"
|
||||
#include "newgui.h"
|
||||
|
||||
enum {
|
||||
kOkCmd = 'OK ',
|
||||
kCancelCmd = 'CNCL'
|
||||
};
|
||||
|
||||
MessageDialog::MessageDialog(NewGui *gui, const String &message, uint32 timer, bool showButton)
|
||||
|
||||
MessageDialog::MessageDialog(NewGui *gui, const String &message, uint32 timer, bool showOkButton, bool showCancelButton)
|
||||
: Dialog(gui, 30, 20, 260, 124)
|
||||
{
|
||||
// First, determine the size the dialog needs. For this we have to break
|
||||
@ -34,7 +39,7 @@ MessageDialog::MessageDialog(NewGui *gui, const String &message, uint32 timer, b
|
||||
const char *str = message.c_str();
|
||||
const char *start = str;
|
||||
int lineWidth, maxlineWidth = 0;
|
||||
int lineCount;
|
||||
int lineCount, okButtonPos, cancelButtonPos;
|
||||
|
||||
while (*str) {
|
||||
if (*str == '\n') {
|
||||
@ -55,7 +60,7 @@ MessageDialog::MessageDialog(NewGui *gui, const String &message, uint32 timer, b
|
||||
_w = maxlineWidth + 20;
|
||||
lineCount = lines.size();
|
||||
_h = lineCount * kLineHeight + 16;
|
||||
if (showButton)
|
||||
if (showOkButton || showCancelButton)
|
||||
_h += 24;
|
||||
|
||||
if (_h > 180) {
|
||||
@ -72,8 +77,18 @@ MessageDialog::MessageDialog(NewGui *gui, const String &message, uint32 timer, b
|
||||
|
||||
// FIXME - allow for multiple buttons, and return in runModal() which one
|
||||
// was selected.
|
||||
if (showButton)
|
||||
addButton((_w - kButtonWidth)/2, _h - 24, "OK", kCloseCmd, '\n'); // Confirm dialog
|
||||
if (showOkButton && showCancelButton) {
|
||||
okButtonPos = (_w - (kButtonWidth * 2))/2;
|
||||
cancelButtonPos = ((_w - (kButtonWidth * 2))/2) + kButtonWidth + 10;
|
||||
} else {
|
||||
okButtonPos = cancelButtonPos = (_w-kButtonWidth)/2;
|
||||
}
|
||||
|
||||
if (showOkButton)
|
||||
addButton(okButtonPos, _h - 24, "OK", kOkCmd, '\n'); // Confirm dialog
|
||||
|
||||
if (showCancelButton)
|
||||
addButton(cancelButtonPos, _h - 24, "CANCEL", kCancelCmd, '\27'); // Cancel dialog
|
||||
|
||||
if (timer)
|
||||
_timer = _gui->get_time() + timer;
|
||||
@ -134,3 +149,16 @@ int MessageDialog::addLine(StringList &lines, const char *line, int size)
|
||||
return maxWidth;
|
||||
}
|
||||
|
||||
void MessageDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data)
|
||||
{
|
||||
if (cmd == kOkCmd) {
|
||||
setResult(1);
|
||||
close();
|
||||
} else if (cmd == kCancelCmd) {
|
||||
setResult(2);
|
||||
close();
|
||||
} else {
|
||||
Dialog::handleCommand(sender, cmd, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -29,9 +29,10 @@ class MessageDialog : public Dialog {
|
||||
typedef ScummVM::String String;
|
||||
typedef ScummVM::StringList StringList;
|
||||
public:
|
||||
MessageDialog(NewGui *gui, const String &message, uint32 timer = 0, bool showButton = true);
|
||||
MessageDialog(NewGui *gui, const String &message, uint32 timer = 0, bool showOKButton = true, bool showCancelButton = false);
|
||||
|
||||
void handleTickle();
|
||||
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
||||
|
||||
protected:
|
||||
uint32 _timer;
|
||||
|
@ -27,9 +27,8 @@
|
||||
#include "scumm/sound.h"
|
||||
#include "common/map.h"
|
||||
#include "common/str.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gui/message.h"
|
||||
#include "dialogs.h"
|
||||
|
||||
uint16 newTag2Old(uint32 oldTag);
|
||||
|
||||
@ -75,9 +74,11 @@ void Scumm::openRoom(int room)
|
||||
}
|
||||
if (!(_features & GF_SMALL_HEADER)) {
|
||||
|
||||
if (_features & GF_AFTER_V7)
|
||||
if (_features & GF_AFTER_V7) {
|
||||
if (room > 0)
|
||||
_vars[VAR_CURRENTDISK] = res.roomno[rtRoom][room];
|
||||
sprintf(buf, "%s.la%d", _exe_name, room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||
else if (_features & GF_HUMONGOUS)
|
||||
} else if (_features & GF_HUMONGOUS)
|
||||
sprintf(buf, "%s.he%.1d", _exe_name, room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||
else
|
||||
sprintf(buf, "%s.%.3d", _exe_name, room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||
@ -90,10 +91,10 @@ void Scumm::openRoom(int room)
|
||||
if (openResourceFile(buf)) {
|
||||
return;
|
||||
}
|
||||
askForDisk(buf);
|
||||
askForDisk(buf, room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||
|
||||
} else {
|
||||
sprintf(buf, "disk%.2d.lec", res.roomno[rtRoom][room]);
|
||||
sprintf(buf, "disk%.2d.lec", room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||
_encbyte = 0x69;
|
||||
}
|
||||
} else {
|
||||
@ -115,7 +116,7 @@ void Scumm::openRoom(int room)
|
||||
error("Room %d not in %s", room, buf);
|
||||
return;
|
||||
}
|
||||
askForDisk(buf);
|
||||
askForDisk(buf, room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||
}
|
||||
|
||||
do {
|
||||
@ -123,7 +124,7 @@ void Scumm::openRoom(int room)
|
||||
_encbyte = 0;
|
||||
if (openResourceFile(buf))
|
||||
break;
|
||||
askForDisk(buf);
|
||||
askForDisk(buf, room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||
} while (1);
|
||||
|
||||
deleteRoomOffsets();
|
||||
@ -199,9 +200,25 @@ bool Scumm::openResourceFile(const char *filename)
|
||||
return _fileHandle.isOpen();
|
||||
}
|
||||
|
||||
void Scumm::askForDisk(const char *filename)
|
||||
void Scumm::askForDisk(const char *filename, int disknum)
|
||||
{
|
||||
error("ask Cannot find '%s'", filename);
|
||||
char buf[128];
|
||||
|
||||
if (_features & GF_AFTER_V8) {
|
||||
char result;
|
||||
|
||||
sprintf(buf, "Cannot find file: '%s'\nInsert disk %d into drive %s\nHit Ok to retry, Cancel to exit", filename, disknum, getResDataPath());
|
||||
|
||||
result = displayError(true, buf);
|
||||
if (result == 2)
|
||||
error("Cannot find file: '%s'", filename);
|
||||
} else {
|
||||
sprintf(buf, "Cannot find file: '%s'", filename);
|
||||
InfoDialog* dialog = new InfoDialog(_newgui, this, (char*)buf);
|
||||
runDialog (dialog);
|
||||
delete dialog;
|
||||
error("Cannot find file: '%s'", filename);
|
||||
}
|
||||
}
|
||||
|
||||
void Scumm::readIndexFile()
|
||||
|
@ -321,7 +321,7 @@ public:
|
||||
void pauseDialog();
|
||||
void saveloadDialog();
|
||||
void optionsDialog();
|
||||
void displayError(const char *message, ...);
|
||||
char displayError(bool showCancel, const char *message, ...);
|
||||
|
||||
// Misc startup/event functions
|
||||
void main();
|
||||
@ -512,7 +512,7 @@ public:
|
||||
void closeRoom();
|
||||
void deleteRoomOffsets();
|
||||
void readRoomsOffsets();
|
||||
void askForDisk(const char *filename);
|
||||
void askForDisk(const char *filename, int disknum);
|
||||
bool openResourceFile(const char *filename);
|
||||
void loadPtrToResource(int type, int i, byte *ptr);
|
||||
void readResTypeList(int id, uint32 tag, const char *name);
|
||||
|
@ -474,7 +474,7 @@ int Scumm::scummLoop(int delta)
|
||||
|
||||
makeSavegameName(filename, _saveLoadSlot, _saveLoadCompatible);
|
||||
if (!success) {
|
||||
displayError(errMsg, filename);
|
||||
displayError(false, errMsg, filename);
|
||||
} else if (_saveLoadFlag == 1 && _saveLoadSlot != 0 && !_saveLoadCompatible) {
|
||||
// Display "Save succesful" message, except for auto saves
|
||||
char buf[1024];
|
||||
@ -1065,18 +1065,20 @@ void Scumm::optionsDialog()
|
||||
runDialog(_optionsDialog);
|
||||
}
|
||||
|
||||
void Scumm::displayError(const char *message, ...)
|
||||
char Scumm::displayError(bool showCancel, const char *message, ...)
|
||||
{
|
||||
char buf[1024];
|
||||
char buf[1024], result;
|
||||
va_list va;
|
||||
|
||||
va_start(va, message);
|
||||
vsprintf(buf, message, va);
|
||||
va_end(va);
|
||||
|
||||
Dialog *dialog = new MessageDialog(_newgui, buf);
|
||||
runDialog(dialog);
|
||||
Dialog *dialog = new MessageDialog(_newgui, buf, 0, true, showCancel);
|
||||
result = runDialog(dialog);
|
||||
delete dialog;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void Scumm::shutDown(int i)
|
||||
|
@ -958,8 +958,10 @@ void Sound::playBundleMusic(char * song) {
|
||||
// FIXME: we have MUSDISK1.BUN and MUSDISK2.BUN in COMI.
|
||||
_outputMixerSize = 66150; // ((22050 * 2 * 2) / 4) * 3
|
||||
if (_scumm->_gameId == GID_CMI) {
|
||||
char bunfile[20];
|
||||
sprintf(bunfile, "musdisk%d.bun", _scumm->_vars[_scumm->VAR_CURRENTDISK]);
|
||||
printf("Opening bundle\n");
|
||||
if (_scumm->_bundle->openMusicFile("musdisk1.bun", _scumm->getGameDataPath()) == false)
|
||||
if (_scumm->_bundle->openMusicFile(bunfile, _scumm->getGameDataPath()) == false)
|
||||
return;
|
||||
_outputMixerSize = 88140; // ((22050 * 2 * 2)
|
||||
} else {
|
||||
@ -1123,11 +1125,11 @@ int Sound::playBundleSound(char *sound) {
|
||||
byte * ptr;
|
||||
bool result;
|
||||
|
||||
if (_scumm->_gameId == GID_CMI)
|
||||
// FIXME: HACK! There are actually two voice files in COMI... I dunno how to do this
|
||||
// right, though :-/
|
||||
result = _scumm->_bundle->openVoiceFile("voxdisk1.bun", _scumm->getGameDataPath());
|
||||
else if (_scumm->_gameId == GID_DIG)
|
||||
if (_scumm->_gameId == GID_CMI) {
|
||||
char voxfile[20];
|
||||
sprintf(voxfile, "voxdisk%d.bun", _scumm->_vars[_scumm->VAR_CURRENTDISK]);
|
||||
result = _scumm->_bundle->openVoiceFile(voxfile, _scumm->getGameDataPath());
|
||||
} else if (_scumm->_gameId == GID_DIG)
|
||||
result = _scumm->_bundle->openVoiceFile("digvoice.bun", _scumm->getGameDataPath());
|
||||
else
|
||||
error("Don't know which bundle file to load");
|
||||
|
Loading…
Reference in New Issue
Block a user