← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~thenifker13/widelands/trunk into lp:widelands

 

You have been requested to review the proposed merge of lp:~thenifker13/widelands/trunk into lp:widelands.

For more details, see:
https://code.launchpad.net/~thenifker13/widelands/trunk/+merge/368235

Window closing, opening OptionsMenu and exiting using the keyboard.

-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~thenifker13/widelands/trunk into lp:widelands.
=== modified file 'src/editor/editorinteractive.cc'
--- src/editor/editorinteractive.cc	2019-04-26 05:52:49 +0000
+++ src/editor/editorinteractive.cc	2019-07-28 13:42:36 +0000
@@ -566,7 +566,9 @@
 		case SDLK_F1:
 			helpmenu_.toggle();
 			return true;
-
+		case SDLK_ESCAPE:
+			new EditorMainMenu(*this, mainmenu_);
+			return true;
 		default:
 			break;
 		}

=== modified file 'src/editor/ui_menus/main_menu.cc'
--- src/editor/ui_menus/main_menu.cc	2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/main_menu.cc	2019-07-28 13:42:36 +0000
@@ -82,6 +82,22 @@
 		center_to_parent();
 }
 
+bool EditorMainMenu::handle_key(bool down, SDL_Keysym code) {
+	if (down) {
+		switch (code.sym) {
+			case SDLK_ESCAPE:
+				die();
+				return true;
+			case SDLK_RETURN:
+				exit_btn();
+				return true;
+			default:
+				break;
+		}
+	}
+	return UI::Window::handle_key(down, code);
+}
+
 void EditorMainMenu::new_map_btn() {
 	new MainMenuNewMap(eia());
 	die();

=== modified file 'src/editor/ui_menus/main_menu.h'
--- src/editor/ui_menus/main_menu.h	2019-02-23 11:00:49 +0000
+++ src/editor/ui_menus/main_menu.h	2019-07-28 13:42:36 +0000
@@ -32,6 +32,8 @@
 struct EditorMainMenu : public UI::UniqueWindow {
 	EditorMainMenu(EditorInteractive&, UI::UniqueWindow::Registry&);
 
+	bool handle_key(bool down, SDL_Keysym code) override;
+
 private:
 	EditorInteractive& eia();
 	UI::Box box_;

=== modified file 'src/ui_basic/window.cc'
--- src/ui_basic/window.cc	2019-07-27 11:20:37 +0000
+++ src/ui_basic/window.cc	2019-07-28 13:42:36 +0000
@@ -101,6 +101,7 @@
 	   VT_B_PIXMAP_THICKNESS, VT_B_PIXMAP_THICKNESS, TP_B_PIXMAP_THICKNESS, BT_B_PIXMAP_THICKNESS);
 	set_top_on_click(true);
 	set_layout_toplevel(true);
+	focus();
 }
 
 /**
@@ -411,6 +412,25 @@
 	return true;
 }
 
+bool Window::handle_key(bool down, SDL_Keysym code) {
+	// Handles a key input and event and will close when pressing ESC
+
+	if (down) {
+		switch (code.sym) {
+			case SDLK_ESCAPE: {
+				die();
+				Panel *ch = get_next_sibling();
+				if (ch != nullptr)
+					ch->focus();
+				return true;
+			}
+			default:
+				break;
+		}
+	}
+	return UI::Panel::handle_key(down, code);
+}
+
 /**
  * Close the window. Overwrite this virtual method if you want
  * to take some action before the window is destroyed, or to

=== modified file 'src/ui_basic/window.h'
--- src/ui_basic/window.h	2019-02-23 11:00:49 +0000
+++ src/ui_basic/window.h	2019-07-28 13:42:36 +0000
@@ -98,6 +98,7 @@
 	handle_mousemove(uint8_t state, int32_t mx, int32_t my, int32_t xdiff, int32_t ydiff) override;
 	bool handle_mousewheel(uint32_t which, int32_t x, int32_t y) override;
 	bool handle_tooltip() override;
+	bool handle_key(bool down, SDL_Keysym code) override;
 
 protected:
 	void die() override;

=== modified file 'src/ui_fsmenu/campaign_select.cc'
--- src/ui_fsmenu/campaign_select.cc	2019-05-26 17:21:15 +0000
+++ src/ui_fsmenu/campaign_select.cc	2019-07-28 13:42:36 +0000
@@ -74,6 +74,8 @@
 	table_.focus();
 	fill_table();
 	layout();
+
+	table_.cancel.connect(boost::bind(&FullscreenMenuCampaignSelect::clicked_back, boost::ref(*this)));
 }
 
 void FullscreenMenuCampaignSelect::layout() {

=== modified file 'src/ui_fsmenu/loadgame.cc'
--- src/ui_fsmenu/loadgame.cc	2019-05-26 17:21:15 +0000
+++ src/ui_fsmenu/loadgame.cc	2019-07-28 13:42:36 +0000
@@ -109,6 +109,8 @@
 	if (!load_or_save_.table().empty()) {
 		load_or_save_.table().select(0);
 	}
+
+	load_or_save_.table_.cancel.connect(boost::bind(&FullscreenMenuLoadGame::clicked_back, boost::ref(*this)));
 }
 
 void FullscreenMenuLoadGame::layout() {

=== modified file 'src/ui_fsmenu/mapselect.cc'
--- src/ui_fsmenu/mapselect.cc	2019-05-26 17:21:15 +0000
+++ src/ui_fsmenu/mapselect.cc	2019-07-28 13:42:36 +0000
@@ -298,6 +298,8 @@
 		table_.select(0);
 	}
 	set_has_selection();
+
+	table_.cancel.connect(boost::bind(&FullscreenMenuMapSelect::clicked_back, boost::ref(*this)));
 }
 
 /*

=== modified file 'src/ui_fsmenu/scenario_select.cc'
--- src/ui_fsmenu/scenario_select.cc	2019-05-26 17:21:15 +0000
+++ src/ui_fsmenu/scenario_select.cc	2019-07-28 13:42:36 +0000
@@ -118,6 +118,8 @@
 	table_.focus();
 	fill_table();
 	layout();
+
+	table_.cancel.connect(boost::bind(&FullscreenMenuScenarioSelect::clicked_back, boost::ref(*this)));
 }
 
 void FullscreenMenuScenarioSelect::layout() {

=== modified file 'src/wui/game_message_menu.cc'
--- src/wui/game_message_menu.cc	2019-06-25 07:34:58 +0000
+++ src/wui/game_message_menu.cc	2019-07-28 13:42:36 +0000
@@ -360,6 +360,10 @@
  * Handle message menu hotkeys.
  */
 bool GameMessageMenu::handle_key(bool down, SDL_Keysym code) {
+	// Special ESCAPE handling
+	// When ESCAPE is pressed down is false
+	if (code.sym == SDLK_ESCAPE)
+		return UI::Window::handle_key(true, code);
 	if (down) {
 		switch (code.sym) {
 		// Don't forget to change the tooltips if any of these get reassigned

=== modified file 'src/wui/game_options_menu.cc'
--- src/wui/game_options_menu.cc	2019-03-18 07:11:02 +0000
+++ src/wui/game_options_menu.cc	2019-07-28 13:42:36 +0000
@@ -101,6 +101,28 @@
 		center_to_parent();
 }
 
+bool GameOptionsMenu::handle_key(bool down, SDL_Keysym code) {
+	if (down) {
+		switch (code.sym) {
+			case SDLK_ESCAPE:
+				die();
+				return true;
+			case SDLK_RETURN:
+				if ((code.mod & (KMOD_LCTRL | KMOD_RCTRL))) {
+					igb_.end_modal<UI::Panel::Returncodes>(UI::Panel::Returncodes::kBack);
+					return true;
+				}
+				
+				new GameExitConfirmBox(*get_parent(), igb_);
+				die();
+				return true;
+			default:
+				break;
+		}
+	}
+	return UI::Window::handle_key(down, code);
+}
+
 GameOptionsMenu::~GameOptionsMenu() {
 }
 

=== modified file 'src/wui/game_options_menu.h'
--- src/wui/game_options_menu.h	2019-02-23 11:00:49 +0000
+++ src/wui/game_options_menu.h	2019-07-28 13:42:36 +0000
@@ -32,8 +32,13 @@
 	GameOptionsMenu(InteractiveGameBase&,
 	                UI::UniqueWindow::Registry&,
 	                InteractiveGameBase::GameMainMenuWindows&);
+
+	bool handle_key(bool down, SDL_Keysym code) override;
+
+
 	~GameOptionsMenu();
 
+
 private:
 	InteractiveGameBase& igb_;
 	InteractiveGameBase::GameMainMenuWindows& windows_;

=== modified file 'src/wui/interactive_player.cc'
--- src/wui/interactive_player.cc	2019-05-31 19:31:45 +0000
+++ src/wui/interactive_player.cc	2019-07-28 13:42:36 +0000
@@ -487,7 +487,9 @@
 			map_view()->scroll_to_field(
 			   game().map().get_starting_pos(player_number_), MapView::Transition::Smooth);
 			return true;
-
+		case SDLK_ESCAPE:
+			new GameOptionsMenu(*this, options_, main_windows_);
+			return true;
 		case SDLK_KP_ENTER:
 		case SDLK_RETURN:
 			if (chat_provider_) {

=== modified file 'src/wui/login_box.cc'
--- src/wui/login_box.cc	2019-06-01 11:29:24 +0000
+++ src/wui/login_box.cc	2019-07-28 13:42:36 +0000
@@ -81,6 +81,9 @@
 	}
 
 	eb_nickname->focus();
+
+	eb_nickname->cancel.connect(boost::bind(&LoginBox::clicked_back, boost::ref(*this)));
+	eb_password->cancel.connect(boost::bind(&LoginBox::clicked_back, boost::ref(*this)));
 }
 
 /// think function of the UI (main loop)

=== modified file 'src/wui/story_message_box.cc'
--- src/wui/story_message_box.cc	2019-02-23 11:00:49 +0000
+++ src/wui/story_message_box.cc	2019-07-28 13:42:36 +0000
@@ -97,6 +97,9 @@
 		case SDLK_RETURN:
 			clicked_ok();
 			return true;
+		case SDLK_ESCAPE:
+			clicked_ok();
+			return UI::Window::handle_key(down, code);
 		default:
 			break;  // not handled
 		}


References