From 5aa5a6a989c92e71590236da8857b144fdeb198e Mon Sep 17 00:00:00 2001 From: josua Date: Fri, 6 Dec 2019 13:47:56 +1100 Subject: [PATCH] Removed the built in updator script --- src/projectzombie/display/DisplayRender.java | 11 +- src/projectzombie/input/JoystickCallback.java | 14 ++- src/projectzombie/input/KeyCallback.java | 24 ++++- .../menu/gui/components/ButtonGroupPause.java | 2 - src/projectzombie/resources/Resource.java | 102 ++---------------- .../resources/ResourceDownload.java | 52 --------- src/projectzombie/settings/Settings.java | 2 - 7 files changed, 55 insertions(+), 152 deletions(-) delete mode 100644 src/projectzombie/resources/ResourceDownload.java diff --git a/src/projectzombie/display/DisplayRender.java b/src/projectzombie/display/DisplayRender.java index 82c32dc..54903c2 100644 --- a/src/projectzombie/display/DisplayRender.java +++ b/src/projectzombie/display/DisplayRender.java @@ -1,6 +1,15 @@ package projectzombie.display; -import static org.lwjgl.opengl.GL33.*; +import static org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT; +import static org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT; +import static org.lwjgl.opengl.GL11.GL_MODELVIEW; +import static org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA; +import static org.lwjgl.opengl.GL11.GL_SRC_ALPHA; +import static org.lwjgl.opengl.GL11.glBlendFunc; +import static org.lwjgl.opengl.GL11.glClear; +import static org.lwjgl.opengl.GL11.glLoadMatrixf; +import static org.lwjgl.opengl.GL11.glMatrixMode; +import static org.lwjgl.opengl.GL11.glViewport; import org.joml.Matrix4f; import org.lwjgl.opengl.GL; diff --git a/src/projectzombie/input/JoystickCallback.java b/src/projectzombie/input/JoystickCallback.java index 7de9577..19246d7 100644 --- a/src/projectzombie/input/JoystickCallback.java +++ b/src/projectzombie/input/JoystickCallback.java @@ -1,6 +1,17 @@ package projectzombie.input; -import static projectzombie.input.GameInput.*; +import static projectzombie.input.GameInput.activateItem_last; +import static projectzombie.input.GameInput.activateTile_last; +import static projectzombie.input.GameInput.activate_last; +import static projectzombie.input.GameInput.backButton_last; +import static projectzombie.input.GameInput.dropItem_last; +import static projectzombie.input.GameInput.fireGun; +import static projectzombie.input.GameInput.hotbar_l; +import static projectzombie.input.GameInput.hotbar_r; +import static projectzombie.input.GameInput.moveDown; +import static projectzombie.input.GameInput.moveUp; +import static projectzombie.input.GameInput.move_last; +import static projectzombie.input.GameInput.startButton_last; import java.nio.ByteBuffer; import java.nio.FloatBuffer; @@ -11,7 +22,6 @@ import org.lwjgl.glfw.GLFWJoystickCallbackI; import mainloop.task.IMainloopTask; import projectzombie.Main; -import projectzombie.display.DisplayWindow; import projectzombie.input.types.Input; public class JoystickCallback implements GLFWJoystickCallbackI, IMainloopTask diff --git a/src/projectzombie/input/KeyCallback.java b/src/projectzombie/input/KeyCallback.java index 9a35196..bb9607b 100644 --- a/src/projectzombie/input/KeyCallback.java +++ b/src/projectzombie/input/KeyCallback.java @@ -1,7 +1,27 @@ package projectzombie.input; -import static org.lwjgl.glfw.GLFW.*; -import static projectzombie.input.GameInput.*; +import static org.lwjgl.glfw.GLFW.GLFW_KEY_1; +import static org.lwjgl.glfw.GLFW.GLFW_KEY_2; +import static org.lwjgl.glfw.GLFW.GLFW_KEY_3; +import static org.lwjgl.glfw.GLFW.GLFW_KEY_4; +import static org.lwjgl.glfw.GLFW.GLFW_KEY_5; +import static org.lwjgl.glfw.GLFW.GLFW_KEY_6; +import static org.lwjgl.glfw.GLFW.GLFW_KEY_A; +import static org.lwjgl.glfw.GLFW.GLFW_KEY_D; +import static org.lwjgl.glfw.GLFW.GLFW_KEY_E; +import static org.lwjgl.glfw.GLFW.GLFW_KEY_ESCAPE; +import static org.lwjgl.glfw.GLFW.GLFW_KEY_F11; +import static org.lwjgl.glfw.GLFW.GLFW_KEY_Q; +import static org.lwjgl.glfw.GLFW.GLFW_KEY_S; +import static org.lwjgl.glfw.GLFW.GLFW_KEY_W; +import static org.lwjgl.glfw.GLFW.GLFW_RELEASE; +import static projectzombie.input.GameInput.backButton_last; +import static projectzombie.input.GameInput.fireGun; +import static projectzombie.input.GameInput.moveDown; +import static projectzombie.input.GameInput.moveLeft; +import static projectzombie.input.GameInput.moveRight; +import static projectzombie.input.GameInput.moveUp; +import static projectzombie.input.GameInput.move_last; import org.lwjgl.glfw.GLFWKeyCallbackI; diff --git a/src/projectzombie/menu/gui/components/ButtonGroupPause.java b/src/projectzombie/menu/gui/components/ButtonGroupPause.java index 67a8672..9d62d87 100644 --- a/src/projectzombie/menu/gui/components/ButtonGroupPause.java +++ b/src/projectzombie/menu/gui/components/ButtonGroupPause.java @@ -1,8 +1,6 @@ package projectzombie.menu.gui.components; import projectzombie.Main; -import projectzombie.menu.Menu; -import projectzombie.menu.MenuGamePause; import projectzombie.menu.MenuMain; import projectzombie.menu.MenuSettings; import projectzombie.menu.gui.ButtonGroup; diff --git a/src/projectzombie/resources/Resource.java b/src/projectzombie/resources/Resource.java index 297b60d..5664c2d 100644 --- a/src/projectzombie/resources/Resource.java +++ b/src/projectzombie/resources/Resource.java @@ -1,11 +1,8 @@ package projectzombie.resources; -import java.io.File; import java.io.FileInputStream; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; @@ -14,51 +11,6 @@ public class Resource String path; byte[] data; - /*private InputStream fileURLStream(String path, int tries) - { - System.err.println("Getting \""+fileURL(path)+"\". Try "+ tries); - - try { - return new URL(fileURL(path)).openStream(); - } - - catch(MalformedURLException e) { - System.err.println("Malformed URL"); - e.printStackTrace(); - System.exit(1); - return null; - } - - catch(IOException e) - { - if(tries == 10) { - e.printStackTrace(); - System.err.println("Exceeded max tries"); - System.exit(1); - return null; - } - - else { - e.printStackTrace(); - try { - Thread.sleep(5000); - } catch (InterruptedException e1) { - System.err.println("Terminated by user"); - System.exit(1); - } - return this.fileURLStream(path, tries+1); - } - } - }*/ - - /*private InputStream fileURLStream(String path) { - return this.fileURLStream(path, 0); - }*/ - - private String fileURL(String path) { - return "https://www.onewaycoding.com/files/game_resources/ShooterGame/"+path; - } - private String filePath(String path) { return "resources/"+path; } @@ -71,54 +23,22 @@ public class Resource public void load() { - // Does the resource not exist - File file = new File(filePath(path)); - if(!file.exists()) + try { - // Create the parent directories - file.getParentFile().mkdirs(); + // Open the file stored on the hard drive + InputStream file_stream = new FileInputStream(filePath(path)); - try - { - // Download the file and open the file output stream - OutputStream file_stream = new FileOutputStream(filePath(path)); - - // Get the resource data from the server - data = ResourceDownload.downloadURL(fileURL(path)); - - // Save all the data downloaded to a file - file_stream.write(data); - file_stream.close(); - } - - catch(IOException e) - { - // Print the stacktrace and exit - System.err.println("Error downloading file"); - e.printStackTrace(); - System.exit(1); - } + data = new byte[file_stream.available()]; + file_stream.read(data); + file_stream.close(); } - else + catch(IOException e) { - try - { - // Open the file stored on the hard drive - InputStream file_stream = new FileInputStream(filePath(path)); - - data = new byte[file_stream.available()]; - file_stream.read(data); - file_stream.close(); - } - - catch(IOException e) - { - // Print the stacktrace and exit - System.err.println("Error opening file"); - e.printStackTrace(); - System.exit(1); - } + // Print the stacktrace and exit + System.err.println("Error opening file at "+path+"!"); + e.printStackTrace(); + System.exit(1); } } diff --git a/src/projectzombie/resources/ResourceDownload.java b/src/projectzombie/resources/ResourceDownload.java deleted file mode 100644 index 60c0814..0000000 --- a/src/projectzombie/resources/ResourceDownload.java +++ /dev/null @@ -1,52 +0,0 @@ -package projectzombie.resources; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; -import java.text.DecimalFormat; - -public class ResourceDownload -{ - public static byte[] downloadURL(String path) throws IOException - { - // Get the url and the connection - URL url = new URL(path); - URLConnection con = url.openConnection(); - - // Get the file size - int fileSize = con.getContentLength(); - byte[] data = new byte[fileSize]; - - // Get the input stream - InputStream stream = con.getInputStream(); - - // Get 1 kb packets from the server - for(int i = 0; i < fileSize; i ++) - { - // Load the stream contents to the buffer - byte buffer[] = new byte[1]; - stream.read(buffer); - - // Send a status update - DecimalFormat decim = new DecimalFormat("#.##"); - if(i % 1048576 == 0) System.out.println(decim.format(i / 1048576) + " MB / " + - decim.format(fileSize / 1048576) + " MB - " + - decim.format((double)i / (double)fileSize) + "%"); - - // Store the bytes downloaded to the data variable - for(int b=0;b