void AppearanceAlert (AlertType type, int stringID1, int stringID2) { OSStatus err; DialogRef dialog; DialogItemIndex outItemHit; CFStringRef key1, key2, mes1, mes2; char label1[32], label2[32]; sprintf(label1, "AlertMes_%02d", stringID1); sprintf(label2, "AlertMes_%02d", stringID2); key1 = CFStringCreateWithCString(kCFAllocatorDefault, label1, CFStringGetSystemEncoding()); key2 = CFStringCreateWithCString(kCFAllocatorDefault, label2, CFStringGetSystemEncoding()); if (key1) mes1 = CFCopyLocalizedString(key1, "mes1"); else mes1 = NULL; if (key2) mes2 = CFCopyLocalizedString(key2, "mes2"); else mes2 = NULL; PlayAlertSound(); err = CreateStandardAlert(type, mes1, mes2, NULL, &dialog); err = RunStandardAlert(dialog, NULL, &outItemHit); if (key1) CFRelease(key1); if (key2) CFRelease(key2); if (mes1) CFRelease(mes1); if (mes2) CFRelease(mes2); }
void Client::ShowAlert(const std::string &contents, AlertType type, float timeout, bool quiet) { alertType = type; alertContents = contents; alertDisappearTime = time + timeout; alertAppearTime = time; if(type != AlertType::Notice && !quiet) { PlayAlertSound(); } }
void Client::LocalPlayerBuildError(BuildFailureReason reason) { SPADES_MARK_FUNCTION(); if (!cg_alerts) { PlayAlertSound(); return; } switch (reason) { case BuildFailureReason::InsufficientBlocks: ShowAlert(_Tr("Client", "Insufficient blocks."), AlertType::Error); break; case BuildFailureReason::InvalidPosition: ShowAlert(_Tr("Client", "You cannot place a block there."), AlertType::Error); break; } }