#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 LINE_WIDTH			240

#define ANGLES 8 -82


#define ADD_TAB2(TAB_TEXT, TAB_SHORTCUT, TAB_INDEX, TAB_REPLACEMENTS, TAB_OTHER_GROUPS, TAB_ALIGN)\
    itemdef {	\
	cleantext TAB_TEXT	\
	name "alltabs,tab"#TAB_INDEX"_0,fade_alpha,allgroups,group"#TAB_INDEX	\
	INACTIVE_TAB_PROPS	\
	TAB_ALIGN	\
    }	\
    itemdef {	\
	text TAB_TEXT	\
	name "alltabs,tab"#TAB_INDEX",fade_alpha,allgroups,"TAB_OTHER_GROUPS	\
	shortcutKey TAB_SHORTCUT	\
	shortcutKey #TAB_INDEX	\
	ACTIVE_TAB_PROPS	\
	action { ACTIVATE_TAB(TAB_INDEX) ; uiScript replace TAB_REPLACEMENTS }	\
	ASSIGN_HINT("hint_tab"#TAB_INDEX)	\
	TAB_ALIGN	\
    }



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

{

	menuDef {
		renderpoint
		name "replacements_menu"
		visible MENU_FALSE				// Visible on open
		focusColor RQ3_MAIN_FOCUSCOLOR			// Menu focus color for text and items
		rect 128 88 320 348
		anglevectors ANGLES
		style WINDOW_STYLE_EMPTY
		//style WINDOW_STYLE_FILLED
		//backcolor 0 0 0 1
		popup
		onOOBClick { close _self }
		onOpen { play "sound/ui/whoosh3.wav" ; uiScript buildReplacementList 
			ACTIVATE_TAB(1) ;
		}
		onClose { open _prev }
		onEsc { close _self }

		onOpenSpecial {
			//normal items
			setItemColor "fade_fore_alpha" forecolor 5 5 5 0 ;
			timeFade "fade_fore_alpha" forecolor 5 5 5 1 0 FADEIN_TIME ;
			//icon - special alpha
			setItemColor "icon" forecolor 5 5 5 0 ;
			timeFade "icon" forecolor 5 5 5 ICON_ALPHA 0 FADEIN_TIME ;
			//line - special alpha; using backcolor
			setItemColor "line" backcolor 5 5 5 0 ;
			timeFade "line" backcolor 5 5 5 LINE_ALPHA 0 FADEIN_TIME ;
		}

		itemDef {
			name "paper"
			menuAnchor
			subgroup "fade_fore_alpha"
			style WINDOW_STYLE_SHADER
			background UI_ASSETS"/paper_1"
			forecolor MENUCOLOR_REPLACEMENTS 1
			rect -8 -20 320 420
			anglevectors ANGLES
			visible 1
			decoration
		}

		//Title

		itemdef {
			renderpoint
			name "title"
			subgroup "fade_fore_alpha"
			text "Replacements:"
			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_CENTER -20 40 220 20
			visible 1
			autowrapped
			decoration
		}

		//Line

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

		//Icon

		itemdef {
			name icon
			background UI_ASSETS"/icons/rq3-menu-start"
			forecolor 1 1 1 ICON_ALPHA
			alignrect "line" ITEM_ALIGN_RIGHT 0 -36 32 32
			style WINDOW_STYLE_SHADER
			visible 1
			decoration
		}
		

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

// Weapons

		ADD_TAB2(
			"^_W^_eapons.",
			"W", 1, "weapons", "group2,group3",
			alignrect "title" ITEM_ALIGN_LEFT 2 28 48 16
		)
		ADD_HINT("hint_tab1", "Weapon replacements", "group2,group3")

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

// Items

		ADD_TAB2(
			"^_I^_tems.",
			"I", 2, "items", "group1,group3",
			alignrect "tab1" ITEM_ALIGN_RIGHT -32 0 32 16
		)
		ADD_HINT("hint_tab2", "Item replacements", "group1,group3")

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

// Ammo

		ADD_TAB2(
			"^_A^_mmo.",
			"A", 3, "ammo", "group1,group2",
			alignrect "tab2" ITEM_ALIGN_RIGHT -33 0 32 16
		)
		ADD_HINT("hint_tab3", "Ammo replacements", "group1,group2")

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


		//Preview
		itemdef {
			name "preview"
			//subgroup "fade_fore_alpha,group1,allgroups"
			ownerdraw UI_RQ3_REPLACEMENTMODEL
			background UI_ASSETS"/replacement-back.tga"
			rect 180 64 120 120
			anglevectors 1 -89
			decoration
			visible 1
			style WINDOW_STYLE_SHADER
		}

		itemDef {
			renderpoint
			name "polaroid"
			//group "fade_fore_alpha,group1,allgroups"
			style WINDOW_STYLE_SHADER
			background UI_ASSETS"/polaroid"
			alignrect "preview" ITEM_ALIGN_CENTER 0 -23 160 160
			visible 1
			decoration
		}
		



		//Prev model
		itemDef {
			name "prev"
			shortcutkey "P"
			alignrect "preview" ITEM_ALIGN_LEFT 4 38 16 16
			style WINDOW_STYLE_SHADER
			background UI_ASSETS"/arrow_left_white"
			type ITEM_TYPE_BUTTON
			visible 1
			forecolor 1 1 1 .3
			
			action { play "sound/ui/whoosh3.wav" ; uiScript nextReplacement "-1" }
			
			onFocus {
				show "hint_prev" ; 
				timeFade "hint_prev" forecolor 5 5 5 1 0 HINT_FADE_TIME ;
				timefadeSelf forecolor 1 1 1 1 0 250
			}
			leaveFocus {
				timeFade "hint_prev" forecolor 5 5 5 0 0 HINT_FADE_TIME ;
				timefadeSelf forecolor 1 1 1 .3 0 250
			}
		}

		
		ADD_HINT("hint_prev", "Previous option", "allgroups")


		//Next model
		itemDef {
			name "next"
			shortcutkey "N"
			alignrect "preview" ITEM_ALIGN_RIGHT 4 38 16 16
			style WINDOW_STYLE_SHADER
			background UI_ASSETS"/arrow_right_white"
			type ITEM_TYPE_BUTTON
			visible 1
			forecolor 1 1 1 .3
			
			action { play "sound/ui/whoosh3.wav" ; uiScript nextReplacement "1" }
			
			onFocus {
				show "hint_next" ; 
				timeFade "hint_next" forecolor 5 5 5 1 0 HINT_FADE_TIME ;
				timefadeSelf forecolor 1 1 1 1 0 250
			}
			leaveFocus {
				timeFade "hint_next" forecolor 5 5 5 0 0 HINT_FADE_TIME ;
				timefadeSelf forecolor 1 1 1 .3 0 250
			}
		}

		
		ADD_HINT("hint_next", "Next option", "allgroups")




		itemdef {
			name "weapon_tip"
			group "fade_fore_alpha,group1,allgroups"
			style 0
			text "Select the weapon you\n"
				"want to replace:"
			autowrapped
			alignrect "line" ITEM_ALIGN_LEFT 4 48 208 20
			textscale .225
			textalign 0
			textalignx 4
			textaligny 16
			forecolor OPTION_COLOR
			visible 1
			decoration
		}

		itemdef {
			name "item_tip"
			group "fade_fore_alpha,group2,allgroups"
			style 0
			text "Select the item you\n"
				"want to replace:"
			autowrapped
			alignrect "line" ITEM_ALIGN_LEFT 4 48 208 20
			textscale .225
			textalign 0
			textalignx 4
			textaligny 16
			forecolor OPTION_COLOR
			visible 1
			decoration
		}

		itemdef {
			name "ammo_tip"
			group "fade_fore_alpha,group3,allgroups"
			style 0
			text "Select the ammo type\n"
				"you want to replace:"
			autowrapped
			alignrect "line" ITEM_ALIGN_LEFT 4 48 208 20
			textscale .225
			textalign 0
			textalignx 4
			textaligny 16
			forecolor OPTION_COLOR
			visible 1
			decoration
		}

		//Sub-Type
		itemDef {
			name "sub-type"
			//text "Type:"
			ownerdraw UI_RQ3_REPLACEMENTSUBTYPE
			alignrect "line" ITEM_ALIGN_LEFT 12 84 120 16
			textalign ITEM_ALIGN_LEFT
			textalignx 4
			textaligny 14
			textscale .225
			forecolor OPTION_COLOR
			visible 1
			
			action { play "sound/ui/whoosh3.wav" }
			
			onFocus {
				show "hint_type" ;
				timeFade "hint_type" forecolor 5 5 5 1 0 HINT_FADE_TIME
			}
			leaveFocus {
				timeFade "hint_type" forecolor 5 5 5 0 0 HINT_FADE_TIME
			}
		}

		ADD_HINT("hint_type", "Browse through categories", "allgroups")

		itemdef {
			name "selection_tip"
			style 0
			text "The current option:"
			autowrapped
			alignrect "sub-type" ITEM_ALIGN_LEFT -8 48 208 20
			textscale .225
			textalign 0
			textalignx 4
			textaligny 16
			forecolor OPTION_COLOR
			visible 1
			decoration
		}

		//Replacement name
		itemDef {
			name "replacement"
			ownerdraw UI_RQ3_REPLACEMENTNAME
			alignrect "selection_tip" ITEM_ALIGN_LEFT 8 24 160 16
			textalign ITEM_ALIGN_CENTER
			textalignx 5
			textaligny 12
			textscale .225
			forecolor OPTION_COLOR
			style WINDOW_STYLE_EMPTY
			//style WINDOW_STYLE_FILLED
			//backcolor 0 0 0 1
			visible 1
			decoration
		}

		//Description
		itemDef {
			name "description"
			ownerdraw UI_RQ3_REPLACEMENTINFO
			alignrect "replacement" ITEM_ALIGN_LEFT 12 14 224 104
			textalign ITEM_ALIGN_LEFT
			textalignx 4
			textaligny 14
			textscale .2
			//backcolor 0 0 0 .125
			forecolor .25 .25 .25 1
			//forecolor OPTION_COLOR
			style WINDOW_STYLE_EMPTY
			//style WINDOW_STYLE_FILLED
			visible 1
			decoration
		}

		//Select
		itemDef {
			name "select"
			text "^_S^_elect >"
			shortcutKey "S"
			type ITEM_TYPE_BUTTON
			textscale .25
			style WINDOW_STYLE_EMPTY
			alignrect "paper" ITEM_ALIGN_RIGHT 32 308 96 16
			textalign ITEM_ALIGN_CENTER
			textalignx 48
			textaligny 12
			forecolor OPTION_COLOR
			visible 1
			
			action { play "sound/ui/whoosh3.wav" ; uiScript "selectReplacement" }
			
			onFocus {
				show "hint_select" ;
				timeFade "hint_select" forecolor 5 5 5 1 0 HINT_FADE_TIME
			}
			leaveFocus {
				timeFade "hint_select" forecolor 5 5 5 0 0 HINT_FADE_TIME
			}
		}

		ADD_HINT("hint_select", "Select the current option", "allgroups")
			
	}

}

#if 0

#include "ui/menudef.h"
#define RQ3_Option_Color .75 .75 .75 1

{

    menuDef {
	name "replacements_menu"
	background "rq3-ta-menuback"				// Makro: replace "rq3-ta-menuback" with "rq3-menuback"
								// to use the old background
	fullScreen MENU_TRUE
	visible MENU_TRUE				// Visible on open
	focusColor RQ3_MAIN_FOCUSCOLOR			// Menu focus color for text and items

	onOpen { play "sound/misc/menu1.wav" ; uiScript buildReplacementList }
	//onEsc { close replacements_menu ; open setup_menu }
	onEsc { close _self ; open _previous }


//=================
// RQ3 stuff
//=================


    itemDef {
	name top_bar 				//rq3: Top bar
	rect 0 0 640 56
	style 1
	backcolor RQ3_MAIN_BAR_COLOR
	//border 2
	//bordersize 1
	//bordercolor 1 0 0 1
	decoration
	visible 1
    }

    itemDef {
	name top_bar 				//rq3: Top bar
	rect 0 58 640 12
	style WINDOW_STYLE_SHADER
	background "ui/assets/rq3-main-shadow-1"
	decoration
	visible 1
    }

    itemDef {
	name top_bar2 				//rq3: Top bar - border
	rect 0 56 640 2
	style 1
	backcolor RQ3_MAIN_BAR_COLOR2
	//border 2
	//bordersize 1
	//bordercolor 1 0 0 1
	decoration
	visible 1
    }

    itemDef {
	name bottom_bar 				//rq3: bottom bar
	rect 0 420 640 60
	style 1
	backcolor RQ3_MAIN_BAR_COLOR
	//border 2
	//bordersize 1
	//bordercolor 1 0 0 1
	decoration
	visible 1
    }

    itemDef {
	name bottom_bar2 				//rq3: bottom bar - border
	rect 0 418 640 2
	style 1
	backcolor RQ3_MAIN_BAR_COLOR2
	//border 2
	//bordersize 1
	//bordercolor 1 0 0 1
	decoration
	visible 1
    }

    itemdef {
	name "options_icon"
	style WINDOW_STYLE_SHADER
	rect 8 8 48 48
	background UI_ASSETS"/icons/rq3-setup-replacements"
	decoration
	visible 1
    }

    itemdef {
	name "options_title"
	style WINDOW_STYLE_SHADER
	rect 64 12 256 32
	background UI_ASSETS"/icons/rq3-title-setup.tga"
	decoration
	visible 1
    }

    itemdef {
	name overlay
	style 1
	forecolor 0 0 0 1
	backcolor RQ3_MENU_OVERLAY_COLOR
	rect 0 58 640 360
	visible 1
	decoration
    }


//=================
// Buttons, lists
//=================

	//Window
    itemdef {
	rect 128 118 400 224
	style WINDOW_STYLE_FILLED
	backcolor Ig_Window_Color
	visible 1
	border 1
	bordersize 1
	shadowStyle 1
	bordercolor Ig_Window_BorderColor
	decoration
    }

    //Background
    itemdef {
	name page3
	rect 135 125 114 128
	style WINDOW_STYLE_SHADER
	background "ui/assets/rq3-ingame-loadout"
	border 0
	bordersize 1
	bordercolor Ig_Window_BorderColor
	//backcolor .5 .5 .5 .4
	decoration
	visible 1
    }

	//Preview
    itemdef {
	name page3
	//type ITEM_TYPE_MODEL
	ownerdraw UI_RQ3_REPLACEMENTMODEL
	rect 143 133 98 110
	decoration
	visible 1
    }


    /*
	//"Preview" text
    itemdef {
	style 0
	text "Preview"
	rect 143 133 96 16
	textstyle 3
	textscale .225
	textalign ITEM_ALIGN_CENTER
	textalignx 48
	textaligny 16
	forecolor 1 1 .75 1
	visible 1
	decoration
    }
	*/


    //Prev model
    itemDef {
	name page3
	shortcutkey ","
	shortcutkey "P"
	rect 147 178 16 16
	style WINDOW_STYLE_SHADER
	background "ui/assets/arrow_left_white"
	type ITEM_TYPE_BUTTON
	visible 1
	forecolor 1 1 1 .3
	onFocus { timefadeSelf forecolor 1 1 1 1 0 250 }
	leaveFocus { timefadeSelf forecolor 1 1 1 .3 0 250 }
	action { play "sound/misc/menu1.wav" ; uiScript nextReplacement "-1" }
    }

    //Next model
    itemDef {
	name page3
	shortcutkey "."
	shortcutkey "N"
	rect 219 178 16 16
	style WINDOW_STYLE_SHADER
	background "ui/assets/arrow_right_white"
	type ITEM_TYPE_BUTTON
	visible 1
	forecolor 1 1 1 .3
	onFocus { timefadeSelf forecolor 1 1 1 1 0 250 }
	leaveFocus { timefadeSelf forecolor 1 1 1 .3 0 250 }
	action { play "sound/misc/menu1.wav" ; uiScript nextReplacement "1" }
    }

    // Text

    //Name
    itemDef {
	name page3
	style 1
	ownerdraw UI_RQ3_REPLACEMENTNAME
	rect 147 220 80 16
	textalign ITEM_ALIGN_LEFT
	textalignx 5
	textaligny 12
	textscale .18
	forecolor 0 0 0 1
	border 0
	bordersize 1
	bordercolor Ig_Window_BorderColor
	visible 1
	decoration
    }

    //Select button

    itemdef {
	name page3
	style WINDOW_STYLE_SHADER
	forecolor .5 .5 .5 1
	rect 135 240 112 32
	decoration
	background "ui/assets/button.tga"
	visible 1
	}

    itemDef {
	name page3
	text "^_S^_elect"
	shortcutKey "S"
	type ITEM_TYPE_BUTTON
	textscale .225
	style WINDOW_STYLE_FILLED
	rect 143 248 96 16
	textalign ITEM_ALIGN_CENTER
	textalignx 48
	textaligny 12
	textstyle ITEM_TEXTSTYLE_SHADOWED
	border 1
	bordersize 1
	backcolor Ig_Sub_Color1
	forecolor Ig_Sub_TextColor
	bordercolor Ig_Sub_BorderColor1
	visible 1
	action { play "sound/misc/menu1.wav" ; uiScript "selectReplacement" }
	//onFocus { setcolor backcolor Ig_Sub_Color2 ; setcolor bordercolor Ig_Sub_BorderColor2 }
	//leaveFocus { setcolor backcolor Ig_Sub_Color1 ; setcolor bordercolor Ig_Sub_BorderColor1 }
	onFocus { show hint_select ; timeFade hint_select forecolor .9 .9 .9 1 0 250 }
	leaveFocus { timeFade hint_select forecolor .9 .9 .9 0 0 250 }
    }

    itemdef {
	name hint_select
	text "Use the chosen model"
	forecolor RQ3_MAIN_HINT_COLOR
	textalign 1
	textalignx 240
	textaligny 20
	textscale RQ3_MAIN_TEXTSIZE
	rect 80 420 480 40
	type 0
	style 0
	visible 0
	decoration
    }

    //Type

    itemDef {
	name page3
	style 1
	text "Replace:"
	ownerdraw UI_RQ3_REPLACEMENTTYPE
	rect 252 310 96 16
	textalign ITEM_ALIGN_LEFT
	textalignx 4
	textaligny 14
	textscale .2
	forecolor Ig_Sub_TextColor
	visible 1
	action { play "sound/misc/menu1.wav" }
    }

    //Sub-Type
    itemDef {
	name page3
	style 1
	text "Type:"
	ownerdraw UI_RQ3_REPLACEMENTSUBTYPE
	rect 357 310 96 16
	textalign ITEM_ALIGN_LEFT
	textalignx 4
	textaligny 14
	textscale .2
	forecolor Ig_Sub_TextColor
	visible 1
	action { play "sound/misc/menu1.wav" }
    }

	//"Description" Text
    itemdef {
	style 0
	text "Description"
	rect 252 134 260 20
	textstyle 0
	textscale .25
	textalign ITEM_ALIGN_LEFT
	textalignx 4
	textaligny 16
	forecolor 1 1 1 1
	backcolor 0.5 0.5 0.5 0.25
	visible 1
	decoration
    }

    //line
	itemdef {
	style 1
	rect 252 154 260 1
	backcolor 0.5 0.5 0.5 1.0
	visible 1
	decoration
    }

    //Description
    itemDef {
	name page3
	style 1
	//text "Text goes here"
	ownerdraw UI_RQ3_REPLACEMENTINFO
	rect 252 158 260 144
	textalign ITEM_ALIGN_LEFT
	textalignx 4
	textaligny 14
	textscale .225
	forecolor Ig_Sub_TextColor
	backcolor 0.5 0.5 0.5 0.1
	visible 1
	decoration
    }
	
//Back

    itemdef {
	name "btn_back"
	shortcutKey "B"
	style WINDOW_STYLE_SHADER
	rect 12 432 32 32
	type ITEM_TYPE_BUTTON
	background UI_ASSETS"/icons/rq3-menu-back.tga"
	action { close _self ; open setup_menu ; }
	onFocus { setbackground UI_ASSETS"/icons/rq3-menu-back-focus-anim" ;
		show hint_back ; timeFade hint_back forecolor .9 .9 .9 1 0 250 }
	leaveFocus { setbackground UI_ASSETS"/icons/rq3-menu-back.tga" ;
		timeFade hint_back forecolor .9 .9 .9 0 0 250 }
	visible 1
    }

    itemdef {
	name hint_back
	text "Go ^_b^_ack to setup menu"
	forecolor RQ3_MAIN_HINT_COLOR
	textalign 1
	textalignx 240
	textaligny 20
	textscale RQ3_MAIN_TEXTSIZE
	rect 80 420 480 40
	type 0
	style 0
	visible 0
	decoration
    }

}

#endif