[Scummvm-cvs-logs] scummvm master -> d75dc3e660a826cd3ea36a785120617017fbd5df
sev-
sev at scummvm.org
Wed Apr 20 00:56:33 CEST 2016
This automated email contains information about 7 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
fd7bf64131 WAGE: Switched event processing to generic code
b8ec681b86 WAGE: Implement callback calling in MacWindow
c9d3b7210e WAGE: Switched WM::add() to returning window pointer instead of id
6f03947bc9 WAGE: Implemented text console callback
9a4a8ac5ef WAGE: Fixed border highlights
fd7b31292d WAGE: Implement object clicking as part of callbacks
d75dc3e660 WAGE: Console scroll via callbacks
Commit: fd7bf64131a0f1ecc5f3b4039c481fff52eb6efa
https://github.com/scummvm/scummvm/commit/fd7bf64131a0f1ecc5f3b4039c481fff52eb6efa
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-19T10:37:53+02:00
Commit Message:
WAGE: Switched event processing to generic code
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/macwindow.cpp
engines/wage/macwindow.h
engines/wage/macwindowmanager.cpp
engines/wage/macwindowmanager.h
engines/wage/wage.cpp
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 8833f7f..5bb342f 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -55,10 +55,10 @@
#include "wage/wage.h"
#include "wage/design.h"
#include "wage/entities.h"
+#include "wage/gui.h"
#include "wage/macwindow.h"
#include "wage/macwindowmanager.h"
#include "wage/menu.h"
-#include "wage/gui.h"
#include "wage/world.h"
namespace Wage {
@@ -540,6 +540,32 @@ void Gui::popCursor() {
CursorMan.popCursor();
}
+bool Gui::processEvent(Common::Event &event) {
+ if (_wm.processEvent(event))
+ return true;
+
+ switch (event.type) {
+ case Common::EVENT_MOUSEMOVE:
+ mouseMove(event.mouse.x, event.mouse.y);
+ break;
+ case Common::EVENT_LBUTTONDOWN:
+ mouseDown(event.mouse.x, event.mouse.y);
+ break;
+ case Common::EVENT_LBUTTONUP:
+ {
+ Designed *obj = mouseUp(event.mouse.x, event.mouse.y);
+ if (obj != NULL)
+ _engine->processTurn(NULL, obj);
+ }
+ break;
+
+ default:
+ return false;
+ }
+
+ return true;
+}
+
static int isInBorder(Common::Rect &rect, int x, int y) {
if (x >= rect.left - kBorderWidth && x < rect.left && y >= rect.top - kBorderWidth && y < rect.top)
return kBorderCloseButton;
@@ -645,8 +671,6 @@ Designed *Gui::mouseUp(int x, int y) {
void Gui::mouseDown(int x, int y) {
int borderClick;
- _wm.mouseDown(x, y);
-
if (_menu->mouseClick(x, y)) {
_menuDirty = true;
} else if (_consoleTextArea.contains(x, y)) {
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index dc3a593..c731c94 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -52,6 +52,7 @@
#include "graphics/font.h"
#include "graphics/fontman.h"
#include "graphics/managed_surface.h"
+#include "common/events.h"
#include "common/rect.h"
#include "wage/macwindow.h"
@@ -89,6 +90,7 @@ public:
void draw();
void appendText(const char *str);
void clearOutput();
+ bool processEvent(Common::Event &event);
void mouseMove(int x, int y);
void mouseDown(int x, int y);
Designed *mouseUp(int x, int y);
diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index 490ab9e..eac5522 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -46,6 +46,7 @@
*/
#include "graphics/primitives.h"
+#include "common/events.h"
#include "wage/wage.h"
#include "wage/gui.h"
@@ -264,6 +265,31 @@ static WindowClick isInBorder(Common::Rect &rect, int x, int y) {
return kBorderNone;
}
+bool MacWindow::processEvent(Common::Event &event) {
+ switch (event.type) {
+ case Common::EVENT_MOUSEMOVE:
+ //mouseMove(event.mouse.x, event.mouse.y);
+ break;
+ case Common::EVENT_LBUTTONDOWN:
+ mouseDown(event.mouse.x, event.mouse.y);
+ break;
+ case Common::EVENT_LBUTTONUP:
+#if 0
+ {
+ Designed *obj = mouseUp(event.mouse.x, event.mouse.y);
+ if (obj != NULL)
+ _engine->processTurn(NULL, obj);
+ }
+#endif
+ break;
+
+ default:
+ return false;
+ }
+
+ return true;
+}
+
void MacWindow::mouseDown(int x, int y) {
if (_innerDims.contains(x, y)) {
// (*callback)(x - _dims.left, y - dims.top);
diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h
index 73984b0..fb2974a 100644
--- a/engines/wage/macwindow.h
+++ b/engines/wage/macwindow.h
@@ -85,7 +85,7 @@ public:
void setScroll(float scrollPos, float scrollSize) { _scrollPos = scrollPos; _scrollSize = scrollSize; }
void setDirty(bool dirty) { _contentIsDirty = dirty; }
int getId() { return _id; }
- void mouseDown(int x, int y);
+ bool processEvent(Common::Event &event);
private:
void drawBorder();
@@ -94,6 +94,8 @@ private:
const Graphics::Font *getTitleFont();
bool builtInFonts();
+ void mouseDown(int x, int y);
+
private:
Graphics::ManagedSurface _surface;
Graphics::ManagedSurface _borderSurface;
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index 08c8a4d..1bf7b54 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -45,8 +45,9 @@
*
*/
-#include "common/list.h"
#include "common/array.h"
+#include "common/events.h"
+#include "common/list.h"
#include "common/system.h"
#include "graphics/managed_surface.h"
@@ -115,16 +116,20 @@ void MacWindowManager::draw() {
_fullRefresh = false;
}
-bool MacWindowManager::mouseDown(int x, int y) {
+bool MacWindowManager::processEvent(Common::Event &event) {
+ if (event.type != Common::EVENT_MOUSEMOVE && event.type != Common::EVENT_LBUTTONDOWN &&
+ event.type != Common::EVENT_LBUTTONUP)
+ return false;
+
for (Common::List<MacWindow *>::const_iterator it = _windowStack.end(); it != _windowStack.begin();) {
it--;
MacWindow *w = *it;
- if (w->getDimensions().contains(x, y)) {
- setActive(w->getId());
- w->mouseDown(x, y);
+ if (w->getDimensions().contains(event.mouse.x, event.mouse.y)) {
+ if (event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_LBUTTONUP)
+ setActive(w->getId());
- return true;
+ return w->processEvent(event);
}
}
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index adb086d..d074564 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -66,7 +66,7 @@ public:
void draw();
- bool mouseDown(int x, int y);
+ bool processEvent(Common::Event &event);
MacWindow *getWindow(int id) { return _windows[id]; }
diff --git a/engines/wage/wage.cpp b/engines/wage/wage.cpp
index 3a52aed..73794f7 100644
--- a/engines/wage/wage.cpp
+++ b/engines/wage/wage.cpp
@@ -148,24 +148,14 @@ void WageEngine::processEvents() {
Common::Event event;
while (_eventMan->pollEvent(event)) {
+ if (_gui->processEvent(event))
+ continue;
+
switch (event.type) {
case Common::EVENT_QUIT:
if (saveDialog())
_shouldQuit = true;
break;
- case Common::EVENT_MOUSEMOVE:
- _gui->mouseMove(event.mouse.x, event.mouse.y);
- break;
- case Common::EVENT_LBUTTONDOWN:
- _gui->mouseDown(event.mouse.x, event.mouse.y);
- break;
- case Common::EVENT_LBUTTONUP:
- {
- Designed *obj = _gui->mouseUp(event.mouse.x, event.mouse.y);
- if (obj != NULL)
- processTurn(NULL, obj);
- }
- break;
case Common::EVENT_KEYDOWN:
switch (event.kbd.keycode) {
case Common::KEYCODE_BACKSPACE:
Commit: b8ec681b86b165caf1486fdf2f1b11c0567e6714
https://github.com/scummvm/scummvm/commit/b8ec681b86b165caf1486fdf2f1b11c0567e6714
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-19T10:53:06+02:00
Commit Message:
WAGE: Implement callback calling in MacWindow
Changed paths:
engines/wage/macwindow.cpp
engines/wage/macwindow.h
diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index eac5522..048b193 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -61,6 +61,9 @@ MacWindow::MacWindow(int id, bool scrollable) : _scrollable(scrollable), _id(id)
_highlightedPart = kBorderNone;
_scrollPos = _scrollSize = 0.0;
+
+ _callback = 0;
+ _dataPtr = 0;
}
MacWindow::~MacWindow() {
@@ -271,7 +274,7 @@ bool MacWindow::processEvent(Common::Event &event) {
//mouseMove(event.mouse.x, event.mouse.y);
break;
case Common::EVENT_LBUTTONDOWN:
- mouseDown(event.mouse.x, event.mouse.y);
+ mouseDown(event);
break;
case Common::EVENT_LBUTTONUP:
#if 0
@@ -290,13 +293,16 @@ bool MacWindow::processEvent(Common::Event &event) {
return true;
}
-void MacWindow::mouseDown(int x, int y) {
- if (_innerDims.contains(x, y)) {
- // (*callback)(x - _dims.left, y - dims.top);
+void MacWindow::mouseDown(Common::Event &event) {
+ if (_innerDims.contains(event.mouse.x, event.mouse.y)) {
+ if (!_callback)
+ return;
+
+ (*_callback)(kBorderInner, event, _dataPtr);
return;
}
- WindowClick click = isInBorder(_innerDims, x, y);
+ WindowClick click = isInBorder(_innerDims, event.mouse.x, event.mouse.y);
if (click == kBorderNone)
return;
@@ -304,9 +310,11 @@ void MacWindow::mouseDown(int x, int y) {
setHighlight(click);
if (click == kBorderScrollUp || click == kBorderScrollDown) {
- // TODO
- }
+ if (!_callback)
+ return;
+ (*_callback)(click, event, _dataPtr);
+ }
}
} // End of namespace Wage
diff --git a/engines/wage/macwindow.h b/engines/wage/macwindow.h
index fb2974a..1998bff 100644
--- a/engines/wage/macwindow.h
+++ b/engines/wage/macwindow.h
@@ -86,6 +86,7 @@ public:
void setDirty(bool dirty) { _contentIsDirty = dirty; }
int getId() { return _id; }
bool processEvent(Common::Event &event);
+ void setCallback(void (*callback)(WindowClick, Common::Event &, void *), void *data) { _callback = callback; _dataPtr = data; }
private:
void drawBorder();
@@ -94,7 +95,7 @@ private:
const Graphics::Font *getTitleFont();
bool builtInFonts();
- void mouseDown(int x, int y);
+ void mouseDown(Common::Event &event);
private:
Graphics::ManagedSurface _surface;
@@ -113,6 +114,9 @@ private:
Common::Rect _innerDims;
Common::String _title;
+
+ void (*_callback)(WindowClick, Common::Event &, void *);
+ void *_dataPtr;
};
} // End of namespace Wage
Commit: c9d3b7210e10b32c48ecd037e42fa9ef946576ac
https://github.com/scummvm/scummvm/commit/c9d3b7210e10b32c48ecd037e42fa9ef946576ac
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-19T10:56:42+02:00
Commit Message:
WAGE: Switched WM::add() to returning window pointer instead of id
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/macwindowmanager.cpp
engines/wage/macwindowmanager.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 5bb342f..c93c1ee 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -189,8 +189,8 @@ Gui::Gui(WageEngine *engine) {
_menu = new Menu(this);
- _sceneWindowId = _wm.add(false);
- _consoleWindowId = _wm.add(true);
+ _sceneWindow = _wm.add(false);
+ _consoleWindow = _wm.add(true);
}
Gui::~Gui() {
@@ -282,12 +282,10 @@ void Gui::drawScene() {
_scene = _engine->_world->_player->_currentScene;
- MacWindow *w = _wm.getWindow(_sceneWindowId);
-
- w->setDimensions(*_scene->_designBounds);
- w->setTitle(_scene->_name);
- _scene->paint(w->getSurface(), 0, 0);
- w->setDirty(true);
+ _sceneWindow->setDimensions(*_scene->_designBounds);
+ _sceneWindow->setTitle(_scene->_name);
+ _scene->paint(_sceneWindow->getSurface(), 0, 0);
+ _sceneWindow->setDirty(true);
_sceneDirty = true;
_consoleDirty = true;
@@ -310,11 +308,10 @@ void Gui::drawConsole() {
if (!_consoleDirty && !_consoleFullRedraw && !_bordersDirty && !_sceneDirty)
return;
- MacWindow *w = _wm.getWindow(_consoleWindowId);
- w->setDimensions(*_scene->_textBounds);
- renderConsole(w->getSurface(), Common::Rect(kBorderWidth - 2, kBorderWidth - 2,
+ _consoleWindow->setDimensions(*_scene->_textBounds);
+ renderConsole(_consoleWindow->getSurface(), Common::Rect(kBorderWidth - 2, kBorderWidth - 2,
_scene->_textBounds->width() - kBorderWidth, _scene->_textBounds->height() - kBorderWidth));
- w->setDirty(true);
+ _consoleWindow->setDirty(true);
}
void Gui::drawBox(Graphics::ManagedSurface *g, int x, int y, int w, int h) {
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index c731c94..58d24bf 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -181,8 +181,8 @@ private:
int _inputTextLineNum;
MacWindowManager _wm;
- int _sceneWindowId;
- int _consoleWindowId;
+ MacWindow *_sceneWindow;
+ MacWindow *_consoleWindow;
};
} // End of namespace Wage
diff --git a/engines/wage/macwindowmanager.cpp b/engines/wage/macwindowmanager.cpp
index 1bf7b54..3fbd156 100644
--- a/engines/wage/macwindowmanager.cpp
+++ b/engines/wage/macwindowmanager.cpp
@@ -69,7 +69,7 @@ MacWindowManager::~MacWindowManager() {
delete _windows[i];
}
-int MacWindowManager::add(bool scrollable) {
+MacWindow *MacWindowManager::add(bool scrollable) {
MacWindow *w = new MacWindow(_lastId, scrollable);
_windows.push_back(w);
@@ -79,7 +79,7 @@ int MacWindowManager::add(bool scrollable) {
_lastId++;
- return _lastId - 1;
+ return w;
}
void MacWindowManager::setActive(int id) {
diff --git a/engines/wage/macwindowmanager.h b/engines/wage/macwindowmanager.h
index d074564..4174493 100644
--- a/engines/wage/macwindowmanager.h
+++ b/engines/wage/macwindowmanager.h
@@ -59,7 +59,7 @@ public:
void setScreen(Graphics::ManagedSurface *screen) { _screen = screen; }
- int add(bool scrollable);
+ MacWindow *add(bool scrollable);
void setActive(int id);
void setFullRefresh(bool redraw) { _fullRefresh = true; }
Commit: 6f03947bc940d9725727bcbcd80c07816a8dab49
https://github.com/scummvm/scummvm/commit/6f03947bc940d9725727bcbcd80c07816a8dab49
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-19T11:14:48+02:00
Commit Message:
WAGE: Implemented text console callback
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/macwindow.cpp
engines/wage/macwindow.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index c93c1ee..6f8c7c5 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 58d24bf..99bfbd8 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 048b193..b9c7f7a 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 1998bff..af64de2 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);
Commit: 9a4a8ac5eff671b5216f2e17d9876cfae57f8ab7
https://github.com/scummvm/scummvm/commit/9a4a8ac5eff671b5216f2e17d9876cfae57f8ab7
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-19T12:51:15+02:00
Commit Message:
WAGE: Fixed border highlights
Changed paths:
engines/wage/gui.cpp
engines/wage/macwindow.cpp
engines/wage/macwindow.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 6f8c7c5..ffbd801 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -252,9 +252,19 @@ void Gui::draw() {
return;
}
- if (_scene != _engine->_world->_player->_currentScene)
+ if (!_engine->_world->_player->_currentScene)
+ return;
+
+ if (_scene != _engine->_world->_player->_currentScene) {
_sceneDirty = true;
+ _scene = _engine->_world->_player->_currentScene;
+
+ _sceneWindow->setDimensions(*_scene->_designBounds);
+ _sceneWindow->setTitle(_scene->_name);
+ _consoleWindow->setDimensions(*_scene->_textBounds);
+ }
+
if (_sceneDirty || _bordersDirty) {
drawDesktop();
_wm.setFullRefresh(true);
@@ -286,10 +296,6 @@ void Gui::drawScene() {
if (!_sceneDirty && !_bordersDirty)
return;
- _scene = _engine->_world->_player->_currentScene;
-
- _sceneWindow->setDimensions(*_scene->_designBounds);
- _sceneWindow->setTitle(_scene->_name);
_scene->paint(_sceneWindow->getSurface(), 0, 0);
_sceneWindow->setDirty(true);
@@ -317,7 +323,6 @@ void Gui::drawConsole() {
if (!_consoleDirty && !_consoleFullRedraw && !_bordersDirty && !_sceneDirty)
return;
- _consoleWindow->setDimensions(*_scene->_textBounds);
renderConsole(_consoleWindow->getSurface(), Common::Rect(kBorderWidth - 2, kBorderWidth - 2,
_scene->_textBounds->width() - kBorderWidth, _scene->_textBounds->height() - kBorderWidth));
_consoleWindow->setDirty(true);
@@ -333,8 +338,6 @@ static void consoleWindowCallback(WindowClick click, Common::Event &event, void
gui->_consoleWindow->setScroll(scrollPos, scrollSize);
- warning("pos: %f size: %f", scrollPos, scrollSize);
-
return;
}
}
diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index b9c7f7a..682045b 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -235,6 +235,24 @@ void MacWindow::drawBorder() {
}
}
+void MacWindow::setHighlight(WindowClick highlightedPart) {
+ if (_highlightedPart == highlightedPart)
+ return;
+
+ _highlightedPart = highlightedPart;
+ _borderIsDirty = true;
+ }
+
+ void MacWindow::setScroll(float scrollPos, float scrollSize) {
+ if (_scrollPos == scrollPos && _scrollSize == scrollSize)
+ return;
+
+ _scrollPos = scrollPos;
+ _scrollSize = scrollSize;
+ _borderIsDirty = true;
+ }
+
+
void MacWindow::drawBox(Graphics::ManagedSurface *g, int x, int y, int w, int h) {
Common::Rect r(x, y, x + w + 1, y + h + 1);
@@ -277,6 +295,7 @@ bool MacWindow::processEvent(Common::Event &event) {
mouseDown(event);
break;
case Common::EVENT_LBUTTONUP:
+ setHighlight(kBorderNone);
#if 0
{
Designed *obj = mouseUp(event.mouse.x, event.mouse.y);
@@ -294,7 +313,6 @@ 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;
@@ -304,7 +322,6 @@ 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 af64de2..d82807d 100644
--- a/engines/wage/macwindow.h
+++ b/engines/wage/macwindow.h
@@ -81,8 +81,8 @@ public:
void setActive(bool active);
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; _borderIsDirty = true; }
+ void setHighlight(WindowClick highlightedPart);
+ void setScroll(float scrollPos, float scrollSize);
void setDirty(bool dirty) { _contentIsDirty = dirty; }
int getId() { return _id; }
bool processEvent(Common::Event &event);
Commit: fd7b31292dffe0ad456f590c4d9e6e29bfed0f00
https://github.com/scummvm/scummvm/commit/fd7b31292dffe0ad456f590c4d9e6e29bfed0f00
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-20T00:55:54+02:00
Commit Message:
WAGE: Implement object clicking as part of callbacks
Changed paths:
engines/wage/entities.cpp
engines/wage/entities.h
engines/wage/gui.cpp
engines/wage/gui.h
engines/wage/macwindow.cpp
diff --git a/engines/wage/entities.cpp b/engines/wage/entities.cpp
index 49e2592..d0a838f 100644
--- a/engines/wage/entities.cpp
+++ b/engines/wage/entities.cpp
@@ -202,6 +202,22 @@ const char *Scene::getFontName() {
return "Unknown";
}
+Designed *Scene::lookUpEntity(int x, int y) {
+ for (ObjList::const_iterator it = _objs.end(); it != _objs.begin(); ) {
+ it--;
+ if ((*it)->_design->isPointOpaque(x, y))
+ return *it;
+ }
+
+ for (ChrList::const_iterator it = _chrs.end(); it != _chrs.begin(); ) {
+ it--;
+ if ((*it)->_design->isPointOpaque(x, y))
+ return *it;
+ }
+
+ return nullptr;
+}
+
Obj::Obj() : _currentOwner(NULL), _currentScene(NULL) {
_index = 0;
_namePlural = false;
diff --git a/engines/wage/entities.h b/engines/wage/entities.h
index c393f15..9e706f0 100644
--- a/engines/wage/entities.h
+++ b/engines/wage/entities.h
@@ -322,6 +322,8 @@ public:
Scene(Common::String name, Common::SeekableReadStream *data);
~Scene();
+ Designed *lookUpEntity(int x, int y);
+
Common::Rect *getTextBounds() {
return _textBounds == NULL ? NULL : new Common::Rect(*_textBounds);
}
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index ffbd801..05af566 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -315,7 +315,18 @@ void Gui::drawScene() {
_consoleTextArea.setHeight(_scene->_textBounds->height() - 2 * kBorderWidth);
}
-static void sceneWindowCallback(WindowClick click, Common::Event &event, void *gui) {
+static void sceneWindowCallback(WindowClick click, Common::Event &event, void *g) {
+ Gui *gui = (Gui *)g;
+
+ if (click == kBorderInner && event.type == Common::EVENT_LBUTTONUP) {
+ Designed *obj = gui->_scene->lookUpEntity(event.mouse.x - gui->_sceneWindow->getDimensions().left,
+ event.mouse.y - gui->_sceneWindow->getDimensions().top);
+
+ if (obj != nullptr)
+ gui->_engine->processTurn(NULL, obj);
+
+ return;
+ }
}
// Render console
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index 99bfbd8..baf167a 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -155,13 +155,13 @@ public:
bool _menuDirty;
+ Scene *_scene;
MacWindow *_sceneWindow;
MacWindow *_consoleWindow;
private:
Graphics::ManagedSurface _console;
Menu *_menu;
- Scene *_scene;
bool _sceneDirty;
bool _consoleDirty;
bool _bordersDirty;
diff --git a/engines/wage/macwindow.cpp b/engines/wage/macwindow.cpp
index 682045b..1b869fa 100644
--- a/engines/wage/macwindow.cpp
+++ b/engines/wage/macwindow.cpp
@@ -267,6 +267,9 @@ void MacWindow::fillRect(Graphics::ManagedSurface *g, int x, int y, int w, int h
}
static WindowClick isInBorder(Common::Rect &rect, int x, int y) {
+ if (rect.contains(x, y))
+ return kBorderInner;
+
if (x >= rect.left - kBorderWidth && x < rect.left && y >= rect.top - kBorderWidth && y < rect.top)
return kBorderCloseButton;
@@ -294,15 +297,12 @@ bool MacWindow::processEvent(Common::Event &event) {
case Common::EVENT_LBUTTONDOWN:
mouseDown(event);
break;
- case Common::EVENT_LBUTTONUP:
- setHighlight(kBorderNone);
-#if 0
- {
- Designed *obj = mouseUp(event.mouse.x, event.mouse.y);
- if (obj != NULL)
- _engine->processTurn(NULL, obj);
+ case Common::EVENT_LBUTTONUP: {
+ setHighlight(kBorderNone);
+
+ WindowClick click = isInBorder(_innerDims, event.mouse.x, event.mouse.y);
+ (*_callback)(click, event, _dataPtr);
}
-#endif
break;
default:
@@ -313,14 +313,6 @@ bool MacWindow::processEvent(Common::Event &event) {
}
void MacWindow::mouseDown(Common::Event &event) {
- if (_innerDims.contains(event.mouse.x, event.mouse.y)) {
- if (!_callback)
- return;
-
- (*_callback)(kBorderInner, event, _dataPtr);
- return;
- }
-
WindowClick click = isInBorder(_innerDims, event.mouse.x, event.mouse.y);
if (click == kBorderNone)
@@ -328,7 +320,7 @@ void MacWindow::mouseDown(Common::Event &event) {
setHighlight(click);
- if (click == kBorderScrollUp || click == kBorderScrollDown) {
+ if (click == kBorderScrollUp || click == kBorderScrollDown || click == kBorderInner) {
if (!_callback)
return;
Commit: d75dc3e660a826cd3ea36a785120617017fbd5df
https://github.com/scummvm/scummvm/commit/d75dc3e660a826cd3ea36a785120617017fbd5df
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-04-20T00:56:04+02:00
Commit Message:
WAGE: Console scroll via callbacks
Changed paths:
engines/wage/gui.cpp
engines/wage/gui.h
diff --git a/engines/wage/gui.cpp b/engines/wage/gui.cpp
index 05af566..5aa4531 100644
--- a/engines/wage/gui.cpp
+++ b/engines/wage/gui.cpp
@@ -342,150 +342,43 @@ void Gui::drawConsole() {
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);
-
- 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);
-
- g->fillRect(r, kColorWhite);
- g->frameRect(r, kColorBlack);
-}
-
-void Gui::fillRect(Graphics::ManagedSurface *g, int x, int y, int w, int h, int color) {
- Common::Rect r(x, y, x + w, y + h);
-
- g->fillRect(r, color);
-}
-
-#define ARROW_W 12
-#define ARROW_H 6
-const int arrowPixels[ARROW_H][ARROW_W] = {
- {0,0,0,0,0,1,1,0,0,0,0,0},
- {0,0,0,0,1,1,1,1,0,0,0,0},
- {0,0,0,1,1,1,1,1,1,0,0,0},
- {0,0,1,1,1,1,1,1,1,1,0,0},
- {0,1,1,1,1,1,1,1,1,1,1,0},
- {1,1,1,1,1,1,1,1,1,1,1,1}};
-
-static void drawPixelInverted(int x, int y, int color, void *data) {
- Graphics::ManagedSurface *surface = (Graphics::ManagedSurface *)data;
+ gui->processConsoleEvents(click, event);
- if (x >= 0 && x < surface->w && y >= 0 && y < surface->h) {
- byte *p = (byte *)surface->getBasePtr(x, y);
-
- *p = *p == kColorWhite ? kColorBlack : kColorWhite;
- }
}
-void Gui::paintBorder(Graphics::ManagedSurface *g, Common::Rect &r, WindowType windowType, int highlightedPart, float scrollPos, float scrollSize) {
- bool active = false, scrollable = false, closeable = false, drawTitle = false;
- const int size = kBorderWidth;
- int x = r.left - size;
- int y = r.top - size;
- int width = r.width() + 2 * size;
- int height = r.height() + 2 * size;
-
- switch (windowType) {
- case kWindowScene:
- active = _sceneIsActive;
- scrollable = false;
- closeable = _sceneIsActive;
- drawTitle = true;
- break;
- case kWindowConsole:
- active = !_sceneIsActive;
- scrollable = true;
- closeable = !_sceneIsActive;
- drawTitle = false;
- break;
- }
-
- drawBox(g, x, y, size, size);
- drawBox(g, x + width - size - 1, y, size, size);
- drawBox(g, x + width - size - 1, y + height - size - 1, size, size);
- drawBox(g, x, y + height - size - 1, size, size);
- drawBox(g, x + size, y + 2, width - 2 * size - 1, size - 4);
- drawBox(g, x + size, y + height - size + 1, width - 2 * size - 1, size - 4);
- drawBox(g, x + 2, y + size, size - 4, height - 2 * size - 1);
- drawBox(g, x + width - size + 1, y + size, size - 4, height - 2 * size - 1);
-
- if (active) {
- fillRect(g, x + size, y + 5, width - 2 * size - 1, 8);
- fillRect(g, x + size, y + height - 13, width - 2 * size - 1, 8);
- fillRect(g, x + 5, y + size, 8, height - 2 * size - 1);
- if (!scrollable) {
- fillRect(g, x + width - 13, y + size, 8, height - 2 * size - 1);
- } else {
- int x1 = x + width - 15;
- int y1 = y + size + 1;
-
- for (int yy = 0; yy < ARROW_H; yy++) {
- for (int xx = 0; xx < ARROW_W; xx++)
- g->hLine(x1 + xx, y1 + yy, x1 + xx, (arrowPixels[yy][xx] != 0 ? kColorBlack : kColorWhite));
- }
-
- fillRect(g, x + width - 13, y + size + ARROW_H, 8, height - 2 * size - 1 - ARROW_H * 2);
-
- y1 += height - 2 * size - ARROW_H - 2;
- for (int yy = 0; yy < ARROW_H; yy++) {
- for (int xx = 0; xx < ARROW_W; xx++)
- g->hLine(x1 + xx, y1 + yy, x1 + xx, (arrowPixels[ARROW_H - yy - 1][xx] != 0 ? kColorBlack : kColorWhite));
- }
+void Gui::processConsoleEvents(WindowClick click, Common::Event &event) {
+ if (click == kBorderScrollUp || click == kBorderScrollDown) {
+ if (event.type == Common::EVENT_LBUTTONDOWN) {
+ int textFullSize = _lines.size() * _consoleLineHeight + _consoleTextArea.height();
+ float scrollPos = (float)_scrollPos / textFullSize;
+ float scrollSize = (float)_consoleTextArea.height() / textFullSize;
- if (highlightedPart == kBorderScrollUp || highlightedPart == kBorderScrollDown) {
- int rx1 = x + width - kBorderWidth + 2;
- int ry1 = y + size + r.height() * scrollPos;
- int rx2 = rx1 + size - 4;
- int ry2 = ry1 + r.height() * scrollSize;
- Common::Rect rr(rx1, ry1, rx2, ry2);
+ _consoleWindow->setScroll(scrollPos, scrollSize);
+ } else if (event.type == Common::EVENT_LBUTTONUP) {
+ int oldScrollPos = _scrollPos;
- Graphics::drawFilledRect(rr, kColorBlack, drawPixelInverted, g);
- }
- }
- if (closeable) {
- if (highlightedPart == kBorderCloseButton) {
- fillRect(g, x + 6, y + 6, 6, 6);
- } else {
- drawBox(g, x + 5, y + 5, 7, 7);
+ switch (click) {
+ case kBorderScrollUp:
+ _scrollPos = MAX<int>(0, _scrollPos - _consoleLineHeight);
+ undrawCursor();
+ _cursorY -= (_scrollPos - oldScrollPos);
+ _consoleDirty = true;
+ _consoleFullRedraw = true;
+ break;
+ case kBorderScrollDown:
+ _scrollPos = MIN<int>((_lines.size() - 2) * _consoleLineHeight, _scrollPos + _consoleLineHeight);
+ undrawCursor();
+ _cursorY -= (_scrollPos - oldScrollPos);
+ _consoleDirty = true;
+ _consoleFullRedraw = true;
+ break;
+ default:
+ break;
}
}
- }
- if (drawTitle) {
- const Graphics::Font *font = getTitleFont();
- int yOff = _builtInFonts ? 3 : 1;
-
- int w = font->getStringWidth(_scene->_name) + 10;
- int maxWidth = width - size * 2 - 7;
- if (w > maxWidth)
- w = maxWidth;
- drawBox(g, x + (width - w) / 2, y, w, size);
- font->drawString(g, _scene->_name, x + (width - w) / 2 + 5, y + yOff, w, kColorBlack);
- }
-
- if (x < 0) {
- width += x;
- x = 0;
- }
- if (y < 0) {
- height += y;
- y = 0;
+ return;
}
- if (x + width > _screen.w)
- width = _screen.w - x;
- if (y + height > _screen.h)
- height = _screen.h - y;
-
- g_system->copyRectToScreen(g->getBasePtr(x, y), g->pitch, x, y, width, height);
}
void Gui::loadFonts() {
@@ -602,26 +495,6 @@ bool Gui::processEvent(Common::Event &event) {
return true;
}
-static int isInBorder(Common::Rect &rect, int x, int y) {
- if (x >= rect.left - kBorderWidth && x < rect.left && y >= rect.top - kBorderWidth && y < rect.top)
- return kBorderCloseButton;
-
- if (x >= rect.right && x < rect.right + kBorderWidth) {
- if (y < rect.top - kBorderWidth)
- return kBorderNone;
-
- if (y >= rect.bottom + kBorderWidth)
- return kBorderNone;
-
- if (y >= rect.top + rect.height() / 2)
- return kBorderScrollDown;
-
- return kBorderScrollUp;
- }
-
- return kBorderNone;
-}
-
Designed *Gui::mouseUp(int x, int y) {
if (_menu->_menuActivated) {
if (_menu->mouseRelease(x, y)) {
@@ -655,68 +528,14 @@ Designed *Gui::mouseUp(int x, int y) {
}
}
- int borderClick;
-
- if (_sceneArea.contains(x, y)) {
- if (!_sceneIsActive) {
- _sceneIsActive = true;
- _bordersDirty = true;
- }
-
- for (ObjList::const_iterator it = _scene->_objs.end(); it != _scene->_objs.begin(); ) {
- it--;
- if ((*it)->_design->isPointOpaque(x - _sceneArea.left + kBorderWidth, y - _sceneArea.top + kBorderWidth))
- return *it;
- }
-
- for (ChrList::const_iterator it = _scene->_chrs.end(); it != _scene->_chrs.begin(); ) {
- it--;
- if ((*it)->_design->isPointOpaque(x - _sceneArea.left + kBorderWidth, y - _sceneArea.top + kBorderWidth))
- return *it;
- }
- } else if (_consoleTextArea.contains(x, y)) {
- if (_sceneIsActive) {
- _sceneIsActive = false;
- _bordersDirty = true;
- }
- } else if ((borderClick = isInBorder(_consoleTextArea, x, y)) != kBorderNone) {
- _bordersDirty = true;
- int _oldScrollPos = _scrollPos;
-
- switch (borderClick) {
- case kBorderScrollUp:
- _scrollPos = MAX<int>(0, _scrollPos - _consoleLineHeight);
- undrawCursor();
- _cursorY -= (_scrollPos - _oldScrollPos);
- _consoleDirty = true;
- _consoleFullRedraw = true;
- break;
- case kBorderScrollDown:
- _scrollPos = MIN<int>((_lines.size() - 2) * _consoleLineHeight, _scrollPos + _consoleLineHeight);
- undrawCursor();
- _cursorY -= (_scrollPos - _oldScrollPos);
- _consoleDirty = true;
- _consoleFullRedraw = true;
- break;
- }
- }
-
return NULL;
}
void Gui::mouseDown(int x, int y) {
- int borderClick;
-
if (_menu->mouseClick(x, y)) {
_menuDirty = true;
} else if (_consoleTextArea.contains(x, y)) {
startMarking(x, y);
- } else if ((borderClick = isInBorder(_consoleTextArea, x, y)) != kBorderNone) {
- int textFullSize = _lines.size() * _consoleLineHeight + _consoleTextArea.height();
- float scrollPos = (float)_scrollPos / textFullSize;
- float scrollSize = (float)_consoleTextArea.height() / textFullSize;
-
- paintBorder(&_screen, _consoleTextArea, kWindowConsole, borderClick, scrollPos, scrollSize);
}
}
diff --git a/engines/wage/gui.h b/engines/wage/gui.h
index baf167a..aadb7ea 100644
--- a/engines/wage/gui.h
+++ b/engines/wage/gui.h
@@ -114,21 +114,14 @@ public:
bool builtInFonts() { return _builtInFonts; }
- uint getScrollPos() { return _scrollPos; }
- uint getLinesSize() { return _lines.size(); }
- int getConsoleLineHeight() { return _consoleLineHeight; }
- int getConsoleTextAreaHeight() { return _consoleTextArea.height(); }
+ void processConsoleEvents(WindowClick click, Common::Event &event);
private:
void drawScene();
void drawConsole();
void undrawCursor();
void drawDesktop();
- void paintBorder(Graphics::ManagedSurface *g, Common::Rect &r, WindowType windowType, int highlightedPart = kBorderNone,
- float scrollPos = 0.0, float scrollSize = 0.0);
void renderConsole(Graphics::ManagedSurface *g, const Common::Rect &r);
- void drawBox(Graphics::ManagedSurface *g, int x, int y, int w, int h);
- void fillRect(Graphics::ManagedSurface *g, int x, int y, int w, int h, int color = kColorBlack);
void loadFonts();
void flowText(Common::String &str);
const Graphics::Font *getConsoleFont();
More information about the Scummvm-git-logs
mailing list