1 /*
2 * Copyright (C) 2002-2020 by the Widelands Development Team
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 *
18 */
19
20 #include "ui_fsmenu/base.h"
21
22 /*
23 ==============================================================================
24
25 FullscreenMenuBase
26
27 ==============================================================================
28 */
29
30 /**
31 * Initialize a pre-game menu
32 */
FullscreenMenuBase()33 FullscreenMenuBase::FullscreenMenuBase() : UI::FullscreenWindow() {
34 }
35
~FullscreenMenuBase()36 FullscreenMenuBase::~FullscreenMenuBase() {
37 }
38
handle_key(bool down,SDL_Keysym code)39 bool FullscreenMenuBase::handle_key(bool down, SDL_Keysym code) {
40 if (down) {
41 switch (code.sym) {
42 case SDLK_KP_ENTER:
43 case SDLK_RETURN:
44 clicked_ok();
45 return true;
46 case SDLK_ESCAPE:
47 clicked_back();
48 return true;
49 default:
50 break; // not handled
51 }
52 }
53 return UI::Panel::handle_key(down, code);
54 }
55
clicked_back()56 void FullscreenMenuBase::clicked_back() {
57 end_modal<FullscreenMenuBase::MenuTarget>(FullscreenMenuBase::MenuTarget::kBack);
58 }
clicked_ok()59 void FullscreenMenuBase::clicked_ok() {
60 end_modal<FullscreenMenuBase::MenuTarget>(FullscreenMenuBase::MenuTarget::kOk);
61 }
62