void setTalentsFromTree(SavedVariablesDictionary characterInfo) { if (!characterInfo.ContainsKey("Talents")) { #if RAWR3 || RAWR4 || SILVERLIGHT //new ErrorWindow() { Message = "Not yet implemented." }.Show(); #else MessageBox.Show("Talent data was not found, and must be manually added.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); #endif return; } SavedVariablesDictionary talent_tree = characterInfo["Talents"] as SavedVariablesDictionary; TalentsBase Talents = m_character.CurrentTalents; if (Talents != null) { List <string> treeNames = new List <string>((string[])Talents.GetType().GetField("TreeNames").GetValue(Talents)); //TalentTree currentTree; foreach (PropertyInfo pi in Talents.GetType().GetProperties()) { TalentDataAttribute[] talentDatas = pi.GetCustomAttributes(typeof(TalentDataAttribute), true) as TalentDataAttribute[]; if (talentDatas.Length > 0) { TalentDataAttribute talentData = talentDatas[0]; int points = getTalentPointsFromTree(talent_tree, treeNames[talentData.Tree], talentData); m_character.CurrentTalents.Data[talentData.Index] = points; } } } }
void setTalentsFromTree(SavedVariablesDictionary characterInfo) { if (!characterInfo.ContainsKey("Talents")) { return; } SavedVariablesDictionary talent_tree = characterInfo["Talents"] as SavedVariablesDictionary; TalentsBase Talents = Character.CurrentTalents; if (Talents != null) { List <string> treeNames = new List <string>((string[])Talents.GetType().GetField("TreeNames").GetValue(Talents)); //TalentTree currentTree; foreach (PropertyInfo pi in Talents.GetType().GetProperties()) { TalentDataAttribute[] talentDatas = pi.GetCustomAttributes(typeof(TalentDataAttribute), true) as TalentDataAttribute[]; if (talentDatas.Length > 0) { TalentDataAttribute talentData = talentDatas[0]; int points = getTalentPointsFromTree(talent_tree, treeNames[talentData.Tree], talentData); Character.CurrentTalents.Data[talentData.Index] = points; } } } }
private void InitializeTalentList(Character character) { talentList = new string[character.CurrentTalents.Data.Length]; foreach (PropertyInfo pi in character.CurrentTalents.GetType().GetProperties()) { TalentDataAttribute[] talentDatas = pi.GetCustomAttributes(typeof(TalentDataAttribute), true) as TalentDataAttribute[]; if (talentDatas.Length > 0) { TalentDataAttribute talentData = talentDatas[0]; talentList[talentData.Index] = talentData.Name; } } }
private void UpdateTrees() { ClearTalentPickerItems(); if (Talents != null) { _treeNames = new List <string>((string[])Talents.GetType().GetField("TreeNames").GetValue(Talents)); talentTree1.CharacterClass = _character.Class; talentTree1.TreeName = _treeNames[0]; tabPageTree1.Text = _treeNames[0]; talentTree2.CharacterClass = _character.Class; talentTree2.TreeName = _treeNames[1]; tabPageTree2.Text = _treeNames[1]; talentTree3.CharacterClass = _character.Class; talentTree3.TreeName = _treeNames[2]; tabPageTree3.Text = _treeNames[2]; TalentTree currentTree; List <GlyphDataAttribute> majors = new List <GlyphDataAttribute>(); List <GlyphDataAttribute> minors = new List <GlyphDataAttribute>(); List <string> relevant = Calculations.GetModel(Character.CurrentModel).GetRelevantGlyphs(); foreach (PropertyInfo pi in Talents.GetType().GetProperties()) { TalentDataAttribute[] talentDatas = pi.GetCustomAttributes(typeof(TalentDataAttribute), true) as TalentDataAttribute[]; if (talentDatas.Length > 0) { TalentDataAttribute talentData = talentDatas[0]; switch (talentData.Tree) { case 0: currentTree = talentTree1; break; case 1: currentTree = talentTree2; break; default: currentTree = talentTree3; break; } TalentItem item = new TalentItem(currentTree, talentData.Name, talentData.Row - 1, talentData.Column - 1, talentData.Index, LineWrapDescription(talentData.Description), talentData.Icon, (int)pi.GetValue(Talents, null), talentData.MaxPoints, talentData.Prerequisite >= 0 ? _talentPickerItems[talentData.Prerequisite] : null); _talentPickerItems[talentData.Index] = item; currentTree.AddTalent(item); item.CurrentRankChanged += new EventHandler(item_CurrentRankChanged); } GlyphDataAttribute[] glyphDatas = pi.GetCustomAttributes(typeof(GlyphDataAttribute), true) as GlyphDataAttribute[]; if (glyphDatas.Length > 0) { GlyphDataAttribute glyphData = glyphDatas[0]; if (glyphData.Major) { majors.Add(glyphData); } else { minors.Add(glyphData); } } } tabPageGlyphs.SuspendLayout(); foreach (Control c in grpMajorGlyph.Controls) { c.Dispose(); } grpMajorGlyph.Controls.Clear(); int count = 0; foreach (GlyphDataAttribute glyph in majors) { if (relevant == null || relevant.Contains(glyph.Name)) { CheckBox cb = new CheckBox(); grpMajorGlyph.Controls.Add(cb); cb.AutoSize = true; cb.Text = glyph.Name; cb.Tag = glyph.Index; cb.Checked = Talents.GlyphData[glyph.Index]; cb.UseVisualStyleBackColor = true; cb.Location = new Point(8, 17 + 21 * count); cb.CheckedChanged += new EventHandler(this.glyph_ValueChanged); tooltipGlyph.SetToolTip(cb, glyph.Description); count++; } } if (count == 0) { grpMajorGlyph.Hide(); } else { grpMajorGlyph.Show(); } count = 0; foreach (Control c in grpMinorGlyph.Controls) { c.Dispose(); } grpMinorGlyph.Controls.Clear(); foreach (GlyphDataAttribute glyph in minors) { if (relevant == null || relevant.Contains(glyph.Name)) { CheckBox cb = new CheckBox(); grpMinorGlyph.Controls.Add(cb); cb.AutoSize = true; cb.Text = glyph.Name; cb.Tag = glyph.Index; cb.Checked = Talents.GlyphData[glyph.Index]; cb.UseVisualStyleBackColor = true; cb.Location = new Point(6, 19 + 23 * count); cb.CheckedChanged += new EventHandler(this.glyph_ValueChanged); tooltipGlyph.SetToolTip(cb, glyph.Description); count++; } } if (count == 0) { grpMinorGlyph.Hide(); } else { grpMinorGlyph.Show(); } tabPageGlyphs.ResumeLayout(); talentTree1.Redraw(); talentTree2.Redraw(); talentTree3.Redraw(); item_CurrentRankChanged(null, null); } }
static int getTalentPointsFromTree(SavedVariablesDictionary talent_tree, string spec, TalentDataAttribute talent) { int points = 0; if (talent_tree.ContainsKey(spec)) { SavedVariablesDictionary spec_tree = talent_tree[spec] as SavedVariablesDictionary; if (spec_tree.ContainsKey(talent.Name)) { SavedVariablesDictionary talent_info = spec_tree[talent.Name] as SavedVariablesDictionary; string rank_info = talent_info["Rank"] as string; int split_pos = rank_info.IndexOf(':'); string points_str = rank_info.Remove(split_pos); points = (int)Int32.Parse(points_str); } else { Debug.WriteLine("Talent Not Found: " + talent); } } else { // we're most likely dealing with non-English data, try to determine by position in tree foreach (SavedVariablesDictionary tree in talent_tree.Values) { if ((long)tree["Order"] == talent.Tree + 1) { string loc = talent.Row + ":" + talent.Column; foreach (object t in tree.Values) { SavedVariablesDictionary td = t as SavedVariablesDictionary; if (td != null) { if ((string)td["Location"] == loc) { string rank_info = td["Rank"] as string; int split_pos = rank_info.IndexOf(':'); string points_str = rank_info.Remove(split_pos); points = (int)Int32.Parse(points_str); return(points); } } } } } Debug.WriteLine("Talent Tree Not Found: " + spec); } return(points); }
public void LoadTalents() { List <ComparisonCalculationBase> talentCalculations = new List <ComparisonCalculationBase>(); Character baseChar = Character.Clone(); Character newChar = Character.Clone(); CharacterCalculationsBase currentCalc; CharacterCalculationsBase newCalc; ComparisonCalculationBase compare; currentCalc = Calculations.GetCharacterCalculations(baseChar, null, false, true, false); foreach (PropertyInfo pi in baseChar.CurrentTalents.GetType().GetProperties()) { TalentDataAttribute[] talentDatas = pi.GetCustomAttributes(typeof(TalentDataAttribute), true) as TalentDataAttribute[]; int orig = 0; if (talentDatas.Length > 0) { TalentDataAttribute talentData = talentDatas[0]; orig = baseChar.CurrentTalents.Data[talentData.Index]; if (talentData.MaxPoints == (int)pi.GetValue(baseChar.CurrentTalents, null)) { newChar.CurrentTalents.Data[talentData.Index]--; newCalc = Calculations.GetCharacterCalculations(newChar, null, false, true, false); compare = Calculations.GetCharacterComparisonCalculations(newCalc, currentCalc, talentData.Name, talentData.MaxPoints == orig, orig != 0); } else { newChar.CurrentTalents.Data[talentData.Index]++; newCalc = Calculations.GetCharacterCalculations(newChar, null, false, true, false); compare = Calculations.GetCharacterComparisonCalculations(currentCalc, newCalc, talentData.Name, talentData.MaxPoints == orig, orig != 0); } string text = string.Format("Current Rank {0}/{1}\r\n\r\n", orig, talentData.MaxPoints); if (orig == 0) { // We originally didn't have it, so first rank is next rank text += "Next Rank:\r\n"; text += talentData.Description[0]; } else if (orig >= talentData.MaxPoints) { // We originally were at max, so there isn't a next rank, just show the capped one text += talentData.Description[talentData.MaxPoints - 1]; } else { // We aren't at 0 or MaxPoints originally, so it's just a point in between text += talentData.Description[orig - 1]; text += "\r\n\r\nNext Rank:\r\n"; text += talentData.Description[orig]; } compare.Description = text; compare.Item = null; talentCalculations.Add(compare); newChar.CurrentTalents.Data[talentData.Index] = orig; } } comparisonGraph1.RoundValues = true; comparisonGraph1.CustomRendered = false; comparisonGraph1.ItemCalculations = talentCalculations.ToArray(); comparisonGraph1.EquipSlot = CharacterSlot.None; _characterSlot = CharacterSlot.None; }
public void UpdatePrereqs() { foreach (KeyValuePair <int, TalentDataAttribute> kvp in talentAttributes) { if (kvp.Value.Prerequisite >= 0) { TalentDataAttribute prereq = GetAttribute(kvp.Value.Prerequisite); int row = kvp.Value.Row - prereq.Row; int col = kvp.Value.Column - prereq.Column; string suffix; if (kvp.Value.MaxPoints == Talents.Data[kvp.Value.Index]) { suffix = "-yellow.png"; } else if (PointsBelowRow(kvp.Value.Row) >= (kvp.Value.Row - 1) * 5 && Talents.Data[prereq.Index] == prereq.MaxPoints) { suffix = "-green.png"; } else { suffix = "-grey.png"; } Image image; if (prereqArrows.ContainsKey(kvp.Value.Index)) { image = prereqArrows[kvp.Value.Index]; } else { image = new Image(); Grid.SetColumn(image, kvp.Value.Column); Grid.SetRow(image, kvp.Value.Row); #if SILVERLIGHT image.Stretch = Stretch.None; #else // it looks like these images have non standard dpi, so make sure wpf doesn't stretch it around image.Stretch = Stretch.Fill; image.SetBinding(Image.WidthProperty, new System.Windows.Data.Binding() { Path = new PropertyPath("Source.PixelWidth"), RelativeSource = new System.Windows.Data.RelativeSource(System.Windows.Data.RelativeSourceMode.Self) }); image.SetBinding(Image.HeightProperty, new System.Windows.Data.Binding() { Path = new PropertyPath("Source.PixelHeight"), RelativeSource = new System.Windows.Data.RelativeSource(System.Windows.Data.RelativeSourceMode.Self) }); #endif image.HorizontalAlignment = HorizontalAlignment.Left; image.VerticalAlignment = VerticalAlignment.Top; GridPanel.Children.Add(image); prereqArrows[kvp.Value.Index] = image; } #if SILVERLIGHT string iconPrefix = ".."; #else string iconPrefix = "/Rawr.UI.WPF;component"; #endif if (row == 0) { if (col == -1) { image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/Images/across-left" + suffix, UriKind.Relative)); image.Margin = new Thickness(47, 15, 0, 0); } else if (col == 1) { image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/Images/across-right" + suffix, UriKind.Relative)); image.Margin = new Thickness(-17, 15, 0, 0); } } else if (row == 1) { if (col == -1) { image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/Images/down-left" + suffix, UriKind.Relative)); image.Margin = new Thickness(13, -44, 0, 0); Grid.SetRowSpan(image, 2); } else if (col == 0) { image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/Images/down-1" + suffix, UriKind.Relative)); image.Margin = new Thickness(14, -17, 0, 0); } else if (col == 1) { image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/Images/down-right" + suffix, UriKind.Relative)); image.Margin = new Thickness(-18, -44, 0, 0); } } else if (row == 2) { if (col == -1) { image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/Images/down-2-left" + suffix, UriKind.Relative)); image.Margin = new Thickness(-18, 20, 0, 0); Grid.SetRowSpan(image, 2); } else if (col == 0) { image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/Images/down-2" + suffix, UriKind.Relative)); image.Margin = new Thickness(13, -81, 0, 0); Grid.SetRowSpan(image, 2); } else if (col == 1) { image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/Images/down-2-right" + suffix, UriKind.Relative)); image.Margin = new Thickness(46, 20, 0, 0); Grid.SetRowSpan(image, 2); } } else if (row == 3) { if (col == -1) { image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/Images/down-3-left" + suffix, UriKind.Relative)); image.Margin = new Thickness(-18, 84, 0, 0); Grid.SetRowSpan(image, 2); } else if (col == 0) { image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/Images/down-3" + suffix, UriKind.Relative)); image.Margin = new Thickness(13, -145, 0, 0); Grid.SetRowSpan(image, 2); } else if (col == 1) { image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/Images/down-3-right" + suffix, UriKind.Relative)); image.Margin = new Thickness(46, 84, 0, 0); Grid.SetRowSpan(image, 2); } } else if (row == 4) { if (col == 0) { image.Source = Icons.NewBitmapImage(new Uri(iconPrefix + "/Images/down-4" + suffix, UriKind.Relative)); image.Margin = new Thickness(13, -209, 0, 0); Grid.SetRowSpan(image, 2); } } } } }
public void UpdatePrereqs() { foreach (KeyValuePair <int, TalentDataAttribute> kvp in talentAttributes) { if (kvp.Value.Prerequisite >= 0) { TalentDataAttribute prereq = GetAttribute(kvp.Value.Prerequisite); int row = kvp.Value.Row - prereq.Row; int col = kvp.Value.Column - prereq.Column; string suffix; if (kvp.Value.MaxPoints == Talents.Data[kvp.Value.Index]) { suffix = "-yellow.png"; } else if (PointsBelowRow(kvp.Value.Row) >= (kvp.Value.Row - 1) * 5 && Talents.Data[prereq.Index] == prereq.MaxPoints) { suffix = "-green.png"; } else { suffix = "-grey.png"; } Image image; if (prereqArrows.ContainsKey(kvp.Value.Index)) { image = prereqArrows[kvp.Value.Index]; } else { image = new Image(); Grid.SetColumn(image, kvp.Value.Column); Grid.SetRow(image, kvp.Value.Row); image.Stretch = Stretch.None; image.HorizontalAlignment = HorizontalAlignment.Left; image.VerticalAlignment = VerticalAlignment.Top; GridPanel.Children.Add(image); prereqArrows[kvp.Value.Index] = image; } if (row == 0) { if (col == -1) { image.Source = Icons.NewBitmapImage(new Uri("../Images/across-left" + suffix, UriKind.Relative)); image.Margin = new Thickness(47, 15, 0, 0); } else if (col == 1) { image.Source = Icons.NewBitmapImage(new Uri("../Images/across-right" + suffix, UriKind.Relative)); image.Margin = new Thickness(-17, 15, 0, 0); } } else if (row == 1) { if (col == -1) { image.Source = Icons.NewBitmapImage(new Uri("../Images/down-left" + suffix, UriKind.Relative)); image.Margin = new Thickness(13, -44, 0, 0); Grid.SetRowSpan(image, 2); } else if (col == 0) { image.Source = Icons.NewBitmapImage(new Uri("../Images/down-1" + suffix, UriKind.Relative)); image.Margin = new Thickness(14, -17, 0, 0); } else if (col == 1) { image.Source = Icons.NewBitmapImage(new Uri("../Images/down-right" + suffix, UriKind.Relative)); image.Margin = new Thickness(-18, -44, 0, 0); } } else if (row == 2) { if (col == -1) { image.Source = Icons.NewBitmapImage(new Uri("../Images/down-2-left" + suffix, UriKind.Relative)); image.Margin = new Thickness(-18, 20, 0, 0); Grid.SetRowSpan(image, 2); } else if (col == 0) { image.Source = Icons.NewBitmapImage(new Uri("../Images/down-2" + suffix, UriKind.Relative)); image.Margin = new Thickness(13, -81, 0, 0); Grid.SetRowSpan(image, 2); } else if (col == 1) { image.Source = Icons.NewBitmapImage(new Uri("../Images/down-2-right" + suffix, UriKind.Relative)); image.Margin = new Thickness(46, 20, 0, 0); Grid.SetRowSpan(image, 2); } } else if (row == 3) { if (col == -1) { image.Source = Icons.NewBitmapImage(new Uri("../Images/down-3-left" + suffix, UriKind.Relative)); image.Margin = new Thickness(-18, 84, 0, 0); Grid.SetRowSpan(image, 2); } else if (col == 0) { image.Source = Icons.NewBitmapImage(new Uri("../Images/down-3" + suffix, UriKind.Relative)); image.Margin = new Thickness(13, -145, 0, 0); Grid.SetRowSpan(image, 2); } else if (col == 1) { image.Source = Icons.NewBitmapImage(new Uri("../Images/down-3-right" + suffix, UriKind.Relative)); image.Margin = new Thickness(46, 84, 0, 0); Grid.SetRowSpan(image, 2); } } else if (row == 4) { if (col == 0) { image.Source = Icons.NewBitmapImage(new Uri("../Images/down-4" + suffix, UriKind.Relative)); image.Margin = new Thickness(13, -209, 0, 0); Grid.SetRowSpan(image, 2); } } } } }