1
0
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:
Laserlicht
2023-09-11 12:57:10 +02:00
committed by GitHub
parent 0d7f3e61c2
commit fc1ce85a72
4 changed files with 12 additions and 8 deletions

View File

@ -29,8 +29,7 @@ CPrologEpilogVideo::CPrologEpilogVideo(CampaignScenarioPrologEpilog _spe, std::f
CCS->videoh->open(spe.prologVideo);
CCS->musich->playMusic(spe.prologMusic, true, true);
// MPTODO: Custom campaign crashing on this?
// voiceSoundHandle = CCS->soundh->playSound(CCampaignHandler::prologVoiceName(spe.prologVideo));
voiceSoundHandle = CCS->soundh->playSound(spe.prologVoice);
text = std::make_shared<CMultiLineLabel>(Rect(100, 500, 600, 100), EFonts::FONT_BIG, ETextAlignment::CENTER, Colors::METALLIC_GOLD, spe.prologText);
text->scrollTextTo(-100);

View File

@ -168,6 +168,7 @@ CampaignScenario CampaignHandler::readScenarioFromJson(JsonNode & reader)
{
ret.prologVideo = VideoPath::fromJson(identifier["video"]);
ret.prologMusic = AudioPath::fromJson(identifier["music"]);
ret.prologVoice = AudioPath::fromJson(identifier["voice"]);
ret.prologText = identifier["text"].String();
}
return ret;
@ -403,8 +404,10 @@ CampaignScenario CampaignHandler::readScenarioFromMemory( CBinaryReader & reader
ret.hasPrologEpilog = reader.readUInt8();
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.prologVoice = CampaignHandler::prologVoiceName(index);
ret.prologText = readLocalizedString(reader, header.filename, header.modName, header.encoding, identifier);
}
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))));
}
std::string CampaignHandler::prologVoiceName(ui8 index)
AudioPath CampaignHandler::prologVoiceName(ui8 index)
{
JsonNode config(JsonPath::builtin("CONFIG/campaignMedia"));
auto audio = config["voice"].Vector();
if(index < audio.size())
return audio[index].String();
return "";
return AudioPath::fromJson(audio[index]);
return AudioPath();
}
VCMI_LIB_NAMESPACE_END

View File

@ -35,7 +35,7 @@ class DLL_LINKAGE CampaignHandler
static VideoPath prologVideoName(ui8 index);
static AudioPath prologMusicName(ui8 index);
static std::string prologVoiceName(ui8 index);
static AudioPath prologVoiceName(ui8 index);
public:
static std::unique_ptr<Campaign> getHeader( const std::string & name); //name - name of appropriate file

View File

@ -16,8 +16,9 @@ VCMI_LIB_NAMESPACE_BEGIN
struct DLL_LINKAGE CampaignScenarioPrologEpilog
{
bool hasPrologEpilog = false;
VideoPath prologVideo; // from CmpMovie.txt
VideoPath prologVideo;
AudioPath prologMusic; // from CmpMusic.txt
AudioPath prologVoice;
std::string prologText;
template <typename Handler> void serialize(Handler &h, const int formatVersion)
@ -25,6 +26,7 @@ struct DLL_LINKAGE CampaignScenarioPrologEpilog
h & hasPrologEpilog;
h & prologVideo;
h & prologMusic;
h & prologVoice;
h & prologText;
}
};