[Scummvm-cvs-logs] scummvm master -> 3e98c563770bdfde049c0f74871d606be3b9698e
fuzzie
fuzzie at fuzzie.org
Sat Nov 5 11:20:42 CET 2011
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:
3e98c56377 COMPOSER: Support keyboard shortcuts.
Commit: 3e98c563770bdfde049c0f74871d606be3b9698e
https://github.com/scummvm/scummvm/commit/3e98c563770bdfde049c0f74871d606be3b9698e
Author: Alyssa Milburn (fuzzie at fuzzie.org)
Date: 2011-11-05T03:19:22-07:00
Commit Message:
COMPOSER: Support keyboard shortcuts.
Changed paths:
engines/composer/composer.cpp
engines/composer/composer.h
engines/composer/resource.h
diff --git a/engines/composer/composer.cpp b/engines/composer/composer.cpp
index af08ad6..17c14dd 100644
--- a/engines/composer/composer.cpp
+++ b/engines/composer/composer.cpp
@@ -262,6 +262,33 @@ void ComposerEngine::onMouseMove(const Common::Point &pos) {
void ComposerEngine::onKeyDown(uint16 keyCode) {
runEvent(kEventKeyDown, keyCode, 0, 0);
runEvent(kEventChar, keyCode, 0, 0);
+
+ for (Common::List<Library>::iterator i = _libraries.begin(); i != _libraries.end(); i++) {
+ for (Common::List<KeyboardHandler>::iterator j = i->_keyboardHandlers.begin(); j != i->_keyboardHandlers.end(); j++) {
+ const KeyboardHandler &handler = *j;
+ if (keyCode != handler.keyId)
+ continue;
+
+ int modifiers = g_system->getEventManager()->getModifierState();
+ switch (handler.modifierId) {
+ case 0x10: // shift
+ if (!(modifiers & Common::KBD_SHIFT))
+ continue;
+ break;
+ case 0x11: // control
+ if (!(modifiers & Common::KBD_CTRL))
+ continue;
+ break;
+ case 0:
+ break;
+ default:
+ warning("unknown keyb modifier %d", handler.modifierId);
+ continue;
+ }
+
+ runScript(handler.scriptId);
+ }
+ }
}
void ComposerEngine::setCursor(uint16 id, const Common::Point &offset) {
@@ -406,6 +433,16 @@ void ComposerEngine::loadLibrary(uint id) {
newLib._buttons.insert(newLib._buttons.begin(), button);
}
+ Common::Array<uint16> accelResources = library._archive->getResourceIDList(ID_ACEL);
+ for (uint i = 0; i < accelResources.size(); i++) {
+ Common::SeekableReadStream *stream = library._archive->getResource(ID_ACEL, accelResources[i]);
+ KeyboardHandler handler;
+ handler.keyId = stream->readUint16LE();
+ handler.modifierId = stream->readUint16LE();
+ handler.scriptId = stream->readUint16LE();
+ newLib._keyboardHandlers.push_back(handler);
+ }
+
// add background sprite, if it exists
if (hasResource(ID_BMAP, 1000))
setBackground(1000);
diff --git a/engines/composer/composer.h b/engines/composer/composer.h
index d92add1..02dbca5 100644
--- a/engines/composer/composer.h
+++ b/engines/composer/composer.h
@@ -95,11 +95,18 @@ enum {
kEventKeyUp = 7
};
+struct KeyboardHandler {
+ uint16 keyId;
+ uint16 modifierId;
+ uint16 scriptId;
+};
+
struct Library {
uint _id;
Archive *_archive;
Common::List<Button> _buttons;
+ Common::List<KeyboardHandler> _keyboardHandlers;
};
struct QueuedScript {
diff --git a/engines/composer/resource.h b/engines/composer/resource.h
index aeaa5b9..cc1985e 100644
--- a/engines/composer/resource.h
+++ b/engines/composer/resource.h
@@ -35,6 +35,7 @@ struct Animation;
#define ID_LBRC MKTAG('L','B','R','C') // Main FourCC
+#define ID_ACEL MKTAG('A','C','E','L') // Keyboard Accelerator (v1)
#define ID_AMBI MKTAG('A','M','B','I') // Ambient (v1 sprite button)
#define ID_ANIM MKTAG('A','N','I','M') // Animation
#define ID_BMAP MKTAG('B','M','A','P') // Bitmap
More information about the Scummvm-git-logs
mailing list