shift + click/ctrl to go to prev category

This commit is contained in:
radimous 2024-12-05 20:25:16 +01:00
parent 15ebedce84
commit ab5fbdfec2
2 changed files with 23 additions and 3 deletions

View file

@ -39,4 +39,8 @@ public enum ModifierCategory {
return values()[(this.ordinal() + 1) % values().length];
}
public ModifierCategory previous() {
return values()[(this.ordinal() + values().length - 1) % values().length];
}
}

View file

@ -235,12 +235,18 @@ public class GearModifierScreen extends AbstractElementScreen {
this.addElement(btnPlus);
}
private void cycleModifierCategories() {
private void nextModifierCategory() {
this.modifierCategory = modifierCategory.next();
updateModifierCategoryButtonLabel();
updateModifierList(true);
}
private void previousModifierCategory() {
this.modifierCategory = modifierCategory.previous();
updateModifierCategoryButtonLabel();
updateModifierList(true);
}
private void updateModifierCategoryButtonLabel() {
if (this.modifierCategoryLabel != null) {
this.removeElement(this.modifierCategoryLabel);
@ -255,7 +261,13 @@ public class GearModifierScreen extends AbstractElementScreen {
updateModifierCategoryButtonLabel();
NineSliceButtonElement<?> btnLegend =
new NineSliceButtonElement<>(Spatials.positionXY(this.getGuiSpatial().width() - 8 - 13, 35).size(14, 14),
ScreenTextures.BUTTON_EMPTY_TEXTURES, this::cycleModifierCategories).layout(this.translateWorldSpatial());
ScreenTextures.BUTTON_EMPTY_TEXTURES, () -> {
if (hasShiftDown()) {
previousModifierCategory();
} else {
nextModifierCategory();
}
}).layout(this.translateWorldSpatial());
this.addElement(btnLegend);
}
@ -308,7 +320,11 @@ public class GearModifierScreen extends AbstractElementScreen {
}
// ctrl to change modifier category (normal, greater, legendary)
if (keyCode == InputConstants.KEY_LCONTROL || keyCode == InputConstants.KEY_RCONTROL) {
cycleModifierCategories();
if (hasShiftDown()) {
previousModifierCategory();
} else {
nextModifierCategory();
}
}
return super.keyPressed(keyCode, scanCode, modifiers);
}