Skip to content

Commit

Permalink
add info on selected mode to config screen
Browse files Browse the repository at this point in the history
- improve text readability
  • Loading branch information
ix0rai committed Oct 11, 2022
1 parent d54d1a8 commit 50111bb
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
- optimise config reading and writing
- optimise colour lookups (improvements to in game performance)
- mixin compatibility improvements
- improve config file with prettier screen and more info
- config screen now displays the currently enabled colours, the colours in the currently selected mode, and is prettier
32 changes: 27 additions & 5 deletions src/main/java/io/ix0rai/rainglow/config/RainglowConfigScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,23 @@ public class RainglowConfigScreen extends SpruceScreen {
private final SpruceOption resetOption;
private RainglowMode mode;

private SpruceLabelWidget coloursToApplyLabel;

public RainglowConfigScreen(@Nullable Screen parent) {
super(Rainglow.translatableText("config.title"));
this.parent = parent;
this.mode = Rainglow.CONFIG.getMode();

this.modeOption = new SpruceCyclingOption(Rainglow.translatableTextKey("config.mode"),
amount -> mode = mode.cycle(),
amount -> {
mode = mode.cycle();
this.remove(coloursToApplyLabel);
StringBuilder coloursToApply = new StringBuilder(Language.getInstance().get(Rainglow.translatableTextKey("config.colours_to_apply")));
appendColours(coloursToApply, this.mode);
Style style = Style.EMPTY.withColor(this.mode.getText().getStyle().getColor());
this.coloursToApplyLabel = new SpruceLabelWidget(Position.of(this, this.width / 2 - 108, this.height / 4 + 20), Text.literal(coloursToApply.toString()).setStyle(style), this.width, true);
this.addDrawableChild(coloursToApplyLabel);
},
option -> option.getDisplayText(mode.getText()),
Rainglow.translatableText("tooltip.mode",
List.of(RainglowMode.values())
Expand Down Expand Up @@ -72,11 +82,17 @@ protected void init() {
this.addDrawableChild(this.customOption.createWidget(Position.of(this.width / 2 + 5, this.height / 6 - buttonHeight + buttonOffset), 200));

this.addDrawableChild(new SpruceLabelWidget(Position.of(this, 0, this.height / 9), Rainglow.translatableText("config.title"), this.width, true));

StringBuilder text = new StringBuilder(Language.getInstance().get(Rainglow.translatableTextKey("config.current_colours")));
for (SquidColour colour : Rainglow.CONFIG.getMode().getColours()) {
text.append("\n").append(Language.getInstance().get(Rainglow.translatableTextKey("colour." + colour.getId())));
}
this.addDrawableChild(new SpruceLabelWidget(Position.of(this, 0, this.height / 4 + buttonHeight), Text.of(text.toString()).copy().setStyle(Style.EMPTY.withColor(Rainglow.CONFIG.getMode().getText().getStyle().getColor())), this.width, true));
appendColours(text, Rainglow.CONFIG.getMode());
Style style = Style.EMPTY.withColor(Rainglow.CONFIG.getMode().getText().getStyle().getColor());
this.addDrawableChild(new SpruceLabelWidget(Position.of(this, this.width / 2 - 318, this.height / 4 + buttonHeight), Text.literal(text.toString()).setStyle(style), this.width, true));

StringBuilder coloursToApply = new StringBuilder(Language.getInstance().get(Rainglow.translatableTextKey("config.colours_to_apply")));
appendColours(coloursToApply, this.mode);
style = Style.EMPTY.withColor(this.mode.getText().getStyle().getColor());
this.coloursToApplyLabel = new SpruceLabelWidget(Position.of(this, this.width / 2 - 108, this.height / 4 + buttonHeight), Text.literal(coloursToApply.toString()).setStyle(style), this.width, true);
this.addDrawableChild(coloursToApplyLabel);

this.addDrawableChild(this.resetOption.createWidget(Position.of(this, this.width / 2 - 155, this.height - 29), 150));
this.addDrawableChild(new SpruceButtonWidget(Position.of(this, this.width / 2 - 155 + 160, this.height - 29), 150,
Expand All @@ -87,4 +103,10 @@ protected void init() {
}
));
}

private void appendColours(StringBuilder text, RainglowMode mode) {
for (SquidColour colour : mode.getColours()) {
text.append("\n").append(Language.getInstance().get(Rainglow.translatableTextKey("colour." + colour.getId())));
}
}
}
5 changes: 3 additions & 2 deletions src/main/java/io/ix0rai/rainglow/config/RainglowMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public enum RainglowMode {
SquidColour.PINK,
SquidColour.PURPLE
),
BI_PRIDE(Rainglow.translatableText("mode.bi_pride"), TextColor.fromRgb(0x292784),
BI_PRIDE(Rainglow.translatableText("mode.bi_pride"), TextColor.fromRgb(0x0063A0),
SquidColour.BLUE,
SquidColour.PINK,
SquidColour.PURPLE
Expand All @@ -62,7 +62,7 @@ public enum RainglowMode {
SquidColour.WHITE,
SquidColour.GREEN
),
ENBY_PRIDE(Rainglow.translatableText("mode.enby_pride"), TextColor.fromRgb(0x531F82),
ENBY_PRIDE(Rainglow.translatableText("mode.enby_pride"), TextColor.fromRgb(0x705CA8),
SquidColour.YELLOW,
SquidColour.WHITE,
SquidColour.BLACK,
Expand All @@ -84,6 +84,7 @@ public enum RainglowMode {
SquidColour.BLUE
),
CUSTOM(Rainglow.translatableText("mode.custom"), TextColor.fromRgb(0x00FFE1));

private static final Map<String, RainglowMode> BY_ID = new HashMap<>();

static {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/rainglow/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"rainglow.config.title": "Rainglow Configuration",
"rainglow.config.current_colours": "Currently enabled colours:",
"rainglow.config.colours_to_apply": "Colours to apply:",
"rainglow.config.mode": "Mode",
"rainglow.config.save": "Save",
"rainglow.config.clear": "Clear",
Expand Down

0 comments on commit 50111bb

Please sign in to comment.