public new void Load(string spellPath) { SpellPath = spellPath; Text = spellPath; Cursor.Current = Cursors.WaitCursor; Cache = new SpellCache(); Cache.LoadSpells(spellPath); SearchCategory.Items.AddRange(Cache.SpellList.SelectMany(x => x.Categories).Distinct().ToArray()); SearchClass_TextChanged(this, null); AutoSearch.Enabled = false; Cursor.Current = Cursors.Default; var html = HtmlBuilder.InitTemplate(); html.AppendFormat("<p>Loaded <strong>{0}</strong> spells from {1}.</p></html>", Cache.SpellList.Count(), SpellPath); html.Append("<p>Use the search button to perform a search on this spell file based on the filters on the left."); html.Append("<p>Use the compare button to compare two different spell files and show the differences. e.g. test server vs live server spells."); html.AppendFormat("<p>This parser is an open source application. Visit <a href='{0}' class='ext' target='_top'>{0}</a> to download updates.", "https://github.com/rumstil/eqspellparser"); //html.Append("<p>Nov 8 2017 - Some spells will now show as 'Mostly Unresistable'. This means they are unresistable by standard resists and can only be resisted by Sanctification/Mystical Shielding AA or SPA 180 spells."); ShowHtml(html.ToString()); }
private bool DoMatch(SpellCache spellsCache, string keywordInTrueCase, bool isCaseSensitive, ref List <bool> hitFlags) { Debug.Assert(!string.IsNullOrEmpty(keywordInTrueCase)); Debug.Assert(spellsCache.Units.Count > 0 && spellsCache.Units.All(x => x.Count > 0)); bool isKeywordMatched = false; for (int i = 0; i <= spellsCache.Units.Count - keywordInTrueCase.Length; i++) { bool flag = true; // check any matched to keyword for (int j = 0; j < keywordInTrueCase.Length; j++) { if (spellsCache.ConvertFlag[i + j] == true && spellsCache.Units[i + j].All(x => x != keywordInTrueCase[j].ToString().ToLower()) || spellsCache.ConvertFlag[i + j] == false && spellsCache.Units[i + j].All(x => x != keywordInTrueCase[j].ToString())) { // no match for this turn. flag = false; break; } } if (flag) { // matched then update hitFlags. isKeywordMatched = true; for (int j = 0; j < keywordInTrueCase.Length; j++) { hitFlags[i + j] = true; } } } return(isKeywordMatched); }
private bool MatchSpellUnits(SpellCache spellsCache, int index, string keyword, int keywordIndex, List <bool> hitFlags) { for (int i = 0; i < spellsCache.Units[index].Count; i++) { if (MatchOneSpell(spellsCache.Units[index][i], spellsCache.ConvertFlag[index], keyword, keywordIndex)) { if (keywordIndex + spellsCache.Units[index][i].Length >= keyword.Length) { hitFlags[index] = true; return(true); } if (index + 1 < spellsCache.Units.Count && MatchSpellUnits(spellsCache, index + 1, keyword, keywordIndex + spellsCache.Units[index][i].Length, hitFlags)) { hitFlags[index] = true; return(true); } else { hitFlags[index] = false; } } } hitFlags[index] = false; return(false); }
/// <summary> /// append cache for this match provider to MatchCache /// </summary> /// <returns></returns> /// <param name="matchCache"></param> public override void AppendDescriptions(ref MatchCache matchCache) { if (matchCache.SpellCaches.ContainsKey(nameof(InitialsMatchProvider))) { matchCache.SpellCaches.TryRemove(nameof(InitialsMatchProvider), out _); } var sp = new SpellCache(GetProviderName(), matchCache.StringLength); // set PinYin chart cache for (var i = 0; i < matchCache.OriginalString.Length; i++) { var c = matchCache.OriginalString[i]; if (i == 0 && c != ' ' || i > 0 && matchCache.OriginalString[i - 1] == ' ' && c != ' ') { sp.Units[i].Add(base.IsCaseSensitive ? c.ToString() : c.ToString().ToLower()); } else { sp.SkipFlag[i] = true; } } matchCache.SpellCaches.AddOrUpdate(nameof(InitialsMatchProvider), sp, (key, value) => value); }
static void Main(string[] args) { try { int dec = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalDigits; if (dec < 2) Console.Error.WriteLine("Your system has been configured to display {0} decimal digits. Some values will be rounded.", dec); if (args.Length == 0) { Console.Error.WriteLine("You must include a search parameter on the command line."); Thread.Sleep(2000); return; } if (args[0] == "update") { DownloadPatchFiles(args.Length >= 2 ? args[1] : null); return; } if (File.Exists(args[0])) { SpellFilename = args[0]; args[0] = "all"; } if (!File.Exists(SpellFilename)) DownloadPatchFiles(null); SpellParser.loadFriendlyNames(); Console.Error.Write("Loading {0}... ", SpellFilename); spells = new SpellCache(Path.GetFileName(SpellFilename), SpellParser.LoadFromFile(SpellFilename, SpellFilename.Replace("spells_us", "dbstr_us"))); Console.Error.WriteLine("{0} spells", spells.Count); // perform search based on command line parameters string type = args.Length >= 1 ? args[0].ToLower() : null; string value = args.Length >= 2 ? args[1] : null; Console.Error.Write("Searching for {0} {1}... ", type, value); var results = Search(type, value); if (results != null) { Console.Error.WriteLine("{0} results", results.Count); Console.Error.WriteLine(); spells.Expand(results, false); Show(results); } } catch (Exception ex) { Console.Error.WriteLine(ex); } }
private bool DoMatch(string orgStringInTrueCase, SpellCache spellCache, string keywordInTrueCase, ref List <bool> hitFlags) { bool isKeywordMatched = false; for (int i = 0; i <= orgStringInTrueCase.Length - keywordInTrueCase.Length; i++) { if (spellCache.SkipFlag[i]) { continue; } var tmpHitFlags = CreateBoolFlags(hitFlags.Count); bool flag = true; int j = 0; int k = i; for (; j < keywordInTrueCase.Length; j++) { if (k >= orgStringInTrueCase.Length || j >= keywordInTrueCase.Length) { break; } if (orgStringInTrueCase[k] == keywordInTrueCase[j]) { tmpHitFlags[k] = true; ++k; while (k < orgStringInTrueCase.Length && spellCache.SkipFlag[k]) { ++k; } continue; } else { flag = false; break; } } if (flag && tmpHitFlags.Count(x => x) == keywordInTrueCase.Length) { // matched then update hitFlags. isKeywordMatched = true; for (int l = 0; l < hitFlags.Count; l++) { hitFlags[l] |= tmpHitFlags[l]; } } } return(isKeywordMatched); }
public void ClearCachesAndFreeMemory(int severity) { UnityEngine.Debug.LogWarning(string.Format("Clearing Caches; this will force assets to be reloaded off disk and may be slow! {0}", severity)); if (StoreManager.Get() != null) { StoreManager.Get().UnloadAndFreeMemory(); } if (severity > 15) { if (SpellCache.Get() != null) { SpellCache.Get().Clear(); } AssetCache.ClearAllCaches(true, false); } ApplicationMgr.Get().UnloadUnusedAssets(); }
/// <summary> /// append cache for this match provider to MatchCache /// </summary> /// <returns></returns> public override void AppendDescriptions(ref MatchCache matchCache) { var sp = new SpellCache(GetProviderName(), matchCache.StringLength); // set PinYin chart cache for (var i = 0; i < matchCache.OriginalString.Length; i++) { var tmp = ToolGood.Words.Pinyin.WordsHelper.GetAllPinyin(matchCache.OriginalString[i]); if (tmp?.Any() == true) { foreach (var t in tmp) { // PinYin ignore case sp.Units[i].Add(t.ToLower()); } sp.ConvertFlag[i] = true; } else { sp.ConvertFlag[i] = false; } } // no Chinese character. if (sp.Units.All(x => x.Count == 0)) { matchCache.SpellCaches.AddOrUpdate(nameof(ChineseZhCnPinYinMatchProvider), new SpellCache(GetProviderName(), matchCache.StringLength), (key, value) => value); return; } // set original char cache for (var i = 0; i < matchCache.OriginalString.Length; i++) { if (sp.Units[i].Count == 0) { var c = matchCache.OriginalString[i]; // PinYin ignore case sp.Units[i].Add(base.IsCaseSensitive ? c.ToString() : c.ToString().ToLower()); } } matchCache.SpellCaches.AddOrUpdate(nameof(ChineseZhCnPinYinMatchProvider), sp, (key, value) => value); }
private bool DoMatch(SpellCache spellsCache, string keywordInTrueCase, bool isCaseSensitive, ref List <bool> hitFlags) { Debug.Assert(!string.IsNullOrEmpty(keywordInTrueCase)); Debug.Assert(spellsCache.Units.Count > 0 && spellsCache.Units.All(x => x.Count > 0)); bool isKeywordMatched = false; for (int i = 0; i < spellsCache.Units.Count; i++) { var tmpHitFlags = CreateBoolFlags(hitFlags.Count); var flag = MatchSpellUnits(spellsCache, i, keywordInTrueCase, 0, tmpHitFlags); if (flag == true) { // matched then update hitFlags. isKeywordMatched = true; for (int j = 0; j < hitFlags.Count; j++) { hitFlags[j] |= tmpHitFlags[j]; } } } return(isKeywordMatched); }
static void Main(string[] args) { var path = LaunchpadManifest.SPELL_FILE; try { int dec = CultureInfo.CurrentCulture.NumberFormat.NumberDecimalDigits; if (dec < 2) { Console.Error.WriteLine("Your system has been configured to display {0} decimal digits. Some values will be rounded.", dec); } if (args.Length == 0) { Console.Error.WriteLine("You must include a search parameter on the command line."); Thread.Sleep(2000); return; } if (args[0] == "update") { var server = args.Length >= 2 ? args[1] : null; LaunchpadPatcher.DownloadSpellFiles(server); return; } if (File.Exists(args[0])) { path = args[0]; args[0] = "all"; } if (!File.Exists(path)) { LaunchpadPatcher.DownloadSpellFiles(); } Console.Error.Write("Loading {0}... ", path); cache = new SpellCache(); cache.LoadSpells(path); Console.Error.WriteLine("{0} spells", cache.SpellList.Count()); // perform search based on command line parameters var type = args.Length >= 1 ? args[0].ToLower() : null; var value = args.Length >= 2 ? args[1] : null; Console.Error.Write("Searching for {0} {1}... ", type, value); var results = Search(type, value); if (results != null) { Console.Error.WriteLine("{0} results", results.Count); Console.Error.WriteLine(); cache.AddForwardRefs(results); Show(results); } } catch (Exception ex) { Console.Error.WriteLine(ex); } }
public HtmlBuilder(SpellCache cache) { Cache = cache; Html = InitTemplate(); }
public new void Load(string spellPath, string descPath) { SpellPath = spellPath; Text = spellPath; Cursor.Current = Cursors.WaitCursor; Spells = new SpellCache(Path.GetFileName(spellPath), SpellParser.LoadFromFile(spellPath, descPath)); SearchClass_TextChanged(this, null); AutoSearch.Enabled = false; int i = 0; foreach (var s in Spells) { if (!String.IsNullOrEmpty(s.Desc)) i++; } Cursor.Current = Cursors.Default; var html = InitHtml(); html.AppendFormat("<p>Loaded <strong>{0}</strong> spells from {1}.</p></html>", Spells.Count, SpellPath); if (i > 0) html.AppendFormat("<p>Loaded <strong>{0}</strong> spell descriptions from {1}.</p></html>", i, descPath); html.Append("<p>Use the <strong>Search</strong> button to perform a search on this spell file based on the filters to the left."); //html.Append("<p>Use the compare button to compare two different spell files and show the differences. e.g. test server vs live server spells."); //html.Append("<p>Tip: You can use the up/down arrow keys when the cursor is in the Class/Has Effect/Category fields to quickly try different searches."); //html.Append("<p>Tip: This parser is an open source application and accepts updates and corrections here: <a href='http://code.google.com/p/eqspellparser/' class='ext' target='_top'>http://code.google.com/p/eqspellparser/</a>"); ShowHtml(html); PrintBtn.Enabled = false; }
private void Awake() { s_instance = this; }
private void OnDestroy() { s_instance = null; }