1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

Prefer high-quality bik's to smk's

This commit is contained in:
Ivan Savenko 2024-05-03 20:08:29 +03:00
parent 661a66121b
commit 7ad64207ed
4 changed files with 21 additions and 9 deletions

View File

@ -61,14 +61,27 @@ static si64 lodSeek(void * opaque, si64 pos, int whence)
throw std::runtime_error(errorMessage.data());
}
void CVideoInstance::open(const VideoPath & videoToOpen)
static std::unique_ptr<CInputStream> findVideoData(const VideoPath & videoToOpen)
{
if(CResourceHandler::get()->existsResource(videoToOpen))
state.actualPath = videoToOpen;
else
state.actualPath = videoToOpen.addPrefix("VIDEO/");
return CResourceHandler::get()->load(videoToOpen);
state.videoData = CResourceHandler::get()->load(state.actualPath);
auto highQualityVideoToOpenWithDir = videoToOpen.addPrefix("VIDEO/");
auto lowQualityVideo = videoToOpen.toType<EResType::VIDEO_LOW_QUALITY>();
auto lowQualityVideoWithDir = highQualityVideoToOpenWithDir.toType<EResType::VIDEO_LOW_QUALITY>();
if(CResourceHandler::get()->existsResource(highQualityVideoToOpenWithDir))
return CResourceHandler::get()->load(highQualityVideoToOpenWithDir);
if(CResourceHandler::get()->existsResource(lowQualityVideo))
return CResourceHandler::get()->load(lowQualityVideo);
return CResourceHandler::get()->load(lowQualityVideoWithDir);
}
void CVideoInstance::open(const VideoPath & videoToOpen)
{
state.videoData = findVideoData(videoToOpen);
static const int BUFFER_SIZE = 4096;

View File

@ -113,11 +113,8 @@ EResType EResTypeHelper::getTypeFromExtension(std::string extension)
{".MP3", EResType::SOUND},
{".OGG", EResType::SOUND},
{".FLAC", EResType::SOUND},
{".SMK", EResType::VIDEO},
{".SMK", EResType::VIDEO_LOW_QUALITY},
{".BIK", EResType::VIDEO},
{".MJPG", EResType::VIDEO},
{".MPG", EResType::VIDEO},
{".AVI", EResType::VIDEO},
{".WEBM", EResType::VIDEO},
{".ZIP", EResType::ARCHIVE_ZIP},
{".LOD", EResType::ARCHIVE_LOD},

View File

@ -46,6 +46,7 @@ enum class EResType
TTF_FONT,
IMAGE,
VIDEO,
VIDEO_LOW_QUALITY,
SOUND,
ARCHIVE_VID,
ARCHIVE_ZIP,

View File

@ -493,6 +493,7 @@ static std::string imageFile(const JsonNode & node)
static std::string videoFile(const JsonNode & node)
{
TEST_FILE(node.getModScope(), "Video/", node.String(), EResType::VIDEO);
TEST_FILE(node.getModScope(), "Video/", node.String(), EResType::VIDEO_LOW_QUALITY);
return "Video file \"" + node.String() + "\" was not found";
}
#undef TEST_FILE