Esempio n. 1
0
    public void Initialise(bool isAssay)
    {
        assayMode = isAssay;
        mainMenu.SetActive(false);
        sharedMenu.SetActive(true);
        assayMenu.SetActive(isAssay);
        combiMenu.SetActive(!isAssay);
        for (int i = 0; i < csvController.samplePositions.Count; i++)
        {
            string sampleID  = csvController.sampleList[i];
            int    samplePos = csvController.samplePositions[i];
            samples.Add(sampleID);

            GameObject g = GameObject.Instantiate(samplePrefab) as GameObject;
            g.transform.SetParent(sampleScrollView.transform, false);
            g.GetComponentInChildren <Text>().text      = sampleID;
            g.GetComponent <SampleListEntry>().SampleID = sampleID;
            g.GetComponent <SampleListEntry>().index    = samplePos;

            sampleToggles.Add(g.GetComponent <Toggle>());
        }
        if (isAssay)
        {
            for (int i = 1; i < csvController.grid.GetUpperBound(0); i++)
            {
                string columnHeader = csvController.grid[i, 0];

                if (columnHeader != "" && columnHeader != null)
                {
                    columns.Add(columnHeader);

                    GameObject g = GameObject.Instantiate(samplePrefab) as GameObject;
                    g.transform.SetParent(columnScrollView.transform, false);
                    g.GetComponentInChildren <Text>().text      = columnHeader;
                    g.GetComponent <SampleListEntry>().SampleID = columnHeader;
                    g.GetComponent <SampleListEntry>().index    = i;
                    if (!ContainsNoCase(columnHeader, "_pc"))
                    {
                        g.GetComponent <Toggle>().isOn = false;
                    }
                    columnToggles.Add(g.GetComponent <Toggle>());
                }
                //int samplePos = csvController.samplePositions[i];

                //sampleToggles.Add(g.GetComponent<Toggle>());
            }
        }
        else
        {
            for (int i = 1; i < csvController.grid.GetUpperBound(0); i++)
            {
                string columnHeader = csvController.grid[i, 0];

                if (columnHeader != "" && columnHeader != null)
                {
                    columns.Add(columnHeader);

                    GameObject g = GameObject.Instantiate(combiElemMinPrefab) as GameObject;
                    g.transform.SetParent(combiColumnScrollView.transform, false);
                    g.GetComponentInChildren <Text>().text = columnHeader;
                    g.GetComponent <CombiMineralElementListEntry>().SampleID   = columnHeader;
                    g.GetComponent <CombiMineralElementListEntry>().label.text = columnHeader;
                    g.GetComponent <CombiMineralElementListEntry>().index      = i;
                    if (ContainsNoCase(columnHeader, "_ppm"))
                    {
                        g.GetComponent <CombiMineralElementListEntry>().ElementToggle.isOn = true;
                    }
                    else if (ContainsNoCase(columnHeader, "_pc"))
                    {
                        g.GetComponent <CombiMineralElementListEntry>().ElementToggle.isOn = true;
                    }
                    else if (ContainsNoCase(columnHeader, "_wt%"))
                    {
                        g.GetComponent <CombiMineralElementListEntry>().MineralToggle.isOn = true;
                    }
                    //g.GetComponent<CombiMineralElementListEntry>().ElementToggle.
                    //columnToggles.Add(g.GetComponent<Toggle>());
                }
                //int samplePos = csvController.samplePositions[i];

                //sampleToggles.Add(g.GetComponent<Toggle>());


                //NEXT TIME:
                //Add the mineral comps to the- oh shit i need to make the CMC a real thing huh, okay brb gotta do that
                //then add them to the CombiMineralCompScrollview which definitely already exists in code
            }
        }

        //Add all mineral compositions and elements to the corresponding lists
        int k = 0;

        //Dataset dataset = new Dataset(defaultMineralDict);

        datasetDict.Add("Default", defaultDataset);


        Dictionary <string, MineralComposition> defaultMineralDict = defaultDataset.mineralDict;

        currentMineralDict = defaultMineralDict;

        foreach (MineralComposition mc in defaultMineralDict.Values)
        {
            GameObject g = GameObject.Instantiate(mineralCompListPrefab) as GameObject;
            g.transform.SetParent(mineralCompScrollView.transform, false);
            MineralCompositionListEntry mcle = g.GetComponent <MineralCompositionListEntry>();
            mcle.label.text  = mc.mineral;
            mcle.MineralComp = mc.mineral;
            mcle.index       = k;
            if (isAssay)
            {
                g.GetComponentInChildren <InputField>().text = mc.weight.ToString();
            }
            else
            {
                g.GetComponentInChildren <InputField>().text = mc.startPoint.ToString();
            }
            mineralToggles.Add(g.GetComponent <Toggle>());
            k++;
        }

        foreach (MineralComposition mc in elementDict.Values)
        {
            GameObject g = GameObject.Instantiate(mineralCompListPrefab) as GameObject;
            g.transform.SetParent(elementCompScrollView.transform, false);
            MineralCompositionListEntry mcle = g.GetComponent <MineralCompositionListEntry>();
            mcle.label.text  = mc.mineral;
            mcle.MineralComp = mc.mineral;
            mcle.index       = k;
            g.GetComponent <Toggle>().isOn = false;
            if (isAssay)
            {
                g.GetComponentInChildren <InputField>().text = mc.weight.ToString();
            }
            else
            {
                g.GetComponentInChildren <InputField>().text = mc.startPoint.ToString();
            }
            elementToggles.Add(g.GetComponent <Toggle>());
            k++;
        }

        /*
         * if (isAssay)
         * {
         * }
         * else
         * {
         *  int i = 0;
         *  foreach (CombiController.CombiMineralComposition cmc in combiController.combiMineralDict.Values)
         *  {
         *
         *      GameObject g = GameObject.Instantiate(mineralCompListPrefab) as GameObject;
         *      g.transform.SetParent(mineralCompScrollView.transform, false);
         *      MineralCompositionListEntry mcle = g.GetComponent<MineralCompositionListEntry>();
         *      mcle.label.text = cmc.mineral;
         *      mcle.MineralComp = cmc.mineral;
         *      mcle.index = i;
         *      g.GetComponentInChildren<InputField>().text = cmc.weight.ToString();
         *      mineralToggles.Add(g.GetComponent<Toggle>());
         *      i++;
         *  }
         *  foreach (CombiController.CombiMineralComposition cmc in combiController.combiElementDict.Values)
         *  {
         *
         *      GameObject g = GameObject.Instantiate(mineralCompListPrefab) as GameObject;
         *      g.transform.SetParent(elementCompScrollView.transform, false);
         *      MineralCompositionListEntry mcle = g.GetComponent<MineralCompositionListEntry>();
         *      mcle.label.text = cmc.mineral;
         *      mcle.MineralComp = cmc.mineral;
         *      mcle.index = i;
         *      g.GetComponent<Toggle>().isOn = false;
         *      g.GetComponentInChildren<InputField>().text = cmc.weight.ToString();
         *      elementToggles.Add(g.GetComponent<Toggle>());
         *      i++;
         *  }
         * }*/
    }
Esempio n. 2
0
    public IEnumerator ChangeDataset()
    {
        Dataset ds;

        if (!datasetDict.TryGetValue(datasetDropdown.options[datasetDropdown.value].text, out ds))
        {
            Debug.Log("dataset not found - creating new one");
            Dictionary <string, MineralComposition> mineralDict = new Dictionary <string, MineralComposition>();
            yield return(StartCoroutine(FastDownload(path + datasetDropdown.options[datasetDropdown.value].text, fileContents => fileContentString = fileContents)));

            string[,] datasetGrid = CSVReader.SplitCsvGrid(fileContentString);

            for (int i = 1; i <= datasetGrid.GetUpperBound(1); i++)
            {
                string columnHeader = datasetGrid[0, i];

                string             mineralComp = datasetGrid[0, i];
                MineralComposition MC          = new MineralComposition(mineralComp);
                double[]           val         = new double[] { Double.Parse(datasetGrid[1, i]),
                                                                Double.Parse(datasetGrid[2, i]),
                                                                Double.Parse(datasetGrid[3, i]),
                                                                Double.Parse(datasetGrid[4, i]),
                                                                Double.Parse(datasetGrid[5, i]),
                                                                Double.Parse(datasetGrid[6, i]),
                                                                Double.Parse(datasetGrid[7, i]),
                                                                Double.Parse(datasetGrid[8, i]),
                                                                Double.Parse(datasetGrid[9, i]),
                                                                Double.Parse(datasetGrid[10, i]),
                                                                Double.Parse(datasetGrid[11, i]),
                                                                Double.Parse(datasetGrid[12, i]),
                                                                Double.Parse(datasetGrid[13, i]),
                                                                Double.Parse(datasetGrid[14, i]),
                                                                Double.Parse(datasetGrid[15, i]),
                                                                Double.Parse(datasetGrid[16, i]),
                                                                Double.Parse(datasetGrid[17, i]),
                                                                Double.Parse(datasetGrid[18, i]),
                                                                Double.Parse(datasetGrid[19, i]),
                                                                Double.Parse(datasetGrid[20, i]),
                                                                Double.Parse(datasetGrid[21, i]) };
                FillMCDatabase(MC, val);
                MC.weight     = double.Parse(datasetGrid[22, i]);
                MC.startPoint = double.Parse(datasetGrid[23, i]);

                mineralDict.Add(mineralComp, MC);
            }
            ds = new Dataset(mineralDict);
            datasetDict.Add(datasetDropdown.options[datasetDropdown.value].text, ds);
        }

        currentMineralDict = ds.mineralDict;
        mineralToggles.Clear();
        foreach (Transform child in mineralCompScrollView.transform)
        {
            GameObject.Destroy(child.gameObject);
        }
        int k = 0;

        foreach (MineralComposition mc in currentMineralDict.Values)
        {
            GameObject g = GameObject.Instantiate(mineralCompListPrefab) as GameObject;
            g.transform.SetParent(mineralCompScrollView.transform, false);
            MineralCompositionListEntry mcle = g.GetComponent <MineralCompositionListEntry>();
            mcle.label.text  = mc.mineral;
            mcle.MineralComp = mc.mineral;
            mcle.index       = k;
            if (assayMode)
            {
                g.GetComponentInChildren <InputField>().text = mc.weight.ToString();
            }
            else
            {
                g.GetComponentInChildren <InputField>().text = mc.startPoint.ToString();
            }
            mineralToggles.Add(g.GetComponent <Toggle>());
            k++;
        }

        foreach (Transform child in elementCompScrollView.transform)
        {
            MineralCompositionListEntry mcle = child.gameObject.GetComponent <MineralCompositionListEntry>();
            mcle.index = k;
            k++;
        }
        yield return(null);
    }