void WidgetBase::close() { Events &events = *_vm->_events; TattooScene &scene = *(TattooScene *)_vm->_scene; TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; banishWindow(); ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; events.clearEvents(); }
void WidgetPassword::close() { Talk &talk = *_vm->_talk; banishWindow(); if (talk._talkToAbort) return; // See if they entered the correct password Common::String correct1 = FIXED(CorrectPassword); Common::String correct2 = Common::String::format("%s?", FIXED(CorrectPassword)); Common::String correct3 = Common::String::format("%s ?", FIXED(CorrectPassword)); if (!_password.compareToIgnoreCase(correct1) || !_password.compareToIgnoreCase(correct2) || !_password.compareToIgnoreCase(correct3)) // They got it correct _vm->setFlags(149); talk.talkTo("LASC52P"); }
void WidgetMessage::handleEvents() { Events &events = *_vm->_events; TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; WidgetBase::handleEvents(); --_menuCounter; // Check if a mouse or keypress has occurred, or the display counter has expired if (events._pressed || events._released || events._rightPressed || events._rightReleased || ui._keyState.keycode || !_menuCounter) { // Close the window banishWindow(); // Reset cursor and switch back to standard mode events.setCursor(ARROW); events.clearEvents(); ui._key = -1; ui._oldBgFound = -1; ui._menuMode = STD_MODE; } }
void WidgetVerbs::handleEvents() { Events &events = *_vm->_events; FixedText &fixedText = *_vm->_fixedText; People &people = *_vm->_people; TattooScene &scene = *(TattooScene *)_vm->_scene; Talk &talk = *_vm->_talk; TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; Common::Point mousePos = events.mousePos(); Common::Point scenePos = mousePos + ui._currentScroll; bool noDesc = false; Common::String strLook = fixedText.getText(kFixedText_Look); Common::String strTalk = fixedText.getText(kFixedText_Talk); Common::String strJournal = fixedText.getText(kFixedText_Journal); checkTabbingKeys(_verbCommands.size()); // Highlight verb display as necessary highlightVerbControls(); // Flag if the user has started pressing the button with the cursor outsie the menu if (events._firstPress && !_bounds.contains(mousePos)) _outsideMenu = true; // See if they released the mouse button if (events._released || events._rightReleased) { // See if they want to close the menu (they clicked outside of the menu) if (!_bounds.contains(mousePos)) { if (_outsideMenu) { // Free the current menu graphics & erase the menu banishWindow(); if (events._rightReleased) { // Reset the selected shape to what was clicked on ui._bgFound = scene.findBgShape(scenePos); ui._personFound = ui._bgFound >= 1000; Object *_bgShape = ui._personFound ? nullptr : &scene._bgShapes[ui._bgFound]; if (ui._personFound) { if (people[ui._bgFound - 1000]._description.empty() || people[ui._bgFound - 1000]._description.hasPrefix(" ")) noDesc = true; } else if (ui._bgFound != -1) { if (_bgShape->_description.empty() || _bgShape->_description.hasPrefix(" ")) noDesc = true; } else { noDesc = true; } // Call the Routine to turn on the Commands for this Object load(!noDesc); } else { // See if we're in a Lab Table Room ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; } } } else if (_bounds.contains(mousePos)) { // Mouse is within the menu // Erase the menu banishWindow(); // See if they are activating the Look Command if (!_verbCommands[_selector].compareToIgnoreCase(strLook)) { ui._bgFound = ui._activeObj; if (ui._activeObj >= 1000) { ui._personFound = true; } else { ui._personFound = false; ui._bgShape = &scene._bgShapes[ui._activeObj]; } ui.lookAtObject(); } else if (!_verbCommands[_selector].compareToIgnoreCase(strTalk)) { // Talk command is being activated talk.talk(ui._activeObj); ui._activeObj = -1; } else if (!_verbCommands[_selector].compareToIgnoreCase(strJournal)) { ui.doJournal(); // See if we're in a Lab Table scene ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; } else if (_selector >= ((int)_verbCommands.size() - 2)) { switch (_selector - (int)_verbCommands.size() + 2) { case 0: // Inventory ui.doInventory(2); break; case 1: // Options ui.doControls(); break; default: ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; break; } } else { // If they have selected anything else, process it people[HOLMES].gotoStand(); if (ui._activeObj < 1000) { for (int idx = 0; idx < 6; ++idx) { if (!_verbCommands[_selector].compareToIgnoreCase(scene._bgShapes[ui._activeObj]._use[idx]._verb)) { // See if they are Picking this object up if (!scene._bgShapes[ui._activeObj]._use[idx]._target.compareToIgnoreCase("*PICKUP")) ui.pickUpObject(ui._activeObj); else ui.checkAction(scene._bgShapes[ui._activeObj]._use[idx], ui._activeObj); } } } else { for (int idx = 0; idx < 2; ++idx) { if (!_verbCommands[_selector].compareToIgnoreCase(people[ui._activeObj - 1000]._use[idx]._verb)) ui.checkAction(people[ui._activeObj - 1000]._use[idx], ui._activeObj); } } ui._activeObj = -1; if (ui._menuMode != MESSAGE_MODE) { // See if we're in a Lab Table Room ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; } } } } else if (ui._keyState.keycode == Common::KEYCODE_ESCAPE) { // User closing the menu with the ESC key banishWindow(); ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE; } }
void WidgetOptions::handleEvents() { TattooEngine &vm = *(TattooEngine *)_vm; Events &events = *_vm->_events; Music &music = *_vm->_music; Screen &screen = *_vm->_screen; Sound &sound = *_vm->_sound; Talk &talk = *_vm->_talk; TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui; Common::Point mousePos = events.mousePos(); if (talk._talkToAbort) { sound.stopSound(); return; } // Flag if they started pressing outside the window if (events._firstPress && !_bounds.contains(mousePos)) _outsideMenu = true; if (events.kbHit()) { ui._keyState = events.getKey(); // Emulate a mouse release if Enter or Space Bar is pressed if (ui._keyState.keycode == Common::KEYCODE_RETURN || ui._keyState.keycode == Common::KEYCODE_SPACE) { events._pressed = events._oldButtons = false; events._released = true; } else if (ui._keyState.keycode == Common::KEYCODE_ESCAPE) { close(); return; } else { checkTabbingKeys(11); } } // Check highlighting the various controls if (_bounds.contains(mousePos)) { _selector = (mousePos.y - _bounds.top) / (_surface.fontHeight() + 7); // If one of the sliders has been selected, & the mouse is not pressed, reset the selector to -1 if ((_selector == 3 || _selector == 6) && !events._pressed) _selector = -1; } else { _selector = -1; if (_outsideMenu && (events._released || events._rightReleased)) { events.clearEvents(); close(); return; } } // If the selected control has changed, redraw the dialog contents if (_selector != _oldSelector) render(OP_CONTENTS); _oldSelector = _selector; // Adjust the Volume Sliders (if neccessary) here switch (_selector) { case 3: { // Set Music Volume _midiSliderX = mousePos.x - _bounds.left; if (_midiSliderX < _surface.widestChar()) _midiSliderX = _surface.widestChar(); else if (_midiSliderX > _bounds.width() - _surface.widestChar()) _midiSliderX = _bounds.width() - _surface.widestChar(); int newVolume = (_midiSliderX - _surface.widestChar()) * 255 / (_bounds.width() - _surface.widestChar() * 2); if (newVolume != music._musicVolume) { music.setMusicVolume(newVolume); vm.saveConfig(); } render(OP_NAMES); break; } case 6: { // Set Digitized Volume _digiSliderX = mousePos.x - _bounds.left; if (_digiSliderX < _surface.widestChar()) _digiSliderX = _surface.widestChar(); else if (_digiSliderX > _bounds.width() - _surface.widestChar()) _digiSliderX = _bounds.width() - _surface.widestChar(); int temp = sound._soundVolume; sound._soundVolume = (_digiSliderX - _surface.widestChar()) * 255 / (_bounds.width() - _surface.widestChar() * 2); if (sound._soundVolume != temp) { sound.setVolume(sound._soundVolume); vm.saveConfig(); } render(OP_NAMES); break; } default: break; } // Option selected if (events._released || events._rightReleased) { events.clearEvents(); _outsideMenu = false; int temp = _selector; _selector = -1; switch (temp) { case 0: // Load Game close(); ui.loadGame(); break; case 1: // Save Game close(); ui.saveGame(); break; case 2: // Toggle Music music._musicOn = !music._musicOn; if (!music._musicOn) music.stopMusic(); else music.startSong(); render(OP_NAMES); vm.saveConfig(); break; case 4: // Toggle Sound Effects sound.stopSound(); sound._digitized = !sound._digitized; render(OP_NAMES); vm.saveConfig(); break; case 5: // Toggle Voices sound._voices = !sound._voices; render(OP_NAMES); vm.saveConfig(); break; case 7: // Toggle Text Windows vm._textWindowsOn = !vm._textWindowsOn; render(OP_NAMES); vm.saveConfig(); break; case 8: { // New Font Style int fontNumber = screen.fontNumber() + 1; if (fontNumber == 7) fontNumber = 0; screen.setFont(fontNumber); render(OP_ALL); vm.saveConfig(); break; } case 9: // Toggle Transparent Menus vm._transparentMenus = !vm._transparentMenus; render(OP_NAMES); vm.saveConfig(); break; case 10: // Quit banishWindow(); ui.doQuitMenu(); break; default: break; } _oldSelector = -1; } }