Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import static meteordevelopment.meteorclient.MeteorClient.mc;
import static meteordevelopment.meteorclient.utils.Utils.getWindowHeight;
import static meteordevelopment.meteorclient.utils.Utils.getWindowWidth;
import static org.lwjgl.glfw.GLFW.*;
import static com.mojang.blaze3d.platform.InputConstants.*;

public abstract class WidgetScreen extends Screen {
private static final GuiRenderer RENDERER = new GuiRenderer();
Expand Down Expand Up @@ -151,7 +151,7 @@ public boolean mouseReleased(@NonNull MouseButtonEvent click) {
mouseX *= s;
mouseY *= s;

if (debug && click.button() == GLFW_MOUSE_BUTTON_RIGHT)
if (debug && click.button() == MOUSE_BUTTON_RIGHT)
DEBUG_RENDERER.mouseReleased(root, new MouseButtonEvent(mouseX, mouseY, click.buttonInfo()), 0);

return root.mouseReleased(new MouseButtonEvent(mouseX, mouseY, click.buttonInfo()));
Expand Down Expand Up @@ -184,12 +184,12 @@ public boolean mouseScrolled(double mouseX, double mouseY, double horizontalAmou
public boolean keyReleased(@NonNull KeyEvent input) {
if (locked) return false;

if ((input.modifiers() == GLFW_MOD_CONTROL || input.modifiers() == GLFW_MOD_SUPER) && input.key() == GLFW_KEY_9) {
if ((input.modifiers() == MOD_CONTROL || input.modifiers() == MOD_SUPER) && input.key() == KEY_9) {
debug = !debug;
return true;
}

if ((input.key() == GLFW_KEY_ENTER || input.key() == GLFW_KEY_KP_ENTER) && enterAction != null) {
if ((input.key() == KEY_RETURN || input.key() == KEY_NUMPADENTER) && enterAction != null) {
enterAction.run();
return true;
}
Expand All @@ -205,7 +205,7 @@ public boolean keyPressed(@NonNull KeyEvent input) {
if (shouldReturn) return true;

// Select next text box if TAB was pressed
if (input.key() == GLFW_KEY_TAB) {
if (input.key() == KEY_TAB) {
AtomicReference<WTextBox> firstTextBox = new AtomicReference<>(null);
AtomicBoolean done = new AtomicBoolean(false);
AtomicBoolean foundFocused = new AtomicBoolean(false);
Expand Down Expand Up @@ -236,10 +236,10 @@ public boolean keyPressed(@NonNull KeyEvent input) {
return true;
}

boolean control = MacosUtil.IS_MACOS ? input.modifiers() == GLFW_MOD_SUPER : input.modifiers() == GLFW_MOD_CONTROL;
boolean control = MacosUtil.IS_MACOS ? input.modifiers() == MOD_SUPER : input.modifiers() == MOD_CONTROL;

return (control && input.key() == GLFW_KEY_C && toClipboard())
|| (control && input.key() == GLFW_KEY_V && fromClipboard());
return (control && input.key() == KEY_C && toClipboard())
|| (control && input.key() == KEY_V && fromClipboard());
}

public void keyRepeated(KeyEvent input) {
Expand Down Expand Up @@ -354,7 +354,7 @@ public void removed() {

// Restore mouse position to where it was when the screen was closed
if (parent != null) {
glfwSetCursorPos(mc.getWindow().handle(), restoreX, restoreY);
grabOrReleaseMouse(mc.getWindow(), CURSOR_NORMAL, restoreX, restoreY);
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.BundleContents;
import org.jspecify.annotations.NonNull;
import org.lwjgl.glfw.GLFW;
import com.mojang.blaze3d.platform.InputConstants;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -151,7 +151,7 @@ public boolean keyPressed(@NonNull KeyEvent input) {
return tooltips.openContent(stack);
}

if (input.key() == GLFW.GLFW_KEY_ESCAPE || mc.options.keyInventory.matches(input)) {
if (input.key() == InputConstants.KEY_ESCAPE || mc.options.keyInventory.matches(input)) {
onClose();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

import static meteordevelopment.meteorclient.utils.Utils.getWindowHeight;
import static meteordevelopment.meteorclient.utils.Utils.getWindowWidth;
import static org.lwjgl.glfw.GLFW.*;
import static com.mojang.blaze3d.platform.InputConstants.*;

public class ModulesScreen extends TabScreen {
private WCategoryController controller;
Expand Down Expand Up @@ -153,9 +153,9 @@ protected WWindow createSearch(WContainer c) {
public boolean keyPressed(@NonNull KeyEvent value) {
if (locked) return false;

boolean cntrl = MacosUtil.IS_MACOS ? value.modifiers() == GLFW_MOD_SUPER : value.modifiers() == GLFW_MOD_CONTROL;
boolean cntrl = MacosUtil.IS_MACOS ? value.modifiers() == MOD_SUPER : value.modifiers() == MOD_CONTROL;

if (cntrl && value.key() == GLFW_KEY_F) {
if (cntrl && value.key() == KEY_F) {
if (searchWindow != null) searchWindow.setExpanded(true);
if (searchTextBox != null) {
searchTextBox.setFocused(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import net.minecraft.util.Mth;

import static meteordevelopment.meteorclient.MeteorClient.mc;
import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_LEFT;
import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_RIGHT;
import static com.mojang.blaze3d.platform.InputConstants.MOUSE_BUTTON_LEFT;
import static com.mojang.blaze3d.platform.InputConstants.MOUSE_BUTTON_RIGHT;

public class WMeteorModule extends WPressable implements MeteorWidget {
private final Module module;
Expand Down Expand Up @@ -58,8 +58,8 @@ protected void onCalculateSize() {

@Override
protected void onPressed(int button) {
if (button == GLFW_MOUSE_BUTTON_LEFT) module.toggle();
else if (button == GLFW_MOUSE_BUTTON_RIGHT) mc.gui.setScreen(theme.moduleScreen(module));
if (button == MOUSE_BUTTON_LEFT) module.toggle();
else if (button == MOUSE_BUTTON_RIGHT) mc.gui.setScreen(theme.moduleScreen(module));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import net.minecraft.client.gui.screens.Screen;

import static meteordevelopment.meteorclient.MeteorClient.mc;
import static org.lwjgl.glfw.GLFW.glfwSetCursorPos;
import static com.mojang.blaze3d.platform.InputConstants.*;

public abstract class WTopBar extends WHorizontalList {
protected abstract Color getButtonColor(boolean pressed, boolean hovered);
Expand Down Expand Up @@ -57,7 +57,7 @@ protected void onPressed(int button) {
double mouseY = mc.mouseHandler.ypos();

tab.openScreen(theme);
glfwSetCursorPos(mc.getWindow().handle(), mouseX, mouseY);
grabOrReleaseMouse(mc.getWindow(), CURSOR_NORMAL, mouseX, mouseY);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import net.minecraft.client.input.MouseButtonEvent;
import net.minecraft.util.Mth;

import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_LEFT;
import static com.mojang.blaze3d.platform.InputConstants.MOUSE_BUTTON_LEFT;

public abstract class WSection extends WVerticalList {
public Runnable action;
Expand Down Expand Up @@ -124,7 +124,7 @@ public WHeader(String title) {

@Override
public boolean onMouseClicked(MouseButtonEvent click, boolean doubled) {
if (mouseOver && click.button() == GLFW_MOUSE_BUTTON_LEFT && !doubled) {
if (mouseOver && click.button() == MOUSE_BUTTON_LEFT && !doubled) {
onClick();
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import net.minecraft.client.input.MouseButtonEvent;
import net.minecraft.util.Mth;

import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_LEFT;
import static com.mojang.blaze3d.platform.InputConstants.MOUSE_BUTTON_LEFT;

public abstract class WView extends WVerticalList {
public double maxHeight = Double.MAX_VALUE;
Expand Down Expand Up @@ -74,7 +74,7 @@ protected void onCalculateWidgetPositions() {

@Override
public boolean onMouseClicked(MouseButtonEvent click, boolean doubled) {
if (handleMouseOver && click.button() == GLFW_MOUSE_BUTTON_LEFT && !doubled) {
if (handleMouseOver && click.button() == MOUSE_BUTTON_LEFT && !doubled) {
setFocused(true);
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import static meteordevelopment.meteorclient.utils.Utils.getWindowHeight;
import static meteordevelopment.meteorclient.utils.Utils.getWindowWidth;
import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_RIGHT;
import static com.mojang.blaze3d.platform.InputConstants.MOUSE_BUTTON_RIGHT;

public abstract class WWindow extends WVerticalList {
public double padding = 8;
Expand Down Expand Up @@ -191,7 +191,7 @@ protected void onCalculateSize() {
@Override
public boolean onMouseClicked(MouseButtonEvent click, boolean doubled) {
if (mouseOver && !doubled) {
if (click.button() == GLFW_MOUSE_BUTTON_RIGHT) setExpanded(!expanded);
if (click.button() == MOUSE_BUTTON_RIGHT) setExpanded(!expanded);
else {
dragging = true;
dragged = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import java.util.List;

import static meteordevelopment.meteorclient.MeteorClient.mc;
import static org.lwjgl.glfw.GLFW.*;
import static com.mojang.blaze3d.platform.InputConstants.*;

public abstract class WTextBox extends WWidget {
private static final Renderer DEFAULT_RENDERER = (renderer, x, y, text, color) -> renderer.text(text, x, y, color, false);
Expand Down Expand Up @@ -110,7 +110,7 @@ protected double maxTextWidth() {
@Override
public boolean onMouseClicked(MouseButtonEvent click, boolean doubled) {
if (mouseOver) {
if (click.button() == GLFW_MOUSE_BUTTON_RIGHT) {
if (click.button() == MOUSE_BUTTON_RIGHT) {
if (!text.isEmpty()) {
text = "";
cursor = 0;
Expand All @@ -119,7 +119,7 @@ public boolean onMouseClicked(MouseButtonEvent click, boolean doubled) {

runAction();
}
} else if (click.button() == GLFW_MOUSE_BUTTON_LEFT) {
} else if (click.button() == MOUSE_BUTTON_LEFT) {
selecting = true;

double overflowWidth = getOverflowWidthForRender();
Expand Down Expand Up @@ -240,32 +240,32 @@ public boolean onMouseReleased(MouseButtonEvent click) {
public boolean onKeyPressed(KeyEvent input) {
if (!focused) return false;

boolean control = MacosUtil.IS_MACOS ? input.modifiers() == GLFW_MOD_SUPER : input.modifiers() == GLFW_MOD_CONTROL;
boolean control = MacosUtil.IS_MACOS ? input.modifiers() == MOD_SUPER : input.modifiers() == MOD_CONTROL;

if (control && input.key() == GLFW_KEY_C) {
if (control && input.key() == KEY_C) {
if (cursor != selectionStart || cursor != selectionEnd) {
mc.keyboardHandler.setClipboard(text.substring(selectionStart, selectionEnd));
}
return true;
} else if (control && input.key() == GLFW_KEY_X) {
} else if (control && input.key() == KEY_X) {
if (cursor != selectionStart || cursor != selectionEnd) {
mc.keyboardHandler.setClipboard(text.substring(selectionStart, selectionEnd));
clearSelection();
}

return true;
} else if (control && input.key() == GLFW_KEY_A) {
} else if (control && input.key() == KEY_A) {
cursor = text.length();
selectionStart = 0;
selectionEnd = cursor;
} else if (input.modifiers() == ((MacosUtil.IS_MACOS ? GLFW_MOD_SUPER : GLFW_MOD_CONTROL) | GLFW_MOD_SHIFT) && input.key() == GLFW_KEY_A) {
} else if (input.modifiers() == ((MacosUtil.IS_MACOS ? MOD_SUPER : MOD_CONTROL) | MOD_SHIFT) && input.key() == KEY_A) {
resetSelection();
} else if (input.key() == GLFW_KEY_ENTER || input.key() == GLFW_KEY_KP_ENTER) {
} else if (input.key() == KEY_RETURN || input.key() == KEY_NUMPADENTER) {
setFocused(false);

if (actionOnUnfocused != null) actionOnUnfocused.run();
return true;
} else if (input.key() == GLFW_KEY_TAB && completionsW != null) {
} else if (input.key() == KEY_TAB && completionsW != null) {
String completion = ((ICompletionItem) completionsW.cells.get(getSelectedCompletion()).widget()).getCompletion();

StringBuilder sb = new StringBuilder(text.length() + completion.length() + 1);
Expand Down Expand Up @@ -299,12 +299,12 @@ public boolean onKeyPressed(KeyEvent input) {
public boolean onKeyRepeated(KeyEvent input) {
if (!focused) return false;

boolean control = MacosUtil.IS_MACOS ? input.modifiers() == GLFW_MOD_SUPER : input.modifiers() == GLFW_MOD_CONTROL;
boolean shift = input.modifiers() == GLFW_MOD_SHIFT;
boolean controlShift = input.modifiers() == ((SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_ALT : MacosUtil.IS_MACOS ? GLFW_MOD_SUPER : GLFW_MOD_CONTROL) | GLFW_MOD_SHIFT);
boolean altShift = input.modifiers() == ((SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_CONTROL : GLFW_MOD_ALT) | GLFW_MOD_SHIFT);
boolean control = MacosUtil.IS_MACOS ? input.modifiers() == MOD_SUPER : input.modifiers() == MOD_CONTROL;
boolean shift = input.modifiers() == MOD_SHIFT;
boolean controlShift = input.modifiers() == ((SystemUtils.IS_OS_WINDOWS ? MOD_ALT : MacosUtil.IS_MACOS ? MOD_SUPER : MOD_CONTROL) | MOD_SHIFT);
boolean altShift = input.modifiers() == ((SystemUtils.IS_OS_WINDOWS ? MOD_CONTROL : MOD_ALT) | MOD_SHIFT);

if (control && input.key() == GLFW_KEY_V) {
if (control && input.key() == KEY_V) {
clearSelection();

String preText = text;
Expand All @@ -328,13 +328,13 @@ public boolean onKeyRepeated(KeyEvent input) {

if (!text.equals(preText)) runAction();
return true;
} else if (input.key() == GLFW_KEY_BACKSPACE) {
} else if (input.key() == KEY_BACKSPACE) {
if (cursor > 0 && cursor == selectionStart && cursor == selectionEnd) {
String preText = text;

int count = (input.modifiers() == (SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_ALT : MacosUtil.IS_MACOS ? GLFW_MOD_SUPER : GLFW_MOD_CONTROL))
int count = (input.modifiers() == (SystemUtils.IS_OS_WINDOWS ? MOD_ALT : MacosUtil.IS_MACOS ? MOD_SUPER : MOD_CONTROL))
? cursor
: (input.modifiers() == (SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_CONTROL : GLFW_MOD_ALT))
: (input.modifiers() == (SystemUtils.IS_OS_WINDOWS ? MOD_CONTROL : MOD_ALT))
? countToNextSpace(true)
: 1;

Expand All @@ -348,14 +348,14 @@ public boolean onKeyRepeated(KeyEvent input) {
}

return true;
} else if (input.key() == GLFW_KEY_DELETE) {
} else if (input.key() == KEY_DELETE) {
if (cursor == selectionStart && cursor == selectionEnd) {
if (cursor < text.length()) {
String preText = text;

int count = input.modifiers() == (SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_ALT : MacosUtil.IS_MACOS ? GLFW_MOD_SUPER : GLFW_MOD_CONTROL)
int count = input.modifiers() == (SystemUtils.IS_OS_WINDOWS ? MOD_ALT : MacosUtil.IS_MACOS ? MOD_SUPER : MOD_CONTROL)
? text.length() - cursor
: (input.modifiers() == (SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_CONTROL : GLFW_MOD_ALT))
: (input.modifiers() == (SystemUtils.IS_OS_WINDOWS ? MOD_CONTROL : MOD_ALT))
? countToNextSpace(false)
: 1;

Expand All @@ -367,15 +367,15 @@ public boolean onKeyRepeated(KeyEvent input) {
clearSelection();
}
return true;
} else if (input.key() == GLFW_KEY_LEFT) {
} else if (input.key() == KEY_LEFT) {
if (cursor > 0) {
// sets the cursor to just after the next leftmost space
if (input.modifiers() == (SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_CONTROL : GLFW_MOD_ALT)) {
if (input.modifiers() == (SystemUtils.IS_OS_WINDOWS ? MOD_CONTROL : MOD_ALT)) {
cursor -= countToNextSpace(true);
resetSelection();
}
// sets the cursor to the beginning of the text box
else if (input.modifiers() == (SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_ALT : MacosUtil.IS_MACOS ? GLFW_MOD_SUPER : GLFW_MOD_CONTROL)) {
else if (input.modifiers() == (SystemUtils.IS_OS_WINDOWS ? MOD_ALT : MacosUtil.IS_MACOS ? MOD_SUPER : MOD_CONTROL)) {
cursor = 0;
resetSelection();
}
Expand Down Expand Up @@ -431,15 +431,15 @@ else if (shift) {
}

return true;
} else if (input.key() == GLFW_KEY_RIGHT) {
} else if (input.key() == KEY_RIGHT) {
if (cursor < text.length()) {
// sets the cursor to just before the next rightmost space
if (input.modifiers() == (SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_CONTROL : GLFW_MOD_ALT)) {
if (input.modifiers() == (SystemUtils.IS_OS_WINDOWS ? MOD_CONTROL : MOD_ALT)) {
cursor += countToNextSpace(false);
resetSelection();
}
// sets the cursor to the end of the text box
else if (input.modifiers() == (SystemUtils.IS_OS_WINDOWS ? GLFW_MOD_ALT : MacosUtil.IS_MACOS ? GLFW_MOD_SUPER : GLFW_MOD_CONTROL)) {
else if (input.modifiers() == (SystemUtils.IS_OS_WINDOWS ? MOD_ALT : MacosUtil.IS_MACOS ? MOD_SUPER : MOD_CONTROL)) {
cursor = text.length();
resetSelection();
}
Expand Down Expand Up @@ -494,7 +494,7 @@ else if (shift) {
}

return true;
} else if (input.key() == GLFW_KEY_DOWN && completionsW != null) {
} else if (input.key() == KEY_DOWN && completionsW != null) {
int currentI = getSelectedCompletion();

if (currentI == Math.min(5, completions.size() - 1)) {
Expand All @@ -508,7 +508,7 @@ else if (shift) {
}

return true;
} else if (input.key() == GLFW_KEY_UP && completionsW != null) {
} else if (input.key() == KEY_UP && completionsW != null) {
int currentI = getSelectedCompletion();

if (currentI == 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import meteordevelopment.meteorclient.gui.widgets.WWidget;
import net.minecraft.client.input.MouseButtonEvent;

import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_LEFT;
import static org.lwjgl.glfw.GLFW.GLFW_MOUSE_BUTTON_RIGHT;
import static com.mojang.blaze3d.platform.InputConstants.MOUSE_BUTTON_LEFT;
import static com.mojang.blaze3d.platform.InputConstants.MOUSE_BUTTON_RIGHT;

public abstract class WPressable extends WWidget {
public Runnable action;
Expand All @@ -18,7 +18,7 @@ public abstract class WPressable extends WWidget {

@Override
public boolean onMouseClicked(MouseButtonEvent click, boolean doubled) {
if (mouseOver && (click.button() == GLFW_MOUSE_BUTTON_LEFT || click.button() == GLFW_MOUSE_BUTTON_RIGHT))
if (mouseOver && (click.button() == MOUSE_BUTTON_LEFT || click.button() == MOUSE_BUTTON_RIGHT))
pressed = true;
return pressed;
}
Expand Down
Loading
Loading