mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-20 06:53:52 +00:00
Use a multimap to store the text keys
This commit is contained in:
parent
9b491edbf8
commit
cd8515396a
3 changed files with 42 additions and 38 deletions
|
@ -49,45 +49,28 @@ bool Animation::findGroupTimes(const std::string &groupname, Animation::GroupTim
|
||||||
|
|
||||||
std::string::const_iterator strpos = iter->second.begin();
|
std::string::const_iterator strpos = iter->second.begin();
|
||||||
std::string::const_iterator strend = iter->second.end();
|
std::string::const_iterator strend = iter->second.end();
|
||||||
|
|
||||||
while(strpos != strend)
|
|
||||||
{
|
|
||||||
size_t strlen = strend-strpos;
|
size_t strlen = strend-strpos;
|
||||||
std::string::const_iterator striter;
|
|
||||||
|
|
||||||
if(start.size() <= strlen &&
|
if(start.size() <= strlen && std::mismatch(strpos, strend, start.begin(), checklow()).first == strend)
|
||||||
((striter=std::mismatch(strpos, strend, start.begin(), checklow()).first) == strend ||
|
|
||||||
*striter == '\r' || *striter == '\n'))
|
|
||||||
{
|
{
|
||||||
times->mStart = iter->first;
|
times->mStart = iter->first;
|
||||||
times->mLoopStart = iter->first;
|
times->mLoopStart = iter->first;
|
||||||
}
|
}
|
||||||
else if(startloop.size() <= strlen &&
|
else if(startloop.size() <= strlen && std::mismatch(strpos, strend, startloop.begin(), checklow()).first == strend)
|
||||||
((striter=std::mismatch(strpos, strend, startloop.begin(), checklow()).first) == strend ||
|
|
||||||
*striter == '\r' || *striter == '\n'))
|
|
||||||
{
|
{
|
||||||
times->mLoopStart = iter->first;
|
times->mLoopStart = iter->first;
|
||||||
}
|
}
|
||||||
else if(stoploop.size() <= strlen &&
|
else if(stoploop.size() <= strlen && std::mismatch(strpos, strend, stoploop.begin(), checklow()).first == strend)
|
||||||
((striter=std::mismatch(strpos, strend, stoploop.begin(), checklow()).first) == strend ||
|
|
||||||
*striter == '\r' || *striter == '\n'))
|
|
||||||
{
|
{
|
||||||
times->mLoopStop = iter->first;
|
times->mLoopStop = iter->first;
|
||||||
}
|
}
|
||||||
else if(stop.size() <= strlen &&
|
else if(stop.size() <= strlen && std::mismatch(strpos, strend, stop.begin(), checklow()).first == strend)
|
||||||
((striter=std::mismatch(strpos, strend, stop.begin(), checklow()).first) == strend ||
|
|
||||||
*striter == '\r' || *striter == '\n'))
|
|
||||||
{
|
{
|
||||||
times->mStop = iter->first;
|
times->mStop = iter->first;
|
||||||
if(times->mLoopStop < 0.0f)
|
if(times->mLoopStop < 0.0f)
|
||||||
times->mLoopStop = iter->first;
|
times->mLoopStop = iter->first;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
strpos = std::find(strpos+1, strend, '\n');
|
|
||||||
while(strpos != strend && *strpos == '\n')
|
|
||||||
strpos++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (times->mStart >= 0.0f && times->mLoopStart >= 0.0f && times->mLoopStop >= 0.0f && times->mStop >= 0.0f);
|
return (times->mStart >= 0.0f && times->mLoopStart >= 0.0f && times->mLoopStop >= 0.0f && times->mStop >= 0.0f);
|
||||||
|
|
|
@ -152,6 +152,28 @@ static void fail(const std::string &msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void insertTextKeys(const Nif::NiTextKeyExtraData *tk, TextKeyMap *textkeys)
|
||||||
|
{
|
||||||
|
for(size_t i = 0;i < tk->list.size();i++)
|
||||||
|
{
|
||||||
|
const std::string &str = tk->list[i].text;
|
||||||
|
std::string::size_type pos = 0;
|
||||||
|
while(pos < str.length())
|
||||||
|
{
|
||||||
|
while(pos < str.length() && ::isspace(str[pos]))
|
||||||
|
pos++;
|
||||||
|
if(pos >= str.length())
|
||||||
|
break;
|
||||||
|
|
||||||
|
std::string::size_type nextpos = std::min(str.find('\r', pos), str.find('\n', pos));
|
||||||
|
textkeys->insert(std::make_pair(tk->list[i].time, str.substr(pos, nextpos-pos)));
|
||||||
|
|
||||||
|
pos = nextpos;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void buildBones(Ogre::Skeleton *skel, const Nif::Node *node, std::vector<Nif::NiKeyframeController*> &ctrls, Ogre::Bone *parent=NULL)
|
void buildBones(Ogre::Skeleton *skel, const Nif::Node *node, std::vector<Nif::NiKeyframeController*> &ctrls, Ogre::Bone *parent=NULL)
|
||||||
{
|
{
|
||||||
Ogre::Bone *bone;
|
Ogre::Bone *bone;
|
||||||
|
@ -359,8 +381,7 @@ bool createSkeleton(const std::string &name, const std::string &group, TextKeyMa
|
||||||
if(e->recType == Nif::RC_NiTextKeyExtraData)
|
if(e->recType == Nif::RC_NiTextKeyExtraData)
|
||||||
{
|
{
|
||||||
const Nif::NiTextKeyExtraData *tk = static_cast<const Nif::NiTextKeyExtraData*>(e.getPtr());
|
const Nif::NiTextKeyExtraData *tk = static_cast<const Nif::NiTextKeyExtraData*>(e.getPtr());
|
||||||
for(size_t i = 0;i < tk->list.size();i++)
|
insertTextKeys(tk, textkeys);
|
||||||
(*textkeys)[tk->list[i].time] = tk->list[i].text;
|
|
||||||
}
|
}
|
||||||
e = e->extra;
|
e = e->extra;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace NifOgre
|
||||||
{
|
{
|
||||||
|
|
||||||
// FIXME: These should not be in NifOgre, it works agnostic of what model format is used
|
// FIXME: These should not be in NifOgre, it works agnostic of what model format is used
|
||||||
typedef std::map<float,std::string> TextKeyMap;
|
typedef std::multimap<float,std::string> TextKeyMap;
|
||||||
struct EntityList {
|
struct EntityList {
|
||||||
std::vector<Ogre::Entity*> mEntities;
|
std::vector<Ogre::Entity*> mEntities;
|
||||||
Ogre::Entity *mSkelBase;
|
Ogre::Entity *mSkelBase;
|
||||||
|
|
Loading…
Reference in a new issue