@ECHO OFF

CALL C:\LiveDigital\config.bat

SET var_displayscreen0=1
SET var_displayscreen1=2
SET var_displayscreen2=3
SET var_displayscreen3=4
SET var_displayscreen4=5
SET var_displayscreen5=6

SET /A var_xoffset=0

C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen0%" -rotate=up
C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen0%" -width=%var_reswidth% -height=%var_resheight% -depth=max -primary

IF "%var_resorientation%"=="LANDSCAPE" (
	SET /A var_xoffset=%var_reswidth%*0
	SET var_swidth=%var_reswidth%
	SET var_sheight=%var_resheight%
) ELSE (
	SET /A var_xoffset=%var_resheight%*0
	SET var_swidth=%var_resheight%
	SET var_sheight=%var_reswidth%
)

C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen0%" -rotate=%var_resrotation% -lx=%var_xoffset% -ty=0
@ECHO Making screen%var_displayscreen0%[0] primary at %var_xoffset%,0 sized to %var_swidth%x%var_sheight%, rotation %var_resrotation%

IF %var_noscreens% GTR 1 (
	C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen1%" -rotate=up
	C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen1%" -width=%var_reswidth% -height=%var_resheight% -depth=max -secondary
	
	setlocal enabledelayedexpansion
	IF "%var_resorientation%"=="LANDSCAPE" (
		SET /A var_xoffset=%var_reswidth%*1
	) ELSE (
		SET /A var_xoffset=%var_resheight%*1
	)
	
	C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen1%" -rotate=%var_resrotation% -lx=!var_xoffset! -ty=0
	@ECHO Making screen%var_displayscreen1%[1] secondary at !var_xoffset!,0 sized to %var_swidth%x%var_sheight%, rotation %var_resrotation%
	setlocal disabledelayedexpansion
)

IF %var_noscreens% GTR 2 (
	C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen2%" -rotate=up
	C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen2%" -width=%var_reswidth% -height=%var_resheight% -depth=max -secondary
	
	setlocal enabledelayedexpansion
	IF "%var_resorientation%"=="LANDSCAPE" (
		SET /A var_xoffset=%var_reswidth%*2
	) ELSE (
		SET /A var_xoffset=%var_resheight%*2	
	)
	C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen2%" -rotate=%var_resrotation% -lx=!var_xoffset! -ty=0
	@ECHO Making screen%var_displayscreen2%[2] secondary at !var_xoffset!,0 sized to %var_swidth%x%var_sheight%, rotation %var_resrotation%
	setlocal disabledelayedexpansion
)

IF %var_noscreens% GTR 3 (
	C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen3%" -rotate=up
	C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen3%" -width=%var_reswidth% -height=%var_resheight% -depth=max -secondary
	
	setlocal enabledelayedexpansion
	IF "%var_resorientation%"=="LANDSCAPE" (
		SET /A var_xoffset=%var_reswidth%*3
	) ELSE (
		SET /A var_xoffset=%var_resheight%*3	
	)
	C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen3%" -rotate=%var_resrotation% -lx=!var_xoffset! -ty=0
	@ECHO Making screen%var_displayscreen3%[3] secondary at !var_xoffset!,0 sized to %var_swidth%x%var_sheight%, rotation %var_resrotation%
	setlocal disabledelayedexpansion
)

IF %var_noscreens% GTR 4 (
	C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen4%" -rotate=up
	C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen4%" -width=%var_reswidth% -height=%var_resheight% -depth=max -secondary
	
	setlocal enabledelayedexpansion
	IF "%var_resorientation%"=="LANDSCAPE" (
		SET /A var_xoffset=%var_reswidth%*4
	) ELSE (
		SET /A var_xoffset=%var_resheight%*4	
	)
	C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen4%" -rotate=%var_resrotation% -lx=!var_xoffset! -ty=0
	@ECHO Making screen%var_displayscreen4%[4] secondary at !var_xoffset!,0 sized to %var_swidth%x%var_sheight%, rotation %var_resrotation%
	setlocal disabledelayedexpansion
)

IF %var_noscreens% GTR 5 (
	C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen5%" -rotate=up
	C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen5%" -width=%var_reswidth% -height=%var_resheight% -depth=max -secondary
	
	setlocal enabledelayedexpansion
	IF "%var_resorientation%"=="LANDSCAPE" (
		SET /A var_xoffset=%var_reswidth%*5
	) ELSE (
		SET /A var_xoffset=%var_resheight%*5	
	)
	C:\LiveDigital\dccmd.exe -monitor="\\.\DISPLAY%var_displayscreen5%" -rotate=%var_resrotation% -lx=!var_xoffset! -ty=0
	@ECHO Making screen%var_displayscreen5%[5] secondary at !var_xoffset!,0 sized to %var_swidth%x%var_sheight%, rotation %var_resrotation%
	setlocal disabledelayedexpansion
)

TIMEOUT 30

EXIT