Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding config for inverse push order #156

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ neoVersion=21.3.3-beta
neoLoaderVersion=[4,)

fabricMcVersion=1.21.3
fabricLoaderVersion=0.16.7
fabricLoaderVersion=0.16.8
fabricApiVersion=0.106.1+1.21.3
fabricModMenuVersion=12.0.0-beta.1
3 changes: 3 additions & 0 deletions src/main/java/yalter/mousetweaks/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class Config {
public WheelScrollDirection wheelScrollDirection = WheelScrollDirection.NORMAL;
public ScrollItemScaling scrollItemScaling = ScrollItemScaling.PROPORTIONAL;
public static boolean debug = false;
public boolean inversePushOrder = false;

Config(String fileName) {
this.fileName = fileName;
Expand Down Expand Up @@ -51,6 +52,7 @@ public void read() {
0));
scrollItemScaling = ScrollItemScaling.fromId(parseIntOrDefault(properties.getProperty(Constants.CONFIG_SCROLL_ITEM_SCALING), 0));
debug = parseIntOrDefault(properties.getProperty(Constants.CONFIG_DEBUG), 0) != 0;
inversePushOrder = parseIntOrDefault(properties.getProperty(Constants.CONFIG_INVERSE_PUSH_ORDER), 0) != 0;
}

private static int parseIntOrDefault(String s, int defaultValue) {
Expand Down Expand Up @@ -81,6 +83,7 @@ public void save() {
String.valueOf(wheelScrollDirection.ordinal()));
writeString(configWriter, Constants.CONFIG_SCROLL_ITEM_SCALING, String.valueOf(scrollItemScaling.ordinal()));
writeBoolean(configWriter, Constants.CONFIG_DEBUG, debug);
writeBoolean(configWriter, Constants.CONFIG_INVERSE_PUSH_ORDER, inversePushOrder);

configWriter.close();

Expand Down
3 changes: 3 additions & 0 deletions src/main/java/yalter/mousetweaks/ConfigScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ protected void init() {
this.addRenderableWidget(CycleButton.onOffBuilder(Config.debug)
.create(this.width / 2 - 155, this.height / 6 + 24 * 5, 310, 20,
Component.literal("Debug Mode"), (button, value) -> Config.debug = value));
this.addRenderableWidget(CycleButton.onOffBuilder(Main.config.inversePushOrder)
.create(this.width / 2 - 155, this.height / 6 + 24 * 6, 310, 20,
Component.literal("Inverse Push Order"), (cycleButton, value) -> Main.config.inversePushOrder = value));

this.addRenderableWidget(Button.builder(CommonComponents.GUI_DONE, button -> this.onClose())
.bounds(this.width / 2 - 100, this.height - 27, 200, 20).build());
Expand Down
1 change: 1 addition & 0 deletions src/main/java/yalter/mousetweaks/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public class Constants {
static final String CONFIG_WHEEL_SCROLL_DIRECTION = "WheelScrollDirection";
static final String CONFIG_DEBUG = "Debug";
static final String CONFIG_SCROLL_ITEM_SCALING = "ScrollItemScaling";
static final String CONFIG_INVERSE_PUSH_ORDER = "InversePushOrder";
}
6 changes: 4 additions & 2 deletions src/main/java/yalter/mousetweaks/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,11 @@ private static List<Slot> findPushSlots(List<Slot> slots, Slot selectedSlot, int
// Applicable empty slots, they can be used once applicable non-empty slots run out.
List<Slot> goodEmptySlots = new ArrayList<>();

for (int i = 0; i != slots.size() && itemCount > 0; i++) {
for (int i = config.inversePushOrder ? slots.size() - 1 : 0;
config.inversePushOrder ? i >= 0 : i < slots.size() && itemCount > 0;
i += config.inversePushOrder ? -1 : 1) {
Slot slot = slots.get(i);

// Skip ignored slots.
if (handler.isIgnored(slot))
continue;
Expand Down