protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); float thickness = (float)SettingsManager.getSettingDouble("CurvedBarsFontSize"); Rectangle rect = this.DisplayRectangle; rect.Y -= (rect.Width - rect.Height) / 2; rect.Height = rect.Width; rect.Width -= (int)(thickness + 2); rect.X += (int)(thickness / 2 + 1); using (Pen pen = new Pen(Color.Black)) { pen.Width = thickness + 2; e.Graphics.DrawArc(pen, rect, 135, 90); e.Graphics.DrawArc(pen, rect, 45, -90); pen.Width = thickness; health = health.ClampPercentage(); mana = mana.ClampPercentage(); pen.Color = StyleManager.GetHealthColor(health); e.Graphics.DrawArc(pen, rect, 135, 90 * health); pen.Color = StyleManager.ManaColor; e.Graphics.DrawArc(pen, rect, 45, -90 * mana); } }
public void RefreshHUD(long min, long max, double percentage) { if (displayText) { if (statusType == StatusType.Experience) { healthBarLabel.Text = String.Format("Lvl {0}: {1}%", MemoryReader.Level, (int)(percentage * 100)); } else { healthBarLabel.Text = String.Format("{0}/{1}", min, max); } } else { healthBarLabel.Text = ""; } healthBarLabel.percentage = percentage; if (statusType == StatusType.Health) { healthBarLabel.BackColor = StyleManager.GetHealthColor(percentage); } else if (statusType == StatusType.Mana) { healthBarLabel.BackColor = StyleManager.ManaColor; } else if (statusType == StatusType.Experience) { healthBarLabel.BackColor = StyleManager.ExperienceColor; } }
private void RefreshHUD(long value, long max) { double percentage = ((double)value) / ((double)max); if (displayText) { healthBarLabel.Text = String.Format("{0}/{1}", value, max); } else { healthBarLabel.Text = ""; } healthBarLabel.percentage = percentage; healthBarLabel.Size = this.Size; healthBarLabel.BackColor = StyleManager.GetHealthColor(percentage); }
public void RefreshHUD() { lock (players) { int playerIndex = 0; MemoryReader.UpdateBattleList(); for (int index = 0; index < players.Count; index++) { PlayerEntry player = players[index]; if (player.playerid < 0) { player.playerid = MemoryReader.GetPlayerID(player.name); } if (player.playerid >= 0) { if (player.healthBar == null) { int basePositionX = 0; int basePositionY = playerIndex * playerBarHeight; if (displayNames) { player.playerNameLabel = new Label(); player.playerNameLabel.Text = player.name; player.playerNameLabel.Location = new Point(basePositionX, basePositionY); player.playerNameLabel.Size = new Size(this.Size.Width, healthBarHeight * 2 / 3); player.playerNameLabel.ForeColor = StyleManager.MainFormButtonForeColor; player.playerNameLabel.BackColor = Color.Transparent; player.playerNameLabel.Font = baseFont; this.Controls.Add(player.playerNameLabel); basePositionY += healthBarHeight * 2 / 3; } if (displayIcons && player.playerImage != null) { player.playerIconLabel = new PictureBox(); player.playerIconLabel.Size = new Size(healthBarHeight, healthBarHeight); player.playerIconLabel.Location = new Point(basePositionX, basePositionY); player.playerIconLabel.BackColor = Color.Transparent; player.playerIconLabel.SizeMode = PictureBoxSizeMode.Zoom; player.playerIconLabel.Image = player.playerImage; this.Controls.Add(player.playerIconLabel); basePositionX += healthBarHeight; } player.healthBar = new ProgressBarLabel(); player.healthBar.Location = new Point(basePositionX, basePositionY); player.healthBar.Size = new Size(this.Size.Width - basePositionX, healthBarHeight); player.healthBar.percentage = 100; player.healthBar.Font = baseFont; player.healthBar.Text = ""; this.Controls.Add(player.healthBar); for (int j = index + 1; j < players.Count; j++) { if (players[j].healthBar != null) { players[j].healthBar.Location = new Point(players[j].healthBar.Location.X, players[j].healthBar.Location.Y + playerBarHeight); } if (players[j].playerIconLabel != null) { players[j].playerIconLabel.Location = new Point(players[j].playerIconLabel.Location.X, players[j].playerIconLabel.Location.Y + playerBarHeight); } if (players[j].playerNameLabel != null) { players[j].playerNameLabel.Location = new Point(players[j].playerNameLabel.Location.X, players[j].playerNameLabel.Location.Y + playerBarHeight); } } this.Size = new Size(this.Size.Width, playerBarHeight * players.Count); } int percentage = MemoryReader.GetHealthPercentage(player.playerid, ref player.battlelistentry); if (displayText) { player.healthBar.Text = String.Format("{0}%", percentage); } if (percentage <= 0) { player.playerid = -1; if (player.healthBar != null) { this.Controls.Remove(player.healthBar); player.healthBar.Dispose(); player.healthBar = null; } if (player.playerNameLabel != null) { this.Controls.Remove(player.playerNameLabel); player.playerNameLabel.Dispose(); player.playerNameLabel = null; } if (player.playerIconLabel != null) { this.Controls.Remove(player.playerIconLabel); player.playerIconLabel.Dispose(); player.playerIconLabel = null; } for (int j = index + 1; j < players.Count; j++) { if (players[j].healthBar != null) { players[j].healthBar.Location = new Point(players[j].healthBar.Location.X, players[j].healthBar.Location.Y - playerBarHeight); } if (players[j].playerIconLabel != null) { players[j].playerIconLabel.Location = new Point(players[j].playerIconLabel.Location.X, players[j].playerIconLabel.Location.Y - playerBarHeight); } if (players[j].playerNameLabel != null) { players[j].playerNameLabel.Location = new Point(players[j].playerNameLabel.Location.X, players[j].playerNameLabel.Location.Y - playerBarHeight); } } } else { player.healthBar.percentage = percentage / 100.0; player.healthBar.BackColor = StyleManager.GetHealthColor(percentage / 100.0); playerIndex++; } } } } }
private void RefreshHUD(double lifePercentage, double manaPercentage) { lifePercentage = lifePercentage.ClampPercentage(); manaPercentage = manaPercentage.ClampPercentage(); Bitmap bitmap = new Bitmap(pictureBox.Size.Width, pictureBox.Size.Height); int width = bitmap.Width; int height = bitmap.Height; using (Graphics gr = Graphics.FromImage(bitmap)) { // we set the interpolation mode to nearest neighbor because other interpolation modes modify the colors // which causes the transparency key to appear around the edges of the object gr.Clear(StyleManager.BlendTransparencyKey); Rectangle lifeRectangle = new Rectangle(); lifeRectangle.X = (int)(height * 0.7); lifeRectangle.Y = (int)(height * 0.15) - 2; lifeRectangle.Width = width - lifeRectangle.X; lifeRectangle.Height = (int)(height * 0.2) + 4; gr.FillRectangle(Brushes.Black, lifeRectangle); lifeRectangle.Y += 2; lifeRectangle.Height -= 4; lifeRectangle.Width = (int)(lifeRectangle.Width * lifePercentage) - 2; using (Brush brush = new SolidBrush(StyleManager.GetHealthColor(lifePercentage))) { gr.FillRectangle(brush, lifeRectangle); } Rectangle manaRectangle = new Rectangle(); manaRectangle.X = (int)(height * 0.7); manaRectangle.Y = (int)(height * 0.15) - 2 + lifeRectangle.Height + 2; manaRectangle.Width = (int)((width - lifeRectangle.X) * 0.95); manaRectangle.Height = (int)(height * 0.2) + 4; gr.FillRectangle(Brushes.Black, manaRectangle); manaRectangle.Y += 2; manaRectangle.Height -= 4; manaRectangle.Width = (int)(manaRectangle.Width * manaPercentage) - 2; using (Brush brush = new SolidBrush(StyleManager.ManaColor)) { gr.FillRectangle(brush, manaRectangle); } int backgroundSize = (int)(height * backgroundScale / 100.0); int backgroundBaseOffset = (height - backgroundSize) / 2; int centerSize = (int)(height * centerScale / 100.0); int centerBaseOffset = (height - centerSize) / 2; SummaryForm.RenderImageResized(gr, backgroundImage, new Rectangle(backgroundBaseOffset + backgroundOffset.X, backgroundBaseOffset + backgroundOffset.Y, backgroundSize, backgroundSize)); SummaryForm.RenderImageResized(gr, centerImage, new Rectangle(centerBaseOffset + centerOffset.X, centerBaseOffset + centerOffset.Y, centerSize, centerSize)); Rectangle levelRect = new Rectangle((int)(height * 0.7), (int)(height * 0.6), (int)(height * 0.35), (int)(height * 0.35)); using (Brush brush = new SolidBrush(StyleManager.MainFormButtonColor)) { gr.FillEllipse(brush, levelRect); } using (Pen pen = new Pen(StyleManager.MainFormButtonForeColor, 2)) { gr.DrawEllipse(pen, levelRect); } using (Brush brush = new SolidBrush(StyleManager.MainFormButtonForeColor)) { string level = MemoryReader.Level.ToString(); gr.DrawString(level, StyleManager.MainFormLabelFont, brush, new PointF(height * (0.725f + (3 - level.Length) * 0.0375f), height * 0.7f)); } } bitmap.MakeTransparent(StyleManager.TransparencyKey); Image oldImage = pictureBox.Image; pictureBox.Image = bitmap; if (oldImage != null) { lock (oldImage) { oldImage.Dispose(); } } }
private void RefreshHUD() { float life = lifePercentage.ClampPercentage(); float mana = manaPercentage.ClampPercentage(); Bitmap bitmap = new Bitmap(pictureBox.Size.Width, pictureBox.Size.Height); int width = bitmap.Width; int height = bitmap.Height; using (Graphics gr = Graphics.FromImage(bitmap)) { // we set the interpolation mode to nearest neighbor because other interpolation modes modify the colors // which causes the transparency key to appear around the edges of the object gr.Clear(StyleManager.BlendTransparencyKey); Rectangle lifeRectangle = new Rectangle(); lifeRectangle.X = (int)(height * 0.7); lifeRectangle.Y = (int)(height * 0.15) - 2; lifeRectangle.Width = width - lifeRectangle.X; lifeRectangle.Height = (int)(height * 0.2) + 4; gr.FillRectangle(Brushes.Black, lifeRectangle); lifeRectangle.Y += 2; lifeRectangle.Height -= 4; lifeRectangle.Width = (int)(lifeRectangle.Width * life) - 2; using (Brush brush = new SolidBrush(StyleManager.GetHealthColor(life))) { gr.FillRectangle(brush, lifeRectangle); } Rectangle manaRectangle = new Rectangle(); manaRectangle.X = (int)(height * 0.7); manaRectangle.Y = (int)(height * 0.15) - 2 + lifeRectangle.Height + 2; manaRectangle.Width = (int)((width - lifeRectangle.X) * 0.95); manaRectangle.Height = (int)(height * 0.2) + 4; gr.FillRectangle(Brushes.Black, manaRectangle); manaRectangle.Y += 2; manaRectangle.Height -= 4; manaRectangle.Width = (int)(manaRectangle.Width * mana) - 2; using (Brush brush = new SolidBrush(StyleManager.ManaColor)) { gr.FillRectangle(brush, manaRectangle); } int backgroundSize = (int)(height * backgroundScale / 100.0); int backgroundBaseOffset = (height - backgroundSize) / 2; int centerSize = (int)(height * centerScale / 100.0); int centerBaseOffset = (height - centerSize) / 2; using (Brush brush = new SolidBrush(this.TransparencyKey)) { gr.FillEllipse(brush, new Rectangle(backgroundBaseOffset + backgroundOffset.X, backgroundBaseOffset + backgroundOffset.Y, backgroundSize, backgroundSize)); } using (Pen pen = new Pen(Color.Black, 5)) { gr.DrawEllipse(pen, new Rectangle(backgroundBaseOffset + backgroundOffset.X, backgroundBaseOffset + backgroundOffset.Y, backgroundSize, backgroundSize)); } //SummaryForm.RenderImageResized(gr, backgroundImage, new Rectangle(backgroundBaseOffset + backgroundOffset.X, backgroundBaseOffset + backgroundOffset.Y, backgroundSize, backgroundSize)); SummaryForm.RenderImageResized(gr, centerImage, new Rectangle(centerBaseOffset + centerOffset.X, centerBaseOffset + centerOffset.Y, centerSize, centerSize)); } bitmap.MakeTransparent(StyleManager.TransparencyKey); Image oldImage = pictureBox.Image; pictureBox.Image = bitmap; if (oldImage != null) { lock (oldImage) { oldImage.Dispose(); } } }