Esempio n. 1
0
        private void ADD_ROW(NFGUID self, string strRecordName, NFMsg.RecordAddRowStruct xAddStruct)
        {
            NFIObject        go             = NFCKernelModule.Instance().GetObject(self);
            NFIRecordManager xRecordManager = go.GetRecordManager();


            Hashtable recordVecDesc = new Hashtable();
            Hashtable recordVecData = new Hashtable();

            for (int k = 0; k < xAddStruct.record_int_list.Count; ++k)
            {
                NFMsg.RecordInt addIntStruct = (NFMsg.RecordInt)xAddStruct.record_int_list[k];

                if (addIntStruct.col >= 0)
                {
                    recordVecDesc[addIntStruct.col] = NFIDataList.VARIANT_TYPE.VTYPE_INT;
                    recordVecData[addIntStruct.col] = addIntStruct.data;
                }
            }

            for (int k = 0; k < xAddStruct.record_float_list.Count; ++k)
            {
                NFMsg.RecordFloat addFloatStruct = (NFMsg.RecordFloat)xAddStruct.record_float_list[k];

                if (addFloatStruct.col >= 0)
                {
                    recordVecDesc[addFloatStruct.col] = NFIDataList.VARIANT_TYPE.VTYPE_FLOAT;
                    recordVecData[addFloatStruct.col] = addFloatStruct.data;
                }
            }

            for (int k = 0; k < xAddStruct.record_string_list.Count; ++k)
            {
                NFMsg.RecordString addStringStruct = (NFMsg.RecordString)xAddStruct.record_string_list[k];

                if (addStringStruct.col >= 0)
                {
                    recordVecDesc[addStringStruct.col] = NFIDataList.VARIANT_TYPE.VTYPE_STRING;
                    recordVecData[addStringStruct.col] = System.Text.Encoding.Default.GetString(addStringStruct.data);
                }
            }

            for (int k = 0; k < xAddStruct.record_object_list.Count; ++k)
            {
                NFMsg.RecordObject addObjectStruct = (NFMsg.RecordObject)xAddStruct.record_object_list[k];

                if (addObjectStruct.col >= 0)
                {
                    recordVecDesc[addObjectStruct.col] = NFIDataList.VARIANT_TYPE.VTYPE_OBJECT;
                    recordVecData[addObjectStruct.col] = PBToNF(addObjectStruct.data);
                }
            }

            NFIDataList varListDesc = new NFCDataList();
            NFIDataList varListData = new NFCDataList();

            for (int m = 0; m < recordVecDesc.Count; m++)
            {
                if (recordVecDesc.ContainsKey(m) && recordVecData.ContainsKey(m))
                {
                    NFIDataList.VARIANT_TYPE nType = (NFIDataList.VARIANT_TYPE)recordVecDesc[m];
                    switch (nType)
                    {
                    case NFIDataList.VARIANT_TYPE.VTYPE_INT:
                    {
                        varListDesc.AddInt(0);
                        varListData.AddInt((Int64)recordVecData[m]);
                    }

                    break;

                    case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT:
                    {
                        varListDesc.AddFloat(0.0f);
                        varListData.AddFloat((float)recordVecData[m]);
                    }
                    break;

                    case NFIDataList.VARIANT_TYPE.VTYPE_STRING:
                    {
                        varListDesc.AddString("");
                        varListData.AddString((string)recordVecData[m]);
                    }
                    break;

                    case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT:
                    {
                        varListDesc.AddObject(new NFGUID());
                        varListData.AddObject((NFGUID)recordVecData[m]);
                    }
                    break;

                    default:
                        break;
                    }
                }
                else
                {
                    //报错
                    //Debug.LogException(i);
                }
            }

            NFIRecord xRecord = xRecordManager.GetRecord(strRecordName);

            if (null == xRecord)
            {
                xRecord = xRecordManager.AddRecord(strRecordName, 512, varListDesc);
            }

            xRecord.AddRow(xAddStruct.row, varListData);
        }
Esempio n. 2
0
        public override NFIObject CreateObject(NFGUID self, int nContainerID, int nGroupID, string strClassName, string strConfigIndex, NFIDataList arg)
        {
            if (!mhtObject.ContainsKey(self))
            {
                NFIObject xNewObject = new NFCObject(self, nContainerID, nGroupID, strClassName, strConfigIndex);
                mhtObject.Add(self, xNewObject);

                NFCDataList varConfigID = new NFCDataList();
                varConfigID.AddString(strConfigIndex);
                xNewObject.GetPropertyManager().AddProperty("ConfigID", varConfigID);

                NFCDataList varConfigClass = new NFCDataList();
                varConfigClass.AddString(strClassName);
                xNewObject.GetPropertyManager().AddProperty("ClassName", varConfigClass);

                if (arg.Count() % 2 == 0)
                {
                    for (int i = 0; i < arg.Count() - 1; i += 2)
                    {
                        string strPropertyName         = arg.StringVal(i);
                        NFIDataList.VARIANT_TYPE eType = arg.GetType(i + 1);
                        switch (eType)
                        {
                        case NFIDataList.VARIANT_TYPE.VTYPE_INT:
                        {
                            NFIDataList xDataList = new NFCDataList();
                            xDataList.AddInt(arg.IntVal(i + 1));
                            xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList);
                        }
                        break;

                        case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT:
                        {
                            NFIDataList xDataList = new NFCDataList();
                            xDataList.AddFloat(arg.FloatVal(i + 1));
                            xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList);
                        }
                        break;

                        case NFIDataList.VARIANT_TYPE.VTYPE_DOUBLE:
                        {
                            NFIDataList xDataList = new NFCDataList();
                            xDataList.AddDouble(arg.DoubleVal(i + 1));
                            xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList);
                        }
                        break;

                        case NFIDataList.VARIANT_TYPE.VTYPE_STRING:
                        {
                            NFIDataList xDataList = new NFCDataList();
                            xDataList.AddString(arg.StringVal(i + 1));
                            xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList);
                        }
                        break;

                        case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT:
                        {
                            NFIDataList xDataList = new NFCDataList();
                            xDataList.AddObject(arg.ObjectVal(i + 1));
                            xNewObject.GetPropertyManager().AddProperty(strPropertyName, xDataList);
                        }
                        break;

                        default:
                            break;
                        }
                    }
                }

                InitProperty(self, strClassName);
                InitRecord(self, strClassName);

                ClassHandleDel xHandleDel = (ClassHandleDel)mhtClassHandleDel[strClassName];
                if (null != xHandleDel && null != xHandleDel.GetHandler())
                {
                    NFIObject.ClassEventHandler xHandlerList = xHandleDel.GetHandler();
                    xHandlerList(self, nContainerID, nGroupID, NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE, strClassName, strConfigIndex);
                    xHandlerList(self, nContainerID, nGroupID, NFIObject.CLASS_EVENT_TYPE.OBJECT_LOADDATA, strClassName, strConfigIndex);
                    xHandlerList(self, nContainerID, nGroupID, NFIObject.CLASS_EVENT_TYPE.OBJECT_CREATE_FINISH, strClassName, strConfigIndex);
                }

                //NFCLog.Instance.Log(NFCLog.LOG_LEVEL.DEBUG, "Create object: " + self.ToString() + " ClassName: " + strClassName + " SceneID: " + nContainerID + " GroupID: " + nGroupID);
                return(xNewObject);
            }

            return(null);
        }
    public void OnGUI(NFIKernelModule kernel, int nHeight, int nWidth)
    {
        if (buttonLeft == null)
        {
            buttonLeft = GUI.skin.button;

            buttonLeft.alignment = TextAnchor.MiddleLeft;
        }


        int nElementWidth  = 300;
        int nElementHeight = 20;

        GUI.color  = Color.red;
        strInfo    = GUI.TextField(new Rect(0, nHeight - 20, nElementWidth, 20), strInfo);
        strCommand = GUI.TextField(new Rect(nElementWidth, nHeight - 20, 350, 20), strCommand);
        if (GUI.Button(new Rect(nElementWidth + 350, nHeight - 20, 100, 20), "cmd"))
        {
        }
        GUI.color = Color.white;


        NFIDataList objectList = kernel.GetObjectList();

        scrollPositionFirst = GUI.BeginScrollView(new Rect(0, nElementHeight, nElementWidth / 2 + 20, nHeight - 100), scrollPositionFirst, new Rect(0, 0, nElementWidth, objectList.Count() * (nElementHeight)));


        //all object
        for (int i = 0; i < objectList.Count(); i++)
        {
            NFGUID ident = objectList.ObjectVal(i);

            if (GUI.Button(new Rect(0, i * nElementHeight, nElementWidth, nElementHeight), ident.nHead64.ToString() + "_" + ident.nData64.ToString()))
            {
                xTargetIdent = ident;
                strTableName = "";
                strInfo      = ident.ToString();
            }
        }

        GUI.EndScrollView();

        ////////////////
        if (!xTargetIdent.IsNull())
        {
            NFIObject go = kernel.GetObject(xTargetIdent);
            if (null != go)
            {
                NFIDataList recordLlist  = go.GetRecordManager().GetRecordList();
                NFIDataList propertyList = go.GetPropertyManager().GetPropertyList();

                int nAllElement = 1;
                for (int j = 0; j < recordLlist.Count(); j++)
                {
                    string strRecordName = recordLlist.StringVal(j);
                    if (strRecordName.Length > 0)
                    {
                        nAllElement++;
                    }
                }
                for (int j = 0; j < propertyList.Count(); j++)
                {
                    string strPropertyName = propertyList.StringVal(j);
                    if (strPropertyName.Length > 0)
                    {
                        nAllElement++;
                    }
                }
                //////////////////
                scrollPositionSecond = GUI.BeginScrollView(new Rect(nElementWidth / 2 + 25, nElementHeight, nElementWidth / 2 + 25, nHeight - 100), scrollPositionSecond, new Rect(0, 0, nElementWidth, (nAllElement + 1) * (nElementHeight) + 1));

                int nElementIndex = 0;
                GUI.Button(new Rect(0, nElementIndex * nElementHeight, nElementWidth, nElementHeight), xTargetIdent.ToString());
                nElementIndex++;
                //all record
                for (int j = 0; j < recordLlist.Count(); j++)
                {
                    string strRecordName = recordLlist.StringVal(j);
                    if (strRecordName.Length > 0)
                    {
                        if (GUI.Button(new Rect(0, nElementIndex * nElementHeight, nElementWidth, nElementHeight), "++" + strRecordName))
                        {
                            strTableName = strRecordName;
                        }

                        nElementIndex++;
                    }
                }


                ///////////////////////////////
                //all property


                for (int k = 0; k < propertyList.Count(); k++)
                {
                    string      strPropertyValue   = null;
                    string      strPropertyName    = propertyList.StringVal(k);
                    NFIProperty property           = go.GetPropertyManager().GetProperty(strPropertyName);
                    NFIDataList.VARIANT_TYPE eType = property.GetType();
                    switch (eType)
                    {
                    case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT:
                        strPropertyValue = property.QueryFloat().ToString();
                        break;

                    case NFIDataList.VARIANT_TYPE.VTYPE_INT:
                        strPropertyValue = property.QueryInt().ToString();
                        break;

                    case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT:
                        strPropertyValue = property.QueryObject().nData64.ToString();
                        break;

                    case NFIDataList.VARIANT_TYPE.VTYPE_STRING:
                        strPropertyValue = property.QueryString();
                        break;

                    default:
                        strPropertyValue = "?";
                        break;
                    }

                    if (strPropertyName.Length > 0)
                    {
                        if (GUI.Button(new Rect(0, nElementIndex * nElementHeight, nElementWidth, nElementHeight), strPropertyName + ":" + strPropertyValue))
                        {
                            strTableName = "";
                            strInfo      = strPropertyName + ":" + strPropertyValue;
                        }
                        nElementIndex++;
                    }
                }


                GUI.EndScrollView();
                ////////////////////////


                if (strTableName.Length > 0)
                {
                    NFIRecord record = go.GetRecordManager().GetRecord(strTableName);
                    if (null != record)
                    {
                        int nRow    = record.GetRows();
                        int nCol    = record.GetCols();
                        int nOffest = 30;

                        scrollPositionThird = GUI.BeginScrollView(new Rect(nElementWidth + 50, nElementHeight, nElementWidth * 3, nHeight / 2), scrollPositionThird, new Rect(0, 0, nElementWidth * nCol + nOffest, nRow * nElementHeight + nOffest));


                        string selString = null;


                        for (int row = 0; row < nRow; row++)
                        {
                            GUI.Button(new Rect(0, row * nElementHeight + nOffest, nOffest, nElementHeight), row.ToString());                        //row
                            for (int col = 0; col < nCol; col++)
                            {
                                if (0 == row)
                                {
                                    GUI.Button(new Rect(col * nElementWidth + nOffest, 0, nElementWidth, nElementHeight), col.ToString() + "  [" + record.GetColType(col) + "]");
                                }

                                if (record.IsUsed(row))
                                {
                                    NFIDataList.VARIANT_TYPE eType = record.GetColType(col);
                                    switch (eType)
                                    {
                                    case NFIDataList.VARIANT_TYPE.VTYPE_INT:
                                        selString = record.QueryInt(row, col).ToString();
                                        break;

                                    case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT:
                                        selString = record.QueryFloat(row, col).ToString();
                                        break;

                                    case NFIDataList.VARIANT_TYPE.VTYPE_STRING:
                                        selString = record.QueryString(row, col).ToString();
                                        break;

                                    case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT:
                                        selString = record.QueryObject(row, col).nData64.ToString();
                                        break;

                                    default:
                                        selString = "UnKnowType";
                                        break;
                                    }
                                }
                                else
                                {
                                    selString = "NoUse";
                                }

                                if (GUI.Button(new Rect(col * nElementWidth + nOffest, row * nElementHeight + nOffest, nElementWidth, nElementHeight), selString))
                                {
                                    strInfo = "Row:" + row.ToString() + " Col:" + col.ToString() + " " + selString;
                                }
                            }
                        }

                        GUI.EndScrollView();
                    }
                }
            }
        }
    }
        private void LoadInstanceElement(NFILogicClass xLogicClass)
        {
            string strLogicPath = mstrRootPath;

            strLogicPath += xLogicClass.GetInstance();

            XmlDocument xmldoc = new XmlDocument();

            if (xLogicClass.GetEncrypt())
            {
                ///////////////////////////////////////////////////////////////////////////////////////
                StreamReader cepherReader = new StreamReader(strLogicPath);;
                string       strContent   = cepherReader.ReadToEnd();
                cepherReader.Close();

                byte[] data = Convert.FromBase64String(strContent);

                string res = System.Text.ASCIIEncoding.Default.GetString(data);

                xmldoc.LoadXml(res);
                /////////////////////////////////////////////////////////////////
            }
            else
            {
                xmldoc.Load(strLogicPath);
            }

            XmlNode xRoot = xmldoc.SelectSingleNode("XML");

            XmlNodeList xNodeList = xRoot.SelectNodes("Object");

            for (int i = 0; i < xNodeList.Count; ++i)
            {
                //NFCLog.Instance.Log("Class:" + xLogicClass.GetName());

                XmlNode      xNodeClass = xNodeList.Item(i);
                XmlAttribute strID      = xNodeClass.Attributes["Id"];

                //NFCLog.Instance.Log("ClassID:" + strID.Value);

                NFIElement xElement = GetElement(strID.Value);
                if (null == xElement)
                {
                    xElement = new NFCElement();
                    AddElement(strID.Value, xElement);
                    xLogicClass.AddConfigName(strID.Value);

                    XmlAttributeCollection xCollection = xNodeClass.Attributes;
                    for (int j = 0; j < xCollection.Count; ++j)
                    {
                        XmlAttribute xAttribute = xCollection[j];
                        NFIProperty  xProperty  = xLogicClass.GetPropertyManager().GetProperty(xAttribute.Name);
                        if (null != xProperty)
                        {
                            NFIDataList.VARIANT_TYPE eType = xProperty.GetType();
                            switch (eType)
                            {
                            case NFIDataList.VARIANT_TYPE.VTYPE_INT:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddInt(int.Parse(xAttribute.Value));
                                NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                property.SetUpload(xProperty.GetUpload());
                            }
                            break;

                            case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddFloat(float.Parse(xAttribute.Value));
                                NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                property.SetUpload(xProperty.GetUpload());
                            }
                            break;

                            case NFIDataList.VARIANT_TYPE.VTYPE_STRING:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddString(xAttribute.Value);
                                NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                property.SetUpload(xProperty.GetUpload());
                            }
                            break;

                            case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddObject(new NFGUID(0, int.Parse(xAttribute.Value)));
                                NFIProperty property = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                                property.SetUpload(xProperty.GetUpload());
                            }
                            break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        private void LoadInstanceElement(NFILogicClass xLogicClass)
        {
            string strLogicPath = mstrRootPath;

            strLogicPath += xLogicClass.GetInstance();

            XmlDocument xmldoc = new XmlDocument();

            xmldoc.Load(strLogicPath);

            XmlNode xRoot = xmldoc.SelectSingleNode("XML");

            XmlNodeList xNodeList = xRoot.SelectNodes("Object");

            for (int i = 0; i < xNodeList.Count; ++i)
            {
                //NFCLog.Instance.Log("Class:" + xLogicClass.GetName());

                XmlNode      xNodeClass = xNodeList.Item(i);
                XmlAttribute strID      = xNodeClass.Attributes["ID"];

                //NFCLog.Instance.Log("ClassID:" + strID.Value);

                NFIElement xElement = GetElement(strID.Value);
                if (null == xElement)
                {
                    xElement = new NFCElement();
                    AddElement(strID.Value, xElement);
                    xLogicClass.AddConfigName(strID.Value);

                    XmlAttributeCollection xCollection = xNodeClass.Attributes;
                    for (int j = 0; j < xCollection.Count; ++j)
                    {
                        XmlAttribute xAttribute = xCollection[j];
                        NFIProperty  xProperty  = xLogicClass.GetPropertyManager().GetProperty(xAttribute.Name);
                        if (null != xProperty)
                        {
                            NFIDataList.VARIANT_TYPE eType = xProperty.GetType();
                            switch (eType)
                            {
                            case NFIDataList.VARIANT_TYPE.VTYPE_INT:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddInt(int.Parse(xAttribute.Value));
                                xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                            }
                            break;

                            case NFIDataList.VARIANT_TYPE.VTYPE_FLOAT:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddFloat(float.Parse(xAttribute.Value));
                                xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                            }
                            break;

                            case NFIDataList.VARIANT_TYPE.VTYPE_DOUBLE:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddDouble(double.Parse(xAttribute.Value));
                                xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                            }
                            break;

                            case NFIDataList.VARIANT_TYPE.VTYPE_STRING:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddString(xAttribute.Value);
                                NFIProperty xTestProperty = xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                            }
                            break;

                            case NFIDataList.VARIANT_TYPE.VTYPE_OBJECT:
                            {
                                NFIDataList xValue = new NFCDataList();
                                xValue.AddObject(new NFIDENTID(0, int.Parse(xAttribute.Value)));
                                xElement.GetPropertyManager().AddProperty(xAttribute.Name, xValue);
                            }
                            break;

                            default:
                                break;
                            }
                        }
                    }
                }
            }
        }