Skip to content

Commit 0eedd78

Browse files
committed
support pre-mission cutscenes
1 parent 7cc8fc9 commit 0eedd78

4 files changed

Lines changed: 28 additions & 3 deletions

File tree

‎src/Battlescape/BriefingState.cpp‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#include <sstream>
4141
#include "../Engine/Options.h"
4242
#include "../Engine/Screen.h"
43+
#include "../Menu/CutsceneState.h"
4344

4445
namespace OpenXcom
4546
{
@@ -76,19 +77,21 @@ BriefingState::BriefingState(Craft *craft, Base *base)
7677
if (!deployment) // none defined - should never happen, but better safe than sorry i guess.
7778
{
7879
setPalette("PAL_GEOSCAPE", 0);
79-
_game->getResourcePack()->playMusic("GMDEFEND");
80+
_musicId = "GMDEFEND";
8081
_window->setBackground(_game->getResourcePack()->getSurface("BACK16.SCR"));
8182
}
8283
else
8384
{
8485
BriefingData data = deployment->getBriefingData();
8586
setPalette("PAL_GEOSCAPE", data.palette);
86-
_game->getResourcePack()->playMusic(data.music);
8787
_window->setBackground(_game->getResourcePack()->getSurface(data.background));
8888
_txtCraft->setY(56 + data.textOffset);
8989
_txtBriefing->setY(72 + data.textOffset);
9090
_txtTarget->setVisible(data.showTarget);
9191
_txtCraft->setVisible(data.showCraft);
92+
93+
_cutsceneId = data.cutscene;
94+
_musicId = data.music;
9295
}
9396

9497
add(_window, "window", "briefing");
@@ -156,6 +159,23 @@ BriefingState::~BriefingState()
156159

157160
}
158161

162+
void BriefingState::init()
163+
{
164+
State::init();
165+
166+
if (!_cutsceneId.empty())
167+
{
168+
_game->pushState(new CutsceneState(_cutsceneId));
169+
170+
// don't play the cutscene again when we return to this state
171+
_cutsceneId = "";
172+
}
173+
else
174+
{
175+
_game->getResourcePack()->playMusic(_musicId);
176+
}
177+
}
178+
159179
/**
160180
* Closes the window.
161181
* @param action Pointer to an action.

‎src/Battlescape/BriefingState.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ class BriefingState : public State
4040
TextButton *_btnOk;
4141
Window *_window;
4242
Text *_txtTitle, *_txtTarget, *_txtCraft, *_txtBriefing;
43+
std::string _cutsceneId, _musicId;
4344
public:
4445
/// Creates the Briefing state.
4546
BriefingState(Craft *craft = 0, Base *base = 0);
4647
/// Cleans up the Briefing state.
4748
~BriefingState();
49+
/// Initialization
50+
void init();
4851
/// Handler for clicking the Ok button.
4952
void btnOkClick(Action *action);
5053
};

‎src/Ruleset/AlienDeployment.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ namespace YAML
8080
node["palette"] = rhs.palette;
8181
node["textOffset"] = rhs.textOffset;
8282
node["music"] = rhs.music;
83+
node["cutscene"] = rhs.cutscene;
8384
node["background"] = rhs.background;
8485
node["showCraft"] = rhs.showCraft;
8586
node["showTarget"] = rhs.showTarget;
@@ -92,6 +93,7 @@ namespace YAML
9293
rhs.palette = node["palette"].as<int>(rhs.palette);
9394
rhs.textOffset = node["textOffset"].as<int>(rhs.textOffset);
9495
rhs.music = node["music"].as<std::string>(rhs.music);
96+
rhs.cutscene = node["cutscene"].as<std::string>(rhs.cutscene);
9597
rhs.background = node["background"].as<std::string>(rhs.background);
9698
rhs.showCraft = node["showCraft"].as<bool>(rhs.showCraft);
9799
rhs.showTarget = node["showTarget"].as<bool>(rhs.showTarget);

‎src/Ruleset/AlienDeployment.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ struct DeploymentData
4444
struct BriefingData
4545
{
4646
int palette, textOffset;
47-
std::string music, background;
47+
std::string music, background, cutscene;
4848
bool showCraft, showTarget;
4949
BriefingData() : palette(0), textOffset(0), music("GMDEFEND"), background("BACK16.SCR"), showCraft(true), showTarget(true) { /*Empty by Design*/ };
5050
};

0 commit comments

Comments
 (0)