Sprite Sheet Importer

by DarkCampainger
Quickly import sprite sheets into full movie icon_states using a simple markup
ID:920994
 
/* ********************************************************* /
_____ _ __ _____ __ __
/ ___/____ _____(_) /____ / ___// /_ ___ ___ / /_
\__ \/ __ \/ ___/ / __/ _ \ \__ \/ __ \/ _ \/ _ \/ __/
___/ / /_/ / / / / /_/ __/ ___/ / / / / __/ __/ /_
/____/ .___/_/ /_/\__/\___/ /____/_/ /_/\___/\___/\__/
/_/
____ __
/ _/___ ___ ____ ____ _____/ /____ _____
/ // __ `__ \/ __ \/ __ \/ ___/ __/ _ \/ ___/
_/ // / / / / / /_/ / /_/ / / / /_/ __/ /
/___/_/ /_/ /_/ .___/\____/_/ \__/\___/_/
/_/
*/
//////////////////////////////////////////////////////////

Created by DarkCampainger
Version 1.0 / August 9, 2012

"' This tool allows you to import a spritesheet by defining
"' the sequence of states as they appear in the source image.
"'
"' The different directions and even frames for any individual
"' state do not need to be adjacent.
"'
"' The following can be defined:
"'
"' - Global icon width, height, spacing, margins, and scan order
"'
"' - Icon state name, movement flag, rewind flag, directions,
"' frames, and delays
"
"' You use the importer by writing a 'blueprint' script that lays
"' out the states.
"'
"' See 'skeleton.txt' and 'skeleton.png' for an example blueprint.
"'
"' Blueprints start with a header that defines the global params:
"'
// # Defines the width of each state
//
## Width: 32
//
// # Defines the height of each state
//
## Height: 32
//
// # Spacing defines the INTERNAL spacing between each state.
// # First number is the horizontal spacing, second is vertical.
// # Spacing is NOT applied around the outer edges of the
// # sprite sheet (hence it being "internal" spacing)
//
## Spacing: 0 0
//
// # Margin defines the external margins around the edges of the
// # sprite sheet. The margins can be specified individually
// # in this order: top, right, bottom, left.
//
## Margin: 0
//
// # Order defines how the the importer moves over the sprite sheet.
// # The first value is the primary direction, followed by the
// # secondary direction.
// # Valid values are ltr (left-to-right), rtl (right-to-left),
// # ttb (top-to-bottom), and btt (bottom-to-top).
//
## Order: ltr, ttb
//
//
"' After the header you define the strips of state data:
//
// # Here's all the options used at once:
//
## "StateName", Movement, Rewind, (S,N,E,W), 8, (1,4,2,1)
//
// # Each line must start with the state's name in quotes
// #
// # The following can optionally be defined (in this order):
// # Movement / M - Load strip as part of movement state
// # Rewind / R - Make state play in reverse
// # (S,N,E,W) - Directions in strip (S,N,E,W,NE,NW,SE,
// # and/or SW). You can leave off the parens
// # if its a single direction
// # 8 - Number of frames in the state
// # (1,4,2,1) - Delays for each frame (unspecified delays
// # default to the last set delay). You can
// # leave off the parens if its a single delay
// #
// # If you define the frame delays, you must specify the
// # number of frames
// #
// # Based on these strips, the importer moves from grid cell to
// # grid cell (based on the order in the header) pulling out
// # the required number of sprites for each strip definition.
// #
// # If a state's directions or frames aren't located sequentially
// # in the sprite sheet, you can define their strips separately
// # and they will be correctly combined.
Thing looks incredibly promising. It will be VERY useful for my games. Thank you sir.
In response to Pyro_dragons
Glad to hear it! Let me know if there's any other features you need.
Bravo! A much needed alternative to RPG2DMI by Falacy (Not saying his is bad)
In response to Yusuke13
Thanks :)

You know, I thought he had one, but I couldn't find it when I originally went looking for it. Now I see it.

It look like our tools are pretty complimentary: mine for those who are comfortable working with text, and his for those who prefer a GUI.

I considered a GUI approach myself, but decided text would be faster for my needs. It's especially handy when you use a tool like Notepad++ with rectangular selections and regex.
This is kind of a stretch, but would it be possible to also have an option to load single files in sequence into an icon or icon state?

What I mean is when sprites are rendered as single frames in separate files, with the same file name and an incrementing number at the end of it. I have a couple different effects programs and one does it this way while the other does it as separate files. This would be handy for me, and others I would imagine.

Not sure how feasible it is though.
In response to Pyro_dragons
That should be feasible. I'll have to think about how I want it to work... whether it should be specified in the script or just run from a different verb.
Perhaps a quick alert before the file choice? To choose "Load Sprite Sheet" or "Load Files in Sequence". Something along those lines perhaps.
How are you calculating the Margin and spacing on the skeleton.png. If I knew that I could get this to work a lot better. I have tried a few different things to figure out the spacing and Margins, but it still comes out with incorrect allignment.
In response to Akando5959
Hey Akando5959,

I uploaded an image showing how the margins and spacing work:
http://www.byond.com/games/hubpic/102751_12878.png

The only strange thing is that the 'spacing' isn't applied around the outside edge of the image. I did that because it seemed easier for allowing sprite sheets that were offset a bit.

Let me know if you have any other questions!