Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group mod credits by role instead of bunching them together #706

Merged
merged 6 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,7 @@ public void renderList(DrawContext DrawContext, int mouseX, int mouseY, float de
var role = iterator.next();
var roleName = role.getKey();

var component = Text.translatableWithFallback("modmenu.credits.role." + roleName.toLowerCase(), roleName);

for (var line : textRenderer.wrapLines(component.append(Text.literal(":")), wrapWidth - 16)) {
for (var line : textRenderer.wrapLines(this.creditsRoleText(roleName), wrapWidth - 16)) {
children().add(new DescriptionEntry(line, indent));
indent = 16;
}
Expand Down Expand Up @@ -352,6 +350,18 @@ public void renderScrollBar(BufferBuilder bufferBuilder, Tessellator tessellator
}
}

private Text creditsRoleText(String roleName) {
// Replace spaces and dashes in role names with underscores if they exist
// Notably Quilted Fabric API does this with FabricMC as "Upstream Owner"
var translationKey = roleName.replaceAll("[\s-]", "_");

// Add an s to the default untranslated string if it ends in r since this
// Fixes common role names people use in English (e.g. Author -> Authors)
var fallback = roleName.endsWith("r") ? roleName + "s" : roleName;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems a bit strange but I guess it's fine lol. we can remove if it causes issues


return Text.translatableWithFallback("modmenu.credits.role." + translationKey, fallback).append(Text.literal(":"));
}

protected class DescriptionEntry extends ElementListWidget.Entry<DescriptionEntry> {
protected OrderedText text;
protected int indent;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/modmenu/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"modmenu.credits.role.maintainer": "Maintainers",
"modmenu.credits.role.playtester": "Playtesters",
"modmenu.credits.role.illustrator": "Illustrators",
"modmenu.credits.role.owner": "Owners",

"modmenu.modsFolder": "Open Mods Folder",
"modmenu.configsFolder": "Open Configs Folder",
Expand Down
Loading