NewGRF Editor
Moderator: Graphics Moderators
- UnicycleBloke
- Engineer
- Posts: 80
- Joined: 30 Aug 2011 14:39
- Location: Cambridge, England
NewGRF Editor
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
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
- Digitalfox
- Chief Executive
- Posts: 710
- Joined: 28 Oct 2004 04:42
- Location: Catch the Fox if you can...
Re: NewGRF Editor
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+
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+
-
- Tycoon
- Posts: 1283
- Joined: 23 Oct 2009 19:35
- Location: Here and there, sometime or another
Re: NewGRF Editor
I'd like to give compiling it on Linux a try - where can I find the source code?
--- Licenses: GNU LGPL, version 2 or newer, code and graphics. CC-By-SA, graphics, alternatively. If you're using any, I'd like to hear about it --- Call them "track types" ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---
--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---
--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
- UnicycleBloke
- Engineer
- Posts: 80
- Joined: 30 Aug 2011 14:39
- Location: Cambridge, England
Re: NewGRF Editor
@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
@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
Re: NewGRF Editor
Yet, UnicycleBloke when use for NewGRF Editor can give GRF anyone edit
Ease Back.
The SkiddLow's NewGRF Ideas (including my scrapped)
My Screenshots || http://postimg.cc/user/skiddlowottd || I'm support "HTTP is Dead (2017-present)"
The SkiddLow's NewGRF Ideas (including my scrapped)
My Screenshots || http://postimg.cc/user/skiddlowottd || I'm support "HTTP is Dead (2017-present)"
- UnicycleBloke
- Engineer
- Posts: 80
- Joined: 30 Aug 2011 14:39
- Location: Cambridge, England
Re: NewGRF Editor
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
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
- UnicycleBloke
- Engineer
- Posts: 80
- Joined: 30 Aug 2011 14:39
- Location: Cambridge, England
Re: NewGRF Editor
@SkiddLow: I'm sorry, but I haven't understood what you are saying.
Re: NewGRF Editor
It seems to assume the DOS palette - at least it creates false colors when loading my AI_SwedishW.grf...
- UnicycleBloke
- Engineer
- Posts: 80
- Joined: 30 Aug 2011 14:39
- Location: Cambridge, England
Re: NewGRF Editor
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?
Re: NewGRF Editor
you can use somewhat of an heuristic of detecting the presence of a "magic pink" colour
- UnicycleBloke
- Engineer
- Posts: 80
- Joined: 30 Aug 2011 14:39
- Location: Cambridge, England
Re: NewGRF Editor
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.
Re: NewGRF Editor
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).
-
- Tycoon
- Posts: 1283
- Joined: 23 Oct 2009 19:35
- Location: Here and there, sometime or another
Re: NewGRF Editor
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.
- 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
-
- newgrf-editor-linux-bin.zip
- libqt4 must be installed. 32 bit as well as 64 bit, license there.
- (1.41 MiB) Downloaded 340 times
-
- fix_compiling.patch
- (2.51 KiB) Downloaded 338 times
--- Licenses: GNU LGPL, version 2 or newer, code and graphics. CC-By-SA, graphics, alternatively. If you're using any, I'd like to hear about it --- Call them "track types" ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---
--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---
--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
- UnicycleBloke
- Engineer
- Posts: 80
- Joined: 30 Aug 2011 14:39
- Location: Cambridge, England
Re: NewGRF Editor
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.
-
- Tycoon
- Posts: 1283
- Joined: 23 Oct 2009 19:35
- Location: Here and there, sometime or another
Re: NewGRF Editor
Alright. For good measure, an OS X build too.
- Attachments
-
- newgrf_editor_hg.zip
- 64-bit .app, requires 10.5 or higher
- (742.22 KiB) Downloaded 356 times
--- Licenses: GNU LGPL, version 2 or newer, code and graphics. CC-By-SA, graphics, alternatively. If you're using any, I'd like to hear about it --- Call them "track types" ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---
--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---
--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
Re: NewGRF Editor
Doesn't work, gives me this:oberhümer wrote:Alright. For good measure, an OS X build too.
Code: Select all
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
Re: NewGRF Editor
Same here (10.6.8, Core 2 Duo, 64-Bit).alluke wrote:Doesn't work, ...oberhümer wrote:Alright. For good measure, an OS X build too.
-
- Tycoon
- Posts: 1283
- Joined: 23 Oct 2009 19:35
- Location: Here and there, sometime or another
Re: NewGRF Editor
Eh, seems Qt is dynamically linked on OS X too... what I did was install Homebrew and then run
There are probably other ways of getting the Qt libraries, but this one definitely works.
Code: Select all
ruby -e "$(curl -fsSkL raw.github.com/mxcl/homebrew/go)"
Code: Select all
brew install qt
--- Licenses: GNU LGPL, version 2 or newer, code and graphics. CC-By-SA, graphics, alternatively. If you're using any, I'd like to hear about it --- Call them "track types" ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---
--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
--- Mostly inactive developer for: NuTracks - Central European Train Set --- Running/compiling for: Linux (x86) - Android - Windows (32/64 bit) ---
--- Need a file packer? 7-Zip --- BOINC - use your computing power to benefit science --- Block trackers, not ads --- Unix in dispersible pellets, the formula for the future. ---
- Railwaymodeler
- Tycoon
- Posts: 2111
- Joined: 23 Dec 2004 18:31
- Location: Wisconsin, USA
Re: NewGRF Editor
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!
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!
- UnicycleBloke
- Engineer
- Posts: 80
- Joined: 30 Aug 2011 14:39
- Location: Cambridge, England
Re: NewGRF Editor
Thanks for your encouraging words. To be fair, though, wouldn't grfcodec have allowed you decompile, edit images and recompile?
UnicycleBloke
UnicycleBloke
Who is online
Users browsing this forum: No registered users and 7 guests