Skip to content

Commit 087aba7

Browse files
author
DevKevYT
committed
WIP
1 parent 54a7fdb commit 087aba7

4 files changed

Lines changed: 45 additions & 8 deletions

File tree

.project

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>devscript</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>

changelog.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ NOTICE:
55
Another future plan: Command: "include <abs|rel> <pathToFile>" a command to include external compiled libraries "plug in style".
66
Added in 1.8.0 with the command: import "path_to_jar";
77

8+
1.9.13:
9+
- The "import" command got very few love the last updates:
10+
- The class of the imported .jar file only has to extend the "Library" class and does not need to be named "CustomLibrary"
11+
BUT that means I have to use a third party library :(
12+
- Relative paths (*/lib.jar for example) can either be:
13+
The folder of a script file that is being executed
14+
OR the folder of the script host, if no file is being loaded
15+
816
1.9.12:
917
- DevScript can now property handle the null variable $null. (="undefined")
1018
- Added an explanation for the "wait" command

src/com/devkev/devscript/nativecommands/NativeLibrary.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,18 +1040,28 @@ public Object execute(Object[] args, Process application, Block block) throws Ex
10401040
}
10411041
},
10421042

1043-
new Command("import", "string", "Imports a library from a compiled .jar file. The class should extend com.mygdx.devkev.devscript.raw.Library and be named CustomLibrary\n"
1044-
+ "You can use a * to reference the current path the process is executed in (*/library.jar") {
1043+
new Command("import", "string", "Imports a library from a compiled .jar file. The class should extend com.mygdx.devkev.devscript.raw.Library. If the path starts with * it looks in the current folder of the script file") {
10451044
@Override
10461045
public Object execute(Object[] args, Process application, Block block) throws Exception {
1046+
10471047
if(!args[0].toString().endsWith(".jar")) args[0] += ".jar";
1048+
10481049
File fileToImport;
1049-
if(!args[0].toString().startsWith("*")) fileToImport = new File(args[0].toString());
1050-
else {
1051-
File jarFile = new File(URLDecoder.decode(ConsoleMain.class.getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8"));
1052-
fileToImport = new File(jarFile.getParent() + args[0].toString().substring(1));
1050+
1051+
if(!args[0].toString().startsWith("*")) {
1052+
fileToImport = new File(args[0].toString());
1053+
1054+
} else {
1055+
if(application.file == null) {
1056+
File jarFile = new File(URLDecoder.decode(ConsoleMain.class.getProtectionDomain().getCodeSource().getLocation().getPath(), "UTF-8"));
1057+
fileToImport = new File(jarFile.getParent() + args[0].toString().substring(1));
1058+
} else {
1059+
fileToImport = new File(application.file.getParentFile().getAbsolutePath() + "\\" + args[0].toString().substring(1));
1060+
}
10531061
}
10541062

1063+
System.out.println("Trying to import from: " + fileToImport);
1064+
10551065
if(!fileToImport.exists()) {
10561066
application.kill(block, "File to import not found: " + fileToImport.getPath());
10571067
return null;
@@ -1061,10 +1071,11 @@ public Object execute(Object[] args, Process application, Block block) throws Ex
10611071
java.net.URL url = uri.toURL();
10621072

10631073
Library lib;
1074+
10641075
try {
10651076
@SuppressWarnings("resource")
10661077
ClassLoader loader = new java.net.URLClassLoader(new java.net.URL[] {url});
1067-
Class<?> pluginClass = loader.loadClass("Library");
1078+
Class<?> pluginClass = loader.loadClass("com.devkev.devscript.raw.Library");
10681079

10691080
lib = (Library) pluginClass.getConstructor().newInstance();
10701081
lib.bound = application;

src/com/devkev/gui/Window.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ public void actionPerformed(ActionEvent e) {
305305
runWindow.setTitle("Running...");
306306
runWindow.setVisible(true);
307307
window.setEnabled(false);
308+
p.file = openedFile;
308309
p.setCaseSensitive(false);
309310
p.execute(textArea.getText(), true);
310311
p.setVariable("keyCode", "", false, true);
@@ -595,7 +596,7 @@ public void keyPressed(KeyEvent e) {
595596
runWindow.add(consolePane);
596597

597598
runWindow.pack();
598-
runWindow.setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().width *.5f-250), (int) (Toolkit.getDefaultToolkit().getScreenSize().height *.5f-100), 500, 200);
599+
runWindow.setBounds((int) (Toolkit.getDefaultToolkit().getScreenSize().width * .5f - 250), (int) (Toolkit.getDefaultToolkit().getScreenSize().height *.5f-100), 500, 200);
599600

600601
runWindow.addKeyListener(new KeyListener() {
601602

0 commit comments

Comments
 (0)