diff options
author | Justin Clark-Casey (justincc) | 2010-07-12 19:46:23 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2010-07-12 19:46:23 +0100 |
commit | 4a92046b589a0ced240cbf5b174855daf5504a4f (patch) | |
tree | 6e2e993c495f02c5d93e5298d0dbea34ce1ddc31 /OpenSim/Region/ScriptEngine/Shared | |
parent | Implement llGetPrimMediaParams() (diff) | |
download | opensim-SC-4a92046b589a0ced240cbf5b174855daf5504a4f.zip opensim-SC-4a92046b589a0ced240cbf5b174855daf5504a4f.tar.gz opensim-SC-4a92046b589a0ced240cbf5b174855daf5504a4f.tar.bz2 opensim-SC-4a92046b589a0ced240cbf5b174855daf5504a4f.tar.xz |
implement llSetPrimMediaParams()
Untested
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 113 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | 12 |
2 files changed, 123 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 9290fc3..2600790 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -7816,7 +7816,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7816 | // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid | 7816 | // LSL Spec http://wiki.secondlife.com/wiki/LlGetPrimMediaParams says to fail silently if face is invalid |
7817 | // TODO: Need to correctly handle case where a face has no media (which gives back an empty list). | 7817 | // TODO: Need to correctly handle case where a face has no media (which gives back an empty list). |
7818 | // Assuming silently fail means give back an empty list. Ideally, need to check this. | 7818 | // Assuming silently fail means give back an empty list. Ideally, need to check this. |
7819 | if (face < 0 || face > m_host.Shape.Media.Count - 1) | 7819 | if (face < 0 || face > m_host.GetNumberOfSides() - 1) |
7820 | return new LSL_List(); | 7820 | return new LSL_List(); |
7821 | 7821 | ||
7822 | return GetLinkPrimMediaParams(face, rules); | 7822 | return GetLinkPrimMediaParams(face, rules); |
@@ -7830,6 +7830,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7830 | 7830 | ||
7831 | MediaEntry me = module.GetMediaEntry(m_host, face); | 7831 | MediaEntry me = module.GetMediaEntry(m_host, face); |
7832 | 7832 | ||
7833 | // As per http://wiki.secondlife.com/wiki/LlGetPrimMediaParams | ||
7834 | if (null == me) | ||
7835 | return new LSL_List(); | ||
7836 | |||
7833 | LSL_List res = new LSL_List(); | 7837 | LSL_List res = new LSL_List(); |
7834 | 7838 | ||
7835 | for (int i = 0; i < rules.Length; i++) | 7839 | for (int i = 0; i < rules.Length; i++) |
@@ -7912,6 +7916,113 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7912 | return res; | 7916 | return res; |
7913 | } | 7917 | } |
7914 | 7918 | ||
7919 | public LSL_Integer llSetPrimMediaParams(int face, LSL_List rules) | ||
7920 | { | ||
7921 | m_host.AddScriptLPS(1); | ||
7922 | ScriptSleep(1000); | ||
7923 | |||
7924 | // LSL Spec http://wiki.secondlife.com/wiki/LlSetPrimMediaParams says to fail silently if face is invalid | ||
7925 | // Assuming silently fail means sending back LSL_STATUS_OK. Ideally, need to check this. | ||
7926 | // Don't perform the media check directly | ||
7927 | if (face < 0 || face > m_host.GetNumberOfSides() - 1) | ||
7928 | return ScriptBaseClass.LSL_STATUS_OK; | ||
7929 | |||
7930 | return SetPrimMediaParams(face, rules); | ||
7931 | } | ||
7932 | |||
7933 | public LSL_Integer SetPrimMediaParams(int face, LSL_List rules) | ||
7934 | { | ||
7935 | IMoapModule module = m_ScriptEngine.World.RequestModuleInterface<IMoapModule>(); | ||
7936 | if (null == module) | ||
7937 | throw new Exception("Media on a prim functions not available"); | ||
7938 | |||
7939 | MediaEntry me = module.GetMediaEntry(m_host, face); | ||
7940 | if (null == me) | ||
7941 | me = new MediaEntry(); | ||
7942 | |||
7943 | int i = 0; | ||
7944 | |||
7945 | while (i < rules.Length - 1) | ||
7946 | { | ||
7947 | int code = rules.GetLSLIntegerItem(i++); | ||
7948 | |||
7949 | switch (code) | ||
7950 | { | ||
7951 | case ScriptBaseClass.PRIM_MEDIA_ALT_IMAGE_ENABLE: | ||
7952 | me.EnableAlterntiveImage = (rules.GetLSLIntegerItem(i++) != 0 ? true : false); | ||
7953 | break; | ||
7954 | |||
7955 | case ScriptBaseClass.PRIM_MEDIA_CONTROLS: | ||
7956 | int v = rules.GetLSLIntegerItem(i++); | ||
7957 | if (ScriptBaseClass.PRIM_MEDIA_CONTROLS_STANDARD == v) | ||
7958 | me.Controls = MediaControls.Standard; | ||
7959 | else | ||
7960 | me.Controls = MediaControls.Mini; | ||
7961 | break; | ||
7962 | |||
7963 | case ScriptBaseClass.PRIM_MEDIA_CURRENT_URL: | ||
7964 | me.CurrentURL = rules.GetLSLStringItem(i++); | ||
7965 | break; | ||
7966 | |||
7967 | case ScriptBaseClass.PRIM_MEDIA_HOME_URL: | ||
7968 | me.HomeURL = rules.GetLSLStringItem(i++); | ||
7969 | break; | ||
7970 | |||
7971 | case ScriptBaseClass.PRIM_MEDIA_AUTO_LOOP: | ||
7972 | me.AutoLoop = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false); | ||
7973 | break; | ||
7974 | |||
7975 | case ScriptBaseClass.PRIM_MEDIA_AUTO_PLAY: | ||
7976 | me.AutoPlay = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false); | ||
7977 | break; | ||
7978 | |||
7979 | case ScriptBaseClass.PRIM_MEDIA_AUTO_SCALE: | ||
7980 | me.AutoScale = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false); | ||
7981 | break; | ||
7982 | |||
7983 | case ScriptBaseClass.PRIM_MEDIA_AUTO_ZOOM: | ||
7984 | me.AutoZoom = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false); | ||
7985 | break; | ||
7986 | |||
7987 | case ScriptBaseClass.PRIM_MEDIA_FIRST_CLICK_INTERACT: | ||
7988 | me.InteractOnFirstClick = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false); | ||
7989 | break; | ||
7990 | |||
7991 | case ScriptBaseClass.PRIM_MEDIA_WIDTH_PIXELS: | ||
7992 | me.Width = (int)rules.GetLSLIntegerItem(i++); | ||
7993 | break; | ||
7994 | |||
7995 | case ScriptBaseClass.PRIM_MEDIA_HEIGHT_PIXELS: | ||
7996 | me.Height = (int)rules.GetLSLIntegerItem(i++); | ||
7997 | break; | ||
7998 | |||
7999 | case ScriptBaseClass.PRIM_MEDIA_WHITELIST_ENABLE: | ||
8000 | me.EnableWhiteList = (ScriptBaseClass.TRUE == rules.GetLSLIntegerItem(i++) ? true : false); | ||
8001 | break; | ||
8002 | |||
8003 | case ScriptBaseClass.PRIM_MEDIA_WHITELIST: | ||
8004 | string[] rawWhiteListUrls = rules.GetLSLStringItem(i++).ToString().Split(new char[] { ',' }); | ||
8005 | List<string> whiteListUrls = new List<string>(); | ||
8006 | Array.ForEach( | ||
8007 | rawWhiteListUrls, delegate(string rawUrl) { whiteListUrls.Add(rawUrl.Trim()); }); | ||
8008 | me.WhiteList = whiteListUrls.ToArray(); | ||
8009 | break; | ||
8010 | |||
8011 | case ScriptBaseClass.PRIM_MEDIA_PERMS_INTERACT: | ||
8012 | me.InteractPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++); | ||
8013 | break; | ||
8014 | |||
8015 | case ScriptBaseClass.PRIM_MEDIA_PERMS_CONTROL: | ||
8016 | me.ControlPermissions = (MediaPermission)(byte)(int)rules.GetLSLIntegerItem(i++); | ||
8017 | break; | ||
8018 | } | ||
8019 | } | ||
8020 | |||
8021 | module.SetMediaEntry(m_host, face, me); | ||
8022 | |||
8023 | return ScriptBaseClass.LSL_STATUS_OK; | ||
8024 | } | ||
8025 | |||
7915 | // <remarks> | 8026 | // <remarks> |
7916 | // <para> | 8027 | // <para> |
7917 | // The .NET definition of base 64 is: | 8028 | // The .NET definition of base 64 is: |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 9a64f8c..6ef786a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -518,7 +518,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
518 | public static readonly vector TOUCH_INVALID_TEXCOORD = new vector(-1.0, -1.0, 0.0); | 518 | public static readonly vector TOUCH_INVALID_TEXCOORD = new vector(-1.0, -1.0, 0.0); |
519 | public static readonly vector TOUCH_INVALID_VECTOR = ZERO_VECTOR; | 519 | public static readonly vector TOUCH_INVALID_VECTOR = ZERO_VECTOR; |
520 | 520 | ||
521 | // constants for llGetPrimMediaParams | 521 | // constants for llGetPrimMediaParams/llSetPrimMediaParams |
522 | public const int PRIM_MEDIA_ALT_IMAGE_ENABLE = 0; | 522 | public const int PRIM_MEDIA_ALT_IMAGE_ENABLE = 0; |
523 | public const int PRIM_MEDIA_CONTROLS = 1; | 523 | public const int PRIM_MEDIA_CONTROLS = 1; |
524 | public const int PRIM_MEDIA_CURRENT_URL = 2; | 524 | public const int PRIM_MEDIA_CURRENT_URL = 2; |
@@ -542,6 +542,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
542 | public const int PRIM_MEDIA_PERM_OWNER = 1; | 542 | public const int PRIM_MEDIA_PERM_OWNER = 1; |
543 | public const int PRIM_MEDIA_PERM_GROUP = 2; | 543 | public const int PRIM_MEDIA_PERM_GROUP = 2; |
544 | public const int PRIM_MEDIA_PERM_ANYONE = 4; | 544 | public const int PRIM_MEDIA_PERM_ANYONE = 4; |
545 | |||
546 | // extra constants for llSetPrimMediaParams | ||
547 | public static readonly LSLInteger LSL_STATUS_OK = new LSLInteger(0); | ||
548 | public static readonly LSLInteger LSL_STATUS_MALFORMED_PARAMS = new LSLInteger(1000); | ||
549 | public static readonly LSLInteger LSL_STATUS_TYPE_MISMATCH = new LSLInteger(1001); | ||
550 | public static readonly LSLInteger LSL_STATUS_BOUNDS_ERROR = new LSLInteger(1002); | ||
551 | public static readonly LSLInteger LSL_STATUS_NOT_FOUND = new LSLInteger(1003); | ||
552 | public static readonly LSLInteger LSL_STATUS_NOT_SUPPORTED = new LSLInteger(1004); | ||
553 | public static readonly LSLInteger LSL_STATUS_INTERNAL_ERROR = new LSLInteger(1999); | ||
554 | public static readonly LSLInteger LSL_STATUS_WHITELIST_FAILED = new LSLInteger(2001); | ||
545 | 555 | ||
546 | // Constants for default textures | 556 | // Constants for default textures |
547 | public const string TEXTURE_BLANK = "5748decc-f629-461c-9a36-a35a221fe21f"; | 557 | public const string TEXTURE_BLANK = "5748decc-f629-461c-9a36-a35a221fe21f"; |