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
![Smile :)](./images/smilies/icon_e_smile.gif)
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
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
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:)
Code: Select all
org.iceburg.ftl.homeworld.core
- FTLHomeworld
- SaveGameParser
org.iceburg.ftl.homeworld.elements
- Savegame
org.iceburg.ftl.homeworld.ui
- SpaceDockUI
- CargoBayUI
iceburg333 wrote:(...) check out the new FTL Homeworld (...)
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();
}
}
Code: Select all
Cannot run program "D:\Games\Faster": CreateProcess error=2, The system cannot find the file specified
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
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
Code: Select all
String ftlPath = (find the path somehow);
String[] arguments = { ftlPath };
exec(arguments);
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.
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();
}