예제 #1
0
        public RandomSuffixEditor(Item item)
        {
            this.item = item;

            InitializeComponent();

#if !SILVERLIGHT
            this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            this.WindowState           = System.Windows.WindowState.Normal;
#endif

            data = new List <SuffixAvailability>();
            foreach (var s in RandomSuffix.GetAllSuffixes())
            {
                SuffixAvailability sa;
                data.Add(sa = new SuffixAvailability()
                {
                    Id        = s,
                    Suffix    = RandomSuffix.GetSuffix(s),
                    Available = item.AllowedRandomSuffixes != null && item.AllowedRandomSuffixes.Contains(s)
                });
                RandomSuffix.AccumulateStats(sa.Stats = new Stats(), item, s);
            }

            SuffixGrid.ItemsSource = data;
        }
예제 #2
0
        public void UpdateTooltip()
        {
            Item actualItem = null;

            if (ItemInstance != null)
            {
                actualItem = ItemInstance.Item;
            }
            else if (Item != null)
            {
                actualItem = Item;
            }
            else if (ItemSet != null)
            {
                NonItemTooltip();
                return;
            }
            else if (CurrentString != null && CurrentString != "")
            {
                NonItemTooltip();
                return;
            }
            else
            {
                RootLayout.Visibility = Visibility.Collapsed;
                return;
            }
            RootLayout.Visibility = Visibility.Visible;

            ItemName.Text       = ItemInstance != null ? ItemInstance.Name : (actualItem != null ? actualItem.Name : "");
            ItemName.Foreground = new SolidColorBrush(ColorForQuality(actualItem != null ? actualItem.Quality : ItemQuality.Common));

            #region Displaying Item Types
            var liTypes = new List <string>();

            if (actualItem != null && (actualItem.Type != ItemType.None || (actualItem.Type == ItemType.None &&
                                                                            (actualItem.Slot == ItemSlot.Back || actualItem.Slot == ItemSlot.Neck || actualItem.Slot == ItemSlot.Finger || actualItem.Slot == ItemSlot.Trinket))))
            {
                //if (Properties.GeneralSettings.Default.DisplayExtraItemInfo) {
                if (actualItem.ItemLevel > 0)
                {
                    liTypes.Add(string.Format("[{0}]", actualItem.ItemLevel));
                }

                liTypes.Add(string.Format("[{0}]", actualItem.Id));

                if (actualItem.Bind != BindsOn.None)
                {
                    liTypes.Add(string.Format("[{0}]", actualItem.Bind));
                }

                if (!string.IsNullOrEmpty(actualItem.SlotString))
                {
                    liTypes.Add(string.Format("[{0}]", actualItem.SlotString));
                }

                if (actualItem.Type != ItemType.None)
                {
                    liTypes.Add(string.Format("[{0}]", actualItem.Type));
                }
                //}
            }
            List2Panel(TypesPanel, liTypes, new SolidColorBrush(Colors.Gray), false);

            #endregion // Displaying Item Types

            #region Displaying Item Stats
            List <string> statsList       = new List <string>();
            List <string> unusedStatsList = new List <string>();
            if (Rawr.Properties.GeneralSettings.Default.DisplayUnusedStats)
            {
                statsList.Add("Used Stats:");
                unusedStatsList.Add("Unused Stats:");
            }

            if (actualItem != null)
            {
                // Pull the Actual Stats, including Random Suffix if it has one
                Stats stats = actualItem.Stats;
                if (ItemInstance != null && ItemInstance.RandomSuffixId != 0)
                {
                    stats = stats.Clone();
                    RandomSuffix.AccumulateStats(stats, actualItem, ItemInstance.RandomSuffixId);
                }
                // Relevant Stats
                Stats relevantStats = Calculations.GetRelevantStats(stats);
                var   nonzeroStats  = relevantStats.Values(x => x != 0);
                foreach (System.Reflection.PropertyInfo info in nonzeroStats.Keys)
                {
                    float value = nonzeroStats[info];
                    if (Stats.IsPercentage(info))
                    {
                        value *= 100;
                    }
                    value = (float)Math.Round(value * 100f) / 100f;
                    string text = string.Format("{0}{1}", value, Extensions.DisplayName(info));
                    statsList.Add(text);
                }
                if (actualItem.DPS > 0)
                {
                    float  dps  = (float)Math.Round(actualItem.DPS * 100f) / 100f;
                    string text = dps + " DPS";
                    statsList.Add(text);
                    text = actualItem.Speed + " Speed";
                    statsList.Add(text);
                }
                foreach (SpecialEffect effect in relevantStats.SpecialEffects())
                {
                    string text = effect.ToString();
                    statsList.Add(text);
                }
                // Irrelevant Stats
                Stats unusedStats        = stats - relevantStats;
                var   unusedNonzeroStats = unusedStats.Values(x => x != 0);
                foreach (System.Reflection.PropertyInfo info in unusedNonzeroStats.Keys)
                {
                    float value = unusedNonzeroStats[info];
                    if (Stats.IsPercentage(info))
                    {
                        value *= 100;
                    }
                    value = (float)Math.Round(value * 100f) / 100f;
                    string text = string.Format("{0}{1}", value, Extensions.DisplayName(info));
                    unusedStatsList.Add(text);
                }
                foreach (SpecialEffect effect in unusedStats.SpecialEffects())
                {
                    string text = effect.ToString();
                    unusedStatsList.Add(text);
                }
            }
            if (statsList.Count > 1 || !Rawr.Properties.GeneralSettings.Default.DisplayUnusedStats)
            {
                if (unusedStatsList.Count <= 1 && Rawr.Properties.GeneralSettings.Default.DisplayUnusedStats)
                {
                    // Take off the "Used Stats" statement, we dont need to differentiate
                    statsList.RemoveAt(0);
                }
                List2Panel(StatPanel, statsList, null, true);
            }
            else
            {
                StatPanel.Children.Clear();
            }
            if (Rawr.Properties.GeneralSettings.Default.DisplayUnusedStats && unusedStatsList.Count > 1)
            {
                List2Panel(UnusedStatPanel, unusedStatsList, new SolidColorBrush(Colors.Gray), true);
            }
            else
            {
                UnusedStatPanel.Children.Clear();
            }
            #endregion

            #region Displaying Item Sets

            if (actualItem != null && actualItem.SetName != null && actualItem.SetName != "")
            {
                SetLabel.Text       = string.Format("Set: {0}", actualItem.SetName);
                SetLabel.Visibility = Visibility.Visible;
            }
            else
            {
                SetLabel.Text       = "";
                SetLabel.Visibility = Visibility.Collapsed;
            }

            #endregion

            #region Setting Up Gems
            bool hasGems = false;
            if (actualItem == null || actualItem.SocketColor1 == ItemSlot.None)
            {
                GemColor1.Visibility      = Visibility.Collapsed;
                GemImage1.Visibility      = Visibility.Collapsed;
                GemStat1.Visibility       = Visibility.Collapsed;
                GemNamesLabel1.Visibility = Visibility.Collapsed;
            }
            else
            {
                GemColor1.Visibility = Visibility.Visible;
                GemColor1.Background = new SolidColorBrush(ColorForGem(actualItem.SocketColor1));

                GemImage1.Visibility = Visibility.Visible;
                GemImage1.Source     = null;

                GemStat1.Visibility = Visibility.Visible;
                GemStat1.Children.Clear();
                GemNamesLabel1.Visibility = Visibility.Visible;
                hasGems = true;
            }
            if (actualItem == null || actualItem.SocketColor2 == ItemSlot.None)
            {
                GemColor2.Visibility      = Visibility.Collapsed;
                GemImage2.Visibility      = Visibility.Collapsed;
                GemStat2.Visibility       = Visibility.Collapsed;
                GemNamesLabel2.Visibility = Visibility.Collapsed;
            }
            else
            {
                GemColor2.Visibility = Visibility.Visible;
                GemColor2.Background = new SolidColorBrush(ColorForGem(actualItem.SocketColor2));

                GemImage2.Visibility = Visibility.Visible;
                GemImage2.Source     = null;

                GemStat2.Visibility = Visibility.Visible;
                GemStat2.Children.Clear();
                GemNamesLabel2.Visibility = Visibility.Visible;
                hasGems = true;
            }
            if (actualItem == null || actualItem.SocketColor3 == ItemSlot.None)
            {
                GemColor3.Visibility      = Visibility.Collapsed;
                GemImage3.Visibility      = Visibility.Collapsed;
                GemStat3.Visibility       = Visibility.Collapsed;
                GemNamesLabel3.Visibility = Visibility.Collapsed;
            }
            else
            {
                GemColor3.Visibility = Visibility.Visible;
                GemColor3.Background = new SolidColorBrush(ColorForGem(actualItem.SocketColor3));

                GemImage3.Visibility = Visibility.Visible;
                GemImage3.Source     = null;

                GemStat3.Visibility = Visibility.Visible;
                GemStat3.Children.Clear();
                GemNamesLabel3.Visibility = Visibility.Visible;
                hasGems = true;
            }
            if (hasGems)
            {
                GemStack.Visibility         = Visibility.Visible;
                SocketBonusLabel.Visibility = Visibility.Visible;
                SocketBonusLabel.Text       = "Socket Bonus: " + (actualItem.SocketBonus.ToString().Length == 0 ? "None" : actualItem.SocketBonus.ToString());
            }
            else
            {
                SocketBonusLabel.Visibility = Visibility.Collapsed;
            }
            #endregion

            #region Gem Sockets
            EnchantLabel.Visibility = Visibility.Collapsed;

            if (ItemInstance != null)
            {
                if (ItemInstance.EnchantId > 0 && ItemInstance.Enchant != null)
                {
                    EnchantLabel.Text       = /*ItemInstance.Enchant.Name + ": "
                                               + */Calculations.GetRelevantStats(ItemInstance.Enchant.Stats).ToString();
                    EnchantLabel.Visibility = Visibility.Visible;
                }
                if (ItemInstance.Gem1 != null)
                {
                    if (actualItem.SocketColor1 == ItemSlot.None)
                    {
                        GemColor1.Visibility = Visibility.Visible;
                        GemColor1.Background = new SolidColorBrush(ColorForGem(ItemSlot.Prismatic));
                        GemImage1.Visibility = Visibility.Visible;
                        GemImage1.Source     = null;
                        GemStat1.Visibility  = Visibility.Visible;
                        GemStat1.Children.Clear();
                        hasGems = true;
                    }
                    GemImage1.Source = Icons.AnIcon(ItemInstance.Gem1.IconPath);
                    foreach (string s in Calculations.GetRelevantStats(ItemInstance.Gem1.Stats).ToString().Split(','))
                    {
                        string    r = s.Contains("Armor Penetration") ? s.Replace("Armor Penetration", "ArP") : s;
                        TextBlock t = new TextBlock();
                        t.Text = r.Trim();
                        GemStat1.Children.Add(t);
                    }
                    GemNamesLabel1.Text = "- " + ItemInstance.Gem1.Name;
                }
                if (ItemInstance.Gem2 != null)
                {
                    if (actualItem.SocketColor2 == ItemSlot.None)
                    {
                        GemColor2.Visibility = Visibility.Visible;
                        GemColor2.Background = new SolidColorBrush(ColorForGem(ItemSlot.Prismatic));
                        GemImage2.Visibility = Visibility.Visible;
                        GemImage2.Source     = null;
                        GemStat2.Visibility  = Visibility.Visible;
                        GemStat2.Children.Clear();
                        hasGems = true;
                    }
                    GemImage2.Source = Icons.AnIcon(ItemInstance.Gem2.IconPath);
                    foreach (string s in Calculations.GetRelevantStats(ItemInstance.Gem2.Stats).ToString().Split(','))
                    {
                        string    r = s.Contains("Armor Penetration") ? s.Replace("Armor Penetration", "ArP") : s;
                        TextBlock t = new TextBlock();
                        t.Text = r.Trim();
                        GemStat2.Children.Add(t);
                    }
                    GemNamesLabel2.Text = "- " + ItemInstance.Gem2.Name;
                }
                if (ItemInstance.Gem3 != null)
                {
                    if (actualItem.SocketColor3 == ItemSlot.None)
                    {
                        GemColor3.Visibility = Visibility.Visible;
                        GemColor3.Background = new SolidColorBrush(ColorForGem(ItemSlot.Prismatic));
                        GemImage3.Visibility = Visibility.Visible;
                        GemImage3.Source     = null;
                        GemStat3.Visibility  = Visibility.Visible;
                        GemStat3.Children.Clear();
                        hasGems = true;
                    }
                    GemImage3.Source = Icons.AnIcon(ItemInstance.Gem3.IconPath);
                    foreach (string s in Calculations.GetRelevantStats(ItemInstance.Gem3.Stats).ToString().Split(','))
                    {
                        string    r = s.Contains("Armor Penetration") ? s.Replace("Armor Penetration", "ArP") : s;
                        TextBlock t = new TextBlock();
                        t.Text = r.Trim();
                        GemStat3.Children.Add(t);
                    }
                    GemNamesLabel3.Text = "- " + ItemInstance.Gem3.Name;
                }
                if (actualItem != null && (!Item.GemMatchesSlot(itemInstance.Gem1, actualItem.SocketColor1) ||
                                           !Item.GemMatchesSlot(itemInstance.Gem2, actualItem.SocketColor2) ||
                                           !Item.GemMatchesSlot(itemInstance.Gem3, actualItem.SocketColor3)))
                {
                    SocketBonusLabel.Foreground = new SolidColorBrush(Colors.Gray);
                }
                else
                {
                    SocketBonusLabel.Foreground = new SolidColorBrush(Colors.Black);
                }
            }
            #endregion

            #region Reforging
#if RAWR4
            if (ItemInstance != null && ItemInstance.Reforging != null && ItemInstance.Reforging.ReforgeAmount > 0)
            {
                ReforgingLabel.Text       = string.Format("Reforge {0} {1} → {2}", ItemInstance.Reforging.ReforgeAmount, Extensions.SpaceCamel(ItemInstance.Reforging.ReforgeFrom.ToString()), Extensions.SpaceCamel(ItemInstance.Reforging.ReforgeTo.ToString()));
                ReforgingLabel.Visibility = Visibility.Visible;
            }
            else
            {
                ReforgingLabel.Visibility = Visibility.Collapsed;
            }
#endif
            #endregion

            #region Location Section
            // the actualItem.Id check to make sure it's an item, not a reforging or something
            if (actualItem != null && actualItem.Id > 0 && actualItem.Id < (int)AvailableItemIDModifiers.Reforges)
            {
                if (/*actualItem.LocationInfo != null &&*/
                    /*actualItem.LocationInfo.Count > 0 &&*/
                    ((LocationLabel.Text = actualItem.GetFullLocationDesc) != ""))
                {
                    LocationLabel.Visibility = Visibility.Visible;
                }
                else
                {
                    LocationLabel.Visibility = Visibility.Collapsed;
                }
            }
            else
            {
                LocationLabel.Visibility = Visibility.Collapsed;
            }
            #endregion

            #region Additional Items, like in Build Upgrade List
            ItemsGrid.Children.Clear();
            ItemsGrid.RowDefinitions.Clear();
            if (CharacterItems == null || CharacterItems.Length == 0)
            {
                ItemsGrid.Visibility = Visibility.Collapsed;
            }
            else
            {
                ItemsGrid.Visibility = Visibility.Visible;
                int row = 0;
                foreach (ItemInstance characterItem in CharacterItems)
                {
                    ItemsGrid.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = GridLength.Auto
                    });

                    if (characterItem == null)
                    {
                        continue;
                    }
                    Image iconImage = new Image();
                    iconImage.Style  = Resources["SmallIconStyle"] as Style;
                    iconImage.Source = Icons.AnIcon(characterItem.Item.IconPath);
                    Grid.SetColumn(iconImage, 0);
                    Grid.SetRow(iconImage, row);
                    ItemsGrid.Children.Add(iconImage);

                    if (characterItem.Gem1Id > 0)
                    {
                        Image gem1Image = new Image();
                        gem1Image.Style  = Resources["SmallIconStyle"] as Style;
                        gem1Image.Source = Icons.AnIcon(characterItem.Gem1.IconPath);
                        Grid.SetColumn(gem1Image, 1);
                        Grid.SetRow(gem1Image, row);
                        ItemsGrid.Children.Add(gem1Image);
                    }

                    if (characterItem.Gem2Id > 0)
                    {
                        Image gem2Image = new Image();
                        gem2Image.Style  = Resources["SmallIconStyle"] as Style;
                        gem2Image.Source = Icons.AnIcon(characterItem.Gem2.IconPath);
                        Grid.SetColumn(gem2Image, 2);
                        Grid.SetRow(gem2Image, row);
                        ItemsGrid.Children.Add(gem2Image);
                    }

                    if (characterItem.Gem3Id > 0)
                    {
                        Image gem3Image = new Image();
                        gem3Image.Style  = Resources["SmallIconStyle"] as Style;
                        gem3Image.Source = Icons.AnIcon(characterItem.Gem3.IconPath);
                        Grid.SetColumn(gem3Image, 3);
                        Grid.SetRow(gem3Image, row);
                        ItemsGrid.Children.Add(gem3Image);
                    }

                    TextBlock nameText = new TextBlock();
                    if (characterItem.EnchantId > 0)
                    {
                        nameText.Text = string.Format("{0} ({1})", characterItem.Item.Name, characterItem.Enchant.Name);
                    }
                    else
                    {
                        nameText.Text = string.Format("{0}", characterItem.Item.Name);
                    }
                    nameText.Foreground = new SolidColorBrush(ColorForQuality(characterItem.Item.Quality));
                    Grid.SetColumn(nameText, 4);
                    Grid.SetRow(nameText, row);
                    ItemsGrid.Children.Add(nameText);

                    row++;
                }
            }
            #endregion
        }