widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #08941
[Merge] lp:~widelands-dev/widelands/actionconfirm_improvements into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/actionconfirm_improvements into lp:widelands.
Commit message:
Actionconfirm redesign and a fix to multilinetextarea:
- Actionconfirm now uses Box layout and resizes according to text size.
- Removed building names from confirmation messages, as they cause grammar problems in some languages.
- Added supplementary warning to enhancement message for military sites.
- Fixed fuzzy text in multilinetextarea.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/actionconfirm_improvements/+merge/312301
Somebody accidentally razed their tower when enhancing it, so I added a warning to the confirm message. This snowballed into a little redesign for the action confirm dialog.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/actionconfirm_improvements into lp:widelands.
=== modified file 'src/ui_basic/multilinetextarea.cc'
--- src/ui_basic/multilinetextarea.cc 2016-10-29 06:41:42 +0000
+++ src/ui_basic/multilinetextarea.cc 2016-12-01 20:40:53 +0000
@@ -158,11 +158,11 @@
uint32_t blit_height = std::min(text_im->height(), static_cast<int>(get_inner_h()));
if (blit_width > 0 && blit_height > 0) {
- float anchor = 0.f;
+ float anchor = 0;
Align alignment = mirror_alignment(align_);
switch (alignment & UI::Align::kHorizontal) {
case UI::Align::kHCenter:
- anchor = (get_eff_w() - blit_width) / 2.f;
+ anchor = (get_eff_w() - blit_width) / 2;
break;
case UI::Align::kRight:
anchor = get_eff_w() - blit_width - RICHTEXT_MARGIN;
=== modified file 'src/wui/actionconfirm.cc'
--- src/wui/actionconfirm.cc 2016-11-23 08:31:25 +0000
+++ src/wui/actionconfirm.cc 2016-12-01 20:40:53 +0000
@@ -28,6 +28,7 @@
#include "logic/map_objects/tribes/building.h"
#include "logic/map_objects/tribes/ship.h"
#include "logic/player.h"
+#include "ui_basic/box.h"
#include "ui_basic/multilinetextarea.h"
#include "ui_basic/window.h"
#include "wui/interactive_player.h"
@@ -127,19 +128,38 @@
Widelands::MapObject& map_object)
: UI::Window(&parent, "building_action_confirm", 0, 0, 200, 120, windowtitle),
object_(&map_object) {
- new UI::MultilineTextarea(this, 0, 0, 200, 74, message, UI::Align::kCenter);
-
- UI::Button* okbtn = new UI::Button(this, "ok", UI::g_fh1->fontset()->is_rtl() ? 6 : 114, 80, 80,
- 34, g_gr->images().get("images/ui_basic/but4.png"),
- g_gr->images().get("images/wui/menu_okay.png"));
+ const int padding = 6;
+ UI::Box* main_box = new UI::Box(this, padding, padding, UI::Box::Vertical);
+ UI::Box* button_box = new UI::Box(main_box, 0, 0, UI::Box::Horizontal);
+
+ UI::MultilineTextarea* textarea =
+ new UI::MultilineTextarea(main_box, 0, 0, 200, 74, message, UI::Align::kCenter,
+ g_gr->images().get("images/ui_basic/but1.png"),
+ UI::MultilineTextarea::ScrollMode::kNoScrolling);
+ textarea->force_new_renderer();
+
+ UI::Button* okbtn =
+ new UI::Button(button_box, "ok", 0, 0, 80, 34, g_gr->images().get("images/ui_basic/but4.png"),
+ g_gr->images().get("images/wui/menu_okay.png"));
okbtn->sigclicked.connect(boost::bind(&ActionConfirm::ok, this));
- UI::Button* cancelbtn =
- new UI::Button(this, "abort", UI::g_fh1->fontset()->is_rtl() ? 114 : 6, 80, 80, 34,
- g_gr->images().get("images/ui_basic/but4.png"),
- g_gr->images().get("images/wui/menu_abort.png"));
+ UI::Button* cancelbtn = new UI::Button(button_box, "abort", 0, 0, 80, 34,
+ g_gr->images().get("images/ui_basic/but4.png"),
+ g_gr->images().get("images/wui/menu_abort.png"));
cancelbtn->sigclicked.connect(boost::bind(&ActionConfirm::die, this));
+ button_box->add(
+ UI::g_fh1->fontset()->is_rtl() ? okbtn : cancelbtn, UI::Align::kLeft, false, true);
+ button_box->add_space(2 * padding);
+ button_box->add(
+ UI::g_fh1->fontset()->is_rtl() ? cancelbtn : okbtn, UI::Align::kLeft, false, true);
+ main_box->add(textarea, UI::Align::kLeft);
+ main_box->add_space(1.5 * padding);
+ main_box->add(button_box, UI::Align::kLeft, true);
+ button_box->set_size(textarea->get_w(), okbtn->get_h());
+ main_box->set_size(textarea->get_w(), textarea->get_h() + button_box->get_h() + 1.5 * padding);
+ set_inner_size(main_box->get_w() + 2 * padding, main_box->get_h() + 2 * padding);
+
center_to_parent();
cancelbtn->center_mouse();
}
@@ -152,12 +172,10 @@
BulldozeConfirm::BulldozeConfirm(InteractivePlayer& parent,
Widelands::Building& building,
Widelands::PlayerImmovable* todestroy)
- : ActionConfirm(
- parent,
- _("Destroy building?"),
- (boost::format(_("Do you really want to destroy this %s?")) % building.descr().descname())
- .str(),
- building),
+ : ActionConfirm(parent,
+ _("Destroy building?"),
+ _("Do you really want to destroy this building?"),
+ building),
todestroy_(todestroy ? todestroy : &building) {
// Nothing special to do
}
@@ -199,12 +217,10 @@
===============
*/
DismantleConfirm::DismantleConfirm(InteractivePlayer& parent, Widelands::Building& building)
- : ActionConfirm(
- parent,
- _("Dismantle building?"),
- (boost::format(_("Do you really want to dismantle this %s?")) % building.descr().descname())
- .str(),
- building) {
+ : ActionConfirm(parent,
+ _("Dismantle building?"),
+ _("Do you really want to dismantle this building?"),
+ building) {
// Nothing special to do
}
@@ -249,8 +265,12 @@
: ActionConfirm(
parent,
_("Enhance building?"),
- (boost::format(_("Do you really want to enhance this %s?")) % building.descr().descname())
- .str(),
+ building.descr().type() == Widelands::MapObjectType::MILITARYSITE ?
+ (boost::format("%s\n\n%s") % _("Do you really want to enhance this building?") %
+ /** TRANSLATORS: Warning message when player wants to enhance a military building */
+ _("Be careful if the enemy is near!"))
+ .str() :
+ _("Do you really want to enhance this building?"),
building),
id_(id) {
// Nothing special to do
Follow ups