[Scummvm-git-logs] scummvm master -> f7ed3253001652bb36526ddac937b4bfe3efd01c
neuromancer
noreply at scummvm.org
Fri Nov 14 10:37:32 UTC 2025
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
a943bca6a5 HYPNO: only render subtitles when they are needed and properly adjust size of them
f7ed325300 PRIVATE: properly adjust subtitle size without using magic constants
Commit: a943bca6a59db1da6ab26cd7291a51f155167703
https://github.com/scummvm/scummvm/commit/a943bca6a59db1da6ab26cd7291a51f155167703
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2025-11-14T11:27:25+01:00
Commit Message:
HYPNO: only render subtitles when they are needed and properly adjust size of them
Changed paths:
engines/hypno/hypno.cpp
engines/hypno/hypno.h
diff --git a/engines/hypno/hypno.cpp b/engines/hypno/hypno.cpp
index f33adab007f..b1e52e168e4 100644
--- a/engines/hypno/hypno.cpp
+++ b/engines/hypno/hypno.cpp
@@ -58,7 +58,7 @@ HypnoEngine::HypnoEngine(OSystem *syst, const ADGameDescription *gd)
_playerFrameIdx(0), _playerFrameSep(0), _refreshConversation(false),
_countdown(0), _timerStarted(false), _score(0), _bonus(0), _lives(0),
_defaultCursor(""), _defaultCursorIdx(0), _skipDefeatVideo(false),
- _background(nullptr), _masks(nullptr),
+ _background(nullptr), _masks(nullptr), _useSubtitles(false),
_additionalVideo(nullptr), _ammo(0), _maxAmmo(0), _skipNextVideo(false),
_screenW(0), _screenH(0), // Every games initializes its own resolution
_keepTimerDuringScenes(false), _subtitles(nullptr) {
@@ -89,6 +89,11 @@ HypnoEngine::HypnoEngine(OSystem *syst, const ADGameDescription *gd)
if (!Common::parseBool(ConfMan.get("restored"), _restoredContentEnabled))
error("Failed to parse bool from restored options");
+
+ // Only enable if subtitles are available
+ if (!Common::parseBool(ConfMan.get("subtitles"), _useSubtitles))
+ warning("Failed to parse bool from subtitles options");
+
// Add quit level
Hotspot q(MakeMenu);
Action *a = new Quit();
@@ -565,11 +570,24 @@ void HypnoEngine::drawScreen() {
void HypnoEngine::adjustSubtitleSize() {
debugC(1, kHypnoDebugMedia, "%s()", __FUNCTION__);
if (_subtitles) {
+ // Subtitle positioning constants (as percentages of screen height)
+ const int HORIZONTAL_MARGIN = 20;
+ const float BOTTOM_MARGIN_PERCENT = 0.009f; // ~20px at 2160p
+ const float SUBTITLE_HEIGHT_PERCENT = 0.102f; // ~220px at 2160p
+
+ // Font sizing constants (as percentage of screen height)
+ const int MIN_FONT_SIZE = 8;
+ const float BASE_FONT_SIZE_PERCENT = 0.023f; // ~50px at 2160p
+
int16 h = g_system->getOverlayHeight();
int16 w = g_system->getOverlayWidth();
- float scale = h / 2160.f;
- _subtitles->setBBox(Common::Rect(20, h - 160 * scale, w - 20, h - 20));
- int fontSize = MAX(8, int(50 * scale));
+
+ int bottomMargin = int(h * BOTTOM_MARGIN_PERCENT);
+ int topOffset = int(h * SUBTITLE_HEIGHT_PERCENT);
+
+ _subtitles->setBBox(Common::Rect(HORIZONTAL_MARGIN, h - topOffset, w - HORIZONTAL_MARGIN, h - bottomMargin));
+
+ int fontSize = MAX(MIN_FONT_SIZE, int(h * BASE_FONT_SIZE_PERCENT));
_subtitles->setColor(0xff, 0xff, 0x80);
_subtitles->setFont("NotoSerif-Regular.ttf", fontSize, Video::Subtitles::kFontStyleRegular);
_subtitles->setFont("NotoSerif-Italic.ttf", fontSize, Video::Subtitles::kFontStyleItalic);
@@ -578,6 +596,9 @@ void HypnoEngine::adjustSubtitleSize() {
void HypnoEngine::loadSubtitles(const Common::Path &path) {
debugC(1, kHypnoDebugMedia, "%s(%s)", __FUNCTION__, path.toString().c_str());
+ if (!_useSubtitles)
+ return;
+
debug("Subtitle path: %s", path.toString().c_str());
Common::String subPathStr = path.toString() + ".srt";
subPathStr.toLowercase();
diff --git a/engines/hypno/hypno.h b/engines/hypno/hypno.h
index 995991f2c2b..2c41b5ee7f7 100644
--- a/engines/hypno/hypno.h
+++ b/engines/hypno/hypno.h
@@ -202,6 +202,7 @@ public:
bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override { return (isDemo() ? false : true); }
Common::String _checkpoint;
+ bool _useSubtitles;
Video::Subtitles *_subtitles;
void adjustSubtitleSize();
void loadSubtitles(const Common::Path &path);
Commit: f7ed3253001652bb36526ddac937b4bfe3efd01c
https://github.com/scummvm/scummvm/commit/f7ed3253001652bb36526ddac937b4bfe3efd01c
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2025-11-14T11:37:16+01:00
Commit Message:
PRIVATE: properly adjust subtitle size without using magic constants
Changed paths:
engines/private/private.cpp
diff --git a/engines/private/private.cpp b/engines/private/private.cpp
index 25f536aab6d..34575201de2 100644
--- a/engines/private/private.cpp
+++ b/engines/private/private.cpp
@@ -1626,18 +1626,44 @@ bool PrivateEngine::isSoundActive() {
void PrivateEngine::adjustSubtitleSize() {
debugC(1, kPrivateDebugFunction, "%s()", __FUNCTION__);
if (_subtitles) {
+ // Subtitle positioning constants (as percentages of screen height)
+ const int HORIZONTAL_MARGIN = 20;
+ const float BOTTOM_MARGIN_PERCENT = 0.009f; // ~20px at 2160p
+ const float MAIN_MENU_HEIGHT_PERCENT = 0.093f; // ~200px at 2160p
+ const float ALTERNATE_MODE_HEIGHT_PERCENT = 0.102f; // ~220px at 2160p
+ const float DEFAULT_HEIGHT_PERCENT = 0.074f; // ~160px at 2160p
+
+ // Font sizing constants (as percentage of screen height)
+ const int MIN_FONT_SIZE = 8;
+ const float BASE_FONT_SIZE_PERCENT = 0.023f; // ~50px at 2160p
+
int16 h = g_system->getOverlayHeight();
int16 w = g_system->getOverlayWidth();
- float scale = h / 2160.f;
+
+ int bottomMargin = int(h * BOTTOM_MARGIN_PERCENT);
+
// If we are in the main menu, we need to adjust the position of the subtitles
if (_mode == 0) {
- _subtitles->setBBox(Common::Rect(20, h - 200 * scale, w - 20, h - 20));
+ int topOffset = int(h * MAIN_MENU_HEIGHT_PERCENT);
+ _subtitles->setBBox(Common::Rect(HORIZONTAL_MARGIN,
+ h - topOffset,
+ w - HORIZONTAL_MARGIN,
+ h - bottomMargin));
} else if (_mode == -1) {
- _subtitles->setBBox(Common::Rect(20, h - 220 * scale, w - 20, h - 20));
+ int topOffset = int(h * ALTERNATE_MODE_HEIGHT_PERCENT);
+ _subtitles->setBBox(Common::Rect(HORIZONTAL_MARGIN,
+ h - topOffset,
+ w - HORIZONTAL_MARGIN,
+ h - bottomMargin));
} else {
- _subtitles->setBBox(Common::Rect(20, h - 160 * scale, w - 20, h - 20));
+ int topOffset = int(h * DEFAULT_HEIGHT_PERCENT);
+ _subtitles->setBBox(Common::Rect(HORIZONTAL_MARGIN,
+ h - topOffset,
+ w - HORIZONTAL_MARGIN,
+ h - bottomMargin));
}
- int fontSize = MAX(8, int(50 * scale));
+
+ int fontSize = MAX(MIN_FONT_SIZE, int(h * BASE_FONT_SIZE_PERCENT));
_subtitles->setColor(0xff, 0xff, 0x80);
_subtitles->setFont("LiberationSans-Regular.ttf", fontSize, Video::Subtitles::kFontStyleRegular);
_subtitles->setFont("LiberationSans-Italic.ttf", fontSize, Video::Subtitles::kFontStyleItalic);
More information about the Scummvm-git-logs
mailing list