Exemplo n.º 1
0
    void RecordEventHandler(NFGUID self, string strRecordName, NFIRecord.ERecordOptype eType, int nRow, int nCol, NFDataList.TData oldVar, NFDataList.TData newVar)
    {
        if (ColValueCondition)
        {
            if (ColConditionNum >= 0 && ColConditionContent.Length > 0)
            {
                NFIRecord xRecord = mkernelModule.FindRecord(self, recordName);
                if (xRecord != null)
                {
                    if (xRecord.GetCols() > ColConditionNum)
                    {
                        switch (xRecord.GetColType(ColConditionNum))
                        {
                        case NFDataList.VARIANT_TYPE.VTYPE_INT:
                        {
                            long value = xRecord.QueryInt(nRow, ColConditionNum);
                            if (value.ToString() != ColConditionContent)
                            {
                                return;
                            }
                        }
                        break;

                        case NFDataList.VARIANT_TYPE.VTYPE_STRING:
                        {
                            string value = xRecord.QueryString(nRow, ColConditionNum);
                            if (value != ColConditionContent)
                            {
                                return;
                            }
                        }
                        break;

                        default:
                            break;
                        }
                    }
                }
            }
        }

        if (ColPropertyCondition)
        {
            if (ColConditionNum >= 0 && ColConditionPropertyName.Length > 0 && ColConditionPropertyValue.Length > 0)
            {
                NFIRecord xRecord = mkernelModule.FindRecord(self, recordName);
                if (xRecord != null)
                {
                    if (xRecord.GetCols() > ColConditionNum)
                    {
                        switch (xRecord.GetColType(ColConditionNum))
                        {
                        case NFDataList.VARIANT_TYPE.VTYPE_INT:
                        {
                            long       value    = xRecord.QueryInt(nRow, ColConditionNum);
                            NFIElement xElement = mElementModule.GetElement(value.ToString());
                            if (xElement == null)
                            {
                                Debug.LogError("Col:" + ColConditionNum.ToString() + " Value:" + value.ToString());
                                return;
                            }

                            NFIProperty xProperty = xElement.GetPropertyManager().GetProperty(ColConditionPropertyName);
                            if (xProperty == null)
                            {
                                Debug.LogError("Col:" + ColConditionNum.ToString() + " Value:" + value.ToString() + " Property:" + ColConditionPropertyName);
                                return;
                            }

                            if (xProperty.GetData() != null)
                            {
                                switch (xProperty.GetData().GetType())
                                {
                                case NFDataList.VARIANT_TYPE.VTYPE_INT:
                                {
                                    if (xProperty.QueryInt().ToString() != ColConditionPropertyValue)
                                    {
                                        return;
                                    }
                                }
                                break;

                                case NFDataList.VARIANT_TYPE.VTYPE_STRING:
                                {
                                    if (xProperty.QueryString() != ColConditionPropertyValue)
                                    {
                                        return;
                                    }
                                }
                                break;
                                }
                            }
                        }
                        break;

                        case NFDataList.VARIANT_TYPE.VTYPE_STRING:
                        {
                            string     value    = xRecord.QueryString(nRow, ColConditionNum);
                            NFIElement xElement = mElementModule.GetElement(value);
                            if (xElement == null)
                            {
                                Debug.LogError("Col:" + ColConditionNum.ToString() + " Value:" + value);
                                return;
                            }

                            NFIProperty xProperty = xElement.GetPropertyManager().GetProperty(ColConditionPropertyName);
                            if (xProperty == null)
                            {
                                Debug.LogError("Col:" + ColConditionNum.ToString() + " Value:" + value + " Property:" + ColConditionPropertyName);
                                return;
                            }

                            if (xProperty.GetData() != null)
                            {
                                switch (xProperty.GetData().GetType())
                                {
                                case NFDataList.VARIANT_TYPE.VTYPE_INT:
                                {
                                    if (xProperty.QueryInt().ToString() != ColConditionPropertyValue)
                                    {
                                        return;
                                    }
                                }
                                break;

                                case NFDataList.VARIANT_TYPE.VTYPE_STRING:
                                {
                                    if (xProperty.QueryString() != ColConditionPropertyValue)
                                    {
                                        return;
                                    }
                                }
                                break;
                                }
                            }
                        }
                        break;

                        default:
                            break;
                        }
                    }
                }
            }
        }

        switch (eType)
        {
        case NFIRecord.ERecordOptype.Add:
        {
            NFRecordRowData rowData = new NFRecordRowData();
            rowData.row        = nRow;
            rowData.recordName = strRecordName;
            rowData.id         = self;

            _data.Add(rowData);

            StartCoroutine(CreateObject(self, rowViewItem, rowData));
        }
        break;

        case NFIRecord.ERecordOptype.Del:
        {
            int nIndex = -1;
            for (int i = 0; i < _data.Count; ++i)
            {
                NFRecordRowData rowData = _data[i];
                if (rowData.row == nRow)
                {
                    nIndex = nRow;
                    break;
                }
            }

            if (nIndex >= 0)
            {
                _data.RemoveAt(nIndex);
            }

            NFRecordRowView[] rowViews = this.GetComponentsInChildren <NFRecordRowView>();
            for (int i = 0; i < rowViews.Length; ++i)
            {
                NFRecordRowData rowData = rowViews[i].GetData();
                if (rowData != null &&
                    rowData.row == nRow)
                {
                    GameObject.Destroy(rowViews[i].gameObject);
                    break;
                }
            }
        }
        break;

        case NFIRecord.ERecordOptype.Update:
        {
            NFRecordRowView[] rowViews = this.GetComponentsInChildren <NFRecordRowView>();
            for (int i = 0; i < rowViews.Length; ++i)
            {
                NFRecordRowData rowData = rowViews[i].GetData();
                if (rowData != null &&
                    rowData.row == nRow)
                {
                    rowViews[i].SetData(self, recordName, this, rowData);
                    break;
                }
            }
        }
        break;

        case NFIRecord.ERecordOptype.Create:
            break;

        case NFIRecord.ERecordOptype.Cleared:
            _data.Clear();
            break;

        default:
            break;
        }
    }
Exemplo n.º 2
0
        void RecordEventHandler(NFGUID self, string strRecordName, NFIRecord.ERecordOptype eType, int nRow, int nCol, NFDataList.TData oldVar, NFDataList.TData newVar)
        {
            switch (eType)
            {
            case NFIRecord.ERecordOptype.Add:
            {
                mNetModule.RequireAddRow(self, strRecordName, nRow);
            }
            break;

            case NFIRecord.ERecordOptype.Del:
            {
                mNetModule.RequireRemoveRow(self, strRecordName, nRow);
            }
            break;

            case NFIRecord.ERecordOptype.Update:
            {
                switch (newVar.GetType())
                {
                case NFDataList.VARIANT_TYPE.VTYPE_INT:
                {
                    mNetModule.RequireRecordInt(self, strRecordName, nRow, nCol, newVar);
                }
                break;

                case NFDataList.VARIANT_TYPE.VTYPE_FLOAT:
                {
                    mNetModule.RequireRecordFloat(self, strRecordName, nRow, nCol, newVar);
                }
                break;

                case NFDataList.VARIANT_TYPE.VTYPE_STRING:
                {
                    mNetModule.RequireRecordString(self, strRecordName, nRow, nCol, newVar);
                }
                break;

                case NFDataList.VARIANT_TYPE.VTYPE_OBJECT:
                {
                    mNetModule.RequireRecordObject(self, strRecordName, nRow, nCol, newVar);
                }
                break;

                case NFDataList.VARIANT_TYPE.VTYPE_VECTOR2:
                {
                    mNetModule.RequireRecordVector2(self, strRecordName, nRow, nCol, newVar);
                }
                break;

                case NFDataList.VARIANT_TYPE.VTYPE_VECTOR3:
                {
                    mNetModule.RequireRecordVector3(self, strRecordName, nRow, nCol, newVar);
                }
                break;

                default:
                    break;
                }
            }
            break;

            case NFIRecord.ERecordOptype.Create:
                break;

            case NFIRecord.ERecordOptype.Cleared:
            {
            }
            break;

            default:
                break;
            }
        }