[Scummvm-cvs-logs] scummvm master -> b2de771613536cb4f9298d919cd4aef0ede74e5d
dreammaster
dreammaster at scummvm.org
Sun Jul 26 15:25:08 CEST 2015
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
b2de771613 SHERLOCK: RT: Implement Files dialog event handling
Commit: b2de771613536cb4f9298d919cd4aef0ede74e5d
https://github.com/scummvm/scummvm/commit/b2de771613536cb4f9298d919cd4aef0ede74e5d
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2015-07-26T09:24:02-04:00
Commit Message:
SHERLOCK: RT: Implement Files dialog event handling
Changed paths:
engines/sherlock/tattoo/tattoo_user_interface.cpp
engines/sherlock/tattoo/widget_base.cpp
engines/sherlock/tattoo/widget_files.cpp
engines/sherlock/tattoo/widget_files.h
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index 6c40323..16cd6f2 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -388,13 +388,13 @@ void TattooUserInterface::doStandardControl() {
switch (_keyState.keycode) {
case Common::KEYCODE_F5:
// Save game
- freeMenu();
+ events.warpMouse();
saveGame();
return;
case Common::KEYCODE_F7:
// Load game
- freeMenu();
+ events.warpMouse();
loadGame();
return;
diff --git a/engines/sherlock/tattoo/widget_base.cpp b/engines/sherlock/tattoo/widget_base.cpp
index cc8e5c9..57d2fe0 100644
--- a/engines/sherlock/tattoo/widget_base.cpp
+++ b/engines/sherlock/tattoo/widget_base.cpp
@@ -59,11 +59,13 @@ void WidgetBase::banishWindow() {
}
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();
}
bool WidgetBase::active() const {
diff --git a/engines/sherlock/tattoo/widget_files.cpp b/engines/sherlock/tattoo/widget_files.cpp
index 29ca0c5..620c252 100644
--- a/engines/sherlock/tattoo/widget_files.cpp
+++ b/engines/sherlock/tattoo/widget_files.cpp
@@ -166,8 +166,11 @@ void WidgetFiles::render(FilesRenderMode mode) {
}
void WidgetFiles::handleEvents() {
- //Events &events = *_vm->_events;
+ Events &events = *_vm->_events;
+ TattooScene &scene = *(TattooScene *)_vm->_scene;
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
+ Common::Point mousePos = events.mousePos();
+ Common::KeyState keyState = ui._keyState;
// Handle scrollbar events
ScrollHighlight oldHighlight = ui._scrollHighlight;
@@ -176,11 +179,74 @@ void WidgetFiles::handleEvents() {
int oldScrollIndex = _savegameIndex;
handleScrolling(_savegameIndex, FILES_LINES_COUNT, _savegames.size());
+ // See if the mouse is pointing at any filenames in the window
+ if (Common::Rect(_bounds.left, _bounds.top + _surface.fontHeight() + 14,
+ _bounds.right - BUTTON_SIZE - 5, _bounds.bottom - 5).contains(mousePos)) {
+ _selector = (mousePos.y - _bounds.top - _surface.fontHeight() - 14) / (_surface.fontHeight() + 1) +
+ _savegameIndex;
+ } else {
+ _selector = -1;
+ }
+
+ // Check for the Tab key
+ if (keyState.keycode == Common::KEYCODE_TAB) {
+ // If the mouse is not over any of the filenames, move the mouse so that it points to the first one
+ if (_selector == -1) {
+ events.warpMouse(Common::Point(_bounds.right - BUTTON_SIZE - 20,
+ _bounds.top + _surface.fontHeight() * 2 + 8));
+ } else {
+ // See if we're doing Tab or Shift Tab
+ if (keyState.flags & Common::KBD_SHIFT) {
+ // We're doing Shift Tab
+ if (_selector == _savegameIndex)
+ _selector = _savegameIndex + 4;
+ else
+ --_selector;
+ } else {
+ // We're doing Tab
+ ++_selector;
+ if (_selector >= _savegameIndex + 5)
+ _selector = _savegameIndex;
+ }
+
+ events.warpMouse(Common::Point(mousePos.x, _bounds.top + _surface.fontHeight() * 2
+ + 8 + (_selector - _savegameIndex) * (_surface.fontHeight() + 1)));
+ }
+ }
+
// Only redraw the window if the the scrollbar position has changed
- if (ui._scrollHighlight != oldHighlight || oldScrollIndex != _savegameIndex)
+ if (ui._scrollHighlight != oldHighlight || oldScrollIndex != _savegameIndex || _selector != _oldSelector)
render(RENDER_NAMES_AND_SCROLLBAR);
+ _oldSelector = _selector;
+
+ if (events._firstPress && !_bounds.contains(mousePos))
+ _outsideMenu = true;
+
+ if (events._released || events._rightReleased || keyState.keycode == Common::KEYCODE_ESCAPE) {
+ ui._scrollHighlight = SH_NONE;
+
+ if (_outsideMenu && !_bounds.contains(mousePos)) {
+ close();
+ } else {
+ _outsideMenu = false;
+
+ if (_selector != -1) {
+ if (_fileMode = SAVEMODE_LOAD) {
+ // We're in Load Mode
+ _vm->loadGameState(_selector);
+ } else if (_fileMode == SAVEMODE_SAVE) {
+ // We're in Save Mode
+ if (getFilename())
+ _vm->saveGameState(_selector, _savegames[_selector]);
+ close();
+ }
+ }
+ }
+ }
+}
- // TODO
+bool WidgetFiles::getFilename() {
+ return false;
}
Common::Rect WidgetFiles::getScrollBarBounds() const {
diff --git a/engines/sherlock/tattoo/widget_files.h b/engines/sherlock/tattoo/widget_files.h
index e861206..94a029d 100644
--- a/engines/sherlock/tattoo/widget_files.h
+++ b/engines/sherlock/tattoo/widget_files.h
@@ -57,6 +57,11 @@ private:
void showScummVMRestoreDialog();
/**
+ * Prompt the user for a savegame name in the currently selected slot
+ */
+ bool getFilename();
+
+ /**
* Return the area of a widget that the scrollbar will be drawn in
*/
virtual Common::Rect getScrollBarBounds() const;
More information about the Scummvm-git-logs
mailing list