Hey Iceberg - I put up a PR in github for a few changes to support other OSes. (I basically just copied the code from FTL Editor that handles it correctly).
I also fixed the case of not having any save games causing the program to crash. Also, you might want to figure out a way to include/package/link to the required code from FTL Editor with your program so it doesn't crash when it can't be found
[Save Manager] FTL Homeworld AE -v3.1
-
- Posts: 1
- Joined: Tue Jul 23, 2013 4:40 pm
- Estel
- Posts: 466
- Joined: Sat Jun 22, 2013 4:03 am
Re: [Program] FTL SpaceDock
Very interesting idea. When it delivers things like using scrap/items for building/purchasing other ships, it could be even balanced to the point of not giving player any edge, just as others suggested, practically "merge" it into part of the game.
I'll follow this with great interest.
/Estel
I'll follow this with great interest.
/Estel
-
- Posts: 67
- Joined: Tue Jun 25, 2013 8:52 pm
Re: [Program] FTL SpaceDock
lologarithm wrote:Hey Iceberg - I put up a PR in github for a few changes to support other OSes. (I basically just copied the code from FTL Editor that handles it correctly).
I also fixed the case of not having any save games causing the program to crash. Also, you might want to figure out a way to include/package/link to the required code from FTL Editor with your program so it doesn't crash when it can't be found
Hey Lologarithm! I saw your PR and I'm such a newb at github that I had no idea what was going on. At first, I was like "Oh no, someone has done something bad to my code," and then I read your comments and got pumped! The fact that someone would just show up and improve the code is so cool! Thank you! I'm a github noob, so it may take a bit to figure it out (though I think what's going on now) but I'm going to review the code changes, confirm it or whatever, and then update my code in my IDE as well. Thank you!
Estel wrote:Very interesting idea. When it delivers things like using scrap/items for building/purchasing other ships, it could be even balanced to the point of not giving player any edge, just as others suggested, practically "merge" it into part of the game.
I'll follow this with great interest.
/Estel
Thanks Estel! I agree with you, I'm excited to see how it turns out.
LordAshram wrote:Nevermind, downloaded now... now I just have to figure out the install, because I don't totally understand all that stuff:) Let me do some reading:)
Sweet, let me know if you need help or anything.
Last edited by iceburg333 on Wed Jul 24, 2013 2:29 pm, edited 1 time in total.
-
- Posts: 67
- Joined: Tue Jun 25, 2013 8:52 pm
Re: [Program] FTL SpaceDock
Lologarithm, I've added your changes to the new FTL Program. Thank you so much!
I'm going to work on testing to make sure I transcribed stuff correctly and that everything works, and then may release an updated version of Spacedock based on all the improvements you made.
If you want, check out the new FTL Homeworld Github! I'm only half way done with writing the gui, but it's coming along.
EDIT: I'm making a lot of progress! I'll update Github tonight with what I get done. I'll definitely be releasing another Spacedock update before finishing my cargobay. I'm excited! =D
I'm going to work on testing to make sure I transcribed stuff correctly and that everything works, and then may release an updated version of Spacedock based on all the improvements you made.
If you want, check out the new FTL Homeworld Github! I'm only half way done with writing the gui, but it's coming along.
EDIT: I'm making a lot of progress! I'll update Github tonight with what I get done. I'll definitely be releasing another Spacedock update before finishing my cargobay. I'm excited! =D
Last edited by iceburg333 on Wed Jul 24, 2013 7:14 pm, edited 1 time in total.
- kartoFlane
- Posts: 1488
- Joined: Mon Jan 14, 2013 10:20 pm
Re: [Program] FTL SpaceDock
Back again, I peeked at the code several times; I'd recommend making the ShipSave class into its own file, to make use of the object-oriented nature of Java.
It looks like right now it only holds a reference to the savegame file itself - it's kind of a waste (you could use an ArrayList<File> for that), especially since you could have it contain the ship's image, button reference, data from within the save file (so you don't have to read it anew each time you need the info), as well as making it host the dockShip and boardShip functions (and all the other relevant methods I haven't spotted)
Also, as I was told by shark when I started, it might be a good idea to organize the code into relevant packages:
It might also be a good idea to include relevant pieces of code from the Savegame Editor in your own project, to eliminate the confusing dependency. The code is open-source, so it's not a crime if you copy it.
Also, since the savegame location cannot be changed AFAIK, you can just hardcode it into your program, so that the Spacedock doesn't have to be placed inside FTL's savegame directory. And even if the savegame location can be changed, you can prompt the user to point the program to it.
Well, that's about it - there are some other things I wanted to suggest, but figured I'd leave them to you to learn
It looks like right now it only holds a reference to the savegame file itself - it's kind of a waste (you could use an ArrayList<File> for that), especially since you could have it contain the ship's image, button reference, data from within the save file (so you don't have to read it anew each time you need the info), as well as making it host the dockShip and boardShip functions (and all the other relevant methods I haven't spotted)
Also, as I was told by shark when I started, it might be a good idea to organize the code into relevant packages:
Code: Select all
org.iceburg.ftl.homeworld.core
- FTLHomeworld
- SaveGameParser
org.iceburg.ftl.homeworld.elements
- Savegame
org.iceburg.ftl.homeworld.ui
- SpaceDockUI
- CargoBayUI
It might also be a good idea to include relevant pieces of code from the Savegame Editor in your own project, to eliminate the confusing dependency. The code is open-source, so it's not a crime if you copy it.
Also, since the savegame location cannot be changed AFAIK, you can just hardcode it into your program, so that the Spacedock doesn't have to be placed inside FTL's savegame directory. And even if the savegame location can be changed, you can prompt the user to point the program to it.
Well, that's about it - there are some other things I wanted to suggest, but figured I'd leave them to you to learn
Superluminal2 - a ship editor for FTL
- Estel
- Posts: 466
- Joined: Sat Jun 22, 2013 4:03 am
Re: [Program] FTL SpaceDock
iceburg333 wrote:(...) check out the new FTL Homeworld (...)
Homeworld? FTL? Whatever you're up to, it sounds very, very good!
(sorry for the pun, just couldn't stop myself).
/Estel
-
- Posts: 67
- Joined: Tue Jun 25, 2013 8:52 pm
Re: [Program] FTL SpaceDock
I've updated Github to be about even with where I'm at. I've installed a button to choose your save folder (In case you have saves in more than one place) and I've created a refresh button (in case saves are modified/added/lost while the program is up). I'd like to make a button that let's you launch the game (so that this program could work as a save manager/ game launcher) but I'm having trouble getting it to launch. Here is my code:
My error reads as follows:
I believe that there are two problems: "Faster Than Light" has spaces in the folder name, and I've installed my game on the D: drive instead of the C: drive. Can anyone help me figure out how to get around these two issues?
Thanks!
Ice
Code: Select all
else if (o.equals(launchbtn)) {
//TODO - launch game
System.out.println("launched");
//File gameFolder = new File(FTLHomeworld.datsPath.getParentFile() + "\\");
String command = new String(FTLHomeworld.datsPath.getParentFile() + "\\FTLGame.exe" );
String command1 = new String(FTLHomeworld.datsPath.getParentFile() + "\\FTLGame.exe" );
try {
//Runtime.getRuntime().exec("FTLGame.exe", null, gameFolder);
Runtime.getRuntime().exec(command);
//This launches and the immediatly exits FTL
// ProcessBuilder pb = new ProcessBuilder(command);
// pb.start();
} catch (IOException e1) {
// Auto-generated catch block
e1.printStackTrace();
}
}
My error reads as follows:
Code: Select all
Cannot run program "D:\Games\Faster": CreateProcess error=2, The system cannot find the file specified
I believe that there are two problems: "Faster Than Light" has spaces in the folder name, and I've installed my game on the D: drive instead of the C: drive. Can anyone help me figure out how to get around these two issues?
Thanks!
Ice
-
- Posts: 67
- Joined: Tue Jun 25, 2013 8:52 pm
Re: [Program] FTL SpaceDock
Estel wrote:iceburg333 wrote:(...) check out the new FTL Homeworld (...)
Homeworld? FTL? Whatever you're up to, it sounds very, very good!
(sorry for the pun, just couldn't stop myself).
/Estel
Haha, Thanks Estel! =D
kartoFlane wrote:Back again, I peeked at the code several times; I'd recommend making the ShipSave class into its own file, to make use of the object-oriented nature of Java.
It looks like right now it only holds a reference to the savegame file itself - it's kind of a waste (you could use an ArrayList<File> for that), especially since you could have it contain the ship's image, button reference, data from within the save file (so you don't have to read it anew each time you need the info), as well as making it host the dockShip and boardShip functions (and all the other relevant methods I haven't spotted)
Also, as I was told by shark when I started, it might be a good idea to organize the code into relevant packages:Code: Select all
org.iceburg.ftl.homeworld.core
- FTLHomeworld
- SaveGameParser
org.iceburg.ftl.homeworld.elements
- Savegame
org.iceburg.ftl.homeworld.ui
- SpaceDockUI
- CargoBayUI
It might also be a good idea to include relevant pieces of code from the Savegame Editor in your own project, to eliminate the confusing dependency. The code is open-source, so it's not a crime if you copy it.
Also, since the savegame location cannot be changed AFAIK, you can just hardcode it into your program, so that the Spacedock doesn't have to be placed inside FTL's savegame directory. And even if the savegame location can be changed, you can prompt the user to point the program to it.
Well, that's about it - there are some other things I wanted to suggest, but figured I'd leave them to you to learn
I was just going to go to lunch, but now I'm excited to come back! What you're saying makes sense, I'll start working on it after lunch. It's so cool to have pros drop by and give me advice like this. Please do feel free to give me as much correction/ suggestions as you'd like, they really help me to grow.
As I work through this after lunch I'll respond in more detail to your post. Thanks!
- kartoFlane
- Posts: 1488
- Joined: Mon Jan 14, 2013 10:20 pm
Re: [Program] FTL SpaceDock
Yes, the spaces are precisely the cause for why it is not working; this is due to the way exec(String) works (it essentially splits the argument by spaces) - in order to work around that you have to put your command into a string array, and then pass that into exec(), like this:
exec(String[]) doesn't split arguments by spaces, and instead treats each index in the array as separate argument.
Code: Select all
String ftlPath = (find the path somehow);
String[] arguments = { ftlPath };
exec(arguments);
exec(String[]) doesn't split arguments by spaces, and instead treats each index in the array as separate argument.
Superluminal2 - a ship editor for FTL
-
- Posts: 67
- Joined: Tue Jun 25, 2013 8:52 pm
Re: [Program] FTL SpaceDock
kartoFlane wrote:Yes, the spaces are precisely the cause for why it is not working; this is due to the way exec(String) works (it essentially splits the argument by spaces) - in order to work around that you have to put your command into a string array, and then pass that into exec(), like this:Code: Select all
String ftlPath = (find the path somehow);
String[] arguments = { ftlPath };
exec(arguments);
exec(String[]) doesn't split arguments by spaces, and instead treats each index in the array as separate argument.
Man, it's a wonderful thing to be able to post a question and get it answered like that! Thank you!
Your suggestion worked perfectly, and I would not have figured that out otherwise!
So, I have it working now... sort of. The code worked just as you said, however, FTL nearly instantly crashes/exits after it starts up, where as when I run FTL from a bat file it starts the game as normal. Do you have any idea as to why running it from java would instantly close it?
Code: Select all
String command = new String(FTLHomeworld.datsPath.getParentFile() + "\\FTLGame.exe" );
String[] command1 = {command};
try {
//Runtime.getRuntime().exec("FTLGame.exe", null, gameFolder);
Runtime.getRuntime().exec(command1).waitFor();
//This launches and the immediatly exits FTL
// ProcessBuilder pb = new ProcessBuilder(command);
// pb.start();
} catch (IOException e1) {
// Auto-generated catch block
e1.printStackTrace();
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
I'm also going to spend time better organizing the code/ removing the FTL editor dependencies while I try to figure this out.