Merge lp:~widelands-dev/widelands/economy-target-profiles into lp:widelands

Proposed by Benedikt Straub
Status: Merged
Merged at revision: 9179
Proposed branch: lp:~widelands-dev/widelands/economy-target-profiles
Merge into: lp:widelands
Diff against target: 75 lines (+10/-8)
2 files modified
src/wui/economy_options_window.cc (+10/-7)
src/wui/economy_options_window.h (+0/-1)
To merge this branch: bzr merge lp:~widelands-dev/widelands/economy-target-profiles
Reviewer Review Type Date Requested Status
GunChleoc Approve
Review via email: mp+371251@code.launchpad.net

Commit message

Forbid changing economy targets by spectators

Description of the change

Added some missing checks for can_act and got rid of an unused variable.
It is still allowed to save another player´s targets to disk though as this does not affect the game.

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

LGTM :)

Do we want to disable the save button too?

Revision history for this message
Benedikt Straub (nordfriese) wrote :

It cannot affect the game, so this isn´t necessary. But perhaps one might want to save some clever economy settings of another player for future use in own games, so why not allow it?

Revision history for this message
GunChleoc (gunchleoc) wrote :

OK, let's have it then :)

@bunnybot merge

review: Approve
Revision history for this message
bunnybot (widelandsofficial) wrote :

Continuous integration builds have changed state:

Travis build 5320. State: passed. Details: https://travis-ci.org/widelands/widelands/builds/571293137.
Appveyor build 5092. State: success. Details: https://ci.appveyor.com/project/widelands-dev/widelands/build/_widelands_dev_widelands_economy_target_profiles-5092.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/wui/economy_options_window.cc'
2--- src/wui/economy_options_window.cc 2019-08-10 16:38:15 +0000
3+++ src/wui/economy_options_window.cc 2019-08-13 11:25:16 +0000
4@@ -76,6 +76,7 @@
5 b->sigclicked.connect([this] { change_target(-10); });
6 buttons->add(b);
7 b->set_repeating(true);
8+ b->set_enabled(can_act);
9 buttons->add_space(8);
10 b = new UI::Button(buttons, "decrease_target", 0, 0, 44, 28, UI::ButtonStyle::kWuiSecondary,
11 g_gr->images().get("images/ui_basic/scrollbar_down.png"),
12@@ -83,6 +84,7 @@
13 b->sigclicked.connect([this] { change_target(-1); });
14 buttons->add(b);
15 b->set_repeating(true);
16+ b->set_enabled(can_act);
17 buttons->add_space(24);
18
19 b = new UI::Button(buttons, "increase_target", 0, 0, 44, 28, UI::ButtonStyle::kWuiSecondary,
20@@ -90,6 +92,7 @@
21 b->sigclicked.connect([this] { change_target(1); });
22 buttons->add(b);
23 b->set_repeating(true);
24+ b->set_enabled(can_act);
25 buttons->add_space(8);
26 b = new UI::Button(buttons, "increase_target_fast", 0, 0, 44, 28, UI::ButtonStyle::kWuiSecondary,
27 g_gr->images().get("images/ui_basic/scrollbar_up_fast.png"),
28@@ -97,11 +100,16 @@
29 b->sigclicked.connect([this] { change_target(10); });
30 buttons->add(b);
31 b->set_repeating(true);
32+ b->set_enabled(can_act);
33
34 dropdown_.set_tooltip(_("Profile to apply to the selected items"));
35 dropdown_box_.set_size(40, 20); // Prevent assert failures
36 dropdown_box_.add(&dropdown_, UI::Box::Resizing::kFullSize);
37- dropdown_.selected.connect([this] { reset_target(); });
38+ if (can_act) {
39+ dropdown_.selected.connect([this] { reset_target(); });
40+ } else {
41+ dropdown_.set_enabled(false);
42+ }
43
44 b = new UI::Button(&dropdown_box_, "save_targets", 0, 0, 34, 34, UI::ButtonStyle::kWuiMenu,
45 g_gr->images().get("images/wui/menus/save_game.png"),
46@@ -239,16 +247,11 @@
47 serial_(serial),
48 player_(player),
49 type_(type),
50- can_act_(can_act),
51- display_(this, 0, 0, serial_, player_, type_, can_act_),
52+ display_(this, 0, 0, serial_, player_, type_, can_act),
53 economy_options_window_(eco_window) {
54 add(&display_, UI::Box::Resizing::kFullSize);
55
56 display_.set_hgap(AbstractWaresDisplay::calc_hgap(display_.get_extent().w, min_w));
57-
58- if (!can_act_) {
59- return;
60- }
61 }
62
63 void EconomyOptionsWindow::EconomyOptionsPanel::set_economy(Widelands::Serial serial) {
64
65=== modified file 'src/wui/economy_options_window.h'
66--- src/wui/economy_options_window.h 2019-05-14 18:08:22 +0000
67+++ src/wui/economy_options_window.h 2019-08-13 11:25:16 +0000
68@@ -117,7 +117,6 @@
69 Widelands::Serial serial_;
70 Widelands::Player* player_;
71 Widelands::WareWorker type_;
72- bool can_act_;
73 TargetWaresDisplay display_;
74 EconomyOptionsWindow* economy_options_window_;
75 };

Subscribers

People subscribed via source and target branches

to status/vote changes: