-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use a separate scene for the inn logic. This refactors the Scene::MainFunction() to support resuming async callbacks between scene changes. The correct execution sequence is like this: 1. Scene_Map::Update(): Push(Inn), set async_continuation 2. Scene_Inn::Scene_Inn(): Remembers music 3. Scene_Map::Suspend(): 4. Scene_Map::TransitionOut(): FadeOut 5. Scene_Inn::Start(): Heal, start inn music 6. Scene_Inn::Update(): wait inn music 7. Scene_Inn::Suspend(): Play prev music 8. Scene_Map::Continue(): 9. Scene_Map::TransitionIn(): Fade In 10. Scene_Map::async_continuation(): Resume game loop after inn 11. Scene_Map::Update()
- Loading branch information
Showing
8 changed files
with
192 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* This file is part of EasyRPG Player. | ||
* | ||
* EasyRPG Player is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* EasyRPG Player is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
// Headers | ||
#include "scene_inn.h" | ||
#include "game_system.h" | ||
#include "transition.h" | ||
#include "audio.h" | ||
#include "main_data.h" | ||
#include "game_party.h" | ||
|
||
Scene_Inn::Scene_Inn() { | ||
Scene::type = Scene::Inn; | ||
music_before_inn = Game_System::GetCurrentBGM(); | ||
Game_System::BgmFade(800); | ||
} | ||
|
||
void Scene_Inn::Start() { | ||
// Full heal | ||
std::vector<Game_Actor*> actors = Main_Data::game_party->GetActors(); | ||
for (Game_Actor* actor : actors) { | ||
actor->FullHeal(); | ||
} | ||
|
||
const RPG::Music& bgm_inn = Game_System::GetSystemBGM(Game_System::BGM_Inn); | ||
if (Game_System::IsStopMusicFilename(bgm_inn.name)) { | ||
Game_System::BgmStop(); | ||
} else { | ||
Game_System::BgmPlay(bgm_inn); | ||
} | ||
} | ||
|
||
void Scene_Inn::Update() { | ||
if (!Audio().BGM_IsPlaying() || Audio().BGM_PlayedOnce()) { | ||
Game_System::BgmStop(); | ||
Scene::Pop(); | ||
} | ||
} | ||
|
||
void Scene_Inn::Suspend() { | ||
Game_System::BgmPlay(music_before_inn); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* This file is part of EasyRPG Player. | ||
* | ||
* EasyRPG Player is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* EasyRPG Player is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#ifndef EP_SCENE_INN_H | ||
#define EP_SCENE_INN_H | ||
|
||
// Headers | ||
#include "scene.h" | ||
#include "rpg_music.h" | ||
|
||
/** | ||
* Scene_Inn class. | ||
*/ | ||
class Scene_Inn : public Scene { | ||
|
||
public: | ||
Scene_Inn(); | ||
|
||
void Start() override; | ||
void Update() override; | ||
void Suspend() override; | ||
|
||
void TransitionIn(Scene::SceneType) override {} | ||
void TransitionOut(Scene::SceneType) override {} | ||
|
||
private: | ||
RPG::Music music_before_inn = {}; | ||
AsyncContinuation inn_continuation = {}; | ||
}; | ||
|
||
#endif |
Oops, something went wrong.