[Scummvm-git-logs] scummvm master -> 92e8988936274dddb6e1a460ec8bc152942d3d36
phcoder
phcoder at gmail.com
Sat Oct 31 23:18:24 UTC 2020
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:
92e8988936 HADESCH: Use U32String for hero and save name
Commit: 92e8988936274dddb6e1a460ec8bc152942d3d36
https://github.com/scummvm/scummvm/commit/92e8988936274dddb6e1a460ec8bc152942d3d36
Author: Vladimir Serbinenko (phcoder at google.com)
Date: 2020-11-01T00:05:09+01:00
Commit Message:
HADESCH: Use U32String for hero and save name
This doesn't have any immediate benefit as fonts have only 256
characters but it's a step in right direction.
Changed paths:
engines/hadesch/hadesch.h
engines/hadesch/persistent.cpp
engines/hadesch/persistent.h
engines/hadesch/rooms/options.cpp
engines/hadesch/rooms/walloffame.cpp
engines/hadesch/video.cpp
engines/hadesch/video.h
diff --git a/engines/hadesch/hadesch.h b/engines/hadesch/hadesch.h
index 4b1e485a2a..54a7110c0a 100644
--- a/engines/hadesch/hadesch.h
+++ b/engines/hadesch/hadesch.h
@@ -68,7 +68,7 @@ public:
virtual void handleMouseOver(const Common::String &name) {}
virtual void handleMouseOut(const Common::String &name) {}
virtual void frameCallback() {}
- virtual void handleKeypress(uint16 ucode) {}
+ virtual void handleKeypress(uint32 ucode) {}
virtual void prepareRoom() = 0;
virtual bool handleCheat(const Common::String &cheat) {
return false;
diff --git a/engines/hadesch/persistent.cpp b/engines/hadesch/persistent.cpp
index e0c30fe024..d034fb06e1 100644
--- a/engines/hadesch/persistent.cpp
+++ b/engines/hadesch/persistent.cpp
@@ -163,9 +163,17 @@ bool Persistent::isInInventory(InventoryItem item) {
HadeschSaveDescriptor::HadeschSaveDescriptor(Common::Serializer &s, int slot) {
s.matchBytes("hadesch", 7);
- s.syncVersion(1);
- s.syncString(_heroName);
- s.syncString(_slotName);
+ s.syncVersion(2);
+ if (s.getVersion() < 2) {
+ Common::String str;
+ s.syncString(str);
+ _heroName = str;
+ s.syncString(str);
+ _slotName = str;
+ } else {
+ s.syncString32(_heroName);
+ s.syncString32(_slotName);
+ }
s.syncAsByte(_room);
_slot = slot;
}
@@ -173,11 +181,19 @@ HadeschSaveDescriptor::HadeschSaveDescriptor(Common::Serializer &s, int slot) {
bool Persistent::syncGameStream(Common::Serializer &s) {
if(!s.matchBytes("hadesch", 7))
return false;
- if (!s.syncVersion(1))
+ if (!s.syncVersion(2))
return false;
- s.syncString(_heroName);
- s.syncString(_slotDescription);
+ if (s.getVersion() < 2) {
+ Common::String str;
+ s.syncString(str);
+ _heroName = str;
+ s.syncString(str);
+ _slotDescription = str;
+ } else {
+ s.syncString32(_heroName);
+ s.syncString32(_slotDescription);
+ }
s.syncAsByte(_currentRoomId);
s.syncAsByte(_previousRoomId);
diff --git a/engines/hadesch/persistent.h b/engines/hadesch/persistent.h
index 8f18a51f7b..b5f840d5ac 100644
--- a/engines/hadesch/persistent.h
+++ b/engines/hadesch/persistent.h
@@ -35,8 +35,8 @@ struct HadeschSaveDescriptor {
HadeschSaveDescriptor(Common::Serializer &s, int slot);
int _slot;
- Common::String _heroName;
- Common::String _slotName;
+ Common::U32String _heroName;
+ Common::U32String _slotName;
RoomId _room;
};
@@ -51,8 +51,8 @@ static const int inventorySize = 6;
struct Persistent {
// Generic
Gender _gender;
- Common::String _heroName;
- Common::String _slotDescription; // valid only in saves
+ Common::U32String _heroName;
+ Common::U32String _slotDescription; // valid only in saves
Quest _quest;
int _powerLevel[3];
RoomId _currentRoomId;
diff --git a/engines/hadesch/rooms/options.cpp b/engines/hadesch/rooms/options.cpp
index 1242de1e11..d4337f4e8f 100644
--- a/engines/hadesch/rooms/options.cpp
+++ b/engines/hadesch/rooms/options.cpp
@@ -279,7 +279,7 @@ public:
saveMenu(_saveVariant);
break;
case kDeleteUser: {
- Common::String username = _userNames[_selectedSave];
+ Common::U32String username = _userNames[_selectedSave];
for (unsigned i = 0; i < _saves.size(); i++)
if (_saves[i]._heroName == username)
g_vm->deleteSave(_saves[i]._slot);
@@ -373,7 +373,7 @@ public:
}
}
- void handleKeypress(uint16 ucode) override {
+ void handleKeypress(uint32 ucode) override {
Common::SharedPtr<VideoRoom> room = g_vm->getVideoRoom();
if (_currentMenu == kSaveMenu) {
if (ucode == '\n' || ucode == '\r') {
@@ -382,7 +382,7 @@ public:
}
if (ucode == '\b' && _typedSlotName.size() > 0) {
- _typedSlotName = _typedSlotName.substr(0, _typedSlotName.size() - 1);
+ _typedSlotName.deleteLastChar();
room->playSound("keyclick");
renderSaveName();
return;
@@ -416,9 +416,13 @@ private:
void performSave() {
int slot = g_vm->firstAvailableSlot();
Persistent *persistent = g_vm->getPersistent();
- Common::String desc = Common::String::format(
+ // UTF-8
+ Common::String descPos = Common::String::format(
saveDescs[persistent->_currentRoomId],
- persistent->_heroName.c_str());
+ persistent->_heroName.encode(Common::kUtf8).c_str());
+ // UTF-8
+ Common::String desc = _typedSlotName.empty() ? descPos
+ : _typedSlotName + " (" + descPos + ")";
persistent->_slotDescription = _typedSlotName;
Common::Error res = g_vm->saveGameState(slot, desc);
@@ -473,7 +477,7 @@ private:
void loadMenuUser() {
Common::SharedPtr<VideoRoom> room = g_vm->getVideoRoom();
- Common::HashMap<Common::String, bool> userset;
+ Common::HashMap<Common::U32String, bool> userset;
loadSaves();
_currentMenu = kLoadUserMenu;
@@ -510,7 +514,7 @@ private:
Common::SharedPtr<VideoRoom> room = g_vm->getVideoRoom();
bool selectedIsShown = false;
for (int i = 0; i < 6 && _showPos + i < (int) _userNames.size(); i++) {
- Common::String name = _userNames[_showPos + i];
+ Common::U32String name = _userNames[_showPos + i];
if (name == "")
name = "No name";
room->renderString("largeascii", name,
@@ -697,7 +701,7 @@ private:
_saves = g_vm->getHadeschSavesList();
}
- void loadFilteredSaves(const Common::String &heroname) {
+ void loadFilteredSaves(const Common::U32String &heroname) {
loadSaves();
_filteredSaves.clear();
for (unsigned i = 0; i < _saves.size(); i++)
@@ -716,9 +720,9 @@ private:
Common::Array<HadeschSaveDescriptor> _saves;
Common::Array<HadeschSaveDescriptor> _filteredSaves;
- Common::Array<Common::String> _userNames;
- Common::String _chosenName;
- Common::String _typedSlotName;
+ Common::Array<Common::U32String> _userNames;
+ Common::U32String _chosenName;
+ Common::U32String _typedSlotName;
int _showPos;
int _selectedSave;
bool _savesLoaded;
diff --git a/engines/hadesch/rooms/walloffame.cpp b/engines/hadesch/rooms/walloffame.cpp
index 14148f2701..a7a8a11e80 100644
--- a/engines/hadesch/rooms/walloffame.cpp
+++ b/engines/hadesch/rooms/walloffame.cpp
@@ -755,10 +755,10 @@ public:
playPhilVideo("phil good work", kPhilNewQuestScroll, Common::Point(40, 324)); // state 35
break;
case 19900:
- if (_gender != kUnknown && _heroName != "") {
+ if (_gender != kUnknown && !_heroName.empty()) {
break;
}
- if (_heroName != "") {
+ if (!_heroName.empty()) {
room->playVideo("phil pick a statue", 0, 19901);
break;
}
@@ -775,7 +775,7 @@ public:
}
}
- void handleKeypress(uint16 code) override {
+ void handleKeypress(uint32 code) override {
Common::SharedPtr<VideoRoom> room = g_vm->getVideoRoom();
if (_applicationIsActive && room->isMouseEnabled()) {
if (_heroName.size() < 18 &&
@@ -791,7 +791,7 @@ public:
}
if (_heroName.size() > 0 && code == '\b') {
- _heroName = _heroName.substr(0, _heroName.size() - 1);
+ _heroName.deleteLastChar();
room->playSound("application click");
renderNameInApplication();
computeEnter();
@@ -1118,7 +1118,7 @@ private:
bool _philIsOnTheRight;
int _philWalkPhase;
bool _philIsBusy;
- Common::String _heroName;
+ Common::U32String _heroName;
AmbientAnim _hercules;
bool _endGameOutro;
bool _applicationIsActive;
diff --git a/engines/hadesch/video.cpp b/engines/hadesch/video.cpp
index a079fe7649..9db8c63c1e 100644
--- a/engines/hadesch/video.cpp
+++ b/engines/hadesch/video.cpp
@@ -970,7 +970,7 @@ void VideoRoom::hideString(const Common::String &font, size_t maxLen, const Comm
}
}
-void VideoRoom::renderString(const Common::String &font, const Common::String &str, Common::Point startPos, int zVal, int fontDelta, const Common::String &extraId) {
+void VideoRoom::renderString(const Common::String &font, const Common::U32String &str, Common::Point startPos, int zVal, int fontDelta, const Common::String &extraId) {
Common::Point curPos = startPos;
bool small = font == "smallascii";
for (unsigned i = 0; i < str.size(); i++) {
@@ -1008,7 +1008,7 @@ void VideoRoom::loadFontWidth(const Common::String &font) {
_fontWidths[font].push_back(pi[i].getWidth()+pi[i].getOffset().x + (small ? 1 : 3));
}
-int VideoRoom::computeStringWidth(const Common::String &font, const Common::String &str, int fontDelta) {
+int VideoRoom::computeStringWidth(const Common::String &font, const Common::U32String &str, int fontDelta) {
int width = 0;
bool small = font == "smallascii";
if (!_fontWidths.contains(font)) {
@@ -1027,7 +1027,7 @@ int VideoRoom::computeStringWidth(const Common::String &font, const Common::Stri
return width;
}
-void VideoRoom::renderStringCentered(const Common::String &font, const Common::String &str, Common::Point centerPos, int zVal, int fontDelta, const Common::String &extraId) {
+void VideoRoom::renderStringCentered(const Common::String &font, const Common::U32String &str, Common::Point centerPos, int zVal, int fontDelta, const Common::String &extraId) {
int width = computeStringWidth(font, str, fontDelta);
renderString(font, str, centerPos - Common::Point(width / 2, 0), zVal, fontDelta, extraId);
}
diff --git a/engines/hadesch/video.h b/engines/hadesch/video.h
index c13ae1809a..09a53f2b9c 100644
--- a/engines/hadesch/video.h
+++ b/engines/hadesch/video.h
@@ -248,12 +248,12 @@ public:
}
// Font
- void renderString(const Common::String &font, const Common::String &str,
+ void renderString(const Common::String &font, const Common::U32String &str,
Common::Point startPos, int zVal, int fontDelta = 0, const Common::String &extraId = "letter");
- void renderStringCentered(const Common::String &font, const Common::String &str,
+ void renderStringCentered(const Common::String &font, const Common::U32String &str,
Common::Point centerPos, int zVal, int fontDelta = 0, const Common::String &extraId = "letter");
void hideString(const Common::String &font, size_t maxLen, const Common::String &extraId = "letter");
- int computeStringWidth(const Common::String &font, const Common::String &str, int fontDelta = 0);
+ int computeStringWidth(const Common::String &font, const Common::U32String &str, int fontDelta = 0);
// Misc
void playSound(const Common::String &soundName,
More information about the Scummvm-git-logs
mailing list