From c27ff70d5c9c7f91ff63b197359de84f7508ec60 Mon Sep 17 00:00:00 2001 From: Melanie Date: Wed, 15 Aug 2012 18:22:16 +0200 Subject: Add support for the extra params to scene and the event manager --- OpenSim/Region/Framework/Scenes/EventManager.cs | 23 +++++++++++++++ OpenSim/Region/Framework/Scenes/Scene.cs | 39 +++++++++++++++++++++++++ 2 files changed, 62 insertions(+) (limited to 'OpenSim/Region/Framework/Scenes') diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 6dea2f0..4d65be9 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -213,6 +213,9 @@ namespace OpenSim.Region.Framework.Scenes /// public event NewScript OnNewScript; + public delegate void ExtraSettingChangedDelegate(Scene scene, string name, string value); + public event ExtraSettingChangedDelegate OnExtraSettingChanged; + public virtual void TriggerNewScript(UUID clientID, SceneObjectPart part, UUID itemID) { NewScript handlerNewScript = OnNewScript; @@ -2591,5 +2594,25 @@ namespace OpenSim.Region.Framework.Scenes } } + public void TriggerExtraSettingChanged(Scene scene, string name, string val) + { + ExtraSettingChangedDelegate handler = OnExtraSettingChanged; + + if (handler != null) + { + foreach (ExtraSettingChangedDelegate d in handler.GetInvocationList()) + { + try + { + d(scene, name, val); + } + catch (Exception e) + { + m_log.ErrorFormat("[EVENT MANAGER]: Delegate for ExtraSettingChanged failed - continuing {0} - {1}", + e.Message, e.StackTrace); + } + } + } + } } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 59f49ea..0e5ddfd 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -5447,5 +5447,44 @@ namespace OpenSim.Region.Framework.Scenes callback(asset); } + + public string GetExtraSetting(string name) + { + string val; + + if (!m_extraSettings.TryGetValue(name, out val)) + return String.Empty; + + return val; + } + + public void StoreExtraSetting(string name, string val) + { + string oldVal; + + if (m_extraSettings.TryGetValue(name, out oldVal)) + { + if (oldVal == val) + return; + } + + m_extraSettings[name] = val; + + m_SimulationDataService.SaveExtra(RegionInfo.RegionID, name, val); + + m_eventManager.TriggerExtraSettingChanged(this, name, val); + } + + public void RemoveExtraSetting(string name) + { + if (!m_extraSettings.ContainsKey(name)) + return; + + m_extraSettings.Remove(name); + + m_SimulationDataService.RemoveExtra(RegionInfo.RegionID, name); + + m_eventManager.TriggerExtraSettingChanged(this, name, String.Empty); + } } } -- cgit v1.1