Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sun May 19, 2013 10:33 pm

All times are UTC




Post new topic Reply to topic  [ 35 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: NewGRF Viewer
PostPosted: Fri Oct 07, 2011 8:17 am 
Offline
Engineer
Engineer
User avatar

Joined: Tue Aug 30, 2011 2:39 pm
Posts: 27
Location: Cambridge, England
I used to play TTD a lot many years ago, and was very happy to find OpenTTD. I haven't really played with it much yet, but have become fascinated in particular by the development of NewGRFs. The specification seems mind-bogglingly Byzantine, and my hat is off to everyone who is writing GRFs, especially in NFO. NML is a very worthwhile project, but I understand it currently has limited support for the many features of the spec. I found quite it difficult to map the NML back to the NFO.

Anyway, the point of posting is that I have written a viewer which reads a GRF file and allows the user to browse its contents. Each record (i.e. sprite or pseudo-sprite) is represented as a treeview of fields. This was a lot easier than trying to develop specific dialogs for each type (and special subtype) of action or property. Each field is, where possible, given a description which I cribbed from the wiki (feature names, industry names, property descriptions, and so on). I guess I've reproduced Grf2Html somewhat...

The program can in theory read any Version 7 GRF, but there are bound to be bugs like reading a word instead of an extended byte, or where I've overlooked some detail in the spec. And there are one or two as yet undocumented areas. I've also found one or two broken GRFs, which OTTD also rejected. It will pick up the palette and version from Action 14 and Action 8, if these are present, but you can swap at any time. The software currently only distinguishes GRF7 from earlier versions (referred to as GRF6), and this information is only used when creating a description for a language.

I would be very interested in feedback on whether this is actually a useful tool, and what direction it might take. I have some ideas about how to turn it into an in-place editor, but this is not a small task. For now, I think I've split out the information too finely in some cases, and want to review all the fields for a consistent presentation, and to combine multiple treeitems where it makes sense to do so (properties are prime candidates). I would also like to beef up the properties to split out bitfields, show enumeration names, use appropriate number formatting, and show units. It is also likely that I have missed some important relationships between records.

The program is developed using Qt4, so should in principle build for Linux as easily as for Windows, though I have not looked into this yet. The consequence is that the GUI framework requires one or two large redistributable DLLs, making the program a 12Mb download. I didn't feel comfortable posting that here, but would it be OK? Or should I set up some hosting on SourceForge or something? I'm working on Windows 7 and have no idea if the executable will work on earlier versions. Screen dumps attached.

Cheers


Al

Attachment:
newgrfviewer2.png [83.6 KiB]
Downloaded 1 time

Attachment:
newgrfviewer.png [108.47 KiB]
Downloaded 1 time


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Fri Oct 07, 2011 10:03 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Tue Apr 24, 2007 9:37 am
Posts: 2397
Location: The Land of Oz
Welcome to the forums! Great start on the program, but you may be interested in looking at grf2html, which appears to do the same thing or something similar, except it puts it into a HTML format. :wink:

- Jake

_________________
--Stuff I made (or helped make)--
ImageImageImageImage

--My Award-Winning Screenshots and Videos--


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Fri Oct 07, 2011 10:21 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Nov 27, 2004 3:05 pm
Posts: 4206
Location: Canada
This looks very interesting and I think I'll have an opportunity to use it over the next several weeks. I'll be able to give you some feedback on it's use with Windows XP Pro SP3, Send me a PM and I'll send you my email address so that you can send me that rather large file. :D

_________________
Visit Simuscape - A world of its own.

French Set - Série française - thread - tables
Wallyweb Productions - Scenarios and screenshots for TTDP
Canadian Town Names
NewObjects are for real!
Wallyweb Graphics Studio - Wallyweb's Graphics Releases
TTDPatch Questions? Go here - OpenTTD Questions? Go here


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Fri Oct 07, 2011 10:53 am 
Offline
Engineer
Engineer
User avatar

Joined: Tue Aug 30, 2011 2:39 pm
Posts: 27
Location: Cambridge, England
I mentioned grf2html. I used it a bit and it fell over on (I think) undocumented registers I had to look up in the OTTD source. In any case, my intention all along has been to develop this with a view to making it into an editor, but the first stage is to have a good understanding of the GRF spec.

At the very least it could manage the ordering and size calculations for sprites. I've no idea if other tools already do these things, but I got the impression that this is not so. But I think we could do a lot more: choose an operator for a VarAction2 from a combobox instead of learning a bunch of switches; hit a checkbox instead of adding 0x80 to some other number; named check boxes for bits in a bitfield; ... I doubt any of this would remove the need to really understand the spec, but I hope it would make life easier.

What I'd really like at the moment is if some people would have a play with the viewer: try to break it; make suggestions; and so on. If it's useless, well, it's been fun anyway. I realised that the download might be a lot smaller after I've zipped it. :) At work now, though.

I'm releasing this under GPL3. I'll stick it on SF when I get a chance.


Al


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Fri Oct 07, 2011 11:13 am 
Offline
Tycoon
Tycoon

Joined: Wed Apr 27, 2005 7:09 am
Posts: 4394
UnicycleBloke wrote:
In any case, my intention all along has been to develop this with a view to making it into an editor, [...] I think we could do a lot more: choose an operator for a VarAction2 from a combobox instead of learning a bunch of switches; hit a checkbox instead of adding 0x80 to some other number; named check boxes for bits in a bitfield; [...]

BTW, there is also GRFmaker, a graphical frontend for nfo-programming.

regards
Michael

_________________
Image


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Fri Oct 07, 2011 12:17 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Thu Sep 11, 2008 7:32 am
Posts: 1028
Location: Spain
You can compile Qt4 statically. That way, the resulting executable will contain the dll files inside itself making distribution a bit simpler (in my experience, static Qt executables tend to be smaller in size than "normal" Qt executable + dlls). I followed this tutorial to recompile Qt4.

_________________
Spanish translation of OpenTTD
Extended heightmaps

Have fun, don't quarrel too much and add as many advanced settings as you can.


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Fri Oct 07, 2011 1:49 pm 
Offline
Engineer
Engineer
User avatar

Joined: Tue Aug 30, 2011 2:39 pm
Posts: 27
Location: Cambridge, England
@Michael

Yeah. I looked at GrfMaker. Perhaps I had an older version. It does have a nifty rectangle finder for images, but I was unable to select them: just kept getting errors.

@Terkhen

Thanks. I was thinking about that. It is preferable, really, but I have been focused on developing the app so far. :)


Al


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Fri Oct 07, 2011 3:26 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Mar 19, 2009 7:25 pm
Posts: 1568
Location: Paddock Wood, England
Itd be cool to have a new graphical GRF maker which was a bit easier to follow.

_________________
Image
|UK Roads /w Signs|British Rail Openttd Set (BROS)|
|Road Types NewGRF Specification|Leanden's Screenshots|


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Fri Oct 07, 2011 4:15 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Apr 19, 2004 8:09 pm
Posts: 1672
Location: Sweden
Leanden wrote:
Itd be cool to have a new graphical GRF maker which was a bit easier to follow.


I think this reasoning is a dead end. You can't program NFO without understanding NFO. GRFMaker makes some thing easier to do, but if it isn't implemented in GRFMaker, you can't do it. Period. The same thing goes for NML - easier to use, but dead end if what you need isn't implemented.

It's much better to create tools that work directly on the GRF/NFO, as that means that what you can't fix with one tool, you may be able to fix with another. For example, I've written a program that can help you visually align sprites - viewtopic.php?p=793813#p793813 but that's all it does.

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


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Fri Oct 07, 2011 4:41 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Nov 27, 2004 3:05 pm
Posts: 4206
Location: Canada
AndersI wrote:
easier to use, but dead end if what you need isn't implemented.
Amen. :bow:

_________________
Visit Simuscape - A world of its own.

French Set - Série française - thread - tables
Wallyweb Productions - Scenarios and screenshots for TTDP
Canadian Town Names
NewObjects are for real!
Wallyweb Graphics Studio - Wallyweb's Graphics Releases
TTDPatch Questions? Go here - OpenTTD Questions? Go here


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Fri Oct 07, 2011 5:17 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon May 21, 2007 11:47 am
Posts: 6117
Location: The Netherlands
AndersI wrote:
Leanden wrote:
Itd be cool to have a new graphical GRF maker which was a bit easier to follow.


I think this reasoning is a dead end.

I like to disagree. It really depends on what level the tool is implemented. Yes, if you make something that is a graphical interface for NFO, then indeed you must know NFO in order to be able to use it.

However, if you take it to the next level, disconnecting the GUI from NFO, one should be able to get much further indeed. Instead, you present the user with graphical tools to for instance make a train, completely separate from the NFO structure. The conversion to NFO and/or GRF is done completely in the background.
I think if one were to for instance take the principles of NML and put that into a graphical editor one could end far ahead of everything. NML manages to be completely different than NFO while still ending up creating GRF files. Even a graphical interface on top of NML would be very plausible indeed if you ask me.

Then you have a "new graphical GRF maker" which is completely different and IMO much easier to understand. Still for more advanced stuff like the callbacks you need some sort of documentation, but that is true for every graphical tool that implements advanced stuff.

_________________
FooBar's Tram Tracks | TransRapid Track Set | Metro Track Set | OpenGFX base graphics set | FIRS Industry Replacement Set
Dutch Tram Set | Dutch Trainset 2 | Dutch Road Furniture


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Fri Oct 07, 2011 5:31 pm 
Offline
Chairman
Chairman
User avatar

Joined: Thu Mar 25, 2010 1:36 pm
Posts: 774
Quote:
but if it isn't implemented in GRFMaker, you can't do it. Period.


You can insert raw code snippets - though you may argue that defeats the object


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Fri Oct 07, 2011 8:50 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Mon Apr 19, 2004 8:09 pm
Posts: 1672
Location: Sweden
FooBar wrote:
I like to disagree. It really depends on what level the tool is implemented.

But every NFO function/aspect still has to be *implemented* in the tool before you can use it. Every time some new facility is added to the NFO spec, all the conversion tools will lag (or never be updated). With a graphical layer on top of NML there are two sets of programs/systems that need to be updated before you get at the new NFO functionality.

If you create tools that work directly on NFO, there's always Notepad to use the latest enhancements *now*, not in three to six months when GRFMaker (probably not) or NML (still alive and kicking) implements it.



Bob_Mackenzie wrote:
You can insert raw code snippets - though you may argue that defeats the object

Oh, I know that you can insert raw NFO in GRFMaker, I have recommended it a couple of times :-) But as you really need to know both NFO and the internal workings of GRFMaker to be sure to get (complicated) things right, it would in the end be better to work in NFO only. I don't know if NML has a raw NFO facility, and I don't know if the inner workings of NML demands that you know a lot about how NML works, to be able to use raw NFO.



@UnicycleBloke: Sorry for going off on a tangent. Your grfviewer looks like an interesting program and you're welcome to send me a copy at anders@blockcad.net. If you want, I can host the file(s) for download at my BlockCAD domain, but I'd suggest you ask orudge for a place here at tt-forums.net, there's usually no problem.

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


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Fri Oct 07, 2011 10:51 pm 
Offline
Engineer
Engineer
User avatar

Joined: Tue Aug 30, 2011 2:39 pm
Posts: 27
Location: Cambridge, England
OK. The software is now hosted at http://dev.openttdcoop.org/projects/newgrf-viewer. Please don't shout at me if my C++ is not to your liking.

I've done a release build and stored it, along with the necessary distributables, at http://dev.openttdcoop.org/projects/new ... 2011-10-07. I will endeavour to get a statically linked version working in the near future. All I can say about this version is that it works as expected on my machine. I would definitely consider it an alpha. :) For all I know it does not run on any other Windows platform than 7, or any other machine than mine. :( My lappie is an i5 with oodles of RAM, so performance may also be an issue. Dunno.

Please try it. Try to break it with your GRFs (shouldn't be too hard). And let me know.

@AndersI

My vision was for something that would allow essentially compete control over the NFO, while taking care of as much of the tedious bit twiddling, size calculations, bookkeeping and so on as possible. I stress that at the moment this is a viewer only. I can think of several ways to improve it as a viewer even. I'm not making any promises for an editor right now, but the potential is there...

I've spent the last two weeks converting assembly code from one assembler's syntax to another's. Assembler is pretty low level, and gives access to all the features of the hardware, but at least it is readable by mortals. It is miles better than hand editing the machine code in hex, which is what NFO boils down to. Assembler abstracts the bit-twiddling and bean-counting without hiding the features. I think that's what I'd be aiming for initially.


Al


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Sat Oct 08, 2011 5:32 am 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Nov 27, 2004 3:05 pm
Posts: 4206
Location: Canada
Windows XP Professional SP3
Dell PC (an old one)
2 GHz Celeron
512 MB RAM

:D No noticeable performance hits with 11 apps running.

:D Produced this:
Attachment:
screenshot.PNG
screenshot.PNG [ 38.34 KiB | Viewed 1763 times ]

_________________
Visit Simuscape - A world of its own.

French Set - Série française - thread - tables
Wallyweb Productions - Scenarios and screenshots for TTDP
Canadian Town Names
NewObjects are for real!
Wallyweb Graphics Studio - Wallyweb's Graphics Releases
TTDPatch Questions? Go here - OpenTTD Questions? Go here


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Sat Oct 08, 2011 7:33 am 
Offline
Engineer
Engineer
User avatar

Joined: Tue Aug 30, 2011 2:39 pm
Posts: 27
Location: Cambridge, England
Excellent! Good to know it did not eat your hard disk, email all your friends with Viagra offers, or start a game of Global Thermonuclear War.


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Sat Oct 08, 2011 2:45 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Nov 27, 2004 3:05 pm
Posts: 4206
Location: Canada
UnicycleBloke wrote:
Good to know it did not eat your hard disk,
The cat got to it first.
Quote:
email all your friends with Viagra offers,
I interrupted the messages and bought all the Viagra for myself. I also am quite impressed with the lack of quality in this Genuine Rolex Watch Reproduction.
Quote:
start a game of Global Thermonuclear War.
This is an automatic reply generated from a bunker located deep beneath Canada.
:lol:

_________________
Visit Simuscape - A world of its own.

French Set - Série française - thread - tables
Wallyweb Productions - Scenarios and screenshots for TTDP
Canadian Town Names
NewObjects are for real!
Wallyweb Graphics Studio - Wallyweb's Graphics Releases
TTDPatch Questions? Go here - OpenTTD Questions? Go here


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Sat Oct 08, 2011 3:43 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Thu Jun 25, 2009 4:42 pm
Posts: 2241
Location: Suffolk, UK
UnicycleBloke wrote:
OK. The software is now hosted at http://dev.openttdcoop.org/projects/newgrf-viewer....

I've done a release build and stored it, along with the necessary distributables, at http://dev.openttdcoop.org/projects/new ... 2011-10-07.


Can i suggest that you (eventually) use the openttdcoop devzone build system to build your program, instead of uploading the executable.

Program looking good btw - might interest me enough to bother to learn newgrf making! :)

_________________
AroAI - A really feeble attempt at an AI

  • Unix *is* user-friendly. It is not ignorant-friendly and idiot-friendly.
  • Duct tape is like the force. It has a light side, a dark side, and it holds the universe together... -- Carl Zwanzig
  • I am always doing that which I cannot do, in order that I may learn how to do it. -- Pablo Picasso
  • Time LINE...? Ehh, time isn't made out of LINES. It is made out of circles. That is why clocks are round! -- Caboose, RvB


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Sun Oct 09, 2011 10:11 pm 
Offline
Engineer
Engineer
User avatar

Joined: Tue Aug 30, 2011 2:39 pm
Posts: 27
Location: Cambridge, England
Most sites offer both binaries and source: not everyone wants to build software before using it. I'm still learning what the site can do for me and have already been ticked off. I find this both discouraging and patronising.


Al


Top
 Profile  
 
 Post subject: Re: NewGRF Viewer
PostPosted: Sun Oct 09, 2011 10:13 pm 
Offline
Engineer
Engineer
User avatar

Joined: Tue Aug 30, 2011 2:39 pm
Posts: 27
Location: Cambridge, England
Lord Aro wrote:
Program looking good btw - might interest me enough to bother to learn newgrf making! :)


But thank you for your own encouragement. :)


Al


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

All times are UTC


Who is online

Users browsing this forum: Google Feedfetcher and 6 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.