Skip to content

Commit

Permalink
add click sounds to sub account UI
Browse files Browse the repository at this point in the history
  • Loading branch information
techno-sam committed Aug 9, 2024
1 parent 0ee6549 commit dce621c
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.client.renderer.Rect2i;
import net.minecraft.client.resources.sounds.SimpleSoundInstance;
import net.minecraft.network.chat.Component;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.util.FormattedCharSequence;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.player.Inventory;
Expand Down Expand Up @@ -131,6 +133,10 @@ protected void init() {
stopPopup();
}

private void clickSound() {
Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
}

protected void editSubAccount(UUID subAccountID) {
menu.openSubAccountEditScreen(subAccountID);
NumismaticsPackets.PACKETS.send(new OpenSubAccountEditScreenPacket(subAccountID));
Expand All @@ -148,6 +154,7 @@ protected void startPopup() {
hasPopup = true;

editorConfirm = new IconButton(leftPos + 56 + 168 - 13, topPos + 65 + 22, AllIcons.I_CONFIRM);
editorConfirm.withCallback(() -> editSubAccount(null));
addRenderableWidget(editorConfirm);

int x = leftPos - 12;
Expand Down Expand Up @@ -455,6 +462,7 @@ public boolean action(@Nullable GuiGraphics graphics, double mouseX, double mous
renderActionTooltip(graphics, ImmutableList.of(Components.translatable("gui.numismatics.bank_terminal.sub_accounts.remove")), mx, my);
}
if (click == 0) {
clickSound();
if (ready) {
menu.removeSubAccount(subAccount.getAuthorizationID());
removeProgress.updateChaseTarget(0.0f);
Expand All @@ -474,6 +482,7 @@ public boolean action(@Nullable GuiGraphics graphics, double mouseX, double mous
if (cx >= 195 && cx <= 203) {
renderActionTooltip(graphics, ImmutableList.of(Components.translatable("gui.numismatics.bank_terminal.sub_accounts.edit")), mx, my);
if (click == 0) {
clickSound();
editSubAccount(subAccount.getAuthorizationID());
}
return true;
Expand All @@ -487,6 +496,7 @@ public boolean action(@Nullable GuiGraphics graphics, double mouseX, double mous
if (cx >= 193 && cx <= 204) {
renderActionTooltip(graphics, ImmutableList.of(Components.translatable("gui.numismatics.bank_terminal.sub_accounts.reset_spending")), mx, my);
if (click == 0) {
clickSound();
menu.resetSubAccountSpending(subAccount.getAuthorizationID());
}
return true;
Expand Down Expand Up @@ -539,11 +549,6 @@ protected void endStencil() {
public boolean mouseClicked(double pMouseX, double pMouseY, int pButton) {
syncName();

if (editorConfirm != null && editorConfirm.isMouseOver(pMouseX, pMouseY)) {
editSubAccount(null);
return true;
}

if (action(null, pMouseX, pMouseY, pButton))
return true;

Expand Down

0 comments on commit dce621c

Please sign in to comment.