Ejemplo n.º 1
0
        private List <OverlayDataGridViewItem> getViewItems(List <CombatantData> combatants)
        {
            try
            {
                List <OverlayDataGridViewItem> viewItems = new List <OverlayDataGridViewItem>();

                foreach (CombatantData combatant in combatants)
                {
                    OverlayDataGridViewItem viewItem = combatant;
                    viewItem.TotalAlliesDamage = currentEncounterData.Damage;
                    viewItem.TotalAlliesHealed = currentEncounterData.Healed;
                    viewItems.Add(viewItem);
                }

                return(viewItems);
            }
            catch
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
        private void populateTable(OverlayDataGridView dataGridView, List <OverlayDataGridViewItem> dataSource, List <OverlayDataGridViewItem> viewItems, OverlayTableSetting tableSetting)
        {
            if (!tableSetting.ShowTable)
            {
                return;
            }

            if (viewItems == null || viewItems.Count == 0)
            {
                return;
            }

            dataGridView.SuspendLayout();
            dataSource.Clear();

            if (!tableSetting.ShowLimit)
            {
                OverlayDataGridViewItem limit = viewItems.FirstOrDefault(x => x.Job == "LIMIT");

                if (limit != null)
                {
                    viewItems.Remove(limit);
                }
            }

            List <OverlayDataGridViewItem> players = viewItems.Where(x => !string.IsNullOrEmpty(x.Job) && x.Job != "PET").ToList();
            List <OverlayDataGridViewItem> pets    = viewItems.Where(x => x.Job == "PET").ToList();

            foreach (OverlayDataGridViewItem pet in pets)
            {
                string masterName = pet.Name.Substring(pet.Name.IndexOf('(') + 1);
                masterName = masterName.Substring(0, masterName.LastIndexOf(')')).Trim();

                if (masterName == charName)
                {
                    masterName = "YOU";
                }

                pet.Master = players.FirstOrDefault(x => x.Name == masterName);

                if (pet.Master != null && pet.Master.Name == "YOU")
                {
                    pet.HiddenName = pet.Name;
                }
            }

            if (tableSetting.ShowOnlyHealer)
            {
                List <OverlayDataGridViewItem> healers = players.Where(x => healerJobNames.Contains(x.Job)).ToList();
                players = healers;

                List <OverlayDataGridViewItem> healerPets = pets.Where(x => players.Contains(x.Master)).ToList();
                pets = healerPets;
            }

            if (tableSetting.CombinePets)
            {
                foreach (OverlayDataGridViewItem pet in pets)
                {
                    if (pet.Master != null)
                    {
                        pet.Master.PetDPS += pet.EncDPS;
                        pet.Master.PetHPS += pet.EncHPS;

                        pet.Master.PetDamage   += pet.Damage;
                        pet.Master.PetHealed   += pet.Healed;
                        pet.Master.PetOverHeal += pet.OverHeal;

                        pet.Master.PetHits       += pet.Hits;
                        pet.Master.PetDirectHits += pet.DirectHits;
                        pet.Master.PetCritHits   += pet.CritHits;

                        pet.Master.PetHeals     += pet.Heals;
                        pet.Master.PetCritHeals += pet.CritHeals;

                        if (pet.MaxHit > pet.Master.MaxHit)
                        {
                            pet.Master.PetMaxHit       = pet.MaxHit;
                            pet.Master.PetMaxHitString = pet.MaxHitString;
                        }

                        if (pet.MaxHeal > pet.Master.MaxHeal)
                        {
                            pet.Master.PetMaxHeal       = pet.MaxHeal;
                            pet.Master.PetMaxHealString = pet.MaxHealString;
                        }

                        pet.Master.PetSwings += pet.Swings;
                        pet.Master.PetMisses += pet.Misses;
                    }
                }

                foreach (OverlayDataGridViewItem player in players)
                {
                    player.RefreshPrints();
                    dataSource.Add(player);
                }
            }
            else
            {
                foreach (OverlayDataGridViewItem player in players)
                {
                    player.RefreshPrints();
                    dataSource.Add(player);
                }

                foreach (OverlayDataGridViewItem pet in pets)
                {
                    pet.RefreshPrints();
                    dataSource.Add(pet);
                }
            }

            ((BindingList <OverlayDataGridViewItem>)dataGridView.DataSource).ResetBindings();
            dataGridView.ResumeLayout(true);
        }
Ejemplo n.º 3
0
        protected override void OnRowPrePaint(DataGridViewRowPrePaintEventArgs e)
        {
            base.OnRowPrePaint(e);

            e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(1, 1, 1)), e.RowBounds);

            if (!setting.ShowGraph)
            {
                return;
            }
            if (string.IsNullOrEmpty(setting.CurrentGraphDataPropertyName))
            {
                return;
            }

            OverlayDataGridViewItem currentItem = (OverlayDataGridViewItem)Rows[e.RowIndex].DataBoundItem;

            IEnumerable <OverlayDataGridViewItem> filteredItems =
                setting.IncludeLimitInSorting ?
                backingSource :
                backingSource.Where(x => x.Job != "LIMIT");

            int width         = 0;
            int overHealWidth = 0;
            int petWidth      = 0;

            switch (setting.CurrentGraphDataPropertyName)
            {
            case "TotalDPS":
                double topTotalDPS = filteredItems.Max(x => x.PetDPS + x.EncDPS);
                width    = (int)(e.RowBounds.Width * currentItem.EncDPS / topTotalDPS);
                petWidth = (int)(e.RowBounds.Width * currentItem.PetDPS / topTotalDPS);
                break;

            case "TotalHPS":
                double topTotalHPS  = filteredItems.Max(x => x.PetHPS + x.EncHPS);
                double overHealHPS  = currentItem.EncHPS * (currentItem.OverHeal + currentItem.PetOverHeal) / (currentItem.Healed + currentItem.PetHealed);
                double validHealHPS = currentItem.EncHPS - overHealHPS;
                width         = (int)(e.RowBounds.Width * validHealHPS / topTotalHPS);
                overHealWidth = (int)(e.RowBounds.Width * overHealHPS / topTotalHPS);
                petWidth      = (int)(e.RowBounds.Width * currentItem.PetHPS / topTotalHPS);
                break;

            case "DamagePercent":
            case "TotalDamage":
                long topDamage = filteredItems.Max(x => x.PetDamage + x.Damage);
                width    = (int)((double)e.RowBounds.Width * currentItem.Damage / topDamage);
                petWidth = (int)((double)e.RowBounds.Width * currentItem.PetDamage / topDamage);
                break;

            case "HealedPercent":
            case "TotalHealed":
                long topHealed = filteredItems.Max(x => x.PetHealed + x.Healed);
                width    = (int)((double)e.RowBounds.Width * currentItem.Healed / topHealed);
                petWidth = (int)((double)e.RowBounds.Width * currentItem.PetHealed / topHealed);
                break;

            case "OverHealPercent":
            case "TotalOverHeal":
                long topOverHeal = filteredItems.Max(x => x.OverHeal + x.PetOverHeal);
                width    = (int)((double)e.RowBounds.Width * currentItem.OverHeal / topOverHeal);
                petWidth = (int)((double)e.RowBounds.Width * currentItem.PetOverHeal / topOverHeal);
                break;

            case "DirectHitPercent":
                int topDirectHits = filteredItems.Max(x => x.DirectHits + x.PetDirectHits);
                width    = (int)((float)e.RowBounds.Width * currentItem.DirectHits / topDirectHits);
                petWidth = (int)((float)e.RowBounds.Width * currentItem.PetDirectHits / topDirectHits);
                break;

            case "CritPercent":
                int topCritHits = filteredItems.Max(x => x.CritHits + x.PetCritHits);
                width    = (int)((float)e.RowBounds.Width * currentItem.CritHits / topCritHits);
                petWidth = (int)((float)e.RowBounds.Width * currentItem.PetCritHits / topCritHits);
                break;

            case "CritHealPercent":
                int topCritHeals = filteredItems.Max(x => x.CritHeals + x.PetCritHeals);
                width    = (int)((float)e.RowBounds.Width * currentItem.CritHeals / topCritHeals);
                petWidth = (int)((float)e.RowBounds.Width * currentItem.PetCritHeals / topCritHeals);
                break;

            case "TotalMaxHitString":
                long topMaxHit = filteredItems.Max(x => x.TotalMaxHit);
                width = (int)((double)e.RowBounds.Width * currentItem.TotalMaxHit / topMaxHit);
                break;

            case "TotalMaxHealString":
                long topMaxHeal = filteredItems.Max(x => x.TotalMaxHeal);
                width = (int)((double)e.RowBounds.Width * currentItem.TotalMaxHeal / topMaxHeal);
                break;

            case "TotalSwings":
                int topSwings = filteredItems.Max(x => x.Swings + x.PetSwings);
                width    = (int)((float)e.RowBounds.Width * currentItem.Swings / topSwings);
                petWidth = (int)((float)e.RowBounds.Width * currentItem.PetSwings / topSwings);
                break;

            case "TotalMisses":
                int topMisses = filteredItems.Max(x => x.Misses + x.PetMisses);
                width    = (int)((float)e.RowBounds.Width * currentItem.Misses / topMisses);
                petWidth = (int)((float)e.RowBounds.Width * currentItem.PetMisses / topMisses);
                break;

            case "Deaths":
                int topDeaths = filteredItems.Max(x => x.Deaths);
                width = (int)((float)e.RowBounds.Width * currentItem.Deaths / topDeaths);
                break;
            }

            Color mainColor = Color.FromArgb(128, 128, 128);

            if (jobColorDictionary.ContainsKey(currentItem.Job))
            {
                mainColor = jobColorDictionary[currentItem.Job];
            }

            if (width > 0)
            {
                e.Graphics.FillRectangle(new SolidBrush(mainColor), new Rectangle(e.RowBounds.X, e.RowBounds.Y, width, e.RowBounds.Height));
            }

            if (overHealWidth > 0)
            {
                e.Graphics.FillRectangle(
                    new SolidBrush(ActPlugin.Setting.OverlaySetting.HpsOverHealColor),
                    new Rectangle(e.RowBounds.X + width, e.RowBounds.Y, overHealWidth, e.RowBounds.Height));
            }

            if (petWidth > 0)
            {
                e.Graphics.FillRectangle(
                    new SolidBrush(Color.FromArgb(
                                       Math.Min(mainColor.R + 50, 255),
                                       Math.Min(mainColor.G + 50, 255),
                                       Math.Min(mainColor.B + 50, 255))),
                    new Rectangle(e.RowBounds.X + width + overHealWidth, e.RowBounds.Y, petWidth, e.RowBounds.Height));
            }
        }
Ejemplo n.º 4
0
        public void Sort()
        {
            if (string.IsNullOrEmpty(setting.CurrentSortingDataPropertyName))
            {
                return;
            }

            bool sorted = true;

            switch (setting.CurrentSortingDataPropertyName)
            {
            case "Name":
            case "HiddenName":
                backingSource.Sort((x, y) =>
                                   string.Compare(x.Name, y.Name) *
                                   (setting.CurrentSortOrder == SortOrder.Descending ? 1 : -1));
                break;

            case "Job":
            case "JobIcon":
                backingSource.Sort((x, y) =>
                                   (jobOrderDictionary[x.Job] > jobOrderDictionary[y.Job] ? -1 : 1) *
                                   (setting.CurrentSortOrder == SortOrder.Descending ? 1 : -1));
                break;

            case "TotalDPS":
                backingSource.Sort((x, y) =>
                                   ((x.PetDPS + x.EncDPS) > (y.PetDPS + y.EncDPS) ? -1 : 1) *
                                   (setting.CurrentSortOrder == SortOrder.Descending ? 1 : -1));
                break;

            case "TotalHPS":
                backingSource.Sort((x, y) =>
                                   ((x.PetHPS + x.EncHPS) > (y.PetHPS + y.EncHPS) ? -1 : 1) *
                                   (setting.CurrentSortOrder == SortOrder.Descending ? 1 : -1));
                break;

            case "DamagePercent":
            case "TotalDamage":
                backingSource.Sort((x, y) =>
                                   ((x.Damage + x.PetDamage) > (y.Damage + y.PetDamage) ? -1 : 1) *
                                   (setting.CurrentSortOrder == SortOrder.Descending ? 1 : -1));
                break;

            case "HealedPercent":
            case "TotalHealed":
                backingSource.Sort((x, y) =>
                                   ((x.Healed + x.PetHealed) > (y.Healed + y.PetHealed) ? -1 : 1) *
                                   (setting.CurrentSortOrder == SortOrder.Descending ? 1 : -1));
                break;

            case "OverHealPercent":
            case "TotalOverHeal":
                backingSource.Sort((x, y) =>
                                   ((x.OverHeal + x.PetOverHeal) > (y.OverHeal + y.PetOverHeal) ? -1 : 1) *
                                   (setting.CurrentSortOrder == SortOrder.Descending ? 1 : -1));
                break;

            case "DirectHitPercent":
                backingSource.Sort((x, y) =>
                                   ((x.DirectHits + x.PetDirectHits) > (y.DirectHits + y.PetDirectHits) ? -1 : 1) *
                                   (setting.CurrentSortOrder == SortOrder.Descending ? 1 : -1));
                break;

            case "CritPercent":
                backingSource.Sort((x, y) =>
                                   ((x.CritHits + x.PetCritHits) > (y.CritHits + y.PetCritHits) ? -1 : 1) *
                                   (setting.CurrentSortOrder == SortOrder.Descending ? 1 : -1));
                break;

            case "CritHealPercent":
                backingSource.Sort((x, y) =>
                                   ((x.CritHeals + x.PetCritHeals) > (y.CritHeals + y.PetCritHeals) ? -1 : 1) *
                                   (setting.CurrentSortOrder == SortOrder.Descending ? 1 : -1));
                break;

            case "TotalMaxHitString":
                backingSource.Sort((x, y) =>
                                   (x.TotalMaxHit > y.TotalMaxHit ? -1 : 1) *
                                   (setting.CurrentSortOrder == SortOrder.Descending ? 1 : -1));
                break;

            case "TotalMaxHealString":
                backingSource.Sort((x, y) =>
                                   (x.TotalMaxHeal > y.TotalMaxHeal ? -1 : 1) *
                                   (setting.CurrentSortOrder == SortOrder.Descending ? 1 : -1));
                break;

            case "TotalSwings":
                backingSource.Sort((x, y) =>
                                   ((x.Swings + x.PetSwings) > (y.Swings + y.PetSwings) ? -1 : 1) *
                                   (setting.CurrentSortOrder == SortOrder.Descending ? 1 : -1));
                break;

            case "TotalMisses":
                backingSource.Sort((x, y) =>
                                   ((x.Misses + x.PetMisses) > (y.Misses + y.PetMisses) ? -1 : 1) *
                                   (setting.CurrentSortOrder == SortOrder.Descending ? 1 : -1));
                break;

            case "Deaths":
                backingSource.Sort((x, y) =>
                                   (x.Deaths > y.Deaths ? -1 : 1) *
                                   (setting.CurrentSortOrder == SortOrder.Descending ? 1 : -1));
                break;

            default:
                sorted = false;
                break;
            }

            if (!sorted)
            {
                return;
            }

            if (!setting.IncludeLimitInSorting)
            {
                OverlayDataGridViewItem limit = backingSource.FirstOrDefault(x => x.Job == "LIMIT");

                if (limit != null)
                {
                    backingSource.Remove(limit);
                    backingSource.Add(limit);
                }
            }

            ((BindingList <OverlayDataGridViewItem>)DataSource).ResetBindings();

            foreach (DataGridViewColumn column in Columns)
            {
                if (column.DataPropertyName == setting.CurrentSortingDataPropertyName)
                {
                    column.HeaderText = column.Name + (setting.CurrentSortOrder == SortOrder.Descending ? " ▼" : " ▲");
                    break;
                }
            }
        }