onEvent [ "AOPANEL_START" ] = function( params )
	SendAddon()
end

onEvent [ "AOPANEL_BUTTON_LEFT_CLICK" ] = function( params )
	if params.sender == "FittingRoom" then
		if enable == 0 then 
			wtMain:Show( true )
			enable = 1
			onEvent [ "EVENT_AVATAR_CREATED" ]()
		else
			wtMain:Show( false )
			enable = 0
		end
	end
end

onEvent [ "EVENT_AVATAR_CREATED" ] = function( params )
	mission.SetCharacterScene( 1, wtControl3D, avatar.GetId() )
	mission.SetCharacterSceneScaleFactor( 1, 1 )
	mission.SetCharacterScenePosition( 1, { posX = 0.0; posY = 0.0; posZ = 0.0 } )
end

onEvent [ "EVENT_UNKNOWN_SLASH_COMMAND" ] = function( params )
	if userMods.FromWString(params.text) == "/fr" or userMods.FromWString(params.text) == "/ръ" then
		if enable == 0 then 
			wtMain:Show( true )
			enable = 1
			onEvent [ "EVENT_AVATAR_CREATED" ]()
		else
			wtMain:Show( false )
			enable = 0
		end
	end
end

onEvent [ "EVENT_TEXT_OBJECT_CLICKED" ] = function( params )
	local IId = params.object:GetId()
	if params.object:GetType() == 1 and params.kbFlags == KBF_SHIFT then
		if enable == 0 then 
			wtMain:Show( true )
			enable = 1
			onEvent [ "EVENT_AVATAR_CREATED" ]()
		end
		mission.DressCharacterScene( 1, IId )
	end
end

onEvent [ "EVENT_VALUED_OBJECT_CLICKED" ] = onEvent [ "EVENT_TEXT_OBJECT_CLICKED" ]

onReaction [ "click_btn_left" ] = function( params )
	mission.RotateCharacterScene( 1, -0.5 )
end

onReaction [ "click_btn_right" ] = function( params )
	mission.RotateCharacterScene( 1, 0.5 )
end

onReaction [ "click_btn_zoomin" ] = function( params )
	if view == 0 then
		view = 1
		mission.SetCharacterSceneScaleFactor( 1, 3 )
		mission.SetCharacterScenePosition( 1, { posX = 0; posY = 0.0; posZ = -4 } )
	else
		view = 0
		mission.SetCharacterSceneScaleFactor( 1, 1 )
		mission.SetCharacterScenePosition( 1, { posX = 0; posY = 0.0; posZ = 0.0 } )
	end
end

onReaction [ "click_btn_zoomout" ] = function( params )
	mission.SetCharacterScene( 1, wtControl3D, avatar.GetId() )
end

onReaction [ "mouse_left_click" ] = function( params )
	wtMain:Show( false )
	enable = 0
end