From 80809a2fe05df7b173aafc0f54a08188f19a1e70 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Tue, 29 Aug 2023 19:35:07 +0300 Subject: [PATCH] Fix drum QWERTY (generalize filterQwerty method) --- .../client/config/enumType/label/DrumNoteLabel.java | 3 ++- .../client/config/enumType/label/NoteGridLabel.java | 3 ++- .../screen/instrument/partial/note/label/INoteLabel.java | 7 +++---- .../gui/screen/options/instrument/DrumOptionsScren.java | 4 ++-- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/cstav/genshinstrument/client/config/enumType/label/DrumNoteLabel.java b/src/main/java/com/cstav/genshinstrument/client/config/enumType/label/DrumNoteLabel.java index 5334ced..72b78f5 100644 --- a/src/main/java/com/cstav/genshinstrument/client/config/enumType/label/DrumNoteLabel.java +++ b/src/main/java/com/cstav/genshinstrument/client/config/enumType/label/DrumNoteLabel.java @@ -1,5 +1,6 @@ package com.cstav.genshinstrument.client.config.enumType.label; +import com.cstav.genshinstrument.client.config.ModClientConfigs; import com.cstav.genshinstrument.client.gui.screen.instrument.drum.DrumNoteButton; import com.cstav.genshinstrument.client.gui.screen.instrument.partial.note.NoteButton; import com.cstav.genshinstrument.client.gui.screen.instrument.partial.note.label.INoteLabel; @@ -37,7 +38,7 @@ private DrumNoteLabel(final NoteLabelSupplier supplier) { } public static INoteLabel[] availableVals() { - return INoteLabel.filterQwerty(values(), QWERTY); + return INoteLabel.filterQwerty(values(), ModClientConfigs.DRUM_LABEL_TYPE.get(), QWERTY); } diff --git a/src/main/java/com/cstav/genshinstrument/client/config/enumType/label/NoteGridLabel.java b/src/main/java/com/cstav/genshinstrument/client/config/enumType/label/NoteGridLabel.java index 5aa654f..015f494 100644 --- a/src/main/java/com/cstav/genshinstrument/client/config/enumType/label/NoteGridLabel.java +++ b/src/main/java/com/cstav/genshinstrument/client/config/enumType/label/NoteGridLabel.java @@ -1,5 +1,6 @@ package com.cstav.genshinstrument.client.config.enumType.label; +import com.cstav.genshinstrument.client.config.ModClientConfigs; import com.cstav.genshinstrument.client.gui.screen.instrument.partial.note.NoteButton; import com.cstav.genshinstrument.client.gui.screen.instrument.partial.note.label.INoteLabel; import com.cstav.genshinstrument.client.gui.screen.instrument.partial.note.label.NoteLabelSupplier; @@ -36,7 +37,7 @@ private NoteGridLabel(final NoteLabelSupplier labelSupplier) { } public static INoteLabel[] availableVals() { - return INoteLabel.filterQwerty(values(), QWERTY); + return INoteLabel.filterQwerty(values(), ModClientConfigs.GRID_LABEL_TYPE.get(), QWERTY); } diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screen/instrument/partial/note/label/INoteLabel.java b/src/main/java/com/cstav/genshinstrument/client/gui/screen/instrument/partial/note/label/INoteLabel.java index 9a1de26..6218c6b 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screen/instrument/partial/note/label/INoteLabel.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screen/instrument/partial/note/label/INoteLabel.java @@ -2,7 +2,6 @@ import com.cstav.genshinstrument.client.ClientUtil; -import com.cstav.genshinstrument.client.config.ModClientConfigs; import com.mojang.blaze3d.platform.InputConstants.Key; import net.minecraft.network.chat.Component; @@ -32,10 +31,10 @@ public static MutableComponent getQwerty(final Key key) { /** * @return All the values of this note label type, filtering QWERTY if already using it. */ - public static INoteLabel[] filterQwerty(final INoteLabel[] values, final INoteLabel qwerty) { + public static INoteLabel[] filterQwerty(INoteLabel[] values, INoteLabel currentLabel, INoteLabel qwerty) { // Ignore QWERTY if already using this layout // Or if the user already selected it - if (!ClientUtil.isOnQwerty() || (ModClientConfigs.GRID_LABEL_TYPE.get() == qwerty)) + if (!ClientUtil.isOnQwerty() || (currentLabel.equals(qwerty))) return values; @@ -44,7 +43,7 @@ public static INoteLabel[] filterQwerty(final INoteLabel[] values, final INoteLa // 2nd index to not go out of bounds int j = 0; for (int i = 0; i < values.length; i++) { - if (values[i] == qwerty) + if (values[i].equals(qwerty)) i++; result[j] = values[i]; diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screen/options/instrument/DrumOptionsScren.java b/src/main/java/com/cstav/genshinstrument/client/gui/screen/options/instrument/DrumOptionsScren.java index 4de8163..f33278a 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screen/options/instrument/DrumOptionsScren.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screen/options/instrument/DrumOptionsScren.java @@ -25,8 +25,8 @@ protected void saveLabel(INoteLabel newLabel) { } @Override - public DrumNoteLabel[] getLabels() { - return DrumNoteLabel.values(); + public INoteLabel[] getLabels() { + return DrumNoteLabel.availableVals(); } @Override public DrumNoteLabel getCurrentLabel() {