← Back to team overview

widelands-dev team mailing list archive

Re: [Merge] lp:~widelands-dev/widelands/bug-859245 into lp:widelands

 

Review: Needs Fixing

You have been working on the layout of the menus now for quite some time. Do you not think it is time to move to UI::Box and a more manageable layout instead of the hardcoding?

Also, couple of comments.

Diff comments:

> === modified file 'src/build_info.h'
> --- src/build_info.h	2014-07-05 16:41:51 +0000
> +++ src/build_info.h	2014-11-12 18:38:19 +0000
> @@ -20,10 +20,11 @@
>  #ifndef WL_BUILD_INFO_H
>  #define WL_BUILD_INFO_H
>  
> -#define WLCR "(C) 2002-2014 "
> -
>  #include <string>
>  
> +constexpr uint16_t kWidelandsCopyrightStart = 2002;
> +constexpr uint16_t kWidelandsCopyrightEnd = 2014;
> +
>  ///\return the build id which is automagically created from the checkout's
>  ///revision number or the VERSION file
>  const std::string & build_id();
> 
> === modified file 'src/ui_fsmenu/CMakeLists.txt'
> --- src/ui_fsmenu/CMakeLists.txt	2014-11-03 06:55:18 +0000
> +++ src/ui_fsmenu/CMakeLists.txt	2014-11-12 18:38:19 +0000
> @@ -22,6 +22,8 @@
>      load_map_or_game.h
>      main.cc
>      main.h
> +    main_menu.cc
> +    main_menu.h
>      mapselect.cc
>      mapselect.h
>      multiplayer.cc
> 
> === modified file 'src/ui_fsmenu/base.cc'
> --- src/ui_fsmenu/base.cc	2014-09-18 18:52:34 +0000
> +++ src/ui_fsmenu/base.cc	2014-11-12 18:38:19 +0000
> @@ -117,3 +117,7 @@
>  {
>  	return d->textstyle_big.font;
>  }
> +
> +int32_t FullscreenMenuBase::get_y_from_preceding(UI::Panel& preceding_panel) {

The proper solution for this is using a UI::Box. Absolute positioning makes a lot of headaches.

> +	return preceding_panel.get_y() + preceding_panel.get_h();
> +}
> 
> === modified file 'src/ui_fsmenu/base.h'
> --- src/ui_fsmenu/base.h	2014-09-10 14:08:25 +0000
> +++ src/ui_fsmenu/base.h	2014-11-12 18:38:19 +0000
> @@ -52,6 +52,10 @@
>  	UI::Font * font_small();
>  	UI::Font * font_big();
>  
> +protected:
> +	// Returns a y coordinate that can be used to position a Panel below the Panel directly above it
> +	int32_t get_y_from_preceding(UI::Panel& preceding_panel);
> +
>  private:
>  	/**
>  	 * Query the configured screen resolution.
> 
> === modified file 'src/ui_fsmenu/editor.cc'
> --- src/ui_fsmenu/editor.cc	2014-09-27 09:28:51 +0000
> +++ src/ui_fsmenu/editor.cc	2014-11-12 18:38:19 +0000
> @@ -24,43 +24,44 @@
>  #include "wui/text_constants.h"
>  
>  FullscreenMenuEditor::FullscreenMenuEditor() :
> -	FullscreenMenuBase("ui_fsmenu.jpg"),
> -
> -// Values for alignment and size
> -	m_butw (get_w() * 7 / 20),
> -	m_buth (get_h() * 19 / 400),
> -	m_butx ((get_w() - m_butw) / 2),
> +	FullscreenMenuMainMenu(),
>  
>  // Title
>  	title
> -		(this, get_w() / 2, get_h() * 3 / 40, _("Editor"), UI::Align_HCenter),
> +		(this, get_w() / 2, m_title_y, _("Editor"), UI::Align_HCenter),
>  
>  // Buttons
>  	new_map
>  		(this, "new_map",
> -		 m_butx, get_h() * 6 / 25, m_butw, m_buth,
> -		 g_gr->images().get("pics/but1.png"),
> -		 _("New Map"), std::string(), true, false),
> +		 m_butx, m_buty, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("New Map"), "", true, false),
>  	load_map
>  		(this, "load_map",
> -		 m_butx, get_h() * 61 / 200, m_butw, m_buth,
> -		 g_gr->images().get("pics/but1.png"),
> -		 _("Load Map"), std::string(), true, false),
> +		 m_butx, get_y_from_preceding(new_map) + m_padding, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("Load Map"), "", true, false),
>  	back
>  		(this, "back",
> -		 m_butx, get_h() * 3 / 4, m_butw, m_buth,
> -		 g_gr->images().get("pics/but0.png"),
> -		 _("Back"), std::string(), true, false)
> +		 m_butx, m_back_button_y, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("Back"), "", true, false)
>  {
>  	new_map.sigclicked.connect
> -		(boost::bind(&FullscreenMenuEditor::end_modal, boost::ref(*this), static_cast<int32_t>(New_Map)));
> +			(boost::bind(
> +				 &FullscreenMenuEditor::end_modal,
> +				 boost::ref(*this),
> +				 static_cast<int32_t>(MenuTarget::kNewMap)));
>  	load_map.sigclicked.connect
> -		(boost::bind(&FullscreenMenuEditor::end_modal, boost::ref(*this), static_cast<int32_t>(Load_Map)));
> +			(boost::bind
> +			 (&FullscreenMenuEditor::end_modal,
> +			  boost::ref(*this),
> +			  static_cast<int32_t>(MenuTarget::kLoadMap)));
>  	back.sigclicked.connect
> -		(boost::bind(&FullscreenMenuEditor::end_modal, boost::ref(*this), static_cast<int32_t>(Back)));
> +			(boost::bind
> +			 (&FullscreenMenuEditor::end_modal,
> +			  boost::ref(*this),
> +			  static_cast<int32_t>(MenuTarget::kBack)));
>  
> -	new_map.set_font(font_small());
> -	load_map.set_font(font_small());
> -	back.set_font(font_small());
>  	title.set_font(ui_fn(), fs_big(), UI_FONT_CLR_FG);
>  }
> 
> === modified file 'src/ui_fsmenu/editor.h'
> --- src/ui_fsmenu/editor.h	2014-09-10 14:08:25 +0000
> +++ src/ui_fsmenu/editor.h	2014-11-12 18:38:19 +0000
> @@ -20,7 +20,7 @@
>  #ifndef WL_UI_FSMENU_EDITOR_H
>  #define WL_UI_FSMENU_EDITOR_H
>  
> -#include "ui_fsmenu/base.h"
> +#include "ui_fsmenu/main_menu.h"
>  #include "ui_basic/button.h"
>  #include "ui_basic/textarea.h"
>  
> @@ -28,19 +28,20 @@
>   * Fullscreen Menu for Editor.
>   * Here you select what game you want to play.
>   */
> -struct FullscreenMenuEditor : public FullscreenMenuBase {
> +struct FullscreenMenuEditor : public FullscreenMenuMainMenu {
>  	FullscreenMenuEditor();
>  
> -	enum {Back = dying_code, New_Map, Load_Map};
> +	enum class MenuTarget: int32_t {
> +		kBack = UI::Panel::dying_code,
> +		kNewMap,
> +		kLoadMap
> +	};
>  
>  private:
> -	uint32_t                                      m_butw;
> -	uint32_t                                      m_buth;
> -	uint32_t                                      m_butx;
> -	UI::Textarea                                  title;
> -	UI::Button                       new_map;
> -	UI::Button                       load_map;
> -	UI::Button                       back;
> +	UI::Textarea title;
> +	UI::Button   new_map;
> +	UI::Button   load_map;
> +	UI::Button   back;
>  };
>  
>  #endif  // end of include guard: WL_UI_FSMENU_EDITOR_H
> 
> === modified file 'src/ui_fsmenu/load_map_or_game.cc'
> --- src/ui_fsmenu/load_map_or_game.cc	2014-10-28 12:53:29 +0000
> +++ src/ui_fsmenu/load_map_or_game.cc	2014-11-12 18:38:19 +0000
> @@ -87,12 +87,6 @@
>  	return FullscreenMenuBase::handle_key(down, code);
>  }
>  
> -
> -int32_t FullscreenMenuLoadMapOrGame::get_y_from_preceding(UI::Panel& preceding_panel) {
> -	return preceding_panel.get_y() + preceding_panel.get_h();
> -}
> -
> -
>  int32_t FullscreenMenuLoadMapOrGame::get_right_column_w(int32_t x) {
>  	return get_w() - m_right_column_margin - x;
>  }
> 
> === modified file 'src/ui_fsmenu/load_map_or_game.h'
> --- src/ui_fsmenu/load_map_or_game.h	2014-10-31 07:40:54 +0000
> +++ src/ui_fsmenu/load_map_or_game.h	2014-11-12 18:38:19 +0000
> @@ -93,9 +93,6 @@
>  		return has_selection;
>  	}
>  
> -	// Returns a y coordinate that can be used to position a Panel below the Panel directly above it
> -	int32_t get_y_from_preceding(UI::Panel& preceding_panel);
> -
>  	// Returns the width that a Panel in the right column should have, depending on its x position
>  	int32_t get_right_column_w(int32_t x);
>  
> 
> === modified file 'src/ui_fsmenu/main.cc'
> --- src/ui_fsmenu/main.cc	2014-10-11 08:43:07 +0000
> +++ src/ui_fsmenu/main.cc	2014-11-12 18:38:19 +0000
> @@ -19,76 +19,80 @@
>  
>  #include "ui_fsmenu/main.h"
>  
> +#include <boost/format.hpp>
> +
>  #include "base/i18n.h"
>  #include "build_info.h"
>  #include "graphic/graphic.h"
>  
>  FullscreenMenuMain::FullscreenMenuMain() :
> -	FullscreenMenuBase("mainmenu.jpg"),
> -
> -// Values for alignment and size
> -	m_butx (get_w() * 13 / 40),
> -	m_butw (get_w() * 7 / 20),
> -	m_buth (get_h() * 19 / 400),
> -	wlcr   (WLCR),
> +	FullscreenMenuMainMenu("mainmenu.jpg"),
>  
>  // Buttons
>  	playtutorial
>  		(this, "play_tutorial",
>  		 m_butx, get_h() * 42 / 200, m_butw, m_buth,
> -		 g_gr->images().get("pics/but3.png"),
> -		 _("Play Tutorial"), std::string(), true, false),
> +		 g_gr->images().get(m_button_background),
> +		 _("Play Tutorial"), "", true, false),
>  	singleplayer
>  		(this, "single_player",
> -		 m_butx, get_h() * 61 / 200, m_butw, m_buth,
> -		 g_gr->images().get("pics/but3.png"),
> -		 _("Single Player"), std::string(), true, false),
> +		 m_butx, get_y_from_preceding(playtutorial) + m_buth, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("Single Player"), "", true, false),
>  	multiplayer
>  		(this, "multi_player",
> -		 m_butx, get_h() * 37 / 100, m_butw, m_buth,
> -		 g_gr->images().get("pics/but3.png"),
> -		 _("Multiplayer"), std::string(), true, false),
> +		 m_butx, get_y_from_preceding(singleplayer) + m_padding, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("Multiplayer"), "", true, false),
>  	replay
>  		(this, "replay",
> -		 m_butx, get_h() * 87 / 200, m_butw, m_buth,
> -		 g_gr->images().get("pics/but3.png"),
> -		 _("Watch Replay"), std::string(), true, false),
> +		 m_butx, get_y_from_preceding(multiplayer) + m_padding, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("Watch Replay"), "", true, false),
>  	editor
>  		(this, "editor",
> -		 m_butx, get_h() * 100 / 200, m_butw, m_buth,
> -		 g_gr->images().get("pics/but3.png"),
> -		 _("Editor"), std::string(), true, false),
> +		 m_butx, get_y_from_preceding(replay) + m_padding, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("Editor"), "", true, false),
>  	options
>  		(this, "options",
> -		 m_butx, get_h() * 119 / 200, m_butw, m_buth,
> -		 g_gr->images().get("pics/but3.png"),
> -		 _("Options"), std::string(), true, false),
> +		 m_butx, get_y_from_preceding(editor) + m_buth, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("Options"), "", true, false),
>  	readme
>  		(this, "readme",
> -		 m_butx, get_h() * 138 / 200, m_butw, m_buth,
> -		 g_gr->images().get("pics/but3.png"),
> -		 _("View Readme"), std::string(), true, false),
> +		 m_butx, get_y_from_preceding(options) + m_buth, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("View Readme"), "", true, false),
>  	license
>  		(this, "license",
> -		 m_butx, get_h() * 151 / 200, m_butw, m_buth,
> -		 g_gr->images().get("pics/but3.png"),
> -		 _("License"), std::string(), true, false),
> +		 m_butx, get_y_from_preceding(readme) + m_padding, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("License"), "", true, false),
> +	authors
> +		(this, "authors",
> +		 m_butx, get_y_from_preceding(license) + m_padding, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("Authors"), "", true, false),
>  	exit
>  		(this, "exit",
> -		 m_butx, get_h() * 178 / 200, m_butw, m_buth,
> -		 g_gr->images().get("pics/but3.png"),
> -		 _("Exit Widelands"), std::string(), true, false),
> +		 m_butx, get_y_from_preceding(authors) + m_buth, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("Exit Widelands"), "", true, false),
>  
>  // Textlabels
>  	version
>  		(this,
>  		 get_w(), get_h(),
> -		 _("Version ") + build_id() + '(' + build_type() + ')',
> +		 /** TRANSLATORS: %1$s = version string, %2%s = "Debug" or "Release" */
> +		 (boost::format(_("Version %1$s (%2$s)")) % build_id().c_str() % build_type().c_str()).str(),
>  		 UI::Align_BottomRight),
>  	copyright
>  		(this,
>  		 0, get_h() - 0.5 * m_buth,
> -		 (wlcr + _("by the Widelands Development Team")).c_str(),
> +		 /** TRANSLATORS: Placeholders are the copyright years */
> +		 (boost::format(_("(C) %1%-%2% by the Widelands Development Team"))
> +		  % kWidelandsCopyrightStart % kWidelandsCopyrightEnd).str(),
>  		 UI::Align_BottomLeft),
>  	gpl
>  		(this,
> @@ -99,51 +103,41 @@
>  	playtutorial.sigclicked.connect
>  		(boost::bind
>  			 (&FullscreenMenuMain::end_modal, boost::ref(*this),
> -			  static_cast<int32_t>(mm_playtutorial)));
> +			  static_cast<int32_t>(MenuTarget::kTutorial)));
>  	singleplayer.sigclicked.connect
>  		(boost::bind
>  			 (&FullscreenMenuMain::end_modal, boost::ref(*this),
> -			  static_cast<int32_t>(mm_singleplayer)));
> +			  static_cast<int32_t>(MenuTarget::kSinglePlayer)));
>  	multiplayer.sigclicked.connect
>  		(boost::bind
>  			 (&FullscreenMenuMain::end_modal, boost::ref(*this),
> -			  static_cast<int32_t>(mm_multiplayer)));
> +			  static_cast<int32_t>(MenuTarget::kMultiplayer)));
>  	replay.sigclicked.connect
>  		(boost::bind
>  			 (&FullscreenMenuMain::end_modal, boost::ref(*this),
> -			  static_cast<int32_t>(mm_replay)));
> +			  static_cast<int32_t>(MenuTarget::kReplay)));
>  	editor.sigclicked.connect
>  		(boost::bind
>  			 (&FullscreenMenuMain::end_modal, boost::ref(*this),
> -			  static_cast<int32_t>(mm_editor)));
> +			  static_cast<int32_t>(MenuTarget::kEditor)));
>  	options.sigclicked.connect
>  		(boost::bind
>  			 (&FullscreenMenuMain::end_modal, boost::ref(*this),
> -			  static_cast<int32_t>(mm_options)));
> +			  static_cast<int32_t>(MenuTarget::kOptions)));
>  	readme.sigclicked.connect
>  		(boost::bind
>  			 (&FullscreenMenuMain::end_modal, boost::ref(*this),
> -			  static_cast<int32_t>(mm_readme)));
> +			  static_cast<int32_t>(MenuTarget::kReadme)));
>  	license.sigclicked.connect
>  		(boost::bind
>  			 (&FullscreenMenuMain::end_modal, boost::ref(*this),
> -			  static_cast<int32_t>(mm_license)));
> +			  static_cast<int32_t>(MenuTarget::kLicense)));
> +	authors.sigclicked.connect
> +		(boost::bind
> +			 (&FullscreenMenuMain::end_modal, boost::ref(*this),
> +			  static_cast<int32_t>(MenuTarget::kAuthors)));
>  	exit.sigclicked.connect
>  		(boost::bind
>  			 (&FullscreenMenuMain::end_modal, boost::ref(*this),
> -			  static_cast<int32_t>(mm_exit)));
> -
> -	playtutorial.set_font(font_small());
> -	singleplayer.set_font(font_small());
> -	multiplayer.set_font(font_small());
> -	replay.set_font(font_small());
> -	editor.set_font(font_small());
> -	options.set_font(font_small());
> -	readme.set_font(font_small());
> -	license.set_font(font_small());
> -	exit.set_font(font_small());
> -
> -	version.set_textstyle(ts_small());
> -	copyright.set_textstyle(ts_small());
> -	gpl.set_textstyle(ts_small());
> +			  static_cast<int32_t>(MenuTarget::kExit)));
>  }
> 
> === modified file 'src/ui_fsmenu/main.h'
> --- src/ui_fsmenu/main.h	2014-09-10 14:08:25 +0000
> +++ src/ui_fsmenu/main.h	2014-11-12 18:38:19 +0000
> @@ -20,7 +20,7 @@
>  #ifndef WL_UI_FSMENU_MAIN_H
>  #define WL_UI_FSMENU_MAIN_H
>  
> -#include "ui_fsmenu/base.h"
> +#include "ui_fsmenu/main_menu.h"
>  #include "ui_basic/button.h"
>  #include "ui_basic/textarea.h"
>  
> @@ -28,37 +28,34 @@
>   * This runs the main menu. There, you can select
>   * between different playmodes, exit and so on.
>  */
> -struct FullscreenMenuMain : public FullscreenMenuBase {
> +struct FullscreenMenuMain : public FullscreenMenuMainMenu {
>  	FullscreenMenuMain();
> -	enum {
> -		mm_summary,
> -		mm_playtutorial,
> -		mm_singleplayer,
> -		mm_multiplayer,
> -		mm_replay,
> -		mm_editor,
> -		mm_options,
> -		mm_readme,
> -		mm_license,
> -		mm_exit
> +	enum class MenuTarget: int32_t {
> +		kTutorial,
> +		kSinglePlayer,
> +		kMultiplayer,
> +		kReplay,
> +		kEditor,
> +		kOptions,
> +		kReadme,
> +		kLicense,
> +		kAuthors,
> +		kExit
>  	};
>  private:
> -	uint32_t                                    m_butx;
> -	uint32_t                                    m_butw;
> -	uint32_t                                    m_buth;
> -	std::string                                 wlcr;
> -	UI::Button                     playtutorial;
> -	UI::Button                     singleplayer;
> -	UI::Button                     multiplayer;
> -	UI::Button                     replay;
> -	UI::Button                     editor;
> -	UI::Button                     options;
> -	UI::Button                     readme;
> -	UI::Button                     license;
> -	UI::Button                     exit;
> -	UI::Textarea                                version;
> -	UI::Textarea                                copyright;
> -	UI::Textarea                                gpl;
> +	UI::Button   playtutorial;
> +	UI::Button   singleplayer;
> +	UI::Button   multiplayer;
> +	UI::Button   replay;
> +	UI::Button   editor;
> +	UI::Button   options;
> +	UI::Button   readme;
> +	UI::Button   license;
> +	UI::Button   authors;
> +	UI::Button   exit;
> +	UI::Textarea version;
> +	UI::Textarea copyright;
> +	UI::Textarea gpl;
>  };
>  
>  #endif  // end of include guard: WL_UI_FSMENU_MAIN_H
> 
> === added file 'src/ui_fsmenu/main_menu.cc'
> --- src/ui_fsmenu/main_menu.cc	1970-01-01 00:00:00 +0000
> +++ src/ui_fsmenu/main_menu.cc	2014-11-12 18:38:19 +0000
> @@ -0,0 +1,38 @@
> +/*
> + * Copyright (C) 2002-2004, 2006-2009 by the Widelands Development Team
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> + *
> + */
> +
> +#include "ui_fsmenu/main_menu.h"
> +
> +FullscreenMenuMainMenu::FullscreenMenuMainMenu():
> +	FullscreenMenuMainMenu("ui_fsmenu.jpg")
> +	{}
> +
> +FullscreenMenuMainMenu::FullscreenMenuMainMenu(const char* background_image):
> +	FullscreenMenuBase(background_image),
> +
> +	// Values for alignment and size
> +	m_butx(get_w() * 13 / 40),
> +	m_buty(get_h() * 6 / 25),
> +	m_butw(get_w() * 7 / 20),
> +	m_buth(get_h() * 9 / 200),
> +	m_back_button_y(get_h() * 3 / 4),
> +	m_title_y(get_h() * 3 / 40),
> +	m_padding(m_buth / 3),
> +	m_button_background("pics/but3.png")
> +{}
> 
> === added file 'src/ui_fsmenu/main_menu.h'
> --- src/ui_fsmenu/main_menu.h	1970-01-01 00:00:00 +0000
> +++ src/ui_fsmenu/main_menu.h	2014-11-12 18:38:19 +0000
> @@ -0,0 +1,41 @@
> +/*
> + * Copyright (C) 2002, 2006-2008 by the Widelands Development Team
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * as published by the Free Software Foundation; either version 2
> + * of the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
> + *
> + */
> +
> +#ifndef WL_UI_FSMENU_MAIN_MENU_H
> +#define WL_UI_FSMENU_MAIN_MENU_H
> +
> +#include "ui_fsmenu/base.h"
> +
> +/**
> + * This sets the values for alignment and size and other common properties
> + * for main menus that contain only buttons.
> + */
> +struct FullscreenMenuMainMenu : public FullscreenMenuBase {

Make it a class please.

> +	FullscreenMenuMainMenu();

What does the default constructor do? Please add a comment.

> +	FullscreenMenuMainMenu(char const * background_image);
> +
> +protected:

Make everything that can be private private if possible.

> +	uint32_t m_butx, m_buty, m_butw, m_buth;
> +	uint32_t m_back_button_y, m_title_y;
> +	uint32_t m_padding;
> +
> +	const std::string m_button_background;

Nit: I put const members first.

> +};
> +
> +#endif  // end of include guard: WL_UI_FSMENU_MAIN_MENU_H
> 
> === modified file 'src/ui_fsmenu/multiplayer.cc'
> --- src/ui_fsmenu/multiplayer.cc	2014-09-29 19:25:24 +0000
> +++ src/ui_fsmenu/multiplayer.cc	2014-11-12 18:38:19 +0000
> @@ -25,52 +25,44 @@
>  #include "wui/text_constants.h"
>  
>  FullscreenMenuMultiPlayer::FullscreenMenuMultiPlayer() :
> -	FullscreenMenuBase("ui_fsmenu.jpg"),
> -
> -// Values for alignment and size
> -	m_butw (get_w() * 7 / 20),
> -	m_buth (get_h() * 19 / 400),
> -	m_butx ((get_w() - m_butw) / 2),
> -	m_fs   (fs_small()),
> -	m_fn   (ui_fn()),
> +	FullscreenMenuMainMenu(),
>  
>  // Title
>  	title
>  		(this,
> -		 get_w() / 2, get_h() * 3 / 40,
> +		 get_w() / 2, m_title_y,
>  		 _("Choose game type"), UI::Align_HCenter),
>  
>  // Buttons
>  	metaserver
>  		(this, "metaserver",
> -		 m_butx, get_h() * 6 / 25, m_butw, m_buth,
> -		 g_gr->images().get("pics/but1.png"),
> -		 _("Internet game"), std::string(), true, false),
> +		 m_butx, m_buty, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("Internet game"), "", true, false),
>  	lan
>  		(this, "lan",
> -		 m_butx, get_h() * 61 / 200, m_butw, m_buth,
> -		 g_gr->images().get("pics/but1.png"),
> -		 _("LAN / Direct IP"), std::string(), true, false),
> +		 m_butx, get_y_from_preceding(metaserver) + m_padding, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("LAN / Direct IP"), "", true, false),
>  	back
>  		(this, "back",
> -		 m_butx, get_h() * 3 / 4, m_butw, m_buth,
> -		 g_gr->images().get("pics/but0.png"),
> -		 _("Back"), std::string(), true, false)
> +		 m_butx, m_back_button_y, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("Back"), "", true, false)
>  {
>  	metaserver.sigclicked.connect(boost::bind(&FullscreenMenuMultiPlayer::internet_login, boost::ref(*this)));
> -	metaserver.set_font(font_small());
> -	lan.set_font(font_small());
> +
>  	lan.sigclicked.connect
>  		(boost::bind
>  			 (&FullscreenMenuMultiPlayer::end_modal, boost::ref(*this),
> -			  static_cast<int32_t>(Lan)));
> -	back.set_font(font_small());
> +			  static_cast<int32_t>(MenuTarget::kLan)));
> +
>  	back.sigclicked.connect
>  		(boost::bind
>  			 (&FullscreenMenuMultiPlayer::end_modal, boost::ref(*this),
> -			  static_cast<int32_t>(Back)));
> +			  static_cast<int32_t>(MenuTarget::kBack)));
>  
> -	title.set_font(m_fn, fs_big(), UI_FONT_CLR_FG);
> +	title.set_font(ui_fn(), fs_big(), UI_FONT_CLR_FG);
>  
>  	Section & s = g_options.pull_section("global");
>  	m_auto_log = s.get_bool("auto_log", false);
> @@ -115,7 +107,7 @@
>  		m_nickname = s.get_string("nickname", _("nobody"));
>  		m_password = s.get_string("password", "nobody");
>  		m_register = s.get_bool("registered", false);
> -		end_modal(Metaserver);
> +		end_modal(static_cast<int32_t>(MenuTarget::kMetaserver));
>  		return;
>  	}
>  
> @@ -128,6 +120,6 @@
>  		s.set_bool("registered", lb.registered());
>  		s.set_bool("auto_log", lb.set_automaticlog());
>  
> -		end_modal(Metaserver);
> +		end_modal(static_cast<int32_t>(MenuTarget::kMetaserver));
>  	}
>  }
> 
> === modified file 'src/ui_fsmenu/multiplayer.h'
> --- src/ui_fsmenu/multiplayer.h	2014-09-20 09:37:47 +0000
> +++ src/ui_fsmenu/multiplayer.h	2014-11-12 18:38:19 +0000
> @@ -20,7 +20,7 @@
>  #ifndef WL_UI_FSMENU_MULTIPLAYER_H
>  #define WL_UI_FSMENU_MULTIPLAYER_H
>  
> -#include "ui_fsmenu/base.h"
> +#include "ui_fsmenu/main_menu.h"
>  #include "network/internet_gaming.h"
>  #include "ui_basic/button.h"
>  #include "ui_basic/textarea.h"
> @@ -29,10 +29,14 @@
>   * Fullscreen Menu for MultiPlayer.
>   * Here you select what game you want to play.
>   */
> -struct FullscreenMenuMultiPlayer : public FullscreenMenuBase {
> +struct FullscreenMenuMultiPlayer : public FullscreenMenuMainMenu {
>  	FullscreenMenuMultiPlayer();
>  
> -	enum {Back = dying_code, Metaserver, Lan};
> +	enum class MenuTarget: int32_t {
> +		kBack = UI::Panel::dying_code,
> +		kMetaserver,
> +		kLan
> +	};
>  
>  	void show_internet_login();
>  	void internet_login();
> @@ -41,16 +45,11 @@
>  	bool registered()          {return m_register;}
>  
>  private:
> -	uint32_t                                            m_butw;
> -	uint32_t                                            m_buth;
> -	uint32_t                                            m_butx;
> -	uint32_t                                            m_fs;
> -	std::string                                         m_fn;
> -	UI::Textarea                                        title;
> -	UI::Button                             metaserver;
> -	UI::Button                           * showloginbox;
> -	UI::Button                             lan;
> -	UI::Button                             back;
> +	UI::Textarea title;
> +	UI::Button   metaserver;
> +	UI::Button*  showloginbox;
> +	UI::Button   lan;
> +	UI::Button   back;
>  
>  	// Values from internet login window
>  	std::string m_nickname;
> 
> === modified file 'src/ui_fsmenu/singleplayer.cc'
> --- src/ui_fsmenu/singleplayer.cc	2014-09-27 09:28:51 +0000
> +++ src/ui_fsmenu/singleplayer.cc	2014-11-12 18:38:19 +0000
> @@ -24,65 +24,56 @@
>  #include "wui/text_constants.h"
>  
>  FullscreenMenuSinglePlayer::FullscreenMenuSinglePlayer() :
> -FullscreenMenuBase("ui_fsmenu.jpg"),
> -
> -// Values for alignment and size
> -	m_butw (get_w() * 7 / 20),
> -	m_buth (get_h() * 19 / 400),
> -	m_butx ((get_w() - m_butw) / 2),
> -	m_fs   (fs_small()),
> -	m_fn   (ui_fn()),
> +	FullscreenMenuMainMenu(),
>  
>  // Title
>  	title
>  		(this,
> -		 get_w() / 2, get_h() * 3 / 40,
> +		 get_w() / 2, m_title_y,
>  		 _("Single Player"), UI::Align_HCenter),
>  
>  // Buttons
>  	new_game
>  		(this, "new_game",
> -		 m_butx, get_h() * 6 / 25, m_butw, m_buth,
> -		 g_gr->images().get("pics/but1.png"),
> -		 _("New Game"), std::string(), true, false),
> +		 m_butx, m_buty, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("New Game"), "", true, false),
>  	campaign
>  		(this, "campaigns",
> -		 m_butx, get_h() * 61 / 200, m_butw, m_buth,
> -		 g_gr->images().get("pics/but1.png"),
> -		 _("Campaigns"), std::string(), true, false),
> +		 m_butx, get_y_from_preceding(new_game) + m_padding, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("Campaigns"), "", true, false),
>  	load_game
>  		(this, "load_game",
> -		 m_butx, get_h() * 87 / 200, m_butw, m_buth,
> -		 g_gr->images().get("pics/but1.png"),
> -		 _("Load Game"), std::string(), true, false),
> +		 m_butx, get_y_from_preceding(campaign) + 2 * m_buth, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("Load Game"), "", true, false),
>  	back
>  		(this, "back",
> -		 m_butx, get_h() * 3 / 4, m_butw, m_buth,
> -		 g_gr->images().get("pics/but0.png"),
> -		 _("Back"), std::string(), true, false)
> +		 m_butx, m_back_button_y, m_butw, m_buth,
> +		 g_gr->images().get(m_button_background),
> +		 _("Back"), "", true, false)
>  {
>  	new_game.sigclicked.connect
>  		(boost::bind
>  			(&FullscreenMenuSinglePlayer::end_modal,
>  			 boost::ref(*this),
> -			 static_cast<int32_t>(New_Game)));
> +			 static_cast<int32_t>(MenuTarget::kNewGame)));
>  	campaign.sigclicked.connect
>  		(boost::bind
>  			(&FullscreenMenuSinglePlayer::end_modal,
>  			 boost::ref(*this),
> -			 static_cast<int32_t>(Campaign)));
> +			 static_cast<int32_t>(MenuTarget::kCampaign)));
>  	load_game.sigclicked.connect
>  		(boost::bind
>  			(&FullscreenMenuSinglePlayer::end_modal,
>  			 boost::ref(*this),
> -			 static_cast<int32_t>(Load_Game)));
> +			 static_cast<int32_t>(MenuTarget::kLoadGame)));
>  	back.sigclicked.connect
> -		(boost::bind(&FullscreenMenuSinglePlayer::end_modal, boost::ref(*this), static_cast<int32_t>(Back)));
> -
> -	back.set_font(font_small());
> -	new_game.set_font(font_small());
> -	campaign.set_font(font_small());
> -	load_game.set_font(font_small());
> -
> -	title.set_font(m_fn, fs_big(), UI_FONT_CLR_FG);
> +		(boost::bind
> +			(&FullscreenMenuSinglePlayer::end_modal,
> +			 boost::ref(*this),
> +			 static_cast<int32_t>(MenuTarget::kBack)));
> +
> +	title.set_font(ui_fn(), fs_big(), UI_FONT_CLR_FG);
>  }
> 
> === modified file 'src/ui_fsmenu/singleplayer.h'
> --- src/ui_fsmenu/singleplayer.h	2014-09-10 14:08:25 +0000
> +++ src/ui_fsmenu/singleplayer.h	2014-11-12 18:38:19 +0000
> @@ -20,7 +20,7 @@
>  #ifndef WL_UI_FSMENU_SINGLEPLAYER_H
>  #define WL_UI_FSMENU_SINGLEPLAYER_H
>  
> -#include "ui_fsmenu/base.h"
> +#include "ui_fsmenu/main_menu.h"
>  #include "ui_basic/button.h"
>  #include "ui_basic/textarea.h"
>  
> @@ -28,22 +28,22 @@
>   * Fullscreen Menu for SinglePlayer.
>   * Here you select what game you want to play.
>   */
> -struct FullscreenMenuSinglePlayer : public FullscreenMenuBase {
> +struct FullscreenMenuSinglePlayer : public FullscreenMenuMainMenu {
>  	FullscreenMenuSinglePlayer();
>  
> -	enum {Back = dying_code, New_Game, Campaign, Load_Game};
> +	enum class MenuTarget: int32_t {
> +		kBack = UI::Panel::dying_code,
> +		kNewGame,
> +		kCampaign,
> +		kLoadGame
> +	};
>  
>  private:
> -	uint32_t                                            m_butw;
> -	uint32_t                                            m_buth;
> -	uint32_t                                            m_butx;
> -	uint32_t                                            m_fs;
> -	std::string                                         m_fn;
> -	UI::Textarea                                        title;
> -	UI::Button                             new_game;
> -	UI::Button                             campaign;
> -	UI::Button                             load_game;
> -	UI::Button                             back;
> +	UI::Textarea title;
> +	UI::Button   new_game;
> +	UI::Button   campaign;
> +	UI::Button   load_game;
> +	UI::Button   back;
>  };
>  
>  #endif  // end of include guard: WL_UI_FSMENU_SINGLEPLAYER_H
> 
> === modified file 'src/wlapplication.cc'
> --- src/wlapplication.cc	2014-11-08 14:59:03 +0000
> +++ src/wlapplication.cc	2014-11-12 18:38:19 +0000
> @@ -1099,38 +1099,43 @@
>  
>  		try {
>  			switch (mm.run()) {
> -			case FullscreenMenuMain::mm_playtutorial:
> +			case static_cast<int32_t>(FullscreenMenuMain::MenuTarget::kTutorial):

do not cast the case:s, instead cast the variable in the switch (mm.run()) to the enum class once.

Same comment for everywhere else below.

>  				mainmenu_tutorial();
>  				break;
> -			case FullscreenMenuMain::mm_singleplayer:
> +			case static_cast<int32_t>(FullscreenMenuMain::MenuTarget::kSinglePlayer):
>  				mainmenu_singleplayer();
>  				break;
> -			case FullscreenMenuMain::mm_multiplayer:
> +			case static_cast<int32_t>(FullscreenMenuMain::MenuTarget::kMultiplayer):
>  				mainmenu_multiplayer();
>  				break;
> -			case FullscreenMenuMain::mm_replay:
> +			case static_cast<int32_t>(FullscreenMenuMain::MenuTarget::kReplay):
>  				replay();
>  				break;
> -			case FullscreenMenuMain::mm_options: {
> +			case static_cast<int32_t>(FullscreenMenuMain::MenuTarget::kOptions): {
>  				Section & s = g_options.pull_section("global");
>  				OptionsCtrl om(s);
>  				break;
>  			}
> -			case FullscreenMenuMain::mm_readme: {
> +			case static_cast<int32_t>(FullscreenMenuMain::MenuTarget::kReadme): {
>  				FullscreenMenuFileView ff("txts/README.lua");
>  				ff.run();
>  				break;
>  			}
> -			case FullscreenMenuMain::mm_license: {
> +			case static_cast<int32_t>(FullscreenMenuMain::MenuTarget::kLicense): {
>  				FullscreenMenuFileView ff("txts/license");
>  				ff.run();
>  				break;
>  			}
> -			case FullscreenMenuMain::mm_editor:
> +			case static_cast<int32_t>(FullscreenMenuMain::MenuTarget::kAuthors): {
> +				FullscreenMenuFileView ff("txts/developers");
> +				ff.run();
> +				break;
> +			}
> +			case static_cast<int32_t>(FullscreenMenuMain::MenuTarget::kEditor):
>  				mainmenu_editor();
>  				break;
>  			default:
> -			case FullscreenMenuMain::mm_exit:
> +			case static_cast<int32_t>(FullscreenMenuMain::MenuTarget::kExit):
>  				return;
>  			}
>  		} catch (const WLWarning & e) {
> @@ -1199,7 +1204,8 @@
>  	//  This is the code returned by UI::Panel::run() when the panel is dying.
>  	//  Make sure that the program exits when the window manager says so.
>  	static_assert
> -		(FullscreenMenuSinglePlayer::Back == UI::Panel::dying_code, "Panel should be dying.");
> +		(static_cast<int32_t>(FullscreenMenuSinglePlayer::MenuTarget::kBack) == UI::Panel::dying_code,
> +		 "Panel should be dying.");
>  
>  	for (;;) {
>  		int32_t code;
> @@ -1208,17 +1214,17 @@
>  			code = single_player_menu.run();
>  		}
>  		switch (code) {
> -		case FullscreenMenuSinglePlayer::Back:
> +		case static_cast<int32_t>(FullscreenMenuSinglePlayer::MenuTarget::kBack):
>  			return;
> -		case FullscreenMenuSinglePlayer::New_Game:
> +		case static_cast<int32_t>(FullscreenMenuSinglePlayer::MenuTarget::kNewGame):
>  			if (new_game())
>  				return;
>  			break;
> -		case FullscreenMenuSinglePlayer::Load_Game:
> +		case static_cast<int32_t>(FullscreenMenuSinglePlayer::MenuTarget::kLoadGame):
>  			if (load_game())
>  				return;
>  			break;
> -		case FullscreenMenuSinglePlayer::Campaign:
> +		case static_cast<int32_t>(FullscreenMenuSinglePlayer::MenuTarget::kCampaign):
>  			if (campaign_game())
>  				return;
>  			break;
> @@ -1240,12 +1246,12 @@
>  		bool internet = false;
>  		FullscreenMenuMultiPlayer mp;
>  		switch (mp.run()) {
> -			case FullscreenMenuMultiPlayer::Back:
> +			case static_cast<int32_t>(FullscreenMenuMultiPlayer::MenuTarget::kBack):
>  				return;
> -			case FullscreenMenuMultiPlayer::Metaserver:
> +			case static_cast<int32_t>(FullscreenMenuMultiPlayer::MenuTarget::kMetaserver):
>  				internet = true;
>  				break;
> -			case FullscreenMenuMultiPlayer::Lan:
> +			case static_cast<int32_t>(FullscreenMenuMultiPlayer::MenuTarget::kLan):
>  				break;
>  			default:
>  				assert(false);
> @@ -1315,7 +1321,8 @@
>  	//  This is the code returned by UI::Panel::run() when the panel is dying.
>  	//  Make sure that the program exits when the window manager says so.
>  	static_assert
> -		(FullscreenMenuEditor::Back == UI::Panel::dying_code, "Editor should be dying.");
> +		(static_cast<int32_t>(FullscreenMenuEditor::MenuTarget::kBack) == UI::Panel::dying_code,
> +		 "Editor should be dying.");
>  
>  	for (;;) {
>  		int32_t code;
> @@ -1324,12 +1331,12 @@
>  			code = editor_menu.run();
>  		}
>  		switch (code) {
> -		case FullscreenMenuEditor::Back:
> +		case static_cast<int32_t>(FullscreenMenuEditor::MenuTarget::kBack):
>  			return;
> -		case FullscreenMenuEditor::New_Map:
> +		case static_cast<int32_t>(FullscreenMenuEditor::MenuTarget::kNewMap):
>  			EditorInteractive::run_editor(m_filename, m_script_to_run);
>  			return;
> -		case FullscreenMenuEditor::Load_Map: {
> +		case static_cast<int32_t>(FullscreenMenuEditor::MenuTarget::kLoadMap): {
>  			std::string filename;
>  			{
>  				SinglePlayerGameSettingsProvider sp;
> 
> === modified file 'txts/developers'
> --- txts/developers	2014-10-12 12:22:54 +0000
> +++ txts/developers	2014-11-12 18:38:19 +0000
> @@ -1,4 +1,4 @@
> -title=_ Development
> +title=_Authors
>  text=_""<rt text-align=center><p font-size=28 font-decoration=bold font-face=DejaVuSerif font-color=2F9131>"
>  _ "Widelands Development Team"
>  "</p></rt>"
> 


-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-859245/+merge/241549
Your team Widelands Developers is subscribed to branch lp:~widelands-dev/widelands/bug-859245.


References