Merge lp:~timfelgentreff/stratagus/ButtonCheckUnitsNot into lp:stratagus

Proposed by timfelgentreff
Status: Merged
Approved by: Pali
Approved revision: 8709
Merged at revision: 8744
Proposed branch: lp:~timfelgentreff/stratagus/ButtonCheckUnitsNot
Merge into: lp:stratagus
Diff against target: 49 lines (+17/-0)
3 files modified
src/include/interface.h (+2/-0)
src/ui/button_checks.cpp (+13/-0)
src/ui/script_ui.cpp (+2/-0)
To merge this branch: bzr merge lp:~timfelgentreff/stratagus/ButtonCheckUnitsNot
Reviewer Review Type Date Requested Status
Pali Approve
Review via email: mp+165268@code.launchpad.net

Description of the change

In Warcraft I, only one town hall can be built. Add an allow button check to test if no unit exists to disable a button

To post a comment you must log in.
Revision history for this message
Pali (pali) wrote :

Patch is simple and looks OK, commit it.

review: Approve
Revision history for this message
cybermind (iddqd-mail) wrote :

Why not to use DefineUnitAllow function which has the same functionality?

Revision history for this message
timfelgentreff (timfelgentreff) wrote :

@cybermind you're right, DefineUnitAllow allows me to limit the number of town halls to 1, but the button is still shown. I'd like the button to be hidden if you cannot actually build the town hall

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/include/interface.h'
--- src/include/interface.h 2013-03-03 15:23:19 +0000
+++ src/include/interface.h 2013-05-22 23:26:26 +0000
@@ -405,6 +405,8 @@
405extern bool ButtonCheckUnitsOr(const CUnit &unit, const ButtonAction &button);405extern bool ButtonCheckUnitsOr(const CUnit &unit, const ButtonAction &button);
406/// Check if allowed units exists406/// Check if allowed units exists
407extern bool ButtonCheckUnitsAnd(const CUnit &unit, const ButtonAction &button);407extern bool ButtonCheckUnitsAnd(const CUnit &unit, const ButtonAction &button);
408/// Check if units don't exist
409extern bool ButtonCheckUnitsNot(const CUnit &unit, const ButtonAction &button);
408/// Check if have network play410/// Check if have network play
409extern bool ButtonCheckNetwork(const CUnit &unit, const ButtonAction &button);411extern bool ButtonCheckNetwork(const CUnit &unit, const ButtonAction &button);
410/// Check if don't have network play412/// Check if don't have network play
411413
=== modified file 'src/ui/button_checks.cpp'
--- src/ui/button_checks.cpp 2012-08-31 13:16:50 +0000
+++ src/ui/button_checks.cpp 2013-05-22 23:26:26 +0000
@@ -203,6 +203,19 @@
203}203}
204204
205/**205/**
206** Check for button enabled, if no unit is available.
207**
208** @param unit Pointer to unit for button.
209** @param button Pointer to button to check/enable.
210**
211** @return True if enabled.
212*/
213bool ButtonCheckUnitsNot(const CUnit &unit, const ButtonAction &button)
214{
215 return !ButtonCheckUnitsAnd(unit, button);
216}
217
218/**
206** Check if network play is enabled.219** Check if network play is enabled.
207**220**
208** @param unit Pointer to unit for button.221** @param unit Pointer to unit for button.
209222
=== modified file 'src/ui/script_ui.cpp'
--- src/ui/script_ui.cpp 2013-04-30 18:36:53 +0000
+++ src/ui/script_ui.cpp 2013-05-22 23:26:26 +0000
@@ -968,6 +968,8 @@
968 ba.Allowed = ButtonCheckUnitsOr;968 ba.Allowed = ButtonCheckUnitsOr;
969 } else if (!strcmp(value, "check-units-and")) {969 } else if (!strcmp(value, "check-units-and")) {
970 ba.Allowed = ButtonCheckUnitsAnd;970 ba.Allowed = ButtonCheckUnitsAnd;
971 } else if (!strcmp(value, "check-units-not")) {
972 ba.Allowed = ButtonCheckUnitsNot;
971 } else if (!strcmp(value, "check-network")) {973 } else if (!strcmp(value, "check-network")) {
972 ba.Allowed = ButtonCheckNetwork;974 ba.Allowed = ButtonCheckNetwork;
973 } else if (!strcmp(value, "check-no-network")) {975 } else if (!strcmp(value, "check-no-network")) {

Subscribers

People subscribed via source and target branches

to status/vote changes: