示例#1
0
        public override IEnumerator RunOptions(Options optionsCollection, OptionChooser optionChooser)
        {
            dialogueText.gameObject.SetActive(false);
            dialogueEndStar.gameObject.SetActive(false);

            int options = optionsCollection.options.Count;

            for (int i = 0; i < options; i++)
            {
                optionsTexts[i].text = optionsCollection.options[i];
                optionsButtons[i].SetActive(true);
            }

            for (int k = options; k < optionsButtons.Length; k++)
            {
                optionsButtons[k].SetActive(false);
            }

            SetSelectedOption = optionChooser;

            while (SetSelectedOption != null)
            {
                yield return(null);
            }

            for (int j = 0; j < optionsButtons.Length; j++)
            {
                optionsButtons[j].SetActive(false);
            }
        }
示例#2
0
    public override IEnumerator RunOptions(Options optionsCollection, OptionChooser optionChooser)
    {
        // Do a little bit of safety checking
        if (optionsCollection.options.Count > optionButtons.Count)
        {
            Debug.LogWarning("There are more options to present than there are" +
                             "buttons to present them in. This will cause problems.");
        }

        // Display each option in a button, and make it visible
        int i = 0;

        foreach (var optionString in optionsCollection.options)
        {
            optionButtons[i].gameObject.SetActive(true);
            optionButtons[i].text = optionString;
            i++;
        }

        // Record that we're using it
        SetSelectedOption = optionChooser;

        // Wait until the chooser has been used and then removed (see SetOption below)
        while (SetSelectedOption != null)
        {
            yield return(null);
        }

        // Hide all the buttons
        foreach (var button in optionButtons)
        {
            button.gameObject.SetActive(false);
        }
    }
            public OptionSetResult(IList <string> optionStrings, OptionChooser setSelectedOption)
            {
                var options = new Options();

                options.options = optionStrings;
                this.options    = options;
                this.setSelectedOptionDelegate = setSelectedOption;
            }
示例#4
0
            public OptionSetResult(IList <Option> optionList, OptionChooser setSelectedOption)
            {
                var options = new Options();

                options.options = optionList;
                this.options    = options;
                this.setSelectedOptionDelegate = setSelectedOption;
            }
示例#5
0
    public override IEnumerator RunOptions(Options options, OptionChooser optionsChooser)
    {
        GameObject choiceContainer = m_lastTextBox.textBox.transform.Find("ChoiceContainer").gameObject;

        m_lastTextBox.textBox.gameObject.SetActive(true);
        choiceContainer.SetActive(true);

        bool optionSelected = false;
        int  optionindex    = -1;

        //destroy old choices.
        for (int i = 0; i < choiceContainer.transform.childCount; i++)
        {
            Destroy(choiceContainer.transform.GetChild(i).gameObject);
        }
        //create new choices.
        foreach (string option in options.options)
        {
            GameObject choiceObj = Instantiate(choicePrefab, choiceContainer.transform);
            choiceObj.GetComponentInChildren <TextMeshProUGUI>().text = option;

            // set what happens when we click a choice.
            choiceObj.GetComponent <Button>().onClick.AddListener(() =>
            {
                optionindex    = choiceObj.transform.GetSiblingIndex();
                optionSelected = true;
                choiceContainer.SetActive(false);
            });
        }

        //get the the first UI Element "choice" so we can focus on it.
        yield return(new WaitForEndOfFrame());

        GameObject lastSelected = choiceContainer.transform.GetChild(0).gameObject;

        //wait until the user has picked an option.
        yield return(new WaitWhile(() =>
        {
            // if we dont have focus while waiting for the user to pick an option, we need to reset the focus to the last selected option.
            if (EventSystem.current.currentSelectedGameObject == null)
            {
                EventSystem.current.SetSelectedGameObject(lastSelected);
            }

            lastSelected = EventSystem.current.currentSelectedGameObject;

            return optionSelected == false;
        }));

        //start closing tween
        m_lastTextBox.textBox.DisableTextbox(m_lastTextBox.textBoxSettings.useTween);

        // wait until the tween has finished and disabled the text box. then continue to the next node.
        yield return(new WaitWhile(() => { return m_lastTextBox.textBox.gameObject.activeSelf; }));

        optionsChooser(optionindex);
    }
示例#6
0
            public void RunOptions(Options optionsGroup, OptionChooser optionChooser)
            {
                // Check to see if the number of expected options
                // is what we're expecting to see
                if (numberOfExpectedOptions != -1 &&
                    optionsGroup.options.Count != numberOfExpectedOptions)
                {
                    // TODO: Output diagnostic info here
                    Console.WriteLine(string.Format("ERROR: Expected {0} options, but received {1}", numberOfExpectedOptions, optionsGroup.options.Count));
                    Console.WriteLine("Received options were:");
                    foreach (string option in optionsGroup.options)
                    {
                        Console.WriteLine(" - " + option);
                    }
                    Environment.Exit(1);
                }

                // If we were told to automatically select an option, do so
                if (autoSelectOptionNumber != -1)
                {
                    optionChooser(autoSelectOptionNumber);

                    autoSelectOptionNumber = -1;

                    return;
                }

                // Reset the expected options counter
                numberOfExpectedOptions = -1;


                Console.WriteLine("Options:");
                for (int i = 0; i < optionsGroup.options.Count; i++)
                {
                    var optionDisplay = string.Format("{0}. {1}", i + 1, optionsGroup.options [i]);
                    Console.WriteLine(optionDisplay);
                }
                do
                {
                    Console.Write("? ");
                    try {
                        var selectedKey = Console.ReadKey().KeyChar.ToString();
                        var selection   = int.Parse(selectedKey) - 1;
                        Console.WriteLine();

                        if (selection > optionsGroup.options.Count)
                        {
                            Console.WriteLine("Invalid option.");
                        }
                        else
                        {
                            optionChooser(selection);
                            break;
                        }
                    } catch (FormatException) {}
                } while (true);
            }
 public override IEnumerator RunOptions(Options optionsCollection, OptionChooser optionChooser)
 {
     for (int i = 0; i < optionsCollection.options.Count; i++)
     {
         optionButtons[i].Setup(i, optionsCollection.options[i], SelectOption);
     }
     selected = -1;
     while (selected == -1)
     {
         yield return(null);                   // wait for an option to be selected
     }
     optionChooser(selected);
     foreach (OptionButton b in optionButtons)
     {
         b.gameObject.SetActive(false);
     }
 }
示例#8
0
    public override IEnumerator RunOptions(Options optionsCollection, OptionChooser optionChooser)
    {
        ConversationBox.SetActive(true);
        int childCount = ConversationOptions.transform.childCount;

        for (int currentChild = childCount - 1; currentChild >= 0; currentChild--)
        {
            var childObject = ConversationOptions.transform.GetChild(currentChild).gameObject;
            if (childObject.name == "OptionPrefab")
            {
                continue;
            }
            Destroy(childObject);
        }

        for (int currentOption = 0; currentOption < optionsCollection.options.Count; currentOption++)
        {
            var option       = optionsCollection.options[currentOption];
            var optionButton = Instantiate(OptionPrefab);
            optionButton.gameObject.SetActive(true);
            optionButton.transform.SetParent(ConversationOptions.transform, false);
            optionButton.enabled = true;
            var optionText = optionButton.GetComponentInChildren <Text>();
            optionText.text    = option;
            optionText.enabled = true;
            var optionImage = optionButton.GetComponent <Image>();
            optionImage.enabled = true;
            SetSelectedOption   = optionChooser;

            int selectedOption = currentOption;
            optionButton.onClick.AddListener(() =>
            {
                ConversationBox.SetActive(false);
                optionChooser(selectedOption);
                SetSelectedOption = null;
            });
        }

        while (SetSelectedOption != null)
        {
            yield return(null);
        }
    }
    //Mostly stolen outright from the example
    public override IEnumerator RunOptions(Options optionsCollection, OptionChooser optionChooser)
    {
        if (optionsCollection.options.Count > optionButtons.Count)
        {
            Debug.LogWarning("There are more options to present than there are" +
                             "buttons to present them in. This will cause problems.");
        }

        if (choicePanel)
        {
            choicePanel.SetActive(true);
        }

        int i = 0;

        foreach (var optionString in optionsCollection.options)
        {
            optionButtons[i].gameObject.SetActive(true);
            optionButtons[i].GetComponentInChildren <Text>().text = optionString;
            i++;
        }

        // Set the delegate that this script uses to the one passed as an argument from Yarn
        optionChoiceDelegate = optionChooser;

        // Wait until the chooser has been used and then removed (see SetOption below)
        while (optionChoiceDelegate != null)
        {
            yield return(null);
        }

        // Hide all the buttons
        if (choicePanel)
        {
            choicePanel.SetActive(false);
        }
        foreach (var button in optionButtons)
        {
            button.gameObject.SetActive(false);
        }
    }
示例#10
0
 public override IEnumerator RunOptions(Options optionsCollection, OptionChooser optionChooser)
 {
     throw new System.NotImplementedException();
 }
示例#11
0
 public OptionSetResult(IList<string> optionStrings, OptionChooser setSelectedOption)
 {
     var options = new Options();
     options.options = optionStrings;
     this.options = options;
     this.setSelectedOptionDelegate = setSelectedOption;
 }
示例#12
0
            public void RunOptions(Options optionsGroup, OptionChooser optionChooser)
            {
                Console.WriteLine("Options:");
                for (int i = 0; i < optionsGroup.options.Count; i++) {
                    var optionDisplay = string.Format ("{0}. {1}", i + 1, optionsGroup.options [i]);
                    Console.WriteLine (optionDisplay);
                }

                // Check to see if the number of expected options
                // is what we're expecting to see
                if (numberOfExpectedOptions != -1 &&
                    optionsGroup.options.Count != numberOfExpectedOptions) {
                    // TODO: Output diagnostic info here
                    Console.WriteLine (string.Format("[ERROR: Expected {0} options, but received {1}]", numberOfExpectedOptions, optionsGroup.options.Count));
                    Environment.Exit (1);
                }

                // If we were told to automatically select an option, do so
                if (autoSelectOptionNumber != -1) {
                    Console.WriteLine ("[Received {0} options, choosing option {1}]", optionsGroup.options.Count, autoSelectOptionNumber);

                    optionChooser (autoSelectOptionNumber);

                    autoSelectOptionNumber = -1;

                    return;

                }

                // Reset the expected options counter
                numberOfExpectedOptions = -1;

                if (autoSelectFirstOption == true) {
                    Console.WriteLine ("[automatically choosing option 1]");
                    optionChooser (0);
                    return;
                }

                do {
                    Console.Write ("? ");
                    try {
                        var selectedKey = Console.ReadKey ().KeyChar.ToString();
                        var selection = int.Parse (selectedKey) - 1;
                        Console.WriteLine();

                        if (selection > optionsGroup.options.Count) {
                            Console.WriteLine ("Invalid option.");
                        } else {
                            optionChooser(selection);
                            break;
                        }
                    } catch (FormatException) {}

                } while (true);
            }
示例#13
0
 private void SetOption(int selectedOption, OptionChooser optionChooser)
 {
     Debug.Log(selectedOption);
     optionChooser(selectedOption);
     SetSelectedOption = null;
 }
示例#14
0
            public void RunOptions(Options optionsGroup, OptionChooser optionChooser)
            {
                Console.WriteLine("Options:");
                for (int i = 0; i < optionsGroup.options.Count; i++) {
                    var optionDisplay = string.Format ("{0}. {1}", i + 1, optionsGroup.options [i]);
                    Console.WriteLine (optionDisplay);
                }
                do {
                    Console.Write ("? ");
                    try {
                        var selectedKey = Console.ReadKey ().KeyChar.ToString();
                        var selection = int.Parse (selectedKey) - 1;
                        Console.WriteLine();

                        if (selection > optionsGroup.options.Count) {
                            Console.WriteLine ("Invalid option.");
                        } else {
                            optionChooser(selection);
                            break;
                        }
                    } catch (FormatException) {}

                } while (true);
            }
示例#15
0
 public override IEnumerator RunOptions(Options optionsCollection, OptionChooser optionChooser)
 {
     yield break;
 }
示例#16
0
        public void SetOption(int selectedOption)
        {
            SetSelectedOption(selectedOption);

            SetSelectedOption = null;
        }
示例#17
0
            public void RunOptions(Options optionsGroup, OptionChooser optionChooser)
            {
                Console.WriteLine("Options:");
                for (int i = 0; i < optionsGroup.options.Count; i++)
                {
                    var optionDisplay = string.Format(CultureInfo.CurrentCulture, "{0}. {1}", i + 1, optionsGroup.options[i]);
                    Console.WriteLine(optionDisplay);
                }


                // Check to see if the number of expected options
                // is what we're expecting to see
                if (numberOfExpectedOptions != -1 &&
                    optionsGroup.options.Count != numberOfExpectedOptions)
                {
                    // TODO: Output diagnostic info here
                    Error(string.Format(CultureInfo.CurrentCulture, "[ERROR: Expected {0} options, but received {1}]", numberOfExpectedOptions, optionsGroup.options.Count));
                }

                // If we were told to automatically select an option, do so
                if (autoSelectOptionNumber != -1)
                {
                    Note(string.Format(CultureInfo.CurrentCulture, "[Received {0} options, choosing option {1}]", optionsGroup.options.Count, autoSelectOptionNumber));

                    optionChooser(autoSelectOptionNumber);

                    autoSelectOptionNumber = -1;

                    return;
                }

                // Reset the expected options counter
                numberOfExpectedOptions = -1;



                if (autoSelectFirstOption == true)
                {
                    Note("[automatically choosing option 1]");
                    optionChooser(0);
                    return;
                }

                do
                {
                    Console.Write("? ");
                    try
                    {
                        var selectedKey = Console.ReadKey().KeyChar.ToString(CultureInfo.InvariantCulture);
                        int selection;

                        if (int.TryParse(selectedKey, out selection) == true)
                        {
                            Console.WriteLine();

                            // we present the list as 1,2,3, but the API expects
                            // answers as 0,1,2
                            selection -= 1;

                            if (selection > optionsGroup.options.Count)
                            {
                                Console.WriteLine("Invalid option.");
                            }
                            else
                            {
                                optionChooser(selection);
                                break;
                            }
                        }
                    }
                    catch (FormatException) { }
                } while (true);
            }
示例#18
0
        static void Main(string[] args)
        {
            var noLimitIncr = new Incrementer(INCREMENT_NO_LIMITS);
            var speedIncr   = new SpeedIncrementer();
            var hourIncr    = new Incrementer(INCREMENT_WRAP, new[] { 23, 59, 59 });
            var decIncr     = new RaDecIncrementer("DEC");
            var raIncr      = new RaDecIncrementer("RA");

            // Main top-level menu
            var menu = new MainMenu();

            //////  RA  ///////
            var raMenu = new MenuItem("RA");

            raMenu.addMenuItem(new NumberInput("TRA", 4, "^%02dh^%02dm^%02ds ^@", raConfirmed, raIncr));

            //////  DEC  ///////
            var decMenu = new MenuItem("DEC");

            decMenu.addMenuItem(new NumberInput("TDEC", 4, "^%02d*^%02d\"^%02d' ^@", decConfirmed, decIncr));

            //////  GO  ///////
            var goMenu = new MenuItem("GO");
            var goList = new ScrollList();

            goList.addMenuItem(new Button("Polaris", goPointChosen));
            goList.addMenuItem(new Button("Vega", goPointChosen));
            goList.addMenuItem(new Button("Orions Nebla", goPointChosen));
            goList.addMenuItem(new Button("M31 Andromeda", goPointChosen));
            goList.addMenuItem(new Button("Navi", goPointChosen));
            goList.addMenuItem(new Button("Antares", goPointChosen));
            goList.addMenuItem(new Button("Home", goPointChosen));
            goList.addMenuItem(new Button("Unpark", goPointChosen));
            goList.addMenuItem(new Button("Park", goPointChosen));
            goMenu.addMenuItem(goList);

            //////  HA  ///////
            var haMenu = new MenuItem("HA");

            haMenu.addMenuItem(new NumberInput("HA", new[] { 15, 32 }, "^%02dh^%02dm", haConfirmed, hourIncr));

            //////  CTRL  ///////
            var ctrlMenu = new MenuItem("CTRL");

            ctrlMenu.addMenuItem(new Button("Manual Control", startManualControl));
            var dlgManualControl = new ManualControlModal(manualControlEvent, "RADECControl");

            var dlgSetHome = new MenuItem("Set home pos?", "ConfirmHome");

            dlgSetHome.addMenuItem(new OptionChooser(new string[] { "Yes", "No" }, 0, setHomePosition));

            //////  CAL  ///////
            var calMenu = new MenuItem("CAL");
            var calList = new ScrollList();

            var dlgStoreSync = new MenuItem("Adjust mount ", "StoreAndSync");

            dlgStoreSync.addMenuItem(new Button("Centered", storeAndSync));

            var dlgSlewToPolaris = new MultiStepActionRunnerModal("Slewing....", "SlewToPolaris", polarAlignFunction, dlgStoreSync);
            var paBtn            = new Button("Polar Alignmnt", (eventArgs) => menu.activateDialog("SlewToPolaris"));

            calList.addMenuItem(paBtn);

            var driftLenOption = new OptionChooser(new string[] { "1m", "2m", "3m", "5m" }, 0, setDriftLength);
            var driftAlignBtn  = new Button("Drift Alignmnt", driftLenOption);

            var dlgDriftAlign = new MultiStepActionRunnerModal("Drift alignment", "DriftAlign", driftAlignPhaseFunction);

            calList.addMenuItem(driftAlignBtn);

            calList.addMenuItem(new Button("Speed Calibratn", new NumberInput("SPD", 1, "SpdFctr: @", null, speedIncr, NumberInput.BehaviorFlags.AcceleratingRepetition)));
            calList.addMenuItem(new Button("RA Step Adjust", new NumberInput("RA", 1, "RA Steps: @", null, speedIncr, NumberInput.BehaviorFlags.AcceleratingRepetition)));
            calList.addMenuItem(new Button("DEC Step Adjust", new NumberInput("DEC", 1, "DEC Steps: @", null, speedIncr, NumberInput.BehaviorFlags.AcceleratingRepetition)));
            calList.addMenuItem(new Button("Backlash Adjust", new NumberInput("DEC", 1, "DEC Steps: @", null, speedIncr, NumberInput.BehaviorFlags.AcceleratingRepetition)));
            calList.addMenuItem(new Button("Roll Offset", new PitchRollDisplay("ROLL")));
            calList.addMenuItem(new Button("Pitch Offset", new PitchRollDisplay("PITCH")));
            calMenu.addMenuItem(calList);

            //////  INFO  ///////
            var infoMenu = new MenuItem("INFO");
            var infoList = new ScrollList();

            infoList.addMenuItem(new MultiTextInfo(3, getRASteps));
            infoList.addMenuItem(new MultiTextInfo(3, getDECSteps));
            infoList.addMenuItem(new MultiTextInfo(2, getTRKSteps));
            //infoList.addMenuItem(new TextInfo( "Loc ", getLocation));
            //infoList.addMenuItem(new TextInfo( "Temp: ", getTemperature));
            //infoList.addMenuItem(new TextInfo( "MemAvail: ", getMemAvail));
            //infoList.addMenuItem(new TextInfo( "Up: ", getUpTime));
            infoList.addMenuItem(new TextInfo("Firmw.: ", () => "V1.9.00"));
            infoMenu.addMenuItem(infoList);

            // Add all the menus
            menu.addMenuItem(raMenu);
            menu.addMenuItem(decMenu);
            menu.addMenuItem(goMenu);
            menu.addMenuItem(haMenu);
            menu.addMenuItem(ctrlMenu);
            menu.addMenuItem(calMenu);
            menu.addMenuItem(infoMenu);

            // Add all the model dialogs.
            menu.addModalDialog(dlgSlewToPolaris);
            menu.addModalDialog(dlgStoreSync);
            menu.addModalDialog(dlgDriftAlign);

            // Startup Wizard
            var dlgStartIsHome = new MenuItem("Home Position?", "StartIsHome");

            dlgStartIsHome.addMenuItem(new OptionChooser(new string[] { "Yes", "No", "Cancl" }, 1, startupIsHomePosition));
            var dlgStartFindGPS = new MenuItem("Finding GPS...", "StartFindGPS");

            dlgStartFindGPS.addMenuItem(new FindGPSDisplay("FINDGPS"));
            var dlgStartHowToGetHA = new MenuItem("Set HA via?", "StartHAChooser");

            dlgStartHowToGetHA.addMenuItem(new OptionChooser(new string[] { "GPS Sync", "Manual Set" }, 0, startupHowToGetHA));
            var dlgStartHAGetManual = new MenuItem("Polaris HA?", "StartEnterHA");

            dlgStartHAGetManual.addMenuItem(new NumberInput("HA", new[] { 15, 32 }, "^%02dh^%02dm", startHAConfirmed, hourIncr, NumberInput.BehaviorFlags.ConstantRepetition));
            var dlgStartManualControl = new ManualControlModal(manualControlEvent, "StartManualControl");

            menu.addModalDialog(dlgStartIsHome);
            menu.addModalDialog(dlgStartFindGPS);
            menu.addModalDialog(dlgStartHowToGetHA);
            menu.addModalDialog(dlgStartHAGetManual);
            menu.addModalDialog(dlgStartManualControl);

            // Set the first modal dialog on the menu system
            menu.activateDialog("StartIsHome");

            do
            {
                int keyState = getKeyState();

                // Console.Write("Key:{0} ", keyState);
                if (!menu.onPreviewKey(keyState))
                {
                    if (menu.processKeys(keyState))
                    {
                        while (getKeyState() != btnNONE)
                        {
                            ;
                        }
                    }
                }

                Console.CursorTop  = 1;
                Console.CursorLeft = 0;
                menu.updateDisplay();
            }while (true);
        }
        internal AlbumInfoEditor(IEnumerable<Track> tracks, IMusicSession iContext)
        {
            Tracks = tracks.ToList();

            var ab = Tracks.Select(t => t.RawAlbum).Distinct();

            AlbumMaturity DefaultAlbumMaturity = ab.Any(a => a.Maturity == AlbumMaturity.Discover) ? AlbumMaturity.Discover : AlbumMaturity.Collection;
            Context = (iContext as IInternalMusicSession).GetNewSessionContext(DefaultAlbumMaturity);

            //AutorOption = new OptionChooserArtist(ab.Select(alb => alb.Author).Distinct(), Context.Session);
            ArtistOption = new OptionArtistChooser(ab.Select(alb => alb.Artists), Context.Session);
            GenreOption = new OptionChooser<string>(ab.Select(alb => alb.Genre).Distinct());
            YearOption = new OptionChooser<int?>(ab.Select(alb => (int?)alb.Year).Distinct());
            NameOption = new OptionChooser<string>(ab.Select(alb => alb.Name).Distinct());
        }
 public override IEnumerator RunOptions(Options optionsCollection, OptionChooser optionChooser)
 {
     yield return(null);
 }