View Single Post
Old 03-04-10, 07:16 AM   #2
karamazovnew
The Old Man
 
Join Date: Mar 2009
Location: Bucharest, Romania
Posts: 1,403
Downloads: 151
Uploads: 0


Default

CREATING NEW ITEMS

I always like to start with a blank page (literally) when I practice things so I'll create a new page and we'll mess it up as much as possible without the risk of breaking the game.

So what are Pages/Groups? They are invisible items that have a specific position, resolution scaling and dimensions. You can place anything inside them and when you move them, all the items will move as a group (duh).

I have no idea in what way a Page is different from a Group. They're probably accessed differently by the hardcode. In SH4 it was possible to show the Periscope Interface 3D while on the Bridge or at the Hydrophone Station. So for now let's just say that Pages are "Screens": the periscope screen, the map screen and so on.

In SH3 and SH4, all Pages were sitting in one humongous file, the dreaded menu_1024_768.ini file. Things have changed FOR THE BETTER.
We can now save each page in its own file. Thus mods can now tackle particular screens, without the risk of major incompatibility.
All the files that make up the interface sit inside the \data\Menu\Pages folder. So make sure you back up that folder before you begin modding. Or use JSGME.

Can we create new pages? Hell yeah!

Just Right click on the Root Parent in the Control Panel list...



In the new dialog box, just enter a good name and, if you want, a specific ID. Don't worry about existing items, the edit will not let you create duplicates:



For example, I've just created 2 items, a Page called Karamazov and a group called Karamazovgroup. After I saved here's what happened:



The proper files were created. Both new items were added to the menu_1024_768.ini file (which now acts as an index for all the pages). You might also see that any new page is automatically configured to fill the entire screen on any resolution (more about that later). Both new items appear just under the Root Menu, first in the list. But you can drag/drop them to any place you want. This will have an effect on the order in which these pages appear on screen. More about that later, but remember that the any item will appear BEHIND any item that is further down in the list. In other words, any new item that you've just created inside a group/page will always be behind any other items that were already in that group. I'll come back to this in just a second.

Let's add a new item to my Karamazov page. I will right click on it and get the following menu:



- Change ID: allows you to input a custom ID.
- Add Controls group: allows you to create a group. You can create as many nested groups as you want, even if only to keep the list tidy for easy modding
- Add Control: Create a new item inside the group. Here's the control box you get when you click it:



You can now select the type of item you want to create. Be careful as this is the only time you can do this. If you change your mind later, you'll have to delete this and create a new item.
Also notice that the ID input box is dynamic. When we created the Page we were only allowed to change the first 2 numbers in the string. We are now allowed to change the last 4 items in the string. This is done to prevent a mess up of the ID's and also to keep things simple to read for you:

-Any page or main group (the ones just below the root) will have this pattern: XX000000. So you have a maximum of 196 pages available to you. Remember that all of these get their own file!
My Karamazovgroup item got the ID of: 1B000000.
-Any group inside a page will inherit the ID of the parent. So any groups that I create inside my Karamazovgroup will look like this: 1BXX0000. It doesn't matter how they're nested together (unless you write this in binary code ). Thus you can create a total of 196 groups in any page!
For example, I create a new group that receives the ID of: 1B010000
- Any item that is placed inside this group will have this pattern: 1B01XXXX. In other words I am able to create 9999 items inside ANY on of my 196 total possible groups in ANY 196 pages. That's a LOT of possible items

So what items can we create? Here's a quick list:
Static Text, Static BMP, Static BMP Array, Button, Checkbox, Slider, EditBox, Radio button, EditBox, Move, Progress, TabControl, DetectMouse, etc., etc.,etc.


Renaming items

To rename an item, first select it in the list by clicking on it in the list. Then, after half a second or so, click it again. Don't rapidly double click or it won't work.


Deleting Items

At the moment refrain yourself from deleting any original game items. It might cause crashes. If you want to remove an item from the screen, just move it outside of the viewport (I'll explain how in the next post). The only way to delete items is to Right click on them in the list and select Delete from the menu.


Changing the Order of the items inside a group

For the next example I have created the following structure:
1. I created GROUP 1
2. I created a Progress Bar inside GROUP 1
3. I created a Static Text inside Group 1
4. I created GROUP 2

I then moved the items with my mouse in the Preview Screen:



As you can see, the LAST item you create is placed at the TOP of the list. But in the game, the LAST item is always shown Behind all the other objects in the group.
Note that the text ("TO GAME") is behind the progress bar picture. Also note that items don't need to be positioned INSIDE the bounding box of a group. The Static Text Object is completely outside GROUP1. To make the Text appear in front of the Progress Bar Image you just need to drag it BELOW, in the list.



As you can see, the text now appears on top of the image. The same rule and method applies to groups, parent groups and pages. Dragging an item in the list will only change the order inside it's group. You can't drag and drop any item into another group. You'll need to use Copy/Cut/Paste to do that.

To delete an item simply right click on it in the list and select delete. Please note that the editor doesn't automatically renumber the other items. For example:
- my "New Progress bar" object has an ID of 01010001 (as it was the first item I created inside the first group inside the first page).
- my "New Static text" object has an ID of 01010002. It figures, since it was the second object I created.
If I now delete the Progress Bar, the static text will not automatically be renumbered. However the next item I create inside that group will automatically be given the first id available (01010001). The order in which objects appear on the screen has nothing to do with these ID's. The only thing that counts is the order in the list (and thus, in the .ini file of that page). SH3+SH4 UI modders already know this, of course... Just moving objects around in the list by dragging them will thus never change the ID's.

NOTE: How can you see an ID? Just right click the item in the list and select "Change ID" or simply look down a few lines:





Cut/Copy/Paste:

Sure we can drag GROUP1 behind or on top of GROUP2. But what if we wanted to move GROUP1 INSIDE GROUP2? We can't do that with dragging. So we'll just
1. Right Click on GROUP1 and select CUT
2. Right Click on GROUP2 and select PASTE



GROUP1 and all of its items will be moved to GROUP2 (at the top of the list, by the way).

If we instead copy GROUP1 to GROUP2, we'll get this:



As you can see, they have the same names. But their IDs are different. Can you guess how?
- The new GROUP1 is now the third group in my page so it will have an ID of: 01030000
- The old Progress bar had an id of 01010002, so can you guess what ID it will have now? 01030002.
- Similarly, the new text object will have an ID of 01030001.

Now because the ID's have the format of: PG.GR.ITEM (page.group.item or xxyyzzzz), if you copy or cut items from one page to another they will automatically inherit the Page ID of the destination AND be assigned the first free Group or Item ID available.

Thus,you easily copy buttons, dials, even entire groups from one page to another, or even inside the same page, or even inside the same group and you don't need to worry about their order or ID's. If the similar names annoy you, just rename them. And yes, you can rename all the items to "Mini Me" if you want to... the game won't care.

There is no longer any need for renumbering items in the ini files, it's all done for you when you save.

Last edited by karamazovnew; 03-04-10 at 04:43 PM.
karamazovnew is offline   Reply With Quote