From 647affea8a8b341b541f1452de8927aa46d2f59a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Einar=20Johan=20Tr=C3=B8an=20S=C3=B8ma=CC=8Aen?= Date: Tue, 24 Feb 2015 12:58:06 +0100 Subject: [PATCH] STARK: Add a quick hack to allow the action menu to actually perform actions. --- engines/stark/actionmenu.cpp | 14 ++++++++++++++ engines/stark/actionmenu.h | 2 ++ engines/stark/services/userinterface.cpp | 13 ++++++++++++- engines/stark/ui.cpp | 8 ++++---- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/engines/stark/actionmenu.cpp b/engines/stark/actionmenu.cpp index ca097e76064..97b66c1f017 100644 --- a/engines/stark/actionmenu.cpp +++ b/engines/stark/actionmenu.cpp @@ -103,5 +103,19 @@ void ActionMenu::enableAction(ActionMenuType action) { error("Invalid action type in ActionMenu::enableAction"); } } + +int ActionMenu::isThisYourButton(Resources::Object *object) { + Resources::Item *item = object->findParent(); + warning("Item: %s", item->getName().c_str()); + if (item == _mouth) { + return kActionHand; + } else if (item == _eye) { + return kActionEye; + } else if (item == _hand) { + return kActionHand; + } else { + return -1; + } +} } // End of namespace Stark diff --git a/engines/stark/actionmenu.h b/engines/stark/actionmenu.h index cbaaab0bc60..863955c2f77 100644 --- a/engines/stark/actionmenu.h +++ b/engines/stark/actionmenu.h @@ -31,6 +31,7 @@ class VisualImageXMG; namespace Resources { class Item; +class Object; } class ActionMenu { @@ -55,6 +56,7 @@ public: void clearActions(); void enableAction(ActionMenuType action); Gfx::RenderEntryArray getRenderEntries() { return _renderEntries; } + int isThisYourButton(Resources::Object *object); }; diff --git a/engines/stark/services/userinterface.cpp b/engines/stark/services/userinterface.cpp index d5b53ed807b..87bdc3f0285 100644 --- a/engines/stark/services/userinterface.cpp +++ b/engines/stark/services/userinterface.cpp @@ -221,7 +221,18 @@ bool UserInterface::performActionOnObject(Resources::Object *object, Resources:: // * Click in the action menu, which has 0 available actions (TODO) if (table->getNumActions() == 0) { if (activeObject) { - warning("TODO: We should check if the active object got an action from the action menu"); + // HACK: presumably this can be resolved by adding SubItem2, and hooking up the item to the actionMenu directly. + int menuResult = _actionMenu->isThisYourButton(object); + if (menuResult != -1 && activeObject->getType() == Resources::Type::kPATTable) { + Resources::PATTable *table = (Resources::PATTable *)activeObject; + if (menuResult == ActionMenu::kActionHand) { + table->getScriptForAction(Resources::PATTable::kActionUse)->execute(Resources::Script::kCallModePlayerAction); + } else if (menuResult == ActionMenu::kActionEye) { + table->getScriptForAction(Resources::PATTable::kActionLook)->execute(Resources::Script::kCallModePlayerAction); + } else if (menuResult == ActionMenu::kActionMouth) { + table->getScriptForAction(Resources::PATTable::kActionTalk)->execute(Resources::Script::kCallModePlayerAction); + } + } } return true; } else if (table->getNumActions() == 1) { diff --git a/engines/stark/ui.cpp b/engines/stark/ui.cpp index 414289c805d..0e331840e7e 100644 --- a/engines/stark/ui.cpp +++ b/engines/stark/ui.cpp @@ -85,10 +85,6 @@ void UI::update(Gfx::RenderEntryArray renderEntries, bool keepExisting) { _cursor->setCursorType(Cursor::kPassive); } _cursor->setMouseHint(mouseHint); - - if (_hasClicked) { - handleClick(); - } } void UI::handleClick() { @@ -116,6 +112,10 @@ void UI::render() { Common::Point pos = _cursor->getMousePosition(); UserInterface *ui = StarkServices::instance().userInterface; update(ui->getRenderEntries(), true); + // Can't handle clicks before this point, since we need to have updated the mouse-over state to include the UI. + if (_hasClicked) { + handleClick(); + } ui->render(); }