diff options
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule')
6 files changed, 75 insertions, 6 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs new file mode 100644 index 0000000..4de249f --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Graphics.cs | |||
@@ -0,0 +1,48 @@ | |||
1 | using System.Drawing; | ||
2 | using OpenMetaverse; | ||
3 | using OpenMetaverse.Imaging; | ||
4 | using OpenSim.Framework; | ||
5 | using OpenSim.Region.Framework.Scenes; | ||
6 | |||
7 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | ||
8 | { | ||
9 | class Graphics : IGraphics | ||
10 | { | ||
11 | private readonly Scene m_scene; | ||
12 | |||
13 | public Graphics(Scene m_scene) | ||
14 | { | ||
15 | this.m_scene = m_scene; | ||
16 | } | ||
17 | |||
18 | public UUID SaveBitmap(Bitmap data) | ||
19 | { | ||
20 | return SaveBitmap(data, false, true); | ||
21 | } | ||
22 | |||
23 | public UUID SaveBitmap(Bitmap data, bool lossless, bool temporary) | ||
24 | { | ||
25 | AssetBase asset = new AssetBase(); | ||
26 | asset.FullID = UUID.Random(); | ||
27 | asset.Data = OpenJPEG.EncodeFromImage(data, lossless); | ||
28 | asset.Name = "MRMDynamicImage" + Util.RandomClass.Next(1, 10000); | ||
29 | asset.Type = 0; | ||
30 | asset.Description = "MRM Image"; | ||
31 | asset.Local = false; | ||
32 | asset.Temporary = temporary; | ||
33 | m_scene.CommsManager.AssetCache.AddAsset(asset); | ||
34 | |||
35 | return asset.FullID; | ||
36 | } | ||
37 | |||
38 | public Bitmap LoadBitmap(UUID assetID) | ||
39 | { | ||
40 | AssetBase bmp = m_scene.CommsManager.AssetCache.GetAsset(assetID, true); | ||
41 | ManagedImage outimg; | ||
42 | Image img; | ||
43 | OpenJPEG.DecodeToImage(bmp.Data, out outimg, out img); | ||
44 | |||
45 | return new Bitmap(img); | ||
46 | } | ||
47 | } | ||
48 | } | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs index 394e024..f5953d0 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Host.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System.Reflection; | 28 | using System.Reflection; |
29 | using log4net; | 29 | using log4net; |
30 | using OpenSim.Region.Framework.Scenes; | ||
30 | 31 | ||
31 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | 32 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule |
32 | { | 33 | { |
@@ -34,10 +35,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
34 | { | 35 | { |
35 | private readonly IObject m_obj; | 36 | private readonly IObject m_obj; |
36 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 37 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
38 | private readonly IGraphics m_graphics; | ||
39 | private Scene m_scene; | ||
37 | 40 | ||
38 | public Host(IObject m_obj) | 41 | public Host(IObject m_obj, Scene m_scene) |
39 | { | 42 | { |
40 | this.m_obj = m_obj; | 43 | this.m_obj = m_obj; |
44 | this.m_scene = m_scene; | ||
45 | |||
46 | m_graphics = new Graphics(m_scene); | ||
41 | } | 47 | } |
42 | 48 | ||
43 | public IObject Object | 49 | public IObject Object |
@@ -49,5 +55,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
49 | { | 55 | { |
50 | get { return m_log; } | 56 | get { return m_log; } |
51 | } | 57 | } |
58 | |||
59 | public IGraphics Graphics | ||
60 | { | ||
61 | get { return m_graphics; } | ||
62 | } | ||
52 | } | 63 | } |
53 | } | 64 | } |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IGraphics.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IGraphics.cs new file mode 100644 index 0000000..f4bc12e --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IGraphics.cs | |||
@@ -0,0 +1,12 @@ | |||
1 | using System.Drawing; | ||
2 | using OpenMetaverse; | ||
3 | |||
4 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | ||
5 | { | ||
6 | public interface IGraphics | ||
7 | { | ||
8 | UUID SaveBitmap(Bitmap data); | ||
9 | UUID SaveBitmap(Bitmap data, bool lossless, bool temporary); | ||
10 | Bitmap LoadBitmap(UUID assetID); | ||
11 | } | ||
12 | } | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs index deb7c57..6c76919 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/IHost.cs | |||
@@ -36,5 +36,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
36 | { | 36 | { |
37 | IObject Object { get; } | 37 | IObject Object { get; } |
38 | ILog Console { get; } | 38 | ILog Console { get; } |
39 | IGraphics Graphics { get; } | ||
39 | } | 40 | } |
40 | } | 41 | } |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 910ddea..b978d7c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | |||
@@ -82,7 +82,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
82 | { | 82 | { |
83 | m_log.Info("[MRM] Found C# MRM"); | 83 | m_log.Info("[MRM] Found C# MRM"); |
84 | IWorld m_world = new World(m_scene); | 84 | IWorld m_world = new World(m_scene); |
85 | IHost m_host = new Host(new SOPObject(m_scene, localID)); | 85 | IHost m_host = new Host(new SOPObject(m_scene, localID), m_scene); |
86 | 86 | ||
87 | MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( | 87 | MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( |
88 | CompileFromDotNetText(script, itemID.ToString()), | 88 | CompileFromDotNetText(script, itemID.ToString()), |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index 2280022..f2b3e81 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs | |||
@@ -26,10 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Reflection; | ||
30 | using log4net; | ||
31 | using OpenSim.Framework; | 29 | using OpenSim.Framework; |
32 | using OpenSim.Framework.Client; | ||
33 | using OpenSim.Region.Framework.Interfaces; | 30 | using OpenSim.Region.Framework.Interfaces; |
34 | using OpenSim.Region.Framework.Scenes; | 31 | using OpenSim.Region.Framework.Scenes; |
35 | 32 | ||
@@ -159,7 +156,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
159 | // Skip if other | 156 | // Skip if other |
160 | } | 157 | } |
161 | 158 | ||
162 | void EventManager_OnChatFromClient(object sender, OpenSim.Framework.OSChatMessage chat) | 159 | void EventManager_OnChatFromClient(object sender, OSChatMessage chat) |
163 | { | 160 | { |
164 | if (_OnChat != null) | 161 | if (_OnChat != null) |
165 | { | 162 | { |