public frmPropertiesProp(cProp aProp) { // // Required for Windows Form Designer support // InitializeComponent(); // // TODO: Add any constructor code after InitializeComponent call // objWidthText.Text = aProp.mfWidth.ToString(); objHeightText.Text = aProp.mfHeight.ToString(); objAngleText.Text = aProp.mfAngle.ToString(); objZText.Text = aProp.mfZ.ToString(); objFlipHBox.SelectedIndex = aProp.mbFlipH?1:0; objFlipVBox.SelectedIndex = aProp.mbFlipV?1:0; objNameText.Text = aProp.msName; objActiveBox.SelectedIndex = aProp.mbActive?1:0; objAnimBox.Items.Clear(); if (aProp.mEntityData.mlFrames < 0) { objAnimBox.Items.Add("0: Default"); objAnimBox.SelectedIndex = 0; } else { for (int i = 0; i < aProp.mEntityData.mlstAnimations.Count; i++) { cEntityAnimation Anim = (cEntityAnimation)aProp.mEntityData.mlstAnimations[i]; objAnimBox.Items.Add(i + ": " + Anim.msName); } objAnimBox.SelectedIndex = aProp.mlAnimNum; } }
public override void Draw(Graphics aGfx, int alWorldX, int alWorldY, eEditMode mMode, bool abSelected) { Image Pic; Matrix Mtx = new Matrix(); PointF vRotPoint = new PointF((float)mlX - alWorldX, (float)mlY - alWorldY); float fAngle = mfAngle; if (mbFlipH) { fAngle = 360 - fAngle; } if (mbFlipV) { fAngle = 360 - fAngle; } Mtx.RotateAt(fAngle, vRotPoint, MatrixOrder.Append); PointF[] vPoints = new PointF[4]; aGfx.Transform = Mtx; if (mbFlipH) { mEntityData.mImage.RotateFlip(RotateFlipType.RotateNoneFlipX); } if (mbFlipV) { mEntityData.mImage.RotateFlip(RotateFlipType.RotateNoneFlipY); } if (mEntityData.mlFrames < 0) { Pic = mEntityData.mImage; } else { cEntityAnimation Anim = (cEntityAnimation)mEntityData.mlstAnimations[mlAnimNum]; int lFrame = (int)Anim.mlstAnimData[0]; Pic = mEntityData.mvFrameImages[lFrame]; } /*ImageAttributes Attrib = new ImageAttributes(); * Attrib.SetColorKey(Color.FromArgb(0,Color.FromArgb(0,0,0)), * Color.FromArgb(0,Color.FromArgb(1,1,1)));*/ aGfx.DrawImage(Pic, mlX - alWorldX - (int)mfWidth / 2, mlY - alWorldY - (int)mfHeight / 2, (int)mfWidth, (int)mfHeight); if (mbFlipH) { mEntityData.mImage.RotateFlip(RotateFlipType.RotateNoneFlipX); } if (mbFlipV) { mEntityData.mImage.RotateFlip(RotateFlipType.RotateNoneFlipY); } if (mMode == eEditMode.Props) { Pen RectPen; if (abSelected) { RectPen = new Pen(Color.FromArgb(150, 255, 150)); } else { RectPen = new Pen(Color.FromArgb(255, 0, 255)); } aGfx.DrawRectangle(RectPen, mlX - alWorldX - (int)mfWidth / 2, mlY - alWorldY - (int)mfHeight / 2, (int)mfWidth, (int)mfHeight); } Mtx.Reset(); aGfx.Transform = Mtx; }
public bool LoadData() { XmlDocument Doc = new XmlDocument(); try { Doc.Load(msFile); } catch { MessageBox.Show("Coldn't load file: '"+msFile+"'!"); return false; } XmlElement RootElem = (XmlElement)Doc.FirstChild; mlFrames = -1; foreach(XmlElement ChildElem in RootElem.ChildNodes) { /// MAIN ///// if(ChildElem.Name == "MAIN") { msName = cHplXml.GetStr(ChildElem,"Name",""); msRenderType = cHplXml.GetStr(ChildElem,"RenderType","Image"); msType = cHplXml.GetStr(ChildElem,"Type",""); msSubType = cHplXml.GetStr(ChildElem,"Subtype",""); } /// IMAGE ///// else if(ChildElem.Name == "IMAGE") { string sDir = cHplXml.GetStr(ChildElem,"Dir",""); string sImageName = cHplXml.GetStr(ChildElem,"Name",""); if(sDir.EndsWith("\\")==false && sDir.EndsWith("/")==false) sDir+="/"; msImageFile = sDir + sImageName; msMaterialType = cHplXml.GetStr(ChildElem,"Material",""); msMeshType = cHplXml.GetStr(ChildElem,"Mesh",""); mfStretchW = cHplXml.GetFloat(ChildElem,"StretchWidth",-1); mfStretchH = cHplXml.GetFloat(ChildElem,"StretchHeight",-1); } /// PROPERTIES ///// else if(ChildElem.Name == "PROPERTIES") { mbCastShadows = cHplXml.GetBool(ChildElem,"CastShadows",false); mbLit = cHplXml.GetBool(ChildElem,"CastShadows",true); mbCollidable = cHplXml.GetBool(ChildElem,"Collidable",false); } /// ANIMATIONS ///// else if(ChildElem.Name == "ANIMATIONS") { mlFrames = cHplXml.GetInt(ChildElem,"Frames",1); foreach(XmlElement AnimElem in ChildElem.ChildNodes) { string sName = cHplXml.GetStr(AnimElem,"Name",""); float fSpeed = cHplXml.GetFloat(AnimElem,"Speed",1); ArrayList lstAnim; lstAnim = new ArrayList(); cHplXml.GetIntList(AnimElem,"Data",lstAnim); cEntityAnimation Animation; Animation = new cEntityAnimation(sName, fSpeed); Animation.mlstAnimData = lstAnim; mlstAnimations.Add(Animation); } } } if(mlFrames<0) { mImage = LoadImage(msImageFile); if(mImage==null)return false; } else { mvFrameImages = new Image[mlFrames]; for(int i=0;i<mlFrames;i++) { int lNum = i+1; string sEnd = lNum<10? "0"+lNum.ToString() : lNum.ToString(); string sFile = msImageFile+sEnd; mvFrameImages[i] = LoadImage(sFile); if(mvFrameImages[i]==null) return false; } mImage = mvFrameImages[0]; } return true; }
public bool LoadData() { XmlDocument Doc = new XmlDocument(); try { Doc.Load(msFile); } catch { MessageBox.Show("Coldn't load file: '" + msFile + "'!"); return(false); } XmlElement RootElem = (XmlElement)Doc.FirstChild; mlFrames = -1; foreach (XmlElement ChildElem in RootElem.ChildNodes) { /// MAIN ///// if (ChildElem.Name == "MAIN") { msName = cHplXml.GetStr(ChildElem, "Name", ""); msRenderType = cHplXml.GetStr(ChildElem, "RenderType", "Image"); msType = cHplXml.GetStr(ChildElem, "Type", ""); msSubType = cHplXml.GetStr(ChildElem, "Subtype", ""); } /// IMAGE ///// else if (ChildElem.Name == "IMAGE") { string sDir = cHplXml.GetStr(ChildElem, "Dir", ""); string sImageName = cHplXml.GetStr(ChildElem, "Name", ""); if (sDir.EndsWith("\\") == false && sDir.EndsWith("/") == false) { sDir += "/"; } msImageFile = sDir + sImageName; msMaterialType = cHplXml.GetStr(ChildElem, "Material", ""); msMeshType = cHplXml.GetStr(ChildElem, "Mesh", ""); mfStretchW = cHplXml.GetFloat(ChildElem, "StretchWidth", -1); mfStretchH = cHplXml.GetFloat(ChildElem, "StretchHeight", -1); } /// PROPERTIES ///// else if (ChildElem.Name == "PROPERTIES") { mbCastShadows = cHplXml.GetBool(ChildElem, "CastShadows", false); mbLit = cHplXml.GetBool(ChildElem, "CastShadows", true); mbCollidable = cHplXml.GetBool(ChildElem, "Collidable", false); } /// ANIMATIONS ///// else if (ChildElem.Name == "ANIMATIONS") { mlFrames = cHplXml.GetInt(ChildElem, "Frames", 1); foreach (XmlElement AnimElem in ChildElem.ChildNodes) { string sName = cHplXml.GetStr(AnimElem, "Name", ""); float fSpeed = cHplXml.GetFloat(AnimElem, "Speed", 1); ArrayList lstAnim; lstAnim = new ArrayList(); cHplXml.GetIntList(AnimElem, "Data", lstAnim); cEntityAnimation Animation; Animation = new cEntityAnimation(sName, fSpeed); Animation.mlstAnimData = lstAnim; mlstAnimations.Add(Animation); } } } if (mlFrames < 0) { mImage = LoadImage(msImageFile); if (mImage == null) { return(false); } } else { mvFrameImages = new Image[mlFrames]; for (int i = 0; i < mlFrames; i++) { int lNum = i + 1; string sEnd = lNum < 10? "0" + lNum.ToString() : lNum.ToString(); string sFile = msImageFile + sEnd; mvFrameImages[i] = LoadImage(sFile); if (mvFrameImages[i] == null) { return(false); } } mImage = mvFrameImages[0]; } return(true); }