2 using System.Collections.Generic;
5 using Microsoft.Xna.Framework;
6 using Microsoft.Xna.Framework.Graphics;
8 namespace SuperPolarity
12 public List<Widget> Children;
13 public Dictionary<string, List<Action<float>>> Listeners;
15 public Vector2 Position;
16 public SuperPolarity Game;
18 protected bool Active;
20 public Widget(SuperPolarity game, Vector2 position)
25 Children = new List<Widget>();
26 Listeners = new Dictionary<string, List<Action<float>>>();
29 public void Activate()
34 public void Deactivate()
39 public virtual void AppendChild(Widget widget)
44 public virtual void Bind(string eventName, Action<float> eventListener)
46 List<Action<float>> newListenerList;
47 List<Action<float>> listenerList;
50 if (!Listeners.ContainsKey(eventName))
52 newListenerList = new List<Action<float>>();
53 Listeners.Add(eventName, newListenerList);
56 foundListeners = Listeners.TryGetValue(eventName, out listenerList);
58 listenerList.Add(eventListener);
61 public virtual void Unbind(string eventName, Action<float> eventListener)
63 // NOT YET IMPLEMENTED;
66 public virtual void Dispatch(string eventName, float value)
68 List<Action<float>> listenerList;
71 foundListeners = Listeners.TryGetValue(eventName, out listenerList);
78 foreach (Action<float> method in listenerList)
84 public virtual void Update(GameTime gameTime)
88 public virtual void Draw(SpriteBatch spriteBatch)