public frmPropertiesSound(cSoundSource aSound)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
			objNameText.Text = aSound.msName;
			
			objActiveBox.SelectedIndex = aSound.mbActive?1:0;
			objLoopBox.SelectedIndex = aSound.mbLoop?1:0;
			objRelativeBox.SelectedIndex = aSound.mbRelative?1:0;
			
			objSoundText.Text = aSound.msSoundName;
			objMinDistText.Text = aSound.mfMinDist.ToString();
			objMaxDistText.Text = aSound.mfMaxDist.ToString();
			objRandomText.Text = aSound.mlRandom.ToString();
			objIntervalText.Text = aSound.mlInterval.ToString();
			objXText.Text = aSound.mfRelX.ToString();
			objYText.Text = aSound.mfRelY.ToString();
			objZText.Text = aSound.mfRelZ.ToString();
			objVolumeText.Text = aSound.mfVolume.ToString();
       }
Example #2
0
        public frmPropertiesSound(cSoundSource aSound)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            objNameText.Text = aSound.msName;

            objActiveBox.SelectedIndex   = aSound.mbActive?1:0;
            objLoopBox.SelectedIndex     = aSound.mbLoop?1:0;
            objRelativeBox.SelectedIndex = aSound.mbRelative?1:0;

            objSoundText.Text    = aSound.msSoundName;
            objMinDistText.Text  = aSound.mfMinDist.ToString();
            objMaxDistText.Text  = aSound.mfMaxDist.ToString();
            objRandomText.Text   = aSound.mlRandom.ToString();
            objIntervalText.Text = aSound.mlInterval.ToString();
            objXText.Text        = aSound.mfRelX.ToString();
            objYText.Text        = aSound.mfRelY.ToString();
            objZText.Text        = aSound.mfRelZ.ToString();
            objVolumeText.Text   = aSound.mfVolume.ToString();
        }
        ////////////////////////////////////////////////////////////////////////
        // LOAD THE MAP
        //
        ////////////////////////////////////////////////////////////////////////

        public bool Load(string asFileName)
        {
            XmlDocument Doc = new XmlDocument();

            try{
                Doc.Load(asFileName);
            }
            catch {
                return(false);
            }
            XmlElement HplMapElem = (XmlElement)Doc.FirstChild;
            ///////////////////////////
            ////// HPL MAP ///////////
            ///////////////////////////
            int lR, lG, lB;

            mMainForm.msMapName   = cHplXml.GetStr(HplMapElem, "Name", "");
            mMainForm.mlMapWidth  = cHplXml.GetInt(HplMapElem, "Width", 0);
            mMainForm.mlMapHeight = cHplXml.GetInt(HplMapElem, "Height", 0);
            mMainForm.mfLightZ    = cHplXml.GetFloat(HplMapElem, "LightZ", 10);
            lR = cHplXml.GetInt(HplMapElem, "AmbColR", 0);
            lG = cHplXml.GetInt(HplMapElem, "AmbColG", 0);
            lB = cHplXml.GetInt(HplMapElem, "AmbColB", 0);
            mMainForm.mAmbientColor = Color.FromArgb(lR, lG, lB);

            foreach (XmlElement HplMapChild in HplMapElem.ChildNodes)
            {
                ///////////////////////////
                ////// LIGHT //////////////
                ///////////////////////////
                if (HplMapChild.Name == "Lights")
                {
                    XmlElement LightRootElem = HplMapChild;

                    foreach (XmlElement LightElem in LightRootElem.ChildNodes)
                    {
                        string sName     = LightElem.GetAttribute("Name");
                        bool   bActive   = cHplXml.GetBool(LightElem, "Active", true);
                        float  fRadius   = cHplXml.GetFloat(LightElem, "Radius", 0);
                        float  fSpecular = cHplXml.GetFloat(LightElem, "Specular", 1);

                        lR = cHplXml.GetInt(LightElem, "ColR", 0);
                        lG = cHplXml.GetInt(LightElem, "ColG", 0);
                        lB = cHplXml.GetInt(LightElem, "ColB", 0);
                        Color Col = Color.FromArgb(lR, lG, lB);

                        int   lX = cHplXml.GetInt(LightElem, "X", 0);
                        int   lY = cHplXml.GetInt(LightElem, "Y", 0);
                        float fZ = cHplXml.GetFloat(LightElem, "Z", 0);

                        cLight LData = new cLight(lX, lY, fZ);
                        LData.mColor     = Col;
                        LData.msName     = sName;
                        LData.mfRadius   = fRadius;
                        LData.mfSpecular = fSpecular;
                        LData.mbActive   = bActive;

                        LData.mbCastShadows    = cHplXml.GetBool(LightElem, "CastShadows", true);
                        LData.mbAffectMaterial = cHplXml.GetBool(LightElem, "AffectMaterial", true);


                        mMainForm.mLightForm.mlstLights.Add(LData);
                    }
                }
                ///////////////////////////
                ////// SOUNDSOURCE/////////
                ///////////////////////////
                if (HplMapChild.Name == "SoundSources")
                {
                    XmlElement SoundRootElem = HplMapChild;

                    foreach (XmlElement SoundElem in SoundRootElem.ChildNodes)
                    {
                        string sName = SoundElem.GetAttribute("Name");
                        int    lX    = cHplXml.GetInt(SoundElem, "X", 0);
                        int    lY    = cHplXml.GetInt(SoundElem, "Y", 0);
                        float  fZ    = cHplXml.GetFloat(SoundElem, "Z", 0);

                        cSoundSource SData = new cSoundSource(lX, lY, fZ);
                        SData.msName = sName;

                        SData.mbActive = cHplXml.GetBool(SoundElem, "Active", true);

                        SData.msSoundName = cHplXml.GetStr(SoundElem, "SoundName", "");

                        SData.mfMinDist  = cHplXml.GetFloat(SoundElem, "MinDist", 1);
                        SData.mfMaxDist  = cHplXml.GetFloat(SoundElem, "MaxDist", 100);
                        SData.mlRandom   = cHplXml.GetInt(SoundElem, "Random", 0);
                        SData.mlInterval = cHplXml.GetInt(SoundElem, "Interval", 0);
                        SData.mbLoop     = cHplXml.GetBool(SoundElem, "Loop", true);
                        SData.mbRelative = cHplXml.GetBool(SoundElem, "Relative", false);
                        SData.mfRelX     = cHplXml.GetFloat(SoundElem, "RelX", 0);
                        SData.mfRelY     = cHplXml.GetFloat(SoundElem, "RelY", 0);
                        SData.mfRelZ     = cHplXml.GetFloat(SoundElem, "RelZ", 0);
                        SData.mfVolume   = cHplXml.GetFloat(SoundElem, "Volume", 1);


                        mMainForm.mSoundForm.mlstSounds.Add(SData);
                    }
                }
                ///////////////////////////
                ////// PARTICLE SYSTEM ////
                ///////////////////////////
                if (HplMapChild.Name == "ParticleSystems")
                {
                    XmlElement PartRootElem = HplMapChild;

                    foreach (XmlElement PartElem in PartRootElem.ChildNodes)
                    {
                        string sName = PartElem.GetAttribute("Name");
                        int    lX    = cHplXml.GetInt(PartElem, "X", 0);
                        int    lY    = cHplXml.GetInt(PartElem, "Y", 0);
                        float  fZ    = cHplXml.GetFloat(PartElem, "Z", 0);

                        cParticle PartData = new cParticle(mMainForm.mParticlesForm, lX, lY, fZ);
                        PartData.msName = sName;

                        PartData.mbActive = cHplXml.GetBool(PartElem, "Active", true);

                        string sPartName = cHplXml.GetStr(PartElem, "PartName", "");
                        PartData.mlTypeNum = 0;
                        int lCount = 0;
                        foreach (cParticleType PType in mMainForm.mParticlesForm.mlstTypes)
                        {
                            if (sPartName == PType.msName)
                            {
                                PartData.mlTypeNum = lCount;
                                break;
                            }
                            lCount++;
                        }

                        PartData.mfSizeX = cHplXml.GetFloat(PartElem, "SizeX", 0);
                        PartData.mfSizeY = cHplXml.GetFloat(PartElem, "SizeY", 0);
                        PartData.mfSizeZ = cHplXml.GetFloat(PartElem, "SizeZ", 0);

                        mMainForm.mParticlesForm.mlstParticles.Add(PartData);
                    }
                }
                ///////////////////////////
                ////// AREAS //////////////
                ///////////////////////////
                if (HplMapChild.Name == "Areas")
                {
                    XmlElement AreaRootElem = HplMapChild;

                    foreach (XmlElement AreaElem in AreaRootElem.ChildNodes)
                    {
                        string sName = AreaElem.GetAttribute("Name");
                        int    lX    = cHplXml.GetInt(AreaElem, "X", 0);
                        int    lY    = cHplXml.GetInt(AreaElem, "Y", 0);
                        float  fZ    = cHplXml.GetFloat(AreaElem, "Z", 0);

                        cArea AreaData = new cArea(mMainForm.mAreasForm, lX, lY, fZ);
                        AreaData.msName = sName;

                        AreaData.mbActive = cHplXml.GetBool(AreaElem, "Active", true);

                        string sAreaName = cHplXml.GetStr(AreaElem, "AreaType", "");
                        AreaData.mlTypeNum = 0;
                        int lCount = 0;
                        foreach (cAreaType AType in mMainForm.mAreasForm.mlstTypes)
                        {
                            if (sAreaName == AType.msName)
                            {
                                AreaData.mlTypeNum = lCount;
                                break;
                            }
                            lCount++;
                        }

                        AreaData.mfWidth  = cHplXml.GetFloat(AreaElem, "Width", 0);
                        AreaData.mfHeight = cHplXml.GetFloat(AreaElem, "Height", 0);

                        AreaData.mfSizeX = cHplXml.GetFloat(AreaElem, "SizeX", 0);
                        AreaData.mfSizeY = cHplXml.GetFloat(AreaElem, "SizeY", 0);
                        AreaData.mfSizeZ = cHplXml.GetFloat(AreaElem, "SizeZ", 0);

                        mMainForm.mAreasForm.mlstAreas.Add(AreaData);
                    }
                }
                ///////////////////////////
                ////// PROP DATA///////////
                ///////////////////////////
                else if (HplMapChild.Name == "PropData")
                {
                    foreach (XmlElement PDataElem in HplMapChild.ChildNodes)
                    {
                        string    sFile    = Directory.GetCurrentDirectory() + cHplXml.GetStr(PDataElem, "File", "");
                        cPropData PropData = new cPropData(sFile);

                        PropData.LoadData();

                        mMainForm.mPropsForm.AddProp(PropData);
                    }
                }
                ///////////////////////////
                ////// ENTITIES ///////////
                ///////////////////////////
                else if (HplMapChild.Name == "Entities")
                {
                    foreach (XmlElement EntityElem in HplMapChild.ChildNodes)
                    {
                        string       sClass = EntityElem.GetAttribute("Class");
                        cImageEntity Entity = null;

                        string sName     = EntityElem.GetAttribute("Name");
                        string sDataName = EntityElem.GetAttribute("DataName");
                        bool   bActive   = cHplXml.GetBool(EntityElem, "Active", true);

                        int   lX = cHplXml.GetInt(EntityElem, "X", 0);
                        int   lY = cHplXml.GetInt(EntityElem, "Y", 0);
                        float fZ = cHplXml.GetFloat(EntityElem, "Z", 0);

                        float fWidth  = cHplXml.GetFloat(EntityElem, "Width", 0);
                        float fHeight = cHplXml.GetFloat(EntityElem, "Height", 0);
                        float fAngle  = cHplXml.GetFloat(EntityElem, "Angle", 0);

                        bool bFlipH = cHplXml.GetBool(EntityElem, "FlipH", false);
                        bool bFlipV = cHplXml.GetBool(EntityElem, "FlipV", false);

                        int lAnimNum = cHplXml.GetInt(EntityElem, "AnimNum", 0);

                        if (sClass == "Mapeditor.cProp")
                        {
                            cPropData PData = mMainForm.mPropsForm.GetData(sDataName);
                            Entity = new cProp(PData, lX, lY, fZ);
                        }

                        Entity.msName   = sName;
                        Entity.mbActive = bActive;

                        Entity.mfWidth  = fWidth;
                        Entity.mfHeight = fHeight;
                        Entity.mfAngle  = fAngle;

                        Entity.mbFlipH = bFlipH;
                        Entity.mbFlipV = bFlipV;

                        Entity.mlAnimNum = lAnimNum;

                        if (sClass == "Mapeditor.cProp")
                        {
                            mMainForm.mPropsForm.mlstProps.Add(Entity);
                        }
                    }
                }
                ///////////////////////////
                ////// TILE MAP ///////////
                ///////////////////////////
                else if (HplMapChild.Name == "TileMap")
                {
                    XmlElement TileMapElem = HplMapChild;

                    int lShadowLayerIndex = Convert.ToInt32(TileMapElem.GetAttribute("ShadowLayer"));

                    mMainForm.mlDefaultTileSize = Convert.ToInt32(TileMapElem.GetAttribute("TileSize"));

                    foreach (XmlElement TileMapChild in TileMapElem.ChildNodes)
                    {
                        ////////////////////////////
                        ////// TILE SETS ///////////
                        ////////////////////////////
                        if (TileMapChild.Name == "TileSets")
                        {
                            XmlElement TileSetRootElem = TileMapChild;

                            frmTileSets TileSetsForm = mMainForm.mTilesetsForm;
                            foreach (XmlElement TSElem in TileSetRootElem.ChildNodes)
                            {
                                string   sPath  = Directory.GetCurrentDirectory() + TSElem.GetAttribute("FileName");
                                cTileSet TSData = new cTileSet(sPath);
                                //MessageBox.Show(sPath);
                                if (TSData.LoadData() == false)
                                {
                                    MessageBox.Show("Couldn't load tileset '" + TSElem.GetAttribute("FileName") + "'!",
                                                    "Error");
                                    return(false);
                                }

                                TileSetsForm.AddTileSet(TSData);
                            }
                        }
                        ////////////////////////////
                        ////// TILE LAYERS /////////
                        ////////////////////////////
                        else if (TileMapChild.Name == "Layers")
                        {
                            XmlElement LayerRootElem = TileMapChild;

                            frmLayers LayerForm = mMainForm.mLayersForm;
                            foreach (XmlElement TLayerElem in LayerRootElem.ChildNodes)
                            {
                                string sName     = TLayerElem.GetAttribute("Name");
                                int    lWidth    = Convert.ToInt32(TLayerElem.GetAttribute("Width"));
                                int    lHeight   = Convert.ToInt32(TLayerElem.GetAttribute("Height"));
                                float  fZ        = (float)Convert.ToDouble(TLayerElem.GetAttribute("Z"));
                                bool   bCollide  = Convert.ToBoolean(TLayerElem.GetAttribute("Collide"));
                                bool   bLit      = Convert.ToBoolean(TLayerElem.GetAttribute("Lit"));
                                int    lTileSize = Convert.ToInt32(TLayerElem.GetAttribute("TileSize"));

                                cTileLayer TLayer = new cTileLayer(mMainForm.mTilesetsForm, sName, lWidth, lHeight,
                                                                   fZ, bCollide, bLit, lTileSize);


                                int lTileCount = 0;
                                foreach (XmlElement TRowElem in TLayerElem.ChildNodes)
                                {
                                    string sData      = TRowElem.GetAttribute("Data");
                                    int    lDataCount = 0;
                                    //MessageBox.Show(sData);
                                    while (lDataCount < sData.Length)
                                    {
                                        cTile T = TLayer.mvTiles[lTileCount];
                                        lDataCount = LoadTileData(T, sData, lDataCount);
                                        //MessageBox.Show("T:"+T.mlSet+" "+T.mlNum+" "+T.mlRotation+" ");
                                        lTileCount++;
                                    }
                                }

                                LayerForm.AddLayer(TLayer, -1);
                            }
                        }
                    }
                    //Set the shadow layer.
                    mMainForm.mLayersForm.objShadowLayerList.SelectedIndex = lShadowLayerIndex;
                }
            }

            ///////////////////////
            ////// UPDATE ///////////
            ///////////////////////

            //MessageBox.Show("Loaded!");
            return(true);
        }
Example #4
0
		////////////////////////////////////////////////////////////////////////
		// LOAD THE MAP
		//
		////////////////////////////////////////////////////////////////////////
		
		public bool Load(string asFileName)
		{
			XmlDocument Doc = new XmlDocument();
			try{
				Doc.Load(asFileName);
			}
			catch{
				return false;
			}
			XmlElement HplMapElem = (XmlElement)Doc.FirstChild;
			///////////////////////////
			////// HPL MAP ///////////
			///////////////////////////
			int lR,lG,lB;
			mMainForm.msMapName = cHplXml.GetStr(HplMapElem,"Name","");
			mMainForm.mlMapWidth = cHplXml.GetInt(HplMapElem,"Width",0);
			mMainForm.mlMapHeight = cHplXml.GetInt(HplMapElem,"Height",0);
			mMainForm.mfLightZ = cHplXml.GetFloat(HplMapElem,"LightZ",10);
			lR = cHplXml.GetInt(HplMapElem,"AmbColR",0);
			lG = cHplXml.GetInt(HplMapElem,"AmbColG",0);
			lB = cHplXml.GetInt(HplMapElem,"AmbColB",0);
			mMainForm.mAmbientColor = Color.FromArgb(lR,lG,lB);
				
			foreach(XmlElement HplMapChild in HplMapElem.ChildNodes)
			{
				///////////////////////////
				////// LIGHT //////////////
				///////////////////////////
				if(HplMapChild.Name == "Lights")
				{
					XmlElement LightRootElem = HplMapChild;
					
					foreach(XmlElement LightElem in LightRootElem.ChildNodes)
					{
						string sName = LightElem.GetAttribute("Name");
						bool bActive = cHplXml.GetBool(LightElem,"Active",true);
						float fRadius = cHplXml.GetFloat(LightElem,"Radius",0);
						float fSpecular = cHplXml.GetFloat(LightElem,"Specular",1);
						
						lR = cHplXml.GetInt(LightElem,"ColR",0);
						lG = cHplXml.GetInt(LightElem,"ColG",0);
						lB =cHplXml.GetInt(LightElem,"ColB",0);
						Color Col = Color.FromArgb(lR,lG,lB);

						int lX = cHplXml.GetInt(LightElem,"X",0);
						int lY = cHplXml.GetInt(LightElem,"Y",0);
						float fZ = cHplXml.GetFloat(LightElem,"Z",0);

						cLight LData = new cLight(lX,lY,fZ);
						LData.mColor = Col;
						LData.msName =sName;
						LData.mfRadius = fRadius;
						LData.mfSpecular = fSpecular;
						LData.mbActive = bActive;

						LData.mbCastShadows = cHplXml.GetBool(LightElem,"CastShadows",true);
						LData.mbAffectMaterial = cHplXml.GetBool(LightElem,"AffectMaterial",true);
				

						mMainForm.mLightForm.mlstLights.Add(LData);
					}
				}
				///////////////////////////
				////// SOUNDSOURCE/////////
				///////////////////////////
				if(HplMapChild.Name == "SoundSources")
				{
					XmlElement SoundRootElem = HplMapChild;
					
					foreach(XmlElement SoundElem in SoundRootElem.ChildNodes)
					{
						string sName = SoundElem.GetAttribute("Name");
						int lX = cHplXml.GetInt(SoundElem,"X",0);
						int lY = cHplXml.GetInt(SoundElem,"Y",0);
						float fZ = cHplXml.GetFloat(SoundElem,"Z",0);

						cSoundSource SData = new cSoundSource(lX,lY,fZ);
						SData.msName = sName;
						
						SData.mbActive = cHplXml.GetBool(SoundElem,"Active",true);

						SData.msSoundName = cHplXml.GetStr(SoundElem,"SoundName","");
						
						SData.mfMinDist = cHplXml.GetFloat(SoundElem,"MinDist",1);
						SData.mfMaxDist = cHplXml.GetFloat(SoundElem,"MaxDist",100);
						SData.mlRandom = cHplXml.GetInt(SoundElem,"Random", 0);
						SData. mlInterval = cHplXml.GetInt(SoundElem,"Interval",0);
						SData.mbLoop = cHplXml.GetBool(SoundElem,"Loop", true);
						SData.mbRelative = cHplXml.GetBool(SoundElem,"Relative", false);
						SData.mfRelX = cHplXml.GetFloat(SoundElem,"RelX",0); 
						SData.mfRelY = cHplXml.GetFloat(SoundElem,"RelY", 0); 
						SData.mfRelZ = cHplXml.GetFloat(SoundElem,"RelZ", 0);
						SData.mfVolume = cHplXml.GetFloat(SoundElem,"Volume", 1);


						mMainForm.mSoundForm.mlstSounds.Add(SData);
					}
				}
				///////////////////////////
				////// PARTICLE SYSTEM ////
				///////////////////////////
				if(HplMapChild.Name == "ParticleSystems")
				{
					XmlElement PartRootElem = HplMapChild;
					
					foreach(XmlElement PartElem in PartRootElem.ChildNodes)
					{
						string sName = PartElem.GetAttribute("Name");
						int lX = cHplXml.GetInt(PartElem,"X",0);
						int lY = cHplXml.GetInt(PartElem,"Y",0);
						float fZ = cHplXml.GetFloat(PartElem,"Z",0);

						cParticle PartData = new cParticle(mMainForm.mParticlesForm,lX,lY,fZ);
						PartData.msName = sName;
						
						PartData.mbActive = cHplXml.GetBool(PartElem,"Active",true);

						string sPartName = cHplXml.GetStr(PartElem,"PartName","");
						PartData.mlTypeNum = 0;
						int lCount=0;
						foreach(cParticleType PType in mMainForm.mParticlesForm.mlstTypes){
							if(sPartName == PType.msName){
								PartData.mlTypeNum = lCount;
								break;
							}
							lCount++;
						}
						
						PartData.mfSizeX = cHplXml.GetFloat(PartElem,"SizeX",0);
						PartData.mfSizeY = cHplXml.GetFloat(PartElem,"SizeY",0);
						PartData.mfSizeZ = cHplXml.GetFloat(PartElem,"SizeZ",0);
						
						mMainForm.mParticlesForm.mlstParticles.Add(PartData);
					}
				}
				///////////////////////////
				////// AREAS //////////////
				///////////////////////////
				if(HplMapChild.Name == "Areas")
				{
					XmlElement AreaRootElem = HplMapChild;
					
					foreach(XmlElement AreaElem in AreaRootElem.ChildNodes)
					{
						string sName = AreaElem.GetAttribute("Name");
						int lX = cHplXml.GetInt(AreaElem,"X",0);
						int lY = cHplXml.GetInt(AreaElem,"Y",0);
						float fZ = cHplXml.GetFloat(AreaElem,"Z",0);

						cArea AreaData = new cArea(mMainForm.mAreasForm,lX,lY,fZ);
						AreaData.msName = sName;
						
						AreaData.mbActive = cHplXml.GetBool(AreaElem,"Active",true);

						string sAreaName = cHplXml.GetStr(AreaElem,"AreaType","");
						AreaData.mlTypeNum = 0;
						int lCount=0;
						foreach(cAreaType AType in mMainForm.mAreasForm.mlstTypes)
						{
							if(sAreaName == AType.msName)
							{
								AreaData.mlTypeNum = lCount;
								break;
							}
							lCount++;
						}

						AreaData.mfWidth = cHplXml.GetFloat(AreaElem,"Width",0);
						AreaData.mfHeight = cHplXml.GetFloat(AreaElem,"Height",0);						
			
						AreaData.mfSizeX = cHplXml.GetFloat(AreaElem,"SizeX",0);
						AreaData.mfSizeY = cHplXml.GetFloat(AreaElem,"SizeY",0);
						AreaData.mfSizeZ = cHplXml.GetFloat(AreaElem,"SizeZ",0);
						
						mMainForm.mAreasForm.mlstAreas.Add(AreaData);
					}
				}
				///////////////////////////
				////// PROP DATA///////////
				///////////////////////////
				else if(HplMapChild.Name == "PropData")
				{
					foreach(XmlElement PDataElem in HplMapChild.ChildNodes)
					{
						string sFile = Directory.GetCurrentDirectory() + cHplXml.GetStr(PDataElem,"File","");
						cPropData PropData= new cPropData(sFile);

						PropData.LoadData();

						mMainForm.mPropsForm.AddProp(PropData);
					}
				}
				///////////////////////////
				////// ENTITIES ///////////
				///////////////////////////
				else if(HplMapChild.Name == "Entities")
				{
					foreach(XmlElement EntityElem in HplMapChild.ChildNodes)
					{
						string sClass = EntityElem.GetAttribute("Class");
						cImageEntity Entity=null;
						
						string sName = EntityElem.GetAttribute("Name");
						string sDataName = EntityElem.GetAttribute("DataName");
						bool bActive = cHplXml.GetBool(EntityElem,"Active",true);
												
						int lX = cHplXml.GetInt(EntityElem,"X",0);
						int lY = cHplXml.GetInt(EntityElem,"Y",0);
						float fZ = cHplXml.GetFloat(EntityElem,"Z",0);

						float fWidth = cHplXml.GetFloat(EntityElem,"Width",0);
						float fHeight = cHplXml.GetFloat(EntityElem,"Height",0);
						float fAngle = cHplXml.GetFloat(EntityElem,"Angle",0);

						bool bFlipH = cHplXml.GetBool(EntityElem,"FlipH",false);
						bool bFlipV = cHplXml.GetBool(EntityElem,"FlipV",false);

						int lAnimNum = cHplXml.GetInt(EntityElem,"AnimNum",0);
		
						if(sClass=="Mapeditor.cProp") {
							cPropData PData = mMainForm.mPropsForm.GetData(sDataName);
							Entity = new cProp(PData,lX,lY,fZ);
						}
						
						Entity.msName = sName;
						Entity.mbActive = bActive;

						Entity.mfWidth = fWidth;
						Entity.mfHeight = fHeight;
						Entity.mfAngle = fAngle;

						Entity.mbFlipH = bFlipH;
						Entity.mbFlipV = bFlipV;
						
						Entity.mlAnimNum = lAnimNum;
						
						if(sClass=="Mapeditor.cProp") mMainForm.mPropsForm.mlstProps.Add(Entity);
					}
				}
				///////////////////////////
				////// TILE MAP ///////////
				///////////////////////////
				else if(HplMapChild.Name == "TileMap")
				{
					XmlElement TileMapElem = HplMapChild;
					
					int lShadowLayerIndex = Convert.ToInt32(TileMapElem.GetAttribute("ShadowLayer"));

					mMainForm.mlDefaultTileSize = Convert.ToInt32(TileMapElem.GetAttribute("TileSize"));
					
					foreach(XmlElement TileMapChild in TileMapElem.ChildNodes)
					{
					
						////////////////////////////
						////// TILE SETS ///////////
						////////////////////////////
						if(TileMapChild.Name == "TileSets")
						{
							XmlElement TileSetRootElem = TileMapChild;
									
							frmTileSets TileSetsForm = mMainForm.mTilesetsForm;
							foreach(XmlElement TSElem in TileSetRootElem.ChildNodes)
							{
								string sPath = Directory.GetCurrentDirectory() + TSElem.GetAttribute("FileName");
								cTileSet TSData = new cTileSet(sPath);
								//MessageBox.Show(sPath);
								if(TSData.LoadData()==false)
								{
									MessageBox.Show("Couldn't load tileset '"+TSElem.GetAttribute("FileName")+"'!",
										"Error");
									return false;
								}
								
								TileSetsForm.AddTileSet(TSData);
							}
						}
							////////////////////////////
							////// TILE LAYERS /////////
							////////////////////////////
						else if(TileMapChild.Name == "Layers")
						{
							XmlElement LayerRootElem = TileMapChild;
							
							frmLayers LayerForm = mMainForm.mLayersForm;
							foreach(XmlElement TLayerElem in LayerRootElem.ChildNodes)
							{
								string sName = TLayerElem.GetAttribute("Name");
								int lWidth = Convert.ToInt32(TLayerElem.GetAttribute("Width"));						
								int lHeight = Convert.ToInt32(TLayerElem.GetAttribute("Height"));
								float fZ = (float)Convert.ToDouble(TLayerElem.GetAttribute("Z"));
								bool bCollide = Convert.ToBoolean(TLayerElem.GetAttribute("Collide"));
								bool bLit = Convert.ToBoolean(TLayerElem.GetAttribute("Lit"));
								int lTileSize = Convert.ToInt32(TLayerElem.GetAttribute("TileSize"));

								cTileLayer TLayer = new cTileLayer(mMainForm.mTilesetsForm,sName,lWidth,lHeight,
									fZ,bCollide, bLit,lTileSize);

														
								int lTileCount=0;
								foreach(XmlElement TRowElem in TLayerElem.ChildNodes)
								{
									string sData = TRowElem.GetAttribute("Data");
									int lDataCount =0;
									//MessageBox.Show(sData);
									while(lDataCount<sData.Length)
									{
										cTile T = TLayer.mvTiles[lTileCount];
										lDataCount = LoadTileData(T, sData, lDataCount);
										//MessageBox.Show("T:"+T.mlSet+" "+T.mlNum+" "+T.mlRotation+" ");
										lTileCount++;
									}
								}

								LayerForm.AddLayer(TLayer,-1);
							}
						}
					}
					//Set the shadow layer.
					mMainForm.mLayersForm.objShadowLayerList.SelectedIndex = lShadowLayerIndex;
				}
			}

			///////////////////////
			////// UPDATE ///////////
			///////////////////////
			
			//MessageBox.Show("Loaded!");
			return true;
		}