diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 6efa3bbf6b..6b2628670a 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -222,6 +222,7 @@ + diff --git a/OpenRA.Game/Widgets/Delegates/MusicPlayerDelegate.cs b/OpenRA.Game/Widgets/Delegates/MusicPlayerDelegate.cs index 75b53738d6..86a5b388ea 100644 --- a/OpenRA.Game/Widgets/Delegates/MusicPlayerDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/MusicPlayerDelegate.cs @@ -20,7 +20,7 @@ namespace OpenRA.Widgets.Delegates bg.GetWidget("BUTTON_PLAY").OnMouseUp = mi => { var foo = Widget.RootWidget.GetWidget("VIDEOPLAYER"); - foo.Load("ally1.vqa"); + foo.Load("intro2.vqa"); foo.Play(); /* if (Sound.MusicStopped) diff --git a/OpenRA.Game/Widgets/Delegates/VideoPlayerDelegate.cs b/OpenRA.Game/Widgets/Delegates/VideoPlayerDelegate.cs new file mode 100644 index 0000000000..b2a0e18e7b --- /dev/null +++ b/OpenRA.Game/Widgets/Delegates/VideoPlayerDelegate.cs @@ -0,0 +1,45 @@ +#region Copyright & License Information +/* + * Copyright 2007-2010 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see LICENSE. + */ +#endregion + +namespace OpenRA.Widgets.Delegates +{ + public class VideoPlayerDelegate : IWidgetDelegate + { + public VideoPlayerDelegate() + { + var bg = Widget.RootWidget.GetWidget("VIDEOPLAYER_MENU"); + var player = bg.GetWidget("VIDEOPLAYER"); + bg.GetWidget("BUTTON_PLAY").OnMouseUp = mi => + { + player.Load("foo.vqa"); + player.Play(); + return true; + }; + + bg.GetWidget("BUTTON_STOP").OnMouseUp = mi => + { + player.Stop(); + return true; + }; + + bg.GetWidget("BUTTON_CLOSE").OnMouseUp = mi => { + player.Stop(); + Widget.RootWidget.CloseWindow(); + return true; + }; + + // Menu Buttons + Widget.RootWidget.GetWidget("MAINMENU_BUTTON_VIDEOPLAYER").OnMouseUp = mi => { + Widget.RootWidget.OpenWindow("VIDEOPLAYER_MENU"); + return true; + }; + } + } +} diff --git a/OpenRA.Game/Widgets/VqaPlayerWidget.cs b/OpenRA.Game/Widgets/VqaPlayerWidget.cs index 17c3aecb79..5bc810e4c0 100644 --- a/OpenRA.Game/Widgets/VqaPlayerWidget.cs +++ b/OpenRA.Game/Widgets/VqaPlayerWidget.cs @@ -18,11 +18,11 @@ namespace OpenRA.Widgets { public class VqaPlayerWidget : Widget { - float timestep; Sprite videoSprite; VqaReader video = null; string cachedVideo; float invLength; + float2 videoOrigin, videoSize; public void Load(string filename) { if (filename == cachedVideo) @@ -30,16 +30,19 @@ namespace OpenRA.Widgets cachedVideo = filename; video = new VqaReader(FileSystem.Open(filename)); - timestep = 1f/video.Framerate; invLength = video.Framerate*1f/video.Frames; - var size = OpenRA.Graphics.Util.NextPowerOf2(Math.Max(video.Width, video.Height)); - videoSprite = new Sprite(new Sheet(new Size(size,size)), new Rectangle( 0, 0, video.Width, video.Height ), TextureChannel.Alpha); + var size = Math.Max(video.Width, video.Height); + var textureSize = OpenRA.Graphics.Util.NextPowerOf2(size); + videoSprite = new Sprite(new Sheet(new Size(textureSize,textureSize)), new Rectangle( 0, 0, video.Width, video.Height ), TextureChannel.Alpha); + + var scale = Math.Min(RenderBounds.Width / video.Width, RenderBounds.Height / video.Height); + videoOrigin = new float2(RenderBounds.X + (RenderBounds.Width - scale*video.Width)/2, RenderBounds.Y + (RenderBounds.Height - scale*video.Height)/2); + videoSize = new float2(video.Width * scale, video.Height * scale); } bool playing = false; Stopwatch sw = new Stopwatch(); - bool first; public override void DrawInner(World world) { if (!playing) @@ -58,8 +61,7 @@ namespace OpenRA.Widgets if (nextFrame == video.CurrentFrame) videoSprite.sheet.Texture.SetData(video.FrameData); } - - Game.Renderer.RgbaSpriteRenderer.DrawSprite(videoSprite, new int2(RenderBounds.X,RenderBounds.Y), "chrome"); + Game.Renderer.RgbaSpriteRenderer.DrawSprite(videoSprite, videoOrigin, "chrome", videoSize); } public void Play() diff --git a/mods/cnc/chrome/mainmenu.yaml b/mods/cnc/chrome/mainmenu.yaml index b815632e8d..8dd8930a49 100644 --- a/mods/cnc/chrome/mainmenu.yaml +++ b/mods/cnc/chrome/mainmenu.yaml @@ -1,17 +1,11 @@ Container@ROOT: Children: - VqaPlayer: - Id:VIDEOPLAYER - X:WINDOW_RIGHT - 400 - Y:WINDOW_BOTTOM - 250 - Width:200 - Height:200 Background@MAINMENU_BG: Id:MAINMENU_BG X:(WINDOW_RIGHT - WIDTH)/2 Y:(WINDOW_BOTTOM - HEIGHT)/2 Width:250 - Height:250 + Height:290 Delegate:MainMenuButtonsDelegate Children: Label@MAINMENU_LABEL_TITLE: @@ -47,10 +41,18 @@ Container@ROOT: Height:25 Text:Settings Bold:True + Button@MAINMENU_BUTTON_VIDEOPLAYER: + Id:MAINMENU_BUTTON_VIDEOPLAYER + X:45 + Y:190 + Width:160 + Height:25 + Text:Video Player + Bold:True Button@MAINMENU_BUTTON_QUIT: Id:MAINMENU_BUTTON_QUIT X:45 - Y:190 + Y:230 Width:160 Height:25 Text:Quit @@ -86,43 +88,4 @@ Container@ROOT: X:20 Y:205 Width:170 - Height:40 - Background@MUSIC_BG: - Id:MUSIC_BG - Delegate:MusicPlayerDelegate - X:WINDOW_RIGHT - 175 - Y:WINDOW_BOTTOM - 95 - Width: 160 - Height: 55 - Visible: true - Children: - Button@BUTTON_PLAY: - Id:BUTTON_PLAY - X:50 - Y:15 - Width:25 - Height:25 - Children: - Image@IMAGE_PLAY: - Id:IMAGE_PLAY - X:0 - Y:0 - Width:25 - Height:25 - ImageCollection:music - ImageName:play - Button@BUTTON_STOP: - Id:BUTTON_STOP - X:85 - Y:15 - Width:25 - Height:25 - Children: - Image@IMAGE_STOP: - Id:IMAGE_STOP - X:0 - Y:0 - Width:25 - Height:25 - ImageCollection:music - ImageName:stop \ No newline at end of file + Height:40 \ No newline at end of file diff --git a/mods/cnc/chrome/videoplayer.yaml b/mods/cnc/chrome/videoplayer.yaml new file mode 100644 index 0000000000..39608e87b2 --- /dev/null +++ b/mods/cnc/chrome/videoplayer.yaml @@ -0,0 +1,78 @@ +Container@ROOT: + Children: + Background@VIDEOPLAYER_MENU: + Id:VIDEOPLAYER_MENU + Delegate:VideoPlayerDelegate + X:(WINDOW_RIGHT - WIDTH)/2 + Y:(WINDOW_BOTTOM- HEIGHT)/2 + Width: 700 + Height: 680 + Visible: false + Children: + Label@VIDEOPLAYER_TITLE: + X:0 + Y:20 + Align:Center + Width:PARENT_RIGHT + Height:20 + Text:Video Player + Bold:True + VqaPlayer: + Id:VIDEOPLAYER + X:30 + Y:50 + Width:640 + Height:400 + ListBox@VIDEO_LIST: + Id:VIDEO_LIST + X:20 + Y:460 + Width:480 + Height:200 + Children: + Label@VIDEO_TEMPLATE: + Id:VIDEO_TEMPLATE + Width:PARENT_RIGHT-28 + Height:25 + ClickThrough:false + X:2 + Y:0 + Visible:false + Button@BUTTON_PLAY: + Id:BUTTON_PLAY + X:590 - WIDTH + Y:460 + Width:25 + Height:25 + Children: + Image@IMAGE_PLAY: + Id:IMAGE_PLAY + X:0 + Y:0 + Width:25 + Height:25 + ImageCollection:music + ImageName:play + Button@BUTTON_STOP: + Id:BUTTON_STOP + X:610 + Y:460 + Width:25 + Height:25 + Children: + Image@IMAGE_STOP: + Id:IMAGE_STOP + X:0 + Y:0 + Width:25 + Height:25 + ImageCollection:music + ImageName:stop + Button@BUTTON_CLOSE: + Id:BUTTON_CLOSE + X:PARENT_RIGHT - 180 + Y:PARENT_BOTTOM - 45 + Width:160 + Height:25 + Text:Close + Bold:True \ No newline at end of file diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index 226f45882c..c33eb2d805 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -42,6 +42,7 @@ Assemblies: ChromeLayout: mods/cnc/chrome/ingame.yaml: mods/cnc/chrome/mainmenu.yaml: + mods/cnc/chrome/videoplayer.yaml: mods/cnc/chrome/settings.yaml: mods/cnc/chrome/gamelobby.yaml: mods/cnc/chrome/serverbrowser.yaml: diff --git a/mods/ra/chrome/mainmenu.yaml b/mods/ra/chrome/mainmenu.yaml index 0cf1309ac0..e4003288a1 100644 --- a/mods/ra/chrome/mainmenu.yaml +++ b/mods/ra/chrome/mainmenu.yaml @@ -9,7 +9,7 @@ Background@MAINMENU_BG: X:(WINDOW_RIGHT - WIDTH)/2 Y:(WINDOW_BOTTOM - HEIGHT)/2 Width:250 - Height:250 + Height:290 Delegate:MainMenuButtonsDelegate Children: Label@MAINMENU_LABEL_TITLE: @@ -45,10 +45,18 @@ Background@MAINMENU_BG: Height:25 Text:Settings Bold:True + Button@MAINMENU_BUTTON_VIDEOPLAYER: + Id:MAINMENU_BUTTON_VIDEOPLAYER + X:45 + Y:190 + Width:160 + Height:25 + Text:Video Player + Bold:True Button@MAINMENU_BUTTON_QUIT: Id:MAINMENU_BUTTON_QUIT X:45 - Y:190 + Y:230 Width:160 Height:25 Text:Quit @@ -84,43 +92,4 @@ Background@PERF_BG: X:20 Y:205 Width:170 - Height:40 -Background@MUSIC_BG: - Id:MUSIC_BG - Delegate:MusicPlayerDelegate - X:WINDOW_RIGHT - 175 - Y:WINDOW_BOTTOM - 95 - Width: 160 - Height: 55 - Visible: true - Children: - Button@BUTTON_PLAY: - Id:BUTTON_PLAY - X:50 - Y:15 - Width:25 - Height:25 - Children: - Image@IMAGE_PLAY: - Id:IMAGE_PLAY - X:0 - Y:0 - Width:25 - Height:25 - ImageCollection:music - ImageName:play - Button@BUTTON_STOP: - Id:BUTTON_STOP - X:85 - Y:15 - Width:25 - Height:25 - Children: - Image@IMAGE_STOP: - Id:IMAGE_STOP - X:0 - Y:0 - Width:25 - Height:25 - ImageCollection:music - ImageName:stop \ No newline at end of file + Height:40 \ No newline at end of file diff --git a/mods/ra/chrome/videoplayer.yaml b/mods/ra/chrome/videoplayer.yaml new file mode 100644 index 0000000000..39608e87b2 --- /dev/null +++ b/mods/ra/chrome/videoplayer.yaml @@ -0,0 +1,78 @@ +Container@ROOT: + Children: + Background@VIDEOPLAYER_MENU: + Id:VIDEOPLAYER_MENU + Delegate:VideoPlayerDelegate + X:(WINDOW_RIGHT - WIDTH)/2 + Y:(WINDOW_BOTTOM- HEIGHT)/2 + Width: 700 + Height: 680 + Visible: false + Children: + Label@VIDEOPLAYER_TITLE: + X:0 + Y:20 + Align:Center + Width:PARENT_RIGHT + Height:20 + Text:Video Player + Bold:True + VqaPlayer: + Id:VIDEOPLAYER + X:30 + Y:50 + Width:640 + Height:400 + ListBox@VIDEO_LIST: + Id:VIDEO_LIST + X:20 + Y:460 + Width:480 + Height:200 + Children: + Label@VIDEO_TEMPLATE: + Id:VIDEO_TEMPLATE + Width:PARENT_RIGHT-28 + Height:25 + ClickThrough:false + X:2 + Y:0 + Visible:false + Button@BUTTON_PLAY: + Id:BUTTON_PLAY + X:590 - WIDTH + Y:460 + Width:25 + Height:25 + Children: + Image@IMAGE_PLAY: + Id:IMAGE_PLAY + X:0 + Y:0 + Width:25 + Height:25 + ImageCollection:music + ImageName:play + Button@BUTTON_STOP: + Id:BUTTON_STOP + X:610 + Y:460 + Width:25 + Height:25 + Children: + Image@IMAGE_STOP: + Id:IMAGE_STOP + X:0 + Y:0 + Width:25 + Height:25 + ImageCollection:music + ImageName:stop + Button@BUTTON_CLOSE: + Id:BUTTON_CLOSE + X:PARENT_RIGHT - 180 + Y:PARENT_BOTTOM - 45 + Width:160 + Height:25 + Text:Close + Bold:True \ No newline at end of file diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index 6bcc130bde..22a3b3a27b 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -42,6 +42,7 @@ Assemblies: ChromeLayout: mods/ra/chrome/ingame.yaml: mods/ra/chrome/mainmenu.yaml: + mods/ra/chrome/videoplayer.yaml: mods/ra/chrome/settings.yaml: mods/ra/chrome/gamelobby.yaml: mods/ra/chrome/serverbrowser.yaml: