Skip to content

Commit

Permalink
add translation credits and link to crowdin
Browse files Browse the repository at this point in the history
  • Loading branch information
bl4ckscor3 committed May 21, 2024
1 parent eedaac3 commit 822abeb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@
import net.geforcemods.securitycraft.screen.components.TextHoverChecker;
import net.geforcemods.securitycraft.util.BlockUtils;
import net.geforcemods.securitycraft.util.Utils;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.client.gui.narration.NarrationElementOutput;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.core.NonNullList;
import net.minecraft.core.RegistryAccess;
import net.minecraft.network.chat.ClickEvent;
Expand All @@ -52,6 +53,7 @@
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Style;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
Expand Down Expand Up @@ -95,13 +97,15 @@ public class SCManualScreen extends Screen {
private static int lastPage = -1;
private final MutableComponent intro1 = Utils.localize("gui.securitycraft:scManual.intro.1").setStyle(Style.EMPTY.withUnderlined(true));
private final Component ourPatrons = Utils.localize("gui.securitycraft:scManual.patreon.title");
private final Style crowdinLinkStyle = Style.EMPTY.withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://crowdin.com/project/securitycraft"));
private final HoverChecker translationCreditsArea = new HoverChecker(180, 200, 135, 290);
private List<HoverChecker> hoverCheckers = new ArrayList<>();
private int currentPage = lastPage;
private NonNullList<Ingredient> recipe;
private IngredientDisplay[] displays = new IngredientDisplay[9];
private int startX = -1;
private List<FormattedText> subpages = new ArrayList<>();
private List<FormattedCharSequence> author = new ArrayList<>();
private List<FormattedCharSequence> translationCredits;
private int currentSubpage = 0;
private List<FormattedCharSequence> intro2;
private PatronList patronList;
Expand Down Expand Up @@ -142,6 +146,7 @@ public void init() {

return key1.compareTo(key2);
});
translationCredits = font.split(Utils.localize("gui.securitycraft:scManual.crowdin").withStyle(ChatFormatting.BLUE, ChatFormatting.UNDERLINE), 180);
}

@Override
Expand Down Expand Up @@ -200,8 +205,8 @@ else if (i < displays.length && !displays[i].getCurrentStack().isEmpty()) {
guiGraphics.drawString(font, text, width / 2 - font.width(text) / 2, 150 + 10 * i, 0, false);
}

for (int i = 0; i < author.size(); i++) {
FormattedCharSequence text = author.get(i);
for (int i = 0; i < translationCredits.size(); i++) {
FormattedCharSequence text = translationCredits.get(i);

guiGraphics.drawString(font, text, width / 2 - font.width(text) / 2, 180 + 10 * i, 0, false);
}
Expand Down Expand Up @@ -317,12 +322,6 @@ private void updateRecipeAndIcons() {
recipe = null;
nextSubpage.visible = false;
previousSubpage.visible = false;

if (I18n.exists("gui.securitycraft:scManual.author"))
author = font.split(Utils.localize("gui.securitycraft:scManual.author"), 180);
else
author.clear();

intro2 = font.split(Utils.localize("gui.securitycraft:scManual.intro.2"), 202);
patronList.fetchPatrons();
return;
Expand Down Expand Up @@ -573,6 +572,11 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (patronList != null)
patronList.mouseClicked(mouseX, mouseY, button);

if (translationCreditsArea.checkHover(mouseX, mouseY)) {
handleComponentClicked(crowdinLinkStyle);
minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
}

return super.mouseClicked(mouseX, mouseY, button);
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/securitycraft/lang/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@
"gui.securitycraft:scManual.author": "Übersetzt von bl4ckscor3 und Redstone_Dubstep",
"gui.securitycraft:scManual.block_mines": "Blockminen",
"gui.securitycraft:scManual.block_reinforcers": "Universelle Blockverstärker",
"gui.securitycraft:scManual.crowdin": "Vielen Dank unseren Übersetzern auf Crowdin!",
"gui.securitycraft:scManual.customizableBlock": "Anpassbar: Du kannst den Universellen Blockmodifizierer verwenden, um die Funktionen hiervon anzupassen.",
"gui.securitycraft:scManual.designedBy": "Entworfen von: %s",
"gui.securitycraft:scManual.disabled": "Deaktiviert",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/securitycraft/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,7 @@
"gui.securitycraft:rift_stabilizer.toggle": "Click the entries in the list below to toggle the detection of that specific teleportation type.",
"gui.securitycraft:scManual.block_mines": "Block Mines",
"gui.securitycraft:scManual.block_reinforcers": "Universal Block Reinforcers",
"gui.securitycraft:scManual.crowdin": "Thanks to our translators on Crowdin!",
"gui.securitycraft:scManual.customizableBlock": "Customizable: You may use the Universal Block Modifier and the various modules added by SecurityCraft to customize the functions of this.",
"gui.securitycraft:scManual.designedBy": "Designed by: %s",
"gui.securitycraft:scManual.disabled": "Disabled",
Expand Down

0 comments on commit 822abeb

Please sign in to comment.