diff options
Update svn properties.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs | 286 |
1 files changed, 143 insertions, 143 deletions
diff --git a/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs b/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs index adb607a..8613e77 100644 --- a/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs +++ b/OpenSim/Region/Environment/Modules/ExportSerialiser/ExportSerialisationModule.cs | |||
@@ -1,143 +1,143 @@ | |||
1 | | 1 | |
2 | using System; | 2 | using System; |
3 | using System.Collections.Generic; | 3 | using System.Collections.Generic; |
4 | using System.Drawing; | 4 | using System.Drawing; |
5 | using libsecondlife; | 5 | using libsecondlife; |
6 | using Nini.Config; | 6 | using Nini.Config; |
7 | using OpenSim.Framework; | 7 | using OpenSim.Framework; |
8 | using OpenSim.Region.Environment.Interfaces; | 8 | using OpenSim.Region.Environment.Interfaces; |
9 | using OpenSim.Region.Environment.Scenes; | 9 | using OpenSim.Region.Environment.Scenes; |
10 | using OpenSim.Region.Environment.Modules.ModuleFramework; | 10 | using OpenSim.Region.Environment.Modules.ModuleFramework; |
11 | using System.IO; | 11 | using System.IO; |
12 | 12 | ||
13 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser | 13 | namespace OpenSim.Region.Environment.Modules.ExportSerialiser |
14 | { | 14 | { |
15 | public class ExportSerialisationModule : IRegionModule | 15 | public class ExportSerialisationModule : IRegionModule |
16 | { | 16 | { |
17 | private List<Scene> m_regions = new List<Scene>(); | 17 | private List<Scene> m_regions = new List<Scene>(); |
18 | private List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>(); | 18 | private List<IFileSerialiser> m_serialisers = new List<IFileSerialiser>(); |
19 | private Commander m_commander = new Commander("Export"); | 19 | private Commander m_commander = new Commander("Export"); |
20 | private string m_savedir = "exports" + "/"; | 20 | private string m_savedir = "exports" + "/"; |
21 | 21 | ||
22 | private List<string> SerialiseRegion(Scene scene) | 22 | private List<string> SerialiseRegion(Scene scene) |
23 | { | 23 | { |
24 | List<string> results = new List<string>(); | 24 | List<string> results = new List<string>(); |
25 | 25 | ||
26 | string saveDir = m_savedir + scene.RegionInfo.RegionID.ToString() + "/"; | 26 | string saveDir = m_savedir + scene.RegionInfo.RegionID.ToString() + "/"; |
27 | 27 | ||
28 | if (!Directory.Exists(saveDir)) | 28 | if (!Directory.Exists(saveDir)) |
29 | { | 29 | { |
30 | Directory.CreateDirectory(saveDir); | 30 | Directory.CreateDirectory(saveDir); |
31 | } | 31 | } |
32 | 32 | ||
33 | lock (m_serialisers) | 33 | lock (m_serialisers) |
34 | { | 34 | { |
35 | foreach (IFileSerialiser serialiser in m_serialisers) | 35 | foreach (IFileSerialiser serialiser in m_serialisers) |
36 | { | 36 | { |
37 | results.Add(serialiser.WriteToFile(scene, saveDir)); | 37 | results.Add(serialiser.WriteToFile(scene, saveDir)); |
38 | } | 38 | } |
39 | } | 39 | } |
40 | 40 | ||
41 | TextWriter regionInfoWriter = new StreamWriter(saveDir + "README.TXT"); | 41 | TextWriter regionInfoWriter = new StreamWriter(saveDir + "README.TXT"); |
42 | regionInfoWriter.WriteLine("Region Name: " + scene.RegionInfo.RegionName); | 42 | regionInfoWriter.WriteLine("Region Name: " + scene.RegionInfo.RegionName); |
43 | regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID.ToString()); | 43 | regionInfoWriter.WriteLine("Region ID: " + scene.RegionInfo.RegionID.ToString()); |
44 | regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow.ToString()); | 44 | regionInfoWriter.WriteLine("Backup Time: UTC " + DateTime.UtcNow.ToString()); |
45 | regionInfoWriter.WriteLine("Serialise Version: 0.1"); | 45 | regionInfoWriter.WriteLine("Serialise Version: 0.1"); |
46 | regionInfoWriter.Close(); | 46 | regionInfoWriter.Close(); |
47 | 47 | ||
48 | TextWriter manifestWriter = new StreamWriter(saveDir + "region.manifest"); | 48 | TextWriter manifestWriter = new StreamWriter(saveDir + "region.manifest"); |
49 | foreach (string line in results) | 49 | foreach (string line in results) |
50 | { | 50 | { |
51 | manifestWriter.WriteLine(line); | 51 | manifestWriter.WriteLine(line); |
52 | } | 52 | } |
53 | manifestWriter.Close(); | 53 | manifestWriter.Close(); |
54 | 54 | ||
55 | return results; | 55 | return results; |
56 | } | 56 | } |
57 | 57 | ||
58 | 58 | ||
59 | #region IRegionModule Members | 59 | #region IRegionModule Members |
60 | 60 | ||
61 | public void Initialise(Scene scene, IConfigSource source) | 61 | public void Initialise(Scene scene, IConfigSource source) |
62 | { | 62 | { |
63 | scene.RegisterModuleCommander("Export", m_commander); | 63 | scene.RegisterModuleCommander("Export", m_commander); |
64 | scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; | 64 | scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; |
65 | 65 | ||
66 | lock (m_regions) | 66 | lock (m_regions) |
67 | { | 67 | { |
68 | m_regions.Add(scene); | 68 | m_regions.Add(scene); |
69 | } | 69 | } |
70 | } | 70 | } |
71 | 71 | ||
72 | void EventManager_OnPluginConsole(string[] args) | 72 | void EventManager_OnPluginConsole(string[] args) |
73 | { | 73 | { |
74 | if (args[0] == "export") | 74 | if (args[0] == "export") |
75 | { | 75 | { |
76 | string[] tmpArgs = new string[args.Length - 2]; | 76 | string[] tmpArgs = new string[args.Length - 2]; |
77 | int i = 0; | 77 | int i = 0; |
78 | for (i = 2; i < args.Length; i++) | 78 | for (i = 2; i < args.Length; i++) |
79 | tmpArgs[i - 2] = args[i]; | 79 | tmpArgs[i - 2] = args[i]; |
80 | 80 | ||
81 | m_commander.ProcessConsoleCommand(args[1], tmpArgs); | 81 | m_commander.ProcessConsoleCommand(args[1], tmpArgs); |
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
85 | private void InterfaceSaveRegion(Object[] args) | 85 | private void InterfaceSaveRegion(Object[] args) |
86 | { | 86 | { |
87 | foreach (Scene region in m_regions) | 87 | foreach (Scene region in m_regions) |
88 | { | 88 | { |
89 | if (region.RegionInfo.RegionName == (string)args[0]) | 89 | if (region.RegionInfo.RegionName == (string)args[0]) |
90 | { | 90 | { |
91 | List<string> results = SerialiseRegion(region); | 91 | List<string> results = SerialiseRegion(region); |
92 | } | 92 | } |
93 | } | 93 | } |
94 | } | 94 | } |
95 | 95 | ||
96 | private void InterfaceSaveAllRegions(Object[] args) | 96 | private void InterfaceSaveAllRegions(Object[] args) |
97 | { | 97 | { |
98 | foreach (Scene region in m_regions) | 98 | foreach (Scene region in m_regions) |
99 | { | 99 | { |
100 | List<string> results = SerialiseRegion(region); | 100 | List<string> results = SerialiseRegion(region); |
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
104 | private void LoadCommanderCommands() | 104 | private void LoadCommanderCommands() |
105 | { | 105 | { |
106 | Command serialiseSceneCommand = new Command("save", InterfaceSaveRegion, "Saves the named region into the exports directory."); | 106 | Command serialiseSceneCommand = new Command("save", InterfaceSaveRegion, "Saves the named region into the exports directory."); |
107 | serialiseSceneCommand.AddArgument("region-name", "The name of the region you wish to export", "String"); | 107 | serialiseSceneCommand.AddArgument("region-name", "The name of the region you wish to export", "String"); |
108 | 108 | ||
109 | Command serialiseAllScenesCommand = new Command("save-all", InterfaceSaveAllRegions, "Saves all regions into the exports directory."); | 109 | Command serialiseAllScenesCommand = new Command("save-all", InterfaceSaveAllRegions, "Saves all regions into the exports directory."); |
110 | 110 | ||
111 | m_commander.RegisterCommand("save", serialiseSceneCommand); | 111 | m_commander.RegisterCommand("save", serialiseSceneCommand); |
112 | m_commander.RegisterCommand("save-all", serialiseAllScenesCommand); | 112 | m_commander.RegisterCommand("save-all", serialiseAllScenesCommand); |
113 | } | 113 | } |
114 | 114 | ||
115 | public void PostInitialise() | 115 | public void PostInitialise() |
116 | { | 116 | { |
117 | lock (m_serialisers) | 117 | lock (m_serialisers) |
118 | { | 118 | { |
119 | m_serialisers.Add(new SerialiseTerrain()); | 119 | m_serialisers.Add(new SerialiseTerrain()); |
120 | m_serialisers.Add(new SerialiseObjects()); | 120 | m_serialisers.Add(new SerialiseObjects()); |
121 | } | 121 | } |
122 | 122 | ||
123 | LoadCommanderCommands(); | 123 | LoadCommanderCommands(); |
124 | } | 124 | } |
125 | 125 | ||
126 | public void Close() | 126 | public void Close() |
127 | { | 127 | { |
128 | m_regions.Clear(); | 128 | m_regions.Clear(); |
129 | } | 129 | } |
130 | 130 | ||
131 | public string Name | 131 | public string Name |
132 | { | 132 | { |
133 | get { return "ExportSerialisationModule"; } | 133 | get { return "ExportSerialisationModule"; } |
134 | } | 134 | } |
135 | 135 | ||
136 | public bool IsSharedModule | 136 | public bool IsSharedModule |
137 | { | 137 | { |
138 | get { return true; } | 138 | get { return true; } |
139 | } | 139 | } |
140 | 140 | ||
141 | #endregion | 141 | #endregion |
142 | } | 142 | } |
143 | } | 143 | } |