public void AddAsset(int x, int y, SuperGumpAsset asset) { if (SuperGumpAsset.IsNullOrEmpty(asset)) { return; } int ax, ay; Color ac; for (ax = 0; ax < asset.Width; ax++) { for (ay = 0; ay < asset.Height; ay++) { if ((ac = asset[ax, ay]).A > 0) { AddHtml(x + ax, y + ay, 1, 1, " ".WrapUOHtmlBG(ac), false, false); } } } }
public static SuperGumpAsset CreateInstance(FileInfo file, bool cache, bool reload) { if (file == null || !file.Exists) { return(Empty); } return(VitaNexCore.TryCatchGet( () => { var hash = CryptoGenerator.GenString(CryptoHashType.MD5, file.FullName); SuperGumpAsset a; lock (_CacheLock) { a = AssetCache.FirstOrDefault(ca => ca.Hash == hash); } if (a == null || reload) { using (var img = new Bitmap(file.FullName, true)) { a = new SuperGumpAsset(file, img); if (cache) { lock (_CacheLock) { AssetCache.AddOrReplace(a); } } } } if (IsNullOrEmpty(a)) { return Empty; } if (!cache || a.Capacity > 0x1000) { lock (_CacheLock) { AssetCache.Remove(a); AssetCache.Free(false); } } lock (_CacheLock) { if (AssetCache.Count > 100) { AssetCache.RemoveAt(0); } AssetCache.Free(false); } return a; }, VitaNexCore.ToConsole)); }
public static bool IsNullOrEmpty(SuperGumpAsset asset) { return(asset == null || asset == Empty || asset.Hash == Empty.Hash || asset.Capacity == 0 || asset.Count == 0); }
static SuperGumpAsset() { AssetCache = new List <SuperGumpAsset>(); Empty = new SuperGumpAsset(); }
public void AddAsset(int x, int y, FileInfo file) { AddAsset(x, y, SuperGumpAsset.LoadAsset(file)); }
public void AddAsset(int x, int y, Uri url) { AddAsset(x, y, SuperGumpAsset.LoadAsset(url)); }
public void AddAsset(int x, int y, string path) { AddAsset(x, y, SuperGumpAsset.LoadAsset(path)); }
protected SuperGumpAsset LoadAsset(string path) { return(SuperGumpAsset.LoadAsset(path)); }
public bool Equals(SuperGumpAsset other) { return(!ReferenceEquals(other, null) && Hash.Equals(other.Hash)); }