Skip to content

Commit

Permalink
SCUMM: MACGUI: Fall back on using no Mac GUI for unrecognized versions
Browse files Browse the repository at this point in the history
Rather than crashing, allow the user to continue playing the
unrecognized Mac version, albeit without the Mac GUI. Certain other Mac
aspects may still survive.
  • Loading branch information
Torbjörn Andersson committed Nov 14, 2024
1 parent 5da62c9 commit 286c6b8
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 16 deletions.
4 changes: 2 additions & 2 deletions engines/scumm/macgui/macgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ int MacGui::getNumColors() const {
return _impl->getNumColors();
}

void MacGui::initialize() {
_impl->initialize();
bool MacGui::initialize() {
return _impl->initialize();
}

void MacGui::reset() {
Expand Down
2 changes: 1 addition & 1 deletion engines/scumm/macgui/macgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class MacGui {

int getNumColors() const;

void initialize();
bool initialize();
void reset();
void update(int delta);
void updateWindowManager();
Expand Down
7 changes: 6 additions & 1 deletion engines/scumm/macgui/macgui_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ void MacGuiImpl::menuCallback(int id, Common::String &name, void *data) {
}
}

void MacGuiImpl::initialize() {
bool MacGuiImpl::initialize() {
if (!readStrings())
return false;

uint32 menuMode = Graphics::kWMModeNoDesktop | Graphics::kWMModeAutohideMenu |
Graphics::kWMModalMenuMode | Graphics::kWMModeNoCursorOverride | Graphics::kWMModeForceMacFonts;

Expand Down Expand Up @@ -286,6 +289,8 @@ void MacGuiImpl::initialize() {
break;
}
}

return true;
}

bool MacGuiImpl::handleMenu(int id, Common::String &name) {
Expand Down
4 changes: 2 additions & 2 deletions engines/scumm/macgui/macgui_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class MacGuiImpl {

bool runOkCancelDialog(Common::String text);

void readStrings();
bool readStrings();
void parseSTRSBlock(uint8 *strsData, MacSTRSParsingEntry *parsingTable, int parsingTableSize);

// These are non interactable, no point in having them as widgets for now...
Expand Down Expand Up @@ -708,7 +708,7 @@ class MacGuiImpl {
virtual bool handleEvent(Common::Event event);

static void menuCallback(int id, Common::String &name, void *data);
virtual void initialize();
virtual bool initialize();
void updateWindowManager();

const Graphics::Font *getFont(FontId fontId);
Expand Down
2 changes: 0 additions & 2 deletions engines/scumm/macgui/macgui_indy3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -928,8 +928,6 @@ MacIndy3Gui::MacIndy3Gui(ScummEngine *vm, const Common::Path &resourceFile) :

_dirtyRects.clear();
_textArea.create(448, 47, Graphics::PixelFormat::createFormatCLUT8());

readStrings();
}

MacIndy3Gui::~MacIndy3Gui() {
Expand Down
1 change: 0 additions & 1 deletion engines/scumm/macgui/macgui_loom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ MacLoomGui::MacLoomGui(ScummEngine *vm, const Common::Path &resourceFile) : MacG
// a large screen, and it's not saved.

_practiceBoxPos = Common::Point(215, 376 + 2 * _vm->_macScreenDrawOffset);
readStrings();
}

MacLoomGui::~MacLoomGui() {
Expand Down
8 changes: 4 additions & 4 deletions engines/scumm/macgui/macgui_strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,13 +602,13 @@ static MacGuiImpl::MacSTRSParsingEntry strsIndy4FloppyVariant2Table[] = {
#undef SKIP_C
#undef SKIP_P

void MacGuiImpl::readStrings() {
bool MacGuiImpl::readStrings() {
Common::MacResManager resource;
resource.open(_resourceFile);
uint32 strsLen = resource.getResLength(MKTAG('S', 'T', 'R', 'S'), 0);

if (strsLen <= 0)
return;
return false;

Common::SeekableReadStream *strsStream = resource.getResource(MKTAG('S', 'T', 'R', 'S'), 0);
uint8 *strsBlock = (uint8 *)malloc(strsLen);
Expand Down Expand Up @@ -676,8 +676,6 @@ void MacGuiImpl::readStrings() {
parsingTableSize = ARRAYSIZE(strsIndy4CDVariant2Table);
break;
}
} else {
error("MacGuiImpl::readStrings(): String parsing table not defined for this game");
}

if (parsingTable)
Expand All @@ -687,6 +685,8 @@ void MacGuiImpl::readStrings() {

free(strsBlock);
delete strsStream;

return parsingTable != nullptr;
}

void MacGuiImpl::parseSTRSBlock(uint8 *strsData, MacSTRSParsingEntry *parsingTable, int parsingTableSize) {
Expand Down
1 change: 0 additions & 1 deletion engines/scumm/macgui/macgui_v5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ namespace Scumm {
// ===========================================================================

MacV5Gui::MacV5Gui(ScummEngine *vm, const Common::Path &resourceFile) : MacGuiImpl(vm, resourceFile) {
readStrings();
}

const Graphics::Font *MacV5Gui::getFontByScummId(int32 id) {
Expand Down
8 changes: 6 additions & 2 deletions engines/scumm/scumm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1335,8 +1335,12 @@ Common::Error ScummEngine::init() {

memset(_completeScreenBuffer, 0, 320 * 200);

if (_macGui)
_macGui->initialize();
if (_macGui) {
if (!_macGui->initialize()) {
delete _macGui;
_macGui = nullptr;
}
}
}

// Initialize backend
Expand Down

0 comments on commit 286c6b8

Please sign in to comment.