Ejemplo n.º 1
0
        public void MyTestInitialize()
        {
            db = new OptionStorage();

            versionOption = new OptionDefinition.Builder(db)
                            .AddShortName('v')
                            .AddLongName("version")
                            .HelpText("Print version information.")
                            .Mandatory(true)
                            .Build();

            lengthOption = new OptionDefinition.Builder(db)
                           .AddLongName("length")
                           .HelpText("Calculates magic length.")
                           .Mandatory(true)
                           .SetArgumentPresence(ArgumentPresence.Mandatory)
                           .ValueParser(new IntegerParser(0, Int32.MaxValue))
                           .Build();

            helpOption = new OptionDefinition.Builder(db)
                         .AddLongName("help")
                         .HelpText("Print a usage message...")
                         .Build();

            sOption = new OptionDefinition.Builder(db)
                      .AddShortName('s')
                      .Build();
        }
Ejemplo n.º 2
0
    //Displays the current option set's options on the various UI elements
    public void DisplayCurrentOptions()
    {
        for (short i = 0; i < 9; i++)
        {
            rulesDropdowns[i].value = OptionStorage.GetCurrent().GetRule(i);
        }
        edgeTypeDropdown.value  = OptionStorage.GetCurrent().GetEdgeType();
        nameInputField.text     = OptionStorage.GetCurrent().GetName();
        randomColorsToggle.isOn = OptionStorage.GetCurrent().ColorsAreRandom();
        localColors             = OptionStorage.GetCurrent().GetColors();
        DisplayColors();

        //Disallows editing of the Default options and the example options
        if (OptionStorage.GetCurrentOptionIndex() == 0 || OptionStorage.GetCurrentOptionIndex() == 1)
        {
            editButton.interactable   = false;
            deleteButton.interactable = false;
            renameButton.interactable = false;
        }
        else
        {
            editButton.interactable   = true;
            deleteButton.interactable = true;
            renameButton.interactable = true;
        }
    }
Ejemplo n.º 3
0
    //Edits the current options
    public void Edit()
    {
        //Disables the option buttons
        GameObject[] temp = GameObject.FindGameObjectsWithTag("OptionButton");
        foreach (GameObject t in temp)
        {
            t.GetComponent <Button>().interactable = false;
        }

        //Enables all UI elements that change options
        changableColors                 = GameObject.FindGameObjectsWithTag("ColorButton");
        changableButtons                = GameObject.FindGameObjectsWithTag("ChangableButton");
        nameInputField.interactable     = true;
        nameInputField.text             = OptionStorage.GetCurrent().GetName();
        randomColorsToggle.interactable = true;
        for (int i = 0; i < changableColors.Length; i++)
        {
            changableColors[i].GetComponent <Button>().interactable = true;
        }
        for (int i = 0; i < changableButtons.Length; i++)
        {
            changableButtons[i].GetComponent <Button>().interactable = true;
        }
        for (int i = 0; i < changableDropdowns.Length; i++)
        {
            changableDropdowns[i].GetComponent <Dropdown>().interactable = true;
        }
        addOptionButton.interactable = false;
    }
Ejemplo n.º 4
0
    //Loads options and displays current option
    private void Start()
    {
        //Fixes position of scroll plane content rect
        optionListPlane.content.transform.position = optionListPos;
        colorListPlane.content.transform.position  = colorListPos;

        //Makes sure the color picker is inactive
        ColorPickerBackground.SetActive(false);

        //Allows changing the states of cetain UI objects
        changableButtons   = GameObject.FindGameObjectsWithTag("ChangableButton");
        changableDropdowns = GameObject.FindGameObjectsWithTag("ChangableDropdown");
        changableColors    = GameObject.FindGameObjectsWithTag("ColorButton");

        storedOptions = OptionStorage.GetSavedOptions();

        optionButtons = new List <Button>();
        DisplayOptionList();

        colorButtons = new List <Button>();
        localColors  = OptionStorage.GetCurrent().GetColors();
        DisplayColors();

        EndEditing();
        DisplayCurrentOptions();
    }
        public void OptionDefinitionBuilder_OmmitedValueParser()
        {
            OptionStorage optionStorage = new OptionStorage();

            IOptionDefinitionBuilder optionBuilder1 = new OptionDefinition.Builder(optionStorage);

            optionBuilder1.AddLongName("version").AddLongName("ver").SetArgumentPresence(ArgumentPresence.Mandatory).Build();
        }
        public void OptionDefinitionBuilder_OmmitedOptionName()
        {
            OptionStorage optionStorage = new OptionStorage();

            IOptionDefinitionBuilder optionBuilder1 = new OptionDefinition.Builder(optionStorage);

            optionBuilder1.Build();
        }
    // Start is called before the first frame update
    void Start()
    {
        speed = 0.2f;

        //Gets access to current game options
        optionStorage  = GameObject.FindObjectOfType <OptionStorage>();
        currentOptions = OptionStorage.GetCurrent();
    }
Ejemplo n.º 8
0
        public void Hello()
        {
            var optionStorage = new OptionStorage();
            var optionSound   = new OptionSound(optionStorage);

            Assert.IsFalse(optionSound.IsMute);
            optionSound.IsMute = true;
            Assert.IsTrue(optionSound.IsMute);
            Assert.IsTrue(optionStorage._boolDic[nameof(OptionSound.IsMute)]);
        }
        public void OptionDefinitionBuilder_DuplicitOptionName()
        {
            OptionStorage optionStorage = new OptionStorage();

            IOptionDefinitionBuilder optionBuilder1 = new OptionDefinition.Builder(optionStorage);

            optionBuilder1.AddLongName("version").AddLongName("ver").Build();

            IOptionDefinitionBuilder optionBuilder2 = new OptionDefinition.Builder(optionStorage);

            optionBuilder2.AddLongName("version").AddLongName("ver").Build();
        }
Ejemplo n.º 10
0
 //Allows for renaming of the current option set
 public void Rename()
 {
     //Disables option buttons
     GameObject[] temp = GameObject.FindGameObjectsWithTag("OptionButton");
     foreach (GameObject t in temp)
     {
         t.GetComponent <Button>().interactable = false;
     }
     addOptionButton.interactable = false;
     //Enables the name input field
     nameInputField.interactable = true;
     nameInputField.text         = OptionStorage.GetCurrent().GetName();
 }
Ejemplo n.º 11
0
    //Deletes an option from the list
    public void DeleteOption()
    {
        OptionStorage.DeleteCurrent();

        optionButtons = new List <Button>();
        DisplayOptionList();

        colorButtons = new List <Button>();
        DisplayColors();

        EndEditing();
        DisplayCurrentOptions();
    }
Ejemplo n.º 12
0
    //Adds a new option to the list
    public void AddOption()
    {
        OptionStorage.AddOption();

        optionButtons = new List <Button>();
        DisplayOptionList();

        colorButtons = new List <Button>();
        DisplayColors();

        SetHighlightedOption(optionButtons.Count - 1);
        OptionStorage.PickOption(optionButtons.Count - 1);

        DisplayCurrentOptions();
    }
Ejemplo n.º 13
0
        static void Main(string[] args)
        {
            // Sample command line to accept
            string commandLine = "cmd -v --length=20";

            // Initialize a new db
            OptionStorage db = new OptionStorage();

            // Create and register a new option definition
            OptionDefinition versionOption = new OptionDefinition.Builder(db)
                                             .AddShortName('v')
                                             .AddLongName("version")
                                             .HelpText("Print version information.")
                                             .Build();

            // Create and register another option definition
            OptionDefinition lengthOption = new OptionDefinition.Builder(db)
                                            .AddShortName('v')
                                            .AddLongName("length")
                                            .HelpText("...")
                                            .Mandatory(true)
                                            .SetArgumentPresence(ArgumentPresence.Mandatory)
                                            .ValueParser(new IntegerParser())
                                            .Build();

            // Parse the provided command line while using our option storage.
            ParseResult parserResult = Parser.Parse(commandLine, db);

            if (!parserResult.ParseSucceeded)
            {
                ;
            }
            //PrintErrorAndEnd();

            if (parserResult.IsOptionParsed("version"))
            {
                Console.WriteLine("Version 10.0.14393");
            }

            OptionParsed lengthOptionParsed = parserResult.GetParsedOption(lengthOption);

            int lengthValue = (int)lengthOptionParsed.GetParsedValue();
        }
Ejemplo n.º 14
0
    //Saves current options
    public void AcceptChanges()
    {
        Options temp = OptionStorage.GetCurrent();

        temp.SetName(nameInputField.text);
        temp.SetEdgeType((short)edgeTypeDropdown.value);
        temp.SetColorsAreRandom(randomColorsToggle.isOn);
        temp.SetColors(localColors);

        for (short i = 0; i < 9; i++)
        {
            temp.SetRule(i, (short)rulesDropdowns[i].value);
        }

        OptionStorage.SetCurrent(temp);

        optionButtons[OptionStorage.GetCurrentOptionIndex()].gameObject.GetComponentInChildren <Text>().text = temp.GetName();

        EndEditing();
    }
Ejemplo n.º 15
0
        public void MyTestInitialize()
        {
            db = new OptionStorage();
            IOptionDefinitionBuilder versionODB    = new OptionDefinition.Builder(db);
            OptionDefinition         versionOption = versionODB
                                                     .AddShortName('v')
                                                     .AddLongName("version")
                                                     .HelpText("Print version information.")
                                                     .Mandatory(true)
                                                     .SetArgumentPresence(ArgumentPresence.None)
                                                     .ValueParser(null)
                                                     .Build();
            IOptionDefinitionBuilder lengthODB    = new OptionDefinition.Builder(db);
            OptionDefinition         lengthOption = lengthODB
                                                    .AddLongName("length")
                                                    .HelpText("Calculates magic length.")
                                                    .Mandatory(true)
                                                    .SetArgumentPresence(ArgumentPresence.Mandatory)
                                                    .ValueParser(new IntegerParser(0, Int32.MaxValue))
                                                    .Build();
            IOptionDefinitionBuilder outputFormatOB    = new OptionDefinition.Builder(db);
            IOptionDefinitionBuilder portabilityOB     = new OptionDefinition.Builder(db);
            IOptionDefinitionBuilder fileOutputOB      = new OptionDefinition.Builder(db);
            IOptionDefinitionBuilder appendOB          = new OptionDefinition.Builder(db);
            IOptionDefinitionBuilder verboseOB         = new OptionDefinition.Builder(db);
            IOptionDefinitionBuilder helpOptionBuilder = new OptionDefinition.Builder(db);

            outputFormatOB.AddLongName("format").AddShortName('f').HelpText("Specify output, format...").Build();
            portabilityOB.AddLongName("portability").AddShortName('p').HelpText("Use the portable output format").SetArgumentPresence(ArgumentPresence.Mandatory).ValueParser(new StringParser()).Build();
            fileOutputOB.AddLongName("output").AddShortName('o').HelpText("Do not send the results to stderr, ...").SetArgumentPresence(ArgumentPresence.Mandatory).ValueParser(new StringParser()).Build();
            appendOB.AddLongName("append").AddShortName('a').HelpText("(Used together with -o.) Do not overwrite but append").SetArgumentPresence(ArgumentPresence.None).ValueParser(null).Build();
            verboseOB.AddLongName("verbose").HelpText("Give very verbose output...").Build();
            helpOptionBuilder.AddLongName("help").HelpText("Print a usage message...").Build();

            new OptionDefinition.Builder(db).AddShortName('s').Build();
        }
Ejemplo n.º 16
0
    //Displays the whole list of saved options in special button objects
    private void DisplayOptionList()
    {
        //Destroys any buttons currently being displayed
        GameObject[] tempArray = GameObject.FindGameObjectsWithTag("OptionButton");
        for (int i = tempArray.Length - 1; i >= 0; i--)
        {
            Destroy(tempArray[i]);
        }

        //Lets the option button class know a new set of options will be created
        OptionButton.ResetIndexCounter();

        //Creates a new option button object for each stored option
        for (int i = 0; i < storedOptions.Count; i++)
        {
            optionListPlane.content.sizeDelta = new Vector2(182, 100 + (70 * (i + 1)));
            Button temp = Instantiate(objectButtonPrefab, optionListPlane.content);
            optionButtons.Add(temp);
            optionButtons[i].transform.position = new Vector3(0f, (-5f - (80 * i)), 0f) + optionButtons[i].transform.position;
            optionButtons[i].gameObject.GetComponentInChildren <Text>().text = storedOptions[i].GetName();
        }

        optionButtons[OptionStorage.GetCurrentOptionIndex()].image.color = Color.gray;
    }
Ejemplo n.º 17
0
 //Changes the highlighted opton button
 public void SetHighlightedOption(int newIndex)
 {
     optionButtons[OptionStorage.GetCurrentOptionIndex()].image.color = Color.white;
     optionButtons[newIndex].image.color = Color.gray;
 }
 //Restores in game values to the values of the currently selected option set
 public void ResetOptions()
 {
     currentOptions = OptionStorage.GetCurrent();
     DisplayOptions();
 }
Ejemplo n.º 19
0
 //Chooses itself as the current option
 public void ChooseSelf()
 {
     om.SetHighlightedOption(selfIndex);
     OptionStorage.PickOption(selfIndex);
     om.DisplayCurrentOptions();
 }