Add some Media functions to new Lua API
This commit is contained in:
@@ -8,14 +8,58 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using Eluant;
|
||||||
|
using OpenRA.Scripting;
|
||||||
|
|
||||||
namespace OpenRA.Scripting
|
namespace OpenRA.Scripting
|
||||||
{
|
{
|
||||||
[ScriptGlobal("Media")]
|
[ScriptGlobal("Media")]
|
||||||
public class MediaGlobal : ScriptGlobal
|
public class MediaGlobal : ScriptGlobal
|
||||||
{
|
{
|
||||||
public MediaGlobal(ScriptContext context) : base(context) { }
|
World world;
|
||||||
|
public MediaGlobal(ScriptContext context) : base(context)
|
||||||
|
{
|
||||||
|
world = context.World;
|
||||||
|
}
|
||||||
|
[Desc("Play an announcer voice listed in notifications.yaml")]
|
||||||
|
public void PlaySpeechNotification(Player player, string notification)
|
||||||
|
{
|
||||||
|
Sound.PlayNotification(world.Map.Rules, player, "Speech", notification, player != null ? player.Country.Race : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Desc("Play a sound listed in notifications.yaml")]
|
||||||
|
public void PlaySoundNotification(Player player, string notification)
|
||||||
|
{
|
||||||
|
Sound.PlayNotification(world.Map.Rules, player, "Sounds", notification, player != null ? player.Country.Race : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
Action onComplete;
|
||||||
|
[Desc("Play a VQA video including the file extension.")]
|
||||||
|
public void PlayMovieFullscreen(string movie, LuaFunction func = null)
|
||||||
|
{
|
||||||
|
if (func != null)
|
||||||
|
{
|
||||||
|
var f = func.CopyReference() as LuaFunction;
|
||||||
|
onComplete = () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (f)
|
||||||
|
f.Call();
|
||||||
|
}
|
||||||
|
catch (LuaException e)
|
||||||
|
{
|
||||||
|
context.FatalError(e.Message);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
onComplete = () => { };
|
||||||
|
|
||||||
|
Media.PlayFMVFullscreen(world, movie, onComplete);
|
||||||
|
}
|
||||||
|
|
||||||
[Desc("Display a text message to the player.")]
|
[Desc("Display a text message to the player.")]
|
||||||
public void DisplayMessage(string text, string prefix = "Mission") // TODO: expose HSLColor to Lua and add as parameter
|
public void DisplayMessage(string text, string prefix = "Mission") // TODO: expose HSLColor to Lua and add as parameter
|
||||||
|
|||||||
Reference in New Issue
Block a user