Beispiel #1
0
    void OnGUI()
    {
        if (GUI.Button(new Rect(10, 50, 100, 50), "Save"))
        {
            //Set data by enum
            mForm.SetString(DateTime.Now.ToString(), "Value", "SAVE_TIME");
            mForm.SetBool(mIsTick, "Value", "IS_TICK");
            mForm.SetRect(mWindowRect, "Value", "WINDOW_RECT");
            Save();
        }

        GUI.Label(new Rect(10, 150, 100, 20), "RunTimes:");
        GUI.Label(new Rect(10, 180, 100, 20), "SaveTime:");
        GUI.Label(new Rect(10, 210, 100, 20), "Text1:");
        GUI.Label(new Rect(10, 240, 100, 20), "Text2:");
        GUI.Label(new Rect(10, 270, 100, 20), "IsTick:");

        GUI.Label(new Rect(110, 150, 100, 20), mForm.GetString("Value", "RUN_TIMES"));
        GUI.Label(new Rect(110, 180, 300, 20), mForm.GetString("Value", "SAVE_TIME"));

        //Read data and set data by id
        mForm.mData[1][3] = GUI.TextField(new Rect(110, 210, 300, 20), mForm.mData[1][3]);
        mForm.mData[1][4] = GUI.TextField(new Rect(110, 240, 300, 20), mForm.mData[1][4]);

        mIsTick = GUI.Toggle(new Rect(110, 270, 100, 20), mIsTick, "");

        mWindowRect = GUI.Window(0, mWindowRect, DoMyWindow, "Drag me and save");
    }
Beispiel #2
0
    public static string GetString(object key)
    {
        if (mForm == null)
        {
            mForm = OOFormArray.ReadFromResources("OOForm/Tables/StringTable");
        }

        return(mForm.GetString(mLanguage.ToString(), key));
    }
    void OnGUI()
    {
        Rect tmp_rect;

        if (mForm != null)
        {
            for (int i = 1; i < mForm.mRowCount; i++)
            {
                tmp_rect = mForm.GetRect("rect", i);

                if (GUI.Button(tmp_rect, mForm.GetString("name", i)))
                {
                    mForm.DeleteRow(i);
                    Save();
                    return;
                }
            }
        }
    }
Beispiel #4
0
    public static bool LoadFromCSVFile(string path, ref DataTable DT)
    {
        int DTColNum = DT.Columns.Count;

        OOFormArray form = new OOFormArray();

        form = OOFormArray.ReadFormCSVFile(path);
        int rowCnt = form.mRowCount;
        int colCnt = form.mColumnCount;

        //print("DTColNum" + DTColNum + " colCnt:" + colCnt + " rowCnt:" + rowCnt);

        if (DTColNum != colCnt)
        {
            print("Not Match!");
        }

        List <string> Keys      = new List <string>();
        bool          bSameKeys = true;

        for (int i = 0; i < colCnt; i++)
        {
            string key = form.GetString(i, 0);

            if (DT.Columns[i].ColumnName != key)
            {
                bSameKeys = false;
                break;
            }
            //print("ColumnName:" + DT.Columns[i].ColumnName + " Key:" + key);

            /* if(DT.Columns[i].ColumnName == key)
             * {
             *  print("Good Key:" + key);
             * }*/

            Keys.Add(key);
            //print("Key:" + key);
        }
        if (!bSameKeys)
        {
            return(false);
        }


        // read data
        for (int r = 1; r < rowCnt; r++)
        {
            DataRow dr = DT.NewRow();
            for (int c = 0; c < Keys.Count; c++)
            {
                System.Type tp = DT.Columns[c].DataType;
                if (tp == typeof(int))
                {
                    int val = form.GetInt(c, r);
                    dr[c] = val;
                    DebugPrint("Int:" + val);
                    // print("Set Int:" + val.ToString() + " OK?" + bSet.ToString());
                }
                else if (tp == typeof(Vector2))
                {
                    Vector2 val = form.GetVector2(c, r);
                    dr[c] = val;
                    DebugPrint("Vector2:" + val.ToString());
                }
                else if (tp == typeof(Vector3))
                {
                    Vector3 val = form.GetVector3(c, r);
                    dr[c] = val;
                    DebugPrint("Vector3:" + val.ToString());
                }
                else if (tp == typeof(Vector4))
                {
                    Vector4 val = form.GetVector4(c, r);
                    dr[c] = val;
                    DebugPrint("Vector4:" + val.ToString());
                }
                else if (tp == typeof(string))
                {
                    string val = form.GetString(c, r);
                    dr[c] = val;
                    DebugPrint("string:" + val);
                }
                else if (tp == typeof(float))
                {
                    float val = form.GetFloat(c, r);
                    dr[c] = val;
                    DebugPrint("float:" + val.ToString());
                }
                else if (tp == typeof(Rect))
                {
                    Rect val = form.GetRect(c, r);
                    dr[c] = val;
                    DebugPrint("Rect:" + val.ToString());
                }
                else if (tp == typeof(bool))
                {
                    bool val = form.GetBool(c, r);
                    dr[c] = val;
                    DebugPrint("Bool:" + val.ToString());
                }

                else
                {
                    DebugPrint("Invalid Datatype");
                }
            }
            DT.Rows.Add(dr);
            //PrintDataTable(DT);
        }
        int DTRowCnt =
            DT.Rows.Count;

        print("Load DataTable Rows:" + DTRowCnt.ToString());

        return(true);
    }