1 /*
2 * This file is part of EasyRPG Player.
3 *
4 * EasyRPG Player is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * EasyRPG Player 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 EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 // Headers
19 #include <vector>
20 #include "audio.h"
21 #include "baseui.h"
22 #include "cache.h"
23 #include "game_system.h"
24 #include "input.h"
25 #include "scene_end.h"
26 #include "scene_menu.h"
27 #include "scene_title.h"
28 #include "util_macro.h"
29 #include "bitmap.h"
30
Scene_End()31 Scene_End::Scene_End() {
32 Scene::type = Scene::End;
33 }
34
Start()35 void Scene_End::Start() {
36 CreateCommandWindow();
37 CreateHelpWindow();
38 }
39
Update()40 void Scene_End::Update() {
41 command_window->Update();
42
43 if (Input::IsTriggered(Input::CANCEL)) {
44 Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Cancel));
45 Scene::Pop(); // Select End Game
46 } else if (Input::IsTriggered(Input::DECISION)) {
47 Main_Data::game_system->SePlay(Main_Data::game_system->GetSystemSE(Main_Data::game_system->SFX_Decision));
48 switch (command_window->GetIndex()) {
49 case 0: // Yes
50 Main_Data::game_system->BgmFade(400);
51 Scene::ReturnToTitleScene();
52 break;
53 case 1: // No
54 Scene::Pop();
55 break;
56 }
57 }
58 }
59
CreateCommandWindow()60 void Scene_End::CreateCommandWindow() {
61 // Create Options Window
62 std::vector<std::string> options;
63 options.push_back(ToString(lcf::Data::terms.yes));
64 options.push_back(ToString(lcf::Data::terms.no));
65
66 command_window.reset(new Window_Command(options));
67 command_window->SetX((SCREEN_TARGET_WIDTH/2) - command_window->GetWidth() / 2);
68 command_window->SetY(72 + 48);
69 command_window->SetIndex(1);
70 }
71
CreateHelpWindow()72 void Scene_End::CreateHelpWindow() {
73 int text_size = Font::Default()->GetSize(lcf::Data::terms.exit_game_message).width;
74
75 help_window.reset(new Window_Help((SCREEN_TARGET_WIDTH/2) - (text_size + 16)/ 2,
76 72, text_size + 16, 32));
77 help_window->SetText(ToString(lcf::Data::terms.exit_game_message), Font::ColorDefault, Text::AlignLeft, false);
78
79 command_window->SetHelpWindow(help_window.get());
80 }
81