#include "ui/menudef.h"
#include "ui/menumacros.h"

// Defines //
#define WINDOW_X		0
#define WINDOW_Y		0
#define WINDOW_WIDTH	640
#define WINDOW_HEIGHT	480
#define GROUP_NAME		"grpPopupServerRedirect"

// Redirect Popup //
menuDef {
	name		"popupServerRedirect"
	visible		0
	fullscreen	1
	rect		WINDOW_X WINDOW_Y WINDOW_WIDTH WINDOW_HEIGHT
	style		WINDOW_STYLE_FILLED
	popup

	fadeClamp	0.5
	fadeAmount  0.075

	onOpen {
		close fadebox_black ;
		close background_1 ;
		close backgroundmusic ;
		close main ;
		uiScript ServerStatus_diagnose ;
		setitemcolor background backcolor 0 0 0 0 ;
		fadein background ;
		playlooped "sound/music/menu_server.wav"
	}

	onESC {
		uiScript clearError ;
		close popupServerRedirect ;
		open main
	}

	onEnter	{
		close popupServerRedirect ;
		uiScript redirect
	}

// Background //
	itemDef {
		name		"loadPanel"
		rect		0 0 640 480
		type		ITEM_TYPE_OWNERDRAW
		ownerdraw	UI_LOADPANEL
		visible		1
		decoration
	}

	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		256
#define SUBWINDOW_HEIGHT	64
#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, _("REDIRECTION ADVISED") )

	LABEL( (SUBWINDOW_X+4)+26+6, SUBWINDOW_Y+16, (SUBWINDOW_WIDTH)-8, 10, _("Do you want to redirect to:"), .2, ITEM_ALIGN_LEFT, 0, 8 )
	CVARLABEL( (SUBWINDOW_X+4)+26+6, SUBWINDOW_Y+26, (SUBWINDOW_WIDTH)-8-56-6, 10, "com_errorMessage", .2, ITEM_ALIGN_LEFT, 0, 8 )

	BUTTON( SUBWINDOW_X+6, SUBWINDOW_Y+SUBWINDOW_HEIGHT-24, .30*(SUBWINDOW_WIDTH-18), 18, _("NO"), .3, 14, uiScript clearError ; close popupServerRedirect ; open main_opener )
	BUTTON( SUBWINDOW_X+6+.30*(SUBWINDOW_WIDTH-18)+6, SUBWINDOW_Y+SUBWINDOW_HEIGHT-24, .30*(SUBWINDOW_WIDTH-18), 18, _("YES"), .3, 14, close popupServerRedirect ; uiScript redirect )
	BUTTON( SUBWINDOW_X+6+.30*(SUBWINDOW_WIDTH-18)+6+.30*(SUBWINDOW_WIDTH-18)+6, SUBWINDOW_Y+SUBWINDOW_HEIGHT-24, .38*(SUBWINDOW_WIDTH-18), 18, _("RECONNECT"), .3, 14, close popupServerRedirect ; uiScript reconnect )
}
