Skip to content

Commit

Permalink
Fix kit selection ui
Browse files Browse the repository at this point in the history
  • Loading branch information
PotatoPresident committed Dec 18, 2024
1 parent 2592340 commit c119383
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
minecraft_version=1.21.4
yarn_mappings=1.21.4+build.1
loader_version=0.16.9

# Mod Properties
Expand All @@ -14,7 +14,7 @@ archives_base_name=skywars

# Dependencies
# check these on https://modmuss50.me/fabric.html
fabric_version=0.110.0+1.21.3
fabric_version=0.110.5+1.21.4

# check this on https://ci.gegy.dev/job/plasmid/
plasmid_version=0.6.1+1.21.3
plasmid_version=0.6.2+1.21.4
12 changes: 12 additions & 0 deletions src/main/java/us/potatoboy/skywars/game/ui/KitPreviewUI.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package us.potatoboy.skywars.game.ui;

import eu.pb4.sgui.api.GuiHelpers;
import eu.pb4.sgui.api.elements.GuiElementBuilder;
import eu.pb4.sgui.api.gui.GuiInterface;
import eu.pb4.sgui.api.gui.SimpleGui;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
Expand All @@ -9,14 +11,17 @@
import net.minecraft.sound.SoundEvents;
import net.minecraft.text.Style;
import net.minecraft.text.Text;
import org.jetbrains.annotations.Nullable;
import us.potatoboy.skywars.kit.Kit;

public class KitPreviewUI extends SimpleGui {
private final KitSelectorUI selectorUI;
private final Kit kit;
private final @Nullable GuiInterface prev;

public KitPreviewUI(KitSelectorUI selectorUI, Kit kit) {
super(ScreenHandlerType.GENERIC_9X3, selectorUI.getPlayer(), false);
this.prev = GuiHelpers.getCurrentGui(player);
this.selectorUI = selectorUI;
this.kit = kit;
this.setTitle(kit.displayName());
Expand Down Expand Up @@ -49,4 +54,11 @@ public void onOpen() {

super.onOpen();
}

@Override
public void onClose() {
if (this.prev != null) {
this.prev.open();
}
}
}
12 changes: 12 additions & 0 deletions src/main/java/us/potatoboy/skywars/game/ui/KitSelectorUI.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package us.potatoboy.skywars.game.ui;

import eu.pb4.sgui.api.GuiHelpers;
import eu.pb4.sgui.api.elements.GuiElementBuilder;
import eu.pb4.sgui.api.gui.GuiInterface;
import eu.pb4.sgui.api.gui.SimpleGui;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.server.network.ServerPlayerEntity;
Expand All @@ -9,6 +11,7 @@
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
import org.jetbrains.annotations.Nullable;
import us.potatoboy.skywars.game.SkyWarsPlayer;
import us.potatoboy.skywars.game.SkyWarsWaiting;
import us.potatoboy.skywars.kit.Kit;
Expand All @@ -23,9 +26,11 @@ public final class KitSelectorUI extends SimpleGui {
private final SkyWarsPlayer playerData;
private final SkyWarsWaiting game;
private final List<Kit> kits;
private final @Nullable GuiInterface prev;

KitSelectorUI(ServerPlayerEntity player, SkyWarsPlayer data, SkyWarsWaiting game, List<Kit> kits) {
super(getType(kits.size()), player, kits.size() > 53);
this.prev = GuiHelpers.getCurrentGui(player);
this.playerData = data;
this.game = game;
this.kits = kits;
Expand Down Expand Up @@ -104,4 +109,11 @@ public void onOpen() {
public static void changeKit(SkyWarsWaiting game, ServerPlayerEntity player, SkyWarsPlayer playerData, Kit kit) {
playerData.selectedKit = kit;
}

@Override
public void onClose() {
if (this.prev != null) {
this.prev.open();
}
}
}

0 comments on commit c119383

Please sign in to comment.