Example #1
0
        private DataManager()
        {
            DictionaryUniqueListHelper <string, SpellData> helper = new DictionaryUniqueListHelper <string, SpellData>();
            var spellList = new List <SpellData>();

            // build ranks cache
            Enumerable.Range(1, 9).ToList().ForEach(r => RanksCache[r.ToString(CultureInfo.CurrentCulture)] = "");
            Enumerable.Range(1, 200).ToList().ForEach(r => RanksCache[TextFormatUtils.IntToRoman(r)]        = "");
            RanksCache["Third"]  = "Root";
            RanksCache["Fifth"]  = "Root";
            RanksCache["Octave"] = "Root";

            // Old Spell cache (EQEMU)
            ConfigUtil.ReadList(@"data\oldspells.txt").ForEach(line => OldSpellNamesDB[line] = true);

            ConfigUtil.ReadList(@"data\spells.txt").ForEach(line =>
            {
                try
                {
                    var spellData = ParseCustomSpellData(line);
                    if (spellData != null)
                    {
                        spellList.Add(spellData);
                        helper.AddToList(SpellsNameDB, spellData.Name, spellData);

                        if (!SpellsAbbrvDB.ContainsKey(spellData.NameAbbrv))
                        {
                            SpellsAbbrvDB[spellData.NameAbbrv] = spellData;
                        }
                        else if (string.Compare(SpellsAbbrvDB[spellData.NameAbbrv].Name, spellData.Name, true, CultureInfo.CurrentCulture) < 0)
                        {
                            // try to keep the newest version
                            SpellsAbbrvDB[spellData.NameAbbrv] = spellData;
                        }

                        if (spellData.LandsOnOther.StartsWith("'s ", StringComparison.Ordinal))
                        {
                            spellData.LandsOnOther = spellData.LandsOnOther.Substring(3);
                            helper.AddToList(PosessiveLandsOnOthers, spellData.LandsOnOther, spellData);
                        }
                        else if (!string.IsNullOrEmpty(spellData.LandsOnOther))
                        {
                            spellData.LandsOnOther = spellData.LandsOnOther.Substring(1);
                            helper.AddToList(NonPosessiveLandsOnOthers, spellData.LandsOnOther, spellData);
                        }

                        if (!string.IsNullOrEmpty(spellData.LandsOnYou)) // just do stuff in common
                        {
                            helper.AddToList(LandsOnYou, spellData.LandsOnYou, spellData);
                        }
                    }
                }
                catch (OverflowException ex)
                {
                    LOG.Error("Error reading spell data", ex);
                }
            });

            // sort by duration for the timeline to pick better options
            NonPosessiveLandsOnOthers.Values.ToList().ForEach(value => value.Sort((a, b) => DurationCompare(a, b)));
            PosessiveLandsOnOthers.Values.ToList().ForEach(value => value.Sort((a, b) => DurationCompare(a, b)));
            LandsOnYou.Values.ToList().ForEach(value => value.Sort((a, b) => DurationCompare(a, b)));

            var keepOut    = new Dictionary <string, byte>();
            var classEnums = Enum.GetValues(typeof(SpellClass)).Cast <SpellClass>().ToList();

            spellList.ForEach(spell =>
            {
                // exact match meaning class-only spell that are of certain target types
                var tgt = (SpellTarget)spell.Target;
                if (spell.Level <= 250 && (tgt == SpellTarget.SELF || tgt == SpellTarget.SINGLETARGET || tgt == SpellTarget.LOS || spell.Rank > 1) &&
                    classEnums.Contains((SpellClass)spell.ClassMask))
                {
                    // Obviously illusions are bad to look for
                    // Call of Fire is Ranger only and self target but VT clickie lets warriors use it
                    if (spell.Name.IndexOf("Illusion", StringComparison.OrdinalIgnoreCase) == -1 && spell.Name.IndexOf("Call of Fire", StringComparison.OrdinalIgnoreCase) == -1)
                    {
                        // these need to be unique and keep track if a conflict is found
                        if (SpellsToClass.ContainsKey(spell.Name))
                        {
                            SpellsToClass.TryRemove(spell.Name, out SpellClass _);
                            keepOut[spell.Name] = 1;
                        }
                        else if (!keepOut.ContainsKey(spell.Name))
                        {
                            SpellsToClass[spell.Name] = (SpellClass)spell.ClassMask;
                        }
                    }
                }
            });

            // load NPCs
            ConfigUtil.ReadList(@"data\npcs.txt").ForEach(line => AllNpcs[line.Trim()] = 1);

            // Load Adps
            AdpsKeys.ForEach(adpsKey => AdpsActive[adpsKey] = new Dictionary <string, uint>());
            AdpsKeys.ForEach(adpsKey => AdpsValues[adpsKey] = new Dictionary <string, uint>());

            string key = null;

            foreach (var line in ConfigUtil.ReadList(@"data\adpsMeter.txt"))
            {
                if (!string.IsNullOrEmpty(line) && line.Trim() is string trimmed && trimmed.Length > 0)
                {
                    if (trimmed[0] != '#' && !string.IsNullOrEmpty(key))
                    {
                        if (trimmed.Split('|') is string[] multiple && multiple.Length > 0)
                        {
                            foreach (var spellLine in multiple)
                            {
                                if (spellLine.Split('=') is string[] list && list.Length == 2 && uint.TryParse(list[1], out uint rate))
                                {
                                    if (GetAdpsByName(list[0]) is SpellData spellData)
                                    {
                                        AdpsValues[key][spellData.NameAbbrv] = rate;

                                        if (!AdpsWearOff.TryGetValue(spellData.WearOff, out HashSet <SpellData> wearOffList))
                                        {
                                            AdpsWearOff[spellData.WearOff] = new HashSet <SpellData>();
                                        }

                                        AdpsWearOff[spellData.WearOff].Add(spellData);

                                        if (!AdpsLandsOn.TryGetValue(spellData.LandsOnYou, out HashSet <SpellData> landsOnList))
                                        {
                                            AdpsLandsOn[spellData.LandsOnYou] = new HashSet <SpellData>();
                                        }

                                        AdpsLandsOn[spellData.LandsOnYou].Add(spellData);
                                    }
                                }
                            }
                        }
                    }
                    else if (AdpsKeys.Contains(trimmed))
                    {
                        key = trimmed;
                    }
                }
            }

            PlayerManager.Instance.EventsNewTakenPetOrPlayerAction += (sender, name) => RemoveFight(name);
            PlayerManager.Instance.EventsNewVerifiedPlayer         += (sender, name) => RemoveFight(name);
            PlayerManager.Instance.EventsNewVerifiedPet            += (sender, name) => RemoveFight(name);

            int DurationCompare(SpellData a, SpellData b)
            {
                if (b.Duration.CompareTo(a.Duration) is int result && result == 0)
                {
                    if (int.TryParse(a.ID, out int aInt) && int.TryParse(b.ID, out int bInt) && aInt != bInt)
                    {
                        result = aInt > bInt ? -1 : 1;
                    }
                }

                return(result);
            }
        }
Example #2
0
        private void ArchiveChat(object state)
        {
            try
            {
                List <ChatType> working            = null;
                DateUtil        dateUtil           = new DateUtil();
                DateUtil        dateUtilSavedLines = new DateUtil();

                lock (LockObject)
                {
                    working   = ChatTypes;
                    ChatTypes = new List <ChatType>();
                }

                for (int i = 0; i < working.Count; i++)
                {
                    var      chatType = working[i];
                    var      chatLine = CreateLine(dateUtil, chatType.Line);
                    DateTime dateTime = DateTime.MinValue.AddSeconds(chatLine.BeginTime);
                    string   year     = dateTime.ToString("yyyy", CultureInfo.CurrentCulture);
                    string   month    = dateTime.ToString("MM", CultureInfo.CurrentCulture);
                    string   day      = dateTime.ToString("dd", CultureInfo.CurrentCulture);
                    AddToArchive(year, month, day, chatLine, chatType, dateUtilSavedLines);
                }

                lock (LockObject)
                {
                    if (ChatTypes.Count > 0)
                    {
                        ArchiveTimer?.Dispose();
                        ArchiveTimer = new Timer(new TimerCallback(ArchiveChat));
                        ArchiveTimer.Change(0, Timeout.Infinite);
                    }
                    else
                    {
                        SaveCurrent(true);

                        if (ChannelCacheUpdated)
                        {
                            var current = ChannelCache.Keys.ToList();
                            ConfigUtil.SaveList(PLAYER_DIR + @"\channels.txt", current);
                            ChannelCacheUpdated = false;
                            EventsNewChannels?.Invoke(this, current);
                        }

                        if (PlayerCacheUpdated)
                        {
                            ConfigUtil.SaveList(PLAYER_DIR + @"\players.txt", PlayerCache.Keys.OrderBy(player => player)
                                                .Where(player => !PlayerManager.Instance.IsVerifiedPet(player)).ToList());
                            PlayerCacheUpdated = false;
                        }

                        EventsUpdatePlayer?.Invoke(this, CurrentPlayer);
                        Running = false;
                    }
                }
            }
            catch (ObjectDisposedException ex)
            {
                LOG.Error(ex);
            }
        }
        public FightTable()
        {
            InitializeComponent();

            // fight search box
            fightSearchBox.FontStyle = FontStyles.Italic;
            fightSearchBox.Text      = Properties.Resources.NPC_SEARCH_TEXT;

            fightMenuItemClear.IsEnabled  = fightMenuItemSelectAll.IsEnabled = fightMenuItemUnselectAll.IsEnabled = fightMenuItemSelectFight.IsEnabled = false;
            fightMenuItemSetPet.IsEnabled = fightMenuItemSetPlayer.IsEnabled = false;

            var view = CollectionViewSource.GetDefaultView(Fights);

            view.Filter = new Predicate <object>(item =>
            {
                var fightItem = (Fight)item;
                return(CurrentShowBreaks ? fightItem.GroupId >= -1 : fightItem.GroupId > -1);
            });

            fightDataGrid.ItemsSource = view;

            SelectionTimer = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 0, 0, 800)
            };
            SelectionTimer.Tick += (sender, e) =>
            {
                EventsSelectionChange(this, fightDataGrid.SelectedItems);
                SelectionTimer.Stop();
            };

            SearchTextTimer = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 0, 0, 400)
            };
            SearchTextTimer.Tick += (sender, e) =>
            {
                HandleSearchTextChanged();
                SearchTextTimer.Stop();
            };

            UpdateTimer = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 0, 0, 500)
            };
            UpdateTimer.Tick += (sender, e) =>
            {
                // get state so it can't be modified outside this thread
                var currentNeedRefresh = NeedRefresh;

                if (NeedScroll)
                {
                    (fightDataGrid.ItemsSource as ICollectionView).Refresh();
                    currentNeedRefresh = false;
                    NeedRefresh        = false;

                    var last = Fights.LastOrDefault(fight => fight.GroupId > -1);

                    if (last != null)
                    {
                        fightDataGrid.ScrollIntoView(last);
                    }

                    NeedScroll = false;
                }

                if (currentNeedRefresh)
                {
                    (fightDataGrid.ItemsSource as ICollectionView).Refresh();
                    NeedRefresh = false;
                }
            };

            UpdateTimer.Start();

            // read show hp setting
            string showHitPoints = ConfigUtil.GetApplicationSetting("NpcShowHitPoints");

            fightShowHitPoints.IsChecked        = bool.TryParse(showHitPoints, out bool bValue) && bValue;
            fightDataGrid.Columns[1].Visibility = bValue ? Visibility.Visible : Visibility.Hidden;

            // read show breaks setting
            string showBreaks = ConfigUtil.GetApplicationSetting("NpcShowInactivityBreaks");

            fightShowBreaks.IsChecked = CurrentShowBreaks = (showBreaks == null || (bool.TryParse(showBreaks, out bValue) && bValue));
        }
Example #4
0
        public FightTable()
        {
            InitializeComponent();

            // fight search box
            fightSearchBox.FontStyle = FontStyles.Italic;
            fightSearchBox.Text      = Properties.Resources.NPC_SEARCH_TEXT;

            fightMenuItemClear.IsEnabled           = fightMenuItemSelectAll.IsEnabled = fightMenuItemUnselectAll.IsEnabled =
                fightMenuItemSelectFight.IsEnabled = fightMenuItemUnselectFight.IsEnabled = fightMenuItemSetPet.IsEnabled = fightMenuItemSetPlayer.IsEnabled = false;

            View           = CollectionViewSource.GetDefaultView(Fights);
            NonTankingView = CollectionViewSource.GetDefaultView(NonTankingFights);

            var filter = new Predicate <object>(item => !(CurrentShowBreaks == false && ((Fight)item).IsInactivity));

            View.Filter           = filter;
            NonTankingView.Filter = filter;

            SelectionTimer = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 0, 0, 800)
            };
            SelectionTimer.Tick += (sender, e) =>
            {
                if (!rightClickMenu.IsOpen)
                {
                    EventsSelectionChange(this, fightDataGrid.SelectedItems);
                }
                else
                {
                    NeedSelectionChange = true;
                }

                SelectionTimer.Stop();
            };

            SearchTextTimer = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 0, 0, 500)
            };
            SearchTextTimer.Tick += (sender, e) =>
            {
                HandleSearchTextChanged();
                SearchTextTimer.Stop();
            };

            UpdateTimer = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 0, 0, 1500)
            };
            UpdateTimer.Tick += (sender, e) => ProcessFights();
            UpdateTimer.Start();

            // read show hp setting
            fightShowHitPoints.IsChecked        = ConfigUtil.IfSet("NpcShowHitPoints");
            fightDataGrid.Columns[1].Visibility = fightShowHitPoints.IsChecked.Value ? Visibility.Visible : Visibility.Hidden;

            // read show breaks and spells setting
            fightShowBreaks.IsChecked  = CurrentShowBreaks = ConfigUtil.IfSet("NpcShowInactivityBreaks", null, true);
            fightShowTanking.IsChecked = ConfigUtil.IfSet("NpcShowTanking", null, true);

            fightDataGrid.ItemsSource = fightShowTanking.IsChecked.Value ? View : NonTankingView;

            DataManager.Instance.EventsClearedActiveData  += Instance_EventsCleardActiveData;
            DataManager.Instance.EventsRemovedFight       += Instance_EventsRemovedFight;
            DataManager.Instance.EventsNewFight           += Instance_EventsNewFight;
            DataManager.Instance.EventsUpdateFight        += Instance_EventsUpdateFight;
            DataManager.Instance.EventsNewNonTankingFight += Instance_EventsNewNonTankingFight;
        }
Example #5
0
        public ChatViewer()
        {
            InitializeComponent();

            fontSize.ItemsSource = FontSizeList;
            startDate.Text       = Properties.Resources.CHAT_START_DATE;
            endDate.Text         = Properties.Resources.CHAT_END_DATE;
            textFilter.Text      = Properties.Resources.CHAT_TEXT_FILTER;

            var context = new AutoCompleteText()
            {
                Text = Properties.Resources.CHAT_TO_FILTER
            };

            context.Items.AddRange(PlayerAutoCompleteList);
            toFilter.DataContext = context;

            context = new AutoCompleteText()
            {
                Text = Properties.Resources.CHAT_FROM_FILTER
            };
            context.Items.AddRange(PlayerAutoCompleteList);
            fromFilter.DataContext = context;

            string fgColor = ConfigUtil.GetSetting("ChatFontFgColor");

            if (fontFgColor.ItemsSource is List <ColorItem> colors)
            {
                fontFgColor.SelectedItem = (colors.Find(item => item.Name == fgColor) is ColorItem found) ? found : colors.Find(item => item.Name == "#ffffff");
            }

            string family = ConfigUtil.GetSetting("ChatFontFamily");

            fontFamily.SelectedItem = (family != null) ? new FontFamily(family) : chatBox.FontFamily;

            string size = ConfigUtil.GetSetting("ChatFontSize");

            if (size != null && double.TryParse(size, out double dsize))
            {
                fontSize.SelectedItem = dsize;
            }
            else
            {
                fontSize.SelectedValue = chatBox.FontSize;
            }

            FilterTimer = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 0, 0, 500)
            };
            FilterTimer.Tick += (sender, e) =>
            {
                FilterTimer.Stop();
                ChangeSearch();
            };

            RefreshTimer = new DispatcherTimer {
                Interval = new TimeSpan(0, 0, 1)
            };
            RefreshTimer.Tick += (sender, e) =>
            {
                ChatIterator newIterator = new ChatIterator(players.SelectedValue as string, CurrentChatFilter);
                var          tempChat    = FirstChat;
                var          tempFilter  = CurrentChatFilter;

                if (tempChat != null)
                {
                    Task.Run(() =>
                    {
                        foreach (var chatType in newIterator.TakeWhile(chatType => chatType.Line != tempChat.Line).Reverse())
                        {
                            Dispatcher.Invoke(() =>
                            {
                                // make sure user didnt start new search
                                if (tempFilter == CurrentChatFilter && RefreshTimer.IsEnabled && tempFilter.PastLiveFilter(chatType))
                                {
                                    if (chatBox.Document.Blocks.Count == 0)
                                    {
                                        MainParagraph = new Paragraph {
                                            Margin = new Thickness(0, 0, 0, 0), Padding = new Thickness(4, 0, 0, 4)
                                        };
                                        chatBox.Document.Blocks.Add(MainParagraph);
                                        MainParagraph.Inlines.Add(new Run());
                                    }

                                    var newItem = new Span(new Run(Environment.NewLine));
                                    newItem.Inlines.Add(new Run(chatType.Line));
                                    MainParagraph.Inlines.InsertAfter(MainParagraph.Inlines.LastInline, newItem);
                                    statusCount.Text = ++CurrentLineCount + " Lines";

                                    FirstChat = chatType;
                                }
                            }, DispatcherPriority.DataBind);
                        }

                        Dispatcher.Invoke(() => RefreshTimer.Stop());
                    });
                }
            };

            LoadPlayers();

            Ready = true;
            ChangeSearch();

            ChatManager.EventsUpdatePlayer += ChatManager_EventsUpdatePlayer;
            ChatManager.EventsNewChannels  += ChatManager_EventsNewChannels;
        }
Example #6
0
 internal static bool LoadSettings()
 {
     IsDamageOverlayEnabled = ConfigUtil.IfSet("IsDamageOverlayEnabled");
     return(IsDamageOverlayEnabled);
 }
Example #7
0
        public MainWindow()
        {
            try
            {
                InitializeComponent();

                // update titles
#pragma warning disable CA1303 // Do not pass literals as localized parameters
                versionText.Text = VERSION;
#pragma warning restore CA1303 // Do not pass literals as localized parameters

                // used for setting menu icons based on open windows
                IconToWindow = new Dictionary <string, DockingWindow>()
                {
                    { npcIcon.Name, npcWindow }, { verifiedPlayersIcon.Name, verifiedPlayersWindow },
                    { verifiedPetsIcon.Name, verifiedPetsWindow }, { petMappingIcon.Name, petMappingWindow },
                    { playerParseIcon.Name, playerParseTextWindow }
                };

                // Clear/Reset
                DataManager.Instance.EventsClearedActiveData += Instance_EventsClearedActiveData;

                // verified pets table
                verifiedPetsGrid.ItemsSource = VerifiedPetsView;
                PlayerManager.Instance.EventsNewVerifiedPet += (sender, name) => Dispatcher.InvokeAsync(() =>
                {
                    Helpers.InsertNameIntoSortedList(name, VerifiedPetsView);
                    verifiedPetsWindow.Title = string.Format(CultureInfo.CurrentCulture, PETS_LIST_TITLE, VerifiedPetsView.Count);
                });

                // pet -> players
                petMappingGrid.ItemsSource = PetPlayersView;
                PlayerManager.Instance.EventsNewPetMapping += (sender, mapping) =>
                {
                    Dispatcher.InvokeAsync(() =>
                    {
                        var existing = PetPlayersView.FirstOrDefault(item => item.Pet.Equals(mapping.Pet, StringComparison.OrdinalIgnoreCase));
                        if (existing != null && existing.Owner != mapping.Owner)
                        {
                            existing.Owner = mapping.Owner;
                        }
                        else
                        {
                            PetPlayersView.Add(mapping);
                        }

                        petMappingWindow.Title = "Pet Owners (" + PetPlayersView.Count + ")";
                    });
                    CheckComputeStats();
                };

                PlayerManager.Instance.EventsRemoveVerifiedPet += (sender, name) => Dispatcher.InvokeAsync(() =>
                {
                    var found = VerifiedPetsView.FirstOrDefault(item => item.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
                    if (found != null)
                    {
                        VerifiedPetsView.Remove(found);
                        verifiedPetsWindow.Title = string.Format(CultureInfo.CurrentCulture, PETS_LIST_TITLE, VerifiedPetsView.Count);

                        var existing = PetPlayersView.FirstOrDefault(item => item.Pet.Equals(name, StringComparison.OrdinalIgnoreCase));
                        if (existing != null)
                        {
                            PetPlayersView.Remove(existing);
                            petMappingWindow.Title = "Pet Owners (" + PetPlayersView.Count + ")";
                        }
                        CheckComputeStats();
                    }
                });

                // verified player table
                verifiedPlayersGrid.ItemsSource = VerifiedPlayersProperty;
                PlayerManager.Instance.EventsNewVerifiedPlayer += (sender, name) => Dispatcher.InvokeAsync(() =>
                {
                    Helpers.InsertNameIntoSortedList(name, VerifiedPlayersProperty);
                    verifiedPlayersWindow.Title = string.Format(CultureInfo.CurrentCulture, PLAYER_LIST_TITLE, VerifiedPlayersProperty.Count);
                });

                PlayerManager.Instance.EventsRemoveVerifiedPlayer += (sender, name) => Dispatcher.InvokeAsync(() =>
                {
                    var found = VerifiedPlayersProperty.FirstOrDefault(item => item.Name.Equals(name, StringComparison.OrdinalIgnoreCase));
                    if (found != null)
                    {
                        VerifiedPlayersProperty.Remove(found);
                        verifiedPlayersWindow.Title = string.Format(CultureInfo.CurrentCulture, PLAYER_LIST_TITLE, VerifiedPlayersProperty.Count);

                        var existing = PetPlayersView.FirstOrDefault(item => item.Owner.Equals(name, StringComparison.OrdinalIgnoreCase));
                        if (existing != null)
                        {
                            PetPlayersView.Remove(existing);
                            petMappingWindow.Title = "Pet Owners (" + PetPlayersView.Count + ")";
                        }
                        CheckComputeStats();
                    }
                });

                (npcWindow.Content as FightTable).EventsSelectionChange += (sender, data) => ComputeStats();
                DamageStatsManager.Instance.EventsUpdateDataPoint       += (sender, data) => HandleChartUpdateEvent(DamageChartWindow, sender, data);
                HealingStatsManager.Instance.EventsUpdateDataPoint      += (sender, data) => HandleChartUpdateEvent(HealingChartWindow, sender, data);
                TankingStatsManager.Instance.EventsUpdateDataPoint      += (sender, data) => HandleChartUpdateEvent(TankingChartWindow, sender, data);

                // Setup themes
                ThemeManager.BeginUpdate();
                ThemeManager.AreNativeThemesEnabled = true;
                SystemThemeCatalogRegistrar.Register();
                ThemeManager.CurrentTheme = ThemeNames.Dark;

                UpdateDeleteChatMenu();

                // Bane Damage
                IsBaneDamageEnabled             = ConfigUtil.IfSet("IncludeBaneDamage");
                enableBaneDamageIcon.Visibility = IsBaneDamageEnabled ? Visibility.Visible : Visibility.Hidden;

                // Damage Overlay
                enableDamageOverlayIcon.Visibility = OverlayUtil.LoadSettings() ? Visibility.Visible : Visibility.Hidden;

                // AoE healing
                IsAoEHealingEnabled             = ConfigUtil.IfSet("IncludeAoEHealing");
                enableAoEHealingIcon.Visibility = IsAoEHealingEnabled ? Visibility.Visible : Visibility.Hidden;

                // Hide window when minimized
                IsHideOnMinimizeEnabled             = ConfigUtil.IfSet("HideWindowOnMinimize");
                enableHideOnMinimizeIcon.Visibility = IsHideOnMinimizeEnabled ? Visibility.Visible : Visibility.Hidden;

                // Show Tanking Summary at startup
                ConfigUtil.IfSet("ShowTankingSummaryAtStartup", OpenTankingSummary);
                // Show Healing Summary at startup
                ConfigUtil.IfSet("ShowHealingSummaryAtStartup", OpenHealingSummary);
                // Show Healing Summary at startup
                ConfigUtil.IfSet("ShowDamageSummaryAtStartup", OpenDamageSummary, true);
                // Show Tanking Summary at startup
                ConfigUtil.IfSet("ShowTankingChartAtStartup", OpenTankingChart);
                // Show Healing Summary at startup
                ConfigUtil.IfSet("ShowHealingChartAtStartup", OpenHealingChart);
                // Show Healing Summary at startup
                ConfigUtil.IfSet("ShowDamageChartAtStartup", OpenDamageChart);
                LOG.Info("Initialized Components");

                if (ConfigUtil.IfSet("AutoMonitor"))
                {
                    enableAutoMonitorIcon.Visibility = Visibility.Visible;
                    var previousFile = ConfigUtil.GetSetting("LastOpenedFile");
                    if (File.Exists(previousFile))
                    {
                        OpenLogFile(LogOption.MONITOR, previousFile);
                    }
                }
                else
                {
                    enableAutoMonitorIcon.Visibility = Visibility.Hidden;
                }

                if (ConfigUtil.IfSet("Debug"))
                {
                    LOG.Info("Debug Enabled. Saving Unprocessed Lines to " + ConfigUtil.LogsDir);
                    ConfigUtil.Debug = true;
                }
            }
            catch (Exception e)
            {
                LOG.Error(e);
                throw;
            }
            finally
            {
                ThemeManager.EndUpdate();
            }
        }
Example #8
0
        public OverlayWindow(bool configure = false)
        {
            InitializeComponent();
            LoadColorSettings();

            string width  = ConfigUtil.GetSetting("OverlayWidth");
            string height = ConfigUtil.GetSetting("OverlayHeight");
            string top    = ConfigUtil.GetSetting("OverlayTop");
            string left   = ConfigUtil.GetSetting("OverlayLeft");

            // Hide other player names on overlay
            IsHideOverlayOtherPlayersEnabled = ConfigUtil.IfSet("HideOverlayOtherPlayers");
            showNameSelection.SelectedIndex  = IsHideOverlayOtherPlayersEnabled ? 1 : 0;

            // Hide/Show crit rate
            IsShowOverlayCritRateEnabled        = ConfigUtil.IfSet("ShowOverlayCritRate");
            showCritRateSelection.SelectedIndex = IsShowOverlayCritRateEnabled ? 1 : 0;

            var  margin     = SystemParameters.WindowNonClientFrameThickness;
            bool offsetSize = configure || width == null || height == null || top == null || left == null;

            if (!offsetSize)
            {
                CreateRows();
                Title       = "Overlay";
                MinHeight   = 0;
                UpdateTimer = new DispatcherTimer {
                    Interval = new TimeSpan(0, 0, 0, 0, 1000)
                };
                UpdateTimer.Tick  += UpdateTimerTick;
                AllowsTransparency = true;
                Style       = null;
                WindowStyle = WindowStyle.None;
                SetVisible(false);
                ShowActivated = false;
            }
            else
            {
                overlayCanvas.Background = new SolidColorBrush(Color.FromRgb(45, 45, 48));
                CreateRows(true);
                MinHeight          = 130;
                AllowsTransparency = false;
                WindowStyle        = WindowStyle.SingleBorderWindow;
                SetVisible(true);
                LoadTestData();
            }

            if (width != null && double.TryParse(width, out double dvalue) && !double.IsNaN(dvalue))
            {
                Width = offsetSize ? dvalue + margin.Left + margin.Right : dvalue;
            }

            if (height != null && double.TryParse(height, out dvalue) && !double.IsNaN(dvalue))
            {
                Height = offsetSize ? dvalue + margin.Top + margin.Bottom : 0;
                if (!offsetSize)
                {
                    CalculatedRowHeight = dvalue / (MAX_ROWS + 1);
                }
            }

            if (top != null && double.TryParse(top, out dvalue) && !double.IsNaN(dvalue))
            {
                var test = offsetSize ? dvalue - margin.Top : dvalue;
                if (test >= SystemParameters.VirtualScreenTop && test < SystemParameters.VirtualScreenHeight)
                {
                    Top = test;
                }
            }

            if (left != null && double.TryParse(left, out dvalue) && !double.IsNaN(dvalue))
            {
                var test = offsetSize ? dvalue - margin.Left : dvalue;
                if (test >= SystemParameters.VirtualScreenLeft && test < SystemParameters.VirtualScreenWidth)
                {
                    Left = test;
                }
            }

            int damageMode = ConfigUtil.GetSettingAsInteger("OverlayDamageMode");

            foreach (var item in damageModeSelection.Items.Cast <ComboBoxItem>())
            {
                if ((string)item.Tag == damageMode.ToString(CultureInfo.CurrentCulture))
                {
                    damageModeSelection.SelectedItem = item;
                    CurrentDamageSelectionMode       = damageMode;
                }
            }

            string fontSize        = ConfigUtil.GetSetting("OverlayFontSize");
            bool   fontHasBeenSet  = false;
            int    currentFontSize = DEFAULT_TEXT_FONT_SIZE;

            if (fontSize != null && int.TryParse(fontSize, out currentFontSize) && currentFontSize >= 0 && currentFontSize <= 64)
            {
                foreach (var item in fontSizeSelection.Items)
                {
                    if ((item as ComboBoxItem).Tag as string == fontSize)
                    {
                        fontSizeSelection.SelectedItem = item;
                        SetFont(currentFontSize);
                        fontHasBeenSet = true;
                    }
                }
            }

            if (!fontHasBeenSet)
            {
                SetFont(currentFontSize);
            }

            if (!offsetSize)
            {
                NpcDamageManager.EventsPlayerAttackProcessed += NpcDamageManager_EventsPlayerAttackProcessed;
                DataManager.Instance.EventsNewInactiveFight  += Instance_EventsNewInactiveFight;
                Active = true;
            }
            else
            {
                // remove when configuring
                NpcDamageManager.EventsPlayerAttackProcessed -= NpcDamageManager_EventsPlayerAttackProcessed;
                DataManager.Instance.EventsNewInactiveFight  -= Instance_EventsNewInactiveFight;
            }

            if (!configure)
            {
                var settingsButton = CreateButton("Change Settings", "\xE713", currentFontSize - 1);
                settingsButton.Click += (object sender, RoutedEventArgs e) => OverlayUtil.OpenOverlay(Dispatcher, true, false);
                settingsButton.Margin = new Thickness(4, 0, 0, 0);

                var copyButton = CreateButton("Copy Parse", "\xE8C8", currentFontSize - 1);
                copyButton.Click += (object sender, RoutedEventArgs e) =>
                {
                    lock (Stats)
                    {
                        (Application.Current.MainWindow as MainWindow)?.AddAndCopyDamageParse(Stats, Stats.StatsList);
                    }
                };

                var refreshButton = CreateButton("Cancel Current Parse", "\xE8BB", currentFontSize - 1);
                refreshButton.Click += (object sender, RoutedEventArgs e) => OverlayUtil.ResetOverlay(Dispatcher);

                ButtonPopup  = new Popup();
                ButtonsPanel = CreateNameStackPanel();
                ButtonsPanel.Children.Add(settingsButton);
                ButtonsPanel.Children.Add(copyButton);
                ButtonsPanel.Children.Add(refreshButton);
                ButtonPopup.Child = ButtonsPanel;
                ButtonPopup.AllowsTransparency = true;
                ButtonPopup.Opacity            = 0.3;
                ButtonPopup.Placement          = PlacementMode.Relative;
                ButtonPopup.PlacementTarget    = this;
                ButtonPopup.VerticalOffset     = -1;

                ButtonsPanel.SizeChanged += (object sender, SizeChangedEventArgs e) =>
                {
                    if (TitlePanel.Margin.Left != e.NewSize.Width + 2)
                    {
                        TitlePanel.Margin = new Thickness(e.NewSize.Width + 2, TitlePanel.Margin.Top, 0, TitlePanel.Margin.Bottom);
                    }

                    if (ButtonsPanel != null && ButtonsPanel.ActualHeight != TitlePanel.ActualHeight)
                    {
                        ButtonsPanel.Height = TitlePanel.ActualHeight;
                    }
                };
            }
        }
Example #9
0
 private void ToggleAutoMonitorClick(object sender, RoutedEventArgs e)
 {
     ConfigUtil.SetSetting("AutoMonitor", (enableAutoMonitorIcon.Visibility == Visibility.Hidden).ToString(CultureInfo.CurrentCulture));
     enableAutoMonitorIcon.Visibility = enableAutoMonitorIcon.Visibility == Visibility.Visible ? Visibility.Hidden : Visibility.Visible;
 }
Example #10
0
 private void ToggleHideOnMinimizeClick(object sender, RoutedEventArgs e)
 {
     IsHideOnMinimizeEnabled = !IsHideOnMinimizeEnabled;
     ConfigUtil.SetSetting("HideWindowOnMinimize", IsHideOnMinimizeEnabled.ToString(CultureInfo.CurrentCulture));
     enableHideOnMinimizeIcon.Visibility = IsHideOnMinimizeEnabled ? Visibility.Visible : Visibility.Hidden;
 }
Example #11
0
        internal static Dictionary <string, bool> ShowColumns(ComboBox columns, DataGrid dataGrid, List <DataGrid> children = null)
        {
            Dictionary <string, bool> cache = new Dictionary <string, bool>();

            if (columns.Items.Count > 0)
            {
                for (int i = 0; i < columns.Items.Count; i++)
                {
                    var checkedItem = columns.Items[i] as ComboBoxItemDetails;
                    if (checkedItem.IsChecked)
                    {
                        cache[checkedItem.Text] = true;
                    }
                }

                SetSelectedColumnsTitle(columns, cache.Count);

                for (int i = 0; i < dataGrid.Columns.Count; i++)
                {
                    string header = dataGrid.Columns[i].Header as string;
                    if (!string.IsNullOrEmpty(header) && header != "Name")
                    {
                        if (cache.ContainsKey(header))
                        {
                            if (dataGrid.Columns[i].Visibility != Visibility.Visible)
                            {
                                dataGrid.Columns[i].Visibility = Visibility.Visible;
                            }

                            if (children != null)
                            {
                                children.ForEach(child =>
                                {
                                    if (child.Columns[i].Visibility != Visibility.Visible)
                                    {
                                        child.Columns[i].Visibility = Visibility.Visible;
                                    }
                                });
                            }
                        }
                        else
                        {
                            if (dataGrid.Columns[i].Visibility != Visibility.Hidden)
                            {
                                dataGrid.Columns[i].Visibility = Visibility.Hidden;
                            }

                            if (children != null)
                            {
                                children.ForEach(child =>
                                {
                                    if (child.Columns[i].Visibility != Visibility.Hidden)
                                    {
                                        child.Columns[i].Visibility = Visibility.Hidden;
                                    }
                                });
                            }
                        }
                    }
                }

                if (!string.IsNullOrEmpty(columns.Tag as string))
                {
                    ConfigUtil.SetSetting(columns.Tag as string, string.Join(",", cache.Keys));
                }
            }

            return(cache);
        }
Example #12
0
        internal static Dictionary <string, bool> LoadColumns(ComboBox columns, DataGrid dataGrid)
        {
            var indexesCache = new Dictionary <string, int>();
            var indexString  = ConfigUtil.GetSetting(columns.Tag as string + "DisplayIndex");

            if (!string.IsNullOrEmpty(indexString))
            {
                foreach (var index in indexString.Split(','))
                {
                    if (!string.IsNullOrEmpty(index))
                    {
                        var split = index.Split('|');
                        if (split != null && split.Length == 2 && !string.IsNullOrEmpty(split[0]) && !string.IsNullOrEmpty(split[1]))
                        {
                            if (int.TryParse(split[1], out int result))
                            {
                                indexesCache[split[0]] = result;
                            }
                        }
                    }
                }
            }

            var    cache         = new Dictionary <string, bool>();
            string columnSetting = ConfigUtil.GetSetting(columns.Tag as string);

            if (!string.IsNullOrEmpty(columnSetting))
            {
                foreach (var selected in columnSetting.Split(','))
                {
                    cache[selected] = true;
                }
            }

            int selectedCount = 0;
            List <ComboBoxItemDetails> list = new List <ComboBoxItemDetails>();

            for (int i = 0; i < dataGrid.Columns.Count; i++)
            {
                var column = dataGrid.Columns[i];
                var header = column.Header as string;
                if (!string.IsNullOrEmpty(header))
                {
                    if (header != "Name")
                    {
                        var visible = (cache.Count == 0 && column.Visibility == Visibility.Visible) || cache.ContainsKey(header);
                        column.Visibility = visible ? Visibility.Visible : Visibility.Hidden;
                        selectedCount    += visible ? 1 : 0;
                        list.Add(new ComboBoxItemDetails {
                            Text = column.Header as string, IsChecked = visible
                        });

                        if (indexesCache.ContainsKey(header) && column.DisplayIndex != indexesCache[header])
                        {
                            column.DisplayIndex = indexesCache[header];
                        }
                    }
                }
            }

            columns.ItemsSource = list;
            SetSelectedColumnsTitle(columns, selectedCount);
            return(cache);
        }
        public OverlayWindow(bool configure = false)
        {
            InitializeComponent();

            string width  = ConfigUtil.GetApplicationSetting("OverlayWidth");
            string height = ConfigUtil.GetApplicationSetting("OverlayHeight");
            string top    = ConfigUtil.GetApplicationSetting("OverlayTop");
            string left   = ConfigUtil.GetApplicationSetting("OverlayLeft");

            var  margin     = SystemParameters.WindowNonClientFrameThickness;
            bool offsetSize = configure || width == null || height == null || top == null || left == null;

            if (!offsetSize)
            {
                CreateRows();
                Title       = "Overlay";
                MinHeight   = 0;
                UpdateTimer = new DispatcherTimer {
                    Interval = new TimeSpan(0, 0, 0, 0, 1500)
                };
                UpdateTimer.Tick  += UpdateTimerTick;
                AllowsTransparency = true;
                Style       = null;
                WindowStyle = WindowStyle.None;
                SetVisible(false);
                ShowActivated = false;
            }
            else
            {
                CreateRows(true);
                MinHeight          = 130;
                AllowsTransparency = false;
                WindowStyle        = WindowStyle.SingleBorderWindow;
                SetVisible(true);
                LoadTestData();
            }

            if (width != null && double.TryParse(width, out double dvalue) && !double.IsNaN(dvalue))
            {
                Width = offsetSize ? dvalue + margin.Left + margin.Right : dvalue;
            }

            if (height != null && double.TryParse(height, out dvalue) && !double.IsNaN(dvalue))
            {
                Height = offsetSize ? dvalue + margin.Top + margin.Bottom : 0;
                if (!offsetSize)
                {
                    CalculatedRowHeight = dvalue / (MAX_ROWS + 1);
                }
            }

            if (top != null && double.TryParse(top, out dvalue) && !double.IsNaN(dvalue))
            {
                var test = offsetSize ? dvalue - margin.Top : dvalue;
                if (test >= SystemParameters.VirtualScreenTop && test < SystemParameters.VirtualScreenHeight)
                {
                    Top = test;
                }
            }

            if (left != null && double.TryParse(left, out dvalue) && !double.IsNaN(dvalue))
            {
                var test = offsetSize ? dvalue - margin.Left : dvalue;
                if (test >= SystemParameters.VirtualScreenLeft && test < SystemParameters.VirtualScreenWidth)
                {
                    Left = test;
                }
            }

            string value           = ConfigUtil.GetApplicationSetting("OverlayFontSize");
            bool   fontHasBeenSet  = false;
            int    currentFontSize = DEFAULT_TEXT_FONT_SIZE;

            if (value != null && int.TryParse(value, out currentFontSize) && currentFontSize >= 0 && currentFontSize <= 64)
            {
                foreach (var item in fontSizeSelection.Items)
                {
                    if ((item as ComboBoxItem).Content as string == value)
                    {
                        fontSizeSelection.SelectedItem = item;
                        SetFont(currentFontSize);
                        fontHasBeenSet = true;
                    }
                }
            }

            if (!fontHasBeenSet)
            {
                SetFont(currentFontSize);
            }

            if (!offsetSize)
            {
                NpcDamageManager.EventsPlayerAttackProcessed += NpcDamageManager_EventsPlayerAttackProcessed;
                DataManager.Instance.EventsNewInactiveFight  += Instance_EventsNewInactiveFight;
                Active = true;
            }
            else
            {
                // remove when configuring
                NpcDamageManager.EventsPlayerAttackProcessed -= NpcDamageManager_EventsPlayerAttackProcessed;
                DataManager.Instance.EventsNewInactiveFight  -= Instance_EventsNewInactiveFight;
            }

            if (!configure)
            {
                var settingsButton = CreateButton();
                settingsButton.ToolTip = new ToolTip {
                    Content = "Change Settings"
                };
                settingsButton.Margin   = new Thickness(8, 1, 0, 0);
                settingsButton.Content  = "\xE713";
                settingsButton.FontSize = currentFontSize - 1;
                settingsButton.Click   += (object sender, RoutedEventArgs e) => (Application.Current.MainWindow as MainWindow)?.OpenOverlay(true, false);

                var copyButton = CreateButton();
                copyButton.ToolTip = new ToolTip {
                    Content = "Copy Parse"
                };
                copyButton.Margin   = new Thickness(4, 1, 0, 0);
                copyButton.Content  = "\xE8C8";
                copyButton.FontSize = currentFontSize - 1;
                copyButton.Click   += (object sender, RoutedEventArgs e) =>
                {
                    lock (Stats)
                    {
                        (Application.Current.MainWindow as MainWindow)?.AddAndCopyDamageParse(Stats, Stats.StatsList);
                    }
                };

                var refreshButton = CreateButton();
                refreshButton.ToolTip = new ToolTip {
                    Content = "Cancel Current Parse"
                };
                refreshButton.Margin   = new Thickness(4, 1, 0, 0);
                refreshButton.Content  = "\xE8BB";
                refreshButton.FontSize = currentFontSize - 2;
                refreshButton.Click   += (object sender, RoutedEventArgs e) => (Application.Current.MainWindow as MainWindow)?.ResetOverlay();

                ButtonPopup = new Popup();
                StackPanel btns = new StackPanel {
                    Orientation = Orientation.Horizontal
                };
                btns.Children.Add(settingsButton);
                btns.Children.Add(copyButton);
                btns.Children.Add(refreshButton);
                ButtonPopup.Child              = btns;
                ButtonPopup.Height             = currentFontSize + 2;
                ButtonPopup.Width              = 80;
                ButtonPopup.AllowsTransparency = true;
                ButtonPopup.Opacity            = 0.3;
                ButtonPopup.HorizontalOffset   = Width / 2.1;
                ButtonPopup.VerticalOffset     = 2;
                ButtonPopup.Placement          = PlacementMode.RelativePoint;
                ButtonPopup.PlacementTarget    = this;
            }
        }