← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1773688-ui-starting-condition2 into lp:widelands

 

Notabilis has proposed merging lp:~widelands-dev/widelands/bug-1773688-ui-starting-condition2 into lp:widelands.

Commit message:
Fixing optical ui bugs with setting up scenario games.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1773688-ui-starting-condition2/+merge/347633

(Second merge request for this branch. First one wasn't handled correctly within launchpad.)

Three changes:
- Displaying start type of players as "Scenario" when selecting a scenario map in single player. In trunk, the previously selected start type (e.g., Headquarters) is still displayed even though it is no longer valid.
- Setting same tooltip for the start type of scenarios in multiplayer. In trunk the tooltype is only set for the players that have been active on the previously selected map.
- Same handling for single player "select map" dialog independent of whether it is reached per "back" or "select map" button. In trunk "select map" kept the settings regarding tribe, etc., while the "back" button resets it.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1773688-ui-starting-condition2 into lp:widelands.
=== modified file 'src/ui_fsmenu/launch_spg.cc'
--- src/ui_fsmenu/launch_spg.cc	2018-04-27 06:11:05 +0000
+++ src/ui_fsmenu/launch_spg.cc	2018-06-07 17:51:58 +0000
@@ -127,8 +127,7 @@
  * showing the actual setup menu.
  */
 void FullscreenMenuLaunchSPG::start() {
-	select_map();
-	if (settings_->settings().mapname.empty()) {
+	if (!select_map()) {
 		end_modal<FullscreenMenuBase::MenuTarget>(FullscreenMenuBase::MenuTarget::kBack);
 	}
 }
@@ -141,11 +140,10 @@
 	//  user it seems as if the launchgame-menu is a child of mapselect and
 	//  not the other way around - just end_modal(0); will be seen as bug
 	//  from user point of view, so we reopen the mapselect-menu.
-	settings_->set_map(std::string(), std::string(), 0);
-	select_map();
-	if (settings_->settings().mapname.empty())
+	if (!select_map()) {
+		// No map has been selected: Go back to main menu
 		return end_modal<FullscreenMenuBase::MenuTarget>(FullscreenMenuBase::MenuTarget::kBack);
-	refresh();
+	}
 }
 
 void FullscreenMenuLaunchSPG::win_condition_selected() {
@@ -222,10 +220,11 @@
 
 /**
  * Select a map and send all information to the user interface.
+ * Returns whether a map has been selected.
  */
-void FullscreenMenuLaunchSPG::select_map() {
+bool FullscreenMenuLaunchSPG::select_map() {
 	if (!settings_->can_change_map())
-		return;
+		return false;
 
 	FullscreenMenuMapSelect msm(settings_, nullptr);
 	FullscreenMenuBase::MenuTarget code = msm.run<FullscreenMenuBase::MenuTarget>();
@@ -233,7 +232,7 @@
 	if (code == FullscreenMenuBase::MenuTarget::kBack) {
 		// Set scenario = false, else the menu might crash when back is pressed.
 		settings_->set_scenario(false);
-		return;  // back was pressed
+		return false;  // back was pressed
 	}
 
 	is_scenario_ = code == FullscreenMenuBase::MenuTarget::kScenarioGame;
@@ -245,6 +244,7 @@
 	safe_place_for_host(nr_players_);
 	settings_->set_map(mapdata.name, mapdata.filename, nr_players_);
 	update_win_conditions();
+	return true;
 }
 
 /**

=== modified file 'src/ui_fsmenu/launch_spg.h'
--- src/ui_fsmenu/launch_spg.h	2018-04-27 06:11:05 +0000
+++ src/ui_fsmenu/launch_spg.h	2018-06-07 17:51:58 +0000
@@ -60,7 +60,7 @@
 private:
 	void layout() override;
 
-	void select_map();
+	bool select_map();
 	void win_condition_selected() override;
 	void set_scenario_values();
 	void switch_to_position(uint8_t);

=== modified file 'src/wui/multiplayersetupgroup.cc'
--- src/wui/multiplayersetupgroup.cc	2018-05-13 07:15:39 +0000
+++ src/wui/multiplayersetupgroup.cc	2018-06-07 17:51:58 +0000
@@ -502,6 +502,7 @@
 		const PlayerSettings& player_setting = settings.players[id_];
 		if (settings.scenario) {
 			init_dropdown_.set_label(_("Scenario"));
+			init_dropdown_.set_tooltip(_("Start type is set through the scenario"));
 		} else if (settings.savegame) {
 			/** Translators: This is a game type */
 			init_dropdown_.set_label(_("Saved Game"));

=== modified file 'src/wui/playerdescrgroup.cc'
--- src/wui/playerdescrgroup.cc	2018-05-26 08:52:13 +0000
+++ src/wui/playerdescrgroup.cc	2018-06-07 17:51:58 +0000
@@ -174,7 +174,10 @@
 				d->btnPlayerTribe->set_tooltip(info.tooltip);
 			}
 
-			{
+			if (settings.scenario) {
+				d->btnPlayerInit->set_title(_("Scenario"));
+				d->btnPlayerInit->set_tooltip(_("Start type is set through the scenario"));
+			} else {
 				i18n::Textdomain td("tribes");  // for translated initialisation
 				for (const Widelands::TribeBasicInfo& tribeinfo : settings.tribes) {
 					if (tribeinfo.name == player.tribe) {


Follow ups