Something went wrong. Try again.
[Mirror] Libreopolis is a cross-platform city simulation game fully compatible with SimCity 2000. gitlab.com/conasg/libreopolis
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435// 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);
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);
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(kModalCancelCommand != kModalAlternateCommand); CHECK(kModalAlternateCommand != kModalPrimaryCommand);
std::printf("modal: alert/confirmation/choice specifications are distinct\n"); return failures ? 1 : 0;}