Skip to content

Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.

Languages: NumBlocks' menus and commands in French and Chinese

Mason Chen915d90458745
diff --git a/games/numblocks/Makefile b/games/numblocks/Makefile
index 6a3fe770..be0fc410 100644
--- a/games/numblocks/Makefile
+++ b/games/numblocks/Makefile
@@ -11,7 +11,7 @@ STRIP ?= arm-none-eabi-strip --strip-unneeded
CLIENT_JAR ?= client.jar
GEN ?= src/gen.c
GAME = src/main.c src/world.c src/edits.c src/render.c src/player.c src/phys.c src/inv.c src/entity.c src/mob.c src/tick.c src/gui.c src/hand.c src/save.c src/data.c src/names.c src/command.c $(GEN)
-HEADERS = $(wildcard src/*.h) ../common/epsilon_app.h ../common/epsilon_files.h Makefile
+HEADERS = $(wildcard src/*.h) ../common/epsilon_app.h ../common/epsilon_files.h ../common/np_text.h Makefile
CFLAGS = -std=gnu11 $(shell $(NWLINK) eadk-cflags-device)
CFLAGS += -O2 -Wall -Wextra -Wno-unused-parameter -fno-math-errno -fsingle-precision-constant -ffast-math
diff --git a/games/numblocks/lang/fr.txt b/games/numblocks/lang/fr.txt
new file mode 100644
index 00000000..54de0a2c
--- /dev/null
+++ b/games/numblocks/lang/fr.txt
@@ -0,0 +1,226 @@
+# NumBlocks in French: the English text as in the source, a tab, the translation (see tools/lang.py).
+# Minecraft's own French where it has one (fr_FR), shorter where a button or a key is narrow.
+# ---- menus
+Done Terminé
+Singleplayer Solo
+Multiplayer Multijoueur
+Options... Options...
+Quit Game Quitter le jeu
+Play Selected World Jouer au monde choisi
+Create New World Créer un nouveau monde
+Rename Renommer
+Delete Supprimer
+Re-Create Recréer
+Cancel Annuler
+Game Mode: Mode de jeu :
+Creative Créatif
+Survival Survie
+Allow Cheats: Autoriser les cheats :
+ON Oui
+OFF Non
+Seed: Graine :
+(random) (aléatoire)
+World Type: Type de monde :
+Superflat Superplat
+Default Par défaut
+Peaceful Paisible
+Easy Facile
+Normal Normale
+Hard Difficile
+Difficulty: Difficulté :
+Graphics: Graphismes :
+Fancy Détaillés
+Fast Rapides
+Look Speed: Sensibilité :
+Clouds: Nuages :
+View Bobbing: Balancement :
+Controls... Commandes...
+Back to Game Retour au jeu
+Achievements Succès
+Statistics Statistiques
+Open to LAN Ouvrir en LAN
+Save and Quit to Title Sauvegarder et quitter
+Start LAN World Lancer le monde en LAN
+Respawn Réapparaître
+Title screen Écran titre
+New World Nouveau monde
+Copy of Copie de
+Select World Choisir un monde
+Creative Mode Mode Créatif
+Survival Mode Mode Survie
+, Cheats , cheats
+No worlds yet Pas encore de monde
+Storage free: Espace libre :
+ KB Ko
+World Name Nom du monde
+Unlimited resources, free flying and Ressources illimitées, vol libre et
+destroy blocks instantly destruction instantanée des blocs
+Search for resources, crafting, gain Cherche des ressources, fabrique, gagne
+levels, health and hunger des niveaux, de la santé et de la faim
+alpha: letters or digits, shift: capitals, OK: done alpha : lettres/chiffres, shift : majuscules, OK : fini
+Leave blank for a random seed Laisse vide pour une graine aléatoire
+Rename World Renommer le monde
+Enter Name Saisis le nom
+Are you sure you want to delete this world? Veux-tu vraiment supprimer ce monde ?
+' \"
+' will be lost forever! (A long time!) \" sera perdu à jamais ! (Très longtemps !)
+Options Options
+Game menu Menu du jeu
+LAN World Monde en LAN
+Settings for Other Players Réglages pour les autres joueurs
+Loading world Chargement du monde
+Building terrain Construction du terrain
+You died! Tu es mort !
+Score: Score :
+Inspired by Minecraft, not affiliated with Mojang Inspiré de Minecraft, sans lien avec Mojang
+Made by Mason Chen as part of NumPlay Créé par Mason Chen pour NumPlay
+# ---- containers
+Crafting Artisanat
+Inventory Inventaire
+Furnace Fourneau
+Chest Coffre
+# ---- the chat
+alpha: abc/123 shift: Abc toolbox: finish the word alpha : abc/123 shift : Abc outils : finir le mot
+x,n,t : var _ x10^x ~ ans space 0 @ x,n,t : var _ x10^x ~ ans espace 0 @
+You can only sleep at night Tu ne peux dormir que la nuit
+You may not rest now, there are monsters nearby Tu ne peux pas te reposer, des monstres rôdent
+# ---- the keys: names in Controls (Minecraft's), then the key sheet's words (one word for both where English has one)
+Controls Commandes
+Key Sheet... Plan des touches...
+Reset Réinit.
+Reset Keys Tout réinitialiser
+Gameplay Jeu
+Miscellaneous Divers
+Movement Mouvement
+Attack/Destroy Attaquer/Détruire
+Mine, attack Miner, frapper
+Pick Block Choisir le bloc
+Pick block Choisir
+Use Item/Place Block Utiliser/Placer
+Place, use Poser, utiliser
+Drop Item Jeter l'objet
+Drop Jeter
+Hotbar Slot 1 Emplacement 1
+Hotbar Slot 2 Emplacement 2
+Hotbar Slot 3 Emplacement 3
+Hotbar Slot 4 Emplacement 4
+Hotbar Slot 5 Emplacement 5
+Hotbar Slot 6 Emplacement 6
+Hotbar Slot 7 Emplacement 7
+Hotbar Slot 8 Emplacement 8
+Hotbar Slot 9 Emplacement 9
+Slot 1 Case 1
+Slot 2 Case 2
+Slot 3 Case 3
+Slot 4 Case 4
+Slot 5 Case 5
+Slot 6 Case 6
+Slot 7 Case 7
+Slot 8 Case 8
+Slot 9 Case 9
+Pause Pause
+Jump Saut
+Sneak Furtif
+Sprint Courir
+Strafe Left Pas à gauche
+Left Gauche
+Strafe Right Pas à droite
+Right Droite
+Walk Backwards Reculer
+Backward Reculer
+Walk Forwards Avancer
+Forward Avancer
+Open Chat Ouvrir le chat
+Chat Chat
+Open Command Ouvrir les commandes
+Command Commande
+Look Vue
+Back Retour
+toolbox outils
+NONE AUCUNE
+Home Accueil
+Save, quit Quitter
+1 to 9: hotbar slot. 1 à 9 : case de la barre.
+EXE: as OK. EXE : comme OK.
+# (a key, these two, then what it does)
+: :
+. .
+Forward twice: sprint. Jump twice: fly (Creative). Avancer 2 fois : courir. Sauter 2 fois : voler (Créatif).
+Menus: OK takes or puts, EXE one, shift+OK moves. Menus : OK prend ou pose, EXE un seul, shift+OK déplace.
+Hold OK and move over slots to spread a stack out. Garde OK sur des cases pour y répartir une pile.
+# ---- the commands' answers (Minecraft's en_US words: %s and %d take the same things in turn, strings and numbers apart)
+Usage: %s Utilisation : %s
+'%s' is not a valid number '%s' n'est pas un nombre valide
+The number you have entered (%d) is too small, it must be at least %d Le nombre saisi (%d) est trop petit, il doit valoir au moins %d
+The number you have entered (%d) is too big, it must be at most %d Le nombre saisi (%d) est trop grand, il doit valoir au plus %d
+That player cannot be found Ce joueur est introuvable
+Your game mode has been updated Ton mode de jeu a été mis à jour
+Set own game mode to %s Ton mode de jeu est maintenant : %s
+Set the time to %d Heure réglée sur %d
+Added %d to the time %d ajouté à l'heure
+Time is %d L'heure est %d
+Changing to clear weather Le temps devient clair
+Changing to rainy weather Il se met à pleuvoir
+Changing to rain and thunder Un orage éclate
+There is no such item with name %s Il n'y a pas d'objet nommé %s
+Given %s * %d to %s %s * %d donné à %s
+Teleported %s to %s %s téléporté vers %s
+Teleported Player to Player téléporté en
+Killed %s %s a été tué
+Set game difficulty to %s Difficulté du jeu : %s
+Set Player's spawn point to ( Point d'apparition de Player placé en (
+Taken %d levels from %s %d niveaux retirés à %s
+Given %d levels to %s %d niveaux donnés à %s
+Cannot give player negative experience points Impossible de donner des points d'expérience négatifs
+Given %d experience to %s %d points d'expérience donnés à %s
+Could not clear the inventory of %s, no items to remove Impossible de vider l'inventaire de %s : aucun objet à retirer
+Cleared the inventory of %s, removing %d items Inventaire de %s vidé : %d objets retirés
+Couldn't take any effects from %s as they do not have any Impossible de retirer les effets de %s : il n'en a aucun
+Took all effects from %s Tous les effets de %s ont été retirés
+There is no such mob effect with ID %d Il n'y a pas d'effet d'ID %d
+There is no such mob effect with ID %s Il n'y a pas d'effet d'ID %s
+# (an effect's name between these)
+Couldn't take Impossible de retirer l'effet
+ from Player as they do not have the effect à Player : il ne l'a pas
+Took Effet
+ from Player retiré à Player
+Given Effet
+ (ID (ID
+) * ) *
+ to Player for donné à Player pour
+ seconds secondes
+Poison Poison
+Hunger Faim
+Regeneration Régénération
+Cannot summon the object out of the world Impossible d'invoquer l'objet hors du monde
+Object successfully summoned Objet invoqué
+Unable to summon object Impossible d'invoquer l'objet
+There is no such block with ID/name %s Il n'y a pas de bloc d'ID ou de nom %s
+Cannot place block outside of the world Impossible de placer un bloc hors du monde
+The block couldn't be placed Le bloc n'a pas pu être placé
+Block placed Bloc placé
+No game rule called '%s' is available Aucune règle de jeu ne s'appelle '%s'
+Game rule has been updated La règle de jeu a été mise à jour
+Unknown command. Try /help for a list of commands Commande inconnue. Essaie /help pour la liste des commandes
+--- Showing help page %d of %d (/help <page>) --- --- Page d'aide %d sur %d (/help <page>) ---
+Tip: Use the toolbox key while typing a command to auto-complete the command or its arguments Astuce : pendant la saisie d'une commande, la touche outils complète la commande ou ses arguments
+You do not have permission to use this command Tu n'as pas la permission d'utiliser cette commande
+Toggled downfall Précipitations inversées
+# ---- the commands' usage (their words, as typed, stay)
+/clear [player] [item] [data] [maxCount] [dataTag] /clear [joueur] [objet] [données] [quantitéMax] [étiquette]
+/difficulty <new difficulty> /difficulty <nouvelle difficulté>
+/effect <player> <effect> [seconds] [amplifier] [hideParticles] OR /effect <player> clear /effect <joueur> <effet> [secondes] [niveau] [masquerParticules] OU /effect <joueur> clear
+/gamemode <mode> [player] /gamemode <mode> [joueur]
+/gamerule <rule name> [value] /gamerule <nom de la règle> [valeur]
+/give <player> <item> [amount] [data] [dataTag] /give <joueur> <objet> [quantité] [données] [étiquette]
+/help [page|command name] /help [page|nom de la commande]
+/kill [player|entity] /kill [joueur|entité]
+/me <action ...> /me <action ...>
+/say <message ...> /say <message ...>
+/setblock <x> <y> <z> <TileName> [dataValue] [oldBlockHandling] [dataTag] /setblock <x> <y> <z> <nomDuBloc> [données] [ancienBloc] [étiquette]
+/spawnpoint [player] [<x> <y> <z>] /spawnpoint [joueur] [<x> <y> <z>]
+/summon <EntityName> [x] [y] [z] [dataTag] /summon <nomDeL'Entité> [x] [y] [z] [étiquette]
+/time <set|add|query> <value> /time <set|add|query> <valeur>
+/tp [target player] <destination player> OR /tp [target player] <x> <y> <z> [<y-rot> <x-rot>] /tp [joueur ciblé] <joueur de destination> OU /tp [joueur ciblé] <x> <y> <z> [<rot-y> <rot-x>]
+/weather <clear|rain|thunder> [duration in seconds] /weather <clear|rain|thunder> [durée en secondes]
+/xp <amount> [player] OR /xp <amount>L [player] /xp <quantité> [joueur] OU /xp <quantité>L [joueur]
diff --git a/games/numblocks/lang/zh.txt b/games/numblocks/lang/zh.txt
new file mode 100644
index 00000000..e4d0fd63
--- /dev/null
+++ b/games/numblocks/lang/zh.txt
@@ -0,0 +1,226 @@
+# NumBlocks in Chinese: the English text as in the source, a tab, the translation (see tools/lang.py).
+# Minecraft's own Simplified Chinese where it has one (zh_CN), shorter where a button or a key is narrow.
+# ---- menus
+Done 完成
+Singleplayer 单人游戏
+Multiplayer 多人游戏
+Options... 选项...
+Quit Game 退出游戏
+Play Selected World 进入选中的世界
+Create New World 创建新的世界
+Rename 重命名
+Delete 删除
+Re-Create 重新创建
+Cancel 取消
+Game Mode: 游戏模式:
+Creative 创造
+Survival 生存
+Allow Cheats: 允许作弊:
+ON 开
+OFF 关
+Seed: 种子:
+(random) (随机)
+World Type: 世界类型:
+Superflat 超平坦
+Default 默认
+Peaceful 和平
+Easy 简单
+Normal 普通
+Hard 困难
+Difficulty: 难度:
+Graphics: 图像品质:
+Fancy 高品质
+Fast 流畅
+Look Speed: 灵敏度:
+Clouds: 云:
+View Bobbing: 视角摇晃:
+Controls... 按键控制...
+Back to Game 回到游戏
+Achievements 成就
+Statistics 统计信息
+Open to LAN 对局域网开放
+Save and Quit to Title 保存并退回到标题画面
+Start LAN World 创建局域网世界
+Respawn 重生
+Title screen 标题画面
+New World 新的世界
+Copy of 副本
+Select World 选择世界
+Creative Mode 创造模式
+Survival Mode 生存模式
+, Cheats ,作弊
+No worlds yet 还没有世界
+Storage free: 剩余空间:
+ KB KB
+World Name 世界名称
+Unlimited resources, free flying and 无限的资源、自由地飞翔并且
+destroy blocks instantly 能够瞬间破坏方块
+Search for resources, crafting, gain 探索世界、收集资源、合成道具、
+levels, health and hunger 提高等级、补充体力和饥饿值
+alpha: letters or digits, shift: capitals, OK: done alpha:字母/数字,shift:大写,OK:完成
+Leave blank for a random seed 留空以生成随机种子
+Rename World 重命名世界
+Enter Name 输入名称
+Are you sure you want to delete this world? 你确定要删除这个世界吗?
+' “
+' will be lost forever! (A long time!) ”将会永久消失!(真的很久!)
+Options 选项
+Game menu 游戏菜单
+LAN World 局域网世界
+Settings for Other Players 其他玩家的设置
+Loading world 正在载入世界
+Building terrain 正在建立地形
+You died! 你死了!
+Score: 分数:
+Inspired by Minecraft, not affiliated with Mojang 灵感来自Minecraft,与Mojang无关
+Made by Mason Chen as part of NumPlay Mason Chen为NumPlay制作
+# ---- containers
+Crafting 合成
+Inventory 物品栏
+Furnace 熔炉
+Chest 箱子
+# ---- the chat
+alpha: abc/123 shift: Abc toolbox: finish the word alpha:abc/123 shift:Abc 工具箱:补全单词
+x,n,t : var _ x10^x ~ ans space 0 @ x,n,t : var _ x10^x ~ ans 空格 0 @
+You can only sleep at night 你只能在夜间入睡
+You may not rest now, there are monsters nearby 你现在不能休息,周围有怪物在游荡
+# ---- the keys: names in Controls (Minecraft's), then the key sheet's words
+Controls 按键控制
+Key Sheet... 按键图...
+Reset 重置
+Reset Keys 全部重置
+Gameplay 游戏内容
+Miscellaneous 杂项
+Movement 移动
+Attack/Destroy 攻击/摧毁
+Mine, attack 挖掘、攻击
+Pick Block 选取方块
+Pick block 选取方块
+Use Item/Place Block 使用物品/放置方块
+Place, use 放置、使用
+Drop Item 丢弃物品
+Drop 丢弃
+Hotbar Slot 1 快捷栏1
+Hotbar Slot 2 快捷栏2
+Hotbar Slot 3 快捷栏3
+Hotbar Slot 4 快捷栏4
+Hotbar Slot 5 快捷栏5
+Hotbar Slot 6 快捷栏6
+Hotbar Slot 7 快捷栏7
+Hotbar Slot 8 快捷栏8
+Hotbar Slot 9 快捷栏9
+Slot 1 快捷栏1
+Slot 2 快捷栏2
+Slot 3 快捷栏3
+Slot 4 快捷栏4
+Slot 5 快捷栏5
+Slot 6 快捷栏6
+Slot 7 快捷栏7
+Slot 8 快捷栏8
+Slot 9 快捷栏9
+Pause 暂停
+Jump 跳跃
+Sneak 潜行
+Sprint 疾跑
+Strafe Left 向左平移
+Left 左移
+Strafe Right 向右平移
+Right 右移
+Walk Backwards 向后
+Backward 后退
+Walk Forwards 向前
+Forward 前进
+Open Chat 打开聊天栏
+Chat 聊天
+Open Command 输入命令
+Command 命令
+Look 视角
+Back 返回
+toolbox 工具箱
+NONE 无
+Home 主页
+Save, quit 保存退出
+1 to 9: hotbar slot. 1至9:快捷栏。
+EXE: as OK. EXE:同OK。
+# (a key, these two, then what it does)
+: :
+. 。
+Forward twice: sprint. Jump twice: fly (Creative). 连按前进:疾跑。 连按跳跃:飞行(创造模式)。
+Menus: OK takes or puts, EXE one, shift+OK moves. 菜单:OK拿取或放下,EXE放一个,shift+OK移动。
+Hold OK and move over slots to spread a stack out. 按住OK划过格子,可分散一组物品。
+# ---- the commands' answers (Minecraft's words: %s and %d take the same things in turn, strings and numbers apart)
+Usage: %s 用法:%s
+'%s' is not a valid number '%s'不是有效的数字
+The number you have entered (%d) is too small, it must be at least %d 你输入的数字(%d)太小,至少需要为%d
+The number you have entered (%d) is too big, it must be at most %d 你输入的数字(%d)太大,最多只能为%d
+That player cannot be found 找不到该玩家
+Your game mode has been updated 你的游戏模式已被更新
+Set own game mode to %s 已将自己的游戏模式设为%s
+Set the time to %d 已将时间设为%d
+Added %d to the time 已将时间增加%d
+Time is %d 时间是%d
+Changing to clear weather 天气已变为晴天
+Changing to rainy weather 天气已变为雨天
+Changing to rain and thunder 天气已变为雷雨
+There is no such item with name %s 不存在名为%s的物品
+Given %s * %d to %s 已将%s * %d给予%s
+Teleported %s to %s 已将%s传送到%s
+Teleported Player to 已将Player传送到
+Killed %s 已清除%s
+Set game difficulty to %s 已将游戏难度设为%s
+Set Player's spawn point to ( 已将Player的出生点设为(
+Taken %d levels from %s 已从%s拿走%d级经验
+Given %d levels to %s 已给予%s %d级经验
+Cannot give player negative experience points 不能给予玩家负数的经验
+Given %d experience to %s 已给予%s %d点经验
+Could not clear the inventory of %s, no items to remove 无法清除%s的物品栏,没有可移除的物品
+Cleared the inventory of %s, removing %d items 已清除%s的物品栏,共移除%d个物品
+Couldn't take any effects from %s as they do not have any 无法移除%s的效果,因为其没有任何效果
+Took all effects from %s 已移除%s的所有效果
+There is no such mob effect with ID %d 不存在ID为%d的效果
+There is no such mob effect with ID %s 不存在ID为%s的效果
+# (an effect's name between these)
+Couldn't take 无法移除Player的
+ from Player as they do not have the effect 效果,因为其没有该效果
+Took 已移除Player的
+ from Player 效果
+Given 已将
+ (ID (ID
+) * ) *
+ to Player for 给予Player,持续
+ seconds 秒
+Poison 中毒
+Hunger 饥饿
+Regeneration 生命恢复
+Cannot summon the object out of the world 无法在世界外生成实体
+Object successfully summoned 成功生成实体
+Unable to summon object 无法生成实体
+There is no such block with ID/name %s 不存在ID或名称为%s的方块
+Cannot place block outside of the world 无法在世界外放置方块
+The block couldn't be placed 无法放置方块
+Block placed 方块已放置
+No game rule called '%s' is available 没有名为'%s'的游戏规则
+Game rule has been updated 游戏规则已更新
+Unknown command. Try /help for a list of commands 未知的命令。输入/help查看命令列表
+--- Showing help page %d of %d (/help <page>) --- --- 显示帮助第%d页,共%d页(/help <页码>)---
+Tip: Use the toolbox key while typing a command to auto-complete the command or its arguments 提示:输入命令时按工具箱键可自动补全命令或其参数
+You do not have permission to use this command 你没有使用此命令的权限
+Toggled downfall 已切换降水
+# ---- the commands' usage (their words, as typed, stay)
+/clear [player] [item] [data] [maxCount] [dataTag] /clear [玩家] [物品] [数据值] [最大数量] [数据标签]
+/difficulty <new difficulty> /difficulty <新难度>
+/effect <player> <effect> [seconds] [amplifier] [hideParticles] OR /effect <player> clear /effect <玩家> <效果> [秒数] [等级] [隐藏粒子] 或 /effect <玩家> clear
+/gamemode <mode> [player] /gamemode <模式> [玩家]
+/gamerule <rule name> [value] /gamerule <规则名> [值]
+/give <player> <item> [amount] [data] [dataTag] /give <玩家> <物品> [数量] [数据值] [数据标签]
+/help [page|command name] /help [页码|命令名]
+/kill [player|entity] /kill [玩家|实体]
+/me <action ...> /me <动作 ...>
+/say <message ...> /say <消息 ...>
+/setblock <x> <y> <z> <TileName> [dataValue] [oldBlockHandling] [dataTag] /setblock <x> <y> <z> <方块名> [数据值] [旧方块处理] [数据标签]
+/spawnpoint [player] [<x> <y> <z>] /spawnpoint [玩家] [<x> <y> <z>]
+/summon <EntityName> [x] [y] [z] [dataTag] /summon <实体名> [x] [y] [z] [数据标签]
+/time <set|add|query> <value> /time <set|add|query> <值>
+/tp [target player] <destination player> OR /tp [target player] <x> <y> <z> [<y-rot> <x-rot>] /tp [目标玩家] <目的地玩家> 或 /tp [目标玩家] <x> <y> <z> [<y旋转> <x旋转>]
+/weather <clear|rain|thunder> [duration in seconds] /weather <clear|rain|thunder> [持续秒数]
+/xp <amount> [player] OR /xp <amount>L [player] /xp <数量> [玩家] 或 /xp <数量>L [玩家]
diff --git a/games/numblocks/src/command.c b/games/numblocks/src/command.c
index 0b8430b7..81c580c3 100644
--- a/games/numblocks/src/command.c
+++ b/games/numblocks/src/command.c
@@ -63,7 +63,7 @@ static void fail(const char *f, const char *s1, long long d1, long long d2) { sa
/* CommandException: the command stops, the chat says why (in red) */
static bool failed;
static void usage(const char *u) {
- if (!failed) say(CHAT_RED, "Usage: %s", u, NULL, 0, 0);
+ if (!failed) say(CHAT_RED, T("Usage: %s"), u, NULL, 0, 0);
failed = true;
}
static void error(const char *f, const char *s1, long long d1, long long d2) {
@@ -86,15 +86,15 @@ static bool is_num(const char *s, bool dec) {
static long long num(const char *s, long long lo, long long hi) {
if (failed) return lo;
if (!is_num(s, false) || strlen(s) > 11) {
- error("'%s' is not a valid number", s, 0, 0);
+ error(T("'%s' is not a valid number"), s, 0, 0);
return lo;
}
long long v = 0;
const char *p = s + (*s == '-' || *s == '+');
for (; *p; p++) v = v * 10 + (*p - '0');
if (*s == '-') v = -v;
- if (v < lo) error("The number you have entered (%d) is too small, it must be at least %d", NULL, v, lo);
- else if (v > hi) error("The number you have entered (%d) is too big, it must be at most %d", NULL, v, hi);
+ if (v < lo) error(T("The number you have entered (%d) is too small, it must be at least %d"), NULL, v, lo);
+ else if (v > hi) error(T("The number you have entered (%d) is too big, it must be at most %d"), NULL, v, hi);
return v;
}
static float to_float(const char *s) {
@@ -114,7 +114,7 @@ static float coord(float base, const char *s, bool center) {
if (rel) s++;
if (rel && !*s) return base;
if (!is_num(s, true)) {
- error("'%s' is not a valid number", s - rel, 0, 0);
+ error(T("'%s' is not a valid number"), s - rel, 0, 0);
return base;
}
float v = to_float(s);
@@ -126,7 +126,7 @@ static float coord(float base, const char *s, bool center) {
static bool player(const char *s) {
if (failed) return false;
if (!strcmp(s, PLAYER) || (s[0] == '@' && strchr("pare", s[1]) && (!s[2] || s[2] == '['))) return true;
- error("That player cannot be found", NULL, 0, 0);
+ error(T("That player cannot be found"), NULL, 0, 0);
return false;
}
static int to_int(const char *s) {
@@ -177,39 +177,39 @@ static const char *const cmd_name[N_COMMANDS] = {"clear", "difficulty", "effect"
"help", "kill", "me", "say", "seed", "setblock", "spawnpoint",
"summon", "time", "toggledownfall", "tp", "weather", "xp"};
static const char *const cmd_usage[N_COMMANDS] = {
- "/clear [player] [item] [data] [maxCount] [dataTag]",
- "/difficulty <new difficulty>",
- "/effect <player> <effect> [seconds] [amplifier] [hideParticles] OR /effect <player> clear",
- "/gamemode <mode> [player]",
- "/gamerule <rule name> [value]",
- "/give <player> <item> [amount] [data] [dataTag]",
- "/help [page|command name]",
- "/kill [player|entity]",
- "/me <action ...>",
- "/say <message ...>",
+ T("/clear [player] [item] [data] [maxCount] [dataTag]"),
+ T("/difficulty <new difficulty>"),
+ T("/effect <player> <effect> [seconds] [amplifier] [hideParticles] OR /effect <player> clear"),
+ T("/gamemode <mode> [player]"),
+ T("/gamerule <rule name> [value]"),
+ T("/give <player> <item> [amount] [data] [dataTag]"),
+ T("/help [page|command name]"),
+ T("/kill [player|entity]"),
+ T("/me <action ...>"),
+ T("/say <message ...>"),
"/seed",
- "/setblock <x> <y> <z> <TileName> [dataValue] [oldBlockHandling] [dataTag]",
- "/spawnpoint [player] [<x> <y> <z>]",
- "/summon <EntityName> [x] [y] [z] [dataTag]",
- "/time <set|add|query> <value>",
+ T("/setblock <x> <y> <z> <TileName> [dataValue] [oldBlockHandling] [dataTag]"),
+ T("/spawnpoint [player] [<x> <y> <z>]"),
+ T("/summon <EntityName> [x] [y] [z] [dataTag]"),
+ T("/time <set|add|query> <value>"),
"/toggledownfall",
- "/tp [target player] <destination player> OR /tp [target player] <x> <y> <z> [<y-rot> <x-rot>]",
- "/weather <clear|rain|thunder> [duration in seconds]",
- "/xp <amount> [player] OR /xp <amount>L [player]"};
+ T("/tp [target player] <destination player> OR /tp [target player] <x> <y> <z> [<y-rot> <x-rot>]"),
+ T("/weather <clear|rain|thunder> [duration in seconds]"),
+ T("/xp <amount> [player] OR /xp <amount>L [player]")};
/* (permission level 0, or /seed in a world of one's own) */
static bool allowed(int c) { return cheats_on() || c == C_HELP || c == C_ME || c == C_SEED; }
-static const char *const mode_name[2] = {"Survival Mode", "Creative Mode"};
+static const char *const mode_name[2] = {T("Survival Mode"), T("Creative Mode")};
static const char *const modes[4] = {"survival", "creative", "adventure", "spectator"};
static const char *const diffs[4] = {"peaceful", "easy", "normal", "hard"};
-static const char *const diff_name[4] = {"Peaceful", "Easy", "Normal", "Hard"};
+static const char *const diff_name[4] = {T("Peaceful"), T("Easy"), T("Normal"), T("Hard")};
static const char *const rule_name[8] = {"keepInventory", "doDaylightCycle", "doMobSpawning", "mobGriefing",
"naturalRegeneration", "doTileDrops", "doMobLoot", "doFireTick"};
static const char *const mob_name[8] = {"Zombie", "Skeleton", "Creeper", "Spider", "Pig", "Cow", "Sheep", "Chicken"};
/* the effects NumBlocks has: Potion's ids and names */
static const uint8_t eff_id[3] = {19, 17, 10};
static const char *const eff_key[3] = {"poison", "hunger", "regeneration"};
-static const char *const eff_name[3] = {"Poison", "Hunger", "Regeneration"};
+static const char *const eff_name[3] = {T("Poison"), T("Hunger"), T("Regeneration")};
/* /gamemode, /difficulty: a name, its first letter, or its number */
static int choice(const char *s, const char *const *names, int n, const char *const *letters) {
@@ -224,12 +224,12 @@ static void cmd_gamemode(char **a, int n) {
int m = choice(a[0], modes, 4, l);
if (n > 1) player(a[1]);
if (failed) return;
- if (m > 1) return error("'%s' is not a valid number", a[0], 0, 0); /* (NumBlocks has no adventure or spectator) */
+ if (m > 1) return error(T("'%s' is not a valid number"), a[0], 0, 0); /* (NumBlocks has no adventure or spectator) */
pl.mode = (uint8_t)m;
pl.fall = 0;
if (m == 0) pl.flying = false;
- chat_add("Your game mode has been updated", CHAT_WHITE);
- ok("Set own game mode to %s", mode_name[m], 0);
+ chat_add(T("Your game mode has been updated"), CHAT_WHITE);
+ ok(T("Set own game mode to %s"), mode_name[m], 0);
}
static void cmd_time(char **a, int n) {
@@ -238,15 +238,15 @@ static void cmd_time(char **a, int n) {
long long v = !strcmp(a[1], "day") ? 1000 : !strcmp(a[1], "night") ? 13000 : num(a[1], 0, 0x7FFFFFFF);
if (failed) return;
game_time = (uint32_t)v;
- ok("Set the time to %d", NULL, v);
+ ok(T("Set the time to %d"), NULL, v);
} else if (!strcmp(a[0], "add")) {
long long v = num(a[1], 0, 0x7FFFFFFF);
if (failed) return;
game_time += (uint32_t)v;
- ok("Added %d to the time", NULL, v);
+ ok(T("Added %d to the time"), NULL, v);
} else if (!strcmp(a[0], "query")) {
- if (!strcmp(a[1], "daytime")) ok("Time is %d", NULL, game_time % 24000);
- else if (!strcmp(a[1], "gametime")) ok("Time is %d", NULL, game_time);
+ if (!strcmp(a[1], "daytime")) ok(T("Time is %d"), NULL, game_time % 24000);
+ else if (!strcmp(a[1], "gametime")) ok(T("Time is %d"), NULL, game_time);
else usage(cmd_usage[C_TIME]);
} else
usage(cmd_usage[C_TIME]);
@@ -259,13 +259,13 @@ static void cmd_weather(char **a, int n) {
if (failed) return;
if (!strcmp(a[0], "clear")) {
weather.rain_time = weather.thunder_time = 0, weather.raining = weather.thundering = 0;
- ok("Changing to clear weather", NULL, 0);
+ ok(T("Changing to clear weather"), NULL, 0);
} else if (!strcmp(a[0], "rain")) {
weather.rain_time = weather.thunder_time = t, weather.raining = 1, weather.thundering = 0;
- ok("Changing to rainy weather", NULL, 0);
+ ok(T("Changing to rainy weather"), NULL, 0);
} else if (!strcmp(a[0], "thunder")) {
weather.rain_time = weather.thunder_time = t, weather.raining = weather.thundering = 1;
- ok("Changing to rain and thunder", NULL, 0);
+ ok(T("Changing to rain and thunder"), NULL, 0);
} else
usage(cmd_usage[C_WEATHER]);
}
@@ -275,13 +275,13 @@ static void cmd_give(char **a, int n) {
player(a[0]);
if (failed) return;
int id = item_named(a[1]);
- if (id < 0) return error("There is no such item with name %s", a[1], 0, 0);
+ if (id < 0) return error(T("There is no such item with name %s"), a[1], 0, 0);
int count = n > 2 ? (int)num(a[2], 1, 64) : 1, data = n > 3 ? (int)num(a[3], -2147483647, 2147483647) : 0;
if (failed) return;
/* data: which kind (wool's colour), or for tools how worn */
int it = data >= 0 && data <= 15 ? give_of(id, data) : -1;
if (it < 0) it = give_of(id, 0);
- if (it < 0) return error("There is no such item with name %s", a[1], 0, 0);
+ if (it < 0) return error(T("There is no such item with name %s"), a[1], 0, 0);
int wear = item_dur(it) ? (data < 0 ? 0 : data > item_dur(it) ? item_dur(it) : data) : 0;
/* InventoryPlayer.addItemStackToInventory; what does not fit falls at the player's feet */
int left = inv_add(pl.inv, 36, it, count, wear);
@@ -289,7 +289,7 @@ static void cmd_give(char **a, int n) {
char lab[40] = "[";
strcat(lab, item_label(it));
strcat(lab, "]");
- say(CHAT_WHITE, "Given %s * %d to %s", lab, PLAYER, count, 0);
+ say(CHAT_WHITE, T("Given %s * %d to %s"), lab, PLAYER, count, 0);
}
static void cmd_tp(char **a, int n) {
@@ -300,7 +300,7 @@ static void cmd_tp(char **a, int n) {
if (n - i == 1) {
/* to a player: the only one is here */
player(a[i]);
- if (!failed) say(CHAT_WHITE, "Teleported %s to %s", PLAYER, PLAYER, 0, 0);
+ if (!failed) say(CHAT_WHITE, T("Teleported %s to %s"), PLAYER, PLAYER, 0, 0);
return;
}
if (n - i != 3 && n - i != 5) return usage(cmd_usage[C_TP]);
@@ -309,7 +309,7 @@ static void cmd_tp(char **a, int n) {
if (n - i == 5) yaw = coord(pl.yaw, a[i + 3], false), pitch = coord(pl.pitch, a[i + 4], false);
if (failed) return;
if (x < -30000000 || x > 30000000 || z < -30000000 || z > 30000000 || y < -512 || y > 512)
- return error("'%s' is not a valid number", a[i], 0, 0);
+ return error(T("'%s' is not a valid number"), a[i], 0, 0);
pl.x = x, pl.y = y, pl.z = z, pl.vx = pl.vy = pl.vz = 0, pl.fall = 0;
yaw = fmodf(yaw, 360);
if (yaw >= 180) yaw -= 360;
@@ -317,7 +317,7 @@ static void cmd_tp(char **a, int n) {
pl.yaw = yaw, pl.pitch = pitch < -90 ? -90 : pitch > 90 ? 90 : pitch;
camera_reset();
out_n = 0;
- put("Teleported " PLAYER " to "), put_num(x), put(", "), put_num(y), put(", "), put_num(z);
+ put(T("Teleported Player to ")), put_num(x), put(", "), put_num(y), put(", "), put_num(z);
chat_add(out, CHAT_WHITE);
}
@@ -326,7 +326,7 @@ static void cmd_kill(char **a, int n) {
if (failed) return;
/* EntityPlayer.onKillCommand: out of the world */
player_hurt(3.4e38f, DMG_VOID);
- ok("Killed %s", PLAYER, 0);
+ ok(T("Killed %s"), PLAYER, 0);
}
static void cmd_difficulty(char **a, int n) {
@@ -336,12 +336,12 @@ static void cmd_difficulty(char **a, int n) {
if (failed) return;
opt.difficulty = (uint8_t)d;
save_options();
- ok("Set game difficulty to %s", diff_name[d], 0);
+ ok(T("Set game difficulty to %s"), diff_name[d], 0);
}
static void cmd_seed(void) {
out_n = 0;
- put("Seed: "), put_int(world_seed);
+ put(T("Seed: ")), put_int(world_seed);
chat_add(out, CHAT_WHITE);
}
@@ -354,7 +354,7 @@ static void cmd_spawnpoint(char **a, int n) {
if (failed) return;
pl.spawn_x = x, pl.spawn_y = y, pl.spawn_z = z;
out_n = 0;
- put("Set " PLAYER "'s spawn point to ("), put_int(x), put(", "), put_int(y), put(", "), put_int(z), put(")");
+ put(T("Set Player's spawn point to (")), put_int(x), put(", "), put_int(y), put(", "), put_int(z), put(")");
chat_add(out, CHAT_WHITE);
}
@@ -372,12 +372,12 @@ static void cmd_xp(char **a, int n) {
/* EntityPlayer.addExperienceLevel */
pl.xp_level += (int)k;
if (pl.xp_level < 0) pl.xp_level = 0, pl.xp = 0, pl.xp_total = 0;
- if (k < 0) say(CHAT_WHITE, "Taken %d levels from %s", PLAYER, NULL, -k, 0);
- else say(CHAT_WHITE, "Given %d levels to %s", PLAYER, NULL, k, 0);
+ if (k < 0) say(CHAT_WHITE, T("Taken %d levels from %s"), PLAYER, NULL, -k, 0);
+ else say(CHAT_WHITE, T("Given %d levels to %s"), PLAYER, NULL, k, 0);
} else {
- if (k < 0) return error("Cannot give player negative experience points", NULL, 0, 0);
+ if (k < 0) return error(T("Cannot give player negative experience points"), NULL, 0, 0);
player_add_xp((int)k);
- say(CHAT_WHITE, "Given %d experience to %s", PLAYER, NULL, k, 0);
+ say(CHAT_WHITE, T("Given %d experience to %s"), PLAYER, NULL, k, 0);
}
}
@@ -386,7 +386,7 @@ static void cmd_clear(char **a, int n) {
int id = -1, data = -1, most = -1;
if (n > 1) {
id = item_named(a[1]);
- if (id < 0 && !failed) error("There is no such item with name %s", a[1], 0, 0);
+ if (id < 0 && !failed) error(T("There is no such item with name %s"), a[1], 0, 0);
}
if (n > 2) data = (int)num(a[2], -1, 2147483647);
if (n > 3) most = (int)num(a[3], -1, 2147483647);
@@ -413,8 +413,8 @@ static void cmd_clear(char **a, int n) {
if (take == c) t->id = 0, t->aux = 0;
else stack_take(t, take);
}
- if (!gone) return error("Could not clear the inventory of %s, no items to remove", PLAYER, 0, 0);
- say(CHAT_WHITE, "Cleared the inventory of %s, removing %d items", PLAYER, NULL, gone, 0);
+ if (!gone) return error(T("Could not clear the inventory of %s, no items to remove"), PLAYER, 0, 0);
+ say(CHAT_WHITE, T("Cleared the inventory of %s, removing %d items"), PLAYER, NULL, gone, 0);
}
static void cmd_effect(char **a, int n) {
@@ -424,34 +424,34 @@ static void cmd_effect(char **a, int n) {
if (!strcmp(a[1], "clear")) {
bool any = false;
for (int i = 0; i < 3; i++) any |= pl.eff[i] > 0, pl.eff[i] = 0, pl.eff_amp[i] = 0;
- if (!any) return error("Couldn't take any effects from %s as they do not have any", PLAYER, 0, 0);
- ok("Took all effects from %s", PLAYER, 0);
+ if (!any) return error(T("Couldn't take any effects from %s as they do not have any"), PLAYER, 0, 0);
+ ok(T("Took all effects from %s"), PLAYER, 0);
return;
}
const char *e = strip_ns(a[1]);
int k = -1;
for (int i = 0; i < 3; i++)
if (!strcmp(e, eff_key[i]) || (is_num(e, false) && to_int(e) == eff_id[i])) k = i;
- if (k < 0) return error(is_num(e, false) ? "There is no such mob effect with ID %d" : "There is no such mob effect with ID %s",
+ if (k < 0) return error(is_num(e, false) ? T("There is no such mob effect with ID %d") : T("There is no such mob effect with ID %s"),
e, is_num(e, false) ? to_int(e) : 0, 0);
int secs = n > 2 ? (int)num(a[2], 0, 1000000) : 30, amp = n > 3 ? (int)num(a[3], 0, 255) : 0;
if (failed) return;
if (!secs) {
if (!pl.eff[k]) {
out_n = 0;
- put("Couldn't take "), put(eff_name[k]), put(" from " PLAYER " as they do not have the effect");
+ put(T("Couldn't take ")), put(eff_name[k]), put(T(" from Player as they do not have the effect"));
return error("%s", out, 0, 0);
}
pl.eff[k] = 0;
out_n = 0;
- put("Took "), put(eff_name[k]), put(" from " PLAYER);
+ put(T("Took ")), put(eff_name[k]), put(T(" from Player"));
chat_add(out, CHAT_WHITE);
return;
}
pl.eff[k] = (uint16_t)(secs * 20 > 65535 ? 65535 : secs * 20), pl.eff_amp[k] = (uint8_t)amp;
out_n = 0;
- put("Given "), put(eff_name[k]), put(" (ID "), put_int(eff_id[k]), put(") * "), put_int(amp + 1);
- put(" to " PLAYER " for "), put_int(secs), put(" seconds");
+ put(T("Given ")), put(eff_name[k]), put(T(" (ID ")), put_int(eff_id[k]), put(T(") * ")), put_int(amp + 1);
+ put(T(" to Player for ")), put_int(secs), put(T(" seconds"));
chat_add(out, CHAT_WHITE);
}
@@ -461,19 +461,19 @@ static void cmd_summon(char **a, int n) {
if (n >= 4) x = coord(x, a[1], true), y = coord(y, a[2], false), z = coord(z, a[3], true);
if (failed) return;
if (y < 0 || y >= WORLD_H || !world_loaded((int)floorf(x), (int)floorf(y), (int)floorf(z)))
- return error("Cannot summon the object out of the world", NULL, 0, 0);
+ return error(T("Cannot summon the object out of the world"), NULL, 0, 0);
if (!strcmp(a[0], "LightningBolt")) {
bolt_start(x, y, z);
- ok("Object successfully summoned", NULL, 0);
+ ok(T("Object successfully summoned"), NULL, 0);
return;
}
for (int i = 0; i < 8; i++)
if (!strcmp(a[0], mob_name[i])) {
- if (!mob_summon(E_ZOMBIE + i, x, y, z)) return error("Unable to summon object", NULL, 0, 0);
- ok("Object successfully summoned", NULL, 0);
+ if (!mob_summon(E_ZOMBIE + i, x, y, z)) return error(T("Unable to summon object"), NULL, 0, 0);
+ ok(T("Object successfully summoned"), NULL, 0);
return;
}
- error("Unable to summon object", NULL, 0, 0);
+ error(T("Unable to summon object"), NULL, 0, 0);
}
static void cmd_setblock(char **a, int n) {
@@ -482,28 +482,28 @@ static void cmd_setblock(char **a, int n) {
z = (int)floorf(coord(floorf(pl.z), a[2], false));
if (failed) return;
int id = block_named(a[3]);
- if (id < 0) return error("There is no such block with ID/name %s", a[3], 0, 0);
+ if (id < 0) return error(T("There is no such block with ID/name %s"), a[3], 0, 0);
int data = n > 4 ? (int)num(a[4], 0, 15) : 0;
if (failed) return;
- if (y < 0 || y >= WORLD_H || !world_loaded(x, y, z)) return error("Cannot place block outside of the world", NULL, 0, 0);
+ if (y < 0 || y >= WORLD_H || !world_loaded(x, y, z)) return error(T("Cannot place block outside of the world"), NULL, 0, 0);
/* the state: the block's with that data, else its first */
int b = -1;
for (int i = 0; i < B_COUNT && b < 0; i++)
if (blk_id[i] == id && blk_meta[i] == data) b = i;
for (int i = 0; i < B_COUNT && b < 0; i++)
if (blk_id[i] == id) b = i;
- if (b < 0) return error("There is no such block with ID/name %s", a[3], 0, 0);
+ if (b < 0) return error(T("There is no such block with ID/name %s"), a[3], 0, 0);
int was = world_get(x, y, z);
if (n > 5) {
- if (!strcmp(a[5], "keep") && was != B_AIR) return error("The block couldn't be placed", NULL, 0, 0);
+ if (!strcmp(a[5], "keep") && was != B_AIR) return error(T("The block couldn't be placed"), NULL, 0, 0);
if (!strcmp(a[5], "destroy")) break_block_at(x, y, z, true);
}
- if (world_get(x, y, z) == b) return error("The block couldn't be placed", NULL, 0, 0);
+ if (world_get(x, y, z) == b) return error(T("The block couldn't be placed"), NULL, 0, 0);
/* (a chest or furnace replaced is emptied first, nothing falls out) */
tiles_forget(x, y, z);
world_set(x, y, z, b);
neighbours_changed(x, y, z);
- ok("Block placed", NULL, 0);
+ ok(T("Block placed"), NULL, 0);
}
static void cmd_gamerule(char **a, int n) {
@@ -517,7 +517,7 @@ static void cmd_gamerule(char **a, int n) {
int r = -1;
for (int i = 0; i < 8; i++)
if (!strcmp(a[0], rule_name[i])) r = i;
- if (r < 0) return error("No game rule called '%s' is available", a[0], 0, 0);
+ if (r < 0) return error(T("No game rule called '%s' is available"), a[0], 0, 0);
if (n == 1) {
out_n = 0;
put(rule_name[r]), put(" = "), put(rule(1 << r) ? "true" : "false");
@@ -527,7 +527,7 @@ static void cmd_gamerule(char **a, int n) {
/* (GameRules.setOrCreateGameRule: true is "true", anything else false) */
if (!strcmp(a[1], "true")) game_rules |= (uint8_t)(1 << r);
else game_rules &= (uint8_t)~(1 << r);
- ok("Game rule has been updated", NULL, 0);
+ ok(T("Game rule has been updated"), NULL, 0);
}
static void cmd_help(char **a, int n) {
@@ -539,14 +539,14 @@ static void cmd_help(char **a, int n) {
if (n > 0) {
for (int c = 0; c < N_COMMANDS; c++)
if (!strcmp(a[0], cmd_name[c]) && allowed(c)) return usage(cmd_usage[c]);
- if (!is_num(a[0], false)) return error("Unknown command. Try /help for a list of commands", NULL, 0, 0);
+ if (!is_num(a[0], false)) return error(T("Unknown command. Try /help for a list of commands"), NULL, 0, 0);
page = (int)num(a[0], 1, pages + 1) - 1;
if (failed) return;
}
- say(CHAT_DARK_GREEN, "--- Showing help page %d of %d (/help <page>) ---", NULL, NULL, page + 1, pages + 1);
+ say(CHAT_DARK_GREEN, T("--- Showing help page %d of %d (/help <page>) ---"), NULL, NULL, page + 1, pages + 1);
for (int i = page * 7; i < k && i < page * 7 + 7; i++) chat_add(cmd_usage[list[i]], CHAT_WHITE);
if (page == 0)
- chat_add("Tip: Use the toolbox key while typing a command to auto-complete the command or its arguments",
+ chat_add(T("Tip: Use the toolbox key while typing a command to auto-complete the command or its arguments"),
CHAT_GREEN);
}
@@ -579,8 +579,8 @@ void command_run(const char *line) {
if (!strcmp(w[0], cmd_name[i])) c = i;
if (n && !strcmp(w[0], "?")) c = C_HELP;
failed = false;
- if (c < 0) return error("Unknown command. Try /help for a list of commands", NULL, 0, 0);
- if (!allowed(c)) return error("You do not have permission to use this command", NULL, 0, 0);
+ if (c < 0) return error(T("Unknown command. Try /help for a list of commands"), NULL, 0, 0);
+ if (!allowed(c)) return error(T("You do not have permission to use this command"), NULL, 0, 0);
char **a = w + 1;
n--;
switch (c) {
@@ -607,7 +607,7 @@ void command_run(const char *line) {
case C_TIME: cmd_time(a, n); break;
case C_TOGGLEDOWNFALL:
weather.raining = !weather.raining;
- ok("Toggled downfall", NULL, 0);
+ ok(T("Toggled downfall"), NULL, 0);
break;
case C_TP: cmd_tp(a, n); break;
case C_WEATHER: cmd_weather(a, n); break;
diff --git a/games/numblocks/src/gui.c b/games/numblocks/src/gui.c
index 447547b2..c7732ce6 100644
--- a/games/numblocks/src/gui.c
+++ b/games/numblocks/src/gui.c
@@ -104,6 +104,57 @@ static const uint8_t sym_bits[5][8] = {{0x00, 0x3F, 0x12, 0x12, 0x12, 0x12, 0x21
{0x00, 0x04, 0x00, 0x1F, 0x00, 0x04, 0x00, 0x00}};
static const uint8_t sym_w[5] = {7, 8, 9, 6, 6};
static int char_w(int c) { return c >= 1 && c <= 5 ? sym_w[c - 1] : c >= 32 && c < 127 ? font_w[c - 32] : 0; }
+#if NP_TEXT_EXTRA
+/* Other languages: an accented letter is the font's own with np_accent() in the two rows over lowercase letters
+ * (a capital under it as a small capital: its rows 0, 1, 2, 4 and 6), a cedilla under it; an accented i three
+ * columns wide, as Minecraft's are; œ and æ two letters sharing a column. Chinese comes from the 12-pixel font
+ * (11 pixels tall), its line's top 2 pixels over the text's; a Chinese build's lines are further apart (TALL). */
+#define TALL ((uint8_t)T("Done")[0] >= 0xE0)
+static uint16_t pen;
+static void pen_px(int x, int y, void *ctx) {
+ if (y >= clip_y0 && y < clip_y1 && (unsigned)x < SCREEN_W) row_at(y)[x] = pen;
+}
+static void glyph(int c, int x, int y, int scale, bool small, int from) {
+ static const int8_t small_rows[8] = {-1, -1, 0, 1, 2, 4, 6, 7};
+ const uint8_t *g = c < 32 ? sym_bits[c - 1] : font_bits + (c - 32) * 8;
+ for (int j = 0; j < 8; j++) {
+ int r = small ? small_rows[j] : j;
+ if (r < from) continue;
+ for (int k = 0; k < 8; k++)
+ if (g[r] >> k & 1)
+ for (int a = 0; a < scale * scale; a++) pen_px(x + k * scale + a % scale, y + j * scale + a / scale, 0);
+ }
+}
+/* draws (if draw) the next letter of *s at (x, y) in pen, each font pixel scale x scale; returns its advance */
+static int letter(const char **s, int x, int y, int scale, bool draw) {
+ uint32_t cp = np_utf8(s);
+ char b = (char)cp, b2 = 0;
+ int acc = 0;
+ if (cp >= 0x80 && (acc = np_latin(cp, &b, &b2), !b)) {
+ if (draw) np_xdraw(cp, x, y - 2 * scale, scale, pen_px, 0);
+ return np_xadvance(cp, scale);
+ }
+ if (!char_w((uint8_t)b)) return 0;
+ bool over = acc && acc != NP_ACC_CEDIL, thin = acc && (b == 'i' || b == 'I');
+ int w = b == 'i' && acc ? 4 : char_w((uint8_t)b), lig = (b2 | 32) == 'e' ? 2 : 0;
+ if (draw) {
+ glyph(b, b == 'i' && acc ? x + scale : x, y, scale, over && b >= 'A' && b <= 'Z', b == 'i' && acc);
+ np_accent(acc, thin ? x - scale : x, acc == NP_ACC_CEDIL ? y + 7 * scale : y, scale, pen_px, 0);
+ if (b2) glyph(b2, x + (w - lig) * scale, y, scale, false, 0);
+ }
+ return (w + (b2 ? char_w((uint8_t)b2) - lig : 0)) * scale;
+}
+int text_width(const char *s) {
+ int w = 0;
+ while (*s) w += letter(&s, 0, 0, 1, false);
+ return w;
+}
+static void glyphs(const char *s, int x, int y, uint16_t col, int scale) {
+ pen = col;
+ while (*s) x += letter(&s, x, y, scale, true);
+}
+#else
+#define TALL 0
int text_width(const char *s) {
int w = 0;
for (; *s; s++) w += char_w((unsigned char)*s);
@@ -126,16 +177,17 @@ static void glyphs(const char *s, int x, int y, uint16_t col, int scale) {
x += char_w(c) * scale;
}
}
+#endif
/* drawStringWithShadow: the shadow is the colour at a quarter, one pixel down and right */
static void text(const char *s, int x, int y, uint16_t col, bool shadow) {
- if (y + 9 <= clip_y0 || y >= clip_y1) return;
+ if (y + (NP_TEXT_EXTRA ? 11 : 9) <= clip_y0 || y - (NP_TEXT_EXTRA ? 2 : 0) >= clip_y1) return;
if (shadow) glyphs(s, x + 1, y + 1, (uint16_t)((col >> 2) & 0x39E7), 1);
glyphs(s, x, y, col, 1);
}
static void text_center(const char *s, int cx, int y, uint16_t col) { text(s, cx - text_width(s) / 2, y, col, true); }
static void text_big(const char *s, int cx, int y, uint16_t col, int scale) {
int w = text_width(s) * scale;
- if (y + 9 * scale <= clip_y0 || y >= clip_y1) return;
+ if (y + (NP_TEXT_EXTRA ? 11 : 9) * scale <= clip_y0 || y - (NP_TEXT_EXTRA ? 2 * scale : 0) >= clip_y1) return;
glyphs(s, cx - w / 2 + scale, y + scale, (uint16_t)((col >> 2) & 0x39E7), scale);
glyphs(s, cx - w / 2, y, col, scale);
}
@@ -209,6 +261,19 @@ static int chat_age(int i) { return (uint16_t)(chat_clock - ((uint8_t)chat[i + 1
/* how much of s fits on a line w pixels wide: up to a space if it can (FontRenderer.sizeStringToWidth) */
static int wrap_len(const char *s, int w) {
+#if NP_TEXT_EXTRA /* (by letter; a line may end after a Chinese one too) */
+ int x = 0, sp = -1;
+ const char *p = s;
+ while (*p) {
+ int i = (int)(p - s);
+ bool wide = (uint8_t)*p >= 0xE0;
+ if (*p == ' ') sp = i;
+ x += letter(&p, 0, 0, 1, false);
+ if (x > w) return sp > 0 ? sp : i > 0 ? i : (int)(p - s);
+ if (wide) sp = (int)(p - s);
+ }
+ return (int)(p - s);
+#else
int x = 0, i = 0, sp = -1;
for (; s[i]; i++) {
if (s[i] == ' ') sp = i;
@@ -216,16 +281,18 @@ static int wrap_len(const char *s, int w) {
if (x > w) return sp > 0 ? sp : i > 0 ? i : 1;
}
return i;
+#endif
}
/* GuiNewChat.drawChat: the newest at the bottom, 9 pixels a line on a dark band; each fades out after
* 10 seconds (10 lines at most), or with the chat open all of them (20 lines) */
+#define CHAT_H (TALL ? 12 : 9) /* a line's height */
static void chat_lines(void) {
bool open = gui == GUI_CHAT;
- if (SCREEN_H - 28 - (open ? 20 : 10) * 9 >= clip_y1 || SCREEN_H - 28 <= clip_y0) return;
+ if (SCREEN_H - 28 - (open ? 20 : 10) * CHAT_H >= clip_y1 || SCREEN_H - 28 <= clip_y0) return;
int at[64], n = 0;
for (int i = 0; i < chat_used && n < 64; i += chat_size(i)) at[n++] = i;
- int line = 0, most = open ? 20 : 10;
+ int line = 0, most = open ? (TALL ? 15 : 20) : 10;
for (int m = n - 1; m >= 0 && line < most; m--) {
int age = chat_age(at[m]), a = 32;
if (!open) {
@@ -243,14 +310,14 @@ static void chat_lines(void) {
if (*s == ' ') s++;
}
for (int j = k - 1; j >= 0 && line < most; j--, line++) {
- int y = SCREEN_H - 28 - line * 9;
- if (y <= clip_y0 || y - 9 >= clip_y1) continue;
- tint_rect(2, y - 9, SCREEN_W - 2, 9, 0, a / 2);
+ int y = SCREEN_H - 28 - line * CHAT_H;
+ if (y <= clip_y0 || y - CHAT_H >= clip_y1) continue;
+ tint_rect(2, y - CHAT_H, SCREEN_W - 2, CHAT_H, 0, a / 2);
if (a > 3) {
- char t[64];
- int l = ll[j] < 63 ? ll[j] : 63;
+ char t[NP_TEXT_EXTRA ? 96 : 64];
+ int l = ll[j] < (int)sizeof t - 1 ? ll[j] : (int)sizeof t - 1;
memcpy(t, ls[j], (size_t)l), t[l] = 0;
- text(t, 2, y - 8, chat_col[(int)chat[at[m]]], true);
+ text(t, 2, y - 8 - (TALL ? 1 : 0), chat_col[(int)chat[at[m]]], true);
}
}
}
@@ -483,6 +550,33 @@ static const uint16_t tab_icon[12] = {B_BRICKS, B_PEONY_LOWER, I_REDSTONE, B_RAI
#define TAB_SEARCH 5
static char csearch[16]; /* Search Items: what is typed (GuiContainerCreative.searchField) */
/* an item whose name has what is typed in it (updateCreativeSearch) */
+#if NP_TEXT_EXTRA
+/* (other languages: accented letters found by their plain letter; and by Minecraft's name, typed with spaces for
+ * its _, as letters typed can't be Chinese ones) */
+static bool has(const char *n) {
+ for (; *n; n++) {
+ const char *p = n;
+ int k = 0;
+ for (; csearch[k] && *p; k++) {
+ uint32_t c = np_utf8(&p);
+ char b = (char)c, b2;
+ if (c >= 0x80) np_latin(c, &b, &b2);
+ if (((b == '_' ? ' ' : b) | 32) != csearch[k]) break;
+ }
+ if (!csearch[k]) return true;
+ }
+ return false;
+}
+static bool found(int id) {
+ if (!csearch[0] || has(item_label(id))) return true;
+ for (int g = 0; g < n_give; g++)
+ if (give_id[g] == id) {
+ int k = give_key[g] >> 4;
+ return has(k < 256 ? mc_block_name[k] : mc_item_name[k - 256]);
+ }
+ return false;
+}
+#else
static bool found(int id) {
const char *n = item_label(id);
for (; *n; n++) {
@@ -492,6 +586,7 @@ static bool found(int id) {
}
return !csearch[0];
}
+#endif
static int tab_count(void) {
int n = tab_start[ctab + 1] - tab_start[ctab];
if (ctab != TAB_SEARCH || !csearch[0]) return n;
@@ -843,7 +938,7 @@ static void move_cursor(int dx, int dy) {
/* ---------------------------------------------------------------- menus
* GuiMainMenu, GuiSelectWorld, GuiCreateWorld, GuiYesNo, GuiOptions,
* GuiIngameMenu, GuiGameOver: their buttons where 1.8 puts them. */
-typedef struct { int16_t x, y, w; uint8_t on, id; char label[32]; } Button;
+typedef struct { int16_t x, y, w; uint8_t on, id; char label[NP_TEXT_EXTRA ? 48 : 32]; } Button;
static Button buttons[12];
static int nbuttons, bcur;
enum { B_NO, B_SINGLE, B_OPTIONS, B_QUITAPP, B_PLAY, B_CREATE, B_DELETE, B_CANCEL, B_MODE, B_SEED, B_DOCREATE,
@@ -926,7 +1021,10 @@ static void field_input(void) {
else if (k <= 3) f_sel = false; /* (the arrows) */
else if (k == RK_BACKSPACE) {
if (f_sel) t[n = 0] = 0, f_sel = false;
- else if (n > 0) t[--n] = 0;
+ else if (n > 0) {
+ while (NP_TEXT_EXTRA && n > 1 && (t[n - 1] & 0xC0) == 0x80) n--; /* (a whole letter) */
+ t[--n] = 0;
+ }
} else if (k == RK_OK || k == RK_EXE || k == RK_BACK) {
if (gui == GUI_RENAME && k != RK_BACK && name_text[0]) {
/* (OK in the rename screen's field: rename, as Enter does) */
@@ -1068,8 +1166,8 @@ static void chat_input(void) {
static void chat_screen(void) {
if (clip_y0 < 22) {
tint_rect(0, 0, SCREEN_W, 22, 0, 16);
- text_center("alpha: abc/123 shift: Abc toolbox: finish the word", SCREEN_W / 2, 2, RGB(0xA0, 0xA0, 0xA0));
- text_center("x,n,t : var _ x10^x ~ ans space 0 @", SCREEN_W / 2, 12, RGB(0xA0, 0xA0, 0xA0));
+ text_center(T("alpha: abc/123 shift: Abc toolbox: finish the word"), SCREEN_W / 2, 2, RGB(0xA0, 0xA0, 0xA0));
+ text_center(T("x,n,t : var _ x10^x ~ ans space 0 @"), SCREEN_W / 2, 12, RGB(0xA0, 0xA0, 0xA0));
}
if (clip_y1 <= SCREEN_H - 14) return;
tint_rect(2, SCREEN_H - 14, SCREEN_W - 4, 12, 0, 16);
@@ -1085,7 +1183,7 @@ static void add_button(int x, int y, int w, int on, int id, const char *label) {
Button *b = &buttons[nbuttons++];
*b = (Button){(int16_t)x, (int16_t)y, (int16_t)w, (uint8_t)on, (uint8_t)id, {0}};
int i = 0;
- for (; label[i] && i < 31; i++) b->label[i] = label[i];
+ for (; label[i] && i < (int)sizeof b->label - 1; i++) b->label[i] = label[i];
b->label[i] = 0;
}
static void cat(char *d, const char *a, const char *b) {
@@ -1097,92 +1195,92 @@ static void cat(char *d, const char *a, const char *b) {
static void menu(int screen) {
nbuttons = 0;
int w = SCREEN_W, h = SCREEN_H;
- char t[40];
+ char t[NP_TEXT_EXTRA ? 64 : 40];
switch (screen) {
case GUI_TITLE: {
int j = h / 4 + 48;
- add_button(w / 2 - 100, j, 200, 1, B_SINGLE, "Singleplayer");
- add_button(w / 2 - 100, j + 24, 200, 0, B_NO, "Multiplayer");
- add_button(w / 2 - 100, j + 72 + 12 - 24, 98, 1, B_OPTIONS, "Options...");
- add_button(w / 2 + 2, j + 72 + 12 - 24, 98, 1, B_QUITAPP, "Quit Game");
+ add_button(w / 2 - 100, j, 200, 1, B_SINGLE, T("Singleplayer"));
+ add_button(w / 2 - 100, j + 24, 200, 0, B_NO, T("Multiplayer"));
+ add_button(w / 2 - 100, j + 72 + 12 - 24, 98, 1, B_OPTIONS, T("Options..."));
+ add_button(w / 2 + 2, j + 72 + 12 - 24, 98, 1, B_QUITAPP, T("Quit Game"));
break;
}
case GUI_WORLDS: {
bool any = nworlds > 0;
- add_button(w / 2 - 154, h - 52, 150, any, B_PLAY, "Play Selected World");
- add_button(w / 2 + 4, h - 52, 150, world_free_slot() != 0, B_CREATE, "Create New World");
- add_button(w / 2 - 154, h - 28, 72, any, B_RENAME, "Rename");
- add_button(w / 2 - 76, h - 28, 72, any, B_DELETE, "Delete");
- add_button(w / 2 + 4, h - 28, 72, any && world_free_slot() != 0, B_RECREATE, "Re-Create");
- add_button(w / 2 + 82, h - 28, 72, 1, B_CANCEL, "Cancel");
+ add_button(w / 2 - 154, h - 52, 150, any, B_PLAY, T("Play Selected World"));
+ add_button(w / 2 + 4, h - 52, 150, world_free_slot() != 0, B_CREATE, T("Create New World"));
+ add_button(w / 2 - 154, h - 28, 72, any, B_RENAME, T("Rename"));
+ add_button(w / 2 - 76, h - 28, 72, any, B_DELETE, T("Delete"));
+ add_button(w / 2 + 4, h - 28, 72, any && world_free_slot() != 0, B_RECREATE, T("Re-Create"));
+ add_button(w / 2 + 82, h - 28, 72, 1, B_CANCEL, T("Cancel"));
break;
}
case GUI_CREATE:
add_button(w / 2 - 100, 60, 200, 1, B_NAME, name_text); /* (drawn as a field) */
- cat(t, "Game Mode: ", create_mode ? "Creative" : "Survival");
+ cat(t, T("Game Mode: "), create_mode ? T("Creative") : T("Survival"));
add_button(w / 2 - 155, 100, 150, 1, B_MODE, t);
- cat(t, "Allow Cheats: ", create_cheats ? "ON" : "OFF");
+ cat(t, T("Allow Cheats: "), create_cheats ? T("ON") : T("OFF"));
add_button(w / 2 + 5, 100, 150, 1, B_CHEATS, t);
- cat(t, "Seed: ", seed_text[0] ? seed_text : (field == F_SEED ? "" : "(random)"));
+ cat(t, T("Seed: "), seed_text[0] ? seed_text : (field == F_SEED ? "" : T("(random)")));
add_button(w / 2 - 100, 146, 200, 1, B_SEED, t);
- cat(t, "World Type: ", create_type == WT_FLAT ? "Superflat" : "Default");
+ cat(t, T("World Type: "), create_type == WT_FLAT ? T("Superflat") : T("Default"));
add_button(w / 2 - 100, 182, 200, 1, B_TYPE, t);
- add_button(w / 2 - 155, h - 28, 150, 1, B_DOCREATE, "Create New World");
- add_button(w / 2 + 5, h - 28, 150, 1, B_CANCEL, "Cancel");
+ add_button(w / 2 - 155, h - 28, 150, 1, B_DOCREATE, T("Create New World"));
+ add_button(w / 2 + 5, h - 28, 150, 1, B_CANCEL, T("Cancel"));
break;
case GUI_RENAME:
/* GuiRenameWorld */
add_button(w / 2 - 100, 60, 200, 1, B_NAME, name_text);
- add_button(w / 2 - 100, h / 4 + 96 + 12, 200, name_text[0] != 0, B_DORENAME, "Rename");
- add_button(w / 2 - 100, h / 4 + 120 + 12, 200, 1, B_CANCEL, "Cancel");
+ add_button(w / 2 - 100, h / 4 + 96 + 12, 200, name_text[0] != 0, B_DORENAME, T("Rename"));
+ add_button(w / 2 - 100, h / 4 + 120 + 12, 200, 1, B_CANCEL, T("Cancel"));
break;
case GUI_CONFIRM:
- add_button(w / 2 - 155, h / 6 + 96, 150, 1, B_DODELETE, "Delete");
- add_button(w / 2 + 5, h / 6 + 96, 150, 1, B_CANCEL, "Cancel");
+ add_button(w / 2 - 155, h / 6 + 96, 150, 1, B_DODELETE, T("Delete"));
+ add_button(w / 2 + 5, h / 6 + 96, 150, 1, B_CANCEL, T("Cancel"));
break;
case GUI_OPTIONS: {
- static const char *const diff[4] = {"Peaceful", "Easy", "Normal", "Hard"};
- cat(t, "Difficulty: ", diff[opt.difficulty & 3]);
+ static const char *const diff[4] = {T("Peaceful"), T("Easy"), T("Normal"), T("Hard")};
+ cat(t, T("Difficulty: "), diff[opt.difficulty & 3]);
add_button(w / 2 - 155, h / 6 - 12, 150, 1, B_DIFF, t);
- cat(t, "Graphics: ", opt.fancy ? "Fancy" : "Fast");
+ cat(t, T("Graphics: "), opt.fancy ? T("Fancy") : T("Fast"));
add_button(w / 2 + 5, h / 6 - 12, 150, 1, B_GFX, t);
char n[8];
number(opt.look, n);
- cat(t, "Look Speed: ", n);
+ cat(t, T("Look Speed: "), n);
int k = (int)strlen(t);
t[k] = '%', t[k + 1] = 0;
add_button(w / 2 - 155, h / 6 + 12, 150, 1, B_LOOK, t);
- cat(t, "Clouds: ", opt.clouds ? "ON" : "OFF");
+ cat(t, T("Clouds: "), opt.clouds ? T("ON") : T("OFF"));
add_button(w / 2 + 5, h / 6 + 12, 150, 1, B_CLOUDS, t);
- cat(t, "View Bobbing: ", opt.bobbing ? "ON" : "OFF");
+ cat(t, T("View Bobbing: "), opt.bobbing ? T("ON") : T("OFF"));
add_button(w / 2 - 155, h / 6 + 36, 150, 1, B_BOB, t);
- add_button(w / 2 + 5, h / 6 + 36, 150, 1, B_CONTROLS, "Controls...");
- add_button(w / 2 - 100, h / 6 + 168, 200, 1, B_DONE, "Done");
+ add_button(w / 2 + 5, h / 6 + 36, 150, 1, B_CONTROLS, T("Controls..."));
+ add_button(w / 2 - 100, h / 6 + 168, 200, 1, B_DONE, T("Done"));
break;
case GUI_CONTROLS:
- add_button(w / 2 - 100, h - 22, 200, 1, B_CONTROLS_DONE, "Done");
+ add_button(w / 2 - 100, h - 22, 200, 1, B_CONTROLS_DONE, T("Done"));
break;
}
case GUI_PAUSE:
- add_button(w / 2 - 100, h / 4 + 24 - 16, 200, 1, B_BACK_GAME, "Back to Game");
- add_button(w / 2 - 100, h / 4 + 48 - 16, 98, 0, B_NO, "Achievements");
- add_button(w / 2 + 2, h / 4 + 48 - 16, 98, 0, B_NO, "Statistics");
- add_button(w / 2 - 100, h / 4 + 96 - 16, 98, 1, B_OPTIONS, "Options...");
- add_button(w / 2 + 2, h / 4 + 96 - 16, 98, !lan_open, B_LAN, "Open to LAN");
- add_button(w / 2 - 100, h / 4 + 120 - 16, 200, 1, B_SAVEQUIT, "Save and Quit to Title");
+ add_button(w / 2 - 100, h / 4 + 24 - 16, 200, 1, B_BACK_GAME, T("Back to Game"));
+ add_button(w / 2 - 100, h / 4 + 48 - 16, 98, 0, B_NO, T("Achievements"));
+ add_button(w / 2 + 2, h / 4 + 48 - 16, 98, 0, B_NO, T("Statistics"));
+ add_button(w / 2 - 100, h / 4 + 96 - 16, 98, 1, B_OPTIONS, T("Options..."));
+ add_button(w / 2 + 2, h / 4 + 96 - 16, 98, !lan_open, B_LAN, T("Open to LAN"));
+ add_button(w / 2 - 100, h / 4 + 120 - 16, 200, 1, B_SAVEQUIT, T("Save and Quit to Title"));
break;
case GUI_LAN:
/* GuiShareToLan */
- cat(t, "Game Mode: ", lan_mode ? "Creative" : "Survival");
+ cat(t, T("Game Mode: "), lan_mode ? T("Creative") : T("Survival"));
add_button(w / 2 - 155, 100, 150, 1, B_LAN_MODE, t);
- cat(t, "Allow Cheats: ", lan_allow ? "ON" : "OFF");
+ cat(t, T("Allow Cheats: "), lan_allow ? T("ON") : T("OFF"));
add_button(w / 2 + 5, 100, 150, 1, B_LAN_CHEATS, t);
- add_button(w / 2 - 155, h - 28, 150, 1, B_LAN_START, "Start LAN World");
- add_button(w / 2 + 5, h - 28, 150, 1, B_CANCEL, "Cancel");
+ add_button(w / 2 - 155, h - 28, 150, 1, B_LAN_START, T("Start LAN World"));
+ add_button(w / 2 + 5, h - 28, 150, 1, B_CANCEL, T("Cancel"));
break;
case GUI_DEATH:
- add_button(w / 2 - 100, h / 4 + 72, 200, 1, B_RESPAWN, "Respawn");
- add_button(w / 2 - 100, h / 4 + 96, 200, 1, B_TITLE, "Title screen");
+ add_button(w / 2 - 100, h / 4 + 72, 200, 1, B_RESPAWN, T("Respawn"));
+ add_button(w / 2 - 100, h / 4 + 96, 200, 1, B_TITLE, T("Title screen"));
break;
}
if (bcur >= nbuttons || !buttons[bcur].on)
@@ -1228,14 +1326,14 @@ static void press(int id) {
create_mode = 0, create_type = WT_DEFAULT;
create_cheats = cheats_set = false;
seed_text[0] = 0;
- world_unique_name("New World", name_text);
+ world_unique_name(T("New World"), name_text);
gui_menu(GUI_CREATE);
break;
case B_RECREATE: {
/* GuiCreateWorld.func_146318_a: a new world as the selected one began, "Copy of" its name */
if (!selected(&wi)) break;
char n[WORLD_NAME + 9];
- cat(n, "Copy of ", wi.name);
+ cat(n, T("Copy of "), wi.name);
n[WORLD_NAME] = 0;
world_unique_name(n, name_text);
create_mode = wi.mode;
@@ -1417,6 +1515,10 @@ static void dirt_background(void) {
/* ---------------------------------------------------------------- the key sheet */
/* a key's name, a character after ^ raised (x^y) */
static void key_text(const char *s, int cx, int y, uint16_t col) {
+ if (NP_TEXT_EXTRA && !strchr(s, '^')) {
+ text(s, cx - text_width(s) / 2, y, col, true);
+ return;
+ }
int w = 0;
for (const char *c = s; *c; c++) w += *c == '^' ? 0 : char_w((unsigned char)*c);
int x = cx - w / 2;
@@ -1458,25 +1560,25 @@ static void arrow_pad(int cx, int cy, int r) {
fill(cx - r + 3 + i, cy - i, 1, 2 * i, 0xFFFF);
fill(cx + r - 4 - i, cy - i, 1, 2 * i, 0xFFFF);
}
- text_center("Look", cx, cy - 4, RGB(0xFF, 0xFF, 0xA0));
+ text_center(T("Look"), cx, cy - 4, RGB(0xFF, 0xFF, 0xA0));
}
/* ---------------------------------------------------------------- the keys (KeyBinding) */
typedef struct { uint32_t bit; uint8_t key; const char *name, *what; } Action;
/* (what: the key sheet's word for it; key: where it starts) */
static const Action actions[N_ACTIONS] = {
- {K_ATTACK, 4, "Attack/Destroy", "Mine, attack"}, {0, 20, "Pick Block", "Pick block"},
- {K_USE, 5, "Use Item/Place Block", "Place, use"}, {K_DROP, 14, "Drop Item", "Drop"},
- {K_SLOT1, 42, "Hotbar Slot 1", "Slot 1"}, {K_SLOT1 << 1, 43, "Hotbar Slot 2", "Slot 2"},
- {K_SLOT1 << 2, 44, "Hotbar Slot 3", "Slot 3"}, {K_SLOT1 << 3, 36, "Hotbar Slot 4", "Slot 4"},
- {K_SLOT1 << 4, 37, "Hotbar Slot 5", "Slot 5"}, {K_SLOT1 << 5, 38, "Hotbar Slot 6", "Slot 6"},
- {K_SLOT1 << 6, 30, "Hotbar Slot 7", "Slot 7"}, {K_SLOT1 << 7, 31, "Hotbar Slot 8", "Slot 8"},
- {K_SLOT1 << 8, 32, "Hotbar Slot 9", "Slot 9"}, {K_INV, 15, "Inventory", "Inventory"},
- {K_PAUSE, 51, "Pause", "Pause"}, {K_JUMP, 12, "Jump", "Jump"}, {K_SNEAK, 13, "Sneak", "Sneak"},
- {K_SPRINT, 17, "Sprint", "Sprint"}, {K_STRAFE_L, 27, "Strafe Left", "Left"},
- {K_STRAFE_R, 29, "Strafe Right", "Right"}, {K_BACKW, 28, "Walk Backwards", "Backward"},
- {K_FWD, 22, "Walk Forwards", "Forward"}, {K_CHAT, 39, "Open Chat", "Chat"},
- {K_COMMAND, 40, "Open Command", "Command"}};
-static const char *const categories[5] = {"Gameplay", "Inventory", "Miscellaneous", "Movement", "Multiplayer"};
+ {K_ATTACK, 4, T("Attack/Destroy"), T("Mine, attack")}, {0, 20, T("Pick Block"), T("Pick block")},
+ {K_USE, 5, T("Use Item/Place Block"), T("Place, use")}, {K_DROP, 14, T("Drop Item"), T("Drop")},
+ {K_SLOT1, 42, T("Hotbar Slot 1"), T("Slot 1")}, {K_SLOT1 << 1, 43, T("Hotbar Slot 2"), T("Slot 2")},
+ {K_SLOT1 << 2, 44, T("Hotbar Slot 3"), T("Slot 3")}, {K_SLOT1 << 3, 36, T("Hotbar Slot 4"), T("Slot 4")},
+ {K_SLOT1 << 4, 37, T("Hotbar Slot 5"), T("Slot 5")}, {K_SLOT1 << 5, 38, T("Hotbar Slot 6"), T("Slot 6")},
+ {K_SLOT1 << 6, 30, T("Hotbar Slot 7"), T("Slot 7")}, {K_SLOT1 << 7, 31, T("Hotbar Slot 8"), T("Slot 8")},
+ {K_SLOT1 << 8, 32, T("Hotbar Slot 9"), T("Slot 9")}, {K_INV, 15, T("Inventory"), T("Inventory")},
+ {K_PAUSE, 51, T("Pause"), T("Pause")}, {K_JUMP, 12, T("Jump"), T("Jump")}, {K_SNEAK, 13, T("Sneak"), T("Sneak")},
+ {K_SPRINT, 17, T("Sprint"), T("Sprint")}, {K_STRAFE_L, 27, T("Strafe Left"), T("Left")},
+ {K_STRAFE_R, 29, T("Strafe Right"), T("Right")}, {K_BACKW, 28, T("Walk Backwards"), T("Backward")},
+ {K_FWD, 22, T("Walk Forwards"), T("Forward")}, {K_CHAT, 39, T("Open Chat"), T("Chat")},
+ {K_COMMAND, 40, T("Open Command"), T("Command")}};
+static const char *const categories[5] = {T("Gameplay"), T("Inventory"), T("Miscellaneous"), T("Movement"), T("Multiplayer")};
static const uint8_t category_at[5] = {A_ATTACK, A_DROP, A_PAUSE, A_JUMP, A_CHAT};
void keys_reset(void) {
@@ -1503,12 +1605,12 @@ uint32_t keys_of(uint64_t raw) {
/* the key's name, as the calculator writes it */
static const char *key_name(int k) {
static const char *const names[52] = {
- [4] = "OK", [5] = "Back", [12] = "shift", [13] = "alpha", [14] = "x,n,t", [15] = "var", [16] = "toolbox",
+ [4] = "OK", [5] = T("Back"), [12] = "shift", [13] = "alpha", [14] = "x,n,t", [15] = "var", [16] = T("toolbox"),
[17] = "\3", [18] = "e^x", [19] = "ln", [20] = "log", [21] = "i", [22] = ",", [23] = "x^y", [24] = "sin",
[25] = "cos", [26] = "tan", [27] = "\1", [28] = "\2", [29] = "x^2", [30] = "7", [31] = "8", [32] = "9",
[33] = "(", [34] = ")", [36] = "4", [37] = "5", [38] = "6", [39] = "\4", [40] = "\5", [42] = "1", [43] = "2",
[44] = "3", [45] = "+", [46] = "-", [48] = "0", [49] = ".", [50] = "x10^x", [51] = "ans"};
- return k < 52 && names[k] ? names[k] : "NONE";
+ return k < 52 && names[k] ? names[k] : T("NONE");
}
static const char *action_on(int k) {
for (int a = 0; a < N_ACTIONS; a++)
@@ -1517,35 +1619,35 @@ static const char *action_on(int k) {
}
static void key_sheet(void) {
- text_center("Controls", SCREEN_W / 2, 4, 0xFFFF);
+ text_center(T("Controls"), SCREEN_W / 2, 4, 0xFFFF);
arrow_pad(40, 45, 27);
- key(130, 30, 60, "Home", "Save, quit");
+ key(130, 30, 60, T("Home"), T("Save, quit"));
key(236, 14, 80, "OK", action_on(4));
- key(236, 46, 80, "Back", action_on(5));
+ key(236, 46, 80, T("Back"), action_on(5));
/* the three rows under them, as on the calculator (the two left columns narrower) */
for (int r = 0; r < 3; r++)
for (int c = 0; c < 6; c++) {
int k = 12 + r * 6 + c;
- key(c < 2 ? 5 + c * 37 : 79 + (c - 2) * 60, 80 + r * 32, c < 2 ? 34 : 57, key_name(k), action_on(k));
+ key(c < 2 ? 5 + c * 37 : 79 + (c - 2) * 60, (TALL ? 76 : 80) + r * 32, c < 2 ? 34 : 57, key_name(k), action_on(k));
}
/* the keys set further down, in words */
- char line[2][72];
+ char line[2][NP_TEXT_EXTRA ? 128 : 72];
int n = 0, len = 0;
line[0][0] = line[1][0] = 0;
bool digits = true;
for (int a = A_SLOT1; a < A_SLOT1 + 9; a++) digits &= opt.keys[a] == actions[a].key;
for (int a = -1; a <= N_ACTIONS && n < 2; a++) {
- char t[32];
+ char t[NP_TEXT_EXTRA ? 64 : 32];
if (a == -1) {
if (!digits) continue;
- strcpy(t, "1 to 9: hotbar slot.");
- } else if (a == N_ACTIONS) strcpy(t, "EXE: as OK.");
+ strcpy(t, T("1 to 9: hotbar slot."));
+ } else if (a == N_ACTIONS) strcpy(t, T("EXE: as OK."));
else {
int k = opt.keys[a];
if ((digits && a >= A_SLOT1 && a < A_SLOT1 + 9) || k == 4 || k == 5 || (k >= 12 && k < 30) || k > 51) continue;
- cat(t, key_name(k), ": ");
- cat(t + strlen(t), actions[a].what, ".");
- for (char *c = t + strlen(key_name(k)) + 2; *c; c++)
+ cat(t, key_name(k), T(": "));
+ cat(t + strlen(t), actions[a].what, T("."));
+ for (char *c = t + strlen(key_name(k)) + strlen(T(": ")); *c; c++)
if (*c >= 'A' && *c <= 'Z') *c = (char)(*c - 'A' + 'a');
}
if (len && text_width(line[n]) + text_width(t) + 12 > SCREEN_W - 8) {
@@ -1556,12 +1658,13 @@ static void key_sheet(void) {
strcat(line[n], t);
len++;
}
- static const char *const notes[3] = {"Forward twice: sprint. Jump twice: fly (Creative).",
- "Menus: OK takes or puts, EXE one, shift+OK moves.",
- "Hold OK and move over slots to spread a stack out."};
+ static const char *const notes[3] = {T("Forward twice: sprint. Jump twice: fly (Creative)."),
+ T("Menus: OK takes or puts, EXE one, shift+OK moves."),
+ T("Hold OK and move over slots to spread a stack out.")};
int rows = line[1][0] ? 2 : 1;
- for (int i = 0; i < rows; i++) text_center(line[i], SCREEN_W / 2, 177 + i * 10, 0xFFFF);
- for (int i = 0; i + rows < 4; i++) text_center(notes[i], SCREEN_W / 2, 177 + (i + rows) * 10, 0xFFFF);
+ int y0 = TALL ? 171 : 177, dy = TALL ? 12 : 10; /* (Chinese letters 11 pixels tall: the keys a little higher) */
+ for (int i = 0; i < rows; i++) text_center(line[i], SCREEN_W / 2, y0 + i * dy, 0xFFFF);
+ for (int i = 0; i + rows < 4; i++) text_center(notes[i], SCREEN_W / 2, y0 + (i + rows) * dy, 0xFFFF);
}
/* GuiControls: the actions by category, each with its key and Reset; Done and Reset Keys under them */
@@ -1574,8 +1677,8 @@ static int krow_of(int a) {
}
static void keys_screen(void) {
int w = SCREEN_W, h = SCREEN_H;
- text_center("Controls", w / 2, 8, 0xFFFF);
- Button b = {(int16_t)(w / 2 - 100), 18, 200, 1, 0, "Key Sheet..."};
+ text_center(T("Controls"), w / 2, 8, 0xFFFF);
+ Button b = {(int16_t)(w / 2 - 100), 18, 200, 1, 0, T("Key Sheet...")};
button(&b, ksel == -1);
/* the label column: as wide as the widest label */
int lw = 0;
@@ -1606,15 +1709,15 @@ static void keys_screen(void) {
text(">", x + 105 + 37 - nw - 6, y + 6, 0xFFFF, true);
text("<", x + 105 + 37 + nw, y + 6, 0xFFFF, true);
}
- Button rb = {(int16_t)(x + 190), (int16_t)y, 50, opt.keys[a] != actions[a].key, 0, "Reset"};
+ Button rb = {(int16_t)(x + 190), (int16_t)y, 50, opt.keys[a] != actions[a].key, 0, T("Reset")};
button(&rb, ksel == a && kcol == 1);
}
a++;
}
- Button done = {(int16_t)(w / 2 - 155), (int16_t)(h - 29), 150, 1, 0, "Done"};
+ Button done = {(int16_t)(w / 2 - 155), (int16_t)(h - 29), 150, 1, 0, T("Done")};
bool any = false;
for (int a = 0; a < N_ACTIONS; a++) any |= opt.keys[a] != actions[a].key;
- Button all = {(int16_t)(w / 2 + 5), (int16_t)(h - 29), 150, any, 0, "Reset Keys"};
+ Button all = {(int16_t)(w / 2 + 5), (int16_t)(h - 29), 150, any, 0, T("Reset Keys")};
button(&done, ksel == N_ACTIONS && kcol == 0);
button(&all, ksel == N_ACTIONS && kcol == 1);
}
@@ -1679,13 +1782,13 @@ static void menu_screen(void) {
logo(30);
splash("Also try Minecraft!", w / 2 + 72, 72, 1.25f + 0.08f * fabsf(sinf((frame_no % 60) * 0.1047f)));
text("NumBlocks 1.0", 2, h - 10, 0xFFFF, true);
- text("Inspired by Minecraft, not affiliated with Mojang",
- w - text_width("Inspired by Minecraft, not affiliated with Mojang") - 2, h - 20, 0xFFFF, true);
- text("Made by Mason Chen as part of NumPlay", w - text_width("Made by Mason Chen as part of NumPlay") - 2, h - 10,
+ text(T("Inspired by Minecraft, not affiliated with Mojang"),
+ w - text_width(T("Inspired by Minecraft, not affiliated with Mojang")) - 2, h - (TALL ? 24 : 20), 0xFFFF, true);
+ text(T("Made by Mason Chen as part of NumPlay"), w - text_width(T("Made by Mason Chen as part of NumPlay")) - 2, h - 10,
0xFFFF, true);
break;
case GUI_WORLDS: {
- text_center("Select World", w / 2, 20, 0xFFFF);
+ text_center(T("Select World"), w / 2, 20, 0xFFFF);
/* GuiSlot: 36 pixels a world, the selected one framed */
int first = wsel > 3 ? wsel - 3 : 0;
for (int k = first; k < nworlds && k < first + 4; k++) {
@@ -1699,52 +1802,52 @@ static void menu_screen(void) {
text(wi.name, x + 2, y + 1, 0xFFFF, true);
char f[4] = {'n', 'b', (char)('0' + wlist[k]), 0};
text(f, x + 2, y + 12, RGB(0x80, 0x80, 0x80), true);
- char m[24];
- cat(m, wi.mode == 1 ? "Creative Mode" : "Survival Mode", wi.cheats ? ", Cheats" : "");
+ char m[NP_TEXT_EXTRA ? 48 : 24];
+ cat(m, wi.mode == 1 ? T("Creative Mode") : T("Survival Mode"), wi.cheats ? T(", Cheats") : "");
text(m, x + 2, y + 22, RGB(0x80, 0x80, 0x80), true);
}
- if (!nworlds) text_center("No worlds yet", w / 2, 60, RGB(0x80, 0x80, 0x80));
- char t[40], n[12];
+ if (!nworlds) text_center(T("No worlds yet"), w / 2, 60, RGB(0x80, 0x80, 0x80));
+ char t[NP_TEXT_EXTRA ? 64 : 40], n[12];
number((int)(plat_storage_free() / 1024), n);
- cat(t, "Storage free: ", n);
- cat(t + strlen(t), " KB", "");
+ cat(t, T("Storage free: "), n);
+ cat(t + strlen(t), T(" KB"), "");
text_center(t, w / 2, h - 63, RGB(0x80, 0x80, 0x80));
break;
}
case GUI_CREATE:
- text_center("Create New World", w / 2, 20, 0xFFFF);
- text("World Name", w / 2 - 100, 47, RGB(0xA0, 0xA0, 0xA0), true);
- text_center(create_mode ? "Unlimited resources, free flying and" : "Search for resources, crafting, gain",
+ text_center(T("Create New World"), w / 2, 20, 0xFFFF);
+ text(T("World Name"), w / 2 - 100, 47, RGB(0xA0, 0xA0, 0xA0), true);
+ text_center(create_mode ? T("Unlimited resources, free flying and") : T("Search for resources, crafting, gain"),
w / 2, 122, RGB(0xA0, 0xA0, 0xA0));
- text_center(create_mode ? "destroy blocks instantly" : "levels, health and hunger", w / 2, 134,
+ text_center(create_mode ? T("destroy blocks instantly") : T("levels, health and hunger"), w / 2, 134,
RGB(0xA0, 0xA0, 0xA0));
- text_center(field ? "alpha: letters or digits, shift: capitals, OK: done" : "Leave blank for a random seed",
+ text_center(field ? T("alpha: letters or digits, shift: capitals, OK: done") : T("Leave blank for a random seed"),
w / 2, 169, RGB(0xA0, 0xA0, 0xA0));
break;
case GUI_RENAME:
- text_center("Rename World", w / 2, 20, 0xFFFF);
- text("Enter Name", w / 2 - 100, 47, RGB(0xA0, 0xA0, 0xA0), true);
- if (field) text_center("alpha: letters or digits, shift: capitals, OK: done", w / 2, 90, RGB(0xA0, 0xA0, 0xA0));
+ text_center(T("Rename World"), w / 2, 20, 0xFFFF);
+ text(T("Enter Name"), w / 2 - 100, 47, RGB(0xA0, 0xA0, 0xA0), true);
+ if (field) text_center(T("alpha: letters or digits, shift: capitals, OK: done"), w / 2, 90, RGB(0xA0, 0xA0, 0xA0));
break;
case GUI_CONFIRM: {
WorldInfo wi;
- char t[64];
- text_center("Are you sure you want to delete this world?", w / 2, 70, 0xFFFF);
- cat(t, "'", nworlds && world_info(wlist[wsel], &wi) ? wi.name : "");
- cat(t + strlen(t), "' will be lost forever! (A long time!)", "");
+ char t[NP_TEXT_EXTRA ? 96 : 64];
+ text_center(T("Are you sure you want to delete this world?"), w / 2, 70, 0xFFFF);
+ cat(t, T("'"), nworlds && world_info(wlist[wsel], &wi) ? wi.name : "");
+ cat(t + strlen(t), T("' will be lost forever! (A long time!)"), "");
text_center(t, w / 2, 90, 0xFFFF);
break;
}
- case GUI_OPTIONS: text_center("Options", w / 2, 15, 0xFFFF); break;
+ case GUI_OPTIONS: text_center(T("Options"), w / 2, 15, 0xFFFF); break;
case GUI_CONTROLS: key_sheet(); break;
- case GUI_PAUSE: text_center("Game menu", w / 2, 40, 0xFFFF); break;
+ case GUI_PAUSE: text_center(T("Game menu"), w / 2, 40, 0xFFFF); break;
case GUI_LAN:
- text_center("LAN World", w / 2, 50, 0xFFFF);
- text_center("Settings for Other Players", w / 2, 82, 0xFFFF);
+ text_center(T("LAN World"), w / 2, 50, 0xFFFF);
+ text_center(T("Settings for Other Players"), w / 2, 82, 0xFFFF);
break;
case GUI_LOADING:
- text_center("Loading world", w / 2, h / 2 - 50, 0xFFFF);
- text_center("Building terrain", w / 2, h / 2 - 20, 0xFFFF);
+ text_center(T("Loading world"), w / 2, h / 2 - 50, 0xFFFF);
+ text_center(T("Building terrain"), w / 2, h / 2 - 20, 0xFFFF);
break;
}
for (int i = 0; i < nbuttons; i++)
@@ -1877,7 +1980,7 @@ void gui_input(uint32_t keys, uint32_t pressed) {
/* ---------------------------------------------------------------- drawing a screen */
static void tooltip(const char *s, int x, int y) {
/* GuiScreen.drawHoveringText: dark violet box with a blue to purple frame */
- int w = text_width(s), h = 8;
+ int w = text_width(s), h = TALL ? 11 : 8;
x += 12, y -= 12;
if (x + w + 4 > SCREEN_W) x = SCREEN_W - w - 4;
if (y < 4) y = 4;
@@ -1890,7 +1993,7 @@ static void tooltip(const char *s, int x, int y) {
fill(x + w + 2, y - 2, 1, h + 4, RGB(0x28, 0, 0x7F));
fill(x - 3, y - 3, w + 6, 1, RGB(0x50, 0, 0xFF));
fill(x - 3, y + h + 2, w + 6, 1, RGB(0x28, 0, 0x7F));
- text(s, x, y, 0xFFFF, true);
+ text(s, x, y + (TALL ? 2 : 0), 0xFFFF, true);
}
static void container(void) {
@@ -1920,17 +2023,17 @@ static void container(void) {
switch (gui) {
case GUI_INVENTORY:
sprite(SP_STEVE, px + 51 - 13, py + 75 - 54 + 2);
- text("Crafting", px + 86, py + 16, label, false);
+ text(T("Crafting"), px + 86, py + 16, label, false);
for (int i = 0; i < 4; i++)
if (!pl.armor[3 - i].id) sprite(SP_SLOT_HELMET + i, px + 8, py + 8 + i * 18);
break;
case GUI_CRAFTING:
- text("Crafting", px + 28, py + 6, label, false);
- text("Inventory", px + 8, py + panel_h - 96 + 2, label, false);
+ text(T("Crafting"), px + 28, py + 6, label, false);
+ text(T("Inventory"), px + 8, py + panel_h - 96 + 2, label, false);
break;
case GUI_FURNACE: {
- text("Furnace", px + 88 - text_width("Furnace") / 2, py + 6, label, false);
- text("Inventory", px + 8, py + panel_h - 96 + 2, label, false);
+ text(T("Furnace"), px + 88 - text_width(T("Furnace")) / 2, py + 6, label, false);
+ text(T("Inventory"), px + 8, py + panel_h - 96 + 2, label, false);
if (furnace->burn > 0) {
int k = furnace->burn * 13 / (furnace->burn_max ? furnace->burn_max : 200);
sprite_part(SP_FLAME, px + 56, py + 36 + 12 - k, 0, 12 - k, 14, k + 1);
@@ -1940,8 +2043,8 @@ static void container(void) {
break;
}
case GUI_CHEST:
- text("Chest", px + 8, py + 6, label, false);
- text("Inventory", px + 8, py + panel_h - 96 + 2, label, false);
+ text(T("Chest"), px + 8, py + 6, label, false);
+ text(T("Inventory"), px + 8, py + panel_h - 96 + 2, label, false);
break;
}
bool spread = drag && ndragged > 1;
@@ -2019,10 +2122,16 @@ void hud_strip(uint16_t *buf, int y0, int rows) {
uint16_t *d = row_at(y);
for (int x = 0; x < SCREEN_W; x++) d[x] = blend(d[x], k, a);
}
- text_big("You died!", SCREEN_W / 2, 60 / 2 * 2, 0xFFFF, 2);
+ text_big(T("You died!"), SCREEN_W / 2, 60 / 2 * 2, 0xFFFF, 2);
+#if NP_TEXT_EXTRA
+ char b[40], n[12];
+ number(pl.xp_total, n);
+ cat(b, T("Score: "), n);
+#else
char b[24] = "Score: ", n[12];
number(pl.xp_total, n);
memcpy(b + 7, n, strlen(n) + 1);
+#endif
text_center(b, SCREEN_W / 2, 100, 0xFFFF);
for (int i = 0; i < nbuttons; i++) button(&buttons[i], i == bcur);
break;
diff --git a/games/numblocks/src/main.c b/games/numblocks/src/main.c
index 063f916d..2240f139 100644
--- a/games/numblocks/src/main.c
+++ b/games/numblocks/src/main.c
@@ -98,7 +98,7 @@ void game_init(void) {
#endif
last = plat_millis();
if (start_in_world) {
- new_world(1, start_seed, 0, false, start_type, "New World");
+ new_world(1, start_seed, 0, false, start_type, T("New World"));
game_time = 1000;
#ifdef BENCH_FALL
pl.mode = 1, pl.y += BENCH_FALL; /* (timing a fall from that high, in Creative: no harm) */
diff --git a/games/numblocks/src/nb.h b/games/numblocks/src/nb.h
index 8defa760..18efc47f 100644
--- a/games/numblocks/src/nb.h
+++ b/games/numblocks/src/nb.h
@@ -14,6 +14,7 @@
#include <string.h>
#include "blocks.h"
#include "data.h"
+#include "../../common/np_text.h"
/* ---------------------------------------------------------------- the platform (plat_eadk.c / plat_host.c) */
enum {
diff --git a/games/numblocks/src/player.c b/games/numblocks/src/player.c
index 11425c47..df251d53 100644
--- a/games/numblocks/src/player.c
+++ b/games/numblocks/src/player.c
@@ -546,14 +546,14 @@ static void eat_done(void) {
/* EntityPlayer.trySleep: at night (or in a storm), with no monster within 8 blocks; the bed is the new spawn point */
static void sleep_in(int x, int y, int z) {
if (sky_sub() < 4) {
- gui_message("You can only sleep at night");
+ gui_message(T("You can only sleep at night"));
return;
}
for (int i = 0; i < N_ENT; i++) {
const Entity *e = &ents[i];
if (e->type >= E_ZOMBIE && e->type <= E_SPIDER && fabsf(e->x - x) < 8 && fabsf(e->y - y) < 5 &&
fabsf(e->z - z) < 8) {
- gui_message("You may not rest now, there are monsters nearby");
+ gui_message(T("You may not rest now, there are monsters nearby"));
return;
}
}
diff --git a/games/numblocks/src/save.c b/games/numblocks/src/save.c
index 99b0f717..d25aea5e 100644
--- a/games/numblocks/src/save.c
+++ b/games/numblocks/src/save.c
@@ -49,6 +49,7 @@ static void record_of(int s, char *out) {
static void copy_name(char *d, const char *s) {
int i = 0;
for (; s[i] && i < WORLD_NAME; i++) d[i] = s[i];
+ while (NP_TEXT_EXTRA && i && (s[i] & 0xC0) == 0x80) i--; /* (not a letter cut) */
d[i] = 0;
}
@@ -61,7 +62,7 @@ static const uint8_t *read_head(int s, Head *h, uint32_t *len, uint32_t *head_le
memset(h, 0, sizeof *h);
if (!memcmp(d, "NBW1", 4)) {
memcpy(&h->h2.h, d, sizeof(Head1));
- copy_name(h->h2.name, "New World");
+ copy_name(h->h2.name, T("New World"));
*head_len = sizeof(Head1);
} else if (!memcmp(d, "NBW2", 4) && *len >= sizeof(Head2)) {
memcpy(&h->h2, d, sizeof(Head2));
@@ -113,7 +114,7 @@ static bool name_taken(const char *n) {
void world_unique_name(const char *base, char *out) {
char b[WORLD_NAME + 1];
- copy_name(b, base[0] ? base : "New World");
+ copy_name(b, base[0] ? base : T("New World"));
copy_name(out, b);
for (int k = 2; name_taken(out) && k < 100; k++) {
/* "New World (2)": the number kept whole, the name cut to fit */
@@ -123,6 +124,7 @@ void world_unique_name(const char *base, char *out) {
sfx[n++] = (char)('0' + k % 10), sfx[n++] = ')', sfx[n] = 0;
int bl = (int)strlen(b), room = WORLD_NAME - n;
if (bl > room) bl = room;
+ while (NP_TEXT_EXTRA && bl && (b[bl] & 0xC0) == 0x80) bl--;
memcpy(out, b, (size_t)bl);
memcpy(out + bl, sfx, (size_t)n + 1);
}