Exemplo n.º 1
0
 public void ClearNodes()
 {
     lock (bubbleDictionary) {
         foreach (long oid in bubbleDictionary.Keys)
         {
             BubbleTextNode node = bubbleDictionary[oid];
             window.RemoveChild(node.Widget);
             node.Dispose();
         }
         bubbleDictionary.Clear();
     }
 }
Exemplo n.º 2
0
 public void RemoveNode(long oid)
 {
     lock (bubbleDictionary) {
         if (!bubbleDictionary.ContainsKey(oid))
         {
             return;
         }
         BubbleTextNode node = bubbleDictionary[oid];
         window.RemoveChild(node.Widget);
         bubbleDictionary.Remove(oid);
         node.Dispose();
     }
 }
Exemplo n.º 3
0
 public void SetBubbleText(long oid, string text, long now)
 {
     lock (bubbleDictionary) {
         if (bubbleDictionary.ContainsKey(oid))
         {
             BubbleTextNode node = bubbleDictionary[oid];
             // expire in 5 seconds, plus one second for each 5 chars
             long expire = now + 5000 + (1000 * text.Length) / 5;
             node.SetText(text, expire);
             UpdateNode(node, now);
         }
     }
 }
Exemplo n.º 4
0
        /// <summary>
        ///   Lock on the bubble dictionary is held already
        /// </summary>
        /// <param name="widgetNode"></param>
        /// <param name="now"></param>
        private void UpdateNode(AttachedWidget widgetNode, long now)
        {
            const float MaxFadeRange        = 40 * Client.OneMeter;
            const float MinFadeRange        = 20 * Client.OneMeter;
            const float MaxFadeRangeSquared = MaxFadeRange * MaxFadeRange;
            const float MinFadeRangeSquared = MinFadeRange * MinFadeRange;

            Axiom.MathLib.Vector3 ray =
                widgetNode.Node.DerivedPosition - client.Camera.DerivedPosition;

            // Don't show if they are too far away
            if (ray.LengthSquared > MaxFadeRangeSquared)
            {
                widgetNode.Visible = false;
                return;
            }

            BubbleTextNode bubbleNode = (BubbleTextNode)widgetNode;

            if (bubbleNode.IsExpired(now))
            {
                widgetNode.Visible = false;
                return;
            }

            Vector3 widgetOffset = new Vector3(0, 0.3f * Client.OneMeter, 0);
            Point   pixelOffset  = new Point(0, -50);

            // if (!SetWidgetPosition(widgetNode, widgetOffset, pixelOffset))
            if (!SetWidgetPosition(widgetNode, Vector3.Zero, pixelOffset))
            {
                return;
            }

            if (ray.LengthSquared < MinFadeRangeSquared)
            {
                widgetNode.Widget.Alpha = 1.0f;
            }
            else
            {
                widgetNode.Widget.Alpha = 1.0f - (ray.Length - MinFadeRange) / (MaxFadeRange - MinFadeRange);
            }
            if (this.Visible)
            {
                widgetNode.Visible = true;
            }
        }
Exemplo n.º 5
0
        // FIXME: Thread safety
        public void AddNode(long oid, ObjectNode objNode)
        {
            BubbleTextNode    widgetNode = new BubbleTextNode(oid);
            Node              attachNode = null;
            WidgetSceneObject attachObj  = new WidgetSceneObject();

            attachObj.WidgetNode = widgetNode;
            AttachmentPoint ap = objNode.GetAttachmentPoint("bubble-disabled");

            if (ap == null)
            {
                // Default to a bit larger than the height of the bounding box
                float objectHeight = objNode.Entity.BoundingBox.Size.y * 1.02f;
                ap = new AttachmentPoint("bubble-disabled", null, Quaternion.Identity, Vector3.UnitY * objectHeight);
            }
            attachNode = objNode.AttachLocalObject(ap, attachObj);
            if (attachNode == null)
            {
                widgetNode.NodeVisible = true;
                widgetNode.Node        = objNode.SceneNode;
            }
            else
            {
                // The node visible will be set by the attachObj
                widgetNode.Node = attachNode;
            }

            // FIXME
            // widgetNode.Widget.Font = font;
            window.AddChild(widgetNode.Widget);
            widgetNode.Widget.Initialize();
            widgetNode.SetFont(font);
            lock (bubbleDictionary) {
                bubbleDictionary[oid] = widgetNode;
            }
        }
        // FIXME: Thread safety
        public void AddNode(long oid, ObjectNode objNode)
        {
            BubbleTextNode widgetNode = new BubbleTextNode(oid);
            Node attachNode = null;
            WidgetSceneObject attachObj = new WidgetSceneObject();
            attachObj.WidgetNode = widgetNode;
            AttachmentPoint ap = objNode.GetAttachmentPoint("bubble-disabled");
            if (ap == null) {
                // Default to a bit larger than the height of the bounding box
                float objectHeight = objNode.Entity.BoundingBox.Size.y * 1.02f;
                ap = new AttachmentPoint("bubble-disabled", null, Quaternion.Identity, Vector3.UnitY * objectHeight);
            }
            attachNode = objNode.AttachLocalObject(ap, attachObj);
            if (attachNode == null) {
                widgetNode.NodeVisible = true;
                widgetNode.Node = objNode.SceneNode;
            } else {
                // The node visible will be set by the attachObj
                widgetNode.Node = attachNode;
            }

            // FIXME
            // widgetNode.Widget.Font = font;
            window.AddChild(widgetNode.Widget);
            widgetNode.Widget.Initialize();
            widgetNode.SetFont(font);
            lock (bubbleDictionary) {
                bubbleDictionary[oid] = widgetNode;
            }
        }