diff --git a/CHANGELOG.md b/CHANGELOG.md index 01f0102..39ffef3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,4 @@ -Made logo square and added the issues page for better compat with ModMenu. - -Fixed null crashes. \ No newline at end of file +Make sure sound is not cleared midway (fix possible crash) +Fixed non-muffled sounds non being removed from the muffled screen +Fixed muffled and play sound button tooltips being just bad +Other small gui fixes \ No newline at end of file diff --git a/Common/src/main/java/com/leobeliik/extremesoundmuffler/gui/MufflerScreen.java b/Common/src/main/java/com/leobeliik/extremesoundmuffler/gui/MufflerScreen.java index 2c9d3a1..43480f4 100644 --- a/Common/src/main/java/com/leobeliik/extremesoundmuffler/gui/MufflerScreen.java +++ b/Common/src/main/java/com/leobeliik/extremesoundmuffler/gui/MufflerScreen.java @@ -57,9 +57,6 @@ protected void init() { minYButton = getY() + 46; maxYButton = getY() + 164; - //allows to hold a key to keep printing it. in this case I want it to easy erase text - //minecraft.keyboardHandler.setSendRepeatsToGui(true); - addButtons(); addSideButtons(); addAnchorButtons(); @@ -498,7 +495,9 @@ private void renderSideScreen(GuiGraphics stack) { } private void renderButtonTooltip(GuiGraphics stack, Component message, AbstractWidget button) { - int centeredMessageX = button.getX() - (font.width(message) / 2); + //to render CSL button tooltip more centered + int CSLShift = button.equals(btnCSL) ? 25 : 0; + int centeredMessageX = button.getX() - ((font.width(message) - CSLShift) / 2); int centeredMessageY = button.equals(btnPrevSounds) || button.equals(btnNextSounds) ? button.getY() - 1 : button.getY() + button.getHeight() + 16; stack.renderTooltip(font, message, centeredMessageX, centeredMessageY); } diff --git a/Common/src/main/java/com/leobeliik/extremesoundmuffler/gui/buttons/MuffledSlider.java b/Common/src/main/java/com/leobeliik/extremesoundmuffler/gui/buttons/MuffledSlider.java index 505f40a..e6dc0fe 100644 --- a/Common/src/main/java/com/leobeliik/extremesoundmuffler/gui/buttons/MuffledSlider.java +++ b/Common/src/main/java/com/leobeliik/extremesoundmuffler/gui/buttons/MuffledSlider.java @@ -72,15 +72,13 @@ public void renderWidget(@NotNull GuiGraphics stack, int mouseX, int mouseY, flo this.drawMessage(stack); } - private void renderButtonTooltip(GuiGraphics stack, AbstractButton btn, Component text) { - int lengthierText = font.width(text); - int x1 = btn.getX() + (btn.getHeight() / 2) - (font.width(text) / 2); - int x2 = x1 + lengthierText + 2; - int y1 = btn.getY() - font.lineHeight - 2; - int y2 = btn.getY() - 1; + private void renderButtonTooltip(GuiGraphics stack, AbstractButton button, Component message) { + int centeredMessageX = button.getX() - (font.width(message) / 2); + int centeredMessageY = button.getY() - 1; - stack.fill(x1 - 3, y1 - 5, x2, y2 + 1, darkBG); - stack.drawString(font, text, x1, y1 - 2, whiteText); + stack.pose().pushPose(); + stack.renderTooltip(font, message, centeredMessageX, centeredMessageY); + stack.pose().popPose(); } private void drawMessage(GuiGraphics stack) { @@ -127,6 +125,7 @@ private void setBtnToggleSound(ResourceLocation sound) { if (isMuffling) { if (screen.removeSoundMuffled(sound)) { setFGColor(this, "white"); + this.visible = false; } } else { setSliderValue(CommonConfig.get().defaultMuteVolume().get()); @@ -172,13 +171,15 @@ protected void onDrag(double mouseX, double mouseY, double dragX, double dragY) @Override public boolean mouseClicked(double mouseX, double mouseY, int button) { - this.btnToggleSound.mouseClicked(mouseX, mouseY, button); - this.btnPlaySound.mouseClicked(mouseX, mouseY, button); - - if (isHovered && isMuffling) { - changeSliderValue((float) mouseX); - showSlider = true; - setFocused(true); + if (this.visible) { + this.btnToggleSound.mouseClicked(mouseX, mouseY, button); + this.btnPlaySound.mouseClicked(mouseX, mouseY, button); + + if (isHovered && isMuffling) { + changeSliderValue((float) mouseX); + showSlider = true; + setFocused(true); + } } return super.mouseClicked(mouseX, mouseY, button); } diff --git a/Common/src/main/java/com/leobeliik/extremesoundmuffler/mixins/SoundMixin.java b/Common/src/main/java/com/leobeliik/extremesoundmuffler/mixins/SoundMixin.java index 8fe3829..2a78e69 100644 --- a/Common/src/main/java/com/leobeliik/extremesoundmuffler/mixins/SoundMixin.java +++ b/Common/src/main/java/com/leobeliik/extremesoundmuffler/mixins/SoundMixin.java @@ -41,22 +41,23 @@ private void esm_captureTickableSoundVolume(SoundInstance sound, CallbackInfo ci @ModifyArg(index = 0, at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Mth;clamp(FFF)F"), method = "calculateVolume(FLnet/minecraft/sounds/SoundSource;)F") private float esm_setVolume(float volume) { + SoundInstance tempSound = esmSound; //don't care about forbidden sounds or from the psb - if (esmSound != null && !esm_isForbidden(esmSound) && !PlaySoundButton.isFromPSB()) { + if (tempSound != null && !esm_isForbidden(tempSound) && !PlaySoundButton.isFromPSB()) { //add sound to recent sounds list - recentSoundsList.add(esmSound.getLocation()); + recentSoundsList.add(tempSound.getLocation()); if (MufflerScreen.isMuffling()) { - if (muffledSounds.containsKey(esmSound.getLocation())) { - return (float) (esmSound.getVolume() * muffledSounds.get(esmSound.getLocation())); + if (muffledSounds.containsKey(tempSound.getLocation())) { + return (float) (tempSound.getVolume() * muffledSounds.get(tempSound.getLocation())); } //don't continue if the anchors are disabled if (CommonConfig.get() == null || !CommonConfig.get().disableAnchors().get()) { - Anchor anchor = Anchor.getAnchor(esmSound); + Anchor anchor = Anchor.getAnchor(tempSound); if (anchor != null) { - return (float) (esmSound.getVolume() * anchor.getMuffledSounds().get(esmSound.getLocation())); + return (float) (tempSound.getVolume() * anchor.getMuffledSounds().get(tempSound.getLocation())); } } } diff --git a/Common/src/main/resources/assets/extremesoundmuffler/textures/gui/sm_gui.png b/Common/src/main/resources/assets/extremesoundmuffler/textures/gui/sm_gui.png index 1909ad3..5151959 100644 Binary files a/Common/src/main/resources/assets/extremesoundmuffler/textures/gui/sm_gui.png and b/Common/src/main/resources/assets/extremesoundmuffler/textures/gui/sm_gui.png differ diff --git a/Common/src/main/resources/assets/extremesoundmuffler/textures/gui/sm_gui_dark.png b/Common/src/main/resources/assets/extremesoundmuffler/textures/gui/sm_gui_dark.png index cabad4e..5c08a20 100644 Binary files a/Common/src/main/resources/assets/extremesoundmuffler/textures/gui/sm_gui_dark.png and b/Common/src/main/resources/assets/extremesoundmuffler/textures/gui/sm_gui_dark.png differ diff --git a/gradle.properties b/gradle.properties index 4557469..083c8c5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,5 +1,5 @@ # Project -modversion = 39 +modversion = 40 group=com.leobeliik.extremesoundmuffler # Common