mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Save achievements data after each completion.
This commit is contained in:
parent
50f5345ea5
commit
9f0f3a7218
@ -82,21 +82,7 @@ AchievementsMgr::AchievementsMgr()
|
||||
|
||||
AchievementsMgr::~AchievementsMgr()
|
||||
{
|
||||
const auto fn = tracy::GetSavePath( "achievements.ini" );
|
||||
FILE* f = fopen( fn, "wb" );
|
||||
if( !f ) return;
|
||||
|
||||
for( auto& v : m_map )
|
||||
{
|
||||
auto& it = v.second.item;
|
||||
fprintf( f, "[%s]\n", it->id );
|
||||
fprintf( f, "unlockTime=%" PRIu64 "\n", it->unlockTime );
|
||||
fprintf( f, "doneTime=%" PRIu64 "\n", it->doneTime );
|
||||
fprintf( f, "hideCompleted=%d\n", it->hideCompleted ? 1 : 0 );
|
||||
fprintf( f, "hideNew=%d\n\n", it->hideNew ? 1 : 0 );
|
||||
}
|
||||
|
||||
fclose( f );
|
||||
Save();
|
||||
}
|
||||
|
||||
void AchievementsMgr::Achieve( const char* id )
|
||||
@ -129,6 +115,8 @@ void AchievementsMgr::Achieve( const char* id )
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
Save();
|
||||
}
|
||||
|
||||
data::AchievementCategory** AchievementsMgr::GetCategories() const
|
||||
@ -200,4 +188,23 @@ void AchievementsMgr::FillMap( data::AchievementItem** items, data::AchievementC
|
||||
}
|
||||
}
|
||||
|
||||
void AchievementsMgr::Save()
|
||||
{
|
||||
const auto fn = tracy::GetSavePath( "achievements.ini" );
|
||||
FILE* f = fopen( fn, "wb" );
|
||||
if( !f ) return;
|
||||
|
||||
for( auto& v : m_map )
|
||||
{
|
||||
auto& it = v.second.item;
|
||||
fprintf( f, "[%s]\n", it->id );
|
||||
fprintf( f, "unlockTime=%" PRIu64 "\n", it->unlockTime );
|
||||
fprintf( f, "doneTime=%" PRIu64 "\n", it->doneTime );
|
||||
fprintf( f, "hideCompleted=%d\n", it->hideCompleted ? 1 : 0 );
|
||||
fprintf( f, "hideNew=%d\n\n", it->hideNew ? 1 : 0 );
|
||||
}
|
||||
|
||||
fclose( f );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -71,6 +71,7 @@ public:
|
||||
|
||||
private:
|
||||
void FillMap( data::AchievementItem** items, data::AchievementCategory* category );
|
||||
void Save();
|
||||
|
||||
std::vector<data::AchievementItem*> m_queue;
|
||||
tracy::unordered_flat_map<const char*, AchievementPair, charutil::Hasher, charutil::Comparator> m_map;
|
||||
|
Loading…
Reference in New Issue
Block a user