[Scummvm-cvs-logs] SF.net SVN: scummvm:[35668] scummvm/trunk
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Fri Jan 2 04:21:41 CET 2009
Revision: 35668
http://scummvm.svn.sourceforge.net/scummvm/?rev=35668&view=rev
Author: lordhoto
Date: 2009-01-02 03:21:40 +0000 (Fri, 02 Jan 2009)
Log Message:
-----------
Renamed gui/newgui.cpp -> gui/GuiManager.cpp and gui/newgui.h -> gui/GuiManager.h
Modified Paths:
--------------
scummvm/trunk/backends/platform/dc/vmsave.cpp
scummvm/trunk/backends/platform/ds/arm9/source/dsoptions.cpp
scummvm/trunk/backends/platform/wince/CELauncherDialog.cpp
scummvm/trunk/base/main.cpp
scummvm/trunk/engines/dialogs.cpp
scummvm/trunk/engines/engine.cpp
scummvm/trunk/engines/scumm/dialogs.cpp
scummvm/trunk/engines/scumm/input.cpp
scummvm/trunk/engines/scumm/scumm.cpp
scummvm/trunk/engines/sword1/resman.cpp
scummvm/trunk/engines/sword1/sword1.cpp
scummvm/trunk/gui/EditTextWidget.cpp
scummvm/trunk/gui/KeysDialog.h
scummvm/trunk/gui/ListWidget.cpp
scummvm/trunk/gui/PopUpWidget.cpp
scummvm/trunk/gui/ScrollBarWidget.cpp
scummvm/trunk/gui/TabWidget.cpp
scummvm/trunk/gui/ThemeParser.cpp
scummvm/trunk/gui/about.cpp
scummvm/trunk/gui/browser.cpp
scummvm/trunk/gui/chooser.cpp
scummvm/trunk/gui/console.h
scummvm/trunk/gui/dialog.cpp
scummvm/trunk/gui/editable.cpp
scummvm/trunk/gui/editable.h
scummvm/trunk/gui/launcher.cpp
scummvm/trunk/gui/massadd.cpp
scummvm/trunk/gui/message.cpp
scummvm/trunk/gui/module.mk
scummvm/trunk/gui/object.cpp
scummvm/trunk/gui/options.cpp
scummvm/trunk/gui/widget.cpp
Added Paths:
-----------
scummvm/trunk/gui/GuiManager.cpp
scummvm/trunk/gui/GuiManager.h
Removed Paths:
-------------
scummvm/trunk/gui/newgui.cpp
scummvm/trunk/gui/newgui.h
Modified: scummvm/trunk/backends/platform/dc/vmsave.cpp
===================================================================
--- scummvm/trunk/backends/platform/dc/vmsave.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/backends/platform/dc/vmsave.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -28,7 +28,7 @@
#include "dc.h"
#include "icon.h"
#include <common/savefile.h>
-#include <gui/newgui.h>
+#include <gui/GuiManager.h>
#include <gui/message.h>
#include <backends/saves/compressed/compressed-saves.h>
Modified: scummvm/trunk/backends/platform/ds/arm9/source/dsoptions.cpp
===================================================================
--- scummvm/trunk/backends/platform/ds/arm9/source/dsoptions.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/backends/platform/ds/arm9/source/dsoptions.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -23,7 +23,7 @@
#include "dsoptions.h"
#include "dsmain.h"
#include "gui/dialog.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/ListWidget.h"
#include "gui/TabWidget.h"
#include "osystem_ds.h"
Modified: scummvm/trunk/backends/platform/wince/CELauncherDialog.cpp
===================================================================
--- scummvm/trunk/backends/platform/wince/CELauncherDialog.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/backends/platform/wince/CELauncherDialog.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -30,7 +30,7 @@
#include "engines/metaengine.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/widget.h"
#include "gui/browser.h"
#include "gui/message.h"
Modified: scummvm/trunk/base/main.cpp
===================================================================
--- scummvm/trunk/base/main.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/base/main.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -43,7 +43,7 @@
#include "common/file.h"
#include "common/fs.h"
#include "common/system.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/message.h"
#if defined(_WIN32_WCE)
Modified: scummvm/trunk/engines/dialogs.cpp
===================================================================
--- scummvm/trunk/engines/dialogs.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/engines/dialogs.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -32,7 +32,7 @@
#include "graphics/scaler.h"
#include "gui/about.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/launcher.h"
#include "gui/ListWidget.h"
#include "gui/ThemeEval.h"
Modified: scummvm/trunk/engines/engine.cpp
===================================================================
--- scummvm/trunk/engines/engine.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/engines/engine.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -37,7 +37,7 @@
#include "common/savefile.h"
#include "common/system.h"
#include "gui/message.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "sound/mixer.h"
#include "engines/dialogs.h"
#include "engines/metaengine.h"
Modified: scummvm/trunk/engines/scumm/dialogs.cpp
===================================================================
--- scummvm/trunk/engines/scumm/dialogs.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/engines/scumm/dialogs.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -35,7 +35,7 @@
#include "gui/about.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/ListWidget.h"
#include "gui/ThemeEval.h"
Modified: scummvm/trunk/engines/scumm/input.cpp
===================================================================
--- scummvm/trunk/engines/scumm/input.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/engines/scumm/input.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -28,7 +28,7 @@
#include "common/system.h"
#include "gui/message.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "scumm/debugger.h"
#include "scumm/dialogs.h"
Modified: scummvm/trunk/engines/scumm/scumm.cpp
===================================================================
--- scummvm/trunk/engines/scumm/scumm.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/engines/scumm/scumm.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -30,7 +30,7 @@
#include "common/system.h"
#include "gui/message.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "graphics/cursorman.h"
Modified: scummvm/trunk/engines/sword1/resman.cpp
===================================================================
--- scummvm/trunk/engines/sword1/resman.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/engines/sword1/resman.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -36,7 +36,7 @@
#include "sword1/swordres.h"
#include "gui/message.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
namespace Sword1 {
void guiFatalError(char *msg) {
Modified: scummvm/trunk/engines/sword1/sword1.cpp
===================================================================
--- scummvm/trunk/engines/sword1/sword1.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/engines/sword1/sword1.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -39,7 +39,7 @@
#include "common/config-manager.h"
#include "gui/message.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
namespace Sword1 {
Modified: scummvm/trunk/gui/EditTextWidget.cpp
===================================================================
--- scummvm/trunk/gui/EditTextWidget.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/EditTextWidget.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -24,7 +24,7 @@
#include "gui/EditTextWidget.h"
#include "gui/dialog.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/ThemeEval.h"
Copied: scummvm/trunk/gui/GuiManager.cpp (from rev 35667, scummvm/trunk/gui/newgui.cpp)
===================================================================
--- scummvm/trunk/gui/GuiManager.cpp (rev 0)
+++ scummvm/trunk/gui/GuiManager.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -0,0 +1,424 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#include "common/events.h"
+#include "common/system.h"
+#include "common/util.h"
+#include "common/config-manager.h"
+
+#include "gui/GuiManager.h"
+#include "gui/dialog.h"
+#include "gui/ThemeEngine.h"
+#include "gui/ThemeEval.h"
+
+#include "graphics/cursorman.h"
+
+DECLARE_SINGLETON(GUI::GuiManager);
+
+namespace GUI {
+
+enum {
+ kDoubleClickDelay = 500, // milliseconds
+ kCursorAnimateDelay = 250
+};
+
+// Constructor
+GuiManager::GuiManager() : _redrawStatus(kRedrawDisabled),
+ _stateIsSaved(false), _cursorAnimateCounter(0), _cursorAnimateTimer(0) {
+ _theme = 0;
+ _useStdCursor = false;
+
+ _system = g_system;
+ _lastScreenChangeID = _system->getScreenChangeID();
+
+ // Clear the cursor
+ memset(_cursor, 0xFF, sizeof(_cursor));
+
+
+ ConfMan.registerDefault("gui_theme", "scummmodern.zip");
+ Common::String themefile(ConfMan.get("gui_theme"));
+ if (themefile.compareToIgnoreCase("default") == 0)
+ themefile = "builtin";
+
+ ConfMan.registerDefault("gui_renderer", ThemeEngine::findModeConfigName(ThemeEngine::_defaultRendererMode));
+ ThemeEngine::GraphicsMode gfxMode = (ThemeEngine::GraphicsMode)ThemeEngine::findMode(ConfMan.get("gui_renderer"));
+
+ // Try to load the theme
+ if (!loadNewTheme(themefile, gfxMode)) {
+ // Loading the theme failed, try to load the built-in theme
+ if (!loadNewTheme("builtin", gfxMode)) {
+ // Loading the built-in theme failed as well. Bail out
+ error("Failed to load any GUI theme, aborting");
+ }
+ }
+ _themeChange = false;
+}
+
+GuiManager::~GuiManager() {
+ delete _theme;
+}
+
+bool GuiManager::loadNewTheme(Common::String filename, ThemeEngine::GraphicsMode gfx) {
+ // If we are asked to reload the currently active theme, just do nothing
+ // FIXME: Actually, why? It might be desirable at times to force a theme reload...
+ if (_theme && filename == _theme->getThemeId() && gfx == _theme->getGraphicsMode())
+ return true;
+
+ ThemeEngine *newTheme = 0;
+
+ if (gfx == ThemeEngine::kGfxDisabled)
+ gfx = ThemeEngine::_defaultRendererMode;
+
+ // Try to load the new theme
+ newTheme = new ThemeEngine(filename, gfx);
+ assert(newTheme);
+
+ if (!newTheme->init())
+ return false;
+
+ //
+ // Disable and delete the old theme
+ //
+ if (_theme)
+ _theme->disable();
+ delete _theme;
+
+ if (_useStdCursor) {
+ CursorMan.popCursorPalette();
+ CursorMan.popCursor();
+ }
+
+ //
+ // Enable the new theme
+ //
+ _theme = newTheme;
+ _themeChange = true;
+
+ // refresh all dialogs
+ for (int i = 0; i < _dialogStack.size(); ++i) {
+ _dialogStack[i]->reflowLayout();
+ }
+
+ // We need to redraw immediately. Otherwise
+ // some other event may cause a widget to be
+ // redrawn before redraw() has been called.
+ _redrawStatus = kRedrawFull;
+ redraw();
+ _system->updateScreen();
+
+ return true;
+}
+
+void GuiManager::redraw() {
+ int i;
+
+ if (_redrawStatus == kRedrawDisabled)
+ return;
+
+ if (_dialogStack.empty())
+ return;
+
+ switch (_redrawStatus) {
+ case kRedrawCloseDialog:
+ case kRedrawFull:
+ case kRedrawTopDialog:
+ _theme->clearAll();
+ _theme->openDialog(true);
+
+ for (i = 0; i < _dialogStack.size() - 1; i++) {
+ _dialogStack[i]->drawDialog();
+ }
+
+ _theme->finishBuffering();
+ _theme->updateScreen();
+
+ case kRedrawOpenDialog:
+ _theme->openDialog(true, (ThemeEngine::ShadingStyle)xmlEval()->getVar("Dialog." + _dialogStack.top()->_name + ".Shading", 0));
+ _dialogStack.top()->drawDialog();
+ _theme->finishBuffering();
+ break;
+
+ default:
+ return;
+ }
+
+ _theme->updateScreen();
+ _redrawStatus = kRedrawDisabled;
+}
+
+Dialog *GuiManager::getTopDialog() const {
+ if (_dialogStack.empty())
+ return 0;
+ return _dialogStack.top();
+}
+
+void GuiManager::runLoop() {
+ Dialog *activeDialog = getTopDialog();
+ bool didSaveState = false;
+ int button;
+ uint32 time;
+
+ if (activeDialog == 0)
+ return;
+
+ if (!_stateIsSaved) {
+ saveState();
+ _theme->enable();
+ didSaveState = true;
+
+ _useStdCursor = !_theme->ownCursor();
+ if (_useStdCursor)
+ setupCursor();
+
+// _theme->refresh();
+
+ _themeChange = false;
+ _redrawStatus = kRedrawFull;
+ redraw();
+ }
+
+ Common::EventManager *eventMan = _system->getEventManager();
+ uint32 lastRedraw = 0;
+ const uint32 waitTime = 1000 / 45;
+
+ while (!_dialogStack.empty() && activeDialog == getTopDialog()) {
+ redraw();
+
+ // Don't "tickle" the dialog until the theme has had a chance
+ // to re-allocate buffers in case of a scaler change.
+
+ activeDialog->handleTickle();
+
+ if (_useStdCursor)
+ animateCursor();
+// _theme->updateScreen();
+// _system->updateScreen();
+
+ if (lastRedraw + waitTime < _system->getMillis()) {
+ _theme->updateScreen();
+ _system->updateScreen();
+ lastRedraw = _system->getMillis();
+ }
+
+ Common::Event event;
+ while (eventMan->pollEvent(event)) {
+
+ // The top dialog can change during the event loop. In that case, flush all the
+ // dialog-related events since they were probably generated while the old dialog
+ // was still visible, and therefore not intended for the new one.
+ //
+ // This hopefully fixes strange behaviour/crashes with pop-up widgets. (Most easily
+ // triggered in 3x mode or when running ScummVM under Valgrind.)
+ if (activeDialog != getTopDialog() && event.type != Common::EVENT_SCREEN_CHANGED)
+ continue;
+
+ Common::Point mouse(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y);
+
+ // HACK to change the cursor to the new themes one
+ if (_themeChange) {
+ _theme->enable();
+
+ _useStdCursor = !_theme->ownCursor();
+ if (_useStdCursor)
+ setupCursor();
+
+// _theme->refresh();
+
+ _themeChange = false;
+ _redrawStatus = kRedrawFull;
+ redraw();
+ }
+
+ if (lastRedraw + waitTime < _system->getMillis()) {
+ _theme->updateScreen();
+ _system->updateScreen();
+ lastRedraw = _system->getMillis();
+ }
+
+ switch (event.type) {
+ case Common::EVENT_KEYDOWN:
+ activeDialog->handleKeyDown(event.kbd);
+ break;
+ case Common::EVENT_KEYUP:
+ activeDialog->handleKeyUp(event.kbd);
+ break;
+ case Common::EVENT_MOUSEMOVE:
+ activeDialog->handleMouseMoved(mouse.x, mouse.y, 0);
+ break;
+ // We don't distinguish between mousebuttons (for now at least)
+ case Common::EVENT_LBUTTONDOWN:
+ case Common::EVENT_RBUTTONDOWN:
+ button = (event.type == Common::EVENT_LBUTTONDOWN ? 1 : 2);
+ time = _system->getMillis();
+ if (_lastClick.count && (time < _lastClick.time + kDoubleClickDelay)
+ && ABS(_lastClick.x - event.mouse.x) < 3
+ && ABS(_lastClick.y - event.mouse.y) < 3) {
+ _lastClick.count++;
+ } else {
+ _lastClick.x = event.mouse.x;
+ _lastClick.y = event.mouse.y;
+ _lastClick.count = 1;
+ }
+ _lastClick.time = time;
+ activeDialog->handleMouseDown(mouse.x, mouse.y, button, _lastClick.count);
+ break;
+ case Common::EVENT_LBUTTONUP:
+ case Common::EVENT_RBUTTONUP:
+ button = (event.type == Common::EVENT_LBUTTONUP ? 1 : 2);
+ activeDialog->handleMouseUp(mouse.x, mouse.y, button, _lastClick.count);
+ break;
+ case Common::EVENT_WHEELUP:
+ activeDialog->handleMouseWheel(mouse.x, mouse.y, -1);
+ break;
+ case Common::EVENT_WHEELDOWN:
+ activeDialog->handleMouseWheel(mouse.x, mouse.y, 1);
+ break;
+ case Common::EVENT_QUIT:
+ return;
+ case Common::EVENT_SCREEN_CHANGED:
+ screenChange();
+ break;
+ default:
+ break;
+ }
+ }
+
+ // Delay for a moment
+ _system->delayMillis(10);
+ }
+
+ if (didSaveState) {
+ _theme->disable();
+ restoreState();
+ _useStdCursor = false;
+ }
+}
+
+#pragma mark -
+
+void GuiManager::saveState() {
+ // Backup old cursor
+ _lastClick.x = _lastClick.y = 0;
+ _lastClick.time = 0;
+ _lastClick.count = 0;
+
+ _stateIsSaved = true;
+}
+
+void GuiManager::restoreState() {
+ if (_useStdCursor) {
+ CursorMan.popCursor();
+ CursorMan.popCursorPalette();
+ }
+
+ _system->updateScreen();
+
+ _stateIsSaved = false;
+}
+
+void GuiManager::openDialog(Dialog *dialog) {
+ _dialogStack.push(dialog);
+ if (_redrawStatus != kRedrawFull)
+ _redrawStatus = kRedrawOpenDialog;
+
+ // We reflow the dialog just before opening it. If the screen changed
+ // since the last time we looked, also refresh the loaded theme,
+ // and reflow all other open dialogs, too.
+ if (!checkScreenChange())
+ dialog->reflowLayout();
+}
+
+void GuiManager::closeTopDialog() {
+ // Don't do anything if no dialog is open
+ if (_dialogStack.empty())
+ return;
+
+ // Remove the dialog from the stack
+ _dialogStack.pop();
+ if (_redrawStatus != kRedrawFull)
+ _redrawStatus = kRedrawCloseDialog;
+}
+
+void GuiManager::setupCursor() {
+ const byte palette[] = {
+ 255, 255, 255, 0,
+ 255, 255, 255, 0,
+ 171, 171, 171, 0,
+ 87, 87, 87, 0
+ };
+
+ CursorMan.pushCursorPalette(palette, 0, 4);
+ CursorMan.pushCursor(NULL, 0, 0, 0, 0);
+ CursorMan.showMouse(true);
+}
+
+// Draw the mouse cursor (animated). This is pretty much the same as in old
+// SCUMM games, but the code no longer resembles what we have in cursor.cpp
+// very much. We could plug in a different cursor here if we like to.
+
+void GuiManager::animateCursor() {
+ int time = _system->getMillis();
+ if (time > _cursorAnimateTimer + kCursorAnimateDelay) {
+ for (int i = 0; i < 15; i++) {
+ if ((i < 6) || (i > 8)) {
+ _cursor[16 * 7 + i] = _cursorAnimateCounter;
+ _cursor[16 * i + 7] = _cursorAnimateCounter;
+ }
+ }
+
+ CursorMan.replaceCursor(_cursor, 16, 16, 7, 7);
+
+ _cursorAnimateTimer = time;
+ _cursorAnimateCounter = (_cursorAnimateCounter + 1) % 4;
+ }
+}
+
+bool GuiManager::checkScreenChange() {
+ int tmpScreenChangeID = _system->getScreenChangeID();
+ if (_lastScreenChangeID != tmpScreenChangeID) {
+ GuiManager::screenChange();
+ return true;
+ }
+ return false;
+}
+
+void GuiManager::screenChange() {
+ _lastScreenChangeID = _system->getScreenChangeID();
+
+ // reinit the whole theme
+ _theme->refresh();
+
+ // refresh all dialogs
+ for (int i = 0; i < _dialogStack.size(); ++i) {
+ _dialogStack[i]->reflowLayout();
+ }
+ // We need to redraw immediately. Otherwise
+ // some other event may cause a widget to be
+ // redrawn before redraw() has been called.
+ _redrawStatus = kRedrawFull;
+ redraw();
+ _system->updateScreen();
+}
+
+} // End of namespace GUI
Property changes on: scummvm/trunk/gui/GuiManager.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Copied: scummvm/trunk/gui/GuiManager.h (from rev 35667, scummvm/trunk/gui/newgui.h)
===================================================================
--- scummvm/trunk/gui/GuiManager.h (rev 0)
+++ scummvm/trunk/gui/GuiManager.h 2009-01-02 03:21:40 UTC (rev 35668)
@@ -0,0 +1,151 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ */
+
+#ifndef NEWGUI_H
+#define NEWGUI_H
+
+#include "common/scummsys.h"
+#include "common/singleton.h"
+#include "common/stack.h"
+#include "common/str.h"
+#include "graphics/fontman.h"
+
+#include "gui/widget.h"
+
+#include "gui/ThemeEngine.h"
+
+class OSystem;
+
+namespace GUI {
+
+class Dialog;
+class Eval;
+class ThemeEval;
+
+#define g_gui (GUI::GuiManager::instance())
+
+
+// Height of a single text line
+#define kLineHeight (g_gui.getFontHeight() + 2)
+
+
+
+// Simple dialog stack class
+// Anybody nesting dialogs deeper than 4 is mad anyway
+typedef Common::FixedStack<Dialog *> DialogStack;
+
+
+/**
+ * GUI manager singleton.
+ */
+class GuiManager : public Common::Singleton<GuiManager> {
+ friend class Dialog;
+ friend class Common::Singleton<SingletonBaseType>;
+ GuiManager();
+ ~GuiManager();
+public:
+
+ // Main entry for the GUI: this will start an event loop that keeps running
+ // until no dialogs are active anymore.
+ void runLoop();
+
+ bool isActive() const { return ! _dialogStack.empty(); }
+
+ bool loadNewTheme(Common::String file, ThemeEngine::GraphicsMode gfx = ThemeEngine::kGfxDisabled);
+ ThemeEngine *theme() { return _theme; }
+
+ ThemeEval *xmlEval() { return _theme->getEvaluator(); }
+
+ const Graphics::Font &getFont(ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return *(_theme->getFont(style)); }
+ int getFontHeight(ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getFontHeight(style); }
+ int getStringWidth(const Common::String &str, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getStringWidth(str, style); }
+ int getCharWidth(byte c, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getCharWidth(c, style); }
+
+ /**
+ * Tell the GuiManager to check whether the screen resolution has changed.
+ * If that is the case, the GuiManager will reload/refresh the active theme.
+ *
+ * @return true if the a screen change indeed occurred, false otherwise
+ */
+ bool checkScreenChange();
+
+protected:
+ enum RedrawStatus {
+ kRedrawDisabled = 0,
+ kRedrawOpenDialog,
+ kRedrawCloseDialog,
+ kRedrawTopDialog,
+ kRedrawFull
+ };
+
+
+
+ OSystem *_system;
+
+ ThemeEngine *_theme;
+
+// bool _needRedraw;
+ RedrawStatus _redrawStatus;
+ int _lastScreenChangeID;
+ DialogStack _dialogStack;
+
+ bool _stateIsSaved;
+
+ bool _useStdCursor;
+
+ // position and time of last mouse click (used to detect double clicks)
+ struct {
+ int16 x, y; // Position of mouse when the click occured
+ uint32 time; // Time
+ int count; // How often was it already pressed?
+ } _lastClick;
+
+ // mouse cursor state
+ int _cursorAnimateCounter;
+ int _cursorAnimateTimer;
+ byte _cursor[2048];
+
+ bool _themeChange;
+
+ void saveState();
+ void restoreState();
+
+ void openDialog(Dialog *dialog);
+ void closeTopDialog();
+
+ void redraw();
+
+ void loop();
+
+ void setupCursor();
+ void animateCursor();
+
+ Dialog *getTopDialog() const;
+
+ void screenChange();
+};
+
+} // End of namespace GUI
+
+#endif
Property changes on: scummvm/trunk/gui/GuiManager.h
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ Date Rev Author URL Id
Added: svn:mergeinfo
+
Added: svn:eol-style
+ native
Modified: scummvm/trunk/gui/KeysDialog.h
===================================================================
--- scummvm/trunk/gui/KeysDialog.h 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/KeysDialog.h 2009-01-02 03:21:40 UTC (rev 35668)
@@ -26,7 +26,7 @@
#ifndef KEYSDIALOG_H
#define KEYSDIALOG_H
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/dialog.h"
#include "gui/ListWidget.h"
#include "common/str.h"
Modified: scummvm/trunk/gui/ListWidget.cpp
===================================================================
--- scummvm/trunk/gui/ListWidget.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/ListWidget.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -27,7 +27,7 @@
#include "gui/ListWidget.h"
#include "gui/ScrollBarWidget.h"
#include "gui/dialog.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/ThemeEval.h"
Modified: scummvm/trunk/gui/PopUpWidget.cpp
===================================================================
--- scummvm/trunk/gui/PopUpWidget.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/PopUpWidget.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -25,7 +25,7 @@
#include "common/system.h"
#include "common/events.h"
#include "gui/dialog.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/PopUpWidget.h"
#include "engines/engine.h"
Modified: scummvm/trunk/gui/ScrollBarWidget.cpp
===================================================================
--- scummvm/trunk/gui/ScrollBarWidget.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/ScrollBarWidget.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -24,7 +24,7 @@
#include "ScrollBarWidget.h"
#include "gui/dialog.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
namespace GUI {
Modified: scummvm/trunk/gui/TabWidget.cpp
===================================================================
--- scummvm/trunk/gui/TabWidget.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/TabWidget.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -25,7 +25,7 @@
#include "common/util.h"
#include "gui/TabWidget.h"
#include "gui/dialog.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/ThemeEval.h"
Modified: scummvm/trunk/gui/ThemeParser.cpp
===================================================================
--- scummvm/trunk/gui/ThemeParser.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/ThemeParser.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -33,7 +33,7 @@
#include "gui/ThemeEngine.h"
#include "gui/ThemeEval.h"
#include "gui/ThemeParser.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "graphics/VectorRenderer.h"
namespace GUI {
Modified: scummvm/trunk/gui/about.cpp
===================================================================
--- scummvm/trunk/gui/about.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/about.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -29,7 +29,7 @@
#include "common/system.h"
#include "common/util.h"
#include "gui/about.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/widget.h"
#include "gui/ThemeEval.h"
Modified: scummvm/trunk/gui/browser.cpp
===================================================================
--- scummvm/trunk/gui/browser.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/browser.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -23,7 +23,7 @@
*/
#include "gui/browser.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/ListWidget.h"
#include "common/config-manager.h"
Modified: scummvm/trunk/gui/chooser.cpp
===================================================================
--- scummvm/trunk/gui/chooser.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/chooser.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -24,7 +24,7 @@
#include "common/system.h"
#include "gui/chooser.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/ListWidget.h"
namespace GUI {
Modified: scummvm/trunk/gui/console.h
===================================================================
--- scummvm/trunk/gui/console.h 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/console.h 2009-01-02 03:21:40 UTC (rev 35668)
@@ -26,7 +26,7 @@
#define CONSOLE_DIALOG_H
#include "gui/dialog.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
namespace GUI {
Modified: scummvm/trunk/gui/dialog.cpp
===================================================================
--- scummvm/trunk/gui/dialog.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/dialog.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -24,7 +24,7 @@
#include "common/events.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/dialog.h"
#include "gui/widget.h"
#include "gui/PopUpWidget.h"
Modified: scummvm/trunk/gui/editable.cpp
===================================================================
--- scummvm/trunk/gui/editable.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/editable.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -24,7 +24,7 @@
#include "common/events.h"
#include "gui/editable.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
namespace GUI {
Modified: scummvm/trunk/gui/editable.h
===================================================================
--- scummvm/trunk/gui/editable.h 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/editable.h 2009-01-02 03:21:40 UTC (rev 35668)
@@ -28,7 +28,7 @@
#include "common/str.h"
#include "common/rect.h"
#include "gui/widget.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
namespace GUI {
Modified: scummvm/trunk/gui/launcher.cpp
===================================================================
--- scummvm/trunk/gui/launcher.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/launcher.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -37,7 +37,7 @@
#include "gui/launcher.h"
#include "gui/massadd.h"
#include "gui/message.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/options.h"
#include "gui/saveload.h"
#include "gui/EditTextWidget.h"
Modified: scummvm/trunk/gui/massadd.cpp
===================================================================
--- scummvm/trunk/gui/massadd.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/massadd.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -30,7 +30,7 @@
#include "gui/launcher.h" // For addGameToConf()
#include "gui/massadd.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/widget.h"
Modified: scummvm/trunk/gui/message.cpp
===================================================================
--- scummvm/trunk/gui/message.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/message.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -26,7 +26,7 @@
#include "common/str.h"
#include "common/system.h"
#include "gui/message.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/ThemeEval.h"
#include "gui/widget.h"
Modified: scummvm/trunk/gui/module.mk
===================================================================
--- scummvm/trunk/gui/module.mk 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/module.mk 2009-01-02 03:21:40 UTC (rev 35668)
@@ -9,11 +9,11 @@
dialog.o \
editable.o \
EditTextWidget.o \
+ GuiManager.o \
launcher.o \
ListWidget.o \
massadd.o \
message.o \
- newgui.o \
object.o \
options.o \
PopUpWidget.o \
Deleted: scummvm/trunk/gui/newgui.cpp
===================================================================
--- scummvm/trunk/gui/newgui.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/newgui.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -1,424 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- */
-
-#include "common/events.h"
-#include "common/system.h"
-#include "common/util.h"
-#include "common/config-manager.h"
-
-#include "gui/newgui.h"
-#include "gui/dialog.h"
-#include "gui/ThemeEngine.h"
-#include "gui/ThemeEval.h"
-
-#include "graphics/cursorman.h"
-
-DECLARE_SINGLETON(GUI::GuiManager);
-
-namespace GUI {
-
-enum {
- kDoubleClickDelay = 500, // milliseconds
- kCursorAnimateDelay = 250
-};
-
-// Constructor
-GuiManager::GuiManager() : _redrawStatus(kRedrawDisabled),
- _stateIsSaved(false), _cursorAnimateCounter(0), _cursorAnimateTimer(0) {
- _theme = 0;
- _useStdCursor = false;
-
- _system = g_system;
- _lastScreenChangeID = _system->getScreenChangeID();
-
- // Clear the cursor
- memset(_cursor, 0xFF, sizeof(_cursor));
-
-
- ConfMan.registerDefault("gui_theme", "scummmodern.zip");
- Common::String themefile(ConfMan.get("gui_theme"));
- if (themefile.compareToIgnoreCase("default") == 0)
- themefile = "builtin";
-
- ConfMan.registerDefault("gui_renderer", ThemeEngine::findModeConfigName(ThemeEngine::_defaultRendererMode));
- ThemeEngine::GraphicsMode gfxMode = (ThemeEngine::GraphicsMode)ThemeEngine::findMode(ConfMan.get("gui_renderer"));
-
- // Try to load the theme
- if (!loadNewTheme(themefile, gfxMode)) {
- // Loading the theme failed, try to load the built-in theme
- if (!loadNewTheme("builtin", gfxMode)) {
- // Loading the built-in theme failed as well. Bail out
- error("Failed to load any GUI theme, aborting");
- }
- }
- _themeChange = false;
-}
-
-GuiManager::~GuiManager() {
- delete _theme;
-}
-
-bool GuiManager::loadNewTheme(Common::String filename, ThemeEngine::GraphicsMode gfx) {
- // If we are asked to reload the currently active theme, just do nothing
- // FIXME: Actually, why? It might be desirable at times to force a theme reload...
- if (_theme && filename == _theme->getThemeId() && gfx == _theme->getGraphicsMode())
- return true;
-
- ThemeEngine *newTheme = 0;
-
- if (gfx == ThemeEngine::kGfxDisabled)
- gfx = ThemeEngine::_defaultRendererMode;
-
- // Try to load the new theme
- newTheme = new ThemeEngine(filename, gfx);
- assert(newTheme);
-
- if (!newTheme->init())
- return false;
-
- //
- // Disable and delete the old theme
- //
- if (_theme)
- _theme->disable();
- delete _theme;
-
- if (_useStdCursor) {
- CursorMan.popCursorPalette();
- CursorMan.popCursor();
- }
-
- //
- // Enable the new theme
- //
- _theme = newTheme;
- _themeChange = true;
-
- // refresh all dialogs
- for (int i = 0; i < _dialogStack.size(); ++i) {
- _dialogStack[i]->reflowLayout();
- }
-
- // We need to redraw immediately. Otherwise
- // some other event may cause a widget to be
- // redrawn before redraw() has been called.
- _redrawStatus = kRedrawFull;
- redraw();
- _system->updateScreen();
-
- return true;
-}
-
-void GuiManager::redraw() {
- int i;
-
- if (_redrawStatus == kRedrawDisabled)
- return;
-
- if (_dialogStack.empty())
- return;
-
- switch (_redrawStatus) {
- case kRedrawCloseDialog:
- case kRedrawFull:
- case kRedrawTopDialog:
- _theme->clearAll();
- _theme->openDialog(true);
-
- for (i = 0; i < _dialogStack.size() - 1; i++) {
- _dialogStack[i]->drawDialog();
- }
-
- _theme->finishBuffering();
- _theme->updateScreen();
-
- case kRedrawOpenDialog:
- _theme->openDialog(true, (ThemeEngine::ShadingStyle)xmlEval()->getVar("Dialog." + _dialogStack.top()->_name + ".Shading", 0));
- _dialogStack.top()->drawDialog();
- _theme->finishBuffering();
- break;
-
- default:
- return;
- }
-
- _theme->updateScreen();
- _redrawStatus = kRedrawDisabled;
-}
-
-Dialog *GuiManager::getTopDialog() const {
- if (_dialogStack.empty())
- return 0;
- return _dialogStack.top();
-}
-
-void GuiManager::runLoop() {
- Dialog *activeDialog = getTopDialog();
- bool didSaveState = false;
- int button;
- uint32 time;
-
- if (activeDialog == 0)
- return;
-
- if (!_stateIsSaved) {
- saveState();
- _theme->enable();
- didSaveState = true;
-
- _useStdCursor = !_theme->ownCursor();
- if (_useStdCursor)
- setupCursor();
-
-// _theme->refresh();
-
- _themeChange = false;
- _redrawStatus = kRedrawFull;
- redraw();
- }
-
- Common::EventManager *eventMan = _system->getEventManager();
- uint32 lastRedraw = 0;
- const uint32 waitTime = 1000 / 45;
-
- while (!_dialogStack.empty() && activeDialog == getTopDialog()) {
- redraw();
-
- // Don't "tickle" the dialog until the theme has had a chance
- // to re-allocate buffers in case of a scaler change.
-
- activeDialog->handleTickle();
-
- if (_useStdCursor)
- animateCursor();
-// _theme->updateScreen();
-// _system->updateScreen();
-
- if (lastRedraw + waitTime < _system->getMillis()) {
- _theme->updateScreen();
- _system->updateScreen();
- lastRedraw = _system->getMillis();
- }
-
- Common::Event event;
- while (eventMan->pollEvent(event)) {
-
- // The top dialog can change during the event loop. In that case, flush all the
- // dialog-related events since they were probably generated while the old dialog
- // was still visible, and therefore not intended for the new one.
- //
- // This hopefully fixes strange behaviour/crashes with pop-up widgets. (Most easily
- // triggered in 3x mode or when running ScummVM under Valgrind.)
- if (activeDialog != getTopDialog() && event.type != Common::EVENT_SCREEN_CHANGED)
- continue;
-
- Common::Point mouse(event.mouse.x - activeDialog->_x, event.mouse.y - activeDialog->_y);
-
- // HACK to change the cursor to the new themes one
- if (_themeChange) {
- _theme->enable();
-
- _useStdCursor = !_theme->ownCursor();
- if (_useStdCursor)
- setupCursor();
-
-// _theme->refresh();
-
- _themeChange = false;
- _redrawStatus = kRedrawFull;
- redraw();
- }
-
- if (lastRedraw + waitTime < _system->getMillis()) {
- _theme->updateScreen();
- _system->updateScreen();
- lastRedraw = _system->getMillis();
- }
-
- switch (event.type) {
- case Common::EVENT_KEYDOWN:
- activeDialog->handleKeyDown(event.kbd);
- break;
- case Common::EVENT_KEYUP:
- activeDialog->handleKeyUp(event.kbd);
- break;
- case Common::EVENT_MOUSEMOVE:
- activeDialog->handleMouseMoved(mouse.x, mouse.y, 0);
- break;
- // We don't distinguish between mousebuttons (for now at least)
- case Common::EVENT_LBUTTONDOWN:
- case Common::EVENT_RBUTTONDOWN:
- button = (event.type == Common::EVENT_LBUTTONDOWN ? 1 : 2);
- time = _system->getMillis();
- if (_lastClick.count && (time < _lastClick.time + kDoubleClickDelay)
- && ABS(_lastClick.x - event.mouse.x) < 3
- && ABS(_lastClick.y - event.mouse.y) < 3) {
- _lastClick.count++;
- } else {
- _lastClick.x = event.mouse.x;
- _lastClick.y = event.mouse.y;
- _lastClick.count = 1;
- }
- _lastClick.time = time;
- activeDialog->handleMouseDown(mouse.x, mouse.y, button, _lastClick.count);
- break;
- case Common::EVENT_LBUTTONUP:
- case Common::EVENT_RBUTTONUP:
- button = (event.type == Common::EVENT_LBUTTONUP ? 1 : 2);
- activeDialog->handleMouseUp(mouse.x, mouse.y, button, _lastClick.count);
- break;
- case Common::EVENT_WHEELUP:
- activeDialog->handleMouseWheel(mouse.x, mouse.y, -1);
- break;
- case Common::EVENT_WHEELDOWN:
- activeDialog->handleMouseWheel(mouse.x, mouse.y, 1);
- break;
- case Common::EVENT_QUIT:
- return;
- case Common::EVENT_SCREEN_CHANGED:
- screenChange();
- break;
- default:
- break;
- }
- }
-
- // Delay for a moment
- _system->delayMillis(10);
- }
-
- if (didSaveState) {
- _theme->disable();
- restoreState();
- _useStdCursor = false;
- }
-}
-
-#pragma mark -
-
-void GuiManager::saveState() {
- // Backup old cursor
- _lastClick.x = _lastClick.y = 0;
- _lastClick.time = 0;
- _lastClick.count = 0;
-
- _stateIsSaved = true;
-}
-
-void GuiManager::restoreState() {
- if (_useStdCursor) {
- CursorMan.popCursor();
- CursorMan.popCursorPalette();
- }
-
- _system->updateScreen();
-
- _stateIsSaved = false;
-}
-
-void GuiManager::openDialog(Dialog *dialog) {
- _dialogStack.push(dialog);
- if (_redrawStatus != kRedrawFull)
- _redrawStatus = kRedrawOpenDialog;
-
- // We reflow the dialog just before opening it. If the screen changed
- // since the last time we looked, also refresh the loaded theme,
- // and reflow all other open dialogs, too.
- if (!checkScreenChange())
- dialog->reflowLayout();
-}
-
-void GuiManager::closeTopDialog() {
- // Don't do anything if no dialog is open
- if (_dialogStack.empty())
- return;
-
- // Remove the dialog from the stack
- _dialogStack.pop();
- if (_redrawStatus != kRedrawFull)
- _redrawStatus = kRedrawCloseDialog;
-}
-
-void GuiManager::setupCursor() {
- const byte palette[] = {
- 255, 255, 255, 0,
- 255, 255, 255, 0,
- 171, 171, 171, 0,
- 87, 87, 87, 0
- };
-
- CursorMan.pushCursorPalette(palette, 0, 4);
- CursorMan.pushCursor(NULL, 0, 0, 0, 0);
- CursorMan.showMouse(true);
-}
-
-// Draw the mouse cursor (animated). This is pretty much the same as in old
-// SCUMM games, but the code no longer resembles what we have in cursor.cpp
-// very much. We could plug in a different cursor here if we like to.
-
-void GuiManager::animateCursor() {
- int time = _system->getMillis();
- if (time > _cursorAnimateTimer + kCursorAnimateDelay) {
- for (int i = 0; i < 15; i++) {
- if ((i < 6) || (i > 8)) {
- _cursor[16 * 7 + i] = _cursorAnimateCounter;
- _cursor[16 * i + 7] = _cursorAnimateCounter;
- }
- }
-
- CursorMan.replaceCursor(_cursor, 16, 16, 7, 7);
-
- _cursorAnimateTimer = time;
- _cursorAnimateCounter = (_cursorAnimateCounter + 1) % 4;
- }
-}
-
-bool GuiManager::checkScreenChange() {
- int tmpScreenChangeID = _system->getScreenChangeID();
- if (_lastScreenChangeID != tmpScreenChangeID) {
- GuiManager::screenChange();
- return true;
- }
- return false;
-}
-
-void GuiManager::screenChange() {
- _lastScreenChangeID = _system->getScreenChangeID();
-
- // reinit the whole theme
- _theme->refresh();
-
- // refresh all dialogs
- for (int i = 0; i < _dialogStack.size(); ++i) {
- _dialogStack[i]->reflowLayout();
- }
- // We need to redraw immediately. Otherwise
- // some other event may cause a widget to be
- // redrawn before redraw() has been called.
- _redrawStatus = kRedrawFull;
- redraw();
- _system->updateScreen();
-}
-
-} // End of namespace GUI
Deleted: scummvm/trunk/gui/newgui.h
===================================================================
--- scummvm/trunk/gui/newgui.h 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/newgui.h 2009-01-02 03:21:40 UTC (rev 35668)
@@ -1,151 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- */
-
-#ifndef NEWGUI_H
-#define NEWGUI_H
-
-#include "common/scummsys.h"
-#include "common/singleton.h"
-#include "common/stack.h"
-#include "common/str.h"
-#include "graphics/fontman.h"
-
-#include "gui/widget.h"
-
-#include "gui/ThemeEngine.h"
-
-class OSystem;
-
-namespace GUI {
-
-class Dialog;
-class Eval;
-class ThemeEval;
-
-#define g_gui (GUI::GuiManager::instance())
-
-
-// Height of a single text line
-#define kLineHeight (g_gui.getFontHeight() + 2)
-
-
-
-// Simple dialog stack class
-// Anybody nesting dialogs deeper than 4 is mad anyway
-typedef Common::FixedStack<Dialog *> DialogStack;
-
-
-/**
- * GUI manager singleton.
- */
-class GuiManager : public Common::Singleton<GuiManager> {
- friend class Dialog;
- friend class Common::Singleton<SingletonBaseType>;
- GuiManager();
- ~GuiManager();
-public:
-
- // Main entry for the GUI: this will start an event loop that keeps running
- // until no dialogs are active anymore.
- void runLoop();
-
- bool isActive() const { return ! _dialogStack.empty(); }
-
- bool loadNewTheme(Common::String file, ThemeEngine::GraphicsMode gfx = ThemeEngine::kGfxDisabled);
- ThemeEngine *theme() { return _theme; }
-
- ThemeEval *xmlEval() { return _theme->getEvaluator(); }
-
- const Graphics::Font &getFont(ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return *(_theme->getFont(style)); }
- int getFontHeight(ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getFontHeight(style); }
- int getStringWidth(const Common::String &str, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getStringWidth(str, style); }
- int getCharWidth(byte c, ThemeEngine::FontStyle style = ThemeEngine::kFontStyleBold) const { return _theme->getCharWidth(c, style); }
-
- /**
- * Tell the GuiManager to check whether the screen resolution has changed.
- * If that is the case, the GuiManager will reload/refresh the active theme.
- *
- * @return true if the a screen change indeed occurred, false otherwise
- */
- bool checkScreenChange();
-
-protected:
- enum RedrawStatus {
- kRedrawDisabled = 0,
- kRedrawOpenDialog,
- kRedrawCloseDialog,
- kRedrawTopDialog,
- kRedrawFull
- };
-
-
-
- OSystem *_system;
-
- ThemeEngine *_theme;
-
-// bool _needRedraw;
- RedrawStatus _redrawStatus;
- int _lastScreenChangeID;
- DialogStack _dialogStack;
-
- bool _stateIsSaved;
-
- bool _useStdCursor;
-
- // position and time of last mouse click (used to detect double clicks)
- struct {
- int16 x, y; // Position of mouse when the click occured
- uint32 time; // Time
- int count; // How often was it already pressed?
- } _lastClick;
-
- // mouse cursor state
- int _cursorAnimateCounter;
- int _cursorAnimateTimer;
- byte _cursor[2048];
-
- bool _themeChange;
-
- void saveState();
- void restoreState();
-
- void openDialog(Dialog *dialog);
- void closeTopDialog();
-
- void redraw();
-
- void loop();
-
- void setupCursor();
- void animateCursor();
-
- Dialog *getTopDialog() const;
-
- void screenChange();
-};
-
-} // End of namespace GUI
-
-#endif
Modified: scummvm/trunk/gui/object.cpp
===================================================================
--- scummvm/trunk/gui/object.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/object.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -25,7 +25,7 @@
#include "common/system.h"
#include "gui/object.h"
#include "gui/widget.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/ThemeEval.h"
namespace GUI {
Modified: scummvm/trunk/gui/options.cpp
===================================================================
--- scummvm/trunk/gui/options.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/options.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -26,7 +26,7 @@
#include "gui/themebrowser.h"
#include "gui/chooser.h"
#include "gui/message.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/ThemeEval.h"
#include "gui/options.h"
#include "gui/PopUpWidget.h"
Modified: scummvm/trunk/gui/widget.cpp
===================================================================
--- scummvm/trunk/gui/widget.cpp 2009-01-02 03:03:06 UTC (rev 35667)
+++ scummvm/trunk/gui/widget.cpp 2009-01-02 03:21:40 UTC (rev 35668)
@@ -26,7 +26,7 @@
#include "graphics/fontman.h"
#include "gui/widget.h"
#include "gui/dialog.h"
-#include "gui/newgui.h"
+#include "gui/GuiManager.h"
#include "gui/ThemeEval.h"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list