#include "ui/menudef.h"

// Defines //

#define WINDOW_X		0
#define WINDOW_Y		0
#define WINDOW_WIDTH	640
#define WINDOW_HEIGHT	480
#define GROUP_NAME		"grpVidConfirm"

// Macros //

#include "ui/menumacros.h"
		
// Confirm Video Mode Menu //
	
menuDef
{
	name		"vid_confirm"
	visible		0
	fullscreen	0
	rect		WINDOW_X WINDOW_Y WINDOW_WIDTH WINDOW_HEIGHT
	style		WINDOW_STYLE_FILLED
	popup
	modal
	
	fadeClamp	0.5
	fadeAmount  0.075
	
	onOpen
	{
		setitemcolor background backcolor 0 0 0 0 ;
		fadein background
	}
	
	onESC
	{
		uiScript VidReset ;
		exec "vid_restart" 
	}
	
	// after 15 seconds, reset to previous video mode
	onTimeout 15000
	{
		uiScript VidReset ;
		exec "vid_restart" 
	}
	
// Background //

	itemDef {
		name		"background"
		rect		0 0 640 480
		style		WINDOW_STYLE_FILLED
		background	"ui/assets/fadebox.tga"
		backcolor	0 0 0 0
		visible		1
		decoration
	}

// Subwindows //

#define SUBWINDOW_WIDTH		216
#define SUBWINDOW_HEIGHT	96
#define SUBWINDOW_X			.5 * (WINDOW_WIDTH - SUBWINDOW_WIDTH)
#define SUBWINDOW_Y			.5 * (WINDOW_HEIGHT - SUBWINDOW_HEIGHT)

	SUBWINDOWBLACK( SUBWINDOW_X, SUBWINDOW_Y, SUBWINDOW_WIDTH, SUBWINDOW_HEIGHT, "CONFIRM VIDEO CHANGE" )
/*	LABEL( SUBWINDOW_X+2, SUBWINDOW_Y+16, (SUBWINDOW_WIDTH)-8, 10,
		"Use this video mode?\nReverting to previous\nsetting in 15 seconds...",
		.2, ITEM_ALIGN_CENTER, .5*((SUBWINDOW_WIDTH)-4), 8 )

#define COUNTER_WIDTH		32
	itemDef
	{
		name			"mapPreview"
		group			GROUP_NAME
		rect			$evalfloat((SUBWINDOW_X)+(SUBWINDOW_WIDTH)-COUNTER_WIDTH-4) $evalfloat((SUBWINDOW_Y)+2) $evalfloat((COUNTER_WIDTH)) 12
		type			ITEM_TYPE_TIMEOUT_COUNTER
		text			" "	// filler, must be present
		textfont		UI_FONT_ARIBLK_16
		textscale		.19
		textalign		ITEM_ALIGN_RIGHT
		textalignx		COUNTER_WIDTH	//%	3
		textaligny		10
		border			WINDOW_BORDER_NONE
		style			WINDOW_STYLE_EMPTY
		forecolor		.6 .6 .6 1
		visible			1
		decoration
    }*/
    
    LABEL( SUBWINDOW_X+2, SUBWINDOW_Y+16, (SUBWINDOW_WIDTH)-8, 10,
		"Use this video mode?",
		.2, ITEM_ALIGN_CENTER, .5*((SUBWINDOW_WIDTH)-4), 8 )
	LABEL( SUBWINDOW_X+2, SUBWINDOW_Y+28, (SUBWINDOW_WIDTH)-8, 10,
		"Reverting to previous",
		.2, ITEM_ALIGN_CENTER, .5*((SUBWINDOW_WIDTH)-4), 8 )
    
    itemDef {
		name			"labelConfirmCounter"
      	group			GROUP_NAME
		rect			$evalfloat(SUBWINDOW_X+2) $evalfloat( SUBWINDOW_Y+40) $evalfloat((SUBWINDOW_WIDTH)-8) $evalfloat(10)
		type			ITEM_TYPE_TIMEOUT_COUNTER
		text			"setting in %s seconds..."
		textfont		UI_FONT_COURBD_21
		textstyle		ITEM_TEXTSTYLE_SHADOWED
		textscale		.2
		textalign		ITEM_ALIGN_CENTER
		textalignx		$evalfloat(.5*((SUBWINDOW_WIDTH)-4))
		textaligny		8
		forecolor		.6 .6 .6 1
		visible			1
		decoration
    }
	
#ifdef FUI
	BUTTON( SUBWINDOW_X+6, SUBWINDOW_Y+SUBWINDOW_HEIGHT-24, .5*(SUBWINDOW_WIDTH-18), 18, "YES", .3, 14, uiScript vidConfirm ; close vid_confirm ; open main )
#else
	BUTTON( SUBWINDOW_X+6, SUBWINDOW_Y+SUBWINDOW_HEIGHT-24, .5*(SUBWINDOW_WIDTH-18), 18, "YES", .3, 14, uiScript vidConfirm ; close vid_confirm ; open ingame_main )
#endif // FUI
	BUTTON( SUBWINDOW_X+6+.5*(SUBWINDOW_WIDTH-18)+6, SUBWINDOW_Y+SUBWINDOW_HEIGHT-24, .5*(SUBWINDOW_WIDTH-18), 18, "NO", .3, 14, uiScript vidReset ; exec "vid_restart" )
}
