add a button check to disable a button when a unit is available
This commit is contained in:
parent
a7e147a480
commit
921c298c9c
3 changed files with 17 additions and 0 deletions
src
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
**
|
||||
|
|
|
@ -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")) {
|
||||
|
|
Loading…
Add table
Reference in a new issue