aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
Diffstat (limited to 'gui')
-rw-r--r--gui/InterfaceManager.cpp12
-rw-r--r--gui/InterfaceManager.h9
-rw-r--r--gui/ThemeParser.cpp66
-rw-r--r--gui/ThemeParser.h9
4 files changed, 86 insertions, 10 deletions
diff --git a/gui/InterfaceManager.cpp b/gui/InterfaceManager.cpp
index ae52387502..dc2250a2bd 100644
--- a/gui/InterfaceManager.cpp
+++ b/gui/InterfaceManager.cpp
@@ -77,6 +77,11 @@ void InterfaceManager::setGraphicsMode(Graphics_Mode mode) {
_vectorRenderer->setSurface(_screen);
}
+void InterfaceManager::addDrawStep(Common::String &drawDataId, Graphics::DrawStep *step) {
+ _widgets[getDrawDataId(drawDataId)]->_steps.push_back(step);
+}
+
+
bool InterfaceManager::init() {
return false;
}
@@ -96,7 +101,7 @@ void InterfaceManager::drawDD(DrawData type, const Common::Rect &r) {
if (isWidgetCached(type, r)) {
drawCached(type, r);
} else {
- for (int i = 0; i < _widgets[type]->_stepCount; ++i)
+ for (uint i = 0; i < _widgets[type]->_steps.size(); ++i)
_vectorRenderer->drawStep(r, *_widgets[type]->_steps[i]);
}
}
@@ -171,7 +176,6 @@ int InterfaceManager::runGUI() {
steps[0].gradColor2.b = 25;
steps[0].fillMode = VectorRenderer::kFillGradient;
steps[0].drawingCall = &VectorRenderer::drawCallback_FILLSURFACE;
- steps[0].flags = DrawStep::kStepSetGradient | DrawStep::kStepSetFillMode;
steps[1].gradColor1.r = 206;
steps[1].gradColor1.g = 121;
@@ -182,7 +186,6 @@ int InterfaceManager::runGUI() {
steps[1].radius = 8; // radius
steps[1].fillArea = true;
steps[1].drawingCall = &VectorRenderer::drawCallback_ROUNDSQ;
- steps[1].flags = DrawStep::kStepSetGradient;
steps[1].scale = (1 << 16);
steps[2].radius = 8; // radius
@@ -194,13 +197,12 @@ int InterfaceManager::runGUI() {
steps[2].w = 128;
steps[2].h = 32;
steps[2].drawingCall = &VectorRenderer::drawCallback_ROUNDSQ;
- steps[2].flags = DrawStep::kStepCallbackOnly;
steps[2].scale = (1 << 16);
steps[3].fgColor.r = 255;
steps[3].fgColor.g = 255;
steps[3].fgColor.b = 255;
- steps[3].flags = DrawStep::kStepSettingsOnly | DrawStep::kStepSetFG;
+ steps[3].drawingCall = &VectorRenderer::drawCallback_VOID;
Common::Rect area = Common::Rect(32, 32, 256, 256);
diff --git a/gui/InterfaceManager.h b/gui/InterfaceManager.h
index 7ab3f4c9db..f5efb105ec 100644
--- a/gui/InterfaceManager.h
+++ b/gui/InterfaceManager.h
@@ -167,6 +167,12 @@ public:
void drawCaret(const Common::Rect &r, bool erase, WidgetStateInfo state = kStateEnabled) {}
void drawLineSeparator(const Common::Rect &r, WidgetStateInfo state = kStateEnabled);
+ DrawData getDrawDataId(Common::String &name) {
+ return (DrawData)0;
+ }
+
+ void addDrawStep(Common::String &drawDataId, Graphics::DrawStep *step);
+
protected:
template<typename PixelType> void screenInit();
@@ -209,8 +215,7 @@ struct WidgetDrawData {
Common::Rect _realSize;
bool _scaled;
- Graphics::DrawStep **_steps;
- int _stepCount;
+ Common::Array<Graphics::DrawStep*> _steps;
bool _cached;
Graphics::Surface *_surfaceCache;
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
index 267efba371..287805b0b6 100644
--- a/gui/ThemeParser.cpp
+++ b/gui/ThemeParser.cpp
@@ -29,7 +29,9 @@
#include "common/hashmap.h"
#include "common/hash-str.h"
+#include "gui/InterfaceManager.h"
#include "gui/ThemeParser.h"
+#include "graphics/VectorRenderer.h"
/**
@@ -42,6 +44,8 @@
namespace GUI {
+using namespace Graphics;
+
void ThemeParser::debug_testEval() {
static const char *debugConfigText =
"</* lol this is just a moronic test */drawdata id = \"background_default\" cache = true>\n"
@@ -50,6 +54,11 @@ void ThemeParser::debug_testEval() {
"</ drawdata>/* lol this is just a simple test*/\n";
_text = strdup(debugConfigText);
+
+ Common::String test = "12, 125, 125";
+
+ printf("\n\nRegex result: %s.\n\n", test.regexMatch("^[d]*,[d]*,[d]*$", true) ? "Success." : "Fail");
+
parse();
}
@@ -59,8 +68,59 @@ void ThemeParser::parserError(const char *error_string) {
printf("PARSER ERROR: %s\n", error_string);
}
+Graphics::DrawStep *ThemeParser::newDrawStep() {
+
+ Graphics::DrawStep *step = new DrawStep;
+
+ step->fgColor.set = false;
+ step->bgColor.set = false;
+ step->gradColor1.set = false;
+ step->gradColor2.set = false;
+
+ step->extraData = 0;
+ step->factor = 1;
+ step->fillArea = false;
+ step->fillMode = Graphics::VectorRenderer::kFillDisabled;
+ step->scale = (1 << 16);
+ step->shadow = 0;
+ step->stroke = 1;
+
+ return step;
+}
+
void ThemeParser::parserCallback_DRAWSTEP() {
- printf("Draw callback!\n");
+ ParserNode *stepNode = _activeKey.pop();
+ ParserNode *drawdataNode = _activeKey.pop();
+
+ assert(stepNode->name == "drawstep");
+ assert(drawdataNode->name == "drawdata");
+ assert(drawdataNode->values.contains("id"));
+
+ Graphics::DrawStep *drawstep = newDrawStep();
+
+ Common::String functionName = stepNode->values["func"];
+
+ if (_drawFunctions.contains(functionName) == false) {
+ parserError("Invalid drawing function in draw step.");
+ _activeKey.push(drawdataNode);
+ _activeKey.push(stepNode);
+ return;
+ }
+
+ drawstep->drawingCall = _drawFunctions[functionName];
+
+ if (stepNode->values.contains("stroke")) {
+
+ }
+
+ if (functionName == "roundedsq") {
+
+ }
+
+ g_InterfaceManager.addDrawStep(drawdataNode->values["id"], drawstep);
+
+ _activeKey.push(drawdataNode);
+ _activeKey.push(stepNode);
}
void ThemeParser::parserCallback_DRAWDATA() {
@@ -78,8 +138,8 @@ void ThemeParser::parseActiveKey(bool closed) {
// Don't you just love C++ syntax? Water clear.
(this->*(_callbacks[_activeKey.top()->name]))();
- for (Common::StringMap::const_iterator t = _activeKey.top()->values.begin(); t != _activeKey.top()->values.end(); ++t)
- printf(" Key %s = %s\n", t->_key.c_str(), t->_value.c_str());
+// for (Common::StringMap::const_iterator t = _activeKey.top()->values.begin(); t != _activeKey.top()->values.end(); ++t)
+// printf(" Key %s = %s\n", t->_key.c_str(), t->_value.c_str());
if (closed) {
delete _activeKey.pop();
diff --git a/gui/ThemeParser.h b/gui/ThemeParser.h
index 956a6d1df2..c5ee55dbbf 100644
--- a/gui/ThemeParser.h
+++ b/gui/ThemeParser.h
@@ -34,6 +34,8 @@
#include "common/hash-str.h"
#include "common/stack.h"
+#include "graphics/VectorRenderer.h"
+
/**
*********************************************
** Theme Description File format overview. **
@@ -302,10 +304,13 @@ func = "fill"
namespace GUI {
+using namespace Graphics;
+
class ThemeParser {
static const int kParserMaxDepth = 4;
typedef void (ThemeParser::*ParserCallback)();
+ typedef void (VectorRenderer::*DrawingFunctionCallback)(const Common::Rect &, const DrawStep &);
public:
ThemeParser() {
@@ -337,6 +342,8 @@ protected:
void parseActiveKey(bool closed);
void parserError(const char *errorString);
+ Graphics::DrawStep *newDrawStep();
+
inline bool skipSpaces() {
if (!isspace(_text[_pos]))
return false;
@@ -395,7 +402,9 @@ protected:
};
Common::FixedStack<ParserNode*, kParserMaxDepth> _activeKey;
+
Common::HashMap<Common::String, ParserCallback, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _callbacks;
+ Common::HashMap<Common::String, DrawingFunctionCallback, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> _drawFunctions;
};
}