void item_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { MasteryItem item = (MasteryItem)sender; masteries playerItem = (masteries)item.Tag; if (playerItem.selectedRank == 0) { return; } //Temp check - make it so you can remove masteries even if they are above mastery if enough points in tree List <masteries> FilteredMasteries = Client.Masteries.FindAll(x => x.tree == playerItem.tree && x.treeRow > playerItem.treeRow); foreach (masteries checkMastery in FilteredMasteries) { if (checkMastery.selectedRank > 0) { return; } } playerItem.selectedRank -= 1; foreach (masteries talent in Client.Masteries) { if (playerItem.id == talent.id) { talent.selectedRank = playerItem.selectedRank; } } RenderMasteries(); }
void item_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { MasteryItem item = (MasteryItem)sender; masteries playerItem = (masteries)item.Tag; //Max rank if (playerItem.selectedRank == playerItem.ranks) { return; } //Has enough points in tree switch (playerItem.tree) { case "Offense": if (OffenseUsedPoints < playerItem.treeRow * 4) { return; } break; case "Defense": if (DefenseUsedPoints < playerItem.treeRow * 4) { return; } break; default: if (UtilityUsedPoints < playerItem.treeRow * 4) { return; } break; } //Has enough points overall if (UsedPoints >= Client.LoginPacket.AllSummonerData.SummonerTalentsAndPoints.TalentPoints) { return; } //If it has a prerequisite mastery, check if points in it if (playerItem.prereq != 0) { masteries prereqMastery = Client.Masteries.Find(x => playerItem.prereq == x.id); if (prereqMastery.selectedRank != prereqMastery.ranks) { return; } } playerItem.selectedRank += 1; foreach (masteries talent in Client.Masteries) { if (playerItem.id == talent.id) { talent.selectedRank = playerItem.selectedRank; } } RenderMasteries(); }
public static void SetSongMastery(SongItem song, MasteryItem mastery) { song.MasteryId = mastery.Id; SongTable table = new SongTable(); using (SqliteConnection con = CreateConnection()) { con.Open(); UpdateRow(con, table, song); } }
public static void SetSongsMastery(IEnumerable <SongItem> songs, MasteryItem mastery) { SongTable table = new SongTable(); using (SqliteConnection con = CreateConnection()) { con.Open(); bool transactionStarted = StartTransaction(con); foreach (SongItem song in songs) { song.MasteryId = mastery.Id; UpdateRow(con, table, song); } if (transactionStarted) { _transaction?.Commit(); } } }
private static void CreateMasteryTable(SqliteConnection con, bool force = false) { MasteryTable masteryTable = new MasteryTable(); CreateTable(con, masteryTable, force); if (IsEmpty(con, masteryTable)) { MasteryItem defaultUnset = new MasteryItem("Unset", true, "#F0FDFA") { Id = DefaultMasteryId }; MasteryItem defaultBeginner = new MasteryItem("Beginner", true, "#D8F4EF"); MasteryItem defaultIntermediate = new MasteryItem("Intermediate", true, "#B7ECEA"); MasteryItem defaultAdvanced = new MasteryItem("Advanced", true, "#97DEE7"); MasteryItem defaultMastered = new MasteryItem("Mastered", true, "#78C5DC"); InsertRows(con, masteryTable, new BaseModelItem[] { defaultUnset, defaultBeginner, defaultIntermediate, defaultAdvanced, defaultMastered }); } }
public void RenderMasteries() { OffenseListView.Items.Clear(); DefenseListView.Items.Clear(); UtilityListView.Items.Clear(); UsedPoints = 0; OffenseUsedPoints = 0; DefenseUsedPoints = 0; UtilityUsedPoints = 0; foreach (masteries Mastery in Client.Masteries) { bool IsOffense = false; bool IsDefense = false; bool IsUtility = false; MasteryItem item = new MasteryItem(); item.RankLabel.Content = "0/" + Mastery.ranks; item.MasteryImage.Source = Mastery.icon; item.MasteryImage.Opacity = 0.4; item.Margin = new Thickness(2, 2, 2, 2); if (Mastery.selectedRank > 0) { item.MasteryImage.Opacity = 1; item.RankLabel.Content = Mastery.selectedRank + "/" + Mastery.ranks; } UsedPoints += Mastery.selectedRank; switch (Mastery.tree) { case "Offense": OffenseUsedPoints += Mastery.selectedRank; IsOffense = true; OffenseListView.Items.Add(item); break; case "Defense": DefenseUsedPoints += Mastery.selectedRank; IsDefense = true; DefenseListView.Items.Add(item); break; default: UtilityUsedPoints += Mastery.selectedRank; IsUtility = true; UtilityListView.Items.Add(item); break; } //Add spaces if (Mastery.id == 4152 || Mastery.id == 4222 || Mastery.id == 4253 || Mastery.id == 4314 || Mastery.id == 4344 || Mastery.id == 4353) { Rectangle rect = new Rectangle(); rect.Width = 64; rect.Height = 64; rect.Margin = new Thickness(2, 2, 2, 2); if (IsOffense) { OffenseListView.Items.Add(rect); } if (IsDefense) { DefenseListView.Items.Add(rect); } if (IsUtility) { UtilityListView.Items.Add(rect); } } item.Tag = Mastery; item.MouseWheel += item_MouseWheel; item.MouseLeftButtonDown += item_MouseLeftButtonDown; item.MouseRightButtonDown += item_MouseRightButtonDown; item.MouseMove += item_MouseMove; item.MouseLeave += item_MouseLeave; } UsedLabel.Content = "Points Used: " + UsedPoints; FreeLabel.Content = "Points Free: " + (Client.LoginPacket.AllSummonerData.SummonerTalentsAndPoints.TalentPoints - UsedPoints); OffenseLabel.Content = "Offense: " + OffenseUsedPoints; DefenseLabel.Content = "Defense: " + DefenseUsedPoints; UtilityLabel.Content = "Utility: " + UtilityUsedPoints; }
private void item_MouseMove(object sender, MouseEventArgs e) { MasteryItem item = (MasteryItem)sender; masteries playerItem = (masteries)item.Tag; if (PlayerItem == null) { PlayerItem = new LargeChatPlayer(); Client.MainGrid.Children.Add(PlayerItem); Panel.SetZIndex(PlayerItem, 4); //Only load once PlayerItem.ProfileImage.Source = playerItem.icon; PlayerItem.PlayerName.Content = playerItem.name; PlayerItem.PlayerName.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); if (PlayerItem.PlayerName.DesiredSize.Width > 250) //Make title fit in item { PlayerItem.Width = PlayerItem.PlayerName.DesiredSize.Width; } else { PlayerItem.Width = 250; } PlayerItem.PlayerWins.Content = "Requires " + playerItem.treeRow * 4 + " points in " + playerItem.tree; bool IsAtRequirement = true; switch (playerItem.tree) { case "Offense": if (OffenseUsedPoints < playerItem.treeRow * 4) { IsAtRequirement = false; } break; case "Defense": if (DefenseUsedPoints < playerItem.treeRow * 4) { IsAtRequirement = false; } break; default: if (UtilityUsedPoints < playerItem.treeRow * 4) { IsAtRequirement = false; } break; } if (IsAtRequirement) { if (playerItem.prereq != 0) { masteries prereqMastery = Client.Masteries.Find(x => playerItem.prereq == x.id); PlayerItem.PlayerWins.Content = "Requires " + prereqMastery.ranks + " points in " + prereqMastery.name; } } PlayerItem.PlayerLeague.Content = playerItem.id; PlayerItem.LevelLabel.Content = playerItem.selectedRank + "/" + playerItem.ranks; PlayerItem.UsingLegendary.Visibility = System.Windows.Visibility.Hidden; int SelectedRank = playerItem.selectedRank; if (SelectedRank == 0) { SelectedRank = 1; } PlayerItem.PlayerStatus.Text = ((string)playerItem.description[SelectedRank - 1]).Replace("<br>", Environment.NewLine); PlayerItem.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; PlayerItem.VerticalAlignment = System.Windows.VerticalAlignment.Top; } Point MouseLocation = e.GetPosition(Client.MainGrid); double YMargin = MouseLocation.Y; double XMargin = MouseLocation.X; if (XMargin + PlayerItem.Width + 10 > Client.MainGrid.ActualWidth) { XMargin = Client.MainGrid.ActualWidth - PlayerItem.Width - 10; } PlayerItem.Margin = new Thickness(XMargin + 5, YMargin + 5, 0, 0); }
public void RenderMasteries() { OffenseListView.Items.Clear(); DefenseListView.Items.Clear(); UtilityListView.Items.Clear(); _usedPoints = 0; _offenseUsedPoints = 0; _defenseUsedPoints = 0; _utilityUsedPoints = 0; foreach (var mastery in Client.Masteries) { var isOffense = false; var isDefense = false; var item = new MasteryItem { RankLabel = { Content = "0/" + mastery.ranks }, MasteryImage = { Source = mastery.icon, Opacity = 0.4 }, Margin = new Thickness(2, 2, 2, 2) }; if (mastery.selectedRank > 0) { item.MasteryImage.Opacity = 1; item.RankLabel.Content = mastery.selectedRank + "/" + mastery.ranks; } _usedPoints += mastery.selectedRank; switch (mastery.tree) { case "Offense": _offenseUsedPoints += mastery.selectedRank; isOffense = true; OffenseListView.Items.Add(item); break; case "Defense": _defenseUsedPoints += mastery.selectedRank; isDefense = true; DefenseListView.Items.Add(item); break; default: _utilityUsedPoints += mastery.selectedRank; UtilityListView.Items.Add(item); break; } //Add spaces if (mastery.id == 4152 || mastery.id == 4222 || mastery.id == 4253 || mastery.id == 4314 || mastery.id == 4344 || mastery.id == 4353 || mastery.id == 4154) { var rect = new Rectangle { Width = 64, Height = 64, Margin = new Thickness(2, 2, 2, 2) }; if (isOffense) { OffenseListView.Items.Add(rect); } else if (isDefense) { DefenseListView.Items.Add(rect); if (mastery.id == 4253) { DefenseListView.Items.Add(new Rectangle { Width = 64, Height = 64, Margin = new Thickness(2, 2, 2, 2) }); } } else { UtilityListView.Items.Add(rect); if (mastery.id == 4353) { UtilityListView.Items.Add(new Rectangle { Width = 64, Height = 64, Margin = new Thickness(2, 2, 2, 2) }); } } } item.Tag = mastery; item.MouseWheel += item_MouseWheel; item.MouseLeftButtonDown += item_MouseLeftButtonDown; item.MouseRightButtonDown += item_MouseRightButtonDown; item.MouseMove += item_MouseMove; item.MouseLeave += item_MouseLeave; } UsedLabel.Content = "Points Used: " + _usedPoints; FreeLabel.Content = "Points Free: " + (Client.LoginPacket.AllSummonerData.SummonerTalentsAndPoints.TalentPoints - _usedPoints); OffenseLabel.Content = "Offense: " + _offenseUsedPoints; DefenseLabel.Content = "Defense: " + _defenseUsedPoints; UtilityLabel.Content = "Utility: " + _utilityUsedPoints; }