#include "ui/menudef.h"
#include "ui/tabs.h"

////////////////////////////////////
//
// CONSTANTS
//
//


#define OPTION_COLOR		0 0 .1 1
#define Tab_Color1			0 0 0 1
#define Tab_Color2			0 0 .5 1
#define VSPACE				16
#define VSIZE				16
#define ICON_ALPHA			0.5
#define LINE_ALPHA			0.2
#define FADEIN_TIME			125
#define HINT_COLOR			.25 .25 .25
#define HINT_FADE_TIME		125
#define TAB_HEIGHT			20
#define LINE_WIDTH			300


////////////////////////////////////
//
// MENU DEFINITION
//
//

{
    menuDef {
		name "ingame_matchmode_captain"
		visible MENU_FALSE				// Visible on open
		focusColor RQ3_MAIN_FOCUSCOLOR			// Menu focus color for text and items
		rect 232 120 344 264
		anglevectors 3 -87
		style WINDOW_STYLE_EMPTY
		popup
		
		onOOBClick { close _self ; }
		onOpen {
			play "sound/ui/whoosh3.wav" ;
			uiScript readMMcaptainSettings ;
			setitemcolor hints forecolor HINT_COLOR 1 ; hide "hints" ;
		}
		onClose { open _prev ; }
		onESC { close _self }
		
		onOpenSpecial {
			//normal items
			ALPHA_FADE_FORE(fade_alpha, 1) ;
			//icon - special alpha
			ALPHA_FADE_FORE(icon, ICON_ALPHA) ;
			timeFade "icon" forecolor 5 5 5 ICON_ALPHA 0 FADEIN_TIME ;
			//line - special alpha; using backcolor
			ALPHA_FADE_BACK(line, LINE_ALPHA) ;
			ACTIVATE_TAB(1) ;
		}
		
		itemDef {
			name "paper,fade_alpha"
			style WINDOW_STYLE_SHADER
			background UI_ASSETS"/paper_1"
			forecolor .95 .94 .87 1
			rect -8 -16 380 320
			anglevectors 3 -87
			visible 1
			menuAnchor
			decoration
		}
		
		itemDef {
			renderpoint
			name "title,fade_alpha"
			text "Match Mode:"
			forecolor .6 .0 .0 1
			style WINDOW_STYLE_EMPTY
			textalign ITEM_ALIGN_LEFT
			textalignx 4
			textaligny 24
			textscale RQ3_MAIN_TEXTSIZE
			alignrect paper ITEM_ALIGN_LEFT 32 32 240 36 
			visible 1
			autowrapped
			decoration
		}

		//Line

		itemDef {
			name "line,fade_alpha"
			style WINDOW_STYLE_FILLED
			backcolor .25 .25 .25 LINE_ALPHA
			alignrect "title" ITEM_ALIGN_LEFT 0 48 LINE_WIDTH 2
			visible 1
			decoration
		}

    ///////////////////////////////////////////////////////////
    //
    // Sub-options
    //
    //

	// Status

	ADD_TAB(
		"^_S^_tatus.",
		"S", 1, "group2,group3",
		alignrect "title" ITEM_ALIGN_LEFT 2 28 40 TAB_HEIGHT
	)
    ADD_HINT("hint_tab1", "Become a captain and lead your team", "group2,group3")

//---------------------------------------------------------

	// Settings

	ADD_TAB(
		"S^_e^_ttings.",
		"E", 2, "group1,group3",
		alignrect "tab1" ITEM_ALIGN_RIGHT -49 0 48 TAB_HEIGHT
	)
    ADD_HINT("hint_tab2", "Change match settings", "group1,group3")


//---------------------------------------------------------

	// Referee

	ADD_TAB(
		"^_R^_eferee.",
		"R", 3, "group1,group2",
		alignrect "tab2" ITEM_ALIGN_RIGHT -45 0 44 TAB_HEIGHT
	)
    ADD_HINT("hint_tab3", "Nominate a player to be the match referee", "group1,group2")

/*
==========================================================

Group # 1 - Status

==========================================================
*/

		itemDef {
			name "allgroups,group1,gr1_ctrl1,fade_alpha"
			subgroup "fade_fore_alpha"
			text "> Become a ^_C^_aptain"
			shortcutKey "C"
			type ITEM_TYPE_BUTTON
			textscale .225
			style WINDOW_STYLE_EMPTY
			alignrect "line" ITEM_ALIGN_LEFT 72 42 160 20
			textalign ITEM_ALIGN_LEFT
			textalignx 0
			textaligny 16
			forecolor 0 0 0 1
			visible 1
			action { play "sound/ui/whoosh3.wav" ; exec "captain" }
			ASSIGN_HINT("hint_captain")
		}

		itemDef {
			name "ready"
			group "fade_fore_alpha,group1,allgroups"
			text "> Ready/Unready ^_T^_eam"
			shortcutKey "T"
			type ITEM_TYPE_BUTTON
			textscale .225
			style WINDOW_STYLE_EMPTY
			alignrect "gr1_ctrl1" ITEM_ALIGN_LEFT 0 24 160 20
			textalign ITEM_ALIGN_LEFT
			textalignx 0
			textaligny 16
			forecolor 0 0 0 1
			visible 1
			action { play "sound/ui/whoosh3.wav" ; exec "ready" }
			ASSIGN_HINT("hint_ready")
		}

		ADD_HINT("hint_captain", "Become a captain, or click again to resign", "group1")
		ADD_HINT("hint_ready", "Ready to start the match, or click again to pause the match in-progress", "group1")


/*
==========================================================

Group # 2 - Settings

==========================================================
*/

		itemDef {
			name "team_caption"
			group "fade_fore_alpha,group2,allgroups"
			style 0
			text "Team Name:"
			alignrect "line" ITEM_ALIGN_LEFT 8 24 208 20
			textscale .225
			textalign 0
			textalignx 4
			textaligny 16
			forecolor OPTION_COLOR
			visible 1
			decoration
		}

		itemDef {
			name "team_dots"
			group "fade_fore_alpha,group2,allgroups"
			style 0
			text "........................................................"
			alignrect "team_caption" ITEM_ALIGN_LEFT 80 0 168 20
			textscale .225
			textalign ITEM_ALIGN_LEFT
			textaligny 20
			forecolor OPTION_COLOR
			visible 1
			decoration
		}

		itemDef {
			name "allgroups,group2,gr2_ctrl1,fade_alpha"
			group "fade_fore_alpha,group2,allgroups"
			alignrect "team_caption" ITEM_ALIGN_RIGHT -32 0 168 20
			type ITEM_TYPE_EDITFIELD
			style 0
			text ""
			cvar "ui_RQ3_teamName"
			backcolor 0 0 0 .1
			forecolor 0 0 0 1
			textstyle 0
			maxChars 32
			maxPaintChars 18
			textscale .225
			textalign 0
			textalignx 8
			textaligny 16
			visible 1
			ASSIGN_HINT("hint_teamname")
		}
		
		itemdef {
			name "allgroups,group2,gr2_ctrl2,fade_alpha"
			group "fade_fore_alpha,group2,allgroups"
			alignrect "team_caption" ITEM_ALIGN_LEFT 0 28 288 60
			type ITEM_TYPE_LISTBOX
			style WINDOW_STYLE_EMPTY
			elementwidth 40
			elementheight 40
			elementtype LISTBOX_IMAGE
			feeder FEEDER_MMHEADS
			horizontalscroll
			backcolor 0 0 0 1
			forecolor 1 1 1 1
			bordercolor 1 0 0 1
			bordersize 2
			visible 1
			ASSIGN_HINT("hint_teammodel")
		}
		
		itemDef {
			name "model_dots"
			group "fade_fore_alpha,group2,allgroups"
			style 0
			text "...................................................."
			alignrect "gr2_ctrl2" ITEM_ALIGN_LEFT 48 68 168 20
			textscale .225
			textalign ITEM_ALIGN_LEFT
			textaligny 20
			forecolor OPTION_COLOR
			visible 1
			decoration
		}
		
		itemDef {
			name "allgroups,group2,gr2_ctrl3,fade_alpha"
			group "fade_fore_alpha,group2,allgroups"
			text "Model:"
			cvar "ui_RQ3_teamModel"
			textscale .225
			alignrect "gr2_ctrl2" ITEM_ALIGN_LEFT 0 68 80 20
			type ITEM_TYPE_EDITFIELD
			textalign ITEM_ALIGN_LEFT
			textalignx 4
			textaligny 14
			forecolor 0 0 0 1
			visible 0
			decoration
		}
		
		itemDef {
			name "allgroups,group2,gr2_ctrl4,fade_alpha"
			group "fade_fore_alpha,group2,allgroups"
			text "> ^_A^_pply"
			shortcutKey "A"
			textscale .225
			alignrect "gr2_ctrl3" ITEM_ALIGN_LEFT 232 0 56 20
			type 1
			textalign ITEM_ALIGN_LEFT
			textalignx 8
			textaligny 14
			forecolor 0 0 0 1
			visible 1
			action { play "sound/misc/menu1.wav" ; uiScript "captainSetTeamModel" }
			ASSIGN_HINT("hint_apply")
		}

		itemDef {
			name "allgroups,group2,gr2_ctrl5,fade_alpha"
			subgroup "fade_fore_alpha"
			text "> ^_M^_atch Settings..."
			shortcutKey "M"
			type ITEM_TYPE_BUTTON
			textscale .225
			style WINDOW_STYLE_EMPTY
			alignrect "gr2_ctrl4" ITEM_ALIGN_LEFT -56 28 104 20
			textalign ITEM_ALIGN_LEFT
			textalignx 0
			textaligny 16
			forecolor 0 0 0 1
			visible 1
			action { play "sound/ui/whoosh3.wav" ; openSpecial "ingame_matchmode_settings" }
			ASSIGN_HINT("hint_settings")
		}
		
		ADD_HINT("hint_settings", "Change match rules", "group2")
		ADD_HINT("hint_teamname", "Type in the name of your team", "group2")
		ADD_HINT("hint_teammodel", "Change the appearance of your team", "group2")
		itemDef {
			text "Select"
			name "hint_apply,allgroups,group2,hints,fade_alpha"	
			group "fade_fore_alpha,group2,allgroups"
			cvar "ui_RQ3_teamModel"
			type ITEM_TYPE_EDITFIELD
			autowrapped
			forecolor HINT_COLOR 1
			textalign ITEM_ALIGN_LEFT
			textalignx 6
			textaligny 10
			textscale .2
			alignrect "line" ITEM_ALIGN_LEFT 0 8 288 40
			style WINDOW_STYLE_EMPTY
			visible 0
			decoration
		}
	
/*
==========================================================

Group # 3 - Referee

==========================================================
*/
		itemDef {
			name "allgroups,group3,gr3_ctrl1,fade_alpha"
			subgroup "fade_fore_alpha"
			LISTBOX_STYLE(.225, 8)
			alignrect "line" ITEM_ALIGN_LEFT 4 32 188 124
			feeder FEEDER_PLAYER_LIST
			visible 1
			ASSIGN_HINT("hint_nominate")
		}

		itemDef	{
			name "btn_kick,allgroups,group3"
			subgroup "fade_fore_alpha"
			alignrect "paper" ITEM_ALIGN_LEFT 240 224 36 14
			text "> ^_O^_K <"
			shortcutKey "O"
			style WINDOW_STYLE_EMPTY
			forecolor .5 0 0 1
			textalignx 0
			textaligny 12
			textscale .225
			visible 1
			type ITEM_TYPE_BUTTON
			action { play "sound/ui/whoosh3.wav" ; uiScript captainRef }
			ASSIGN_HINT("hint_referee")
		}
		
		ADD_HINT("hint_nominate", "Nominate a player to be the match referee", "group3")
		itemDef {
			text "Nominate"
			name "hint_referee,allgroups,group3,hints,fade_alpha"	
			group "fade_fore_alpha,group2,allgroups"
			ownerdraw UI_SELECTEDPLAYER
			autowrapped
			forecolor HINT_COLOR 1
			textalign ITEM_ALIGN_LEFT
			textalignx 6
			textaligny 10
			textscale .2
			alignrect "line" ITEM_ALIGN_LEFT 0 8 288 40
			style WINDOW_STYLE_EMPTY
			visible 0
			decoration
		}
	}
}

#if 0
#include "ui/menudef.h"

#define SECCOLOR1 1 1 1 0
#define SECCOLOR2 1 1 1 .2

{

    menuDef {
	name "ingame_matchmode_captain"
	visible 0
	fullscreen 0
	//outOfBoundsClick			// this closes the window if it gets a click out of the rectangle
	onOOBClick { close _self ; open ingame_matchmode }
	rect 296 64 288 212
	focusColor 1 .75 0 1			// Menu focus color for text and items
	style WINDOW_STYLE_EMPTY
	shadowStyle 1
	border 0
	onOpen { uiScript readMMcaptainSettings ; hide grpCaptain ; show status
		setitemcolor grpSections backcolor SECCOLOR1;
		timeFade sectionStatus backColor SECCOLOR2 0 250
		setFocus sectionStatus }

//Window

    itemDef {
	rect 0 0 80 212
	style WINDOW_STYLE_FILLED
	backcolor Ig_Window_Color
	visible 1
	border 1
	bordersize 1
	bordercolor Ig_Window_BorderColor
	decoration
    }

    itemDef {
	rect 79 0 207 212
	style WINDOW_STYLE_FILLED
	backcolor Ig_Window_Color
	visible 1
	border 1
	bordersize 1
	bordercolor Ig_Window_BorderColor
	decoration
    }

    itemDef {
	rect 169 1 120 24
	style WINDOW_STYLE_SHADER
	background "ui/assets/rq3-ingame-title"
	visible 1
	decoration
    }

    itemDef {
	rect 169 1 120 24
	style WINDOW_STYLE_EMPTY
	forecolor Ig_Window_TitleColor
	textstyle ITEM_TEXTSTYLE_NORMAL
	textscale .225
	textalign ITEM_ALIGN_LEFT
	textalignx 24
	textaligny 16
	text "Captain"
	visible 1
	decoration
    }

//Sub-sections

    itemDef {
	name sectionStatus
	group grpSections
	text "Status. 1"
	shortcutKey "1"
	type ITEM_TYPE_BUTTON
	textscale .225
	style WINDOW_STYLE_FILLED
	rect 0 44 80 16
	textalign ITEM_ALIGN_RIGHT
	textalignx 72
	textaligny 12
	textstyle ITEM_TEXTSTYLE_SHADOWED
	border 1
	bordersize 1
	bordercolor Ig_Window_BorderColor
	forecolor Ig_Sub_TextColor
	backcolor SECCOLOR1
	visible 1
	action { play "sound/misc/menu1.wav" ; hide grpCaptain ; show status ;
		setitemcolor grpSections backcolor SECCOLOR1;
		timeFadeSelf backColor SECCOLOR2 0 250 }
    }

    itemDef {
	name sectionSettings
	group grpSections
	text "Settings. 2"
	shortcutKey "2"
	type ITEM_TYPE_BUTTON
	textscale .225
	style WINDOW_STYLE_FILLED
	rect 0 68 80 16
	textalign ITEM_ALIGN_RIGHT
	textalignx 72
	textaligny 12
	textstyle ITEM_TEXTSTYLE_SHADOWED
	border 1
	bordersize 1
	bordercolor Ig_Window_BorderColor
	forecolor Ig_Sub_TextColor
	backcolor SECCOLOR1
	visible 1
	action { play "sound/misc/menu1.wav" ; hide grpCaptain ; show settings ;
		setitemcolor grpSections backcolor SECCOLOR1;
		timeFadeSelf backColor SECCOLOR2 0 250 }
    }

    itemDef {
	name sectionRef
	group grpSections
	text "Referee. 3"
	shortcutKey "3"
	type ITEM_TYPE_BUTTON
	textscale .225
	style WINDOW_STYLE_FILLED
	rect 0 92 80 16
	textalign ITEM_ALIGN_RIGHT
	textalignx 72
	textaligny 12
	textstyle ITEM_TEXTSTYLE_SHADOWED
	border 1
	bordersize 1
	bordercolor Ig_Window_BorderColor
	forecolor Ig_Sub_TextColor
	backcolor SECCOLOR1
	visible 1
	action { play "sound/misc/menu1.wav" ; hide grpCaptain ; show ref ;
		setitemcolor grpSections backcolor SECCOLOR1;
		timeFadeSelf backColor SECCOLOR2 0 250 }
    }

//=======================

    // STATUS //

    itemDef {
	name status
	group grpCaptain
	text "Become a captain"
	shortcutKey "B"
	type ITEM_TYPE_BUTTON
	style 0
	textscale .225
	rect 100 76 160 20
	textalign ITEM_ALIGN_CENTER
	textalignx 80
	textaligny 12
	forecolor 1 1 1 1
	visible 0
	action { play "sound/misc/menu1.wav" ; exec "captain"; uiScript closeingame }
    }

    itemDef {
	name status
	group grpCaptain
	text "Ready / Unready team"
	shortcutKey "R"
	type ITEM_TYPE_BUTTON
	style 0
	textscale .225
	rect 100 96 160 20
	textalign ITEM_ALIGN_CENTER
	textalignx 80
	textaligny 12
	forecolor 1 1 1 1
	visible 0
	action { play "sound/misc/menu1.wav" ; exec "ready"; uiScript closeingame }
    }

    // 	REF  //

    itemDef {
	name ref
	group grpCaptain
	text "Vote Referee:"
	textscale .225
	rect 92 32 80 20
	textalign ITEM_ALIGN_LEFT
	textalignx 4
	textaligny 14
	forecolor 1 1 1 1
	visible 0
	decoration
    }

    itemDef {
	name ref
	group grpCaptain
	rect 92 52 180 124
	style WINDOW_STYLE_FILLED
	type ITEM_TYPE_LISTBOX
	elementwidth 120
	elementheight 15
	textscale .225
	elementtype LISTBOX_TEXT
	feeder FEEDER_PLAYER_LIST
	border 1
	bordercolor .25 .25 .25 1
	forecolor 1 1 1 1
	backcolor 0 0 0 .25
	outlinecolor .75 .75 1 .25
	visible 0
    }

    // Scrollbar separator //

    itemDef {
	name ref
	group grpCaptain
	rect 254 52 18 124
	style WINDOW_STYLE_EMPTY
	border 1
	borderSize 1
	bordercolor .25 .25 .25 1
	visible 0
	decoration
    }	

    itemDef {
	name ref
	text "OK"
	shortcutKey "O"
	type 1
	textscale .225
	group grpCaptain
	style WINDOW_STYLE_FILLED
	rect 224 180 48 20
	textalign 1
	textalignx 24
	textaligny 14
	border 1
	bordersize 1
	backcolor Ig_Sub_Color1
	forecolor Ig_Sub_TextColor
	bordercolor Ig_Sub_BorderColor1
	visible 0
	action { play "sound/misc/menu1.wav" ; uiScript captainRef ; uiScript closeingame }
	onFocus { setcolor backcolor Ig_Sub_Color2 ; setcolor bordercolor Ig_Sub_BorderColor2 }
	leaveFocus { setcolor backcolor Ig_Sub_Color1 ; setcolor bordercolor Ig_Sub_BorderColor1 }
    }

    // SETTINGS //

    itemDef {
	name settings
	group grpCaptain
	text "Match Settings..."
	shortcutKey "M"
	type ITEM_TYPE_BUTTON
	style 0
	textscale .225
	rect 88 44 188 20
	textalign ITEM_ALIGN_LEFT
	textalignx 4
	textaligny 12
	forecolor 1 1 1 1
	visible 0
	action { play "sound/misc/menu1.wav" ; close ingame_matchmode_captain ; open ingame_matchmode_settings }
    }

    itemDef {
	name settings
	group grpCaptain
	text "Team Name:"
	textscale .225
	rect 88 72 80 20
	type ITEM_TYPE_TEXT
	textalign ITEM_ALIGN_LEFT
	textalignx 4
	textaligny 14
	forecolor 1 1 1 1
	visible 0
	decoration
    }

    itemdef {
	name settings
	group grpCaptain
	type ITEM_TYPE_EDITFIELD
	style WINDOW_STYLE_FILLED
	text ""
	cvar "ui_RQ3_teamName"
	rect 88 92 148 16
	maxPaintChars 8
	textalign ITEM_ALIGN_LEFT
	textalignx 4
	textaligny 12
	textscale .225
	outlinecolor 1 .5 .5 .5
	forecolor 1 1 1 1
	border 1
	bordercolor .25 .25 .25 1
	backcolor 1 1 1 .05
	visible 0
	onfocus { setcolor backcolor 1 1 1 .15 }
	leavefocus { setcolor backcolor 1 1 1 .05 }
    }

    itemDef {
	name settings
	group grpCaptain
	text "Set"
	shortcutKey "S"
	textscale .225
	rect 240 92 40 20
	type 1
	textalign ITEM_ALIGN_LEFT
	textalignx 8
	textaligny 14
	forecolor 1 1 1 1
	visible 0
	action { play "sound/misc/menu1.wav" ; uiScript "captainSetTeamName" ; uiScript closeingame }
    }

    itemDef {
	name settings
	group grpCaptain
	text "Model:"
	cvar "ui_RQ3_teamModel"
	textscale .225
	rect 88 128 80 20
	type ITEM_TYPE_EDITFIELD
	textalign ITEM_ALIGN_LEFT
	textalignx 4
	textaligny 14
	forecolor 1 1 1 1
	visible 0
	decoration
    }

    itemDef {
	name settings
	group grpCaptain
	text "Set"
	shortcutKey "S"
	textscale .225
	rect 240 128 40 20
	type 1
	textalign ITEM_ALIGN_LEFT
	textalignx 8
	textaligny 14
	forecolor 1 1 1 1
	visible 0
	action { play "sound/misc/menu1.wav" ; uiScript "captainSetTeamModel" ; uiScript closeingame }
    }

    itemdef {
	name settings
	group grpCaptain
	rect 88 148 188 52
	type ITEM_TYPE_LISTBOX
	style WINDOW_STYLE_EMPTY
	elementwidth 26
	elementheight 26
	elementtype LISTBOX_IMAGE
	feeder FEEDER_MMHEADS
	horizontalscroll
	backcolor 0 0 0 1
	border 0
	bordercolor Ig_Window_BorderColor
	forecolor 1 1 1 1
	visible 1
    }

}
}
#endif