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
1=== modified file 'src/include/interface.h'
2--- src/include/interface.h 2013-03-03 15:23:19 +0000
3+++ src/include/interface.h 2013-05-22 23:26:26 +0000
4@@ -405,6 +405,8 @@
5 extern bool ButtonCheckUnitsOr(const CUnit &unit, const ButtonAction &button);
6 /// Check if allowed units exists
7 extern bool ButtonCheckUnitsAnd(const CUnit &unit, const ButtonAction &button);
8+/// Check if units don't exist
9+extern bool ButtonCheckUnitsNot(const CUnit &unit, const ButtonAction &button);
10 /// Check if have network play
11 extern bool ButtonCheckNetwork(const CUnit &unit, const ButtonAction &button);
12 /// Check if don't have network play
13
14=== modified file 'src/ui/button_checks.cpp'
15--- src/ui/button_checks.cpp 2012-08-31 13:16:50 +0000
16+++ src/ui/button_checks.cpp 2013-05-22 23:26:26 +0000
17@@ -203,6 +203,19 @@
18 }
19
20 /**
21+** Check for button enabled, if no unit is available.
22+**
23+** @param unit Pointer to unit for button.
24+** @param button Pointer to button to check/enable.
25+**
26+** @return True if enabled.
27+*/
28+bool ButtonCheckUnitsNot(const CUnit &unit, const ButtonAction &button)
29+{
30+ return !ButtonCheckUnitsAnd(unit, button);
31+}
32+
33+/**
34 ** Check if network play is enabled.
35 **
36 ** @param unit Pointer to unit for button.
37
38=== modified file 'src/ui/script_ui.cpp'
39--- src/ui/script_ui.cpp 2013-04-30 18:36:53 +0000
40+++ src/ui/script_ui.cpp 2013-05-22 23:26:26 +0000
41@@ -968,6 +968,8 @@
42 ba.Allowed = ButtonCheckUnitsOr;
43 } else if (!strcmp(value, "check-units-and")) {
44 ba.Allowed = ButtonCheckUnitsAnd;
45+ } else if (!strcmp(value, "check-units-not")) {
46+ ba.Allowed = ButtonCheckUnitsNot;
47 } else if (!strcmp(value, "check-network")) {
48 ba.Allowed = ButtonCheckNetwork;
49 } else if (!strcmp(value, "check-no-network")) {

Subscribers

People subscribed via source and target branches

to status/vote changes: