#include "ui/menudef.h"
#include "ui_mp/common_macro.inc"
#include "ui/framestyle.inc"
#include "ui_mp/newframe.inc"
#include "ui/choices_setup_common.menu"
#include "ui_mp/custom_mode_layout.inc"
#include "ui_mp/custom_mode.inc"

#undef CHOICE_Y_START
#define CHOICE_Y_START			-150

#undef CHOICE_X_START
#define CHOICE_X_START			-200

#ifdef PC
#undef CHOICE_TEXTSIZE
#define CHOICE_TEXTSIZE			TEXTSIZE_DEFAULT
#endif //#ifdef PC

#define SERVERSETTINGS_NAME_X					40
#define SERVERSETTINGS_NAME_Y					(80)
#define SERVERSETTINGS_NAME_SIZE				SERVERSETTINGS_IMAGE_WIDTH 30

#define SERVERSETTINGS_IMAGE_X				SERVERSETTINGS_NAME_X
#define SERVERSETTINGS_IMAGE_Y				(CHOICE_Y_START - 170)
#define SERVERSETTINGS_IMAGE_ASPECT_RATIO		1.0
#define SERVERSETTINGS_IMAGE_WIDTH			180
#define SERVERSETTINGS_IMAGE_HEIGHT			(SERVERSETTINGS_IMAGE_WIDTH * SERVERSETTINGS_IMAGE_ASPECT_RATIO)
#define SERVERSETTINGS_IMAGE_SIZE				SERVERSETTINGS_IMAGE_WIDTH SERVERSETTINGS_IMAGE_HEIGHT

#define SERVERSETTINGS_DESC_X					0
#define SERVERSETTINGS_DESC_Y					(CHOICE_Y_START + 20)
#define SERVERSETTINGS_DESC_SIZE				244 60

#undef DEFAULT_SLIDE_IN_SPEED
#define DEFAULT_SLIDE_IN_SPEED					180

#undef DEFAULT_SLIDE_OUT_SPEED
#define DEFAULT_SLIDE_OUT_SPEED					180

#define CHOICE_BUTTON_NAME				"SERVERSETTINGS_"
#define MENUDEF_NAME					server_settings

#define SERVERSETTINGS_FRAME_WIDTH NEW_FRAME_DEFAULT_WIDTH
#define SERVERSETTINGS_FRAME_HEIGHT NEW_FRAME_DEFAULT_HEIGHT

#undef ON_ESC
#define ON_ESC							\
	play uin_navigation_menu_lg_close;	\
	close self;

menuDef
{
	name					MENUDEF_NAME
	rect					0 0 640 480 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_FULLSCREEN
	focuscolor				COLOR_FOCUSED
	style					WINDOW_STYLE_FILLED
	soundloop 				MENU_MUSIC
	openSlideSpeed			DEFAULT_SLIDE_IN_SPEED
	closeSlideSpeed			DEFAULT_SLIDE_OUT_SPEED
	openSlideDirection		MENU_SLIDE_DIRECTION_TOP_TO_BOTTOM
	closeSlideDirection		MENU_SLIDE_DIRECTION_TOP_TO_BOTTOM

	onOpen	
	{
		activateBlur;
		play uin_navigation_menu_lg_open;
		setdvar invite_visible "0"; 
	}
	onFocus { }
	onClose
	{
		deactivateBlur;
		setdvar invite_visible "1";
	}
	onESC
	{
		ON_ESC
	}

	NEW_FRAME( SERVERSETTINGS_FRAME_WIDTH, SERVERSETTINGS_FRAME_HEIGHT )
	NEW_FRAME_TITLE( SERVERSETTINGS_FRAME_WIDTH, SERVERSETTINGS_FRAME_HEIGHT, "@MENU_SERVER_SETTINGS_CAPS", 1 )

	// Server Name
	FRAME_CHOICE_DVAREDIT_FOCUS_VIS_EX(			2, "@PATCH_SERVER_NAME_CAPS",
												"sv_hostname", 20, 20,
												;,
												SET_CHOICE_DESC( "", "@PATCH_SERVER_NAME_DESC", "" ),
												CLEAR_CHOICE_DESC, 1, ; )

	// Minimum Ping
	FRAME_CHOICE_DVAREDIT_NUMERIC_FOCUS_VIS_EX(	4, "@PATCH_MINIMUM_PING_CAPS",
												"sv_minping", 4,
												;,
												SET_CHOICE_DESC( "", "@PATCH_MINIMUM_PING_DESC", "" ),
												CLEAR_CHOICE_DESC, 1, ; )

	// Maximum Ping
	FRAME_CHOICE_DVAREDIT_NUMERIC_FOCUS_VIS_EX(	5, "@PATCH_MAXIMUM_PING_CAPS",
												"sv_maxping", 4,
												;,
												SET_CHOICE_DESC( "", "@PATCH_MAXIMUM_PING_DESC", "" ),
												CLEAR_CHOICE_DESC, 1, ; )

	// Password
	FRAME_CHOICE_DVAREDIT_FOCUS_VIS_EX(			6, "@PATCH_PASSWORD1_CAPS",
												"g_password", 12, 12,
												;,
												SET_CHOICE_DESC( "", "@PATCH_PASSWORD_DESC", "" ),
												CLEAR_CHOICE_DESC, 1, ; )

	// Voice Chat Enabled
	FRAME_CHOICE_DVARYESNO_FOCUS_VIS_EX(		7, "@MENU_VOICECHAT_CAPS",
												"sv_voice", 
												;,
												SET_CHOICE_DESC( "", "@PATCH_VOICECHAT_DESC", "" ),
												CLEAR_CHOICE_DESC, 1, ; )

	// Team Change Enabled
	FRAME_CHOICE_DVARYESNO_FOCUS_VIS_EX(		8, "@PATCH_MP_TEAMCHANGE_ALLOW_CAPS",
												"g_allow_teamchange", 
												;,
												SET_CHOICE_DESC( "", "@PATCH_MP_TEAMCHANGE_ALLOW_DESC", "" ),
												CLEAR_CHOICE_DESC, 1, ; )


	// Team Change Keep Balanced
	FRAME_CHOICE_DVARYESNO_FOCUS_VIS_EX(		9, "@PATCH_MP_TEAMCHANGE_KEEPBALANCED_CAPS",
												"g_teamchange_keepbalanced", 
												;,
												SET_CHOICE_DESC( "", "@PATCH_MP_TEAMCHANGE_KEEPBALANCED_DESC", "" ),
												CLEAR_CHOICE_DESC, 1, ; )

	// Team Change Grace Period
	FRAME_CHOICE_DVAREDIT_NUMERIC_FOCUS_VIS_EX(	10, "@PATCH_MP_TEAMCHANGE_GRACEPERIOD_CAPS",
												"g_teamchange_graceperiod", 4,
												;,
												SET_CHOICE_DESC( "", "@PATCH_MP_TEAMCHANGE_GRACEPERIOD_DESC", "" ),
												CLEAR_CHOICE_DESC, 1, ; )

	// Auto-Balance Enabled
	FRAME_CHOICE_DVARYESNO_FOCUS_VIS_EX(		11, "@PATCH_AUTOBALANCE_TEAMS_CAPS",
												"scr_teambalance", 
												;,
												SET_CHOICE_DESC( "", "@PATCH_AUTO_BALANCE_DESC", "" ),
												CLEAR_CHOICE_DESC, 1, ; )


	// Voting Enabled
	FRAME_CHOICE_DVARYESNO_FOCUS_VIS_EX(		12, "@PATCH_ALLOW_VOTING_CAPS",
												"g_allowvote", 
												;,
												SET_CHOICE_DESC( "", "@PATCH_ALLOW_VOTING_DESC", "" ),
												CLEAR_CHOICE_DESC, 1, ; )

	// Pre-game enabled
	FRAME_CHOICE_DVARYESNO_FOCUS_VIS_EX(		13, "@PATCH_PREGAME_ENABLED_CAPS",
												"g_pregame_enabled", 
												;,
												SET_CHOICE_DESC( "", "@PATCH_PRE_MATCH_DESC", "" ),
												CLEAR_CHOICE_DESC, 1, ; )

	// Pre-game min players
	FRAME_CHOICE_DVAREDIT_NUMERIC_FOCUS_VIS_EX(	14, "@PATCH_PREGAME_MINPLAYERS_CAPS",
												"party_minplayers", 3,
												;,
												SET_CHOICE_DESC( "", "@PATCH_MINIMUM_PLAYERS_DESC", "" ),
												CLEAR_CHOICE_DESC, 1, ; )

	// Maximum Players
	FRAME_CHOICE_DVAREDIT_NUMERIC_FOCUS_VIS_EX(	15, "@PATCH_MAXIMUM_PLAYERS_CAPS",
												"sv_maxclients", 3,
												;,
												SET_CHOICE_DESC( "", "@PATCH_MAXIMUM_PLAYERS_DESC", "" ),
												CLEAR_CHOICE_DESC, 1, ; )

	// VAC
	FRAME_CHOICE_DVARYESNO_FOCUS_VIS_EX( 		16, "@PLATFORM_VAC_CAPS", 
												"sv_vac",
												;,
												SET_CHOICE_DESC( "", "@PATCH_VALVE_ANTI_CHEAT_DESC", "" ),
												CLEAR_CHIOCE_DESC, 1, ; )

	HINT_TEXT_ALL_RECT( CHOICE_X_START, ( (SERVERSETTINGS_FRAME_HEIGHT / 2) - 30 ), ( CHOICE_SIZE_X ), dvarString( ui_choice_desc ), 1 1 1 1, ( MenuHasFocus() && dvarString( ui_choice_desc ) != "" ), ; )

	NEW_FRAME_BACK_BUTTON_ACTION( SERVERSETTINGS_FRAME_WIDTH, SERVERSETTINGS_FRAME_HEIGHT, ON_ESC )

	#include "ui/safearea.menu"
}

