---------------------------------------------------------------------------------------------------
--  Copyright © 2009 PoBros, Incorporated. All Rights Reserved.
--
--  This source code is the proprietary confidential property of PoBros Incorporated.
--  Modification, reproduction, publication, or distribution in any form to any party 
--  other than the licensee is strictly prohibited.
--
--  FOR USE BY AUTHORIZED PERSONS ONLY
---------------------------------------------------------------------------------------------------

require( "scripts/style.lua" );

local kScriptToLoad = "";
local kButtonX = 10;
local kButtonY = 470;
local kButtonWidth = 200;
local kButtonHeight = 20;

if( gDialogTable.scriptToLoad ~= "/assets/" ) then
	kScriptToLoad = gDialogTable.scriptToLoad;
end

---------------------------------------------------------------------------------------------------

MakeDialog
{
	name = "modeleditor";
	SetStyle( GameWindowStyle );
	
	ModelEditor
	{
		x = 0;
		y = 0;
		w = kMax;
		h = kMax;
		scrim = "backgrounds/scrim";
		scrimtop = 465;
		scrimleft = 0;
		scrimbottom = 600;
		scrimright = 800;
		scripttoload = kScriptToLoad;
		outputfilename = "/assets/scripts/cursors/";
				
		-- Editor Light Model Definition ( not the acutal light used on an object )
		lightmodel =
		{
			nearplane = 0.100000;
			farplane = 100.000000;
			fov = 0.628318;
			aspect = 0.000000;
			localmatrix = {0.000000,0,12};
			rotation = {3.1419,1.57,0};
			
			material =
			{
				diffuse = {1.000000,1.000000,1.000000,0.850000};
				ambient = {1.0,1.0,1.0,1.0};
				specular = {1.0,1.0,1.0,1.0};
				emit = {0.0,0.0,0.0,1.0};
				reflectance = 10.000000;
			};
			
			light =
			{
				type = 1;
				diffuse = {1.000000,1.000000,1.000000,1.000000};
			};
		};

		-- Model Definition
		model =
		{
			model = 'mesh/arrow.mesh';
			texture = 'mesh/arrowtexture';
			nearplane = 0.100000;
			farplane = 100.000000;
			fov = 0.628318;
			aspect = 0.000000;
			localmatrix = {0.000000,0,12};
			rotation = {3.1419,1.57,0};
			
			material =
			{
				diffuse = {1.000000,1.000000,1.000000,0.850000};
				ambient = {0.200000,0.200000,0.200000,1.000000};
				specular = {0.750000,0.750000,0.750000,1.000000};
				emit = {0.000000,0.000000,0.000000,0.750000};
				reflectance = 10.000000;
			};
			
			light =
			{
				type=0;
				diffuse = {1.000000,1.000000,1.000000,1.000000};
				specular = {0.100000,0.100000,0.100000,1.000000};
				ambient = {0.100000,0.100000,0.100000,1.000000};
				position = {0.000000,0.000000,0.000000};
				direction = {0.000000,0.000000,1.000000};
				range = 0.000000;
				attenuation = {0.000000,0.000000,0.000000};
				theta = 0.000000;
				phi = 0.000000;
			};
		};
		
		-- Model Editor HUD 		
		SetStyle( EdittingHUDStyle );
		
		Button
		{
			text = "#x:";
			name = "x";
			x = kButtonX;
			y = kButtonY;			

			command =
				function()
					SelectAttribute( 0 );
				end
		};
		
		Button
		{
			text = "#y:";
			name = "y";
			x = kButtonX;
			y = kButtonY + ( kButtonHeight * 1 );

			command =
				function()
					SelectAttribute( 1 );
				end
		};
		
		Button
		{
			text = "#z:";
			name = "z";
			x = kButtonX;
			y = kButtonY + ( kButtonHeight * 2 );

			command =
				function()
					SelectAttribute( 2 );
				end
		};

		Button
		{
			text = "#xRotate:";
			name = "xrotate";
			x = kButtonX;
			y = kButtonY + ( kButtonHeight * 3 );

			command =
				function()
					SelectAttribute( 3 );
				end
		};
		
		Button
		{
			text = "#yRotate:";
			name = "yrotate";
			x = kButtonX;
			y = kButtonY + ( kButtonHeight * 4 );

			command =
				function()
					SelectAttribute( 4 );
				end
		};
		
		Button
		{
			text = "#zRotate:";
			name = "zrotate";
			x = kButtonX;
			y = kButtonY + ( kButtonHeight * 5 );

			command =
				function()
					SelectAttribute( 5 );
				end
		};
		
		Button
		{
			text = "#xLight:";
			name = "xlight";
			x = kButtonX + kButtonWidth;
			y = kButtonY;
			
			command =
				function()
					SelectAttribute( 6 );
				end
		};
		
		Button
		{
			text = "#yLight:";
			name = "ylight";
			x = kButtonX + kButtonWidth;
			y = kButtonY + ( kButtonHeight * 1 );
			
			command =
				function()
					SelectAttribute( 7 );
				end
		};
		
		Button
		{
			text = "#zLight:";
			name = "zlight";
			x = kButtonX + kButtonWidth;
			y = kButtonY + ( kButtonHeight * 2 );
			
			command =
				function()
					SelectAttribute( 8 );
				end
		};
		
		Button
		{
			text = "#xRotateLight:";
			name = "xrotatelight";
			x = kButtonX + kButtonWidth;
			y = kButtonY + ( kButtonHeight * 3 );
			
			command =
				function()
					SelectAttribute( 9 );
				end
		};
		
		Button
		{
			text = "#yRotateLight:";
			name = "yrotatelight";
			x = kButtonX + kButtonWidth;
			y = kButtonY + ( kButtonHeight * 4 );
			
			command =
				function()
					SelectAttribute( 10 );
				end
		};
		
		Button
		{
			text = "#zRotateLight:";
			name = "zrotatelight";
			x = kButtonX + kButtonWidth;
			y = kButtonY + ( kButtonHeight * 5 );
			
			command =
				function()
					SelectAttribute( 11 );
				end
		};
		
		Button
		{
			text = "#LightType:";
			name = "lighttype";
			x = kButtonX + ( kButtonWidth * 2 );
			y = kButtonY;
			
			command =
				function()
					SelectAttribute( 12 );
				end
		};
		
		Button
		{
			text = "#LightRange:";
			name = "lightrange";
			x = kButtonX + ( kButtonWidth * 2 );
			y = kButtonY + kButtonHeight;
			
			command =
				function()
					SelectAttribute( 13 );
				end
		};
		
		Button
		{
			text = "#LightRcolor:";
			name = "lightRcolor";
			x = kButtonX + ( kButtonWidth * 2 );
			y = kButtonY + ( kButtonHeight * 2 );
			
			command =
				function()
					SelectAttribute( 14 );
				end
		};
		
		Button
		{
			text = "#LightGcolor:";
			name = "lightgcolor";
			x = kButtonX + ( kButtonWidth * 2 );
			y = kButtonY + ( kButtonHeight * 3 );
			
			command =
				function()
					SelectAttribute( 15 );
				end
		};
		
		Button
		{
			text = "#LightBcolor:";
			name = "lightbcolor";
			x = kButtonX + ( kButtonWidth * 2 );
			y = kButtonY + ( kButtonHeight * 4 );
			
			command =
				function()
					SelectAttribute( 16 );
				end
		};
		
		Button
		{
			text = "#LightFollows:";
			name = "lightFollows";
			x = kButtonX + ( kButtonWidth * 2 );
			y = kButtonY + ( kButtonHeight * 5 );
			
			command =
				function()
					SelectAttribute( 17 );
				end
		};
	
		Button
		{
			text = "#Save State";
			name = "savestate";
			x = 690;
			y = 530;
			
			command =
				function()
					SaveState();
				end
		};

		Button
		{
			text = "#Save";
			name = "save";
			x = 710;
			y = 550;
			
			command =
				function()
					local filename = GetCurrentCursorName();
					
					if( filename == "" ) then
						filename = DoModal( "scripts/enterfilename.lua" ) .. ".lua";
					end
					
					if( filename ~= "" ) then
						Save( filename );
					end
				end
		};

		Button
		{
			text = "#Quit";
			name = "quit";
			x = 710;
			y = 570;
			
			command =
				function()
					PopModal( "modeleditor" );
				end
		};				
	};
};

---------------------------------------------------------------------------------------------------
