Asunaya

Untitled

Jun 17th, 2018
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.11 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include "RAniEventInfo.h"
  3.  
  4. RAniNameEventSet* _RAniIDEventSet::GetAniNameEventSet(char* AnimationName)
  5. {
  6. for(m_AniIDEventSetIter = m_AniIDEventSet.begin(); m_AniIDEventSetIter != m_AniIDEventSet.end(); m_AniIDEventSetIter++)
  7. {
  8. if( strcmp( (*(m_AniIDEventSetIter))->GetAnimationName(), AnimationName) == 0)
  9. {
  10. return (*(m_AniIDEventSetIter));
  11. }
  12. }
  13. return NULL;
  14. }
  15.  
  16.  
  17. RAniIDEventSet* RAniEventMgr::GetAniIDEventSet(int id)
  18. {
  19. for(m_AniEventMgrIter = m_AniEventMgr.begin(); m_AniEventMgrIter != m_AniEventMgr.end() ; m_AniEventMgrIter++)
  20. {
  21. if( (*(m_AniEventMgrIter))->GetID() == id)
  22. {
  23. return (*(m_AniEventMgrIter));
  24. }
  25. }
  26. return NULL;
  27. }
  28.  
  29. bool RAniEventMgr::ReadXml(MZFileSystem* pFileSystem, const char* szFileName)
  30. {
  31.  
  32. MXmlDocument xmlIniData;
  33. xmlIniData.Create();
  34.  
  35. char *buffer;
  36. MZFile mzf;
  37.  
  38. if(pFileSystem) {
  39. if(!mzf.Open(szFileName,pFileSystem)) {
  40. if(!mzf.Open(szFileName)) {
  41. xmlIniData.Destroy();
  42. return false;
  43. }
  44. }
  45. }
  46. else {
  47.  
  48. if(!mzf.Open(szFileName)) {
  49.  
  50. xmlIniData.Destroy();
  51. return false;
  52. }
  53. }
  54.  
  55. buffer = new char[mzf.GetLength()+1];
  56. buffer[mzf.GetLength()] = 0;
  57.  
  58. mzf.Read(buffer,mzf.GetLength());
  59.  
  60. if(!xmlIniData.LoadFromMemory(buffer)) {
  61. xmlIniData.Destroy();
  62. return false;
  63. }
  64.  
  65. delete[] buffer;
  66. mzf.Close();
  67.  
  68.  
  69. MXmlElement rootElement, chrElement, attrElement;
  70. char szTagName[256];
  71.  
  72. rootElement = xmlIniData.GetDocumentElement();
  73. int iCount = rootElement.GetChildNodeCount();
  74.  
  75. for (int i = 0; i < iCount; i++) {
  76.  
  77. chrElement = rootElement.GetChildNode(i);
  78. chrElement.GetTagName(szTagName);
  79.  
  80. if (szTagName[0] == '#') continue;
  81.  
  82. if (!stricmp(szTagName, "NPC")) {
  83. char ID[256];
  84.  
  85. chrElement.GetAttribute(ID, "id");
  86. //¾Ö´Ï¸ÞÀÌ¼Ç ¾ÆÀ̵ð À̺¥Æ® ¼Â »ý¼º
  87. RAniIDEventSet * pAniIDEventSet = new RAniIDEventSet();
  88. pAniIDEventSet->SetID(atoi(ID));
  89. ParseAniEvent(&chrElement, pAniIDEventSet);
  90. //¾Ö´Ï¸ÞÀÌ¼Ç ¾ÆÀ̵ð À̺¥Æ® ¼ÂÀ» ¾Ö´Ï¸ÞÀÌ¼Ç À̺¥Æ® ¸Þ´ÏÀú¿¡ µî·ÏÇÑ´Ù.
  91. m_AniEventMgr.push_back(pAniIDEventSet);
  92. }
  93. }
  94.  
  95. xmlIniData.Destroy();
  96.  
  97. return true;
  98. }
  99.  
  100. void RAniEventMgr::ParseAniEvent(MXmlElement* PNode, RAniIDEventSet* pAnimIdEventSet)
  101. {
  102. char NodeName[256];
  103. char cAnimationName[256];
  104.  
  105. int nCnt = PNode->GetChildNodeCount();
  106.  
  107. MXmlElement Node;
  108.  
  109. for (int i=0; i<nCnt; i++)
  110. {
  111. Node = PNode->GetChildNode(i);
  112.  
  113. Node.GetTagName(NodeName);
  114.  
  115. if (NodeName[0] == '#') continue;
  116.  
  117. if (strcmp(NodeName, "Animation")==0)
  118. {
  119. Node.GetAttribute(cAnimationName, "name");
  120. //¾Ö´Ï¸ÞÀÌ¼Ç À̸§ À̺¥Æ® ¼Â »ý¼º
  121. RAniNameEventSet* pAniNameEventSet = new RAniNameEventSet();
  122. pAniNameEventSet->SetAnimationName(cAnimationName);
  123.  
  124. MXmlElement ChildNode;
  125. int nEventChiledCnt = Node.GetChildNodeCount(); //Â÷ÀÏµå ³ëµå °³¼ö Àоî¿Í¼­
  126. for(int i=0; i<nEventChiledCnt; i++) //ÆĽÌÇϱâ
  127. {
  128. char ChildNodeName[256];
  129. char ChildEventType[256];
  130. char ChildEventFileName[256];
  131. char ChildEventBeginFrame[256];
  132.  
  133. ChildNode = Node.GetChildNode(i);
  134. ChildNode.GetNodeName(ChildNodeName);
  135. if(strcmp(ChildNodeName, "AddAnimEvent")==0)
  136. {
  137. ChildNode.GetAttribute(ChildEventType, "eventtype");
  138. ChildNode.GetAttribute(ChildEventFileName, "filename");
  139. ChildNode.GetAttribute(ChildEventBeginFrame, "beginframe");
  140.  
  141. //¾Ö´Ï¸ÞÀÌ¼Ç À̺¥Æ® »ý¼º
  142. RAniEventInfo* AniEventInfo = new RAniEventInfo();
  143.  
  144. AniEventInfo->SetBeginFrame(atoi(ChildEventBeginFrame));
  145. AniEventInfo->SetEventType(ChildEventType);
  146. AniEventInfo->SetFileName(ChildEventFileName);
  147. //¾Ö´Ï¸ÞÀÌ¼Ç À̺¥Æ®¸¦ ¾Ö´Ï¸ÞÀÌ¼Ç À̸§ À̺¥Æ® ¼Â¿¡ Ãß°¡
  148. pAniNameEventSet->m_AniNameEventSet.push_back(AniEventInfo);
  149. }
  150. }
  151. //¾Ö´Ï¸ÞÀÌ¼Ç À̸§ À̺¥Æ® ¼ÂÀ» ¾Ö´Ï¸ÞÀÌ¼Ç ¾ÆÀ̵ð À̺¥Æ® ¼Â¿¡ Ãß°¡
  152. pAnimIdEventSet->m_AniIDEventSet.push_back(pAniNameEventSet);
  153. }
  154. }
  155. }
Add Comment
Please, Sign In to add comment