Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Pages: [1] 2 3 ... 10

Author Topic: .ship/.variant editor  (Read 79906 times)

Redbull

  • Ensign
  • *
  • Posts: 15
    • View Profile
.ship/.variant editor
« on: December 27, 2011, 01:36:12 AM »

As a sort of intro to javascript I decided I'd write a ship editor, I think it turned out alright. Here is a picture;


Changelog
v5
  • Added upload functionality
  • Added graphical ship and variant listing
  • Improved loading of non-parsing variants
  • Moved ships, variants and their sprites to database
v4
  • Moved the whole shebang online
  • Added save as for the generated .ship/.variant files
  • Added load from file for ship sprites
  • Added load from list of standard ships/variants
  • Fixed compatability with Chrome
  • Moved weapon lookup to utilities

v3
  • Loads variants with malformed JSON
  • Added more information to weapon lookup

v2
  • Added cursor
  • Changed how variant weapon groups are assigned
  • Added weapon lookup
  • Added visible engine trails

Starfarer Ship Editor
Documentation (somewhat outdated)

I hope someone finds this useful and if you have any questions/comments go right ahead.
« Last Edit: January 19, 2012, 08:47:05 PM by Redbull »
Logged

Thana

  • Captain
  • ****
  • Posts: 289
    • View Profile
Re: .ship/.variant editor
« Reply #1 on: December 27, 2011, 01:39:58 AM »

Okay, this does look pretty good!  :)
Logged

Flare

  • Admiral
  • *****
  • Posts: 906
    • View Profile
Re: .ship/.variant editor
« Reply #2 on: December 27, 2011, 06:15:55 AM »

I am speechless ;D.
Logged
Quote from: Thana
Quote from: Alex

The battle station is not completely operational, shall we say.

"Now witness the firepower of this thoroughly buggy and unoperational batt... Oh, hell, you know what? Just ignore the battle station, okay?"

InfinitySquared

  • Commander
  • ***
  • Posts: 119
    • View Profile
Re: .ship/.variant editor
« Reply #3 on: December 27, 2011, 10:01:15 AM »

Dumb question. How do I get this to work? I already put it in the Starfarer directory. Also, I'm using Google Chrome if that matters.

ED: By trying to get it to work, I mean. It doesn't load .ship files (the button doesn't work), doesn't display the image I selected even when I already have a pre-prepared ship file selected.
« Last Edit: December 27, 2011, 10:08:36 AM by InfinitySquared »
Logged

Redbull

  • Ensign
  • *
  • Posts: 15
    • View Profile
Re: .ship/.variant editor
« Reply #4 on: December 27, 2011, 10:12:33 AM »

You should be able to open .ship files without any fuss by selecting them with the file input thingy and then clicking "Load ship". The JSON parser doesnt like the .variant files already in the game, since they have comments and some commas in odd places. If that's what you're doing you'll need to run it through jsonlint.com until it validates.

That all said, I've only tested it on the latest firefox (e: and Opera) so there may be cross-browser issues I havn't noticed. What exactly is it that's not working?

e2: Yeah, looks like it's not working in Chrome. Firefox and Opera both work, I havn't been able to test IE9 - I'm going to try to fix whatever issue chrome is having but for now it looks like you'll have to use another browser. Sorry.
« Last Edit: December 27, 2011, 10:37:28 AM by Redbull »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23986
    • View Profile
Re: .ship/.variant editor
« Reply #5 on: December 27, 2011, 10:52:36 AM »

Wow, very cool! That must have taken quite a bit of work.

I already put it in the Starfarer directory. Also, I'm using Google Chrome if that matters.

In Windows, it looks like you have to put it under Starfarer/starfarer-core. The Linux build has one less level. And yeah, looks like it's Firefox-only at the moment. I don't have IE9, but it doesn't like IE8.


Took me a little while to figure out how it works - in particular, "set from clicked". What it looks like it does is get the *last* point you clicked on in the ship view - I expected it to require you to click on a point. It might be helpful if the "clicked" point was highlighted somehow on the ship view.

Also, it would be great if this let you create a whole new ship - i.e., load up just the image, without a data file.

These are pretty minor though, good stuff!
Logged

Zarcon

  • Captain
  • ****
  • Posts: 329
    • View Profile
Re: .ship/.variant editor
« Reply #6 on: December 27, 2011, 11:03:18 PM »

As a sort of intro to javascript I decided I'd write a ship editor, I think it turned out alright. Here are some pictures;

I believe it's easy to use, then again I made it so my view might not be exactly objective. My main gripe at this point is that the variant interface is a little clunky but apart from that it should be straight-foward. To make a new ship you have to load up an existing one and remove the hardpoints etc.

Get it here
Notice that you have to put starfarer.html in your starfarer directory, for example games/starfarer/starfarer.html for linux and games/starfarer/starfarer-core/starfarer.html for windows. This is because doing it any other way would involve massive amounts of file selecting or alternatively, and worse, redistributing the assets without permission.

I hope someone finds this useful and if you have any questions/comments go right ahead.

Very nice indeed, I feel foolish for asking, but how do I get the Reset All button to become a Save button?  I was able to load in my Desired .ship file, but then I could never get the Save button to show up, etc.  So I went ahead and copied out the JSON code that was generated, and made a new .ship file from that, and then did the same with the .variant file.  That worked fine, but clearly I missed the boat at some point, and is most likely an easier way to do this ha ha.  :)

Also, my methodology of downloading the starfarer.html was just to save the source of the website that you directed me to with the above link, was that the correct download approach?

Once again, this is a crazy cool little website you put together, very impressive, I just got a little confused trying to use it.  :)
Logged
There is no instance of a nation benefitting from prolonged warfare.
Thus it is that in war the victorious strategist only seeks battle after the victory has been won, whereas he who is destined to defeat first fights and afterwards looks for victory.

Zarcon

  • Captain
  • ****
  • Posts: 329
    • View Profile
Re: .ship/.variant editor
« Reply #7 on: December 28, 2011, 08:44:40 AM »

Hmm, on further review, I did figure out a way to use that raw JSON data you provide to copy/paste into .ship and .variant files directly, so I'm fine now.  :) 

And once I got my first heavily modified Onslaught in the game....wow.  I can only say thank you Redbull.  :)  ha ha

Also, Alex, I was able to test using larger amounts of Harpoon Missiles on fighters, wow, yeah they are pretty tight after-all.  BOOM!!!  Missiles have their uses.

 ;D
Logged
There is no instance of a nation benefitting from prolonged warfare.
Thus it is that in war the victorious strategist only seeks battle after the victory has been won, whereas he who is destined to defeat first fights and afterwards looks for victory.

Redbull

  • Ensign
  • *
  • Posts: 15
    • View Profile
Re: .ship/.variant editor
« Reply #8 on: December 28, 2011, 11:10:12 AM »

Quote from: Alex
Took me a little while to figure out how it works - in particular, "set from clicked". What it looks like it does is get the *last* point you clicked on in the ship view - I expected it to require you to click on a point. It might be helpful if the "clicked" point was highlighted somehow on the ship view.

Yeah, that is how it works. I agree that it could be implemented better and I'll try making it easier to use.

Quote from: Alex
Also, it would be great if this let you create a whole new ship - i.e., load up just the image, without a data file.

You can do this now, just put in the (relative) path to the sprite and go to town.

Quote from: Zarcon
how do I get the Reset All button to become a Save button?

I removed all the save buttons in favor of having it automatically save changes.

Quote from: Zarcon
So I went ahead and copied out the JSON code that was generated, and made a new .ship file from that, and then did the same with the .variant file.  That worked fine, but clearly I missed the boat at some point, and is most likely an easier way to do this ha ha.

No, you're doing it right. As far as I know, which isn't very since I'm learning javascript as I go, there isn't a way to give the data to the user as a file. If I'm wrong, I'd love to hear about it. Oh and speaking of the JSON window, you can edit that directly too if you want to.

Quote from: Zarcon
Also, my methodology of downloading the starfarer.html was just to save the source of the website that you directed me to with the above link, was that the correct download approach?

Yep!

I'm glad you people like it, and it seems like the biggest issue is that it's a bit hard to figure out. I'll write up some documentation after I've tracked down, or given up on, the Chrome bug.
« Last Edit: December 28, 2011, 11:11:47 AM by Redbull »
Logged

Zarcon

  • Captain
  • ****
  • Posts: 329
    • View Profile
Re: .ship/.variant editor
« Reply #9 on: December 28, 2011, 11:48:16 AM »

I'm glad you people like it, and it seems like the biggest issue is that it's a bit hard to figure out. I'll write up some documentation after I've tracked down, or given up on, the Chrome bug.

Btw, I'm not sure this helps, but I recently found out that Chrome doesn't seem to properly load .CSS files (or even CSS in the main html file) for dynamic HTML that is generated after the main page has already loaded, like for iFrames and such that work as containers/holders.  Chrome was giving me some grief on a website I was working on because of this.  Anyways, just a random note that may be unrelated to your issue with Chrome, heh heh.  :)

I can't wait to go home and fiddle with some more ship ideas tonight!  ha ha.
Logged
There is no instance of a nation benefitting from prolonged warfare.
Thus it is that in war the victorious strategist only seeks battle after the victory has been won, whereas he who is destined to defeat first fights and afterwards looks for victory.

Redbull

  • Ensign
  • *
  • Posts: 15
    • View Profile
Re: .ship/.variant editor
« Reply #10 on: December 28, 2011, 12:03:42 PM »

Yeah I think I figured it out. It seems like Chrome is much more restrictive towards local pages than the other browsers, which is why it won't work. This is to stop malicious local content but in our case it works against us.
Apparently you can "fix" it by using the switch --allow-file-access-from-files but I had no luck with that. The other way is to run a local http server and put it all on there. I hate to say it, but the easiest solution is probably to use another browser.
Logged

Zarcon

  • Captain
  • ****
  • Posts: 329
    • View Profile
Re: .ship/.variant editor
« Reply #11 on: December 28, 2011, 12:11:55 PM »

Yeah I think I figured it out. It seems like Chrome is much more restrictive towards local pages than the other browsers, which is why it won't work. This is to stop malicious local content but in our case it works against us.
Apparently you can "fix" it by using the switch --allow-file-access-from-files but I had no luck with that. The other way is to run a local http server and put it all on there. I hate to say it, but the easiest solution is probably to use another browser.

Yeah I just downloaded FireFox last night specifically for this, worked great for me.  :)    Btw, I highly recommend that everyone who can manage it, mod a fighter wing to fire several triple Harpoon missile launchers, and enjoy the devastation that results from that.  ha ha.   ;D
Logged
There is no instance of a nation benefitting from prolonged warfare.
Thus it is that in war the victorious strategist only seeks battle after the victory has been won, whereas he who is destined to defeat first fights and afterwards looks for victory.

Redbull

  • Ensign
  • *
  • Posts: 15
    • View Profile
Re: .ship/.variant editor
« Reply #12 on: December 28, 2011, 12:56:49 PM »

I put some light documentation up, check the link in the OP. If anyone has something they want me to add, or feel is unclear, just tell me.
Next up, making the variant editing less awkward.
Logged

moffrevenge

  • Ensign
  • *
  • Posts: 24
    • View Profile
Re: .ship/.variant editor
« Reply #13 on: January 10, 2012, 01:33:43 PM »

Hi, actually we can't open variant files?
Logged

Zarcon

  • Captain
  • ****
  • Posts: 329
    • View Profile
Re: .ship/.variant editor
« Reply #14 on: January 10, 2012, 01:44:59 PM »

Hi, actually we can't open variant files?

Hmm, that is tricky, that was a question or a statement?   ;D  heh heh 


Welp, the idea is that currently you use the editor to load in a .ship file and create a new .ship vile via the JSON code that the editor provides once you make your changes, just paste it into a notepad file ending with .ship, and then proceed to the second row of tabs for the variant, when you are done inputing the information then copy the contents of the JSON tab of the variant area into a new notepad file ending with .variant.

I find that using Control A on the raw JSON code does the trick nicely, to make sure I don't miss any of it when I copy it.

It is a little confusing, but it works currently for creating new ship types and then creating variants of that ship.  If you wanted to just make a plain .variant of an original game ship, then you could just load in that .ship file from the hull folder and skip the new .ship part, head to the variant row of tabs and go to town.

Also, you have to reference your new .ship file in the main ship file in the hull folder, I'll get some more details for ya once I get back to my home computer, but that is the best I can do from memory. 

Someone else might have said it better before I get the chance to re-reference the code/editor.  :)

If that made Zero sense, ignore me, ha ha, and Redbull will no doubt answer the question pretty soon, etc.

Good luck with getting into the editing, I have really enjoyed it personally.
Logged
There is no instance of a nation benefitting from prolonged warfare.
Thus it is that in war the victorious strategist only seeks battle after the victory has been won, whereas he who is destined to defeat first fights and afterwards looks for victory.
Pages: [1] 2 3 ... 10