MCPcopy Create free account
hub / github.com/TurningWheel/Barony / createStatisticUpdateNotification

Method createStatisticUpdateNotification

src/interface/ui_general.cpp:941–998  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

939}
940
941void UIToastNotificationManager_t::createStatisticUpdateNotification(const char* name, int currentValue, int maxValue)
942{
943 UIToastNotification* n = nullptr;
944 if ( n = getNotificationAchievementSingle(name) )
945 {
946 n->setStatisticMaxValue(maxValue);
947 n->updateCardStatisticEvent(currentValue);
948 return;
949 }
950
951 const bool unlocked = (currentValue >= maxValue);
952 const char* achievementName = "Unknown Achievement";
953 bool challenge = false;
954 if ( !strcmp(name, "CHALLENGE_MONSTER_KILLS") )
955 {
956 challenge = true;
957 achievementName = Language::get(6155);
958 n = UIToastNotificationManager.addNotification("*#images/ui/Main Menus/Challenges/seed_attempted64px.png");
959 n->setHeaderText(unlocked ? Language::get(6156) : Language::get(6154));
960 }
961 else if ( !strcmp(name, "CHALLENGE_FURNITURE_KILLS") )
962 {
963 challenge = true;
964 achievementName = Language::get(6157);
965 n = UIToastNotificationManager.addNotification("*#images/ui/Main Menus/Challenges/seed_attempted64px.png");
966 n->setHeaderText(unlocked ? Language::get(6156) : Language::get(6154));
967 }
968 else
969 {
970 auto it = Compendium_t::achievements.find(name);
971 if ( it != Compendium_t::achievements.end() )
972 {
973 achievementName = it->second.name.c_str();
974 }
975 const std::string imgName = unlocked ?
976 std::string("*#images/achievements/") + name + std::string(".png"):
977 std::string("*#images/achievements/") + name + std::string("_l.png");
978 n = UIToastNotificationManager.addNotification(imgName.c_str());
979 n->setHeaderText(unlocked ? "Achievement Unlocked!" : "Achievement Updated!");
980 }
981
982 std::string achStr = std::string(achievementName);
983 truncateMainText(achStr);
984 n->setMainText(achStr.c_str());
985 n->setAchievementName(name);
986 n->actionFlags |= (UIToastNotification::ActionFlags::UI_NOTIFICATION_STATISTIC_UPDATE);
987 n->actionFlags |= (UIToastNotification::ActionFlags::UI_NOTIFICATION_REMOVABLE);
988 n->actionFlags |= (UIToastNotification::ActionFlags::UI_NOTIFICATION_AUTO_HIDE);
989 n->actionFlags |= (UIToastNotification::ActionFlags::UI_NOTIFICATION_CLOSE);
990 if ( challenge )
991 {
992 n->actionFlags |= (UIToastNotification::ActionFlags::UI_NOTIFICATION_CHALLENGE_UPDATE);
993 }
994 n->cardType = UIToastNotification::CardType::UI_CARD_ACHIEVEMENT;
995 n->setStatisticCurrentValue(currentValue);
996 n->setStatisticMaxValue(maxValue);
997 n->setIdleSeconds(5);
998}

Callers 4

updateKillEventMethod · 0.80
net.cppFile · 0.80
ui_general.cppFile · 0.80

Calls 11

truncateMainTextFunction · 0.85
setStatisticMaxValueMethod · 0.80
setHeaderTextMethod · 0.80
c_strMethod · 0.80
setMainTextMethod · 0.80
setAchievementNameMethod · 0.80
setIdleSecondsMethod · 0.80
addNotificationMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected