@echo off

CALL C:\LiveDigital\config.bat

SET /a var_yoffset=0

IF "%var_resorientation%"=="PORTRAIT" (
	SET var_wsize=%var_resheight%
	SET var_hsize=%var_reswidth%
) ELSE (
	SET var_wsize=%var_reswidth%
	SET var_hsize=%var_resheight%
)

SET var_halfwidth=%var_wsize%/2
CD C:\LiveDigital\

setlocal enabledelayedexpansion

SET var_playerid=1
SET /A var_xoffset=!var_wsize!*0
SET /A var_mousex=!var_xoffset!+!var_halfwidth!
nircmd win setsize process "firefox.exe" !var_xoffset! !var_yoffset! !var_wsize! !var_hsize! 

echo Moving Player !var_playerid! to !var_xoffset!, !var_yoffset! and resizing to !var_wsize!x!var_hsize!
echo Moving mouse to !var_mousex!, 0
nircmd setcursor !var_mousex! 0


IF %var_noscreens% GTR 1 (
	SET var_playerid=2
	SET /A var_xoffset=!var_wsize!*1
	SET /A var_mousex=!var_xoffset!+!var_halfwidth!	
	nircmd win setsize process "firefox2.exe" !var_xoffset! !var_yoffset! !var_wsize! !var_hsize!

	echo Moving Player !var_playerid! to !var_xoffset!, !var_yoffset! and resizing to !var_wsize!x!var_hsize!
	echo Moving mouse to !var_mousex!, 0
	nircmd setcursor !var_mousex! 0
)

IF %var_noscreens% GTR 2 (
	SET var_playerid=3
	SET /A var_xoffset=!var_wsize!*2
	SET /A var_mousex=!var_xoffset!+!var_halfwidth!	
	nircmd win setsize process "firefox3.exe" !var_xoffset! !var_yoffset! !var_wsize! !var_hsize!

	echo Moving Player !var_playerid! to !var_xoffset!, !var_yoffset! and resizing to !var_wsize!x!var_hsize!
	echo Moving mouse to !var_mousex!, 0
	nircmd setcursor !var_mousex! 0
)

IF %var_noscreens% GTR 3 (
	SET var_playerid=4
	SET /A var_xoffset=!var_wsize!*3
	SET /A var_mousex=!var_xoffset!+!var_halfwidth!	
	nircmd win setsize process "firefox4.exe" !var_xoffset! !var_yoffset! !var_wsize! !var_hsize!

	echo Moving Player !var_playerid! to !var_xoffset!, !var_yoffset! and resizing to !var_wsize!x!var_hsize!
	echo Moving mouse to !var_mousex!, 0
	nircmd setcursor !var_mousex! 0
)

C:\LiveDigital\nircmd.exe setcursor 100 100

PAUSE

EXIT