aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBorja Lorente2016-06-17 12:44:52 +0200
committerBorja Lorente2016-08-14 18:26:46 +0200
commit79496ea5c07cf3da9fef845e53b6df2c36a6a8e7 (patch)
tree79f2a4b703513e170817fa16b9273023734fc092
parentef5a1525149b8f9cfc6806fdb46217d912025195 (diff)
downloadscummvm-rg350-79496ea5c07cf3da9fef845e53b6df2c36a6a8e7.tar.gz
scummvm-rg350-79496ea5c07cf3da9fef845e53b6df2c36a6a8e7.tar.bz2
scummvm-rg350-79496ea5c07cf3da9fef845e53b6df2c36a6a8e7.zip
MACVENTURE: Add command activation
-rw-r--r--engines/macventure/gui.cpp37
-rw-r--r--engines/macventure/gui.h5
-rw-r--r--engines/macventure/macventure.cpp41
-rw-r--r--engines/macventure/macventure.h5
4 files changed, 73 insertions, 15 deletions
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 3aa9c5de33..aeca8df1c9 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -68,7 +68,7 @@ static const Graphics::MenuData menuSubItems[] = {
{ 0, NULL, 0, 0, false }
};
-bool controlsWindowCallback(Graphics::WindowClick, Common::Event &event, void *gui);
+bool commandsWindowCallback(Graphics::WindowClick, Common::Event &event, void *gui);
bool mainGameWindowCallback(Graphics::WindowClick, Common::Event &event, void *gui);
bool outConsoleWindowCallback(Graphics::WindowClick, Common::Event &event, void *gui);
bool selfWindowCallback(Graphics::WindowClick, Common::Event &event, void *gui);
@@ -145,7 +145,7 @@ void Gui::initWindows() {
_controlsWindow = _wm.addWindow(false, false, false);
_controlsWindow->setDimensions(getWindowData(kCommandsWindow).bounds);
_controlsWindow->setActive(false);
- _controlsWindow->setCallback(controlsWindowCallback, this);
+ _controlsWindow->setCallback(commandsWindowCallback, this);
loadBorder(_controlsWindow, "border_command.bmp", false);
loadBorder(_controlsWindow, "border_command.bmp", true);
@@ -462,7 +462,7 @@ void Gui::drawSelfWindow() {
/* CALLBACKS */
-bool controlsWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
+bool commandsWindowCallback(Graphics::WindowClick click, Common::Event &event, void *gui) {
Gui *g = (Gui*)gui;
@@ -564,20 +564,27 @@ void Gui::handleMenuAction(MenuAction action) {
bool Gui::processCommandEvents(WindowClick click, Common::Event &event) {
if (event.type == Common::EVENT_LBUTTONUP) {
- if (_engine->isPaused()) {
- _engine->requestUnpause();
- } else {
- Common::Point position(
- event.mouse.x - _controlsWindow->getDimensions().left,
- event.mouse.y - _controlsWindow->getDimensions().top);
- Common::List<CommandButton>::const_iterator it = _controlData->begin();
- for (; it != _controlData->end(); ++it) {
- const CommandButton &data = *it;
- if (data.isInsideBounds(position)) {
- debug("Command active: %s", data.getData().title);
- }
+ if (_engine->isPaused())
+ return true;
+
+ Common::Point position(
+ event.mouse.x - _controlsWindow->getDimensions().left,
+ event.mouse.y - _controlsWindow->getDimensions().top);
+
+ CommandButton data;
+ Common::List<CommandButton>::const_iterator it = _controlData->begin();
+ for (; it != _controlData->end(); ++it) {
+ if (it->isInsideBounds(position)) {
+ debug("Command active: %s", it->getData().title);
+ data = *it;
}
}
+
+ _engine->selectControl((ControlReference)data.getData().refcon);
+ _engine->activateCommand((ControlReference)data.getData().refcon);
+
+ // Run main
+
}
return false;
}
diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h
index 1eba4d231b..4d760e8382 100644
--- a/engines/macventure/gui.h
+++ b/engines/macventure/gui.h
@@ -198,6 +198,11 @@ enum {
};
public:
+
+ CommandButton() {
+ _gui = nullptr;
+ }
+
CommandButton(ControlData data, Gui *g) {
_data = data;
_gui = g;
diff --git a/engines/macventure/macventure.cpp b/engines/macventure/macventure.cpp
index 8466c1bf2d..27a2aad1fc 100644
--- a/engines/macventure/macventure.cpp
+++ b/engines/macventure/macventure.cpp
@@ -135,6 +135,22 @@ void MacVentureEngine::requestUnpause() {
_gameState = kGameStatePlaying;
}
+void MacVentureEngine::selectControl(ControlReference id) {
+ ControlAction action = referenceToAction(id);
+ debug(7, "Select control %x", action);
+ _selectedControl = action;
+}
+
+void MacVentureEngine::activateCommand(ControlReference id) {
+ ControlAction action = referenceToAction(id);
+ if (action != _activeControl) {
+ if (_activeControl)
+ _activeControl = kNoCommand;
+ _activeControl = action;
+ }
+ debug(7, "Activating Command %x... Command %x is active", action, _activeControl);
+}
+
void MacVentureEngine::enqueueObject(ObjID id) {
QueuedObject obj;
obj.parent = _world->getObjAttr(id, kAttrParentObject);
@@ -246,6 +262,31 @@ void MacVentureEngine::resetVars() {
_cmdReady = false;
}
+ControlAction MacVenture::MacVentureEngine::referenceToAction(ControlReference id) {
+ switch (id) {
+ case MacVenture::kControlExitBox:
+ return kActivateObject;//??
+ case MacVenture::kControlExamine:
+ return kExamine;
+ case MacVenture::kControlOpen:
+ return kOpen;
+ case MacVenture::kControlClose:
+ return kClose;
+ case MacVenture::kControlSpeak:
+ return kSpeak;
+ case MacVenture::kControlOperate:
+ return kOperate;
+ case MacVenture::kControlGo:
+ return kGo;
+ case MacVenture::kControlHit:
+ return kHit;
+ case MacVenture::kControlConsume:
+ return kConsume;
+ default:
+ return kNoCommand;
+ }
+}
+
// Data retrieval
bool MacVentureEngine::isPaused() {
diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h
index e1a147c28a..8fe5792e7c 100644
--- a/engines/macventure/macventure.h
+++ b/engines/macventure/macventure.h
@@ -146,6 +146,8 @@ public:
void requestQuit();
void requestUnpause();
+ void selectControl(ControlReference id);
+ void activateCommand(ControlReference id);
void enqueueObject(ObjID id);
@@ -169,6 +171,9 @@ private:
bool loadGlobalSettings();
bool loadTextHuffman();
+ // Utils
+ ControlAction referenceToAction(ControlReference id);
+
private: // Attributes
const ADGameDescription *_gameDescription;