//--- OBJECT WRITE BEGIN ---
new GuiControl(IHVTest) {
	profile = "GuiContentProfile";
	horizSizing = "right";
	vertSizing = "bottom";
	position = "0 0";
	extent = "640 480";
	minExtent = "8 8";
	visible = "1";
	setFirstResponder = "0";
	modal = "1";
	helpTag = "0";

	new GuiScrollCtrl() {
		profile = "GuiScrollCtrlProfile";
		horizSizing = "right";
		vertSizing = "bottom";
		position = "34 52";
		extent = "209 318";
		minExtent = "8 8";
		visible = "1";
		setFirstResponder = "1";
		modal = "1";
		helpTag = "0";
		willFirstRespond = "1";
		hScrollBar = "alwaysOff";
		vScrollBar = "alwaysOn";
		constantThumbHeight = "1";

		new GuiScrollContentCtrl() {
			profile = "GuiDefaultProfile";
			horizSizing = "right";
			vertSizing = "bottom";
			position = "1 1";
			extent = "189 316";
			minExtent = "8 8";
			visible = "1";
			setFirstResponder = "0";
			modal = "1";
			helpTag = "0";

			new GuiTextListCtrl(RecordingsList) {
				profile = "GuiTextArrayProfile";
				horizSizing = "right";
				vertSizing = "bottom";
				position = "0 0";
				extent = "52 80";
				minExtent = "8 8";
				visible = "1";
				setFirstResponder = "1";
				modal = "1";
				helpTag = "0";
				enumerate = "1";
				resizeCell = "1";
				columns = "0";
			};
		};
	};
	new GuiButtonCtrl() {
		profile = "GuiButtonProfile";
		horizSizing = "right";
		vertSizing = "bottom";
		position = "34 379";
		extent = "100 20";
		minExtent = "8 8";
		visible = "1";
		setFirstResponder = "1";
		modal = "1";
		command = "quit();";
		helpTag = "0";
		text = "Exit";
	};
	new GuiButtonCtrl() {
		profile = "GuiButtonProfile";
		horizSizing = "right";
		vertSizing = "bottom";
		position = "143 379";
		extent = "100 20";
		minExtent = "8 8";
		visible = "1";
		setFirstResponder = "1";
		modal = "1";
		command = "IHVStartSelectedDemo();";
		helpTag = "0";
		text = "Start Demo";
	};
	new GuiTextCtrl() {
		profile = "GuiBigTextProfile";
		horizSizing = "right";
		vertSizing = "bottom";
		position = "5 5";
		extent = "268 40";
		minExtent = "8 8";
		visible = "1";
		setFirstResponder = "1";
		modal = "1";
		helpTag = "0";
		text = "IHV Test Recordings";
	};
	new GuiCheckBoxCtrl(ArbMultitexture) {
		profile = "GuiButtonProfile";
		horizSizing = "right";
		vertSizing = "bottom";
		position = "290 52";
		extent = "235 24";
		minExtent = "8 8";
		visible = "1";
		setFirstResponder = "0";
		modal = "1";
		variable = "$pref::OpenGL::disableARBMultitexture";
		helpTag = "0";
		text = "Disable ARB_multitexture";
	};
	new GuiCheckBoxCtrl(FogCoord) {
		profile = "GuiButtonProfile";
		horizSizing = "right";
		vertSizing = "bottom";
		position = "290 80";
		extent = "235 24";
		minExtent = "8 8";
		visible = "1";
		setFirstResponder = "0";
		modal = "1";
		variable = "$pref::OpenGL::disableEXTFogCoord";
		helpTag = "0";
		text = "Disable EXT_fog_coord";
	};
	new GuiCheckBoxCtrl(TexEnvCombine) {
		profile = "GuiButtonProfile";
		horizSizing = "right";
		vertSizing = "bottom";
		position = "290 108";
		extent = "235 24";
		minExtent = "8 8";
		visible = "1";
		setFirstResponder = "0";
		modal = "1";
		variable = "$pref::OpenGL::disableEXTTexEnvCombine";
		helpTag = "0";
		text = "Disable EXT_texture_env_combine";
	};
	new GuiButtonCtrl() {
		profile = "GuiButtonProfile";
		horizSizing = "right";
		vertSizing = "bottom";
		position = "290 211";
		extent = "235 24";
		minExtent = "8 8";
		visible = "1";
		setFirstResponder = "0";
		modal = "1";
		command = "toggleFullscreen();";
		helpTag = "0";
		text = "Toggle Fullscreen";
	};
	new GuiCheckBoxCtrl(CVArray) {
		profile = "GuiButtonProfile";
		horizSizing = "right";
		vertSizing = "bottom";
		position = "290 136";
		extent = "235 24";
		minExtent = "8 8";
		visible = "1";
		setFirstResponder = "0";
		modal = "1";
		variable = "$pref::OpenGL::disableEXTCompiledVertexArray";
		helpTag = "0";
		text = "Disable EXT_compiled_vertex_array";
	};
	new GuiCheckBoxCtrl(timedemo) {
		profile = "GuiButtonProfile";
		horizSizing = "right";
		vertSizing = "bottom";
		position = "290 239";
		extent = "235 24";
		minExtent = "8 8";
		visible = "1";
		setFirstResponder = "0";
		modal = "1";
		helpTag = "0";
		text = "Timedemo style playback";
	};
	new GuiTextCtrl(DemoStats) {
		profile = "GuiButtonProfile";
		horizSizing = "right";
		vertSizing = "bottom";
		position = "245 286";
		extent = "325 24";
		minExtent = "8 8";
		visible = "1";
		setFirstResponder = "0";
		modal = "1";
		helpTag = "0";
		text = "Last Demo: None";
	};
};
//--- OBJECT WRITE END ---

function IHVTest::onWake(%gui)
{
   RecordingsList.clear();
   %search = "recordings/*.rec";
   %ct = 0;
   for(%file = findFirstFile(%search); %file !$= ""; %file = findNextFile(%search))
   {
      %fileName = fileBase(%file);
      RecordingsList.addRow(%ct++, %fileName);
   }
   RecordingsList.sort(0);
}

function IHVStartSelectedDemo()
{
   %sel = RecordingsList.getSelectedId();
   %file = RecordingsList.getRowTextById(%sel);
   Canvas.setContent(PlayGui);
   $TSControl::FrameCount = 0;
   
   playDemo("recordings/" @ %file @ ".rec");
}

function TexEnvCombine::onAction()
{
   $pref::OpenGL::disableEXTTexEnvCombine = !$pref::OpenGL::disableEXTTexEnvCombine;
}

function FogCoord::onAction()
{
   $pref::OpenGL::disableEXTFogCoord = !$pref::OpenGL::disableEXTFogCoord;
}

function CVArray::onAction()
{
   $pref::OpenGL::disableEXTCompiledVertexArray = !$pref::OpenGL::disableEXTCompiledVertexArray;
}

function ARBMultitexture::onAction()
{
   $pref::OpenGL::disableARBMultitexture = !$pref::OpenGL::disableARBMultitexture;
}

function timedemo::onAction()
{
   echo("here");

   if ($timeAdvance == 0) {
      $timeAdvance = 30;
   } else {
      $timeAdvance = 0;
   }
}

function resetDemoStats()
{
   %mspf = $Demo::playbackTime / $TSControl::frameCount;
   %fps  = 1000 / %mspf;

   DemoStats.setValue("Last Demo: " @ $TSControl::frameCount @ " frames, " @ %fps @ " fps (" @ %mspf @ " mspf)");
}
