[Scummvm-git-logs] scummvm master -> 3717adb787704731e0b660f66ed107e397ebcd6f
dreammaster
noreply at scummvm.org
Sat Feb 25 06:21:09 UTC 2023
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:
c1ec746a73 MM: MM1: Fix positioning of Y/N buttons
3717adb787 MM: MM1: Improve message display
Commit: c1ec746a7357c3446ff47d0254b7302bb6ab6b89
https://github.com/scummvm/scummvm/commit/c1ec746a7357c3446ff47d0254b7302bb6ab6b89
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-24T22:21:03-08:00
Commit Message:
MM: MM1: Fix positioning of Y/N buttons
Changed paths:
engines/mm/mm1/views_enh/game_messages.cpp
diff --git a/engines/mm/mm1/views_enh/game_messages.cpp b/engines/mm/mm1/views_enh/game_messages.cpp
index 2edcd8bde2f..7b32b8cfa83 100644
--- a/engines/mm/mm1/views_enh/game_messages.cpp
+++ b/engines/mm/mm1/views_enh/game_messages.cpp
@@ -31,12 +31,10 @@ namespace ViewsEnh {
GameMessages::YesNo::YesNo() :
ScrollView("MessagesYesNo", g_events) {
- _bounds = Common::Rect(234, 18 * 8, 320, 200);
- addButton(&g_globals->_confirmIcons,
- Common::Point(14, 10), 0,
+ _bounds = Common::Rect(234, 144, 320, 200);
+ addButton(&g_globals->_confirmIcons, Common::Point(0, 0), 0,
Common::KeyState(Common::KEYCODE_y, 'y'));
- addButton(&g_globals->_confirmIcons,
- Common::Point(40, 10), 2,
+ addButton(&g_globals->_confirmIcons, Common::Point(26, 0), 2,
Common::KeyState(Common::KEYCODE_n, 'n'));
}
Commit: 3717adb787704731e0b660f66ed107e397ebcd6f
https://github.com/scummvm/scummvm/commit/3717adb787704731e0b660f66ed107e397ebcd6f
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2023-02-24T22:21:03-08:00
Commit Message:
MM: MM1: Improve message display
Changed paths:
devtools/create_mm/files/mm1/strings_en.yml
engines/mm/mm1/globals.cpp
engines/mm/mm1/globals.h
engines/mm/mm1/messages.cpp
engines/mm/mm1/messages.h
engines/mm/mm1/views_enh/scroll_text.cpp
diff --git a/devtools/create_mm/files/mm1/strings_en.yml b/devtools/create_mm/files/mm1/strings_en.yml
index 235a7abe9f3..320acefb2f0 100644
--- a/devtools/create_mm/files/mm1/strings_en.yml
+++ b/devtools/create_mm/files/mm1/strings_en.yml
@@ -1089,7 +1089,7 @@ maps:
temple: "Temple Moonshadow"
training: "Otto's Training"
- blacksmith_inside: "A man wearing a leather apron speaks:\n\"Distinguished travelers, you''ve come tothe right place. Can i help you (Y/N)?\""
+ blacksmith_inside: "A man wearing a leather apron speaks:\n\"Distinguished travelers, you've come to\nthe right place. Can I help you (Y/N)?\""
inn_inside: "The innekeeper asks: \"Would you like to sign in (Y/N)?\""
market_inside: "Behind the counter, an overweight dwarf\nexclaims: \"You look like a hungry bunch!\nWould you like to buy some food (Y/N)?\""
temple_inside: "Several orantely robed clerics approach\nthe party and ask, \"Do you seek our help (Y/N)?\""
diff --git a/engines/mm/mm1/globals.cpp b/engines/mm/mm1/globals.cpp
index dd5cf394b6f..a23a56bdea2 100644
--- a/engines/mm/mm1/globals.cpp
+++ b/engines/mm/mm1/globals.cpp
@@ -24,6 +24,7 @@
#include "mm/mm1/globals.h"
#include "mm/mm1/mm1.h"
#include "mm/shared/utils/engine_data.h"
+#include "mm/shared/utils/strings.h"
#include "graphics/fontman.h"
namespace MM {
@@ -96,8 +97,10 @@ bool Globals::load(bool isEnhanced) {
return true;
}
-const Common::String &Globals::operator[](const Common::String &name) {
- if (g_engine->isEnhanced() && name.hasPrefix("maps.map")) {
+Common::String Globals::operator[](const Common::String &name) const {
+ bool isMapStr = g_engine->isEnhanced() && name.hasPrefix("maps.map");
+
+ if (isMapStr) {
// Map strings support having alternate versions in Enhanced version
Common::String altName = Common::String::format("maps.emap%s",
name.c_str() + 8);
@@ -106,7 +109,12 @@ const Common::String &Globals::operator[](const Common::String &name) {
}
assert(_strings.contains(name));
- return _strings[name];
+ Common::String result = _strings[name];
+
+ if (isMapStr)
+ result = searchAndReplace(result, "\n", " ");
+
+ return result;
}
diff --git a/engines/mm/mm1/globals.h b/engines/mm/mm1/globals.h
index 8efaf7aff94..7163d8e574d 100644
--- a/engines/mm/mm1/globals.h
+++ b/engines/mm/mm1/globals.h
@@ -85,7 +85,7 @@ public:
/**
* Returns a string
*/
- const Common::String &operator[](const Common::String &name);
+ Common::String operator[](const Common::String &name) const;
/**
* Saves global data to/from savegames
diff --git a/engines/mm/mm1/messages.cpp b/engines/mm/mm1/messages.cpp
index 913720f99e8..e1378ff551f 100644
--- a/engines/mm/mm1/messages.cpp
+++ b/engines/mm/mm1/messages.cpp
@@ -20,6 +20,7 @@
*/
#include "mm/mm1/messages.h"
+#include "mm/mm1/mm1.h"
namespace MM {
namespace MM1 {
@@ -105,5 +106,22 @@ size_t Line::size() const {
return _text.size();
}
+SoundMessage::SoundMessage(const Common::String &str, TextAlign align) :
+ InfoMessage(0, g_engine->isEnhanced() ? 0 : 1, str, align) {
+ _sound = true;
+}
+
+SoundMessage::SoundMessage(const Common::String &str,
+ YNCallback ynCallback) :
+ InfoMessage(0, g_engine->isEnhanced() ? 0 : 1, str, ynCallback) {
+ _sound = true;
+}
+
+SoundMessage::SoundMessage(const Common::String &str,
+ KeyCallback keyCallback) :
+ InfoMessage(0, g_engine->isEnhanced() ? 0 : 1, str, keyCallback) {
+ _sound = true;
+}
+
} // namespace MM1
} // namespace MM
diff --git a/engines/mm/mm1/messages.h b/engines/mm/mm1/messages.h
index 017a86667fe..e0397f2ee19 100644
--- a/engines/mm/mm1/messages.h
+++ b/engines/mm/mm1/messages.h
@@ -153,8 +153,7 @@ struct InfoMessage : public Message {
struct SoundMessage : public InfoMessage {
public:
SoundMessage() : InfoMessage() { _sound = true; }
- SoundMessage(const Common::String &str, TextAlign align = ALIGN_LEFT) :
- InfoMessage(0, 1, str, align) { _sound = true; }
+ SoundMessage(const Common::String &str, TextAlign align = ALIGN_LEFT);
SoundMessage(int x, int y, const Common::String &str,
TextAlign align = ALIGN_LEFT) :
InfoMessage(x, y, str, align) { _sound = true; }
@@ -162,9 +161,7 @@ public:
int x2, int y2, const Common::String &str2) :
InfoMessage(x1, y1, str1, x2, y2, str2) { _sound = true; }
- SoundMessage(const Common::String &str,
- YNCallback ynCallback) :
- InfoMessage(0, 1, str, ynCallback) { _sound = true; }
+ SoundMessage(const Common::String &str, YNCallback ynCallback);
SoundMessage(int x, int y, const Common::String &str,
YNCallback ynCallback) :
InfoMessage(x, y, str, ynCallback) { _sound = true; }
@@ -173,9 +170,7 @@ public:
YNCallback ynCallback) :
InfoMessage(x1, y1, str1, x2, y2, str2, ynCallback) { _sound = true; }
- SoundMessage(const Common::String &str,
- KeyCallback keyCallback) :
- InfoMessage(0, 1, str, keyCallback) { _sound = true; }
+ SoundMessage(const Common::String &str, KeyCallback keyCallback);
SoundMessage(int x, int y, const Common::String &str,
KeyCallback keyCallback) :
InfoMessage(x, y, str, keyCallback) { _sound = true; }
diff --git a/engines/mm/mm1/views_enh/scroll_text.cpp b/engines/mm/mm1/views_enh/scroll_text.cpp
index 921305503ce..a78e344de31 100644
--- a/engines/mm/mm1/views_enh/scroll_text.cpp
+++ b/engines/mm/mm1/views_enh/scroll_text.cpp
@@ -61,66 +61,18 @@ void ScrollText::addLine(const Common::String &str,
void ScrollText::addText(const Common::String &s,
int lineNum, byte color, TextAlign align, int xp) {
+ const int LINE_HEIGHT = 10;
Common::String str = s;
- Common::Point pt(xp, lineNum * 8);
+ Common::Point pt(xp, lineNum * LINE_HEIGHT);
Graphics::Font &font = _fontReduced ?
g_globals->_fontReduced : g_globals->_fontNormal;
- int strWidth = font.getStringWidth(str);
- char *startP = const_cast<char *>(str.c_str());
- char *endP;
+ // Split the lines
+ Common::StringArray lines = splitLines(s);
- switch (align) {
- case ALIGN_LEFT:
- // We have extra logic for standard left aligned strings to
- // insert extra newlines as necessary to word-wrap any text
- // that would go over the edge of the dialog
- while (*startP && strWidth > _innerBounds.width()) {
- // Find the last space before a full line
- endP = startP + strlen(startP) - 1;
- while (strWidth > _innerBounds.width()) {
- // Move back to a prior space
- for (--endP; endP > startP && *endP != ' '; --endP) {
- }
- assert(endP > startP);
-
- strWidth = font.getStringWidth(
- Common::String(startP, endP));
- }
-
- if (strWidth == _innerBounds.width()) {
- // Word break exactly at the line end.
- // So simply get rid of the space
- uint i = (const char *)endP - str.c_str();
- str.deleteChar(i);
- startP = const_cast<char *>(str.c_str() + i);
- } else {
- // Add a newline
- *endP = '\n';
- startP = endP + 1;
- }
-
- strWidth = font.getStringWidth(startP);
- }
- break;
-
- case ALIGN_MIDDLE:
- // Middle alignment
- if (xp == 0)
- xp = _innerBounds.width() / 2;
- pt.x = xp - strWidth / 2;
- break;
-
- case ALIGN_RIGHT:
- // Right alignment
- if (xp == 0)
- xp = _innerBounds.width();
- pt.x = xp - strWidth;
- break;
- }
-
- if (!str.empty())
- _lines.push_back(Line(str, pt, color));
+ // Add them in
+ for (uint i = 0; i < lines.size(); ++i, ++lineNum, pt.y += LINE_HEIGHT)
+ _lines.push_back(Line(lines[i], pt, color));
}
void ScrollText::draw() {
More information about the Scummvm-git-logs
mailing list