Skip to content

Commit

Permalink
enable levelprogressdialog for editor levels
Browse files Browse the repository at this point in the history
  • Loading branch information
Cvolton committed Jul 2, 2024
1 parent ee714e5 commit e2e5a70
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 35 deletions.
8 changes: 1 addition & 7 deletions src/managers/BetterInfoStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ void BetterInfoStats::logCompletion(GJGameLevel* level, bool practice) {
}

void BetterInfoStats::logCompletion(GJGameLevel* level, bool practice, time_t timestamp) {
if(level->m_levelType == GJLevelType::Editor) return;

auto dict = practice ? m_practiceDict : m_normalDict;
dict->setObject(CCString::create(std::to_string(timestamp).c_str()), keyForLevel(level));

Expand All @@ -114,8 +112,6 @@ time_t BetterInfoStats::getCompletion(GJGameLevel* level, bool practice) {
}

void BetterInfoStats::logPlay(GJGameLevel* level) {
if(level->m_levelType == GJLevelType::Editor) return;

auto idString = keyForLevel(level);
auto timeString = CCString::create(std::to_string(std::time(nullptr)).c_str());
m_lastPlayedDict->setObject(timeString, idString);
Expand All @@ -139,12 +135,10 @@ std::string BetterInfoStats::keyForLevel(GJGameLevel* level) {
auto type = static_cast<int>(level->m_levelType);
if(!type) type = 3;

return fmt::format("{}_{}_{}_{}", level->m_levelID.value(), type, level->m_dailyID.value(), level->m_gauntletLevel);
return fmt::format("{}_{}_{}_{}", EditorIDs::getID(level), type, level->m_dailyID.value(), level->m_gauntletLevel);
}

void BetterInfoStats::logAttempt(GJGameLevel* level, bool practice) {
if(level->m_levelType == GJLevelType::Editor) return;

auto dict = practice ? m_practiceAttemptDict : m_normalAttemptDict;
dict->setObject(CCString::create(std::to_string(getAttempts(level, practice) + 1).c_str()), keyForLevel(level));
}
Expand Down
57 changes: 29 additions & 28 deletions src/utils/LevelProgressDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,50 +38,51 @@ void LevelProgressDialog::show(GJGameLevel* level){
return;
}

std::ostringstream contentStream, secondStream;
std::ostringstream contentStream, secondStream, toMergeStream;
contentStream << "<cg>Total Attempts</c>: " << level->m_attempts
<< "\n<cl>Total Jumps</c>: " << level->m_jumps
<< "\n<cy>Clicks (best att.)</c>: " << level->m_clicks
<< "\n<cr>Time (best att.)</c>: " << TimeUtils::workingTime(level->m_attemptTime);

auto stats = BetterInfoStats::sharedState();
if(level->isPlatformer()) {
toMergeStream << "<cp>Best Time</c>: " << TimeUtils::platformerTime(level->m_bestTime)
<< "\n<co>Best Points</c>: " << level->m_bestPoints;
} else {
toMergeStream << "<cp>Normal</c>: " << level->m_normalPercent
<< "%\n<co>Practice</c>: " << level->m_practicePercent << "%";
if(level->m_orbCompletion != level->m_normalPercent) toMergeStream << "\n<cj>Orbs</c>: " << level->m_orbCompletion << "%";
if(level->m_newNormalPercent2 != level->m_orbCompletion) toMergeStream << "\n<cr>Leaderboard</c>: " << level->m_newNormalPercent2 << "%";
}

if(level->m_levelType != GJLevelType::Editor){
auto stats = BetterInfoStats::sharedState();
//auto statsV2 = BetterInfoStatsV2::sharedState();

if(level->isPlatformer()) {
contentStream << "\n<cp>Best Time</c>: " << TimeUtils::platformerTime(level->m_bestTime)
<< "\n<co>Best Points</c>: " << level->m_bestPoints;
} else {
contentStream << "\n<cp>Normal</c>: " << level->m_normalPercent
<< "%\n<co>Practice</c>: " << level->m_practicePercent << "%";
if(level->m_orbCompletion != level->m_normalPercent) contentStream << "\n<cj>Orbs</c>: " << level->m_orbCompletion << "%";
if(level->m_newNormalPercent2 != level->m_orbCompletion) contentStream << "\n<cr>Leaderboard</c>: " << level->m_newNormalPercent2 << "%";

}

auto normalAttempts = stats->getAttempts(level, false);
auto practiceAttempts = stats->getAttempts(level, true);
//auto commonFail = statsV2->getCommonFail(level);
secondStream << "<cp>Attempts (normal)</c>: " << normalAttempts << "\n";
secondStream << "<co>Attempts (practice)</c>: " << practiceAttempts << "\n";
if((normalAttempts + practiceAttempts) != level->m_attempts) secondStream << "<cy>Attempts (unknown)</c>: " << (level->m_attempts - practiceAttempts - normalAttempts) << "\n";
secondStream << "\n";
if(stats->getPlay(level, false) != 0) secondStream << "<cg>First played</c>: " << TimeUtils::timeToString(stats->getPlay(level, false)) << "\n";
if(stats->getPlay(level, true) != 0) secondStream << "<cl>Last played</c>: " << TimeUtils::timeToString(stats->getPlay(level, true)) << "\n";
if(stats->getCompletion(level, false) > 0) secondStream << "<cp>Completed</c>: " << TimeUtils::timeToString(stats->getCompletion(level, false)) << "\n";
if(stats->getCompletion(level, true) > 0) secondStream << "<co>Completed (practice)</c>: " << TimeUtils::timeToString(stats->getCompletion(level, true)) << "\n";
//secondStream << "<co>Common fail:</c> " << commonFail.first << "% (" << commonFail.second << "x)\n";
contentStream << "\n" << toMergeStream.str() << "\n";
}else{
contentStream << "\n<cp>Objects</c>: " << level->m_objectCount
<< "\n<cr>In Editor</c>: " << TimeUtils::workingTime(level->m_workingTime) << "\n";
if(level->m_workingTime2) contentStream << "<cr>Editor (C)</c>: " << TimeUtils::workingTime(level->m_workingTime2) << "\n";
;

secondStream << toMergeStream.str() << "\n\n";
}

auto normalAttempts = stats->getAttempts(level, false);
auto practiceAttempts = stats->getAttempts(level, true);
//auto commonFail = statsV2->getCommonFail(level);
secondStream << "<cp>Attempts (normal)</c>: " << normalAttempts << "\n";
secondStream << "<co>Attempts (practice)</c>: " << practiceAttempts << "\n";
if((normalAttempts + practiceAttempts) != level->m_attempts) secondStream << "<cy>Attempts (unknown)</c>: " << (level->m_attempts - practiceAttempts - normalAttempts) << "\n";
secondStream << "\n";
if(stats->getPlay(level, false) != 0) secondStream << "<cg>First played</c>: " << TimeUtils::timeToString(stats->getPlay(level, false)) << "\n";
if(stats->getPlay(level, true) != 0) secondStream << "<cl>Last played</c>: " << TimeUtils::timeToString(stats->getPlay(level, true)) << "\n";
if(stats->getCompletion(level, false) > 0) secondStream << "<cp>Completed</c>: " << TimeUtils::timeToString(stats->getCompletion(level, false)) << "\n";
if(stats->getCompletion(level, true) > 0) secondStream << "<co>Completed (practice)</c>: " << TimeUtils::timeToString(stats->getCompletion(level, true)) << "\n";
//secondStream << "<co>Common fail:</c> " << commonFail.first << "% (" << commonFail.second << "x)\n";

std::string progresses;
if(std::string(level->m_personalBests) != ""){
progresses = printableProgress(level->m_personalBests, level->m_newNormalPercent2);
contentStream << "\n\n<cy>Progresses</c>: " << progresses;
contentStream << "\n<cy>Progresses</c>: " << progresses;
}

std::vector<std::string> contents;
Expand Down

0 comments on commit e2e5a70

Please sign in to comment.