private void beginTracking() { Debug.Assert(selectedBeatmap.BeatmapSet != null); downloadTracker = new BeatmapDownloadTracker(selectedBeatmap.BeatmapSet); AddInternal(downloadTracker); downloadTracker.State.BindValueChanged(_ => Scheduler.AddOnce(updateAvailability), true); downloadTracker.Progress.BindValueChanged(_ => { if (downloadTracker.State.Value != DownloadState.Downloading) { return; } // incoming progress changes are going to be at a very high rate. // we don't want to flood the network with this, so rate limit how often we send progress updates. if (progressUpdate?.Completed != false) { progressUpdate = Scheduler.AddDelayed(updateAvailability, progressUpdate == null ? 0 : 500); } }, true); // handles changes to hash that didn't occur from the import process (ie. a user editing the beatmap in the editor, somehow). realmSubscription?.Dispose(); realmSubscription = realm.RegisterForNotifications(r => filteredBeatmaps(), (items, changes, ___) => { if (changes == null) { return; } Scheduler.AddOnce(updateAvailability); }); }
internal static void Initialize(GameHost host) { if (IsInitialized) { return; } if (host.Window is OsuTKWindow win) { IsEmbedded = win.IsEmbedded; } GLWrapper.host = new WeakReference <GameHost>(host); MaxTextureSize = GL.GetInteger(GetPName.MaxTextureSize); MaxRenderBufferSize = GL.GetInteger(GetPName.MaxRenderbufferSize); GL.Disable(EnableCap.StencilTest); GL.Enable(EnableCap.Blend); IsInitialized = true; reset_scheduler.AddDelayed(checkPendingDisposals, 0, true); }
public TestSceneShowMoreButton() { TestButton button = null; int fireCount = 0; Add(button = new TestButton { Anchor = Anchor.Centre, Origin = Anchor.Centre, Action = () => { fireCount++; // ReSharper disable once AccessToModifiedClosure // ReSharper disable once PossibleNullReferenceException Scheduler.AddDelayed(() => button.IsLoading = false, 2000); } }); AddStep("click button", () => button.Click()); AddAssert("action fired once", () => fireCount == 1); AddAssert("is in loading state", () => button.IsLoading); AddStep("click button", () => button.Click()); AddAssert("action not fired", () => fireCount == 1); AddAssert("is in loading state", () => button.IsLoading); AddUntilStep("wait for loaded", () => !button.IsLoading); AddStep("click button", () => button.Click()); AddAssert("action fired twice", () => fireCount == 2); AddAssert("is in loading state", () => button.IsLoading); }
private void updateTimeWithReschedule() { updateTime(); var diffToNow = DateTimeOffset.Now.Subtract(date); double timeUntilNextUpdate = 1000; if (diffToNow.TotalSeconds > 60) { timeUntilNextUpdate *= 60; if (diffToNow.TotalMinutes > 60) { timeUntilNextUpdate *= 60; if (diffToNow.TotalHours > 24) { timeUntilNextUpdate *= 24; } } } Scheduler.AddDelayed(updateTimeWithReschedule, timeUntilNextUpdate); }
protected override bool OnClick(ClickEvent e) { if (sp.Texture == sptex && running == false) { running = true; sp.FadeOutFromOne(100, Easing.Out); Scheduler.AddDelayed(() => sp.Texture = null, 101); } else if (running == false) { running = true; sp.Texture = sptex; sp.FadeInFromZero(131, Easing.In); } if (ClickAction != null) { ClickAction.Invoke(); } running = false; return(base.OnClick(e)); }
public void TestHoldingScaleHandleHidesCorrespondingRotationHandle() { SelectionBoxRotationHandle rotationHandle = null; AddStep("retrieve rotation handle", () => rotationHandle = this.ChildrenOfType <SelectionBoxRotationHandle>().First()); AddAssert("rotation handle hidden", () => rotationHandle.Alpha == 0); AddStep("hover over closest scale handle", () => { InputManager.MoveMouseTo(this.ChildrenOfType <SelectionBoxScaleHandle>().Single(s => s.Anchor == rotationHandle.Anchor)); }); AddUntilStep("rotation handle shown", () => rotationHandle.Alpha == 1); AddStep("hold scale handle", () => InputManager.PressButton(MouseButton.Left)); AddUntilStep("rotation handle hidden", () => rotationHandle.Alpha == 0); int i; ScheduledDelegate mouseMove = null; AddStep("start dragging", () => { i = 0; mouseMove = Scheduler.AddDelayed(() => { InputManager.MoveMouseTo(selectionBox.ScreenSpaceDrawQuad.TopLeft + Vector2.One * (5 * ++i)); }, 100, true); }); AddAssert("rotation handle still hidden", () => rotationHandle.Alpha == 0); AddStep("end dragging", () => mouseMove.Cancel()); AddAssert("rotation handle still hidden", () => rotationHandle.Alpha == 0); AddStep("unhold left", () => InputManager.ReleaseButton(MouseButton.Left)); AddUntilStep("rotation handle shown", () => rotationHandle.Alpha == 1); AddStep("move mouse away", () => InputManager.MoveMouseTo(selectionBox, new Vector2(20))); AddUntilStep("rotation handle hidden", () => rotationHandle.Alpha == 0); }
private void revisarRetiro() { buttonEnabled = false; using (var db = new DatabaseStore()) { var res = db.DepositoUsuario(cuenta, double.Parse(textbox.Text), CuentaDestino, out salida); switch (res) { case ResultadoOperacion.Correcto: tiempoDeposito = Time.Current; MostrarAlerta("Introduzca su efectivo usando cualquier tecla\nTiene 2 minutos para esta operación.", false, false); Scheduler.AddDelayed(depositoFallido, 120000); break; case ResultadoOperacion.NoCuenta: OnAlertHide = null; MostrarAlerta("Esta cuenta no existe o no permite depositos", true, true); break; default: break; } } }
private void bind() { ((IBindable <double>)circularProgress.Current).BindTo(Progress); Progress.ValueChanged += progress => { icon.Scale = new Vector2(1 + (float)progress.NewValue * 0.2f); if (IsDangerousAction) { Colour = Interpolation.ValueAt(progress.NewValue, Color4.White, Color4.Red, 0, 1, Easing.OutQuint); if (progress.NewValue > 0 && progress.NewValue < 1) { shakeOperation ??= Scheduler.AddDelayed(shake, shake_duration, true); } else { Child.MoveTo(Vector2.Zero, shake_duration * 2, Easing.OutQuint); shakeOperation?.Cancel(); shakeOperation = null; } } }; }
private void initializeChannels() { careChannels = new List <Channel>(); //if (api.State != APIAccess.APIState.Online) // return; SpriteText loading; Add(loading = new SpriteText { Text = @"Loading available channels...", Anchor = Anchor.Centre, Origin = Anchor.Centre, TextSize = 40, }); messageRequest?.Cancel(); ListChannelsRequest req = new ListChannelsRequest(); req.Success += delegate(List <Channel> channels) { Scheduler.Add(delegate { loading.FadeOut(100); addChannel(channels.Find(c => c.Name == @"#osu")); }); //addChannel(channels.Find(c => c.Name == @"#lobby")); //addChannel(channels.Find(c => c.Name == @"#english")); messageRequest = Scheduler.AddDelayed(() => FetchNewMessages(api), 1000, true); }; api.Queue(req); }
private void pushWhenLoaded() { if (!this.IsCurrentScreen()) { return; } if (!readyForPush) { // as the pushDebounce below has a delay, we need to keep checking and cancel a future debounce // if we become unready for push during the delay. cancelLoad(); return; } // if a push has already been scheduled, no further action is required. // this value is reset via cancelLoad() to allow a second usage of the same PlayerLoader screen. if (scheduledPushPlayer != null) { return; } scheduledPushPlayer = Scheduler.AddDelayed(() => { // ensure that once we have reached this "point of no return", readyForPush will be false for all future checks (until a new player instance is prepared). var consumedPlayer = consumePlayer(); ContentOut(); TransformSequence <PlayerLoader> pushSequence = this.Delay(CONTENT_OUT_DURATION); // only show if the warning was created (i.e. the beatmap needs it) // and this is not a restart of the map (the warning expires after first load). if (epilepsyWarning?.IsAlive == true) { const double epilepsy_display_length = 3000; pushSequence .Schedule(() => epilepsyWarning.State.Value = Visibility.Visible) .TransformBindableTo(volumeAdjustment, 0.25, EpilepsyWarning.FADE_DURATION, Easing.OutQuint) .Delay(epilepsy_display_length) .Schedule(() => { epilepsyWarning.Hide(); epilepsyWarning.Expire(); }) .Delay(EpilepsyWarning.FADE_DURATION); } else { // This goes hand-in-hand with the restoration of low pass filter in contentOut(). this.TransformBindableTo(volumeAdjustment, 0, CONTENT_OUT_DURATION, Easing.OutCubic); } pushSequence.Schedule(() => { if (!this.IsCurrentScreen()) { return; } LoadTask = null; // By default, we want to load the player and never be returned to. // Note that this may change if the player we load requested a re-run. ValidForResume = false; if (consumedPlayer.LoadedBeatmapSuccessfully) { this.Push(consumedPlayer); } else { this.Exit(); } }); }, 500); }
private void runNextStep(Action onCompletion, Action <Exception> onError, Func <StepButton, bool> stopCondition) { try { if (loadableStep != null) { if (loadableStep.IsMaskedAway) { scroll.ScrollTo(loadableStep); } loadableStep.PerformStep(); } } catch (Exception e) { onError?.Invoke(e); return; } string text = "."; if (actionRepetition == 0) { text = $"{(int)Time.Current}: ".PadLeft(7); if (actionIndex < 0) { text += $"{GetType().ReadableName()}"; } else { text += $"step {actionIndex + 1} {loadableStep?.ToString() ?? string.Empty}"; } } Console.Write(text); actionRepetition++; if (actionRepetition > (loadableStep?.RequiredRepetitions ?? 1) - 1) { actionIndex++; actionRepetition = 0; Console.WriteLine(); if (loadableStep != null && stopCondition?.Invoke(loadableStep) == true) { return; } } if (actionIndex > StepsContainer.Children.Count - 1) { onCompletion?.Invoke(); return; } if (Parent != null) { stepRunner = Scheduler.AddDelayed(() => runNextStep(onCompletion, onError, stopCondition), TimePerAction); } }
/// <summary> /// selection has been changed as the result of a user interaction. /// </summary> private void performUpdateSelected() { var beatmap = beatmapNoDebounce; var ruleset = rulesetNoDebounce; void run() { Logger.Log($"updating selection with beatmap:{beatmap?.ID.ToString() ?? "null"} ruleset:{ruleset?.ID.ToString() ?? "null"}"); bool preview = false; if (ruleset?.Equals(Ruleset.Value) == false) { Logger.Log($"ruleset changed from \"{Ruleset.Value}\" to \"{ruleset}\""); Beatmap.Value.Mods.Value = Enumerable.Empty <Mod>(); Ruleset.Value = ruleset; // force a filter before attempting to change the beatmap. // we may still be in the wrong ruleset as there is a debounce delay on ruleset changes. Carousel.Filter(null, false); // Filtering only completes after the carousel runs Update. // If we also have a pending beatmap change we should delay it one frame. selectionChangedDebounce = Schedule(run); return; } // We may be arriving here due to another component changing the bindable Beatmap. // In these cases, the other component has already loaded the beatmap, so we don't need to do so again. if (!Equals(beatmap, Beatmap.Value.BeatmapInfo)) { Logger.Log($"beatmap changed from \"{Beatmap.Value.BeatmapInfo}\" to \"{beatmap}\""); preview = beatmap?.BeatmapSetInfoID != Beatmap.Value?.BeatmapInfo.BeatmapSetInfoID; Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, Beatmap.Value); if (beatmap != null) { if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID) { sampleChangeDifficulty.Play(); } else { sampleChangeBeatmap.Play(); } } } if (IsCurrentScreen) { ensurePlayingSelected(preview); } UpdateBeatmap(Beatmap.Value); } selectionChangedDebounce?.Cancel(); if (beatmap == null) { run(); } else { selectionChangedDebounce = Scheduler.AddDelayed(run, 200); } }
private void scheduleHit() => AddStep("schedule action", () => { double delay = hitCircle.StartTime - hitCircle.HitWindows.WindowFor(HitResult.Great) - Time.Current; Scheduler.AddDelayed(() => hitAreaReceptor.OnPressed(new KeyBindingPressEvent <OsuAction>(GetContainingInputManager().CurrentState, OsuAction.LeftButton)), delay); });
protected override void LoadComplete() { base.LoadComplete(); Scheduler.AddDelayed(sort, 1000, true); }
private void updateLogoState(ButtonSystemState lastState = ButtonSystemState.Initial) { if (logo == null) { return; } switch (state) { case ButtonSystemState.Exit: case ButtonSystemState.Initial: logoDelayedAction?.Cancel(); logoDelayedAction = Scheduler.AddDelayed(() => { logoTracking = false; game?.Toolbar.Hide(); logo.ClearTransforms(targetMember: nameof(Position)); logo.RelativePositionAxes = Axes.Both; logo.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo); logo.ScaleTo(1, 800, Easing.OutExpo); }, buttonArea.Alpha * 150); break; case ButtonSystemState.TopLevel: case ButtonSystemState.Play: switch (lastState) { case ButtonSystemState.TopLevel: // coming from toplevel to play break; case ButtonSystemState.Initial: logo.ClearTransforms(targetMember: nameof(Position)); logo.RelativePositionAxes = Axes.None; bool impact = logo.Scale.X > 0.6f; if (lastState == ButtonSystemState.Initial) { logo.ScaleTo(0.5f, 200, Easing.In); } logo.MoveTo(logoTrackingPosition, lastState == ButtonSystemState.EnteringMode ? 0 : 200, Easing.In); logoDelayedAction?.Cancel(); logoDelayedAction = Scheduler.AddDelayed(() => { logoTracking = true; if (impact) { logo.Impact(); } game?.Toolbar.Show(); }, 200); break; default: logo.ClearTransforms(targetMember: nameof(Position)); logo.RelativePositionAxes = Axes.None; logoTracking = true; logo.ScaleTo(0.5f, 200, Easing.OutQuint); break; } break; case ButtonSystemState.EnteringMode: logoTracking = true; break; } }
private async Task <bool> checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null) { // should we schedule a retry on completion of this check? bool scheduleRecheck = true; try { updateManager ??= await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true).ConfigureAwait(false); var info = await updateManager.CheckForUpdate(!useDeltaPatching).ConfigureAwait(false); if (info.ReleasesToApply.Count == 0) { if (updatePending) { // the user may have dismissed the completion notice, so show it again. notificationOverlay.Post(new UpdateCompleteNotification(this)); return(true); } // no updates available. bail and retry later. return(false); } if (notification == null) { notification = new UpdateProgressNotification(this) { State = ProgressNotificationState.Active }; Schedule(() => notificationOverlay.Post(notification)); } notification.Progress = 0; notification.Text = @"Downloading update..."; try { await updateManager.DownloadReleases(info.ReleasesToApply, p => notification.Progress = p / 100f).ConfigureAwait(false); notification.Progress = 0; notification.Text = @"Installing update..."; await updateManager.ApplyReleases(info, p => notification.Progress = p / 100f).ConfigureAwait(false); notification.State = ProgressNotificationState.Completed; updatePending = true; } catch (Exception e) { if (useDeltaPatching) { logger.Add(@"delta patching failed; will attempt full download!"); // could fail if deltas are unavailable for full update path (https://github.com/Squirrel/Squirrel.Windows/issues/959) // try again without deltas. await checkForUpdateAsync(false, notification).ConfigureAwait(false); scheduleRecheck = false; } else { notification.State = ProgressNotificationState.Cancelled; Logger.Error(e, @"update failed!"); } } } catch (Exception) { // we'll ignore this and retry later. can be triggered by no internet connection or thread abortion. } finally { if (scheduleRecheck) { // check again in 30 minutes. Scheduler.AddDelayed(async() => await checkForUpdateAsync().ConfigureAwait(false), 60000 * 30); } } return(true); }
private void pushWhenLoaded() { if (!this.IsCurrentScreen()) { return; } try { if (!readyForPush) { // as the pushDebounce below has a delay, we need to keep checking and cancel a future debounce // if we become unready for push during the delay. cancelLoad(); return; } if (scheduledPushPlayer != null) { return; } scheduledPushPlayer = Scheduler.AddDelayed(() => { contentOut(); TransformSequence <PlayerLoader> pushSequence = this.Delay(250); // only show if the warning was created (i.e. the beatmap needs it) // and this is not a restart of the map (the warning expires after first load). if (epilepsyWarning?.IsAlive == true) { const double epilepsy_display_length = 3000; pushSequence.Schedule(() => { epilepsyWarning.State.Value = Visibility.Visible; this.Delay(epilepsy_display_length).Schedule(() => { epilepsyWarning.Hide(); epilepsyWarning.Expire(); }); }); pushSequence.Delay(epilepsy_display_length); } pushSequence.Schedule(() => { if (!this.IsCurrentScreen()) { return; } LoadTask = null; // By default, we want to load the player and never be returned to. // Note that this may change if the player we load requested a re-run. ValidForResume = false; if (player.LoadedBeatmapSuccessfully) { this.Push(player); } else { this.Exit(); } }); }, 500); } finally { Schedule(pushWhenLoaded); } }
public override void OnEntering(IScreen last) { romListUpdateDelegate = Scheduler.AddDelayed(fetchRomList, 5000, true); base.OnEntering(last); }
public override void OnEntering(IScreen last) { base.OnEntering(last); Scheduler.AddDelayed(schedulePush, 5000); }
private void buildTest() { Add(new Container { Padding = new MarginPadding(25f), RelativeSizeAxes = Axes.Both, Children = new Drawable[] { fillContainer = new FillFlowContainer { RelativeSizeAxes = Axes.Both, AutoSizeAxes = Axes.None, }, new Box { Anchor = Anchor.CentreLeft, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, Size = new Vector2(3, 1), Colour = Color4.HotPink, }, new Box { Anchor = Anchor.CentreRight, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Y, Size = new Vector2(3, 1), Colour = Color4.HotPink, }, new Box { Anchor = Anchor.TopCentre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.X, Size = new Vector2(1, 3), Colour = Color4.HotPink, }, new Box { Anchor = Anchor.BottomCentre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.X, Size = new Vector2(1, 3), Colour = Color4.HotPink, } } }); AddToggleStep("Rotate Container", state => { fillContainer.RotateTo(state ? 45f : 0, 1000); }); AddToggleStep("Scale Container", state => { fillContainer.ScaleTo(state ? 1.2f : 1f, 1000); }); AddToggleStep("Shear Container", state => { fillContainer.Shear = state ? new Vector2(0.5f, 0f) : new Vector2(0f, 0f); }); AddToggleStep("Center Container Anchor", state => { fillContainer.Anchor = state ? Anchor.Centre : Anchor.TopLeft; }); AddToggleStep("Center Container Origin", state => { fillContainer.Origin = state ? Anchor.Centre : Anchor.TopLeft; }); AddToggleStep("Autosize Container", state => { if (state) { fillContainer.RelativeSizeAxes = Axes.None; fillContainer.AutoSizeAxes = Axes.Both; } else { fillContainer.AutoSizeAxes = Axes.None; fillContainer.RelativeSizeAxes = Axes.Both; fillContainer.Width = 1; fillContainer.Height = 1; } }); AddToggleStep("Rotate children", state => { if (state) { foreach (var child in fillContainer.Children) { child.RotateTo(45f, 1000); } } else { foreach (var child in fillContainer.Children) { child.RotateTo(0f, 1000); } } }); AddToggleStep("Shear children", state => { if (state) { foreach (var child in fillContainer.Children) { child.Shear = new Vector2(0.2f, 0.2f); } } else { foreach (var child in fillContainer.Children) { child.Shear = Vector2.Zero; } } }); AddToggleStep("Scale children", state => { if (state) { foreach (var child in fillContainer.Children) { child.ScaleTo(1.25f, 1000); } } else { foreach (var child in fillContainer.Children) { child.ScaleTo(1f, 1000); } } }); AddToggleStep("Randomly scale children", state => { if (state) { foreach (var child in fillContainer.Children) { child.ScaleTo(RNG.NextSingle(1, 2), 1000); } } else { foreach (var child in fillContainer.Children) { child.ScaleTo(1f, 1000); } } }); AddToggleStep("Randomly set child origins", state => { if (state) { foreach (var child in fillContainer.Children) { switch (RNG.Next(9)) { case 0: child.Origin = Anchor.TopLeft; break; case 1: child.Origin = Anchor.TopCentre; break; case 2: child.Origin = Anchor.TopRight; break; case 3: child.Origin = Anchor.CentreLeft; break; case 4: child.Origin = Anchor.Centre; break; case 5: child.Origin = Anchor.CentreRight; break; case 6: child.Origin = Anchor.BottomLeft; break; case 7: child.Origin = Anchor.BottomCentre; break; case 8: child.Origin = Anchor.BottomRight; break; } } } else { foreach (var child in fillContainer.Children) { child.Origin = originDropdown.Current.Value; } } }); AddToggleStep("Stop adding children", state => { doNotAddChildren = state; }); scheduledAdder?.Cancel(); scheduledAdder = Scheduler.AddDelayed( () => { if (fillContainer.Parent == null) { scheduledAdder.Cancel(); } if (doNotAddChildren) { fillContainer.Invalidate(); } if (fillContainer.Children.Count < 1000 && !doNotAddChildren) { fillContainer.Add(new Container { Anchor = childAnchor, Origin = childOrigin, AutoSizeAxes = Axes.Both, Children = new Drawable[] { new Box { Width = 50, Height = 50, Colour = Color4.White }, new SpriteText { Colour = Color4.Black, RelativePositionAxes = Axes.Both, Position = new Vector2(0.5f, 0.5f), Origin = Anchor.Centre, Text = fillContainer.Children.Count.ToString() } } }); } }, 100, true ); }
public Storage LocateStableStorage() { scheduled?.Cancel(); Storage = null; try { var path = findStablePath(); if (string.IsNullOrEmpty(path)) { return(null); } Storage = new DesktopStorage(path, host as DesktopGameHost); const string file_ipc_filename = "ipc.txt"; const string file_ipc_state_filename = "ipc-state.txt"; const string file_ipc_scores_filename = "ipc-scores.txt"; const string file_ipc_channel_filename = "ipc-channel.txt"; if (Storage.Exists(file_ipc_filename)) { scheduled = Scheduler.AddDelayed(delegate { try { using (var stream = Storage.GetStream(file_ipc_filename)) using (var sr = new StreamReader(stream)) { var beatmapId = int.Parse(sr.ReadLine()); var mods = int.Parse(sr.ReadLine()); if (lastBeatmapId != beatmapId) { beatmapLookupRequest?.Cancel(); lastBeatmapId = beatmapId; var existing = ladder.CurrentMatch.Value?.Round.Value?.Beatmaps.FirstOrDefault(b => b.ID == beatmapId && b.BeatmapInfo != null); if (existing != null) { Beatmap.Value = existing.BeatmapInfo; } else { beatmapLookupRequest = new GetBeatmapRequest(new BeatmapInfo { OnlineBeatmapID = beatmapId }); beatmapLookupRequest.Success += b => Beatmap.Value = b.ToBeatmap(Rulesets); API.Queue(beatmapLookupRequest); } } Mods.Value = (LegacyMods)mods; } } catch { // file might be in use. } try { using (var stream = Storage.GetStream(file_ipc_channel_filename)) using (var sr = new StreamReader(stream)) { ChatChannel.Value = sr.ReadLine(); } } catch (Exception) { // file might be in use. } try { using (var stream = Storage.GetStream(file_ipc_state_filename)) using (var sr = new StreamReader(stream)) { State.Value = (TourneyState)Enum.Parse(typeof(TourneyState), sr.ReadLine()); } } catch (Exception) { // file might be in use. } try { using (var stream = Storage.GetStream(file_ipc_scores_filename)) using (var sr = new StreamReader(stream)) { Score1.Value = int.Parse(sr.ReadLine()); Score2.Value = int.Parse(sr.ReadLine()); } } catch (Exception) { // file might be in use. } }, 250, true); } } catch (Exception e) { Logger.Error(e, "Stable installation could not be found; disabling file based IPC"); } return(Storage); }
/// <summary> /// Selection has been changed as the result of a user interaction. /// </summary> private void performUpdateSelected() { var beatmap = beatmapNoDebounce; var ruleset = rulesetNoDebounce; selectionChangedDebounce?.Cancel(); if (beatmapNoDebounce == null) { run(); } else { selectionChangedDebounce = Scheduler.AddDelayed(run, 200); } void run() { // clear pending task immediately to track any potential nested debounce operation. selectionChangedDebounce = null; Logger.Log($"updating selection with beatmap:{beatmap?.ID.ToString() ?? "null"} ruleset:{ruleset?.ID.ToString() ?? "null"}"); if (transferRulesetValue()) { Mods.Value = Array.Empty <Mod>(); // transferRulesetValue() may trigger a re-filter. If the current selection does not match the new ruleset, we want to switch away from it. // The default logic on WorkingBeatmap change is to switch to a matching ruleset (see workingBeatmapChanged()), but we don't want that here. // We perform an early selection attempt and clear out the beatmap selection to avoid a second ruleset change (revert). if (beatmap != null && !Carousel.SelectBeatmap(beatmap, false)) { beatmap = null; } } if (selectionChangedDebounce != null) { // a new nested operation was started; switch to it for further selection. // this avoids having two separate debounces trigger from the same source. selectionChangedDebounce.RunTask(); return; } // We may be arriving here due to another component changing the bindable Beatmap. // In these cases, the other component has already loaded the beatmap, so we don't need to do so again. if (!EqualityComparer <BeatmapInfo> .Default.Equals(beatmap, Beatmap.Value.BeatmapInfo)) { Logger.Log($"beatmap changed from \"{Beatmap.Value.BeatmapInfo}\" to \"{beatmap}\""); WorkingBeatmap previous = Beatmap.Value; Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap, previous); if (beatmap != null) { if (beatmap.BeatmapSetInfoID == beatmapNoDebounce?.BeatmapSetInfoID) { sampleChangeDifficulty.Play(); } else { sampleChangeBeatmap.Play(); } } } if (this.IsCurrentScreen()) { ensurePlayingSelected(); } updateComponentFromBeatmap(Beatmap.Value); } }
protected override void LoadComplete() { base.LoadComplete(); Scheduler.AddDelayed(() => comboIndex.Value++, 250, true); }
public TestSceneSpriteTextScenarios() : base(4, 5) { Cell(0, 0).Child = new SpriteText { Text = "Basic: Hello world!" }; Cell(1, 0).Child = new SpriteText { Text = "Font size = 15", Font = new FontUsage(size: 15), }; Cell(2, 0).Child = new SpriteText { Text = "Colour = green", Colour = Color4.Green }; Cell(3, 0).Child = new SpriteText { Anchor = Anchor.Centre, Origin = Anchor.Centre, Text = "Rotation = 45", Rotation = 45 }; Cell(0, 1).Child = new SpriteText { Text = "Scale = 2", Scale = new Vector2(2) }; Cell(1, 1).Child = new CircularContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, Masking = true, AutoSizeAxes = Axes.Both, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both }, new SpriteText { Colour = Color4.Red, Text = "||MASKED||" } } }; Cell(2, 1).Child = new SpriteText { Text = "Explicit width", Width = 50 }; Cell(3, 1).Child = new SpriteText { Text = "AllowMultiline = false", Width = 50, AllowMultiline = false }; Cell(0, 2).Child = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, Width = 50, AutoSizeAxes = Axes.Y, Child = new SpriteText { Text = "Relative size", RelativeSizeAxes = Axes.X } }; Cell(1, 2).Child = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, Width = 50, AutoSizeAxes = Axes.Y, Child = new SpriteText { Text = "GlyphHeight = false", RelativeSizeAxes = Axes.X, UseFullGlyphHeight = false } }; Cell(2, 2).Child = new SpriteText { Text = "Fixed width", Font = new FontUsage(fixedWidth: true), }; Cell(3, 2).Child = new SpriteText { Text = "Scale = -1", Y = 20, Scale = new Vector2(-1) }; Cell(0, 3).Child = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, AutoSizeAxes = Axes.Both, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both }, new SpriteText { Text = "Shadow = true", Shadow = true } } }; Cell(1, 3).Child = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, AutoSizeAxes = Axes.Both, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = Color4.SlateGray }, new SpriteText { Text = "Padded (autosize)", Padding = new MarginPadding(10) }, } }; Cell(2, 3).Child = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, AutoSizeAxes = Axes.Both, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both, Colour = Color4.SlateGray }, new SpriteText { Text = "Padded (fixed size)", Width = 50, Padding = new MarginPadding(10) }, } }; Cell(3, 3).Child = new Container { Anchor = Anchor.Centre, Origin = Anchor.Centre, AutoSizeAxes = Axes.Both, Children = new Drawable[] { new Box { RelativeSizeAxes = Axes.Both }, new SpriteText { Text = "Red text + pink shadow", Shadow = true, Colour = Color4.Red, ShadowColour = Color4.Pink.Opacity(0.5f) } } }; Cell(0, 4).Child = new NoFixedWidthSpaceText { Text = "No fixed width spaces" }; Cell(1, 4).Child = new LocalisableTestContainer { RelativeSizeAxes = Axes.Both, Child = new FillFlowContainer { RelativeSizeAxes = Axes.Both, Direction = FillDirection.Vertical, Spacing = new Vector2(0, 10), Children = new[] { new SpriteText { Text = FakeStorage.LOCALISABLE_STRING_EN }, new SpriteText { Text = new LocalisedString(FakeStorage.LOCALISABLE_STRING_EN) }, } } }; Bindable <string> boundString = new Bindable <string>("bindable: 0"); int boundStringValue = 0; Cell(2, 4).Child = new LocalisableTestContainer { RelativeSizeAxes = Axes.Both, Child = new SpriteText { Current = boundString }, }; Scheduler.AddDelayed(() => boundString.Value = $"bindable: {++boundStringValue}", 200, true); }
private void updateFilterDebounced() { scheduledFilterUpdate?.Cancel(); scheduledFilterUpdate = Scheduler.AddDelayed(UpdateFilter, 200); }
private void updateLogoState(MenuState lastState = MenuState.Initial) { if (logo == null) { return; } logoDelayedAction?.Cancel(); switch (state) { case MenuState.Exit: case MenuState.Initial: logoTracking = false; logoDelayedAction = Scheduler.AddDelayed(() => { showOverlays.Value = false; logo.ClearTransforms(targetMember: nameof(Position)); logo.RelativePositionAxes = Axes.Both; logo.MoveTo(new Vector2(0.5f), 800, Easing.OutExpo); logo.ScaleTo(1, 800, Easing.OutExpo); }, 150); break; case MenuState.TopLevel: case MenuState.Play: logo.ClearTransforms(targetMember: nameof(Position)); logo.RelativePositionAxes = Axes.None; switch (lastState) { case MenuState.TopLevel: // coming from toplevel to play case MenuState.Initial: logoTracking = false; logo.ScaleTo(0.5f, 200, Easing.In); logo.MoveTo(logoTrackingPosition, lastState == MenuState.EnteringMode ? 0 : 200, Easing.In); logoDelayedAction = Scheduler.AddDelayed(() => { logoTracking = true; logo.Impact(); showOverlays.Value = true; }, 200); break; default: logoTracking = true; logo.ScaleTo(0.5f, 200, Easing.OutQuint); break; } break; case MenuState.EnteringMode: logoTracking = true; break; } }
private async void checkForUpdateAsync(bool useDeltaPatching = true, UpdateProgressNotification notification = null) { //should we schedule a retry on completion of this check? bool scheduleRetry = true; try { if (updateManager == null) { updateManager = await UpdateManager.GitHubUpdateManager(@"https://github.com/ppy/osu", @"osulazer", null, null, true); } var info = await updateManager.CheckForUpdate(!useDeltaPatching); if (info.ReleasesToApply.Count == 0) { //no updates available. bail and retry later. return; } if (notification == null) { notification = new UpdateProgressNotification { State = ProgressNotificationState.Active }; Schedule(() => notificationOverlay.Post(notification)); } Schedule(() => { notification.Progress = 0; notification.Text = @"Downloading update..."; }); try { await updateManager.DownloadReleases(info.ReleasesToApply, p => Schedule(() => notification.Progress = p / 100f)); Schedule(() => { notification.Progress = 0; notification.Text = @"Installing update..."; }); await updateManager.ApplyReleases(info, p => Schedule(() => notification.Progress = p / 100f)); Schedule(() => notification.State = ProgressNotificationState.Completed); } catch (Exception e) { if (useDeltaPatching) { Logger.Error(e, @"delta patching failed!"); //could fail if deltas are unavailable for full update path (https://github.com/Squirrel/Squirrel.Windows/issues/959) //try again without deltas. checkForUpdateAsync(false, notification); scheduleRetry = false; } else { Logger.Error(e, @"update failed!"); } } } catch (Exception) { // we'll ignore this and retry later. can be triggered by no internet connection or thread abortion. } finally { if (scheduleRetry) { //check again in 30 minutes. Scheduler.AddDelayed(() => checkForUpdateAsync(), 60000 * 30); if (notification != null) { notification.State = ProgressNotificationState.Cancelled; } } } }
private void Load(GameHost gameHost, CachedMap cachedMap) { IResourceStore <byte[]> store = new StorageBackedResourceStore(gameHost.Storage); ITrackStore trackStore = audio.GetTrackStore(store); var audioFile = $"{Path.GetDirectoryName(_map.Path)}{Path.DirectorySeparatorChar}{_map.AFileName}"; track = trackStore.Get(audioFile); if (track != null) { track.Volume.Value = Gameini.Get <double>(SettingsConfig.Volume); } InternalChildren = new Drawable[] { GameplayScreenLoader = new GameplayScreenLoader { RelativeSizeAxes = Axes.Both, Size = new Vector2(1f), Anchor = Anchor.Centre, Origin = Anchor.Centre, }, rhythmBoxClockContainer = new RhythmBoxClockContainer(0) { RelativeSizeAxes = Axes.Both, Size = new Vector2(1f) }, BreakOverlay = new BreakOverlay(new Action[] { () => BreakOverlay.State.Value = Visibility.Hidden, () => ReturntoSongSelectionAfterFail.Value = true }) { RelativePositionAxes = Axes.Both, Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, Size = new Vector2(1f), Alpha = 0f, }, KeyPress[0] = GetSprite("Skin/K1", 0.3f), KeyPress[1] = GetSprite("Skin/K2", 0.4f), KeyPress[2] = GetSprite("Skin/K3", 0.5f), KeyPress[3] = GetSprite("Skin/K4", 0.6f), volume = new Volume(new Bindable <Track>(track)) { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, RelativePositionAxes = Axes.Both, Size = new Vector2(1f, 0.3f), X = 0.4f, Y = 0.2f, Alpha = 0f, }, }; BreakOverlay.State.Value = Visibility.Hidden; BreakOverlay.State.ValueChanged += async(e) => { if (e.NewValue == Visibility.Hidden) { BreakOverlay.AnimationOut(); await Task.Delay(1500); Resuming.Value = true; rhythmBoxClockContainer.Start(); track.Start(); _RbPlayfield.Clock = rhythmBoxClockContainer.RhythmBoxClock; } }; rhythmBoxClockContainer.Children = new Drawable[] { _RbPlayfield = new Playfield.Playfield(ToApplyMods) { Anchor = Anchor.Centre, Origin = Anchor.Centre, RelativeSizeAxes = Axes.Both, RelativePositionAxes = Axes.Both, Size = new Vector2(0.6f, 0.9f), Map = _map, Y = 0.02f }, hpbar = new HPBar(ToApplyMods) { Anchor = Anchor.TopLeft, Origin = Anchor.TopLeft, RelativeSizeAxes = Axes.Both, Size = new Vector2(0.8f, 1f), Colour = Color4.AliceBlue }, DispayCombo = new TextFlowContainer { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, RelativeSizeAxes = Axes.Both, RelativePositionAxes = Axes.Both, Size = new Vector2(0.1f), TextAnchor = Anchor.BottomLeft, }, DispayScore = new TextFlowContainer { Anchor = Anchor.TopRight, Origin = Anchor.TopRight, RelativeSizeAxes = Axes.Both, RelativePositionAxes = Axes.Both, Size = new Vector2(0.1f), TextAnchor = Anchor.TopRight, X = -0.01f }, }; rhythmBoxClockContainer.IsPaused.BindTo(IsPaused); rhythmBoxClockContainer.UserPlaybackRate.BindTo(UserPlaybackRate); _RbPlayfield.Clock = rhythmBoxClockContainer.RhythmBoxClock; DispayScore.Clock = rhythmBoxClockContainer.RhythmBoxClock; DispayCombo.Clock = rhythmBoxClockContainer.RhythmBoxClock; hpbar.Clock = rhythmBoxClockContainer.RhythmBoxClock; _RbPlayfield.Resuming.BindTo(Resuming); DispayCombo.AddText("0x", x => x.Font = new FontUsage("Roboto", 40)); DispayScore.AddText("000000", x => x.Font = new FontUsage("Roboto", 40)); Score.Combo.PrivateComboBindable.ValueChanged += (e) => hpbar.CurrentValue.Value += hpbar.CalcValue(Score.Combo.currentHit); _RbPlayfield.HasFinished.ValueChanged += (e) => { if (!e.NewValue) { return; } rhythmBoxClockContainer.Stop(); var currentTime = track?.CurrentTime; track?.Stop(); _RbPlayfield.HasFinished.UnbindEvents(); cachedMap.Map = _map; cachedMap.LoadTrackFile(); cachedMap.Seek(currentTime.GetValueOrDefault()); Scheduler.AddDelayed(() => this.Expire(), 1000); LoadComponentAsync(new ResultScreen(), this.Push); }; ReturntoSongSelectionAfterFail.ValueChanged += (e) => { cachedMap.Map = _map; cachedMap.LoadTrackFile(); cachedMap.Seek(track.CurrentTime); Selection songSelction; LoadComponent(songSelction = new Selection()); Schedule(() => this.Push(songSelction)); }; _RbPlayfield.CanStart.ValueChanged += (e) => { if (e.NewValue) { Load(1000); } }; }
public DirectOverlay() { RelativeSizeAxes = Axes.Both; // osu!direct colours are not part of the standard palette Waves.FirstWaveColour = OsuColour.FromHex(@"19b0e2"); Waves.SecondWaveColour = OsuColour.FromHex(@"2280a2"); Waves.ThirdWaveColour = OsuColour.FromHex(@"005774"); Waves.FourthWaveColour = OsuColour.FromHex(@"003a4e"); ScrollFlow.Children = new Drawable[] { resultCountsContainer = new FillFlowContainer { AutoSizeAxes = Axes.Both, Direction = FillDirection.Horizontal, Margin = new MarginPadding { Top = 5 }, Children = new Drawable[] { new OsuSpriteText { Text = "Found ", TextSize = 15, }, resultCountsText = new OsuSpriteText { TextSize = 15, Font = @"Exo2.0-Bold", }, } }, }; Filter.Search.Current.ValueChanged += text => { if (text != string.Empty) { Header.Tabs.Current.Value = DirectTab.Search; if (Filter.Tabs.Current.Value == DirectSortCriteria.Ranked) { Filter.Tabs.Current.Value = DirectSortCriteria.Relevance; } } else { Header.Tabs.Current.Value = DirectTab.NewestMaps; if (Filter.Tabs.Current.Value == DirectSortCriteria.Relevance) { Filter.Tabs.Current.Value = DirectSortCriteria.Ranked; } } }; ((FilterControl)Filter).Ruleset.ValueChanged += ruleset => Scheduler.AddOnce(updateSearch); Filter.DisplayStyleControl.DisplayStyle.ValueChanged += recreatePanels; Filter.DisplayStyleControl.Dropdown.Current.ValueChanged += rankStatus => Scheduler.AddOnce(updateSearch); Header.Tabs.Current.ValueChanged += tab => { if (tab != DirectTab.Search) { currentQuery.Value = string.Empty; Filter.Tabs.Current.Value = (DirectSortCriteria)Header.Tabs.Current.Value; Scheduler.AddOnce(updateSearch); } }; currentQuery.ValueChanged += v => { queryChangedDebounce?.Cancel(); if (string.IsNullOrEmpty(v)) { Scheduler.AddOnce(updateSearch); } else { BeatmapSets = null; ResultAmounts = null; queryChangedDebounce = Scheduler.AddDelayed(updateSearch, 500); } }; currentQuery.BindTo(Filter.Search.Current); Filter.Tabs.Current.ValueChanged += sortCriteria => { if (Header.Tabs.Current.Value != DirectTab.Search && sortCriteria != (DirectSortCriteria)Header.Tabs.Current.Value) { Header.Tabs.Current.Value = DirectTab.Search; } Scheduler.AddOnce(updateSearch); }; updateResultCounts(); }
private void setScrollState(ScrollState newState) { if (scrollState == newState) { return; } delayedStateChangeDelegate?.Cancel(); switch (scrollState = newState) { case ScrollState.Scrolling: resetSelected(); OnScrollStarted?.Invoke(); speedTo(1000f, 200); tracker.FadeOut(100); break; case ScrollState.Stopping: speedTo(0f, 2000); tracker.FadeIn(200); delayedStateChangeDelegate = Scheduler.AddDelayed(() => setScrollState(ScrollState.Stopped), 2300); break; case ScrollState.Stopped: // Find closest to center if (!Children.Any()) { break; } ScrollingTeam closest = null; foreach (var c in Children) { if (!(c is ScrollingTeam stc)) { continue; } if (closest == null) { closest = stc; continue; } float o = Math.Abs(c.Position.X + c.DrawWidth / 2f - DrawWidth / 2f); float lastOffset = Math.Abs(closest.Position.X + closest.DrawWidth / 2f - DrawWidth / 2f); if (o < lastOffset) { closest = stc; } } Trace.Assert(closest != null, "closest != null"); // ReSharper disable once PossibleNullReferenceException offset += DrawWidth / 2f - (closest.Position.X + closest.DrawWidth / 2f); ScrollingTeam st = closest; availableTeams.RemoveAll(at => at == st.Team); st.Selected = true; OnSelected?.Invoke(st.Team); delayedStateChangeDelegate = Scheduler.AddDelayed(() => setScrollState(ScrollState.Idle), 10000); break; case ScrollState.Idle: resetSelected(); OnScrollStarted?.Invoke(); speedTo(40f, 200); tracker.FadeOut(100); break; } }