public void UpdateStatus()
        {
            CaptureMenuItem.Checked    = _teraSniffer.Enabled;
            PasteStatsMenuItem.Enabled = TeraWindow.IsTeraRunning();

            SetHotKeyEnabled(TeraWindow.IsTeraActive());
        }
        private void PasteStatsMenuItem_Click(object sender, EventArgs e)
        {
            if (_damageTracker == null)
            {
                return;
            }

            var       playerStatsSequence = _damageTracker.OrderByDescending(playerStats => playerStats.Dealt.Damage).TakeWhile(x => x.Dealt.Damage > 0);
            var       totalDamage         = playerStatsSequence.Sum(playerStats => playerStats.Dealt.Damage);
            const int maxLength           = 300;

            var  sb    = new StringBuilder();
            bool first = true;

            foreach (var playerInfo in playerStatsSequence)
            {
                var playerText = first ? "" : ", ";

                var damageFraction = (double)playerInfo.Dealt.Damage / totalDamage;
                playerText += string.Format("{0} {1} {2}", playerInfo.Name, FormatHelpers.FormatValue(playerInfo.Dealt.Damage), FormatHelpers.FormatPercent(damageFraction));

                if (sb.Length + playerText.Length > maxLength)
                {
                    break;
                }

                sb.Append(playerText);
                first = false;
            }

            var text = sb.ToString();

            TeraWindow.SendString(text);
        }
Exemple #3
0
        private void PasteStatsMenuItem_Click(object sender, EventArgs e)
        {
            if (_damageTracker == null)
            {
                return;
            }

            var       playerStatsSequence = _damageTracker.OrderByDescending(playerStats => playerStats.Dealt.Damage).TakeWhile(x => x.Dealt.Damage > 0);
            const int maxLength           = 300;

            var  sb    = new StringBuilder();
            bool first = true;

            foreach (var playerInfo in playerStatsSequence)
            {
                var placeHolder = DamagePlaceHolders.FromPlayerInfo(playerInfo, FormatHelpers.Invariant);
                var playerText  = first ? "" : " | ";

                playerText += placeHolder.Replace("{Name} {Damage} {DPS} {DamagePercent}");

                if (sb.Length + playerText.Length > maxLength)
                {
                    break;
                }

                sb.Append(playerText);
                first = false;
            }

            var text = sb.ToString();

            TeraWindow.SendString(text);
        }