Add translations for the experience level description

This commit is contained in:
Sollace 2023-05-21 13:51:03 +01:00
parent 3d9c910f1b
commit 79b5fbc8dd
4 changed files with 155 additions and 10 deletions

View file

@ -4,11 +4,12 @@ import com.minelittlepony.common.client.gui.IViewRoot;
import com.minelittlepony.common.client.gui.dimension.Bounds;
import com.minelittlepony.unicopia.client.gui.*;
import com.minelittlepony.unicopia.entity.player.*;
import com.minelittlepony.unicopia.util.ColorHelper;
import com.sollace.romanizer.api.Romanizer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.font.TextRenderer;
import net.minecraft.client.gui.DrawableHelper;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.text.Text;
import net.minecraft.util.Hand;
@ -69,9 +70,19 @@ public class SpellbookProfilePageContent extends DrawableHelper implements Spell
float delta = pony.asEntity().age + client.getTickDelta();
int currentLevel = pony.getLevel().get();
float currentScaledLevel = pony.getLevel().getScaled(1);
float currentCorruption = pony.getCorruption().getScaled(1);
DrawableUtil.drawScaledText(matrices, pony.asEntity().getName(), SpellbookScreen.TITLE_X, y, 1.3F, SpellbookScreen.TITLE_COLOR);
DrawableUtil.drawScaledText(matrices, ExperienceGroup.forLevel(currentLevel, pony.getCorruption().get()), SpellbookScreen.TITLE_X, y + 13, 0.8F, 0xAA0040FF);
DrawableUtil.drawScaledText(matrices, ExperienceGroup.forLevel(
currentScaledLevel,
currentCorruption
), SpellbookScreen.TITLE_X, y + 13, 0.8F,
ColorHelper.lerp(currentCorruption,
ColorHelper.lerp(currentScaledLevel, 0xAA0040FF, 0xAAA0AA40),
0xAAFF0000
)
);
MagicReserves reserves = pony.getMagicalReserves();
@ -100,6 +111,28 @@ public class SpellbookProfilePageContent extends DrawableHelper implements Spell
DrawableUtil.drawArc(matrices, 0, radius + 24, 0, DrawableUtil.TAU, color, false);
DrawableUtil.drawArc(matrices, radius / 3, radius + 6, 0, DrawableUtil.TAU, color, false);
if (currentLevel >= pony.getLevel().getMax()) {
int rayCount = 6;
float raySeparation = MathHelper.TAU / rayCount;
float rotate = (delta / 120) % (MathHelper.TAU / (rayCount / 2));
growth = MathHelper.sin(delta / 10F) * 2;
int bandAColor = ColorHelper.lerp(currentCorruption, 0xAAFFAA60, 0xFF000030);
int bandBColor = ColorHelper.lerp(currentCorruption, 0xFFFFFF40, 0x00000020);
float glowSize = ColorHelper.lerp(currentCorruption, 8, -8);
for (int i = 0; i < rayCount; i++) {
double rad = (radius + glowSize) * 0.8F + growth - (i % 2) * 5;
float rot = (rotate + raySeparation * i) % MathHelper.TAU;
DrawableUtil.drawArc(matrices, 0, rad, rot, 0.2F, bandAColor, false);
DrawableUtil.drawArc(matrices, 0, rad + 0.3F, rot + 0.37F, 0.25F, bandBColor, false);
}
}
DrawableUtil.drawArc(matrices, radius / 3, radius + 6, 0, xpPercentage * DrawableUtil.TAU, xpColor, false);
radius += 8;
DrawableUtil.drawArc(matrices, radius, radius + 6 + growth, 0, manaPercentage * DrawableUtil.TAU, manaColor, false);

View file

@ -3,8 +3,8 @@ package com.minelittlepony.unicopia.entity.player;
import net.minecraft.text.Text;
import net.minecraft.util.math.MathHelper;
public record ExperienceGroup (String experience, String corruption) {
public static final LinearSelector<String> EXPERIENCES = new LinearSelector<>(new String[] {
public interface ExperienceGroup {
LinearSelector<String> EXPERIENCES = new LinearSelector<>(new String[] {
"MAGICAL_KINDERGARTENER",
"FRIENDSHIP_STUDENT",
"SENIOR_FRIENDSHIP_STUDENT",
@ -20,7 +20,7 @@ public record ExperienceGroup (String experience, String corruption) {
"POLYCORN_PRINCESS",
"FAUSTIAN_LEGEND"
}, 2);
public static final LinearSelector<String> CORRUPTIONS = new LinearSelector<>(new String[] {
LinearSelector<String> CORRUPTIONS = new LinearSelector<>(new String[] {
"PURE",
"IMPURE",
"TAINTED",
@ -29,13 +29,15 @@ public record ExperienceGroup (String experience, String corruption) {
"MONSTROUS"
}, 1F/8F);
public static Text forLevel(int level, int corruption) {
return Text.of(CORRUPTIONS.get(corruption).toLowerCase() + " " + EXPERIENCES.get(level).toLowerCase());
static Text forLevel(float level, float corruption) {
return Text.translatable(
"experience.unicopia." + CORRUPTIONS.get(corruption).toLowerCase() + "." + EXPERIENCES.get(level).toLowerCase()
);
}
public record LinearSelector<T> (T[] values, float ratio) {
public T get(int level) {
return values()[MathHelper.clamp(MathHelper.floor(MathHelper.sqrt(level * ratio())), 0, values().length - 1)];
public T get(float level) {
return values()[MathHelper.clamp(MathHelper.floor(level * values().length), 0, values().length - 1)];
}
}
}

View file

@ -1,5 +1,9 @@
package com.minelittlepony.unicopia.util;
import com.minelittlepony.common.util.Color;
import net.minecraft.util.math.MathHelper;
public interface ColorHelper {
static float[] changeSaturation(float red, float green, float blue, float intensity) {
@ -27,4 +31,12 @@ public interface ColorHelper {
return new float[] {r, g, b};
}
static int lerp(float delta, int fromColor, int toColor) {
return Color.argbToHex(
MathHelper.lerp(delta, Color.a(fromColor), Color.a(toColor)),
MathHelper.lerp(delta, Color.r(fromColor), Color.r(toColor)),
MathHelper.lerp(delta, Color.g(fromColor), Color.g(toColor)),
MathHelper.lerp(delta, Color.b(fromColor), Color.b(toColor))
);
}
}

View file

@ -417,6 +417,104 @@
"gui.unicopia.action.spells_cleared": "Removed all spells",
"gui.unicopia.action.no_spells_cleared": "You have no active spells",
"experience.unicopia.pure.magical_kindergartener": "New Blood",
"experience.unicopia.impure.magical_kindergartener": "Impure",
"experience.unicopia.tainted.magical_kindergartener": "Misguided",
"experience.unicopia.twisted.magical_kindergartener": "Twisted",
"experience.unicopia.corrupt.magical_kindergartener": "Filly Fiend",
"experience.unicopia.monstrous.magical_kindergartener": "Evil Foal",
"experience.unicopia.pure.friendship_student": "Friendship Student",
"experience.unicopia.impure.friendship_student": "Wayward Soul",
"experience.unicopia.tainted.friendship_student": "Misguided Soul",
"experience.unicopia.twisted.friendship_student": "Lost Soul",
"experience.unicopia.corrupt.friendship_student": "Fiendish Friendship Student",
"experience.unicopia.monstrous.friendship_student": "Monstrous Soul",
"experience.unicopia.pure.senior_friendship_student": "Promising Friendship Student",
"experience.unicopia.impure.senior_friendship_student": "Dissapointing Friendship Student",
"experience.unicopia.tainted.senior_friendship_student": "Misguided Friendship Student",
"experience.unicopia.twisted.senior_friendship_student": "Band Influence",
"experience.unicopia.corrupt.senior_friendship_student": "Fiendish Friend",
"experience.unicopia.monstrous.senior_friendship_student": "Learning Cultist",
"experience.unicopia.pure.junior_mage": "Junior Mage",
"experience.unicopia.impure.junior_mage": "Wayward Junior Mage",
"experience.unicopia.tainted.junior_mage": "Misguided Junior Mage",
"experience.unicopia.twisted.junior_mage": "Fiendish Junior Mage",
"experience.unicopia.corrupt.junior_mage": "Junior Anti-Mage",
"experience.unicopia.monstrous.junior_mage": "Junior Cultist",
"experience.unicopia.pure.mage": "Mage",
"experience.unicopia.impure.mage": "Wayward Mage",
"experience.unicopia.tainted.mage": "Misguided Mage",
"experience.unicopia.twisted.mage": "Fiendish Mage",
"experience.unicopia.corrupt.mage": "Anti-Mage",
"experience.unicopia.monstrous.mage": "Cultist",
"experience.unicopia.pure.archmage": "Archmage",
"experience.unicopia.impure.archmage": "Wayward Archmage",
"experience.unicopia.tainted.archmage": "Misguided Archmage",
"experience.unicopia.twisted.archmage": "Fiendish Archmage",
"experience.unicopia.corrupt.archmage": "Anti-Archmage",
"experience.unicopia.monstrous.archmage": "Experienced Cultist",
"experience.unicopia.pure.archmagus": "Archmagus",
"experience.unicopia.impure.archmagus": "Wayward Archmagus",
"experience.unicopia.tainted.archmagus": "Misguided Archmagus",
"experience.unicopia.twisted.archmagus": "Fiendish Archmagus",
"experience.unicopia.corrupt.archmagus": "Anti-Archmagus",
"experience.unicopia.monstrous.archmagus": "Senior Cultist",
"experience.unicopia.pure.senior_archmagus": "Senior Archmagus",
"experience.unicopia.impure.senior_archmagus": "Wayward Senior Archmagus",
"experience.unicopia.tainted.senior_archmagus": "Misguided Senior Archmagus",
"experience.unicopia.twisted.senior_archmagus": "Fiendish Senior Archmagus",
"experience.unicopia.corrupt.senior_archmagus": "Senior Anti-Archmagus",
"experience.unicopia.monstrous.senior_archmagus": "Cult Leader",
"experience.unicopia.pure.ascended_senior_archmagus": "Ascended Senior Archmagus",
"experience.unicopia.impure.ascended_senior_archmagus": "Strugling Senior Archmagus",
"experience.unicopia.tainted.ascended_senior_archmagus": "Falling Senior Archmagus",
"experience.unicopia.twisted.ascended_senior_archmagus": "Fallen Senior Archmagus",
"experience.unicopia.corrupt.ascended_senior_archmagus": "Shadowy Senior Anti-Archmagus",
"experience.unicopia.monstrous.ascended_senior_archmagus": "Dark Cult Leader",
"experience.unicopia.pure.demi_god": "Aspiring Princess",
"experience.unicopia.impure.demi_god": "Impure Aspiring Princess",
"experience.unicopia.tainted.demi_god": "Struggling Aspiring Princess",
"experience.unicopia.twisted.demi_god": "Fallen Princess",
"experience.unicopia.corrupt.demi_god": "Ascendent Dark Lord",
"experience.unicopia.monstrous.demi_god": "Rising Dark Master",
"experience.unicopia.pure.arch_demi_god": "Promising Princess",
"experience.unicopia.impure.arch_demi_god": "Impure Princess",
"experience.unicopia.tainted.arch_demi_god": "Struggling Princess",
"experience.unicopia.twisted.arch_demi_god": "Fallen Demi-God",
"experience.unicopia.corrupt.arch_demi_god": "Dark Demi-God",
"experience.unicopia.monstrous.arch_demi_god": "Dark Master",
"experience.unicopia.pure.alicorn_princess": "Alicorn Princess",
"experience.unicopia.impure.alicorn_princess": "Impure Alicorn Princess",
"experience.unicopia.tainted.alicorn_princess": "Tainted Alicorn Princess",
"experience.unicopia.twisted.alicorn_princess": "Fallen Alicorn Princess",
"experience.unicopia.corrupt.alicorn_princess": "Shadowy Alicorn Lord",
"experience.unicopia.monstrous.alicorn_princess": "Dark Alicorn Lord",
"experience.unicopia.pure.polycorn_princess": "Polycorn Princess",
"experience.unicopia.impure.polycorn_princess": "Impure Polycorn Princess",
"experience.unicopia.tainted.polycorn_princess": "Tainted Polycorn Princess",
"experience.unicopia.twisted.polycorn_princess": "Fallen Polycorn Princess",
"experience.unicopia.corrupt.polycorn_princess": "Shadowy Polycorn King",
"experience.unicopia.monstrous.polycorn_princess": "Dark Polycorn King",
"experience.unicopia.pure.faustian_legend": "Hero of Legend",
"experience.unicopia.impure.faustian_legend": "Legendary",
"experience.unicopia.tainted.faustian_legend": "Storied Figure of Distant Descent",
"experience.unicopia.twisted.faustian_legend": "Dark Figure of Lore",
"experience.unicopia.corrupt.faustian_legend": "The Old God",
"experience.unicopia.monstrous.faustian_legend": "Otherworldly Terror",
"unicopia.category.name": "Pony Abilities",
"key.unicopia.primary": "Primary Ability",