aboutsummaryrefslogtreecommitdiff
path: root/engines/wage
diff options
context:
space:
mode:
authorEugene Sandulenko2016-04-19 11:14:48 +0200
committerEugene Sandulenko2016-04-19 11:14:48 +0200
commit6f03947bc940d9725727bcbcd80c07816a8dab49 (patch)
tree038c83c6491e5c8c24fae0e1e01c810fcbc219db /engines/wage
parentc9d3b7210e10b32c48ecd037e42fa9ef946576ac (diff)
downloadscummvm-rg350-6f03947bc940d9725727bcbcd80c07816a8dab49.tar.gz
scummvm-rg350-6f03947bc940d9725727bcbcd80c07816a8dab49.tar.bz2
scummvm-rg350-6f03947bc940d9725727bcbcd80c07816a8dab49.zip
WAGE: Implemented text console callback
Diffstat (limited to 'engines/wage')
-rw-r--r--engines/wage/gui.cpp25
-rw-r--r--engines/wage/gui.h10
-rw-r--r--engines/wage/macwindow.cpp2
-rw-r--r--engines/wage/macwindow.h2
4 files changed, 36 insertions, 3 deletions
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index c93c1ee751..6f8c7c5efe 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -143,6 +143,9 @@ static void cursorTimerHandler(void *refCon) {
gui->_cursorDirty = true;
}
+static void sceneWindowCallback(WindowClick click, Common::Event &event, void *gui);
+static void consoleWindowCallback(WindowClick click, Common::Event &event, void *gui);
+
Gui::Gui(WageEngine *engine) {
_engine = engine;
_scene = NULL;
@@ -190,7 +193,10 @@ Gui::Gui(WageEngine *engine) {
_menu = new Menu(this);
_sceneWindow = _wm.add(false);
+ _sceneWindow->setCallback(sceneWindowCallback, this);
+
_consoleWindow = _wm.add(true);
+ _consoleWindow->setCallback(consoleWindowCallback, this);
}
Gui::~Gui() {
@@ -303,6 +309,9 @@ void Gui::drawScene() {
_consoleTextArea.setHeight(_scene->_textBounds->height() - 2 * kBorderWidth);
}
+static void sceneWindowCallback(WindowClick click, Common::Event &event, void *gui) {
+}
+
// Render console
void Gui::drawConsole() {
if (!_consoleDirty && !_consoleFullRedraw && !_bordersDirty && !_sceneDirty)
@@ -314,6 +323,22 @@ void Gui::drawConsole() {
_consoleWindow->setDirty(true);
}
+static void consoleWindowCallback(WindowClick click, Common::Event &event, void *g) {
+ Gui *gui = (Gui *)g;
+
+ if (click == kBorderScrollUp || click == kBorderScrollDown) {
+ int textFullSize = gui->getLinesSize() * gui->getConsoleLineHeight() + gui->getConsoleTextAreaHeight();
+ float scrollPos = (float)gui->getScrollPos() / textFullSize;
+ float scrollSize = (float)gui->getConsoleTextAreaHeight() / textFullSize;
+
+ gui->_consoleWindow->setScroll(scrollPos, scrollSize);
+
+ warning("pos: %f size: %f", scrollPos, scrollSize);
+
+ return;
+ }
+}
+
void Gui::drawBox(Graphics::ManagedSurface *g, int x, int y, int w, int h) {
Common::Rect r(x, y, x + w + 1, y + h + 1);
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 58d24bfb5d..99bfbd8fad 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -114,6 +114,11 @@ public:
bool builtInFonts() { return _builtInFonts; }
+ uint getScrollPos() { return _scrollPos; }
+ uint getLinesSize() { return _lines.size(); }
+ int getConsoleLineHeight() { return _consoleLineHeight; }
+ int getConsoleTextAreaHeight() { return _consoleTextArea.height(); }
+
private:
void drawScene();
void drawConsole();
@@ -150,6 +155,9 @@ public:
bool _menuDirty;
+ MacWindow *_sceneWindow;
+ MacWindow *_consoleWindow;
+
private:
Graphics::ManagedSurface _console;
Menu *_menu;
@@ -181,8 +189,6 @@ private:
int _inputTextLineNum;
MacWindowManager _wm;
- MacWindow *_sceneWindow;
- MacWindow *_consoleWindow;
};
} // End of namespace Wage
diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index 048b193db0..b9c7f7a664 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -294,6 +294,7 @@ bool MacWindow::processEvent(Common::Event &event) {
}
void MacWindow::mouseDown(Common::Event &event) {
+ _innerDims.debugPrint();
if (_innerDims.contains(event.mouse.x, event.mouse.y)) {
if (!_callback)
return;
@@ -303,6 +304,7 @@ void MacWindow::mouseDown(Common::Event &event) {
}
WindowClick click = isInBorder(_innerDims, event.mouse.x, event.mouse.y);
+ warning("click: %d", click);
if (click == kBorderNone)
return;
diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h
index 1998bffe0c..af64de21eb 100644
--- a/engines/wage/macwindow.h
+++ b/engines/wage/macwindow.h
@@ -82,7 +82,7 @@ public:
Graphics::ManagedSurface *getSurface() { return &_surface; }
void setTitle(Common::String &title) { _title = title; }
void setHighlight(WindowClick highlightedPart) { _highlightedPart = highlightedPart; }
- void setScroll(float scrollPos, float scrollSize) { _scrollPos = scrollPos; _scrollSize = scrollSize; }
+ void setScroll(float scrollPos, float scrollSize) { _scrollPos = scrollPos; _scrollSize = scrollSize; _borderIsDirty = true; }
void setDirty(bool dirty) { _contentIsDirty = dirty; }
int getId() { return _id; }
bool processEvent(Common::Event &event);