Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
98 changed files
with
7,626 additions
and
3,008 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
268 changes: 134 additions & 134 deletions
268
source/code/eAirReader.cpp → pre053source/code/eAirReader.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,134 +1,134 @@ | ||
#include "eAirReader.h" | ||
#include "eLog.h" | ||
#include <string> | ||
#include <algorithm> | ||
std::vector<eAirReader> eAirManager; | ||
|
||
void eAirReader::Open(const char * name) | ||
{ | ||
strName = name; | ||
pFile = fopen(name, "rb"); | ||
if (!pFile) | ||
{ | ||
Log->PushMessage(false, "eAirReader::Open() | Failed! Cannot open %s!\n", name); | ||
Log->PushError(); | ||
} | ||
|
||
|
||
} | ||
void eAirReader::ReadData() | ||
{ | ||
char szLine[1536]; | ||
int i = 0; | ||
int ID = 0; | ||
eAirEntry airEntry; | ||
airEntry.MaxFrames = 0; | ||
while (fgets(szLine, sizeof(szLine), pFile)) | ||
{ | ||
if (szLine[0] == '[') | ||
{ | ||
i++; | ||
|
||
for (int i = 0; szLine[i]; i++) { | ||
szLine[i] = tolower(szLine[i]); | ||
} | ||
|
||
if (sscanf(szLine, "[begin action %d]", &ID) == 1) | ||
{ | ||
while (fgets(szLine, sizeof(szLine), pFile)) | ||
{ | ||
if (szLine[0] == ';' || szLine[0] == '#') continue; | ||
if (szLine[0] == '\r') break; | ||
|
||
int iGroupID, iIndex, iXPos, iYPos, iFrameTime; | ||
// remove , | ||
std::string strLine(szLine, strlen(szLine)); | ||
std::replace(strLine.begin(), strLine.end(), ',', ' '); | ||
if (sscanf(strLine.c_str(), "%d", &iGroupID) == 1) | ||
{ | ||
sscanf(strLine.c_str(), "%d %d %d %d %d", &iGroupID, &iIndex, &iXPos, &iYPos, &iFrameTime); | ||
airEntry.MaxFrames++; | ||
// create entry | ||
eAirData frame = { iGroupID, iIndex, iXPos, iYPos,iFrameTime }; | ||
airEntry.vAnimData.push_back(frame); | ||
} | ||
|
||
|
||
} | ||
airEntry.AnimID = ID; | ||
vAnimations.push_back(airEntry); | ||
airEntry.vAnimData.clear(); | ||
airEntry.MaxFrames = 0; | ||
} | ||
|
||
} | ||
|
||
} | ||
iAnimCount = i; | ||
fclose(pFile); | ||
} | ||
|
||
eAirEntry eAirReader::GetAnimation(int id) | ||
{ | ||
eAirEntry air; | ||
for (int i = 0; i < vAnimations.size(); i++) | ||
{ | ||
if (vAnimations[i].AnimID == id) { | ||
air = vAnimations[i]; | ||
break; | ||
} | ||
else | ||
air = vAnimations[0]; | ||
} | ||
return air; | ||
} | ||
|
||
int eAirReader::GetAnimCount() | ||
{ | ||
return iAnimCount; | ||
} | ||
|
||
void eAirReader::PrintAnimID() | ||
{ | ||
printf("Loaded anims:\n"); | ||
for (int i = 0; i < vAnimations.size(); i++) | ||
{ | ||
printf("%d ", vAnimations[i].AnimID); | ||
for (int a = 0; a < vAnimations[i].vAnimData.size(); a++) | ||
printf("-%d-", vAnimations[i].vAnimData[a].Index); | ||
} | ||
printf("\n"); | ||
} | ||
|
||
bool eAirReader::CheckName(std::string name) | ||
{ | ||
if (strName == name) | ||
return true; | ||
else | ||
return false; | ||
} | ||
|
||
eAirReader GetAIRFromName(std::string name) | ||
{ | ||
eAirReader temp; | ||
for (int i = 0; i < eAirManager.size(); i++) | ||
{ | ||
if (eAirManager[i].CheckName(name)) { | ||
temp = eAirManager[i]; | ||
break; | ||
} | ||
else | ||
temp = eAirManager[0]; | ||
} | ||
return temp; | ||
} | ||
|
||
int GlobalGetAnimCount() | ||
{ | ||
int iCount = 0; | ||
for (int i = 0; i < eAirManager.size(); i++) | ||
{ | ||
iCount += eAirManager[i].GetAnimCount(); | ||
} | ||
return iCount; | ||
} | ||
#include "eAirReader.h" | ||
#include "eLog.h" | ||
#include <string> | ||
#include <algorithm> | ||
std::vector<eAirReader> eAirManager; | ||
|
||
void eAirReader::Open(const char * name) | ||
{ | ||
strName = name; | ||
pFile = fopen(name, "rb"); | ||
if (!pFile) | ||
{ | ||
Log->PushMessage(false, "eAirReader::Open() | Failed! Cannot open %s!\n", name); | ||
Log->PushError(); | ||
} | ||
|
||
|
||
} | ||
void eAirReader::ReadData() | ||
{ | ||
char szLine[1536]; | ||
int i = 0; | ||
int ID = 0; | ||
eAirEntry airEntry; | ||
airEntry.MaxFrames = 0; | ||
while (fgets(szLine, sizeof(szLine), pFile)) | ||
{ | ||
if (szLine[0] == '[') | ||
{ | ||
i++; | ||
|
||
for (int i = 0; szLine[i]; i++) { | ||
szLine[i] = tolower(szLine[i]); | ||
} | ||
|
||
if (sscanf(szLine, "[begin action %d]", &ID) == 1) | ||
{ | ||
while (fgets(szLine, sizeof(szLine), pFile)) | ||
{ | ||
if (szLine[0] == ';' || szLine[0] == '#') continue; | ||
if (szLine[0] == '\r') break; | ||
|
||
int iGroupID, iIndex, iXPos, iYPos, iFrameTime; | ||
// remove , | ||
std::string strLine(szLine, strlen(szLine)); | ||
std::replace(strLine.begin(), strLine.end(), ',', ' '); | ||
if (sscanf(strLine.c_str(), "%d", &iGroupID) == 1) | ||
{ | ||
sscanf(strLine.c_str(), "%d %d %d %d %d", &iGroupID, &iIndex, &iXPos, &iYPos, &iFrameTime); | ||
airEntry.MaxFrames++; | ||
// create entry | ||
eAirData frame = { iGroupID, iIndex, iXPos, iYPos,iFrameTime }; | ||
airEntry.vAnimData.push_back(frame); | ||
} | ||
|
||
|
||
} | ||
airEntry.AnimID = ID; | ||
vAnimations.push_back(airEntry); | ||
airEntry.vAnimData.clear(); | ||
airEntry.MaxFrames = 0; | ||
} | ||
|
||
} | ||
|
||
} | ||
iAnimCount = i; | ||
fclose(pFile); | ||
} | ||
|
||
eAirEntry eAirReader::GetAnimation(int id) | ||
{ | ||
eAirEntry air; | ||
for (int i = 0; i < vAnimations.size(); i++) | ||
{ | ||
if (vAnimations[i].AnimID == id) { | ||
air = vAnimations[i]; | ||
break; | ||
} | ||
else | ||
air = vAnimations[0]; | ||
} | ||
return air; | ||
} | ||
|
||
int eAirReader::GetAnimCount() | ||
{ | ||
return iAnimCount; | ||
} | ||
|
||
void eAirReader::PrintAnimID() | ||
{ | ||
printf("Loaded anims:\n"); | ||
for (int i = 0; i < vAnimations.size(); i++) | ||
{ | ||
printf("%d ", vAnimations[i].AnimID); | ||
for (int a = 0; a < vAnimations[i].vAnimData.size(); a++) | ||
printf("-%d-", vAnimations[i].vAnimData[a].Index); | ||
} | ||
printf("\n"); | ||
} | ||
|
||
bool eAirReader::CheckName(std::string name) | ||
{ | ||
if (strName == name) | ||
return true; | ||
else | ||
return false; | ||
} | ||
|
||
eAirReader GetAIRFromName(std::string name) | ||
{ | ||
eAirReader temp; | ||
for (int i = 0; i < eAirManager.size(); i++) | ||
{ | ||
if (eAirManager[i].CheckName(name)) { | ||
temp = eAirManager[i]; | ||
break; | ||
} | ||
else | ||
temp = eAirManager[0]; | ||
} | ||
return temp; | ||
} | ||
|
||
int GlobalGetAnimCount() | ||
{ | ||
int iCount = 0; | ||
for (int i = 0; i < eAirManager.size(); i++) | ||
{ | ||
iCount += eAirManager[i].GetAnimCount(); | ||
} | ||
return iCount; | ||
} |
72 changes: 36 additions & 36 deletions
72
source/code/eAirReader.h → pre053source/code/eAirReader.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,36 @@ | ||
#pragma once | ||
#include <vector> | ||
#include <iostream> | ||
|
||
struct eAirData { | ||
int Group; | ||
int Index; | ||
int PosX; | ||
int PosY; | ||
int Frametime; | ||
}; | ||
|
||
struct eAirEntry { | ||
int AnimID; | ||
int MaxFrames; | ||
std::vector<eAirData> vAnimData; | ||
}; | ||
|
||
class eAirReader { | ||
std::vector<eAirEntry> vAnimations; | ||
FILE* pFile; | ||
std::string strName; | ||
int iAnimCount; | ||
public: | ||
void Open(const char* name); | ||
void ReadData(); | ||
eAirEntry GetAnimation(int id); | ||
int GetAnimCount(); | ||
void PrintAnimID(); | ||
bool CheckName(std::string name); | ||
|
||
}; | ||
|
||
extern std::vector<eAirReader> eAirManager; | ||
eAirReader GetAIRFromName(std::string name); | ||
int GlobalGetAnimCount(); | ||
#pragma once | ||
#include <vector> | ||
#include <iostream> | ||
|
||
struct eAirData { | ||
int Group; | ||
int Index; | ||
int PosX; | ||
int PosY; | ||
int Frametime; | ||
}; | ||
|
||
struct eAirEntry { | ||
int AnimID; | ||
int MaxFrames; | ||
std::vector<eAirData> vAnimData; | ||
}; | ||
|
||
class eAirReader { | ||
std::vector<eAirEntry> vAnimations; | ||
FILE* pFile; | ||
std::string strName; | ||
int iAnimCount; | ||
public: | ||
void Open(const char* name); | ||
void ReadData(); | ||
eAirEntry GetAnimation(int id); | ||
int GetAnimCount(); | ||
void PrintAnimID(); | ||
bool CheckName(std::string name); | ||
|
||
}; | ||
|
||
extern std::vector<eAirReader> eAirManager; | ||
eAirReader GetAIRFromName(std::string name); | ||
int GlobalGetAnimCount(); |
Oops, something went wrong.