diff --git a/MHFZ_Overlay/Models/FastestRun.cs b/MHFZ_Overlay/Models/FastestRun.cs index 27ff1f91..7bf7f3df 100644 --- a/MHFZ_Overlay/Models/FastestRun.cs +++ b/MHFZ_Overlay/Models/FastestRun.cs @@ -17,7 +17,7 @@ public sealed class FastestRun public long QuestID { get; set; } - public string YoutubeID { get; set; } = Messages.RickRollID; + public string YouTubeID { get; set; } = Messages.RickRollID; public string FinalTimeDisplay { get; set; } = Messages.MaximumTimerPlaceholder; diff --git a/MHFZ_Overlay/Models/RecentRuns.cs b/MHFZ_Overlay/Models/RecentRuns.cs index a8320aaf..3fa340b7 100644 --- a/MHFZ_Overlay/Models/RecentRuns.cs +++ b/MHFZ_Overlay/Models/RecentRuns.cs @@ -17,7 +17,7 @@ public sealed class RecentRuns public long QuestID { get; set; } - public string YoutubeID { get; set; } = Messages.RickRollID; + public string YouTubeID { get; set; } = Messages.RickRollID; public string FinalTimeDisplay { get; set; } = Messages.MaximumTimerPlaceholder; diff --git a/MHFZ_Overlay/Services/DatabaseService.cs b/MHFZ_Overlay/Services/DatabaseService.cs index e48a8c17..48ec4aff 100644 --- a/MHFZ_Overlay/Services/DatabaseService.cs +++ b/MHFZ_Overlay/Services/DatabaseService.cs @@ -2860,7 +2860,7 @@ BEFORE UPDATE ON Quests cmd.CommandText = @"CREATE TRIGGER IF NOT EXISTS prevent_quest_updates AFTER UPDATE ON Quests FOR EACH ROW - WHEN NEW.YoutubeID = OLD.YoutubeID + WHEN NEW.YouTubeID = OLD.YouTubeID BEGIN SELECT RAISE(ABORT, 'Cannot update quest fields'); END;"; @@ -5672,7 +5672,7 @@ public string GetYoutubeLinkForRunID(long runID) { try { - using (var cmd = new SQLiteCommand("SELECT YoutubeID FROM Quests WHERE RunID = @runID", conn)) + using (var cmd = new SQLiteCommand("SELECT YouTubeID FROM Quests WHERE RunID = @runID", conn)) { cmd.Parameters.AddWithValue("@runID", runID); @@ -5680,7 +5680,7 @@ public string GetYoutubeLinkForRunID(long runID) { if (reader.Read()) { - youtubeLink = (string)reader["YoutubeID"]; + youtubeLink = (string)reader["YouTubeID"]; } else { @@ -5726,7 +5726,7 @@ public bool UpdateYoutubeLink(object sender, RoutedEventArgs e, long runID, stri var count = (long)cmd.ExecuteScalar(); if (count > 0) { - using (var cmd2 = new SQLiteCommand("UPDATE Quests SET YoutubeID = @youtubeLink WHERE RunID = @runID", conn)) + using (var cmd2 = new SQLiteCommand("UPDATE Quests SET YouTubeID = @youtubeLink WHERE RunID = @runID", conn)) { cmd2.Parameters.AddWithValue("@youtubeLink", youtubeLink); cmd2.Parameters.AddWithValue("@runID", runID); @@ -10167,7 +10167,7 @@ public List GetFastestRuns(ConfigWindow configWindow, string weaponN qn.QuestNameName, q.RunID, QuestID, - YoutubeID, + YouTubeID, FinalTimeDisplay, Date, ActualOverlayMode, @@ -10191,7 +10191,7 @@ FinalTimeValue ASC qn.QuestNameName, q.RunID, QuestID, - YoutubeID, + YouTubeID, FinalTimeDisplay, Date, ActualOverlayMode, @@ -10249,7 +10249,7 @@ FinalTimeValue ASC QuestName = (string)reader["QuestNameName"], RunID = (long)reader["RunID"], QuestID = (long)reader["QuestID"], - YoutubeID = (string)reader["YoutubeID"], + YouTubeID = (string)reader["YouTubeID"], FinalTimeDisplay = (string)reader["FinalTimeDisplay"], Date = DateTime.Parse((string)reader["Date"], CultureInfo.InvariantCulture), }); @@ -10271,6 +10271,89 @@ FinalTimeValue ASC return fastestRuns; } + /// + /// TODO: Filter by run buffs and overlay mode speedrun. Speedruns only. + /// + /// + /// + /// + public List GetUneditedYouTubeLinkRuns() + { + var runs = new List(); + if (string.IsNullOrEmpty(this.dataSource)) + { + Logger.Warn(CultureInfo.InvariantCulture, "Cannot get unedited youtube link runs. dataSource: {0}", this.dataSource); + return runs; + } + + using (var conn = new SQLiteConnection(this.dataSource)) + { + conn.Open(); + using (var transaction = conn.BeginTransaction()) + { + try + { + var sql = @"SELECT + ObjectiveImage, + qn.QuestNameName, + q.RunID, + QuestID, + YouTubeID, + FinalTimeDisplay, + Date, + ActualOverlayMode, + PartySize + FROM + Quests q + JOIN + QuestName qn ON q.QuestID = qn.QuestNameID + WHERE + q.PartySize = 1 + AND q.YouTubeID = 'dQw4w9WgXcQ' + AND q.ActualOverlayMode != 'Standard' + ORDER BY + q.RunID DESC"; + + using (var cmd = new SQLiteCommand(sql, conn)) + { + using (var reader = cmd.ExecuteReader()) + { + if (reader == null || !reader.HasRows) + { + return runs; + } + + if (reader.HasRows) + { + while (reader.Read()) + { + runs.Add(new FastestRun + { + ObjectiveImage = (string)reader["ObjectiveImage"], + QuestName = (string)reader["QuestNameName"], + RunID = (long)reader["RunID"], + QuestID = (long)reader["QuestID"], + YouTubeID = (string)reader["YouTubeID"], + FinalTimeDisplay = (string)reader["FinalTimeDisplay"], + Date = DateTime.Parse((string)reader["Date"], CultureInfo.InvariantCulture), + }); + } + } + } + } + + transaction.Commit(); + } + catch (Exception ex) + { + HandleError(transaction, ex); + } + } + } + + return runs; + } + /// /// Get a list of all achievements where the completion date is set or not by the player. /// @@ -10430,7 +10513,7 @@ public ObservableCollection GetRecentRuns() qn.QuestNameName, RunID, QuestID, - YoutubeID, + YouTubeID, FinalTimeDisplay, Date, ActualOverlayMode, @@ -10460,7 +10543,7 @@ Date DESC QuestName = (string)reader["QuestNameName"], RunID = (long)reader["RunID"], QuestID = (long)reader["QuestID"], - YoutubeID = (string)reader["YoutubeID"], + YouTubeID = (string)reader["YouTubeID"], FinalTimeDisplay = (string)reader["FinalTimeDisplay"], Date = DateTime.Parse((string)reader["Date"], CultureInfo.InvariantCulture), ActualOverlayMode = (string)reader["ActualOverlayMode"], @@ -10511,7 +10594,7 @@ public List GetCalendarRuns(DateTime? selectedDate) qn.QuestNameName, RunID, QuestID, - YoutubeID, + YouTubeID, FinalTimeDisplay, Date, ActualOverlayMode, @@ -10543,7 +10626,7 @@ ORDER BY QuestName = (string)reader["QuestNameName"], RunID = (long)reader["RunID"], QuestID = (long)reader["QuestID"], - YoutubeID = (string)reader["YoutubeID"], + YouTubeID = (string)reader["YouTubeID"], FinalTimeDisplay = (string)reader["FinalTimeDisplay"], Date = DateTime.Parse((string)reader["Date"], CultureInfo.InvariantCulture), ActualOverlayMode = (string)reader["ActualOverlayMode"], diff --git a/MHFZ_Overlay/Views/Windows/ConfigWindow.xaml b/MHFZ_Overlay/Views/Windows/ConfigWindow.xaml index ec21f67e..c22a2c94 100644 --- a/MHFZ_Overlay/Views/Windows/ConfigWindow.xaml +++ b/MHFZ_Overlay/Views/Windows/ConfigWindow.xaml @@ -258,7 +258,7 @@ - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/MHFZ_Overlay/Views/Windows/ConfigWindow.xaml.cs b/MHFZ_Overlay/Views/Windows/ConfigWindow.xaml.cs index 635e99b3..6be0ce5c 100644 --- a/MHFZ_Overlay/Views/Windows/ConfigWindow.xaml.cs +++ b/MHFZ_Overlay/Views/Windows/ConfigWindow.xaml.cs @@ -2532,6 +2532,7 @@ private void WeaponUsageChart_Loaded(object sender, RoutedEventArgs e) private TextBox? youtubeLinkTextBox; private DataGrid? mostRecentRunsDataGrid; private DataGrid? top20RunsDataGrid; + private DataGrid? uneditedYouTubeLinkRunsDataGrid; private TextBlock? questLogGearStatsTextBlock; private TextBlock? compendiumTextBlock; private CartesianChart? graphChart; @@ -2631,6 +2632,22 @@ private void Top20Runs_DataGridLoaded(object sender, RoutedEventArgs e) this.top20RunsDataGrid.Items.Refresh(); } + private void UneditedYouTubeLinkRuns_DataGridLoaded(object sender, RoutedEventArgs e) + { + this.uneditedYouTubeLinkRunsDataGrid = (DataGrid)sender; + } + + private void YouTubeFindRuns_Click(object sender, RoutedEventArgs e) + { + if (this.uneditedYouTubeLinkRunsDataGrid == null) + { + return; + } + + this.uneditedYouTubeLinkRunsDataGrid.ItemsSource = DatabaseManager.GetUneditedYouTubeLinkRuns(); + this.uneditedYouTubeLinkRunsDataGrid.Items.Refresh(); + } + private string statsGraphsSelectedOption = string.Empty; private string statsTextSelectedOption = string.Empty; @@ -2652,7 +2669,7 @@ public static void SaveCSVFromListOfRecentRuns(List recentRuns, stri { var objectiveImage = run.ObjectiveImage.Replace(",", string.Empty); var questName = run.QuestName.Replace(",", string.Empty); - var youtubeID = run.YoutubeID.Replace(",", string.Empty); + var youtubeID = run.YouTubeID.Replace(",", string.Empty); var finalTimeDisplay = run.FinalTimeDisplay.Replace(",", string.Empty); var actualOverlayMode = run.ActualOverlayMode.Replace(",", string.Empty); @@ -2854,7 +2871,7 @@ public static void SaveCSVFromListOfRecentRuns(ObservableCollection { var objectiveImage = run.ObjectiveImage.Replace(",", string.Empty); var questName = run.QuestName.Replace(",", string.Empty); - var youtubeID = run.YoutubeID.Replace(",", string.Empty); + var youtubeID = run.YouTubeID.Replace(",", string.Empty); var finalTimeDisplay = run.FinalTimeDisplay.Replace(",", string.Empty); var actualOverlayMode = run.ActualOverlayMode.Replace(",", string.Empty); @@ -2874,7 +2891,7 @@ public static void SaveCSVFromListOfFastestRuns(List fastestRuns, st { var objectiveImage = run.ObjectiveImage.Replace(",", string.Empty); var questName = run.QuestName.Replace(",", string.Empty); - var youtubeID = run.YoutubeID.Replace(",", string.Empty); + var youtubeID = run.YouTubeID.Replace(",", string.Empty); var finalTimeDisplay = run.FinalTimeDisplay.Replace(",", string.Empty); var line = $"{objectiveImage},{questName},{run.RunID},{run.QuestID},{youtubeID},{finalTimeDisplay},{run.Date}";