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 "scene_gameover.h"
20 #include "bitmap.h"
21 #include "cache.h"
22 #include "game_system.h"
23 #include "input.h"
24 #include "main_data.h"
25 #include "transition.h"
26 
Scene_Gameover()27 Scene_Gameover::Scene_Gameover() {
28 	type = Scene::Gameover;
29 }
30 
Start()31 void Scene_Gameover::Start() {
32 	if (!lcf::Data::system.gameover_name.empty()) {
33 		FileRequestAsync* request = AsyncHandler::RequestFile("GameOver", lcf::Data::system.gameover_name);
34 		request->SetGraphicFile(true);
35 		request_id = request->Bind(&Scene_Gameover::OnBackgroundReady, this);
36 		request->Start();
37 	}
38 	// Play gameover music
39 	Main_Data::game_system->BgmPlay(Main_Data::game_system->GetSystemBGM(Main_Data::game_system->BGM_GameOver));
40 }
41 
Update()42 void Scene_Gameover::Update() {
43 	if (Input::IsTriggered(Input::DECISION)) {
44 		Scene::ReturnToTitleScene();
45 	}
46 }
47 
OnBackgroundReady(FileRequestResult * result)48 void Scene_Gameover::OnBackgroundReady(FileRequestResult* result) {
49 	// Load Background Graphic
50 	background.reset(new Sprite());
51 	background->SetBitmap(Cache::Gameover(result->file));
52 }
53 
TransitionIn(SceneType)54 void Scene_Gameover::TransitionIn(SceneType /* prev_scene */) {
55 	Transition::instance().InitShow(Transition::TransitionFadeIn, this, 80);
56 }
57 
TransitionOut(SceneType)58 void Scene_Gameover::TransitionOut(SceneType /* next_scene */) {
59 	Transition::instance().InitErase(Transition::TransitionFadeOut, this, 80);
60 }
61