mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 14:16:07 +08:00
Implement llGetPrimMediaParams()
Exposes method to get media entry via IMoapModule As yet untested.
This commit is contained in:
@@ -7808,6 +7808,110 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
return res;
|
||||
}
|
||||
|
||||
public LSL_List llGetPrimMediaParams(int face, LSL_List rules)
|
||||
{
|
||||
m_host.AddScriptLPS(1);
|
||||
ScriptSleep(1000);
|
||||
|
||||
// LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid
|
||||
// TODO: Need to correctly handle case where a face has no media (which gives back an empty list).
|
||||
// Assuming silently fail means give back an empty list. Ideally, need to check this.
|
||||
if (face < 0 || face > m_host.Shape.Media.Count - 1)
|
||||
return new LSL_List();
|
||||
|
||||
return GetLinkPrimMediaParams(face, rules);
|
||||
}
|
||||
|
||||
public LSL_List GetLinkPrimMediaParams(int face, LSL_List rules)
|
||||
{
|
||||
IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>();
|
||||
if (null == module)
|
||||
throw new Exception("Media on a prim functions not available");
|
||||
|
||||
MediaEntry me = module.GetMediaEntry(m_host, face);
|
||||
|
||||
LSL_List res = new LSL_List();
|
||||
|
||||
for (int i = 0; i < rules.Length; i++)
|
||||
{
|
||||
int code = (int)rules.GetLSLIntegerItem(i);
|
||||
|
||||
switch (code)
|
||||
{
|
||||
case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE:
|
||||
// Not implemented
|
||||
res.Add(new LSL_Integer(0));
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_CONTROLS:
|
||||
if (me.Controls == MediaControls.Standard)
|
||||
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD));
|
||||
else
|
||||
res.Add(new LSL_Integer(ScriptBaseClass.PRIM_MEDIA_CONTROLS_MINI));
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL:
|
||||
res.Add(new LSL_String(me.CurrentURL));
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_HOME_URL:
|
||||
res.Add(new LSL_String(me.HomeURL));
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP:
|
||||
res.Add(me.AutoLoop ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY:
|
||||
res.Add(me.AutoPlay ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE:
|
||||
res.Add(me.AutoScale ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM:
|
||||
res.Add(me.AutoZoom ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT:
|
||||
res.Add(me.InteractOnFirstClick ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS:
|
||||
res.Add(new LSL_Integer(me.Width));
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS:
|
||||
res.Add(new LSL_Integer(me.Height));
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE:
|
||||
res.Add(me.EnableWhiteList ? ScriptBaseClass.TRUE : ScriptBaseClass.FALSE);
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_WHITELIST:
|
||||
string[] urls = (string[])me.WhiteList.Clone();
|
||||
|
||||
for (int j = 0; j < urls.Length; j++)
|
||||
urls[j] = Uri.EscapeDataString(urls[j]);
|
||||
|
||||
res.Add(new LSL_String(string.Join(", ", urls)));
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT:
|
||||
res.Add(new LSL_Integer((int)me.InteractPermissions));
|
||||
break;
|
||||
|
||||
case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL:
|
||||
res.Add(new LSL_Integer((int)me.ControlPermissions));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
// <remarks>
|
||||
// <para>
|
||||
// The .NET definition of base 64 is:
|
||||
|
||||
@@ -517,6 +517,31 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
public const int TOUCH_INVALID_FACE = -1;
|
||||
public static readonly vector TOUCH_INVALID_TEXCOORD = new vector(-1.0, -1.0, 0.0);
|
||||
public static readonly vector TOUCH_INVALID_VECTOR = ZERO_VECTOR;
|
||||
|
||||
// constants for llGetPrimMediaParams
|
||||
public const int PRIM_MEDIA_ALT_IMAGE_ENABLE = 0;
|
||||
public const int PRIM_MEDIA_CONTROLS = 1;
|
||||
public const int PRIM_MEDIA_CURRENT_URL = 2;
|
||||
public const int PRIM_MEDIA_HOME_URL = 3;
|
||||
public const int PRIM_MEDIA_AUTO_LOOP = 4;
|
||||
public const int PRIM_MEDIA_AUTO_PLAY = 5;
|
||||
public const int PRIM_MEDIA_AUTO_SCALE = 6;
|
||||
public const int PRIM_MEDIA_AUTO_ZOOM = 7;
|
||||
public const int PRIM_MEDIA_FIRST_CLICK_INTERACT = 8;
|
||||
public const int PRIM_MEDIA_WIDTH_PIXELS = 9;
|
||||
public const int PRIM_MEDIA_HEIGHT_PIXELS = 10;
|
||||
public const int PRIM_MEDIA_WHITELIST_ENABLE = 11;
|
||||
public const int PRIM_MEDIA_WHITELIST = 12;
|
||||
public const int PRIM_MEDIA_PERMS_INTERACT = 13;
|
||||
public const int PRIM_MEDIA_PERMS_CONTROL = 14;
|
||||
|
||||
public const int PRIM_MEDIA_CONTROLS_STANDARD = 0;
|
||||
public const int PRIM_MEDIA_CONTROLS_MINI = 1;
|
||||
|
||||
public const int PRIM_MEDIA_PERM_NONE = 0;
|
||||
public const int PRIM_MEDIA_PERM_OWNER = 1;
|
||||
public const int PRIM_MEDIA_PERM_GROUP = 2;
|
||||
public const int PRIM_MEDIA_PERM_ANYONE = 4;
|
||||
|
||||
// Constants for default textures
|
||||
public const string TEXTURE_BLANK = "5748decc-f629-461c-9a36-a35a221fe21f";
|
||||
|
||||
Reference in New Issue
Block a user