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/main.h"
21
22 #include "base/i18n.h"
23 #include "build_info.h"
24
FullscreenMenuMain()25 FullscreenMenuMain::FullscreenMenuMain()
26 : FullscreenMenuMainMenu(),
27
28 logo_icon_(this, g_gr->images().get("images/ui_fsmenu/main_title.png")),
29
30 // Buttons
31 playtutorial(&vbox_,
32 "play_tutorial",
33 0,
34 0,
35 butw_,
36 buth_,
37 UI::ButtonStyle::kFsMenuMenu,
38 _("Play Tutorial")),
39 singleplayer(&vbox_,
40 "single_player",
41 0,
42 0,
43 butw_,
44 buth_,
45 UI::ButtonStyle::kFsMenuMenu,
46 _("Single Player")),
47 multiplayer(
48 &vbox_, "multi_player", 0, 0, butw_, buth_, UI::ButtonStyle::kFsMenuMenu, _("Multiplayer")),
49 replay(&vbox_, "replay", 0, 0, butw_, buth_, UI::ButtonStyle::kFsMenuMenu, _("Watch Replay")),
50 editor(&vbox_, "editor", 0, 0, butw_, buth_, UI::ButtonStyle::kFsMenuMenu, _("Editor")),
51 options(&vbox_, "options", 0, 0, butw_, buth_, UI::ButtonStyle::kFsMenuMenu, _("Options")),
52 about(&vbox_, "about", 0, 0, butw_, buth_, UI::ButtonStyle::kFsMenuMenu, _("About Widelands")),
53 exit(&vbox_, "exit", 0, 0, butw_, buth_, UI::ButtonStyle::kFsMenuMenu, _("Exit Widelands")),
54
55 // Textlabels
56 version(
57 this,
58 0,
59 0,
60 0,
61 0,
62 /** TRANSLATORS: %1$s = version string, %2%s = "Debug" or "Release" */
63 (boost::format(_("Version %1$s (%2$s)")) % build_id().c_str() % build_type().c_str()).str(),
64 UI::Align::kRight),
65 copyright(this,
66 0,
67 0,
68 0,
69 0,
70 /** TRANSLATORS: Placeholders are the copyright years */
71 (boost::format(_("(C) %1%-%2% by the Widelands Development Team")) %
72 kWidelandsCopyrightStart % kWidelandsCopyrightEnd)
73 .str()),
74 gpl(this, 0, 0, 0, 0, _("Licensed under the GNU General Public License V2.0")) {
75 playtutorial.sigclicked.connect([this]() {
76 end_modal<FullscreenMenuBase::MenuTarget>(FullscreenMenuBase::MenuTarget::kTutorial);
77 });
78 singleplayer.sigclicked.connect([this]() {
79 end_modal<FullscreenMenuBase::MenuTarget>(FullscreenMenuBase::MenuTarget::kSinglePlayer);
80 });
81 multiplayer.sigclicked.connect([this]() {
82 end_modal<FullscreenMenuBase::MenuTarget>(FullscreenMenuBase::MenuTarget::kMultiplayer);
83 });
84 replay.sigclicked.connect([this]() {
85 end_modal<FullscreenMenuBase::MenuTarget>(FullscreenMenuBase::MenuTarget::kReplay);
86 });
87 editor.sigclicked.connect([this]() {
88 end_modal<FullscreenMenuBase::MenuTarget>(FullscreenMenuBase::MenuTarget::kEditor);
89 });
90 options.sigclicked.connect([this]() {
91 end_modal<FullscreenMenuBase::MenuTarget>(FullscreenMenuBase::MenuTarget::kOptions);
92 });
93 about.sigclicked.connect([this]() {
94 end_modal<FullscreenMenuBase::MenuTarget>(FullscreenMenuBase::MenuTarget::kAbout);
95 });
96 exit.sigclicked.connect([this]() {
97 end_modal<FullscreenMenuBase::MenuTarget>(FullscreenMenuBase::MenuTarget::kExit);
98 });
99
100 vbox_.add(&playtutorial, UI::Box::Resizing::kFullSize);
101 vbox_.add(&singleplayer, UI::Box::Resizing::kFullSize);
102 vbox_.add(&multiplayer, UI::Box::Resizing::kFullSize);
103 vbox_.add_inf_space();
104 vbox_.add(&replay, UI::Box::Resizing::kFullSize);
105 vbox_.add_inf_space();
106 vbox_.add(&editor, UI::Box::Resizing::kFullSize);
107 vbox_.add_inf_space();
108 vbox_.add(&options, UI::Box::Resizing::kFullSize);
109 vbox_.add_inf_space();
110 vbox_.add(&about, UI::Box::Resizing::kFullSize);
111 vbox_.add_inf_space();
112 vbox_.add(&exit, UI::Box::Resizing::kFullSize);
113
114 layout();
115 }
116
clicked_ok()117 void FullscreenMenuMain::clicked_ok() {
118 // do nothing
119 }
120
layout()121 void FullscreenMenuMain::layout() {
122 FullscreenMenuMainMenu::layout();
123
124 logo_icon_.set_pos(
125 Vector2i((get_w() - logo_icon_.get_w()) / 2, title_y_ + logo_icon_.get_h() / 4));
126
127 const int text_height = 0.5 * version.get_h() + padding_;
128 version.set_pos(Vector2i(get_w() - version.get_w(), get_h() - text_height));
129 copyright.set_pos(Vector2i(0, get_h() - 2 * text_height));
130 gpl.set_pos(Vector2i(0, get_h() - text_height));
131
132 playtutorial.set_desired_size(butw_, buth_);
133 singleplayer.set_desired_size(butw_, buth_);
134 multiplayer.set_desired_size(butw_, buth_);
135 replay.set_desired_size(butw_, buth_);
136 editor.set_desired_size(butw_, buth_);
137 options.set_desired_size(butw_, buth_);
138 about.set_desired_size(butw_, buth_);
139 exit.set_desired_size(butw_, buth_);
140
141 vbox_.set_pos(Vector2i(box_x_, box_y_));
142 vbox_.set_inner_spacing(padding_);
143 vbox_.set_size(butw_, get_h() - vbox_.get_y() - 5 * padding_);
144 }
145