mirror of
https://github.com/vcmi/vcmi.git
synced 2025-06-23 00:28:08 +02:00
basic voice support
This commit is contained in:
@ -29,8 +29,7 @@ CPrologEpilogVideo::CPrologEpilogVideo(CampaignScenarioPrologEpilog _spe, std::f
|
|||||||
|
|
||||||
CCS->videoh->open(spe.prologVideo);
|
CCS->videoh->open(spe.prologVideo);
|
||||||
CCS->musich->playMusic(spe.prologMusic, true, true);
|
CCS->musich->playMusic(spe.prologMusic, true, true);
|
||||||
// MPTODO: Custom campaign crashing on this?
|
voiceSoundHandle = CCS->soundh->playSound(spe.prologVoice);
|
||||||
// voiceSoundHandle = CCS->soundh->playSound(CCampaignHandler::prologVoiceName(spe.prologVideo));
|
|
||||||
|
|
||||||
text = std::make_shared<CMultiLineLabel>(Rect(100, 500, 600, 100), EFonts::FONT_BIG, ETextAlignment::CENTER, Colors::METALLIC_GOLD, spe.prologText);
|
text = std::make_shared<CMultiLineLabel>(Rect(100, 500, 600, 100), EFonts::FONT_BIG, ETextAlignment::CENTER, Colors::METALLIC_GOLD, spe.prologText);
|
||||||
text->scrollTextTo(-100);
|
text->scrollTextTo(-100);
|
||||||
|
@ -168,6 +168,7 @@ CampaignScenario CampaignHandler::readScenarioFromJson(JsonNode & reader)
|
|||||||
{
|
{
|
||||||
ret.prologVideo = VideoPath::fromJson(identifier["video"]);
|
ret.prologVideo = VideoPath::fromJson(identifier["video"]);
|
||||||
ret.prologMusic = AudioPath::fromJson(identifier["music"]);
|
ret.prologMusic = AudioPath::fromJson(identifier["music"]);
|
||||||
|
ret.prologVoice = AudioPath::fromJson(identifier["voice"]);
|
||||||
ret.prologText = identifier["text"].String();
|
ret.prologText = identifier["text"].String();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -403,8 +404,10 @@ CampaignScenario CampaignHandler::readScenarioFromMemory( CBinaryReader & reader
|
|||||||
ret.hasPrologEpilog = reader.readUInt8();
|
ret.hasPrologEpilog = reader.readUInt8();
|
||||||
if(ret.hasPrologEpilog)
|
if(ret.hasPrologEpilog)
|
||||||
{
|
{
|
||||||
ret.prologVideo = CampaignHandler::prologVideoName(reader.readUInt8());
|
ui8 index = reader.readUInt8();
|
||||||
|
ret.prologVideo = CampaignHandler::prologVideoName(index);
|
||||||
ret.prologMusic = CampaignHandler::prologMusicName(reader.readUInt8());
|
ret.prologMusic = CampaignHandler::prologMusicName(reader.readUInt8());
|
||||||
|
ret.prologVoice = CampaignHandler::prologVoiceName(index);
|
||||||
ret.prologText = readLocalizedString(reader, header.filename, header.modName, header.encoding, identifier);
|
ret.prologText = readLocalizedString(reader, header.filename, header.modName, header.encoding, identifier);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -605,13 +608,13 @@ AudioPath CampaignHandler::prologMusicName(ui8 index)
|
|||||||
return AudioPath::builtinTODO(VLC->generaltexth->translate("core.cmpmusic." + std::to_string(static_cast<int>(index))));
|
return AudioPath::builtinTODO(VLC->generaltexth->translate("core.cmpmusic." + std::to_string(static_cast<int>(index))));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string CampaignHandler::prologVoiceName(ui8 index)
|
AudioPath CampaignHandler::prologVoiceName(ui8 index)
|
||||||
{
|
{
|
||||||
JsonNode config(JsonPath::builtin("CONFIG/campaignMedia"));
|
JsonNode config(JsonPath::builtin("CONFIG/campaignMedia"));
|
||||||
auto audio = config["voice"].Vector();
|
auto audio = config["voice"].Vector();
|
||||||
if(index < audio.size())
|
if(index < audio.size())
|
||||||
return audio[index].String();
|
return AudioPath::fromJson(audio[index]);
|
||||||
return "";
|
return AudioPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
VCMI_LIB_NAMESPACE_END
|
VCMI_LIB_NAMESPACE_END
|
||||||
|
@ -35,7 +35,7 @@ class DLL_LINKAGE CampaignHandler
|
|||||||
|
|
||||||
static VideoPath prologVideoName(ui8 index);
|
static VideoPath prologVideoName(ui8 index);
|
||||||
static AudioPath prologMusicName(ui8 index);
|
static AudioPath prologMusicName(ui8 index);
|
||||||
static std::string prologVoiceName(ui8 index);
|
static AudioPath prologVoiceName(ui8 index);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static std::unique_ptr<Campaign> getHeader( const std::string & name); //name - name of appropriate file
|
static std::unique_ptr<Campaign> getHeader( const std::string & name); //name - name of appropriate file
|
||||||
|
@ -16,8 +16,9 @@ VCMI_LIB_NAMESPACE_BEGIN
|
|||||||
struct DLL_LINKAGE CampaignScenarioPrologEpilog
|
struct DLL_LINKAGE CampaignScenarioPrologEpilog
|
||||||
{
|
{
|
||||||
bool hasPrologEpilog = false;
|
bool hasPrologEpilog = false;
|
||||||
VideoPath prologVideo; // from CmpMovie.txt
|
VideoPath prologVideo;
|
||||||
AudioPath prologMusic; // from CmpMusic.txt
|
AudioPath prologMusic; // from CmpMusic.txt
|
||||||
|
AudioPath prologVoice;
|
||||||
std::string prologText;
|
std::string prologText;
|
||||||
|
|
||||||
template <typename Handler> void serialize(Handler &h, const int formatVersion)
|
template <typename Handler> void serialize(Handler &h, const int formatVersion)
|
||||||
@ -25,6 +26,7 @@ struct DLL_LINKAGE CampaignScenarioPrologEpilog
|
|||||||
h & hasPrologEpilog;
|
h & hasPrologEpilog;
|
||||||
h & prologVideo;
|
h & prologVideo;
|
||||||
h & prologMusic;
|
h & prologMusic;
|
||||||
|
h & prologVoice;
|
||||||
h & prologText;
|
h & prologText;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user