From 540b9be7e574b33f5e925cd3a9af84f3e7616ce8 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Mon, 7 Aug 2023 15:42:29 +0300 Subject: [PATCH 1/4] Pitch up/down with left/right shift --- .../partial/AbstractInstrumentScreen.java | 44 +++++++++++++- .../client/keyMaps/KeyMappings.java | 57 ++++++++++++++++++- .../assets/genshinstrument/lang/en_us.json | 5 ++ .../assets/genshinstrument/lang/he_il.json | 5 ++ .../assets/genshinstrument/lang/ru_ru.json | 5 ++ 5 files changed, 114 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java index fd0b2ddf..e767966b 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java @@ -11,6 +11,7 @@ import com.cstav.genshinstrument.client.gui.screens.instrument.GenshinConsentScreen; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteButton; import com.cstav.genshinstrument.client.gui.screens.options.instrument.AbstractInstrumentOptionsScreen; +import com.cstav.genshinstrument.client.keyMaps.KeyMappings; import com.cstav.genshinstrument.networking.ModPacketHandler; import com.cstav.genshinstrument.networking.buttonidentifier.NoteButtonIdentifier; import com.cstav.genshinstrument.networking.packet.instrument.CloseInstrumentPacket; @@ -219,9 +220,11 @@ protected AbstractWidget initOptionsButton(final int vertOffset) { } - @Override public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) { + if (checkPitchInstrumentUp(pKeyCode, pScanCode)) + return true; + final NoteButton note = getNoteByKey(pKeyCode); if (note != null) { @@ -233,6 +236,9 @@ public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) { } @Override public boolean keyReleased(int pKeyCode, int pScanCode, int pModifiers) { + if (checkPitchInstrumentDown(pKeyCode, pScanCode)) + return true; + unlockFocused(); final NoteButton note = getNoteByKey(pKeyCode); @@ -242,6 +248,42 @@ public boolean keyReleased(int pKeyCode, int pScanCode, int pModifiers) { return super.keyReleased(pKeyCode, pScanCode, pModifiers); } + private boolean pitchChanged; + protected boolean checkPitchInstrumentUp(int pKeyCode, int pScanCode) { + if (!pitchChanged && KeyMappings.PITCH_UP_MODIFIER.get().matches(pKeyCode, pScanCode)) { + pitchInstrumentUp(true); + return true; + } + if (!pitchChanged && KeyMappings.PITCH_DOWN_MODIFIER.get().matches(pKeyCode, pScanCode)) { + pitchInstrumentDown(true); + return true; + } + + return false; + } + protected boolean checkPitchInstrumentDown(int pKeyCode, int pScanCode) { + if (pitchChanged && KeyMappings.PITCH_UP_MODIFIER.get().matches(pKeyCode, pScanCode)) { + pitchInstrumentDown(false); + return true; + } + if (pitchChanged && KeyMappings.PITCH_DOWN_MODIFIER.get().matches(pKeyCode, pScanCode)) { + pitchInstrumentUp(false); + return true; + } + + return false; + } + + private void pitchInstrumentUp(final boolean pressed) { + setPitch(getPitch() + 1); + pitchChanged = pressed; + } + private void pitchInstrumentDown(final boolean pressed) { + setPitch(getPitch() - 1); + pitchChanged = pressed; + } + + @Override public boolean mouseReleased(double pMouseX, double pMouseY, int pButton) { unlockFocused(); diff --git a/src/main/java/com/cstav/genshinstrument/client/keyMaps/KeyMappings.java b/src/main/java/com/cstav/genshinstrument/client/keyMaps/KeyMappings.java index e39de2c8..99d982eb 100644 --- a/src/main/java/com/cstav/genshinstrument/client/keyMaps/KeyMappings.java +++ b/src/main/java/com/cstav/genshinstrument/client/keyMaps/KeyMappings.java @@ -1,16 +1,71 @@ package com.cstav.genshinstrument.client.keyMaps; +import org.lwjgl.glfw.GLFW; + +import com.cstav.genshinstrument.GInstrumentMod; +import com.cstav.genshinstrument.client.gui.screens.instrument.partial.AbstractInstrumentScreen; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.notegrid.AbstractGridInstrumentScreen; +import com.mojang.blaze3d.platform.InputConstants; import com.mojang.blaze3d.platform.InputConstants.Key; import com.mojang.blaze3d.platform.InputConstants.Type; +import net.minecraft.client.KeyMapping; +import net.minecraft.client.Minecraft; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.client.event.RegisterKeyMappingsEvent; +import net.minecraftforge.client.settings.IKeyConflictContext; +import net.minecraftforge.common.util.Lazy; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber; +import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus; -// Literally only doing this for key translations @OnlyIn(Dist.CLIENT) +@EventBusSubscriber(bus = Bus.MOD, modid = GInstrumentMod.MODID, value = Dist.CLIENT) public class KeyMappings { + public static final String CATEGORY = GInstrumentMod.MODID+".keymaps"; + + public static final IKeyConflictContext INSTRUMENT_KEY_CONFLICT_CONTEXT = new IKeyConflictContext() { + + @SuppressWarnings("resource") + @Override + public boolean isActive() { + return Minecraft.getInstance().screen instanceof AbstractInstrumentScreen; + } + + @Override + public boolean conflicts(IKeyConflictContext other) { + return this == other; + } + + }; + + public static final Lazy PITCH_UP_MODIFIER = Lazy.of( + () -> new KeyMapping(CATEGORY+".pitch_up_modifier", + INSTRUMENT_KEY_CONFLICT_CONTEXT, + InputConstants.Type.KEYSYM, + GLFW.GLFW_KEY_RIGHT_SHIFT + , CATEGORY) + ); + public static final Lazy PITCH_DOWN_MODIFIER = Lazy.of( + () -> new KeyMapping(CATEGORY+".pitch_down_modifier", + INSTRUMENT_KEY_CONFLICT_CONTEXT, + InputConstants.Type.KEYSYM, + GLFW.GLFW_KEY_LEFT_SHIFT + , CATEGORY) + ); + + + @SubscribeEvent + public static void registerKeybinds(final RegisterKeyMappingsEvent event) { + event.register(PITCH_UP_MODIFIER.get()); + event.register(PITCH_DOWN_MODIFIER.get()); + } + + + /* --------------- Builtin Keys --------------- */ + public static final Key[][] GRID_INSTRUMENT_MAPPINGS = createInstrumentMaps(new int[][] { {81, 87, 69, 82, 84, 89, 85, 73}, {65, 83, 68, 70, 71, 72, 74, 75}, diff --git a/src/main/resources/assets/genshinstrument/lang/en_us.json b/src/main/resources/assets/genshinstrument/lang/en_us.json index 6f65f596..1b5d85d7 100644 --- a/src/main/resources/assets/genshinstrument/lang/en_us.json +++ b/src/main/resources/assets/genshinstrument/lang/en_us.json @@ -1,4 +1,9 @@ { + "genshinstrument.keymaps": "Instruments GUI", + "genshinstrument.keymaps.pitch_down_modifier": "Pitch Instrument Down", + "genshinstrument.keymaps.pitch_up_modifier": "Pitch Instrument Up", + + "genshinstrument.itemGroup.instruments": "Instruments", "item.genshinstrument.windsong_lyre": "Windsong Lyre", diff --git a/src/main/resources/assets/genshinstrument/lang/he_il.json b/src/main/resources/assets/genshinstrument/lang/he_il.json index 36d928ee..0e55da30 100644 --- a/src/main/resources/assets/genshinstrument/lang/he_il.json +++ b/src/main/resources/assets/genshinstrument/lang/he_il.json @@ -1,4 +1,9 @@ { + "genshinstrument.keymaps": "כלי נגינה", + "genshinstrument.keymaps.pitch_down_modifier": "המנך גובה צליל", + "genshinstrument.keymaps.pitch_up_modifier": "הגבהה גובה צליל", + + "genshinstrument.itemGroup.instruments": "כלי נגינה", "item.genshinstrument.windsong_lyre": "נבל הרוחות", diff --git a/src/main/resources/assets/genshinstrument/lang/ru_ru.json b/src/main/resources/assets/genshinstrument/lang/ru_ru.json index 6c67276c..b17778ec 100644 --- a/src/main/resources/assets/genshinstrument/lang/ru_ru.json +++ b/src/main/resources/assets/genshinstrument/lang/ru_ru.json @@ -1,4 +1,9 @@ { + "genshinstrument.keymaps": "инструменты", + "genshinstrument.keymaps.pitch_down_modifier": "Уменьшение высоты инструмента", + "genshinstrument.keymaps.pitch_up_modifier": "Повышение высоты инструмента", + + "genshinstrument.itemGroup.instruments": "инструменты", "item.genshinstrument.windsong_lyre": "Лира ветров", From 28b4dd394048e39f290484c1cfad99565033a734 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Mon, 7 Aug 2023 15:49:49 +0300 Subject: [PATCH 2/4] Re-init pitch on open options and key release --- .../partial/AbstractInstrumentScreen.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java index e767966b..a66db154 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java @@ -251,11 +251,13 @@ public boolean keyReleased(int pKeyCode, int pScanCode, int pModifiers) { private boolean pitchChanged; protected boolean checkPitchInstrumentUp(int pKeyCode, int pScanCode) { if (!pitchChanged && KeyMappings.PITCH_UP_MODIFIER.get().matches(pKeyCode, pScanCode)) { - pitchInstrumentUp(true); + setPitch(getPitch() + 1); + pitchChanged = true; return true; } if (!pitchChanged && KeyMappings.PITCH_DOWN_MODIFIER.get().matches(pKeyCode, pScanCode)) { - pitchInstrumentDown(true); + setPitch(getPitch() - 1); + pitchChanged = true; return true; } @@ -263,26 +265,19 @@ protected boolean checkPitchInstrumentUp(int pKeyCode, int pScanCode) { } protected boolean checkPitchInstrumentDown(int pKeyCode, int pScanCode) { if (pitchChanged && KeyMappings.PITCH_UP_MODIFIER.get().matches(pKeyCode, pScanCode)) { - pitchInstrumentDown(false); + initPitch(this::setPitch); + pitchChanged = false; return true; } if (pitchChanged && KeyMappings.PITCH_DOWN_MODIFIER.get().matches(pKeyCode, pScanCode)) { - pitchInstrumentUp(false); + initPitch(this::setPitch); + pitchChanged = false; return true; } return false; } - private void pitchInstrumentUp(final boolean pressed) { - setPitch(getPitch() + 1); - pitchChanged = pressed; - } - private void pitchInstrumentDown(final boolean pressed) { - setPitch(getPitch() - 1); - pitchChanged = pressed; - } - @Override public boolean mouseReleased(double pMouseX, double pMouseY, int pButton) { @@ -314,6 +309,8 @@ public void onOptionsOpen() { setFocused(null); minecraft.pushGuiLayer(optionsScreen); + initPitch(this::setPitch); + isOptionsScreenActive = true; } public void onOptionsClose() { From 4e7af1fa09fd3d383052068c68f7d50180dd5559 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Mon, 7 Aug 2023 15:53:09 +0300 Subject: [PATCH 3/4] Rename KeyMappings to InstrumentKeyMappings --- .../client/config/enumType/label/DrumNoteLabel.java | 2 +- .../client/config/enumType/label/NoteGridLabel.java | 4 ++-- .../gui/screens/instrument/drum/DrumButtonType.java | 6 +++--- .../instrument/partial/AbstractInstrumentScreen.java | 10 +++++----- .../partial/notegrid/AbstractGridInstrumentScreen.java | 4 ++-- .../{KeyMappings.java => InstrumentKeyMappings.java} | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) rename src/main/java/com/cstav/genshinstrument/client/keyMaps/{KeyMappings.java => InstrumentKeyMappings.java} (99%) 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 08d45236..1d409059 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 @@ -4,7 +4,7 @@ import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteButton; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.INoteLabel; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteLabelSupplier; -import com.cstav.genshinstrument.client.keyMaps.KeyMappings.DrumKeys; +import com.cstav.genshinstrument.client.keyMaps.InstrumentKeyMappings.DrumKeys; import net.minecraft.network.chat.Component; import net.minecraftforge.api.distmarker.Dist; 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 8aaf74d4..ad15ceb7 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 @@ -5,7 +5,7 @@ import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.NoteLabelSupplier; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.notegrid.AbstractGridInstrumentScreen; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.notegrid.NoteGridButton; -import com.cstav.genshinstrument.client.keyMaps.KeyMappings; +import com.cstav.genshinstrument.client.keyMaps.InstrumentKeyMappings; import com.cstav.genshinstrument.util.LabelUtil; import net.minecraft.network.chat.Component; @@ -17,7 +17,7 @@ */ public enum NoteGridLabel implements INoteLabel { KEYBOARD_LAYOUT((note) -> INoteLabel.upperComponent( - KeyMappings.GRID_INSTRUMENT_MAPPINGS[ng(note).column][ng(note).row].getDisplayName() + InstrumentKeyMappings.GRID_INSTRUMENT_MAPPINGS[ng(note).column][ng(note).row].getDisplayName() )), NOTE_NAME((note) -> Component.literal( LabelUtil.getCutNoteName(ng(note)) diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/drum/DrumButtonType.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/drum/DrumButtonType.java index efb39332..0615c81b 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/drum/DrumButtonType.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/drum/DrumButtonType.java @@ -1,8 +1,8 @@ package com.cstav.genshinstrument.client.gui.screens.instrument.drum; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.label.INoteLabel; -import com.cstav.genshinstrument.client.keyMaps.KeyMappings; -import com.cstav.genshinstrument.client.keyMaps.KeyMappings.DrumKeys; +import com.cstav.genshinstrument.client.keyMaps.InstrumentKeyMappings; +import com.cstav.genshinstrument.client.keyMaps.InstrumentKeyMappings.DrumKeys; import com.cstav.genshinstrument.sound.ModSounds; import com.cstav.genshinstrument.sound.NoteSound; @@ -35,7 +35,7 @@ public String getTransKey() { // Seperated for server compatibility @OnlyIn(Dist.CLIENT) public DrumKeys getKeys() { - return (this == DON) ? KeyMappings.DON : KeyMappings.KA; + return (this == DON) ? InstrumentKeyMappings.DON : InstrumentKeyMappings.KA; } } \ No newline at end of file diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java index a66db154..7f8f4b3e 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java @@ -11,7 +11,7 @@ import com.cstav.genshinstrument.client.gui.screens.instrument.GenshinConsentScreen; import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteButton; import com.cstav.genshinstrument.client.gui.screens.options.instrument.AbstractInstrumentOptionsScreen; -import com.cstav.genshinstrument.client.keyMaps.KeyMappings; +import com.cstav.genshinstrument.client.keyMaps.InstrumentKeyMappings; import com.cstav.genshinstrument.networking.ModPacketHandler; import com.cstav.genshinstrument.networking.buttonidentifier.NoteButtonIdentifier; import com.cstav.genshinstrument.networking.packet.instrument.CloseInstrumentPacket; @@ -250,12 +250,12 @@ public boolean keyReleased(int pKeyCode, int pScanCode, int pModifiers) { private boolean pitchChanged; protected boolean checkPitchInstrumentUp(int pKeyCode, int pScanCode) { - if (!pitchChanged && KeyMappings.PITCH_UP_MODIFIER.get().matches(pKeyCode, pScanCode)) { + if (!pitchChanged && InstrumentKeyMappings.PITCH_UP_MODIFIER.get().matches(pKeyCode, pScanCode)) { setPitch(getPitch() + 1); pitchChanged = true; return true; } - if (!pitchChanged && KeyMappings.PITCH_DOWN_MODIFIER.get().matches(pKeyCode, pScanCode)) { + if (!pitchChanged && InstrumentKeyMappings.PITCH_DOWN_MODIFIER.get().matches(pKeyCode, pScanCode)) { setPitch(getPitch() - 1); pitchChanged = true; return true; @@ -264,12 +264,12 @@ protected boolean checkPitchInstrumentUp(int pKeyCode, int pScanCode) { return false; } protected boolean checkPitchInstrumentDown(int pKeyCode, int pScanCode) { - if (pitchChanged && KeyMappings.PITCH_UP_MODIFIER.get().matches(pKeyCode, pScanCode)) { + if (pitchChanged && InstrumentKeyMappings.PITCH_UP_MODIFIER.get().matches(pKeyCode, pScanCode)) { initPitch(this::setPitch); pitchChanged = false; return true; } - if (pitchChanged && KeyMappings.PITCH_DOWN_MODIFIER.get().matches(pKeyCode, pScanCode)) { + if (pitchChanged && InstrumentKeyMappings.PITCH_DOWN_MODIFIER.get().matches(pKeyCode, pScanCode)) { initPitch(this::setPitch); pitchChanged = false; return true; diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/notegrid/AbstractGridInstrumentScreen.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/notegrid/AbstractGridInstrumentScreen.java index a6f56034..1468e078 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/notegrid/AbstractGridInstrumentScreen.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/notegrid/AbstractGridInstrumentScreen.java @@ -10,7 +10,7 @@ import com.cstav.genshinstrument.client.gui.screens.instrument.partial.note.NoteButton; import com.cstav.genshinstrument.client.gui.screens.options.instrument.AbstractInstrumentOptionsScreen; import com.cstav.genshinstrument.client.gui.screens.options.instrument.GridInstrumentOptionsScreen; -import com.cstav.genshinstrument.client.keyMaps.KeyMappings; +import com.cstav.genshinstrument.client.keyMaps.InstrumentKeyMappings; import com.cstav.genshinstrument.networking.buttonidentifier.NoteButtonIdentifier; import com.cstav.genshinstrument.networking.buttonidentifier.NoteGridButtonIdentifier; import com.cstav.genshinstrument.sound.NoteSound; @@ -118,7 +118,7 @@ public NoteGrid initNoteGrid() { public final NoteGrid noteGrid = initNoteGrid(); - private final Map noteMap = noteGrid.genKeyboardMap(KeyMappings.GRID_INSTRUMENT_MAPPINGS); + private final Map noteMap = noteGrid.genKeyboardMap(InstrumentKeyMappings.GRID_INSTRUMENT_MAPPINGS); @Override public Map noteMap() { return noteMap; diff --git a/src/main/java/com/cstav/genshinstrument/client/keyMaps/KeyMappings.java b/src/main/java/com/cstav/genshinstrument/client/keyMaps/InstrumentKeyMappings.java similarity index 99% rename from src/main/java/com/cstav/genshinstrument/client/keyMaps/KeyMappings.java rename to src/main/java/com/cstav/genshinstrument/client/keyMaps/InstrumentKeyMappings.java index 99d982eb..be926f85 100644 --- a/src/main/java/com/cstav/genshinstrument/client/keyMaps/KeyMappings.java +++ b/src/main/java/com/cstav/genshinstrument/client/keyMaps/InstrumentKeyMappings.java @@ -22,7 +22,7 @@ @OnlyIn(Dist.CLIENT) @EventBusSubscriber(bus = Bus.MOD, modid = GInstrumentMod.MODID, value = Dist.CLIENT) -public class KeyMappings { +public class InstrumentKeyMappings { public static final String CATEGORY = GInstrumentMod.MODID+".keymaps"; public static final IKeyConflictContext INSTRUMENT_KEY_CONFLICT_CONTEXT = new IKeyConflictContext() { From fc3e34245837613265fbdb54f1305015b9391843 Mon Sep 17 00:00:00 2001 From: StavWasPlayZ Date: Mon, 7 Aug 2023 16:03:35 +0300 Subject: [PATCH 4/4] Rename "pitch" to "transpose" --- .../partial/AbstractInstrumentScreen.java | 16 ++++++++-------- .../client/keyMaps/InstrumentKeyMappings.java | 12 ++++++------ .../assets/genshinstrument/lang/en_us.json | 4 ++-- .../assets/genshinstrument/lang/he_il.json | 4 ++-- .../assets/genshinstrument/lang/ru_ru.json | 4 ++-- 5 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java index 7f8f4b3e..f9dc5ca5 100644 --- a/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java +++ b/src/main/java/com/cstav/genshinstrument/client/gui/screens/instrument/partial/AbstractInstrumentScreen.java @@ -222,7 +222,7 @@ protected AbstractWidget initOptionsButton(final int vertOffset) { @Override public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) { - if (checkPitchInstrumentUp(pKeyCode, pScanCode)) + if (checkPitchTransposeUp(pKeyCode, pScanCode)) return true; final NoteButton note = getNoteByKey(pKeyCode); @@ -236,7 +236,7 @@ public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) { } @Override public boolean keyReleased(int pKeyCode, int pScanCode, int pModifiers) { - if (checkPitchInstrumentDown(pKeyCode, pScanCode)) + if (checkTransposeDown(pKeyCode, pScanCode)) return true; unlockFocused(); @@ -249,13 +249,13 @@ public boolean keyReleased(int pKeyCode, int pScanCode, int pModifiers) { } private boolean pitchChanged; - protected boolean checkPitchInstrumentUp(int pKeyCode, int pScanCode) { - if (!pitchChanged && InstrumentKeyMappings.PITCH_UP_MODIFIER.get().matches(pKeyCode, pScanCode)) { + protected boolean checkPitchTransposeUp(int pKeyCode, int pScanCode) { + if (!pitchChanged && InstrumentKeyMappings.TRANSPOSE_UP_MODIFIER.get().matches(pKeyCode, pScanCode)) { setPitch(getPitch() + 1); pitchChanged = true; return true; } - if (!pitchChanged && InstrumentKeyMappings.PITCH_DOWN_MODIFIER.get().matches(pKeyCode, pScanCode)) { + if (!pitchChanged && InstrumentKeyMappings.TRANSPOSE_DOWN_MODIFIER.get().matches(pKeyCode, pScanCode)) { setPitch(getPitch() - 1); pitchChanged = true; return true; @@ -263,13 +263,13 @@ protected boolean checkPitchInstrumentUp(int pKeyCode, int pScanCode) { return false; } - protected boolean checkPitchInstrumentDown(int pKeyCode, int pScanCode) { - if (pitchChanged && InstrumentKeyMappings.PITCH_UP_MODIFIER.get().matches(pKeyCode, pScanCode)) { + protected boolean checkTransposeDown(int pKeyCode, int pScanCode) { + if (pitchChanged && InstrumentKeyMappings.TRANSPOSE_UP_MODIFIER.get().matches(pKeyCode, pScanCode)) { initPitch(this::setPitch); pitchChanged = false; return true; } - if (pitchChanged && InstrumentKeyMappings.PITCH_DOWN_MODIFIER.get().matches(pKeyCode, pScanCode)) { + if (pitchChanged && InstrumentKeyMappings.TRANSPOSE_DOWN_MODIFIER.get().matches(pKeyCode, pScanCode)) { initPitch(this::setPitch); pitchChanged = false; return true; diff --git a/src/main/java/com/cstav/genshinstrument/client/keyMaps/InstrumentKeyMappings.java b/src/main/java/com/cstav/genshinstrument/client/keyMaps/InstrumentKeyMappings.java index be926f85..c6e075fe 100644 --- a/src/main/java/com/cstav/genshinstrument/client/keyMaps/InstrumentKeyMappings.java +++ b/src/main/java/com/cstav/genshinstrument/client/keyMaps/InstrumentKeyMappings.java @@ -41,15 +41,15 @@ public boolean conflicts(IKeyConflictContext other) { }; - public static final Lazy PITCH_UP_MODIFIER = Lazy.of( - () -> new KeyMapping(CATEGORY+".pitch_up_modifier", + public static final Lazy TRANSPOSE_UP_MODIFIER = Lazy.of( + () -> new KeyMapping(CATEGORY+".transpose_up_modifier", INSTRUMENT_KEY_CONFLICT_CONTEXT, InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_RIGHT_SHIFT , CATEGORY) ); - public static final Lazy PITCH_DOWN_MODIFIER = Lazy.of( - () -> new KeyMapping(CATEGORY+".pitch_down_modifier", + public static final Lazy TRANSPOSE_DOWN_MODIFIER = Lazy.of( + () -> new KeyMapping(CATEGORY+".transpose_down_modifier", INSTRUMENT_KEY_CONFLICT_CONTEXT, InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_LEFT_SHIFT @@ -59,8 +59,8 @@ public boolean conflicts(IKeyConflictContext other) { @SubscribeEvent public static void registerKeybinds(final RegisterKeyMappingsEvent event) { - event.register(PITCH_UP_MODIFIER.get()); - event.register(PITCH_DOWN_MODIFIER.get()); + event.register(TRANSPOSE_UP_MODIFIER.get()); + event.register(TRANSPOSE_DOWN_MODIFIER.get()); } diff --git a/src/main/resources/assets/genshinstrument/lang/en_us.json b/src/main/resources/assets/genshinstrument/lang/en_us.json index 1b5d85d7..808a228d 100644 --- a/src/main/resources/assets/genshinstrument/lang/en_us.json +++ b/src/main/resources/assets/genshinstrument/lang/en_us.json @@ -1,7 +1,7 @@ { "genshinstrument.keymaps": "Instruments GUI", - "genshinstrument.keymaps.pitch_down_modifier": "Pitch Instrument Down", - "genshinstrument.keymaps.pitch_up_modifier": "Pitch Instrument Up", + "genshinstrument.keymaps.transpose_up_modifier": "Transpose Instrument Up", + "genshinstrument.keymaps.transpose_down_modifier": "Transpose Instrument Down", "genshinstrument.itemGroup.instruments": "Instruments", diff --git a/src/main/resources/assets/genshinstrument/lang/he_il.json b/src/main/resources/assets/genshinstrument/lang/he_il.json index 0e55da30..9326ce7a 100644 --- a/src/main/resources/assets/genshinstrument/lang/he_il.json +++ b/src/main/resources/assets/genshinstrument/lang/he_il.json @@ -1,7 +1,7 @@ { "genshinstrument.keymaps": "כלי נגינה", - "genshinstrument.keymaps.pitch_down_modifier": "המנך גובה צליל", - "genshinstrument.keymaps.pitch_up_modifier": "הגבהה גובה צליל", + "genshinstrument.keymaps.transpose_down_modifier": "המנך גובה צליל", + "genshinstrument.keymaps.transpose_up_modifier": "הגבהה גובה צליל", "genshinstrument.itemGroup.instruments": "כלי נגינה", diff --git a/src/main/resources/assets/genshinstrument/lang/ru_ru.json b/src/main/resources/assets/genshinstrument/lang/ru_ru.json index b17778ec..7c81da83 100644 --- a/src/main/resources/assets/genshinstrument/lang/ru_ru.json +++ b/src/main/resources/assets/genshinstrument/lang/ru_ru.json @@ -1,7 +1,7 @@ { "genshinstrument.keymaps": "инструменты", - "genshinstrument.keymaps.pitch_down_modifier": "Уменьшение высоты инструмента", - "genshinstrument.keymaps.pitch_up_modifier": "Повышение высоты инструмента", + "genshinstrument.keymaps.transpose_up_modifier": "Повышение высоты инструмента", + "genshinstrument.keymaps.transpose_down_modifier": "Уменьшение высоты инструмента", "genshinstrument.itemGroup.instruments": "инструменты",