← Back to team overview

widelands-dev team mailing list archive

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

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1371062 into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1371062 in widelands: "Add confirmation dialog to exit game"
  https://bugs.launchpad.net/widelands/+bug/1371062

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1371062/+merge/238048

Added a confirmation dialog to the "Exit Game" button. Added some tooltips and fixed some strings.
-- 
https://code.launchpad.net/~widelands-dev/widelands/bug-1371062/+merge/238048
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1371062 into lp:widelands.
=== modified file 'src/ui_fsmenu/main.cc'
--- src/ui_fsmenu/main.cc	2014-09-10 14:08:25 +0000
+++ src/ui_fsmenu/main.cc	2014-10-11 09:33:25 +0000
@@ -77,7 +77,7 @@
 		(this, "exit",
 		 m_butx, get_h() * 178 / 200, m_butw, m_buth,
 		 g_gr->images().get("pics/but3.png"),
-		 _("Exit Game"), std::string(), true, false),
+		 _("Exit Widelands"), std::string(), true, false),
 
 // Textlabels
 	version

=== modified file 'src/wui/game_main_menu.cc'
--- src/wui/game_main_menu.cc	2014-09-10 16:57:31 +0000
+++ src/wui/game_main_menu.cc	2014-10-11 09:33:25 +0000
@@ -36,7 +36,7 @@
 	 UI::UniqueWindow::Registry                 & registry,
 	 InteractivePlayer::GameMainMenuWindows & windows)
 :
-UI::UniqueWindow(&plr, "main_menu", &registry, 180, 55, _("Main Menu")),
+UI::UniqueWindow(&plr, "main_menu", &registry, 180, 55, _("Statistics Menu")),
 m_player      (plr),
 m_windows     (windows),
 general_stats

=== modified file 'src/wui/game_options_menu.cc'
--- src/wui/game_options_menu.cc	2014-09-10 16:57:31 +0000
+++ src/wui/game_options_menu.cc	2014-10-11 09:33:25 +0000
@@ -30,10 +30,11 @@
 #include "ui_fsmenu/fileview.h"
 #include "wui/game_main_menu_save_game.h"
 #include "wui/game_options_sound_menu.h"
+#include "wui/unique_window_handler.h"
 
 GameOptionsMenu::GameOptionsMenu
-	(InteractiveGameBase                         & gb,
-	 UI::UniqueWindow::Registry                   & registry,
+	(InteractiveGameBase                      & gb,
+	 UI::UniqueWindow::Registry               & registry,
 	 InteractiveGameBase::GameMainMenuWindows & windows)
 :
 	UI::UniqueWindow
@@ -52,28 +53,36 @@
 		 vmargin() + 0 * (20 + vspacing()) + 0 * vgap(),
 		 buttonw(1), 20,
 		 g_gr->images().get("pics/but4.png"),
-		 _("README")),
+		 _("README"),
+		/** TRANSLATORS: Button tooltip */
+		_("Show general information about Widelands and keyboard shortcuts")),
 	license
 		(this, "license",
 		 posx(0, 1),
 		 vmargin() + 1 * (20 + vspacing()) + 0 * vgap(),
 		 buttonw(1), 20,
 		 g_gr->images().get("pics/but4.png"),
-		 _("License")),
+		 _("License"),
+		/** TRANSLATORS: Button tooltip */
+		_("Show the distribution licence document")),
 	authors
 		(this, "authors",
 		 posx(0, 1),
 		 vmargin() + 2 * (20 + vspacing()) + 0 * vgap(),
 		 buttonw(1), 20,
 		 g_gr->images().get("pics/but4.png"),
-		 _("Authors")),
+		 _("Authors"),
+		/** TRANSLATORS: Button tooltip */
+		_("Show information about the Widelands Development Team")),
 	sound
 		(this, "sound_options",
 		 posx(0, 1),
 		 vmargin() + 3 * (20 + vspacing()) + 1 * vgap(),
 		 buttonw(1), 20,
 		 g_gr->images().get("pics/but4.png"),
-		 _("Sound Options")),
+		 _("Sound Options"),
+		/** TRANSLATORS: Button tooltip */
+		_("Set sound effect and music options")),
 	save_game
 		(this, "save_game",
 		 posx(0, 1),
@@ -81,6 +90,7 @@
 		 buttonw(1), 35,
 		 g_gr->images().get("pics/but4.png"),
 		 g_gr->images().get("pics/menu_save_game.png"),
+		 /** TRANSLATORS: Button tooltip */
 		 _("Save Game")),
 	exit_game
 		(this, "exit_game",
@@ -90,6 +100,7 @@
 		 buttonw(1), 35,
 		 g_gr->images().get("pics/but4.png"),
 		 g_gr->images().get("pics/menu_exit_game.png"),
+		 /** TRANSLATORS: Button tooltip */
 		 _("Exit Game"))
 {
 	readme.sigclicked.connect
@@ -133,6 +144,11 @@
 	if (get_usedefaultpos())
 		center_to_parent();
 }
+GameOptionsMenu::~GameOptionsMenu() {
+	UI::UniqueWindow::Registry& registry =
+		m_gb.unique_windows().get_registry("game_options_confirm_exit_game");
+	registry.destroy();
+}
 
 void GameOptionsMenu::clicked_sound() {
 	if (m_windows.sound_options.window)
@@ -146,4 +162,44 @@
 	die();
 }
 
-void GameOptionsMenu::clicked_exit_game() {m_gb.end_modal(0);}
+
+struct GameOptionsMenuExitConfirmBox : public UI::WLMessageBox {
+	GameOptionsMenuExitConfirmBox
+		(UI::Panel& parent, InteractiveGameBase & gb)
+		:
+		UI::WLMessageBox
+			(&parent,
+			 /** TRANSLATORS: Window label when "Exit game" has been pressed */
+			 _("Exit Game Confirmation"),
+			_("Are you sure you wish to exit this game?"),
+			 YESNO),
+		m_gb(gb)
+	{}
+
+	void pressed_yes() override
+	{
+		m_gb.end_modal(0);
+	}
+
+	void pressed_no() override
+	{
+		die();
+	}
+
+private:
+	InteractiveGameBase & m_gb;
+};
+
+void GameOptionsMenu::clicked_exit_game() {
+	if (get_key_state(SDLK_LCTRL) || get_key_state(SDLK_RCTRL)) {
+		m_gb.end_modal(0);
+	}
+	else {
+		UI::UniqueWindow::Registry& registry =
+			m_gb.unique_windows().get_registry("game_options_confirm_exit_game");
+		registry.open_window = [this, &registry] {
+			new GameOptionsMenuExitConfirmBox(*get_parent(), m_gb);
+		};
+		registry.create();
+	}
+}

=== modified file 'src/wui/game_options_menu.h'
--- src/wui/game_options_menu.h	2014-09-10 16:57:31 +0000
+++ src/wui/game_options_menu.h	2014-10-11 09:33:25 +0000
@@ -22,15 +22,20 @@
 
 #include "wui/interactive_gamebase.h"
 #include "ui_basic/button.h"
+#include "ui_basic/messagebox.h"
 #include "ui_basic/textarea.h"
 #include "ui_basic/unique_window.h"
 
+struct GameOptionsMenuExitConfirmBox;
+
 // The GameOptionsMenu is a rather dumb window with lots of buttons
 struct GameOptionsMenu : public UI::UniqueWindow {
+	friend struct GameOptionsMenuExitConfirmBox;
 	GameOptionsMenu
 		(InteractiveGameBase &,
 		 UI::UniqueWindow::Registry &,
 		 InteractiveGameBase::GameMainMenuWindows &);
+	~GameOptionsMenu();
 
 private:
 	InteractiveGameBase                         & m_gb;

=== modified file 'txts/README.lua'
--- txts/README.lua	2014-09-18 16:41:26 +0000
+++ txts/README.lua	2014-10-11 09:33:25 +0000
@@ -74,6 +74,7 @@
 .. _".: goes to the next location" .. "<br>"
 .. _"F6: shows the debug console (only in debug-builds)" .. "<br>"
 .. _"CTRL+F10: quits the game immediately" .. "<br>"
+.. _"CTRL+Leftclick: skips confirmation dialogs" .. "<br>"
 .. _"F11: takes a screenshot"
    ) .. p(_
 [[In the message window, the following additional shortcuts are available:]]


Follow ups