Beispiel #1
0
        private static async Task CloseApp()
        {
            var userConfirmed = await ConfirmCancelDialog.Show("Quit", "Do you want to exit the application?");

            if (userConfirmed)
            {
                ApplicationV2.Quit();
            }
        }
Beispiel #2
0
        private async Task ShowCancelConfirmDialog()
        {
            var showDialogTask = ConfirmCancelDialog.Show("I am a dialog", "Please click the confirm button to continue");

            await SimulateConfirmButtonClick();

            bool dialogWasConfirmed = await showDialogTask;                     // Wait until the dialog is closed

            AssertV2.IsTrue(dialogWasConfirmed, "User did not confirm dialog"); // Check if user clicked confirm
        }
Beispiel #3
0
        /// <summary> This example shows how to use the DialogLoader manually to have full control over the UI presenter </summary>
        private async Task UseDialogLoaderManually()
        {
            var loader = new DialogLoader <ConfirmCancelDialog>(new ConfirmCancelDialog(caption: "I am a dialog",
                                                                                        message: "I can be awaited in the code, the async or coroutine can wait for the user " +
                                                                                        "to make a decision (select cancel or confirm) before the code continues!"));
            GameObject dialogUi = loader.LoadDialogPrefab(new ConfirmCancelDialog.DefaultPresenter(),
                                                          dialogPrefabName: "Dialogs/DefaultDialog1");

            RootCanvas.GetOrAddRootCanvas().gameObject.AddChild(dialogUi); // Add dialog UI in a canvas
            var waitForUserInputInDialogTask = loader.ShowDialogAsync();

            AssertV2.IsFalse(loader.data.dialogWasConfirmed, "Dialog was already confirmed!");
            await SimulateConfirmButtonClick();

            ConfirmCancelDialog dialog = await waitForUserInputInDialogTask; // Wait until user clicks cancel or confirm

            AssertV2.IsTrue(dialog.dialogWasConfirmed, "Dialog was not confirmed!");
        }
Beispiel #4
0
            public Task OnLoad(IDataStore <MyDataModel> store)
            {
                var map = targetView.GetLinkMap();

                var string1 = map.Get <InputField>("string1");

                string1.SubscribeToStateChanges(store, state => state.subSection1.string1, newVal => string1.text = newVal);
                string1.SetOnValueChangedActionThrottled((newVal) => {
                    store.Dispatch(new ActionSetString1()
                    {
                        newS = newVal
                    });
                });

                var bool1 = map.Get <Toggle>("bool1");

                bool1.SubscribeToStateChanges(store, state => state.subSection1.bool1, newVal => bool1.isOn = newVal);
                bool1.SetOnValueChangedAction((newVal) => {
                    store.Dispatch(new ActionSetBool1()
                    {
                        newB = newVal
                    });
                    return(true);
                });

                map.Get <Button>("ToggleBool1").SetOnClickAction(delegate {
                    store.Dispatch(new ActionSetBool1()
                    {
                        newB = !store.GetState().subSection1.bool1
                    });
                });
                map.Get <Button>("SetString1").SetOnClickAction(delegate {
                    store.Dispatch(new ActionSetString1()
                    {
                        newS = "abc"
                    });
                });
                map.Get <Button>("ShowDialog").SetOnClickAction(async(b) => {
                    bool dialogWasConfirmed = await ConfirmCancelDialog.Show("I am a dialog",
                                                                             "Current model.string1=" + store.GetState().subSection1.string1);
                    Log.d("Dialog was confirmed: " + dialogWasConfirmed);
                });
                return(Task.CompletedTask);
            }
Beispiel #5
0
        /// <summary>
        ///     Starts the deleting process.
        /// </summary>
        public void DeleteSelected()
        {
            // Externally loaded map check.
            if (MapManager.Selected.Value.Game != MapGame.Quaver)
            {
                // Display error message.
                NotificationManager.Show(NotificationLevel.Error, "This map was loaded from another game, and it cannot be deleted.");
                return;
            }

            var view = View as SelectScreenView;
            var type = view.ActiveContainer;

            var selectedMapsetIndex     = view.MapsetScrollContainer.SelectedMapsetIndex;
            var selectedDifficultyIndex = view.DifficultyScrollContainer.SelectedMapIndex;
            var selectedMapset          = AvailableMapsets[selectedMapsetIndex];
            var selectedDifficulty      = selectedMapset.Maps[selectedDifficultyIndex];

            var mapsetPath     = Path.Combine(ConfigManager.SongDirectory.Value, selectedMapset.Directory);
            var difficultyPath = Path.Combine(mapsetPath, selectedDifficulty.Path);

            // Commence deleting and reloading.
            var confirmDelete = new ConfirmCancelDialog($"Are you sure you want to delete this {( type == SelectContainerStatus.Mapsets ? "mapset" : "difficulty" )}?", (sender, confirm) =>
            {
                var mapTitle     = selectedMapset.Maps.First().Title;
                var deleteMapset = type == SelectContainerStatus.Mapsets || type == SelectContainerStatus.Difficulty && selectedMapset.Maps.Count == 1;

                // Dispose of the background for the currently selected map.
                BackgroundHelper.Background?.Dispose();

                // Dispose of the currently playing track.
                AudioEngine.Track?.Dispose();

                // Run path deletion in the background.
                ThreadScheduler.Run(() => DeletePath(deleteMapset ? mapsetPath : difficultyPath));

                // Remove mapset/difficulty from cache and AvailableMapsets list.
                if (deleteMapset)
                {
                    selectedMapset.Maps.ForEach(MapDatabaseCache.RemoveMap);
                    AvailableMapsets.RemoveAt(selectedMapsetIndex);
                    MapManager.Mapsets.RemoveAll(x => x.Directory == selectedMapset.Directory);
                    view.MapsetScrollContainer.InitializeWithNewSets();
                    view.MapsetScrollContainer.SelectMapset(Math.Min(selectedMapsetIndex, AvailableMapsets.Count - 1));
                }
                else
                {
                    MapDatabaseCache.RemoveMap(selectedDifficulty);
                    selectedMapset.Maps.RemoveAt(selectedDifficultyIndex);
                    MapManager.Mapsets.Find(x => x.Directory == selectedMapset.Directory).Maps.RemoveAll(x => x.Md5Checksum == selectedDifficulty.Md5Checksum);
                    view.DifficultyScrollContainer.ReInitializeDifficulties();
                    view.MapsetScrollContainer.SelectMap(selectedMapsetIndex, selectedMapset.Maps[Math.Min(selectedDifficultyIndex, selectedMapset.Maps.Count - 1)], true);
                }

                // Finally show confirmation notification.
                NotificationManager.Show(NotificationLevel.Success, $"Successfully deleted {mapTitle} from Quaver!");

                // If the deleted mapset was the last one, then exit back to menu.
                if (MapManager.Mapsets.Count != 0)
                {
                    return;
                }

                view.Destroy();
                AudioEngine.Track         = null;
                MapManager.Selected.Value = null;
                ExitToMenu();
            });

            // Finally show the confirmation dialog that orchestrates the deleting process.
            DialogManager.Show(confirmDelete);
        }