Example #1
0
        private void PopulateCategories()
        {
            var uniqueCategories = new HashSet <string>();

            // hard-coded to show all recipes
            uniqueCategories.Add(Loc.GetString("All"));

            foreach (var prototype in _prototypeManager.EnumeratePrototypes <ConstructionPrototype>())
            {
                var category = Loc.GetString(prototype.Category);

                if (!string.IsNullOrEmpty(category))
                {
                    uniqueCategories.Add(category);
                }
            }

            _category.Clear();

            var array = uniqueCategories.ToArray();

            Array.Sort(array);

            for (var i = 0; i < array.Length; i++)
            {
                var category = array[i];
                _category.AddItem(category, i);
            }

            _categories = array;
        }
        private void LoadExampleItems()
        {
            SelectExampleButton.Clear();

            foreach (string sceneName in sceneLoader.GetCurrentChapterSampleNames())
            {
                SelectExampleButton.AddItem(sceneName);
            }
        }
        private void LoadChapterItems()
        {
            SelectChapterButton.Clear();

            foreach (string chapterName in sceneLoader.GetChapterNames())
            {
                SelectChapterButton.AddItem(chapterName);
            }
        }
Example #4
0
    public void InitResources(List <string> resourceList, Func <string, Texture> getTextureFunc)
    {
        resourceSelect.Clear();
        resourceSelect.AddItem("");
        foreach (var res in resourceList)
        {
            resourceSelect.AddItem(res);
        }

        getTexture = getTextureFunc;
    }
Example #5
0
    public override void _Ready()
    {
        compounds       = GetNode <OptionButton>(CompoundsPath);
        maximumDistance = GetNode <Slider>(MaximumDistancePath);
        minimumAmount   = GetNode <Slider>(MinimumAmountPath);
        colour          = GetNode <TweakedColourPicker>(ColourPath);

        compounds.Clear();

        maximumDistance.MinValue = Constants.CHEMORECEPTOR_RANGE_MIN;
        maximumDistance.MaxValue = Constants.CHEMORECEPTOR_RANGE_MAX;

        minimumAmount.MinValue = Constants.CHEMORECEPTOR_AMOUNT_MIN;
        minimumAmount.MaxValue = Constants.CHEMORECEPTOR_AMOUNT_MAX;
    }
Example #6
0
    private void _on_TabContainer_tab_selected(int tab)
    {
        //if add receipt tab button is selected, update the ingredient and volume options
        if (tab == 1)
        {
            //cleal the options first
            ingredientOption.Clear();
            volumeOption.Clear();

            //read list of ingredients from JSON and add it to the option button
            try
            {
                StreamReader r     = new StreamReader(ingredientPath);
                string       _json = r.ReadToEnd();
                r.Close();

                JObject rss   = JObject.Parse(_json);        //convert string to object
                var     _list = rss["Ingredients"].ToList(); //convert to list using Linq
                for (var l = 0; l < _list.Count; l++)        //add each item to list
                {
                    ingredientOption.AddItem(rss["Ingredients"][l].ToString());
                }
            }
            catch (FileNotFoundException)
            {
                //do nothing, failed to load file...
            }

            //read list of volumes from JSON and add it to the option button
            try
            {
                StreamReader r     = new StreamReader(volumePath);
                string       _json = r.ReadToEnd();
                r.Close();

                JObject rss  = JObject.Parse(_json);    //convert string to object
                var     list = rss["Volumes"].ToList(); //convert to list using Linq
                for (var l = 0; l < list.Count; l++)    //add each item to list
                {
                    volumeOption.AddItem(rss["Volumes"][l].ToString());
                }
            }
            catch (FileNotFoundException)
            {
                //do nothing, failed to load file...
            }
        }
    }
Example #7
0
    private void UpdateAvailableModsList()
    {
        modSelect.Clear();

        foreach (var mod in mods)
        {
            // When clicking the OptionButton the opened list doesn't scale down the icon sizes so we can't use icons
            // TODO: report the above bug to Godot and get this fixed
            // modSelect.AddIconItem(ModManager.LoadModIcon(mod), mod.InternalName);
            modSelect.AddItem(mod.InternalName);
        }

        if (modSelect.Selected != -1)
        {
            ModSelected(modSelect.Selected);
        }
    }
Example #8
0
    private void _on_TabContainer_tab_selected(int _tab)
    {
        //if Browse tab is selected, load all receipts in to the receipt, volume and ingredient list
        if (_tab == 2)
        {
            //clear the lists and reset values
            receiptList.Clear();
            ingredientOption.Clear();
            ingredientVolumeOption.Clear();
            ingredientSearchOption.Clear();
            ingredientSearchList.Clear();
            receiptSearch.Text        = "";
            ingredientSearchListCount = ingredientSearchList.GetItemCount();
            _resetForm();

            //read list of receipts from JSON and add their titles to the receipt list
            try
            {
                StreamReader _r    = new StreamReader(receiptPath);
                string       _json = _r.ReadToEnd();
                _r.Close();

                JObject _rss = JObject.Parse(_json); //convert string to object
                list = _rss["Receipts"].ToList();    //convert to list using Linq
                for (var l = 0; l < list.Count; l++) //add each item to list
                {
                    receiptList.AddItem(list[l]["Title"].ToString());
                }

                //sort list alphabetically
                receiptList.SortItemsByText();
            }
            catch (FileNotFoundException)
            {
                //do nothing,
            }

            //read list of ingredients from JSON and add it to the option button
            try
            {
                StreamReader r     = new StreamReader(ingredientPath);
                string       _json = r.ReadToEnd();
                r.Close();

                JObject _rss  = JObject.Parse(_json);         //convert string to object
                var     _list = _rss["Ingredients"].ToList(); //convert to list using Linq
                for (var l = 0; l < _list.Count; l++)         //add each item to list
                {
                    ingredientOption.AddItem(_rss["Ingredients"][l].ToString());
                    ingredientSearchOption.AddItem(_rss["Ingredients"][l].ToString());
                }
            }
            catch (FileNotFoundException)
            {
                //do nothing, failed to load file...
            }

            //read list of volumes from JSON and add it to the option button
            try
            {
                StreamReader r     = new StreamReader(volumePath);
                string       _json = r.ReadToEnd();
                r.Close();

                JObject rss   = JObject.Parse(_json);    //convert string to object
                var     _list = rss["Volumes"].ToList(); //convert to list using Linq
                for (var l = 0; l < _list.Count; l++)    //add each item to list
                {
                    ingredientVolumeOption.AddItem(rss["Volumes"][l].ToString());
                }
            }
            catch (FileNotFoundException)
            {
                //do nothing, failed to load file...
            }
        }
    }