void Start() { // tell the scroller that this script will be its delegate _data = new List <NFRecordRowData>(); mkernelModule.RegisterClassCallBack(NFrame.Player.ThisName, OnClassPlayerEventHandler); //generally speaking, this object will be created after the player login (be created) //as a result, we must add the data when the UI object creating to show the data at the UI. if (!group) { xGUID = mLoginModule.mRoleID; } else { xGUID = new NFGUID(); } { NFIRecord xRecord = mkernelModule.FindRecord(mLoginModule.mRoleID, recordName); if (xRecord != null) { mkernelModule.RegisterRecordCallback(mLoginModule.mRoleID, recordName, RecordEventHandler); for (int i = 0; i < xRecord.GetRows(); ++i) { if (xRecord.IsUsed(i)) { RecordEventHandler(mLoginModule.mRoleID, recordName, NFIRecord.ERecordOptype.Add, i, 0, null, null); } } } else { Debug.LogError("no this record " + recordName); } } // load in a large set of data //LoadData(); }
public void SetData(NFGUID xGUID, string strRecordName, NFRecordController xController, NFRecordRowData xData) { data = xData; controller = xController; if (data != null) { foreach (KeyValuePair <int, NFRecordColView> entry in colViewList) { NFIRecord xRecord = mkernelModule.FindRecord(xGUID, strRecordName); entry.Value.Refresh(xGUID, xRecord.QueryRowCol(data.row, entry.Key)); } xController.UpdateEvent(xData.id, xData.recordName, xData.row, this); } }
void PropertyEventHandler(NFGUID self, string strProperty, NFDataList.TData oldVar, NFDataList.TData newVar) { NFIProperty xProperty = mkernelModule.FindProperty(self, propertyName); NFDataList.TData data = xProperty.GetData(); switch (type) { case ViewType.ITEM_CNFID_ICON: { Image xImage = gameObject.GetComponent <Image> (); if (xImage != null) { string strIconName = mElementModule.QueryPropertyString(data.ToString(), NFrame.Item.Icon); string strIconFileName = mElementModule.QueryPropertyString(data.ToString(), NFrame.Item.SpriteFile); Sprite xSprite = null; //NFTexturePacker.Instance.GetSprit(strIconFileName, strIconName); if (xSprite != null) { xImage.overrideSprite = xSprite; if (xImage.sprite == null) { xImage.enabled = false; } else { xImage.enabled = true; } } } } break; case ViewType.HERO_GUID_ICON: { Image xImage = gameObject.GetComponent <Image> (); if (xImage != null) { NFIRecord xRecord = mkernelModule.FindRecord(self, NFrame.Player.PlayerHero.ThisName); int nRow = xRecord.FindObject((int)NFrame.Player.PlayerHero.GUID, data.ObjectVal()); if (nRow >= 0) { string strCnfID = xRecord.QueryString(nRow, (int)NFrame.Player.PlayerHero.ConfigID); string strIconName = mElementModule.QueryPropertyString(strCnfID, NFrame.Item.Icon); string strIconFileName = mElementModule.QueryPropertyString(strCnfID, NFrame.Item.SpriteFile); Sprite xSprite = null; //NFTexturePacker.Instance.GetSprit (strIconFileName, strIconName); if (xSprite != null) { xImage.overrideSprite = xSprite; if (xImage.sprite == null) { xImage.enabled = false; } else { xImage.enabled = true; } } } else { xImage.enabled = false; } } } break; case ViewType.NPC_CNFID_ICON: { Image xImage = gameObject.GetComponent <Image> (); if (xImage != null) { string strCnfID = data.StringVal(); string strIconName = mElementModule.QueryPropertyString(strCnfID, NFrame.NPC.Icon); string strIconFileName = mElementModule.QueryPropertyString(strCnfID, NFrame.NPC.SpriteFile); Sprite xSprite = null; //NFTexturePacker.Instance.GetSprit (strIconFileName, strIconName); if (xSprite != null) { xImage.overrideSprite = xSprite; if (xImage.sprite == null) { xImage.enabled = false; } else { xImage.enabled = true; } } } } break; case ViewType.SKILL_CNFID_ICON: { Image xImage = gameObject.GetComponent <Image> (); if (xImage != null) { string strIconName = mElementModule.QueryPropertyString(propertyName, NFrame.Skill.Icon); string strIconFileName = mElementModule.QueryPropertyString(propertyName, NFrame.Skill.SpriteFile); Sprite xSprite = null; //NFTexturePacker.Instance.GetSprit (strIconFileName, strIconName); if (xSprite != null) { xImage.overrideSprite = xSprite; if (xImage.sprite == null) { xImage.enabled = false; } else { xImage.enabled = true; } } } } break; default: { Text xText = gameObject.GetComponent <Text> (); if (xText != null) { xText.text = data.ToString(); if (xText.text == "0" || xText.text.Length <= 0) { //xText.enabled = false; } } } break; } }
public void Refresh(NFGUID self, NFDataList.TData data) { switch (type) { case ViewType.ITEM_CNFID_ICON: { Image xImage = gameObject.GetComponent <Image> (); if (xImage != null) { string strIconName = mElementModule.QueryPropertyString(data.ToString(), NFrame.Item.Icon); string strIconFileName = mElementModule.QueryPropertyString(data.ToString(), NFrame.Item.SpriteFile); Sprite xSprite = null; // = NFTexturePacker.Instance.GetSprit(strIconFileName, strIconName); if (xSprite != null) { xImage.overrideSprite = xSprite; if (xImage.sprite == null) { xImage.enabled = false; } else { xImage.enabled = true; } } } } break; case ViewType.HERO_GUID_ICON: { Image xImage = gameObject.GetComponent <Image> (); if (xImage != null) { NFIRecord xRecord = mkernelModule.FindRecord(self, NFrame.Player.PlayerHero.ThisName); int nRow = xRecord.FindObject((int)NFrame.Player.PlayerHero.GUID, data.ObjectVal()); if (nRow >= 0) { string strCnfID = xRecord.QueryString(nRow, (int)NFrame.Player.PlayerHero.ConfigID); string strIconName = mElementModule.QueryPropertyString(strCnfID, NFrame.Item.Icon); string strIconFileName = mElementModule.QueryPropertyString(strCnfID, NFrame.Item.SpriteFile); Sprite xSprite = null; //= NFTexturePacker.Instance.GetSprit (strIconFileName, strIconName); if (xSprite != null) { xImage.overrideSprite = xSprite; if (xImage.sprite == null) { xImage.enabled = false; } else { xImage.enabled = true; } } } else { xImage.enabled = false; } } } break; case ViewType.NPC_CNFID_ICON: { } break; default: { Text xText = gameObject.GetComponent <Text> (); if (xText != null) { xText.text = data.ToString(); } } break; } }