public void Save(ICollection <ItemTag> items, ProgressTracker tracker) { int commitSize = items.Count / 10; tracker.MaxValue = items.Count + commitSize; using (var session = SessionCreator.OpenStatelessSession()) { using (ITransaction transaction = session.BeginTransaction()) { session.CreateQuery("DELETE FROM ItemTag").ExecuteUpdate(); foreach (ItemTag item in items) { session.Insert(item); tracker.Increment(); } transaction.Commit(); // A bit of 'fake pending progress' for commit for (int i = 0; i < commitSize; i++) { tracker.Increment(); } } } Logger.InfoFormat("Stored {0} item tags to database..", items.Count); }
public void LoadItems( string itemsfileVanilla, string itemsfileExpansion1, string itemsfileMod, ProgressTracker tracker ) { int numFiles = GrimFolderUtility.CountExisting(itemsfileVanilla, itemsfileExpansion1, itemsfileMod); tracker.MaxValue = numFiles; ItemAccumulator accumulator = new ItemAccumulator(); if (File.Exists(itemsfileVanilla)) { Parser.Arz.ArzParser.LoadItemRecords(itemsfileVanilla, true).ForEach(accumulator.Add); tracker.Increment(); } if (File.Exists(itemsfileExpansion1)) { Parser.Arz.ArzParser.LoadItemRecords(itemsfileExpansion1, true).ForEach(accumulator.Add); tracker.Increment(); } if (File.Exists(itemsfileMod)) { Parser.Arz.ArzParser.LoadItemRecords(itemsfileMod, true).ForEach(accumulator.Add); tracker.Increment(); } Items = accumulator.Items; }
public void Two_out_of_two_should_be_100_percent() { var tracker = new ProgressTracker { MaxValue = 2 }; tracker.Increment(); tracker.Increment(); tracker.Progress.Should().Be.EqualTo(100); }
public void AnimationEnded() { completionCount++; if (completionCount == 3 || completionCount == 6 || completionCount == 9 || completionCount == 12) { progressTracker.Increment(playerID); } else if (completionCount == 15) { hasCompleted = true; progressTracker.Increment(playerID); gameController.missionComplete(playerID, transform.parent.parent.rotation); iTween.ScaleTo(gameObject, iTween.Hash("scale", Vector3.zero, "time", 3)); } }
public void RenamePetStats(ProgressTracker tracker) { Logger.Debug("Detecting records with pet bonus stats.."); var petRecords = Items.SelectMany(m => m.Stats.Where(s => s.Stat == "petBonusName") .Select(s => s.TextValue)) .ToList(); // ToList for performance reasons var petItems = Items.Where(m => petRecords.Contains(m.Record)).ToList(); tracker.MaxValue = petItems.Count; foreach (var petItem in petItems) { var stats = petItem.Stats.Select(s => new DatabaseItemStat { Stat = "pet" + s.Stat, TextValue = s.TextValue, Value = s.Value, Parent = s.Parent }).ToList(); petItem.Stats.Clear(); petItem.Stats = stats; tracker.Increment(); } Items.RemoveAll(m => petRecords.Contains(m.Record)); Items.AddRange(petItems); tracker.MaxProgress(); Logger.Debug($"Classified {petItems.Count()} records as pet stats"); }
public void MapItemNames(ProgressTracker tracker) { var tags = Tags; tracker.MaxValue = Items.Count; Parallel.For(0, Items.Count, i => { var item = Items[i]; if (!item.Slot.StartsWith("Loot")) { var keytags = new[] { item.GetTag("itemStyleTag"), item.GetTag("itemNameTag", "description"), item.GetTag("itemQualityTag") }; List<string> finalTags = new List<string>(); foreach (var tag in keytags) { var t = tags.FirstOrDefault(m => m.Tag == tag); if (t != null) { finalTags.Add(t.Name); } } Items[i].Name = string.Join(" ", finalTags).Trim(); } tracker.Increment(); }); tracker.MaxProgress(); }
public void Generate(ProgressTracker tracker) { Logger.Debug($"Generating skills for {_items.Count} items."); tracker.MaxValue = _items.Count; foreach (var item in _items) { var skill = GetSkill(item); if (skill != null) { if (!SkillItemMapping.ContainsKey(skill.Record)) { SkillItemMapping[skill.Record] = new List <string>(); } SkillItemMapping[skill.Record].Add(item.Record); Skills.Add(skill); } tracker.Increment(); } var numItemsWithSkills = SkillItemMapping.Values.Sum(m => m.Count); Logger.Debug($"Generated {Skills.Count} skills for {numItemsWithSkills} items."); }
public void LoadItems( List <string> arzFiles, ProgressTracker tracker ) { tracker.MaxValue = arzFiles.Select(File.Exists).Count(); // Developers can flip this switch to get a full dump of the GD database. // Setting it to true will cause the parsing to skip a lot of data that IA does not need. const bool skipIrrelevantStats = false; ItemAccumulator accumulator = new ItemAccumulator(); foreach (string arzFile in arzFiles) { if (File.Exists(arzFile)) { Logger.Debug($"Parsing / Loading items from {arzFile}"); Parser.Arz.ArzParser.LoadItemRecords(arzFile, skipIrrelevantStats).ForEach(accumulator.Add); tracker.Increment(); } else { Logger.Debug($"Ignnoring non existing arz file {arzFile}"); } } Items = accumulator.Items; }
public void LoadTags( List <string> tagfiles, string localizationFile, ProgressTracker tracker ) { int numFiles = tagfiles.Count - tagfiles.Where(string.IsNullOrEmpty).Count() + (string.IsNullOrEmpty(localizationFile) ? 0 : 1); tracker.MaxValue = numFiles; // Load tags in a prioritized order foreach (var tagfile in tagfiles) { if (File.Exists(tagfile)) { Logger.Debug($"Loading tags from {tagfile}"); LoadTags(tagfile); } else { Logger.Debug($"Ignoring non-existing tagfile {tagfile}"); } tracker.Increment(); } // User override for some tags var localizationLoader = new LocalizationLoader(); if (!string.IsNullOrEmpty(localizationFile) && localizationLoader.Load(localizationFile)) { Logger.Debug($"Loading tags from {localizationFile}"); var tags = localizationLoader.GetItemTags(); foreach (var tag in tags) { _tagAccumulator.Add(tag.Tag, tag.Name); } Logger.Debug($"Loaded {tags.Count} tags from {localizationFile}"); tracker.Increment(); } tracker.MaxProgress(); }
public void LoadTags( string tagfileVanilla, string tagfileExpansion1, string tagfileMod, string localizationFile, ProgressTracker tracker ) { var files = new[] { tagfileVanilla, tagfileExpansion1, tagfileMod }; int numFiles = files.Length - files.Where(string.IsNullOrEmpty).Count() + (string.IsNullOrEmpty(localizationFile) ? 0 : 1); tracker.MaxValue = numFiles; // Load tags in a prioritized order foreach (var tagfile in files) { if (File.Exists(tagfile)) { LoadTags(tagfile); } tracker.Increment(); } // User override for some tags var localizationLoader = new LocalizationLoader(); if (!string.IsNullOrEmpty(localizationFile) && localizationLoader.Load(localizationFile)) { Logger.Debug($"Loading tags from {localizationFile}"); var tags = localizationLoader.GetItemTags(); foreach (var tag in tags) { _tagAccumulator.Add(tag.Tag, tag.Name); } Logger.Debug($"Loaded {tags.Count} tags from {localizationFile}"); tracker.Increment(); } tracker.MaxProgress(); }
public void AnimationEnded() { completionCount++; if (completionCount == 5) { ParticleSystem.EmissionModule h1 = haze1.emission; h1.rateOverTime = 0; progressTracker.Increment(playerID); } else if (completionCount == 10) { ParticleSystem.EmissionModule h2 = haze2.emission; h2.rateOverTime = 0; progressTracker.Increment(playerID); } else if (completionCount == 15) { ParticleSystem.EmissionModule h3 = haze3.emission; h3.rateOverTime = 0; progressTracker.Increment(playerID); } else if (completionCount == 20) { ParticleSystem.EmissionModule h4 = haze4.emission; h4.rateOverTime = 0; progressTracker.Increment(playerID); } else if (completionCount == 22) { hasCompleted = true; progressTracker.Increment(playerID); gameController.missionComplete(playerID, transform.parent.parent.rotation); iTween.ScaleTo(gameObject, iTween.Hash("scale", Vector3.zero, "time", 3)); } }
public List<DatabaseItemStat> GenerateSpecialRecords(ProgressTracker tracker) { var skills = Items .Where(m => m.Record.Contains("/skills/")) .ToList(); List<DatabaseItemStat> result = new List<DatabaseItemStat>(); var filtered = Items.Where(m => m.Id != 0).ToList(); tracker.MaxValue = filtered.Count; foreach (var item in filtered) { ArzParser.GetSpecialMasteryStats(result, item, Items); ArzParser.GetSpecialSkillAugments(result, item, Items, skills, _tagAccumulator.MappedTags); tracker.Increment(); } return result; }
public void Save(IEnumerable <DatabaseItemStat> objs, ProgressTracker progressTracker) { progressTracker.MaxValue = objs.Count(); using (ISession session = SessionCreator.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { foreach (var entry in objs) { session.Save(entry); progressTracker.Increment(); } transaction.Commit(); } } progressTracker.MaxProgress(); }
// Increasing instruction counter as long there is one public bool IncrementToNextInstruction() { if (currentInstructionNr < instructions.Count - 1) { currentInstructionNr++; if (autoProgress) { progressTracker.Increment(); } return(true); } else { //Debug.Log("Can't increment, instructionNr: " + currentInstructionNr); return(false); } }
public void Save(IEnumerable <DatabaseItemStat> objs, ProgressTracker progressTracker) { var databaseItemStats = objs as DatabaseItemStat[] ?? objs.ToArray(); progressTracker.MaxValue = databaseItemStats.Length; using (ISession session = SessionCreator.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { foreach (var entry in databaseItemStats) { session.Save(entry); progressTracker.Increment(); } transaction.Commit(); } } progressTracker.MaxProgress(); }
public void AnimationEnded() { completionCount++; progressTracker.Increment(playerID); targetSpeed = 0; animator.speed = 0; if (completionCount == 5) { hasCompleted = true; gameController.missionComplete(playerID, transform.parent.parent.rotation); iTween.ScaleTo(gameObject, iTween.Hash("scale", Vector3.zero, "time", 3)); soundEffect.Stop(); } else { StartCoroutine(PrepareNextCup()); } }
private void Update() { // Eject video when done playing if (currentPlayingVideoIsCompleted && currentPlayingVHS != null) { currentPlayingVideoIsCompleted = false; StartCoroutine(EjectVideo(null)); } if (videoPlayer.isPlaying && (int)videoPlayer.time != prevSecond) { // Update progress bar cornerScreenText.text = (int)videoPlayer.time + "/" + videoDuration; if (progressTracker != null) { progressTracker.Increment(); } prevSecond = (int)videoPlayer.time; if (prevSecond == videoDuration) { currentPlayingVideoIsCompleted = true; } } else if (vhsReceived) { // Video received, and when the user's hand has let go of the cassette then start the insert animation if (currentPlayingVHS != null && currentPlayingVHS.ReleasedFromHand) { StartCoroutine(InsertVideo(currentPlayingVHS)); vhsReceived = false; } } }
public void LoadItems( List <string> arzFiles, ProgressTracker tracker ) { tracker.MaxValue = arzFiles.Select(File.Exists).Count(); // Developers can flip this switch to get a full dump of the GD database. // Setting it to true will cause the parsing to skip a lot of data that IA does not need. const bool skipIrrelevantStats = true; // "skipLots" ItemAccumulator accumulator = new ItemAccumulator(); try { foreach (string arzFile in arzFiles) { if (File.Exists(arzFile)) { Logger.Debug($"Parsing / Loading items from {arzFile}"); Parser.Arz.ArzParser.LoadItemRecords(arzFile, skipIrrelevantStats).ForEach(accumulator.Add); tracker.Increment(); } else { Logger.Debug($"Ignoring non existing arz file {arzFile}"); } } } catch (ArgumentException ex) { Logger.Warn(ex.Message, ex); MessageBox.Show("Game installation is corrupted.\nPlease verify the integrity of your Grim Dawn installation and try again.\n\n(Easily done in steam)"); throw ex; } Items = accumulator.Items; }
public void LoadItems( List <string> arzFiles, ProgressTracker tracker ) { tracker.MaxValue = arzFiles.Select(File.Exists).Count(); // Developers can flip this switch to get a full dump of the GD database. // Setting it to true will cause the parsing to skip a lot of data that IA does not need. const bool skipIrrelevantStats = true; // "skipLots" ItemAccumulator accumulator = new ItemAccumulator(); try { foreach (string arzFile in arzFiles) { if (File.Exists(arzFile)) { Logger.Debug($"Parsing / Loading items from {arzFile}"); Parser.Arz.ArzParser.LoadItemRecords(arzFile, skipIrrelevantStats).ForEach(accumulator.Add); tracker.Increment(); } else { Logger.Debug($"Ignoring non existing arz file {arzFile}"); } } } catch (ArgumentException ex) { Logger.Warn(ex.Message, ex); MessageBox.Show(RuntimeSettings.Language.GetTag("iatag_ui_corrupted")); throw ex; } Items = accumulator.Items; }
private void Save(List <DatabaseItem> items, ProgressTracker progressTracker, bool reset) { long numStats = 0; using (var session = SessionCreator.OpenSession()) { if (reset) { using (ITransaction transaction = session.BeginTransaction()) { var records = items.Select(m => m.Record).ToList(); session.CreateSQLQuery($@" DELETE FROM {DatabaseItemStatTable.Table} WHERE {DatabaseItemStatTable.Item} IN ( SELECT {DatabaseItemTable.Id} FROM {DatabaseItemTable.Table} WHERE {DatabaseItemTable.Record} IN ( :records ) )") .SetParameterList("records", records) .ExecuteUpdate(); session.CreateSQLQuery($"DELETE FROM {DatabaseItemTable.Table} WHERE {DatabaseItemTable.Record} IN ( :records )") .SetParameterList("records", records) .ExecuteUpdate(); transaction.Commit(); } } using (ITransaction transaction = session.BeginTransaction()) { foreach (DatabaseItem item in items) { session.Save(item); progressTracker.Increment(); } transaction.Commit(); } } var createCommands = new [] { "create index idx_databaseitemstatv2_parent on DatabaseItemStat_v2 (id_databaseitem)", "create index idx_databaseitemstatv2_stat on DatabaseItemStat_v2 (Stat)", "create index idx_databaseitemstatv2_tv on DatabaseItemStat_v2 (TextValue)" }; var dropCommands = new [] { "drop index if exists idx_databaseitemstatv2_parent", "drop index if exists idx_databaseitemstatv2_stat", "drop index if exists idx_databaseitemstatv2_tv" }; using (SQLiteConnection dbConnection = new SQLiteConnection(SessionFactoryLoader.SessionFactory.ConnectionString)) { dbConnection.Open(); var sq = new System.Diagnostics.Stopwatch(); sq.Start(); ExecuteTransactionSql(dbConnection, dropCommands); using (var transaction = dbConnection.BeginTransaction()) { using (SQLiteCommand command = new SQLiteCommand(dbConnection)) { string sql = "insert into databaseitemstat_v2 (id_databaseitem, stat, textvalue, val1) values (@id, @stat, @tv, @val)"; command.CommandText = sql; foreach (DatabaseItem item in items) { foreach (DatabaseItemStat stat in item.Stats) { command.Parameters.Add(new SQLiteParameter("@id", item.Id)); command.Parameters.Add(new SQLiteParameter("@stat", stat.Stat)); command.Parameters.Add(new SQLiteParameter("@tv", stat.TextValue)); command.Parameters.Add(new SQLiteParameter("@val", stat.Value)); command.ExecuteNonQuery(); numStats++; } } } transaction.Commit(); } ExecuteTransactionSql(dbConnection, createCommands); sq.Stop(); Logger.Info("Records stored"); Console.WriteLine($"Storing the records took {sq.ElapsedMilliseconds} milliseconds"); } Logger.InfoFormat("Stored {0} items and {1} stats to internal db.", items.Count, numStats); }
private void Save(List <DatabaseItem> items, ProgressTracker progressTracker, bool reset) { // Insert the items (not stats) using (var session = SessionCreator.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { var records = items.Select(m => m.Record).ToList(); session.CreateSQLQuery($@" DELETE FROM {DatabaseItemStatTable.Table} WHERE {DatabaseItemStatTable.Item} IN ( SELECT {DatabaseItemTable.Id} FROM {DatabaseItemTable.Table} WHERE {DatabaseItemTable.Record} IN ( :records ) )") .SetParameterList("records", records) .ExecuteUpdate(); session.CreateSQLQuery($"DELETE FROM {DatabaseItemTable.Table} WHERE {DatabaseItemTable.Record} IN ( :records )") .SetParameterList("records", records) .ExecuteUpdate(); transaction.Commit(); } using (ITransaction transaction = session.BeginTransaction()) { foreach (DatabaseItem item in items) { session.Save(item); progressTracker.Increment(); } transaction.Commit(); } } var createCommands = new[] { "create index idx_databaseitemstatv2_parent on DatabaseItemStat_v2 (id_databaseitem)", "create index idx_databaseitemstatv2_stat on DatabaseItemStat_v2 (Stat)", "create index idx_databaseitemstatv2_tv on DatabaseItemStat_v2 (TextValue)" }; var dropCommands = new[] { "drop index if exists idx_databaseitemstatv2_parent", "drop index if exists idx_databaseitemstatv2_stat", "drop index if exists idx_databaseitemstatv2_tv" }; // Drop index, insert stats, recreate index var sq = new System.Diagnostics.Stopwatch(); sq.Start(); const string sql = "insert into databaseitemstat_v2 (id_databaseitem, stat, textvalue, val1) values (@id, @stat, @tv, @val)"; int numStats; if (Dialect == SqlDialect.Sqlite) { numStats = InsertStatsSqlite(dropCommands, createCommands, sql, items); } else { numStats = InsertStatsPostgres(dropCommands, createCommands, items); } sq.Stop(); Logger.Info("Records stored"); Console.WriteLine($"Storing the records took {sq.ElapsedMilliseconds} milliseconds"); Logger.InfoFormat("Stored {0} items and {1} stats to internal db.", items.Count, numStats); }