SpriteAligner - Tool for aligning sprites directly in NFO

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

SpriteAligner - Tool for aligning sprites directly in NFO

Post by AndersI »

I've made a small program - SpriteAligner - that reads an NFO file and gives you an easy way of aligning your train sprites. It is of course still Beta, and it is only tested on trains, so far.

Please try it out, and let me know what you think!

SpriteAligner version 1.0 (Windows.exe, but probably works under Wine)

Version
1.01 - Manage relative paths, crude 'tile limits' indicator
1.02 - Preserve eol comments, fix version number, spelling correction
1.03 - *Actually* (?) manage relative paths, fix cache error
1.04 - Yet another try on the relative paths
1.05 - Load PCX with odd byte counts, file name display
1.06 - Confirmation questions to minimize data loss
1.07 - Wallyweb's templates for SG, NG, RV
1.08 - Fixed loading of template image
Attachments
Example66.png
Example66.png (13.01 KiB) Viewed 6190 times
SpriteAligner.zip
(269.1 KiB) Downloaded 190 times
Last edited by AndersI on 23 Jul 2009 15:24, edited 9 times in total.
User avatar
DJ Nekkid
Tycoon
Tycoon
Posts: 2141
Joined: 30 Nov 2006 20:33

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by DJ Nekkid »

i cant say more then ...
:bow: :bow: :bow: :bow: :bow: :bow: :bow: :bow:

but can i make a feature request? :)

a "gray" box in the background of the sprite to show where it "should be", along perhaps with a small arrow
Member of the
ImageImage
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by planetmaker »

wow, cool :)
May I make a feature request similar to DJNekkid? It'd be cool, if the tile boundaries would be shown so that I get an idea how it relates to the actual tile.
User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by AndersI »

DJ Nekkid wrote:a "gray" box in the background of the sprite to show where it "should be", along perhaps with a small arrow
planetmaker wrote:It'd be cool, if the tile boundaries would be shown so that I get an idea how it relates to the actual tile.
That's the tricky part. First of all, it depends on the shortening of the sprite, then it depends on what you are going to connect. A steamer + tender might have a very 'strange' alignment, looked at individually.

The program isn't smart at all, it doesn't know anything about the sprite, just that it is a part of an image file, so it's not very easy to 'know how it should be'.

All I know is that a 32px sprite should be centered :-)

Anyone is welcome to draw a template, though, I'll be happy to include it as a background picture. Actual pixel scale, please, the program enlarges the view.

Maybe one should be able to load different template images? I'm not at all sure that what goes for trains is good for cars and trams?
User avatar
XeryusTC
Tycoon
Tycoon
Posts: 15415
Joined: 02 May 2005 11:05
Skype: XeryusTC
Location: localhost

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by XeryusTC »

Hmm, imo these kind of prgrams are only useful if it knows about the boundingbox that the sprite is put in. I've seen quite some trains being aligned to the rails but not to it's bounding box making it look very odd when you attach wagons etc.
Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)
Image
OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone
Image Image Image Image Image Image Image
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by DaleStan »

It doesn't seem to understand real-sprite lines of this format:

Code: Select all

   41 sprites/PlaneSetw.pcx 674 8 09 1 1 0 0
   42 sprites/PlaneSetw.pcx 690 8 09 1 1 0 0
I think it's a safe assumption that if you strip the first directory of relative paths, then you'll have a path relative to the NFO. Or maybe prepending "../" would be safer/better/easier.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by AndersI »

No, for the moment only full absolute paths work because of my Q&D IsRealSprite(...). And if/when I manage relative paths, I don't really understand why they shouldn't relate to the directory where the NFO is found? Is this some grfcodec quirk?
frosch
OpenTTD Developer
OpenTTD Developer
Posts: 988
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by frosch »

AndersI wrote:Is this some grfcodec quirk?
Grfcodec does not interpret relative paths relative to the nfo file, but relative to the directory where grfcodec is run from :)
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by AndersI »

DaleStan wrote:It doesn't seem to understand real-sprite lines of this format:

Code: Select all

   41 sprites/PlaneSetw.pcx 674 8 09 1 1 0 0
   42 sprites/PlaneSetw.pcx 690 8 09 1 1 0 0
I think it's a safe assumption that if you strip the first directory of relative paths, then you'll have a path relative to the NFO. Or maybe prepending "../" would be safer/better/easier.
Should be OK now (ver 1.01, see first post). I followed the first part of your suggestion. Please test/break it :-)
User avatar
Ammler
President
President
Posts: 953
Joined: 18 Jun 2006 18:18
Location: Switzerland
Contact:

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by Ammler »

Tried your tool with wine, but wasn't able to see the sprites, how do I need to run it to see the sprites?
Maybe you could make a debug field (which is editable) to see the current location, where the sprites relative to will be.

Greets
Ammler
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by DaleStan »

First the bug: When modifying the line

Code: Select all

   41 sprites/PlaneSetw.pcx 674 8 09 1 1 0 0 // something here
The comment is clobbered, rather than changing the xrel and yrel. If the comment is only "// something", the result is worse; the new xrel and yrel replace '//' and 'something'.
The workaround is obvious: "Don't do that, then."

Incorrect sprite numbers worked just fine.

Then, a couple warts:
  • It freezes unpleasantly when loading large (in my case, ~1MB) PCX files, and it apparently reloads the file every time a new sprite is selected.
  • The UI is not particularly discoverable. The button that looks to me like a calculator is particularly bad.
  • The version number in the About window does not match the version number in the title bar.
  • Again in the About window, the correct spelling of "alignment" has only one 'e'.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by AndersI »

First post updated with version 1.02.
DaleStan wrote:The comment is clobbered, rather than changing the xrel and yrel
Fixed.
Incorrect sprite numbers worked just fine.
Is this good or bad? I don't actually understand what you mean.
It freezes unpleasantly when loading large (in my case, ~1MB) PCX files, and it apparently reloads the file every time a new sprite is selected.
It is expected to freeze once for each new file, it's caching the image files in memory. This works for me in my testing, where all sprites are in the same file (haven't had the time to test other combinations). I can click and hold down the down-arrow button and see all the trains whirl around on the screen, one after another (I even had to add a little sleep() to be able to see them good). Will try to find a faster PCX loader - the current one was ready and available with no additional work for me.

Feel free to PM me a NFO/PCX combo that reloads the file for each sprite, it's probably a bug in the cache handling...
The UI is not particularly discoverable. The button that looks to me like a calculator is particularly bad.
That's the (non-functional) auto-align button. I've hidden it for the time being.
Edit: At least I thought I had hidden it, but it's still visible - oh well...
The version number in the About window does not match the version number in the title bar.
Again in the About window, the correct spelling of "alignment" has only one 'e'.
Fixed.

Thanks!
Last edited by AndersI on 13 Jun 2009 15:47, edited 2 times in total.
User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by AndersI »

Ammler wrote:Tried your tool with wine, but wasn't able to see the sprites, how do I need to run it to see the sprites?
Maybe you could make a debug field (which is editable) to see the current location, where the sprites relative to will be.
It could be the same problem that DaleStan reported with relative path names in the NFO, please test with the new version (1.02). If that's not the case, I don't know, can you PM me a NFO/PCX the gives you problems?

Has anyone else managed to run it with Wine? I don't have a linux computer available, so I can only go on what other people tell me. My BlockCAD program is reported to work on wine, and this program is using graphics in exactly the same way, so I had my hopes up.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by DaleStan »

AndersI wrote:
DaleStan wrote:Incorrect sprite numbers worked just fine.
Is this good or bad? I don't actually understand what you mean.
Good. I fed it out-of-order and not-even-possibly-valid sprite numbers (specifically, I numbered several consecutive sprites 43, 44, 405, -46, 47) and it didn't choke.
AndersI wrote:
DaleStan wrote:It freezes unpleasantly when loading large (in my case, ~1MB) PCX files, and it apparently reloads the file every time a new sprite is selected.
It is expected to freeze once for each new file, it's caching the image files in memory.
Progress bars FTW. Not that they're easy to pull off.
Since it works for you and not for me, I'm guessing that the caching only breaks for relative paths. See attached for a test case; as far as I can tell, it doesn't matter which two sprites are selected; it will always reload the file when the second is selected.
AndersI wrote:Thanks!
No, thank you. It's so nice to work with programmers who fix bugs promptly and without objecting that I'm doing something stupid.
Attachments
PlaneSet.zip
(288.06 KiB) Downloaded 164 times
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Ammler
President
President
Posts: 953
Joined: 18 Jun 2006 18:18
Location: Switzerland
Contact:

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by Ammler »

Seems to work well with a fresh decoded grf, but doesn't work with sources like 01wagons.pnfo.

But then, you have very huge pcx files, which makes it very slow as it seems to reload everytime, as dalestan mentioned.
(Decoding with -h, seems not working, either.)

Greets
Ammler
User avatar
AndersI
Tycoon
Tycoon
Posts: 1732
Joined: 19 Apr 2004 20:09
Location: Sweden
Contact:

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by AndersI »

New version (1.03) in first post.

DaleStan: I've fixed the cache error. Stupid me was storing the relative name in the cache, but looking for the full name...

Ammler: I hope I've fixed that problem now, but I'm not sure. Where in the file tree is your .pnfo file stored (compared to the image files)?

Also, the .pnfo file extension, is that something 'universal' or is it only you? I could add that extension to the list, to save you some clicks. Any other often used extensions?
User avatar
Ammler
President
President
Posts: 953
Joined: 18 Jun 2006 18:18
Location: Switzerland
Contact:

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by Ammler »

AndersI wrote:New version (1.03) in first post.
:shock: fast!
Ammler: I hope I've fixed that problem now, but I'm not sure. Where in the file tree is your .pnfo file stored (compared to the image files)?

Also, the .pnfo file extension, is that something 'universal' or is it only you? I could add that extension to the list, to save you some clicks. Any other often used extensions?
Well, it is from the existing Makefile templates of Aegir or whoever, we have hnfo and pnfo, hnfor needs to be merged, pnfo go thought preprocessor or such alike. As you can chose All files, that isn't very important.

But I guess, the more important fact is that the nfo files can be on very different locations, maybe it would be helpful to have the possibilty to change your path? I.e. if you click on the link you see where it is, and you can also see, where the pcx is saved.

Something else, (not essential either) the pcx looks like you assume DOS? (pinky)

Greets
Ammler
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by DaleStan »

My windows-paletted PCX files work just fine; I'd upload a test case.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Re: SpriteAligner - Tool for aligning sprites directly in NFO

Post by Bilbo »

Looks nice.

Is there planned support for aligning also other graphics? Like houses, signals, bridges... - you'll just need different "synchronization" background.
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: Google Adsense [Bot] and 44 guests