mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
STARK: Add a quick hack to allow the action menu to actually perform actions.
This commit is contained in:
committed by
Bastien Bouclet
parent
767852eea7
commit
647affea8a
@@ -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<Resources::Item>();
|
||||
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
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user