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

// Defines //
#define WINDOW_X		16
#define WINDOW_Y		16
#define WINDOW_WIDTH	160
#ifdef OLD_CLIENT
#define WINDOW_HEIGHT	248
#else
#define WINDOW_HEIGHT	224
#endif
#define GROUP_NAME		"grpIngameMain"

// Main Menu //
menuDef {
	name		"ingame_main"
	visible		0
	fullscreen	0
	rect		WINDOW_X WINDOW_Y WINDOW_WIDTH WINDOW_HEIGHT
	style		WINDOW_STYLE_FILLED

	onOpen {
		conditionalscript ROldModeCheck 2
			( "clearFocus ; open vid_confirm" )
			( "clearFocus" )
	}

	onEsc {
		close ingame_main ;
	}

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

// Buttons //
// FIXME: tooltips with BUTTONEXT don't work when conditionalScript or cvartest is used?! ...
	BUTTONEXT( 6, 32, WINDOW_WIDTH-12, 18, _("MSGID_MENU_INGAME_LIMBO_MENU"), .3, 14, exec "openlimbomenu" ; close ingame_main, tooltip _("Select your team, class, weapon and spawnpoint") )
	BUTTONEXT( 6, 56, WINDOW_WIDTH-12, 18, _("MSGID_MENU_INGAME_VOTE"), .3, 14, uiScript clientCheckVote ;
		conditionalScript cg_ui_novote 0
		( "clearFocus ; open ingame_votedisabled" )
		( "close ingame_main ; open ingame_vote" ),
		cvarTest "authLevel" showCVar { RL_NONE } )
	BUTTONEXT( 6, 56, WINDOW_WIDTH-12, 18, _("MSGID_MENU_INGAME_REFEREE"), .3, 14, close ingame_main ; open ingame_vote, cvarTest "authLevel" showCVar { RL_REFEREE } )
	BUTTONEXT( 6, 56, WINDOW_WIDTH-12, 18, _("MSGID_MENU_INGAME_RCON"), .3, 14, close ingame_main ; open ingame_vote, cvarTest "authLevel" showCVar { RL_RCON } )
	BUTTONEXT( 6, 80, WINDOW_WIDTH-12, 18, _("MSGID_MENU_INGAME_SERVER_INFO"), .3, 14, clearFocus ; open ingame_serverinfo, tooltip _("Print all server info") )
	BUTTONEXT( 6, 104, WINDOW_WIDTH-12, 18, _("MSGID_MENU_INGAME_OPTIONS"), .3, 14, close ingame_main ; open options, tooltip _("Set available game options") )
	BUTTONEXT( 6, 128, WINDOW_WIDTH-12, 18, _("MSGID_MENU_INGAME_FAVORITE"), .3, 14, uiScript clientCheckFavorite ;
		conditionalScript cg_ui_favorite 0
		( "open popupRemoveFavorite" )
        ( "open popupAddFavorite" ), tooltip _("Set or unset this server as favorite") )
	BUTTONEXT( 6, 152, WINDOW_WIDTH-12, 18, _("MSGID_MENU_INGAME_CHANGELOG"), .3, 14, setcvar ui_changelog_ingame 1 ; close ingame_main ; open changelog_popup, tooltip _("Browse changelog files") )
	BUTTONEXT( 6, 176, WINDOW_WIDTH-12, 18, _("MSGID_MENU_INGAME_DISCONNECT"), .3, 14, clearFocus ; open ingame_disconnect, tooltip _("Disconnect your connection from current server") )
	BUTTONEXT( 6, 200, WINDOW_WIDTH-12, 18, _("MSGID_MENU_INGAME_EXIT"), .3, 14, clearFocus ; open quit, tooltip _("Don't press this. Be warned!") )
#ifdef OLD_CLIENT
	BUTTONEXT( 6, 224, WINDOW_WIDTH-12, 18, _("^1UPGRADE NOW"), .3, 14, clearFocus ; uiScript validate_openURL "https://www.etlegacy.com", tooltip _("Upgrade!") )
#endif

// Vanilla client warning //
#ifdef OLD_CLIENT
#define SECURITY_WIDTH	200
	SUBWINDOW( __WINDOW_WIDTH/2-100-16, 240, SECURITY_WIDTH, 85, _("^1SECURITY INFORMATION") )
	LABELWHITE( __WINDOW_WIDTH/2-100-16, 256, SECURITY_WIDTH, 9, _("You are running old software"), .2, ITEM_ALIGN_CENTER, .5*SECURITY_WIDTH, 8 )
	// Yeah we have a Legacy client, but its old.
	#ifdef ETLEGACY
		LABELWHITE( __WINDOW_WIDTH/2-100-16, 270, SECURITY_WIDTH, 9, _("We do recommend to\nupgrade your Legacy client\nClick on ^1UPGRADE NOW\n^7in menu entry"), .2, ITEM_ALIGN_CENTER, .5*SECURITY_WIDTH, 8 )
	#else
		LABELWHITE( __WINDOW_WIDTH/2-100-16, 270, SECURITY_WIDTH, 9, _("We do recommend to\nupgrade your ET client\nClick on ^1UPGRADE NOW\n^7in menu entry"), .2, ITEM_ALIGN_CENTER, .5*SECURITY_WIDTH, 8 )
	#endif
#endif


#ifdef OLD_CLIENT
	itemDef {
		name        "legacy_logo"
		rect        15 WINDOW_HEIGHT 128 64
		style       WINDOW_STYLE_SHADER
		background  "ui/assets/etl_logo"
		forecolor   1 1 1 1
		visible     1
		decoration
	}

	LABEL( 60, 274, 132, 10, "^1"ETLEGACY_VERSION, .2, ITEM_ALIGN_LEFT, 0, 8 )
#else
	itemDef {
		name        "legacy_logo"
		rect        15 WINDOW_HEIGHT 128 64
		style       WINDOW_STYLE_SHADER
		background  "ui/assets/etl_logo"
		forecolor   1 1 1 1
		visible     1
		decoration
	}

	LABEL( 60, WINDOW_HEIGHT+68, 132, 10, "^1"ETLEGACY_VERSION, .2, ITEM_ALIGN_LEFT, 0, 8 )
#endif

#ifdef NON_RELEASE_BUILD
itemDef {
	name "development_build_banner"
	rect 60 $evalfloat(WINDOW_HEIGHT+55) 110 13
	text _("DEVELOPMENT BUILD")
	textfont UI_FONT_ARIBLK_16
	textscale   .19
	textalignx  3
	textaligny  10
	style WINDOW_STYLE_FILLED
	backcolor   1.00 0.34 0.00 .5
	forecolor   0.90 0.90 0.90 1
	visible     1
	decoration
}
#endif
}
