コード例 #1
0
    public void importData(SSRP_attribute attr)
    {
        childUpdateRequired = false;
        if (!ArrayList.Equals(attr.metadatas, data.metadatas))
        {
            childUpdateRequired = true;
        }
        data = attr;

        refresh();
    }
コード例 #2
0
    private void testDataGeneration()
    {
        SSRP_Metadata metaData_00 = new SSRP_Metadata("Faux_name", "faux_type", "faux value");
        SSRP_Metadata metaData_01 = new SSRP_Metadata("meta1", "int", "one");
        SSRP_Metadata metaData_02 = new SSRP_Metadata("meta2", "int", "two");
        SSRP_Metadata metaData_03 = new SSRP_Metadata("meta3", "int", "three");
        SSRP_Metadata metaData_04 = new SSRP_Metadata("meta4", "int", "four");

        SSRP_Metadata[] metaData_list = new SSRP_Metadata[] { metaData_00, metaData_01, metaData_02, metaData_03, metaData_04 };
        SSRP_attribute  testdata      = new SSRP_attribute("Faux_name", "faux_type", "faux value", metaData_list);

        importData(testdata);
    }
コード例 #3
0
    private void testDataGeneration()
    {
        SSRP_Metadata metaData_00 = new SSRP_Metadata("Faux_name", "faux_type", "faux value");
        SSRP_Metadata metaData_01 = new SSRP_Metadata("meta1", "int", "one");
        SSRP_Metadata metaData_02 = new SSRP_Metadata("meta2", "int", "two");
        SSRP_Metadata metaData_03 = new SSRP_Metadata("meta3", "int", "three");
        SSRP_Metadata metaData_04 = new SSRP_Metadata("meta4", "int", "four");

        SSRP_Metadata[] metaData_list = new SSRP_Metadata[] { metaData_00, metaData_01, metaData_02, metaData_03, metaData_04 };
        SSRP_attribute  test_att01    = new SSRP_attribute("att_1", "att_type", "att value", metaData_list);
        SSRP_attribute  test_att02    = new SSRP_attribute("att_2", "float", "344.324432543", metaData_list);
        SSRP_attribute  test_att03    = new SSRP_attribute("att_3", "bool", "false", metaData_list);
        SSRP_attribute  test_att04    = new SSRP_attribute("att_4", "int", "3", metaData_list);
        SSRP_attribute  test_att05    = new SSRP_attribute("att_5", "att_type", "att value", metaData_list);

        SSRP_attribute[]    attList  = new SSRP_attribute[] { test_att01, test_att02, test_att03, test_att04, test_att05 };
        SSRP_ContextElement testdata = new SSRP_ContextElement("34234324243", "sun", "true", attList);

        importData(testdata);
    }
コード例 #4
0
    private void addChildren()
    {
        //data.attributes = new SSRP_attribute[] { };
        Vector2 newCanvasDimensions = new Vector2(0f, 0f);
        int     m = data.attributes.Length;
        int     i = 0;

        /*
         * // debug purposes
         * string childDescription = "";
         * foreach (SSRP_attribute childObj in data.attributes)
         * {
         *  childDescription += childObj.description() + ",\n";
         * }
         * Debug.LogFormat("Element Controller :  canLocateBaseGO:{1} and canRenderMeta:{2}, add {0} Children, attributes = [{3}]", m, canLocateBaseGO, canRenderChildData, childDescription);
         * // */

        if (canLocateBaseGO && canRenderChildData)
        {
            if (m == 0)
            {
                //newCanvasDimensions = childPrefab_canvas_init_dimension;
            }
            else
            {
                Vector3 newCanvasPosition = new Vector3(0f, 0f, 0f);
                Vector2 origin            = new Vector2(0f, 0f);
                Vector2 offset            = new Vector2(10, -10f);
                Vector2 dim        = new Vector2(210f, 126f);
                Vector2 step       = new Vector2(0f, 0f);
                Vector2 stepOffset = new Vector2(0, 0);
                Vector2 pos        = new Vector2(0f, 0f);
                int     rowNo      = 0;
                int     colCount   = 0;

                // rough GRID LAY OUT FOR ATTRIBUTESs - this should be have one level of recursion and to resize 6 boxes, into 2 rows of 3, and not 1 row of 5 and one row of 1.

                // scrollview.transform
                float scrollbarSize = 25;
                if (maxColSize > 0)
                {
                    float rows = 0;
                    float cols = maxColSize;
                    if (m <= maxColSize)
                    {
                        cols = m;
                        rows = 1;
                    }
                    else
                    {
                        rows = Mathf.Floor(m / maxColSize) + 1;
                    }

                    float height = Mathf.Ceil((dim.y + Mathf.Abs(offset.y)) * rows) + scrollbarSize;
                    float width  = offset.x + (dim.x * cols) + scrollbarSize;
                    //       Debug.LogFormat("We have {0} attribute and a maxColSize of {1}, giving us a height:{2} and width:{3}", m, maxColSize, height, width);
                    try
                    {
                        scrollview        = contextEntityViewGameObject.transform.Find("scrollView").gameObject;
                        scrollview_canvas = scrollview.transform.GetComponent <RectTransform>();

                        scrollview_canvas.sizeDelta = new Vector2(width, height);
                    }
                    catch
                    {
                        Debug.LogFormat("couldn't link to scrollview Canvas");
                    }
                }



                // loop through list of Child data and generate their UI
                for (i = 0; i < m; i++)
                {
                    if (maxColSize > 0 && colCount == maxColSize)
                    {
                        colCount = 0;
                        rowNo++;
                    }
                    step.Set(colCount, -rowNo);

                    stepOffset = Vector2.Scale(step, dim);

                    SSRP_attribute childData = data.attributes[i];
                    pos = origin + offset + stepOffset;
                    GameObject data_MVC;

                    data_MVC = (GameObject)Instantiate(attributGameObjectPrefab, pos, Quaternion.identity);
                    data_MVC.transform.SetParent(ViewPortContentTarget.transform, false);
                    prefabChildList.Add(data_MVC);
                    SSRP_Attribute_Controller child_controller = data_MVC.GetComponent <SSRP_Attribute_Controller>();
                    //     Debug.LogFormat("SSRP_attribute childData = [{0}]", childData.description());
                    child_controller.importData(childData);
                    colCount++;
                }


                //resize base canvas
                //newCanvasDimensions = new Vector2(200f, (m + 1) * childPrefab_canvas_init_dimension.y);
                //entity_canvas.sizeDelta = newCanvasDimensions;
            }
        }
    }
コード例 #5
0
    private void addChildren()
    {
        //data.attributes = new SSRP_attribute[] { };
        Vector2 newCanvasDimensions = new Vector2(0f, 0f);
        int     m = data.attributes.Length;
        int     i = 0;


        if (canRenderChildData)
        {
            if (m == 0)
            {
                //newCanvasDimensions = childPrefab_canvas_init_dimension;
            }
            else
            {
                Vector3 newCanvasPosition = new Vector3(0f, 0f, 0f);
                Vector2 origin            = new Vector2(0f, 0f); // new Vector2(0f, -126f);
                Vector2 offset            = new Vector2(10, -10f);
                Vector2 dim        = new Vector2(210f, 126f);
                Vector2 step       = new Vector2(0f, 0f);
                Vector2 stepOffset = new Vector2(0, 0);
                Vector2 pos        = new Vector2(0f, 0f);
                int     rowNo      = 0;
                int     colCount   = 0;

                // rough GRID LAY OUT FOR ATTRIBUTESs - this should be have one level of recursion and to resize 6 boxes, into 2 rows of 3, and not 1 row of 5 and one row of 1.


                float scrollbarSize = 25;
                if (maxColSize > 0)
                {
                    float rows = 0;
                    float cols = maxColSize;
                    if (m <= maxColSize)
                    {
                        cols = m;
                        rows = 1;
                    }
                    else
                    {
                        rows = Mathf.Floor(m / maxColSize) + 1;
                    }

                    float height = Mathf.Ceil((dim.y + Mathf.Abs(offset.y)) * rows) + scrollbarSize;
                    float width  = offset.x + (dim.x * cols) + scrollbarSize;

                    try
                    {
                        scrollview        = transform.Find("popup").gameObject;
                        scrollview_canvas = scrollview.transform.GetComponent <RectTransform>();

                        scrollview_canvas.sizeDelta = new Vector2(width, height);
                    }
                    catch
                    {
                        Debug.LogFormat("couldn't link to scrollview Canvas");
                    }
                }



                // loop through list of Child data and generate their UI
                for (i = 0; i < m; i++)
                {
                    if (maxColSize > 0 && colCount == maxColSize)
                    {
                        colCount = 0;
                        rowNo++;
                    }
                    step.Set(colCount, -rowNo);

                    stepOffset = Vector2.Scale(step, dim);

                    SSRP_attribute childData = data.attributes[i];
                    pos = origin + offset + stepOffset;
                    GameObject data_MVC;

                    Debug.Log(scrollview);
                    if (scrollview == null || scrollview.transform == null)
                    {
                        return;
                    }


                    data_MVC = (GameObject)Instantiate(attributGameObjectPrefab, pos, Quaternion.identity);
                    data_MVC.transform.SetParent(scrollview.transform, false);
                    prefabChildList.Add(data_MVC);
                    SSRP_Attribute_Controller child_controller = data_MVC.GetComponent <SSRP_Attribute_Controller>();
                    //     Debug.LogFormat("SSRP_attribute childData = [{0}]", childData.description());
                    child_controller.importData(childData);
                    colCount++;
                }


                //resize base canvas
                //newCanvasDimensions = new Vector2(200f, (m + 1) * childPrefab_canvas_init_dimension.y);
                //entity_canvas.sizeDelta = newCanvasDimensions;
            }
        }
    }
コード例 #6
0
 void importData(SSRP_attribute data)
 {
     _model = data;
     refresh();
 }