private async Task <bool> IsServerPrompt()
        {
            Promise <DialogOption> dialogPromise = null;

            await QueueAction(() =>
            {
                dialogPromise = Dialog.ShowMessage(new DialogButtonOptions()
                {
                    Message             = "Choose your adventure".ToConsoleString(),
                    AllowEscapeToCancel = false,
                    MaxHeight           = 8,
                    Options             = new List <DialogOption>()
                    {
                        new DialogOption()
                        {
                            DisplayText = "Start a server".ToConsoleString()
                        },
                        new DialogOption()
                        {
                            DisplayText = "Connect to server".ToConsoleString()
                        },
                    }
                });
            }).AsAwaitable();

            return((await dialogPromise.AsAwaitable()).DisplayText.ToString() == "Start a server");
        }
        private async Task <int> PromptForNumberOfPlayers()
        {
            Promise <ConsoleString> p = null;

            await QueueAction(() =>
            {
                p = Dialog.ShowRichTextInput(new RichTextDialogOptions()
                {
                    Message   = "How many players?".ToConsoleString(),
                    MaxHeight = 8,
                    TextBox   = new TextBox()
                    {
                        Value = "2".ToConsoleString()
                    },
                });
            }).AsAwaitable();

            var ret = (await p.AsAwaitable()).ToString();

            if (int.TryParse(ret, out int numPlayers) == false)
            {
                numPlayers = await PromptForNumberOfPlayers();
            }

            return(numPlayers);
        }
        private async Task ShowLogo()
        {
            Promise introPromise = null;

            await QueueAction(() =>
            {
                var logo     = LayoutRoot.Add(new PowerArgsGamesIntro()).CenterBoth();
                introPromise = logo.Play();
                introPromise.Then(() =>
                {
                    QueueAction(() => LayoutRoot.Controls.Remove(logo));
                });
            }).AsAwaitable();

            await introPromise.AsAwaitable();
        }
Exemple #4
0
        private async Task <int> PromptForNumberOfPlayers()
        {
            Promise <ConsoleString> p = null;

            await QueueAction(() =>
            {
                p = Dialog.ShowRichTextInput("How many players?".ToConsoleString(), false, 8, "2".ToConsoleString());
            }).AsAwaitable();

            var ret = (await p.AsAwaitable()).ToString();

            if (int.TryParse(ret, out int numPlayers) == false)
            {
                numPlayers = await PromptForNumberOfPlayers();
            }

            return(numPlayers);
        }