diff options
author | Max Horn | 2003-11-02 02:18:16 +0000 |
---|---|---|
committer | Max Horn | 2003-11-02 02:18:16 +0000 |
commit | b27a871f870df854a6db0f4530d4596483927bb1 (patch) | |
tree | f6c75300cd5dcd22b67044256e36a01f985a054d | |
parent | f2c4bbbdbfb06b5296eb3fcdcb7235292e6ac039 (diff) | |
download | scummvm-rg350-b27a871f870df854a6db0f4530d4596483927bb1.tar.gz scummvm-rg350-b27a871f870df854a6db0f4530d4596483927bb1.tar.bz2 scummvm-rg350-b27a871f870df854a6db0f4530d4596483927bb1.zip |
turned NewGui into a singleton, and made OSystem a pseudo-singleton; added Widget::findWidget (preparing to add support for nested widgets, for the tab widget)
svn-id: r11045
46 files changed, 182 insertions, 233 deletions
diff --git a/backends/dc/vmsave.cpp b/backends/dc/vmsave.cpp index 9b57e583b8..a3e371e561 100644 --- a/backends/dc/vmsave.cpp +++ b/backends/dc/vmsave.cpp @@ -48,7 +48,6 @@ static int lastvm=-1; static void displaySaveResult(vmsaveResult res) { - extern NewGui *g_gui; char buf[1024]; switch(res) { @@ -69,7 +68,7 @@ static void displaySaveResult(vmsaveResult res) break; } - MessageDialog dialog(g_gui, buf); + MessageDialog dialog(buf); dialog.runModal(); } diff --git a/backends/wince/wince.cpp b/backends/wince/wince.cpp index f254763222..20e86811d5 100644 --- a/backends/wince/wince.cpp +++ b/backends/wince/wince.cpp @@ -362,7 +362,6 @@ GameDetector detector; Engine *engine; bool is_simon; bool is_bass; -NewGui *g_gui; extern Scumm *g_scumm; //extern SimonEngine *g_simon; //OSystem *g_system; @@ -851,9 +850,6 @@ void runGame(char *game_name) { mainClass = (OSystem_WINCE3*)system; - //g_system = system; - g_gui = new NewGui(system); - /* Start the engine */ is_simon = (strcmp(detector._plugin.getName(), "simon") == 0); diff --git a/base/gameDetector.cpp b/base/gameDetector.cpp index 0f2a8611a7..cc7f4a4b13 100644 --- a/base/gameDetector.cpp +++ b/base/gameDetector.cpp @@ -22,7 +22,6 @@ #include "stdafx.h" -#include "backends/intern.h" #include "base/engine.h" #include "base/gameDetector.h" #include "base/plugins.h" @@ -587,31 +586,6 @@ bool GameDetector::detectMain() { return true; } -OSystem *GameDetector::createSystem() { - int gfx_mode = parseGraphicsMode(ConfMan.get("gfx_mode")); // FIXME: Get rid of this again! - -#if defined(USE_NULL_DRIVER) - return OSystem_NULL_create(); -#elif defined(__DC__) - return OSystem_Dreamcast_create(); -#elif defined(X11_BACKEND) - return OSystem_X11_create(); -#elif defined(__MORPHOS__) - return OSystem_MorphOS_create(gfx_mode, ConfMan.getBool("fullscreen")); -#elif defined(_WIN32_WCE) - return OSystem_WINCE3_create(); -#elif defined(MACOS_CARBON) - return OSystem_MAC_create(gfx_mode, ConfMan.getBool("fullscreen")); -#elif defined(__GP32__) // ph0x - return OSystem_GP32_create(GFX_NORMAL, true); -#elif defined(__PALM_OS__) //chrilith - return OSystem_PALMOS_create(gfx_mode, ConfMan.getBool("fullscreen")); -#else - /* SDL is the default driver for now */ - return OSystem_SDL_create(gfx_mode); -#endif -} - Engine *GameDetector::createEngine(OSystem *sys) { assert(_plugin); return _plugin->createInstance(this, sys); diff --git a/base/gameDetector.h b/base/gameDetector.h index 8e161933e0..68c7afaa79 100644 --- a/base/gameDetector.h +++ b/base/gameDetector.h @@ -74,7 +74,6 @@ public: Engine *createEngine(OSystem *system); - static OSystem *createSystem(); static SoundMixer *createMixer(); static MidiDriver *createMidi(int midiDriver); diff --git a/base/main.cpp b/base/main.cpp index e8872a9b78..a494715a6a 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -83,9 +83,6 @@ const char *gScummVMBuildDate = __DATE__ " " __TIME__; const char *gScummVMFullVersion = "ScummVM 0.5.4cvs (" __DATE__ " " __TIME__ ")"; -NewGui *g_gui = 0; -OSystem *g_system = 0; - #if defined(WIN32) && defined(NO_CONSOLE) #include <cstdio> #define STDOUT_FILE TEXT("stdout.txt") @@ -186,7 +183,7 @@ static void launcherDialog(GameDetector &detector, OSystem *system) { system->set_palette(dummy_palette, 0, 16); - LauncherDialog dlg(g_gui, detector); + LauncherDialog dlg(detector); dlg.runModal(); } @@ -244,8 +241,7 @@ int main(int argc, char *argv[]) { detector.parseCommandLine(argc, argv); // Create the system object - OSystem *system = detector.createSystem(); - g_system = system; + OSystem *system = OSystem::instance(); // Create the timer services g_timer = new Timer(system); @@ -254,9 +250,6 @@ int main(int argc, char *argv[]) { prop.caption = gScummVMFullVersion; system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop); - // Create the GUI manager - g_gui = new NewGui(system); - // Unless a game was specified, show the launcher dialog if (detector._targetName.isEmpty()) launcherDialog(detector, system); @@ -307,8 +300,6 @@ int main(int argc, char *argv[]) { delete engine; } - delete g_gui; - // ...and quit (the return 0 should never be reached) system->quit(); delete system; diff --git a/common/debugger.cpp b/common/debugger.cpp index 8723ad317f..f47fee07f8 100644 --- a/common/debugger.cpp +++ b/common/debugger.cpp @@ -33,7 +33,7 @@ extern void force_keyboard(bool); namespace Common { template <class T> -Debugger<T>::Debugger(NewGui *gui) { +Debugger<T>::Debugger() { _frame_countdown = 0; _dvar_count = 0; _dcmd_count = 0; @@ -41,7 +41,7 @@ Debugger<T>::Debugger(NewGui *gui) { _isAttached = false; _errStr = NULL; _firstTime = true; - _debuggerDialog = new ConsoleDialog(gui, 1.0, 0.67F); + _debuggerDialog = new ConsoleDialog(1.0, 0.67F); _debuggerDialog->setInputCallback(debuggerInputCallback, this); _debuggerDialog->setCompletionCallback(debuggerCompletionCallback, this); } diff --git a/common/debugger.h b/common/debugger.h index f00910d8ea..7946e5940d 100644 --- a/common/debugger.h +++ b/common/debugger.h @@ -22,7 +22,6 @@ #define COMMON_DEBUGGER_H class ConsoleDialog; -class NewGui; namespace Common { @@ -32,7 +31,7 @@ namespace Common { template <class T> class Debugger { public: - Debugger(NewGui *gui); + Debugger(); virtual ~Debugger(); int DebugPrintf(const char *format, ...); diff --git a/common/module.mk b/common/module.mk index b55428edab..aac0ddda85 100644 --- a/common/module.mk +++ b/common/module.mk @@ -8,6 +8,7 @@ MODULE_OBJS := \ common/timer.o \ common/util.o \ common/savefile.o \ + common/system.o \ common/scaler/2xsai.o \ common/scaler/aspect.o \ common/scaler/hq2x.o \ diff --git a/common/singleton.h b/common/singleton.h index be40b45f42..89d912f69a 100644 --- a/common/singleton.h +++ b/common/singleton.h @@ -48,8 +48,8 @@ protected: ~Singleton<T>() { } private: - Singleton(const Singleton&); - Singleton& operator= (const Singleton&); + Singleton<T>(const Singleton<T>&); + Singleton<T>& operator= (const Singleton<T>&); }; } // End of namespace Common diff --git a/common/system.h b/common/system.h index 164316f71d..9350830d91 100644 --- a/common/system.h +++ b/common/system.h @@ -38,6 +38,9 @@ */ class OSystem { public: + static OSystem *instance(); + +public: typedef struct Mutex *MutexRef; typedef void (*SoundProc)(void *param, byte *buf, int len); typedef int (*TimerProc)(int interval); diff --git a/gui/EditTextWidget.cpp b/gui/EditTextWidget.cpp index 7807683978..9a72badb5b 100644 --- a/gui/EditTextWidget.cpp +++ b/gui/EditTextWidget.cpp @@ -33,14 +33,13 @@ EditTextWidget::EditTextWidget(Dialog *boss, int x, int y, int w, int h, const S _pos = _label.size(); - NewGui *gui = _boss->getGui(); - _labelOffset = (gui->getStringWidth(_label) - (_w - 6)); + _labelOffset = (g_gui.getStringWidth(_label) - (_w - 6)); if (_labelOffset < 0) _labelOffset = 0; } void EditTextWidget::handleTickle() { - uint32 time = _boss->getGui()->get_time(); + uint32 time = g_system->get_msecs(); if (_caretTime < time) { _caretTime = time + kCaretBlinkTime; if (_caretVisible) { @@ -56,7 +55,7 @@ void EditTextWidget::handleMouseDown(int x, int y, int button, int clickCount){ if (_caretVisible) drawCaret(true); - NewGui *gui = _boss->getGui(); + NewGui *gui = &g_gui; x += _labelOffset; @@ -90,7 +89,7 @@ bool EditTextWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) { case 27: // escape _label = _backupString; _pos = _label.size() - 1; - _labelOffset = (_boss->getGui()->getStringWidth(_label) - (_w-6)); + _labelOffset = (g_gui.getStringWidth(_label) - (_w-6)); if (_labelOffset < 0) _labelOffset = 0; _boss->releaseFocus(); @@ -144,24 +143,21 @@ bool EditTextWidget::handleKeyDown(uint16 ascii, int keycode, int modifiers) { } void EditTextWidget::drawWidget(bool hilite) { - NewGui *gui = _boss->getGui(); - // Draw a thin frame around us. - gui->hLine(_x, _y, _x + _w - 1, gui->_color); - gui->hLine(_x, _y + _h - 1, _x +_w - 1, gui->_shadowcolor); - gui->vLine(_x, _y, _y + _h - 1, gui->_color); - gui->vLine(_x + _w - 1, _y, _y + _h - 1, gui->_shadowcolor); + g_gui.hLine(_x, _y, _x + _w - 1, g_gui._color); + g_gui.hLine(_x, _y + _h - 1, _x +_w - 1, g_gui._shadowcolor); + g_gui.vLine(_x, _y, _y + _h - 1, g_gui._color); + g_gui.vLine(_x + _w - 1, _y, _y + _h - 1, g_gui._shadowcolor); // Draw the text adjustOffset(); - gui->drawString(_label, _x + 2, _y + 3, _w - 6, gui->_textcolor, kTextAlignLeft, -_labelOffset); + g_gui.drawString(_label, _x + 2, _y + 3, _w - 6, g_gui._textcolor, kTextAlignLeft, -_labelOffset); } int EditTextWidget::getCaretPos() { - NewGui *gui = _boss->getGui(); int caretpos = 0; for (int i = 0; i < _pos; i++) - caretpos += gui->getCharWidth(_label[i]); + caretpos += g_gui.getCharWidth(_label[i]); caretpos -= _labelOffset; @@ -173,17 +169,15 @@ void EditTextWidget::drawCaret(bool erase) { if (!isVisible() || !_boss->isVisible()) return; - NewGui *gui = _boss->getGui(); - - int16 color = erase ? gui->_bgcolor : gui->_textcolorhi; + int16 color = erase ? g_gui._bgcolor : g_gui._textcolorhi; int x = _x + _boss->getX() + 2; int y = _y + _boss->getY() + 1; int width = getCaretPos(); x += width; - gui->vLine(x, y, y + kLineHeight, color); - gui->addDirtyRect(x, y, 2, kLineHeight); + g_gui.vLine(x, y, y + kLineHeight, color); + g_gui.addDirtyRect(x, y, 2, kLineHeight); _caretVisible = !erase; } @@ -209,7 +203,7 @@ bool EditTextWidget::adjustOffset() { } else if (_labelOffset > 0) { - int width = _boss->getGui()->getStringWidth(_label); + int width = g_gui.getStringWidth(_label); if (width - _labelOffset < (_w - 6)) { // scroll right _labelOffset = (width - (_w - 6)); diff --git a/gui/EditTextWidget.h b/gui/EditTextWidget.h index 1b121c0a1f..a6fe8dbdce 100644 --- a/gui/EditTextWidget.h +++ b/gui/EditTextWidget.h @@ -31,10 +31,10 @@ class EditTextWidget : public StaticTextWidget { typedef Common::String String; protected: String _backupString; - bool _caretVisible; + bool _caretVisible; uint32 _caretTime; - int _pos; - int _labelOffset; + int _pos; + int _labelOffset; public: EditTextWidget(Dialog *boss, int x, int y, int w, int h, const String &text); diff --git a/gui/ListWidget.cpp b/gui/ListWidget.cpp index 2d3e9a7161..a205528cd4 100644 --- a/gui/ListWidget.cpp +++ b/gui/ListWidget.cpp @@ -84,7 +84,7 @@ void ListWidget::scrollBarRecalc() { } void ListWidget::handleTickle() { - uint32 time = _boss->getGui()->get_time(); + uint32 time = g_system->get_msecs(); if (_editMode && _caretTime < time) { _caretTime = time + kCaretBlinkTime; if (_caretVisible) { @@ -253,7 +253,7 @@ void ListWidget::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { } void ListWidget::drawWidget(bool hilite) { - NewGui *gui = _boss->getGui(); + NewGui *gui = &g_gui; int i, pos, len = _list.size(); Common::String buffer; @@ -290,7 +290,7 @@ void ListWidget::drawCaret(bool erase) { if (!isVisible() || !_boss->isVisible()) return; - NewGui *gui = _boss->getGui(); + NewGui *gui = &g_gui; // The item is selected, thus _bgcolor is used to draw the caret and _textcolorhi to erase it int16 color = erase ? gui->_textcolorhi : gui->_bgcolor; diff --git a/gui/PopUpWidget.cpp b/gui/PopUpWidget.cpp index d6b5af978d..62735a17b5 100644 --- a/gui/PopUpWidget.cpp +++ b/gui/PopUpWidget.cpp @@ -75,7 +75,7 @@ protected: }; PopUpDialog::PopUpDialog(PopUpWidget *boss, int clickX, int clickY) - : Dialog(boss->_boss->getGui(), 0, 0, 16, 16), + : Dialog(0, 0, 16, 16), _popUpBoss(boss) { // Copy the selection index _selection = _popUpBoss->_selectedItem; @@ -104,15 +104,15 @@ PopUpDialog::PopUpDialog(PopUpWidget *boss, int clickX, int clickY) _clickY = clickY - _y; // Time the popup was opened - _openTime = _gui->get_time(); + _openTime = g_system->get_msecs(); } void PopUpDialog::drawDialog() { // Draw the menu border - _gui->hLine(_x, _y, _x+_w - 1, _gui->_color); - _gui->hLine(_x, _y + _h - 1, _x + _w - 1, _gui->_shadowcolor); - _gui->vLine(_x, _y, _y+_h - 1, _gui->_color); - _gui->vLine(_x + _w - 1, _y, _y + _h - 1, _gui->_shadowcolor); + g_gui.hLine(_x, _y, _x+_w - 1, g_gui._color); + g_gui.hLine(_x, _y + _h - 1, _x + _w - 1, g_gui._shadowcolor); + g_gui.vLine(_x, _y, _y+_h - 1, g_gui._color); + g_gui.vLine(_x + _w - 1, _y, _y + _h - 1, g_gui._shadowcolor); // Draw the entries int count = _popUpBoss->_entries.size(); @@ -120,14 +120,14 @@ void PopUpDialog::drawDialog() { drawMenuEntry(i, i == _selection); } - _gui->addDirtyRect(_x, _y, _w, _h); + g_gui.addDirtyRect(_x, _y, _w, _h); } void PopUpDialog::handleMouseUp(int x, int y, int button, int clickCount) { // Mouse was released. If it wasn't moved much since the original mouse down, // let the popup stay open. If it did move, assume the user made his selection. int dist = (_clickX - x) * (_clickX - x) + (_clickY - y) * (_clickY - y); - if (dist > 3 * 3 || _gui->get_time() - _openTime > 300) { + if (dist > 3 * 3 || g_system->get_msecs() - _openTime > 300) { setResult(_selection); close(); } @@ -253,15 +253,15 @@ void PopUpDialog::drawMenuEntry(int entry, bool hilite) { int w = _w - 2; Common::String &name = _popUpBoss->_entries[entry].name; - _gui->fillRect(x, y, w, kLineHeight, hilite ? _gui->_textcolorhi : _gui->_bgcolor); + g_gui.fillRect(x, y, w, kLineHeight, hilite ? g_gui._textcolorhi : g_gui._bgcolor); if (name.size() == 0) { // Draw a seperator - _gui->hLine(x, y + kLineHeight / 2, x + w - 1, _gui->_color); - _gui->hLine(x + 1, y + 1 + kLineHeight / 2, x + w - 1, _gui->_shadowcolor); + g_gui.hLine(x, y + kLineHeight / 2, x + w - 1, g_gui._color); + g_gui.hLine(x + 1, y + 1 + kLineHeight / 2, x + w - 1, g_gui._shadowcolor); } else { - _gui->drawString(name, x + 1, y + 2, w - 2, hilite ? _gui->_bgcolor : _gui->_textcolor); + g_gui.drawString(name, x + 1, y + 2, w - 2, hilite ? g_gui._bgcolor : g_gui._textcolor); } - _gui->addDirtyRect(x, y, w, kLineHeight); + g_gui.addDirtyRect(x, y, w, kLineHeight); } @@ -315,7 +315,7 @@ void PopUpWidget::setSelected(int item) { } void PopUpWidget::drawWidget(bool hilite) { - NewGui *gui = _boss->getGui(); + NewGui *gui = &g_gui; // Draw a thin frame around us. // TODO - should look different than the EditTextWidget fram diff --git a/gui/ScrollBarWidget.cpp b/gui/ScrollBarWidget.cpp index 50bcde0e1f..a77752b570 100644 --- a/gui/ScrollBarWidget.cpp +++ b/gui/ScrollBarWidget.cpp @@ -212,7 +212,7 @@ void ScrollBarWidget::recalc() { } void ScrollBarWidget::drawWidget(bool hilite) { - NewGui *gui = _boss->getGui(); + NewGui *gui = &g_gui; int bottomY = _y + _h; bool isSinglePage = (_numEntries <= _entriesPerPage); diff --git a/gui/about.cpp b/gui/about.cpp index e94a6b9598..5ef2188c4c 100644 --- a/gui/about.cpp +++ b/gui/about.cpp @@ -24,8 +24,8 @@ #include "base/engine.h" #include "common/str.h" -AboutDialog::AboutDialog(NewGui *gui) - : Dialog(gui, 10, 20, 300, 124) { +AboutDialog::AboutDialog() + : Dialog(10, 20, 300, 124) { addButton((_w - kButtonWidth)/2, 100, "OK", kCloseCmd, '\r'); // Close dialog - FIXME Common::String version("ScummVM "); diff --git a/gui/about.h b/gui/about.h index 2453447896..744fbb9c6f 100644 --- a/gui/about.h +++ b/gui/about.h @@ -25,7 +25,7 @@ class AboutDialog : public Dialog { public: - AboutDialog(NewGui *gui); + AboutDialog(); }; #endif diff --git a/gui/browser.cpp b/gui/browser.cpp index af935c3c0b..44d4034068 100644 --- a/gui/browser.cpp +++ b/gui/browser.cpp @@ -19,9 +19,9 @@ */ #include "stdafx.h" -#include "browser.h" -#include "newgui.h" -#include "ListWidget.h" +#include "gui/browser.h" +#include "gui/newgui.h" +#include "gui/ListWidget.h" #include "backends/fs/fs.h" @@ -36,8 +36,8 @@ enum { kGoUpCmd = 'GoUp' }; -BrowserDialog::BrowserDialog(NewGui *gui, const char *title) - : Dialog(gui, 20, 10, 320 -2 * 20, 200 - 2 * 10), +BrowserDialog::BrowserDialog(const char *title) + : Dialog(20, 10, 320 -2 * 20, 200 - 2 * 10), _node(0), _nodeContent(0) { _fileList = NULL; diff --git a/gui/browser.h b/gui/browser.h index 640570ad41..847a50a24f 100644 --- a/gui/browser.h +++ b/gui/browser.h @@ -35,7 +35,7 @@ class BrowserDialog : public Dialog { typedef Common::String String; typedef Common::StringList StringList; public: - BrowserDialog(NewGui *gui, const char *title); + BrowserDialog(const char *title); virtual ~BrowserDialog(); virtual void open(); diff --git a/gui/chooser.cpp b/gui/chooser.cpp index ae88e1f007..b62dabdd70 100644 --- a/gui/chooser.cpp +++ b/gui/chooser.cpp @@ -27,8 +27,8 @@ enum { kChooseCmd = 'Chos' }; -ChooserDialog::ChooserDialog(NewGui *gui, const String title, const StringList& list) - : Dialog(gui, 8, 24, 320 -2 * 8, 141) { +ChooserDialog::ChooserDialog(const String title, const StringList& list) + : Dialog(8, 24, 320 -2 * 8, 141) { // Headline new StaticTextWidget(this, 10, 8, _w - 2 * 10, kLineHeight, title, kTextAlignCenter); diff --git a/gui/chooser.h b/gui/chooser.h index 81374bf3dc..3ba83b5cd4 100644 --- a/gui/chooser.h +++ b/gui/chooser.h @@ -36,7 +36,7 @@ class ChooserDialog : public Dialog { typedef Common::String String; typedef Common::StringList StringList; public: - ChooserDialog(NewGui *gui, const String title, const StringList &list); + ChooserDialog(const String title, const StringList &list); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); diff --git a/gui/console.cpp b/gui/console.cpp index c0fa4c0843..cc387dadbc 100644 --- a/gui/console.cpp +++ b/gui/console.cpp @@ -34,8 +34,8 @@ * to erase a single character, do scrolling etc. * - a *lot* of others things, this code is in no way complete and heavily under progress */ -ConsoleDialog::ConsoleDialog(NewGui *gui, float widthPercent, float heightPercent) - : Dialog(gui, 0, 0, 1, 1), +ConsoleDialog::ConsoleDialog(float widthPercent, float heightPercent) + : Dialog(0, 0, 1, 1), _widthPercent(widthPercent), _heightPercent(heightPercent) { // Setup basic layout/dialog size @@ -95,10 +95,10 @@ void ConsoleDialog::open() { void ConsoleDialog::drawDialog() { // Blend over the background - _gui->blendRect(_x, _y, _w, _h, _gui->_bgcolor, 2); + g_gui.blendRect(_x, _y, _w, _h, g_gui._bgcolor, 2); // Draw a border - _gui->hLine(_x, _y + _h - 1, _x + _w - 1, _gui->_color); + g_gui.hLine(_x, _y + _h - 1, _x + _w - 1, g_gui._color); // Draw text int start = _scrollLine - _linesPerPage + 1; @@ -108,7 +108,7 @@ void ConsoleDialog::drawDialog() { for (int column = 0; column < _lineWidth; column++) { int l = (start + line) % _linesInBuffer; byte c = _buffer[l * _lineWidth + column]; - _gui->drawChar(c, x, y, _gui->_textcolor); + g_gui.drawChar(c, x, y, g_gui._textcolor); x += kCharWidth; } y += kLineHeight; @@ -118,11 +118,11 @@ void ConsoleDialog::drawDialog() { _scrollBar->draw(); // Finally blit it all to the screen - _gui->addDirtyRect(_x, _y, _w, _h); + g_gui.addDirtyRect(_x, _y, _w, _h); } void ConsoleDialog::handleTickle() { - uint32 time = _gui->get_time(); + uint32 time = g_system->get_msecs(); if (_caretTime < time) { _caretTime = time + kCaretBlinkTime; if (_caretVisible) { @@ -506,13 +506,13 @@ void ConsoleDialog::drawCaret(bool erase) { char c = _buffer[getBufferPos()]; if (erase) { - _gui->fillRect(x, y, kCharWidth, kLineHeight, _gui->_bgcolor); - _gui->drawChar(c, x, y + 2, _gui->_textcolor); + g_gui.fillRect(x, y, kCharWidth, kLineHeight, g_gui._bgcolor); + g_gui.drawChar(c, x, y + 2, g_gui._textcolor); } else { - _gui->fillRect(x, y, kCharWidth, kLineHeight, _gui->_textcolor); - _gui->drawChar(c, x, y + 2, _gui->_bgcolor); + g_gui.fillRect(x, y, kCharWidth, kLineHeight, g_gui._textcolor); + g_gui.drawChar(c, x, y + 2, g_gui._bgcolor); } - _gui->addDirtyRect(x, y, kCharWidth, kLineHeight); + g_gui.addDirtyRect(x, y, kCharWidth, kLineHeight); _caretVisible = !erase; } diff --git a/gui/console.h b/gui/console.h index b0f4a89970..ebe5fc0972 100644 --- a/gui/console.h +++ b/gui/console.h @@ -21,8 +21,8 @@ #ifndef CONSOLE_DIALOG_H #define CONSOLE_DIALOG_H -#include "dialog.h" -#include "newgui.h" +#include "gui/dialog.h" +#include "gui/newgui.h" #include <stdarg.h> @@ -79,7 +79,7 @@ protected: void reflowLayout(); public: - ConsoleDialog(NewGui *gui, float widthPercent, float heightPercent); + ConsoleDialog(float widthPercent, float heightPercent); void open(); void drawDialog(); diff --git a/gui/dialog.cpp b/gui/dialog.cpp index 0c0e4a73b7..a0c3d41405 100644 --- a/gui/dialog.cpp +++ b/gui/dialog.cpp @@ -54,7 +54,7 @@ int Dialog::runModal() { open(); // Start processing events - _gui->runLoop(); + g_gui.runLoop(); // Return the result code return _result; @@ -65,7 +65,7 @@ void Dialog::open() { _result = 0; _visible = true; - _gui->openDialog(this); + g_gui.openDialog(this); // Search for the first objects that wantsFocus() (if any) and give it the focus while (w && !w->wantsFocus()) { @@ -80,7 +80,7 @@ void Dialog::open() { void Dialog::close() { _visible = false; - _gui->closeTopDialog(); + g_gui.closeTopDialog(); if (_mouseWidget) { _mouseWidget->handleMouseLeft(0); @@ -97,7 +97,7 @@ void Dialog::releaseFocus() { } void Dialog::draw() { - _gui->_needRedraw = true; + g_gui._needRedraw = true; } void Dialog::drawDialog() { @@ -106,15 +106,15 @@ void Dialog::drawDialog() { if (!isVisible()) return; - _gui->blendRect(_x, _y, _w, _h, _gui->_bgcolor); - _gui->box(_x, _y, _w, _h); + g_gui.blendRect(_x, _y, _w, _h, g_gui._bgcolor); + g_gui.box(_x, _y, _w, _h); while (w) { w->draw(); w = w->_next; } - _gui->addDirtyRect(_x, _y, _w, _h); + g_gui.addDirtyRect(_x, _y, _w, _h); } void Dialog::handleMouseDown(int x, int y, int button, int clickCount) { @@ -276,6 +276,8 @@ Widget *Dialog::findWidget(int x, int y) { break; w = w->_next; } + if (w) + w = w->findWidget(x - w->_x, y - w->_y); return w; } diff --git a/gui/dialog.h b/gui/dialog.h index 02fd13324a..f5a35b691a 100644 --- a/gui/dialog.h +++ b/gui/dialog.h @@ -37,7 +37,6 @@ class Dialog : public CommandReceiver { friend class Widget; friend class NewGui; protected: - NewGui *_gui; int16 _x, _y; uint16 _w, _h; Widget *_firstWidget; @@ -49,15 +48,14 @@ private: int _result; public: - Dialog(NewGui *gui, int x, int y, int w, int h) - : _gui(gui), _x(x), _y(y), _w(w), _h(h), _firstWidget(0), + Dialog(int x, int y, int w, int h) + : _x(x), _y(y), _w(w), _h(h), _firstWidget(0), _mouseWidget(0), _focusedWidget(0), _visible(false) { } virtual ~Dialog(); virtual int runModal(); - NewGui *getGui() { return _gui; } bool isVisible() const { return _visible; } int16 getX() const { return _x; } int16 getY() const { return _y; } diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 48d3b64408..814624f4d7 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -78,7 +78,7 @@ class EditGameDialog : public Dialog { typedef Common::String String; typedef Common::StringList StringList; public: - EditGameDialog(NewGui *gui, const String &domain, GameSettings target); + EditGameDialog(const String &domain, GameSettings target); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); @@ -89,8 +89,8 @@ protected: CheckboxWidget *_fullscreenCheckbox; }; -EditGameDialog::EditGameDialog(NewGui *gui, const String &domain, GameSettings target) - : Dialog(gui, 8, 50, 320 - 2 * 8, 200 - 2 * 40), +EditGameDialog::EditGameDialog(const String &domain, GameSettings target) + : Dialog(8, 50, 320 - 2 * 8, 200 - 2 * 40), _domain(domain) { // Determine the description string @@ -130,7 +130,7 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat String newDomain(_domainWidget->getLabel()); if (newDomain != _domain) { if (newDomain.isEmpty() || ConfMan.hasGameDomain(newDomain)) { - MessageDialog alert(_gui, "This game ID is already taken. Please choose another one."); + MessageDialog alert("This game ID is already taken. Please choose another one."); alert.runModal(); return; } @@ -156,8 +156,8 @@ void EditGameDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat * - ... */ -LauncherDialog::LauncherDialog(NewGui *gui, GameDetector &detector) - : Dialog(gui, 0, 0, 320, 200), _detector(detector) { +LauncherDialog::LauncherDialog(GameDetector &detector) + : Dialog(0, 0, 320, 200), _detector(detector) { // Show game name new StaticTextWidget(this, 10, 8, 300, kLineHeight, gScummVMFullVersion, kTextAlignCenter); @@ -194,7 +194,7 @@ LauncherDialog::LauncherDialog(NewGui *gui, GameDetector &detector) updateButtons(); // Create file browser dialog - _browser = new BrowserDialog(_gui, "Select directory with game data"); + _browser = new BrowserDialog("Select directory with game data"); } LauncherDialog::~LauncherDialog() { @@ -286,7 +286,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat int idx; if (candidates.isEmpty()) { // No game was found in the specified directory - MessageDialog alert(_gui, "ScummVM could not find any game in the specified directory!"); + MessageDialog alert("ScummVM could not find any game in the specified directory!"); alert.runModal(); idx = -1; } else if (candidates.size() == 1) { @@ -298,7 +298,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat for (idx = 0; idx < candidates.size(); idx++) list.push_back(candidates[idx].description); - ChooserDialog dialog(_gui, "Pick the game:", list); + ChooserDialog dialog("Pick the game:", list); idx = dialog.runModal(); } if (0 <= idx && idx < candidates.size()) { @@ -323,7 +323,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat ConfMan.set("path", dir->path(), domain); // Display edit dialog for the new entry - EditGameDialog editDialog(_gui, domain, result); + EditGameDialog editDialog(domain, result); if (editDialog.runModal()) { // User pressed OK, so make changes permanent @@ -363,7 +363,7 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat String gameId(ConfMan.get("gameid", _domains[item])); if (gameId.isEmpty()) gameId = _domains[item]; - EditGameDialog editDialog(_gui, _domains[item], GameDetector::findGame(gameId)); + EditGameDialog editDialog(_domains[item], GameDetector::findGame(gameId)); if (editDialog.runModal()) { // User pressed OK, so make changes permanent @@ -382,12 +382,12 @@ void LauncherDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat // - music & graphics driver (but see also the comments on EditGameDialog // for some techincal difficulties with this) // - default volumes (sfx/master/music) - GlobalOptionsDialog options(_gui, _detector); + GlobalOptionsDialog options(_detector); options.runModal(); } break; case kAboutCmd: { - AboutDialog about(_gui); + AboutDialog about; about.runModal(); } break; diff --git a/gui/launcher.h b/gui/launcher.h index f65c7cb1a4..d7f7b6dc81 100644 --- a/gui/launcher.h +++ b/gui/launcher.h @@ -33,7 +33,7 @@ class LauncherDialog : public Dialog { typedef Common::String String; typedef Common::StringList StringList; public: - LauncherDialog(NewGui *gui, GameDetector &detector); + LauncherDialog(GameDetector &detector); ~LauncherDialog(); virtual void open(); diff --git a/gui/message.cpp b/gui/message.cpp index 3df501225f..f82f0086c9 100644 --- a/gui/message.cpp +++ b/gui/message.cpp @@ -29,8 +29,8 @@ enum { kCancelCmd = 'CNCL' }; -MessageDialog::MessageDialog(NewGui *gui, const String &message, const char *defaultButton, const char *altButton) - : Dialog(gui, 30, 20, 260, 124) { +MessageDialog::MessageDialog(const String &message, const char *defaultButton, const char *altButton) + : Dialog(30, 20, 260, 124) { // First, determine the size the dialog needs. For this we have to break // down the string into lines, and taking the maximum of their widths. // Using this, and accounting for the space the button(s) need, we can set @@ -95,9 +95,10 @@ int MessageDialog::addLine(StringList &lines, const char *line, int size) { int width = 0, maxWidth = 0; const char *start = line, *pos = line, *end = start + size; String tmp; + NewGui *gui = &g_gui; while (pos < end) { - int w = _gui->getCharWidth(*pos); + int w = gui->getCharWidth(*pos); // Check if we exceed the maximum line width, if so, split the line. // If possible we split at whitespaces. @@ -114,7 +115,7 @@ int MessageDialog::addLine(StringList &lines, const char *line, int size) { lines.push_back(tmp); // Determine the width of the string, and adjust maxWidth accordingly - width = _gui->getStringWidth(tmp); + width = gui->getStringWidth(tmp); if (maxWidth < width) maxWidth = width; @@ -148,13 +149,13 @@ void MessageDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data } } -TimedMessageDialog::TimedMessageDialog(NewGui *gui, const Common::String &message, uint32 duration) - : MessageDialog(gui, message, 0, 0) { - _timer = _gui->get_time() + duration; +TimedMessageDialog::TimedMessageDialog(const Common::String &message, uint32 duration) + : MessageDialog(message, 0, 0) { + _timer = g_system->get_msecs() + duration; } void TimedMessageDialog::handleTickle() { MessageDialog::handleTickle(); - if (_gui->get_time() > _timer) + if (g_system->get_msecs() > _timer) close(); } diff --git a/gui/message.h b/gui/message.h index 32b94573d2..d2e018ecb8 100644 --- a/gui/message.h +++ b/gui/message.h @@ -35,7 +35,7 @@ class MessageDialog : public Dialog { typedef Common::String String; typedef Common::StringList StringList; public: - MessageDialog(NewGui *gui, const Common::String &message, const char *defaultButton = "OK", const char *altButton = 0); + MessageDialog(const Common::String &message, const char *defaultButton = "OK", const char *altButton = 0); void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); @@ -48,7 +48,7 @@ protected: */ class TimedMessageDialog : public MessageDialog { public: - TimedMessageDialog(NewGui *gui, const Common::String &message, uint32 duration); + TimedMessageDialog(const Common::String &message, uint32 duration); void handleTickle(); diff --git a/gui/newgui.cpp b/gui/newgui.cpp index b6f7808b24..0a9b44074c 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -82,8 +82,11 @@ static byte guifont[] = { #endif // Constructor -NewGui::NewGui(OSystem *system) : _system(system), _screen(0), _needRedraw(false), +NewGui::NewGui() : _screen(0), _needRedraw(false), _stateIsSaved(false), _cursorAnimateCounter(0), _cursorAnimateTimer(0) { + + _system = OSystem::instance(); + // Clear the cursor memset(_cursor, 0xFF, sizeof(_cursor)); @@ -144,7 +147,7 @@ void NewGui::runLoop() { _system->update_screen(); OSystem::Event event; - uint32 time = get_time(); + uint32 time = _system->get_msecs(); while (_system->poll_event(&event)) { switch (event.event_code) { @@ -504,7 +507,7 @@ void NewGui::drawBitmap(uint32 *bitmap, int x, int y, NewGuiColor color, int h) // We could plug in a different cursor here if we like to. // void NewGui::animateCursor() { - int time = get_time(); + int time = _system->get_msecs(); if (time > _cursorAnimateTimer + kCursorAnimateDelay) { const byte colors[4] = { 15, 15, 7, 8 }; const byte color = colors[_cursorAnimateCounter]; diff --git a/gui/newgui.h b/gui/newgui.h index b610825b3d..7cec44d567 100644 --- a/gui/newgui.h +++ b/gui/newgui.h @@ -22,14 +22,18 @@ #define NEWGUI_H #include "common/scummsys.h" -#include "common/system.h" // For events +#include "common/singleton.h" #include "common/str.h" +#include "common/system.h" // For events class Dialog; #define hLine(x, y, x2, color) line(x, y, x2, y, color); #define vLine(x, y, y2, color) line(x, y, x, y2, color); +#define g_gui (NewGui::instance()) + + // Height of a single text line enum { kLineHeight = 11 @@ -60,9 +64,11 @@ public: }; // This class hopefully will replace the old Gui class completly one day -class NewGui { - friend class Dialog; +class NewGui : public Common::Singleton<NewGui> { typedef Common::String String; + friend class Dialog; + friend class Common::Singleton<NewGui>; + NewGui(); public: // Main entry for the GUI: this will start an event loop that keeps running @@ -71,8 +77,6 @@ public: bool isActive() { return ! _dialogStack.empty(); } - NewGui(OSystem *system); - protected: OSystem *_system; NewGuiColor *_screen; @@ -122,9 +126,6 @@ public: NewGuiColor _textcolor; NewGuiColor _textcolorhi; - // Misc util - uint32 get_time() const { return _system->get_msecs(); } - // Drawing primitives NewGuiColor *getBasePtr(int x, int y); void box(int x, int y, int width, int height, bool inverted = false); diff --git a/gui/options.cpp b/gui/options.cpp index 819fcac070..4f8582af0a 100644 --- a/gui/options.cpp +++ b/gui/options.cpp @@ -61,8 +61,8 @@ enum { kOKCmd = 'ok ' }; -GlobalOptionsDialog::GlobalOptionsDialog(NewGui *gui, GameDetector &detector) - : Dialog(gui, 10, 15, 320 - 2 * 10, 200 - 2 * 15) { +GlobalOptionsDialog::GlobalOptionsDialog(GameDetector &detector) + : Dialog(10, 15, 320 - 2 * 10, 200 - 2 * 15) { // The GFX mode popup & a label // TODO - add an API to query the list of available GFX modes, and to get/set the mode new StaticTextWidget(this, 5, 10+1, 100, kLineHeight, "Graphics mode: ", kTextAlignRight); @@ -156,7 +156,7 @@ GlobalOptionsDialog::GlobalOptionsDialog(NewGui *gui, GameDetector &detector) addButton(_w - (kButtonWidth + 10), _h - 24, "OK", kOKCmd, 0); // Create file browser dialog - _browser = new BrowserDialog(_gui, "Select directory for savegames"); + _browser = new BrowserDialog("Select directory for savegames"); } GlobalOptionsDialog::~GlobalOptionsDialog() { diff --git a/gui/options.h b/gui/options.h index 71f3011c8c..e589563ab6 100644 --- a/gui/options.h +++ b/gui/options.h @@ -32,7 +32,7 @@ class PopUpWidget; class GlobalOptionsDialog : public Dialog { typedef Common::String String; public: - GlobalOptionsDialog(NewGui *gui, GameDetector &detector); + GlobalOptionsDialog(GameDetector &detector); ~GlobalOptionsDialog(); void open(); diff --git a/gui/widget.cpp b/gui/widget.cpp index ea032b1bc5..f20dbf4624 100644 --- a/gui/widget.cpp +++ b/gui/widget.cpp @@ -23,7 +23,7 @@ #include "dialog.h" #include "newgui.h" -Widget::Widget (Dialog *boss, int x, int y, int w, int h) +Widget::Widget(Dialog *boss, int x, int y, int w, int h) : _type(0), _boss(boss), _x(x), _y(y), _w(w), _h(h), _id(0), _flags(0), _hasFocus(false) { // Insert into the widget list of the boss @@ -32,7 +32,7 @@ Widget::Widget (Dialog *boss, int x, int y, int w, int h) } void Widget::draw() { - NewGui *gui = _boss->getGui(); + NewGui *gui = &g_gui; if (!isVisible() || !_boss->isVisible()) return; @@ -75,7 +75,7 @@ void Widget::draw() { #pragma mark - StaticTextWidget::StaticTextWidget(Dialog *boss, int x, int y, int w, int h, const String &text, int align) - : Widget (boss, x, y, w, h), _align(align) { + : Widget(boss, x, y, w, h), _align(align) { _type = kStaticTextWidget; setLabel(text); } @@ -87,7 +87,7 @@ void StaticTextWidget::setValue(int value) { } void StaticTextWidget::drawWidget(bool hilite) { - NewGui *gui = _boss->getGui(); + NewGui *gui = &g_gui; gui->drawString(_label, _x, _y, _w, gui->_textcolor, _align); } @@ -106,7 +106,7 @@ void ButtonWidget::handleMouseUp(int x, int y, int button, int clickCount) { } void ButtonWidget::drawWidget(bool hilite) { - NewGui *gui = _boss->getGui(); + NewGui *gui = &g_gui; gui->drawString(_label, _x, _y, _w, !isEnabled() ? gui->_color : hilite ? gui->_textcolorhi : gui->_textcolor, _align); @@ -156,7 +156,7 @@ void CheckboxWidget::handleMouseUp(int x, int y, int button, int clickCount) { } void CheckboxWidget::drawWidget(bool hilite) { - NewGui *gui = _boss->getGui(); + NewGui *gui = &g_gui; // Draw the box gui->box(_x, _y, 14, 14); @@ -213,7 +213,7 @@ void SliderWidget::handleMouseUp(int x, int y, int button, int clickCount) { } void SliderWidget::drawWidget(bool hilite) { - NewGui *gui = _boss->getGui(); + NewGui *gui = &g_gui; // Draw the box gui->box(_x, _y, _w, _h); diff --git a/gui/widget.h b/gui/widget.h index e938985ac5..de650dcfa4 100644 --- a/gui/widget.h +++ b/gui/widget.h @@ -87,7 +87,7 @@ public: /* Widget */ class Widget { -friend class Dialog; + friend class Dialog; protected: uint32 _type; Dialog *_boss; @@ -129,6 +129,8 @@ protected: virtual void receivedFocusWidget() {} virtual void lostFocusWidget() {} + + virtual Widget *findWidget(int x, int y) { return this; } }; /* StaticTextWidget */ diff --git a/scumm/debugger.cpp b/scumm/debugger.cpp index 28c0d9890b..3461bb6ad0 100644 --- a/scumm/debugger.cpp +++ b/scumm/debugger.cpp @@ -40,7 +40,7 @@ extern uint16 _debugLevel; namespace Scumm { ScummDebugger::ScummDebugger(ScummEngine *s) - : Common::Debugger<ScummDebugger>(s->_newgui) { + : Common::Debugger<ScummDebugger>() { _vm = s; // Register variables diff --git a/scumm/dialogs.cpp b/scumm/dialogs.cpp index a8a66c370a..0f66ece8e3 100644 --- a/scumm/dialogs.cpp +++ b/scumm/dialogs.cpp @@ -192,8 +192,8 @@ enum { kQuitCmd = 'QUIT' }; -SaveLoadDialog::SaveLoadDialog(NewGui *gui, ScummEngine *scumm) - : ScummDialog(gui, scumm, 20, 8, 280, 184) { +SaveLoadDialog::SaveLoadDialog(ScummEngine *scumm) + : ScummDialog(scumm, 20, 8, 280, 184) { const int x = _w - kButtonWidth - 8; int y = 20; @@ -218,9 +218,9 @@ SaveLoadDialog::SaveLoadDialog(NewGui *gui, ScummEngine *scumm) // // Create the sub dialog(s) // - _aboutDialog = new AboutDialog(gui); + _aboutDialog = new AboutDialog(); #ifndef DISABLE_HELP - _helpDialog = new HelpDialog(gui, scumm); + _helpDialog = new HelpDialog(scumm); #endif // The save game list @@ -388,11 +388,11 @@ enum { }; #ifndef _WIN32_WCE -OptionsDialog::OptionsDialog(NewGui *gui, ScummEngine *scumm) - : ScummDialog(gui, scumm, 40, 30, 240, 124) { +OptionsDialog::OptionsDialog(ScummEngine *scumm) + : ScummDialog(scumm, 40, 30, 240, 124) { #else -OptionsDialog::OptionsDialog(NewGui *gui, ScummEngine *scumm) - : ScummDialog(gui, scumm, 40, 30, 240, 124 + kButtonHeight + 4) { +OptionsDialog::OptionsDialog(ScummEngine *scumm) + : ScummDialog(scumm, 40, 30, 240, 124 + kButtonHeight + 4) { #endif // // Add the buttons @@ -442,7 +442,7 @@ OptionsDialog::OptionsDialog(NewGui *gui, ScummEngine *scumm) // Create the sub dialog(s) // #ifdef _WIN32_WCE - _keysDialog = new KeysDialog(gui, scumm); + _keysDialog = new KeysDialog(scumm); #endif } @@ -538,8 +538,8 @@ enum { kPrevCmd = 'PREV' }; -HelpDialog::HelpDialog(NewGui *gui, ScummEngine *scumm) - : ScummDialog(gui, scumm, 5, 5, 310, 190) { +HelpDialog::HelpDialog(ScummEngine *scumm) + : ScummDialog(scumm, 5, 5, 310, 190) { _page = 1; _numPages = ScummHelp::numPages(scumm->_gameId); @@ -608,18 +608,18 @@ void HelpDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { #pragma mark - -InfoDialog::InfoDialog(NewGui *gui, ScummEngine *scumm, int res) -: ScummDialog(gui, scumm, 0, 80, 0, 16) { // dummy x and w +InfoDialog::InfoDialog(ScummEngine *scumm, int res) +: ScummDialog(scumm, 0, 80, 0, 16) { // dummy x and w setInfoText(queryResString (res)); } -InfoDialog::InfoDialog(NewGui *gui, ScummEngine *scumm, const String& message) -: ScummDialog(gui, scumm, 0, 80, 0, 16) { // dummy x and w +InfoDialog::InfoDialog(ScummEngine *scumm, const String& message) +: ScummDialog(scumm, 0, 80, 0, 16) { // dummy x and w setInfoText(message); } void InfoDialog::setInfoText(const String& message) { - int width = _gui->getStringWidth(message.c_str()) + 16; + int width = g_gui.getStringWidth(message) + 16; _x = (_scumm->_screenWidth - width) >> 1; _w = width; @@ -629,12 +629,12 @@ void InfoDialog::setInfoText(const String& message) { #pragma mark - -PauseDialog::PauseDialog(NewGui *gui, ScummEngine *scumm) - : InfoDialog(gui, scumm, 10) { +PauseDialog::PauseDialog(ScummEngine *scumm) + : InfoDialog(scumm, 10) { } -ConfirmExitDialog::ConfirmExitDialog(NewGui *gui, ScummEngine *scumm) - : InfoDialog(gui, scumm, "Do you really want to quit (y/n)?") { +ConfirmExitDialog::ConfirmExitDialog(ScummEngine *scumm) + : InfoDialog(scumm, "Do you really want to quit (y/n)?") { } void ConfirmExitDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) { @@ -657,8 +657,8 @@ enum { }; -KeysDialog::KeysDialog(NewGui *gui, ScummEngine *scumm) - : ScummDialog(gui, scumm, 30, 20, 260, 160) { +KeysDialog::KeysDialog(ScummEngine *scumm) + : ScummDialog(scumm, 30, 20, 260, 160) { addButton(160, 20, "Map", kMapCmd, 'M'); // Map addButton(160, 40, "OK", kOKCmd, 'O'); // OK addButton(160, 60, "Cancel", kCancelCmd, 'C'); // Cancel diff --git a/scumm/dialogs.h b/scumm/dialogs.h index 1d268f1c0d..a537436db6 100644 --- a/scumm/dialogs.h +++ b/scumm/dialogs.h @@ -37,8 +37,8 @@ class ScummEngine; class ScummDialog : public Dialog { public: - ScummDialog(NewGui *gui, ScummEngine *scumm, int x, int y, int w, int h) - : Dialog(gui, x, y, w, h), _scumm(scumm) {} + ScummDialog(ScummEngine *scumm, int x, int y, int w, int h) + : Dialog(x, y, w, h), _scumm(scumm) {} protected: typedef Common::String String; @@ -53,7 +53,7 @@ protected: class SaveLoadDialog : public ScummDialog { public: - SaveLoadDialog(NewGui *gui, ScummEngine *scumm); + SaveLoadDialog(ScummEngine *scumm); ~SaveLoadDialog(); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); virtual void open(); @@ -83,7 +83,7 @@ protected: class HelpDialog : public ScummDialog { public: - HelpDialog(NewGui *gui, ScummEngine *scumm); + HelpDialog(ScummEngine *scumm); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); protected: @@ -111,7 +111,7 @@ protected: #endif public: - OptionsDialog(NewGui *gui, ScummEngine *scumm); + OptionsDialog(ScummEngine *scumm); ~OptionsDialog(); virtual void open(); @@ -137,9 +137,9 @@ protected: class InfoDialog : public ScummDialog { public: // arbitrary message - InfoDialog(NewGui *gui, ScummEngine *scumm, const String& message); + InfoDialog(ScummEngine *scumm, const String& message); // from resources - InfoDialog(NewGui *gui, ScummEngine *scumm, int res); + InfoDialog(ScummEngine *scumm, int res); virtual void handleMouseDown(int x, int y, int button, int clickCount) { close(); @@ -155,7 +155,7 @@ protected: class PauseDialog : public InfoDialog { public: - PauseDialog(NewGui *gui, ScummEngine *scumm); + PauseDialog(ScummEngine *scumm); virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers) { if (ascii == ' ') // Close pause dialog if space key is pressed @@ -167,7 +167,7 @@ public: class ConfirmExitDialog : public InfoDialog { public: - ConfirmExitDialog(NewGui *gui, ScummEngine *scumm); + ConfirmExitDialog(ScummEngine *scumm); virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers); }; @@ -175,7 +175,7 @@ public: class KeysDialog : public ScummDialog { public: - KeysDialog(NewGui *gui, ScummEngine *scumm); + KeysDialog(ScummEngine *scumm); virtual void handleCommand(CommandSender *sender, uint32 cmd, uint32 data); virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers); diff --git a/scumm/resource.cpp b/scumm/resource.cpp index a15585c298..f2ea764c76 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -240,7 +240,7 @@ void ScummEngine::askForDisk(const char *filename, int disknum) { error("Cannot find file: '%s'", filename); } else { sprintf(buf, "Cannot find file: '%s'", filename); - InfoDialog dialog(_newgui, this, (char*)buf); + InfoDialog dialog(this, (char*)buf); runDialog(dialog); error("Cannot find file: '%s'", filename); } diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index bd4ce37b62..e61bc9c174 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -2425,7 +2425,7 @@ void ScummEngine_v6::o6_kernelSetFunctions() { break; case 3: if (readArray(233,0,50) == 0) { - InfoDialog info(_newgui, this, "Set MineRoad - You can now jump the gorge."); + InfoDialog info(this, "Set MineRoad - You can now jump the gorge."); runDialog(info); writeArray(233, 0, 50, 1); // INSANE callback: Chain diff --git a/scumm/scumm.h b/scumm/scumm.h index 10d1faaed9..9ff5adb0c2 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -34,7 +34,6 @@ class Dialog; class GameDetector; -class NewGui; namespace Scumm { @@ -341,9 +340,6 @@ public: /** We keep running until this is set to true. */ bool _quit; - // GUI - NewGui *_newgui; - protected: Dialog *_pauseDialog; Dialog *_optionsDialog; diff --git a/scumm/scummvm.cpp b/scumm/scummvm.cpp index 50a694a130..83d7aac21a 100644 --- a/scumm/scummvm.cpp +++ b/scumm/scummvm.cpp @@ -64,7 +64,6 @@ extern bool isSmartphone(void); #endif -extern NewGui *g_gui; extern uint16 _debugLevel; namespace Scumm { @@ -307,7 +306,6 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS _videoFinished = false; _smushPlay = false; _quit = false; - _newgui = NULL; _pauseDialog = NULL; _optionsDialog = NULL; _saveLoadDialog = NULL; @@ -650,8 +648,6 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst, const ScummGameS // Setup GDI object gdi._numStrips = _screenWidth / 8; - _newgui = g_gui; - // Create debugger _debugger = new ScummDebugger(this); @@ -1366,7 +1362,7 @@ load_game: #endif sprintf(buf, "Successfully saved game state in file:\n\n%s", filename); - TimedMessageDialog dialog(_newgui, buf, 1500); + TimedMessageDialog dialog(buf, 1500); runDialog(dialog); } if (success && _saveLoadFlag != 1) @@ -2459,25 +2455,25 @@ int ScummEngine::runDialog(Dialog &dialog) { void ScummEngine::pauseDialog() { if (!_pauseDialog) - _pauseDialog = new PauseDialog(_newgui, this); + _pauseDialog = new PauseDialog(this); runDialog(*_pauseDialog); } void ScummEngine::saveloadDialog() { if (!_saveLoadDialog) - _saveLoadDialog = new SaveLoadDialog(_newgui, this); + _saveLoadDialog = new SaveLoadDialog(this); runDialog(*_saveLoadDialog); } void ScummEngine::optionsDialog() { if (!_optionsDialog) - _optionsDialog = new OptionsDialog(_newgui, this); + _optionsDialog = new OptionsDialog(this); runDialog(*_optionsDialog); } void ScummEngine::confirmexitDialog() { if (!_confirmExitDialog) - _confirmExitDialog = new ConfirmExitDialog(_newgui, this); + _confirmExitDialog = new ConfirmExitDialog(this); if (runDialog(*_confirmExitDialog)) { _quit = true; @@ -2496,7 +2492,7 @@ char ScummEngine::displayError(bool showCancel, const char *message, ...) { vsprintf(buf, message, va); va_end(va); - MessageDialog dialog(_newgui, buf, "OK", "Cancel"); + MessageDialog dialog(buf, "OK", "Cancel"); return runDialog(dialog); } diff --git a/scumm/string.cpp b/scumm/string.cpp index c0c7041efc..c7c1887e7b 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -80,7 +80,7 @@ void ScummEngine::unkMessage2() { // FIXME: I know this is the right thing to do for MI1 and MI2. For // all other games it's just a guess. - InfoDialog dialog(_newgui, this, (char*)buf); + InfoDialog dialog(this, (char*)buf); VAR(VAR_KEYPRESS) = runDialog(dialog); _messagePtr = tmp; diff --git a/sword2/console.cpp b/sword2/console.cpp index 89d6d26978..db54937152 100644 --- a/sword2/console.cpp +++ b/sword2/console.cpp @@ -48,7 +48,7 @@ static void Var_set(int var, int val) { } Debugger::Debugger(Sword2Engine *s) - : Common::Debugger<Debugger>(s->_newgui) { + : Common::Debugger<Debugger>() { _vm = s; // Register commands diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp index a823e255d9..1d31f4ef05 100644 --- a/sword2/sword2.cpp +++ b/sword2/sword2.cpp @@ -52,7 +52,6 @@ extern bool isSmartphone(void); #endif -extern NewGui *g_gui; extern uint16 _debugLevel; static const GameSettings sword2_settings[] = { @@ -117,7 +116,6 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst) _detector = detector; g_sword2 = this; - _newgui = NULL; _debugger = NULL; _features = detector->_game.features; _targetName = strdup(detector->_targetName.c_str()); @@ -139,7 +137,6 @@ Sword2Engine::Sword2Engine(GameDetector *detector, OSystem *syst) g_display = _display = new Display(640, 480); gui = new Gui(); - _newgui = g_gui; _debugger = new Debugger(this); _lastPaletteRes = 0; diff --git a/sword2/sword2.h b/sword2/sword2.h index cb71de2772..34f77b7ebd 100644 --- a/sword2/sword2.h +++ b/sword2/sword2.h @@ -34,8 +34,6 @@ enum { GF_DEMO = 1 << 0 }; -class NewGui; - namespace Sword2 { // Bodge for PCF76 version so that their demo CD can be labelled "PCF76" @@ -140,7 +138,6 @@ public: Sound *_sound; Display *_display; - NewGui *_newgui; Debugger *_debugger; Common::RandomSource _rnd; |