/// <summary> /// Downloads a mapset banner and returns a stream for it /// </summary> /// <param name="id"></param> public static async Task <Texture2D> DownloadMapsetBanner(int id) { if (DownloadScreen.MapsetBanners.ContainsKey(id)) { return(DownloadScreen.MapsetBanners[id]); } var url = OnlineClient.GetBannerUrl(id); try { using (var webClient = new WebClient()) { var data = await webClient.DownloadDataTaskAsync(url); using (var mem = new MemoryStream(data)) { var img = AssetLoader.LoadTexture2D(mem); DownloadScreen.MapsetBanners[id] = img; return(img); } } } catch (Exception) { // ignored } // Make a transparent texture. return(UserInterface.MenuBackgroundBlurred); }
/// <summary> /// Downloads a mapset banner and returns a stream for it /// </summary> /// <param name="id"></param> public static Texture2D DownloadMapsetBanner(int id) { if (DownloadScreen.MapsetBanners.ContainsKey(id)) { return(DownloadScreen.MapsetBanners[id]); } var url = OnlineClient.GetBannerUrl(id); try { using (var webClient = new WebClient()) { var data = webClient.DownloadData(url); using (var mem = new MemoryStream(data)) { var img = AssetLoader.LoadTexture2D(mem); DownloadScreen.MapsetBanners[id] = img; return(img); } } } catch (Exception) { // ignored } // Make a transparent texture. var texture = new Texture2D(GameBase.Game.GraphicsDevice, 1, 1); texture.SetData(new[] { Color.Transparent }); DownloadScreen.MapsetBanners[id] = texture; return(texture); }