Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Wed May 22, 2013 6:09 pm

All times are UTC




Post new topic Reply to topic  [ 32 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: NewGRF Editor
PostPosted: Thu Dec 06, 2012 12:01 am 
Offline
Engineer
Engineer
User avatar

Joined: Tue Aug 30, 2011 2:39 pm
Posts: 27
Location: Cambridge, England
Firstly, I'm sorry for writing an essay...

You may recall that last year I wrote NewGRF Viewer. That was basically a GUI dump of the contents of a NewGRF file. Wallyweb was kind enough to have a play with it. I made some efforts towards turning it into an editor but found that my basic UI design was unworkable for this purpose, and I abandoned the project. I restarted a couple of months ago, and have written NewGRF Editor. I hope some may find it useful.

Main features:

- Graphical user interface for NFO
- Complete(ish) representation of the GRF8 specification
- Writes directly to GRFs
- Reads existing GRFs
- GRFs can be exported as NFO - for testing against grfcodec (no escapes)
- Sprites can be exported as a PNG sprite sheet
- Sprites can be re-imported after modification
- Unicode strings
- String control codes in human readable format
- Currently only GRF container format 1

Some notes and caveats:

This is not a graphical NML tool. I really like the idea of a visual NML, but this would almost certainly preclude modifying existing GRFs, which was a key goal.

Though I have attempted to address every aspect of the specification, there are almost certainly some things I overlooked, forgot, didn't understand well enough, or implemented incorrectly. One or two things are not documented (e.g. advanced station layouts). There are some loose ends, and probably/definitely bugs, too. Action00 properties are stored in numerical order and can only appear once per action, which is more limited than the spec. I have one or two mitigations in mind, if necessary.

Users of GRFMaker should be more or less at home with the software, and there are a few places where the design is very clearly influenced by GRFMaker. Some of the custom controls for editing values need a little work, but they are functional. I'm quite happy with some bits of the UI, others not so much.

There is no image editing capability. People far cleverer than me have spent years developing any number of amazing tools for this purpose. The editor can import and export 8-bit PNG images, and maintains metadata so that they can be re-imported after subsequent editing. The palettes in the images are ignored.

I have no real experience in actually creating GRFs, so the UI might not always be the most sensible design for an experienced coder. I have tweaked a few, and OTTD seemed to like them. I have endeavoured to make all the data relatively simple to get at, but some of the data structures are rather involved. There might be simplifications or improvements which would not compromise supporting the whole specification. Aside from the coding aspect, I couldn't draw to save my life.

Cargos are a bit odd. There is a global table that is used if there is no cargo translation table in the GRF. I assumed at most one such table will be defined, and this allows me to toggle the global table on/off as necessary. Having two alternate translation tables would mess that up. Reading older GRFs will work, but there is sure to be some weirdness where old style cargo slots have been used.

Testing thus far has mostly comprised reading existing GRFs and knocking up dummy GRFs as I went through each pseudosprite. This does not amount to complete coverage of all possibilities. A *lot* more work is needed to confirm that the binary output is correct in all cases. I think the software is useable, but it's an alpha. There definitely needs to be more validation to avoid illegal or inconsistent GRFs (Action14s in the wrong place, more than one Action08, etc).

The project was developed in C++ using Qt4, and I'm releasing it under GPL3. I did all the development under Windows, but getting it running under Linux should in theory be straightforward. The source has some features that do not fill me with professional pride, but refactoring can wait. I would prefer a static release build, but it seems this is only allowed under Qt's commercial licence. It's a bit of a faff with Qt, to be honest.

Anyway, I think the software has now reached the point where it would really benefit from some feedback and bug reports. I had hoped to deliver something more polished, but I'm running out of steam.

If you are interested, please take a look in my dropbox (https://www.dropbox.com/sh/7te6csl7pxmalgf/K4lgj-iPTX). You'll need the Qt DLLs, and might have to run the MS redistributable installer. I think that's everything, but it's hard to be certain if you don't have a pristine machine to try it out on.

Cheers.


UnicycleBloke
Only an egg


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Thu Dec 06, 2012 1:42 am 
Offline
Route Supervisor
Route Supervisor
User avatar

Joined: Thu Oct 28, 2004 4:42 am
Posts: 456
Location: Portugal
Ok, just some quick thoughts:

I'm running W7 SP1 and the files you provided worked perfectly, just had to install VCRedist 2010.

Tried one old GRF and it opened fine, plus it's settings matched what I remembered about it (It's a russian GRF an225_gr.grf).

Tomorrow I'll look a bit more but I think the UI is nice plus the GRF settings look really easy to modify!


A+


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Thu Dec 06, 2012 9:50 am 
Offline
Tycoon
Tycoon

Joined: Fri Oct 23, 2009 7:35 pm
Posts: 1165
Location: Thoftkinwise Theedishland
I'd like to give compiling it on Linux a try - where can I find the source code?

_________________
--- My code and sprites may be used under the terms of the GPL v2 or newer, if I have not stated otherwise - no need to contact me beforehand --- Call them "track types", that's what they are ---
--- Developer for: NuTracks - Central European Train Set - Britrains --- Running/compiling for: Linux (32/64 bit x86, ARM) - Windows (32/64 bit) - OS X (32/64 bit x86) - Haiku ---

--- Need a file packer? 7-Zip --- Bypass web blockers? Tor --- BOINC - use your computing power to benefit science --- Unix in dispersible pellets, the formula for the future. ---
Image


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Thu Dec 06, 2012 10:03 am 
Offline
Engineer
Engineer
User avatar

Joined: Tue Aug 30, 2011 2:39 pm
Posts: 27
Location: Cambridge, England
@Digitalfox: Thanks. Good to know it's all there.

@oberhümer: Excellent! I'll zip up the repository and stick it in the dropbox when I get home. Perhaps I will install a VM and have a go, too. It's been on my list for quite a while.


UnicycleBloke


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Thu Dec 06, 2012 10:55 pm 
Offline
Engineer
Engineer
User avatar

Joined: Mon Jul 09, 2012 12:44 am
Posts: 108
Location: Surabaya, East java
Yet, UnicycleBloke when use for NewGRF Editor can give GRF anyone edit

_________________
Image
100 THREAD POSTING - December 7, 2012
My Screenshots My Chronology


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Fri Dec 07, 2012 12:44 am 
Offline
Engineer
Engineer
User avatar

Joined: Tue Aug 30, 2011 2:39 pm
Posts: 27
Location: Cambridge, England
I have spent my evening getting this working on a new Linux VM. I learnt a few things:

1. MSVC lets an awful lot slide by which g++ warns or even errors on. Tsk, tsk, MS.
2. g++ really, really hates unused parameters.
3. Something is badly wrong with the code organisation, or g++, perhaps re templates - the build takes a lifetime.
4. I will not be installing Ubuntu again in a hurry - Unity is awful, and runs like a three-legged dog with a hangover.
Pity. I previously found it excellent.

Oh well, at least none of this affects the user.

5. I forgot to mention that the forms and table columns are generally resizable. The defaults are clearly too small,
but your changes are persisted.

I have uploaded the repository to Dropbox as a tar.gz. There is an awful lot more code than originally anticipated. A lot of it is generated
boiler plate, but a lot of the rest seems unnecessarily repetitive.


UnicycleBloke


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Fri Dec 07, 2012 8:34 am 
Offline
Engineer
Engineer
User avatar

Joined: Tue Aug 30, 2011 2:39 pm
Posts: 27
Location: Cambridge, England
@SkiddLow: I'm sorry, but I haven't understood what you are saying.


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Fri Dec 07, 2012 10:19 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Apr 19, 2004 8:09 pm
Posts: 1672
Location: Sweden
It seems to assume the DOS palette - at least it creates false colors when loading my AI_SwedishW.grf...

_________________
Image
Swedish trains * Swedish Town Names * BlockCAD * The GRFMaker Community Page


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Fri Dec 07, 2012 10:37 pm 
Offline
Engineer
Engineer
User avatar

Joined: Tue Aug 30, 2011 2:39 pm
Posts: 27
Location: Cambridge, England
Thanks. That GRF does not contain an Action 14 with a PALS element. The reader would detect this and set the palette type. I forgot to add an option to set the palette explicitly. Before I do, is there another way that I can detect the palette automagically?


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Fri Dec 07, 2012 11:03 pm 
Offline
Tycoon
Tycoon

Joined: Wed Jan 17, 2007 12:14 am
Posts: 4576
you can use somewhat of an heuristic of detecting the presence of a "magic pink" colour

_________________
You might not exactly be interested in Ferion, but if you are, have fun :)


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Sat Dec 08, 2012 12:19 am 
Offline
Engineer
Engineer
User avatar

Joined: Tue Aug 30, 2011 2:39 pm
Posts: 27
Location: Cambridge, England
I like that. The method is not infallable, though. I check every sprite as it is loaded or imported. At least one might have some pink in it. I've added the menu option as well.


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Sat Dec 08, 2012 10:39 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Apr 19, 2004 8:09 pm
Posts: 1672
Location: Sweden
You could also use the heuristic: "If the name ends in 'W' it's probably the Windows palette". That was the recommended norm for TTDP (for which my grf was created).

_________________
Image
Swedish trains * Swedish Town Names * BlockCAD * The GRFMaker Community Page


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Sun Dec 09, 2012 6:41 pm 
Offline
Tycoon
Tycoon

Joined: Fri Oct 23, 2009 7:35 pm
Posts: 1165
Location: Thoftkinwise Theedishland
Right, managed to compile it on Linux myself, but I had to:
- remove the "template" directory, or the template file would be compiled, which obviously doesn't work
- in the Makefile: manually add -DQT_XML_LIBS to DEFINES, -I/usr/include/qt4/QtXml to INCPATH and -lQtXml to LIBS since qmake wasn't adding the QtXml requirement for some reason
- change an '#include "FileNameProperty.h"' to 'include "FilenameProperty.h"' in Properties/Framework/PropertyGroupDescriptor.cpp.


Attachments:
File comment: libqt4 must be installed. 32 bit as well as 64 bit, license there.
newgrf-editor-linux-bin.zip [1.41 MiB]
Downloaded 26 times
fix_compiling.patch [2.51 KiB]
Downloaded 22 times

_________________
--- My code and sprites may be used under the terms of the GPL v2 or newer, if I have not stated otherwise - no need to contact me beforehand --- Call them "track types", that's what they are ---
--- Developer for: NuTracks - Central European Train Set - Britrains --- Running/compiling for: Linux (32/64 bit x86, ARM) - Windows (32/64 bit) - OS X (32/64 bit x86) - Haiku ---

--- Need a file packer? 7-Zip --- Bypass web blockers? Tor --- BOINC - use your computing power to benefit science --- Unix in dispersible pellets, the formula for the future. ---
Image
Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Sun Dec 09, 2012 7:31 pm 
Offline
Engineer
Engineer
User avatar

Joined: Tue Aug 30, 2011 2:39 pm
Posts: 27
Location: Cambridge, England
Thanks for doing that. I built it using QtCreator, which I assumed just runs qmake, but had a slightly different experience. Hmm. I'll take a look at the patch.


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Sun Dec 09, 2012 8:32 pm 
Offline
Tycoon
Tycoon

Joined: Fri Oct 23, 2009 7:35 pm
Posts: 1165
Location: Thoftkinwise Theedishland
Alright. For good measure, an OS X build too.


Attachments:
File comment: 64-bit .app, requires 10.5 or higher
newgrf_editor_hg.zip [742.22 KiB]
Downloaded 29 times

_________________
--- My code and sprites may be used under the terms of the GPL v2 or newer, if I have not stated otherwise - no need to contact me beforehand --- Call them "track types", that's what they are ---
--- Developer for: NuTracks - Central European Train Set - Britrains --- Running/compiling for: Linux (32/64 bit x86, ARM) - Windows (32/64 bit) - OS X (32/64 bit x86) - Haiku ---

--- Need a file packer? 7-Zip --- Bypass web blockers? Tor --- BOINC - use your computing power to benefit science --- Unix in dispersible pellets, the formula for the future. ---
Image
Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Mon Dec 10, 2012 3:18 pm 
Online
Traffic Manager
Traffic Manager
User avatar

Joined: Mon Dec 27, 2010 4:26 pm
Posts: 170
Location: Finland
oberhümer wrote:
Alright. For good measure, an OS X build too.


Doesn't work, gives me this:

Code:
Process:         newgrf_editor_hg [74681]
Path:            /Applications/newgrf_editor_hg.app/Contents/MacOS/newgrf_editor_hg
Identifier:      com.yourcompany.newgrf_editor_hg
Version:         ??? (???)
Code Type:       X86-64 (Native)
Parent Process:  launchd [168]

Date/Time:       2012-12-10 17:17:22.637 +0200
OS Version:      Mac OS X 10.6.8 (10K549)
Report Version:  6

Interval Since Last Report:          2106537 sec
Crashes Since Last Report:           30
Per-App Crashes Since Last Report:   2
Anonymous UUID:                      9A0191DB-BFCA-4B99-99C5-E590EECD3845

Exception Type:  EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000002, 0x0000000000000000
Crashed Thread:  0

Dyld Error Message:
  Library not loaded: /usr/local/lib/QtGui.framework/Versions/4/QtGui
  Referenced from: /Applications/newgrf_editor_hg.app/Contents/MacOS/newgrf_editor_hg
  Reason: image not found

Binary Images:
    0x7fff5fc00000 -     0x7fff5fc3be0f  dyld 132.1 (???) <29DECB19-0193-2575-D838-CF743F0400B2> /usr/lib/dyld

Model: iMac12,1, BootROM IM121.0047.B1F, 4 processors, Intel Core i5, 2.5 GHz, 4 GB, SMC 1.71f22
Graphics: AMD Radeon HD 6750M, AMD Radeon HD 6750M, PCIe, 512 MB
Memory Module: global_name
AirPort: spairport_wireless_card_type_airport_extreme (0x168C, 0x9A), Atheros 9380: 4.0.35.3
Bluetooth: Version 2.4.5f3, 2 service, 19 devices, 1 incoming serial ports
Network Service: AirPort, AirPort, en1
Network Service: Ethernet, Ethernet, en0
Serial ATA Device: ST3500418AS, 465,76 GB
Serial ATA Device: HL-DT-STDVDRW  GA32N
USB Device: FaceTime HD Camera (Built-in), 0x05ac  (Apple Inc.), 0x850b, 0xfa200000 / 3
USB Device: Hub, 0x0424  (SMSC), 0x2514, 0xfa100000 / 2
USB Device: Keyboard Hub, 0x05ac  (Apple Inc.), 0x1006, 0xfa130000 / 5
USB Device: Apple Keyboard, 0x05ac  (Apple Inc.), 0x0221, 0xfa132000 / 6
USB Device: BRCM2046 Hub, 0x0a5c  (Broadcom Corp.), 0x4500, 0xfa110000 / 4
USB Device: Bluetooth USB Host Controller, 0x05ac  (Apple Inc.), 0x8215, 0xfa111000 / 7
USB Device: Hub, 0x0424  (SMSC), 0x2514, 0xfd100000 / 2
USB Device: iPod, 0x05ac  (Apple Inc.), 0x1263, 0xfd140000 / 6
USB Device: LaCie Device, 0x059f  (LaCie), 0x102a, 0xfd130000 / 5
USB Device: IR Receiver, 0x05ac  (Apple Inc.), 0x8242, 0xfd120000 / 4
USB Device: Internal Memory Card Reader, 0x05ac  (Apple Inc.), 0x8403, 0xfd110000 / 3


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Mon Dec 10, 2012 3:47 pm 
Offline
Engineer
Engineer
User avatar

Joined: Tue May 15, 2007 11:35 am
Posts: 94
Location: Germany
alluke wrote:
oberhümer wrote:
Alright. For good measure, an OS X build too.


Doesn't work, ...


Same here (10.6.8, Core 2 Duo, 64-Bit).

_________________
My screenshots


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Mon Dec 10, 2012 5:34 pm 
Offline
Tycoon
Tycoon

Joined: Fri Oct 23, 2009 7:35 pm
Posts: 1165
Location: Thoftkinwise Theedishland
Eh, seems Qt is dynamically linked on OS X too... what I did was install Homebrew
Code:
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
and then run
Code:
brew install qt

There are probably other ways of getting the Qt libraries, but this one definitely works.

_________________
--- My code and sprites may be used under the terms of the GPL v2 or newer, if I have not stated otherwise - no need to contact me beforehand --- Call them "track types", that's what they are ---
--- Developer for: NuTracks - Central European Train Set - Britrains --- Running/compiling for: Linux (32/64 bit x86, ARM) - Windows (32/64 bit) - OS X (32/64 bit x86) - Haiku ---

--- Need a file packer? 7-Zip --- Bypass web blockers? Tor --- BOINC - use your computing power to benefit science --- Unix in dispersible pellets, the formula for the future. ---
Image


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Wed Dec 12, 2012 3:38 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Dec 23, 2004 6:31 pm
Posts: 1984
Location: Waukegan, IL
I just tried the program, and it is what I've been wanting for a while.

I've wanted to draw new sprites for a long time now, perhaps be part of a GRF project, but drawing in pixels seems a bit intimidating. So, I thought that just for practice (Not for release), I could try adding new liveries to the US Set trains. But, I was at a loss for how to decode the GRF file into an image I could edit.

This tool did just that for me.

Trying out "repainting" some of the models from the set tonight. If I come up with anything nice, I probably can't release the sprites due to licensing, though I really haven't researched the licensing yet on it. As I said, it will be good practice to get my feet wet.

Thanks again for a handy tool!

_________________
Without Trains America Stops

Image
Image


Top
 Profile  
 
 Post subject: Re: NewGRF Editor
PostPosted: Wed Dec 12, 2012 12:45 pm 
Offline
Engineer
Engineer
User avatar

Joined: Tue Aug 30, 2011 2:39 pm
Posts: 27
Location: Cambridge, England
Thanks for your encouraging words. To be fair, though, wouldn't grfcodec have allowed you decompile, edit images and recompile?


UnicycleBloke


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 32 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000-2013 phpBB Group

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2013.
Hosted by Zernebok Hosting.