protected internal virtual void DrawControl() { if (!DrawControlTexture) { return; } if (!TextureValid) { CreateTexture(); } if (ControlTexture == null || ControlTexture.IsDisposed) { return; } float oldOpacity = DXManager.Opacity; DXManager.SetOpacity(Opacity); DXManager.Sprite.Draw(ControlTexture, SharpDX.Color.White, new RawRectangle(0, 0, Size.Width, Size.Height), null, new RawVector3(DisplayLocation.X, DisplayLocation.Y, 0.0f)); DXManager.SetOpacity(oldOpacity); CleanTime = CMain.Time + Settings.CleanDelay; }
protected internal virtual void DrawControl() { if (!DrawControlTexture) { return; } if (!TextureValid) { CreateTexture(); } if (ControlTexture == null || ControlTexture.Disposed) { return; } float oldOpacity = DXManager.Opacity; DXManager.SetOpacity(Opacity); DXManager.Sprite.Draw2D(ControlTexture, Point.Empty, 0F, DisplayLocation, Color.White); DXManager.SetOpacity(oldOpacity); CleanTime = CMain.Time + Settings.CleanDelay; }
public void DrawShadow2(int l, int t, int r, int b) { MirImage image = BodyLibrary?.GetImage(ArmourFrame); if (image == null) { return; } int w = (DrawX + image.OffSetX) - l; int h = (DrawY + image.OffSetY) - t; Matrix m = Matrix.Scaling(1F, 0.5f, 0); m.M21 = -0.50F; DXManager.Sprite.Transform = m * Matrix.Translation(DrawX + image.ShadowOffSetX - w + (image.Height) / 2 + h / 2, DrawY + image.ShadowOffSetY - h / 2, 0); DXManager.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.None); float oldOpacity = DXManager.Opacity; if (oldOpacity != 0.5F) { DXManager.SetOpacity(0.5F); } DXManager.Sprite.Draw(DXManager.ScratchTexture, Rectangle.FromLTRB(l, t, r, b), Vector3.Zero, Vector3.Zero, Color.Black); DXManager.Sprite.Transform = Matrix.Identity; DXManager.Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Point); if (0.5F != oldOpacity) { DXManager.SetOpacity(oldOpacity); } }
protected internal virtual void DrawControl() { if (!DrawControlTexture) { return; } if (!TextureValid) { CreateTexture(); } if (ControlTexture == null || ControlTexture.Disposed) { return; } float oldOpacity = DXManager.Opacity; DXManager.SetOpacity(Opacity); DXManager.Sprite.Draw(ControlTexture, new Rectangle(0, 0, Size.Width, Size.Height), Vector3.Zero, new Vector3?(new Vector3((float)(DisplayLocation.X), (float)(DisplayLocation.Y), 0.0f)), Color.White); CMain.DPSCounter++; DXManager.SetOpacity(oldOpacity); CleanTime = CMain.Time + Settings.CleanDelay; }
protected virtual void DrawControl() { if (!DrawControlTexture) { return; } if (!TextureValid || ControlTexture == null || ControlTexture.Disposed) { if (!CreateTexture()) { return; } } float OldOpacity = DXManager.Opacity; DXManager.SetOpacity(Opacity); DXManager.Sprite.Draw2D(ControlTexture, Point.Empty, 0F, DisplayLocation, Color.White); DXManager.SetOpacity(OldOpacity); }
public void DrawBody(bool shadow) { Surface oldSurface = DXManager.CurrentSurface; DXManager.SetSurface(DXManager.ScratchSurface); DXManager.Device.Clear(ClearFlags.Target, 0, 0, 0); DXManager.Sprite.Flush(); int l = int.MaxValue, t = int.MaxValue, r = int.MinValue, b = int.MinValue; MirImage image; switch (Direction) { case MirDirection.Up: case MirDirection.DownLeft: case MirDirection.Left: case MirDirection.UpLeft: if (!DrawWeapon) { break; } image = WeaponLibrary1?.GetImage(WeaponFrame); if (image == null) { break; } WeaponLibrary1.Draw(WeaponFrame, DrawX, DrawY, Color.White, true, 1F, ImageType.Image); l = Math.Min(l, DrawX + image.OffSetX); t = Math.Min(t, DrawY + image.OffSetY); r = Math.Max(r, image.Width + DrawX + image.OffSetX); b = Math.Max(b, image.Height + DrawY + image.OffSetY); break; default: if (!DrawWeapon) { break; } image = WeaponLibrary2?.GetImage(WeaponFrame); if (image == null) { break; } WeaponLibrary2.Draw(WeaponFrame, DrawX, DrawY, Color.White, true, 1F, ImageType.Image); l = Math.Min(l, DrawX + image.OffSetX); t = Math.Min(t, DrawY + image.OffSetY); r = Math.Max(r, image.Width + DrawX + image.OffSetX); b = Math.Max(b, image.Height + DrawY + image.OffSetY); break; } image = BodyLibrary?.GetImage(ArmourFrame); if (image != null) { BodyLibrary.Draw(ArmourFrame, DrawX, DrawY, Color.White, true, 1F, ImageType.Image); if (ArmourColour.ToArgb() != 0) { BodyLibrary.Draw(ArmourFrame, DrawX, DrawY, ArmourColour, true, 1F, ImageType.Overlay); } l = Math.Min(l, DrawX + image.OffSetX); t = Math.Min(t, DrawY + image.OffSetY); r = Math.Max(r, image.Width + DrawX + image.OffSetX); b = Math.Max(b, image.Height + DrawY + image.OffSetY); } if (HelmetShape > 0) { image = HelmetLibrary?.GetImage(HelmetFrame); if (image != null) { HelmetLibrary.Draw(HelmetFrame, DrawX, DrawY, Color.White, true, 1F, ImageType.Image); l = Math.Min(l, DrawX + image.OffSetX); t = Math.Min(t, DrawY + image.OffSetY); r = Math.Max(r, image.Width + DrawX + image.OffSetX); b = Math.Max(b, image.Height + DrawY + image.OffSetY); } } else { image = HairLibrary.GetImage(HairFrame); if (HairType > 0 && image != null) { HairLibrary.Draw(HairFrame, DrawX, DrawY, HairColour, true, 1F, ImageType.Image); l = Math.Min(l, DrawX + image.OffSetX); t = Math.Min(t, DrawY + image.OffSetY); r = Math.Max(r, image.Width + DrawX + image.OffSetX); b = Math.Max(b, image.Height + DrawY + image.OffSetY); } } switch (Direction) { case MirDirection.UpRight: case MirDirection.Right: case MirDirection.DownRight: case MirDirection.Down: if (!DrawWeapon) { break; } image = WeaponLibrary1?.GetImage(WeaponFrame); if (image == null) { break; } WeaponLibrary1.Draw(WeaponFrame, DrawX, DrawY, Color.White, true, 1F, ImageType.Image); l = Math.Min(l, DrawX + image.OffSetX); t = Math.Min(t, DrawY + image.OffSetY); r = Math.Max(r, image.Width + DrawX + image.OffSetX); b = Math.Max(b, image.Height + DrawY + image.OffSetY); break; default: if (!DrawWeapon) { break; } image = WeaponLibrary2?.GetImage(WeaponFrame); if (image == null) { break; } WeaponLibrary2.Draw(WeaponFrame, DrawX, DrawY, Color.White, true, 1F, ImageType.Image); l = Math.Min(l, DrawX + image.OffSetX); t = Math.Min(t, DrawY + image.OffSetY); r = Math.Max(r, image.Width + DrawX + image.OffSetX); b = Math.Max(b, image.Height + DrawY + image.OffSetY); break; } DXManager.SetSurface(oldSurface); float oldOpacity = DXManager.Opacity; if (shadow) { switch (CurrentAnimation) { case MirAnimation.HorseStanding: case MirAnimation.HorseWalking: case MirAnimation.HorseRunning: case MirAnimation.HorseStruck: HorseLibrary?.Draw(HorseFrame, DrawX, DrawY, Color.Black, true, 0.5F, ImageType.Shadow); break; default: DrawShadow2(l, t, r, b); break; } } if (oldOpacity != Opacity && !DXManager.Blending) { DXManager.SetOpacity(Opacity); } switch (CurrentAnimation) { case MirAnimation.HorseStanding: case MirAnimation.HorseWalking: case MirAnimation.HorseRunning: case MirAnimation.HorseStruck: switch (HorseShape) { case 0: HorseLibrary?.Draw(HorseFrame, DrawX, DrawY, Color.White, true, Opacity, ImageType.Image); break; case 1: case 2: case 3: HorseShapeLibrary?.Draw(HorseFrame, DrawX, DrawY, Color.White, true, Opacity, ImageType.Image); break; case 4: HorseShapeLibrary?.Draw(DrawFrame, DrawX, DrawY, Color.White, true, Opacity, ImageType.Image); break; case 5: HorseShapeLibrary?.Draw(DrawFrame, DrawX, DrawY, Color.White, true, Opacity, ImageType.Image); if (shadow) { HorseShapeLibrary2?.DrawBlend(DrawFrame, DrawX, DrawY, Color.White, true, Opacity, ImageType.Image); } break; } break; } DXManager.Sprite.Draw(DXManager.ScratchTexture, Rectangle.FromLTRB(l, t, r, b), Vector3.Zero, new Vector3(l, t, 0), DrawColour); CEnvir.DPSCounter++; if (oldOpacity != Opacity && !DXManager.Blending) { DXManager.SetOpacity(oldOpacity); } }
private static void RenderObjects() { int ImageIndex, FileIndex; byte AnimationFrame, AnimationTick; Size S; Point P; List <MapObject> DrawList = new List <MapObject>(); #region Objects for (int Y = MapObject.User.Location.Y - ViewRangeY; Y <= MapObject.User.Location.Y + ViewRangeY + 25; Y++) { if (Y < 0) { continue; } if (Y >= MapSize.Height) { break; } for (int X = MapObject.User.Location.X - ViewRangeX; X < MapObject.User.Location.X + ViewRangeX; X++) { if (X < 0) { continue; } if (X >= MapSize.Width) { break; } ImageIndex = M2CellInfo[X, Y].FrontImage & 0x7FFF; if (ImageIndex-- > 0) { AnimationFrame = (byte)(M2CellInfo[X, Y].AnimationFrame & 0x7F); if (AnimationFrame > 0) { AnimationTick = M2CellInfo[X, Y].AnimationTick; ImageIndex += (AnimationCount % (AnimationFrame + (AnimationFrame * AnimationTick))) / (1 + AnimationTick); } FileIndex = M2CellInfo[X, Y].FileIndex; S = Libraries.Objects[FileIndex].GetSize(ImageIndex); if (S.Width == Globals.CellWidth && S.Height == Globals.CellHeight) { continue; } P = new Point((X + Settings.PlayerOffSet.X - MapObject.User.MovePoint.X) * Globals.CellWidth + MapObject.User.MovingOffSet.X, (Y + Settings.PlayerOffSet.Y - MapObject.User.MovePoint.Y) * Globals.CellHeight + MapObject.User.MovingOffSet.Y + 32 - S.Height); if (AnimationFrame > 0) { P.Offset(Libraries.Objects[FileIndex].GetOffSet(ImageIndex)); } if (P.Y <= Settings.ScreenSize.Height) { if (AnimationFrame > 0) { Libraries.Objects[FileIndex].DrawBlend(ImageIndex, P, Color.White, false); } else { Libraries.Objects[FileIndex].Draw(ImageIndex, P, Color.White, 1F, false); } } } } for (int I = 0; I < ObjectList.Count; I++) { MapObject Ob = ObjectList[I]; if (Ob.DrawLocation.Y - Y == 0) { Ob.Draw(); } } } #endregion float OldOpacity = DXManager.Opacity; DXManager.SetOpacity(0.5F); MapObject.User.DrawBody(); MapObject.User.DrawHead(); DXManager.SetOpacity(OldOpacity); if (MapObject.MouseObject != null) { MapObject.MouseObject.DrawBlend(); } }