瀏覽代碼

prescale support for video

Laserlicht 10 月之前
父節點
當前提交
543185a530
共有 2 個文件被更改,包括 25 次插入4 次删除
  1. 21 1
      client/widgets/VideoWidget.cpp
  2. 4 3
      docs/modders/HD_Graphics.md

+ 21 - 1
client/widgets/VideoWidget.cpp

@@ -16,6 +16,7 @@
 #include "../media/ISoundPlayer.h"
 #include "../media/ISoundPlayer.h"
 #include "../media/IVideoPlayer.h"
 #include "../media/IVideoPlayer.h"
 #include "../render/Canvas.h"
 #include "../render/Canvas.h"
+#include "../render/IScreenHandler.h"
 
 
 #include "../../lib/filesystem/Filesystem.h"
 #include "../../lib/filesystem/Filesystem.h"
 
 
@@ -45,7 +46,26 @@ void VideoWidgetBase::playVideo(const VideoPath & fileToPlay)
 	else if(CResourceHandler::get()->existsResource(subTitlePathVideoDir))
 	else if(CResourceHandler::get()->existsResource(subTitlePathVideoDir))
 		subTitleData = JsonNode(subTitlePathVideoDir);
 		subTitleData = JsonNode(subTitlePathVideoDir);
 
 
-	videoInstance = CCS->videoh->open(fileToPlay, scaleFactor);
+	float preScaleFactor = 1;
+	VideoPath videoFile = fileToPlay;
+	if(GH.screenHandler().getScalingFactor() > 1)
+	{
+		std::vector<int> factorsToCheck = {GH.screenHandler().getScalingFactor(), 4, 3, 2};
+		for(auto factorToCheck : factorsToCheck)
+		{
+			std::string name = boost::algorithm::to_upper_copy(videoFile.getName());
+			boost::replace_all(name, "VIDEO/", std::string("VIDEO") + std::to_string(factorToCheck) + std::string("X/"));
+			auto p = VideoPath::builtin(name).addPrefix("VIDEO" + std::to_string(factorToCheck) + "X/");
+			if(CResourceHandler::get()->existsResource(p))
+			{
+				preScaleFactor = 1.0 / static_cast<float>(factorToCheck);
+				videoFile = p;
+				break;
+			}
+		}
+	}
+
+	videoInstance = CCS->videoh->open(videoFile, scaleFactor * preScaleFactor);
 	if (videoInstance)
 	if (videoInstance)
 	{
 	{
 		pos.w = videoInstance->size().x;
 		pos.w = videoInstance->size().x;

+ 4 - 3
docs/modders/HD_Graphics.md

@@ -12,11 +12,12 @@ If user for example selects 3x resolution and only 2x exists in mod then the 2x
 
 
 ## Mod
 ## Mod
 
 
-For upscaled images you have to use following folders (next to `sprites` and `data` folders):
+For upscaled images you have to use following folders (next to `sprites`, `data` and `video` folders):
 - `sprites2x`, `sprites3x`, `sprites4x` for sprites
 - `sprites2x`, `sprites3x`, `sprites4x` for sprites
 - `data2x`, `data3x`, `data4x` for images
 - `data2x`, `data3x`, `data4x` for images
+- `video2x`, `video3x`, `video4x` for videos
 
 
-The sprites should have the same name and folder structure as in `sprites` and `data` folder. All images that are missing in the upscaled folders are scaled with the selected upscaling filter instead of using prescaled images.
+The sprites should have the same name and folder structure as in `sprites`, `data` and `video` folder. All images that are missing in the upscaled folders are scaled with the selected upscaling filter instead of using prescaled images.
 
 
 ### Shadows / Overlays
 ### Shadows / Overlays
 
 
@@ -31,4 +32,4 @@ Same for overlays with `-overlay`. But overlays are **necessary** for some anima
 
 
 Currently needed for:
 Currently needed for:
 - Flaggable adventure map objects. Overlay must contain a transparent image with white flags on it and will be used to colorize flags to owning player
 - Flaggable adventure map objects. Overlay must contain a transparent image with white flags on it and will be used to colorize flags to owning player
-- Creature battle animations, idle and mouse hover group. Overlay must contain a transparent image with white outline of creature for highlighting on mouse hover)
+- Creature battle animations, idle and mouse hover group. Overlay must contain a transparent image with white outline of creature for highlighting on mouse hover