<commit_before>﻿// Original Work Copyright (c) <NAME> 2014-2016
// This file is subject to the GPL v2 License
// For additional details, see the LICENSE file

using System;
using Microsoft.Xna.Framework;

namespace EndlessClient.HUD.StatusBars
{
    public class HPStatusBar : BaseStatusBar
    {
        public HPStatusBar()
        {
            DrawLocation = new Vector2(100, 0);
            drawArea = new Rectangle((int)DrawLocation.X, (int)DrawLocation.Y, m_elemSourceRect.Width, m_elemSourceRect.Height);
        }

        protected override void UpdateLabelText()
        {
            m_label.Text = $"{m_stats.HP}/{m_stats.MaxHP}";
        }

        protected override void DrawStatusBar()
        {
            int srcWidth = 25 + (int)Math.Round((m_stats.HP / (double)m_stats.MaxHP) * 79);
            Rectangle maskSrc = new Rectangle(m_elemSourceRect.X, m_elemSourceRect.Height, srcWidth, m_elemSourceRect.Height);

            SpriteBatch.Begin();
            SpriteBatch.Draw(m_textSheet, new Vector2(DrawAreaWithOffset.X, DrawAreaWithOffset.Y), m_elemSourceRect, Color.White);
            SpriteBatch.Draw(m_textSheet, new Vector2(DrawAreaWithOffset.X, DrawAreaWithOffset.Y), maskSrc, Color.White);
            SpriteBatch.End();
        }
    }
}<commit_msg>Issue #52: Rewrite HPStatusBar<commit_after>﻿// Original Work Copyright (c) <NAME> 2014-2016
// This file is subject to the GPL v2 License
// For additional details, see the LICENSE file

using System;
using EOLib.Domain.Character;
using EOLib.Graphics;
using Microsoft.Xna.Framework;

namespace EndlessClient.HUD.StatusBars
{
    public class HPStatusBar : StatusBarBase
    {
        public HPStatusBar(INativeGraphicsManager nativeGraphicsManager,
                           ICharacterProvider characterProvider)
            : base(nativeGraphicsManager, characterProvider)
        {
            DrawArea = new Rectangle(100, 0, _sourceRectangleArea.Width, _sourceRectangleArea.Height);
        }

        protected override void UpdateLabelText()
        {
            _label.Text = $"{Stats[CharacterStat.HP]}/{Stats[CharacterStat.MaxHP]}";
        }

        protected override void DrawStatusBar()
        {
            //todo: figure out these magic numbers
            var srcWidth = 25 + (int)Math.Round(Stats[CharacterStat.HP] / (double)Stats[CharacterStat.MaxHP] * 79);
            var maskSrc = new Rectangle(_sourceRectangleArea.X, _sourceRectangleArea.Height, srcWidth, _sourceRectangleArea.Height);

            _spriteBatch.Begin();
            _spriteBatch.Draw(_texture, DrawPositionWithParentOffset, _sourceRectangleArea, Color.White);
            _spriteBatch.Draw(_texture, DrawPositionWithParentOffset, maskSrc, Color.White);
            _spriteBatch.End();
        }
    }
}
{'fraction_non_alphanumeric': 0.0950666186532229, 'fraction_numerical': 0.014043932301044292, 'mean_word_length': 2.8636995827538247, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '966184', 'n_tokens_mistral': 821, 'n_tokens_neox': 780, 'n_words': 174}