#include "ui/menudef.h"
#include "ui_mp/main.inc"
#include "ui_mp/pc_options.inc"

#define MENU_NAME									"pc_options_advanced_video"
#define MENU_TITLE									"@MENU_ADVANCED_VIDEO"

#undef CHOICE_GROUP
#define CHOICE_GROUP								MENU_NAME

#define CLOSE_MENUS \
	close "controls_multi"; \
	close "main_controls"; \
	close "main_options"; \
	close "options_control_defaults"; \
	close "options_graphics"; \
	close "options_graphics_defaults"; \
	close "options_graphics_texture"; \
	close "options_multi"; \
	close "options_voice"; \
	close "pc_options_actions"; \
	close "pc_options_audio"; \
	close "pc_options_controls"; \
	close "pc_options_game"; \
	close "pc_options_look"; \
	close "pc_options_movement"; \
	close "pc_options_multi"; \
	close "pc_options_video"; \
	close "pc_options_voice";

#define ON_MENU_OPEN \
	CLOSE_MENUS										\
	execnow											"profile_menuDvarsSetup; resetViewport"; \
	setLocalVarBool									"ui_hideBack" (1);

#define ON_MENU_CLOSE \
	execnow											"profile_menuDvarsFinish; resetViewport"; \
	setLocalVarBool									"ui_hideBack" (0); \
	execOnDvarIntValue								"r_lodScaleRigid" 2 "set r_lodScaleSkinned 4; set r_lodBiasSkinned -200; set r_lodBiasRigid -100"; \
	execOnDvarIntValue								"r_lodScaleRigid" 1 "set r_lodScaleSkinned 1; set r_lodBiasSkinned 0; set r_lodBiasRigid 0"; \
	open											"pc_options_video";

#define ON_MENU_ESC \
	close											self;

menuDef
{
	name											MENU_NAME
	rect											0 0 640 480
	foreColor										CHOICE_TEXTCOLOR
	focusColor										CHOICE_TEXTCOLOR
	blurWorld										7

	MENU_ON_OPEN(ON_MENU_OPEN)
	MENU_ON_CLOSE(ON_MENU_CLOSE)
	MENU_ON_ESC(ON_MENU_ESC)

	#define BACKGROUND_PC_OPTIONS
	#define BACKGROUND_IW4
	#define DISABLE_SIDEBAR
	#define BACKGROUND_FULL
	#include "ui_mp/bg.inc"

	PC_OPTIONS_SECTION_TITLE(MENU_TITLE)

	PC_OPTIONS_FLOATLIST_RAW(0, "@MENU_ASPECT_RATIO", "ui_r_aspectratio", {"@MENU_AUTO" 0 "@MENU_STANDARD_4_3" 1 "@MENU_WIDE_16_10" 2 "@MENU_WIDE_16_9" 3}, setDvarInt r_aspectratio dvarInt("ui_r_aspectratio"); setLocalVarBool "ui_showApply" (1);, "@NULL_EMPTY", when((dvarBool("cl_ingame") || dvarBool("sv_running") || inlobby())), 1)
	PC_OPTIONS_FLOATLIST_RAW(1, "@MENU_ANTIALIASING", "ui_r_aasamples", {"@MENU_OFF" 1 "@MENU_2X" 2 "@MENU_4X" 4}, setLocalVarBool "ui_showApply" (1);, "@NULL_EMPTY", when((dvarBool("cl_ingame") || dvarBool("sv_running") || inlobby())), 1)
	PC_OPTIONS_DVARENUMLIST(2, "@MENU_SCREEN_REFRESH_RATE", "ui_r_displayRefresh", "r_displayRefresh", ACTION_SHOW_APPLY, when((dvarBool("cl_ingame") || dvarBool("sv_running") || inlobby())))
	PC_OPTIONS_DVARYESNO_RAW(3, "@MENU_SYNC_EVERY_FRAME", "ui_r_vsync", ACTION_SHOW_APPLY, "@NULL_EMPTY", when((dvarBool("cl_ingame") || dvarBool("sv_running") || inlobby())), 1)

	PC_OPTIONS_SEPERATOR(3)

	PC_OPTIONS_DVARYESNO(4, "@MENU_SHADOWS", "sm_enable", ;, when(0))
	PC_OPTIONS_DVARYESNO(5, "@MENU_SPECULAR_MAP", "r_specular", ;, when(0))
	PC_OPTIONS_DVARYESNO(6, "@MENU_DOF", "r_dof_enable", ;, when(0))

	PC_OPTIONS_SEPERATOR(6)

	PC_OPTIONS_DVARYESNO(7, "@MENU_ZFEATHER_SMOKE", "r_zfeather", ;, when(0))
	PC_OPTIONS_DVARYESNO(8, "@MENU_RAGDOLL", "ragdoll_enable", ;, when(0))
	PC_OPTIONS_DVARYESNO(9, "@MENU_BULLET_IMPACTS", "fx_marks", ;, when(0))

	PC_OPTIONS_SEPERATOR(9)

	PC_OPTIONS_FLOATLIST_RAW(10, "@MENU_TEXTURE_QUALITY", "ui_r_picmip_manual", {"@MENU_AUTOMATIC" 0 "@MENU_MANUAL" 1}, setLocalVarBool "ui_showApply" (1);, "@NULL_EMPTY", when((dvarBool("cl_ingame") || dvarBool("sv_running") || inlobby())), 1)
	PC_OPTIONS_FLOATLIST_RAW(11, "@MENU_TEXTURE_RESOLUTION", "ui_r_picmip", {"@MENU_LOW" 3 "@MENU_NORMAL" 2 "@MENU_HIGH" 1 "@MENU_EXTRA" 0}, setLocalVarBool "ui_showApply" (1);, "@NULL_EMPTY", when((dvarBool("cl_ingame") || dvarBool("sv_running") || inlobby())), when(dvarBool("ui_r_picmip_manual")))
	PC_OPTIONS_FLOATLIST_RAW(12, "@MENU_NORMAL_MAP_RESOLUTION", "ui_r_picmip_bump", {"@MENU_LOW" 3 "@MENU_NORMAL" 2 "@MENU_HIGH" 1 "@MENU_EXTRA" 0}, setLocalVarBool "ui_showApply" (1);, "@NULL_EMPTY", when((dvarBool("cl_ingame") || dvarBool("sv_running") || inlobby())), when(dvarBool("ui_r_picmip_manual")))
	PC_OPTIONS_FLOATLIST_RAW(13, "@MENU_SPECULAR_MAP_RESOLUTION", "ui_r_picmip_spec", {"@MENU_LOW" 3 "@MENU_NORMAL" 2 "@MENU_HIGH" 1 "@MENU_EXTRA" 0}, setLocalVarBool "ui_showApply" (1);, "@NULL_EMPTY", when((dvarBool("cl_ingame") || dvarBool("sv_running") || inlobby())), when(dvarBool("ui_r_picmip_manual")))

	ITEM_BUTTON_BACK(ON_MENU_ESC)
}
