<?xml version="1.0" encoding="UTF-8"?>
<rmml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="L:\collaborative-nir\program\Cscl3DWS\rmml\RMML.xsd">
	<!-- описание сцены -->
	<include src="window.xml"/>
	<include src="chembase.xml"/>
	<include src="equip.xml"/>
	<include src="reacseqs.xml"/>
	<include src="sengine.xml"/>
	<include src="photocam.xml"/>
	<include src="comments.xml"/>
	<include src="chemist.xml"/>
	<include src="scheme.xml"/>
	<include src="bigview.xml"/>
	<include src="instruction.xml"/>
	<include src="labReport.xml"/>
	<include src="button.xml"/>
	<include src="chemcase.xml"/>
	<include src="hint.xml"/>
	<include src="imhint.xml"/>
	<include src="photolist.xml"/>
	<include src="helpWindow.xml"/>

	<scene _name="CBaseScene" _class="CChemBaseScene"  _final="false" userEvents="evJournalShown onLabReportPress">
		<script src="reactions.mjs"/>
		<script>
			this.sResPath='';
			this.useTubeStand=false;
			this.useChemCase = false;
			this.autoPouring = false;	// автоматическое наливание
			this.instructionClosedOnce = false;
		</script>
		<composition name="photoList" class="CPhotoList" depth="-200">
			<script>
				this.list.enableList(false);
			</script>
		</composition>
		<image _name="background" _depth="100"/>
		<composition name="btnInstruction" class="CImageButton" _x="664" _y="539" _depth="99" _visible="true">
			<image _name="img" src="eval(ENVRPATH+'instr.png')" />
			<script event="onClick">
				scene.instruction.showDialog();
			</script>
		</composition>
		<composition _name="iconscheme" class="CImageButton" _x="700" _y="539" _depth="99" _visible="false">
			<script>
				this.schemeName="";
			</script>
			<image _name="img" src="eval(ENVRPATH+'sceme.png')" />
			<script event="onClick">
				scene.showScheme(this.schemeName);
			</script>
		</composition>
		<composition   _name="hint" _class="CViewportHint" visible="false" />
		<viewport _name="main_viewport" class="CHintViewport" _camera="objects.main_camera" userEvents="onShowHint,onHideHint" width="800" height="600"/>
		<scene3d _name="objects">
			<light src="rmeq:environment\common_light.xml"/>
			<camera src="rmeq:environment\common_camera.xml" _name="main_camera"/>
			<!--<group _name="chemist" _class="CChemist"/>-->
		</scene3d>

		<viewport _name="chemist_viewport" _camera="chemistscene.main_camera" depth="-11"  width="800" height="600"/>
		<scene3d _name="chemistscene">
			<light src="rmeq:environment\common_light.xml"/>
			<camera src="rmeq:environment\common_camera.xml" _name="main_camera"/>
			<group _name="chemist" _class="CChemist"/>
		</scene3d>

		<script><![CDATA[
			function AddCase()
			{
				if( eval("scene.chemcase")!=undefined)	return;
				var cs = new Composition();
				cs._class = "CChemCase";
				cs.name = "chemcase";
				cs.parent = this;
				cs.show();
			}

			function	Initialize()
			{
				comments.Initialize();
				instruction.Initialize(comments.instruction);
trace("comments.instruction="+comments.instruction);
				if (comments.instruction != "")
					instruction.showDialog();
				if( scene.useChemCase)
					scene.AddCase();
			}

			function addBulbStub(n, fprefix)
			{
				im = new Image();
				if( n <= 3)
				{
					im._x = 93 + 49*(n-1);
					im._y = 124;
				}
				else	if( n <= 6)
				{
					im._x = 97 + 49*(n-1-3);
					im._y = 218;
				}
				else	if( n <= 9)
				{
					im._x = 649 + 49*(n-1-6);
					im._y = 126;
				}
				else	if( n <= 12)
				{
					im._x = 649 + 49*(n-1-9);
					im._y = 218;
				}
				im._name = "bulbStub"+n;
				im.src = this.sResPath + fprefix + ".png";
				im._depth = -10;
				im.onPress = function()
				{
					if( scene.onBulbStubPressed != null)
						scene.onBulbStubPressed(im);
				};
				im.parent = scene;
			}

			function makePhoto(wait)
			{
				if( wait == undefined)
					this.photocamera.alertPhotoCamera(false);
				else
					return this.photocamera.alertPhotoCamera(true);
			}

			function showComment(id)
			{
				comments.showComment(id);
			}

			function labReport(cause)
			{
				if( cause == 1)	showMEditor();
				else	if( cause == 2)	showJournal();
				else	if( cause == 3)	showIEditor();
				else	if( cause == 4)	showSIEditor();
				else	if( cause == 5)	showJournal();
			}

			function showMEditor(cSound,txt)
			{
				if (typeof(txt)=="undefined"){
					trace("составьте уравнения реакций в молекулярном виде");
					scene.showComment("Составьте уравнения реакций в молекулярном виде.");
				}else {trace('showComment        txt');
					scene.showComment(txt);
					}
				if (typeof(cSound)=="undefined")
					sengine.scplay(36);
				else
					sengine.splay(cSound);
				showEditor();
			}

			function showIEditor(cSound)
			{
				trace("cоставьте ионные уравнения");
				scene.showComment("Составьте ионные уравнения.");
				if (typeof(cSound)=="undefined")
					sengine.scplay(37);
				else
					sengine.splay(cSound);
				showEditor();
			}

			function showSIEditor()
			{
				trace("cоставьте краткие ионные уравнения");
				scene.showComment("Составьте краткие ионные уравнения.");
				scene.sengine.scplay(39);
				showEditor();
			}

			function showEditor()
			{
				if (this.loadReport())
					this.labReportWin.showChemEditor();
			}

			function showJournal(cSound,txt)
			{
				if (typeof(txt)=="undefined")
				{
					trace("результаты экспериментов оформите  лабораторном журнале");
					scene.showComment("Результаты экспериментов оформите в лабораторном журнале.");
				}
				else
				{
					scene.showComment(txt);
				}
				if (typeof(cSound)=="undefined")	sengine.scplay(38);
				else	sengine.scplay(cSound);
				this.showJournalNoSound();
			}
			function showJournalNoSound()
			{
				if (this.loadReport())
				{
					this.labReportWin.showReport();
					fireEvent("evJournalShown");

				}

			}
			function loadReport()
			{
				trace("#00FF00loadReport");
				if (this.labReportWin == null)
				{
					this.labReportWin = this.labReportWindow;
					this.journal = new Composition();
					this.journal.userEvents="evClosed";
					this.labReportWin.journalWrap = this.journal;
					this.journal.parent  = this;
					this.editor = new Composition();
					this.editor.userEvents="evClosed";
					this.labReportWin.editorWrap = this.editor;
					this.editor.parent  = this;
				}
				// Hide photocam
				this.photocamera.cancelShot();
				return (this.labReportWin != null);
			}

			function showScheme(img)
			{
				scene.iconscheme.show();
				scene.iconscheme.schemeName = img;
				this.scheme.showScheme(img);
				this.scheme.centerScreen();
			}

			function errorAction()
			{
				if( scene.sengine != undefined)
					scene.sengine.errorAction();
			}

			function showBigView(obj, bshow, icam, iview, subimage)
			{
				//if( bshowbin == undefined)	bshowbin = true;
				if( iview == undefined)	iview = 1;
				if( icam == undefined)	icam = 0;
				if( bshow == undefined)	bshow = true;

				var	pBigView = eval("scene.bigView"+iview);
				if( typeof(pBigView) == undefined && !bshow)	return;

				var	vx = 0;
				var	vy = 0;
				var	vw = 220;
				var	vh = 165;
				var camera = icam;

				if( iview == 1)
				{
					vx = 27;
					vy = 71;
				}
				else	if( iview == 2)
				{
					vx = 397;
					vy = 71;
				}
				if( pBigView == undefined)
				{
					pBigView = new Composition();
					pBigView._name = "bigView"+iview;
					pBigView._class = "CBigView";
					pBigView.parent = scene;
				}

				if(  bshow)
				{
					pBigView.show(vx,vy,vw,vh,camera);
					if( subimage != undefined)
						pBigView.loadSubImage(":"+subimage);
					pBigView.addObject(obj);
					pBigView._visible = true;
				}
				else
				{
					pBigView.hide();
					pBigView.removeObject(obj);
					pBigView._visible = false;
				}
			}

			function moveBigView(iview, x, y)
			{
				var	pBigView = eval("scene.bigView"+iview);
				if( typeof(pBigView) == undefined)	return;
				pBigView.moveTo(x,y);
			}

			function CreateSEngineIfNecessary()
			{
				if(eval("scene.sengine")!=undefined)	return;
				var sengine = new Composition();
				sengine._class = "CSoundEngine";
				sengine._name = "sengine";
				sengine.parent = scene;
			}

			function PlaySE(fname)
			{
				if( scene.sengine!=undefined)
					scene.sengine.seplay(fname);
			}
		]]></script>
		<!-- Окно помощи -->
		<composition name="helpWindow" class="CHelpWin" x="137" depth="-300">
			<script>
				this.sHelpPath = getFullPath("rmlabshelp:help.htm");
			</script>
		</composition>

		<composition name="btnLabReport" class="CSkinedButton" x="670" y="565" depth="99" userProperties="skinN=3">
			<image _name="imSkin" src="rmgr:tools/bt_labreport.png" />
		</composition>
		<script event="btnLabReport.onRelease">
			//trace( '------==========-------btnLabReport.onClock');
			if (this.loadReport())
			{
				this.labReportWin.showReportButton();
				fireEvent("evJournalShown");
			}
		</script>
		<composition _name="sengine" _class="CSoundEngine">
		</composition>
		<composition _name="photocamera" _class="CPhotoCamera" _depth="-1">
		</composition>
		<composition _name="comments" _class="CComments" _depth="-100" _x="107" _y="536">
		</composition>
		<composition _name="scheme" _class="CScheme" _depth="-220" _visible="false">
		</composition>
		<composition name="labReportWindow" class="CLabReportWin" depth="-250" visible="false"/>
		<composition _name="instruction" _class="CInstruction" _depth="-230" _x="235" _y="154" _visible="false">
		</composition>
		<script event="instruction.evClosed"><![CDATA[
			if( !this.instructionClosedOnce)
			{
				this.instructionClosedOnce = true;
				if( this.start_exp != undefined)
					this.start_exp();
				if( eval("scene.chemcase") != undefined)
					eval("scene.chemcase").closeCase();
			}
		]]></script>
	</scene>
</rmml>
