aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2009-11-26 11:48:43 +0000
committerPaul Gilbert2009-11-26 11:48:43 +0000
commit5afc0e5ed7499e94201b7d2f723ef2556319be46 (patch)
tree44617cf18aa60cf5059ddd75081fe7e814cb424a
parent6f45ecff1a260ef404c6f30a5866d2130e9815de (diff)
downloadscummvm-rg350-5afc0e5ed7499e94201b7d2f723ef2556319be46.tar.gz
scummvm-rg350-5afc0e5ed7499e94201b7d2f723ef2556319be46.tar.bz2
scummvm-rg350-5afc0e5ed7499e94201b7d2f723ef2556319be46.zip
Added the basics of a action list display
svn-id: r46152
-rw-r--r--engines/m4/events.h1
-rw-r--r--engines/m4/m4.cpp2
-rw-r--r--engines/m4/m4.h1
-rw-r--r--engines/m4/mads_menus.cpp1
-rw-r--r--engines/m4/scene.cpp167
-rw-r--r--engines/m4/scene.h23
6 files changed, 195 insertions, 0 deletions
diff --git a/engines/m4/events.h b/engines/m4/events.h
index 5f309e0a03..c31a870b89 100644
--- a/engines/m4/events.h
+++ b/engines/m4/events.h
@@ -56,6 +56,7 @@ enum M4MouseState {
enum M4CommonCursors {
CURSOR_ARROW = 0,
+ CURSOR_WAIT = 1,
CURSOR_HOURGLASS = 5,
CURSOR_LOOK = 6,
CURSOR_TAKE = 8,
diff --git a/engines/m4/m4.cpp b/engines/m4/m4.cpp
index 05c1bf897b..4d713f3de8 100644
--- a/engines/m4/m4.cpp
+++ b/engines/m4/m4.cpp
@@ -182,6 +182,7 @@ Common::Error M4Engine::run() {
}
_rails = new Rails(); // needs to be initialized before _scene
_scene = new Scene(this);
+ _actionsView = new ActionsView(this);
_dialogs = new Dialogs();
_viewManager = new ViewManager(this);
_inventory = new Inventory(this);
@@ -306,6 +307,7 @@ Common::Error M4Engine::goMADS() {
}
_viewManager->addView(_scene);
+ _viewManager->addView(_actionsView);
_font->setFont(FONT_MAIN_MADS);
_font->setColors(2, 1, 3);
diff --git a/engines/m4/m4.h b/engines/m4/m4.h
index 1b534bb2b7..fe94c0f77e 100644
--- a/engines/m4/m4.h
+++ b/engines/m4/m4.h
@@ -173,6 +173,7 @@ public:
Font *_font;
Actor *_actor;
Scene *_scene;
+ ActionsView *_actionsView;
Dialogs *_dialogs;
M4Surface *_screen;
Inventory *_inventory;
diff --git a/engines/m4/mads_menus.cpp b/engines/m4/mads_menus.cpp
index de44ddca41..65ad96ef1e 100644
--- a/engines/m4/mads_menus.cpp
+++ b/engines/m4/mads_menus.cpp
@@ -308,6 +308,7 @@ void RexMainMenuView::handleAction(MadsGameAction action) {
// removes this menu screen from being displayed
vm->_mouse->cursorOn();
vm->_viewManager->addView(vm->_scene);
+ vm->_viewManager->addView(vm->_actionsView);
vm->_scene->loadScene(101);
// **DEBUG** - set the default object
diff --git a/engines/m4/scene.cpp b/engines/m4/scene.cpp
index 30c304161c..d17de815e3 100644
--- a/engines/m4/scene.cpp
+++ b/engines/m4/scene.cpp
@@ -717,4 +717,171 @@ void Scene::setSelectedObject(int objectNumber) {
_selectedObject = objectNumber;
}
+/*
+ * TODO: decide if this should be kept centralised like it is in the original, or separated for the different
+ * visual elements
+void Scene::getInterfaceObjectRect(int xv, int yv, Common::Rect &bounds) {
+ // TODO: Implement these later as proper fields of the interface when I understand them better
+ const int interfaceObjY = 0;
+ const int interfaceObjX = 0;
+
+ int16 height = 8, width = 0;
+ bounds.top = 0; bounds.left = 0;
+
+ // Handle X position and width
+ switch (xv) {
+ case 1:
+ bounds.left = ((yv / 5) << 3) + 3;
+ width = ((yv / 5) << 6) + 2;
+ break;
+
+ case 2:
+ if ((yv < interfaceObjX) || (yv > (interfaceObjX + 5))) return;
+ bounds.left = ((yv - interfaceObjX) << 3) + 3;
+ width = yv * 69 + 90;
+ break;
+
+ case 6:
+ bounds.left = (yv << 3) + 3;
+ width = yv * 318 + 2;
+ break;
+
+ case 7:
+ bounds.left = 0;
+ width = (yv == 4) ? 75 : 73;
+ break;
+
+ default:
+ bounds.left = (yv << 3) + 3;
+ width = yv * 80 + 240;
+ break;
+ }
+
+ // Handle Y position and height
+ if (xv == 7) {
+ switch (yv) {
+ case 1:
+ bounds.top = 4;
+ height = 7;
+ break;
+ case 2:
+ bounds.top = 35;
+ height = 7;
+ break;
+ case 3:
+ bounds.top = 12;
+ height = 22;
+ break;
+ case 4:
+ bounds.top = interfaceObjY + 14;
+ height = 1;
+ break;
+ default:
+ break;
+ }
+ }
+
+ // Set the right and bottom bounds based on the specified size
+ bounds.right = bounds.left + width;
+ bounds.bottom = bounds.top + height;
+}
+*/
+
+/**
+ *--------------------------------------------------------------------------
+ * Base class for interface elements
+ *
+ *--------------------------------------------------------------------------
+ */
+
+InterfaceElement::InterfaceElement(M4Engine *vm, const Common::Rect &viewBounds, bool transparent):
+ View(vm, viewBounds, transparent) {
+}
+
+void InterfaceElement::setFontMode(FontMode newMode) {
+ switch (newMode) {
+ case MODE_0:
+ _vm->_font->setColors(4, 4, 0xff);
+ break;
+ case MODE_1:
+ //_vm->_font->setColors(5, 5, 0xff);
+ _vm->_font->setColors(0xff, 0xff, 0xff);
+ break;
+ case MODE_2:
+ _vm->_font->setColors(6, 6, 0xff);
+ break;
+ }
+}
+
+/**
+ *--------------------------------------------------------------------------
+ * ActionsView handles the display of the actions/verb list
+ *
+ *--------------------------------------------------------------------------
+ */
+
+ActionsView::ActionsView(M4Engine *vm): InterfaceElement(vm, Common::Rect(0, MADS_SURFACE_HEIGHT, 70,
+ vm->_screen->height())) {
+ _screenType = VIEWID_INTERFACE;
+ _highlightedAction = 0;
+}
+
+void ActionsView::getActionRect(int actionId, Common::Rect &bounds) {
+ int idx = actionId - kVerbLook;
+
+ bounds.left = (idx / 5) * 32 + 2;
+ bounds.top = (idx % 5) * 8 + MADS_SURFACE_HEIGHT + 3;
+ bounds.right = ((idx / 5) + 1) * 32 + 3;
+ bounds.bottom = ((idx % 5) + 1) * 8 + MADS_SURFACE_HEIGHT + 4;
+}
+
+void ActionsView::onRefresh(RectList *rects, M4Surface *destSurface) {
+ _vm->_font->setFont(FONT_INTERFACE_MADS);
+
+ int actionId = kVerbLook;
+ for (int x = 0; x < 2; ++x) {
+ for (int y = 0; y < 5; ++y, ++actionId) {
+ // Get the bounds for the next item
+ Common::Rect r;
+ getActionRect(actionId, r);
+
+ // Determine the font colour depending on whether an item is selected
+ setFontMode((_highlightedAction == actionId) ? MODE_1 : MODE_0);
+
+ // Get the verb action and capitalise it
+ const char *verbStr = _vm->_globals->getVocab(actionId);
+ char buffer[20];
+ strcpy(buffer, verbStr);
+ if ((buffer[0] >= 'a') && (buffer[0] <= 'z')) buffer[0] -= 'a' - 'A';
+
+ // Display the verb
+ _vm->_font->writeString(destSurface, buffer, r.left, r.top, r.width(), 0);
+ }
+ }
+}
+
+bool ActionsView::onEvent(M4EventType eventType, int param1, int x, int y, bool &captureEvents) {
+ if (eventType == MEVENT_MOVE) {
+ // If the cursor isn't in "wait mode", reset it back to the normal cursor
+ if (_vm->_mouse->getCursorNum() != CURSOR_WAIT)
+ _vm->_mouse->setCursorNum(CURSOR_ARROW);
+
+ // Check if any of the actions are currently highlighted
+ _highlightedAction = 0;
+ for (int i = kVerbLook; i <= kVerbThrow; ++i) {
+ Common::Rect r;
+ getActionRect(i, r);
+
+ if (r.contains(x, y)) {
+ _highlightedAction = i;
+ break;
+ }
+ }
+
+ return true;
+ }
+
+ return false;
+}
+
} // End of namespace M4
diff --git a/engines/m4/scene.h b/engines/m4/scene.h
index 092ae8372b..b684750b18 100644
--- a/engines/m4/scene.h
+++ b/engines/m4/scene.h
@@ -127,6 +127,29 @@ private:
void nextCommonCursor();
};
+enum FontMode {MODE_0, MODE_1, MODE_2};
+
+class InterfaceElement: public View {
+protected:
+ void setFontMode(FontMode newMode);
+public:
+ InterfaceElement(M4Engine *vm, const Common::Rect &viewBounds, bool transparent = true);
+ ~InterfaceElement() {};
+};
+
+class ActionsView: public InterfaceElement {
+private:
+ int _highlightedAction;
+
+ void getActionRect(int actionId, Common::Rect &bounds);
+public:
+ ActionsView(M4Engine *vm);
+ ~ActionsView() {};
+
+ void onRefresh(RectList *rects, M4Surface *destSurface);
+ bool onEvent(M4EventType eventType, int param1, int x, int y, bool &captureEvents);
+};
+
} // End of namespace M4
#endif