Exemplo n.º 1
0
        private void SliderOnValueChanged(object sender, SliderValueChangedEventArgs e)
        {
            if (_updatingSliders)
            {
                return;
            }

            var slider = (SliderViewModel)sender;

            IMod[] tiers = SelectedAffix.QueryModsSingleValue(slider.ValueIndex, e.NewValue)
                           .OrderBy(m => m.RequiredLevel).ToArray();
            _updatingSliders = true;
            foreach (var other in _sliders.Where(s => s != slider))
            {
                var iValue = other.ValueIndex;
                if (!SelectedAffix.QueryModsSingleValue(iValue, other.Value).Intersect(tiers).Any())
                {
                    // slider isn't inside current tier
                    Range <int> moveto = tiers[0].Stats[iValue].Range;
                    other.Value = (e.NewValue > e.OldValue) ? moveto.From : moveto.To;
                }
            }
            _updatingSliders = false;

            OnPropertyChanged("SelectedValues");

            AffixText = string.Join("/", SelectedAffix.QueryMods(SelectedValues).Select(s => $"{s.Name}").Distinct());
        }
Exemplo n.º 2
0
        public ItemMod[] GetExactMods()
        {
            if (SelectedAffix != null)
            {
                float[] values = sliders.Select(s => (float)s.Value).ToArray();
                if (SelectedAffix.Name.Contains(" per second"))
                {
                    values = values.Select(v => v * 60f).ToArray();
                }

                var aff = SelectedAffix.Query(values).FirstOrDefault();


                if (aff.ParentAffix.IsRangeMod)
                {
                    return(new[] { aff.Stats[0].ToItemMod(sliders.Select(s => (float)s.Value).ToArray()) });
                }

                var fvalues = aff.Stats.Select((s, i) => s.ToItemMod((float)sliders[i].Value));

                return(fvalues.ToArray());
            }

            return(new ItemMod[0]);
        }
Exemplo n.º 3
0
        private void SliderOnValueChanged(object sender, SliderValueChangedEventArgs e)
        {
            if (_updatingSliders)
            {
                return;
            }

            var slider = (SliderViewModel)sender;

            ItemModTier[] tiers = SelectedAffix.QueryMod(slider.StatIndex, slider.ValueIndex, e.NewValue)
                                  .OrderBy(m => m.Name).ToArray();
            _updatingSliders = true;
            foreach (var other in _sliders.Where(s => s != slider))
            {
                var iStat  = other.StatIndex;
                var iValue = other.ValueIndex;
                if (!SelectedAffix.QueryMod(iStat, iValue, other.Value).Intersect(tiers).Any())
                {
                    // slider isn't inside current tier
                    Range <float> moveto = tiers[0].Stats[iStat].Ranges[iValue];
                    other.Value = (e.NewValue > e.OldValue) ? moveto.From : moveto.To;
                }
            }
            _updatingSliders = false;

            OnPropertyChanged("SelectedValues");

            AffixText = TiersString(Query());
        }
Exemplo n.º 4
0
 public IEnumerable <ItemMod> GetExactMods()
 {
     if (IsEmptySelection)
     {
         return(new ItemMod[0]);
     }
     return(SelectedAffix.ToItemMods(SelectedValues));
 }
Exemplo n.º 5
0
        private void OnSelectedAffixChanged()
        {
            _sliders.ForEach(s => s.ValueChanged -= SliderOnValueChanged);
            _sliders.Clear();
            _sliderGroups.Clear();

            if (SelectedAffix != null && !IsEmptySelection)
            {
                var ids       = new List <string>();
                var idToIndex = new Dictionary <string, int>();
                for (var i = 0; i < SelectedAffix.ValueCount; i++)
                {
                    var stat = SelectedAffix.FirstTierStats[i];
                    ids.Add(stat.Id);
                    idToIndex[stat.Id] = i;
                }

                var translations = _statTranslator.GetTranslations(ids);
                var groups       = new List <IReadOnlyList <int> >();
                foreach (var translation in translations)
                {
                    var translatedIndices = translation.Ids
                                            .Where(id => idToIndex.ContainsKey(id))
                                            .Select(id => idToIndex[id]).ToList();
                    groups.Add(translatedIndices);
                }

                foreach (var group in groups)
                {
                    var sliderGroup = new List <SliderViewModel>();

                    foreach (var valueIndex in group)
                    {
                        var ranges = SelectedAffix.GetRanges(valueIndex);
                        var ticks  = ranges.SelectMany(r => Enumerable.Range(r.From, r.To - r.From + 1))
                                     .OrderBy(i => i).Distinct();
                        var slider = new SliderViewModel(valueIndex, ticks);
                        sliderGroup.Add(slider);
                        _sliders.Add(slider);
                    }

                    var translation = new DynamicTranslation(_statTranslator, SelectedAffix, group);
                    _sliderGroups.Add(new SliderGroupViewModel(sliderGroup, translation));
                }
            }

            _sliders.ForEach(s => s.ValueChanged += SliderOnValueChanged);

            if (_sliders.Count > 0)
            {
                SliderOnValueChanged(_sliders[0], new SliderValueChangedEventArgs(_sliders[0].Value, _sliders[0].Value));
            }
            else
            {
                AffixText = "";
            }
        }
Exemplo n.º 6
0
        public IEnumerable <StatIdValuePair> GetStatValues()
        {
            var firstMatch = SelectedAffix.QueryMods(SelectedValues).FirstOrDefault();

            if (firstMatch == null)
            {
                return(Enumerable.Empty <StatIdValuePair>());
            }
            return(firstMatch.Stats.EquiZip(SelectedValues, (s, v) => new StatIdValuePair(s.Id, v)));
        }
Exemplo n.º 7
0
        private void OnSelectedAffixChanged()
        {
            _sliders.ForEach(s => s.ValueChanged -= SliderOnValueChanged);
            _sliders.Clear();
            _sliderGroups.Clear();

            if (SelectedAffix != null && !IsEmptySelection)
            {
                for (int i = 0; i < SelectedAffix.StatNames.Count; i++)
                {
                    var sliderGroup = new List <SliderViewModel>();

                    for (var j = 0; j < SelectedAffix.ValueCountPerStat[i]; j++)
                    {
                        var ranges     = SelectedAffix.GetRanges(i, j);
                        var isFloatMod = ranges
                                         .Any(r => !r.From.AlmostEquals((int)r.From, 1e-5) || !r.To.AlmostEquals((int)r.To, 1e-5));
                        IEnumerable <double> ticks = ranges
                                                     .SelectMany(
                            r =>
                            Enumerable.Range((int)Math.Round(isFloatMod ? r.From * 100 : r.From),
                                             (int)Math.Round((r.To - r.From) * (isFloatMod ? 100 : 1) + 1)))
                                                     .Select(f => isFloatMod ? (double)f / 100 : f);

                        var slider = new SliderViewModel(i, j, ticks);
                        sliderGroup.Add(slider);
                        _sliders.Add(slider);
                    }

                    string groupFormat = StatNameToFormat(SelectedAffix.StatNames[i]);
                    var    group       = new SliderGroupViewModel(sliderGroup, groupFormat);
                    _sliderGroups.Add(group);
                }
            }

            _sliders.ForEach(s => s.ValueChanged += SliderOnValueChanged);

            if (_sliders.Count > 0)
            {
                SliderOnValueChanged(_sliders[0], new SliderValueChangedEventArgs(_sliders[0].Value, _sliders[0].Value));
            }
            else
            {
                AffixText = "";
            }
        }
Exemplo n.º 8
0
        public IEnumerable <ItemMod> GetExactMods()
        {
            if (SelectedAffix != null)
            {
                float[] values = _sliders.Select(s => (float)s.Value).ToArray();

                var aff = SelectedAffix.Query(values).First();

                if (aff.IsRangeMod)
                {
                    return(new[] { aff.RangeCombinedStat.ToItemMod(false, _sliders.Select(s => (float)s.Value).ToArray()) });
                }

                return(aff.Stats.Select((s, i) => s.ToItemMod(false, (float)_sliders[i].Value)));
            }

            return(new ItemMod[0]);
        }
Exemplo n.º 9
0
        private void slValue_ValueChanged(object sender, RoutedPropertyChangedEventArgs <double> e)
        {
            if (_updatingSliders || _changingaffix)
            {
                return;
            }
            var aff = cbAffix.SelectedItem as Affix;

            if (aff == null)
            {
                return;
            }

            int indx = (int)((OverlayedSlider)sender).Tag;

            var tiers = aff.QueryMod(indx, (float)e.NewValue).OrderBy(m => m.Name).ToArray();

            _updatingSliders = true;
            for (int i = 0; i < _sliders.Count; i++)
            {
                if (i != indx)
                {
                    if (!aff.QueryMod(i, (float)_sliders[i].Value).Intersect(tiers).Any())
                    { //slider isnt inside current tier
                        var moveto = tiers[0].Stats[i].Range;
                        _sliders[i].Value = (e.NewValue > e.OldValue) ? moveto.From : moveto.To;
                    }
                }
            }
            _updatingSliders = false;
            OnPropertyChanged("SelectedValues");
            if (SelectedValuesChanged != null)
            {
                SelectedValuesChanged(this, SelectedValues);
            }

            tbtlabel.Text = TiersString(SelectedAffix.Query(_sliders.Select(s => (float)s.Value).ToArray()));
        }
Exemplo n.º 10
0
 public IEnumerable <ItemModTier> Query()
 {
     return(SelectedAffix.Query(SelectedValues));
 }
Exemplo n.º 11
0
 public IMod Query()
 {
     return(SelectedAffix.QueryMods(SelectedValues).First());
 }