Skip to content

Commit

Permalink
Release v3.2+fabric-1.20.2
Browse files Browse the repository at this point in the history
This commit adds the "Credits" button for translators.
  • Loading branch information
TheCSDev committed Oct 12, 2023
1 parent fa41c54 commit c961f76
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
import static io.github.thecsdev.betterstats.client.network.BetterStatsClientNetworkHandler.serverHasBSS;
import static io.github.thecsdev.betterstats.network.BetterStatsNetworkHandler.TXT_CONSENT_WARNING;
import static io.github.thecsdev.betterstats.network.BetterStatsNetworkHandler.TXT_TOGGLE_TOOLTIP;
import static io.github.thecsdev.tcdcommons.api.util.TextUtils.fLiteral;
import static io.github.thecsdev.tcdcommons.api.util.TextUtils.translatable;

import java.awt.Rectangle;
import java.util.Objects;

import org.apache.commons.lang3.StringUtils;

import io.github.thecsdev.betterstats.api.client.gui.panel.BSComponentPanel;
import io.github.thecsdev.betterstats.api.client.gui.screen.BetterStatsConfigScreen;
import io.github.thecsdev.tcdcommons.api.client.gui.screen.TScreenWrapper;
Expand Down Expand Up @@ -87,6 +90,35 @@ public ActionBarPanel(int x, int y, int width, ActionBarPanelProxy proxy) throws
});
btn_bssNet.setEnabled(serverHasBSS() && !MC_CLIENT.isInSingleplayer());
addChild(btn_bssNet, false);

//credits button
final var btn_credits = new TButtonWidget(btn_bssNet.getX() - 20, btn_bssNet.getY(), 20, 20);
final var tt_credits = fLiteral("§e" + translatable("credits_and_attribution.button.credits").getString())
.append(fLiteral("§r\n\n§7# " + translatable("betterstats.translators.title").getString() + "§r\n"))
.append(getCreditsTranslatorNames());
btn_credits.setTooltip(Tooltip.of(tt_credits));
btn_credits.setIcon(new UITexture(BS_WIDGETS_TEXTURE, new Rectangle(0, 100, 20, 20)));
addChild(btn_credits, false);
}
// --------------------------------------------------
private static final String getCreditsTranslatorNames()
{
final String translators = translatable("betterstats.translators").getString();
if(StringUtils.isBlank(translators))
return "-";

String[] names = translators.split(",");
StringBuilder output = new StringBuilder();

for (String name : names)
{
//skip blank names
if(StringUtils.isBlank(name)) continue;
//append name
output.append("- " + name.trim()).append("\n");
}

return output.toString().trim();
}
// ==================================================
public static interface ActionBarPanelProxy
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c961f76

Please sign in to comment.