// Reusable modal specifications: alert, confirmation, and three-way choice expose only their intended actions. #include "sc2k/ui/modal.hpp" #include "test_harness.hpp" using namespace sc2k::ui; int main() { const ModalSpec alert = ModalSpec::alert("Notice", "Converted", "Continue"); CHECK(alert.has_primary()); CHECK(!alert.has_alternate()); CHECK(!alert.has_cancel()); CHECK(alert.closeButton); CHECK(alert.tone == ModalTone::Information); CHECK(alert.pausePolicy == SimulationPausePolicy::DoesNotPause); const ModalSpec confirm = ModalSpec::confirmation("Repay?", "This cannot be undone.", "Repay", "Cancel", ModalTone::Destructive); CHECK(confirm.has_primary()); CHECK(!confirm.has_alternate()); CHECK(confirm.has_cancel()); CHECK(confirm.tone == ModalTone::Destructive); CHECK(confirm.pausePolicy == SimulationPausePolicy::DoesNotPause); const ModalSpec choice = ModalSpec::choice("Unsaved city", "Save first?", "Save", "Don't Save", "Cancel", ModalTone::Warning); CHECK(choice.has_primary()); CHECK(choice.has_alternate()); CHECK(choice.has_cancel()); CHECK(choice.primaryLabel == "Save"); CHECK(choice.alternateLabel == "Don't Save"); CHECK(choice.cancelLabel == "Cancel"); CHECK(choice.pausePolicy == SimulationPausePolicy::DoesNotPause); const ModalSpec pausingChoice = ModalSpec::choice("Unsaved city", "Save first?", "Save", "Don't Save", "Cancel", ModalTone::Warning, SimulationPausePolicy::PauseSimulation); CHECK(pausingChoice.pausePolicy == SimulationPausePolicy::PauseSimulation); CHECK(kModalCancelCommand != kModalAlternateCommand); CHECK(kModalAlternateCommand != kModalPrimaryCommand); std::printf("modal: alert/confirmation/choice specifications are distinct\n"); return failures ? 1 : 0; }