--------------------------------------------------------------------------------
-- SimNetwork
-- Intro screen
-- intro.lua
-- -----------------------------------------------------------------------------

SimNetwork_INTRO = true
if not SimNetwork_GLOBAL then dofile("global.lua") end

-- global variables
introScreen = nil	-- holds sprite of splash screen
introCamera = nil	-- camera of splash screen

function createSelectionBox()
		
	-- load splash image
	local image = E.create_image("data/screens/menuitem.png")
	local brush = E.create_brush()
	E.set_brush_flags(brush, E.brush_flag_transparent, false)
	E.set_brush_flags(brush, E.brush_flag_unlit,       true)
	E.set_brush_flags(brush, E.brush_flag_diffuse,     false)
	E.set_brush_flags(brush, E.brush_flag_specular,     true)
	E.set_brush_flags(brush, E.brush_flag_ambient,     true)
	E.set_brush_flags(brush, E.brush_flag_shiny,    true)
	E.set_brush_color(brush, 1.0, 1.0, 1.0, 1.0)
	E.set_brush_image(brush, image)
	
	selectionBox = E.create_sprite(brush)
	introCamera = E.create_camera(E.camera_type_orthogonal)
	
	E.set_entity_position(introCamera, -viewport.k * viewport.w/2, 
					-viewport.k * viewport.h/2, 0)
	E.set_entity_scale(introCamera, viewport.k, viewport.k, viewport.k)
	E.set_entity_position(selectionBox,-230,-68,0)
	
	-- start with intro screen being transparent
	--E.set_entity_alpha(introScreen, 0.0)
	E.parent_entity(selectionBox,introCamera)
end

function createSplashScreen()

	-- set background to black
	E.set_background(0.0, 0.0, 0.0)
		
	-- load splash image
	local image = E.create_image("data/screens/presents.png")
	local brush = E.create_brush()
	E.set_brush_flags(brush, E.brush_flag_transparent, false)
	E.set_brush_flags(brush, E.brush_flag_unlit,       true)
	E.set_brush_flags(brush, E.brush_flag_diffuse,     false)
	E.set_brush_flags(brush, E.brush_flag_specular,     true)
	E.set_brush_flags(brush, E.brush_flag_ambient,     true)
	E.set_brush_flags(brush, E.brush_flag_shiny,    true)
	E.set_brush_color(brush, 1.0, 1.0, 1.0, 1.0)
	E.set_brush_image(brush, image)
	
	introScreen = E.create_sprite(brush)
	
	E.set_entity_position(introCamera, -viewport.k * viewport.w/2, 
					-viewport.k * viewport.h/2, 0)
	E.set_entity_scale(introCamera, viewport.k, viewport.k, viewport.k)
	E.set_entity_position(introScreen,0,0,0)
	
	-- start with intro screen being transparent
	--E.set_entity_alpha(introScreen, 0.0)
	E.parent_entity(introScreen,introCamera)
end

function createMenuScreen()
	-- load splash image
	local image = E.create_image("data/screens/menu.png")
	local brush = E.create_brush()
	E.set_brush_flags(brush, E.brush_flag_transparent, false)
	E.set_brush_flags(brush, E.brush_flag_unlit,       true)
	E.set_brush_flags(brush, E.brush_flag_diffuse,     false)
	E.set_brush_flags(brush, E.brush_flag_specular,     true)
	E.set_brush_flags(brush, E.brush_flag_ambient,     true)
	E.set_brush_flags(brush, E.brush_flag_shiny,    true)
	E.set_brush_color(brush, 1.0, 1.0, 1.0, 1.0)
	E.set_brush_image(brush, image)
	menuScreen = E.create_sprite(brush)
	E.set_entity_position(menuScreen,0,0,0)
	E.parent_entity(menuScreen,introCamera)
end

function createHelpScreen()
	-- load splash image
	local image = E.create_image("data/screens/help.png")
	local brush = E.create_brush()
	E.set_brush_flags(brush, E.brush_flag_transparent, false)
	E.set_brush_flags(brush, E.brush_flag_unlit,       true)
	E.set_brush_flags(brush, E.brush_flag_diffuse,     false)
	E.set_brush_flags(brush, E.brush_flag_specular,     true)
	E.set_brush_flags(brush, E.brush_flag_ambient,     true)
	E.set_brush_flags(brush, E.brush_flag_shiny,    true)
	E.set_brush_color(brush, 1.0, 1.0, 1.0, 1.0)
	E.set_brush_image(brush, image)
	helpScreen = E.create_sprite(brush)
	E.set_entity_position(helpScreen,0,0,0)
	E.parent_entity(helpScreen,introCamera)
end

function createHelp2Screen()
	-- load splash image
	local image = E.create_image("data/screens/help2.png")
	local brush = E.create_brush()
	E.set_brush_flags(brush, E.brush_flag_transparent, false)
	E.set_brush_flags(brush, E.brush_flag_unlit,       true)
	E.set_brush_flags(brush, E.brush_flag_diffuse,     false)
	E.set_brush_flags(brush, E.brush_flag_specular,     true)
	E.set_brush_flags(brush, E.brush_flag_ambient,     true)
	E.set_brush_flags(brush, E.brush_flag_shiny,    true)
	E.set_brush_color(brush, 1.0, 1.0, 1.0, 1.0)
	E.set_brush_image(brush, image)
	help2Screen = E.create_sprite(brush)
	E.set_entity_position(help2Screen,0,0,0)
	E.parent_entity(help2Screen,introCamera)
end

function createCreditsScreen()
	-- load splash image
	local image = E.create_image("data/screens/credits.png")
	local brush = E.create_brush()
	E.set_brush_flags(brush, E.brush_flag_transparent, false)
	E.set_brush_flags(brush, E.brush_flag_unlit,       true)
	E.set_brush_flags(brush, E.brush_flag_diffuse,     false)
	E.set_brush_flags(brush, E.brush_flag_specular,     true)
	E.set_brush_flags(brush, E.brush_flag_ambient,     true)
	E.set_brush_flags(brush, E.brush_flag_shiny,    true)
	E.set_brush_color(brush, 1.0, 1.0, 1.0, 1.0)
	E.set_brush_image(brush, image)
	creditsScreen = E.create_sprite(brush)
	E.set_entity_position(creditsScreen,0,0,0)
	E.parent_entity(creditsScreen,introCamera)
end

function createLevelScreen()
	-- load splash image
	local image = E.create_image("data/screens/levelselect.png")
	local brush = E.create_brush()
	E.set_brush_flags(brush, E.brush_flag_transparent, false)
	E.set_brush_flags(brush, E.brush_flag_unlit,       true)
	E.set_brush_flags(brush, E.brush_flag_diffuse,     false)
	E.set_brush_flags(brush, E.brush_flag_specular,     true)
	E.set_brush_flags(brush, E.brush_flag_ambient,     true)
	E.set_brush_flags(brush, E.brush_flag_shiny,    true)
	E.set_brush_color(brush, 1.0, 1.0, 1.0, 1.0)
	E.set_brush_image(brush, image)
	levelScreen = E.create_sprite(brush)
	E.set_entity_position(levelScreen,0,0,0)
	E.parent_entity(levelScreen,introCamera)
end

function createLoadingScreen()
	-- load splash image
	local image = E.create_image("data/screens/loading.png")
	local brush = E.create_brush()
	E.set_brush_flags(brush, E.brush_flag_transparent, false)
	E.set_brush_flags(brush, E.brush_flag_unlit,       true)
	E.set_brush_flags(brush, E.brush_flag_diffuse,     false)
	E.set_brush_flags(brush, E.brush_flag_specular,     true)
	E.set_brush_flags(brush, E.brush_flag_ambient,     true)
	E.set_brush_flags(brush, E.brush_flag_shiny,    true)
	E.set_brush_color(brush, 1.0, 1.0, 1.0, 1.0)
	E.set_brush_image(brush, image)
	loadingScreen = E.create_sprite(brush)
	E.set_entity_position(loadingScreen,0,0,0)
	E.parent_entity(loadingScreen,introCamera)
end

function hideIntroScreens()
	hide(introScreen)
	hide(menuScreen)
	hide(helpScreen)
	hide(help2Screen)
	hide(creditsScreen)
	hide(levelScreen)
	--hide(winScreen)
	--hide(LooseScreen)
end

function removeMenuScreen()
	E.delete_entity(menuScreen)
end

function removeSplashScreen()
	E.delete_entity(introScreen)
end

function removeIntroCamera()
	E.delete_entity(introCamera)
end
