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/load_map_or_game.h"
21
22 #include "base/i18n.h"
23 #include "io/filesystem/filesystem.h"
24 #include "ui_basic/button.h"
25
26 /// Select a Map, Saved Game or Replay in Fullscreen Mode.
27 /// This class defines common coordinates for these UI screens.
28 /// It also defines common buttons.
FullscreenMenuLoadMapOrGame()29 FullscreenMenuLoadMapOrGame::FullscreenMenuLoadMapOrGame()
30 : FullscreenMenuBase(),
31 // Main buttons
32 back_(this, "back", 0, 0, 0, 0, UI::ButtonStyle::kFsMenuSecondary, _("Back")),
33 ok_(this, "ok", 0, 0, 0, 0, UI::ButtonStyle::kFsMenuPrimary, _("OK")) {
34 layout();
35 }
36
layout()37 void FullscreenMenuLoadMapOrGame::layout() {
38 // UI coordinates and spacers
39 tablex_ = get_w() * 47 / 2500;
40 tabley_ = get_h() * 17 / 50;
41 tablew_ = get_w() * 711 / 1250;
42 tableh_ = get_h() * 6083 / 10000;
43 right_column_x_ = tablex_ + tablew_ + right_column_margin_;
44 buty_ = get_h() * 9 / 10;
45 butw_ = (get_w() - right_column_x_ - right_column_margin_) / 2 - padding_;
46 buth_ = get_h() * 9 / 200;
47 right_column_tab_ = get_w() - right_column_margin_ - butw_;
48
49 // Main buttons
50 back_.set_size(butw_, buth_);
51 back_.set_pos(Vector2i(right_column_x_, buty_));
52 ok_.set_size(butw_, buth_);
53 ok_.set_pos(Vector2i(get_w() - right_column_margin_ - butw_, buty_));
54 }
55
get_y_from_preceding(UI::Panel & preceding_panel)56 int32_t FullscreenMenuLoadMapOrGame::get_y_from_preceding(UI::Panel& preceding_panel) {
57 return preceding_panel.get_y() + preceding_panel.get_h();
58 }
59
get_right_column_w(int32_t x)60 int32_t FullscreenMenuLoadMapOrGame::get_right_column_w(int32_t x) {
61 return get_w() - right_column_margin_ - x;
62 }
63