<?xml version="1.0" encoding="UTF-8"?>
<rmml>
<!--
$RCSfile: rnmc_stdQt.xml,v $
$Revision: 957 $

last change: $Date: 2009-02-17 14:00:06 +0300 (Вт, 17 фев 2009) $
             $Author: toha $

	Lacerta Project
	version 1.0.0.1
	Copyright (C) 2007-2009 RNMC
-->
<composition name="rnmc_stdQuickTime" class="rnmc_stdMediaObject">
<script><![CDATA[
	this.type = "rnmc_stdQuickTime"
	this.objectPlaying = false;
	
//	для каждого объекта необходимо определить
//	какие эффекты к нему применимы
	this.fadeEffectEnabled = true;
	this.moveEffectEnabled = true;
	this.scaleEffectEnabled = false;

	this.rotateDelay = 0;
	this.rotationDelta = 2;

//  массивы действий на QuickTime события
	this.onEnterNodeActions = null;
	this.onLeaveNodeActions = null;
	this.onEnterHotSpotActions = null;
	this.onLeaveHotSpotActions = null;
	this.onTriggerHotSpotActions = null;

	function initFromNode(srcNode){
		var xmlNode = null;
		var xmlAttributeMap = null;
		var xmlAttribute = null;

		xmlAttributeMap = srcNode.attributes;
		if (xmlAttributeMap){
			xmlAttribute = xmlAttributeMap.getNamedItem("id");
			if (xmlAttribute != null && xmlAttribute.specified)
				this.id = xmlAttribute.value;
			xmlAttribute = xmlAttributeMap.getNamedItem("visible");
			if (xmlAttribute != null && xmlAttribute.specified){
				if(xmlAttribute.value == "true")
					this.visibility = OBJECT_VISIBILITY_TRUE;
				else if(xmlAttribute.value == "false")
					this.visibility = OBJECT_VISIBILITY_FALSE;
			}
			xmlAttribute = xmlAttributeMap.getNamedItem("enabled");
			if (xmlAttribute != null && xmlAttribute.specified && xmlAttribute.value == "false")
				this.disabled = true;
			xmlAttribute = xmlAttributeMap.getNamedItem("playing");
			if (xmlAttribute != null && xmlAttribute.specified){
				if(xmlAttribute.value == "true"){
					this.playing = OBJECT_PLAYING_TRUE;
				} else if(xmlAttribute.value == "false"){
					this.playing = OBJECT_PLAYING_FALSE;
				}
			}
		}

	//	считывание настроек по умолчанию
		if(scene.defaultSettings && scene.defaultSettings.stdQT){
			this.titleStyle = scene.defaultSettings.stdQT.titleStyle;
		}

		xmlNode = srcNode.firstChild;
		while(xmlNode){
			if(xmlNode.nodeName == "param"){
				xmlAttributeMap = xmlNode.attributes;
				if (xmlAttributeMap){
					xmlAttribute = xmlAttributeMap.getNamedItem("rotationDelay");
					if (xmlAttribute != null && xmlAttribute.specified)
						this.rotateDelay = parseInt(xmlAttribute.value);
					xmlAttribute = xmlAttributeMap.getNamedItem("rotationDelta");
					if (xmlAttribute != null && xmlAttribute.specified)
						this.rotationDelta = Math.abs(parseInt(xmlAttribute.value));
				}
				this.parseParamNode(xmlNode);
			} else if(xmlNode.nodeName == "control"){
				this.parseControlNode(xmlNode);
			} else if(xmlNode.nodeName == "rollovermenu"){
				this.parseRolloverMenuNode(xmlNode);
			} else if(xmlNode.nodeName == "actions"){
			// обработка специфичных для QuickTime cобытий
				this.onEnterNodeActions = scene.Utils.parseActionsNode(xmlNode, "onEnterNode");
				this.onLeaveNodeActions = scene.Utils.parseActionsNode(xmlNode, "onLeaveNode");
				this.onEnterHotSpotActions =
					scene.Utils.parseActionsNode(xmlNode, "onEnterHotSpot");
				this.onLeaveHotSpotActions =
					scene.Utils.parseActionsNode(xmlNode, "onLeaveHotSpot");
				this.onTriggerHotSpotActions =
					scene.Utils.parseActionsNode(xmlNode, "onPressHotSpot");
			//	стандартые события
				rnmc_stdMediaObject_parseActionsNode(xmlNode);
			} else if(xmlNode.nodeName == "title"){
				this.parseTitleNode(xmlNode);
			} else if(xmlNode.nodeName == "hint"){
				this.parseHintNode(xmlNode);
			} else if(xmlNode.nodeName == "effects"){
				this.parseEffectsNode(xmlNode);
			} else if(xmlNode.nodeName == "effect"){	//	старый вариант, NOT SAFE
				this.parseEffectNode(xmlNode);
			} else if(xmlNode.nodeName == "drag"){ //	таскание медиа-объекта
				this.parseDraggingNode(xmlNode);
			} else if(xmlNode.nodeName == "scrollmenu"){ //	таскание медиа-объекта
				this.parseScrollMenuNode(xmlNode);
			} else if(xmlNode.nodeName == "objectives"){
				this.parseObjectivesNode(xmlNode);
			}
					
			xmlNode = xmlNode.nextSibling;
		}
		return true;
	};

	function loadObject(){
		if(!this.objectContent){
			this.objectContent = new QuickTime();
			this.objectContent.src = this.objectSrc;
			if (this.objectHitArea != null)
				this.objectContent.hitArea = this.objectHitArea;
			this.objectContent.parent = this;
		}
	}

	function unloadObject(){
		this.effectsTarget = null;
		if(this.objectContent){
			this.objectContent.src = null;
			this.objectContent.parent = null;
			this.objectContent = null;
		}
	}
	
	function showObject(){
		this.x = 0;
		this.y = 0;
		this.loadObject();
		if(this.objectContent){
			var objectPosition = this.getPosition();
			this.setPosition(objectPosition[0], objectPosition[1], objectPosition[2], objectPosition[3], this.objectDepth);
			this.objectContent.opacity = this.objectOpacity;
			if(this.playing == OBJECT_PLAYING_TRUE)
				this.objectContent.playing = true;
			if(this.playing == OBJECT_PLAYING_FALSE)
				this.objectContent.playing = false;

			if(this.onEnterNodeActions){
				this.objectContent.enterNode = this.onEnterNodeAlias;
			}
			if(this.onLeaveNodeActions){
				this.objectContent.leaveNode = this.onLeaveNodeAlias;
			}
			if(this.onEnterHotSpotActions){
				this.objectContent.enterHotSpot = this.onEnterHotSpotAlias;
			}
			if(this.onLeaveHotSpotActions){
				this.objectContent.leaveHotSpot = this.onLeaveHotSpotAlias;
			}
			if(this.onTriggerHotSpotActions){
				this.objectContent.triggerHotSpot = this.onTriggerHotSpotAlias;
			}
		}	

		rnmc_stdMediaObject_showObject();
	};

	function hideObject(){
		rnmc_stdMediaObject_hideObject();
	};

 	function buttonDispatcher(btnId){
		switch(btnId){
		default:
			rnmc_stdMediaObject_buttonDispatcher(btnId);
		}
	}

	function playObject(){
		if(this.objectContent)
			this.objectContent.playing = true;
		if(this.playControl)
			this.playControl.synchronizeControl();
		if (this.rolloverMenuObject)
			this.rolloverMenuObject.synchronizeControl();
		this.applyActions(EVENT_ON_PLAY);
	}

	function pauseObject(){
		if(this.objectContent)
			this.objectContent.playing = false;
		if(this.playControl)
			this.playControl.synchronizeControl();
		if (this.rolloverMenuObject)
			this.rolloverMenuObject.synchronizeControl();
		this.applyActions(EVENT_ON_PAUSE);
	}

	function stopObject(){
		if(this.objectContent)
			this.objectContent.playing = false;
		if(this.playControl)
			this.playControl.synchronizeControl();
		if (this.rolloverMenuObject)
			this.rolloverMenuObject.synchronizeControl();
		//this.applyActions(EVENT_ON_STOP);
	}
	
//	=======================================  EVENT HANDLERS	===================================
//  обработчики специфичных для qt-событий
	function onEnterNodeAlias(){
		onEnterNode();
	}

	function onEnterNode(){
//trace("rnmc_stdQuickTime.onEnterNode: " + Event.nodeID);
		for(var i = 0; i < this.onEnterNodeActions.length; i++){
			if(this.onEnterNodeActions[i].eventParam
				&& this.onEnterNodeActions[i].eventParam == Event.nodeID){
				parent.dispatchAction(this.onEnterNodeActions[i]);
			}
		}
	}

	function onLeaveNodeAlias(){
		onLeaveNode();
	}

	function onLeaveNode(){
//trace("rnmc_stdQuickTime.onLeaveNode: " + Event.nodeID);
		for(var i = 0; i < this.onLeaveNodeActions.length; i++){
			if(this.onLeaveNodeActions[i].eventParam
				&& this.onLeaveNodeActions[i].eventParam == Event.nodeID){
				parent.dispatchAction(this.onLeaveNodeActions[i]);
			}
		}
	}

	function onEnterHotSpotAlias(){
		onEnterHotSpot();
	}

	function onEnterHotSpot(){
//trace("rnmc_stdQuickTime.onEnterHotSpot: " + Event.hotSpot);
		for(var i = 0; i < this.onEnterHotSpotActions.length; i++){
			if(this.onEnterHotSpotActions[i].eventParam
				&& this.onEnterHotSpotActions[i].eventParam == Event.hotSpot){
				parent.dispatchAction(this.onEnterHotSpotActions[i]);
			}
		}
	}

	function onLeaveHotSpotAlias(){
		onLeaveHotSpot();
	}

	function onLeaveHotSpot(){
//trace("rnmc_stdQuickTime.onLeaveHotSpot: " + Event.hotSpot);
		for(var i = 0; i < this.onLeaveHotSpotActions.length; i++){
			if(this.onLeaveHotSpotActions[i].eventParam
				&& this.onLeaveHotSpotActions[i].eventParam == Event.hotSpot){
				parent.dispatchAction(this.onLeaveHotSpotActions[i]);
			}
		}
	}

	function onTriggerHotSpotAlias(){
		onTriggerHotSpot();
	}

	function onTriggerHotSpot(){
//trace("rnmc_stdQuickTime.onTriggerHotSpot: " + Event.hotSpot);
		for(var i = 0; i < this.onTriggerHotSpotActions.length; i++){
			if(this.onTriggerHotSpotActions[i].eventParam
				&& this.onTriggerHotSpotActions[i].eventParam == Event.hotSpot){
				parent.dispatchAction(this.onTriggerHotSpotActions[i]);
			}
		}
	}

	function playQtFromAngleToAngle(minAngle, maxAngle, rotateDirection){
		//trace("rnmc_stdQuickTime.playQtFromAngleToAngle: " + minAngle + ", " + maxAngle);
		var minRotateBound = parseInt(minAngle);
		var maxRotateBound = parseInt(maxAngle);
		if((minRotateBound >= -360) && (minRotateBound <= 360) &&
			(maxRotateBound >= -360) && (maxRotateBound <= 360)){
			this.rotateAngle = maxRotateBound - minRotateBound;
			if(this.rotateAngle > 0){
				this.angleDelta = this.rotationDelta;
			} else {
				this.angleDelta = -this.rotationDelta;
			}
			this.rotateAngle = Math.abs(this.rotateAngle);
			if(this.objectContent){
				if(minRotateBound < 0){
					this.objectContent.panAngle = (minRotateBound + 360);
				} else {
					this.objectContent.panAngle = minRotateBound;
				}
				this.currentDelta = 0;
				rotateSequencer.playing = true;
			}
		} else {
			trace("#FF0000Ошибка: QuickTime - " + this.id + " - неправильно заданы углы вращения.");
		}
	}

	function rotateUpdate(){
		this.objectContent.panAngle += this.angleDelta;
		this.currentDelta += this.rotationDelta;
		if(this.currentDelta >= this.rotateAngle){
			rotateSequencer.playing = false;		
		}
	}
]]></script>
<sequencer name="rotateSequencer" playing="false" loop="true">
	 <script>
		this.rotateDelay; // ms
	</script>
	<script>
		rotateUpdate();
	</script>
</sequencer>
</composition>
</rmml>
