Skip to content

Commit cc9fced

Browse files
committed
Lobby button style
1 parent aae1f2e commit cc9fced

File tree

15 files changed

+70
-9
lines changed

15 files changed

+70
-9
lines changed

1.21.6/src/main/java/com/bleudev/ppl_utils/client/compat/modmenu/PplUtilsConfig.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,38 @@
33
import com.google.common.collect.Lists;
44
import eu.midnightdust.lib.config.MidnightConfig;
55
import net.minecraft.client.MinecraftClient;
6+
import net.minecraft.util.Identifier;
67

78
import java.util.List;
89

910
import static com.bleudev.ppl_utils.PplUtilsConst.MOD_ID;
11+
import static com.bleudev.ppl_utils.util.RegistryUtils.getIdentifier;
1012

1113
public class PplUtilsConfig extends MidnightConfig {
1214
@Comment(centered = true)
1315
public static Comment lobby_button_comment;
1416
@Entry
1517
public static boolean lobby_button_enabled = true;
16-
@Condition(requiredOption = "lobby_button_enabled")
18+
@Condition(requiredOption = "lobby_button_enabled", visibleButLocked = true)
1719
@Entry
1820
public static boolean lobby_button_tooltip_enabled = true;
21+
public enum LobbyButtonStyle {
22+
PEPE("lobby/pepe"),
23+
PEPE_MONO("lobby/pepe_mono");
24+
25+
private final Identifier sprite;
26+
27+
LobbyButtonStyle(String sprite) {
28+
this.sprite = getIdentifier(sprite);
29+
}
30+
31+
public Identifier getSprite() {
32+
return this.sprite;
33+
}
34+
}
35+
@Condition(requiredOption = "lobby_button_enabled", visibleButLocked = true)
36+
@Entry
37+
public static LobbyButtonStyle lobby_button_style = LobbyButtonStyle.PEPE;
1938

2039
@Comment(centered = true)
2140
public static Comment join_leave_messages_rendering_comment;

1.21.6/src/main/java/com/bleudev/ppl_utils/mixin/client/GameMenuScreenMixin.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
import net.minecraft.client.gui.tooltip.Tooltip;
88
import net.minecraft.client.gui.widget.TextIconButtonWidget;
99
import net.minecraft.text.Text;
10+
import net.minecraft.util.Identifier;
1011
import org.spongepowered.asm.mixin.Mixin;
1112
import org.spongepowered.asm.mixin.Unique;
1213
import org.spongepowered.asm.mixin.injection.At;
1314
import org.spongepowered.asm.mixin.injection.Inject;
1415
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1516

1617
import static com.bleudev.ppl_utils.client.ClientCallbacks.executeLobby;
17-
import static com.bleudev.ppl_utils.util.RegistryUtils.getIdentifier;
1818

1919
@Mixin(GameMenuScreen.class)
2020
public abstract class GameMenuScreenMixin extends Screen {
@@ -23,11 +23,16 @@ protected GameMenuScreenMixin(Text title) {
2323
}
2424

2525
// Rendering
26+
@Unique
27+
private Identifier getLobbyButtonTexture() {
28+
return PplUtilsConfig.lobby_button_style.getSprite();
29+
}
30+
2631
@Unique
2732
private void drawLobbyButton() {
2833
var btn = TextIconButtonWidget.builder(Text.translatable("text.ppl_utils.game_menu.lobby_button.tooltip"),
2934
button -> executeLobby(), true)
30-
.texture(getIdentifier("pepe_mono"), 13, 13)
35+
.texture(getLobbyButtonTexture(), 13, 13)
3136
.dimension(20, 20)
3237
.build();
3338
btn.setPosition(this.width / 2 - 125, this.height / 4 + 32);

1.21.6/src/main/java/com/bleudev/ppl_utils/util/ServerUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ServerUtils {
1414
"issues2.pepeland.net"
1515
);
1616

17-
public static boolean isClientOnServerSupportsLobbyCommand(MinecraftClient client) {
17+
public static boolean isClientOnServerSupportsLobbyCommand(@NotNull MinecraftClient client) {
1818
final var server = client.getCurrentServerEntry();
1919
if (server == null) return false;
2020
return Nullables.mapOrElse(server.address, SUPPORTS_LOBBY_COMMAND_IPS::contains, false);

1.21.6/src/main/resources/assets/ppl_utils/lang/en_us.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"ppl_utils.midnightconfig.lobby_button_comment": "Lobby button",
1010
"ppl_utils.midnightconfig.lobby_button_enabled": "Enable lobby button",
1111
"ppl_utils.midnightconfig.lobby_button_tooltip_enabled": "Enable lobby button tooltip",
12+
"ppl_utils.midnightconfig.lobby_button_style": "Lobby button style",
13+
"ppl_utils.midnightconfig.enum.LobbyButtonStyle.PEPE": "Normal",
14+
"ppl_utils.midnightconfig.enum.LobbyButtonStyle.PEPE_MONO": "Monochrome",
1215
"ppl_utils.midnightconfig.join_leave_messages_rendering_comment": "Join/leave messages rendering",
1316
"ppl_utils.midnightconfig.do_join_leave_messages_rendering": "Do join/leave messages rendering",
1417
"ppl_utils.midnightconfig.always_show_join_leave_messages_by": "Always show join/leave messages for these players"

1.21.6/src/main/resources/assets/ppl_utils/lang/ru_ru.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"ppl_utils.midnightconfig.lobby_button_comment": "Лобби-кнопка",
1010
"ppl_utils.midnightconfig.lobby_button_enabled": "Включить лобби-кнопку",
1111
"ppl_utils.midnightconfig.lobby_button_tooltip_enabled": "Показывать подсказку при наведении на лобби-кнопку",
12+
"ppl_utils.midnightconfig.lobby_button_style": "Стиль лобби-кнопки",
13+
"ppl_utils.midnightconfig.enum.LobbyButtonStyle.PEPE": "Стандартный",
14+
"ppl_utils.midnightconfig.enum.LobbyButtonStyle.PEPE_MONO": "Монохромный",
1215
"ppl_utils.midnightconfig.join_leave_messages_rendering_comment": "Отображение сообщений при входе/выходе игроков",
1316
"ppl_utils.midnightconfig.do_join_leave_messages_rendering": "Отображать сообщения при входе/выходе игроков",
1417
"ppl_utils.midnightconfig.always_show_join_leave_messages_by": "Всегда показывать сообщения при входе/выходе данных игроков"

1.21.6/src/main/resources/assets/ppl_utils/textures/gui/sprites/pepe.png renamed to 1.21.6/src/main/resources/assets/ppl_utils/textures/gui/sprites/lobby/pepe.png

File renamed without changes.

1.21.6/src/main/resources/assets/ppl_utils/textures/gui/sprites/pepe_mono.png renamed to 1.21.6/src/main/resources/assets/ppl_utils/textures/gui/sprites/lobby/pepe_mono.png

File renamed without changes.

1.21.9/src/main/java/com/bleudev/ppl_utils/client/compat/modmenu/PplUtilsConfig.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,38 @@
33
import com.google.common.collect.Lists;
44
import eu.midnightdust.lib.config.MidnightConfig;
55
import net.minecraft.client.MinecraftClient;
6+
import net.minecraft.util.Identifier;
67

78
import java.util.List;
89

910
import static com.bleudev.ppl_utils.PplUtilsConst.MOD_ID;
11+
import static com.bleudev.ppl_utils.util.RegistryUtils.getIdentifier;
1012

1113
public class PplUtilsConfig extends MidnightConfig {
1214
@Comment(centered = true)
1315
public static Comment lobby_button_comment;
1416
@Entry
1517
public static boolean lobby_button_enabled = true;
16-
@Condition(requiredOption = "lobby_button_enabled")
18+
@Condition(requiredOption = "lobby_button_enabled", visibleButLocked = true)
1719
@Entry
1820
public static boolean lobby_button_tooltip_enabled = true;
21+
public enum LobbyButtonStyle {
22+
PEPE("lobby/pepe"),
23+
PEPE_MONO("lobby/pepe_mono");
24+
25+
private final Identifier sprite;
26+
27+
LobbyButtonStyle(String sprite) {
28+
this.sprite = getIdentifier(sprite);
29+
}
30+
31+
public Identifier getSprite() {
32+
return this.sprite;
33+
}
34+
}
35+
@Condition(requiredOption = "lobby_button_enabled", visibleButLocked = true)
36+
@Entry
37+
public static LobbyButtonStyle lobby_button_style = LobbyButtonStyle.PEPE;
1938

2039
@Comment(centered = true)
2140
public static Comment join_leave_messages_rendering_comment;

1.21.9/src/main/java/com/bleudev/ppl_utils/mixin/client/GameMenuScreenMixin.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
import net.minecraft.client.gui.screen.Screen;
77
import net.minecraft.client.gui.widget.TextIconButtonWidget;
88
import net.minecraft.text.Text;
9+
import net.minecraft.util.Identifier;
910
import org.spongepowered.asm.mixin.Mixin;
1011
import org.spongepowered.asm.mixin.Unique;
1112
import org.spongepowered.asm.mixin.injection.At;
1213
import org.spongepowered.asm.mixin.injection.Inject;
1314
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
1415

1516
import static com.bleudev.ppl_utils.client.ClientCallbacks.executeLobby;
16-
import static com.bleudev.ppl_utils.util.RegistryUtils.getIdentifier;
1717

1818
@Mixin(GameMenuScreen.class)
1919
public abstract class GameMenuScreenMixin extends Screen {
@@ -22,11 +22,16 @@ protected GameMenuScreenMixin(Text title) {
2222
}
2323

2424
// Rendering
25+
@Unique
26+
private Identifier getLobbyButtonTexture() {
27+
return PplUtilsConfig.lobby_button_style.getSprite();
28+
}
29+
2530
@Unique
2631
private void drawLobbyButton() {
2732
var b = TextIconButtonWidget.builder(Text.translatable("text.ppl_utils.game_menu.lobby_button.tooltip"),
2833
button -> executeLobby(), true)
29-
.texture(getIdentifier("pepe_mono"), 13, 13)
34+
.texture(getLobbyButtonTexture(), 13, 13)
3035
.dimension(20, 20);
3136
if (PplUtilsConfig.lobby_button_tooltip_enabled) b = b.useTextAsTooltip();
3237
var btn = b.build();

1.21.9/src/main/java/com/bleudev/ppl_utils/util/ServerUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ServerUtils {
1414
"issues2.pepeland.net"
1515
);
1616

17-
public static boolean isClientOnServerSupportsLobbyCommand(MinecraftClient client) {
17+
public static boolean isClientOnServerSupportsLobbyCommand(@NotNull MinecraftClient client) {
1818
final var server = client.getCurrentServerEntry();
1919
if (server == null) return false;
2020
return Nullables.mapOrElse(server.address, SUPPORTS_LOBBY_COMMAND_IPS::contains, false);

0 commit comments

Comments
 (0)