Add a "Video Player" menu with basic impl; kill the music player widget.
This commit is contained in:
@@ -222,6 +222,7 @@
|
||||
<Compile Include="Traits\RepairableBuilding.cs" />
|
||||
<Compile Include="Traits\Activities\Drag.cs" />
|
||||
<Compile Include="Widgets\VqaPlayerWidget.cs" />
|
||||
<Compile Include="Widgets\Delegates\VideoPlayerDelegate.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenRA.Widgets.Delegates
|
||||
bg.GetWidget("BUTTON_PLAY").OnMouseUp = mi =>
|
||||
{
|
||||
var foo = Widget.RootWidget.GetWidget<VqaPlayerWidget>("VIDEOPLAYER");
|
||||
foo.Load("ally1.vqa");
|
||||
foo.Load("intro2.vqa");
|
||||
foo.Play();
|
||||
/*
|
||||
if (Sound.MusicStopped)
|
||||
|
||||
45
OpenRA.Game/Widgets/Delegates/VideoPlayerDelegate.cs
Normal file
45
OpenRA.Game/Widgets/Delegates/VideoPlayerDelegate.cs
Normal file
@@ -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<VqaPlayerWidget>("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;
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
@@ -87,42 +89,3 @@ Container@ROOT:
|
||||
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
|
||||
78
mods/cnc/chrome/videoplayer.yaml
Normal file
78
mods/cnc/chrome/videoplayer.yaml
Normal file
@@ -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
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
@@ -85,42 +93,3 @@ Background@PERF_BG:
|
||||
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
|
||||
78
mods/ra/chrome/videoplayer.yaml
Normal file
78
mods/ra/chrome/videoplayer.yaml
Normal file
@@ -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
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user