View Single Post
Old 04-14-07, 06:32 AM   #1
zAmboni
Stowaway
 
Posts: n/a
Downloads:
Uploads:
Default [TEC] Tutorial: Deconstructing the menu_1024_768.ini file items

Part I - How layout items are placed and how to interpret the Zone= line

This tutorial is by no means complete, but I wanted to pass along what I have learned to other potential modders on how to decipher lines within the items. Hopefully this will make things easier for future modding efforts. The SH4 menu_1024_768.ini items are similar to the items in the SH3 menu_1024_768.ini except that the SH4 items now contain a Zone= line. This Zone= line is a bit more flexible in allowing the developer/modder to place graphical items within a page. For this tutorial I will be using items found on the Navigation Map pages since this is the page that I did my Retro Nav Map tools mod and I am a bit familiar with how things are place on this page. There are a bunch of things that need to be explained because several of the numbers in the Zone= line are active or inactive depending on the value of other lines within the item. So lets get going.

The Nav Map tools layout is defined in the G31 section of the menu_1024_768.ini file. Many of the items within the G31 section are holdover items from SH3 and are not active in SH4. items I2 through I14 are the holdovers from SH3 and can be completely ignored. I am going to start off with the G31 I1 item. This is the item that sets up the navigation map page. This is shown below:

[G31 I1]
Name=Page navigation map
Type=1027;Menu page
ItemID=0x31000000
ParentID=0x0
Pos=0,0,1024,768
Zone= 0 768 1024 768 2 1 0x0 0.5 -0.5 0x31000000 -0.5 0.5 0 0
LoadingMode=2

In SH4, the Zone= line basically replaces the Pos= line. In the above item, the first notable difference between the Pos= and Zone= is their initial point of reference. The Pos= line basically says "This item starts at the position x=0, y=0 (top left of the screen) and this item is 1024 pixels wide and 768 pixels deep." In other words The navigation map covers the entire screen at a 1024x768 resolution. The first four numbers in the Zone= line is really the same as the Pos= line, except that the 0,0 position is defined as being the bottom left corner instead of top left corner. (0 768), and again the dimensions of the item is 1024x768) Currently, I have no idea what the 5th and 6th numbers are for (2 1). The next element of the Zone= line refers to the ParentID (0x0). I have found out the next two numbers (0.5 -0.5) are involved in the placement of the item and is linked to the Parent ID. I will call this the ParentID placement. The next element refers to the ItemID (0x31000000) and the two numbers after that (-0.5 0.5) are linked to the ItemID and are also involved in the Item placement. The final two numbers are what I call the "offset" (0 0).

If you arent already confused, you may be asking....if the first two numbers of the Zone= line tells you where to place the item, why are the other numbers related to the ParentID and ItemID necessary? Well depending on other lines in an item, either one of the two sets of numbers are "active", they do not appear to be active at the same time. I'll come to this later....but for now I'll show you how the ParentID and ItemID defines where the item starts within a page.

1)The ultimate start point is 0,0 (top right corner of the screen). Now we are ready to move.

2) The element 0x0 0.5 -0.5 in the zone line says "go right half of the 0x0 item width and down half of the 0x0 item height". The width and height of the 0x0 item is the default screen resolution of 1024 (width)x 768 (height). So doing the calcuations this means "go right 512 pixels and down 384 pixels" This places us at the position 512,-384.

3) We aren't done yet....now we need to apply the next element 0x31000000 -0.5 0.5. This says "go left half of the 0x31000000 item width and then up half of the 0x31000000 height." From the Zone= line above the width and height of the 0x31000000 item is...again...1024x768. After calculation we go "left 512 pixels and up 384 pixels".....that places us at the position 0,0....um right where we started!

4) still not done though....then we apply the "offset" (0,0). Ok this is easy. we don't go anywhere. To finish this portion with the setup of the navigation page....the item starts at the position 0,0 and stretches 1024 pixels right and 768 down (the entire screen).

Now let's go on to something that isnt circular. This is the next relevant item on the nav page layout:

[G31 I15]
Name=Geometric tools
Type=1026;Menu group
ItemID=0x31010000
ParentID=0x31000000
Pos=0,-448,400,300
Zone= 0 320 400 300 0 1 0x31000000 0 -1 0x31010000 0 1 0 20

Why is this so called "menu group" necessary? Grouping keeps related items together...all nice and neat. In this case, each of the nav map tools (ok almost all of them) are given the ParentID of the Geometric tools. This has the advantage of keeping them together and also making it easy to change the placement of all the tools. This is because the placement of the tools are all relative to the placement of the geometric tools item. If you move the geometric tools item, all items within the group are moved the same amount. This saves time going in and figuring out how to change the zone= line in each and every map tool item. You just have to change the zone= line in the geometric tools item.

OK now...just where is this Geometric tools item placed on the page? Actually, it isnt *really* placed on the page, it is invisible. But I have ways of showing you just where it is!. Lets start out like we did above and walk through this item.

1) We start out with the ParentID position of the geometric tools. The ParentID of the geometric tools refers to the Navigation Page that we set up above....We determined that the navigation page start position is 0,0. This is where we start here also.

2) we skip over the first few numbers and go straight fo0,r the element 0x31000000 0 -1. Now say along with me "go right 0 of the 0x31000000 item width and go down all of the 0x31000000 item height". the width and height of the 0x31000000 item is...again...1024x760. Starting at 0,0 we "go right 0 pixels, and down 768 pixels". This places us at 0,-768.....i.e. the bottom left of the screen.

3) now we apply the second element: 0x31010000 0 1 "go right 0, and now go up all the 0x31010000 item height". From the zone line of item 0x31010000, the width is 400 pixels and height is 300 pixels. OK now we start at the position 0,768 (from #3 above) and then move right 0 pixels and up 300 pixels. This places us at the position 0,-468.

4) again we are not done yet. We still have to apply the "offset": 0 20. From position 0,-468 we go right 0 pixels and up 20 pixels, that places us at the final position 0,-448.

How do we check we did things right? Just compare the final number from #4 with the first two numbers in the Pos= line. YUP THEY MATCH! YAY! We're cooking with fire now!






Now we have determined where the Geometric tools group is located, we are ready to place one of the tools on the navigation map page. I decided to use the Ruler for the example here, mainly because it is needed to show something afterwards. Lets now take a look at the Ruler item:

[G31 I22]
Name=Ruler
Type=1032;Button
ItemID=0x31010001
ParentID=0x31010000
Pos=-60,106,200,406
Zone= -60 426 200 406 0 1 0x31010000 0 -1 0x31010001 -0.3 1 0 0

1) I am only going to focus on the positioning of the ruler for now....and that means focusing on the Zone= line. But first we have to look at what the ruler's parent is....ParentID=0x31010000. The ParentID is the ID number of the Geometric Tools group. To place the ruler on the nav map, we need to place it relative to the start position of the Geometric Tools item that we determined above (0,-448)

2) 0x31010000 0 -1 -- right 0, down all the 0x31010000 item height. Starting at 0,-448, go right 0 pixels and down 300 pixels. This places us at 0,-748.

3) 0x31010001 -0.3 1 -- go left 3 tenths the width of the Ruler item and go up all of the Ruler height......3 tenths of the ruler width = 0.3x200 = 60 pixels. Full height of the ruler = 406 pixels. Now starting at 0,-748 we move left 60 pixels and move up 406 pixels. This leaves us at position -60,-342.

4) Apply offset (0,0) -- OK there is no offset...so final number = -60,-342. We check this with what the Pos= line says above and.....what??? they don't match! This is because the Pos= line actually gives the position relative to the parentID element....but trust me...it is right!.

One last thing about positioning. The seventh element in the Zone= line DOES NOT ALWAYS have to refer to the ParentID item. It can be any item on the page that the developer/modder wants to place it relative to. We can see this happening in the Tool Helper. The tool helper is place relative to the start position of the Ruler instead of the start position of the Geometric tools group



[G31 I16]
Name=Tool Helper
Type=1033;Check box
ItemID=0x3101000A
ParentID=0x31010000
Pos=20,186,160,80
Zone= 20 506 160 80 0 1 0x31010001 0 0 0x3101000A 0.5 1 0 0

I'll let you work out the math on this one (hopefully you followed me through the above examples to a T!). But to break it down, the start position here is the where we ended off with the Ruler (-60, -342). In this case we go right 80 pixels and up 80 pixels to find the Tool Helper starting point = 20,-262



I just want to remind you all that the numbers that I have calculated for the starting points for the items are using the top left of the screen as the 0,0 reference point. The first two numbers of the Zone= line uses the BOTTOM LEFT as the 0,0 reference point. You can actually verify the calculations I have done by adding 768 to the second number of the two. In the Tool Helper this means --- -262 + 768 = 506....the 20, 506 matches the first two numbers of the Zone= line.

Something that I want to note that I may have not mentioned earlier. The Pos= line IS NOT ACTIVE in this menu. I think it is just a holdover from SH3. It does play an informational purpose in pointing out relative spacing to the parent item. Also IN THE ABOVE EXAMPLES, the first two numbers of the Zone= line ARE NOT ACTIVE. In other words, if you change the first two numbers in this example, it does not do anything with the layout. THIS IS NOT ALWAYS SO! and I will explain under what conditions in the next part of the tutorial.

I think I will let this be the end of the first part of this tutorial. The next part of the tutorial will deal with conditional interpretations of the Zone= line along with some of the things I have learned about the other lines in individual items.
  Reply With Quote