Skip to content

Commit

Permalink
Change the layout of the navigator (active toggle) (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugman76 authored Sep 4, 2023
1 parent f7b9b55 commit 4c75a33
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,34 +122,21 @@ public void applyTo(ServerPlayerEntity player) {

private void fill(ServerPlayerEntity player, SimpleGui gui, boolean viewOpen) {
var page = new MutableInt();
var all = new GuiElementBuilder(Items.COMPASS);
if (!viewOpen) {
all.glow();
} else {
all.setCallback(() -> {
this.fill(player, gui, false);
PagedGui.playClickSound(player);
});
}

gui.setSlot(5 * 9 + 3, all.setName(Text.translatable("nucleoid.navigator.all_games")));

var open = new GuiElementBuilder(Items.REDSTONE_TORCH);
if (viewOpen) {
open.glow();
} else {
open.setCallback(() -> {
this.fill(player, gui, true);
PagedGui.playClickSound(player);
});
}
gui.setSlot(5 * 9 + 5, open.setName(Text.translatable("nucleoid.navigator.open_games")));
var filter = new GuiElementBuilder(viewOpen ? Items.SOUL_LANTERN : Items.LANTERN);
filter.setCallback(() -> {
this.fill(player, gui, !viewOpen);
PagedGui.playClickSound(player);
});

if (viewOpen) {
filter.glow();
gui.setTitle(this.uiTitle.copy().append(Text.of(" ")).append(Text.translatable("nucleoid.navigator.open_only")));
this.fillOpen(player, gui, page);
} else {
gui.setTitle(this.uiTitle);
this.fillInterface(player, gui, page);
}
gui.setSlot(5 * 9 + 4, filter.setName(Text.translatable(viewOpen ? "nucleoid.navigator.open_games" : "nucleoid.navigator.all_games")));
}

private void fillOpen(ServerPlayerEntity player, SimpleGui gui, MutableInt page) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/data/nucleoid_extras/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
"nucleoid.stop.scheduled.already": "Server restart has already been scheduled.",
"nucleoid.stop.game.open": "Cannot join this game: a server stop has been scheduled!",

"nucleoid.navigator.all_games": "View Games",
"nucleoid.navigator.open_games": "View Active",
"nucleoid.navigator.all_games": "All Games",
"nucleoid.navigator.open_games": "Open Games",
"nucleoid.navigator.open_only": "(Open only)",

"block.nucleoid_extras.end_portal": "End Portal (Lobby only!)",
"block.nucleoid_extras.end_gateway": "End Gateway (Lobby only!)",
Expand Down

0 comments on commit 4c75a33

Please sign in to comment.