public static void DrawText(Font font, string text, int posX, int posY, Color color) { Rectangle rec = font.MeasureText(null, text, FontDrawFlags.Center); font.DrawText(null, text, posX + 1 + rec.X, posY + 1, Color.Black); font.DrawText(null, text, posX + rec.X, posY + 1, Color.Black); font.DrawText(null, text, posX - 1 + rec.X, posY - 1, Color.Black); font.DrawText(null, text, posX + rec.X, posY - 1, Color.Black); font.DrawText(null, text, posX + rec.X, posY, color); }
public void Draw() { if (Font == null || Font.IsDisposed || Drawing.Direct3DDevice == null || Drawing.Direct3DDevice.IsDisposed || Height < 1 || string.IsNullOrEmpty(Message)) { return; } //using (Font) { Font?.DrawText(null, Message, X, Y, Color); } }
public static void DrawText(Font aFont, String aText, int aPosX, int aPosY, SharpDX.Color aColor) { aFont.DrawText(null, aText, aPosX + 2, aPosY + 2, aColor != SharpDX.Color.Black ? SharpDX.Color.Black : SharpDX.Color.White); aFont.DrawText(null, aText, aPosX, aPosY, aColor); }
private void DrawText(Font font, Vector2 pos, string text, ColorBGRA color) { font.DrawText(null, text, new Rectangle((int) pos.X, (int) pos.Y, 0, 0), SharpDX.Direct3D9.FontDrawFlags.NoClip, color); }
public static void DrawText(Font vFont, string vText, float vPosX, float vPosY, ColorBGRA vColor, bool shadow = false) { if (shadow) { vFont.DrawText(null, vText, (int)vPosX + 2, (int)vPosY + 2, SharpDX.Color.Black); } vFont.DrawText(null, vText, (int)vPosX, (int)vPosY, vColor); }
/// <summary> /// Implementation of capturing from the render target of the Direct3D9 Device (or DeviceEx) /// </summary> /// <param name="device"></param> void DoCaptureRenderTarget(Device device, string hook) { this.Frame(); try { #region Screenshot Request // Single frame capture request if (this.Request != null) { DateTime start = DateTime.Now; try { using (Surface renderTargetTemp = device.GetRenderTarget(0)) { int width, height; // TODO: If resizing the captured image is required it can be adjusted here //if (renderTargetTemp.Description.Width > 1280) //{ // width = 1280; // height = (int)Math.Round((renderTargetTemp.Description.Height * (1280.0 / renderTargetTemp.Description.Width))); //} //else { width = renderTargetTemp.Description.Width; height = renderTargetTemp.Description.Height; } // First ensure we have a Surface to the render target data into if (_renderTarget == null) { // Create offscreen surface to use as copy of render target data using (SwapChain sc = device.GetSwapChain(0)) { _renderTarget = Surface.CreateOffscreenPlain(device, width, height, sc.PresentParameters.BackBufferFormat, Pool.SystemMemory); } } // Create our resolved surface (resizing if necessary and to resolve any multi-sampling) using (Surface resolvedSurface = Surface.CreateRenderTarget(device, width, height, renderTargetTemp.Description.Format, MultisampleType.None, 0, false)) { // Resize from Render Surface to resolvedSurface device.StretchRectangle(renderTargetTemp, resolvedSurface, TextureFilter.None); // Get Render Data device.GetRenderTargetData(resolvedSurface, _renderTarget); } } if (Request != null) ProcessRequest(); } finally { // We have completed the request - mark it as null so we do not continue to try to capture the same request // Note: If you are after high frame rates, consider implementing buffers here to capture more frequently // and send back to the host application as needed. The IPC overhead significantly slows down // the whole process if sending frame by frame. Request = null; } DateTime end = DateTime.Now; this.DebugMessage(hook + ": Capture time: " + (end - start).ToString()); } #endregion if (this.Config.ShowOverlay) { #region Draw frame rate // TODO: font needs to be created and then reused, not created each frame! using (SharpDX.Direct3D9.Font font = new SharpDX.Direct3D9.Font(device, new FontDescription() { Height = 16, FaceName = "Arial", Italic = false, Width = 0, MipLevels = 1, CharacterSet = FontCharacterSet.Default, OutputPrecision = FontPrecision.Default, Quality = FontQuality.Antialiased, PitchAndFamily = FontPitchAndFamily.Default | FontPitchAndFamily.DontCare, Weight = FontWeight.Bold })) { if (this.FPS.GetFPS() >= 1) { font.DrawText(null, String.Format("{0:N0} fps", this.FPS.GetFPS()), 5, 5, SharpDX.Color.Red); } if (this.TextDisplay != null && this.TextDisplay.Display) { font.DrawText(null, this.TextDisplay.Text, 5, 25, new SharpDX.ColorBGRA(255, 0, 0, (byte)Math.Round((Math.Abs(1.0f - TextDisplay.Remaining) * 255f)))); } } #endregion } } catch (Exception e) { DebugMessage(e.ToString()); } }
static void Main() { var form = new RenderForm("SharpDX - Direct3D9 Font Sample"); int width = form.ClientSize.Width; int height = form.ClientSize.Height; var device = new Device(new Direct3D(), 0, DeviceType.Hardware, form.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters(width, height) { PresentationInterval = PresentInterval.One }); // Initialize the Font FontDescription fontDescription = new FontDescription() { Height = 72, Italic = false, CharacterSet = FontCharacterSet.Ansi, FaceName = "Arial", MipLevels = 0, OutputPrecision = FontPrecision.TrueType, PitchAndFamily = FontPitchAndFamily.Default, Quality = FontQuality.ClearType, Weight = FontWeight.Bold }; var font = new Font(device, fontDescription); var displayText = "Direct3D9 Text!"; // Measure the text to display var fontDimension = font.MeasureText(null, displayText, new Rectangle(0, 0, width, height), FontDrawFlags.Center | FontDrawFlags.VerticalCenter); int xDir = 1; int yDir = 1; RenderLoop.Run(form, () => { device.Clear(ClearFlags.Target, Color.Black, 1.0f, 0); device.BeginScene(); // Make the text boucing on the screen limits if ((fontDimension.Right + xDir) > width) xDir = -1; else if ((fontDimension.Left + xDir) <= 0) xDir = 1; if ((fontDimension.Bottom + yDir) > height) yDir = -1; else if ((fontDimension.Top + yDir) <= 0) yDir = 1; fontDimension.Left += (int)xDir; fontDimension.Top += (int)yDir; fontDimension.Bottom += (int)yDir; fontDimension.Right += (int)xDir; // Draw the text font.DrawText(null, displayText, fontDimension, FontDrawFlags.Center | FontDrawFlags.VerticalCenter, Color.White); device.EndScene(); device.Present(); }); }
public static void DrawText(Font font, String text, int posX, int posY, Color color) { Rectangle rec = font.MeasureText(null, text, FontDrawFlags.Center); font.DrawText(null, text, posX + 1 + rec.X, posY + 1, SharpColor.White); }
public static void DrawFontTextScreen(Font vFont, string vText, float vPosX, float vPosY, ColorBGRA vColor) { vFont.DrawText(null, vText, (int)vPosX, (int)vPosY, vColor); }
private static void Drawing_OnEndScene(EventArgs args) { if (Drawing.Direct3DDevice9 == null || !(Menu.Item("Hide/Show").GetValue <bool>())) { return; } if (_isPressedFirst == false) { return; } //textFont.DrawText(null, ".", 1417, 817, SharpDX.Color.Yellow); //For Testing Purposes //Game.PrintMessage("<font color='#00aaff'>" + String.Format("{0, -2} | {1, -4} | {2, -3}% | {3, -4}", p.ID, mmr, wr, role), MessageType.ChatMessage); List <Player> players = ObjectManager.GetEntities <Player>().Where(x => x.Team != Team.Observer).ToList(); if (_isDisplayedFirst) { //Panel Positions. int textPosX = 1435 + Menu.Item("BarPosX").GetValue <Slider>().Value; int textPosY = 850 + Menu.Item("BarPosY").GetValue <Slider>().Value; int horDist = 60; int boxDist = 15; //Distance of Box int vertDist = hText; //Header textFont.DrawText(null, "MMR | WIN % | BEST HERO", textPosX, textPosY - vertDist, SharpDX.Color.White); SharpDX.Color textColor = SharpDX.Color.White; foreach (Player player in players) { //Player Color. SharpDX.Color playerColor = SelectColor(player.Id); string mmr; string wr; string bestHero; if (player.Team == Team.Radiant) { //Radiant text position. Vector2 startPosMMRR = new Vector2(textPosX, textPosY + player.TeamSlot * vertDist); Vector2 startPosWRR = new Vector2(textPosX + 1 * horDist, textPosY + player.TeamSlot * vertDist); Vector2 startPosRoleR = new Vector2(textPosX + 2 * horDist, textPosY + player.TeamSlot * vertDist); if (BestHeroesDict.TryGetValue(player.PlayerSteamId, out bestHero)) { //Console.WriteLine(BestHeroesDict[p.PlayerSteamId ][0]); textFont.DrawText(null, bestHero, (int)startPosRoleR.X, (int)startPosRoleR.Y, textColor); } if (MMRDict.TryGetValue(player.PlayerSteamId, out mmr)) { textFont.DrawText(null, "🔲", (int)startPosMMRR.X - boxDist, (int)startPosMMRR.Y, playerColor); textFont.DrawText(null, mmr, (int)startPosMMRR.X, (int)startPosMMRR.Y, textColor); } if (WinRateDict.TryGetValue(player.PlayerSteamId, out wr)) { textFont.DrawText(null, wr + "%", (int)startPosWRR.X, (int)startPosWRR.Y, textColor); } } else if (player.Team == Team.Dire) { //Dire text position. Vector2 startPosMMRD = new Vector2(textPosX + 5 * horDist, textPosY + player.TeamSlot * vertDist); Vector2 startPosWRD = new Vector2(textPosX + 6 * horDist, textPosY + player.TeamSlot * vertDist); Vector2 startPosRoleD = new Vector2(textPosX + 7 * horDist, textPosY + player.TeamSlot * vertDist); if (BestHeroesDict.TryGetValue(player.PlayerSteamId, out bestHero)) { //Console.WriteLine(BestHeroesDict[p.PlayerSteamId ][0]); textFont.DrawText(null, bestHero, (int)startPosRoleD.X, (int)startPosRoleD.Y, textColor); } if (MMRDict.TryGetValue(player.PlayerSteamId, out mmr)) { textFont.DrawText(null, "🔲", (int)startPosMMRD.X - boxDist, (int)startPosMMRD.Y, playerColor); textFont.DrawText(null, mmr, (int)startPosMMRD.X, (int)startPosMMRD.Y, textColor); } if (WinRateDict.TryGetValue(player.PlayerSteamId, out wr)) { textFont.DrawText(null, wr + "%", (int)startPosWRD.X, (int)startPosWRD.Y, textColor); } } else { return; } } return; } }
public static void DrawFontTextMap(Font vFont, string vText, Vector3 Pos, ColorBGRA vColor) { var wts = Drawing.WorldToScreen(Pos); vFont.DrawText(null, vText, (int)wts[0], (int)wts[1], vColor); }
/// <summary> /// Draws an arrow. /// </summary> /// <param name="s"> /// The string. /// </param> /// <param name="position"> /// The position. /// </param> /// <param name="item"> /// The item. /// </param> /// <param name="color"> /// The color. /// </param> internal static void DrawArrow(string s, Vector2 position, MenuItem item, Color color) { DrawBox(position, item.Height, item.Height, Color.FromArgb(0, 37, 53), 1, color); Font.DrawText(null, s, new Rectangle((int)(position.X), (int)item.Position.Y, item.Height, item.Height), FontDrawFlags.VerticalCenter | FontDrawFlags.Center, new ColorBGRA(255, 255, 255, 255)); }
void DoCaptureRenderTarget(Device device, string hook) { this.Frame(); try { #region Screenshot Request // Single frame capture request //if (this.Request != null) //{ // DateTime start = DateTime.Now; // try // { // using (Surface renderTargetTemp = device.GetRenderTarget(0)) // { // int width, height; // // TODO: If resizing the captured image is required it can be adjusted here // //if (renderTargetTemp.Description.Width > 1280) // //{ // // width = 1280; // // height = (int)Math.Round((renderTargetTemp.Description.Height * (1280.0 / renderTargetTemp.Description.Width))); // //} // //else // { // width = renderTargetTemp.Description.Width; // height = renderTargetTemp.Description.Height; // } // // First ensure we have a Surface to the render target data into // if (_renderTarget == null) // { // // Create offscreen surface to use as copy of render target data // using (SwapChain sc = device.GetSwapChain(0)) // { // _renderTarget = Surface.CreateOffscreenPlain(device, width, height, sc.PresentParameters.BackBufferFormat, Pool.SystemMemory); // } // } // // Create our resolved surface (resizing if necessary and to resolve any multi-sampling) // using (Surface resolvedSurface = Surface.CreateRenderTarget(device, width, height, renderTargetTemp.Description.Format, MultisampleType.None, 0, false)) // { // // Resize from Render Surface to resolvedSurface // device.StretchRectangle(renderTargetTemp, resolvedSurface, TextureFilter.None); // // Get Render Data // device.GetRenderTargetData(resolvedSurface, _renderTarget); // } // } // if (Request != null) // ProcessRequest(); // } // finally // { // // We have completed the request - mark it as null so we do not continue to try to capture the same request // // Note: If you are after high frame rates, consider implementing buffers here to capture more frequently // // and send back to the host application as needed. The IPC overhead significantly slows down // // the whole process if sending frame by frame. // Request = null; // } // DateTime end = DateTime.Now; // this.DebugMessage(hook + ": Capture time: " + (end - start).ToString()); //} #endregion if (this.Config.ShowOverlay) { #region Draw frame rate // TODO: font needs to be created and then reused, not created each frame! using (SharpDX.Direct3D9.Font font = new SharpDX.Direct3D9.Font(device, new FontDescription() { Height = 16, FaceName = "Arial", Italic = false, Width = 0, MipLevels = 1, CharacterSet = FontCharacterSet.Default, OutputPrecision = FontPrecision.Default, Quality = FontQuality.Antialiased, PitchAndFamily = FontPitchAndFamily.Default | FontPitchAndFamily.DontCare, Weight = FontWeight.Bold })) { if (this.FPS.GetFPS() >= 1) { font.DrawText(null, String.Format("{0:N0} fps", this.FPS.GetFPS()), 5, 5, SharpDX.Color.Red); } font.DrawText(null, this.ProcessLoad.Text, 5, 20, SharpDX.Color.Red); if (this.TextDisplay != null && this.TextDisplay.Display) { font.DrawText(null, this.TextDisplay.Text, 5, 25, new SharpDX.ColorBGRA(255, 0, 0, (byte)Math.Round((Math.Abs(1.0f - TextDisplay.Remaining) * 255f)))); } } #endregion } } catch (Exception e) { DebugMessage(e.ToString()); } }
static void Drawing_OnDraw(EventArgs args) { if (Drawing.Direct3DDevice == null || Drawing.Direct3DDevice.IsDisposed || !Menu.Item("enabled").GetValue <bool>()) { return; } try { if (Sprite.IsDisposed) { return; } moveSpeed = Menu.Item("moveVal").GetValue <Slider>().Value; if (Menu.Item("drawHUD").GetValue <bool>()) { Sprite.Begin(); Sprite.Draw(HUD, new ColorBGRA(255, 255, 255, 255), null, new Vector3(-startX, -startY, 0)); Sprite.End(); } int newX = startX + 13; int newY = startY + 25; bool trackAll = Menu.Item("trackAll").GetValue <bool>(); var heroes = trackAll ? ObjectManager.Get <Obj_AI_Hero>().Where(hero => hero.IsValid && hero.IsEnemy) : ObjectManager.Get <Obj_AI_Hero>().Where(hero => CCHeros.HasChampion(hero.ChampionName) && hero.IsValid && hero.IsEnemy); foreach (Obj_AI_Hero hero in heroes) { CCHero ccHero = CCHeros.GetChampion(hero.ChampionName); if (trackAll || ccHero.CCSpells.SpellSlots.Length != 0) { Sprite.Begin(); Sprite.Draw(ccHero.Icon, new ColorBGRA(255, 255, 255, 255), null, new Vector3(-newX, -newY, 0)); Sprite.End(); } if (ccHero.CCBuff != null) { newX += 32 + 5; Sprite.Begin(); BuffInstance buff = null; buff = hero.Buffs.First(x => x.Name == ccHero.CCBuff.Name); if (buff != null) { Sprite.Draw(ccHero.CCBuff.BuffIcon, new ColorBGRA(255, 255, 255, 255), null, new Vector3(-newX, -newY, 0)); } else { Sprite.Draw(ccHero.CCBuff.BuffIcon, new ColorBGRA(255, 55, 55, 255), null, new Vector3(-newX, -newY, 0)); } Sprite.End(); } if (trackAll || ccHero.CCSpells.SpellSlots.Length != 0) { SpellSlot[] spellSlots = trackAll ? new SpellSlot[] { SpellSlot.Q, SpellSlot.W, SpellSlot.E, SpellSlot.R } : ccHero.CCSpells.SpellSlots; foreach (SpellSlot spellSlot in spellSlots) { newX += 32 + 5; string slot = spellSlot.ToString(); bool notAvailable = (hero.Spellbook.GetSpell(spellSlot).State == SpellState.NotLearned || hero.Spellbook.GetSpell(spellSlot).State == SpellState.NoMana); float expires = hero.Spellbook.GetSpell(spellSlot).CooldownExpires - Game.Time; float smallExpires = (float)Math.Round(expires, 1); Text.DrawText(null, slot, newX, newY, notAvailable ? new ColorBGRA(33, 33, 33, 255) : expires <= 0 ? new ColorBGRA(0, 255, 0, 255) : new ColorBGRA(255, 0, 0, 255)); if (smallExpires > 0) { SmallText.DrawText(null, smallExpires.ToString(), newX, newY - 3, new ColorBGRA(0, 0, 0, 255)); } } } newX = startX + 13; newY += 32 + 7; } } catch (Exception ex) { Game.PrintChat("Sprite Exception: " + ex.Message); } }
public static void DrawFontTextMap(Font vFont, string vText, Vector3 Pos, ColorBGRA vColor) { var wts = Drawing.WorldToScreen(Pos); vFont.DrawText(null, vText, (int)wts[0] , (int)wts[1], vColor); }
/// <summary> /// Implementation of capturing from the render target of the Direct3D9 Device (or DeviceEx) /// </summary> /// <param name="device"></param> void DoCaptureRenderTarget(Device device, string hook) { try { #region Screenshot Request // Single frame capture request if (this.Request != null) { DateTime start = DateTime.Now; try { using (Surface renderTargetTemp = device.GetRenderTarget(0)) { int width, height; // TODO: If resizing the captured image is required it can be adjusted here //if (renderTargetTemp.Description.Width > 1280) //{ // width = 1280; // height = (int)Math.Round((renderTargetTemp.Description.Height * (1280.0 / renderTargetTemp.Description.Width))); //} //else { width = renderTargetTemp.Description.Width; height = renderTargetTemp.Description.Height; } // First ensure we have a Surface to the render target data into if (_renderTarget == null) { // Create offscreen surface to use as copy of render target data using (SwapChain sc = device.GetSwapChain(0)) { _renderTarget = Surface.CreateOffscreenPlain(device, width, height, sc.PresentParameters.BackBufferFormat, Pool.SystemMemory); } } // Create our resolved surface (resizing if necessary and to resolve any multi-sampling) using ( Surface resolvedSurface = Surface.CreateRenderTarget(device, width, height, renderTargetTemp.Description.Format, MultisampleType.None, 0, false)) { // Resize from Render Surface to resolvedSurface device.StretchRectangle(renderTargetTemp, resolvedSurface, TextureFilter.None); // Get Render Data device.GetRenderTargetData(resolvedSurface, _renderTarget); } } if (Request != null) ProcessRequest(); } finally { // We have completed the request - mark it as null so we do not continue to try to capture the same request // Note: If you are after high frame rates, consider implementing buffers here to capture more frequently // and send back to the host application as needed. The IPC overhead significantly slows down // the whole process if sending frame by frame. Request = null; } DateTime end = DateTime.Now; this.DebugMessage(hook + ": Capture time: " + (end - start).ToString()); } #endregion if (this.Config.ShowOverlay) { // SHIT this.Frame(); #region Draw frame rate // TODO: font needs to be created and then reused, not created each frame! using (var font = new SharpDX.Direct3D9.Font(device, new FontDescription() { Height = 26, FaceName = "Quartz MS", Italic = false, Width = 0, MipLevels = 1, CharacterSet = FontCharacterSet.Default, OutputPrecision = FontPrecision.Default, Quality = FontQuality.Antialiased, PitchAndFamily = FontPitchAndFamily.Default | FontPitchAndFamily.DontCare, Weight = FontWeight.Normal })) { // Make a Texture from a file... using (FileStream myFileStream = new FileStream(@"baronbutton.png", System.IO.FileMode.Open)) { mytexStream = SharpDX.Direct3D9.Texture.FromStream(device, myFileStream); } Sprite spritezor = new SharpDX.Direct3D9.Sprite(device); spritezor.Begin(SharpDX.Direct3D9.SpriteFlags.None); var baronPos = new Vector3(1476, 812, 0); spritezor.Draw(mytexStream, new ColorBGRA(0xffffffff), null, null, baronPos); // Display always... if (this.Config.TestThisShit != 0) { // Draw sprite... spritezor.End(); spritezor.Dispose(); // Oritinal Text before sprites worked... //font.DrawText(null, "Timer 1", 5, 10, SharpDX.Color.Lime); } // Display on Timer... if (this.TextDisplay != null && this.TextDisplay.Display) { font.DrawText(null, this.TextDisplay.Text, 1477, 870, new SharpDX.ColorBGRA(255, 0, 0, 255)); // Alternate font for timers pulsed with alpha fading between ticks... // font.DrawText(null, this.TextDisplay.Text, 5, 25, new SharpDX.ColorBGRA(255, 0, 0, (byte)Math.Round((Math.Abs(1.0f - TextDisplay.Remaining) * 255f)))); } /* DXHookD3D9 Original statements to draw the FPS... if (this.FPS.GetFPS() >= 1) { font.DrawText(null, String.Format("{0:N0} fps", this.FPS.GetFPS()), 5, 5, SharpDX.Color.Red); } if (this.TextDisplay != null && this.TextDisplay.Display) { font.DrawText(null, this.TextDisplay.Text, 5, 25, new SharpDX.ColorBGRA(255, 0, 0, (byte)Math.Round((Math.Abs(1.0f - TextDisplay.Remaining) * 255f)))); } */ } #endregion } } catch (Exception e) { DebugMessage(e.ToString()); } }
private void Drawing_OnDraw(EventArgs args) { if (!getCheckBoxItem(Menu, "showRecalls") || Drawing.Direct3DDevice == null || Drawing.Direct3DDevice.IsDisposed) { return; } bool indicated = false; float fadeout = 1f; int count = 0; foreach (EnemyInfo enemyInfo in EnemyInfo.Where(x => x.Player.IsValid <AIHeroClient>() && x.RecallInfo.ShouldDraw() && !x.Player.IsDead && //maybe redundant x.RecallInfo.GetRecallCountdown() > 0).OrderBy(x => x.RecallInfo.GetRecallCountdown())) { if (!enemyInfo.RecallInfo.LockedTarget) { fadeout = 1f; Color color = Color.White; if (enemyInfo.RecallInfo.WasAborted()) { fadeout = enemyInfo.RecallInfo.GetDrawTime() / (float)enemyInfo.RecallInfo.FADEOUT_TIME; color = Color.Yellow; } DrawRect(BarX, BarY, (int)(Scale * enemyInfo.RecallInfo.GetRecallCountdown()), BarHeight, 1, Color.FromArgb((int)(100f * fadeout), Color.White)); DrawRect(BarX + Scale * enemyInfo.RecallInfo.GetRecallCountdown() - 1, BarY - SeperatorHeight, 0, SeperatorHeight + 1, 1, Color.FromArgb((int)(255f * fadeout), color)); Text.DrawText(null, enemyInfo.Player.ChampionName, (int)BarX + (int)(Scale * enemyInfo.RecallInfo.GetRecallCountdown() - (float)(enemyInfo.Player.ChampionName.Length * Text.Description.Width) / 2), (int)BarY - SeperatorHeight - Text.Description.Height - 1, new ColorBGRA(color.R, color.G, color.B, (byte)(color.A * fadeout))); } else { if (!indicated && enemyInfo.RecallInfo.EstimatedShootT != 0) { indicated = true; DrawRect(BarX + Scale * enemyInfo.RecallInfo.EstimatedShootT, BarY + SeperatorHeight + BarHeight - 3, 0, SeperatorHeight * 2, 2, Color.Orange); } DrawRect(BarX, BarY, (int)(Scale * enemyInfo.RecallInfo.GetRecallCountdown()), BarHeight, 1, Color.FromArgb(255, Color.Red)); DrawRect(BarX + Scale * enemyInfo.RecallInfo.GetRecallCountdown() - 1, BarY + SeperatorHeight + BarHeight - 3, 0, SeperatorHeight + 1, 1, Color.IndianRed); Text.DrawText(null, enemyInfo.Player.ChampionName, (int)BarX + (int)(Scale * enemyInfo.RecallInfo.GetRecallCountdown() - (float)(enemyInfo.Player.ChampionName.Length * Text.Description.Width) / 2), (int)BarY + SeperatorHeight + Text.Description.Height / 2, new ColorBGRA(255, 92, 92, 255)); } count++; } /* * Show in a red rectangle right next to the normal bar the names of champs which can be killed (when they are not recalling yet) * Requires calculating the damages (make more functions!) * * var BaseUltableEnemies = EnemyInfo.Where(x => * x.Player.IsValid<AIHeroClient>() && * !x.RecallInfo.ShouldDraw() && * !x.Player.IsDead && //maybe redundant * x.RecallInfo.GetRecallCountdown() > 0 && x.RecallInfo.LockedTarget).OrderBy(x => x.RecallInfo.GetRecallCountdown());*/ if (count > 0) { if (count != 1) //make the whole bar fadeout when its only 1 { fadeout = 1f; } DrawRect(BarX, BarY, BarWidth, BarHeight, 1, Color.FromArgb((int)(40f * fadeout), Color.White)); DrawRect(BarX - 1, BarY + 1, 0, BarHeight, 1, Color.FromArgb((int)(255f * fadeout), Color.White)); DrawRect(BarX - 1, BarY - 1, BarWidth + 2, 1, 1, Color.FromArgb((int)(255f * fadeout), Color.White)); DrawRect(BarX - 1, BarY + BarHeight, BarWidth + 2, 1, 1, Color.FromArgb((int)(255f * fadeout), Color.White)); DrawRect(BarX + 1 + BarWidth, BarY + 1, 0, BarHeight, 1, Color.FromArgb((int)(255f * fadeout), Color.White)); } }
public static void DrawText(Font font, String text, int posX, int posY, Color color) { if (font == null || font.IsDisposed) { throw new SharpDXException(""); return; } Rectangle rec = font.MeasureText(null, text, FontDrawFlags.Center); font.DrawText(null, text, posX + 1 + rec.X, posY, Color.Black); font.DrawText(null, text, posX + 1 + rec.X, posY + 1, Color.Black); font.DrawText(null, text, posX + rec.X, posY + 1, Color.Black); font.DrawText(null, text, posX - 1 + rec.X, posY, Color.Black); font.DrawText(null, text, posX - 1 + rec.X, posY - 1, Color.Black); font.DrawText(null, text, posX + rec.X, posY - 1, Color.Black); font.DrawText(null, text, posX + rec.X, posY, color); }
private void DrawText(Font font, Vector2 pos, string text, ColorBGRA color) { font.DrawText(null, text, new Rectangle((int)pos.X, (int)pos.Y, 0, 0), SharpDX.Direct3D9.FontDrawFlags.NoClip, color); }
private static void Drawing_OnEndScene(EventArgs args) { if (Drawing.Direct3DDevice == null || Drawing.Direct3DDevice.IsDisposed || Game.Mode != GameMode.Running) { return; } try { if (Sprite.IsDisposed) { return; } if (Misc.getsetwebsite() == "lolnexus") { foreach (Lolnexus.Infoloading infoloading in Lolnexus.Ranksloading.ToList()) { var indicator = new Misc.HpBarIndicator { Unit = infoloading.herohandle }; X = (int)indicator.Position.X; Y = (int)indicator.Position.Y; var startX = X + 50; var startY = Y - 60; if (Misc.Config.Item("enablerank").GetValue <bool>()) { Text.DrawText(null, infoloading.soloqrank, startX + (15 - infoloading.soloqrank.Length * 4) / 2, startY, Misc.ColorRank(infoloading.soloqrank)); } if (Misc.Config.Item("enablekdaratio").GetValue <bool>()) { Text.DrawText( null, "KDA: " + infoloading.kda, startX + (15 - infoloading.soloqrank.Length * 4) / 2, startY + 15, Misc.ColorRank(infoloading.soloqrank)); } } } if (Misc.getsetwebsite() == "lolskill") { foreach (LolSkill.Infoloading infoloading in LolSkill.Ranksloading.ToList()) { var indicator = new Misc.HpBarIndicator { Unit = infoloading.herohandle }; X = (int)indicator.Position.X; Y = (int)indicator.Position.Y; var startX = X + 50; var startY = Y - 60; Text.DrawText( null, infoloading.soloqrank, startX + (15 - infoloading.soloqrank.Length * 4) / 2, startY + 6, Misc.ColorRank(infoloading.soloqrank)); } } if (Misc.getsetwebsite() == "opgg") { foreach (OPGGLIVE.Info info in OPGGLIVE.Ranks) { var indicator = new Misc.HpBarIndicator { Unit = info.herohandle }; X = (int)indicator.Position.X; Y = (int)indicator.Position.Y; var startX = X + 50; var startY = Y - 70; if (Misc.Config.Item("enablerank").GetValue <bool>()) { Text.DrawText( null, info.Ranking, startX + (15 - info.Ranking.Length * 4) / 2, startY + 5, Misc.ColorRank(info.Ranking)); } if (Misc.Config.Item("enablewinratio").GetValue <bool>()) { Text.DrawText( null, "Ranked: " + info.rankedwinrate + " (" + info.rankedwins + " wins)", startX + (15 - info.Ranking.Length * 4) / 2, startY + 20, Misc.ColorRank(info.Ranking)); } if (Misc.Config.Item("enablekdaratio").GetValue <bool>()) { Text.DrawText( null, "Champ: " + info.champwinrate + " (" + info.kda + " KDA)", startX + (15 - info.Ranking.Length * 4) / 2, startY + 35, Misc.ColorRank(info.Ranking)); } } } } catch (Exception e) { Console.WriteLine(@"Error drawing text overheads " + e); } }
/// <summary> /// OnDraw event, specifies a drawing callback which is after IDirect3DDevice9::BeginScene and before /// IDirect3DDevice9::EndScene. /// </summary> /// <param name="basePosition"> /// The base position /// </param> public override void OnDraw(Vector2 basePosition) { if (this.IsVisible) { basePosition.X += this.hideOffsetX; Sprite.Begin(SpriteFlags.AlphaBlend); Line.Begin(); Line.Draw( new[] { new Vector2(basePosition.X - (this.Width / 2f), basePosition.Y), new Vector2(basePosition.X - (this.Width / 2f), basePosition.Y + this.HeaderHeight) }, new ColorBGRA(0, 0, 0, 255 / 2)); if (this.IsOpen || this.DrawBodyHeight > 0 || this.DrawFooterHeight > 0) { Line.Draw( new[] { new Vector2(basePosition.X - (this.Width / 2f), basePosition.Y + this.HeaderHeight), new Vector2( basePosition.X - (this.Width / 2f), basePosition.Y + this.HeaderHeight + this.DrawBodyHeight) }, new ColorBGRA(0, 0, 0, (byte)(255 / 1.5f))); Line.Draw( new[] { new Vector2( basePosition.X - (this.Width / 2f), basePosition.Y + this.HeaderHeight + this.DrawBodyHeight), new Vector2( basePosition.X - (this.Width / 2f), basePosition.Y + this.HeaderHeight + this.DrawFooterHeight + this.DrawBodyHeight) }, new ColorBGRA(0, 0, 0, (byte)(255 / 1.25f))); } Line.End(); HeaderFont.DrawText(Sprite, this.Header, this.GetHeaderRectangle(basePosition), 0, this.HeaderTextColor); var rectangle = this.GetBodyRectangle(basePosition); if (this.IsOpen || rectangle.Height > 0) { for (var i = 0; i < this.LinesList.Count; ++i) { var lineRectangle = rectangle; lineRectangle.Y += BodyFont.Description.Height * i; lineRectangle.Height -= BodyFont.Description.Height * i; BodyFont.DrawText(Sprite, this.LinesList[i], lineRectangle, 0, this.BodyTextColor); } } var matrix = Sprite.Transform; if (this.Icon != NotificationIconType.None && this.IconTexture != null && !this.IconTexture.IsDisposed) { Sprite.Transform = Matrix.Translation(basePosition.X - this.IconOffset, basePosition.Y + 0.5f, 0); Sprite.Draw(this.IconTexture, this.IconColor); } if (HideTexture != null && !HideTexture.IsDisposed) { Sprite.Transform = Matrix.Scaling(0.7f, 0.7f, 0f) * Matrix.Translation( basePosition.X - this.Width + 5f, basePosition.Y + this.HeaderHeight + this.BodyHeight + 1.5f, 0f); Sprite.Draw( HideTexture, Color.White, new SharpDX.Rectangle(0, 0, HideBitmap.Width, (int)this.DrawFooterHeight)); } Sprite.Transform = matrix; Sprite.End(); } }
public static void DrawFont(Font vFont, string vText, float jx, float jy, ColorBGRA jc) { vFont.DrawText(null, vText, (int)jx, (int)jy, jc); }
public static void DrawText(Font vFont, String vText, int vPosX, int vPosY, Color vColor) { vFont.DrawText(null, vText, vPosX + 2, vPosY + 2, vColor != Color.Black ? Color.Black : Color.White); vFont.DrawText(null, vText, vPosX, vPosY, vColor); }
private static void DrawFont(Font vFont, string vText, float vPosX, float vPosY, ColorBGRA vColor) { vFont.DrawText(null, vText, (int)vPosX, (int)vPosY, vColor); }
public static void DrawShadowText(string stext, int x, int y, Color color, Font f) { f.DrawText(null, stext, x + 1, y + 1, Color.Black); f.DrawText(null, stext, x, y, color); }
/// <summary> /// Fired when everything has been drawn. /// </summary> /// <param name="args">The <see cref="EventArgs"/> instance containing the event data.</param> /// <exception cref="Exception">[PermaShow] - MenuItem not supported</exception> private static void Drawing_OnEndScene(EventArgs args) { if (Drawing.Direct3DDevice == null || Drawing.Direct3DDevice.IsDisposed) { return; } if (!placetosave.Item("enablepermashow").GetValue <bool>()) { Unsub(); return; } PermaArea(); var halfwidth = 0.96f * (PermaShowWidth / 2); var baseposition = new Vector2(BoxPosition.X - halfwidth, BoxPosition.Y); var boxx = BoxPosition.X + (PermaShowWidth / 2) - (SmallBoxWidth / 2); foreach (var permaitem in PermaShowItems) { var index = PermaShowItems.IndexOf(permaitem); var boxpos = new Vector2(boxx, baseposition.Y + (Text.Description.Height * 1.2f * index)); var endpos = new Vector2(BoxPosition.X + (PermaShowWidth / 2), baseposition.Y + (Text.Description.Height * 1.2f * index)); var itempos = new Vector2(baseposition.X, baseposition.Y + (Text.Description.Height * 1.2f * index)); int textpos = (int)(endpos.X - (SmallBoxWidth / 1.2f)); switch (permaitem.Item.ValueType) { case MenuValueType.Boolean: DrawBox(boxpos, permaitem.Item.GetValue <bool>()); Text.DrawText(null, permaitem.DisplayName + ":", (int)itempos.X, (int)itempos.Y, permaitem.Color); Text.DrawText(null, permaitem.Item.GetValue <bool>().ToString(), textpos, (int)itempos.Y, permaitem.Color); break; case MenuValueType.Slider: Text.DrawText(null, permaitem.DisplayName + ":", (int)itempos.X, (int)itempos.Y, permaitem.Color); Text.DrawText(null, permaitem.Item.GetValue <Slider>().Value.ToString(), textpos, (int)itempos.Y, permaitem.Color); break; case MenuValueType.KeyBind: DrawBox(boxpos, permaitem.Item.GetValue <KeyBind>().Active); Text.DrawText(null, permaitem.DisplayName + " [" + Utils.KeyToText(permaitem.Item.GetValue <KeyBind>().Key) + "] :", (int)itempos.X, (int)itempos.Y, permaitem.Color); Text.DrawText(null, permaitem.Item.GetValue <KeyBind>().Active.ToString(), textpos, (int)(boxpos.Y), permaitem.Color); break; case MenuValueType.StringList: Text.DrawText(null, permaitem.DisplayName + ":", (int)itempos.X, (int)itempos.Y, permaitem.Color); var dimen = Text.MeasureText(sprite, permaitem.Item.GetValue <StringList>().SelectedValue); Text.DrawText(null, permaitem.Item.GetValue <StringList>().SelectedValue, (int)(textpos + dimen.Width < endpos.X ? textpos : endpos.X - dimen.Width), (int)itempos.Y, permaitem.Color); break; case MenuValueType.Integer: Text.DrawText(null, permaitem.DisplayName + ":", (int)itempos.X, (int)itempos.Y, permaitem.Color); Text.DrawText(null, permaitem.Item.GetValue <int>().ToString(), textpos, (int)itempos.Y, permaitem.Color); break; case MenuValueType.None: break; default: throw new Exception("[PermaShow] - MenuItem not supported"); } } }
static void Main() { var worldSize = new Size2(1024, 768); var renderSize = new Size2(1920, 1080); const bool windowed = true; const int numParticles = 1000000; const int numEmitters = 5; const int budget = numParticles / numEmitters; var form = new RenderForm("Mercury Particle Engine - SharpDX.Direct3D9 Sample") { Size = new System.Drawing.Size(renderSize.Width, renderSize.Height) }; var direct3d = new Direct3D(); var device = new Device(direct3d, 0, DeviceType.Hardware, form.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters(renderSize.Width, renderSize.Height) { PresentationInterval = PresentInterval.Immediate, Windowed = windowed }); var view = new Matrix( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, -1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); var proj = Matrix.OrthoOffCenterLH(worldSize.Width * -0.5f, worldSize.Width * 0.5f, worldSize.Height * 0.5f, worldSize.Height * -0.5f, 0f, 1f); var wvp = Matrix.Identity * view * proj; var emitters = new Emitter[numEmitters]; for (int i = 0; i < numEmitters; i++) { emitters[i] = new Emitter(budget, TimeSpan.FromSeconds(600), Profile.BoxFill(worldSize.Width, worldSize.Height)) { Parameters = new ReleaseParameters { Colour = new Colour(220f, 0.7f, 0.1f), Opacity = 1f, Quantity = budget, Speed = 0f, Scale = 1f, Rotation = 0f, Mass = new RangeF(8f, 12f) }, BlendMode = BlendMode.Add, ReclaimInterval = 600f }; emitters[i].Modifiers.Add(new DragModifier { DragCoefficient = .47f, Density = .15f }, 15f); emitters[i].Modifiers.Add(new VortexModifier { Position = Coordinate.Origin, Mass = 200f, MaxSpeed = 1000f }, 30f); emitters[i].Modifiers.Add(new VelocityHueModifier { StationaryHue = 220f, VelocityHue = 300f, VelocityThreshold = 800f }, 15f); emitters[i].Modifiers.Add(new ContainerModifier { RestitutionCoefficient = 0.75f, Position = Coordinate.Origin, Width = worldSize.Width, Height = worldSize.Height }, 30f); emitters[i].Modifiers.Add(new MoveModifier(), 60f); }; var renderer = new PointSpriteRenderer(device, budget) { // EnableFastFade = true }; var texture = Texture.FromFile(device, "Pixel.dds"); var fontDescription = new FontDescription { Height = 16, FaceName = "Consolas", PitchAndFamily = FontPitchAndFamily.Mono, Quality = FontQuality.Draft }; var font = new Font(device, fontDescription); var totalTimer = Stopwatch.StartNew(); var updateTimer = new Stopwatch(); var renderTimer = new Stopwatch(); var totalTime = 0f; foreach (var emitter in emitters) { emitter.Trigger(Coordinate.Origin); } float updateTime = 0f; RenderLoop.Run(form, () => { // ReSharper disable AccessToDisposedClosure var frameTime = ((float)totalTimer.Elapsed.TotalSeconds) - totalTime; totalTime = (float)totalTimer.Elapsed.TotalSeconds; var mousePosition = form.PointToClient(RenderForm.MousePosition); Task.WaitAll( Task.Factory.StartNew(() => { var mouseVector = new Vector3(mousePosition.X, mousePosition.Y, 0f); var unprojected = Vector3.Unproject(mouseVector, 0, 0, renderSize.Width, renderSize.Height, 0f, 1f, wvp); Parallel.ForEach(emitters, emitter => ((VortexModifier)emitter.Modifiers.ElementAt(1)).Position = new Coordinate(unprojected.X, unprojected.Y)); updateTimer.Restart(); Parallel.ForEach(emitters, emitter => emitter.Update(frameTime)); updateTimer.Stop(); updateTime = (float)updateTimer.Elapsed.TotalSeconds; _updateTimes.Add(updateTime); }), Task.Factory.StartNew(() => { device.Clear(ClearFlags.Target, Color.Black, 1f, 0); device.BeginScene(); renderTimer.Restart(); for (int i = 0; i < numEmitters; i++) { renderer.Render(emitters[i], wvp, texture); } renderTimer.Stop(); var renderTime = (float)renderTimer.Elapsed.TotalSeconds; var totalUpdateTime = 0f; // foreach (var time in _updateTimes) // { // totalUpdateTime += time; // } // totalUpdateTime /= _updateTimes.Count; // // if(_updateTimes.Count > 100) // _updateTimes.RemoveAt(0); font.DrawText(null, String.Format("Time: {0}", totalTimer.Elapsed), 0, 0, Color.White); font.DrawText(null, String.Format("Particles: {0:n0}", emitters[0].ActiveParticles * numEmitters), 0, 16, Color.White); font.DrawText(null, String.Format("Update: {0:n4} ({1,8:P2})", updateTime, updateTime / 0.01666666f), 0, 32, Color.White); font.DrawText(null, String.Format("Render: {0:n4} ({1,8:P2})", renderTime, renderTime / 0.01666666f), 0, 48, Color.White); device.EndScene(); device.Present(); }) ); if (Keyboard.IsKeyDown(Key.Escape)) Environment.Exit(0); // ReSharper restore AccessToDisposedClosure }); form.Dispose(); font.Dispose(); device.Dispose(); direct3d.Dispose(); }
public static void DrawText(Font vFont, String vText, float vPosX, float vPosY, SharpDX.ColorBGRA vColor) { vFont.DrawText(null, vText, (int)vPosX, (int)vPosY, vColor); }
public static void DrawText(Font fuente, String text, float posx, float posy, SharpDX.ColorBGRA color) { fuente.DrawText(null, text, (int)posx, (int)posy, color); }