From bccfd595807a6dacaaba78f72c412b6c8120f0f3 Mon Sep 17 00:00:00 2001 From: Ciro Diaz Date: Sat, 14 Sep 2024 17:21:57 +0200 Subject: [PATCH] Update OpenIC --- pom.xml | 6 +- .../renderer/screens/Menuscreen.java | 2 - src/main/java/org/josl/openic/Keyboard.java | 65 --------- src/main/java/org/josl/openic/Mouse.java | 129 ------------------ 4 files changed, 3 insertions(+), 199 deletions(-) delete mode 100644 src/main/java/org/josl/openic/Keyboard.java delete mode 100644 src/main/java/org/josl/openic/Mouse.java diff --git a/pom.xml b/pom.xml index 1cdef06..fea1b03 100644 --- a/pom.xml +++ b/pom.xml @@ -17,7 +17,7 @@ 1.18.20 1.10.8 - 1.3 + 1.4.1 0.10.4 0.0.7 5.0.4 @@ -38,11 +38,11 @@ ${joml.version} - + io.vavr diff --git a/src/main/java/net/opencraft/renderer/screens/Menuscreen.java b/src/main/java/net/opencraft/renderer/screens/Menuscreen.java index 1530755..88504e7 100644 --- a/src/main/java/net/opencraft/renderer/screens/Menuscreen.java +++ b/src/main/java/net/opencraft/renderer/screens/Menuscreen.java @@ -37,7 +37,6 @@ private Menuscreen() { private void initComponents() { /* Quit Game Button */ - this.quitButton = new GuiButton(font) { public void mouseClicked(int x, int y, int button) { oc.running = false; @@ -53,7 +52,6 @@ public void mouseClicked(int x, int y, int button) { }; settingsButton.setSize(198, 40); - /* Singleplayer button */ this.singlepyButton = new GuiButton(font); diff --git a/src/main/java/org/josl/openic/Keyboard.java b/src/main/java/org/josl/openic/Keyboard.java deleted file mode 100644 index 78016f9..0000000 --- a/src/main/java/org/josl/openic/Keyboard.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.josl.openic; - -import java.awt.Component; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.util.*; - -public class Keyboard implements KeyListener { - - private static HashSet pressedKeys = new HashSet<>(); - private static Keyboard instance; - - private static int currentKeyCode = -1; - - private Keyboard(Component parent) { - parent.addKeyListener(this); - parent.setFocusable(true); - parent.requestFocusInWindow(); - } - - public static void create(Component parent) { - instance = new Keyboard(parent); - } - - public static void destroy() { - instance = null; - } - - public static boolean isCreated() { - return instance != null; - } - - public static boolean isKeyDown(int keyCode) { - return pressedKeys.contains(keyCode); - } - - public static boolean isKeyClicked(int keyCode) { - boolean down = isKeyDown(keyCode); - if (down) - pressedKeys.remove(keyCode); - - return down; - } - - public void keyTyped(KeyEvent e) { - } - - @Override - public void keyPressed(KeyEvent e) { - int keyCode = e.getKeyCode(); - if (keyCode == currentKeyCode) - return; - - pressedKeys.add(e.getKeyCode()); - currentKeyCode = keyCode; - } - - @Override - public void keyReleased(KeyEvent e) { - pressedKeys.remove(e.getKeyCode()); - currentKeyCode = -1; - } - - -} diff --git a/src/main/java/org/josl/openic/Mouse.java b/src/main/java/org/josl/openic/Mouse.java deleted file mode 100644 index 733210e..0000000 --- a/src/main/java/org/josl/openic/Mouse.java +++ /dev/null @@ -1,129 +0,0 @@ -package org.josl.openic; - -import java.awt.*; -import java.awt.event.*; -import java.util.HashSet; -import java.util.Set; - -import javax.swing.JFrame; - -public class Mouse implements MouseListener, MouseMotionListener, MouseWheelListener { - - private static Set pressed = new HashSet<>(); - private static Mouse instance; - private static int x, y, xo, yo, xd, yd; - private static int dwheel; - - private static int currentButton = -1; - - private Mouse(Component parent) { - if (parent instanceof JFrame) - System.err.println("We don't recommend using JFrame for Mouse detection!"); - - parent.addMouseListener(this); - parent.addMouseMotionListener(this); - parent.addMouseWheelListener(this); - parent.setFocusable(true); - parent.requestFocusInWindow(); - } - - public static void create(Component parent) { - instance = new Mouse(parent); - } - - public static void destroy() { - instance = null; - } - - public static boolean isCreated() { - return instance != null; - } - - public static boolean isButtonDown(int button) { - return pressed.contains(button); - } - - public static boolean isButtonClicked(int button) { - boolean down = isButtonDown(button); - if (down) - pressed.remove(button); - - return down; - } - - public static int getX() { - return x; - } - - public static int getY() { - return y; - } - - public static int getDX() { - return xd; - } - - public static int getDY() { - return yd; - } - - public static int getDWheel() { - return dwheel; - } - - @Override - public void mouseMoved(MouseEvent e) { - x = e.getX(); - y = e.getY(); - - xd = x - xo; - yd = y - yo; - xo = x; - yo = y; - } - - @Override - public void mouseDragged(MouseEvent e) { - mouseMoved(e); - } - - @Override - public void mouseWheelMoved(MouseWheelEvent e) { - dwheel = e.getWheelRotation(); - } - - @Override - public void mousePressed(MouseEvent e) { - int button = e.getButton(); - if (button == currentButton) - return; - - pressed.add(e.getButton()); - currentButton = button; - } - - @Override - public void mouseReleased(MouseEvent e) { - pressed.remove(e.getButton()); - currentButton = -1; - } - - public static boolean inRange(Rectangle bounds) { - Point mousePos = getPos(); - return bounds.contains(mousePos); - } - - private static Point getPos() { - return new Point(x, y); - } - - public static boolean inRange(int x, int y, int w, int h) { - Rectangle bounds = new Rectangle(x, y, w, h); - return inRange(bounds); - } - - public void mouseEntered(MouseEvent e) {} - public void mouseClicked(MouseEvent e) {} - public void mouseExited(MouseEvent e) {} - -}