SCUMM: Eliminate need to expose MacDialogWindow outside of MacGui

The plan is to eventually hide as much of the MacGui implementation as
possible from the rest of the engine, and only provide a minimal
macgui.h for it to use.
This commit is contained in:
Torbjörn Andersson 2023-12-10 08:57:51 +01:00 committed by Torbjörn Andersson
parent fb2bd1166d
commit aa35d449a6
3 changed files with 25 additions and 13 deletions

View File

@ -168,19 +168,17 @@ Common::KeyState ScummEngine::mac_showOldStyleBannerAndPause(const char *msg, in
// Fetch the translated string for the message...
convertMessageToString((const byte *)msg, (byte *)bannerMsg, sizeof(bannerMsg));
MacGui::MacDialogWindow *window = _macGui->drawBanner(bannerMsg);
Common::KeyState ks = Common::KEYCODE_INVALID;
_macGui->drawBanner(bannerMsg);
if (waitTime) {
bool leftBtnPressed = false, rightBtnPressed = false;
waitForBannerInput(waitTime, ks, leftBtnPressed, rightBtnPressed);
}
delete window;
_macGui->undrawBanner();
clearClickedStatus();
_messageBannerActive = false;
return ks;

View File

@ -59,6 +59,7 @@ MacGui::MacGui(ScummEngine *vm, Common::String resourceFile) : _vm(vm), _system(
}
MacGui::~MacGui() {
delete _bannerWindow;
delete _windowManager;
}
@ -877,17 +878,26 @@ bool MacGui::runRestartDialog() {
return runOkCancelDialog("Are you sure you want to restart this game from the beginning?");
}
MacGui::MacDialogWindow *MacGui::drawBanner(char *message) {
MacGui::MacDialogWindow *window = createWindow(
void MacGui::drawBanner(char *message) {
if (_bannerWindow)
undrawBanner();
_bannerWindow = createWindow(
Common::Rect(70, 189, 570, 211),
kStyleRounded);
const Graphics::Font *font = getFont(_vm->_game.id == GID_INDY3 ? kIndy3FontMedium : kLoomFontMedium);
Graphics::Surface *s = window->innerSurface();
Graphics::Surface *s = _bannerWindow->innerSurface();
font->drawString(s, (char *)message, 0, 0, s->w, kBlack, Graphics::kTextAlignCenter);
window->show();
return window;
_bannerWindow->show();
}
void MacGui::undrawBanner() {
if (_bannerWindow) {
delete _bannerWindow;
_bannerWindow = nullptr;
}
}
void MacGui::drawBitmap(Graphics::Surface *s, Common::Rect r, const uint16 *bitmap, Color color) const {

View File

@ -37,12 +37,17 @@ class ScummEngine;
class Actor;
class MacGui {
public:
class MacDialogWindow;
protected:
ScummEngine *_vm = nullptr;
OSystem *_system = nullptr;
Graphics::MacWindowManager *_windowManager = nullptr;
Graphics::Surface *_surface = nullptr;
MacGui::MacDialogWindow *_bannerWindow = nullptr;
Common::String _resourceFile;
bool _menuIsActive = false;
@ -135,8 +140,6 @@ protected:
bool runOkCancelDialog(Common::String text);
public:
class MacDialogWindow;
class MacGuiObject {
protected:
bool _redraw = false;
@ -611,7 +614,8 @@ public:
MacDialogWindow *createWindow(Common::Rect bounds, MacDialogWindowStyle style = kStyleNormal);
MacDialogWindow *createDialog(int dialogId);
MacDialogWindow *drawBanner(char *message);
void drawBanner(char *message);
void undrawBanner();
void drawBitmap(Graphics::Surface *s, Common::Rect r, const uint16 *bitmap, Color color) const;
};