internal PakCache(VersionTable.Version version)
 {
     _Version   = version;
     _CachePath = null;
     _Loader    = null;
     _Cache     = new Dictionary <string, BitmapSource>();
 }
 public static BitmapSource GetImage(str object_name, int desired_resolution, VersionTable.Version version)
 {
     if (object_name == null)
     {
         return(null);
     }
     return(GetImage(object_name.ToString(), desired_resolution, version));
 }
        private static bool _CreateCache(VersionTable.Version version, ICallback callback)
        {
            if (!_Cache.ContainsKey(version))
            {
                // Find path to pak by version given
                string pakfile = null;
                try
                {
                    if (version == VersionTable.Version.EarlyAccess)
                    {
                        pakfile = Config.Root.pak_loader.ea_path;
                    }
                    else if (version == VersionTable.Version.Experimental)
                    {
                        pakfile = Config.Root.pak_loader.exp_path;
                    }
                }
                catch
                {
                }
                if (pakfile == null || !File.Exists(pakfile))
                {
                    return(false);
                }

                PakCache cache = new PakCache(version);
                if (!cache.Load(pakfile, callback))
                {
                    return(false);
                }

                _Cache.Add(version, cache);
            }

            return(true);
        }
Example #4
0
 public BitmapSource this[VersionTable.Version version]
 {
     get { return(_icons[(int)version]); }
     set { _icons[(int)version] = value; }
 }
        public static BitmapSource GetImage(string object_name, int desired_resolution, VersionTable.Version version)
        {
            //TODO: Check for background activity, and wait until this cache is loaded finally
            while (_loading)
            {
                Application.Current.Dispatcher.Invoke(() => { }, DispatcherPriority.Render);
                System.Threading.Thread.Yield();
                Application.Current.Dispatcher.Invoke(() => { }, DispatcherPriority.ContextIdle);
            }

            if (!_Cache.ContainsKey(version))
            {
                return(null);
            }
            return(_Cache[version].GetImage(object_name, desired_resolution));
        }
 public static PakLoader GetPak(VersionTable.Version version)
 {
     return(_Cache[version]._Loader);
 }