aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/InterfaceManager.cpp23
-rw-r--r--gui/InterfaceManager.h20
-rw-r--r--gui/ThemeParser.cpp9
-rw-r--r--gui/ThemeParser.h6
-rw-r--r--gui/object.h3
5 files changed, 45 insertions, 16 deletions
diff --git a/gui/InterfaceManager.cpp b/gui/InterfaceManager.cpp
index d4a0a167ff..80fa0d33db 100644
--- a/gui/InterfaceManager.cpp
+++ b/gui/InterfaceManager.cpp
@@ -30,6 +30,8 @@
#include "common/events.h"
#include "common/config-manager.h"
+#include "gui/launcher.h"
+
#include "gui/InterfaceManager.h"
#include "graphics/VectorRenderer.h"
@@ -73,7 +75,7 @@ InterfaceManager::InterfaceManager() :
_screen(0), _bytesPerPixel(0), _initOk(false), _themeOk(false),
_needThemeLoad(false), _enabled(false) {
_system = g_system;
- _parser = new ThemeParser();
+ _parser = new ThemeParser(this);
for (int i = 0; i < kDrawDataMAX; ++i) {
_widgets[i] = 0;
@@ -276,6 +278,22 @@ void InterfaceManager::redrawDialogStack() {
_dialogStack[i]->draw();
}
+void InterfaceManager::openDialog(Dialogs dname, Dialog *parent) {
+ Dialog *dlg = 0;
+ switch (dname) {
+ case kDialogLauncher:
+ dlg = new GUI::LauncherDialog;
+ break;
+
+ default:
+ error("Unhandled dialog opening");
+ break;
+ }
+
+ if (dlg)
+ _dialogStack.push(dlg);
+}
+
int InterfaceManager::runGUI() {
init();
@@ -289,8 +307,7 @@ int InterfaceManager::runGUI() {
if (!activeDialog)
return 0;
- bool didSaveState = false;
- bool stackChange = true;
+ bool stackChange;
int button;
uint32 time;
diff --git a/gui/InterfaceManager.h b/gui/InterfaceManager.h
index 0a0c62c9f8..ac612e0c52 100644
--- a/gui/InterfaceManager.h
+++ b/gui/InterfaceManager.h
@@ -39,8 +39,6 @@
namespace GUI {
-#define g_InterfaceManager (GUI::InterfaceManager::instance())
-
struct WidgetDrawData;
class InterfaceManager;
@@ -64,14 +62,13 @@ struct WidgetDrawData {
}
};
-class InterfaceManager : public Common::Singleton<InterfaceManager> {
+class InterfaceManager {
typedef Common::String String;
typedef GUI::Dialog Dialog;
friend class GUI::Dialog;
friend class GUI::GuiObject;
- friend class Common::Singleton<SingletonBaseType>;
static const char *kDrawDataStrings[];
static const int kMaxDialogDepth = 4;
@@ -82,6 +79,11 @@ public:
kGfxStandard16bit,
kGfxAntialias16bit
};
+
+ enum Dialogs {
+ kDialogLauncher,
+ kDialogMAX
+ };
enum {
kDoubleClickDelay = 500, // milliseconds
@@ -235,6 +237,12 @@ public:
}
bool loadTheme(Common::String themeName);
+ void openDialog(Dialogs dname, Dialog *parent);
+
+ void closeTopDialog() {
+ assert(_dialogStack.empty() == false);
+ delete _dialogStack.pop();
+ }
protected:
template<typename PixelType> void screenInit();
@@ -273,10 +281,6 @@ protected:
return _dialogStack.top();
}
- void openDialog(Dialog *dlg) {
- _dialogStack.push(dlg);
- }
-
bool needThemeReload() {
return (_themeOk == false || _needThemeLoad == true);
}
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
index 8dc02297b7..07789ebee3 100644
--- a/gui/ThemeParser.cpp
+++ b/gui/ThemeParser.cpp
@@ -39,7 +39,7 @@ namespace GUI {
using namespace Graphics;
using namespace Common;
-ThemeParser::ThemeParser() : XMLParser() {
+ThemeParser::ThemeParser(InterfaceManager *parent) : XMLParser() {
_callbacks["drawstep"] = &ThemeParser::parserCallback_DRAWSTEP;
_callbacks["drawdata"] = &ThemeParser::parserCallback_DRAWDATA;
_callbacks["palette"] = &ThemeParser::parserCallback_palette;
@@ -59,6 +59,7 @@ ThemeParser::ThemeParser() : XMLParser() {
_defaultStepGlobal = defaultDrawStep();
_defaultStepLocal = 0;
+ _GUI = parent;
}
bool ThemeParser::keyCallback(Common::String keyName) {
@@ -212,7 +213,7 @@ bool ThemeParser::parserCallback_DRAWSTEP() {
if (!parseDrawStep(stepNode, drawstep, true))
return false;
- g_InterfaceManager.addDrawStep(drawdataNode->values["id"], drawstep);
+ _GUI->addDrawStep(drawdataNode->values["id"], drawstep);
return true;
}
@@ -228,7 +229,7 @@ bool ThemeParser::parserCallback_DRAWDATA() {
if (drawdataNode->values.contains("id") == false)
return parserError("DrawData keys must contain an identifier.");
- InterfaceManager::DrawData id = g_InterfaceManager.getDrawDataId(drawdataNode->values["id"]);
+ InterfaceManager::DrawData id = _GUI->getDrawDataId(drawdataNode->values["id"]);
if (id == -1)
return parserError("%s is not a valid DrawData set identifier.", drawdataNode->values["id"].c_str());
@@ -251,7 +252,7 @@ bool ThemeParser::parserCallback_DRAWDATA() {
}
}*/
- if (g_InterfaceManager.addDrawData(id, cached) == false)
+ if (_GUI->addDrawData(id, cached) == false)
return parserError("Repeated DrawData: Only one set of Drawing Data for a widget may be specified on each platform.");
if (_defaultStepLocal) {
diff --git a/gui/ThemeParser.h b/gui/ThemeParser.h
index 55f39d8a44..68e8272b80 100644
--- a/gui/ThemeParser.h
+++ b/gui/ThemeParser.h
@@ -36,6 +36,7 @@
#include "common/xmlparser.h"
#include "graphics/VectorRenderer.h"
+#include "gui/InterfaceManager.h"
/**
*********************************************
@@ -307,15 +308,18 @@ namespace GUI {
using namespace Graphics;
using namespace Common;
+class InterfaceManager;
class ThemeParser : public XMLParser {
typedef void (VectorRenderer::*DrawingFunctionCallback)(const Common::Rect &, const DrawStep &);
typedef bool (ThemeParser::*ParserCallback)();
+ typedef GUI::InterfaceManager InterfaceManager;
public:
- ThemeParser();
+ ThemeParser(InterfaceManager *parent);
protected:
+ InterfaceManager *_GUI;
bool keyCallback(Common::String keyName);
bool parserCallback_DRAWSTEP();
diff --git a/gui/object.h b/gui/object.h
index 01046bd668..2bdff3f76c 100644
--- a/gui/object.h
+++ b/gui/object.h
@@ -29,6 +29,7 @@ namespace GUI {
class CommandReceiver;
class CommandSender;
+class InterfaceManager;
class CommandReceiver {
friend class CommandSender;
@@ -65,6 +66,7 @@ protected:
Common::String _name;
Widget *_firstWidget;
+ InterfaceManager *_GUI;
public:
GuiObject(int x, int y, int w, int h) : _x(x), _y(y), _w(w), _h(h), _name(""), _firstWidget(0) { }
@@ -83,6 +85,7 @@ public:
virtual void draw() = 0;
virtual void reflowLayout();
+ virtual void setInterfaceManager(InterfaceManager *manager) { _GUI = manager; }
protected:
virtual void releaseFocus() = 0;