aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs78
-rw-r--r--OpenSim/Framework/Util.cs5
-rw-r--r--bin/assets/AssetSets.xml13
-rw-r--r--bin/assets/README.txt12
4 files changed, 89 insertions, 19 deletions
diff --git a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs
index bffced8..46e6ae1 100644
--- a/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs
+++ b/OpenSim/Framework/AssetLoader/Filesystem/AssetLoaderFileSystem.cs
@@ -44,18 +44,18 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
44{ 44{
45 public class AssetLoaderFileSystem : IAssetLoader 45 public class AssetLoaderFileSystem : IAssetLoader
46 { 46 {
47 protected AssetBase CreateAsset(string assetIdStr, string name, string filename, bool isImage) 47 protected AssetBase CreateAsset(string assetIdStr, string name, string path, bool isImage)
48 { 48 {
49 AssetBase asset = new AssetBase( 49 AssetBase asset = new AssetBase(
50 new LLUUID(assetIdStr), 50 new LLUUID(assetIdStr),
51 name 51 name
52 ); 52 );
53 53
54 if (!String.IsNullOrEmpty(filename)) 54 if (!String.IsNullOrEmpty(path))
55 { 55 {
56 MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, filename); 56 MainLog.Instance.Verbose("ASSETS", "Loading: [{0}][{1}]", name, path);
57 57
58 LoadAsset(asset, isImage, filename); 58 LoadAsset(asset, isImage, path);
59 } 59 }
60 else 60 else
61 { 61 {
@@ -65,13 +65,11 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
65 return asset; 65 return asset;
66 } 66 }
67 67
68 protected void LoadAsset(AssetBase info, bool image, string filename) 68 protected void LoadAsset(AssetBase info, bool image, string path)
69 { 69 {
70 string dataPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "assets/OpenSimAssetSet"); //+ folder; 70 FileInfo fInfo = new FileInfo(path);
71 string fileName = Path.Combine(dataPath, filename);
72 FileInfo fInfo = new FileInfo(fileName);
73 long numBytes = fInfo.Length; 71 long numBytes = fInfo.Length;
74 FileStream fStream = new FileStream(fileName, FileMode.Open, FileAccess.Read); 72 FileStream fStream = new FileStream(path, FileMode.Open, FileAccess.Read);
75 byte[] idata = new byte[numBytes]; 73 byte[] idata = new byte[numBytes];
76 BinaryReader br = new BinaryReader(fStream); 74 BinaryReader br = new BinaryReader(fStream);
77 idata = br.ReadBytes((int) numBytes); 75 idata = br.ReadBytes((int) numBytes);
@@ -83,25 +81,64 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
83 81
84 public void ForEachXmlAsset(Action<AssetBase> action) 82 public void ForEachXmlAsset(Action<AssetBase> action)
85 { 83 {
86 List<AssetBase> assets = new List<AssetBase>(); 84 List<AssetBase> assets = new List<AssetBase>();
87 // System.Console.WriteLine("trying loading asset into database"); 85 string assetSetsPath = Path.Combine(Util.assetsDir(), "AssetSets.xml");
88 string filePath = Path.Combine(Util.configDir(), "assets/OpenSimAssetSet/OpenSimAssetSet.xml"); 86
89 if (File.Exists(filePath)) 87 if (File.Exists(assetSetsPath))
90 { 88 {
89 string assetSetPath = "ERROR";
90
91 try 91 try
92 { 92 {
93 XmlConfigSource source = new XmlConfigSource(filePath); 93 XmlConfigSource source = new XmlConfigSource(assetSetsPath);
94
95 for (int i = 0; i < source.Configs.Count; i++)
96 {
97 assetSetPath = source.Configs[i].GetString("file", "");
98
99 LoadXmlAssetSet(Path.Combine(Util.assetsDir(), assetSetPath), assets);
100 }
101 }
102 catch (XmlException e)
103 {
104 MainLog.Instance.Error("ASSETS", "Error loading {0} : {1}", assetSetPath, e);
105 }
106 }
107 else
108 {
109 MainLog.Instance.Error(
110 "ASSETS",
111 "Asset set control file assets/AssetSets.xml does not exist! No assets loaded.");
112 }
113
114 assets.ForEach(action);
115 }
116
117 /// <summary>
118 /// Use the asset set information at path to load assets
119 /// </summary>
120 /// <param name="path"></param>
121 /// <param name="assets"></param>
122 protected void LoadXmlAssetSet(string assetSetPath, List<AssetBase> assets)
123 {
124 MainLog.Instance.Verbose("ASSETS", "Loading asset set {0}", assetSetPath);
125
126 if (File.Exists(assetSetPath))
127 {
128 try
129 {
130 XmlConfigSource source = new XmlConfigSource(assetSetPath);
131 String dir = Path.GetDirectoryName(assetSetPath);
94 132
95 for (int i = 0; i < source.Configs.Count; i++) 133 for (int i = 0; i < source.Configs.Count; i++)
96 { 134 {
97 // System.Console.WriteLine("loading asset into database");
98 string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToString()); 135 string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToString());
99 string name = source.Configs[i].GetString("name", ""); 136 string name = source.Configs[i].GetString("name", "");
100 sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); 137 sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0);
101 sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0); 138 sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0);
102 string fileName = source.Configs[i].GetString("fileName", ""); 139 string assetPath = Path.Combine(dir, source.Configs[i].GetString("fileName", ""));
103 140
104 AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); 141 AssetBase newAsset = CreateAsset(assetIdStr, name, assetPath, false);
105 142
106 newAsset.Type = type; 143 newAsset.Type = type;
107 newAsset.InvType = invType; 144 newAsset.InvType = invType;
@@ -110,10 +147,13 @@ namespace OpenSim.Framework.AssetLoader.Filesystem
110 } 147 }
111 catch (XmlException e) 148 catch (XmlException e)
112 { 149 {
113 MainLog.Instance.Error("ASSETS", "Error loading " + filePath + ": " + e.ToString()); 150 MainLog.Instance.Error("ASSETS", "Error loading {0} : {1}", assetSetPath, e);
114 } 151 }
115 } 152 }
116 assets.ForEach(action); 153 else
154 {
155 MainLog.Instance.Error("ASSETS", "Asset set file {0} does not exist!", assetSetPath);
156 }
117 } 157 }
118 } 158 }
119} 159}
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 08b3a9d..c742cf3 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -318,6 +318,11 @@ namespace OpenSim.Framework
318 temp = "."; 318 temp = ".";
319 return temp; 319 return temp;
320 } 320 }
321
322 public static string assetsDir()
323 {
324 return "assets";
325 }
321 326
322 public static string configDir() 327 public static string configDir()
323 { 328 {
diff --git a/bin/assets/AssetSets.xml b/bin/assets/AssetSets.xml
new file mode 100644
index 0000000..b827e59
--- /dev/null
+++ b/bin/assets/AssetSets.xml
@@ -0,0 +1,13 @@
1<Nini>
2 <!-- You probably don't want to remove the OpenSim asset set
3 since it contains various default assets which are currently hardcoded -->
4 <Section Name="OpenSim Asset Set">
5 <Key Name="file" Value="OpenSimAssetSet/OpenSimAssetSet.xml"/>
6 </Section>
7 <!-- New asset sets can be added as shown below -->
8 <!--
9 <Section Name="My Asset Set">
10 <Key Name="file" Value="MyAssetSet/MyAssetSet.xml"/>
11 </Section>
12 -->
13</Nini>
diff --git a/bin/assets/README.txt b/bin/assets/README.txt
new file mode 100644
index 0000000..02cc78f
--- /dev/null
+++ b/bin/assets/README.txt
@@ -0,0 +1,12 @@
1README
2
3OpenSim comes with a default asset set contained in the OpenSimAssetSet
4directory. You can also load up your own asset set to OpenSim on startup by
5making a file entry in AssetSets.xml. This file should point towards an XML
6file which details the assets in your asset set. The
7OpenSimAssetSet/OpenSimAssetSet.xml is a good template for the information
8required.
9
10If you want your assets to show up in the standard inventory library for an
11avatar, you will also need to add separate entries to the xml files in the
12bin/inventory configuration directory.