#include "ui/menudef.h"

#ifdef PC
	#define 	SCOREBAR_OFFSET 0 4
#else
	#define 	SCOREBAR_OFFSET 0 0
#endif
	
#define SCORE_BAR() \
		itemDef \
		{ \
			style			WINDOW_STYLE_SHADER \
			rect			0 3 640 18 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_TOP \
			origin			SCOREBAR_OFFSET\
			background		"line_horizontal_scorebar" \
			forecolor		0 0 0 1 \
			visible			when( team( name ) == "TEAM_ALLIES" && dvarString( "scr_allies" ) == "sas" && !dvarInt( "splitscreen" ) && !isIntermission() ) \
			decoration \
		} \
		itemDef \
		{ \
			style			WINDOW_STYLE_SHADER \
			rect			0 3 640 18 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_TOP \
			origin			SCOREBAR_OFFSET\
			background		"line_horizontal_scorebar" \
			forecolor		0.6 0.64 0.69 1 \
			visible			when( team( name ) == "TEAM_ALLIES" && dvarString( "scr_allies" ) == "usmc" && !dvarInt( "splitscreen" ) && !isIntermission() ) \
			decoration \
		} \
		itemDef \
		{ \
			style			WINDOW_STYLE_SHADER \
			rect			0 3 640 18 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_TOP \
			origin			SCOREBAR_OFFSET\
			background		"line_horizontal_scorebar" \
			forecolor		0.52 0.28 0.28 1 \
			visible			when( team( name ) == "TEAM_AXIS" && dvarString( "scr_axis" ) == "ussr" && !dvarInt( "splitscreen" ) && !isIntermission() ) \
			decoration \
		} \
		itemDef \
		{ \
			style			WINDOW_STYLE_SHADER \
			rect			0 3 640 18 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_TOP \
			origin			SCOREBAR_OFFSET\
			background		"line_horizontal_scorebar" \
			forecolor		0.65 0.57 0.41 1 \
			visible			when( team( name ) == "TEAM_AXIS" && dvarString( "scr_axis" ) == "arab" && !dvarInt( "splitscreen" ) && !isIntermission() ) \
			decoration \
		} \
		itemDef \
		{ \
			style			WINDOW_STYLE_SHADER \
			rect			0 3 640 18 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_TOP \
			origin			SCOREBAR_OFFSET\
			background		"line_horizontal_scorebar" \
			forecolor		0.1 0.1 0.1 1 \
			visible			when( isIntermission() ) \
			decoration \
		} \		

{	
	menuDef
	{
		name			"scoreboard"
		rect			0 0 640 480
		onEsc 
		{
			close scoreboard;
		}

		itemDef
		{
			style			WINDOW_STYLE_SHADER
			rect			0 0 640 2 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_TOP
			origin			SCOREBAR_OFFSET
			background		"line_horizontal_scorebar"
			forecolor		1 1 1 1
			visible			when( !dvarInt( "splitscreen" ) );
			decoration
		}
		itemDef	
		{
			style			WINDOW_STYLE_SHADER
			rect			0 2 640 1 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_TOP
			origin			SCOREBAR_OFFSET
			background		"line_horizontal_scorebar"
			forecolor		0 0 0 0.5
			visible			when( !dvarInt( "splitscreen" ) );
			decoration
		}	
		SCORE_BAR
		
		itemDef	
		{
			style			WINDOW_STYLE_SHADER
			rect			0 21 640 1 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_TOP
			origin			SCOREBAR_OFFSET
			background		"line_horizontal_scorebar"
			forecolor		0 0 0 0.5
			visible			when( !dvarInt( "splitscreen" ) );
			decoration
		}	
		itemDef
		{
			style			WINDOW_STYLE_SHADER
			rect			0 22 640 2 HORIZONTAL_ALIGN_FULLSCREEN VERTICAL_ALIGN_TOP
			origin			SCOREBAR_OFFSET
			background		"line_horizontal_scorebar"
			forecolor		1 1 1 1
			visible			when( !dvarInt( "splitscreen" ) );
			decoration
		}
		
		itemDef
		{
			style			WINDOW_STYLE_SHADER
			rect			0 -4 36 36 HORIZONTAL_ALIGN_LEFT VERTICAL_ALIGN_TOP
			origin			SCOREBAR_OFFSET
			exp				material( dvarString( "g_TeamIcon_Allies" ) );
			visible			when ( team( name ) == "TEAM_ALLIES" && !dvarInt( "splitscreen" ) ); 
			decoration
		}

		itemDef
		{
			style			WINDOW_STYLE_SHADER
			rect			0 -4 36 36 HORIZONTAL_ALIGN_LEFT VERTICAL_ALIGN_TOP
			origin			SCOREBAR_OFFSET
			exp				material( dvarString( "g_TeamIcon_Allies" ) );
			visible			when (  team( name ) == "TEAM_SPECTATOR" && !dvarInt( "splitscreen" ) ); 
			decoration
		}

		itemDef
		{
			style			WINDOW_STYLE_SHADER
			rect			0 -4 36 36 HORIZONTAL_ALIGN_LEFT VERTICAL_ALIGN_TOP
			origin			SCOREBAR_OFFSET
			exp				material( dvarString( "g_TeamIcon_Axis" ) );
			visible			when ( team( name ) == "TEAM_AXIS" && !dvarInt( "splitscreen" ) );
			decoration
		}

		itemDef
		{
			style			WINDOW_STYLE_SHADER
			rect			0 -4 36 36 HORIZONTAL_ALIGN_LEFT VERTICAL_ALIGN_TOP
			origin			SCOREBAR_OFFSET
			exp				material( dvarString( "g_TeamIcon_Allies" ) );
			visible			when (  team( name ) == "TEAM_FREE" && !dvarInt( "splitscreen" ) ); 
			decoration
		}

		itemDef 
		{
			rect		36 22 1 1 HORIZONTAL_ALIGN_LEFT VERTICAL_ALIGN_TOP
			origin		SCOREBAR_OFFSET
			exp text	( team( score ) );
			textfont	UI_FONT_OBJECTIVE
			textscale	0.4
			textalign	ITEM_ALIGN_LEFT
			textstyle	ITEM_TEXTSTYLE_SHADOWEDMORE
			visible 	when ( (team( name ) == "TEAM_ALLIES" || team( name ) == "TEAM_AXIS") && !dvarInt( "splitscreen" ) )
			decoration 
		}

		itemDef 
		{
			rect		36 22 1 1 HORIZONTAL_ALIGN_LEFT VERTICAL_ALIGN_TOP
			origin		SCOREBAR_OFFSET
			exp text	( player( score ) );
			textfont	UI_FONT_OBJECTIVE
			textscale	0.4
			textalign	ITEM_ALIGN_LEFT
			textstyle	ITEM_TEXTSTYLE_SHADOWEDMORE
			visible 	when ( team( name ) == "TEAM_FREE" && !dvarInt( "splitscreen" ) )
			decoration 
		}

		itemDef
		{
			style			WINDOW_STYLE_SHADER
			rect			95 -4 36 36 HORIZONTAL_ALIGN_LEFT VERTICAL_ALIGN_TOP
			origin			SCOREBAR_OFFSET
			exp				material( dvarString( "g_TeamIcon_Allies" ) );
			visible			when ( team( name ) == "TEAM_AXIS" && !dvarInt( "splitscreen" ) );
			decoration
		}

		itemDef
		{
			style			WINDOW_STYLE_SHADER
			rect			95 -4 36 36 HORIZONTAL_ALIGN_LEFT VERTICAL_ALIGN_TOP
			origin			SCOREBAR_OFFSET
			exp				material( dvarString( "g_TeamIcon_Axis" ) );
			visible			when ( (team( name ) == "TEAM_ALLIES" || team( name ) == "TEAM_SPECTATOR") && !dvarInt( "splitscreen" ) );
			decoration
		}

		itemDef 
		{
			rect		134 22 1 1 HORIZONTAL_ALIGN_LEFT VERTICAL_ALIGN_TOP
			origin		SCOREBAR_OFFSET
			exp text	( otherteam( score ) );
			textfont	UI_FONT_OBJECTIVE
			textscale	0.4
			textalign	ITEM_ALIGN_LEFT
			textstyle	ITEM_TEXTSTYLE_SHADOWEDMORE
			visible 	when ( (team( name ) == "TEAM_ALLIES" || team( name ) == "TEAM_AXIS") && !dvarInt( "splitscreen" ) )
			decoration 
		}

		itemDef 
		{
			rect		0 22 1 1 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_TOP
			origin		SCOREBAR_OFFSET
			exp				text( locString( "@MENU_SCORE_WINNING_WITH", team( score ), dvarint( "ui_scorelimit" ) ) );
			textfont	UI_FONT_NORMAL
			textscale	TEXTSIZE_SMALL
			textalign	ITEM_ALIGN_CENTER
			textstyle	ITEM_TEXTSTYLE_SHADOWEDMORE
			visible 	when( (team( name ) == "TEAM_ALLIES" || team( name ) == "TEAM_AXIS") && team( score ) > otherteam( score ) && timeLeft() % 8 > 3 && !dvarInt( "splitscreen" ) && !isIntermission() )
			decoration 
		}
		itemDef 
		{
			rect		0 22 1 1 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_TOP
			origin		SCOREBAR_OFFSET
			exp				text( locString( "@MENU_SCORE_LOSING_WITH", team( score ), dvarint( "ui_scorelimit" ) ) );
			textfont	UI_FONT_NORMAL
			textscale	TEXTSIZE_SMALL
			textalign	ITEM_ALIGN_CENTER
			textstyle	ITEM_TEXTSTYLE_SHADOWEDMORE
			visible 	when( (team( name ) == "TEAM_ALLIES" || team( name ) == "TEAM_AXIS") && team( score ) < otherteam( score ) && timeLeft() % 8 > 3 && !dvarInt( "splitscreen" ) && !isIntermission() )
			decoration 
		}
		itemDef 
		{
			rect		0 22 1 1 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_TOP
			origin		SCOREBAR_OFFSET
			exp				text( locString( "@MENU_SCORE_TIED_WITH", team( score ), dvarint( "ui_scorelimit" ) ) );
			textfont	UI_FONT_NORMAL
			textscale	TEXTSIZE_SMALL
			textalign	ITEM_ALIGN_CENTER
			textstyle	ITEM_TEXTSTYLE_SHADOWEDMORE
			visible 	when( (team( name ) == "TEAM_ALLIES" || team( name ) == "TEAM_AXIS") && team( score ) == otherteam( score ) && timeLeft() % 8 > 3 && !dvarInt( "splitscreen" ) && !isIntermission() )
			decoration 
		}
		itemDef 
		{
			rect		0 22 1 1 HORIZONTAL_ALIGN_CENTER VERTICAL_ALIGN_TOP
			origin		SCOREBAR_OFFSET
			exp text	( gameTypeName() );
			textfont	UI_FONT_NORMAL
			textscale	TEXTSIZE_SMALL
			textalign	ITEM_ALIGN_CENTER
			textstyle	ITEM_TEXTSTYLE_SHADOWEDMORE
			visible 	when( (timeLeft() % 8 < 4 || timeLeft() < 0) && !dvarInt( "splitscreen" ) && !isIntermission() )
			decoration 
		}

		itemDef 
		{
			rect		0 0 1 1 HORIZONTAL_ALIGN_LEFT VERTICAL_ALIGN_TOP
			origin		2 32
			exp				text( locString( "@MENU_SCORE_WINNING_WITH", team( score ), dvarint( "ui_scorelimit" ) ) );
			textfont	UI_FONT_NORMAL
			textscale	TEXTSIZE_SMALL_SS
			textalign	ITEM_ALIGN_LEFT
			textstyle	ITEM_TEXTSTYLE_SHADOWEDMORE
			visible 	when( (team( name ) == "TEAM_ALLIES" || team( name ) == "TEAM_AXIS") && team( score ) > otherteam( score ) && timeLeft() % 8 > 3 && dvarInt( "splitscreen" ) && !isIntermission() )
			decoration 
		}
		itemDef
		{
			rect		0 0 1 1 HORIZONTAL_ALIGN_LEFT VERTICAL_ALIGN_TOP
			origin		2 32
			exp				text( locString( "@MENU_SCORE_LOSING_WITH", team( score ), dvarint( "ui_scorelimit" ) ) );
			textfont	UI_FONT_NORMAL
			textscale	TEXTSIZE_SMALL_SS
			textalign	ITEM_ALIGN_LEFT
			textstyle	ITEM_TEXTSTYLE_SHADOWEDMORE
			visible 	when( (team( name ) == "TEAM_ALLIES" || team( name ) == "TEAM_AXIS") && team( score ) < otherteam( score ) && timeLeft() % 8 > 3 && dvarInt( "splitscreen" ) && !isIntermission() )
			decoration 
		}
		itemDef
		{
			rect		0 0 1 1 HORIZONTAL_ALIGN_LEFT VERTICAL_ALIGN_TOP
			origin		2 32
			exp				text( locString( "@MENU_SCORE_TIED_WITH", team( score ), dvarint( "ui_scorelimit" ) ) );
			textfont	UI_FONT_NORMAL
			textscale	TEXTSIZE_SMALL_SS
			textalign	ITEM_ALIGN_LEFT
			textstyle	ITEM_TEXTSTYLE_SHADOWEDMORE
			visible 	when( (team( name ) == "TEAM_ALLIES" || team( name ) == "TEAM_AXIS") && team( score ) == otherteam( score ) && timeLeft() % 8 > 3 && dvarInt( "splitscreen" ) && !isIntermission() )
			decoration 
		}
		itemDef 
		{
			rect		0 0 1 1 HORIZONTAL_ALIGN_LEFT VERTICAL_ALIGN_TOP
			origin		2 32
			exp text	( gameTypeName() );
			textfont	UI_FONT_NORMAL
			textscale	TEXTSIZE_SMALL_SS
			textalign	ITEM_ALIGN_LEFT
			textstyle	ITEM_TEXTSTYLE_SHADOWEDMORE
			visible 	when( (timeLeft() % 8 < 4 || timeLeft() < 0) && dvarInt( "splitscreen" ) )
			decoration 
		}

		itemDef 
		{
			rect		36 22 1 1 HORIZONTAL_ALIGN_LEFT VERTICAL_ALIGN_TOP
			origin		SCOREBAR_OFFSET
			exp text	( marinesfield( score ) );
			textfont	UI_FONT_OBJECTIVE
			textscale	0.4
			textalign	ITEM_ALIGN_LEFT
			textstyle	ITEM_TEXTSTYLE_SHADOWEDMORE
			visible 	when ( team( name ) == "TEAM_SEPCTATOR" && !dvarInt( "splitscreen" ) )
			decoration 
		}

		itemDef 
		{
			rect		134 22 1 1 HORIZONTAL_ALIGN_LEFT VERTICAL_ALIGN_TOP
			origin		SCOREBAR_OFFSET
			exp text	( opforfield( score ) );
			textfont	UI_FONT_OBJECTIVE
			textscale	0.4
			textalign	ITEM_ALIGN_LEFT
			textstyle	ITEM_TEXTSTYLE_SHADOWEDMORE
			visible 	when ( team( name ) == "TEAM_SEPCTATOR" && !dvarInt( "splitscreen" ) )
			decoration 
		}

		#ifdef PUBLIC_BETA
			#define TIMEOFFSET 18
		#else
			#define TIMEOFFSET 0
		#endif

		itemDef 
		{
			rect		SCOREBAR_OFFSET 1 1 HORIZONTAL_ALIGN_RIGHT VERTICAL_ALIGN_TOP
			origin		0 (22+TIMEOFFSET)
			exp text	( secondsAsCountdown( timeLeft() ) );
			textfont	UI_FONT_OBJECTIVE
			textscale	0.4
			textalign	ITEM_ALIGN_RIGHT
			textstyle	ITEM_TEXTSTYLE_SHADOWEDMORE
			visible 	when ( timeLeft() >= 30 && !dvarInt( "splitscreen" ) );
			decoration 
		}

		itemDef 
		{
			rect		SCOREBAR_OFFSET 1 1 HORIZONTAL_ALIGN_RIGHT VERTICAL_ALIGN_TOP
			origin		0 (22+TIMEOFFSET)
			exp text	( secondsAsCountdown( timeLeft() ) );
			textfont	UI_FONT_OBJECTIVE
			textscale	0.4
			textalign	ITEM_ALIGN_RIGHT
			textstyle	ITEM_TEXTSTYLE_SHADOWEDMORE
			forecolor	1 0.75 0 1
			visible 	when ( timeLeft() >= 10 && timeLeft() < 30 && !dvarInt( "splitscreen" ) );
			decoration 
		}

		itemDef 
		{
			rect		SCOREBAR_OFFSET 1 1 HORIZONTAL_ALIGN_RIGHT VERTICAL_ALIGN_TOP
			origin		0 (22+TIMEOFFSET)
			exp text	( secondsAsCountdown( timeLeft() ) );
			textfont	UI_FONT_OBJECTIVE
			textscale	0.4
			textalign	ITEM_ALIGN_RIGHT
			textstyle	ITEM_TEXTSTYLE_SHADOWEDMORE
			forecolor	1 0.5 0 1
			visible 	when ( timeLeft() >= 0 && timeLeft() < 10 && !dvarInt( "splitscreen" ) );
			decoration 
		}
	}

}
