MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / VideoScreen

Method VideoScreen

game/ui/general/videoscreen.cpp:19–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17{
18
19VideoScreen::VideoScreen(const UString &videoPath, sp<Stage> nextScreen)
20 : Stage(), nextScreen(nextScreen)
21{
22 if (videoPath != "")
23 {
24 this->video = fw().data->loadVideo(videoPath);
25 if (!this->video)
26 {
27 LogWarning("Failed to load video \"%s\"", videoPath);
28 }
29 else
30 {
31 // Scale keeping aspect ratio to the max of the screen size
32 Vec2<float> unscaled_frame_size = this->video->getVideoSize();
33 Vec2<float> display_size = fw().displayGetSize();
34 Vec2<float> scale_factors = display_size / unscaled_frame_size;
35 float scale = std::min(scale_factors.x, scale_factors.y);
36 this->frame_size = unscaled_frame_size * scale;
37 LogInfo("Scaling video from %s to %s", this->video->getVideoSize(), this->frame_size);
38 this->frame_position = (fw().displayGetSize() / 2) - (this->frame_size / 2);
39 }
40 }
41 else
42 {
43 LogInfo("No video");
44 }
45}
46
47void VideoScreen::begin()
48{

Callers

nothing calls this directly

Calls 3

loadVideoMethod · 0.80
getVideoSizeMethod · 0.80
displayGetSizeMethod · 0.80

Tested by

no test coverage detected