widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #08472
[Merge] lp:~widelands-dev/widelands/buttons_constructor_cleanup into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/buttons_constructor_cleanup into lp:widelands.
Commit message:
Replaced bools in Buttons with enum classes.
- Replaced 'permpressed' and 'flat' bools with enum class 'Style'.
- Replaced 'keep_image_size' with enum class 'ImageMode'.
- Removed 'bool const enabled = true' from constructors.
- Cleanup: Removed default parameters from constructor calls.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/buttons_constructor_cleanup/+merge/308042
Cleaned up too many bools in Button constructors to make code more readable.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/buttons_constructor_cleanup into lp:widelands.
=== modified file 'src/editor/ui_menus/player_menu.cc'
--- src/editor/ui_menus/player_menu.cc 2016-08-04 15:49:05 +0000
+++ src/editor/ui_menus/player_menu.cc 2016-10-10 12:59:45 +0000
@@ -72,8 +72,7 @@
20,
g_gr->images().get("images/ui_basic/but1.png"),
g_gr->images().get("images/ui_basic/scrollbar_up.png"),
- _("Add player"),
- parent.egbase().map().get_nrplayers() < MAX_PLAYERS),
+ _("Add player")),
remove_last_player_(this,
"remove_last_player",
5,
@@ -82,8 +81,7 @@
20,
g_gr->images().get("images/ui_basic/but1.png"),
g_gr->images().get("images/ui_basic/scrollbar_down.png"),
- _("Remove last player"),
- 1 < parent.egbase().map().get_nrplayers()),
+ _("Remove last player")),
tribenames_(eia().egbase().tribes().get_all_tribenames()) {
add_player_.sigclicked.connect(
boost::bind(&EditorPlayerMenu::clicked_add_player, boost::ref(*this)));
@@ -211,6 +209,8 @@
plr_set_pos_buts_[p - 1]->set_pic(player_image);
posy += size + spacing;
}
+ add_player_.set_enabled(nr_players < MAX_PLAYERS);
+ remove_last_player_.set_enabled(1 < nr_players);
set_inner_size(get_inner_w(), posy + spacing);
}
@@ -228,8 +228,6 @@
}
map.set_scenario_player_tribe(nr_players, tribenames_[0]);
eia().set_need_save(true);
- add_player_.set_enabled(nr_players < MAX_PLAYERS);
- remove_last_player_.set_enabled(true);
update();
}
@@ -252,9 +250,6 @@
set_starting_pos_clicked(nr_players);
}
map.set_nrplayers(nr_players);
- add_player_.set_enabled(nr_players < MAX_PLAYERS);
- remove_last_player_.set_enabled(1 < nr_players);
-
update();
// TODO(SirVer): Take steps when the player is referenced someplace. Not
// TODO(SirVer): currently possible in the editor though.
=== modified file 'src/editor/ui_menus/toolsize_menu.cc'
--- src/editor/ui_menus/toolsize_menu.cc 2016-08-04 15:49:05 +0000
+++ src/editor/ui_menus/toolsize_menu.cc 2016-10-10 12:59:45 +0000
@@ -46,9 +46,7 @@
20,
20,
g_gr->images().get("images/ui_basic/but0.png"),
- g_gr->images().get("images/ui_basic/scrollbar_up.png"),
- std::string(),
- parent.get_sel_radius() < MAX_TOOL_AREA),
+ g_gr->images().get("images/ui_basic/scrollbar_up.png")),
decrease_(this,
"decr",
get_inner_w() / 2 + 10,
@@ -56,9 +54,7 @@
20,
20,
g_gr->images().get("images/ui_basic/but0.png"),
- g_gr->images().get("images/ui_basic/scrollbar_down.png"),
- std::string(),
- 0 < parent.get_sel_radius()),
+ g_gr->images().get("images/ui_basic/scrollbar_down.png")),
value_(0) {
increase_.sigclicked.connect(
boost::bind(&EditorToolsizeMenu::increase_radius, boost::ref(*this)));
=== modified file 'src/ui_basic/button.cc'
--- src/ui_basic/button.cc 2016-08-04 15:49:05 +0000
+++ src/ui_basic/button.cc 2016-10-10 12:59:45 +0000
@@ -43,17 +43,14 @@
const Image* bg_pic,
const std::string& title_text,
const std::string& tooltip_text,
- bool const init_enabled,
- bool const flat)
+ UI::Button::Style init_style)
: NamedPanel(parent, name, x, y, w, h, tooltip_text),
highlighted_(false),
pressed_(false),
- permpressed_(false),
- enabled_(init_enabled),
+ enabled_(true),
+ style_(init_style),
repeating_(false),
- flat_(flat),
- keep_image_size_(false),
- draw_flat_background_(false),
+ image_mode_(UI::Button::ImageMode::kShrink),
time_nextact_(0),
title_(title_text),
pic_background_(bg_pic),
@@ -80,18 +77,15 @@
const Image* bg_pic,
const Image* fg_pic,
const std::string& tooltip_text,
- bool const init_enabled,
- bool const flat,
- const bool keep_image_size)
+ UI::Button::Style init_style,
+ ImageMode mode)
: NamedPanel(parent, name, x, y, w, h, tooltip_text),
highlighted_(false),
pressed_(false),
- permpressed_(false),
- enabled_(init_enabled),
+ enabled_(true),
+ style_(init_style),
repeating_(false),
- flat_(flat),
- keep_image_size_(keep_image_size),
- draw_flat_background_(false),
+ image_mode_(mode),
time_nextact_(0),
pic_background_(bg_pic),
pic_custom_(fg_pic),
@@ -152,18 +146,17 @@
*/
void Button::draw(RenderTarget& dst) {
// Draw the background
- if (!flat_ || draw_flat_background_) {
- assert(pic_background_);
+ if (pic_background_) {
dst.fill_rect(Rect(Point(0, 0), get_w(), get_h()), RGBAColor(0, 0, 0, 255));
dst.tile(Rect(Point(0, 0), get_w(), get_h()), pic_background_, Point(get_x(), get_y()));
}
- if (enabled_ && highlighted_ && !flat_)
+ if (enabled_ && highlighted_ && style_ != Style::kFlat)
dst.brighten_rect(Rect(Point(0, 0), get_w(), get_h()), MOUSE_OVER_BRIGHT_FACTOR);
// If we've got a picture, draw it centered
if (pic_custom_) {
- if (keep_image_size_) {
+ if (image_mode_ == UI::Button::ImageMode::kUnscaled) {
if (enabled_) {
// ">> 1" is almost like "/ 2", but simpler for signed types (difference
// is that -1 >> 1 is -1 but -1 / 2 is 0).
@@ -217,14 +210,11 @@
// stays pressed when it is pressed once
RGBAColor black(0, 0, 0, 255);
- // permpressed_ is true, we invert the behaviour on pressed_
- bool draw_pressed = permpressed_ ? !(pressed_ && highlighted_) : (pressed_ && highlighted_);
-
- if (!flat_) {
+ if (style_ != Style::kFlat) {
assert(2 <= get_w());
assert(2 <= get_h());
- // button is a normal one, not flat
- if (!draw_pressed) {
+ // Button is a normal one, not flat. We invert the behaviour for kPermpressed.
+ if ((style_ == Style::kPermpressed) == (pressed_ && highlighted_)) {
// top edge
dst.brighten_rect(Rect(Point(0, 0), get_w(), 2), BUTTON_EDGE_BRIGHT_FACTOR);
// left edge
@@ -340,17 +330,23 @@
return true; // We handle this always by lighting up
}
-void Button::set_perm_pressed(bool state) {
- if (state != permpressed_) {
- permpressed_ = state;
+void Button::set_style(UI::Button::Style input_style) {
+ style_ = input_style;
+}
+
+void Button::set_perm_pressed(bool pressed) {
+ set_style(pressed ? UI::Button::Style::kPermpressed : UI::Button::Style::kRaised);
+}
+
+void Button::toggle() {
+ switch (style_) {
+ case UI::Button::Style::kRaised:
+ style_ = UI::Button::Style::kPermpressed;
+ break;
+ case UI::Button::Style::kPermpressed:
+ style_ = UI::Button::Style::kRaised;
+ break;
+ default:; // Do nothing for flat buttons
}
}
-
-void Button::set_flat(bool flat) {
- flat_ = flat;
-}
-
-void Button::set_draw_flat_background(bool set) {
- draw_flat_background_ = set;
-}
}
=== modified file 'src/ui_basic/button.h'
--- src/ui_basic/button.h 2016-08-04 15:49:05 +0000
+++ src/ui_basic/button.h 2016-10-10 12:59:45 +0000
@@ -36,6 +36,17 @@
/// This is all that is needed in most cases, but if there is a need to give a
/// callback function to the button, there are some templates for that below.
struct Button : public NamedPanel {
+ enum class Style {
+ kRaised, // Normal raised Button
+ kPermpressed, // Button will appear pressed
+ kFlat // Flat button with simple coloured outline
+ };
+
+ enum class ImageMode {
+ kShrink, // Shrink foreground image to fit into the button
+ kUnscaled // Show the foreground image without any scaling
+ };
+
Button /// for textual buttons
(Panel* const parent,
const std::string& name,
@@ -46,9 +57,8 @@
const Image* background_picture_id,
const std::string& title_text,
const std::string& tooltip_text = std::string(),
- bool const enabled = true,
- bool const flat = false);
- // TODO(GunChleoc): We have a lot of bools here. Introduce an enum class.
+ UI::Button::Style init_style = UI::Button::Style::kRaised);
+
Button /// for pictorial buttons
(Panel* const parent,
const std::string& name,
@@ -59,9 +69,8 @@
const Image* background_picture_id,
const Image* foreground_picture_id,
const std::string& tooltip_text = std::string(),
- bool const enabled = true,
- bool const flat = false,
- bool const keep_image_size = false);
+ UI::Button::Style init_style = UI::Button::Style::kRaised,
+ UI::Button::ImageMode mode = UI::Button::ImageMode::kShrink);
~Button();
void set_pic(const Image* pic);
@@ -90,16 +99,18 @@
bool handle_mouserelease(uint8_t btn, int32_t x, int32_t y) override;
bool handle_mousemove(uint8_t, int32_t, int32_t, int32_t, int32_t) override;
- // Set the permanently pressed state of the button
- void set_perm_pressed(bool state);
- bool get_perm_pressed() const {
- return permpressed_;
+ /// Sets the visual style of the button
+ void set_style(UI::Button::Style input_style);
+ UI::Button::Style style() const {
+ return style_;
}
- // Set button to flat / not flat
- void set_flat(bool flat);
- // If no background is drawn, the button is drawn over the current background
- void set_draw_flat_background(bool set);
+ /// Convenience function. If 'pressed', sets the style to kPermpressed, otherwise to kRaised.
+ void set_perm_pressed(bool pressed);
+
+
+ /// Convenience function. Toggles between raised and permpressed style
+ void toggle();
boost::signals2::signal<void()> sigclicked;
boost::signals2::signal<void()> sigmousein;
@@ -111,12 +122,10 @@
bool highlighted_; // mouse is over the button
bool pressed_; // mouse is clicked over the button
- bool permpressed_; // button should appear pressed
bool enabled_;
+ UI::Button::Style style_;
bool repeating_;
- bool flat_;
- bool keep_image_size_; // Keep image's original size and center it
- bool draw_flat_background_;
+ const UI::Button::ImageMode image_mode_;
uint32_t time_nextact_;
=== modified file 'src/ui_basic/icongrid.cc'
--- src/ui_basic/icongrid.cc 2016-08-04 15:49:05 +0000
+++ src/ui_basic/icongrid.cc 2016-10-10 12:59:45 +0000
@@ -43,8 +43,7 @@
background_picture_id,
foreground_picture_id,
tooltip_text,
- true,
- true),
+ UI::Button::Style::kFlat),
icongrid_(parent),
callback_argument_id_(callback_argument_id) {
}
=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc 2016-08-04 15:49:05 +0000
+++ src/ui_basic/table.cc 2016-10-10 12:59:45 +0000
@@ -98,8 +98,7 @@
// All columns have a title button that is clickable for sorting.
// The title text can be empty.
c.btn = new Button(this, title, complete_width, 0, width, headerheight_,
- g_gr->images().get("images/ui_basic/but3.png"), title, tooltip_string,
- true, false);
+ g_gr->images().get("images/ui_basic/but3.png"), title, tooltip_string);
c.btn->sigclicked.connect(
boost::bind(&Table::header_button_clicked, boost::ref(*this), columns_.size()));
c.width = width;
=== modified file 'src/ui_fsmenu/about.cc'
--- src/ui_fsmenu/about.cc 2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/about.cc 2016-10-10 12:59:45 +0000
@@ -43,10 +43,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but2.png"),
- _("Close"),
- std::string(),
- true,
- false),
+ _("Close")),
tabs_(this,
hmargin_,
=== modified file 'src/ui_fsmenu/helpwindow.cc'
--- src/ui_fsmenu/helpwindow.cc 2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/helpwindow.cc 2016-10-10 12:59:45 +0000
@@ -48,9 +48,8 @@
width = (width == 0) ? g_gr->get_xres() * 3 / 5 : width;
height = (height == 0) ? g_gr->get_yres() * 4 / 5 : height;
- Button* btn =
- new Button(this, "ok", width / 3, 0, width / 3, 0,
- g_gr->images().get("images/ui_basic/but5.png"), _("OK"), "", true, false);
+ Button* btn = new Button(this, "ok", width / 3, 0, width / 3, 0,
+ g_gr->images().get("images/ui_basic/but5.png"), _("OK"));
btn->sigclicked.connect(boost::bind(&FullscreenHelpWindow::clicked_ok, boost::ref(*this)));
btn->set_pos(Point(btn->get_x(), height - margin - btn->get_h()));
=== modified file 'src/ui_fsmenu/internet_lobby.cc'
--- src/ui_fsmenu/internet_lobby.cc 2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/internet_lobby.cc 2016-10-10 12:59:45 +0000
@@ -61,10 +61,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but1.png"),
- _("Join this game"),
- std::string(),
- false,
- false),
+ _("Join this game")),
hostgame_(this,
"host_game",
get_w() * 17 / 25,
@@ -72,10 +69,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but1.png"),
- _("Open a new game"),
- std::string(),
- true,
- false),
+ _("Open a new game")),
back_(this,
"back",
get_w() * 17 / 25,
@@ -83,10 +77,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but0.png"),
- _("Back"),
- std::string(),
- true,
- false),
+ _("Back")),
// Edit boxes
edit_servername_(this,
=== modified file 'src/ui_fsmenu/launch_mpg.cc'
--- src/ui_fsmenu/launch_mpg.cc 2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/launch_mpg.cc 2016-10-10 12:59:45 +0000
@@ -60,7 +60,7 @@
uint32_t buth = (get_inner_h() - 2 * space) / 5;
UI::Button* btn = new UI::Button(this, "map", space, y, butw, buth,
g_gr->images().get("images/ui_basic/but0.png"), _("Map"),
- _("Select a map"), true, false);
+ _("Select a map"));
btn->sigclicked.connect(boost::bind(&MapOrSaveSelectionWindow::pressedButton,
boost::ref(*this),
FullscreenMenuBase::MenuTarget::kNormalGame));
@@ -68,14 +68,14 @@
btn = new UI::Button(this, "saved_game", space, y + buth + space, butw, buth,
g_gr->images().get("images/ui_basic/but0.png"),
/** Translators: This is a button to select a savegame */
- _("Saved Game"), _("Select a saved game"), true, false);
+ _("Saved Game"), _("Select a saved game"));
btn->sigclicked.connect(boost::bind(&MapOrSaveSelectionWindow::pressedButton,
boost::ref(*this),
FullscreenMenuBase::MenuTarget::kScenarioGame));
btn = new UI::Button(this, "cancel", space + butw / 4, y + 3 * buth + 2 * space, butw / 2,
buth, g_gr->images().get("images/ui_basic/but1.png"), _("Cancel"),
- _("Cancel selection"), true, false);
+ _("Cancel selection"));
btn->sigclicked.connect(boost::bind(&MapOrSaveSelectionWindow::pressedButton,
boost::ref(*this),
FullscreenMenuBase::MenuTarget::kBack));
@@ -118,9 +118,7 @@
buth_,
g_gr->images().get("images/ui_basic/but1.png"),
g_gr->images().get("images/wui/menus/menu_toggle_minimap.png"),
- _("Change map or saved game"),
- false,
- false),
+ _("Change map or saved game")),
ok_(this,
"ok",
right_column_x_,
@@ -128,10 +126,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but2.png"),
- _("Start game"),
- std::string(),
- false,
- false),
+ _("Start game")),
back_(this,
"back",
right_column_x_,
@@ -139,10 +134,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but0.png"),
- _("Back"),
- std::string(),
- true,
- false),
+ _("Back")),
wincondition_(this,
"win_condition",
right_column_x_,
@@ -150,10 +142,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but1.png"),
- "",
- std::string(),
- false,
- false),
+ ""),
help_button_(this,
"help",
right_column_x_ + butw_ - buth_,
@@ -162,9 +151,7 @@
buth_,
g_gr->images().get("images/ui_basic/but1.png"),
g_gr->images().get("images/ui_basic/menu_help.png"),
- _("Show the help window"),
- true,
- false),
+ _("Show the help window")),
// Text labels
title_(this, get_w() / 2, get_h() / 25, _("Multiplayer Game Setup"), UI::Align::kHCenter),
=== modified file 'src/ui_fsmenu/launch_spg.cc'
--- src/ui_fsmenu/launch_spg.cc 2016-08-27 10:15:32 +0000
+++ src/ui_fsmenu/launch_spg.cc 2016-10-10 12:59:45 +0000
@@ -73,10 +73,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but1.png"),
- _("Select map"),
- std::string(),
- false,
- false),
+ _("Select map")),
wincondition_(this,
"win_condition",
get_w() * 7 / 10,
@@ -84,10 +81,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but1.png"),
- "",
- std::string(),
- false,
- false),
+ ""),
back_(this,
"back",
get_w() * 7 / 10,
@@ -95,10 +89,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but0.png"),
- _("Back"),
- std::string(),
- true,
- false),
+ _("Back")),
ok_(this,
"ok",
get_w() * 7 / 10,
@@ -106,10 +97,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but2.png"),
- _("Start game"),
- std::string(),
- false,
- false),
+ _("Start game")),
// Text labels
title_(this, get_w() / 2, get_h() / 10, _("Launch Game"), UI::Align::kHCenter),
@@ -179,7 +167,7 @@
pos_[i] =
new UI::Button(this, "switch_to_position", get_w() / 100, y += buth_, get_h() * 17 / 500,
get_h() * 17 / 500, g_gr->images().get("images/ui_basic/but1.png"),
- player_image, _("Switch to position"), false);
+ player_image, _("Switch to position"));
pos_[i]->sigclicked.connect(
boost::bind(&FullscreenMenuLaunchSPG::switch_to_position, boost::ref(*this), i));
players_[i] = new PlayerDescriptionGroup(
=== modified file 'src/ui_fsmenu/load_map_or_game.cc'
--- src/ui_fsmenu/load_map_or_game.cc 2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/load_map_or_game.cc 2016-10-10 12:59:45 +0000
@@ -57,10 +57,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but0.png"),
- _("Back"),
- std::string(),
- true,
- false),
+ _("Back")),
ok_(this,
"ok",
get_w() - right_column_margin_ - butw_,
@@ -68,10 +65,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but2.png"),
- _("OK"),
- std::string(),
- false,
- false) {
+ _("OK")) {
}
int32_t FullscreenMenuLoadMapOrGame::get_y_from_preceding(UI::Panel& preceding_panel) {
=== modified file 'src/ui_fsmenu/loadgame.cc'
--- src/ui_fsmenu/loadgame.cc 2016-09-25 12:27:22 +0000
+++ src/ui_fsmenu/loadgame.cc 2016-10-10 12:59:45 +0000
@@ -143,10 +143,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but0.png"),
- _("Delete"),
- std::string(),
- false,
- false),
+ _("Delete")),
ta_errormessage_(this,
right_column_x_,
=== modified file 'src/ui_fsmenu/main.cc'
--- src/ui_fsmenu/main.cc 2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/main.cc 2016-10-10 12:59:45 +0000
@@ -44,10 +44,7 @@
butw_,
buth_,
g_gr->images().get(button_background_),
- _("Play Tutorial"),
- "",
- true,
- false),
+ _("Play Tutorial")),
singleplayer(&vbox,
"single_player",
0,
@@ -55,10 +52,7 @@
butw_,
buth_,
g_gr->images().get(button_background_),
- _("Single Player"),
- "",
- true,
- false),
+ _("Single Player")),
multiplayer(&vbox,
"multi_player",
0,
@@ -66,10 +60,7 @@
butw_,
buth_,
g_gr->images().get(button_background_),
- _("Multiplayer"),
- "",
- true,
- false),
+ _("Multiplayer")),
replay(&vbox,
"replay",
0,
@@ -77,32 +68,11 @@
butw_,
buth_,
g_gr->images().get(button_background_),
- _("Watch Replay"),
- "",
- true,
- false),
- editor(&vbox,
- "editor",
- 0,
- 0,
- butw_,
- buth_,
- g_gr->images().get(button_background_),
- _("Editor"),
- "",
- true,
- false),
- options(&vbox,
- "options",
- 0,
- 0,
- butw_,
- buth_,
- g_gr->images().get(button_background_),
- _("Options"),
- "",
- true,
- false),
+ _("Watch Replay")),
+ editor(
+ &vbox, "editor", 0, 0, butw_, buth_, g_gr->images().get(button_background_), _("Editor")),
+ options(
+ &vbox, "options", 0, 0, butw_, buth_, g_gr->images().get(button_background_), _("Options")),
about(&vbox,
"about",
0,
@@ -110,10 +80,7 @@
butw_,
buth_,
g_gr->images().get(button_background_),
- _("About Widelands"),
- "",
- true,
- false),
+ _("About Widelands")),
exit(&vbox,
"exit",
0,
@@ -121,10 +88,7 @@
butw_,
buth_,
g_gr->images().get(button_background_),
- _("Exit Widelands"),
- "",
- true,
- false),
+ _("Exit Widelands")),
// Textlabels
version(
=== modified file 'src/ui_fsmenu/multiplayer.cc'
--- src/ui_fsmenu/multiplayer.cc 2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/multiplayer.cc 2016-10-10 12:59:45 +0000
@@ -41,10 +41,7 @@
butw_,
buth_,
g_gr->images().get(button_background_),
- _("Internet game"),
- "",
- true,
- false),
+ _("Internet game")),
lan(&vbox,
"lan",
0,
@@ -52,21 +49,8 @@
butw_,
buth_,
g_gr->images().get(button_background_),
- _("LAN / Direct IP"),
- "",
- true,
- false),
- back(&vbox,
- "back",
- 0,
- 0,
- butw_,
- buth_,
- g_gr->images().get(button_background_),
- _("Back"),
- "",
- true,
- false) {
+ _("LAN / Direct IP")),
+ back(&vbox, "back", 0, 0, butw_, buth_, g_gr->images().get(button_background_), _("Back")) {
metaserver.sigclicked.connect(
boost::bind(&FullscreenMenuMultiPlayer::internet_login, boost::ref(*this)));
@@ -96,10 +80,10 @@
Section& s = g_options.pull_section("global");
auto_log_ = s.get_bool("auto_log", false);
if (auto_log_) {
- showloginbox = new UI::Button(
- this, "login_dialog", box_x_ + butw_ + buth_ / 4, get_h() * 6 / 25, buth_, buth_,
- g_gr->images().get("images/ui_basic/but1.png"),
- g_gr->images().get("images/ui_basic/continue.png"), _("Show login dialog"), true, false);
+ showloginbox =
+ new UI::Button(this, "login_dialog", box_x_ + butw_ + buth_ / 4, get_h() * 6 / 25, buth_,
+ buth_, g_gr->images().get("images/ui_basic/but1.png"),
+ g_gr->images().get("images/ui_basic/continue.png"), _("Show login dialog"));
showloginbox->sigclicked.connect(
boost::bind(&FullscreenMenuMultiPlayer::show_internet_login, boost::ref(*this)));
}
=== modified file 'src/ui_fsmenu/netsetup_lan.cc'
--- src/ui_fsmenu/netsetup_lan.cc 2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/netsetup_lan.cc 2016-10-10 12:59:45 +0000
@@ -51,10 +51,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but1.png"),
- _("Join this game"),
- std::string(),
- true,
- false),
+ _("Join this game")),
hostgame(this,
"host_game",
get_w() * 16 / 25,
@@ -62,10 +59,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but1.png"),
- _("Host a new game"),
- std::string(),
- true,
- false),
+ _("Host a new game")),
back(this,
"back",
get_w() * 16 / 25,
@@ -73,10 +67,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but0.png"),
- _("Back"),
- std::string(),
- true,
- false),
+ _("Back")),
loadlasthost(this,
"load_previous_host",
get_w() * 171 / 200,
@@ -85,9 +76,7 @@
buth_,
g_gr->images().get("images/ui_basic/but1.png"),
g_gr->images().get("images/ui_fsmenu/menu_load_game.png"),
- _("Load previous host"),
- true,
- false),
+ _("Load previous host")),
// Edit boxes
playername(this,
=== modified file 'src/ui_fsmenu/options.cc'
--- src/ui_fsmenu/options.cc 2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/options.cc 2016-10-10 12:59:45 +0000
@@ -113,10 +113,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but0.png"),
- _("Cancel"),
- std::string(),
- true,
- false),
+ _("Cancel")),
apply_(this,
"apply",
get_w() * 2 / 4 - butw_ / 2,
@@ -124,10 +121,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but0.png"),
- _("Apply"),
- std::string(),
- true,
- false),
+ _("Apply")),
ok_(this,
"ok",
UI::g_fh1->fontset()->is_rtl() ? get_w() * 1 / 4 - butw_ / 2 : get_w() * 3 / 4 - butw_ / 2,
@@ -135,10 +129,7 @@
butw_,
buth_,
g_gr->images().get("images/ui_basic/but2.png"),
- _("OK"),
- std::string(),
- true,
- false),
+ _("OK")),
tabs_(this,
hmargin_,
=== modified file 'src/ui_fsmenu/singleplayer.cc'
--- src/ui_fsmenu/singleplayer.cc 2016-08-04 15:49:05 +0000
+++ src/ui_fsmenu/singleplayer.cc 2016-10-10 12:59:45 +0000
@@ -38,10 +38,7 @@
butw_,
buth_,
g_gr->images().get(button_background_),
- _("New Game"),
- "",
- true,
- false),
+ _("New Game")),
campaign(&vbox,
"campaigns",
0,
@@ -49,10 +46,7 @@
butw_,
buth_,
g_gr->images().get(button_background_),
- _("Campaigns"),
- "",
- true,
- false),
+ _("Campaigns")),
load_game(&vbox,
"load_game",
0,
@@ -60,21 +54,8 @@
butw_,
buth_,
g_gr->images().get(button_background_),
- _("Load Game"),
- "",
- true,
- false),
- back(&vbox,
- "back",
- 0,
- 0,
- butw_,
- buth_,
- g_gr->images().get(button_background_),
- _("Back"),
- "",
- true,
- false) {
+ _("Load Game")),
+ back(&vbox, "back", 0, 0, butw_, buth_, g_gr->images().get(button_background_), _("Back")) {
new_game.sigclicked.connect(
boost::bind(&FullscreenMenuSinglePlayer::end_modal<FullscreenMenuBase::MenuTarget>,
boost::ref(*this), FullscreenMenuBase::MenuTarget::kNewGame));
=== modified file 'src/wui/building_statistics_menu.cc'
--- src/wui/building_statistics_menu.cc 2016-08-04 15:49:05 +0000
+++ src/wui/building_statistics_menu.cc 2016-10-10 12:59:45 +0000
@@ -264,36 +264,36 @@
navigation_buttons_[NavigationButton::PrevOwned] = new UI::Button(
&navigation_panel_, "previous_owned", get_inner_w() - 2 * kButtonRowHeight, kButtonRowHeight,
kButtonHeight, kButtonHeight, g_gr->images().get("images/ui_basic/but4.png"),
- g_gr->images().get("images/ui_basic/scrollbar_left.png"), _("Show previous building"), false);
+ g_gr->images().get("images/ui_basic/scrollbar_left.png"), _("Show previous building"));
navigation_buttons_[NavigationButton::NextOwned] = new UI::Button(
&navigation_panel_, "next_owned", get_inner_w() - kButtonRowHeight, kButtonRowHeight,
kButtonHeight, kButtonHeight, g_gr->images().get("images/ui_basic/but4.png"),
- g_gr->images().get("images/ui_basic/scrollbar_right.png"), _("Show next building"), false);
+ g_gr->images().get("images/ui_basic/scrollbar_right.png"), _("Show next building"));
navigation_buttons_[NavigationButton::PrevConstruction] = new UI::Button(
&navigation_panel_, "previous_constructed", get_inner_w() - 2 * kButtonRowHeight,
2 * kButtonRowHeight, kButtonHeight, kButtonHeight,
g_gr->images().get("images/ui_basic/but4.png"),
- g_gr->images().get("images/ui_basic/scrollbar_left.png"), _("Show previous building"), false);
+ g_gr->images().get("images/ui_basic/scrollbar_left.png"), _("Show previous building"));
navigation_buttons_[NavigationButton::NextConstruction] = new UI::Button(
&navigation_panel_, "next_constructed", get_inner_w() - kButtonRowHeight,
2 * kButtonRowHeight, kButtonHeight, kButtonHeight,
g_gr->images().get("images/ui_basic/but4.png"),
- g_gr->images().get("images/ui_basic/scrollbar_right.png"), _("Show next building"), false);
+ g_gr->images().get("images/ui_basic/scrollbar_right.png"), _("Show next building"));
navigation_buttons_[NavigationButton::PrevUnproductive] = new UI::Button(
&navigation_panel_, "previous_unproductive", get_inner_w() - 2 * kButtonRowHeight,
3 * kButtonRowHeight, kButtonHeight, kButtonHeight,
g_gr->images().get("images/ui_basic/but4.png"),
- g_gr->images().get("images/ui_basic/scrollbar_left.png"), _("Show previous building"), false);
+ g_gr->images().get("images/ui_basic/scrollbar_left.png"), _("Show previous building"));
navigation_buttons_[NavigationButton::NextUnproductive] = new UI::Button(
&navigation_panel_, "next_unproductive", get_inner_w() - kButtonRowHeight,
3 * kButtonRowHeight, kButtonHeight, kButtonHeight,
g_gr->images().get("images/ui_basic/but4.png"),
- g_gr->images().get("images/ui_basic/scrollbar_right.png"), _("Show next building"), false);
+ g_gr->images().get("images/ui_basic/scrollbar_right.png"), _("Show next building"));
navigation_buttons_[NavigationButton::PrevOwned]->sigclicked.connect(boost::bind(
&BuildingStatisticsMenu::jump_building, boost::ref(*this), JumpTarget::kOwned, true));
@@ -335,7 +335,8 @@
building_buttons_[id] = new UI::Button(
button_box, (boost::format("building_button%s") % id).str(), 0, 0, kBuildGridCellWidth,
kBuildGridCellHeight, g_gr->images().get("images/ui_basic/but1.png"),
- descr.representative_image(&iplayer().get_player()->get_playercolor()), "", false, true);
+ descr.representative_image(&iplayer().get_player()->get_playercolor()), "",
+ UI::Button::Style::kFlat);
button_box->add(building_buttons_[id], UI::Align::kLeft);
owned_labels_[id] =
@@ -718,13 +719,12 @@
if (building_button == nullptr) {
continue;
}
- building_button->set_flat(true);
+ building_button->set_style(UI::Button::Style::kFlat);
}
// Update for current button
current_building_type_ = id;
- building_buttons_[current_building_type_]->set_flat(false);
- building_buttons_[current_building_type_]->set_perm_pressed(true);
+ building_buttons_[current_building_type_]->set_style(UI::Button::Style::kPermpressed);
building_name_.set_text(iplayer().player().tribe().get_building_descr(id)->descname());
low_production_reset_focus();
has_selection_ = true;
=== modified file 'src/wui/buildingwindow.cc'
--- src/wui/buildingwindow.cc 2016-08-04 15:49:05 +0000
+++ src/wui/buildingwindow.cc 2016-10-10 12:59:45 +0000
@@ -431,10 +431,10 @@
if (toggle_workarea_) {
if (workarea_overlay_id_) {
toggle_workarea_->set_tooltip(_("Hide work area"));
- toggle_workarea_->set_perm_pressed(true);
+ toggle_workarea_->set_style(UI::Button::Style::kPermpressed);
} else {
toggle_workarea_->set_tooltip(_("Show work area"));
- toggle_workarea_->set_perm_pressed(false);
+ toggle_workarea_->set_style(UI::Button::Style::kRaised);
}
}
}
=== modified file 'src/wui/game_main_menu.cc'
--- src/wui/game_main_menu.cc 2016-08-04 15:49:05 +0000
+++ src/wui/game_main_menu.cc 2016-10-10 12:59:45 +0000
@@ -81,13 +81,14 @@
stock.sigclicked.connect(
boost::bind(&UI::UniqueWindow::Registry::toggle, boost::ref(windows_.stock)));
+// NOCOM we have this multiple times - can we refactor?
#define INIT_BTN_HOOKS(registry, btn) \
assert(!registry.on_create); \
assert(!registry.on_delete); \
- registry.on_create = std::bind(&UI::Button::set_perm_pressed, &btn, true); \
- registry.on_delete = std::bind(&UI::Button::set_perm_pressed, &btn, false); \
+ registry.on_create = std::bind(&UI::Button::set_style, &btn, UI::Button::Style::kPermpressed); \
+ registry.on_delete = std::bind(&UI::Button::set_style, &btn, UI::Button::Style::kRaised); \
if (registry.window) \
- btn.set_perm_pressed(true);
+ btn.set_style(UI::Button::Style::kPermpressed);
INIT_BTN_HOOKS(windows_.general_stats, general_stats)
INIT_BTN_HOOKS(windows_.ware_stats, ware_stats)
=== modified file 'src/wui/game_main_menu_save_game.cc'
--- src/wui/game_main_menu_save_game.cc 2016-08-04 18:09:55 +0000
+++ src/wui/game_main_menu_save_game.cc 2016-10-10 12:59:45 +0000
@@ -79,9 +79,8 @@
editbox_.changed.connect(boost::bind(&GameMainMenuSaveGame::edit_box_changed, this));
editbox_.ok.connect(boost::bind(&GameMainMenuSaveGame::ok, this));
- button_ok_ =
- new UI::Button(this, "ok", DESCRIPTION_X, OK_Y, DESCRIPTION_WIDTH, BUTTON_HEIGHT,
- g_gr->images().get("images/ui_basic/but4.png"), _("OK"), std::string(), false);
+ button_ok_ = new UI::Button(this, "ok", DESCRIPTION_X, OK_Y, DESCRIPTION_WIDTH, BUTTON_HEIGHT,
+ g_gr->images().get("images/ui_basic/but4.png"), _("OK"));
button_ok_->sigclicked.connect(boost::bind(&GameMainMenuSaveGame::ok, this));
UI::Button* cancelbtn =
@@ -138,7 +137,7 @@
Widelands::GamePreloadPacket gpdp;
gl.preload_game(gpdp); // This has worked before, no problem
{ editbox_.set_text(FileSystem::filename_without_ext(name.c_str())); }
- button_ok_->set_enabled(true);
+ edit_box_changed();
// Try to translate the map name.
{
@@ -191,6 +190,7 @@
} catch (const WException&) {
} // we simply skip illegal entries
}
+ edit_box_changed();
}
void GameMainMenuSaveGame::select_by_name(std::string name) {
=== modified file 'src/wui/game_message_menu.cc'
--- src/wui/game_message_menu.cc 2016-09-16 10:32:40 +0000
+++ src/wui/game_message_menu.cc 2016-10-10 12:59:45 +0000
@@ -77,35 +77,35 @@
geologistsbtn_ =
new UI::Button(this, "filter_geologists_messages", kPadding, kPadding, kButtonSize,
kButtonSize, g_gr->images().get("images/ui_basic/but0.png"),
- g_gr->images().get("images/wui/fieldaction/menu_geologist.png"), "", true);
+ g_gr->images().get("images/wui/fieldaction/menu_geologist.png"));
geologistsbtn_->sigclicked.connect(
boost::bind(&GameMessageMenu::filter_messages, this, Widelands::Message::Type::kGeologists));
economybtn_ =
new UI::Button(this, "filter_economy_messages", 2 * kPadding + kButtonSize, kPadding,
kButtonSize, kButtonSize, g_gr->images().get("images/ui_basic/but0.png"),
- g_gr->images().get("images/wui/stats/genstats_nrwares.png"), "", true);
+ g_gr->images().get("images/wui/stats/genstats_nrwares.png"));
economybtn_->sigclicked.connect(
boost::bind(&GameMessageMenu::filter_messages, this, Widelands::Message::Type::kEconomy));
seafaringbtn_ =
new UI::Button(this, "filter_seafaring_messages", 3 * kPadding + 2 * kButtonSize, kPadding,
kButtonSize, kButtonSize, g_gr->images().get("images/ui_basic/but0.png"),
- g_gr->images().get("images/wui/buildings/start_expedition.png"), "", true);
+ g_gr->images().get("images/wui/buildings/start_expedition.png"));
seafaringbtn_->sigclicked.connect(
boost::bind(&GameMessageMenu::filter_messages, this, Widelands::Message::Type::kSeafaring));
warfarebtn_ =
new UI::Button(this, "filter_warfare_messages", 4 * kPadding + 3 * kButtonSize, kPadding,
kButtonSize, kButtonSize, g_gr->images().get("images/ui_basic/but0.png"),
- g_gr->images().get("images/wui/messages/messages_warfare.png"), "", true);
+ g_gr->images().get("images/wui/messages/messages_warfare.png"));
warfarebtn_->sigclicked.connect(
boost::bind(&GameMessageMenu::filter_messages, this, Widelands::Message::Type::kWarfare));
scenariobtn_ =
new UI::Button(this, "filter_scenario_messages", 5 * kPadding + 4 * kButtonSize, kPadding,
kButtonSize, kButtonSize, g_gr->images().get("images/ui_basic/but0.png"),
- g_gr->images().get("images/wui/menus/menu_objectives.png"), "", true);
+ g_gr->images().get("images/wui/menus/menu_objectives.png"));
scenariobtn_->sigclicked.connect(
boost::bind(&GameMessageMenu::filter_messages, this, Widelands::Message::Type::kScenario));
@@ -140,8 +140,7 @@
(boost::format(_("G: %s"))
/** TRANSLATORS: Tooltip in the messages window */
% _("Center main mapview on location"))
- .str(),
- false);
+ .str());
centerviewbtn_->sigclicked.connect(boost::bind(&GameMessageMenu::center_view, this));
if (get_usedefaultpos())
@@ -485,11 +484,11 @@
case Widelands::Message::Type::kWarfareUnderAttack:
set_filter_messages_tooltips();
message_filter_ = Widelands::Message::Type::kAllMessages;
- geologistsbtn_->set_perm_pressed(false);
- economybtn_->set_perm_pressed(false);
- seafaringbtn_->set_perm_pressed(false);
- warfarebtn_->set_perm_pressed(false);
- scenariobtn_->set_perm_pressed(false);
+ geologistsbtn_->set_style(UI::Button::Style::kRaised);
+ economybtn_->set_style(UI::Button::Style::kRaised);
+ seafaringbtn_->set_style(UI::Button::Style::kRaised);
+ warfarebtn_->set_style(UI::Button::Style::kRaised);
+ scenariobtn_->set_style(UI::Button::Style::kRaised);
break;
}
think();
@@ -501,16 +500,16 @@
void GameMessageMenu::toggle_filter_messages_button(UI::Button& button,
Widelands::Message::Type msgtype) {
set_filter_messages_tooltips();
- if (button.get_perm_pressed()) {
- button.set_perm_pressed(false);
+ if (button.style() == UI::Button::Style::kPermpressed) {
+ button.set_style(UI::Button::Style::kRaised);
message_filter_ = Widelands::Message::Type::kAllMessages;
} else {
- geologistsbtn_->set_perm_pressed(false);
- economybtn_->set_perm_pressed(false);
- seafaringbtn_->set_perm_pressed(false);
- warfarebtn_->set_perm_pressed(false);
- scenariobtn_->set_perm_pressed(false);
- button.set_perm_pressed(true);
+ geologistsbtn_->set_style(UI::Button::Style::kRaised);
+ economybtn_->set_style(UI::Button::Style::kRaised);
+ seafaringbtn_->set_style(UI::Button::Style::kRaised);
+ warfarebtn_->set_style(UI::Button::Style::kRaised);
+ scenariobtn_->set_style(UI::Button::Style::kRaised);
+ button.set_style(UI::Button::Style::kPermpressed);
message_filter_ = msgtype;
/** TRANSLATORS: %1% is a tooltip, %2% is the corresponding hotkey */
=== modified file 'src/wui/game_options_menu.cc'
--- src/wui/game_options_menu.cc 2016-08-04 15:49:05 +0000
+++ src/wui/game_options_menu.cc 2016-10-10 12:59:45 +0000
@@ -111,10 +111,10 @@
boost::bind(&GameOptionsMenu::clicked_exit_game, boost::ref(*this)));
#define INIT_BTN_HOOKS(registry, btn) \
- registry.on_create = std::bind(&UI::Button::set_perm_pressed, &btn, true); \
- registry.on_delete = std::bind(&UI::Button::set_perm_pressed, &btn, false); \
+ registry.on_create = std::bind(&UI::Button::set_style, &btn, UI::Button::Style::kPermpressed); \
+ registry.on_delete = std::bind(&UI::Button::set_style, &btn, UI::Button::Style::kRaised); \
if (registry.window) \
- btn.set_perm_pressed(true);
+ btn.set_style(UI::Button::Style::kPermpressed);
INIT_BTN_HOOKS(windows_.sound_options, sound_)
=== modified file 'src/wui/general_statistics_menu.cc'
--- src/wui/general_statistics_menu.cc 2016-08-04 15:49:05 +0000
+++ src/wui/general_statistics_menu.cc 2016-10-10 12:59:45 +0000
@@ -215,7 +215,8 @@
my_registry_->time = plot_.get_time();
PlayerNumber const nr_players = game.map().get_nrplayers();
iterate_players_existing_novar(p, nr_players, game) {
- my_registry_->selected_players[p - 1] = cbs_[p - 1]->get_perm_pressed();
+ my_registry_->selected_players[p - 1] =
+ cbs_[p - 1]->style() == UI::Button::Style::kPermpressed;
}
}
}
@@ -232,9 +233,9 @@
*/
void GeneralStatisticsMenu::cb_changed_to(int32_t const id) {
// This represents our player number
- cbs_[id - 1]->set_perm_pressed(!cbs_[id - 1]->get_perm_pressed());
-
- plot_.show_plot((id - 1) * ndatasets_ + selected_information_, cbs_[id - 1]->get_perm_pressed());
+ cbs_[id - 1]->toggle();
+ plot_.show_plot((id - 1) * ndatasets_ + selected_information_,
+ cbs_[id - 1]->style() == UI::Button::Style::kPermpressed);
}
/*
@@ -245,7 +246,7 @@
dynamic_cast<InteractiveGameBase&>(*get_parent()).game().get_general_statistics().size();
for (uint32_t i = 0; i < statistics_size; ++i)
if (cbs_[i]) {
- plot_.show_plot(i * ndatasets_ + id, cbs_[i]->get_perm_pressed());
+ plot_.show_plot(i * ndatasets_ + id, cbs_[i]->style() == UI::Button::Style::kPermpressed);
plot_.show_plot(i * ndatasets_ + selected_information_, false);
}
selected_information_ = id;
=== modified file 'src/wui/interactive_gamebase.cc'
--- src/wui/interactive_gamebase.cc 2016-08-04 15:49:05 +0000
+++ src/wui/interactive_gamebase.cc 2016-10-10 12:59:45 +0000
@@ -137,6 +137,7 @@
}
void InteractiveGameBase::on_buildhelp_changed(const bool value) {
+ // NOCOM this is broken in trunk already.
toggle_buildhelp_.set_perm_pressed(value);
}
=== modified file 'src/wui/interactive_player.cc'
--- src/wui/interactive_player.cc 2016-08-04 15:49:05 +0000
+++ src/wui/interactive_player.cc 2016-10-10 12:59:45 +0000
@@ -122,10 +122,10 @@
adjust_toolbar_position();
#define INIT_BTN_HOOKS(registry, btn) \
- registry.on_create = std::bind(&UI::Button::set_perm_pressed, &btn, true); \
- registry.on_delete = std::bind(&UI::Button::set_perm_pressed, &btn, false); \
+ registry.on_create = std::bind(&UI::Button::set_style, &btn, UI::Button::Style::kPermpressed); \
+ registry.on_delete = std::bind(&UI::Button::set_style, &btn, UI::Button::Style::kRaised); \
if (registry.window) \
- btn.set_perm_pressed(true);
+ btn.set_style(UI::Button::Style::kPermpressed);
INIT_BTN_HOOKS(chat_, toggle_chat_)
INIT_BTN_HOOKS(options_, toggle_options_menu_)
=== modified file 'src/wui/interactive_spectator.cc'
--- src/wui/interactive_spectator.cc 2016-08-04 15:49:05 +0000
+++ src/wui/interactive_spectator.cc 2016-10-10 12:59:45 +0000
@@ -94,10 +94,10 @@
fieldclicked.connect(boost::bind(&InteractiveSpectator::node_action, this));
#define INIT_BTN_HOOKS(registry, btn) \
- registry.on_create = std::bind(&UI::Button::set_perm_pressed, &btn, true); \
- registry.on_delete = std::bind(&UI::Button::set_perm_pressed, &btn, false); \
+ registry.on_create = std::bind(&UI::Button::set_style, &btn, UI::Button::Style::kPermpressed); \
+ registry.on_delete = std::bind(&UI::Button::set_style, &btn, UI::Button::Style::kRaised); \
if (registry.window) \
- btn.set_perm_pressed(true);
+ btn.set_style(UI::Button::Style::kPermpressed);
INIT_BTN_HOOKS(chat_, toggle_chat_)
INIT_BTN_HOOKS(options_, toggle_options_menu_)
=== modified file 'src/wui/minimap.cc'
--- src/wui/minimap.cc 2016-08-04 15:49:05 +0000
+++ src/wui/minimap.cc 2016-10-10 12:59:45 +0000
@@ -140,9 +140,8 @@
g_gr->images().get("images/ui_basic/but0.png"),
g_gr->images().get("images/wui/minimap/button_terrn.png"),
_("Terrain"),
- true,
- false,
- true),
+ UI::Button::Style::kRaised,
+ UI::Button::ImageMode::kUnscaled),
button_owner(this,
"owner",
but_w() * 1,
@@ -152,9 +151,8 @@
g_gr->images().get("images/ui_basic/but0.png"),
g_gr->images().get("images/wui/minimap/button_owner.png"),
_("Owner"),
- true,
- false,
- true),
+ UI::Button::Style::kRaised,
+ UI::Button::ImageMode::kUnscaled),
button_flags(this,
"flags",
but_w() * 2,
@@ -164,9 +162,8 @@
g_gr->images().get("images/ui_basic/but0.png"),
g_gr->images().get("images/wui/minimap/button_flags.png"),
_("Flags"),
- true,
- false,
- true),
+ UI::Button::Style::kRaised,
+ UI::Button::ImageMode::kUnscaled),
button_roads(this,
"roads",
but_w() * 0,
@@ -176,9 +173,8 @@
g_gr->images().get("images/ui_basic/but0.png"),
g_gr->images().get("images/wui/minimap/button_roads.png"),
_("Roads"),
- true,
- false,
- true),
+ UI::Button::Style::kRaised,
+ UI::Button::ImageMode::kUnscaled),
button_bldns(this,
"buildings",
but_w() * 1,
@@ -188,9 +184,8 @@
g_gr->images().get("images/ui_basic/but0.png"),
g_gr->images().get("images/wui/minimap/button_bldns.png"),
_("Buildings"),
- true,
- false,
- true),
+ UI::Button::Style::kRaised,
+ UI::Button::ImageMode::kUnscaled),
button_zoom(this,
"zoom",
but_w() * 2,
@@ -200,9 +195,8 @@
g_gr->images().get("images/ui_basic/but0.png"),
g_gr->images().get("images/wui/minimap/button_zoom.png"),
_("Zoom"),
- true,
- false,
- true) {
+ UI::Button::Style::kRaised,
+ UI::Button::ImageMode::kUnscaled) {
button_terrn.sigclicked.connect(
boost::bind(&MiniMap::toggle, boost::ref(*this), MiniMapLayer::Terrain));
button_owner.sigclicked.connect(
=== modified file 'src/wui/multiplayersetupgroup.cc'
--- src/wui/multiplayersetupgroup.cc 2016-08-04 15:49:05 +0000
+++ src/wui/multiplayersetupgroup.cc 2016-10-10 12:59:45 +0000
@@ -76,9 +76,8 @@
add(name, UI::Align::kHCenter);
// Either Button if changeable OR text if not
if (id == settings->settings().usernum) { // Our Client
- type = new UI::Button(this, "client_type", 0, 0, h, h,
- g_gr->images().get("images/ui_basic/but1.png"), std::string(),
- std::string(), true, false);
+ type = new UI::Button(
+ this, "client_type", 0, 0, h, h, g_gr->images().get("images/ui_basic/but1.png"), "");
type->sigclicked.connect(
boost::bind(&MultiPlayerClientGroup::toggle_type, boost::ref(*this)));
add(type, UI::Align::kHCenter);
@@ -179,28 +178,23 @@
assert(player_image);
player = new UI::Icon(this, 0, 0, h, h, player_image);
add(player, UI::Align::kHCenter);
- type = new UI::Button(this, "player_type", 0, 0, h, h,
- g_gr->images().get("images/ui_basic/but1.png"), std::string(),
- std::string(), true, false);
+ type = new UI::Button(
+ this, "player_type", 0, 0, h, h, g_gr->images().get("images/ui_basic/but1.png"), "");
type->sigclicked.connect(
boost::bind(&MultiPlayerPlayerGroup::toggle_type, boost::ref(*this)));
add(type, UI::Align::kHCenter);
- tribe = new UI::Button(this, "player_tribe", 0, 0, h, h,
- g_gr->images().get("images/ui_basic/but1.png"), std::string(),
- std::string(), true, false);
+ tribe = new UI::Button(
+ this, "player_tribe", 0, 0, h, h, g_gr->images().get("images/ui_basic/but1.png"), "");
tribe->sigclicked.connect(
boost::bind(&MultiPlayerPlayerGroup::toggle_tribe, boost::ref(*this)));
add(tribe, UI::Align::kHCenter);
- tribe->set_draw_flat_background(true);
init = new UI::Button(this, "player_init", 0, 0, w - 4 * h, h,
- g_gr->images().get("images/ui_basic/but1.png"), std::string(),
- std::string(), true, false);
+ g_gr->images().get("images/ui_basic/but1.png"), "");
init->sigclicked.connect(
boost::bind(&MultiPlayerPlayerGroup::toggle_init, boost::ref(*this)));
add(init, UI::Align::kHCenter);
- team = new UI::Button(this, "player_team", 0, 0, h, h,
- g_gr->images().get("images/ui_basic/but1.png"), std::string(),
- std::string(), true, false);
+ team = new UI::Button(
+ this, "player_team", 0, 0, h, h, g_gr->images().get("images/ui_basic/but1.png"), "");
team->sigclicked.connect(
boost::bind(&MultiPlayerPlayerGroup::toggle_team, boost::ref(*this)));
add(team, UI::Align::kHCenter);
@@ -253,7 +247,7 @@
team->set_enabled(false);
tribe->set_visible(false);
tribe->set_enabled(false);
- tribe->set_flat(false);
+ tribe->set_style(UI::Button::Style::kRaised);
init->set_visible(false);
init->set_enabled(false);
return;
@@ -264,7 +258,7 @@
team->set_enabled(false);
tribe->set_visible(false);
tribe->set_enabled(false);
- tribe->set_flat(false);
+ tribe->set_style(UI::Button::Style::kRaised);
init->set_visible(false);
init->set_enabled(false);
return;
@@ -282,7 +276,7 @@
team->set_visible(false);
team->set_enabled(false);
// Flat ~= icon
- tribe->set_flat(!initaccess);
+ tribe->set_perm_pressed(!initaccess);
tribe->set_enabled(true);
} else {
std::string title;
@@ -327,7 +321,7 @@
tribe->set_tooltip(tribenames_[player_setting.tribe].c_str());
tribe->set_pic(tribepics_[player_setting.tribe]);
}
- tribe->set_flat(false);
+ tribe->set_style(UI::Button::Style::kRaised);
if (player_setting.team) {
team->set_title(std::to_string(static_cast<unsigned int>(player_setting.team)));
=== modified file 'src/wui/playerdescrgroup.cc'
--- src/wui/playerdescrgroup.cc 2016-08-04 15:49:05 +0000
+++ src/wui/playerdescrgroup.cc 2016-10-10 12:59:45 +0000
@@ -67,25 +67,23 @@
d->btnEnablePlayer = new UI::Checkbox(this, Point(xplayertype - 23, 0), "");
d->btnEnablePlayer->changedto.connect(
boost::bind(&PlayerDescriptionGroup::enable_player, this, _1));
- d->btnPlayerType = new UI::Button(
- this, "player_type", xplayertype, 0, xplayertribe - xplayertype - 2, h / 2,
- g_gr->images().get("images/ui_basic/but1.png"), std::string(), std::string(), true, false);
+ d->btnPlayerType =
+ new UI::Button(this, "player_type", xplayertype, 0, xplayertribe - xplayertype - 2, h / 2,
+ g_gr->images().get("images/ui_basic/but1.png"), "");
d->btnPlayerType->sigclicked.connect(
boost::bind(&PlayerDescriptionGroup::toggle_playertype, boost::ref(*this)));
- d->btnPlayerTeam = new UI::Button(
- this, "player_team", xplayerteam, h / 2, xplayerinit - xplayerteam - 2, h / 2,
- g_gr->images().get("images/ui_basic/but1.png"), std::string(), std::string(), true, false);
+ d->btnPlayerTeam =
+ new UI::Button(this, "player_team", xplayerteam, h / 2, xplayerinit - xplayerteam - 2, h / 2,
+ g_gr->images().get("images/ui_basic/but1.png"), "");
d->btnPlayerTeam->sigclicked.connect(
boost::bind(&PlayerDescriptionGroup::toggle_playerteam, boost::ref(*this)));
d->btnPlayerTribe = new UI::Button(this, "player_tribe", xplayertribe, 0, w - xplayertribe,
- h / 2, g_gr->images().get("images/ui_basic/but1.png"),
- std::string(), std::string(), true, false);
+ h / 2, g_gr->images().get("images/ui_basic/but1.png"), "");
d->btnPlayerTribe->sigclicked.connect(
boost::bind(&PlayerDescriptionGroup::toggle_playertribe, boost::ref(*this)));
d->btnPlayerInit =
new UI::Button(this, "player_initialization", xplayerinit, h / 2, w - xplayerinit, h / 2,
- g_gr->images().get("images/ui_basic/but1.png"), std::string(),
- _("Initialization"), true, false);
+ g_gr->images().get("images/ui_basic/but1.png"), "", _("Initialization"));
d->btnPlayerInit->sigclicked.connect(
boost::bind(&PlayerDescriptionGroup::toggle_playerinit, boost::ref(*this)));
=== modified file 'src/wui/transport_ui.cc'
--- src/wui/transport_ui.cc 2016-08-04 15:49:05 +0000
+++ src/wui/transport_ui.cc 2016-10-10 12:59:45 +0000
@@ -122,7 +122,8 @@
#define ADD_WARE_BUTTON(callback, text, tooltip) \
b = new UI::Button(buttons, #callback, 0, 0, 34, 34, \
- g_gr->images().get("images/ui_basic/but4.png"), text, tooltip, can_act_); \
+ g_gr->images().get("images/ui_basic/but4.png"), text, tooltip); \
+ b->set_enabled(can_act_); \
b->sigclicked.connect(boost::bind(&EconomyOptionsWarePanel::callback, this)); \
buttons->add(b, UI::Align::kHCenter);
ADD_WARE_BUTTON(decrease_target, "-", _("Decrease target"))
@@ -193,7 +194,8 @@
UI::Button* b = nullptr;
#define ADD_WORKER_BUTTON(callback, text, tooltip) \
b = new UI::Button(buttons, #callback, 0, 0, 34, 34, \
- g_gr->images().get("images/ui_basic/but4.png"), text, tooltip, can_act_); \
+ g_gr->images().get("images/ui_basic/but4.png"), text, tooltip); \
+ b->set_enabled(can_act_); \
b->sigclicked.connect(boost::bind(&EconomyOptionsWorkerPanel::callback, this)); \
buttons->add(b, UI::Align::kHCenter);
=== modified file 'src/wui/watchwindow.cc'
--- src/wui/watchwindow.cc 2016-08-04 15:49:05 +0000
+++ src/wui/watchwindow.cc 2016-10-10 12:59:45 +0000
@@ -117,8 +117,7 @@
if (init_single_window) {
for (uint8_t i = 0; i < NUM_VIEWS; ++i) {
view_btns[i] = new UI::Button(this, "view", 74 + (17 * i), 200 - 34, 17, 34,
- g_gr->images().get("images/ui_basic/but0.png"), "-",
- std::string(), false);
+ g_gr->images().get("images/ui_basic/but0.png"), "-");
view_btns[i]->sigclicked.connect(boost::bind(&WatchWindow::view_button_clicked, this, i));
}
@@ -196,8 +195,8 @@
save_coords();
if (single_window) {
- view_btns[cur_index]->set_perm_pressed(false);
- view_btns[idx]->set_perm_pressed(true);
+ view_btns[cur_index]->set_style(UI::Button::Style::kRaised);
+ view_btns[idx]->set_style(UI::Button::Style::kPermpressed);
}
cur_index = idx;
show_view();
Follow ups