#include "ui/menudef.h"

#define ANGLES		2 -88

#define ITEM_OPTION(ITEM, ITEM_ID, ITEM_TEXT, ITEM_KEY, BELOW)\
	itemDef {	\
	name ITEM	\
	ownerdrawFlag UI_SHOW_WEAP##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 weapons ; show "wp_"ITEM"" }	\
	action { exec "choose "ITEM"" ; open ingame_item }	\
	}	\
	itemDef {	\
	name ITEM	\
	ownerdrawFlag UI_SHOW_WEAP##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 "wp_"ITEM	\
	group weapons	\
	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	\
    }
{
	// WEAPON SELECTION MENU //

	menuDef {
		name "ingame_weapon"
		visible 0
		fullscreen 0
		rect 20 20 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 mp5
		}
		onESC { play "sound/ui/whoosh3.wav" ; close _self ; open _prev }
		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 .934 .938 .891 1
			//forecolor .9 .9 .82 1
			//forecolor .78 .82 .86 1
			rect -8 -12 380 320
			anglevectors ANGLES
			visible 1
			decoration
		}
		
		// TITLE //
		
		itemDef {
			renderpoint
			name "title"
			text "Choose weapon:"
			//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 80 120 120
			anglevectors 1 -89
			decoration
			visible 1
			style WINDOW_STYLE_SHADER
		}
		
		// WEAPONS //
		
		// order by: weapon, weapon id, description, shortcut key, previous element  
		ITEM_OPTION("mp5", 1, "^_1^_. MP5/10 Submachinegun", "1", "title")
		ITEM_OPTION("m3", 2, "^_2^_. M3 Super 90 Assault Shotgun", "2", "mp5")
		ITEM_OPTION("hc", 3, "^_3^_. Handcannon", "3", "m3")
		ITEM_OPTION("sniper", 4, "^_4^_. Sniper Rifle", "4", "hc")
		ITEM_OPTION("m4", 5, "^_5^_. M4 Assault Rifle", "5", "sniper")
		ITEM_OPTION("knives", 6, "^_6^_. Combat Knives", "6", "m4")
		ITEM_OPTION("akimbo", 7, "^_7^_. Dual Mk23 Pistols", "7", "knives")
		
		// PREVIEWS //
		
		// order by: weapon, file, origin xyz, fov, rotation, angles xyz
		ITEM_PREVIEW("mp5", "models/weapons2/mp5/mp5.md3", 8 0 0, 60, 10, 90 -5 0)
		ITEM_PREVIEW("m3", "models/weapons2/m3/m3.md3", 28 0 2, 60, 10, 270 22 0)
		ITEM_PREVIEW("hc", "models/weapons2/handcannon/handcannon.md3", 20 0 2, 60, 10, 90 25 0)
		ITEM_PREVIEW("sniper", "models/weapons2/ssg3000/ssg3000.md3", 28 0 3, 60, 10, 270 25 0)
		ITEM_PREVIEW("m4", "models/weapons2/m4/m4.md3", 18 0 2, 60, 10, 90 25 0)
		ITEM_PREVIEW("knives", "models/weapons2/knife/knife.md3", 1 0 1, 60, 10, 180 0 15)
		// 2 pistols!
		ITEM_PREVIEW("akimbo", "models/weapons2/mk23/mk23.md3", 5 0 2, 90, 10, 90 0 0)
		ITEM_PREVIEW("akimbo", "models/weapons2/mk23/mk23.md3", 5 2 -2, 90, 10, 90 180 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
		}
	}
}
