private void load(TextureStore textures, APIController api, ImageFinderOverlay imageFinder, SplashInfoOverlay infoOverlay) { AutoSizeAxes = Axes.Both; Child = new CircularContainer { BorderColour = Colour4.Black, BorderThickness = 3.5f, Masking = true, Size = ButtonSize, Children = new Drawable[] { image = new Sprite { RelativeSizeAxes = Axes.Both, Texture = textures.Get($"https://gamestogo.company/api/Users/DownloadImage/{api.LocalUser.Value.ID}"), }, hoverContainer = new Container { RelativeSizeAxes = Axes.Both, Alpha = 0, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = Colour4.Black.Opacity(0.5f), }, new SpriteIcon { Anchor = Anchor.Centre, Origin = Anchor.BottomCentre, Icon = FontAwesome.Regular.Images, Size = new Vector2(60), }, new SpriteText { Anchor = Anchor.Centre, Origin = Anchor.TopCentre, Font = new FontUsage(size: 40), Text = @"Cambiar imagen", }, }, }, }, }; Action = () => imageFinder.Show(i => { var req = new UploadUserImageRequest(i); req.Success += () => image.Texture = Texture.FromStream(new MemoryStream(i)); req.Failure += e => infoOverlay.Show(@"Falló como siempre", Colour4.DarkRed); api.Queue(req); }); }
private void load() { Resources.AddStore(new DllResourceStore(@"GamesToGo.Game.dll")); Textures.AddStore(Host.CreateTextureLoaderStore(new OnlineStore())); Textures.AddStore(Host.CreateTextureLoaderStore(new StorageBackedResourceStore(store))); dependencies.CacheAs(this); base.Content.Add(content = new DrawSizePreservingFillContainer { TargetDrawSize = new Vector2(1080, 1920), Strategy = DrawSizePreservationStrategy.Minimum, }); content.Add(stack = new ScreenStack { RelativeSizeAxes = Axes.Both, Depth = 0, }); content.Add(api = new APIController()); dependencies.Cache(api); dependencies.Cache(stack); content.Add(infoOverlay = new SplashInfoOverlay(SplashPosition.Top, 150, 60) { Depth = -1 }); dependencies.Cache(infoOverlay); Invitations.BindCollectionChanged((_, e) => { switch (e.Action) { case NotifyCollectionChangedAction.Add: infoOverlay.Show(@$ "{e.NewItems.Cast<Invitation>().Last().Sender.Username} te ha invitado a jugar", Colour4.LightBlue); break; case NotifyCollectionChangedAction.Remove: break; } }); }
private void shortText() { bottomOverlay.Show("Short test", Colour4.Brown); topOverlay.Show("Short test", Colour4.Brown); }
public TaskCompletionSource <bool> DownloadGame(OnlineGame game) { var completionSource = new TaskCompletionSource <bool>(); var files = store.GetStorageForDirectory("files").GetFiles(""); var getFilenamesForGame = new GetFileListForGameRequest(game.Id); getFilenamesForGame.Success += gameFiles => { var missingFiles = new Queue <string>(gameFiles.Except(files).ToArray()); if (missingFiles.Count == gameFiles.Count) { var getGame = new DownloadProjectRequest(game.Id, game.Hash, store); getGame.Success += g => { completionSource.SetResult(true); importGame(game.Hash); }; getGame.Progressed += _ => { infoOverlay.Show(@"Descargando juego...", Colour4.Turquoise); }; getGame.Failure += _ => failure(); api.Queue(getGame); } else { Task.Run(() => { while (missingFiles.Count > 0) { var getFile = new DownloadSpecificFileRequest(missingFiles.Dequeue(), store); var fileDownloaded = false; getFile.Success += () => { fileDownloaded = true; }; getFile.Progressed += current => { Schedule(() => infoOverlay.Show(@$ "Descargando archivos faltantes (faltan {missingFiles.Count + 1})...", Colour4.Turquoise)); }; getFile.Failure += _ => { missingFiles.Clear(); failure(); }; api.Queue(getFile); while (!fileDownloaded && missingFiles.Count > 0) { } } completionSource.SetResult(true); }); } }; getFilenamesForGame.Failure += _ => failure(); api.Queue(getFilenamesForGame); return(completionSource); void failure() { completionSource.SetResult(false); infoOverlay.Show(@"Error al descargar el juego!", Colour4.DarkRed); } }