[Scummvm-git-logs] scummvm master -> ddfa41b327243f5b640d704340f70943f15b507a
antoniou79
noreply at scummvm.org
Tue Feb 15 16:06:00 UTC 2022
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
92393d228b BLADERUNNER: Allow for repeated keys (key spamming)
ddfa41b327 BLADERUNNER: Fix for warning of adding \0 to String
Commit: 92393d228bcfcf0533911b5a66a5202c6115de23
https://github.com/scummvm/scummvm/commit/92393d228bcfcf0533911b5a66a5202c6115de23
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2022-02-15T18:05:52+02:00
Commit Message:
BLADERUNNER: Allow for repeated keys (key spamming)
Added space, backspace and latin letters and numbers (for save game screen)
Space can also be spammed with a visible result in-game (ie. not only in KIA save screen)
Changed paths:
engines/bladerunner/bladerunner.cpp
engines/bladerunner/bladerunner.h
engines/bladerunner/ui/kia_section_save.cpp
diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp
index e85c39d30bc..180ef3fbd52 100644
--- a/engines/bladerunner/bladerunner.cpp
+++ b/engines/bladerunner/bladerunner.cpp
@@ -1262,6 +1262,24 @@ void BladeRunnerEngine::walkingReset() {
_isInsideScriptActor = false;
}
+// The original allowed a few keyboard keys to be repeated ("key spamming")
+// namely, Esc, Return and Space during normal gameplay.
+// "Space" spamming results in McCoy quickly switching between combat mode and normal mode,
+// which is not very useful but it's the original's behavior.
+// Spamming Space, backspace, latin letter keys and a few symbols is allowed
+// in KIA mode, particularly in the Save Panel when writing the name for a save game.
+// F-keys are not repeated.
+bool BladeRunnerEngine::isAllowedRepeatedKey(const Common::KeyState &currKeyState) {
+ return currKeyState.keycode == Common::KEYCODE_ESCAPE
+ || currKeyState.keycode == Common::KEYCODE_RETURN
+ || currKeyState.keycode == Common::KEYCODE_BACKSPACE
+ || currKeyState.keycode == Common::KEYCODE_SPACE
+ || (currKeyState.keycode != Common::KEYCODE_INVALID
+ && ( (currKeyState.ascii >= 'a' && currKeyState.ascii <= 'z')
+ || (currKeyState.ascii >= 'A' && currKeyState.ascii <= 'Z')
+ || (currKeyState.ascii >= '0' && currKeyState.ascii <= '9')));
+}
+
void BladeRunnerEngine::handleEvents() {
if (shouldQuit()) {
_gameIsRunning = false;
@@ -1291,9 +1309,9 @@ void BladeRunnerEngine::handleEvents() {
case Common::EVENT_KEYDOWN:
// Process the actual key press only and filter out repeats
if (!event.kbdRepeat) {
- // Only for Esc and Return keys, allow repeated firing emulation
+ // Only for some keys, allow repeated firing emulation
// First hit (fire) has a bigger delay (kKeyRepeatInitialDelay) before repeated events are fired from the same key
- if (event.kbd.keycode == Common::KEYCODE_ESCAPE || event.kbd.keycode == Common::KEYCODE_RETURN) {
+ if (isAllowedRepeatedKey(event.kbd.keycode)) {
_currentKeyDown = event.kbd.keycode;
_keyRepeatTimeLast = _time->currentSystem();
_keyRepeatTimeDelay = kKeyRepeatInitialDelay;
@@ -1339,7 +1357,7 @@ void BladeRunnerEngine::handleEvents() {
// Some of those may lead to their own internal gameTick() loops (which will call handleEvents()).
// Thus, we need to get a new timeNow value here to ensure we're not comparing with a stale version.
uint32 timeNow = _time->currentSystem();
- if ((_currentKeyDown == Common::KEYCODE_ESCAPE || _currentKeyDown == Common::KEYCODE_RETURN)
+ if (isAllowedRepeatedKey(_currentKeyDown)
&& (timeNow - _keyRepeatTimeLast >= _keyRepeatTimeDelay)) {
// create a "new" keydown event
event.type = Common::EVENT_KEYDOWN;
diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h
index 2c4a10a25a6..cc663c23e61 100644
--- a/engines/bladerunner/bladerunner.h
+++ b/engines/bladerunner/bladerunner.h
@@ -324,6 +324,8 @@ public:
void handleMouseClick3DObject(int objectId, bool buttonDown, bool isClickable, bool isTarget);
void handleMouseClickEmpty(int x, int y, Vector3 &scenePosition, bool buttonDown);
+ bool isAllowedRepeatedKey(const Common::KeyState &currKeyState);
+
void gameWaitForActive();
void loopActorSpeaking();
void loopQueuedDialogueStillPlaying();
diff --git a/engines/bladerunner/ui/kia_section_save.cpp b/engines/bladerunner/ui/kia_section_save.cpp
index ae738b4c788..8cc26cf5b00 100644
--- a/engines/bladerunner/ui/kia_section_save.cpp
+++ b/engines/bladerunner/ui/kia_section_save.cpp
@@ -229,7 +229,10 @@ void KIASectionSave::handleKeyUp(const Common::KeyState &kbd) {
void KIASectionSave::handleKeyDown(const Common::KeyState &kbd) {
if (_state == kStateNormal) {
- if (kbd.keycode == Common::KEYCODE_DELETE && _selectedLineId != _newSaveLineId) {
+ // Delete a saved game entry either with Delete key or numpad's (keypad's) Del key (when Num Lock Off)
+ if (_selectedLineId != _newSaveLineId
+ && ( kbd.keycode == Common::KEYCODE_DELETE
+ || (kbd.keycode == Common::KEYCODE_KP_PERIOD && !(kbd.flags & Common::KBD_NUM)))) {
changeState(kStateDelete);
}
_uiContainer->handleKeyDown(kbd);
Commit: ddfa41b327243f5b640d704340f70943f15b507a
https://github.com/scummvm/scummvm/commit/ddfa41b327243f5b640d704340f70943f15b507a
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2022-02-15T18:05:52+02:00
Commit Message:
BLADERUNNER: Fix for warning of adding \0 to String
This was happening in the KIA save screen's input box when attempting to encode the key pressed to Dos850 charset
Changed paths:
engines/bladerunner/ui/ui_input_box.cpp
diff --git a/engines/bladerunner/ui/ui_input_box.cpp b/engines/bladerunner/ui/ui_input_box.cpp
index fe15285e8b3..9aca44b1275 100644
--- a/engines/bladerunner/ui/ui_input_box.cpp
+++ b/engines/bladerunner/ui/ui_input_box.cpp
@@ -87,18 +87,24 @@ void UIInputBox::hide() {
}
void UIInputBox::handleKeyDown(const Common::KeyState &kbd) {
- // The values that the KeyState::ascii field receives from the SDL backend are actually ISO 8859-1 encoded. They need to be
- // reencoded to DOS so as to match the game font encoding (although we currently use UIInputBox::charIsValid() to block most
- // extra characters, so it might not make much of a difference).
- char kc = Common::U32String(Common::String::format("%c", kbd.ascii), Common::kISO8859_1).encode(Common::kDos850).firstChar();
- if (_isVisible) {
- if (charIsValid(kc) && _text.size() < _maxLength) {
- _text += kc;
- } else if (kbd.keycode == Common::KEYCODE_BACKSPACE) {
- _text.deleteLastChar();
- } else if (kbd.keycode == Common::KEYCODE_RETURN && !_text.empty()) {
- if (_valueChangedCallback) {
- _valueChangedCallback(_callbackData, this);
+ if (kbd.ascii != 0) {
+ // The above check for kbd.ascii > 0 gets rid of the tentative warning:
+ // "Adding \0 to String. This is permitted, but can have unwanted consequences."
+ // which was triggered by the .encode(Common::kDos850) operation below.
+ //
+ // The values that the KeyState::ascii field receives from the SDL backend are actually ISO 8859-1 encoded. They need to be
+ // reencoded to DOS so as to match the game font encoding (although we currently use UIInputBox::charIsValid() to block most
+ // extra characters, so it might not make much of a difference).
+ char kc = Common::U32String(Common::String::format("%c", kbd.ascii), Common::kISO8859_1).encode(Common::kDos850).firstChar();
+ if (_isVisible) {
+ if (charIsValid(kc) && _text.size() < _maxLength) {
+ _text += kc;
+ } else if (kbd.keycode == Common::KEYCODE_BACKSPACE) {
+ _text.deleteLastChar();
+ } else if (kbd.keycode == Common::KEYCODE_RETURN && !_text.empty()) {
+ if (_valueChangedCallback) {
+ _valueChangedCallback(_callbackData, this);
+ }
}
}
}
More information about the Scummvm-git-logs
mailing list