Files
ordoor/doc/formats/mnu.md
Nick Thomas 7a8e9dbd97 Respect sprite X and Y offsets
This makes menus display more correctly, and also fixes trees and other
objects on the main map, although it messes up bounds clipping (sigh).
2020-03-21 00:56:35 +00:00

4.9 KiB

*.mnu

These files appear to be the UI definitions for Chaos Gate. Some relate to system menus, other to in-game menus. Their names are hardcoded into the WH40K.exe binary. Each has a .obj file associated with it.

It's an ASCII-formatted text file with a 12-line header, followed by a number of descriptor records.

Here's the top of MainGame.mnu:

MainGame.obj
BACKGROUND COLOR 0..255..-1 trans : 0
HYPERTEXT COLOR 0..255            : 120
FONT TYPE 0..5                    : 10
wh40k_12
basfnt12
wh40k_47
wh40k_12_red
wh40k_12_blue
wh40k_12_green
wh40k_12_yellow
NULL

The first line of the header is a .obj file containing sprites we want to display on-screen. We see entries further down have a SPRITEID, which must reference entries in that file.

In SaveGame.mnu, we can see multiple .obj files can be referenced.

There are then 3 lines that seem to be fixed descriptor names with values that vary. Is this font colour, perhaps? Unsure.

Next is a variable-length list of font names, referencing files in the Fonts directory.

Finally, there's a list of records that specify the menu itself. Truncated contents of SaveGame.mnu:

#rem..........Background
MENUID     : 1
MENUTYPE   : 0
MOVEABLE   : 0
ACTIVE     : 1
SPRITEID   : 0
ACCELERATOR: 0
DRAW TYPE  : 0
SHARE      : -1
X-CORD     : -1
Y-CORD     : -1
DESC       :
*
#rem..........MAIN BACKGROUND
MENUID     : 2
MENUTYPE   : 45
MOVEABLE   : 0
ACTIVE     : 1
SPRITEID   : 0
ACCELERATOR: 0
DRAW TYPE  : 0
SHARE      : -1
X-CORD     : -1
Y-CORD     : -1
DESC       :
#rem.......... MAIN BACKGROUND
        SUBMENUID  : 1
        SUBMENUTYPE: 31
        FONTTYPE   : 20
        ACTIVE     : 0
        SPRITEID   : -1
        ACCELERATOR: 0
        DRAW TYPE  : 0
        SHARE      : 0
        SOUNDTYPE  : 0
        DESC       :
*
#rem..........Chat List Box Menu
MENUID     : 21
MENUTYPE   : 1
MOVEABLE   : 0
ACTIVE     : 1
SPRITEID   : 764
ACCELERATOR: 0
DRAW TYPE  : 0
SHARE      : -1
X-CORD     : -1
Y-CORD     : -1
DESC       :
[...]
*
~

We start processing these as soon as we see MENUID, I suppose. Each toplevel item is *-delimited, and the list is terminated with ~.

Each menu has a list of parameters:

Name Examples Purpose
MENUID 1, 2, 3 Maybe linking between menus?
MENUTYPE 0, 1, 2, 3, 45, 300 ?
MOVEABLE 0 Unimplemented functionality?
ACTIVE 0, 1, 1,0 ?
SPRITEID -1, 0, 123, 16,-1,1 Select from .obj file?
ACCELERATOR ?
DRAW TYPE ?
SHARE ?
X-CORD -1, 0, 200 X coordinate to draw at
Y-CORD -1, 0, 200 Y coordinate to draw at
FONTTYPE Choose a font from the above?
SOUNDTYPE ?
DESC CHARACTER SELECT, 51005 Text, or reference to Data/USEng.dta

Submenus also show a couple of unique values:

Name Examples Purpose
SUBMENUID 1, 2, 3 As MENUID
SUBMENUTYPE 0, 1, 2 As MENUTYPE

It seems .mnu files can also include other files, which have the extension .mni (presumably for "Menu include"). Examples:

*
$GenDialog.mni
$GenLoad.mni

It looks like we just interpolate the named file into the text when we come across one of these lines.

(Sub)menu types

The types seem to refer to different types of UI widget. Here's a list of unique values:

Value Meaning
0 Background
1 Logical menu grouping?
2 ?
3 Standard button?
30 Equipment?
31 "Character helmet" / "Slot"
40 "X Line Y"
41 "X Line Y"
45 ?
45,10,11,9 ?
45,11,12,10 ?
45,14,15,13 ?
45,17,18,16 ?
45,3,4,2 ?
45,5,6,4 ?
45,6,7,5 ?
45,7,8,6 ?
45,8,9,7 ?
45,9,10,8 ?
50 ?
60 Other text to display? (UltEquip.mnu)
61 Text to display
70 Hypertext to display
91 ?
100 ?
110 ?
120 ?
200 Drop-down button?
205 Single list box item?
220 Psyker power?
221 Page?
228 Big buttons in Main.mnu
232 ?
233 ?
300 Pop-up dialog box
400,0,0,{8, 16} ?
400,22,22,{2, 4, 5, 6, 7, 8, 9, 9, 10, 13, 16} ?
400,30,-1,5 ?
405,0,0,{8, 16} ?
405,22,22,{2, 4, 5, 6, 7, 8, 9, 10, 13, 16} ?
405,30,-1,5 ?

Positioning

The X-CORD and Y-CORD values would seem to be related, to this, but they are universally set to 0 or -1.

Far more important are the XOffset and YOffset values for each sprite in the associated .obj files. Taking these into account is enough to draw Options.mnu successfully, for instance:

Animation

This seems to be done by choosing a different sprite to draw every N ticks. They are laid out sequentially, but I don't yet know how to animate them. It's likely to be the same approach as used for other obj files.