Custom Menu Files

Have a question about modding, modelling or skinning? Have a tutorial to post? Post here!

Moderator: Core Staff

Post Reply
ekat
CJ Newbie
CJ Newbie
Posts: 53
Joined: September 15th, 2010, 4:56 pm

Custom Menu Files

Post by ekat » May 11th, 2013, 2:46 pm

Hey guys..
I'm currently working on the custom menu files for my mod.
Everything works fine but i have some questions..

1.
In some of the menu files there are some "\" at the end of the lines.
What is that for?

Code: Select all

textalign       ITEM_ALIGN_MIDDLE_LEFT \
textscale      CHOICE_TEXTSIZE \
textstyle       ITEM_TEXTSTYLE_SHADOWED \
style            WINDOW_STYLE_FILLED \
forecolor      CHOICE_TEXTCOLOR \
visible          visArg ; \
decoration    \
2.
I want to modify the menu files so its only possible to join "allies" and "spectator" on connect and ingame by pressing esc.
The only file i found is "team_marinesopfor_mw.menu" and "class.menu" but if i change something about the teams its seems like there are no changes ingame.. o.O Did i missed something in all these files? :(

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Custom Menu Files

Post by Drofder2004 » May 11th, 2013, 5:03 pm

1.
These I think are for menu definitions only. I would say they are line continuations for the template that makes up the defined control. There is no reason to use while makign menu, unless you are defining some new structures. This is a 'best guess' answer.

2.
The team chosen is defined in the menu but is easier to adjust by editing the GSC files.
For menu edit, these are the two lines in "team_marinesopfor.menu".

Code: Select all

 
// Team Axis. Only visible when current team is "spectator or 'no team')
CHOICE_BUTTON_VIS( 1, "@" + dvarString( g_TeamName_Axis ), play "mouse_click"; scriptMenuResponse "axis";, when( team( name ) == "TEAM_SPECTATOR" || team(name) == "TEAM_FREE" ); )
 
// Team Allies. Only if NOT on team Allies
CHOICE_BUTTON_VIS_NOHI( 2, "@" + dvarString( g_TeamName_Allies ), play "mouse_click"; scriptMenuResponse "allies";, when( team( name ) == "TEAM_AXIS" || team( name ) == "TEAM_SPECTATOR" || team(name) == "TEAM_FREE" ); )
 
// Team Axis. Only visible when on team Allies.
CHOICE_BUTTON_VIS_NOHI( 2, "@" + dvarString( g_TeamName_Axis ), play "mouse_click"; scriptMenuResponse "axis";, when( team( name ) == "TEAM_ALLIES" ); )        
 
// Team Random. Always visible.
CHOICE_BUTTON_EX( 3, "@MPUI_AUTOASSIGN", play "mouse_click"; scriptMenuResponse "autoassign";, name "auto_assign" )     
 
// Team Spectator. Only visible when NOT spectator and spectator is enabled.
CHOICE_BUTTON_VIS_NOHI( 4, "@MPUI_SPECTATOR", play "mouse_click"; scriptMenuResponse "spectator";, when( team( name ) != "TEAM_SPECTATOR" && dvarbool( scr_game_spectatetype ) ); )
[/size]

You only need two buttons. You do not need either Team Axis or Team Random.
That leaves the two. Remove the lines you no longer need.

This will now have some functionality, but you will need to move the buttons in to the correct index order.

The Spectate & Allies button will share the same button space, so they should also share the same index (1).
This button also requires a 'BG' and 'HIGHLIGHT' setting, again index (1).
Next, we want the Spacer, the spacer must share the same index of the item it will com after, so again index (1).
Then the last 3 options (controls, options, leave) (index 2-4).

Because "MENU_CONTROLS" no longer shares a button with "SPECTATOR", you can change the button type from
"CHOICE_BUTTON_VIS_NOHI", to "CHOICE_BUTTON_VIS" and also remove the corresponding 'BG' and 'HIGHLIGHT' settings.

Finally, you want to play with the "visible" settings.
When you join the game, you are set to spectator, so you should only be able to see the "Allies" button.
When you join Allies, you want them to swap.

You do not need to touch the spectator visibility, as that will show when on a team. However you will need to make sure the Allies button displays ONLY when in spectate.

The final code with all the above changes, can be found below.

Code: Select all

CHOICE_BUTTON_BG( 1, 1 )
CHOICE_HIGHLIGHT( 1, 1 )
CHOICE_BUTTON_VIS_NOHI( 1, "@" + dvarString( g_TeamName_Allies ), play "mouse_click"; scriptMenuResponse "allies";, when( team( name ) == "TEAM_SPECTATOR"); )
CHOICE_BUTTON_VIS_NOHI( 1, "@MPUI_SPECTATOR", play "mouse_click"; scriptMenuResponse "spectator";, when( team( name ) != "TEAM_SPECTATOR" && dvarbool( scr_game_spectatetype ) ); )
CHOICE_SEPARATOR( 1 )
 
CHOICE_BUTTON_VIS( 2, "@MENU_CONTROLS", close self; open main_controls;, when( team( name ) == "TEAM_SPECTATOR" ) )
CHOICE_BUTTON_VIS( 3, "@MENU_OPTIONS", close self; open main_options; execnow "set ui_allow_graphic_change 0";, when( team( name ) == "TEAM_SPECTATOR" ) )
CHOICE_BUTTON_VIS( 4, "@MPUI_LEAVE_GAME", open popup_endgame, when( team( name ) == "TEAM_SPECTATOR" ) )
[/size]

To get the code to work in-game:
- Save the file with exact same name "team_marinesopfor.menu".
- Place this files inside: {CoD4}/mods/{Mod_Name}/ui_mp/scriptmenus/
- Now, open "modbuilder.exe". If you do not have a CSV, click "New CSV" after selecting your mod from the drop down.
(You will NOT be able to move the menu file into the CSV from here - it is not supported.)
- Once you have saved your CSV, change to the "MOD Builder" tab.
- Select your Mod in the 1st box and your FF CSV in the 2nd box.
- You need to add the following line manually:

Code: Select all

menufile,ui_mp/scriptmenus/team_marinesopfor.menu
Now save the CSV.
- You can now build your mod.
(Before building your mod, click the "Run Game" tab and make sure MP and your mod are selected. I also add "+developer 1 +devmap mp_backlot" in the Custom Parameters box - to instantly run a map)
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

ekat
CJ Newbie
CJ Newbie
Posts: 53
Joined: September 15th, 2010, 4:56 pm

Re: Custom Menu Files

Post by ekat » May 11th, 2013, 6:37 pm

Drofder2004 wrote:The team chosen is defined in the menu but is easier to adjust by editing the GSC files.
I thought menu files are the simplest way to edit menus? :D
Now I'm curious.. Would you maybe explain me how to set this changes up with gsc? o.O

For menu files:
I changed everything in the menu files and its working fine, i had only to change the CHOICE_SEP...^^
Thank you! :P

User avatar
Drofder2004
Core Staff
Core Staff
Posts: 13313
Joined: April 13th, 2005, 8:22 pm
Location: UK, London

Re: Custom Menu Files

Post by Drofder2004 » May 11th, 2013, 9:46 pm

There is one thing you NEED to change.
/openscriptmenu team_marinesopfor axis

That code still gives you Opfor. You need to go into "_menus.gsc" and find the response relating to [[level.axis]]();
and either change it or comment it out.

The reason I say it is easier to change it via GSC was not the look but the functionality
You can change the functionality of the button response by changing the response function. This is how the CJ mod used to work - all buttons spawned allies. Obviously the end result is always nicer and more professional looking to change the design.
Image
Virgin Media 20Mb Broadband:
"Perfect for families going online at the same time, downloading movies, online gaming and more."
Borked internet since: 22-07-2010

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests