Esempio n. 1
0
        public static void SaveCache()
        {
            if (!CacheReady)
            {
                return;
            }
            try {
                TLBCache Cache = new TLBCache()
                {
                    Signature     = "TLBC",
                    Original      = Program.Cache.Keys.OfType <string>().ToArray(),
                    Translations  = Program.Cache.Values.OfType <string>().ToArray(),
                    ManualString  = ForceDialogues.Keys.OfType <string>().ToArray(),
                    ManualChecked = ForceDialogues.Values.OfType <bool>().ToArray()
                };

                if (File.Exists(CachePath))
                {
                    File.Delete(CachePath);
                }

                using (StructWriter Writer = new StructWriter(CachePath)) {
                    Writer.WriteStruct(ref Cache);
                    Writer.Close();
                }
            } catch { }

            SaveTask();
        }
Esempio n. 2
0
        public static void LoadCache(Action OnFinish)
        {
            new Thread(() => {
                try {
                    TLBCache Cache = new TLBCache();
                    using (StructReader Reader = new StructReader(CachePath)) {
                        Reader.ReadStruct(ref Cache);
                        Reader.Close();
                    }

                    Program.Cache = new Dictionary <string, string>();
                    for (uint i = 0; i < Cache.Entries; i++)
                    {
                        Program.Cache[Cache.Original[i]] = Cache.Translations[i];
                    }

                    ForceDialogues = new Dictionary <string, bool>();
                    for (uint i = 0; i < Cache.SEntries; i++)
                    {
                        ForceDialogues[Cache.ManualString[i]] = Cache.ManualChecked[i];
                    }
                } catch { }

                try {
                    if (File.Exists(TaskPath))
                    {
                        TaskInfo = new TaskInfo();
                        using (StructReader Reader = new StructReader(TaskPath)) {
                            Reader.ReadStruct(ref TaskInfo);
                            Reader.Close();
                        }
                    }
                } catch { }

                OnFinish?.Invoke();
            }).Start();
        }