#include "ui/menudef.h"
#include "ui_mp/common_macro.inc"

#define CHOICE_X_START			0
#define CHOICE_Y_START			120

#define CHOICE_GROUP			"main"
#define CHOICE_SEP_1			3
#define CHOICE_SEP_2			6
#define CHOICE_SEP_3			9

#define STYLE_PC	1
#include "ui_mp/menustyle.inc"
#include "ui/choices_setup_common.menu"
#include "ui_mp/stats_info.inc"

{
	assetGlobalDef
	{
		fadeClamp		1.0						// sets the fadeup alpha
		fadeCycle		1						// how often fade happens in milliseconds
		fadeAmount		0.1						// amount to adjust alpha per cycle
	}
	menuDef
	{
		name			"main"
		fullScreen		1
		rect			0 0 640 480
		focusColor		COLOR_FOCUSED
		soundloop 		"music_mainmenu_mp"
		onOpen
		{ 
			open main_text;
			uiScript addPlayerProfiles;
			uiScript openMenuOnDvar com_playerProfile "" player_profile;
			uiScript openMenuOnDvarNot ui_playerProfileCount 1 player_profile;
			uiScript stopRefresh;
			setdvar ui_showEndOfGame "0";
		}
		onClose
		{
		}
		onESC 
		{
		}
	}
	
	menuDef
	{
		name			"main_text"
		fullScreen		1
		rect			0 0 640 480
		focusColor		COLOR_FOCUSED
		soundloop 		"music_mainmenu_mp"
		onOpen
		{ 
			exec "selectStringTableEntryInDvar mp/didyouknow.csv 0 didyouknow";
			//execondvarintvalue ui_close_main 1 "closemenu main_text";
			
			// temp CAC (for dev only)
			//exec "set customclass1 @CLASS_CLASS1";
			//exec "set customclass2 @CLASS_CLASS2";
			//exec "set customclass3 @CLASS_CLASS3";
			//exec "set customclass4 @CLASS_CLASS4";
			//exec "set customclass5 @CLASS_CLASS5";	
		}
		onClose
		{
		}
		onESC 
		{
		}

		// Menu items -------------------------------------------
		#include "ui/bg.inc"

		//#include "ui/background_bars.menu"

		// cod:mw logo
		itemDef
		{
			visible			1
			rect			324 56 278 68
			forecolor		1 1 1 1
			style			WINDOW_STYLE_SHADER
			background		"logo_cod2"
			visible 		when( !localvarBool( ui_hideBack ) && dvarString( ui_mod_logo ) == "" );
			decoration
		}

		// mod logo
		itemDef
		{
			visible			1
			rect			324 56 278 68
			forecolor		1 1 1 1
			style			WINDOW_STYLE_SHADER
			exp material	( dvarString( ui_mod_logo ) )
			visible 		when( !localvarBool( ui_hideBack ) && dvarString( ui_mod_logo ) != "" );
			decoration
		}
		
		//#define SETUP_ACTION_CREATEACLASS \				
				//execnow "statset 260 1"; \
				//play "mouse_click"; \
				//open pc_cac_popup;
				
		#define CLEARUIHINT	exec "set ui_hint_text @MP_NULL"
				
		//CHOICE_BUTTON_VIS( 1, "@MENU_AUTO_UPDATE", open auconfirm;, when( dvarbool( cl_updateAvailable ) && !localvarBool( ui_hideBack ) ) )
		//CHOICE_BUTTON_VIS( 0, "@MENU_JOIN_GAME", open join_game_popup;, when( !localvarBool( ui_hideBack ) ) )
		CHOICE_BUTTON_VIS( 4, "Join a ^5Ninja ^7Game", open pc_join_unranked;, when( !localvarBool( ui_hideBack ) ) )
		CHOICE_BUTTON_VIS( 5, "Start a ^5Ninja ^7Game", close self; open createserver;, when( !localvarBool( ui_hideBack ) ) )

		CHOICE_SEPARATOR_VIS( CHOICE_SEP_1, when( !localvarBool( ui_hideBack ) ) )

		CHOICE_BUTTON_VIS( 6, "@MENU_SELECT_PROFILE", setdvar ui_playerProfileAlreadyChosen 0; open player_profile;, when( !localvarBool( ui_hideBack ) ) )
		
		//CHOICE_BUTTON_FOCUS_VIS_ADV( 5, "@MPUI_CREATE_A_CLASS", SETUP_ACTION_CREATEACLASS, exec "set ui_hint_text @MPUI_DESC_CREATE_A_CLASS", CLEARUIHINT, when( !localvarBool( ui_hideBack ) && stat( 260 ) >= 1 ), !localvarBool( ui_hideBack ) && stat( 260 ) >= 1 )
		//CHOICE_BUTTON_FOCUS_VIS_NOHI( 5, "", ;, exec "set ui_hint_text @MPUI_DESC_CREATE_A_CLASS_LOCKED", CLEARUIHINT, when(!localvarBool( ui_hideBack ) && stat( 260 ) < 1 ) )
		//CHOICE_DBUTTON_VIS( 5, "@MPUI_CREATE_A_CLASS", when( !localvarBool( ui_hideBack ) && stat( 260 ) < 1 ) )
		//CHOICE_NEWICON_VIS( 5, "specialty_new", when( !localvarBool( ui_hideBack ) && ANY_NEW_CAC ) )
		
		//CHOICE_BUTTON_VIS( 5, "Create a Class", open pc_cac_popup;, when( !localvarBool( ui_hideBack ) && stat(260) ) )
		//CHOICE_BUTTON_VIS( 6, "@MENU_RANK_AND_CHALLENGES", open menu_challenges;, when( !localvarBool( ui_hideBack ) ) )
	
		CHOICE_SEPARATOR_VIS( CHOICE_SEP_2, when( !localvarBool( ui_hideBack ) ) )
		
		CHOICE_BUTTON_VIS( 7, "@MENU_CONTROLS", open main_controls;, when( !localvarBool( ui_hideBack ) ) )
		CHOICE_BUTTON_VIS( 8, "@MENU_OPTIONS", open main_options;, when( !localvarBool( ui_hideBack ) ) )
		
		CHOICE_SEPARATOR_VIS( CHOICE_SEP_3, when( !localvarBool( ui_hideBack ) ) )
		
		CHOICE_BUTTON_VIS( 9, "@MENU_MODS", close self; open mods_menu;, when( !localvarBool( ui_hideBack ) ) )
		CHOICE_BUTTON_VIS( 10, "@MENU_SINGLE_PLAYER", open single_popmenu;, when( !localvarBool( ui_hideBack ) ) )
		CHOICE_BUTTON_VIS( 11, "@MENU_QUIT", open quit_popmenu;, when( !localvarBool( ui_hideBack ) ) )

		//CHOICE_FOOTNOTE_VIS( "@MENU_GAME_EXPERIENCE_MAY_CHANGE", 40, 420, when( !localvarBool( ui_hideBack ) ) )
		
	}
	
	#include "ui_mp/popupstyle.inc"	
	#include "ui/choices_setup_popmenu.menu"
	
	// ====================== create a class (custom class selection) =========================
	#undef CHOICE_SIZE_X
	#define CHOICE_SIZE_X			212

	#define CAC_POPUP_X		(0)
	#define CAC_POPUP_Y		(212)

	#undef NEW_X_OFFSET			
	#define NEW_X_OFFSET	(0-CHOICE_SIZE_X)
	#undef NEW_Y_OFFSET			
	#define NEW_Y_OFFSET	(0-2)
	
	#include "ui_mp/cacpopup.inc"
	CAC_POPUP( "pc_cac_popup", CAC_POPUP_X, CAC_POPUP_Y )


	// ====================== join server type selection =========================
	
	#undef CHOICE_SIZE_X
	#define CHOICE_SIZE_X	200
	
	menuDef
	{
		IMPROVED_POPUP_SETUP( "join_game_popup", 4, 12, 112, ;, 1 )
		//CHOICE_BUTTON( 1, "Ranked Games", close self; close "main_text"; open pc_join_ranked )
		CHOICE_BUTTON( 3, "Ranked Games", close self; close "main_text"; open pc_join_unranked )
		CHOICE_BUTTON( 4, "Unranked Games", close self; close "main_text"; open pc_join_unranked )
		//CHOICE_BUTTON( 3, "@MENU_CANCEL", close self )
	}
	
	// ====================== single player confirmation =========================
	
	#undef CHOICE_SIZE_X
	#define CHOICE_SIZE_X	320
	

	#undef CHOICE_HORIZONTAL_ALIGN
	#define CHOICE_HORIZONTAL_ALIGN	HORIZONTAL_ALIGN_CENTER
	#undef CHOICE_VERTICAL_ALIGN
	#define CHOICE_VERTICAL_ALIGN	VERTICAL_ALIGN_CENTER
	
	menuDef
	{
		CENTER_POPUP_SETUP( single_popmenu, 4, ;, 1 )

		CHOICE_POPMENU_TITLE( "@MENU_SWITCH_TO_SINGLE_PLAYER" )
		CHOICE_BUTTON( 3, "@MENU_YES", uiScript startsingleplayer )
		CHOICE_BUTTON( 4, "@MENU_NO", close self )
	}
}
