| 939 | } |
| 940 | |
| 941 | void 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 | } |
no test coverage detected