← Back to team overview

widelands-dev team mailing list archive

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

 

Benedikt Straub has proposed merging lp:~widelands-dev/widelands/economy-target-profiles into lp:widelands.

Commit message:
Forbid changing economy targets by spectators

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1827696 in widelands: "Allow users to define their own economy default settings"
  https://bugs.launchpad.net/widelands/+bug/1827696
  Bug #1831196 in widelands: "Economy profile selection doesn't work"
  https://bugs.launchpad.net/widelands/+bug/1831196
  Bug #1839948 in widelands: "Missing can_act check in EconomyOptionsWindow"
  https://bugs.launchpad.net/widelands/+bug/1839948

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/economy-target-profiles/+merge/371251

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.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/economy-target-profiles into lp:widelands.
=== modified file 'src/wui/economy_options_window.cc'
--- src/wui/economy_options_window.cc	2019-08-10 16:38:15 +0000
+++ src/wui/economy_options_window.cc	2019-08-13 11:25:16 +0000
@@ -76,6 +76,7 @@
 	b->sigclicked.connect([this] { change_target(-10); });
 	buttons->add(b);
 	b->set_repeating(true);
+	b->set_enabled(can_act);
 	buttons->add_space(8);
 	b = new UI::Button(buttons, "decrease_target", 0, 0, 44, 28, UI::ButtonStyle::kWuiSecondary,
 	                   g_gr->images().get("images/ui_basic/scrollbar_down.png"),
@@ -83,6 +84,7 @@
 	b->sigclicked.connect([this] { change_target(-1); });
 	buttons->add(b);
 	b->set_repeating(true);
+	b->set_enabled(can_act);
 	buttons->add_space(24);
 
 	b = new UI::Button(buttons, "increase_target", 0, 0, 44, 28, UI::ButtonStyle::kWuiSecondary,
@@ -90,6 +92,7 @@
 	b->sigclicked.connect([this] { change_target(1); });
 	buttons->add(b);
 	b->set_repeating(true);
+	b->set_enabled(can_act);
 	buttons->add_space(8);
 	b = new UI::Button(buttons, "increase_target_fast", 0, 0, 44, 28, UI::ButtonStyle::kWuiSecondary,
 	                   g_gr->images().get("images/ui_basic/scrollbar_up_fast.png"),
@@ -97,11 +100,16 @@
 	b->sigclicked.connect([this] { change_target(10); });
 	buttons->add(b);
 	b->set_repeating(true);
+	b->set_enabled(can_act);
 
 	dropdown_.set_tooltip(_("Profile to apply to the selected items"));
 	dropdown_box_.set_size(40, 20);  // Prevent assert failures
 	dropdown_box_.add(&dropdown_, UI::Box::Resizing::kFullSize);
-	dropdown_.selected.connect([this] { reset_target(); });
+	if (can_act) {
+		dropdown_.selected.connect([this] { reset_target(); });
+	} else {
+		dropdown_.set_enabled(false);
+	}
 
 	b = new UI::Button(&dropdown_box_, "save_targets", 0, 0, 34, 34, UI::ButtonStyle::kWuiMenu,
 	                   g_gr->images().get("images/wui/menus/save_game.png"),
@@ -239,16 +247,11 @@
      serial_(serial),
      player_(player),
      type_(type),
-     can_act_(can_act),
-     display_(this, 0, 0, serial_, player_, type_, can_act_),
+     display_(this, 0, 0, serial_, player_, type_, can_act),
      economy_options_window_(eco_window) {
 	add(&display_, UI::Box::Resizing::kFullSize);
 
 	display_.set_hgap(AbstractWaresDisplay::calc_hgap(display_.get_extent().w, min_w));
-
-	if (!can_act_) {
-		return;
-	}
 }
 
 void EconomyOptionsWindow::EconomyOptionsPanel::set_economy(Widelands::Serial serial) {

=== modified file 'src/wui/economy_options_window.h'
--- src/wui/economy_options_window.h	2019-05-14 18:08:22 +0000
+++ src/wui/economy_options_window.h	2019-08-13 11:25:16 +0000
@@ -117,7 +117,6 @@
 		Widelands::Serial serial_;
 		Widelands::Player* player_;
 		Widelands::WareWorker type_;
-		bool can_act_;
 		TargetWaresDisplay display_;
 		EconomyOptionsWindow* economy_options_window_;
 	};


Follow ups