[Tool] FTL Ship Editor: Superluminal [NOT UPDATED TO AE]

Discuss and distribute tools and methods for modding. Moderator - Grognak
Post Reply
Vhati
Posts: 792
Joined: Thu Oct 25, 2012 12:01 pm

Re: [Tool] Yet Another FTL Ship Editor: Superluminal - u6-2-

Post by Vhati »

:|
Vhati wrote:
I've been googling for like 3 hours, but I still have no idea how to create the bundle for Mac on Windows :/
They do their best to make it mysterious, but it's conceptually not much cleverer than a batch in a folder.
I'll write something up
Time to drink again from the firehose of knowledge...

I no longer have access to a mac to tease out the bare minimum, so what follows is what worked for me in an old project.

Code: Select all

ABC_v123/
|-ABC.app/
| |-Contents/
|    |-MacOS/
|    | |-runme
|    |-Resources/
|    | |-appIcon.icns
|    | |-ABC.jar
|    | |-some-lib.jar
|    | |-another-lib.jar
|    |
|    |-Info.plist
|    |-PkgInfo
|
|- readme.txt

I used IcoFX to create a 128x128 32bit color icon.
That's the only Windows editor I know of that can save Mac *.icns files. The link is to the last freeware version.

After sketching, I added alternate resolutions (Icon menu-New Image). IcoFX offers to fill them with scaled down copies, but you can make each different so they look good small.
32x32 32bit, 32x32 8bit, 32x32 1bit
16x16 32bit, 16x16 8bit, 16x16 1bit
An icon is probably required.


PkgInfo

Code: Select all

APPL????
No newline. Those really are question marks, not unprintable characters.
This file might be deprecated and unimportant by now.

Info.plist

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>English</string>
    <key>CFBundleExecutable</key>
    <string>runme</string>
    <key>CFBundleGetInfoString</key>
    <string>ABC 1.2.3</string>
    <key>CFBundleIconFile</key>
    <string>appIcon.icns</string>
    <key>CFBundleIdentifier</key>
    <string>com.blah.ABC</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>My ABC Bundle</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.2.3</string>
    <key>CFBundleSignature</key>
    <string>????</string>
    <key>CFBundleVersion</key>
    <string>1.2.3</string>
    <key>LSHasLocalizedDisplayName</key>
    <true/>
    <key>NSHumanReadableCopyright</key>
    <string>Copyright 2011 John Doe</string>
    <key>LSEnvironment</key>
    <dict>
        <key>CUSTOM_ENVIRONMENT_VARIABLE</key>
        <string>The var's value. runme can check these for...</string>
        <key>ANOTHER_VARIABLE</key>
        <string>... special behavior when launched via the bundle.</string>
        <key>AND_SO_ON</key>
        <string>LSEnvironment and its dict can be omitted.</string>
    </dict>
</dict>
</plist>
Imagine those as key-value pairs. Unix-style LF line-endings.

runme

Code: Select all

#!/bin/sh
# You can run this script directly in a terminal, but only from a directory
# outside the bundle.

# Chop off a few dirs from the full path used to run the executable.
# Not necessarily an absolute path, but good enough to navigate.
CONTENTDIR="${0%/*/*}";
MAINDIR="${CONTENTDIR%/*/*}";
RESDIR="${CONTENTDIR}/Resources";

CLASSPATH="${RESDIR}/ABC.jar";
CLASSPATH="${CLASSPATH}:${RESDIR}/some-lib.jar";
CLASSPATH="${CLASSPATH}:${RESDIR}/another-lib.jar";

cd "${MAINDIR}";
java -classpath "${CLASSPATH}" -Xdock:icon="${RESDIR}/appIcon.icns" MainClass >log.txt 2>&1;
Unix-style LF line-endings. Needs to be marked executable, a concept alien to both Windows and zip files.
(see tar below)


To distribute, you'll need a tar command (attached) to set execute permissions (--mode), and by convention, gzip to shrink it.

Code: Select all

tar.exe --create --mode=777 -f "archive.tar" "ABC_v123"
gzip.exe archive.tar
OR
tar --create --mode=777 -f - "ABC_v123" | gzip.exe > archive.tar.gz
Note that in the second example, tar's stdout is piped into gzip, whose stdout is redirected to a file. If either command were allowed to print to the screen, your terminal would fill with a binary mess.

The first example's harmless, because they're acting on a filename instead of a stream. Tar writes the file, and gzip quirkily writes a new file with a similar name.


Following that guide you should yield a folder that OSX "helpfully" makes difficult to see inside,
but can be double-clicked to execute 'runme'.
Last edited by Vhati on Sat Feb 09, 2013 11:02 pm, edited 8 times in total.
Pumpkins10
Posts: 12
Joined: Thu Jan 31, 2013 8:13 pm

Re: [Tool] Yet Another FTL Ship Editor: Superluminal - u6-2-

Post by Pumpkins10 »

@kartoflane
I've been googling for like 3 hours, but I still have no idea how to create the bundle for Mac on Windows :/
I'm not much of a coder, but I have a mac. the above quote sounds like you would be able to do it if you had one.

Would it be possible if you or even someone else on the forum make some instructions on how to make the bundle in OSX? then you could be able to finally distribute a working mac friendly copy. :)
Splitstack
Posts: 9
Joined: Sat Jan 12, 2013 4:46 am

Re: [Tool] Yet Another FTL Ship Editor: Superluminal - u6-2-

Post by Splitstack »

So I tried loading my hull image and any time I do the program crashes/closes without any messages. Works fine if I use a picture that came with the game.

This is the error log I get.

java.lang.StringIndexOutOfBoundsException: String index out of range: -41
at java.lang.String.substring(Unknown Source)
at com.kartoflane.superluminal.core.ShipIO.loadImage(ShipIO.java:1084)
at com.kartoflane.superluminal.core.Main$20.widgetSelected(Main.java:2533)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Unknown Source)
at org.eclipse.swt.widgets.Display.readAndDispatch(Unknown Source)
at com.kartoflane.superluminal.core.Main.open(Main.java:373)
at com.kartoflane.superluminal.core.Main.main(Main.java:260)


Okay managed to fix my problem, turns out I needed to name my hull image file "anything_base." Maybe I missed that somewhere in the read me.
Last edited by Splitstack on Fri Feb 08, 2013 3:41 am, edited 1 time in total.
Lord0fHam
Posts: 54
Joined: Sat Feb 02, 2013 1:10 am

Re: [Tool] Yet Another FTL Ship Editor: Superluminal - u6-2-

Post by Lord0fHam »

kartoFlane wrote:So the app launched, but then crashed on the first method of the drawing function:

Code: Select all

1722    c = e.display.getSystemColor(SWT.COLOR_WHITE);
1723    e.gc.setForeground(c);
1724    c.dispose();
Interestingly, it set the font properly earlier, and didn't freak out:

Code: Select all

1159    e.gc.setFont(appFont);
Exception text says that argument is invalid, so that probably means that retrieving system colors on Macs doesn't work as it is supposed to (it returns null / disposed)... Guess defining the colors via RGB will fix it. I'll correct the code for that and edit this post when I'm done.

Edit: alright, try this. Corrected the function to directly create colors from RGB, instead of trying to get system colors (which apparently caused problems when the colors were disposed). Also, it comes with the SWT library packed inside the jar, so that it should be possible to run it completely on its own.
I downloaded this and I can run it fine through the command line. It opens! BUT, there is still a major issue. It opens fine and sits there, but when I select new player or enemy ship, it sits for about 5 seconds and then crashes. This is the error message from trying to make a new player or enemy ship:
java.lang.IllegalArgumentException: Argument not valid
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.SWT.error(Unknown Source)
at org.eclipse.swt.graphics.GC.setForeground(Unknown Source)
at com.kartoflane.superluminal.elements.FTLShip.drawShipAnchor(FTLShip.java:360)
at com.kartoflane.superluminal.core.Main$4.paintControl(Main.java:1701)
at org.eclipse.swt.widgets.TypedListener.handleEvent(Unknown Source)
at org.eclipse.swt.widgets.EventTable.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Display.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Widget.sendEvent(Unknown Source)
at org.eclipse.swt.widgets.Control.drawWidget(Unknown Source)
at org.eclipse.swt.widgets.Canvas.drawWidget(Unknown Source)
at org.eclipse.swt.widgets.Widget.drawRect(Unknown Source)
at org.eclipse.swt.widgets.Canvas.drawRect(Unknown Source)
at org.eclipse.swt.widgets.Display.windowProc(Unknown Source)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSend_bool(Native Method)
at org.eclipse.swt.internal.cocoa.NSRunLoop.runMode(Unknown Source)
at org.eclipse.swt.widgets.Display.sleep(Unknown Source)
at com.kartoflane.superluminal.core.Main.open(Main.java:380)
at com.kartoflane.superluminal.core.Main.main(Main.java:262)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
logout



Hopefully this helps you make a Mac version. At least it launches though!
Image
User avatar
kartoFlane
Posts: 1488
Joined: Mon Jan 14, 2013 10:20 pm

Re: [Tool] Yet Another FTL Ship Editor: Superluminal - u6-2-

Post by kartoFlane »

Code: Select all

1084    Main.ship.imageName = path.substring(path.lastIndexOf(pathDelimiter)+1, path.lastIndexOf("_"));
Aha! that's the problem. An oversight on my part, it's quite easy to correct, and you can fix the issue on your own, too - just add an underscore (the _ sign) at the end of the file, right before the .png, and it'll load just fine :)
Vhati wrote:firehose of knowledge
Lmao. I've got to admit it's a pretty accurate description of what's been going on here lately. Can't say I'm complaining, tho :P I'll try to create the Mac package tomorrow

@Pumpkins10
It definitely would. As of now, I have almost no idea what the package should contain, and what can be achieved with it (haven't read through your entire post yet, Vhati - gonna do it tomorrow :X). Even if the instructions are for a Mac, I guess it'll be possible to reuse at least some of them.

@LordOfHam
Ah, crap, I edited the main paint method, but I forgot about classes that paint themselves -- give me ca. 5 minutes to get it up.
Edit: it's up, here. Should be fixed now, this error at least.
Last edited by kartoFlane on Fri Feb 08, 2013 2:32 am, edited 2 times in total.
Superluminal2 - a ship editor for FTL
Lord0fHam
Posts: 54
Joined: Sat Feb 02, 2013 1:10 am

Re: [Tool] Yet Another FTL Ship Editor: Superluminal - u6-2-

Post by Lord0fHam »

deleted
Last edited by Lord0fHam on Fri Feb 08, 2013 6:46 am, edited 1 time in total.
Image
Lord0fHam
Posts: 54
Joined: Sat Feb 02, 2013 1:10 am

Re: [Tool] Yet Another FTL Ship Editor: Superluminal - u6-2-

Post by Lord0fHam »

I just posted, but for some reason it had to be reviewed, so I am doing this instead. The old one will probably show up later.

I'm not sure if I understand you correctly, but do you mean to add the "_" at the end of the .png file that I am using for my ship image? If so I'll do that, but I meant it crashes even before I can select an image. The crash happens just after I select new player (or enemy) ship.
Image
Lord0fHam
Posts: 54
Joined: Sat Feb 02, 2013 1:10 am

Re: [Tool] Yet Another FTL Ship Editor: Superluminal - u6-2-

Post by Lord0fHam »

Disregard the above, I renamed the image with and underscore in it and it loaded fine. It appears you understood what I meant fine. Sorry I doubted you. I'll mess around with it some more to see if I get anymore crashes, otherwise the Mac version seems to be ready!
Image
Lord0fHam
Posts: 54
Joined: Sat Feb 02, 2013 1:10 am

Re: [Tool] Yet Another FTL Ship Editor: Superluminal - u6-2-

Post by Lord0fHam »

I haven't done much in the way of testing, but I have a question. Where should I align my ship in relation to these green and red lines? What are they and the blue box?
Also here's a bug. The properties menu needs to be extended downwards a little bit. No, I didn't fail at the screenshot, that's actually what it looks like.
Here is a link to see the 2 things I am talking about.
http://imgur.com/a/4LnCJ#0
(If you were wondering, yes that is the Pillar of Autumn from Halo!)
Image
User avatar
kartoFlane
Posts: 1488
Joined: Mon Jan 14, 2013 10:20 pm

Re: [Tool] Yet Another FTL Ship Editor: Superluminal - u6-2-

Post by kartoFlane »

The blue box is an anchor which is used to move the entire ship around. It also serves the purpose that the entire ship is saved in relation to it, so in that it can be used to set the ship's offset (if you create a room two grid cells to the right of the axis, in the exported layout.txt file the ship will have X offset of 2). Basically all of the features are described in the documentation I wrote, linked in the first post - I've been to lazy to update it for 6-2, though :E The anchor did not undergo any changes, however.

And ugh, I really should get myself a Mac VM of sorts (Vagrant?) to test out how the UI aligns. Or a full-fledged Mac, at best. I'll never get the UI right without it ><

Also, it's been years since I've last played Halo. I remember the name, but I almost completely forgot what it was...
Superluminal2 - a ship editor for FTL
Post Reply