From 13a70762559c09a881368dc25bd46176282909de Mon Sep 17 00:00:00 2001 From: ShikiSuen Date: Mon, 6 Feb 2023 20:25:37 +0800 Subject: [PATCH] PrefUI // Only showing fart SFX toggle on April 1st. --- .../UIModules/PrefUI/VwrPrefPaneGeneral.swift | 68 ++++++++++--------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/Source/Modules/UIModules/PrefUI/VwrPrefPaneGeneral.swift b/Source/Modules/UIModules/PrefUI/VwrPrefPaneGeneral.swift index 9df95b01..ecf629e4 100644 --- a/Source/Modules/UIModules/PrefUI/VwrPrefPaneGeneral.swift +++ b/Source/Modules/UIModules/PrefUI/VwrPrefPaneGeneral.swift @@ -168,42 +168,44 @@ struct VwrPrefPaneGeneral: View { PrefMgr.shared.inlineDumpPinyinInLieuOfZhuyin = selInlineDumpPinyinInLieuOfZhuyin } ) - Toggle( - LocalizedStringKey("Stop farting (when typed phonetic combination is invalid, etc.)"), - isOn: $selEnableFartSuppressor.onChange { - let content = String( - format: NSLocalizedString( - "You are about to uncheck this fart suppressor. You are responsible for all consequences lead by letting people nearby hear the fart sound come from your computer. We strongly advise against unchecking this in any public circumstance that prohibits NSFW netas.", - comment: "" - )) - let alert = NSAlert(error: NSLocalizedString("Warning", comment: "")) - alert.informativeText = content - alert.addButton(withTitle: NSLocalizedString("Uncheck", comment: "")) - if #available(macOS 11, *) { - alert.buttons.forEach { button in - button.hasDestructiveAction = true - } - } - alert.addButton(withTitle: NSLocalizedString("Leave it checked", comment: "")) - if let window = CtlPrefUI.shared.controller.window, !selEnableFartSuppressor { - PrefMgr.shared.shouldNotFartInLieuOfBeep = true - alert.beginSheetModal(for: window) { result in - switch result { - case .alertFirstButtonReturn: - PrefMgr.shared.shouldNotFartInLieuOfBeep = false - case .alertSecondButtonReturn: - PrefMgr.shared.shouldNotFartInLieuOfBeep = true - default: break + if Date.isTodayTheDate(from: 0401) { + Toggle( + LocalizedStringKey("Stop farting (when typed phonetic combination is invalid, etc.)"), + isOn: $selEnableFartSuppressor.onChange { + let content = String( + format: NSLocalizedString( + "You are about to uncheck this fart suppressor. You are responsible for all consequences lead by letting people nearby hear the fart sound come from your computer. We strongly advise against unchecking this in any public circumstance that prohibits NSFW netas.", + comment: "" + )) + let alert = NSAlert(error: NSLocalizedString("Warning", comment: "")) + alert.informativeText = content + alert.addButton(withTitle: NSLocalizedString("Uncheck", comment: "")) + if #available(macOS 11, *) { + alert.buttons.forEach { button in + button.hasDestructiveAction = true } - selEnableFartSuppressor = PrefMgr.shared.shouldNotFartInLieuOfBeep - IMEApp.buzz() } - return + alert.addButton(withTitle: NSLocalizedString("Leave it checked", comment: "")) + if let window = CtlPrefUI.shared.controller.window, !selEnableFartSuppressor { + PrefMgr.shared.shouldNotFartInLieuOfBeep = true + alert.beginSheetModal(for: window) { result in + switch result { + case .alertFirstButtonReturn: + PrefMgr.shared.shouldNotFartInLieuOfBeep = false + case .alertSecondButtonReturn: + PrefMgr.shared.shouldNotFartInLieuOfBeep = true + default: break + } + selEnableFartSuppressor = PrefMgr.shared.shouldNotFartInLieuOfBeep + IMEApp.buzz() + } + return + } + PrefMgr.shared.shouldNotFartInLieuOfBeep = selEnableFartSuppressor + IMEApp.buzz() } - PrefMgr.shared.shouldNotFartInLieuOfBeep = selEnableFartSuppressor - IMEApp.buzz() - } - ) + ) + } } SSPreferences.Section(label: { Text(LocalizedStringKey("Misc Settings:")).controlSize(.small) }) { Toggle(