[Save Manager] FTL Homeworld AE -v3.1

Distribute and discuss mods that are functional. Moderator - Grognak
roza3436
Posts: 4
Joined: Thu Jul 25, 2013 11:19 am

Re: [Program] FTL Homeworld

Postby roza3436 » Wed Jul 31, 2013 12:54 am

please help?
User avatar
kartoFlane
Posts: 1479
Joined: Mon Jan 14, 2013 10:20 pm

Re: [Program] FTL Homeworld

Postby kartoFlane » Wed Jul 31, 2013 10:07 am

roza3436 wrote:ftlDatsPath=C\:\\Program Files (x86)\\FTL\\resources
ftlSavePath=C\:\\Users\\Student_2\\Documents\\My Games\\FasterThanLight

Should be: C:\\
Most likely a typo in the program's config-saving function.
Guess you can change it yourself in your config and save it, it shouldn't get overwritten unless you change it during runtime.
Superluminal2 - a ship editor for FTL
Vhati
Posts: 792
Joined: Thu Oct 25, 2012 12:01 pm

Re: [Program] FTL Homeworld

Postby Vhati » Thu Aug 01, 2013 5:01 am

From the editor thread...

iceburg333 wrote:I'm having trouble with the apache logger dependency. I have your source code working in eclipse as I managed to get Maven working. [...]
When I run my program from inside eclipse, it runs but I get this error and no log info works:

Code: Select all

log4j:WARN No appenders could be found for logger (org.iceburg.ftl.homeworld.core.FTLHomeworld).
log4j:WARN Please initialize the log4j system properly.


I'm guessing that the secret lies in moving your log4j2.xmls over to my project, or doing some kind of maven transfer/transfusion.
ComaToes had that set up before I came on board. :|
According to the editor's Maven pom.xml, there are two dependencies: log4j-api and log4j-core (ver 2.0-beta1)

Snooping around "~/.m2/repository/", Maven cached these files:
  • log4j-core-2.0-beta1.jar
  • log4j-api-2.0-beta1.jar

You'll need the log4j stuff in your classpath, either embedded in the jar, or somehow mentioned in meta-inf with jars in the same folder.

log4j2.xml is the config. The logger expects it. I have a little experience editing that file...
The other similar xml's are alternate configs there to be optionally chosen by name with a commandline arg.
Last edited by Vhati on Thu Aug 01, 2013 5:17 am, edited 3 times in total.
Vhati
Posts: 792
Joined: Thu Oct 25, 2012 12:01 pm

Re: [Program] FTL Homeworld

Postby Vhati » Thu Aug 01, 2013 5:11 am

kartoFlane wrote:
roza3436 wrote:ftlDatsPath=C\:\\Program Files (x86)\\FTL\\resources
ftlSavePath=C\:\\Users\\Student_2\\Documents\\My Games\\FasterThanLight

Should be: C:\\
Most likely a typo in the program's config-saving function.
Guess you can change it yourself in your config and save it, it shouldn't get overwritten unless you change it during runtime.


The editor's looks like that too:

Code: Select all

#FTL Profile Editor - Config File
#Tue Feb 19 23:13:56 EST 2013
ftlDatsPath=E\:\\Games\\FasterThanLight\\resources
useDefaultUI=false


Apparently, escaping colons is normal behavior for configs written with Java's Properties.store(). :?
"For each entry the key string is written, then an ASCII =, then the associated element string. [...] The key and element characters #, !, =, and : are written with a preceding backslash to ensure that they are properly loaded."
User avatar
kartoFlane
Posts: 1479
Joined: Mon Jan 14, 2013 10:20 pm

Re: [Program] FTL Homeworld

Postby kartoFlane » Thu Aug 01, 2013 11:12 am

@roza3436
Could you also paste the stack trace (crash log) here? It's generally much more helpful in troubleshooting

Vhati wrote:Apparently, escaping colons is normal behavior for configs written with Java's Properties.store(). :?

Huh. I've never noticed that, though now that I look through the config files of my other programs, they also have escaped colons...

Took a brief look through the code, this
roza3436 wrote:It says error saving to homeworld.cfg.

would imply that the error occurs somewhere here:

Code: Select all

try {
   out = new FileOutputStream(propFile);
   config.store( out, "FTL Homeworld - Config File" );
} catch (IOException e) {
   // log.error( "Error saving config to " + propFile.getPath(), e );
   showErrorDialog( "Error saving config to " + propFile.getPath() );
   e.printStackTrace();
}

Can't see anything inherently wrong with it, though. propFile is never null, and should exist at that point (even if not, FOS should create it automatically, IIRC). Input stream on the properties file is closed. config variable is always created, too. I guess it might be an issue with permissions, or one of the key-value pairs being null, or something *shrug* without the stack trace it's all just guessing though.
Superluminal2 - a ship editor for FTL
iceburg333
Posts: 67
Joined: Tue Jun 25, 2013 8:52 pm
Contact:

Re: [Program] FTL Homeworld

Postby iceburg333 » Thu Aug 01, 2013 7:26 pm

Sorry I haven't posted in a while. Real life has been really busy. I haven't done much programming, other than to fix a bug, but I did make a 3d model of the Kestrel. It doesn't look great as I didn't do a great job with the UV map and haven't done any texturing, but it's kind of neat:
Kestrel Steps 2.gif



Vhati wrote:From the editor thread...

ComaToes had that set up before I came on board. :|
According to the editor's Maven pom.xml, there are two dependencies: log4j-api and log4j-core (ver 2.0-beta1)

Snooping around "~/.m2/repository/", Maven cached these files:
  • log4j-core-2.0-beta1.jar
  • log4j-api-2.0-beta1.jar

You'll need the log4j stuff in your classpath, either embedded in the jar, or somehow mentioned in meta-inf with jars in the same folder.

log4j2.xml is the config. The logger expects it. I have a little experience editing that file...
The other similar xml's are alternate configs there to be optionally chosen by name with a commandline arg.


Thanks for answering this! I snooped into Maven's repository, but I think I only saw the beta1.jar and missed the -api jar. I'll look back around and look into the xml. I'm glad I figured out how to make the program run without the dependencies, so if I don't figure it out it's no big deal, but I did like the logging functionality and I would like to learn how to add it. So thank you for pointing me in the right direction. I'll let you know if I figure it out. Thanks! :D

kartoFlane wrote:@roza3436
Could you also paste the stack trace (crash log) here? It's generally much more helpful in troubleshooting

Vhati wrote:Apparently, escaping colons is normal behavior for configs written with Java's Properties.store(). :?

Huh. I've never noticed that, though now that I look through the config files of my other programs, they also have escaped colons...

Took a brief look through the code, this
roza3436 wrote:It says error saving to homeworld.cfg.

would imply that the error occurs somewhere here:

Code: Select all

try {
   out = new FileOutputStream(propFile);
   config.store( out, "FTL Homeworld - Config File" );
} catch (IOException e) {
   // log.error( "Error saving config to " + propFile.getPath(), e );
   showErrorDialog( "Error saving config to " + propFile.getPath() );
   e.printStackTrace();
}

Can't see anything inherently wrong with it, though. propFile is never null, and should exist at that point (even if not, FOS should create it automatically, IIRC). Input stream on the properties file is closed. config variable is always created, too. I guess it might be an issue with permissions, or one of the key-value pairs being null, or something *shrug* without the stack trace it's all just guessing though.


@KartoFlane: Thank you for bugshooting (as well as Vhati). I'm scraping by on figuring this out, so my solutions and bugshooting is practically non-existant for java, so I really appreciate you guys helping Roza. My config file/writing the config file is nearly completely copied from FTL Editor, so while I could have made a code error, I don't think it's due to my novice-ness... Roza, does FTL Profile Editor work for you?
Roza, based on what KartoFlane said, have you tried running it as administrater? (Right click the jar in windows and "Run as Administrator".

I'm going to get back to programming. From my estimates I have everything figured out that I need to know in order to finish Cargo Bay, unless something comes up. So hopefully I'll be back with some good progress... :D
Image
iceburg333
Posts: 67
Joined: Tue Jun 25, 2013 8:52 pm
Contact:

Re: [Program] FTL Homeworld

Postby iceburg333 » Mon Aug 05, 2013 7:13 pm

MAIN POST UPDATED
V2.0 released: Cargobay now included: allows you to trade items between ships as well as store them in the spacedock's cargo bay for safe keeping!
It's an initial release, so please report any bugs you run into.

To the experts (Vhati and KartoFlane): I've updated githubto reflect the 2.0 release. If either of you guys feel like looking through it/ I'd love to hear any advice you have / criticism/ better ways I could implement things / any comments you guys might have. Also, I'd love to hear your input as I try to conceptualize the next step:

The goal is to make a ship builder, where you can store items collected with ships in the cargo bay. Then, if you have the right supplies you can build 'new' ships. (Predefined ships from FTL, mods, SuperLuminal, etc). Basically FTL Profile Editor's create new ship/ edit shipLayout tab, except you use supplies to construct the ship. I've spent a lot of time thinking through this as I've finished the cargo bay, so here is my working theory. I'd love to hear what you guys think of this / advice on if you think something won't work / I should do it another way to do it better.

-------
First, new items: I'm going to make an FTL mod that you will use with the mod manager to add a couple new items to FTL random reward lists (I'll keep it small): warp core, shield generator, sensor matrix, maneuvering thrusters, etc. Probably one new item for each system on a ship. Following FTL's Crystal Pod being an augment, these new items will be augments. You'll then store them in the cargobay. I also may add items similar to 'drone blueprints' (though they will be augments) that 'unlock' recipes when used in the Dry Dock program.

Second, a recipes.xml will contain recipe 'blueprints' modeled after FTL's blueprint system. Each recipe will contain the object it creates and then a list of the ingredients it needs to create that object. (Ex: Shields System requires shield generator + 30 scrap). (As well as a boolean value whether the recipe is unlocked or hidden by default). For each type (system, ship, etc) I'll make a generic recipe for items that don't have a predefined recipe (like a custom ship). Ex: Generic ship requires warp core and 60 scrap. I'm debating whether to add this to the FTL mod package or place the xml file in my jar's resource folder. I want it to be easy for modders to make a recipe for their custom ship and append it to recipes.xml so people can use the program to build their ship. That makes me think it'd be best to put recipes.xml into the mod package, so people can load their mod after recipes.xml and therefore extend the list.

Third, I'm going to edit FTL Homeworld's save parser to read/write mysterybytes at the end of Homeworld.sav to create and store an arraylist of what recipes have been unlocked for the player to use. That way, not all ships will be available for building from the start. For instance, Dry dock could look at the profile to see what ship's are unlocked, or will consume 'blueprint' augment items to unlock new ships. This will probably all take place on a "Science Station" tab where you'll also be able to break down an object to unlock it's blueprint, so you can build more of it.

Fourth, I want to create a DryDock tab that will read the recipes and allow you to build ships/add systems if you have the resources. This will be modeled after FTL Profile Editor's ship layout tab, but use resources.
-----
So, that's the plan in my head. I'm going to tune up cargo bay, and then start tinkering with it. Does anyone have thoughts/ ideas/ advice/ limitations I've missed?
Thanks!
Ice
Image
iceburg333
Posts: 67
Joined: Tue Jun 25, 2013 8:52 pm
Contact:

Re: [Program] FTL Homeworld v2.0

Postby iceburg333 » Tue Aug 06, 2013 7:59 pm

Hey all, I'm having trouble getting items to list their count. (EX: "Hull Missles x 2"). I have them displaying properly, but I'm getting a null pointer when I try to trade them from ship to ship. This is a short snippet of the crash site (starting at line 623), but the full code can be found on github-cargobay.

Code: Select all

//Decrease count
         //TODO Crashing here!? - not finding test in the map, why not?
         String test = w.getWeaponId();
         int testVal = startMap.get(test);   //Crashes on this line
         
         
         if (testVal > 1) {
            startMap.put(w.getWeaponId(), (startMap.get(w) - 1));
            ((WeaponItem) startBox.getSelectedItem()).setTitle(
                  DataManager.get().getWeapon(w.getWeaponId()).getTitle()
                    + " x"+ startMap.get(w));
         }
         else {
            startMap.remove(w);
            startBox.remove(startBox.getSelectedIndex());
         }

During initialization, keys are added to the startMap (startmap is either shipWeaponMap or tradeWeaponMap). This is a snippet of them being added, starting on line 466:

Code: Select all

//Convert weapons list to string array for combo box - use hashmap for count
   public ArrayList<WeaponItem> weaponToString(ShipState state, HashMap<String, Integer> map) {
      ArrayList<WeaponItem> al = new ArrayList<WeaponItem>();   
      map = new HashMap<String, Integer>();
      //String s = new String("No Weapons!");
      if (state.getWeaponList().size() > 0){
         for (WeaponState w: state.getWeaponList()) {
            //multiple missles = Hull Missiles x2
            if (map.containsKey(w.getWeaponId())) {               
               //increase the item's count
               map.put(w.getWeaponId(), (map.get(w.getWeaponId()) + 1));
            }
            else {
               //add the first item
               map.put(w.getWeaponId(), 1);            
            }
            
         }
         //convert hashmap to string
         Iterator it = map.entrySet().iterator();
          while (it.hasNext()) {
              Map.Entry pairs = (Map.Entry)it.next();
             // System.out.println(pairs.getKey() + " = " + pairs.getValue());
              WeaponState w = new WeaponState((String)pairs.getKey(), false, 0);
              al.add(new WeaponItem(w, DataManager.get().getWeapon(w.getWeaponId()).getTitle()
                    + " x"+ pairs.getValue()));
            //  it.remove(); // avoids a ConcurrentModificationException
          }
      }

I realize that to follow this and debug it, it's all over the place and rather confusing, but as I seem to be stuck I'll ask anyway. Can anyone point me in the right direction/ give me some ideas how to solve my problem? It seems like somehow my map is losing it's keys by the time I try to change it by trading items....


EDIT: Nevermind, I think I got it. Using system.printline I was able to find where it was going null again. Commenting out

Code: Select all

map = new HashMap<String, Integer>();
fixed it. I think.... :D
gosenbach
Posts: 1
Joined: Tue Aug 06, 2013 9:58 pm

Re: [Program] FTL Homeworld v2.0

Postby gosenbach » Tue Aug 06, 2013 9:59 pm

I see a bit of TW2002 in your screenshots :) Love it.
User avatar
kartoFlane
Posts: 1479
Joined: Mon Jan 14, 2013 10:20 pm

Re: [Program] FTL Homeworld v2.0

Postby kartoFlane » Tue Aug 06, 2013 11:29 pm

public ArrayList<WeaponItem> weaponToString(ShipState state, HashMap<String, Integer> map) {
....ArrayList<WeaponItem> al = new ArrayList<WeaponItem>();
....map = new HashMap<String, Integer>();
.......

Well, yeah, you were essentially overwriting the argument with a new HashMap each time you called the function.

Regarding the previous post, well, that's some Overdrive-sized ideas right there. You'll essentially be creating a whole meta-mod/extension for FTL, instead of a simple utility. I think you should read about the dreaded Scope Creep ;)
Best of luck, though.

The hangar is pretty buggy though. Everything looked fine on the first launch, I've sent all stuff on my ship to the hangar. Now I open the hangar again, and most of the Swing UI elements are not even showing up.
Superluminal2 - a ship editor for FTL

Who is online

Users browsing this forum: apposl and 48 guests