Make the diff smaller with an early return?
If (!canact) {Return;}
> Am 02.12.2017 um 12:17 schrieb GunChleoc <email address hidden>: > > GunChleoc has proposed merging lp:~widelands-dev/widelands/can_act into lp:widelands. > > Commit message: > Remove buttons from economy options window for spectators. > > Requested reviews: > Widelands Developers (widelands-dev) > Related bugs: > Bug #1735090 in widelands: "Replays crash when a training site construction window is open" > https://bugs.launchpad.net/widelands/+bug/1735090 > > For more details, see: > https://code.launchpad.net/~widelands-dev/widelands/can_act/+merge/334633 > > A small cosmetic change. > -- > You are subscribed to branch lp:widelands. > === modified file 'src/wui/economy_options_window.cc' --- src/wui/economy_options_window.cc 2017-11-29 21:40:56 +0000 +++ src/wui/economy_options_window.cc 2017-12-02 11:16:37 +0000 @@ -128,31 +128,30 @@ display_(this, 0, 0, type_, can_act_, economy) { add(&display_, UI::Box::Resizing::kFullSize); - UI::Box* buttons = new UI::Box(this, 0, 0, UI::Box::Horizontal); - add(buttons); - - UI::Button* b = - new UI::Button(buttons, "decrease_target", 0, 0, 34, 34, - g_gr->images().get("images/ui_basic/but4.png"), "-", _("Decrease target")); - b->set_enabled(can_act_); - b->sigclicked.connect(boost::bind(&EconomyOptionsPanel::change_target, this, -1)); - buttons->add(b); - b->set_repeating(true); - buttons->add_space(8); - - b = new UI::Button(buttons, "increase_target", 0, 0, 34, 34, - g_gr->images().get("images/ui_basic/but4.png"), "+", _("Increase target")); - b->set_enabled(can_act_); - b->sigclicked.connect(boost::bind(&EconomyOptionsPanel::change_target, this, 1)); - buttons->add(b); - b->set_repeating(true); - buttons->add_space(8); - - b = new UI::Button(buttons, "reset_target", 0, 0, 34, 34, - g_gr->images().get("images/ui_basic/but4.png"), "R", _("Reset to default")); - b->set_enabled(can_act_); - b->sigclicked.connect(boost::bind(&EconomyOptionsPanel::reset_target, this)); - buttons->add(b); + if (can_act_) { + UI::Box* buttons = new UI::Box(this, 0, 0, UI::Box::Horizontal); + add(buttons); + + UI::Button* b = + new UI::Button(buttons, "decrease_target", 0, 0, 34, 34, + g_gr->images().get("images/ui_basic/but4.png"), "-", _("Decrease target")); + b->sigclicked.connect(boost::bind(&EconomyOptionsPanel::change_target, this, -1)); + buttons->add(b); + b->set_repeating(true); + buttons->add_space(8); + + b = new UI::Button(buttons, "increase_target", 0, 0, 34, 34, + g_gr->images().get("images/ui_basic/but4.png"), "+", _("Increase target")); + b->sigclicked.connect(boost::bind(&EconomyOptionsPanel::change_target, this, 1)); + buttons->add(b); + b->set_repeating(true); + buttons->add_space(8); + + b = new UI::Button(buttons, "reset_target", 0, 0, 34, 34, + g_gr->images().get("images/ui_basic/but4.png"), "R", _("Reset to default")); + b->sigclicked.connect(boost::bind(&EconomyOptionsPanel::reset_target, this)); + buttons->add(b); + } } void EconomyOptionsWindow::EconomyOptionsPanel::set_economy(Widelands::Economy* economy) {
« Back to merge proposal
Make the diff smaller with an early return?
If (!canact) {Return;}
> Am 02.12.2017 um 12:17 schrieb GunChleoc <email address hidden>: /bugs.launchpad .net/widelands/ +bug/1735090 /code.launchpad .net/~widelands -dev/widelands/ can_act/ +merge/ 334633 economy_ options_ window. cc' --- src/wui/ economy_ options_ window. cc 2017-11-29 21:40:56 +0000 +++ src/wui/ economy_ options_ window. cc 2017-12-02 11:16:37 +0000 @@ -128,31 +128,30 @@ display_(this, 0, 0, type_, can_act_, economy) { add(&display_, UI::Box: :Resizing: :kFullSize) ; - UI::Box* buttons = new UI::Box(this, 0, 0, UI::Box: :Horizontal) ; - add(buttons); - - UI::Button* b = - new UI::Button(buttons, "decrease_target", 0, 0, 34, 34, - g_gr->images( ).get(" images/ ui_basic/ but4.png" ), "-", _("Decrease target")); - b->set_ enabled( can_act_ ); - b->sigclicked. connect( boost:: bind(&EconomyOp tionsPanel: :change_ target, this, -1)); - buttons->add(b); - b->set_ repeating( true); - buttons- >add_space( 8); - - b = new UI::Button(buttons, "increase_target", 0, 0, 34, 34, - g_gr->images( ).get(" images/ ui_basic/ but4.png" ), "+", _("Increase target")); - b->set_ enabled( can_act_ ); - b->sigclicked. connect( boost:: bind(&EconomyOp tionsPanel: :change_ target, this, 1)); - buttons->add(b); - b->set_ repeating( true); - buttons- >add_space( 8); - - b = new UI::Button(buttons, "reset_target", 0, 0, 34, 34, - g_gr->images( ).get(" images/ ui_basic/ but4.png" ), "R", _("Reset to default")); - b->set_ enabled( can_act_ ); - b->sigclicked. connect( boost:: bind(&EconomyOp tionsPanel: :reset_ target, this)); - buttons->add(b); + if (can_act_) { + UI::Box* buttons = new UI::Box(this, 0, 0, UI::Box: :Horizontal) ; + add(buttons); + + UI::Button* b = + new UI::Button(buttons, "decrease_target", 0, 0, 34, 34, + g_gr->images( ).get(" images/ ui_basic/ but4.png" ), "-", _("Decrease target")); + b->sigclicked. connect( boost:: bind(&EconomyOp tionsPanel: :change_ target, this, -1)); + buttons->add(b); + b->set_ repeating( true); + buttons- >add_space( 8); + + b = new UI::Button(buttons, "increase_target", 0, 0, 34, 34, + g_gr->images( ).get(" images/ ui_basic/ but4.png" ), "+", _("Increase target")); + b->sigclicked. connect( boost:: bind(&EconomyOp tionsPanel: :change_ target, this, 1)); + buttons->add(b); + b->set_ repeating( true); + buttons- >add_space( 8); + + b = new UI::Button(buttons, "reset_target", 0, 0, 34, 34, + g_gr->images( ).get(" images/ ui_basic/ but4.png" ), "R", _("Reset to default")); + b->sigclicked. connect( boost:: bind(&EconomyOp tionsPanel: :reset_ target, this)); + buttons->add(b); + } } void EconomyOptionsW indow:: EconomyOptionsP anel::set_ economy( Widelands: :Economy* economy) {
>
> GunChleoc has proposed merging lp:~widelands-dev/widelands/can_act into lp:widelands.
>
> Commit message:
> Remove buttons from economy options window for spectators.
>
> Requested reviews:
> Widelands Developers (widelands-dev)
> Related bugs:
> Bug #1735090 in widelands: "Replays crash when a training site construction window is open"
> https:/
>
> For more details, see:
> https:/
>
> A small cosmetic change.
> --
> You are subscribed to branch lp:widelands.
> === modified file 'src/wui/