[Scummvm-git-logs] scummvm master -> 1d0ed979346f2c706a513e1fc61a3da0f7a39fb0

yuv422 noreply at scummvm.org
Sat Mar 1 01:35:24 UTC 2025


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:
1d0ed97934 DARKSEED: Add support for chinese menu items + object names.


Commit: 1d0ed979346f2c706a513e1fc61a3da0f7a39fb0
    https://github.com/scummvm/scummvm/commit/1d0ed979346f2c706a513e1fc61a3da0f7a39fb0
Author: Eric Fry (yuv422 at reversedgames.com)
Date: 2025-03-01T12:32:55+11:00

Commit Message:
DARKSEED: Add support for chinese menu items + object names.

Changed paths:
  A engines/darkseed/zhmenufont.cpp
  A engines/darkseed/zhmenufont.h
    dists/engine-data/darkseed.dat
    engines/darkseed/darkseed.cpp
    engines/darkseed/darkseed.h
    engines/darkseed/inventory.cpp
    engines/darkseed/langtext.cpp
    engines/darkseed/langtext.h
    engines/darkseed/menu.cpp
    engines/darkseed/menu.h
    engines/darkseed/module.mk
    engines/darkseed/objects.cpp
    engines/darkseed/objects.h


diff --git a/dists/engine-data/darkseed.dat b/dists/engine-data/darkseed.dat
index bc842365dfc..c9f05dbab98 100644
Binary files a/dists/engine-data/darkseed.dat and b/dists/engine-data/darkseed.dat differ
diff --git a/engines/darkseed/darkseed.cpp b/engines/darkseed/darkseed.cpp
index fe0fbdb53fc..b18846a038d 100644
--- a/engines/darkseed/darkseed.cpp
+++ b/engines/darkseed/darkseed.cpp
@@ -49,6 +49,7 @@ DarkseedEngine::DarkseedEngine(OSystem *syst, const ADGameDescription *gameDesc)
 DarkseedEngine::~DarkseedEngine() {
 	delete _screen;
 	delete _sound;
+	delete _menu;
 }
 
 uint32 DarkseedEngine::getFeatures() const {
@@ -80,6 +81,7 @@ Common::Error DarkseedEngine::run() {
 	_tosText->load();
 	_objectVar.loadObjectNames();
 	_console = new Console(_tosText, _sound);
+	_menu = new Menu();
 	_player = new Player();
 	_useCode = new UseCode(_console, _player, _objectVar, _inventory);
 	_animation = new Animation(_player, _objectVar);
diff --git a/engines/darkseed/darkseed.h b/engines/darkseed/darkseed.h
index b958276673a..991391de11f 100644
--- a/engines/darkseed/darkseed.h
+++ b/engines/darkseed/darkseed.h
@@ -118,7 +118,7 @@ public:
 	UseCode *_useCode = nullptr;
 	Cutscene _cutscene;
 	Animation *_animation = nullptr;
-	Menu _menu;
+	Menu *_menu = nullptr;
 
 	uint8 _currentDay = 1;
 	int _currentTimeInSeconds = 0x7e8e;
@@ -214,7 +214,7 @@ public:
 	}
 
 	bool canSaveGameStateCurrently(Common::U32String *msg) override {
-		return _canSaveGame && !_animation->_isPlayingAnimation_maybe && !_player->_isAutoWalkingToBed && !_player->_heroWaiting && !_cutscene.isPlaying() && !_menu.isOpen();
+		return _canSaveGame && !_animation->_isPlayingAnimation_maybe && !_player->_isAutoWalkingToBed && !_player->_heroWaiting && !_cutscene.isPlaying() && !_menu->isOpen();
 	}
 
 	/**
diff --git a/engines/darkseed/inventory.cpp b/engines/darkseed/inventory.cpp
index f23808268af..29c1b60937b 100644
--- a/engines/darkseed/inventory.cpp
+++ b/engines/darkseed/inventory.cpp
@@ -142,7 +142,7 @@ void Inventory::handleClick() {
 	} else if (icon == 43) {
 		rightArrowClicked();
 	} else if (icon == 4) {
-		g_engine->_menu.loadMenu();
+		g_engine->_menu->loadMenu();
 	} else if (icon == 21) {
 		g_engine->_console->printTosText(935);
 		g_engine->_objectVar[21] = 1;
diff --git a/engines/darkseed/langtext.cpp b/engines/darkseed/langtext.cpp
index a5e18958f36..24b4288e538 100644
--- a/engines/darkseed/langtext.cpp
+++ b/engines/darkseed/langtext.cpp
@@ -40,6 +40,7 @@ const TextWithPosition &getI18NTextWithPosition(const I18NTextWithPosition &i18n
 	case Common::FR_FRA : return i18nTextWithPosition.fr;
 	case Common::DE_DEU : return i18nTextWithPosition.de;
 	case Common::KO_KOR : return i18nTextWithPosition.ko;
+	case Common::ZH_ANY : return i18nTextWithPosition.zh;
 	default : return i18nTextWithPosition.en;
 	}
 }
diff --git a/engines/darkseed/langtext.h b/engines/darkseed/langtext.h
index dae4c2a51a4..71a6f2a2e97 100644
--- a/engines/darkseed/langtext.h
+++ b/engines/darkseed/langtext.h
@@ -54,7 +54,7 @@ struct I18NTextWithPosition {
 	const TextWithPosition fr;
 	const TextWithPosition de;
 	const TextWithPosition ko;
-
+	const TextWithPosition zh;
 };
 
 Common::U32String getI18NText(const I18nText &text);
diff --git a/engines/darkseed/menu.cpp b/engines/darkseed/menu.cpp
index 8968b286c36..29490437aa9 100644
--- a/engines/darkseed/menu.cpp
+++ b/engines/darkseed/menu.cpp
@@ -32,7 +32,8 @@ constexpr I18NTextWithPosition kMenu_load = {
 	{119, 62, "CARGAR"},
 	{118, 62, "CHARGER"},
 	{121, 62, "LADEN"},
-	{120, 62, "\xA6\x89\x9C\xE1\x90\x91"}
+	{120, 62, "\xA6\x89\x9C\xE1\x90\x91"},
+	{118, 55, "\xa8\xfa\x20\xc0\xc9"}
 };
 
 constexpr I18NTextWithPosition kMenu_silent = {
@@ -40,7 +41,9 @@ constexpr I18NTextWithPosition kMenu_silent = {
 	{115, 136, "SIN SON"},
 	{118, 136, "SILENCE"},
 	{129, 136, "RUHE"},
-	{121, 136, "\xB7q\xAD\xA1\x88\xE1"}
+	{121, 136, "\xB7q\xAD\xA1\x88\xE1"},
+	{118, 129, "\xc0\x52\x20\xad\xb5"}
+
 };
 
 constexpr I18NTextWithPosition kMenu_sounds = {
@@ -48,7 +51,8 @@ constexpr I18NTextWithPosition kMenu_sounds = {
 	{121, 136, "SONIDO"},
 	{126, 136, "SONS"},
 	{123, 136, "SOUND"},
-	{128, 136, "\xB7q\xD0\xB7"}
+	{128, 136, "\xB7q\xD0\xB7"},
+{118, 129, "\xad\xb5\x20\xae\xc4"}
 };
 
 constexpr I18NTextWithPosition kMenu_save = {
@@ -56,7 +60,8 @@ constexpr I18NTextWithPosition kMenu_save = {
 	{119, 99, "GRABAR"},
 	{121, 99, "SAUVER"},
 	{115, 99, "SICHERN"},
-	{128, 99, "\xB8\xE1\xB8w"}
+	{128, 99, "\xB8\xE1\xB8w"},
+	{118, 92, "\xa6\x73\x20\xc0\xc9"}
 };
 
 constexpr I18NTextWithPosition kMenu_resume = {
@@ -64,7 +69,8 @@ constexpr I18NTextWithPosition kMenu_resume = {
 	{122, 173, "SEQUIR"},
 	{124, 173, "JOUER"},
 	{118, 173, "WEITER"},
-	{128, 173, "\xA5\xA2\x8A\xE1"}
+	{128, 173, "\xA5\xA2\x8A\xE1"},
+	{118, 166, "\xc4\x7e\x20\xc4\xf2"}
 };
 
 constexpr I18NTextWithPosition kMenu_quit = {
@@ -72,16 +78,25 @@ constexpr I18NTextWithPosition kMenu_quit = {
 	{125, 210, "SALIR"},
 	{117, 210, "QUITTER"},
 	{129, 210, "ENDE"},
-	{119, 210, "\x8F{\xA0""a\xC3\xB1"}
+	{119, 210, "\x8F{\xA0""a\xC3\xB1"},
+	{118, 203, "\xb5\xb2\x20\xa7\xf4"}
 };
 
-void drawMenuItem(const I18NTextWithPosition &menuText) {
+void Menu::drawMenuItem(const I18NTextWithPosition &menuText) {
 	const TextWithPosition &textWithPosition = getI18NTextWithPosition(menuText);
-	g_engine->_console->drawStringAt(textWithPosition.x, textWithPosition.y, convertToU32String(textWithPosition.text, g_engine->getLanguage()));
+	if (_zhFont) {
+		_zhFont->drawString(g_engine->_screen, convertToU32String(textWithPosition.text, g_engine->getLanguage()), textWithPosition.x, textWithPosition.y, 640, 14);
+	} else {
+		g_engine->_console->drawStringAt(textWithPosition.x, textWithPosition.y, convertToU32String(textWithPosition.text, g_engine->getLanguage()));
+	}
 }
 
 void Menu::drawSoundMenuItem() {
-	g_engine->_screen->fillRect({{115, 136}, 62, 13}, 0);
+	if (g_engine->getLanguage() == Common::ZH_ANY) {
+		g_engine->_screen->fillRect({{115, 129}, 62, 20}, 0);
+	} else {
+		g_engine->_screen->fillRect({{115, 136}, 62, 13}, 0);
+	}
 	if (g_engine->_sound->isMuted()) {
 		drawMenuItem(kMenu_silent);
 	} else {
@@ -98,6 +113,16 @@ Common::KeyCode Menu::getLocalisedConfirmToQuitKeycode() {
 	}
 }
 
+Menu::Menu() {
+	if (g_engine->getLanguage() == Common::ZH_ANY) {
+		_zhFont = new ZhMenuFont();
+	}
+}
+
+Menu::~Menu() {
+	delete _zhFont;
+}
+
 void Menu::loadMenu() {
 	if (g_engine->_sound->isPlayingMusic()) {
 		g_engine->_sound->startFadeOut();
diff --git a/engines/darkseed/menu.h b/engines/darkseed/menu.h
index ef96200dc77..f10a2c7af1a 100644
--- a/engines/darkseed/menu.h
+++ b/engines/darkseed/menu.h
@@ -22,18 +22,26 @@
 #ifndef DARKSEED_MENU_H
 #define DARKSEED_MENU_H
 
+#include "darkseed/zhmenufont.h"
+#include "darkseed/langtext.h"
+
 namespace Darkseed {
 
 class Menu {
 private:
 	bool _open = false;
+	ZhMenuFont *_zhFont = nullptr;
+
 public:
+	Menu();
+	~Menu();
 	bool isOpen() const { return _open; }
 
 	void loadMenu();
 private:
 	void drawSoundMenuItem();
 	Common::KeyCode getLocalisedConfirmToQuitKeycode();
+	void drawMenuItem(const I18NTextWithPosition &menuText);
 };
 
 } // namespace Darkseed
diff --git a/engines/darkseed/module.mk b/engines/darkseed/module.mk
index ea88ab8d13c..e5e21cc3e61 100644
--- a/engines/darkseed/module.mk
+++ b/engines/darkseed/module.mk
@@ -32,7 +32,8 @@ MODULE_OBJS = \
 	sprites.o \
 	titlefont.o \
 	tostext.o \
-	usecode.o
+	usecode.o \
+	zhmenufont.o
 
 # This module can be built as a plugin
 ifeq ($(ENABLE_DARKSEED), DYNAMIC_PLUGIN)
diff --git a/engines/darkseed/objects.cpp b/engines/darkseed/objects.cpp
index 12393d913e2..6b436bd22b4 100644
--- a/engines/darkseed/objects.cpp
+++ b/engines/darkseed/objects.cpp
@@ -101,6 +101,8 @@ void Objects::loadObjectNames() {
 	auto lang = g_engine->getLanguage();
 	if (lang == Common::KO_KOR) {
 		loadKoreanObjectNames();
+	} else if (lang == Common::ZH_ANY) {
+		loadChineseObjectNames();
 	} else {
 		for (int i = 0; i < MAX_OBJECTS; i++) {
 			switch (lang) {
@@ -129,6 +131,20 @@ void Objects::loadKoreanObjectNames() {
 	file.close();
 }
 
+void Objects::loadChineseObjectNames() {
+	Common::File file;
+	if (!file.open("zh_objectnames.dat")) {
+		error("Failed to open zh_objectnames.dat");
+	}
+
+	for (int i = 0; i < MAX_OBJECTS; i++) {
+		file.seek(i * 21);
+		_objectNames[i] = readU32String(file);
+	}
+
+	file.close();
+}
+
 Common::U32String Objects::readU32String(Common::SeekableReadStream &readStream) {
 	Common::U32String str;
 	uint8 byte = readStream.readByte();
diff --git a/engines/darkseed/objects.h b/engines/darkseed/objects.h
index 7f96e9b33bf..ded0d547c6b 100644
--- a/engines/darkseed/objects.h
+++ b/engines/darkseed/objects.h
@@ -71,6 +71,7 @@ public:
 
 private:
 	void loadKoreanObjectNames();
+	void loadChineseObjectNames();
 
 	Common::U32String readU32String(Common::SeekableReadStream &readStream);
 };
diff --git a/engines/darkseed/zhmenufont.cpp b/engines/darkseed/zhmenufont.cpp
new file mode 100644
index 00000000000..cf273ecaf48
--- /dev/null
+++ b/engines/darkseed/zhmenufont.cpp
@@ -0,0 +1,92 @@
+/* ScummVM - Graphic Adventure Engine
+*
+* ScummVM is the legal property of its developers, whose names
+* are too numerous to list here. Please refer to the COPYRIGHT
+* file distributed with this source distribution.
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+#include "darkseed/darkseed.h"
+#include "darkseed/zhmenufont.h"
+
+namespace Darkseed {
+
+ZhMenuFont::ZhMenuFont() {
+	load();
+}
+
+void ZhMenuFont::load() {
+	Common::File fontData;
+	if (!fontData.open("zhmenufont_game.dat")) {
+		error("Error: failed to open zhmenufont_game.dat");
+	}
+	_glyphs.resize(10);
+
+	for (int i = 0; i < 10; i++) {
+		_glyphs[i].charIdx = fontData.readUint16BE();
+		fontData.read(_glyphs[i].pixels, 72);
+	}
+
+	fontData.close();
+}
+
+const ZhMenuFontGlyph *ZhMenuFont::getGlyph(uint32 chr) const {
+	for (auto &glyph : _glyphs) {
+		if (glyph.charIdx == chr) {
+			return &glyph;
+		}
+	}
+	return nullptr;
+}
+
+int ZhMenuFont::getFontHeight() const {
+	return 24;
+}
+
+int ZhMenuFont::getMaxCharWidth() const {
+	return 24;
+}
+
+int ZhMenuFont::getCharWidth(uint32 chr) const {
+	auto glyph = getGlyph(chr);
+	return glyph ? getMaxCharWidth() : 8;
+}
+
+void ZhMenuFont::drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const {
+	auto glyph = getGlyph(chr);
+	if (glyph) {
+		byte *ptr = (byte *)g_engine->_screen->getBasePtr(x, y);
+		int srcPixel = 0;
+		int sByteOffset = 0;
+		for (int sy = 0; sy < getFontHeight(); sy++) {
+			for (int sx = 0; sx < getMaxCharWidth(); sx++) {
+				if (glyph->pixels[srcPixel] & 1 << (7 - sByteOffset)) {
+					*ptr = (uint8)color;
+				}
+				sByteOffset++;
+				if (sByteOffset == 8) {
+					sByteOffset = 0;
+					srcPixel++;
+				}
+				ptr++;
+			}
+			ptr -= getMaxCharWidth();
+			ptr += g_engine->_screen->pitch;
+		}
+	}
+}
+
+} // namespace Darkseed
diff --git a/engines/darkseed/zhmenufont.h b/engines/darkseed/zhmenufont.h
new file mode 100644
index 00000000000..c94ad364dfa
--- /dev/null
+++ b/engines/darkseed/zhmenufont.h
@@ -0,0 +1,55 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef DARKSEED_ZHMENUFONT_H
+#define DARKSEED_ZHMENUFONT_H
+
+#include <common/array.h>
+#include "graphics/font.h"
+#include "graphics/surface.h"
+
+namespace Darkseed {
+
+struct ZhMenuFontGlyph {
+	int charIdx;
+	uint8 pixels[72]; // 24x24 pixels @ 1bpp
+};
+
+class ZhMenuFont : public Graphics::Font {
+private:
+	Common::Array<ZhMenuFontGlyph> _glyphs;
+
+public:
+	ZhMenuFont();
+
+	int getFontHeight() const override;
+	int getMaxCharWidth() const override;
+	int getCharWidth(uint32 chr) const override;
+	void drawChar(Graphics::Surface *dst, uint32 chr, int x, int y, uint32 color) const override;
+
+private:
+	void load();
+	const ZhMenuFontGlyph *getGlyph(uint32 chr) const;
+};
+
+} // namespace Darkseed
+
+#endif // DARKSEED_ZHMENUFONT_H




More information about the Scummvm-git-logs mailing list