mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-03 15:41:41 +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 "message.h"
|
||||||
#include "newgui.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)
|
: Dialog(gui, 30, 20, 260, 124)
|
||||||
{
|
{
|
||||||
// First, determine the size the dialog needs. For this we have to break
|
// 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 *str = message.c_str();
|
||||||
const char *start = str;
|
const char *start = str;
|
||||||
int lineWidth, maxlineWidth = 0;
|
int lineWidth, maxlineWidth = 0;
|
||||||
int lineCount;
|
int lineCount, okButtonPos, cancelButtonPos;
|
||||||
|
|
||||||
while (*str) {
|
while (*str) {
|
||||||
if (*str == '\n') {
|
if (*str == '\n') {
|
||||||
@ -55,7 +60,7 @@ MessageDialog::MessageDialog(NewGui *gui, const String &message, uint32 timer, b
|
|||||||
_w = maxlineWidth + 20;
|
_w = maxlineWidth + 20;
|
||||||
lineCount = lines.size();
|
lineCount = lines.size();
|
||||||
_h = lineCount * kLineHeight + 16;
|
_h = lineCount * kLineHeight + 16;
|
||||||
if (showButton)
|
if (showOkButton || showCancelButton)
|
||||||
_h += 24;
|
_h += 24;
|
||||||
|
|
||||||
if (_h > 180) {
|
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
|
// FIXME - allow for multiple buttons, and return in runModal() which one
|
||||||
// was selected.
|
// was selected.
|
||||||
if (showButton)
|
if (showOkButton && showCancelButton) {
|
||||||
addButton((_w - kButtonWidth)/2, _h - 24, "OK", kCloseCmd, '\n'); // Confirm dialog
|
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)
|
if (timer)
|
||||||
_timer = _gui->get_time() + timer;
|
_timer = _gui->get_time() + timer;
|
||||||
@ -134,3 +149,16 @@ int MessageDialog::addLine(StringList &lines, const char *line, int size)
|
|||||||
return maxWidth;
|
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::String String;
|
||||||
typedef ScummVM::StringList StringList;
|
typedef ScummVM::StringList StringList;
|
||||||
public:
|
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 handleTickle();
|
||||||
|
void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32 _timer;
|
uint32 _timer;
|
||||||
|
@ -27,9 +27,8 @@
|
|||||||
#include "scumm/sound.h"
|
#include "scumm/sound.h"
|
||||||
#include "common/map.h"
|
#include "common/map.h"
|
||||||
#include "common/str.h"
|
#include "common/str.h"
|
||||||
|
#include "gui/message.h"
|
||||||
#include <stdio.h>
|
#include "dialogs.h"
|
||||||
|
|
||||||
|
|
||||||
uint16 newTag2Old(uint32 oldTag);
|
uint16 newTag2Old(uint32 oldTag);
|
||||||
|
|
||||||
@ -75,9 +74,11 @@ void Scumm::openRoom(int room)
|
|||||||
}
|
}
|
||||||
if (!(_features & GF_SMALL_HEADER)) {
|
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]);
|
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]);
|
sprintf(buf, "%s.he%.1d", _exe_name, room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||||
else
|
else
|
||||||
sprintf(buf, "%s.%.3d", _exe_name, room == 0 ? 0 : res.roomno[rtRoom][room]);
|
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)) {
|
if (openResourceFile(buf)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
askForDisk(buf);
|
askForDisk(buf, room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
sprintf(buf, "disk%.2d.lec", res.roomno[rtRoom][room]);
|
sprintf(buf, "disk%.2d.lec", room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||||
_encbyte = 0x69;
|
_encbyte = 0x69;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -115,7 +116,7 @@ void Scumm::openRoom(int room)
|
|||||||
error("Room %d not in %s", room, buf);
|
error("Room %d not in %s", room, buf);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
askForDisk(buf);
|
askForDisk(buf, room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -123,7 +124,7 @@ void Scumm::openRoom(int room)
|
|||||||
_encbyte = 0;
|
_encbyte = 0;
|
||||||
if (openResourceFile(buf))
|
if (openResourceFile(buf))
|
||||||
break;
|
break;
|
||||||
askForDisk(buf);
|
askForDisk(buf, room == 0 ? 0 : res.roomno[rtRoom][room]);
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
deleteRoomOffsets();
|
deleteRoomOffsets();
|
||||||
@ -199,9 +200,25 @@ bool Scumm::openResourceFile(const char *filename)
|
|||||||
return _fileHandle.isOpen();
|
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()
|
void Scumm::readIndexFile()
|
||||||
|
@ -321,7 +321,7 @@ public:
|
|||||||
void pauseDialog();
|
void pauseDialog();
|
||||||
void saveloadDialog();
|
void saveloadDialog();
|
||||||
void optionsDialog();
|
void optionsDialog();
|
||||||
void displayError(const char *message, ...);
|
char displayError(bool showCancel, const char *message, ...);
|
||||||
|
|
||||||
// Misc startup/event functions
|
// Misc startup/event functions
|
||||||
void main();
|
void main();
|
||||||
@ -512,7 +512,7 @@ public:
|
|||||||
void closeRoom();
|
void closeRoom();
|
||||||
void deleteRoomOffsets();
|
void deleteRoomOffsets();
|
||||||
void readRoomsOffsets();
|
void readRoomsOffsets();
|
||||||
void askForDisk(const char *filename);
|
void askForDisk(const char *filename, int disknum);
|
||||||
bool openResourceFile(const char *filename);
|
bool openResourceFile(const char *filename);
|
||||||
void loadPtrToResource(int type, int i, byte *ptr);
|
void loadPtrToResource(int type, int i, byte *ptr);
|
||||||
void readResTypeList(int id, uint32 tag, const char *name);
|
void readResTypeList(int id, uint32 tag, const char *name);
|
||||||
|
@ -474,7 +474,7 @@ int Scumm::scummLoop(int delta)
|
|||||||
|
|
||||||
makeSavegameName(filename, _saveLoadSlot, _saveLoadCompatible);
|
makeSavegameName(filename, _saveLoadSlot, _saveLoadCompatible);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
displayError(errMsg, filename);
|
displayError(false, errMsg, filename);
|
||||||
} else if (_saveLoadFlag == 1 && _saveLoadSlot != 0 && !_saveLoadCompatible) {
|
} else if (_saveLoadFlag == 1 && _saveLoadSlot != 0 && !_saveLoadCompatible) {
|
||||||
// Display "Save succesful" message, except for auto saves
|
// Display "Save succesful" message, except for auto saves
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
@ -1065,18 +1065,20 @@ void Scumm::optionsDialog()
|
|||||||
runDialog(_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_list va;
|
||||||
|
|
||||||
va_start(va, message);
|
va_start(va, message);
|
||||||
vsprintf(buf, message, va);
|
vsprintf(buf, message, va);
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
Dialog *dialog = new MessageDialog(_newgui, buf);
|
Dialog *dialog = new MessageDialog(_newgui, buf, 0, true, showCancel);
|
||||||
runDialog(dialog);
|
result = runDialog(dialog);
|
||||||
delete dialog;
|
delete dialog;
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scumm::shutDown(int i)
|
void Scumm::shutDown(int i)
|
||||||
|
@ -958,8 +958,10 @@ void Sound::playBundleMusic(char * song) {
|
|||||||
// FIXME: we have MUSDISK1.BUN and MUSDISK2.BUN in COMI.
|
// FIXME: we have MUSDISK1.BUN and MUSDISK2.BUN in COMI.
|
||||||
_outputMixerSize = 66150; // ((22050 * 2 * 2) / 4) * 3
|
_outputMixerSize = 66150; // ((22050 * 2 * 2) / 4) * 3
|
||||||
if (_scumm->_gameId == GID_CMI) {
|
if (_scumm->_gameId == GID_CMI) {
|
||||||
|
char bunfile[20];
|
||||||
|
sprintf(bunfile, "musdisk%d.bun", _scumm->_vars[_scumm->VAR_CURRENTDISK]);
|
||||||
printf("Opening bundle\n");
|
printf("Opening bundle\n");
|
||||||
if (_scumm->_bundle->openMusicFile("musdisk1.bun", _scumm->getGameDataPath()) == false)
|
if (_scumm->_bundle->openMusicFile(bunfile, _scumm->getGameDataPath()) == false)
|
||||||
return;
|
return;
|
||||||
_outputMixerSize = 88140; // ((22050 * 2 * 2)
|
_outputMixerSize = 88140; // ((22050 * 2 * 2)
|
||||||
} else {
|
} else {
|
||||||
@ -1123,11 +1125,11 @@ int Sound::playBundleSound(char *sound) {
|
|||||||
byte * ptr;
|
byte * ptr;
|
||||||
bool result;
|
bool result;
|
||||||
|
|
||||||
if (_scumm->_gameId == GID_CMI)
|
if (_scumm->_gameId == GID_CMI) {
|
||||||
// FIXME: HACK! There are actually two voice files in COMI... I dunno how to do this
|
char voxfile[20];
|
||||||
// right, though :-/
|
sprintf(voxfile, "voxdisk%d.bun", _scumm->_vars[_scumm->VAR_CURRENTDISK]);
|
||||||
result = _scumm->_bundle->openVoiceFile("voxdisk1.bun", _scumm->getGameDataPath());
|
result = _scumm->_bundle->openVoiceFile(voxfile, _scumm->getGameDataPath());
|
||||||
else if (_scumm->_gameId == GID_DIG)
|
} else if (_scumm->_gameId == GID_DIG)
|
||||||
result = _scumm->_bundle->openVoiceFile("digvoice.bun", _scumm->getGameDataPath());
|
result = _scumm->_bundle->openVoiceFile("digvoice.bun", _scumm->getGameDataPath());
|
||||||
else
|
else
|
||||||
error("Don't know which bundle file to load");
|
error("Don't know which bundle file to load");
|
||||||
|
Loading…
Reference in New Issue
Block a user