#include "ui/menudef.h"

// Defines //

#define WINDOW_X		16
#define WINDOW_Y		16
#define WINDOW_WIDTH	128
#define WINDOW_HEIGHT	224
#define GROUP_NAME		"grpMain"

// Macros //

#include "ui/menumacros.h"
	
// Opener //

menuDef {
	name		"main_opener"
	visible		0
	fullscreen	0
	rect		WINDOW_X WINDOW_Y WINDOW_WIDTH WINDOW_HEIGHT
	
	onOpen {
		open fadebox_black ;
		open background_1 ;
		setmenuitemcolor fadebox_black fadebox backcolor 0 0 0 1 ;
		fadeoutmenu fadebox_black ;
		open main ;
		clearcvar ui_profile_create_error ;
		close main_opener	
	}
}

// Main Menu //

menuDef {
	name		"main"
	visible		0
	fullscreen	0
	rect		WINDOW_X WINDOW_Y WINDOW_WIDTH WINDOW_HEIGHT
	style		WINDOW_STYLE_FILLED
  
	onOpen {
//		setitemcolor fadebox backcolor 0 0 0 1 ;
//		uiScript stopRefresh ;
//		
		conditionalscript cl_profile 1
			( "clearFocus" )
			( "close main ; open profile_create_initial_opener" )	// do we want an abort here?

		// ydnar
		conditionalscript ROldModeCheck 2
			( "clearFocus ; open vid_confirm" )
			( "clearFocus" )

		conditionalscript cl_autoupdate 1
			( "checkautoupdate" )
			( "clearFocus" )
	}
	
	onEsc {
		clearFocus ;
		open quit
	}

// Background Logo //
	
	itemDef {
		name		"et_logo"
		rect		104 124 400 200		// 16, 16 offset!!
		style		WINDOW_STYLE_SHADER
		background	"ui/assets/et_logo_huge"
		visible		1
		decoration
	}

// Company Logos //

	/*itemDef {
		name		"id_logo"
		rect		0 400 48 48		// 16, 16 offset!!
		style		WINDOW_STYLE_SHADER
		background	"ui/assets/logo_id_dark"
		forecolor	1 1 1 1
		visible		1
		decoration
	}
	
	itemDef {
		name		"atvi_logo"
		rect		52 421 108 27		// 16, 16 offset!! (note offset to left a little as well)
		style		WINDOW_STYLE_SHADER
		background	"ui/assets/logo_atvi_dark"
		forecolor	1 1 1 1
		visible		1
		decoration
	}

	itemDef {
		name		"sd_logo"
		rect		$evalfloat(640-(2*WINDOW_X)-48) 400 48 48		// 16, 16 offset!!
		style		WINDOW_STYLE_SHADER
		background	"ui/assets/logo_sd_dark"
		forecolor	1 1 1 1
		visible		1
		decoration
	}*/
	
	itemDef {
		name		"sd_logo"
		rect		4 394 54 54		// 16, 16 offset!!
		style		WINDOW_STYLE_SHADER
		background	"ui/assets/logo_sd_dark"
		forecolor	1 1 1 1
		visible		1
		decoration
	}
	
	itemDef {
		name		"tjmod_logo"
		rect		545 0 64 64	// X Y W H
		style		WINDOW_STYLE_SHADER
		background	"ui/assets/tjmod_logo"
		forecolor	1 1 1 0.25
		visible		1
		decoration
	}
	
	itemDef {
		name		"tjmod_authors"
		rect		527 57 100 100	// X Y W H
		style		WINDOW_STYLE_SHADER
		background	"ui/assets/tjmod_authors"
		forecolor	1 1 1 0.25
		visible		1
		decoration
	}
		
	itemDef {
		name		"atvi_logo"
		rect		$evalfloat(640-(2*WINDOW_X)-48-4-108) 421 108 27		// 16, 16 offset!! (note offset to left a little as well)
		style		WINDOW_STYLE_SHADER
		background	"ui/assets/logo_atvi_dark"
		forecolor	1 1 1 1
		visible		1
		decoration
	}
	
	itemDef {
		name		"id_logo"
		rect		$evalfloat(640-(2*WINDOW_X)-48) 400 48 48		// 16, 16 offset!!
		style		WINDOW_STYLE_SHADER
		background	"ui/assets/logo_id_dark"
		forecolor	1 1 1 1
		visible		1
		decoration
	}

	//LABELWHITE( 400, 65, 250, 10, "1.0.2 by", .2, ITEM_ALIGN_RIGHT, 200, 8 )
	//LABELWHITE( 375, 78, 250, 10, "^dD^7inius", .2, ITEM_ALIGN_CENTER, 200, 8 )
	//LABELWHITE( 375, 91, 250, 10, "^zeT^>|^7setup^>.", .2, ITEM_ALIGN_CENTER, 200, 8 )
	//LABELWHITE( 375, 104, 250, 10, "^f_^7zero ^k>:3", .2, ITEM_ALIGN_CENTER, 200, 8 )
	
	//, ^zeT^>|^7setup^>.^7, ^f_^7zero ^k>:3
// Window //

	WINDOW( "MAIN", 50 )
	
// Buttons //

	BUTTON( 6, 32, WINDOW_WIDTH-12, 18, "PLAY ONLINE", .3, 14, close main ; /*close backgroundmusic ; open backgroundmusic_server ;*/ uiScript UpdateFilter ; uiScript ServerSortDown 4 ; open playonline )
	BUTTON( 6, 56, WINDOW_WIDTH-12, 18, "HOST GAME", .3, 14, close main ; /*close backgroundmusic ; open backgroundmusic_server ;*/ uiScript loadArenas ; uiScript initHostGameFeatures ; open hostgame )
	BUTTON( 6, 80, WINDOW_WIDTH-12, 18, "REPLAYS", .3, 14, close main ; open viewreplay )
	BUTTON( 6, 104, WINDOW_WIDTH-12, 18, "OPTIONS", .3, 14, close main ; open options )
	BUTTON( 6, 128, WINDOW_WIDTH-12, 18, "PROFILE", .3, 14, close main ; open profile )
	BUTTON( 6, 152, WINDOW_WIDTH-12, 18, "CREDITS", .3, 14, close main ; open credits_splashdamage )
	BUTTON( 6, 176, WINDOW_WIDTH-12, 18, "MODS", .3, 14, close main ; open mods )
	BUTTON( 6, 200, WINDOW_WIDTH-12, 18, "EXIT GAME", .3, 14, clearFocus ; open quit )
}
