private void AttachObjectData(NFGUID self) { //Debug.Log ("AttachObjectData : " + self.ToString () ); ObjectDataBuff xDataBuff; if (mxObjectDataBuff.TryGetValue(self, out xDataBuff)) { ////////////////record if (xDataBuff.xRecordList != null) { for (int j = 0; j < xDataBuff.xRecordList.RecordList.Count; j++) { NFMsg.ObjectRecordBase xObjectRecordBase = xDataBuff.xRecordList.RecordList[j]; string srRecordName = xObjectRecordBase.RecordName.ToStringUtf8(); for (int k = 0; k < xObjectRecordBase.RowStruct.Count; ++k) { NFMsg.RecordAddRowStruct xAddRowStruct = xObjectRecordBase.RowStruct[k]; ADD_ROW(self, xObjectRecordBase.RecordName.ToStringUtf8(), xAddRowStruct); } } xDataBuff.xRecordList = null; } ////////////////property if (xDataBuff.xPropertyList != null) { /// NFIObject go = mKernelModule.GetObject(mHelpModule.PBToNF(xDataBuff.xPropertyList.PlayerId)); NFIPropertyManager xPropertyManager = go.GetPropertyManager(); for (int j = 0; j < xDataBuff.xPropertyList.PropertyIntList.Count; j++) { string strPropertyName = xDataBuff.xPropertyList.PropertyIntList[j].PropertyName.ToStringUtf8(); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_INT); xProperty = xPropertyManager.AddProperty(strPropertyName, var); } //string className = mKernelModule.QueryPropertyString(self, NFrame.IObject.ClassName); //Debug.LogError (self.ToString() + " " + className + " " + strPropertyName + " : " + xDataBuff.xPropertyList.property_int_list[j].Data); xProperty.SetInt(xDataBuff.xPropertyList.PropertyIntList[j].Data); } for (int j = 0; j < xDataBuff.xPropertyList.PropertyFloatList.Count; j++) { string strPropertyName = xDataBuff.xPropertyList.PropertyFloatList[j].PropertyName.ToStringUtf8(); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_FLOAT); xProperty = xPropertyManager.AddProperty(strPropertyName, var); } xProperty.SetFloat(xDataBuff.xPropertyList.PropertyFloatList[j].Data); } for (int j = 0; j < xDataBuff.xPropertyList.PropertyStringList.Count; j++) { string strPropertyName = xDataBuff.xPropertyList.PropertyStringList[j].PropertyName.ToStringUtf8(); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_STRING); xProperty = xPropertyManager.AddProperty(strPropertyName, var); } //string className = mKernelModule.QueryPropertyString(self, NFrame.IObject.ClassName); //Debug.LogError(self.ToString() + " " + className + " " + strPropertyName + " : " + xDataBuff.xPropertyList.property_string_list[j].Data.ToStringUtf8()); xProperty.SetString(xDataBuff.xPropertyList.PropertyStringList[j].Data.ToStringUtf8()); } for (int j = 0; j < xDataBuff.xPropertyList.PropertyObjectList.Count; j++) { string strPropertyName = xDataBuff.xPropertyList.PropertyObjectList[j].PropertyName.ToStringUtf8(); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_OBJECT); xProperty = xPropertyManager.AddProperty(strPropertyName, var); } xProperty.SetObject(mHelpModule.PBToNF(xDataBuff.xPropertyList.PropertyObjectList[j].Data)); } for (int j = 0; j < xDataBuff.xPropertyList.PropertyVector2List.Count; j++) { string strPropertyName = xDataBuff.xPropertyList.PropertyVector2List[j].PropertyName.ToStringUtf8(); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_VECTOR2); xProperty = xPropertyManager.AddProperty(strPropertyName, var); } xProperty.SetVector2(mHelpModule.PBToNF(xDataBuff.xPropertyList.PropertyVector2List[j].Data)); } for (int j = 0; j < xDataBuff.xPropertyList.PropertyVector3List.Count; j++) { string strPropertyName = xDataBuff.xPropertyList.PropertyVector3List[j].PropertyName.ToStringUtf8(); NFIProperty xProperty = xPropertyManager.GetProperty(strPropertyName); if (null == xProperty) { NFDataList.TData var = new NFDataList.TData(NFDataList.VARIANT_TYPE.VTYPE_VECTOR3); xProperty = xPropertyManager.AddProperty(strPropertyName, var); } xProperty.SetVector3(mHelpModule.PBToNF(xDataBuff.xPropertyList.PropertyVector3List[j].Data)); } xDataBuff.xPropertyList = null; } } }
public void RequireAddRow(NFGUID objectID, string strRecordName, int nRow) { NFMsg.ObjectRecordAddRow xData = new NFMsg.ObjectRecordAddRow(); xData.PlayerId = mHelpModule.NFToPB(objectID); xData.RecordName = ByteString.CopyFromUtf8(strRecordName); NFMsg.RecordAddRowStruct xRecordAddRowStruct = new NFMsg.RecordAddRowStruct(); xData.RowData.Add(xRecordAddRowStruct); xRecordAddRowStruct.Row = nRow; NFIObject xObject = mKernelModule.GetObject(objectID); NFIRecord xRecord = xObject.GetRecordManager().GetRecord(strRecordName); NFDataList xRowData = xRecord.QueryRow(nRow); for (int i = 0; i < xRowData.Count(); i++) { switch (xRowData.GetType(i)) { case NFDataList.VARIANT_TYPE.VTYPE_INT: { NFMsg.RecordInt xRecordInt = new NFMsg.RecordInt(); xRecordInt.Row = nRow; xRecordInt.Col = i; xRecordInt.Data = xRowData.IntVal(i); xRecordAddRowStruct.RecordIntList.Add(xRecordInt); } break; case NFDataList.VARIANT_TYPE.VTYPE_FLOAT: { NFMsg.RecordFloat xRecordFloat = new NFMsg.RecordFloat(); xRecordFloat.Row = nRow; xRecordFloat.Col = i; xRecordFloat.Data = (float)xRowData.FloatVal(i); xRecordAddRowStruct.RecordFloatList.Add(xRecordFloat); } break; case NFDataList.VARIANT_TYPE.VTYPE_STRING: { NFMsg.RecordString xRecordString = new NFMsg.RecordString(); xRecordString.Row = nRow; xRecordString.Col = i; xRecordString.Data = ByteString.CopyFromUtf8(xRowData.StringVal(i)); xRecordAddRowStruct.RecordStringList.Add(xRecordString); } break; case NFDataList.VARIANT_TYPE.VTYPE_OBJECT: { NFMsg.RecordObject xRecordObject = new NFMsg.RecordObject(); xRecordObject.Row = nRow; xRecordObject.Col = i; xRecordObject.Data = mHelpModule.NFToPB(xRowData.ObjectVal(i)); xRecordAddRowStruct.RecordObjectList.Add(xRecordObject); } break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR2: { NFMsg.RecordVector2 xRecordVector = new NFMsg.RecordVector2(); xRecordVector.Row = nRow; xRecordVector.Col = i; xRecordVector.Data = mHelpModule.NFToPB(xRowData.Vector2Val(i)); xRecordAddRowStruct.RecordVector2List.Add(xRecordVector); } break; case NFDataList.VARIANT_TYPE.VTYPE_VECTOR3: { NFMsg.RecordVector3 xRecordVector = new NFMsg.RecordVector3(); xRecordVector.Row = nRow; xRecordVector.Col = i; xRecordVector.Data = mHelpModule.NFToPB(xRowData.Vector3Val(i)); xRecordAddRowStruct.RecordVector3List.Add(xRecordVector); } break; } } mxBody.SetLength(0); xData.WriteTo(mxBody); Debug.Log("send upload record addRow"); SendMsg((int)NFMsg.EGameMsgID.AckAddRow, mxBody); }
public void OnGUI(NFIKernelModule kernel, int nHeight, int nWidth) { if (buttonLeft == null) { buttonLeft = GUI.skin.button; buttonLeft.alignment = TextAnchor.MiddleLeft; } int nElementWidth = 150; int nElementHeight = 20; GUI.color = Color.red; strInfo = GUI.TextField(new Rect(0, nHeight - 20, nElementWidth * 3f + 120, 20), strInfo); strCommand = GUI.TextField(new Rect(nElementWidth * 3f + 120, nHeight - 20, 350, 20), strCommand); if (GUI.Button(new Rect(nWidth - 100, nHeight - 20, 100, 20), "cmd")) { } GUI.color = Color.white; NFIDataList objectList = kernel.GetObjectList(); scrollPositionFirst = GUI.BeginScrollView(new Rect(0, nElementHeight, nElementWidth / 2 + 20, nHeight), 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 = ""; } } GUI.EndScrollView(); //////////////// if(!xTargetIdent.IsNull()) { NFIObject go = kernel.GetObject(xTargetIdent); 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 + 20, nElementHeight, nElementWidth+20, nHeight/2), scrollPositionSecond, new Rect(0, 0, nElementWidth, (nAllElement+1) * (nElementHeight) + 1)); int nElementIndex = 0; GUI.Button(new Rect(0, nElementIndex*nElementHeight, nElementWidth, nElementHeight), xTargetIdent.nData64.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 * 1.5f + 40, nElementHeight, nElementWidth * 2, 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(); } } } }