add enable disable option

master
Christopher 2020-08-06 02:32:50 +02:00
parent 0b4064150c
commit e92cb674bc
1 changed files with 61 additions and 1 deletions

View File

@ -28,6 +28,7 @@ namespace OpenSim.Modules.TextureFetcher
bool m_checkTexture = false; bool m_checkTexture = false;
List<String> m_defaultTexturs = new List<String>(new string[] { "89556747-24cb-43ed-920b-47caed15465f", "5748decc-f629-461c-9a36-a35a221fe21f", "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903", "8b5fec65-8d8d-9dc5-cda8-8fdf2716e361", "38b86f85-2575-52a9-a531-23108d8da837", "e97cf410-8e61-7005-ec06-629eba4cd1fb", "5a9f4a74-30f2-821c-b88d-70499d3e7183 ", "ae2de45c-d252-50b8-5c6e-19f39ce79317 ", "24daea5f-0539-cfcf-047f-fbc40b2786ba", "52cc6bb6-2ee5-e632-d3ad-50197b1dcb8a", "43529ce8-7faa-ad92-165a-bc4078371687", "09aac1fb-6bce-0bee-7d44-caac6dbb6c63", "ff62763f-d60a-9855-890b-0c96f8f8cd98", "8e915e25-31d1-cc95-ae08-d58a47488251", "9742065b-19b5-297c-858a-29711d539043", "03642e83-2bd1-4eb9-34b4-4c47ed586d2d", "edd51b77-fc10-ce7a-4b3d-011dfc349e4f"}); List<String> m_defaultTexturs = new List<String>(new string[] { "89556747-24cb-43ed-920b-47caed15465f", "5748decc-f629-461c-9a36-a35a221fe21f", "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903", "8b5fec65-8d8d-9dc5-cda8-8fdf2716e361", "38b86f85-2575-52a9-a531-23108d8da837", "e97cf410-8e61-7005-ec06-629eba4cd1fb", "5a9f4a74-30f2-821c-b88d-70499d3e7183 ", "ae2de45c-d252-50b8-5c6e-19f39ce79317 ", "24daea5f-0539-cfcf-047f-fbc40b2786ba", "52cc6bb6-2ee5-e632-d3ad-50197b1dcb8a", "43529ce8-7faa-ad92-165a-bc4078371687", "09aac1fb-6bce-0bee-7d44-caac6dbb6c63", "ff62763f-d60a-9855-890b-0c96f8f8cd98", "8e915e25-31d1-cc95-ae08-d58a47488251", "9742065b-19b5-297c-858a-29711d539043", "03642e83-2bd1-4eb9-34b4-4c47ed586d2d", "edd51b77-fc10-ce7a-4b3d-011dfc349e4f"});
private bool m_enable = false;
public string Name public string Name
{ {
@ -53,6 +54,7 @@ namespace OpenSim.Modules.TextureFetcher
if (m_config.Configs["Startup"] != null) if (m_config.Configs["Startup"] != null)
{ {
m_checkTexture = m_config.Configs["Startup"].GetBoolean("TextureFetcherCheckAssets", m_checkTexture); m_checkTexture = m_config.Configs["Startup"].GetBoolean("TextureFetcherCheckAssets", m_checkTexture);
m_enable = m_config.Configs["Startup"].GetBoolean("TextureFetcherEnable", m_enable);
} }
} }
@ -65,6 +67,18 @@ namespace OpenSim.Modules.TextureFetcher
{ {
m_scene = scene; m_scene = scene;
if (m_enable == false)
{
scene.EventManager.OnObjectAddedToScene += ClearObjekt;
scene.EventManager.OnSceneObjectLoaded += ClearObjekt;
scene.EventManager.OnIncomingSceneObject += ClearObjekt;
scene.EventManager.OnSceneObjectPartUpdated += ClearObjekt;
scene.EventManager.OnSceneObjectPartCopy += ClearObjekt;
return;
}
scene.EventManager.OnObjectAddedToScene += AddObject; scene.EventManager.OnObjectAddedToScene += AddObject;
scene.EventManager.OnSceneObjectLoaded += AddObject; scene.EventManager.OnSceneObjectLoaded += AddObject;
scene.EventManager.OnIncomingSceneObject += AddObject; scene.EventManager.OnIncomingSceneObject += AddObject;
@ -74,6 +88,22 @@ namespace OpenSim.Modules.TextureFetcher
m_log.Info("[" + Name + "] Region '" + scene.Name + "' loaded."); m_log.Info("[" + Name + "] Region '" + scene.Name + "' loaded.");
} }
private void ClearObjekt(SceneObjectPart copy, SceneObjectPart original, bool userExposed)
{
removeTexturesToInventory(copy);
}
private void ClearObjekt(SceneObjectPart sop, bool full)
{
removeTexturesToInventory(sop);
}
private void ClearObjekt(SceneObjectGroup so)
{
foreach (SceneObjectPart _part in so.Parts)
removeTexturesToInventory(_part);
}
private void CopyObject(SceneObjectPart copy, SceneObjectPart original, bool userExposed) private void CopyObject(SceneObjectPart copy, SceneObjectPart original, bool userExposed)
{ {
copyTexturesToInventory(copy); copyTexturesToInventory(copy);
@ -127,6 +157,33 @@ namespace OpenSim.Modules.TextureFetcher
return false; return false;
} }
private void removeTexturesToInventory(SceneObjectPart part)
{
if (m_scene.LoginsEnabled == false)
return;
if (inventoryContainsScripts(part.ParentGroup.RootPart))
return;
try
{
foreach (TaskInventoryItem item in part.ParentGroup.RootPart.Inventory.GetInventoryItems())
{
if(item.Type == (int)InventoryType.Texture)
{
if(item.Description == "This item was automatically generated by the texture fetcher module.")
part.ParentGroup.RootPart.Inventory.RemoveInventoryItem(item.ItemID);
}
}
}
catch (Exception _error)
{
m_log.Error("[" + Name + "] ERROR: " + _error.Message);
}
}
private void copyTexturesToInventory(SceneObjectPart part) private void copyTexturesToInventory(SceneObjectPart part)
{ {
if (m_scene.LoginsEnabled == false) if (m_scene.LoginsEnabled == false)
@ -159,6 +216,9 @@ namespace OpenSim.Modules.TextureFetcher
if(!m_textureBlackList.Contains(face.TextureID) && !m_defaultTexturs.Contains(face.TextureID.ToString())) if(!m_textureBlackList.Contains(face.TextureID) && !m_defaultTexturs.Contains(face.TextureID.ToString()))
allTextures.Add(face.TextureID); allTextures.Add(face.TextureID);
if (m_textureBlackList.Contains(face.TextureID))
face.TextureID = UUID.Parse("89556747-24cb-43ed-920b-47caed15465f");
} }
//Remove not existing textures //Remove not existing textures