Skip to content

Commit

Permalink
feat: Add alternative button styles
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Sep 17, 2023
1 parent 9763f7b commit 16a7618
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,54 +55,54 @@ public class CraftingTweaksButtonStyles {

public static final ButtonStyle SMALL_WIDTH = new ButtonStyle()
.withTweak(TweakType.Rotate, new ButtonProperties(10, 16)
.withState(ButtonState.NORMAL, 16, 78)
.withState(ButtonState.HOVER, 26, 78)
.withState(ButtonState.DISABLED, 36, 78))
.withState(ButtonState.NORMAL, 10, 78)
.withState(ButtonState.HOVER, 10, 94)
.withState(ButtonState.DISABLED, 10, 110))
.withTweak(TweakType.Clear, new ButtonProperties(10, 16)
.withState(ButtonState.NORMAL, 16, 94)
.withState(ButtonState.HOVER, 26, 94)
.withState(ButtonState.DISABLED, 36, 94))
.withState(ButtonState.NORMAL, 20, 78)
.withState(ButtonState.HOVER, 20, 94)
.withState(ButtonState.DISABLED, 30, 110))
.withTweak(TweakType.Balance, new ButtonProperties(10, 16)
.withState(ButtonState.NORMAL, 16, 110)
.withState(ButtonState.HOVER, 26, 110)
.withState(ButtonState.DISABLED, 36, 110))
.withState(ButtonState.NORMAL, 30, 78)
.withState(ButtonState.HOVER, 30, 94)
.withState(ButtonState.DISABLED, 30, 110))
.withTweak(TweakType.RotateCounterClockwise, new ButtonProperties(10, 16)
.withState(ButtonState.NORMAL, 16, 126)
.withState(ButtonState.HOVER, 26, 126)
.withState(ButtonState.DISABLED, 36, 126))
.withState(ButtonState.NORMAL, 40, 78)
.withState(ButtonState.HOVER, 40, 94)
.withState(ButtonState.DISABLED, 40, 110))
.withTweak(TweakType.ForceClear, new ButtonProperties(10, 16)
.withState(ButtonState.NORMAL, 16, 142)
.withState(ButtonState.HOVER, 26, 142)
.withState(ButtonState.DISABLED, 36, 142))
.withState(ButtonState.NORMAL, 50, 78)
.withState(ButtonState.HOVER, 50, 94)
.withState(ButtonState.DISABLED, 50, 110))
.withTweak(TweakType.Spread, new ButtonProperties(10, 16)
.withState(ButtonState.NORMAL, 16, 158)
.withState(ButtonState.HOVER, 26, 158)
.withState(ButtonState.DISABLED, 36, 158));
.withState(ButtonState.NORMAL, 60, 78)
.withState(ButtonState.HOVER, 60, 94)
.withState(ButtonState.DISABLED, 60, 158110));

public static final ButtonStyle SMALL = new ButtonStyle()
.withTweak(TweakType.Rotate, new ButtonProperties(10, 10)
.withState(ButtonState.NORMAL, 16, 126)
.withState(ButtonState.HOVER, 26, 126)
.withState(ButtonState.DISABLED, 36, 126))
.withState(ButtonState.NORMAL, 10, 126)
.withState(ButtonState.HOVER, 10, 136)
.withState(ButtonState.DISABLED, 10, 146))
.withTweak(TweakType.Clear, new ButtonProperties(10, 10)
.withState(ButtonState.NORMAL, 16, 136)
.withState(ButtonState.HOVER, 26, 136)
.withState(ButtonState.DISABLED, 36, 136))
.withState(ButtonState.NORMAL, 20, 126)
.withState(ButtonState.HOVER, 20, 136)
.withState(ButtonState.DISABLED, 20, 146))
.withTweak(TweakType.Balance, new ButtonProperties(10, 10)
.withState(ButtonState.NORMAL, 16, 146)
.withState(ButtonState.HOVER, 26, 146)
.withState(ButtonState.DISABLED, 36, 146))
.withState(ButtonState.NORMAL, 30, 126)
.withState(ButtonState.HOVER, 30, 136)
.withState(ButtonState.DISABLED, 30, 146))
.withTweak(TweakType.RotateCounterClockwise, new ButtonProperties(10, 10)
.withState(ButtonState.NORMAL, 16, 156)
.withState(ButtonState.HOVER, 26, 156)
.withState(ButtonState.DISABLED, 36, 156))
.withState(ButtonState.NORMAL, 40, 126)
.withState(ButtonState.HOVER, 40, 136)
.withState(ButtonState.DISABLED, 40, 146))
.withTweak(TweakType.ForceClear, new ButtonProperties(10, 10)
.withState(ButtonState.NORMAL, 16, 166)
.withState(ButtonState.HOVER, 26, 166)
.withState(ButtonState.DISABLED, 36, 166))
.withState(ButtonState.NORMAL, 50, 126)
.withState(ButtonState.HOVER, 50, 136)
.withState(ButtonState.DISABLED, 50, 146))
.withTweak(TweakType.Spread, new ButtonProperties(10, 10)
.withState(ButtonState.NORMAL, 16, 176)
.withState(ButtonState.HOVER, 26, 176)
.withState(ButtonState.DISABLED, 36, 176));
.withState(ButtonState.NORMAL, 60, 126)
.withState(ButtonState.HOVER, 60, 136)
.withState(ButtonState.DISABLED, 60, 146));

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void setButtonY(Integer buttonY) {
private Integer buttonOffsetX;
private Integer buttonOffsetY;
private String alignToGrid = "left";
private String buttonStyle = "default";
private boolean hideButtons;
private boolean phantomItems;
private TweakData tweakRotate = new TweakData();
Expand Down Expand Up @@ -146,6 +147,14 @@ public void setAlignToGrid(String alignToGrid) {
this.alignToGrid = alignToGrid;
}

public String getButtonStyle() {
return buttonStyle;
}

public void setButtonStyle(String buttonStyle) {
this.buttonStyle = buttonStyle;
}

public boolean isHideButtons() {
return hideButtons;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ public int getGridStartSlot(Player player, AbstractContainerMenu menu) {
}
grid.setButtonAlignment(alignToGrid);

ButtonStyle buttonStyle = CraftingTweaksButtonStyles.DEFAULT;
String buttonStyleName = data.getButtonStyle();
switch (buttonStyleName.toLowerCase()) {
case "default" -> buttonStyle = CraftingTweaksButtonStyles.DEFAULT;
case "small_width" -> buttonStyle = CraftingTweaksButtonStyles.SMALL_WIDTH;
case "small_height" -> buttonStyle = CraftingTweaksButtonStyles.SMALL_HEIGHT;
case "small" -> buttonStyle = CraftingTweaksButtonStyles.SMALL;
}
grid.setButtonStyle(buttonStyle);

if (data.isHideButtons()) {
grid.hideAllTweakButtons();
}
Expand Down

0 comments on commit 16a7618

Please sign in to comment.