/// <summary> /// Create the StackPanel with the ProgressBar. /// </summary> /// <param name="Playtime"></param> /// <param name="data"></param> /// <returns></returns> private StackPanel CreateHltb(long Playtime, HltbDataUser data, bool IntegrationShowTitle) { StackPanel spHltb = new StackPanel(); TextBlock tbHltb = new TextBlock(); Separator hltbsep = new Separator(); if (IntegrationShowTitle) { tbHltb.Name = "PART_tbHltb"; tbHltb.Text = resources.GetString("LOCHowLongToBeatTitle"); tbHltb.Style = (Style)resources.GetResource("BaseTextBlockStyle"); tbHltb.Margin = new Thickness(0, 15, 0, 10); hltbsep.Name = "PART_hltbsep"; hltbsep.Background = (Brush)resources.GetResource("PanelSeparatorBrush"); } UserControl hltbProgressBar = new HltbProgressBar(Playtime, data); hltbProgressBar.Name = "PART_hltbProgressBar"; hltbProgressBar.Margin = new Thickness(0, 5, 0, 5); if (IntegrationShowTitle) { spHltb.Children.Add(tbHltb); spHltb.Children.Add(hltbsep); } spHltb.Children.Add(hltbProgressBar); spHltb.UpdateLayout(); return(spHltb); }
public static void AddAllTag(IPlayniteAPI PlayniteApi, Game game, string PluginUserDataPath) { RemoveAllTag(PlayniteApi, game); if (HaveData(game.Id, PluginUserDataPath)) { try { HowLongToBeatData howLongToBeatData = new HowLongToBeatData(game, PluginUserDataPath, PlayniteApi, false); HltbDataUser data = howLongToBeatData.GetData(); List <Guid> tagIds = SetListHltbTag(PlayniteApi, data); if (tagIds.Count > 0) { game.TagIds = tagIds; PlayniteApi.Database.Games.Update(game); } } catch (Exception ex) { #if DEBUG Common.LogError(ex, "HowLongToBeat", $"Error on AddAllTag()"); #endif logger.Error($"HowLongToBeat - Tag insert error with {game.Name}"); PlayniteApi.Notifications.Add(new NotificationMessage( "HowLongToBeat-Tag-Errors", "HowLongToBeat\r\n" + resources.GetString("LOCCommonNotificationTagError"), NotificationType.Error )); } } }
public static void SaveData(Guid GameId, HltbData hltbData, string PluginUserDataPath) { string FileGameData = PluginUserDataPath + "\\howlongtobeat\\" + GameId.ToString() + ".json"; var SavData = new HltbDataUser { GameHltbData = hltbData }; File.WriteAllText(FileGameData, JsonConvert.SerializeObject(SavData)); }
/// <summary> /// Valid the selection. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonSelect_Click(object sender, RoutedEventArgs e) { HltbData Item = (HltbData)lbSelectable.SelectedItem; var SavData = new HltbDataUser { GameHltbData = Item }; File.WriteAllText(FileGameData, JsonConvert.SerializeObject(SavData)); ((Window)this.Parent).Close(); }
/// <summary> /// Valid the selection. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonSelect_Click(object sender, RoutedEventArgs e) { HltbDataUser Item = (HltbDataUser)lbSelectable.SelectedItem; gameHowLongToBeat = HowLongToBeat.PluginDatabase.GetDefault(_game); gameHowLongToBeat.Items = new List <HltbDataUser>() { Item }; ((Window)this.Parent).Close(); }
public HltbProgressBar(long Playtime, HltbDataUser gameData, HowLongToBeatSettings settings) { InitializeComponent(); this.gameData = gameData; this.Playtime = Playtime; this.settings = settings; ShowToolTip = settings.ProgressBarShowToolTip; ShowTime = settings.ProgressBarShowTime; // Set Binding data DataContext = this; }
public static void SaveData(Guid GameId, HltbData hltbData, string PluginUserDataPath) { string FileGameData = PluginUserDataPath + "\\howlongtobeat\\" + GameId.ToString() + ".json"; var SavData = new HltbDataUser { GameHltbData = hltbData }; try { File.WriteAllText(FileGameData, JsonConvert.SerializeObject(SavData)); } catch (Exception ex) { Common.LogError(ex, "HowLongToBeat", $"Error on saving data for {GameId}"); } }
public override void AddTag(Game game) { GameHowLongToBeat gameHowLongToBeat = Get(game, true); if (gameHowLongToBeat.HasData) { try { HltbDataUser hltbDataUser = gameHowLongToBeat.GetData(); Guid? TagId = FindGoodPluginTags(hltbDataUser); if (TagId != null) { if (game.TagIds != null) { game.TagIds.Add((Guid)TagId); } else { game.TagIds = new List <Guid> { (Guid)TagId }; } _PlayniteApi.Database.Games.Update(game); } } catch (Exception ex) { #if DEBUG Common.LogError(ex, PluginName + " [Ignored]"); #endif logger.Error($"{PluginName} - Tag insert error with {game.Name}"); _PlayniteApi.Notifications.Add(new NotificationMessage( $"{PluginName}-Tag-Errors", $"{PluginName}\r\n" + resources.GetString("LOCCommonNotificationTagError"), NotificationType.Error )); } } }
public static void AddAllTag(IPlayniteAPI PlayniteApi, Game game, string PluginUserDataPath) { RemoveAllTag(PlayniteApi, game); if (HaveData(game.Id, PluginUserDataPath)) { try { HowLongToBeatData howLongToBeatData = new HowLongToBeatData(game, PluginUserDataPath, PlayniteApi, false); HltbDataUser data = howLongToBeatData.GetData(); List <Guid> tagIds = SetListHltbTag(PlayniteApi, data); if (tagIds.Count > 0) { game.TagIds = tagIds; PlayniteApi.Database.Games.Update(game); } } catch (Exception ex) { Common.LogError(ex, "HowLongToBeat", $"Tag insert error with {game.Name}"); } } }
public HowLongToBeat(HowLongToBeatData data, Game game, IPlayniteAPI PlayniteApi) { this.data = data; InitializeComponent(); HltbDataUser gameData = data.GetData(); CoverImage = PlayniteApi.Database.GetFullFilePath(game.CoverImage); GameName = game.Name; int ElIndicator = 0; Hltb_El1.Visibility = System.Windows.Visibility.Hidden; Hltb_El1_Color.Visibility = System.Windows.Visibility.Hidden; Hltb_El2.Visibility = System.Windows.Visibility.Hidden; Hltb_El2_Color.Visibility = System.Windows.Visibility.Hidden; Hltb_El3.Visibility = System.Windows.Visibility.Hidden; Hltb_El3_Color.Visibility = System.Windows.Visibility.Hidden; if (gameData.GameHltbData.MainStory != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatMainStory"), gameData.GameHltbData.MainStoryFormat); } if (gameData.GameHltbData.MainExtra != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatMainExtra"), gameData.GameHltbData.MainExtraFormat); } if (gameData.GameHltbData.Completionist != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatCompletionist"), gameData.GameHltbData.CompletionistFormat); } if (gameData.GameHltbData.Solo != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatSolo"), gameData.GameHltbData.SoloFormat); } if (gameData.GameHltbData.CoOp != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatCoOp"), gameData.GameHltbData.CoOpFormat); } if (gameData.GameHltbData.Vs != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatVs"), gameData.GameHltbData.VsFormat); } LongToTimePlayedConverter converter = new LongToTimePlayedConverter(); PlaytimeFormat = (string)converter.Convert((long)game.Playtime, null, null, CultureInfo.CurrentCulture); HltbProgressBar.Children.Add(new HltbProgressBar(game.Playtime, gameData)); HltbProgressBar.UpdateLayout(); // Set Binding data DataContext = this; }
private static List <Guid> SetListHltbTag(IPlayniteAPI PlayniteApi, HltbDataUser data) { List <Tag> HltbTags = GetTagId(PlayniteApi); List <Guid> tagIds = new List <Guid>(); long hltbTime = 0; #if DEBUG logger.Debug($"HowLongToBeat - HltbTags: {JsonConvert.SerializeObject(HltbTags)}"); #endif if (data != null && data != new HltbDataUser() && data.GameHltbData != null && data.GameHltbData != new HltbData() && HltbTags.Count > 1 && HltbTags != null) { // Get time if (data.GameHltbData.MainStory != 0) { hltbTime = data.GameHltbData.MainStory; } else if (data.GameHltbData.MainExtra != 0) { hltbTime = data.GameHltbData.MainStory; } if (data.GameHltbData.Solo != 0) { hltbTime = data.GameHltbData.Solo; } else if (data.GameHltbData.Vs != 0) { hltbTime = data.GameHltbData.Vs; } // Add tag if (hltbTime != 0) { bool isFind = false; if (hltbTime < 3600 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCPLaytimeLessThenAnHour")}")).Id); } if (hltbTime < 18000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat1to5")}")).Id); } if (hltbTime < 36000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat5to10")}")).Id); } if (hltbTime < 72000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat10to20")}")).Id); } if (hltbTime < 108000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat20to30")}")).Id); } if (hltbTime < 144000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat30to40")}")).Id); } if (hltbTime < 180000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat40to50")}")).Id); } if (hltbTime < 216000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat50to60")}")).Id); } if (hltbTime < 252000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat60to70")}")).Id); } if (hltbTime < 288000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat70to80")}")).Id); } if (hltbTime < 324000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat80to90")}")).Id); } if (hltbTime < 360000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat90to100")}")).Id); } if (hltbTime >= 360000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat100plus")}")).Id); } } } return(tagIds); }
public HowLongToBeatView(HowLongToBeatData data, Game game, IPlayniteAPI PlayniteApi, HowLongToBeatSettings settings) { _data = data; InitializeComponent(); HltbDataUser gameData = data.GetData(); if (data.hasData && gameData != null && gameData.GameHltbData != null) { if (string.IsNullOrEmpty(game.CoverImage)) { CoverImage = gameData.GameHltbData.UrlImg; } else { CoverImage = gameData.GameHltbData.UrlImg; if (!settings.ShowHltbImg) { CoverImage = PlayniteApi.Database.GetFullFilePath(game.CoverImage); } } GameName = game.Name; HltbName = resources.GetString("LOCSourceLabel") + ": " + gameData.GameHltbData.Name; int ElIndicator = 0; Hltb_El1.Visibility = Visibility.Hidden; Hltb_El1_Color.Visibility = Visibility.Hidden; Hltb_El2.Visibility = Visibility.Hidden; Hltb_El2_Color.Visibility = Visibility.Hidden; Hltb_El3.Visibility = Visibility.Hidden; Hltb_El3_Color.Visibility = Visibility.Hidden; if (gameData.GameHltbData.MainStory != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatMainStory"), gameData.GameHltbData.MainStoryFormat); } if (gameData.GameHltbData.MainExtra != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatMainExtra"), gameData.GameHltbData.MainExtraFormat); } if (gameData.GameHltbData.Completionist != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatCompletionist"), gameData.GameHltbData.CompletionistFormat); } if (gameData.GameHltbData.Solo != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatSolo"), gameData.GameHltbData.SoloFormat); } if (gameData.GameHltbData.CoOp != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatCoOp"), gameData.GameHltbData.CoOpFormat); } if (gameData.GameHltbData.Vs != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatVs"), gameData.GameHltbData.VsFormat); } Hltb_El1_Color.Background = new SolidColorBrush(settings.ColorFirst); Hltb_El2_Color.Background = new SolidColorBrush(settings.ColorSecond); Hltb_El3_Color.Background = new SolidColorBrush(settings.ColorThird); LongToTimePlayedConverter converter = new LongToTimePlayedConverter(); PlaytimeFormat = (string)converter.Convert((long)game.Playtime, null, null, CultureInfo.CurrentCulture); if (!data.isEmpty) { HltbProgressBar hltbProgressBar = new HltbProgressBar(); hltbProgressBar.SetHltbData(game.Playtime, data, settings); PART_HltbProgressBar.Children.Add(hltbProgressBar); } } // Set Binding data DataContext = this; }
public HltbProgressBar(long Playtime, HltbDataUser gameData) { InitializeComponent(); int ElIndicator = 0; long MaxValue = 0; long MaxHltb = 0; if (gameData != null) { if (gameData.GameHltbData.MainStory != 0) { ElIndicator += 1; SetDataInView(ElIndicator, gameData.GameHltbData.MainStory); if (MaxValue < gameData.GameHltbData.MainStory) { MaxValue = gameData.GameHltbData.MainStory; } } if (gameData.GameHltbData.MainExtra != 0) { ElIndicator += 1; SetDataInView(ElIndicator, gameData.GameHltbData.MainExtra); if (MaxValue < gameData.GameHltbData.MainExtra) { MaxValue = gameData.GameHltbData.MainExtra; } } if (gameData.GameHltbData.Completionist != 0) { ElIndicator += 1; SetDataInView(ElIndicator, gameData.GameHltbData.Completionist); if (MaxValue < gameData.GameHltbData.Completionist) { MaxValue = gameData.GameHltbData.Completionist; } } if (gameData.GameHltbData.Solo != 0) { ElIndicator += 1; SetDataInView(ElIndicator, gameData.GameHltbData.Solo); if (MaxValue < gameData.GameHltbData.Solo) { MaxValue = gameData.GameHltbData.Solo; } } if (gameData.GameHltbData.CoOp != 0) { ElIndicator += 1; SetDataInView(ElIndicator, gameData.GameHltbData.CoOp); if (MaxValue < gameData.GameHltbData.CoOp) { MaxValue = gameData.GameHltbData.CoOp; } } if (gameData.GameHltbData.Vs != 0) { ElIndicator += 1; SetDataInView(ElIndicator, gameData.GameHltbData.Vs); if (MaxValue < gameData.GameHltbData.Vs) { MaxValue = gameData.GameHltbData.Vs; } } } MaxHltb = MaxValue; if (Playtime > MaxValue) { MaxValue = Playtime; } // Limit MaxValue when playtime is more than MaxHltb long MaxPercent = (long)Math.Ceiling((double)(10 * MaxHltb / 100)); if (MaxValue > MaxHltb + MaxPercent) { MaxValue = MaxHltb + MaxPercent; } // Add data ProgressHltb_El1.Maximum = MaxValue; ProgressHltb_El2.Maximum = MaxValue; ProgressHltb_El3.Maximum = MaxValue; SliderPlaytime.Value = Playtime; SliderPlaytime.Maximum = MaxValue; // Set Binding data DataContext = this; }
public HowLongToBeatView(IPlayniteAPI PlayniteApi, HowLongToBeatSettings settings, GameHowLongToBeat gameHowLongToBeat) { _gameHowLongToBeat = gameHowLongToBeat; InitializeComponent(); HltbDataUser gameData = _gameHowLongToBeat.Items.FirstOrDefault(); if (gameData == null) { return; } if (_gameHowLongToBeat.HasData || _gameHowLongToBeat.HasDataEmpty) { CoverImage = gameData.UrlImg; if (!settings.ShowHltbImg) { if (!_gameHowLongToBeat.CoverImage.IsNullOrEmpty()) { CoverImage = PlayniteApi.Database.GetFullFilePath(_gameHowLongToBeat.CoverImage); } } GameName = _gameHowLongToBeat.Name; HltbName = resources.GetString("LOCSourceLabel") + ": " + gameData.Name; } if (_gameHowLongToBeat.HasData) { int ElIndicator = 0; Hltb_El1.Visibility = Visibility.Hidden; Hltb_El1_Color.Visibility = Visibility.Hidden; Hltb_El2.Visibility = Visibility.Hidden; Hltb_El2_Color.Visibility = Visibility.Hidden; Hltb_El3.Visibility = Visibility.Hidden; Hltb_El3_Color.Visibility = Visibility.Hidden; TitleList titleList = PluginDatabase.GetUserHltbData(_gameHowLongToBeat.GetData().Id); if (gameData.GameHltbData.MainStory != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatMainStory"), gameData.GameHltbData.MainStoryFormat, (titleList != null) ? titleList.HltbUserData.MainStoryFormat : string.Empty); SetColor(ElIndicator, PluginDatabase.PluginSettings.ColorFirst); } if (gameData.GameHltbData.MainExtra != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatMainExtra"), gameData.GameHltbData.MainExtraFormat, (titleList != null) ? titleList.HltbUserData.MainExtraFormat : string.Empty); SetColor(ElIndicator, PluginDatabase.PluginSettings.ColorSecond); } if (gameData.GameHltbData.Completionist != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatCompletionist"), gameData.GameHltbData.CompletionistFormat, (titleList != null) ? titleList.HltbUserData.CompletionistFormat : string.Empty); SetColor(ElIndicator, PluginDatabase.PluginSettings.ColorThird); } if (gameData.GameHltbData.Solo != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatSolo"), gameData.GameHltbData.SoloFormat, (titleList != null) ? titleList.HltbUserData.SoloFormat : string.Empty); SetColor(ElIndicator, PluginDatabase.PluginSettings.ColorFirstMulti); } if (gameData.GameHltbData.CoOp != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatCoOp"), gameData.GameHltbData.CoOpFormat, (titleList != null) ? titleList.HltbUserData.CoOpFormat : string.Empty); SetColor(ElIndicator, PluginDatabase.PluginSettings.ColorSecondMulti); } if (gameData.GameHltbData.Vs != 0) { ElIndicator += 1; SetDataInView(ElIndicator, resources.GetString("LOCHowLongToBeatVs"), gameData.GameHltbData.VsFormat, (titleList != null) ? titleList.HltbUserData.VsFormat : string.Empty); SetColor(ElIndicator, PluginDatabase.PluginSettings.ColorThirdMulti); } LongToTimePlayedConverter converter = new LongToTimePlayedConverter(); PlaytimeFormat = (string)converter.Convert((long)_gameHowLongToBeat.Playtime, null, null, CultureInfo.CurrentCulture); hltbProgressBar = new HltbProgressBar(); PART_HltbProgressBar.Children.Add(hltbProgressBar); } // Set Binding data DataContext = this; }
private Guid?FindGoodPluginTags(HltbDataUser hltbDataUser) { long hltbTime = hltbDataUser.GameHltbData.TimeToBeat; // Add tag if (hltbTime != 0) { if (hltbTime < 3600) { return((PluginTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCPLaytimeLessThenAnHour")}")).Id); } if (hltbTime < 18000) { return((PluginTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat1to5")}")).Id); } if (hltbTime < 36000) { return((PluginTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat5to10")}")).Id); } if (hltbTime < 72000) { return((PluginTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat10to20")}")).Id); } if (hltbTime < 108000) { return((PluginTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat20to30")}")).Id); } if (hltbTime < 144000) { return((PluginTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat30to40")}")).Id); } if (hltbTime < 180000) { return((PluginTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat40to50")}")).Id); } if (hltbTime < 216000) { return((PluginTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat50to60")}")).Id); } if (hltbTime < 252000) { return((PluginTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat60to70")}")).Id); } if (hltbTime < 288000) { return((PluginTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat70to80")}")).Id); } if (hltbTime < 324000) { return((PluginTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat80to90")}")).Id); } if (hltbTime < 360000) { return((PluginTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat90to100")}")).Id); } if (hltbTime >= 360000) { return((PluginTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat100plus")}")).Id); } } return(null); }
public void ConvertDB(IPlayniteAPI PlayniteApi) { GlobalProgressOptions globalProgressOptions = new GlobalProgressOptions( "HowLongToBeat - Database migration", false ); globalProgressOptions.IsIndeterminate = true; PlayniteApi.Dialogs.ActivateGlobalProgress((activateGlobalProgress) => { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); logger.Info($"HowLongToBeat - ConvertDB()"); int Converted = 0; foreach (var item in Items) { try { if (PlayniteApi.Database.Games.Get(item.Key) != null) { GameHowLongToBeat gameHowLongToBeat = HowLongToBeat.PluginDatabase.Get(item.Key, true); HltbDataUser hltbDataUser = new HltbDataUser { Id = item.Value.GameHltbData.Id, Name = item.Value.GameHltbData.Name, Url = item.Value.GameHltbData.Url, UrlImg = item.Value.GameHltbData.UrlImg, GameHltbData = new HltbData { MainStory = item.Value.GameHltbData.MainStory, MainExtra = item.Value.GameHltbData.MainExtra, Completionist = item.Value.GameHltbData.Completionist, Solo = item.Value.GameHltbData.Solo, CoOp = item.Value.GameHltbData.CoOp, Vs = item.Value.GameHltbData.Vs } }; gameHowLongToBeat.Items = new List <HltbDataUser> { hltbDataUser }; Thread.Sleep(10); HowLongToBeat.PluginDatabase.Add(gameHowLongToBeat); Converted++; } else { logger.Warn($"HowLongToBeat - Game is deleted - {item.Key.ToString()}"); } } catch (Exception ex) { Common.LogError(ex, "SuccessStory", $"Failed to load ConvertDB from {item.Key.ToString()}"); } } logger.Info($"HowLongToBeat - Converted {Converted} / {Items.Count}"); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; logger.Info($"HowLongToBeat - Migration - {String.Format("{0:00}:{1:00}.{2:00}", ts.Minutes, ts.Seconds, ts.Milliseconds / 10)}"); }, globalProgressOptions); IsOld = false; }
private static List <Guid> SetListHltbTag(IPlayniteAPI PlayniteApi, HltbDataUser data) { List <Tag> HltbTags = GetTagId(PlayniteApi); List <Guid> tagIds = new List <Guid>(); long hltbTime = 0; if (data != null && data != new HltbDataUser() && data.GameHltbData != null && data.GameHltbData != new HltbData() && HltbTags.Count > 1 && HltbTags != null) { try { // Get time if (data.GameHltbData.MainStory != 0) { hltbTime = data.GameHltbData.MainStory; } else if (data.GameHltbData.MainExtra != 0) { hltbTime = data.GameHltbData.MainStory; } if (data.GameHltbData.Solo != 0) { hltbTime = data.GameHltbData.Solo; } // Add tag if (hltbTime != 0) { bool isFind = false; if (hltbTime < 3600 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCPLaytimeLessThenAnHour")}")).Id); } if (hltbTime < 18000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat1to5")}")).Id); } if (hltbTime < 36000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat5to10")}")).Id); } if (hltbTime < 72000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat10to20")}")).Id); } if (hltbTime < 108000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat20to30")}")).Id); } if (hltbTime < 144000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat30to40")}")).Id); } if (hltbTime < 180000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat40to50")}")).Id); } if (hltbTime < 216000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat50to60")}")).Id); } if (hltbTime < 252000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat60to70")}")).Id); } if (hltbTime < 288000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat70to80")}")).Id); } if (hltbTime < 324000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat80to90")}")).Id); } if (hltbTime < 360000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat90to100")}")).Id); } if (hltbTime >= 360000 && !isFind) { isFind = true; tagIds.Add((HltbTags.Find(x => x.Name == $"[HLTB] {resources.GetString("LOCHowLongToBeat100plus")}")).Id); } } } catch (Exception ex) { Common.LogError(ex, "HowLongToBeat", $"Tag insert error with {hltbTime}"); } } return(tagIds); }