#include "ui/menudef.h"

// Defines //

#define WINDOW_X		16
#define WINDOW_Y		16
//#define WINDOW_WIDTH	128
#define WINDOW_WIDTH	296
#define WINDOW_HEIGHT	276
#define GROUP_NAME		"grpIngameVoteMiscRefRcon"

// Macros //

#include "ui/menumacros.h"

// 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 {
		//copyCvar g_gametype ui_netgametype ;
		
		conditionalScript g_gametype 3	// 3: cvartest
			( "hide bttn_nextmap ; show bttn_nextcampaign" )
			( "show bttn_nextmap ; hide bttn_nextcampaign" ) "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 )
	BUTTON( 6, 68, .5*(WINDOW_WIDTH-18), 14, "RESTART MAP", .24, 11, exec "cmd ref maprestart"; uiScript closeingame )
	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+.5*(WINDOW_WIDTH-18)+6, 32, .5*(WINDOW_WIDTH-18), 14, "XP SHUFFLE", .24, 11, exec "cmd ref shuffleteamsxp"; uiScript closeingame, voteFlag CV_SVF_SHUFFLETEAMS )
	BUTTONEXT( 6+.5*(WINDOW_WIDTH-18)+6, 50, .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, 68, .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, 68, .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, 86, .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, 86, .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, 104, .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, 104, .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, 122, WINDOW_WIDTH-12, 14, "TJMOD COMPETITION", .24, 11, exec "cmd ref comp"; uiScript closeingame, voteFlag CV_SVF_COMP )
	BUTTONEXT( 6, 140, WINDOW_WIDTH-12, 14, "TJMOD PUBLIC", .24, 11, exec "cmd ref pub"; uiScript closeingame, voteFlag CV_SVF_PUB )
	
	MULTILEFT( 8, 158+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, 158, .20*(WINDOW_WIDTH-18), 14, "OK", .24, 11, uiScript refWarmupDamage; uiScript closeingame, voteFlag CV_SVF_WARMUPDAMAGE )
	
	itemDef {
		name		"nfleftbackTimelimit:"
		group		GROUP_NAME
		rect		$evalfloat(70+6) $evalfloat(176+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
	}
	NUMERICFIELDLEFTEXT( 8, 176+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, 176, .20*(WINDOW_WIDTH-18), 14, "OK", .24, 11, uiScript refTimelimit; uiScript closeingame, voteFlag CV_SVF_TIMELIMIT )

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

	BUTTONEXT( 6, 212, 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, 212, 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, 230, .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, 230, .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, 230, .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, 230, .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 )
}
