// Get aspect ratio
__EXEC(AR_CENTER=0; AR_modifX=0; AR_modifY=0; AR_modifX_2NDMON=0; version=0);
temp1 = __EVAL(if (localize "STR_USRACT_CHEAT_1" == "FWATCH") then {version = call loadFile ":info version"});
temp2 = __EVAL(if (version>=1.15) then {call preProcessFile "..\fwatch\data\getAspectRatio.sqf"});






// Define voice samples
class CfgSounds
{
	sounds[] = { };
	
	#define MakeSound(NAME,COMMENT,FILE) \
	class NAME \
	{ \
		name = COMMENT; \
		sound[] = {FILE, db+0, 1.0}; \
		titles[] = {}; \
	};
	
	MakeSound(YesSir, "DUNE2: Yes Sir!", "YesSir.wav");
	MakeSound(Acknowledged, "DUNE2: Acknowledged!", "Acknowledged.wav");
	MakeSound(CComplete, "DUNE2: Construction Complete", "construction_complete.wav");
	MakeSound(built, "DUNE2: Built", "built.wav");
	MakeSound(unitready, "CC: Unit Ready", "Unit_Ready.wav");
	MakeSound(building, "CC: Building", "building.wav");
	MakeSound(newconstruction, "CC: New Construction Options", "newconstruction.wav");
	MakeSound(onhold, "CC: On Hold", "on_hold.wav");
	MakeSound(unablecomply, "CC: Unable to comply", "unable_comply.wav");
	MakeSound(engage, "DUNE2: Engage beep", "engage.wav");
	MakeSound(scream, "DUNE2: Unit death scream", "scream.wav");
	MakeSound(cannot_build, "DUNE2: Cannot Build", "cannot_build.wav");
	MakeSound(enemy_destroyed, "DUNE2: Enemy unit destroyed", "enemy_destroyed.wav");
	MakeSound(enemy_approaching, "DUNE2: Enemy unit approaching", "enemy_approaching.wav");
	MakeSound(BaseUnderAttack, "CC: Our base is under attack", "base_under.wav");

};









// Color macros
#define black		0, 0, 0
#define white		1, 1, 1
#define white2		0.8, 0.8, 0.8
#define red			1, 0, 0
#define red2		0.8, 0, 0
#define gray		0.4, 0.4, 0.4
#define darkblue	0, 0.423, 0.662
#define green 		0.3, 0.8, 0.4
#define muddy 		0.203, 0.203, 0.203



// Base classes
class spigTXT
{
	idc = -1
	type = 0
	style = 0
	text = ;
	colorBackground[] = {black, 1};
	colorText[] = {white2, 1};
	font = "tahomaB48";
	sizeEx = 0.02
	lineSpacing = 1
};

class spigBUT : spigTXT
{
	type = 1
	style = 2
	colorText[] = {black, 1};
	font = "courierNewB64";
	soundPush[] = {"ui\ui_ok", 0.2, 1};
	soundClick[] = {"ui\ui_ok", 0.2, 1};
	soundEscape[] = {"ui\ui_cc", 0.2, 1};
	default = false;
};

class spigActive : spigTXT
{
	type = 11
	soundEnter[] = {"", 0.2, 1};
	soundPush[] = {, 0.2, 1};
	soundClick[] = {"", 0.2, 1};
	soundEscape[] = {"", 0.2, 1};
	color[] = {white, 0};
	colorActive[] = {red, 0};
};



// RTS interface
class MainDialog
{
	idd = 1;
	movingEnable = true;
	
	controls[] = 
	{	
		blackframe,
		timetab, timetabtext, timetablink,
		hour, minute,
		credittab, credittabtext, credittablink,
		sidebartab, sidebartabtext, sidebartablink,
		
		insignia_back,insignia,
		mid_bar,
		Repair1,Repair2,Repair3,
		Sell1,Sell2,Sell3,
		Map1,Map2,Map3,
		sidebar1,sidebar2,
		
		Slot1,Slot1a,Slot1b,Slot1c,Slot1d,Slot1e,Slot1f,
		Slot2,Slot2a,Slot2b,Slot2c,Slot2d,Slot2e,Slot2f,
		Slot3,Slot3a,Slot3b,Slot3c,Slot3d,Slot3e,Slot3f,
		Slot4,Slot4a,Slot4b,Slot4c,Slot4d,Slot4e,Slot4f,
		Slot5,Slot5a,Slot5b,Slot5c,Slot5d,Slot5e,Slot5f,
		Slot6,Slot6a,Slot6b,Slot6c,Slot6d,Slot6e,Slot6f,
		Slot7,Slot7a,Slot7b,Slot7c,Slot7d,Slot7e,Slot7f,
		Slot8,Slot8a,Slot8b,Slot8c,Slot8d,Slot8e,Slot8f,
		
		scroll_buttons,scroll_buttons2,
		black_line_fix,
		description_box,description_box_frame,
		highlight_title
	};

	
	
	
	
	


//***********************************************

	// Black area on top

__EXEC(upperBlackFrameX = 0 - AR_modifX);
__EXEC(upperBlackFrameY = 0 - AR_modifY);
__EXEC(upperBlackFrameW = 1 + AR_modifX * 2);
__EXEC(upperBlackFrameH = 0.035);

	class blackframe : spigTXT
	{
		x = __EVAL(upperBlackFrameX);
		y = __EVAL(upperBlackFrameY);
		w = __EVAL(upperBlackFrameW);
		h = __EVAL(upperBlackFrameH);
	};

//***********************************************









//***********************************************	

	// Tab-Button element on black frame

__EXEC(borderRight   = 1 + AR_modifX);
__EXEC(borderDown    = 1 + AR_modifY);
__EXEC(upperTabWidth = 0.25);

#define upperTab(NAME,POSX,NAME2,IDC,NAME3) \
	class NAME : spigTXT \
	{ \
		style = 48; \
		idc = IDC; \
		x = __EVAL(POSX); \
		y = __EVAL(upperBlackFrameY); \
		w = __EVAL(upperTabWidth); \
		h = __EVAL(upperBlackFrameH); \
		text = "img/tab.paa"; \
	}; \
	class NAME2 : NAME \
	{ \
		style = 2; \
		idc = IDC + 1; \
		sizeEx = __EVAL(upperBlackFrameH - 0.005); \
		colorBackground[] = {black, 0}; \
		colorText[] = {0,1,0,1}; \
		font = "courierNewB64"; \
	}; \
	class NAME3 : spigActive \
	{ \
		idc = IDC + 2; \
		x = __EVAL(POSX); \
		y = __EVAL(upperBlackFrameY); \
		w = __EVAL(upperTabWidth); \
		h = __EVAL(upperBlackFrameH); \
		action = ""; \
	};

upperTab(timetab   , upperBlackFrameX             , timetabtext   , 10, timetablink);
upperTab(credittab , borderRight - upperTabWidth*2, credittabtext , 20, credittablink);
upperTab(sidebartab, borderRight - upperTabWidth  , sidebartabtext, 30, sidebartablink);
	
	class hour : spigTXT
	{
		style = 0;
		idc = 40;
		x = __EVAL(upperBlackframeX + upperTabWidth/2 - 0.03)
		y = __EVAL(upperBlackframeY);
		w = 0.03;
		h = __EVAL(upperBlackframeH);
		sizeEx = __EVAL(upperBlackframeH - 0.005);
		colorBackground[] = {black, 0};
		colorText[] = {0,1,0,1};
		font = "courierNewB64";
	};
	
	class minute : hour
	{
		idc = 41;
		x = __EVAL(upperBlackframeX + upperTabWidth/2 + 0.002);
	};
	
	

//***********************************************









//***********************************************

	// Sidebar start

__EXEC(sidebarX  = borderRight - upperTabWidth);
__EXEC(sidebarY  = upperBlackframeY + upperBlackframeH);
__EXEC(insigniaH = upperTabWidth + 0.02842);

	class insignia_back : spigTXT
	{
		idc = 50;
		style = 48;
		x = __EVAL(sidebarX);
		y = __EVAL(sidebarY);
		w = __EVAL(upperTabWidth);
		h = __EVAL(insigniaH);
		text = "img/insignia.paa";
	};
	
	class insignia : insignia_back 
	{
		idc = 51;
	};

__EXEC(sidebarY = sidebarY + insigniaH);

//***********************************************







//***********************************************

	// Mid brown bar and buttons on it

__EXEC(midBarH      = 0.03);
__EXEC(midBarSpaceH = 0.0025);
__EXEC(midButtonH   = midBarH - midBarSpaceH);

	class mid_bar : insignia
	{
		idc = 52
		y = __EVAL(sidebarY);
		h = __EVAL(midBarH);
		text = "img/mid_bar.paa";
	};

	
__EXEC(sidebarY = sidebarY + midBarSpaceH);

__EXEC(midSpace1  = 0.01);			// space at beggining and end
__EXEC(midSpace2  = 0.01);			// space between buttons

__EXEC(midButtonW = upperTabWidth - midSpace1*2 - midSpace2*2);
__EXEC(midButtonW = midButtonW / 3);

__EXEC(pixelW  = 0.00125);
__EXEC(pixelH  = 0.002);

__EXEC(midPosX = sidebarX + midSpace1);


#define midButton(NAME,NAME2,NAME3,TEXT,TRANSPARENCY,IDC) \
	class NAME : spigTXT \
	{ \
		idc = IDC; \
		colorBackground[] = {gray, 1}; \
		x = __EVAL(midPosX); \
		y = __EVAL(sidebarY); \
		w = __EVAL(midButtonW); \
		h = __EVAL(midButtonH); \
	}; \
	class NAME2 : NAME \
	{ \
		idc = IDC + 1; \
		colorBackground[] = {white2, 1}; \
		w = __EVAL(midButtonW - pixelW); \
		h = __EVAL(midButtonH - pixelH); \
	}; \
	class NAME3 : NAME \
	{ \
		idc = IDC + 2; \
		colorBackground[] = {black, 1}; \
		x = __EVAL(midPosX + pixelW); \
		y = __EVAL(sidebarY + pixelH); \
		w = __EVAL(midButtonW - pixelW*2); \
		h = __EVAL(midButtonH - pixelH*2); \
		style = 2; \
		sizeEx = __EVAL(midButtonH - pixelH*2 - 0.005); \
		colorText[] = {0,1,0,TRANSPARENCY}; \
		font = "courierNewB64"; \
		text = TEXT; \
	}; \
	__EXEC(midPosX = midPosX + midButtonW + midSpace2);

	
midButton(Repair1, Repair2, Repair3, Repair, 1  , 53);
midButton(Sell1  , Sell2  , Sell3  , Sell  , 1  , 60);
midButton(Map1   , Map2   , Map3   , Map   , 0.5, 70);

__EXEC(sidebarY  = sidebarY + midButtonH);
__EXEC(sidebar2Y = sidebarY);						// sidebar2 for building buttons

//***********************************************









//***********************************************

	// Sidebar pattern images

	class sidebar1 : mid_bar
	{
		idc = 80
		y = __EVAL(sidebarY);
		w = __EVAL(upperTabWidth + upperTabWidth*0.6);				// half of the image is empty so compensate
		h = __EVAL((borderDown - sidebarY) / 2);					// calculate space left to fill with 2 images
		text = "img/sidebar1.paa";
	};

__EXEC(tempvar  = borderDown - sidebarY);				//no parenthesis, calculate separately
__EXEC(sidebarY = sidebarY + tempvar / 2);

	class sidebar2 : sidebar1
	{
		idc = 81
		y = __EVAL(sidebarY);
		h = __EVAL(borderDown - sidebarY);
		text = "img/sidebar2.paa";	
	};

//***********************************************









//***********************************************

	// Building buttons

__EXEC(BuildingButtonX     = sidebarX + 0.033);
__EXEC(BuildingButtonW     = 0.095);
__EXEC(BuildingButtonH     = BuildingButtonW / 1.2727);			//proportion
__EXEC(BuildingButtonSpace = 0.015);
__EXEC(secondBButonPos     = BuildingButtonX + BuildingButtonW + BuildingButtonSpace);

#define BuildingButton(NAME0,X,Y,NAME1,NAME2,NAME3,NAME4,IDC,NAME5,NAME6) \
	class NAME0 : spigTXT \
	{ \
		idc = IDC; \
		x = __EVAL(X); \
		y = __EVAL(Y); \
		w = __EVAL(BuildingButtonW); \
		h = __EVAL(pixelH); \
		colorBackground[] = {white, 1}; \
	}; \
	class NAME1 : NAME0 \
	{ \
		idc = IDC + 1; \
		w = __EVAL(pixelW); \
		h = __EVAL(BuildingButtonH); \
	}; \
	class NAME2 : NAME0 \
	{ \
		idc = IDC + 2; \
		x = __EVAL(X + pixelW); \
		y = __EVAL(Y + BuildingButtonH - pixelH); \
		w = __EVAL(BuildingButtonW - pixelW); \
		colorBackground[] = {black, 1}; \
	}; \
	class NAME3 : NAME1 \
	{ \
		idc = IDC + 3; \
		x = __EVAL(X + BuildingButtonW); \
		y = __EVAL(Y); \
		w = __EVAL(pixelW + 0.0003); \
		h = __EVAL(BuildingButtonH); \
		colorBackground[] = {black, 1}; \
	}; \
	class NAME4 : spigTXT \
	{ \
		idc = IDC + 4; \
		style = 48; \
		x = __EVAL(X + pixelW); \
		y = __EVAL(Y + pixelH); \
		w = __EVAL(BuildingButtonW + 0.036); \
		h = __EVAL(BuildingButtonH + 0.007); \
	}; \
	class NAME5 : spigTXT \
	{ \
		idc = IDC + 5; \
		style = 2; \
		x = __EVAL(X + pixelW); \
		y = __EVAL(Y + pixelH); \
		w = __EVAL(BuildingButtonW - pixelW*2); \
		h = __EVAL(BuildingButtonH - pixelH*2); \
		colorBackground[] = {white, 0.35}; \
		colorText[] = {0, 1, 0, 1;}; \
		font = "courierNewB64"; \
		text = "50%"; \
		sizeEx = 0.04; \
	}; \
	class NAME6 : spigActive \
	{ \
		idc = IDC + 6; \
		x = __EVAL(X); \
		y = __EVAL(Y); \
		w = __EVAL(BuildingButtonW); \
		h = __EVAL(BuildingButtonH); \
		action = ""; \
		text = "laaaaaaaaaaaaa"; \
	};
		
// 0. white top line
// 1. white left line
// 2. black bottom line
// 3. black right line
// 4. image
// 5. white overlay with green font
// 6. active text

// for video purpose colortext in name5 was 0, 0.3, 0, 1
	
	__EXEC(sidebar2Y = sidebar2Y + 0.007);
	__EXEC(sidebar3Y = sidebar2Y);					// remember pos for later use

BuildingButton(Slot1, BuildingButtonX, sidebar2Y, Slot1a, Slot1b, Slot1c, Slot1d, 100, Slot1e, Slot1f);
BuildingButton(Slot2, secondBButonPos, sidebar2Y, Slot2a, Slot2b, Slot2c, Slot2d, 107, Slot2e, Slot2f);
	
	__EXEC(sidebar2Y = sidebar2Y + BuildingButtonH);
	
BuildingButton(Slot3, BuildingButtonX, sidebar2Y, Slot3a, Slot3b, Slot3c, Slot3d, 114, Slot3e, Slot3f);
BuildingButton(Slot4, secondBButonPos, sidebar2Y, Slot4a, Slot4b, Slot4c, Slot4d, 121, Slot4e, Slot4f);
	
	__EXEC(sidebar2Y = sidebar2Y + BuildingButtonH);
	
BuildingButton(Slot5, BuildingButtonX, sidebar2Y, Slot5a, Slot5b, Slot5c, Slot5d, 128, Slot5e, Slot5f);
BuildingButton(Slot6, secondBButonPos, sidebar2Y, Slot6a, Slot6b, Slot6c, Slot6d, 135, Slot6e, Slot6f);
	
	__EXEC(sidebar2Y = sidebar2Y + BuildingButtonH);
	
BuildingButton(Slot7, BuildingButtonX, sidebar2Y, Slot7a, Slot7b, Slot7c, Slot7d, 142, Slot7e, Slot7f);
BuildingButton(Slot8, secondBButonPos, sidebar2Y, Slot8a, Slot8b, Slot8c, Slot8d, 149, Slot8e, Slot8f);



	class black_line_fix : spigTXT
	{
		idc = 160
		x = __EVAL(sidebarX + 0.03);
		y = __EVAL(sidebar2Y);
		w = __EVAL(pixelW * 2);
		h = __EVAL(BuildingButtonH + BuildingButtonW / 1.8 - 0.004);
		colorBackground[] = {black, 0.75};
	};

__EXEC(sidebar2Y = sidebar2Y + BuildingButtonH);

	class scroll_buttons : spigTXT
	{
		idc = 161
		style = 48
		x = __EVAL(BuildingButtonX);
		y = __EVAL(sidebar2Y);
		w = __EVAL(BuildingButtonW + 0.003);
		h = __EVAL(BuildingButtonW / 1.8 + 0.006);
		text = "img/scroll_buttons.paa";
	};

	class scroll_buttons2 : scroll_buttons
	{
		idc = 162
		x = __EVAL(secondBButonPos);
	};

//***********************************************









//***********************************************

	// Description box on mouse focus
	
	class description_box : spigTXT
	{
		idc = 1000;
		style = 1 + 16;
		x = __EVAL(sidebarX - 0.225 - 0.025);
		y = __EVAL(sidebar3Y);
		w = 0.228
		h = 0.095
		text = "Light Infantry\n$500";
		colorText[] = {0,1,0,1};
		font = "courierNewB64";
		sizeEx = 0.04
		lineSpacing = 1.2
	};
	
	class description_box_frame : description_box
	{
		idc = 1001
		style = 64;
		colorText[] = {0,1,0,1};
		text = ;
	};
		
//***********************************************









//***********************************************

	// Blinking message

	class highlight_title : spigTXT
	{
		idc = 2000
		x = __EVAL(upperBlackframeX + 0.1);
		y = __EVAL(borderDown - 0.2);
		w = 0.5
		h = 0.05
		sizeEx = 0.04
		colorText[] = {0,1,0,1};
		colorBackground[] = {black, 0};
		font = "courierNewB64";
	};
	
//***********************************************		


};