aboutsummaryrefslogtreecommitdiff
path: root/engines/tsage
diff options
context:
space:
mode:
authorPaul Gilbert2011-10-23 22:09:23 +1100
committerPaul Gilbert2011-10-23 22:12:05 +1100
commitd3c8a8e95e30da3da73642ddee23c992d3765e05 (patch)
treee05271be2d6f25463937c7c9bb02ec95f7fd33dd /engines/tsage
parent4cfafcdf8ba658dc208a62e26288c80309b39fd7 (diff)
downloadscummvm-rg350-d3c8a8e95e30da3da73642ddee23c992d3765e05.tar.gz
scummvm-rg350-d3c8a8e95e30da3da73642ddee23c992d3765e05.tar.bz2
scummvm-rg350-d3c8a8e95e30da3da73642ddee23c992d3765e05.zip
TSAGE: Implemented Ringworld 2 right click dialog
Diffstat (limited to 'engines/tsage')
-rw-r--r--engines/tsage/module.mk1
-rw-r--r--engines/tsage/ringworld2/ringworld2_dialogs.cpp193
-rw-r--r--engines/tsage/ringworld2/ringworld2_dialogs.h66
-rw-r--r--engines/tsage/ringworld2/ringworld2_logic.cpp6
-rw-r--r--engines/tsage/ringworld2/ringworld2_logic.h1
5 files changed, 264 insertions, 3 deletions
diff --git a/engines/tsage/module.mk b/engines/tsage/module.mk
index 7b32636da1..0ea8916647 100644
--- a/engines/tsage/module.mk
+++ b/engines/tsage/module.mk
@@ -35,6 +35,7 @@ MODULE_OBJS := \
ringworld/ringworld_scenes8.o \
ringworld/ringworld_scenes10.o \
ringworld/ringworld_speakers.o \
+ ringworld2/ringworld2_dialogs.o \
ringworld2/ringworld2_logic.o \
ringworld2/ringworld2_scenes0.o \
saveload.o \
diff --git a/engines/tsage/ringworld2/ringworld2_dialogs.cpp b/engines/tsage/ringworld2/ringworld2_dialogs.cpp
new file mode 100644
index 0000000000..8d4863f332
--- /dev/null
+++ b/engines/tsage/ringworld2/ringworld2_dialogs.cpp
@@ -0,0 +1,193 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "common/translation.h"
+
+#include "gui/dialog.h"
+#include "gui/widget.h"
+
+#include "tsage/tsage.h"
+#include "tsage/core.h"
+#include "tsage/dialogs.h"
+#include "tsage/staticres.h"
+#include "tsage/globals.h"
+#include "tsage/ringworld2/ringworld2_dialogs.h"
+
+namespace TsAGE {
+
+namespace Ringworld2 {
+
+/**
+ * This dialog implements the right-click dialog
+ */
+RightClickDialog::RightClickDialog() : GfxDialog() {
+ // Setup button positions
+ _btnList[0] = Common::Point(48, 12);
+ _btnList[1] = Common::Point(31, 29);
+ _btnList[2] = Common::Point(65, 29);
+ _btnList[3] = Common::Point(14, 47);
+ _btnList[4] = Common::Point(48, 47);
+ _btnList[5] = Common::Point(83, 47);
+
+ // Set the palette and change the cursor
+ BF_GLOBALS._events.setCursor(CURSOR_ARROW);
+
+ setPalette();
+
+ // Get the dialog image and selected button images
+ if (R2_GLOBALS._sceneManager._sceneNumber == 2900) {
+ _surface = surfaceFromRes(2902, 1, 1);
+ _btnImages.setVisage(2902, 2);
+ } else {
+ _surface = surfaceFromRes(1, 1, 1);
+ _btnImages.setVisage(1, 2);
+ }
+
+ // Set the dialog position
+ Rect dialogRect;
+ dialogRect.resize(_surface, 0, 0, 100);
+ dialogRect.center(g_globals->_events._mousePos.x, g_globals->_events._mousePos.y);
+
+ // Ensure the dialog will be entirely on-screen
+ Rect screenRect = g_globals->gfxManager()._bounds;
+ screenRect.collapse(4, 4);
+ dialogRect.contain(screenRect);
+
+ _bounds = dialogRect;
+ _gfxManager._bounds = _bounds;
+
+ _highlightedAction = -1;
+ _selectedAction = -1;
+}
+
+RightClickDialog::~RightClickDialog() {
+}
+
+void RightClickDialog::draw() {
+ // Save the covered background area
+ _savedArea = Surface_getArea(g_globals->_gfxManagerInstance.getSurface(), _bounds);
+
+ // Draw the dialog image
+ g_globals->gfxManager().copyFrom(_surface, _bounds.left, _bounds.top);
+}
+
+bool RightClickDialog::process(Event &event) {
+ switch (event.eventType) {
+ case EVENT_MOUSE_MOVE: {
+ // Check whether a button is highlighted
+ int buttonIndex;
+ for (buttonIndex = 6; buttonIndex >= 0; --buttonIndex) {
+ Rect tempRect(0, 0, 28, 29);
+ tempRect.moveTo(_btnList[buttonIndex].x, _btnList[buttonIndex].y);
+
+ if (tempRect.contains(event.mousePos))
+ break;
+ }
+ // If selection has changed, handle it
+ if (buttonIndex != _highlightedAction) {
+ if (_highlightedAction != -1) {
+ // Another button was previously selected, so restore dialog
+ _gfxManager.copyFrom(_surface, 0, 0);
+ }
+
+ if (buttonIndex != -1) {
+ // Draw newly selected button
+ GfxSurface btn = _btnImages.getFrame(buttonIndex + 1);
+ _gfxManager.copyFrom(btn, _btnList[buttonIndex].x, _btnList[buttonIndex].y);
+ }
+
+ _highlightedAction = buttonIndex;
+ }
+
+ event.handled = true;
+ return true;
+ }
+
+ case EVENT_BUTTON_DOWN:
+ // Specify the selected action
+ _selectedAction = (_highlightedAction == -1) ? 999 : _highlightedAction;
+ event.handled = true;
+ return true;
+
+ default:
+ break;
+ }
+
+ return false;
+}
+
+void RightClickDialog::execute() {
+ // Draw the dialog
+ draw();
+
+ // Dialog event handler loop
+ _gfxManager.activate();
+
+ while (!g_vm->shouldQuit() && (_selectedAction == -1)) {
+ Event evt;
+ while (g_globals->_events.getEvent(evt, EVENT_MOUSE_MOVE | EVENT_BUTTON_DOWN)) {
+ evt.mousePos.x -= _bounds.left;
+ evt.mousePos.y -= _bounds.top;
+
+ process(evt);
+ }
+
+ g_system->delayMillis(10);
+ g_system->updateScreen();
+ }
+
+ // Execute the specified action
+ CursorType cursorNum = CURSOR_NONE;
+ switch (_selectedAction) {
+ case 0:
+ // Look action
+ cursorNum = CURSOR_LOOK;
+ break;
+ case 1:
+ // Walk action
+ cursorNum = CURSOR_WALK;
+ break;
+ case 2:
+ // Use action
+ cursorNum = CURSOR_USE;
+ break;
+ case 3:
+ // Talk action
+ cursorNum = CURSOR_TALK;
+ break;
+ case 4:
+ // Change player
+ break;
+ case 5:
+ // Options dialog
+ break;
+ }
+
+ if (cursorNum != CURSOR_NONE)
+ BF_GLOBALS._events.setCursor(cursorNum);
+
+ _gfxManager.deactivate();
+}
+
+} // End of namespace Ringworld2
+
+} // End of namespace TsAGE
diff --git a/engines/tsage/ringworld2/ringworld2_dialogs.h b/engines/tsage/ringworld2/ringworld2_dialogs.h
new file mode 100644
index 0000000000..bbc35da3ea
--- /dev/null
+++ b/engines/tsage/ringworld2/ringworld2_dialogs.h
@@ -0,0 +1,66 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TSAGE_RINGWORLD2_DIALOGS_H
+#define TSAGE_RINGWORLD2_DIALOGS_H
+
+#include "gui/options.h"
+#include "tsage/dialogs.h"
+#include "tsage/events.h"
+#include "tsage/graphics.h"
+#include "common/list.h"
+#include "common/rect.h"
+#include "common/system.h"
+
+namespace TsAGE {
+
+namespace Ringworld2 {
+
+using namespace TsAGE;
+
+class RightClickDialog : public GfxDialog {
+private:
+ GfxSurface _surface;
+ Visage _btnImages;
+ Common::Point _btnList[6];
+
+ Rect _rectList1[5];
+ Rect _rectList2[5];
+ Rect _rectList3[5];
+ Rect _rectList4[5];
+
+ int _highlightedAction;
+ int _selectedAction;
+public:
+ RightClickDialog();
+ ~RightClickDialog();
+
+ virtual void draw();
+ virtual bool process(Event &event);
+ void execute();
+};
+
+} // End of namespace Ringworld2
+
+} // End of namespace TsAGE
+
+#endif
diff --git a/engines/tsage/ringworld2/ringworld2_logic.cpp b/engines/tsage/ringworld2/ringworld2_logic.cpp
index 63b0fc1a71..0bdcf36d0c 100644
--- a/engines/tsage/ringworld2/ringworld2_logic.cpp
+++ b/engines/tsage/ringworld2/ringworld2_logic.cpp
@@ -25,6 +25,7 @@
#include "tsage/tsage.h"
#include "tsage/staticres.h"
#include "tsage/ringworld2/ringworld2_logic.h"
+#include "tsage/ringworld2/ringworld2_dialogs.h"
#include "tsage/ringworld2/ringworld2_scenes0.h"
namespace TsAGE {
@@ -277,6 +278,7 @@ bool DisplayObject::performAction(int action) {
/*--------------------------------------------------------------------------*/
Ringworld2InvObjectList::Ringworld2InvObjectList():
+ _none(1, 1),
_inv1(1, 2),
_inv2(1, 3),
_inv3(1, 4),
@@ -331,6 +333,7 @@ Ringworld2InvObjectList::Ringworld2InvObjectList():
_inv52(4, 2) {
// Add the items to the list
+ _itemList.push_back(&_none);
_itemList.push_back(&_inv1);
_itemList.push_back(&_inv2);
_itemList.push_back(&_inv3);
@@ -484,7 +487,6 @@ void Ringworld2Game::start() {
else {
// Switch to the first game scene
g_globals->_events.setCursor(CURSOR_WALK);
- T2_GLOBALS._uiElements._active = true;
g_globals->_sceneManager.setNewScene(100);
}
@@ -574,11 +576,9 @@ void Ringworld2Game::processEvent(Event &event) {
}
void Ringworld2Game::rightClick() {
-/*
RightClickDialog *dlg = new RightClickDialog();
dlg->execute();
delete dlg;
-*/
}
/*--------------------------------------------------------------------------*/
diff --git a/engines/tsage/ringworld2/ringworld2_logic.h b/engines/tsage/ringworld2/ringworld2_logic.h
index 3922cdb799..bfb3281d5d 100644
--- a/engines/tsage/ringworld2/ringworld2_logic.h
+++ b/engines/tsage/ringworld2/ringworld2_logic.h
@@ -114,6 +114,7 @@ public:
class Ringworld2InvObjectList : public InvObjectList {
public:
+ InvObject _none;
InvObject _inv1;
InvObject _inv2;
InvObject _inv3;