#include "ui/menudef.h"

#define ANGLES		3 -87

#define ITEM_OPTION(ITEM, ITEM_ID, ITEM_TEXT, ITEM_KEY, BELOW)\
	itemDef {	\
	name ITEM	\
	ownerdrawFlag UI_SHOW_ITEM##ITEM_ID	\
	type ITEM_TYPE_BUTTON	\
	text ITEM_TEXT	\
	shortcutKey ITEM_KEY	\
	alignrect BELOW ITEM_ALIGN_LEFT 0 18 192 16	\
	style WINDOW_STYLE_EMPTY	\
	textalign ITEM_ALIGN_LEFT	\
	textalignx 8	\
	textaligny 14	\
	textscale .225	\
	forecolor 0 0 .1 1	\
	visible 1	\
	onFocus { hide items ; show "it_"ITEM"" }	\
	action { exec "choose "ITEM"" ; close _self ; close ingame_weapon }	\
	}	\
	itemDef {	\
	name ITEM	\
	ownerdrawFlag UI_SHOW_ITEM##ITEM_ID	\
	ownerdrawFlag UI_SHOW_TOGGLE	\
	type ITEM_TYPE_TEXT	\
	text ITEM_TEXT	\
	alignrect BELOW ITEM_ALIGN_LEFT 0 18 192 16	\
	style WINDOW_STYLE_EMPTY	\
	textalign ITEM_ALIGN_LEFT	\
	textalignx 8	\
	textaligny 14	\
	textscale .225	\
	forecolor 0 0 .1 .2	\
	visible 1	\
	decoration	\
	}

#define ITEM_PREVIEW(ITEM, FILE, ORIGIN, FOV, ROTATION, ANGLES)\
    itemDef {	\
	name "it_"ITEM	\
	group items	\
	alignrect "preview" ITEM_ALIGN_CENTER 2 -16 128 136	\
	style WINDOW_STYLE_EMPTY	\
	type ITEM_TYPE_MODEL	\
	asset_model FILE	\
	model_origin ORIGIN	\
	model_fovx FOV	\
	model_fovy FOV	\
	model_rotation ROTATION	\
	model_angles ANGLES	\
	decoration	\
	visible 0	\
    }
{
	// ITEM SELECTION MENU //

	menuDef {
		name "ingame_item"
		visible 0
		fullscreen 0
		rect 4 32 340 264
		anglevectors ANGLES
		focusColor .25 .25 .5 1
		popup
		style WINDOW_STYLE_EMPTY
		onOpen {
			//setitemcolor window forecolor 5 5 5 0 ;
			//timefade window forecolor 5 5 5 1 0 FADEIN_TIME ;
			play "sound/ui/whoosh3.wav" ;
			uiScript "updateItemBans" ;
			setfocus kevlar
		}
		onESC { play "sound/ui/whoosh3.wav" ; close _self ; close ingame_weapon }
		onOOBClick { play "sound/ui/whoosh3.wav" ; close _self ; open _prev }
		
		itemDef {
			renderpoint
			name "paper"
			menuAnchor
			group window
			style WINDOW_STYLE_SHADER
			background UI_ASSETS"/paper_1"
			forecolor 1 1 .92 1
			//forecolor .87 .92 .95 1
			rect -8 -12 380 320
			anglevectors ANGLES
			visible 1
			decoration
		}
		
		// TITLE //
		
		itemDef {
			renderpoint
			name "title"
			text "Choose item:"
			//forecolor .6 .0 .0 1
			forecolor .0 .0 .1 1
			style WINDOW_STYLE_EMPTY
			textalign ITEM_ALIGN_LEFT
			textalignx 0
			textaligny 12
			textscale RQ3_MAIN_TEXTSIZE
			alignrect paper ITEM_ALIGN_LEFT 36 36 240 36 
			visible 1
			autowrapped
			decoration
			
			//style WINDOW_STYLE_FILLED
			//backcolor 0 0 0 .6
		}
		
		itemDef {
			name "preview"
			background UI_ASSETS"/replacement-back.tga"
			rect 192 56 120 120
			anglevectors 1 -89
			decoration
			visible 1
			style WINDOW_STYLE_SHADER
		}
		
		// ITEMS //
		
		// order by: item, item id, description, shortcut key, previous element  
		ITEM_OPTION("kevlar", 1, "^_1^_. Kevlar Vest", "1", "title")
		ITEM_OPTION("laser", 2, "^_2^_. Lasersight", "2", "kevlar")
		ITEM_OPTION("slippers", 3, "^_3^_. Stealth Slippers", "3", "laser")
		ITEM_OPTION("silencer", 4, "^_4^_. Silencer", "4", "slippers")
		ITEM_OPTION("bandolier", 5, "^_5^_. Bandolier", "5", "silencer")
		ITEM_OPTION("helmet", 6, "^_6^_. Kevlar Helmet", "6", "bandolier")
		
		// PREVIEWS //
		
		// order by: item, file, origin xyz, fov, rotation, angles xyz
		ITEM_PREVIEW("kevlar", "models/items/kevlar.md3", 28 0 2, 80, 10, 250 0 90)
		ITEM_PREVIEW("laser", "models/items/laser.md3", 24 15 0, 40, 10, 270 75 90)
		ITEM_PREVIEW("slippers", "models/items/slippers.md3", 20 0 2, 90, 10, 270 0 90)
		ITEM_PREVIEW("silencer", "models/items/silencer.md3", 20 0 0, 60, 10, 270 105 90)
		ITEM_PREVIEW("bandolier", "models/items/bandolier.md3", 20 0 2, 70, 10, 270 0 24)
		ITEM_PREVIEW("helmet", "models/items/helmet.md3", 30 0 0, 30, 10, 180 5 0)
		
		itemDef {
			renderpoint
			name "polaroid"
			style WINDOW_STYLE_SHADER
			background UI_ASSETS"/polaroid"
			alignrect "preview" ITEM_ALIGN_CENTER 0 -23 160 160
			visible 1
			decoration
		}
	}
}
