diff --git a/src/main/java/electroblob/wizardry/client/gui/handbook/Contents.java b/src/main/java/electroblob/wizardry/client/gui/handbook/Contents.java index a6a762a5..96ec2df7 100644 --- a/src/main/java/electroblob/wizardry/client/gui/handbook/Contents.java +++ b/src/main/java/electroblob/wizardry/client/gui/handbook/Contents.java @@ -151,7 +151,7 @@ class Contents { int x = GuiWizardHandbook.isRightPage(startPage) ? left + GuiWizardHandbook.GUI_WIDTH - GuiWizardHandbook.TEXT_INSET_X - GuiWizardHandbook.PAGE_WIDTH : left + GuiWizardHandbook.TEXT_INSET_X; int y = top + GuiWizardHandbook.TEXT_INSET_Y + startLine * font.FONT_HEIGHT; - list.add(new GuiButtonHyperlink.Internal(0, x, y, font, entry.title, entry, 0, "", maxLineNumber-startLine, GuiWizardHandbook.isRightPage(startPage))); + list.add(new GuiButtonHyperlink.Internal(0, x, y, font, entry.title, entry, 0, "", maxLineNumber-startLine, GuiWizardHandbook.isRightPage(startPage), false)); startLine++; diff --git a/src/main/java/electroblob/wizardry/client/gui/handbook/GuiButtonHyperlink.java b/src/main/java/electroblob/wizardry/client/gui/handbook/GuiButtonHyperlink.java index d5a48d64..dc1235a5 100644 --- a/src/main/java/electroblob/wizardry/client/gui/handbook/GuiButtonHyperlink.java +++ b/src/main/java/electroblob/wizardry/client/gui/handbook/GuiButtonHyperlink.java @@ -28,15 +28,17 @@ public abstract class GuiButtonHyperlink extends GuiButton { final List lines; final int linesLeft; - GuiButtonHyperlink(int id, int x, int y, FontRenderer font, String text, int indent, String suffix, int linesLeft, boolean rightPage){ + GuiButtonHyperlink(int id, int x, int y, FontRenderer font, String text, int indent, String suffix, int linesLeft, boolean rightPage, boolean spaceless){ super(id, x, y, font.getStringWidth(text), font.FONT_HEIGHT, text); // Sometimes a link has punctuation or something after it that causes it to wrap onto a new line String linkWithSuffix = text + suffix; - // If the string won't fit any words at the end of the current line, treat it as if we started a new line - if(font.getStringWidth(linkWithSuffix.split("\\s")[0]) > GuiWizardHandbook.PAGE_WIDTH - indent){ + // If the string won't fit any words (or characters in a spaceless language) at the end of the current line, + // treat it as if we started a new line + String firstWord = spaceless ? linkWithSuffix.substring(0, 1) : linkWithSuffix.split("\\s")[0]; + if(font.getStringWidth(firstWord) > GuiWizardHandbook.PAGE_WIDTH - indent){ indent = 0; this.y += font.FONT_HEIGHT; } @@ -149,7 +151,7 @@ public abstract class GuiButtonHyperlink extends GuiButton { * @throws IllegalArgumentException if the given argument array is empty or contains more than 2 arguments * @throws JsonSyntaxException if the specified link target is not a URL or a valid section ID */ - public static GuiButtonHyperlink create(int x, int y, FontRenderer font, List upToLink, String[] arguments, String suffix, int linesLeft, boolean rightPage){ + public static GuiButtonHyperlink create(int x, int y, FontRenderer font, List upToLink, String[] arguments, String suffix, int linesLeft, boolean rightPage, boolean spaceless){ if(arguments.length == 0 || arguments.length > 2) throw new IllegalArgumentException("Incorrect array length!"); @@ -158,7 +160,7 @@ public abstract class GuiButtonHyperlink extends GuiButton { if(arguments[0].matches(URL_REGEX)){ button = new GuiButtonHyperlink.External(0, x, y, font, arguments[arguments.length - 1], arguments[0], - font.getStringWidth(upToLink.get(upToLink.size() - 1)), suffix, linesLeft, rightPage); + font.getStringWidth(upToLink.get(upToLink.size() - 1)), suffix, linesLeft, rightPage, spaceless); }else{ @@ -167,7 +169,7 @@ public abstract class GuiButtonHyperlink extends GuiButton { if(target == null) throw new JsonSyntaxException("Hyperlink points to nonexistent section id " + arguments[0]); button = new GuiButtonHyperlink.Internal(0, x, y, font, arguments[arguments.length - 1], - target, font.getStringWidth(upToLink.get(upToLink.size() - 1)), suffix, linesLeft, rightPage); + target, font.getStringWidth(upToLink.get(upToLink.size() - 1)), suffix, linesLeft, rightPage, spaceless); } return button; @@ -177,8 +179,8 @@ public abstract class GuiButtonHyperlink extends GuiButton { final Section target; - Internal(int id, int x, int y, FontRenderer font, String text, Section target, int indent, String suffix, int linesLeft, boolean rightPage){ - super(id, x, y, font, text, indent, suffix, linesLeft, rightPage); + Internal(int id, int x, int y, FontRenderer font, String text, Section target, int indent, String suffix, int linesLeft, boolean rightPage, boolean spaceless){ + super(id, x, y, font, text, indent, suffix, linesLeft, rightPage, spaceless); this.target = target; } @@ -216,8 +218,8 @@ public abstract class GuiButtonHyperlink extends GuiButton { final ITextComponent link; - External(int id, int x, int y, FontRenderer font, String text, String url, int indent, String suffix, int linesLeft, boolean rightPage){ - super(id, x, y, font, text, indent, suffix, linesLeft, rightPage); + External(int id, int x, int y, FontRenderer font, String text, String url, int indent, String suffix, int linesLeft, boolean rightPage, boolean spaceless){ + super(id, x, y, font, text, indent, suffix, linesLeft, rightPage, spaceless); this.link = new TextComponentString(text); link.getStyle().setClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, url)).setColor(TextFormatting.DARK_BLUE); } diff --git a/src/main/java/electroblob/wizardry/client/gui/handbook/Section.java b/src/main/java/electroblob/wizardry/client/gui/handbook/Section.java index 495a4f39..15585c39 100644 --- a/src/main/java/electroblob/wizardry/client/gui/handbook/Section.java +++ b/src/main/java/electroblob/wizardry/client/gui/handbook/Section.java @@ -299,9 +299,8 @@ class Section { String suffix = ""; // Account for trailing punctuation, except in languages that don't use spaces such as Chinese - if(!SPACELESS_LANGUAGES.contains(Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode())){ - paragraph.substring(linkEnd).split("\\s", 2)[0].substring(1); // substring(1) to remove the @ - } + boolean spaceless = SPACELESS_LANGUAGES.contains(Minecraft.getMinecraft().getLanguageManager().getCurrentLanguage().getLanguageCode()); + if(!spaceless) paragraph.substring(linkEnd).split("\\s", 2)[0].substring(1); // substring(1) to remove the @ // The index of the single page currently being formatted, relative to the section int pageRelative = (lines.size() + upToLink.size() - 1) / maxLineNumber; @@ -319,7 +318,7 @@ class Section { } // The button id only does what you use it for, so we're just not using it at all. - this.buttons.get(pageRelative).add(GuiButtonHyperlink.create(x, y, font, upToLink, arguments, suffix, maxLineNumber - lineNumber - 1, GuiWizardHandbook.isRightPage(page))); + this.buttons.get(pageRelative).add(GuiButtonHyperlink.create(x, y, font, upToLink, arguments, suffix, maxLineNumber - lineNumber - 1, GuiWizardHandbook.isRightPage(page), spaceless)); // The link button should exactly overlay the display text in the main string // If the link has no display text specified, it displays the unformatted target string diff --git a/src/main/resources/assets/ebwizardry/texts/handbook_zh_cn.json b/src/main/resources/assets/ebwizardry/texts/handbook_zh_cn.json index 01091181..c75c4f1d 100644 --- a/src/main/resources/assets/ebwizardry/texts/handbook_zh_cn.json +++ b/src/main/resources/assets/ebwizardry/texts/handbook_zh_cn.json @@ -322,15 +322,15 @@ "想要开始你的巫术之旅你需要:", - "- 一把魔杖,合成如下所示:", + "-一把魔杖,合成如下所示:", "#recipe magic_wand", - "- 一个@arcane_workbench 奥术工作台@,合成如下所示:", + "-一个@arcane_workbench 奥术工作台@,合成如下所示:", "#recipe arcane_workbench", - "- 一本@spells 法术@书。你可以在战利品箱中找到法术书,它也会以掉落物形式出现,你也可以与其他巫师交易。\n\n\n\n当然你也可以制作一本初始的法术书:魔法飞弹,如下所示:", + "-一本@spells 法术@书。你可以在战利品箱中找到法术书,它也会以掉落物形式出现,你也可以与其他巫师交易。当然你也可以制作一本初始的法术书:魔法飞弹,如下所示:", "#recipe magic_missile_spell_book", @@ -412,7 +412,7 @@ ], "text": [ - "奥术工作台外观上与附魔台很相似,它可以用来为你的魔杖充能、升级 ,以及绑定@spells 法术@到你的@wands 魔杖@。制作方法如下所示:", + "奥术工作台外观上与附魔台很相似,它可以用来为你的魔杖充能、升级,以及绑定@spells 法术@到你的@wands 魔杖@。制作方法如下所示:", "#recipe arcane_workbench", @@ -482,7 +482,7 @@ ], "text": [ - "作为一名巫师,你需要一些东西在战斗时保护你不受过高的伤害,普通的盔甲可无法承此重任。为了能够在提供保护时还能让你最高效率地使用的魔力,你需要一套巫师护具:包括帽子、长袍、裤子和靴子。与普通盔甲不同的是,它们耐久归零之后不会消失。而且,蕴藏在其中的奥术能量将会保护穿戴者。当然,这意味着它们必须使用水晶充能,这一点和魔杖很相似。\n\n幸运的是,这些护具不太消耗@mana 魔力@。你可以像和魔杖那样,将其放置在@arcane_workbench 奥术工作台@里,或者使用@mana_flasks 魔力瓶@为其充能,但是要小心,如果护具耗尽了魔力,它们将不再提供任何保护效果。", + "作为一名巫师,你需要一些东西在战斗时保护你不受过高的伤害,普通的盔甲可无法承此重任。为了能够在提供保护时还能让你最高效率地使用的魔力,你需要一套巫师护具:包括帽子、长袍、裤子和靴子。与普通盔甲不同的是,它们耐久归零之后不会消失。而且,蕴藏在其中的奥术能量将会保护穿戴者。当然,这意味着它们必须使用水晶充能,这一点和魔杖很相似。幸运的是,这些护具不太消耗@mana 魔力@。你可以像和魔杖那样,将其放置在@arcane_workbench 奥术工作台@里,或者使用@mana_flasks 魔力瓶@为其充能,但是要小心,如果护具耗尽了魔力,它们将不再提供任何保护效果。", "#image wizard_armour", diff --git a/src/main/resources/assets/ebwizardry/texts/handbook_zh_tw.json b/src/main/resources/assets/ebwizardry/texts/handbook_zh_tw.json index b610e0fa..f2793668 100644 --- a/src/main/resources/assets/ebwizardry/texts/handbook_zh_tw.json +++ b/src/main/resources/assets/ebwizardry/texts/handbook_zh_tw.json @@ -320,15 +320,15 @@ "要開始使用法術,你需要準備:", - "》法杖, 請依圖示合成:", + "法杖,請依圖示合成:", "#recipe magic_wand", - "\n\n》@arcane_workbench 法術工作台@, 合成方式如圖:", + "@arcane_workbench 法術工作台@,合成方式如圖:", "#recipe arcane_workbench", - "》@spells 法術書@這個可以在箱子裡找到,或從怪物身上掉落,或向法師購買。\n\n\n\n不然你也可以自己合成一個初學者法術【魔法彈】,如圖所示:", + "@spells 法術書@這個可以在箱子裡找到,或從怪物身上掉落,或向法師購買。不然你也可以自己合成一個初學者法術【魔法彈】,如圖所示:", "#recipe magic_missile_spell_book", @@ -410,7 +410,7 @@ ], "text": [ - "法術工作台看起來有點像附魔台, 用來升級你的@wands 法杖@、為其補充法力和存入@spells 法術@。\n\n其合成方式如下:", + "法術工作台看起來有點像附魔台,用來升級你的@wands 法杖@、為其補充法力和存入@spells 法術@。其合成方式如下:", "#recipe arcane_workbench", @@ -581,7 +581,7 @@ "#image shrine", - "由於這些神殿的重要意義及巨大的神秘力量,更別說裡面的寶物,對於志氣高昂的法師特別有吸引力。\n\n但是務必謹慎,有許多關於法師被關在封鎖區內,可能因為幽閉恐懼症導致慢慢發瘋的報導。且愈來愈多人認為,這就是神殿防護魔法的一個部分,而被關在其中的法師,其實是被控制用來守護神殿。這對於膽敢前往冒險的人來說,無疑是令人不寒而慄的結局..." + "由於這些神殿的重要意義及巨大的神秘力量,更別說裡面的寶物,對於志氣高昂的法師特別有吸引力。但是務必謹慎,有許多關於法師被關在封鎖區內,可能因為幽閉恐懼症導致慢慢發瘋的報導。且愈來愈多人認為,這就是神殿防護魔法的一個部分,而被關在其中的法師,其實是被控制用來守護神殿。這對於膽敢前往冒險的人來說,無疑是令人不寒而慄的結局..." ] }, "library_ruins": { @@ -729,11 +729,11 @@ "亞肯多魔法用品公司 - 為您所需的魔法物品!", - "需要在旅行中為你的@wands 法杖@補充法力嗎?沒問題! 現在@mana 法力@可以裝瓶。只要用一個玻璃瓶及八個魔法水晶合成出法力瓶,就可以隨身攜帶。要用的時候,只要將你的法杖與法力瓶合成,就能將法力存入法杖。(註)", + "需要在旅行中為你的@wands 法杖@補充法力嗎?沒問題!現在@mana 法力@可以裝瓶。只要用一個玻璃瓶及八個魔法水晶合成出法力瓶,就可以隨身攜帶。要用的時候,只要將你的法杖與法力瓶合成,就能將法力存入法杖。(註)", "#recipe medium_mana_flask", - "好消息! 即日起推出全新的小瓶裝及大瓶裝法力,可依您的需求選擇!", + "好消息!即日起推出全新的小瓶裝及大瓶裝法力,可依您的需求選擇!", "#recipe small_mana_flask", "#recipe large_mana_flask",