Beispiel #1
0
    void DrawFormData()
    {
        if (mSelectionTable == null)
        {
            return;
        }

        string tmp_string = "";
        Color  tmp_color;

        //+ - buttons
        GUILayout.BeginHorizontal(); //3A+


        tmp_color = GUI.backgroundColor;

        if (mIsModify)
        {
            GUI.backgroundColor = Color.blue;
        }
        if (GUILayout.Button("Save", GUILayout.Width(50)))
        {
            SaveSelectTable();
            GUI.FocusControl("ForFouce");
        }
        GUI.backgroundColor = tmp_color;

        for (int i = 0; i < mSelectionTable.mColumnCount; i++)
        {
            if (i < (mCurrentColumnPage - 1) * mPageColumnCount || i > mCurrentColumnPage * mPageColumnCount - 1)
            {
                if (i != 0)
                {
                    continue;
                }
            }
            if (GUILayout.Button("<--"))
            {
                mSelectionTable.MoveColumnLeft(i);
                mIsModify = true;
                GUI.FocusControl("ForFouce");
                break;
            }
            if (GUILayout.Button("-->"))
            {
                mSelectionTable.MoveColumnRight(i);
                mIsModify = true;
                GUI.FocusControl("ForFouce");
                break;
            }
        }
        if (GUILayout.Button(" ", GUILayout.Width(30)))
        {
        }
        GUILayout.EndHorizontal(); //3A-



        //+ - buttons
        GUILayout.BeginHorizontal(); //3A+

        tmp_color = GUI.backgroundColor;

        if (mIsModify)
        {
            GUI.backgroundColor = Color.yellow;
        }
        if (GUILayout.Button("Revert", GUILayout.Width(50)))
        {
            //ShowTableData(mSelectionIndex);
            SetAsset(mSelectionAsset);
            mIsModify = false;
            GUI.FocusControl("ForFouce");
        }
        GUI.backgroundColor = tmp_color;

        for (int i = 0; i < mSelectionTable.mColumnCount; i++)
        {
            if (i < (mCurrentColumnPage - 1) * mPageColumnCount || i > mCurrentColumnPage * mPageColumnCount - 1)
            {
                if (i != 0)
                {
                    continue;
                }
            }
            if (GUILayout.Button("+ " + i.ToString()))
            {
                mSelectionTable.InsertColumn(i);
                GUI.FocusControl("ForFouce");
                mIsModify = true;
                break;
            }
            if (GUILayout.Button("-"))
            {
                mSelectionTable.DeleteColumn(i);
                GUI.FocusControl("ForFouce");
                mIsModify = true;
                break;
            }
        }
        if (GUILayout.Button("+", GUILayout.Width(30)))
        {
            mSelectionTable.InsertColumn(mSelectionTable.mColumnCount);
            GUI.FocusControl("ForFouce");
            mIsModify = true;
        }
        GUILayout.EndHorizontal(); //3A-

        //first line
        tmp_color           = GUI.backgroundColor;
        GUI.backgroundColor = mFormHeadColor;

        GUILayout.BeginHorizontal(); //3B+
        if (GUILayout.Button("", GUILayout.Width(50)))
        {
        }
        for (int i = 0; i < mSelectionTable.mColumnCount; i++)
        {
            if (i < (mCurrentColumnPage - 1) * mPageColumnCount || i > mCurrentColumnPage * mPageColumnCount - 1)
            {
                if (i != 0)
                {
                    continue;
                }
            }
            tmp_string = mSelectionTable.mData[i][0];
            mSelectionTable.mData[i][0] = EditorGUILayout.TextField(mSelectionTable.mData[i][0]);
            if (tmp_string != mSelectionTable.mData[i][0])
            {
                mIsModify = true;
            }
        }
        if (GUILayout.Button("", GUILayout.Width(30)))
        {
        }
        GUILayout.EndHorizontal(); //3B-
        GUI.backgroundColor = tmp_color;

        //all
        mFormDataScroll = GUILayout.BeginScrollView(mFormDataScroll, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));//3C+

        for (int j = 0; j < mSelectionTable.mRowCount; j++)
        {
            if (j < (mCurrentRowPage - 1) * mPageRowCount || j > mCurrentRowPage * mPageRowCount - 1)
            {
                if (j != 0)
                {
                    continue;
                }
            }

            if (j % 2 == 0)
            {
                GUI.backgroundColor = mFormColor1;
            }
            else
            {
                GUI.backgroundColor = mFormColor2;
            }
            if (j == 0)
            {
                GUI.backgroundColor = mFormFirstRow;
            }

            GUILayout.BeginHorizontal(); //3D+
            if (GUILayout.Button(j.ToString(), GUILayout.Width(50), GUILayout.Height(20)))
            {
                mSelectionTable.InsertRow(j);
                mIsModify = true;
            }
            for (int i = 0; i < mSelectionTable.mColumnCount; i++)
            {
                if (i < (mCurrentColumnPage - 1) * mPageColumnCount || i > mCurrentColumnPage * mPageColumnCount - 1)
                {
                    if (i != 0)
                    {
                        continue;
                    }
                }

                tmp_string = mSelectionTable.mData[i][j];
                Color tmp_color_2 = GUI.backgroundColor;
                if (tmp_string.Contains(mSearchString) && mSearchString != "")
                {
                    GUI.backgroundColor = mSearchColor;
                }

                mSelectionTable.mData[i][j] = EditorGUILayout.TextField(mSelectionTable.mData[i][j], GetTextField(), GUILayout.Height(20));
                if (tmp_string != mSelectionTable.mData[i][j])
                {
                    mIsModify = true;
                }
                GUI.backgroundColor = tmp_color_2;
            }
            if (GUILayout.Button("-", GUILayout.Width(30), GUILayout.Height(20)))
            {
                mSelectionTable.DeleteRow(j);
                GUI.FocusControl("ForFouce");
                mIsModify = true;
            }
            GUILayout.EndHorizontal(); //3D-

            GUI.backgroundColor = tmp_color;
        }

        if (GUILayout.Button("+", GUILayout.Width(50), GUILayout.Height(20)))
        {
            mSelectionTable.InsertRow(mSelectionTable.mRowCount);
            GUI.FocusControl("ForFouce");
            mIsModify = true;
        }

        GUILayout.EndScrollView();//3C-
    }