Navigation

Making custom menus for mods (Adding customized buttons to main and ingame menus + customizing conne

Druglord

Member

Writing it here since I fucked something up with posting
Making a custom looking menu for the ingame menu is pretty simple. Basically all you will need to keep in it is the main MenuDef, and suggest that you keep the #define rows too.
You can delete the original code part

#include "ui_mp/ingamebg.inc"

#undef CHOICE_X_START
#define CHOICE_X_START -320

#undef CHOICE_HORIZONTAL_ALIGN
#define CHOICE_HORIZONTAL_ALIGN HORIZONTAL_ALIGN_CENTER

CHOICE_MENU_TITLE( "@MPUI_CHOOSE_TEAM" )

#include "ui_mp/tactical_map.inc";

#define BACK_OPEN ;
#include "ui_mp/navcontrols.inc"

CHOICE_HIGHLIGHT( 1, 0 )
CHOICE_BUTTON_VIS_NOHI( 1, "1. " + dvarString( g_TeamName_Allies ), play "mouse_click"; scriptMenuResponse "allies";, when( ( team( name ) == "TEAM_SPECTATOR" || team(name) == "TEAM_FREE" || team( name ) == "TEAM_AXIS" ) ); )
CHOICE_DBUTTON_VIS_NOHI( 1, "1. " + dvarString( g_TeamName_Allies ), when( team( name ) == "TEAM_ALLIES" ); )
CHOICE_HIGHLIGHT( 2, 0 )
CHOICE_BUTTON_VIS_NOHI( 2, "2. " + dvarString( g_TeamName_Axis ), play "mouse_click"; scriptMenuResponse "axis";, when( ( team( name ) == "TEAM_SPECTATOR" || team(name) == "TEAM_FREE" || team( name ) == "TEAM_ALLIES" ) ); )
CHOICE_DBUTTON_VIS_NOHI( 2, "2. " + dvarString( g_TeamName_Axis ), when( team( name ) == "TEAM_AXIS" ); )

CHOICE_HIGHLIGHT( 3, 0 )
CHOICE_BUTTON_VIS_NOHI( 3, "3. Auto-Assign", play "mouse_click"; scriptMenuResponse "autoassign";, 1 )

CHOICE_HIGHLIGHT( 4, 0 )
CHOICE_BUTTON_VIS_NOHI( 4, "4. Shoutcaster", play "mouse_click"; close self;scriptMenuResponse "shoutcast";, when( team( name ) != "TEAM_SPECTATOR" ); )
CHOICE_DBUTTON_VIS_NOHI( 4, "4. Shoutcaster", when( team( name ) == "TEAM_SPECTATOR" ); )

CHOICE_HIGHLIGHT( 5, when( team( name ) == "TEAM_FREE" ) )
CHOICE_BUTTON_VIS_NOHI( 5, "@MPUI_LEAVE_GAME", open popup_endgame, when(team(name) == "TEAM_FREE") )

execKey "1" { scriptMenuResponse "allies"; }
execKey "2" { scriptMenuResponse "axis"; }
execKey "3" { scriptMenuResponse "autoassign"; }
execKey "4" { scriptMenuResponse "shoutcast"; }



A item making is pretty simple as well

itemDef
{
visible 1
rect 30 /*This is align from left to right */ 80 /*Align from top to bottom */ 600 /* size of the item in pixels from left to right */ 300 /* size in pixels from top to bottom */
style WINDOW_STYLE_SHADER
background "ing_bg" // The item material name
decoration /* This row is optional, in ingame menu it can stay in but if you have this in main.menu file item of button then when pressing the button, it wont work*/
}




The align spot can change in rect since there is this behind some rect numbers ( HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_CENTER ) which says to mod to read start point in middle of the screen

The most common button uses 2 items off and on
Example
itemdef
{
rect 115 170 80 36
style WINDOW_STYLE_SHADER
type ITEM_TYPE_BUTTON
background "join"
visible 1
decoration
mouseenter {
play "mouse_over";
show "join_on";
}
mouseexit {
hide "join_on";
}
}
itemdef
{
name "join_on"
rect 115 170 80 36
style WINDOW_STYLE_SHADER
type ITEM_TYPE_BUTTON
background "join_on"
visible 0
decoration
action {
play "mouse_click";
close self;
scriptMenuResponse "autoassign";
}
}


First one is the normal which you will see when you open the menu in game, and second is when the mouse goes on the button. Ofcourse you can use same background but i like to keep 2 different ones. Again, If its menu like team_marinesopfor.menu then decoration line can stay but if its main.menu, it wont work
I got an example which should look the 2nd item for main since you can keep the first one like in previous ones

itemdef
{
name "menu_server_on"
rect 60 170 110 55
style WINDOW_STYLE_SHADER
type ITEM_TYPE_BUTTON
background "menu_server_on"
visible 0
action
{
play "mouse_click";
open pc_join_unranked;
}
}



This one is for to go into servers list
For asset manager. There aint many settings
Main things are
Entry - material
Materialtype - 2d
Surface - none
usage - not in editor
Blendfunc - I suggest either replace or blend (Blend is for transparent but you can use it for both)
In colormap part
no tile
nomip
Thats all

If you got additional questions, write in comments

Best Regards,
Druglord


Git Rekt m8!! smiley

Posted on 27.07.2017 / 21:34

REPLIES

Druglord

Member

Connect uses only the first itemDef in post since your mouse will be mainly freezed during your connection to server


Git Rekt m8!! smiley

Posted on 27.07.2017 / 21:35

Post reply

ONLY USERS CAN POST REPLIES.