RezEditor Alpha Log

Well, for the past few days I have been fighting Windows over Linux (stupid 128 MiB limit), and I still haven't got them to work nicely on a single machine, and next week I'll be gone to tour colleges, but before my upgrade I did get at least the framework for the new version. I'll be using the GUI editor, as much as I hate it. This means the GUI will be like that one that was the root that you used to create launch the Booms, instead of like the Booms with their stupid no-spacing and auto-scaling. Eventually I might change that, but not soon.

At this point, it looks probable that I'll write the main loading and saving parts before the actual editors, so if you like hexadecimal, it will be fully-featured πŸ˜‰ .
I just hope I can get a hexadecimal editor up... maybe a table in a scroll pane, to get around the fixed-size problem - can I make it so that it auto-expands, or not? Easier not.

Got CVS up, with the basics for the new setup. I will not be including the source with future alphas since I am now fulfilling my open-source obligations this way, but will probably include them again (as a separate download within the release) when I get to beta.
Now if I can just figure out how to to the documentation...
Edit: Right now I'm writing the basic resource checker. Anyone know what the following are?

Nova Bible said:

Max Ship Classes 768
Max Stellar Classes 256
Max Cargo Types 256

Edit2:
I'm pretty sure the "Ship Classes" just refers to the maximum number of Ship IDs that will be read.
Here is one contradiction that I've found:

Nova Bible said:

Max Stellar Objects 2048
...
Stellar The stellar object this disaster is linked to
128-1628 ID of a stellar object

When I get done browsing the Nova Bible, I'll post a list of what resources I have been unable to define the limits on (many are clearly limited, others unlimited like desc and str#)

This post has been edited by Nonconventionally Creative : 16 July 2008 - 12:24 AM

My Resource ID Guide (see link in sig) shows the valid ranges for all resource types with limits, including those not mentioned in the Nova bible (eg, crons with a limit of 512).

The bit about spobs you quoted is most likely just an error, perhaps from some development stage when the limit may have been set to 1500 (although the max would actually be 1627 in that case).

This post has been edited by Guy : 20 October 2009 - 04:27 AM

In Escape Velocity and EV Override , the limit was 1500 spΓΆbs, hence a maximum of 1628. The section on disasters must not have been updated when the maximum was increased for EV Nova.

Yeah, there are several pieces of outdated/invalid data, such as the pers/ship weapon slots.
I checked out that Guide and I would assume that the unmentioned resources are unlimited, except that there's an obvious flaw: shans are tied to ships. Sorry, not alphabetical 😞
You did forget colr=128, however, and what's a ppat?
Also, shouldn't pers be up to 1151? Or is Hector sneakily taking that last one? (It would make sense if Hector is simply a pers that is hard-wired)
I know there must be limits on DLOG and DITL.
Are there any on intf and STR ? (I've never understood clearly the STR# patching thing.)

This post has been edited by Nonconventionally Creative : 16 July 2008 - 12:23 PM

@nonconventionally-creative, on Jul 16 2008, 01:00 PM, said in RezEditor Alpha Log:

You did forget colr=128, however, and what's a ppat?

ppat is the colour equivalent of PAT#, a standard resource type for storing repeating graphical patterns.

@nonconventionally-creative, on Jul 16 2008, 01:00 PM, said in RezEditor Alpha Log:

I know there must be limits on DLOG and DITL.

Since the only thing you can do with dialogue boxes in EV Nova is to replace the existing one, ID limits don't really apply; the limitation is that you have to use the exact same IDs as the standard engine, and use them for the same purpose.

@nonconventionally-creative, on Jul 17 2008, 05:00 AM, said in RezEditor Alpha Log:

not alphabetical 😞

Right, done in the same order as the Nova bible.

@nonconventionally-creative, on Jul 17 2008, 05:00 AM, said in RezEditor Alpha Log:

You did forget colr=128

Well no, the bible says only the 'first' resource is loaded, which could be any ID.

@nonconventionally-creative, on Jul 17 2008, 05:00 AM, said in RezEditor Alpha Log:

Also, shouldn't pers be up to 1151? Or is Hector sneakily taking that last one? (It would make sense if Hector is simply a pers that is hard-wired)

That is the suspicion, though no one has been able to prove it.

@nonconventionally-creative, on Jul 17 2008, 05:00 AM, said in RezEditor Alpha Log:

Are there any on intf and STR ? (I've never understood clearly the STR# patching thing.)

No, limits only make sense for the Nova-specific resource types (all the types with umlauts). There's no reason to limit intf though.

I just discovered that my source is not easily compatible between platforms due to encoding issues. (It is currently encoded as Windows 1252, which seems not to be supported correctly on my ubuntu - this does not compute - I'll probably figure it out, or convert it all to UTF-8 - I wonder if...)
In other news, I found an open-source Java 1.6 for Mac 10.4 and 10.5.
Edited: clarification.

This post has been edited by Nonconventionally Creative : 20 July 2008 - 03:21 PM

There's also an official Java 1.6 for Mac, but it's for 64-bit Intel only.

Can i just say as someone who uses both Windows and Mac OSX 10.3 to do TCing that my hat is off to both Nonconventionally Creative and David Arthur for all their efforts in creating the tools we all use to enhance the game we all love.

Guys thank you very much and Noncon... Keep up the good work its well past time we got something with more features for windows than EVNEW.

RezEditor Manual, pre-Draft. Information subject to change without notice.
When you launch RezEditor, the first thing that happens is the command-line arguments are parsed (not yet implemented, but I have a draft defined.) The use of the arguments may affect the way the following is used, but not if the only argument is a file to load.
If you open a file (whether at program-load or through an open-dialog) a new Main window (a Frame, which has its own place on the taskbar as opposed to a Dailog, which does not) appear listing all known ResourceTypes. Clicking on one of those will show a list of all Resources of the type in a pane on the right. Double-clicking will open a new window, without the ResourceType list, showing only the Resources of that type. (should this have its own taskbar entry or not?)
Once I figure out how to, I will make it so that subsequent openings of the jar will pass control back to the original, unless used solely for command-line arguments - you can do a batch-text conversion while working on another part.

Behind, the scenes, RezEditor is not really dealing with the files, but creating a ResourceGroup around the files, which helps with plugins of multiple parts. Each ResourceGroup must correspond with a single file (not for anything currently implemented, but for the future, when I only load the headers and leave the files on disk instead of loading the whole things into memory - this may change if I implement things in a different way. Right now I'm thinking to minimize the footprint of a non-loaded Resource, although it really isn't much of a difference having 2 references than 1).
A ResourceGroup may list other ResourceGroups as dependencies (is there a better term?) So that features like the cross-linking of many resources will work if the resources came from different files, whether implicit or explicit. (Originally I planned to allow the same Resource to be in multiple ResourceGroups, but this was dropped in favor the the current system because of concerns about file-saving introduced above)

By default, RezEditor opens all of the files in your Nova Files folder, and each new plug-in file will by default point to all of those, although this can be changed later if it's a TC.
(The various specifics here and other things can be changed in Preferences, stored in rezeditor.prefs in the User's directory. On Windows this is My Documents, on UNIX it is the user's home directory (/home/username, not the ~/Documents subdirectory thereof, if I understand correctly) - can someone tell me where it is on a Mac - I'll attach a tester.)

I might implement a feature so that RezEditor will handle rename of directories for handling multiple plugin-sets, and allow Launching EV Nova directly from the editor.

Edit: removed attachment, updated below.

This post has been edited by Nonconventionally Creative : 21 July 2008 - 04:01 PM

@nonconventionally-creative, on Jul 20 2008, 10:56 PM, said in RezEditor Alpha Log:

can someone tell me where it is on a Mac

Macintosh applications store their preferences in ~/Library/Preferences.

@david-arthur, on Jul 21 2008, 06:05 AM, said in RezEditor Alpha Log:

Macintosh applications store their preferences in ~/Library/Preferences.

I'm sure native apps do, but I'm not sure how Java picks up the directory - on Windows it would make more sense to use %APPDATA% (C:\Documents and Settings\UserName\Application Data), but the directory is My Documents, as I said.

Probably ~/Documents then.

@guy, on Jul 21 2008, 12:45 PM, said in RezEditor Alpha Log:

Probably ~/Documents then.

But it isn't so on my Ubuntu install - it's just ~. It's the Windows one that doesn't make sense. Can someone just download and run it, please...

Of course, I could nullify this entire argument by using the program's current directory to store settings.
According to the Java Tutorials, Applets can't get the user.dir or user.home System properties, so if I implement that, I'll have to do something different entirely. Maybe I could use Java Web Start instead. This is merely speculation, of course.
Edit: on closer inspection, this is not actually the case on Windows. The default file directory for a JFileChooser seems not to be the same as home.
I have attached a new tester that tests all three directories. Two of them are the same on Linux.

Attached File(s)

This post has been edited by Nonconventionally Creative : 21 July 2008 - 04:19 PM

As I write RezEditor, I seem to write a little here, a little there.
Right now I'm working on the .rez file reader and the rle-color converter. (everything belongs in 24-bit color)
I found the the palette and the rle implementation for the Rle8s and the RleDs are the standard ARRRRRGGGGGBBBBB. I'll include a utility to manually do this conversion, handy for the built-in table viewer (once I make it) or external text files/spreadsheets (remember paint).
For the UI, right now I'm considering just a toolbar, with various button, and no menus. Thoughts?
The good news is that the Java class RandomAccessFile has built-in methods for reading Big-Endian shorts and ints, so I only have to do the manual shifts for the header.
Right now I'm wondering how to best convert to a palette color. I've written a for statement that checks the input against every color in the palette and returns the index of the one with the least value for abs(red-difference)+abs(green-difference)+abs(blue-difference), but I currently don't have a method of dealing with the case when there are multiple palette colors that are least (right now I'm returning whichever came first). What should I do here?
Converting to 16-bit colors, right now I'm just dropping the last 3 bits, but I really should round, by doing a +4 before the shift, I think.

I ran the tester:
user.home = ~ (funny that)
user.dir = the current directory (in my case, ~/Downloads/UserDirTester/dist)
default file directory = ~

@nonconventionally-creative, on Jul 23 2008, 09:57 AM, said in RezEditor Alpha Log:

I found the the palette and the rle implementation for the Rle8s and the RleDs are the standard ARRRRRGGGGGBBBBB.

Hm, I thought it was ARRRRRGGGGGHHHHH!

Got multiple invocations to talk to each other; wrote a lot of implementation code. Set Preferences to user user.dir. Should have something (barely) usable up Soon. Realized that I have to release source via FRS.
Edit: here's a pic. If there were more editors, there would be more choices.
Edit2: for some reason I can only shrink the current resource, not grow it, and it never redraws. These problems continue even if I reinit the whole... wait, I probably have to clear the old ones. Well, that is put aside while I get my RezFile reader working. I have the header read, now I just have to set up the seek and read part.
Edit3: I am amazed at how much redundancy is in the .rez format. Some of it would be useful for quickly seeking a known ResourceType+ID combo, but other bits just don't make sense.

Attached File(s)

This post has been edited by Nonconventionally Creative : 25 July 2008 - 11:32 PM

The function that loads a .rez file into memory is complete. I managed to crash the Java VM by trying to load all of the data files at once... It did get all the way through Nova Ships 3 (alphabetically, with ..\Nova.rez prepended), though. I suppose I should write the "seek to get a known ResourceType+ID" thing while I'm thinking of it.
Saving will not yet be available.
I've abstracted the editor process so that new editor implementations can be added very easily (see preceding attached image).
I'm planning on adding icons to the first release, and I found these, which are adequate, but don't necessarily provide everything I need.
I still need to write the JavaDoc comments for all of my code.
I've written a hexadecimal editor, which works except for changing the size of the resource. I expect to fix that once I get done with
I'm writing some beginning guidelines to a template-based editor. Disadvantages: no individual options for flags, and it wouldn't work for binary types like the graphics and snd . A special tweak would be required for non-binary, variable-length types like STR#, but it would be doable.

Edit: Added and edited so that the resources are not loaded into memory until they are actually used. This may have effects on performance for small resources, so I have added a preference to indicate the size at which the cutoff lies.
Attached a sample output, from a single session.

Attached File(s)

This post has been edited by Nonconventionally Creative : 30 July 2008 - 05:52 PM

Coincidentally I stumbled upon this thread after searching for documentation on the .rez file format and was happy to find that someone else is using the format for new development. I'm using .rez as a compatibility layer for classic MacOS resources in a game port I'm working on, and (just last night, actually) used Burger's EVNovaMacToPCPlugIn.cpp source as a reference to demystify the "unknown" fields in Mehrunes' spec. Hope this helps you NC when writing your code to save .rez files properly:

File Header (Intel byte order)
'BRGR' : Signature
Word32 : 01 00 00 00 : Resource group count (CompressHeaders guarantees this will be 1)
Word32 : Group header size + Name table size : Add 12 (the file header size) to this to get the offset to the resources themselves

Group Header (Intel byte order)
Word32 : 01 00 00 00 : "Obsolete, save as 1" (Type, see footnote)
Word32 : "Resource base ID"
Word32 : "Number of resources in the group"

Name Table (Intel byte order)
repeated for each resource entry {
	Word32 : "Place in the rez file for the data" (offset from beginning of file)
	Word32 : "Size of the data in the rez file" (resource length)
	Word32 : "Offset to the name" (Apparently from the group header; Add 12 to get the offset to the name, the last entry seems to always point to "resource.map")
}

"resource.map" : 12 byte String
00 : null terminator

------------------------
**everything else appears to be in Motorola byte order 

Resource Entry Data
Each entry is immediately followed by the next

------------------------
Resource Map
Word32 : Offset from beginning of resource map to resource type list (seems to always be 8)
Word32 : Number of resource types

repeated for each resource type {
	4 byte String : Resource type name ('BRGR', 'PICT', 'MIDI', etc.)
	Word32 : Offset from beginning of resource map to first entry of that type
	Word32 : Number of entries of that type
}

repeated for each resource entry {
	Word32 : Resource number starting from "Resource base ID" defined in the file header
	4 byte String : Resource type name
	Word16 : Resource ID (typically starts with ID 128 as per Apple guidelines)
	256 byte null-terminated String : Resource name (padded with garbage)
}

Some notes:
There are hints in the source to EVNovaMacToPCPlugIn.cpp that suggest what the "obsolete" Type field in the group header may have at one point been intended for. Namely, the preprocessor constants SOURCEDATAFILE, SOURCEREZFILE, and SOURCEMEM are defined as 0, 1, and 2 respectively. These definitions occur immediately after the declarations for the group header and name table entry structures. Since the .rez file format has so far only seemed to have been used to store Mac resources, it should follow that SOURCEREZFILE is the only group type used, hence it always being set to 1? Speculation on my part...

HTH, and good luck! πŸ™‚