diff --git a/out/artifacts/SpriteBodyEditor_jar/SpriteBodyEditor.jar b/out/artifacts/SpriteBodyEditor_jar/SpriteBodyEditor.jar index efc37c9..f84b164 100644 Binary files a/out/artifacts/SpriteBodyEditor_jar/SpriteBodyEditor.jar and b/out/artifacts/SpriteBodyEditor_jar/SpriteBodyEditor.jar differ diff --git a/src/main/java/com/andres_k/components/gameComponents/controllers/GameController.java b/src/main/java/com/andres_k/components/gameComponents/controllers/GameController.java index f1ff1f9..53e9d99 100644 --- a/src/main/java/com/andres_k/components/gameComponents/controllers/GameController.java +++ b/src/main/java/com/andres_k/components/gameComponents/controllers/GameController.java @@ -15,8 +15,8 @@ import com.andres_k.utils.configs.GlobalVariable; import com.andres_k.utils.stockage.Pair; import com.andres_k.utils.stockage.Tuple; +import com.andres_k.utils.tools.FilesTools; import com.andres_k.utils.tools.MathTools; -import com.andres_k.utils.tools.StringTools; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; import org.newdawn.slick.*; @@ -233,7 +233,7 @@ public boolean loadJsonFile(String path) throws SlickException, JSONException { File file = new File(GlobalVariable.folder + path.substring(0, path.indexOf(".")) + ".json"); if (file.exists() && !file.isDirectory()) { - this.bodyCreator = new BodyCreator(new JSONObject(StringTools.readFile(GlobalVariable.folder + path.substring(0, path.indexOf(".")) + ".json"))); + this.bodyCreator = new BodyCreator(new JSONObject(FilesTools.readFile(GlobalVariable.folder + path.substring(0, path.indexOf(".")) + ".json"))); return true; } return false; diff --git a/src/main/java/com/andres_k/components/gameComponents/controllers/InterfaceController.java b/src/main/java/com/andres_k/components/gameComponents/controllers/InterfaceController.java index 9b1c826..573b798 100644 --- a/src/main/java/com/andres_k/components/gameComponents/controllers/InterfaceController.java +++ b/src/main/java/com/andres_k/components/gameComponents/controllers/InterfaceController.java @@ -16,7 +16,6 @@ import com.andres_k.utils.stockage.Tuple; import com.andres_k.utils.tools.Console; import com.andres_k.utils.tools.FilesTools; -import com.andres_k.utils.tools.StringTools; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; @@ -82,7 +81,7 @@ public void keyPressed(int key, char c) { @Override public void keyReleased(int key, char c) { if (key == Input.KEY_ENTER && this.currentPath != null) { - if (StringTools.validFile(GlobalVariable.folder + this.currentPath.substring(0, this.currentPath.indexOf(".")) + ".json")) { + if (FilesTools.validFile(GlobalVariable.folder + this.currentPath.substring(0, this.currentPath.indexOf(".")) + ".json")) { this.launchWithPath(new MessageFileLoad("admin", "admin", this.currentPath)); } else { diff --git a/src/main/java/com/andres_k/components/gameComponents/gameObject/BodyCreator.java b/src/main/java/com/andres_k/components/gameComponents/gameObject/BodyCreator.java index 7a428c3..9af412c 100644 --- a/src/main/java/com/andres_k/components/gameComponents/gameObject/BodyCreator.java +++ b/src/main/java/com/andres_k/components/gameComponents/gameObject/BodyCreator.java @@ -2,7 +2,7 @@ import com.andres_k.utils.configs.GlobalVariable; import com.andres_k.utils.tools.Console; -import com.andres_k.utils.tools.StringTools; +import com.andres_k.utils.tools.FilesTools; import org.codehaus.jettison.json.JSONArray; import org.codehaus.jettison.json.JSONException; import org.codehaus.jettison.json.JSONObject; @@ -119,7 +119,7 @@ public BodySprite onClick(float x, float y) { public void saveInFile() { String jsonName = this.path.substring(0, this.path.indexOf(".")) + ".json"; - StringTools.writeInFile(GlobalVariable.folder + jsonName, this.toString()); + FilesTools.writeInFile(GlobalVariable.folder + jsonName, this.toString()); } @Override diff --git a/src/main/java/com/andres_k/components/gameComponents/gameObject/BodyRect.java b/src/main/java/com/andres_k/components/gameComponents/gameObject/BodyRect.java index fa35003..e9c9958 100644 --- a/src/main/java/com/andres_k/components/gameComponents/gameObject/BodyRect.java +++ b/src/main/java/com/andres_k/components/gameComponents/gameObject/BodyRect.java @@ -193,10 +193,6 @@ public void setFocused(boolean value) { @Override public String toString() { - - - return forWaterWar(); - /* JSONObject object = new JSONObject(); try { @@ -216,31 +212,6 @@ public String toString() { e.printStackTrace(); } - return object.toString();*/ - } - - private String forWaterWar() { - JSONObject object = new JSONObject(); - - try { - object.put("id", this.id); - object.put("type", this.type.getValue()); - object.put("x", (int) (this.positions.getV1() - this.origin.getV1())); - object.put("y", (int) (this.positions.getV2() - this.origin.getV2())); - object.put("width", this.sizes.getV1().intValue()); - object.put("height", this.sizes.getV2().intValue()); - object.put("rotation", 0f); - object.put("component", ""); - - JSONArray array = new JSONArray(); - for (String value : this.links) { - array.put(value); - } - object.put("links", array); - } catch (JSONException e) { - e.printStackTrace(); - } - return object.toString(); } } diff --git a/src/main/java/com/andres_k/utils/tools/FilesTools.java b/src/main/java/com/andres_k/utils/tools/FilesTools.java index 45b8d48..9bcda1a 100644 --- a/src/main/java/com/andres_k/utils/tools/FilesTools.java +++ b/src/main/java/com/andres_k/utils/tools/FilesTools.java @@ -12,6 +12,12 @@ public class FilesTools { + public static boolean validFile(String path) { + File file = new File(path); + + return (file.exists() && !file.isDirectory()); + } + public static String readInput(InputStream inputStream) { Scanner scan = new Scanner(inputStream).useDelimiter("\\A"); diff --git a/src/main/java/com/andres_k/utils/tools/StringTools.java b/src/main/java/com/andres_k/utils/tools/StringTools.java index 20f162b..82d6e5f 100644 --- a/src/main/java/com/andres_k/utils/tools/StringTools.java +++ b/src/main/java/com/andres_k/utils/tools/StringTools.java @@ -1,48 +1,11 @@ package com.andres_k.utils.tools; -import java.io.*; - /** * Created by andres_k on 24/03/2015. */ public class StringTools { - public static boolean validFile(String path) { - File file = new File(path); - - return (file.exists() && !file.isDirectory()); - } - - public static String readFile(String fileName) { - String content = ""; - File file = new File(fileName); //for ex foo.txt - Console.debug("file: " + file.getAbsolutePath()); - try { - FileReader reader = new FileReader(file); - char[] chars = new char[(int) file.length()]; - reader.read(chars); - content = new String(chars); - reader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - return content; - } - - public static void writeInFile(String fileName, String value) { - File file = new File(fileName); - - try { - FileWriter fw = new FileWriter(file.getAbsoluteFile()); - BufferedWriter bw = new BufferedWriter(fw); - bw.write(value); - bw.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - public static String duplicateString(String value, int number) { String result = "";