[Scummvm-git-logs] scummvm master -> 7e05309077db3c3f1407d10484fc5ee6b1416730
criezy
criezy at scummvm.org
Tue Sep 8 20:25:50 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
54f825359f COMMON: Allow using U32String::format with a C string format string
c5ede297ea JANITORIAL: Simplify some code that use U32String::format
7e05309077 KEYMAPPER: Translate hardware input description
Commit: 54f825359ff829429d7e0a0c2b5b88d92023f92f
https://github.com/scummvm/scummvm/commit/54f825359ff829429d7e0a0c2b5b88d92023f92f
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2020-09-08T21:22:04+01:00
Commit Message:
COMMON: Allow using U32String::format with a C string format string
Changed paths:
common/ustr.cpp
common/ustr.h
diff --git a/common/ustr.cpp b/common/ustr.cpp
index b6a8a6c008..1da58dffe6 100644
--- a/common/ustr.cpp
+++ b/common/ustr.cpp
@@ -639,6 +639,18 @@ U32String U32String::format(U32String fmt, ...) {
return output;
}
+U32String U32String::format(const char *fmt, ...) {
+ U32String output;
+
+ Common::U32String fmtU32(fmt);
+ va_list va;
+ va_start(va, fmt);
+ U32String::vformat(fmtU32.begin(), fmtU32.end(), output, va);
+ va_end(va);
+
+ return output;
+}
+
int U32String::vformat(U32String::const_iterator fmt, const U32String::const_iterator inputItrEnd, U32String &output, va_list args) {
int int_temp;
char *string_temp;
diff --git a/common/ustr.h b/common/ustr.h
index 45c3c31abd..261894bdfd 100644
--- a/common/ustr.h
+++ b/common/ustr.h
@@ -253,6 +253,7 @@ public:
* Print formatted data into a U32String object.
*/
static U32String format(U32String fmt, ...);
+ static U32String format(const char *fmt, ...);
/**
* Print formatted data into a U32String object. It takes in the
Commit: c5ede297ea549ba9dd023fa3a6c6a67cde29bbab
https://github.com/scummvm/scummvm/commit/c5ede297ea549ba9dd023fa3a6c6a67cde29bbab
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2020-09-08T21:24:27+01:00
Commit Message:
JANITORIAL: Simplify some code that use U32String::format
Changed paths:
backends/graphics/openglsdl/openglsdl-graphics.cpp
backends/graphics/surfacesdl/surfacesdl-graphics.cpp
common/achievements.cpp
gui/options.cpp
diff --git a/backends/graphics/openglsdl/openglsdl-graphics.cpp b/backends/graphics/openglsdl/openglsdl-graphics.cpp
index 30e1807fa9..b4857989f7 100644
--- a/backends/graphics/openglsdl/openglsdl-graphics.cpp
+++ b/backends/graphics/openglsdl/openglsdl-graphics.cpp
@@ -659,7 +659,7 @@ bool OpenGLSdlGraphicsManager::notifyEvent(const Common::Event &event) {
endGFXTransaction();
#ifdef USE_OSD
- Common::U32String message = Common::U32String::format(Common::U32String("%S: %S"),
+ Common::U32String message = Common::U32String::format("%S: %S",
_("Stretch mode").c_str(),
_(stretchModes[index].description).c_str()
);
diff --git a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
index 9f58f2be23..2ba3cb4e5a 100644
--- a/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
+++ b/backends/graphics/surfacesdl/surfacesdl-graphics.cpp
@@ -2465,7 +2465,7 @@ void SurfaceSdlGraphicsManager::handleScalerHotkeys(int scalefactor, int scalerT
}
if (newScalerName) {
const Common::U32String message = Common::U32String::format(
- Common::U32String("%S %s\n%d x %d -> %d x %d"),
+ "%S %s\n%d x %d -> %d x %d",
_("Active graphics filter:").c_str(),
newScalerName,
_videoMode.screenWidth, _videoMode.screenHeight,
@@ -2499,13 +2499,13 @@ bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) {
#ifdef USE_OSD
Common::U32String message;
if (_videoMode.aspectRatioCorrection)
- message = Common::U32String::format(Common::U32String("%S\n%d x %d -> %d x %d"),
+ message = Common::U32String::format("%S\n%d x %d -> %d x %d",
_("Enabled aspect ratio correction").c_str(),
_videoMode.screenWidth, _videoMode.screenHeight,
_hwScreen->w, _hwScreen->h
);
else
- message = Common::U32String::format(Common::U32String("%S\n%d x %d -> %d x %d"),
+ message = Common::U32String::format("%S\n%d x %d -> %d x %d",
_("Disabled aspect ratio correction").c_str(),
_videoMode.screenWidth, _videoMode.screenHeight,
_hwScreen->w, _hwScreen->h
@@ -2552,7 +2552,7 @@ bool SurfaceSdlGraphicsManager::notifyEvent(const Common::Event &event) {
endGFXTransaction();
#ifdef USE_OSD
- Common::U32String message = Common::U32String::format(Common::U32String("%S: %S"),
+ Common::U32String message = Common::U32String::format("%S: %S",
_("Stretch mode").c_str(),
_(s_supportedStretchModes[index].description).c_str()
);
diff --git a/common/achievements.cpp b/common/achievements.cpp
index 1aee276917..3e473526b1 100644
--- a/common/achievements.cpp
+++ b/common/achievements.cpp
@@ -89,7 +89,7 @@ bool AchievementsManager::setAchievement(const String &id, const String &display
if (!displayedMessage.empty() && g_system) {
U32String msg;
- msg = Common::U32String::format(Common::U32String("%S\n%S"),
+ msg = Common::U32String::format("%S\n%S",
_("Achievement unlocked!").c_str(),
Common::U32String(displayedMessage).c_str()
);
diff --git a/gui/options.cpp b/gui/options.cpp
index 533bd4e2af..53bdda5b8e 100644
--- a/gui/options.cpp
+++ b/gui/options.cpp
@@ -2810,7 +2810,7 @@ void GlobalOptionsDialog::setupCloudTab() {
uint64 usedSpace = CloudMan.getStorageUsedSpace(_selectedStorageIndex);
Common::String usedSpaceNumber, usedSpaceUnits;
usedSpaceNumber = Common::getHumanReadableBytes(usedSpace, usedSpaceUnits);
- _storageUsedSpace->setLabel(Common::U32String::format(Common::U32String("%s %S"), usedSpaceNumber.c_str(), _(usedSpaceUnits).c_str()));
+ _storageUsedSpace->setLabel(Common::U32String::format("%s %S", usedSpaceNumber.c_str(), _(usedSpaceUnits).c_str()));
_storageUsedSpace->setVisible(shownConnectedInfo);
}
if (_storageSyncHint) {
Commit: 7e05309077db3c3f1407d10484fc5ee6b1416730
https://github.com/scummvm/scummvm/commit/7e05309077db3c3f1407d10484fc5ee6b1416730
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2020-09-08T21:25:02+01:00
Commit Message:
KEYMAPPER: Translate hardware input description
The strings were already marked for translation, but were not actually
translated.
Changed paths:
backends/keymapper/hardware-input.cpp
backends/keymapper/hardware-input.h
backends/keymapper/keymap.cpp
backends/keymapper/remap-widget.cpp
diff --git a/backends/keymapper/hardware-input.cpp b/backends/keymapper/hardware-input.cpp
index d6227c30ef..f3e6c7923f 100644
--- a/backends/keymapper/hardware-input.cpp
+++ b/backends/keymapper/hardware-input.cpp
@@ -297,7 +297,7 @@ HardwareInput KeyboardHardwareInputSet::findHardwareInput(const String &id) cons
byte modifierFlags = 0;
// TODO: Normalize modifier order
- String fullKeyDesc;
+ U32String fullKeyDesc;
String token;
while (!tokenizer.empty()) {
@@ -312,7 +312,7 @@ HardwareInput KeyboardHardwareInputSet::findHardwareInput(const String &id) cons
if (modifier && modifier->id) {
modifierFlags |= modifier->flag;
- fullKeyDesc += modifier->desc;
+ fullKeyDesc += _(modifier->desc);
} else {
// We reached the end of the modifiers, the token is a keycode
break;
@@ -335,7 +335,7 @@ HardwareInput KeyboardHardwareInputSet::findHardwareInput(const String &id) cons
}
const KeyState keystate = KeyState(key->keycode, 0, modifierFlags);
- return HardwareInput::createKeyboard(id, keystate, fullKeyDesc + key->desc);
+ return HardwareInput::createKeyboard(id, keystate, fullKeyDesc + _(key->desc));
}
HardwareInput KeyboardHardwareInputSet::findHardwareInput(const Event &event) const {
@@ -356,20 +356,20 @@ HardwareInput KeyboardHardwareInputSet::findHardwareInput(const Event &event) co
}
String id;
- String fullKeyDesc;
+ U32String fullKeyDesc;
byte modifierFlags = 0;
for (const ModifierTableEntry *modifier = _modifiers; modifier->id; modifier++) {
if (normalizedKeystate.flags & modifier->flag) {
id += modifier->id;
id += "+";
- fullKeyDesc += modifier->desc;
+ fullKeyDesc += _(modifier->desc);
modifierFlags |= modifier->flag;
}
}
const KeyState keystate = KeyState(key->keycode, 0, modifierFlags);
- return HardwareInput::createKeyboard(id + key->hwId, keystate, fullKeyDesc + key->desc);
+ return HardwareInput::createKeyboard(id + key->hwId, keystate, fullKeyDesc + _(key->desc));
}
default:
return HardwareInput();
@@ -431,7 +431,7 @@ HardwareInput MouseHardwareInputSet::findHardwareInput(const String &id) const {
return HardwareInput();
}
- return HardwareInput::createMouse(hw->hwId, hw->code, hw->desc);
+ return HardwareInput::createMouse(hw->hwId, hw->code, _(hw->desc));
}
HardwareInput MouseHardwareInputSet::findHardwareInput(const Event &event) const {
@@ -477,7 +477,7 @@ HardwareInput MouseHardwareInputSet::findHardwareInput(const Event &event) const
return HardwareInput();
}
- return HardwareInput::createMouse(hw->hwId, hw->code, hw->desc);
+ return HardwareInput::createMouse(hw->hwId, hw->code, _(hw->desc));
}
JoystickHardwareInputSet::JoystickHardwareInputSet(const HardwareInputTableEntry *buttonEntries, const AxisTableEntry *axisEntries) :
@@ -490,7 +490,7 @@ JoystickHardwareInputSet::JoystickHardwareInputSet(const HardwareInputTableEntry
HardwareInput JoystickHardwareInputSet::findHardwareInput(const String &id) const {
const HardwareInputTableEntry *hw = HardwareInputTableEntry::findWithId(_buttonEntries, id);
if (hw && hw->hwId) {
- return HardwareInput::createJoystickButton(hw->hwId, hw->code, hw->desc);
+ return HardwareInput::createJoystickButton(hw->hwId, hw->code, _(hw->desc));
}
bool hasHalfSuffix = id.lastChar() == '-' || id.lastChar() == '+';
@@ -504,10 +504,10 @@ HardwareInput JoystickHardwareInputSet::findHardwareInput(const String &id) cons
}
if (axis->type == kAxisTypeHalf) {
- return HardwareInput::createJoystickHalfAxis(axis->hwId, axis->code, true, axis->desc);
+ return HardwareInput::createJoystickHalfAxis(axis->hwId, axis->code, true, _(axis->desc));
} else {
bool positiveHalf = id.lastChar() == '+';
- Common::String desc = String::format("%s%c", axis->desc, id.lastChar());
+ Common::U32String desc = U32String::format("%S%c", _(axis->desc).c_str(), id.lastChar());
return HardwareInput::createJoystickHalfAxis(id, axis->code, positiveHalf, desc);
}
}
@@ -524,7 +524,7 @@ HardwareInput JoystickHardwareInputSet::findHardwareInput(const Event &event) co
return HardwareInput();
}
- return HardwareInput::createJoystickButton(hw->hwId, hw->code, hw->desc);
+ return HardwareInput::createJoystickButton(hw->hwId, hw->code, _(hw->desc));
}
case EVENT_JOYAXIS_MOTION: {
if (ABS(event.joystick.position) < (JOYAXIS_MAX / 2)) {
@@ -537,12 +537,12 @@ HardwareInput JoystickHardwareInputSet::findHardwareInput(const Event &event) co
}
if (hw->type == kAxisTypeHalf) {
- return HardwareInput::createJoystickHalfAxis(hw->hwId, hw->code, true, hw->desc);
+ return HardwareInput::createJoystickHalfAxis(hw->hwId, hw->code, true, _(hw->desc));
} else {
bool positiveHalf = event.joystick.position >= 0;
char halfSuffix = positiveHalf ? '+' : '-';
Common::String hwId = String::format("%s%c", hw->hwId, halfSuffix);
- Common::String desc = String::format("%s%c", hw->desc, halfSuffix);
+ Common::U32String desc = U32String::format("%S%c", _(hw->desc).c_str(), halfSuffix);
return HardwareInput::createJoystickHalfAxis(hwId, hw->code, positiveHalf, desc);
}
}
@@ -563,7 +563,7 @@ HardwareInput CustomHardwareInputSet::findHardwareInput(const String &id) const
return HardwareInput();
}
- return HardwareInput::createCustom(hw->hwId, hw->code, hw->desc);
+ return HardwareInput::createCustom(hw->hwId, hw->code, _(hw->desc));
}
HardwareInput CustomHardwareInputSet::findHardwareInput(const Event &event) const {
@@ -574,7 +574,7 @@ HardwareInput CustomHardwareInputSet::findHardwareInput(const Event &event) cons
return HardwareInput();
}
- return HardwareInput::createCustom(hw->hwId, hw->code, hw->desc);
+ return HardwareInput::createCustom(hw->hwId, hw->code, _(hw->desc));
}
default:
return HardwareInput();
diff --git a/backends/keymapper/hardware-input.h b/backends/keymapper/hardware-input.h
index c72f93758d..d15953e8e4 100644
--- a/backends/keymapper/hardware-input.h
+++ b/backends/keymapper/hardware-input.h
@@ -57,7 +57,7 @@ struct HardwareInput {
String id;
/** Human readable description */
- String description;
+ U32String description;
/** Type tag */
HardwareInputType type;
@@ -79,11 +79,11 @@ struct HardwareInput {
HardwareInput()
: inputCode(0), type(kHardwareInputTypeInvalid) { }
- static HardwareInput createCustom(const String &i, HardwareInputCode ic, const String &desc) {
+ static HardwareInput createCustom(const String &i, HardwareInputCode ic, const U32String &desc) {
return createSimple(kHardwareInputTypeCustom, i, ic, desc);
}
- static HardwareInput createKeyboard(const String &i, KeyState ky, const String &desc) {
+ static HardwareInput createKeyboard(const String &i, KeyState ky, const U32String &desc) {
HardwareInput hardwareInput;
hardwareInput.id = i;
hardwareInput.description = desc;
@@ -93,20 +93,20 @@ struct HardwareInput {
return hardwareInput;
}
- static HardwareInput createJoystickButton(const String &i, uint8 button, const String &desc) {
+ static HardwareInput createJoystickButton(const String &i, uint8 button, const U32String &desc) {
return createSimple(kHardwareInputTypeJoystickButton, i, button, desc);
}
- static HardwareInput createJoystickHalfAxis(const String &i, uint8 axis, bool positiveHalf, const String &desc) {
+ static HardwareInput createJoystickHalfAxis(const String &i, uint8 axis, bool positiveHalf, const U32String &desc) {
return createSimple(kHardwareInputTypeJoystickHalfAxis, i, axis * 2 + (positiveHalf ? 1 : 0), desc);
}
- static HardwareInput createMouse(const String &i, uint8 button, const String &desc) {
+ static HardwareInput createMouse(const String &i, uint8 button, const U32String &desc) {
return createSimple(kHardwareInputTypeMouse, i, button, desc);
}
private:
- static HardwareInput createSimple(HardwareInputType type, const String &i, HardwareInputCode ic, const String &desc) {
+ static HardwareInput createSimple(HardwareInputType type, const String &i, HardwareInputCode ic, const U32String &desc) {
HardwareInput hardwareInput;
hardwareInput.id = i;
hardwareInput.description = desc;
diff --git a/backends/keymapper/keymap.cpp b/backends/keymapper/keymap.cpp
index 3cbbc44f92..2d41247336 100644
--- a/backends/keymapper/keymap.cpp
+++ b/backends/keymapper/keymap.cpp
@@ -140,7 +140,7 @@ Keymap::KeymapMatch Keymap::getMappedActions(const Event &event, ActionArray &ac
case EVENT_KEYDOWN:
case EVENT_KEYUP: {
KeyState normalizedKeystate = KeyboardHardwareInputSet::normalizeKeyState(event.kbd);
- HardwareInput hardwareInput = HardwareInput::createKeyboard("", normalizedKeystate, "");
+ HardwareInput hardwareInput = HardwareInput::createKeyboard("", normalizedKeystate, U32String());
actions.push_back(_hwActionMap[hardwareInput]);
if (!actions.empty()) {
return kKeymapMatchExact;
@@ -161,7 +161,7 @@ Keymap::KeymapMatch Keymap::getMappedActions(const Event &event, ActionArray &ac
// Lastly check again for matches no non-sticky keyboard modifiers
normalizedKeystate.flags &= ~KBD_NON_STICKY;
- hardwareInput = HardwareInput::createKeyboard("", normalizedKeystate, "");
+ hardwareInput = HardwareInput::createKeyboard("", normalizedKeystate, U32String());
actions.push_back(_hwActionMap[hardwareInput]);
return actions.empty() ? kKeymapMatchNone : kKeymapMatchPartial;
}
@@ -169,66 +169,66 @@ Keymap::KeymapMatch Keymap::getMappedActions(const Event &event, ActionArray &ac
}
case EVENT_LBUTTONDOWN:
case EVENT_LBUTTONUP: {
- HardwareInput hardwareInput = HardwareInput::createMouse("", MOUSE_BUTTON_LEFT, "");
+ HardwareInput hardwareInput = HardwareInput::createMouse("", MOUSE_BUTTON_LEFT, U32String());
actions.push_back(_hwActionMap[hardwareInput]);
break;
}
case EVENT_RBUTTONDOWN:
case EVENT_RBUTTONUP: {
- HardwareInput hardwareInput = HardwareInput::createMouse("", MOUSE_BUTTON_RIGHT, "");
+ HardwareInput hardwareInput = HardwareInput::createMouse("", MOUSE_BUTTON_RIGHT, U32String());
actions.push_back(_hwActionMap[hardwareInput]);
break;
}
case EVENT_MBUTTONDOWN:
case EVENT_MBUTTONUP: {
- HardwareInput hardwareInput = HardwareInput::createMouse("", MOUSE_BUTTON_MIDDLE, "");
+ HardwareInput hardwareInput = HardwareInput::createMouse("", MOUSE_BUTTON_MIDDLE, U32String());
actions.push_back(_hwActionMap[hardwareInput]);
break;
}
case Common::EVENT_WHEELUP: {
- HardwareInput hardwareInput = HardwareInput::createMouse("", MOUSE_WHEEL_UP, "");
+ HardwareInput hardwareInput = HardwareInput::createMouse("", MOUSE_WHEEL_UP, U32String());
actions.push_back(_hwActionMap[hardwareInput]);
break;
}
case Common::EVENT_WHEELDOWN: {
- HardwareInput hardwareInput = HardwareInput::createMouse("", MOUSE_WHEEL_DOWN, "");
+ HardwareInput hardwareInput = HardwareInput::createMouse("", MOUSE_WHEEL_DOWN, U32String());
actions.push_back(_hwActionMap[hardwareInput]);
break;
}
case EVENT_X1BUTTONDOWN:
case EVENT_X1BUTTONUP: {
- HardwareInput hardwareInput = HardwareInput::createMouse("", MOUSE_BUTTON_X1, "");
+ HardwareInput hardwareInput = HardwareInput::createMouse("", MOUSE_BUTTON_X1, U32String());
actions.push_back(_hwActionMap[hardwareInput]);
break;
}
case EVENT_X2BUTTONDOWN:
case EVENT_X2BUTTONUP: {
- HardwareInput hardwareInput = HardwareInput::createMouse("", MOUSE_BUTTON_X2, "");
+ HardwareInput hardwareInput = HardwareInput::createMouse("", MOUSE_BUTTON_X2, U32String());
actions.push_back(_hwActionMap[hardwareInput]);
break;
}
case EVENT_JOYBUTTON_DOWN:
case EVENT_JOYBUTTON_UP: {
- HardwareInput hardwareInput = HardwareInput::createJoystickButton("", event.joystick.button, "");
+ HardwareInput hardwareInput = HardwareInput::createJoystickButton("", event.joystick.button, U32String());
actions.push_back(_hwActionMap[hardwareInput]);
break;
}
case EVENT_JOYAXIS_MOTION: {
if (event.joystick.position != 0) {
bool positiveHalf = event.joystick.position >= 0;
- HardwareInput hardwareInput = HardwareInput::createJoystickHalfAxis("", event.joystick.axis, positiveHalf, "");
+ HardwareInput hardwareInput = HardwareInput::createJoystickHalfAxis("", event.joystick.axis, positiveHalf, U32String());
actions.push_back(_hwActionMap[hardwareInput]);
} else {
// Axis position zero is part of both half axes, and triggers actions bound to both
- HardwareInput hardwareInputPos = HardwareInput::createJoystickHalfAxis("", event.joystick.axis, true, "");
- HardwareInput hardwareInputNeg = HardwareInput::createJoystickHalfAxis("", event.joystick.axis, false, "");
+ HardwareInput hardwareInputPos = HardwareInput::createJoystickHalfAxis("", event.joystick.axis, true, U32String());
+ HardwareInput hardwareInputNeg = HardwareInput::createJoystickHalfAxis("", event.joystick.axis, false, U32String());
actions.push_back(_hwActionMap[hardwareInputPos]);
actions.push_back(_hwActionMap[hardwareInputNeg]);
}
break;
}
case EVENT_CUSTOM_BACKEND_HARDWARE: {
- HardwareInput hardwareInput = HardwareInput::createCustom("", event.customType, "");
+ HardwareInput hardwareInput = HardwareInput::createCustom("", event.customType, U32String());
actions.push_back(_hwActionMap[hardwareInput]);
break;
}
diff --git a/backends/keymapper/remap-widget.cpp b/backends/keymapper/remap-widget.cpp
index 4c81b29258..594ac907dd 100644
--- a/backends/keymapper/remap-widget.cpp
+++ b/backends/keymapper/remap-widget.cpp
@@ -288,10 +288,10 @@ void RemapWidget::refreshKeymap() {
Array<HardwareInput> mappedInputs = row.keymap->getActionMapping(row.action);
- String keysLabel;
+ U32String keysLabel;
for (uint j = 0; j < mappedInputs.size(); j++) {
if (!keysLabel.empty()) {
- keysLabel += ", ";
+ keysLabel += Common::U32String(", ");
}
keysLabel += mappedInputs[j].description;
More information about the Scummvm-git-logs
mailing list