#include "ui/menudef.h"
#define ANGLES 2 -88

#define FADEIN_TIME	125
//#define FADEIN_INGAME 1250

#define ITEM_HEIGHT	20

#define MENU_ITEM(ITEM_NAME, DESTINATION, ITEM_TEXT, KEY, ALIGN, ITEM_WIDTH, Y_POS)\
	itemDef { 	\
	renderpoint 	\
	name ITEM_NAME	\
	group ingameMain	\
	text "> "ITEM_TEXT	\
	shortcutKey KEY	\
	forecolor 0 0 0 1	\
	textaligny 14	\
	textscale UI_INGAME_TEXTSIZE	\
	alignrect ALIGN ITEM_ALIGN_LEFT 0 Y_POS ITEM_WIDTH ITEM_HEIGHT	\
	type ITEM_TYPE_BUTTON	\
	style WINDOW_STYLE_EMPTY	\
	visible 1	\
	action { openSpecial DESTINATION }	\
	}

#define MENU_ITEM_TOGGLE(ITEM_NAME, DESTINATION, ITEM_TEXT, KEY, ALIGN, ITEM_WIDTH, Y_POS, CVAR_TEST)\
	itemDef { 	\
	renderpoint 	\
	name ITEM_NAME	\
	group ingameMain	\
	text "> "ITEM_TEXT	\
	forecolor UI_COLOR_INACTIVE	\
	textaligny 14	\
	textscale UI_INGAME_TEXTSIZE	\
	alignrect ALIGN ITEM_ALIGN_LEFT 0 Y_POS ITEM_WIDTH ITEM_HEIGHT	\
	type ITEM_TYPE_TEXT	\
	style WINDOW_STYLE_EMPTY	\
	visible 1	\
	cvartest CVAR_TEST	\
	showCvar { "0" }	\
	decoration	\
	}	\
	itemDef { 	\
	renderpoint 	\
	name ITEM_NAME	\
	group ingameMain	\
	text "> "ITEM_TEXT	\
	shortcutKey KEY	\
	forecolor 0 0 0 1	\
	textaligny 14	\
	textscale UI_INGAME_TEXTSIZE	\
	alignrect ALIGN ITEM_ALIGN_LEFT 0 Y_POS ITEM_WIDTH ITEM_HEIGHT	\
	type ITEM_TYPE_BUTTON	\
	style WINDOW_STYLE_EMPTY	\
	visible 1	\
	cvartest CVAR_TEST	\
	hideCvar { "0" }	\
	action { openSpecial DESTINATION }	\
	}

#define MENU_ITEM_HIDE(ITEM_NAME, DESTINATION, ITEM_TEXT, KEY, ALIGN, ITEM_WIDTH, Y_POS, CVAR_TEST, HIDE_OR_SHOW)\
	itemDef { 	\
	renderpoint 	\
	name ITEM_NAME	\
	group ingameMain	\
	text "> "ITEM_TEXT	\
	shortcutKey KEY	\
	forecolor 0 0 0 1	\
	textaligny 14	\
	textscale UI_INGAME_TEXTSIZE	\
	alignrect ALIGN ITEM_ALIGN_LEFT 0 Y_POS ITEM_WIDTH ITEM_HEIGHT	\
	type ITEM_TYPE_BUTTON	\
	style WINDOW_STYLE_EMPTY	\
	visible 1	\
	cvartest CVAR_TEST	\
	HIDE_OR_SHOW	\
	action { openSpecial DESTINATION }	\
	}

{

	menuDef {
		name "ingame"
		visible 0
		fullScreen 0
		rect UI_MINX UI_MINY UI_WIDTH UI_HEIGHT
		focusColor RQ3_MAIN_FOCUSCOLOR
		disableColor .5 .5 .5 1
		onOpen {
			//setitemcolor "background" forecolor 5 5 5 0 ;
			//timefade "background" forecolor 5 5 5 1 0 FADEIN_INGAME ;
			play "sound/ui/whoosh3.wav" ;
			setfocus "button_about" ;
		}
		onESC {
			uiScript closeInGame ;
		}

		itemdef {
			name "ingame-back"
			group "background"
			background UI_ASSETS"/ingame-back.tga"
			rect 0 0 UI_WIDTH UI_HEIGHT
			style WINDOW_STYLE_SHADER
			visible 1
			decoration
		}
		
		itemdef {
			name "gradient-bottom"
			group "background"
			background UI_ASSETS"/ingame-gradient.tga"
			rect 0 $evalfloat(UI_MAXY - 128) UI_WIDTH 128
			style WINDOW_STYLE_SHADER
			visible 1
			decoration
		}

		itemdef {
			name "clipboard"
			type ITEM_TYPE_MODEL
			asset_model UI_ASSETS"/models/clipboard/clipboard.md3"
			rect 0 0 640 480
			model_fovx 40
			model_fovy 30
			model_origin 34 2.6 -0.25
			model_angles 90 -88 270
			visible 1
			decoration
		}
		
		itemdef {
			name "gradient-top"
			group "background"
			background UI_ASSETS"/ingame-gradient-top.tga"
			rect 0 0 UI_WIDTH 96
			style WINDOW_STYLE_SHADER
			visible 1
			decoration
		}
		
		itemDef {
			renderpoint
			name "spacer"
			style WINDOW_STYLE_SHADER
			rect 146 80 320 420
			anglevectors ANGLES
			visible 0
			decoration
		}
		
		itemdef {
			name "logo"
			group "background"
			background UI_ASSETS"/logo-phoenix-shadow.tga"
			rect $evalfloat(UI_WIDTH - 256) $evalfloat(UI_MAXY - 128) 256 128
			style WINDOW_STYLE_SHADER
			visible 1
			decoration
		}
		
		MENU_ITEM("button_about", "ingame_about", "^_S^_erver info", "S", "spacer", 86, 20)
		MENU_ITEM_HIDE("button_join", "ingame_join", "^_J^_oin Game", "J", "button_about", 78, 20, "g_gametype", hideCvar { 0 })
		MENU_ITEM_HIDE("button_join_dm", "ingame_join_dm", "^_J^_oin Game", "J", "button_about", 78, 20, "g_gametype", showCvar { 0 })
		MENU_ITEM_TOGGLE("button_weapon", "ingame_weapon", "^_W^_eapon Selection", "W", "button_about", 129, 40, "g_gametype")
		MENU_ITEM_TOGGLE("button_vote", "ingame_callvote", "^_V^_ote", "V", "button_weapon", 43, 20, "g_allowVote")
		MENU_ITEM("button_ignore", "ingame_ignore", "^_I^_gnore", "I", "button_vote", 56, 20)
		
		MENU_ITEM_TOGGLE("button_addbot", "ingame_addbot", "Add ^_B^_ot", "B", "button_ignore", 64, 40, "bot_enable")
		MENU_ITEM_TOGGLE("button_mm", "ingame_matchmode", "Mat^_c^_h Mode", "C", "button_addbot", 94, 20, "g_RQ3_matchmode")
		MENU_ITEM_HIDE("button_devmode", "ingame_devmode", "^_D^_eveloper Mode", "D", "button_mm", 119, 20, "sv_cheats", hideCvar { 0 })
		MENU_ITEM("button_options", "ingame_setup", "^_O^_ptions", "O", "button_mm", 64, 40)
		
		MENU_ITEM("button_restart", "confirmRestart", "^_R^_estart", "R", "button_options", 62, 40)
		MENU_ITEM("button_main", "confirmMain", "^_M^_ain Menu", "M", "button_restart", 84, 20)
		MENU_ITEM("button_quit", "confirmQuit", "E^_x^_it Reaction", "X", "button_main", 100, 20)

	}



	//Restart map

	menuDef {
		name "confirmRestart"
		rect 112 250 152 144
		onOpen { play "sound/ui/whoosh3.wav" ; setfocus no }
		onOOBClick { close _self ; open _prev }
		onEsc { close _self ; open _prev }
		disableColor  .5 .5 .5 1
		focusColor RQ3_MAIN_FOCUSCOLOR
		style WINDOW_STYLE_EMPTY
		fullscreen 0
		popup

		itemDef {
			renderpoint
			name "postit"
			group confirm
			style WINDOW_STYLE_SHADER
			background UI_ASSETS"/post_it"
			forecolor .94 .94 .82 1
			rect -16 16 180 152
			anglevectors 6 -84
			visible 1
			decoration
		}
		
		itemdef {
			renderpoint
			name restartConfirm
			group confirm
			autowrapped
			text "Restart Map?"
			forecolor 0 0 0 1
			textaligny 20
			textscale UI_MAIN_TEXTSIZE
			alignrect "postit" ITEM_ALIGN_LEFT 44 8 120 24
			style WINDOW_STYLE_EMPTY
			decoration
			visible 1
		}

		// YES	//

		itemDef {
			name yes
			group confirm
			text "^_Y^_ES"
			shortcutKey "Y"
			type ITEM_TYPE_BUTTON
			style WINDOW_STYLE_EMPTY
			backcolor 0 0 0 .1
			textscale .25
			alignrect restartConfirm ITEM_ALIGN_LEFT 4 56 32 16
			textalign ITEM_ALIGN_CENTER
			textalignx 16
			textaligny 12
			forecolor 0 0 .15 1
			visible 1
			action { play "sound/ui/whoosh3.wav" ; exec "map_restart" ; close _self }
		}

		// NO	//

		itemDef {
			name no
			group confirm
			text "^_N^_O"
			shortcutKey "N"
			type ITEM_TYPE_BUTTON
			style WINDOW_STYLE_EMPTY
			backcolor 0 0 0 .1
			textscale .25
			alignrect restartConfirm ITEM_ALIGN_LEFT 56 56 32 16
			textalign ITEM_ALIGN_CENTER
			textalignx 16
			textaligny 12
			forecolor 0 0 .15 1
			visible 1
			action { close _self ; open _prev }
		}
	}



	// Exit to main menu

	menuDef {
		name "confirmMain"
		rect 118 272 160 144
		onOpen { play "sound/ui/whoosh3.wav" ; setfocus no }
		onOOBClick { close _self ; open _prev }
		onEsc { close _self ; open _prev }
		disableColor  .5 .5 .5 1
		focusColor RQ3_MAIN_FOCUSCOLOR
		style WINDOW_STYLE_EMPTY
		fullscreen 0
		popup

		itemDef {
			renderpoint
			name "postit"
			group confirm
			style WINDOW_STYLE_SHADER
			background UI_ASSETS"/post_it"
			forecolor .94 .94 .82 1
			rect -4 4 180 152
			anglevectors -2 -92
			visible 1
			decoration
		}
		
		itemdef {
			renderpoint
			name restartConfirm
			group confirm
			autowrapped
			text "Return to \nMain Menu?"
			forecolor 0 0 0 1
			textaligny 20
			textscale UI_MAIN_TEXTSIZE
			alignrect "postit" ITEM_ALIGN_LEFT 52 8 120 24
			style WINDOW_STYLE_EMPTY
			decoration
			visible 1
		}

		// YES	//

		itemDef {
			name yes
			group confirm
			text "^_Y^_ES"
			shortcutKey "Y"
			type ITEM_TYPE_BUTTON
			style WINDOW_STYLE_EMPTY
			backcolor 0 0 0 .1
			textscale .25
			alignrect restartConfirm ITEM_ALIGN_LEFT -4 56 32 16
			textalign ITEM_ALIGN_CENTER
			textalignx 16
			textaligny 12
			forecolor 0 0 .15 1
			visible 1
			action { play "sound/ui/whoosh3.wav" ; close _self ; uiScript leave }
		}

		// NO	//

		itemDef {
			name no
			group confirm
			text "^_N^_O"
			shortcutKey "N"
			type ITEM_TYPE_BUTTON
			style WINDOW_STYLE_EMPTY
			backcolor 0 0 0 .1
			textscale .25
			alignrect restartConfirm ITEM_ALIGN_LEFT 48 56 32 16
			textalign ITEM_ALIGN_CENTER
			textalignx 16
			textaligny 12
			forecolor 0 0 .15 1
			visible 1
			action { close _self ; open _prev }
		}
	}


#define BACK_COLOR1	.94 .94 .82 1
#define BACK_COLOR2	1 .95 .8 1

	// Quit game

	menuDef {
		name "confirmQuit"
		rect 84 184 188 144
		onOpen {
			setrandomitemcolor postit forecolor 2 BACK_COLOR1 BACK_COLOR2 ;
			ALPHA_FADE_FORE(confirm, 1) ;
			play "sound/ui/whoosh3.wav" ;
			setQuitText message ;
			setfocus no
		}
		onOOBClick { close _self ; open _prev }
		onEsc { close _self ; open _prev }
		disableColor  .5 .5 .5 1
		focusColor RQ3_MAIN_FOCUSCOLOR
		style WINDOW_STYLE_EMPTY
		//style WINDOW_STYLE_FILLED
		//backcolor 0 0 0 1
		anglevectors -9 -99
		fullscreen 0
		popup

		itemDef {
			renderpoint
			name "postit"
			group confirm
			menuAnchor
			style WINDOW_STYLE_SHADER
			background UI_ASSETS"/post_it"
			forecolor .94 .94 .82 1
			rect 0 0 188 148
			anglevectors -9 -99
			visible 1
			decoration
		}
		
		itemdef {
			renderpoint
			name message
			group confirm
			autowrapped
			text "Exit Reaction?"
			forecolor 0 0 0 1
			textalign ITEM_ALIGN_CENTER
			textalignx 56
			textaligny 20
			textscale UI_SUBMENU_TEXTSIZE
			alignrect "postit" ITEM_ALIGN_LEFT 36 20 112 24
			style WINDOW_STYLE_EMPTY
			decoration
			visible 1
		}

		// YES	//

		itemDef {
			name yes
			group confirm
			text "^_Y^_ES"
			shortcutKey "Y"
			type ITEM_TYPE_BUTTON
			style WINDOW_STYLE_EMPTY
			textscale .25
			alignrect message ITEM_ALIGN_LEFT 20 56 32 16
			textalign ITEM_ALIGN_CENTER
			textalignx 16
			textaligny 12
			forecolor 0 0 .15 1
			visible 1
			action { play "sound/ui/whoosh3.wav" ; close _self ; uiScript quit }
		}

		// NO	//

		itemDef {
			name no
			group confirm
			text "^_N^_O"
			shortcutKey "N"
			type ITEM_TYPE_BUTTON
			style WINDOW_STYLE_EMPTY
			textscale .25
			alignrect message ITEM_ALIGN_RIGHT 20 56 32 16
			textalign ITEM_ALIGN_CENTER
			textalignx 16
			textaligny 12
			forecolor 0 0 .15 1
			visible 1
			action { close _self ; open _prev }
		}
	}
}
