- cleanup achievement code for easier expansion later
This commit is contained in:
parent
ff4eb7e61e
commit
9de36c32a3
|
@ -5231,10 +5231,10 @@ void saveStatsToSteam(Game* game, Stats& endStats) {
|
||||||
for (int factionIndex = 0;
|
for (int factionIndex = 0;
|
||||||
factionIndex < game->getWorld()->getFactionCount(); ++factionIndex) {
|
factionIndex < game->getWorld()->getFactionCount(); ++factionIndex) {
|
||||||
if (factionIndex == game->getWorld()->getThisFactionIndex()) {
|
if (factionIndex == game->getWorld()->getThisFactionIndex()) {
|
||||||
printf("\nWriting out game stats for Faction Index: %d won status: %d\n",factionIndex,endStats.getVictory(factionIndex));
|
//printf("\nWriting out game stats for Faction Index: %d won status: %d\n",factionIndex,endStats.getVictory(factionIndex));
|
||||||
if (endStats.getVictory(factionIndex)) {
|
if (endStats.getVictory(factionIndex)) {
|
||||||
if(steamInstance->isUnlocked("ACH_WIN_ONE_GAME") == false) {
|
if(steamInstance->isUnlocked(EnumParser<SteamAchievementName>::getString(ACH_WIN_ONE_GAME).c_str()) == false) {
|
||||||
steamInstance->unlock("ACH_WIN_ONE_GAME");
|
steamInstance->unlock(EnumParser<SteamAchievementName>::getString(ACH_WIN_ONE_GAME).c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,12 +9,6 @@ namespace Glest{ namespace Game{
|
||||||
|
|
||||||
std::map<std::string,SteamStatType> Steam::SteamStatNameTypes = Steam::create_map();
|
std::map<std::string,SteamStatType> Steam::SteamStatNameTypes = Steam::create_map();
|
||||||
|
|
||||||
// Achievements
|
|
||||||
static const char *const achievementNames[] = {
|
|
||||||
"ACH_WIN_ONE_GAME",
|
|
||||||
};
|
|
||||||
#define NUM_ACHIEVEMENTS (sizeof(achievementNames) / sizeof(achievementNames[0]))
|
|
||||||
|
|
||||||
// Language map
|
// Language map
|
||||||
static inline std::map<std::string, std::string> gen_langToCode()
|
static inline std::map<std::string, std::string> gen_langToCode()
|
||||||
{
|
{
|
||||||
|
@ -103,8 +97,10 @@ struct SteamPrivate {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (size_t index = 0; index < NUM_ACHIEVEMENTS; ++index) {
|
for(int index = 0; index < EnumParser<SteamAchievementName>::getCount(); ++index) {
|
||||||
STEAMSHIM_getAchievement(achievementNames[index]);
|
SteamAchievementName achName = static_cast<SteamAchievementName>(index);
|
||||||
|
string achNameStr = EnumParser<SteamAchievementName>::getString(achName);
|
||||||
|
STEAMSHIM_getAchievement(achNameStr.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
Shared::PlatformCommon::Chrono timer;
|
Shared::PlatformCommon::Chrono timer;
|
||||||
|
@ -118,7 +114,6 @@ struct SteamPrivate {
|
||||||
void setAchievement(const char *name, bool set) {
|
void setAchievement(const char *name, bool set) {
|
||||||
achievements[name] = set;
|
achievements[name] = set;
|
||||||
STEAMSHIM_setAchievement(name, set);
|
STEAMSHIM_setAchievement(name, set);
|
||||||
//STEAMSHIM_storeStats();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateAchievement(const char *name, bool isSet) {
|
void updateAchievement(const char *name, bool isSet) {
|
||||||
|
@ -226,7 +221,7 @@ struct SteamPrivate {
|
||||||
return !userName.empty()
|
return !userName.empty()
|
||||||
&& !lang.empty()
|
&& !lang.empty()
|
||||||
&& (int)stats.size() >= EnumParser<SteamStatName>::getCount()
|
&& (int)stats.size() >= EnumParser<SteamStatName>::getCount()
|
||||||
&& achievements.size() == NUM_ACHIEVEMENTS;
|
&& (int)achievements.size() >= EnumParser<SteamAchievementName>::getCount();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,14 @@ inline EnumParser<SteamStatName>::EnumParser() {
|
||||||
enumMap["stat_online_minutes_played"] = stat_online_minutes_played;
|
enumMap["stat_online_minutes_played"] = stat_online_minutes_played;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum SteamAchievementName {
|
||||||
|
ACH_WIN_ONE_GAME
|
||||||
|
};
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline EnumParser<SteamAchievementName>::EnumParser() {
|
||||||
|
enumMap["ACH_WIN_ONE_GAME"] = ACH_WIN_ONE_GAME;
|
||||||
|
}
|
||||||
|
|
||||||
class Steam
|
class Steam
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue