STARK: Add a quick hack to allow the action menu to actually perform actions.

This commit is contained in:
Einar Johan Trøan Sømåen
2016-01-01 07:29:42 +01:00
committed by Bastien Bouclet
parent 767852eea7
commit 647affea8a
4 changed files with 32 additions and 5 deletions
+14
View File
@@ -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
+2
View File
@@ -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);
};
+12 -1
View File
@@ -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) {
+4 -4
View File
@@ -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();
}