aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2015-06-26 22:31:59 -0400
committerPaul Gilbert2015-06-26 22:31:59 -0400
commitab28816acd893794f766e2860ada1fab8a60d39f (patch)
tree435821d162e55c5e07e1c8a7145e24f3b2bcb22e
parentf5af394babe88a2a0cee2b515e026d982bc341fc (diff)
downloadscummvm-rg350-ab28816acd893794f766e2860ada1fab8a60d39f.tar.gz
scummvm-rg350-ab28816acd893794f766e2860ada1fab8a60d39f.tar.bz2
scummvm-rg350-ab28816acd893794f766e2860ada1fab8a60d39f.zip
SHERLOCK: RT: Finish display of right-click Verbs menu
-rw-r--r--engines/sherlock/fixed_text.h2
-rw-r--r--engines/sherlock/tattoo/tattoo_fixed_text.cpp4
-rw-r--r--engines/sherlock/tattoo/tattoo_fixed_text.h4
-rw-r--r--engines/sherlock/tattoo/tattoo_user_interface.cpp10
-rw-r--r--engines/sherlock/tattoo/widget_verbs.cpp92
-rw-r--r--engines/sherlock/tattoo/widget_verbs.h9
6 files changed, 94 insertions, 27 deletions
diff --git a/engines/sherlock/fixed_text.h b/engines/sherlock/fixed_text.h
index dcc1d69948..32a5266392 100644
--- a/engines/sherlock/fixed_text.h
+++ b/engines/sherlock/fixed_text.h
@@ -28,6 +28,8 @@
namespace Sherlock {
+#define FIXED(MSG) _vm->_fixedText->getText(kFixedText_##MSG##)
+
enum FixedTextActionId {
kFixedTextAction_Invalid = -1,
kFixedTextAction_Open = 0,
diff --git a/engines/sherlock/tattoo/tattoo_fixed_text.cpp b/engines/sherlock/tattoo/tattoo_fixed_text.cpp
index ec0c8ca127..6232ce4a9b 100644
--- a/engines/sherlock/tattoo/tattoo_fixed_text.cpp
+++ b/engines/sherlock/tattoo/tattoo_fixed_text.cpp
@@ -31,7 +31,9 @@ static const char *const FIXED_TEXT_ENGLISH[] = {
"Open",
"Look",
"Talk",
- "Journal"
+ "Journal",
+ "Inventory",
+ "Options"
};
TattooFixedText::TattooFixedText(SherlockEngine *vm) : FixedText(vm) {
diff --git a/engines/sherlock/tattoo/tattoo_fixed_text.h b/engines/sherlock/tattoo/tattoo_fixed_text.h
index 1ac75aa56a..729b7073de 100644
--- a/engines/sherlock/tattoo/tattoo_fixed_text.h
+++ b/engines/sherlock/tattoo/tattoo_fixed_text.h
@@ -33,7 +33,9 @@ enum FixedTextId {
kFixedText_Open,
kFixedText_Look,
kFixedText_Talk,
- kFixedText_Journal
+ kFixedText_Journal,
+ kFixedText_Inventory,
+ kFixedText_Options
};
class TattooFixedText: public FixedText {
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index cbd9c6168f..e309875ef7 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -440,7 +440,13 @@ void TattooUserInterface::doStandardControl() {
if (events._rightReleased) {
// Show the verbs menu for the highlighted object
- _verbsWidget.activateVerbMenu(!noDesc);
+ _tooltipWidget.banishWindow();
+ _verbsWidget.load(!noDesc);
+ _verbsWidget.summonWindow();
+
+ _selector = _oldSelector = -1;
+ _activeObj = _bgFound;
+ _menuMode = VERB_MODE;
} else if (_personFound || (_bgFound != -1 && _bgFound < 1000 && _bgShape->_aType == PERSON)) {
// The object found is a person (the default for people is TALK)
talk.talk(_bgFound);
@@ -524,7 +530,7 @@ void TattooUserInterface::doInventoryControl() {
}
void TattooUserInterface::doVerbControl() {
- _verbsWidget.execute();
+ _verbsWidget.handleEvents();
}
void TattooUserInterface::doTalkControl() {
diff --git a/engines/sherlock/tattoo/widget_verbs.cpp b/engines/sherlock/tattoo/widget_verbs.cpp
index a56b151e34..159965865a 100644
--- a/engines/sherlock/tattoo/widget_verbs.cpp
+++ b/engines/sherlock/tattoo/widget_verbs.cpp
@@ -36,15 +36,13 @@ WidgetVerbs::WidgetVerbs(SherlockEngine *vm) : WidgetBase(vm) {
_outsideMenu = false;
}
-void WidgetVerbs::activateVerbMenu(bool objectsOn) {
+void WidgetVerbs::load(bool objectsOn) {
+ Events &events = *_vm->_events;
Talk &talk = *_vm->_talk;
- FixedText &fixedText = *_vm->_fixedText;
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
TattooPeople &people = *(TattooPeople *)_vm->_people;
+ Common::Point mousePos = events.mousePos();
bool isWatson = false;
- Common::String strLook = fixedText.getText(kFixedText_Look);
- Common::String strTalk = fixedText.getText(kFixedText_Talk);
- Common::String strJournal = fixedText.getText(kFixedText_Journal);
if (talk._talkToAbort)
return;
@@ -64,41 +62,93 @@ void WidgetVerbs::activateVerbMenu(bool objectsOn) {
if (!scumm_strnicmp(npc._npcName.c_str(), "WATS", 4))
isWatson = true;
- if (!scumm_strnicmp(person._examine.c_str(), "_EXIT", 5))
- _verbCommands.push_back(strLook);
+
+ if (scumm_strnicmp(person._examine.c_str(), "_EXIT", 5))
+ _verbCommands.push_back(FIXED(Look));
- _verbCommands.push_back(strTalk);
+ _verbCommands.push_back(FIXED(Talk));
// Add any extra active verbs from the NPC's verb list
- // TODO
+ for (int idx = 0; idx < 2; ++idx) {
+ if (!person._use[idx]._verb.empty() && !person._use[idx]._verb.hasPrefix(" ") &&
+ (person._use[idx]._target.empty() || person._use[idx]._target.hasPrefix(" "))) {
+ _verbCommands.push_back(person._use[idx]._verb);
+ }
+ }
} else {
if (!scumm_strnicmp(ui._bgShape->_name.c_str(), "WATS", 4))
+ // Looking at Watson
isWatson = true;
- if (!scumm_strnicmp(ui._bgShape->_examine.c_str(), "_EXIT", 5))
- _verbCommands.push_back(strLook);
+ if (scumm_strnicmp(ui._bgShape->_examine.c_str(), "_EXIT", 5))
+ // It's not an exit, so include Look as an option
+ _verbCommands.push_back(FIXED(Look));
if (ui._bgShape->_aType == PERSON)
- _verbCommands.push_back(strTalk);
+ _verbCommands.push_back(FIXED(Talk));
- // Add any extra active verbs from the NPC's verb list
- // TODO
+ // Add any extra active verbs from the object's verb list
+ for (int idx = 0; idx < 6; ++idx) {
+ if (!ui._bgShape->_use[idx]._verb.empty() && !ui._bgShape->_use[idx]._verb.hasPrefix(" ") &&
+ (ui._bgShape->_use[idx]._target.empty() || ui._bgShape->_use[idx]._target.hasPrefix(" "))) {
+ _verbCommands.push_back(ui._bgShape->_use[idx]._verb);
+ }
+ }
}
}
+ // If clicked on Watson, have Journal as an option
if (isWatson)
- _verbCommands.push_back(strJournal);
+ _verbCommands.push_back(FIXED(Journal));
// Add the system commands
- // TODO
+ _verbCommands.push_back(FIXED(Inventory));
+ _verbCommands.push_back(FIXED(Options));
+
+ // Figure out the needed width to show the commands
+ int width = 0;
+ for (uint idx = 0; idx < _verbCommands.size(); ++idx)
+ width = MAX(width, _surface.stringWidth(_verbCommands[idx]));
+ width += _surface.widestChar() * 2 + 6;
+ int height = (_surface.fontHeight() + 7) * _verbCommands.size() + 3;
+
+ // Set the bounds
+ _bounds = Common::Rect(width, height);
+ _bounds.moveTo(mousePos.x - _bounds.width() / 2, mousePos.y - _bounds.height() / 2);
+
+ // Render the window on the internal surface
+ render();
+}
+
+void WidgetVerbs::render() {
+ TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
+ ImageFile &images = *ui._interfaceImages;
- // Find the widest command
- // TODO
+ // Create the drawing surface
+ _surface.create(_bounds.width(), _bounds.height());
+ _surface.fill(TRANSPARENCY);
- // TODO: Finish this
+ // Draw basic background
+ makeInfoArea();
+
+ // Draw the verb commands and the lines separating them
+ for (uint idx = 0; idx < _verbCommands.size(); ++idx) {
+ _surface.writeString(_verbCommands[idx], Common::Point((_bounds.width() - _surface.stringWidth(_verbCommands[idx])) / 2,
+ (_surface.fontHeight() + 7) * idx + 5), INFO_TOP);
+
+ if (idx < ((int)_verbCommands.size() - 1)) {
+ _surface.hLine(3, (_surface.fontHeight() + 7) * (idx + 1), _bounds.width() - 4, INFO_TOP);
+ _surface.hLine(3, (_surface.fontHeight() + 7) * (idx + 1) + 1, _bounds.width() - 4, INFO_MIDDLE);
+ _surface.hLine(3, (_surface.fontHeight() + 7) * (idx + 1) + 2, _bounds.width() - 4, INFO_BOTTOM);
+
+ _surface.transBlitFrom(images[4], Common::Point(0, (_surface.fontHeight() + 7) * (idx + 1) - 1));
+ _surface.transBlitFrom(images[5], Common::Point(_bounds.width() - images[5]._width,
+ (_surface.fontHeight() + 7) * (idx + 1) - 1));
+ }
+ }
}
-void WidgetVerbs::execute() {
+void WidgetVerbs::handleEvents() {
Events &events = *_vm->_events;
FixedText &fixedText = *_vm->_fixedText;
People &people = *_vm->_people;
@@ -147,7 +197,7 @@ void WidgetVerbs::execute() {
}
// Call the Routine to turn on the Commands for this Object
- activateVerbMenu(!noDesc);
+ load(!noDesc);
} else {
// See if we're in a Lab Table Room
ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE;
diff --git a/engines/sherlock/tattoo/widget_verbs.h b/engines/sherlock/tattoo/widget_verbs.h
index fa41b3e42c..ce67842409 100644
--- a/engines/sherlock/tattoo/widget_verbs.h
+++ b/engines/sherlock/tattoo/widget_verbs.h
@@ -43,6 +43,11 @@ private:
* Highlights the controls for the verb list
*/
void highlightVerbControls();
+
+ /**
+ * Renders the window on an internal surface for later drawing on-screen
+ */
+ void render();
public:
Common::StringArray _verbCommands;
public:
@@ -52,12 +57,12 @@ public:
/**
* Turns on the menu with all the verbs that are available for the given object
*/
- void activateVerbMenu(bool objectsOn);
+ void load(bool objectsOn);
/**
* Process input for the dialog
*/
- void execute();
+ virtual void handleEvents();
};
} // End of namespace Tattoo