![]() |
[TEC] Adding Items in the Menu Editor Tutorial
Hi I have been trying for the last few weeks to get my head around using the Editor and scripting to create useable object ingame for Modding.
I was getting nowhere fast till ThedarkWraith stepped in and offered me his help. I have used his expertise advice to create a Tutorial on getting started with Modding for Silent Hunter 5 via the use of The Built in Menu Editor, editing of cfg files and the generation of script files. Most of the work here is from TheDarkWraith checking and correcting the work I was doing to learn these steps. I have decided to do up what I've learned so far in the hope it well help others that were in the same situation as me (Banging there heads and getting nowhere fast). First This is available to download in PDF format here: The PDF version includes some notes on top of Pics to show whats going on. (Not in the online version) http://rapidshare.com/files/367306675/Adding_Items_in_the_SH5_Editor_Tutorial.pdf Also the files that were created in this tutorial are availabe here also: http://rapidshare.com/files/367307917/Tutorial_Files.rar Now then on to the Tutorial: Adding Dial’s via the Menu Editor Adding a single dial is a very simple evolution. If you want to teach yourself how do this: using the Menu Editor: We want to add the heading/rudder dial to PageTDC. In Page layout find the Heading group (it's under Group feedback) http://i1004.photobucket.com/albums/...torial/001.jpg http://i1004.photobucket.com/albums/...torial/002.jpg Now copy its entire tree over to PageTDC. ( You can right click on Heading and select Copy then right click on Page TDC and select Paste.) Now when I say the entire tree I'm talking about its anchor group. What denotes an anchor group? The big 'G' in the box. For heading it's 'Heading'. Now if you just copy over heading and think you got a dial you are wrong. The 'whole' dial consists of 'Heading' - a Group, 'Rudder' - a Group, 'Toggle Rudder Heading Around' - a button, and 'Toggle Rudder Heading' - a button. How do I know this? Two ways. One is that when I click on each one I get a yellow outline box on the editor that shows me graphically that it's part of the whole dial. Two, as I click on each one in the menu editor and I look in the zone section I see that the anchor refers to some part of the dial (it doesn't have to but doing so keeps the coherency of the object). You'll notice that the button 'Toggle Rudder Heading' anchor is 'Bkgr'. http://i1004.photobucket.com/albums/...torial/003.jpg You should end up with 2 Groups Rudder and Heading and 2 Buttons (Bt) Toggle Rudder Heading and Toggle Rudder Heading Around. Now after you've copied all those items over to PageTDC you need to check their anchors. You'll notice that 'Toggle Rudder Heading' anchor is set to Null now. Why? Well before it referenced an item in Page layout but we're now in PageTDC so obviously that page doesn't exist here. http://i1004.photobucket.com/albums/...torial/004.jpg I would set the 'Toggle Rudder Heading' anchor to the object on PageTDC that you want this dial to be anchored to. Best thing to do is set the anchors of all the copied objects to reflect the values of the object you copied from in the other page. After setting all the anchors to the values they should be, moving the 'Toggle Rudder Heading' will cause the whole dial to move with it (if all the anchors are setup to reference one another in the object). If one of the anchors is set to reference some other object then that part won't move when you move 'Toggle Rudder Heading'. http://i1004.photobucket.com/albums/...torial/005.jpg Okay so now we have a new dial on PageTDC. But how do we get the game to update it? That's the easy part. Go back to the page you copied this new dial from. I'll use the Heading/Rudder here as an example. For the game to update a dial it needs 3 pieces of information: the dial, the current value, and the new value. Open up the file \data\Menu\cfg\Dials.cfg. http://i1004.photobucket.com/albums/...torial/006.jpg This is where we define the dials. Do a search for 'CompassFdbk'. This dial, [Dial22] is responsible for updating the 'Heading' dial in Page layout. How do I know this? Easy. Look at the values for CrtVal (current value), NewVal (new value), and Dial. They start with 3F (0x just means this is a hex value). If we go back to the menu editor and go to Page layout we see that its ID is 3F000000. If we find the values for CrtVal, NewVal, and Dial on Page layout we see that they reference objects of the dial in question (parts of the Heading dial). http://i1004.photobucket.com/albums/...torial/007.jpg Now if you correlate the CrtVal, NewVal, and Dial to the objects on the screen you can see what is controlling what. After you denote the correlation then add another entry to Dials.cfg at the bottom. Copy the whole entry for [Dial22] to the bottom and give it the next number in the chain (if you're using the stock file the next number will be 75. Now change the CrtVal, NewVal, and Dial IDs on this new entry to reflect the IDs of the dial on PageTDC. http://i1004.photobucket.com/albums/...torial/008.jpg But wait we're not done yet !!! This dial has two states - Heading and Rudder. We have to create another entry in Dials.cfg. But what is this entry? Well I know that rudder needs to look like the entry [Dial21] (RudderFdbk). So copy the whole entry for [Dial21] to the bottom of Dials.cfg and give it the next number in the chain (would be 76 with stock file). Now these names - RudderFdbk, SpeedFdbk, etc. can be anything you want to call them for your new dials. Change the IDs of the new dial entry to reflect the object in PageTDC (parts of the Rudder dial). http://i1004.photobucket.com/albums/...torial/009.jpg Don't forget to change the Dials.cfg's top number 'DialsNo=' to one plus the last entry in the chain of dials (its zero based). For our example that line should read 'DialsNo=77'. Save the file. http://i1004.photobucket.com/albums/...torial/010.jpg So far we have only edited 2 files: Page TDC.ini - (\data\Menu\PagesPage TDC.ini) and Dials.cfg - (\data\Menu\cfg\Dials.cfg). You can back these up into another folder for use in your own Mod. Now before we can see our newly placed dial on screen we need a way for the page to tell the TDC to load up. To do that were going to need the help of Scripting. End of Part 1 |
Part 2 Tutorial
Ok onto Scripting:
Open up an empty script like:- Periscope.py (\data\Scripts\Menu\Page Attack Periscope.py) The reason for this is that we need to tell the periscope to display the TDC Page when we go to that station. Note: Do not just copy and paste as the scripts will not work unless proper formatted, use of proper tabbing must be used (Not spaces). This is what is displayed when opened **IMPORTANT NOTE** Where [TAB] is shown in scripts is just to show here in the forum that a Tab is used to indentate that line in the script to not type in [TAB]. Tabulation is very importatnat in pyton scripting to work correctly. def InitializeScript(): [TAB] pass def StartGame(): [TAB] pass def EndGame(): [TAB] pass def UnloadScript(): [TAB] pass Nowsave a copy of this as Page TDC.py, That will setup the TDC page to be used as an overlay screen that can be imported into other screens like the Periscope and UZO. Next open up the Script file for the screen you want your new TDC script to open in. For example if you want your Dial that you created in the TDC Page to show in the Periscope view, we need to tell the Attack Periscope script to import our TDC page as follows: Ok lets open up (\data\Scripts\Menu\Page Attack Periscope.py) and change it to this: Note: Do not just copy and paste as the scripts will not work unless proper formatted, use of proper tabbing must be used (Not spaces). # Globals ShowTDC = True #Page attack periscope.py from menu import * def InitializeScript(): [TAB] Menu.PageActivated += Menu_PageActivated [TAB] Menu.PageDeactivated += Menu_PageDeactivated [TAB] Menu_PageActivated( Pageattackperiscope ) def StartGame(): [TAB] pass def Menu_PageActivated( page ): [TAB] if page == Pageattackperiscope: [TAB] global ShowTDC [TAB] if ShowTDC: [TAB] [TAB] from PageTDC import PageTDC [TAB] [TAB] PageTDC.Visible = True def Menu_PageDeactivated( page ): [TAB] if page == Pageattackperiscope: [TAB] global ShowTDC [TAB] if ShowTDC: [TAB] [TAB] from PageTDC import PageTDC [TAB] [TAB] PageTDC.Visible = False def EndGame(): [TAB] pass def UnloadScript(): [TAB] Menu.PageActivated -= Menu_PageActivated [TAB] Menu.PageDeactivated -= Menu_PageDeactivated Now what’s that all about then...... Let’s break up into all its bits: First of all anything with a # in front of it is a comment and is ignored by the script. e.g: #Page attack periscope.py This is just a note showing the name of the script. Next we have: # Globals Here were going to set our Globals (Variables). We have set up one global – ShowTDC and have given it the Value True (ShowTDC = True). Next: def InitializeScript(): [TAB] Menu.PageActivated += Menu_PageActivated [TAB] Menu.PageDeactivated += Menu_PageDeactivated [TAB] Menu_PageActivated( Pageattackperiscope ) This is just initialising the script. def Menu_PageActivated( page ): [TAB] if page == Pageattackperiscope: [TAB] global ShowTDC [TAB] if ShowTDC: [TAB] [TAB] from PageTDC import PageTDC [TAB] [TAB] PageTDC.Visible = True Here we are telling are importing the Page TDC into the Page Attack Periscope and making it visible. def Menu_PageDeactivated( page ): [TAB] if page == Pageattackperiscope: [TAB] global ShowTDC [TAB] if ShowTDC: [TAB] [TAB] from PageTDC import PageTDC [TAB] [TAB] PageTDC.Visible = False Now the opposite we are unloading The Page TDC and making it hidden, for when we close the Page Attack Periscope screen. def UnloadScript(): [TAB] Menu.PageActivated -= Menu_PageActivated [TAB] Menu.PageDeactivated -= Menu_PageDeactivated And last of all we unload the script. So far we have only edited 2 script files: Page TDC.py - (\data\Scripts\Menu\Page TDC.py) and, Page Attack Periscope - (\data\Scripts\Menu\Page Attack Periscope.py) You can back these up into another folder for use in your own Mod. Ok that’s done let’s launch the game and head to the Periscope to see our newly installed Dial. http://i1004.photobucket.com/albums/...torial/011.jpg http://i1004.photobucket.com/albums/...torial/012.jpg Are we done yet? Nope. We have a new dial on PageTDC. The game will update it. But the game will not switch it between states - Heading/Rudder. Why? Because the original dial's 'Toggle Rudder Heading' ID is hard coded in the game. The game recognizes 'events' from that ID and responds to them. Your new 'Toggle Rudder Heading' ID means nothing to it. So you have to get creative and create some python code to make it switch states! Where do you place this python code? In PageTDC.py. Reopen the Page TDC.py file from earlier and edit to look like the following: #Page TDC.py # Globals HeadingShown = False def InitializeScript(): [TAB] PageTDC_HeadingRudder.Visible = True [TAB] PageTDC_HeadingRudder_ToggleRudderHeading.Clicked += ToggleRudderHeading [TAB] PageTDC_HeadingRudder_ToggleRudderHeading.Visible = True # set the dial to Heading mode [TAB] ToggleRudderHeading( None ) def StartGame(): [TAB] pass def ToggleRudderHeading( sender ): [TAB] global HeadingShown [TAB] HeadingShown = not HeadingShown [TAB] PageTDC_HeadingRudder_Heading.Visible = HeadingShown [TAB] for item in PageTDC_HeadingRudder_Heading.Controls: [TAB] [TAB] item.Visible = HeadingShown [TAB] PageTDC_HeadingRudder_Rudder.Visible = not HeadingShown [TAB] for item in PageTDC_HeadingRudder_Rudder.Controls: [TAB] [TAB] item.Visible = not HeadingShown def EndGame(): [TAB] pass def UnloadScript(): [TAB] PageTDC_HeadingRudder_ToggleRudderHeading.Clicked -= ToggleRudderHeading [TAB] Pass Now on going back into the Game you should have a fully toggle type Dial. Click in the bow just under the Dial to switch between Heading and Rudder. If you run the game in windowed mode and set the following file to allow developing mode: (\*Your User Name*\Documents\SH5\data\cfg\Main.cfg) [DEVELOPING] Modding=Yes MenuEditor=Yes DebugScripts=Yes Now if you run the Game you can right click the Top bar and select Scripting Editor, this allows you to edit your scripts ingame. http://i1004.photobucket.com/albums/...rial/013-1.jpg And here’s Your fully clickable dial in game on the Periscope Screen. http://i1004.photobucket.com/albums/...rial/014-1.jpg http://i1004.photobucket.com/albums/...rial/015-1.jpg Good Luck. And keep the Mod’s flowing. Written by Reaper7 for the Silent Hunter 5 Community. This was all possible by the continued help of TheDarkWraith Check out his excellent Mod’s on the SH5 Mod’s Forum. |
Interesting and thanx for posting
Will have a look through it Though the black text in your post is impossible to read :doh: Had to highlight it to see it Guess we have different forum skins chosen |
No problem can change the text colour -The PDF version is a more readable format and has some overlay text on the pics that didn't seem to convert from the PDF version when uploading to photobucket.. :)
|
the only comment I have to make is Python is very picky about identation as it defines the flow. With no identation in the examples users will have a hard time getting files to work correctly. Othen than that :yeah:
|
Guys, do yourself a favour and forget editing in notepad.
Use UltraEdit, is the BEST editor out-there. And it also has language words for Python, as in it recognizes Python script files and displays them in a special way. You can also write you own custom language files for it, as in a SH5 scripting language file. |
Quote:
I recommend that ye download the Files in the rar files also as this has the actual files created with the proper indentation included. :up: I have reedited the script section above placing the word [TAB] to show where to place an indentation using the tab key on the keyboard. |
Quote:
use notepad++, its free. and has all the features you'd want. |
Quote:
Quote:
|
Sorry for stupid question, but where i can find Menu Editor? Or how can i launch it?
|
Quote:
\Documents\SH5\data\cfg\Main.cfg Change the following lines to whats shown here: [DEVELOPING] ;Modding=Yes ;MenuEditor=Yes ;DebugScripts=Yes To: [DEVELOPING] Modding=Yes MenuEditor=Yes DebugScripts=Yes Now when you start the Game a dialog box will ask if you want to run the Editor. Just select yes to run or No to run the game. :up: |
Thank you very much, reaper7! For manual and for help. It very useful.
:salute: |
This is just what I what looking for to cut my modding teeth. Thanks a million guys.:salute:
|
Cool... bookmarked :yeah:
|
Quote:
|
All times are GMT -5. The time now is 05:14 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 1995- 2025 Subsim®
"Subsim" is a registered trademark, all rights reserved.