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

// Defines //
#define WINDOW_X		16
#define WINDOW_Y		16
#define WINDOW_WIDTH	608
#define WINDOW_HEIGHT	448
#define GROUP_NAME		"grpViewReplay"

// View Replay Menu //
menuDef {
	name		"viewreplay"
	visible		0
	fullscreen	0
	rect		WINDOW_X WINDOW_Y WINDOW_WIDTH WINDOW_HEIGHT
	style		WINDOW_STYLE_FILLED

	onOpen {
		uiScript LoadDemos
		setfocus demoList
	}

	onESC {
		close viewreplay ;
		open main
	}

	// Window //
	WINDOW( _("REPLAYS"), 150 )

#ifdef ETLEGACY
	// Pure "server" demo viewing. Maybe change this to something more pretty? Checkbox? //
	YESNO( 160, 14, 40, 10, _("Pure Server:"), .2, 8, "sv_pure", _("Limit game content to that contained in PK3 files\non both the client and server with matching CRCs") )
	// Keep replay ordering clickable from the same top-row controls.
	MULTIACTIONLEFT( 256, 14, 100, 10, _("Sorting:"), .2, 8, "ui_demoSortAscending", cvarFloatList { "Descending" 0 "Ascending" 1 }, uiScript LoadDemos, _("Toggle the replay browser sorting order between descending and ascending") )
#endif

	// Demo List //
	itemDef {
		name			"demoList"
		group			GROUP_NAME
		rect			6 32 596 386
		type			ITEM_TYPE_LISTBOX
		textfont		UI_FONT_COURBD_21
		textstyle		ITEM_TEXTSTYLE_SHADOWED
		textscale		.2
		textaligny		-3
		forecolor		.6 .6 .6 1
		outlinecolor	.5 .5 .5 .4
		border			WINDOW_BORDER_FULL
		bordercolor		.1 .1 .1 .5
		feeder			FEEDER_DEMOS
		elementtype		LISTBOX_TEXT
		elementwidth	200
		elementheight	12
		// Let replay names use the available row width instead of the shared 33-char cap.
		columns			1 0 590 0
		visible			1
		tooltip			""

		doubleClick {
			uiScript RunDemo
		}

		onEnter {
			uiScript RunDemo
		}
	}

	// Buttons //
	BUTTON( 6, WINDOW_HEIGHT-24, .33*(WINDOW_WIDTH-24), 18, _("MSGID_MENU_BACK"), .3, 14, close viewreplay ; open main )
	BUTTON( 6+.33*(WINDOW_WIDTH-24)+6, WINDOW_HEIGHT-24, .34*(WINDOW_WIDTH-24), 18, _("MSGID_MENU_REPLAYS_DELETE"), .3, 14, conditionalScript ValidReplaySelected 2
		( "clearFocus ; open viewreplay_delete" )
		( "clearFocus" ) )
	BUTTON( 6+.33*(WINDOW_WIDTH-24)+6+.34*(WINDOW_WIDTH-24)+6, WINDOW_HEIGHT-24, .33*(WINDOW_WIDTH-24), 18, _("MSGID_MENU_REPLAYS_VIEW"), .3, 14, uiScript RunDemo )
}
