Skip to content

Commit

Permalink
Fix drum QWERTY (generalize filterQwerty method)
Browse files Browse the repository at this point in the history
  • Loading branch information
StavWasPlayZ committed Aug 29, 2023
1 parent bceecad commit 80809a2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;


Expand All @@ -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];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 80809a2

Please sign in to comment.