:NAME iap_tutorial

:GLOBAL int32					state
:GLOBAL float32					timer
:GLOBAL float32					focus_start_time
:GLOBAL float32					focus_start_scale
:GLOBAL c_object*				focus
:GLOBAL c_object*				message

local tutoriallib = require "scripts/tutorial_utils"

-- ------------ initial delay ------------ 

local state= tutoriallib.add_delay(1.5)

-- ------------ message 1 ------------ 

state= tutoriallib.make_state("iap_message1")
tutoriallib.focus_on(state, "iap_gear_marker", tutoriallib.k_scale_normal)
function place_scrim()
	world_state_get().place_by_plate("iap_scrim", "iap_scrim")
end
state.start_func= place_scrim

--[[
function hand_start()
	local hand_object= object_place("hand")
	if (hand_object) then
		local ws= world_state_get()
		local tween= hand_object.tween_get()
		if (tween) then
			tween.play_animation_after_delay("start", 1)
			tween.play_animation_after_delay("end", 4)
		end
	end
end
state.start_func= hand_start
--]]


-- ------------ message 2, focus on painting ------------ 

state= tutoriallib.make_state("iap_message2", true)
function place_arrow()
	world_state_get().place_by_plate("iap_tutorial", "iap_arrow")
end
state.start_func= place_arrow

state= tutoriallib.make_state("iap_message3", true)
function place_underline()
	local ws= world_state_get()
	local underline= ws.place_by_plate("iap_tutorial", "iap_underline")
	local ps= ws.plate_state_get("iap_tutorial")
	local msg= ps.object_get("iap_message3")
	if (msg) then
		object_attach(msg, nil, underline, nil)
	end
end
state.start_func= place_underline


-- ------------ delay ------------ 

state= tutoriallib.add_delay(1)
function remove_everything()
	tutoriallib.remove_bubble("iap_message1")
	tutoriallib.remove_bubble("iap_message2")
	tutoriallib.remove_bubble("iap_message3")
	tutoriallib.remove_bubble("iap_arrow")
	
	local ps= world_state_get().plate_state_get("iap_scrim")
	local scrim= ps.object_get("iap_scrim")
	if (scrim) then
		object_delete(scrim)
	end
end
state.start_func= remove_everything

state= tutoriallib.add_delay(0.1)
function unload_myself()
	world_get().zone_unload("iap_tutorial")
end
state.start_func= unload_myself


function global_initialize(g)
	g.state= 0
	g.focus= nil
	g.timer= 0
	g.focus_start_time= 0
	g.focus_start_scale= tutoriallib.k_scale_out	
	
	g.message= nil
	
end

function start()
	local world= world_get()
	local ws= world_state_get()
	global.focus= object_place("iap_focus")
	global.focus.hide(true)
	tutoriallib.start()
end

function update()
	tutoriallib.update(k_states, global)
end

system_register(start, update, nil, nil)
