diff --git a/src/include/interface.h b/src/include/interface.h index f8840e58d..c3da5c05d 100644 --- a/src/include/interface.h +++ b/src/include/interface.h @@ -405,6 +405,8 @@ extern bool ButtonCheckUnitVariable(const CUnit &unit, const ButtonAction &butto extern bool ButtonCheckUnitsOr(const CUnit &unit, const ButtonAction &button); /// Check if allowed units exists extern bool ButtonCheckUnitsAnd(const CUnit &unit, const ButtonAction &button); +/// Check if units don't exist +extern bool ButtonCheckUnitsNot(const CUnit &unit, const ButtonAction &button); /// Check if have network play extern bool ButtonCheckNetwork(const CUnit &unit, const ButtonAction &button); /// Check if don't have network play diff --git a/src/ui/button_checks.cpp b/src/ui/button_checks.cpp index cdcc5ad7c..5601ed899 100644 --- a/src/ui/button_checks.cpp +++ b/src/ui/button_checks.cpp @@ -202,6 +202,19 @@ bool ButtonCheckUnitsAnd(const CUnit &unit, const ButtonAction &button) return true; } +/** +** Check for button enabled, if no unit is available. +** +** @param unit Pointer to unit for button. +** @param button Pointer to button to check/enable. +** +** @return True if enabled. +*/ +bool ButtonCheckUnitsNot(const CUnit &unit, const ButtonAction &button) +{ + return !ButtonCheckUnitsAnd(unit, button); +} + /** ** Check if network play is enabled. ** diff --git a/src/ui/script_ui.cpp b/src/ui/script_ui.cpp index e27ae109b..88527bec4 100644 --- a/src/ui/script_ui.cpp +++ b/src/ui/script_ui.cpp @@ -968,6 +968,8 @@ static int CclDefineButton(lua_State *l) ba.Allowed = ButtonCheckUnitsOr; } else if (!strcmp(value, "check-units-and")) { ba.Allowed = ButtonCheckUnitsAnd; + } else if (!strcmp(value, "check-units-not")) { + ba.Allowed = ButtonCheckUnitsNot; } else if (!strcmp(value, "check-network")) { ba.Allowed = ButtonCheckNetwork; } else if (!strcmp(value, "check-no-network")) {