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

// Defines //
#define WINDOW_X		16
#define WINDOW_Y		16
#define WINDOW_WIDTH	296
#define WINDOW_HEIGHT	310
#define GROUP_NAME		"grpIngameVoteMiscRefRcon"

// Misc Ref/Rcon Menu //
menuDef {
	name		"ingame_vote_misc_refrcon"
	visible		0
	fullscreen	0
	rect		WINDOW_X WINDOW_Y WINDOW_WIDTH WINDOW_HEIGHT
	style		WINDOW_STYLE_FILLED

	onOpen {
		conditionalScript g_gametype 3	// 3: cvartest
			( "hide bttn_nextmap ; show bttn_nextcampaign" )
			( "show bttn_nextmap ; hide bttn_nextcampaign" ) "4" ;

		conditionalScript g_gametype 3
			( "hide bttn_restmap ; show bttn_restcampaign" )
			( "show bttn_restmap ; hide bttn_restcampaign" ) "4" ;

		copyCvar g_gametype ui_voteGameType ;

		conditionalScript ui_voteGameType 3	// 3: cvartest
			( "setcvar ui_voteGameType 2" )
			( "clearFocus" ) "4" ;
	}

	onEsc {
		close ingame_vote_misc_refrcon ;
		open ingame_vote
	}

// Window //
	WINDOW( _("MISC"), 50)

// Buttons //
	BUTTON( 6, 32, .5*(WINDOW_WIDTH-18), 14, _("START MATCH"), .24, 11, exec "cmd ref startmatch" ; uiScript closeingame )
	BUTTONEXT( 6, 50, .5*(WINDOW_WIDTH-18), 14, _("RESET MATCH"), .24, 11, exec "cmd ref matchreset" ; uiScript closeingame, voteFlag CV_SVF_MATCHRESET )
	NAMEDBUTTONEXT( bttn_restmap, 6, 68, .5*(WINDOW_WIDTH-18), 14, _("RESTART MAP"), .24, 11, exec "cmd ref maprestart" ; uiScript closeingame, settingEnabled CV_SVF_MAPRESTART voteFlag CV_SVF_MAPRESTART )
	NAMEDBUTTONEXT( bttn_restcampaign, 6, 68, .5*(WINDOW_WIDTH-18), 14, _("RESTART CAMPAIGN"), .24, 11, exec "cmd ref restartcampaign" ; uiScript closeingame, settingEnabled CV_SVF_RESTARTCAMPAIGN voteFlag CV_SVF_RESTARTCAMPAIGN )
	NAMEDBUTTONEXT( bttn_nextmap, 6, 86, .5*(WINDOW_WIDTH-18), 14, _("NEXT MAP"), .24, 11, exec "cmd ref nextmap" ; uiScript closeingame, settingEnabled CV_SVS_NEXTMAP voteFlag CV_SVF_NEXTMAP )
	NAMEDBUTTONEXT( bttn_nextcampaign, 6, 86, .5*(WINDOW_WIDTH-18), 14, _("NEXT CAMPAIGN"), .24, 11, exec "cmd ref nextmap" ; uiScript closeingame, settingEnabled CV_SVS_NEXTMAP voteFlag CV_SVF_NEXTMAP )
	BUTTONEXT( 6, 104, .5*(WINDOW_WIDTH-18), 14, _("ANTI-LAG ON"), .24, 11, exec "cmd ref antilag 1" ; uiScript closeingame, settingDisabled CV_SVS_ANTILAG voteFlag CV_SVF_ANTILAG )
	BUTTONEXT( 6, 104, .5*(WINDOW_WIDTH-18), 14, _("ANTI-LAG OFF"), .24, 11, exec "cmd ref antilag 0" ; uiScript closeingame, settingEnabled CV_SVS_ANTILAG voteFlag CV_SVF_ANTILAG )
	BUTTONEXT( 6, 122, .5*(WINDOW_WIDTH-18), 14, _("SURRENDER"), .24, 11, exec "cmd ref surrender" ; uiScript closeingame, settingEnabled CV_SVF_SURRENDER voteFlag CV_SVF_SURRENDER )

	BUTTONEXT( 6+.5*(WINDOW_WIDTH-18)+6, 32, .5*(WINDOW_WIDTH-18), 14, _("SHUFFLE"), .24, 11, exec "cmd ref shuffleteams" ; uiScript closeingame, voteFlag CV_SVF_SHUFFLETEAMS )
	BUTTONEXT( 6+.5*(WINDOW_WIDTH-18)+6, 50, .5*(WINDOW_WIDTH-18), 14, _("NO RESTART SHUFFLE"), .24, 11, exec "cmd ref shuffleteams_norestart" ; uiScript closeingame, voteFlag CV_SVF_SHUFFLETEAMS_NORESTART )
	BUTTONEXT( 6+.5*(WINDOW_WIDTH-18)+6, 68, .5*(WINDOW_WIDTH-18), 14, _("SWAP TEAMS"), .24, 11, exec "cmd ref swapteams" ; uiScript closeingame, voteFlag CV_SVF_SWAPTEAMS )
	BUTTONEXT( 6+.5*(WINDOW_WIDTH-18)+6, 86, .5*(WINDOW_WIDTH-18), 14, _("MUTE SPECS"), .24, 11, exec "cmd ref mutespecs 1" ; uiScript closeingame, settingDisabled CV_SVS_MUTESPECS voteFlag CV_SVF_MUTESPECS )
	BUTTONEXT( 6+.5*(WINDOW_WIDTH-18)+6, 86, .5*(WINDOW_WIDTH-18), 14, _("UNMUTE SPECS"), .24, 11, exec "cmd ref mutespecs 0" ; uiScript closeingame, settingEnabled CV_SVS_MUTESPECS voteFlag CV_SVF_MUTESPECS )
	BUTTONEXT( 6+.5*(WINDOW_WIDTH-18)+6, 104, .5*(WINDOW_WIDTH-18), 14, _("FRIENDLY FIRE ON"), .24, 11, exec "cmd ref friendlyfire 1" ; uiScript closeingame, settingDisabled CV_SVS_FRIENDLYFIRE voteFlag CV_SVF_FRIENDLYFIRE )
	BUTTONEXT( 6+.5*(WINDOW_WIDTH-18)+6, 104, .5*(WINDOW_WIDTH-18), 14, _("FRIENDLY FIRE OFF"), .24, 11, exec "cmd ref friendlyfire 0" ; uiScript closeingame, settingEnabled CV_SVS_FRIENDLYFIRE voteFlag CV_SVF_FRIENDLYFIRE )
	BUTTONEXT( 6+.5*(WINDOW_WIDTH-18)+6, 122, .5*(WINDOW_WIDTH-18), 14, _("BALANCED TEAMS ON"), .24, 11, exec "cmd ref balancedteams 1" ; uiScript closeingame, settingDisabled CV_SVS_BALANCEDTEAMS voteFlag CV_SVF_BALANCEDTEAMS )
	BUTTONEXT( 6+.5*(WINDOW_WIDTH-18)+6, 122, .5*(WINDOW_WIDTH-18), 14, _("BALANCED TEAMS OFF"), .24, 11, exec "cmd ref balancedteams 0" ; uiScript closeingame, settingEnabled CV_SVS_BALANCEDTEAMS voteFlag CV_SVF_BALANCEDTEAMS )

	BUTTONEXT( 6, 140, WINDOW_WIDTH-12, 14, _("COMPETITION SETTINGS"), .24, 11, exec "cmd ref config defaultcomp" ; uiScript closeingame, voteFlag CV_SVF_CONFIG )
	BUTTONEXT( 6, 158, WINDOW_WIDTH-12, 14, _("PUBLIC SETTINGS"), .24, 11, exec "cmd ref config defaultpublic" ; uiScript closeingame, voteFlag CV_SVF_CONFIG )

	MULTILEFT( 8, 176+2, .66*(WINDOW_WIDTH-18), 10, _("Warmup Damage:"), .2, 8, "ui_voteWarmupDamage", cvarFloatList { "None" 0 "Enemies" 1 "Everyone" 2 } voteFlag CV_SVF_WARMUPDAMAGE, _("Enable or disable warmup damage") )
	NAMEDBUTTONEXT( "bttnextWarmupDamage", 6+.80*(WINDOW_WIDTH-18)+6, 176, .20*(WINDOW_WIDTH-18), 14, _("OK"), .24, 11, uiScript refWarmupDamage ; uiScript closeingame, voteFlag CV_SVF_WARMUPDAMAGE )

	//	itemDef {
//		name		"poll"
//		group		GROUP_NAME
//		rect		$evalfloat(40+8) $evalfloat(194+2) $evalfloat(.80*(WINDOW_WIDTH-18)-40) 10
//		style		WINDOW_STYLE_FILLED
//		backcolor	.5 .5 .5 .2
//		visible		1
//		voteFlag	CV_SVF_POLL
//		decoration
//	}

	itemDef {
		name		"nfleftbackTimelimit:"
		group		GROUP_NAME
		rect		$evalfloat(70+6) $evalfloat(212+2) $evalfloat(.66*(WINDOW_WIDTH-18)-70-8) 10
		style		WINDOW_STYLE_FILLED
		backcolor	.5 .5 .5 .2
		visible		1
		voteFlag	CV_SVF_TIMELIMIT
		decoration
	}
// Do we need it ?
//	NUMERICFIELDLEFTEXT( 8, 194+2, .66*(WINDOW_WIDTH-18), 10, _("Poll:"), .2, 8, 6, "ui_poll", voteFlag CV_SVF_POLL, _("Enter the text for your poll") )
//	NAMEDBUTTONEXT( "bttnextTimelimit", 6+.80*(WINDOW_WIDTH-18)+6, 194, .20*(WINDOW_WIDTH-18), 14, _("OK"), .24, 11, uiScript votePoll; uiScript closeingame, voteFlag CV_SVF_POLL )

	NUMERICFIELDLEFTEXT( 8, 212+2, .66*(WINDOW_WIDTH-18), 10, _("Time Limit:"), .2, 8, "ui_voteTimelimit", 6, voteFlag CV_SVF_TIMELIMIT, _("Set the time limit for the server") )
	NAMEDBUTTONEXT( "bttnextTimelimit", 6+.80*(WINDOW_WIDTH-18)+6, 212, .20*(WINDOW_WIDTH-18), 14, _("OK"), .24, 11, uiScript refTimelimit ; uiScript closeingame, voteFlag CV_SVF_TIMELIMIT )

	MULTILEFT( 8, 230+2, .66*(WINDOW_WIDTH-18), 10, _("Game Type:"), .2, 8, "ui_voteGameType", cvarFloatList { "Single-Map Objective" 2 "Stopwatch" 3 "Last Man Standing" 5 "Map Voting" 6 } voteFlag CV_SVF_GAMETYPE, _("Set the game type") )
	NAMEDBUTTONEXT( "bttnextGameType", 6+.80*(WINDOW_WIDTH-18)+6, 230, .20*(WINDOW_WIDTH-18), 14, _("OK"), .24, 11, uiScript refGame ; uiScript closeingame, voteFlag CV_SVF_GAMETYPE )

	BUTTONEXT( 6, 248, WINDOW_WIDTH-12, 14, _("PAUSE"), .24, 11, exec "cmd ref pause" ; uiScript closeingame, settingDisabled CV_SVS_PAUSE cvarTest "authLevel" showCVar { RL_REFEREE RL_RCON } )
	BUTTONEXT( 6, 248, WINDOW_WIDTH-12, 14, _("UNPAUSE"), .24, 11, exec "cmd ref unpause" ; uiScript closeingame, settingEnabled CV_SVS_PAUSE cvarTest "authLevel" showCVar { RL_REFEREE RL_RCON } )

	BUTTONEXT( 6, 266, .5*(WINDOW_WIDTH-18), 14, _("LOCK TEAMS"), .24, 11, exec "cmd ref lock" ; uiScript closeingame, settingDisabled CV_SVS_LOCKTEAMS cvarTest "authLevel" showCVar { RL_REFEREE RL_RCON } )
	BUTTONEXT( 6, 266, .5*(WINDOW_WIDTH-18), 14, _("UNLOCK TEAMS"), .24, 11, exec "cmd ref unlock" ; uiScript closeingame, settingEnabled CV_SVS_LOCKTEAMS cvarTest "authLevel" showCVar { RL_REFEREE RL_RCON } )

	BUTTONEXT( 6+.5*(WINDOW_WIDTH-18)+6, 266, .5*(WINDOW_WIDTH-18), 14, _("LOCK SPECS"), .24, 11, exec "cmd ref speclock" ; uiScript closeingame, settingDisabled CV_SVS_LOCKSPECS cvarTest "authLevel" showCVar { RL_REFEREE RL_RCON } )
	BUTTONEXT( 6+.5*(WINDOW_WIDTH-18)+6, 266, .5*(WINDOW_WIDTH-18), 14, _("UNLOCK SPECS"), .24, 11, exec "cmd ref specunlock" ; uiScript closeingame, settingEnabled CV_SVS_LOCKSPECS cvarTest "authLevel" showCVar { RL_REFEREE RL_RCON } )

	BUTTON( 6, WINDOW_HEIGHT-24, WINDOW_WIDTH-12, 18, _("BACK"), .3, 14, close ingame_vote_misc_refrcon ; open ingame_vote )
}
