Beispiel #1
0
        public void AddOverhead(TextOverhead overhead, Vector3 position)
        {
            if ((overhead.Parent is Static || overhead.Parent is Multi) && !_staticToUpdate.Contains(overhead.Parent))
            {
                _staticToUpdate.Add(overhead.Parent);
            }


            overhead.Right = null;

            if (_firstNode == null)
            {
                overhead.Left = null;
                _firstNode    = overhead;
            }
            else
            {
                var last = (GameObject)_firstNode;

                while (last.Right != null)
                {
                    last = last.Right;
                }

                last.Right    = overhead;
                overhead.Left = last;
            }
        }
        public void MoveToTop(TextOverhead obj)
        {
            if (obj == null)
            {
                return;
            }

            if (obj.DRight != null)
            {
                obj.DRight.DLeft = obj.DLeft;
            }

            if (obj.DLeft != null)
            {
                obj.DLeft.DRight = obj.DRight;
            }

            obj.DLeft = obj.DRight = null;


            var next = _firstNode.DRight;

            _firstNode.DRight = obj;
            obj.DLeft         = _firstNode;
            obj.DRight        = next;

            if (next != null)
            {
                next.DLeft = obj;
            }
        }
Beispiel #3
0
        private void CalculateAlpha(TextOverhead msg)
        {
            if (ProfileManager.Current != null && ProfileManager.Current.TextFading)
            {
                int delta = (int)(msg.Time - Time.Ticks);

                if (delta >= 0 && delta <= 1000)
                {
                    delta /= 10;

                    if (delta > 100)
                    {
                        delta = 100;
                    }
                    else if (delta < 1)
                    {
                        delta = 0;
                    }

                    delta = (255 * delta) / 100;

                    if (!msg.IsTransparent || delta <= 0x7F)
                    {
                        msg.Alpha = (byte)delta;
                    }

                    msg.IsTransparent = true;
                }
            }
        }
Beispiel #4
0
        public void AddOverhead(TextOverhead overhead, Vector3 position)
        {
            if (overhead.Parent is Static st && !_staticToUpdate.Contains(st))
            {
                _staticToUpdate.Add(st);
            }


            overhead.Right = null;

            if (_firstNode == null)
            {
                overhead.Left = null;
                _firstNode    = overhead;
            }
            else
            {
                var last = (GameObject)_firstNode;

                while (last.Right != null)
                {
                    last = last.Right;
                }

                last.Right    = overhead;
                overhead.Left = last;
            }

            //_allOverheads.Add(Tuple.Create(overhead, position));
        }
Beispiel #5
0
        public void AddMessage(TextOverhead obj)
        {
            if (obj == null)
            {
                return;
            }

            var item = _firstNode;

            if (item != null)
            {
                if (item.Right != null)
                {
                    var next = item.Right;

                    item.Right = obj;
                    obj.Left   = item;
                    obj.Right  = next;
                    next.Left  = obj;
                }
                else
                {
                    item.Right = obj;
                    obj.Left   = item;
                    obj.Right  = null;
                }
            }
        }
        public TextOverheadView(TextOverhead parent, int maxwidth = 0, ushort hue = 0xFFFF, byte font = 0, bool isunicode = false, FontStyle style = FontStyle.None) : base(parent)
        {
            _text = new RenderedText
            {
                MaxWidth  = maxwidth,
                Hue       = hue,
                Font      = font,
                IsUnicode = isunicode,
                FontStyle = style,
                Text      = parent.Text
            };
            Texture = _text.Texture;
            int delay = Service.Get <Settings>().SpeechDelay;

            if (delay < 10)
            {
                delay = 10;
            }

            if (parent.TimeToLive <= 0.0f)
            {
                parent.TimeToLive = 4000 * _text.LinesCount * delay / 100.0f;
            }

            parent.Initialized = true;

            parent.Disposed += ParentOnDisposed;
        }
        public void AddText(TextOverhead msg)
        {
            if (msg == null)
            {
                return;
            }

            msg.Time = Time.Ticks + 4000;

            TextRenderer.AddMessage(msg);
        }
        public void AddText(TextOverhead msg)
        {
            if (World.ClientFeatures.TooltipsEnabled || msg == null)
            {
                return;
            }

            msg.Time = Time.Ticks + 4000;

            TextRenderer.AddMessage(msg);
        }
Beispiel #9
0
        public override bool Draw(Batcher2D batcher, Vector3 position, MouseOverList objectList)
        {
            if (!AllowedToDraw || GameObject.IsDisposed)
            {
                return(false);
            }

            Texture.Ticks = Engine.Ticks;
            TextOverhead overhead = (TextOverhead)GameObject;

            HueVector = ShaderHuesTraslator.GetHueVector(0, false, overhead.Alpha, true);

            if (EdgeDetection)
            {
                GameScene gs = Engine.SceneManager.GetScene <GameScene>();

                int width  = Texture.Width - Bounds.X;
                int height = Texture.Height - Bounds.Y;

                if (position.X < Bounds.X)
                {
                    position.X = Bounds.X;
                }
                else if (position.X > Engine.Profile.Current.GameWindowSize.X * gs.Scale - width)
                {
                    position.X = Engine.Profile.Current.GameWindowSize.X * gs.Scale - width;
                }

                if (position.Y - Bounds.Y < 0)
                {
                    position.Y = Bounds.Y;
                }
                else if (position.Y > Engine.Profile.Current.GameWindowSize.Y * gs.Scale - height)
                {
                    position.Y = Engine.Profile.Current.GameWindowSize.Y * gs.Scale - height;
                }
            }

            bool ok = base.Draw(batcher, position, objectList);


            //if (_edge == null)
            //{
            //    _edge = new Texture2D(batcher.GraphicsDevice, 1, 1);
            //    _edge.SetData(new Color[] { Color.LightBlue });
            //}

            //batcher.DrawRectangle(_edge, new Rectangle((int) position.X - Bounds.X, (int) position.Y - Bounds.Y, _text.Width, _text.Height) , Vector3.Zero);

            return(ok);
        }
Beispiel #10
0
        public TextOverheadView(TextOverhead parent, int maxwidth = 0, ushort hue = 0xFFFF, byte font = 0, bool isunicode = false, FontStyle style = FontStyle.None) : base(parent)
        {
            RenderedText text = new RenderedText
            {
                MaxWidth  = maxwidth,
                Hue       = hue,
                Font      = font,
                IsUnicode = isunicode,
                FontStyle = style,
                Text      = parent.Text
            };

            Texture = text.Texture;
        }
Beispiel #11
0
        public TextOverheadView(TextOverhead parent, int maxwidth = 0, ushort hue = 0xFFFF, byte font = 0, bool isunicode = false, FontStyle style = FontStyle.None) : base(parent)
        {
            _text = new RenderedText
            {
                MaxWidth   = maxwidth,
                Hue        = hue,
                Font       = font,
                IsUnicode  = isunicode,
                FontStyle  = style,
                SaveHitMap = true,
                Text       = parent.Text
            };
            Texture = _text.Texture;

            //Bounds.X = (Texture.Width >> 1) - 22;
            //Bounds.Y = Texture.Height;
            //Bounds.Width = Texture.Width;
            //Bounds.Height = Texture.Height;

            if (Engine.Profile.Current.ScaleSpeechDelay)
            {
                int delay = Engine.Profile.Current.SpeechDelay;

                if (delay < 10)
                {
                    delay = 10;
                }

                if (parent.TimeToLive <= 0.0f)
                {
                    parent.TimeToLive = 4000 * _text.LinesCount * delay / 100.0f;
                }
            }
            else
            {
                long delay = ((5497558140000 * Engine.Profile.Current.SpeechDelay) >> 32) >> 5;

                if (parent.TimeToLive <= 0.0f)
                {
                    parent.TimeToLive = (delay >> 31) + delay;
                }
            }


            parent.Initialized = true;
            parent.Disposed   += ParentOnDisposed;
            EdgeDetection      = true;
        }
Beispiel #12
0
        public void Dispose()
        {
            foreach (var deque in _damageOverheads.Values)
            {
                foreach (DamageOverhead damageOverhead in deque)
                {
                    damageOverhead.Dispose();
                }
            }


            if (_toRemoveDamages.Count > 0)
            {
                _toRemoveDamages.ForEach(s =>
                {
                    _damageOverheads.Remove(s);
                });
                _toRemoveDamages.Clear();
            }


            //foreach (Tuple<TextOverhead, Vector3> tuple in _allOverheads)
            //{
            //    tuple.Item1.Dispose();
            //}

            //_allOverheads.Clear();

            GameObject last = _firstNode;

            while (last != null)
            {
                GameObject temp = last.Right;

                last.Dispose();

                last.Left  = null;
                last.Right = null;

                last = temp;
            }

            _firstNode = null;

            _staticToUpdate.ForEach(s => s.Dispose());
            _staticToUpdate.Clear();
        }
        public override bool Draw(SpriteBatch3D spriteBatch, Vector3 position, MouseOverList objectList)
        {
            if (!AllowedToDraw || GameObject.IsDisposed)
            {
                return(false);
            }

            Texture.Ticks = CoreGame.Ticks;
            TextOverhead overhead = (TextOverhead)GameObject;

            if (overhead.Alpha < 1.0f)
            {
                HueVector = ShaderHuesTraslator.GetHueVector(0, false, overhead.Alpha, true);
            }

            Settings  settings = Service.Get <Settings>();
            GameScene gs       = SceneManager.GetScene <GameScene>();

            int width  = Texture.Width - Bounds.X;
            int height = Texture.Height - Bounds.Y;

            if (position.X < Bounds.X)
            {
                position.X = Bounds.X;
            }
            else if (position.X > settings.GameWindowWidth * gs.Scale - width)
            {
                position.X = settings.GameWindowWidth * gs.Scale - width;
            }

            if (position.Y - Bounds.Y < 0)
            {
                position.Y = Bounds.Y;
            }
            else if (position.Y > settings.GameWindowHeight * gs.Scale - height)
            {
                position.Y = settings.GameWindowHeight * gs.Scale - height;
            }

            //FrameInfo.X = (int) position.X;
            //FrameInfo.Y = (int) position.Y;
            //FrameInfo.Width = Texture.Width;
            //FrameInfo.Height = Texture.Height;

            return(base.Draw(spriteBatch, position, objectList));
        }
Beispiel #14
0
        private void ItemOnOverheadAdded(object sender, EventArgs e)
        {
            LabelContainer container = Engine.UI.GetByLocalSerial <LabelContainer>(Item);

            if (container == null)
            {
                container = new LabelContainer(Item);
                Engine.UI.Add(container);
            }

            TextOverhead overhead = (TextOverhead)sender;

            overhead.TimeToLive = 4000;

            FadeOutLabel label = new FadeOutLabel(overhead.Text, overhead.IsUnicode, overhead.Hue, overhead.TimeToLive, overhead.MaxWidth, overhead.Font, overhead.Style, TEXT_ALIGN_TYPE.TS_CENTER);

            container.Add(label);
        }
        public virtual void Draw(UltimaBatcher2D batcher, int startX, int startY, int renderIndex, bool isGump = false)
        {
            ProcessWorldText(false);

            int mouseX = Mouse.Position.X;
            int mouseY = Mouse.Position.Y;

            TextOverhead last = null;

            for (var o = _drawPointer; o != null; o = o.DLeft)
            {
                if (o.RenderedText == null || o.RenderedText.IsDestroyed || o.RenderedText.Texture == null || o.Time < Time.Ticks || (o.Owner.UseInRender != renderIndex && !isGump))
                {
                    continue;
                }

                ushort hue = 0;

                float alpha = 1f - o.Alpha / 255f;

                if (o.IsTransparent)
                {
                    if (o.Alpha == 0xFF)
                    {
                        alpha = 1f - 0x7F / 255f;
                    }
                }

                if (o.RenderedText.Texture.Contains(mouseX - startX - o.RealScreenPosition.X, mouseY - startY - o.RealScreenPosition.Y))
                {
                    SelectedObject.Object = o;
                    last = o;

                    if (!isGump && o.Owner is Entity)
                    {
                        hue = 0x0035;
                    }
                }

                o.RenderedText.Draw(batcher, startX + o.RealScreenPosition.X, startY + o.RealScreenPosition.Y, alpha, hue);
            }

            MoveToTop(last);
        }
        public TextOverheadView(TextOverhead parent, int maxwidth = 0, ushort hue = 0xFFFF, byte font = 0, bool isunicode = false, FontStyle style = FontStyle.None) : base(parent)
        {
            _text = new RenderedText
            {
                MaxWidth  = maxwidth,
                Hue       = hue,
                Font      = font,
                IsUnicode = isunicode,
                FontStyle = style,
                Text      = parent.Text
            };
            Texture = _text.Texture;

            if (parent.TimeToLive <= 0.0f)
            {
                parent.TimeToLive = (((4000 * _text.LinesCount) * Service.Get <Settings>().SpeechDelay) / 100);
            }

            parent.Initialized = true;
        }
        public override bool Draw(SpriteBatch3D spriteBatch, Vector3 position, MouseOverList objectList)
        {
            if (!AllowedToDraw || GameObject.IsDisposed)
            {
                _text?.Dispose();
                _text = null;
                return(false);
            }

            Texture.Ticks = CoreGame.Ticks;
            TextOverhead overhead = (TextOverhead)GameObject;

            if (!overhead.IsPersistent && overhead.Alpha < 1.0f)
            {
                HueVector = RenderExtentions.GetHueVector(0, false, overhead.Alpha, true);
            }
            Settings settings = Service.Get <Settings>();
            int      width    = Texture.Width - Bounds.X;
            int      height   = Texture.Height - Bounds.Y;

            if (position.X < Bounds.X)
            {
                position.X = Bounds.X;
            }
            else if (position.X > settings.GameWindowWidth - width)
            {
                position.X = settings.GameWindowWidth - width;
            }

            if (position.Y - Bounds.Y < 0)
            {
                position.Y = Bounds.Y;
            }
            else if (position.Y > settings.GameWindowHeight - height)
            {
                position.Y = settings.GameWindowHeight - height;
            }

            return(base.Draw(spriteBatch, position, objectList));
        }
Beispiel #18
0
        private bool Collides(TextOverhead msg)
        {
            bool result = false;

            Rectangle rect = new Rectangle()
            {
                X      = msg.RealScreenPosition.X,
                Y      = msg.RealScreenPosition.Y,
                Width  = msg.RenderedText.Width,
                Height = msg.RenderedText.Height
            };

            for (int i = 0; i < _bounds.Count; i++)
            {
                if (_bounds[i].Intersects(rect))
                {
                    result = true;
                    break;
                }
            }

            _bounds.Add(rect);
            return(result);
        }
Beispiel #19
0
        private void DrawTextOverheads(Batcher2D batcher, MouseOverList list)
        {
            if (_firstNode != null)
            {
                int skip = 0;

                for (TextOverhead overhead = _firstNode; overhead != null; overhead = (TextOverhead)overhead.Right)
                {
                    GameObject owner = overhead.Parent;

                    if (overhead.IsDisposed || owner.IsDisposed)
                    {
                        continue;
                    }

                    Vector3 position = owner.RealScreenPosition;

                    if (owner is Mobile m)
                    {
                        GetAnimationDimensions(m, 0xFF, out int height, out int centerY);

                        position = new Vector3
                        {
                            X = position.X + m.Offset.X,
                            Y = position.Y + (m.Offset.Y - m.Offset.Z) - (height + centerY + 8),
                            Z = position.Z
                        };
                    }
                    //else if (owner is Static st)
                    //    position.Y -= st.ItemData.Height /*((ArtTexture)st.View.Texture).ImageRectangle.Height / 2*/;

                    View      v       = overhead.View;
                    Rectangle current = new Rectangle((int)position.X - v.Bounds.X, (int)position.Y - v.Bounds.Y, v.Bounds.Width, v.Bounds.Height);

                    if (skip == 0)
                    {
                        for (TextOverhead ov = (TextOverhead)overhead.Right; ov != null; ov = (TextOverhead)ov.Right)
                        {
                            View    b    = ov.View;
                            Vector3 pos2 = ov.Parent.RealScreenPosition;

                            if (ov.Parent is Mobile mm)
                            {
                                GetAnimationDimensions(mm, 0xFF, out int height, out int centerY);

                                pos2 = new Vector3
                                {
                                    X = pos2.X + mm.Offset.X,
                                    Y = pos2.Y + (mm.Offset.Y - mm.Offset.Z) - (height + centerY + 8),
                                    Z = pos2.Z
                                };
                            }

                            Rectangle next = new Rectangle((int)pos2.X - b.Bounds.X, (int)pos2.Y - b.Bounds.Y, b.Bounds.Width, b.Bounds.Height);

                            overhead.IsOverlapped = current.Intersects(next);

                            if (overhead.IsOverlapped)
                            {
                                bool startSkip = false;
                                foreach (TextOverhead parentOverhead in owner.Overheads)
                                {
                                    parentOverhead.IsOverlapped = true;

                                    if (parentOverhead == overhead)
                                    {
                                        startSkip = true;
                                    }
                                    else if (startSkip)
                                    {
                                        skip++;
                                    }
                                }

                                break;
                            }
                        }
                    }
                    else
                    {
                        skip--;
                    }

                    v.Draw(batcher, position, list);
                }

                GameObject last = _firstNode;

                while (last != null)
                {
                    GameObject temp = last.Right;

                    last.Left  = null;
                    last.Right = null;

                    last = temp;
                }

                _firstNode = null;
            }
        }
Beispiel #20
0
        public static void HandleMessage(Entity parent, string text, string name, ushort hue, MessageType type, byte font, bool unicode = false, string lang = null)
        {
            if (ProfileManager.Current != null && ProfileManager.Current.OverrideAllFonts)
            {
                font    = ProfileManager.Current.ChatFont;
                unicode = ProfileManager.Current.OverrideAllFontsIsUnicode;
            }

            switch (type)
            {
            case MessageType.Spell:

            {
                //server hue color per default
                if (!string.IsNullOrEmpty(text) && SpellDefinition.WordToTargettype.TryGetValue(text, out SpellDefinition spell))
                {
                    if (ProfileManager.Current != null && ProfileManager.Current.EnabledSpellFormat && !string.IsNullOrWhiteSpace(ProfileManager.Current.SpellDisplayFormat))
                    {
                        StringBuilder sb = new StringBuilder(ProfileManager.Current.SpellDisplayFormat);
                        sb.Replace("{power}", spell.PowerWords);
                        sb.Replace("{spell}", spell.Name);
                        text = sb.ToString().Trim();
                    }

                    //server hue color per default if not enabled
                    if (ProfileManager.Current != null && ProfileManager.Current.EnabledSpellHue)
                    {
                        if (spell.TargetType == TargetType.Beneficial)
                        {
                            hue = ProfileManager.Current.BeneficHue;
                        }
                        else if (spell.TargetType == TargetType.Harmful)
                        {
                            hue = ProfileManager.Current.HarmfulHue;
                        }
                        else
                        {
                            hue = ProfileManager.Current.NeutralHue;
                        }
                    }
                }

                goto case MessageType.Label;
            }

            case MessageType.Focus:
            case MessageType.Whisper:
            case MessageType.Yell:
            case MessageType.Regular:
            case MessageType.Label:
            case MessageType.Limit3Spell:

                if (parent == null)
                {
                    break;
                }

                TextOverhead msg = CreateMessage(text, hue, font, unicode, type);
                msg.Owner = parent;

                if (parent is Item it && !it.OnGround)
                {
                    msg.X = Mouse.LastClickPosition.X;
                    msg.Y = Mouse.LastClickPosition.Y;

                    bool found = false;

                    for (var gump = UIManager.Gumps.Last; gump != null; gump = gump.Previous)
                    {
                        var g = gump.Value;

                        if (!g.IsDisposed)
                        {
                            switch (g)
                            {
                            case PaperDollGump paperDoll when g.LocalSerial == it.Container:
                                msg.X -= paperDoll.ScreenCoordinateX;
                                msg.Y -= paperDoll.ScreenCoordinateY;
                                paperDoll.AddText(msg);
                                found = true;
                                break;

                            case ContainerGump container when g.LocalSerial == it.Container:
                                msg.X -= container.ScreenCoordinateX;
                                msg.Y -= container.ScreenCoordinateY;
                                container.AddText(msg);
                                found = true;
                                break;

                            case TradingGump trade when g.LocalSerial == it.Container || trade.ID1 == it.Container || trade.ID2 == it.Container:
                                msg.X -= trade.ScreenCoordinateX;
                                msg.Y -= trade.ScreenCoordinateY;
                                trade.AddText(msg);
                                found = true;
                                break;
                            }
                        }

                        if (found)
                        {
                            break;
                        }
                    }
                }

                parent.AddMessage(msg);

                break;


            case MessageType.Command:
            case MessageType.Encoded:
            case MessageType.System:
            case MessageType.Party:
            case MessageType.Guild:
            case MessageType.Alliance:

                break;

            default:
                if (parent == null)
                {
                    break;
                }

                msg = CreateMessage(text, hue, font, unicode, type);

                parent.AddMessage(msg);

                break;
            }

            MessageReceived.Raise(new UOMessageEventArgs(parent, text, name, hue, type, font, unicode, lang), parent);
        }
Beispiel #21
0
        private void DrawTextOverheads(Batcher2D batcher, MouseOverList list)
        {
            if (_firstNode != null)
            {
                //for (int i = 0; i < _allOverheads.Count; i++)

                for (TextOverhead overhead = _firstNode; overhead != null; overhead = (TextOverhead)overhead.Right)
                {
                    // TextOverhead overhead = _allOverheads[i].Item1;
                    GameObject owner = overhead.Parent;

                    if (overhead.IsDisposed || owner.IsDisposed)
                    {
                        //_allOverheads.RemoveAt(i--);
                        continue;
                    }


                    Vector3 position = owner.RealScreenPosition; // _allOverheads[i].Item2;

                    if (owner is Mobile m)
                    {
                        GetAnimationDimensions(m, 0xFF, out int height, out int centerY);

                        position = new Vector3
                        {
                            X = position.X + m.Offset.X,
                            Y = position.Y + (m.Offset.Y - m.Offset.Z) - (height + centerY + 8),
                            Z = position.Z
                        };
                    }
                    //else if (owner is Static st)
                    //    position.Y -= st.ItemData.Height /*((ArtTexture)st.View.Texture).ImageRectangle.Height / 2*/;

                    View      v       = overhead.View;
                    Rectangle current = new Rectangle((int)position.X - v.Bounds.X, (int)position.Y - v.Bounds.Y, v.Bounds.Width, v.Bounds.Height);

                    for (TextOverhead ov = (TextOverhead)overhead.Right; ov != null; ov = (TextOverhead)ov.Right)
                    //for (int j = i + 1; j < _allOverheads.Count; j++)
                    {
                        //var a = _allOverheads[j];
                        //TextOverhead ov = a.Item1;
                        View    b    = ov.View;
                        Vector3 pos2 = ov.RealScreenPosition; // a.Item2;

                        if (ov.Parent is Mobile mm)
                        {
                            GetAnimationDimensions(mm, 0xFF, out int height, out int centerY);

                            pos2 = new Vector3
                            {
                                X = pos2.X + mm.Offset.X,
                                Y = pos2.Y + (mm.Offset.Y - mm.Offset.Z) - (height + centerY + 8),
                                Z = pos2.Z
                            };
                        }

                        Rectangle next = new Rectangle((int)pos2.X - b.Bounds.X, (int)pos2.Y - b.Bounds.Y, b.Bounds.Width, b.Bounds.Height);

                        if (overhead.IsOverlapped = current.Intersects(next))
                        {
                            break;
                        }
                    }

                    v.Draw(batcher, position, list);
                }

                //_allOverheads.Clear();

                GameObject last = _firstNode;

                while (last != null)
                {
                    GameObject temp = last.Right;

                    last.Left  = null;
                    last.Right = null;

                    last = temp;
                }

                _firstNode = null;
            }
        }
Beispiel #22
0
        private void AddTileToRenderList(GameObject obj, int worldX, int worldY, bool useObjectHandles, int maxZ)
        {
            for (; obj != null; obj = obj.Right)
            {
                if (obj.CurrentRenderIndex == _renderIndex || obj.IsDisposed)
                {
                    continue;
                }

                if (_updateDrawPosition && obj.CurrentRenderIndex != _renderIndex || obj.IsPositionChanged)
                {
                    obj.UpdateRealScreenPosition(_offset);
                }

                //obj.UseInRender = 0xFF;

                float drawX = obj.RealScreenPosition.X;
                float drawY = obj.RealScreenPosition.Y;

                if (drawX < _minPixel.X || drawX > _maxPixel.X)
                {
                    break;
                }

                int z          = obj.Z;
                int maxObjectZ = obj.PriorityZ;

                bool mounted  = false;
                bool ismobile = false;

                StaticTiles itemData     = default;
                bool        changinAlpha = false;

                switch (obj)
                {
                case Mobile mob:
                    maxObjectZ += Constants.DEFAULT_CHARACTER_HEIGHT;
                    ismobile    = true;
                    mounted     = mob.IsMounted;
                    break;

                default:

                    if (GameObjectHelper.TryGetStaticData(obj, out itemData))
                    {
                        if (obj is Static st)
                        {
                            if (StaticFilters.IsCave(st.OriginalGraphic))
                            {
                                if (Engine.Profile.Current.EnableCaveBorder && !st.IsBordered())
                                {
                                    st.SetBorder(true);
                                }
                                else if (!Engine.Profile.Current.EnableCaveBorder && st.IsBordered())
                                {
                                    st.SetBorder(false);
                                }
                            }
                            else if (StaticFilters.IsTree(st.OriginalGraphic))
                            {
                                if (Engine.Profile.Current.TreeToStumps && st.Graphic != Constants.TREE_REPLACE_GRAPHIC)
                                {
                                    st.SetGraphic(Constants.TREE_REPLACE_GRAPHIC);
                                }
                                else if (st.OriginalGraphic != st.Graphic && !Engine.Profile.Current.TreeToStumps)
                                {
                                    st.RestoreOriginalGraphic();
                                }
                            }
                        }

                        if (_noDrawRoofs && itemData.IsRoof)
                        {
                            if (_alphaChanged)
                            {
                                changinAlpha = obj.ProcessAlpha(0);
                            }
                            else
                            {
                                changinAlpha = obj.AlphaHue != 0;
                            }


                            if (!changinAlpha)
                            {
                                continue;
                            }
                        }

                        if ((Engine.Profile.Current.TreeToStumps && itemData.IsFoliage) || (Engine.Profile.Current.HideVegetation && StaticFilters.IsVegetation(obj.Graphic)))
                        {
                            continue;
                        }

                        maxObjectZ += itemData.Height;
                    }
                    break;
                }

                if (maxObjectZ > maxZ)
                {
                    break;
                }

                obj.CurrentRenderIndex = _renderIndex;

                bool iscorpse = !ismobile && obj is Item item && item.IsCorpse;

                if (!ismobile && !iscorpse && itemData.IsInternal)
                {
                    continue;
                }

                bool island = !ismobile && !iscorpse && obj is Land;

                if (!island && z >= _maxZ)
                {
                    if (!changinAlpha)
                    {
                        if (_alphaChanged)
                        {
                            changinAlpha = obj.ProcessAlpha(0);
                        }
                        else
                        {
                            changinAlpha = obj.AlphaHue != 0;
                        }

                        if (!changinAlpha)
                        {
                            continue;
                        }
                    }
                }

                int testMinZ = (int)drawY + z * 4;
                int testMaxZ = (int)drawY;

                if (island)
                {
                    Land t = obj as Land;
                    if (t.IsStretched)
                    {
                        testMinZ -= t.MinZ * 4;
                    }
                    else
                    {
                        testMinZ = testMaxZ;
                    }
                }
                else
                {
                    testMinZ = testMaxZ;
                }

                if (testMinZ < _minPixel.Y || testMaxZ > _maxPixel.Y)
                {
                    continue;
                }


                if (obj.Overheads != null && obj.Overheads.Count != 0)
                {
                    int offY;

                    if (ismobile && !mounted || iscorpse)
                    {
                        offY = -22;
                    }
                    else
                    {
                        switch (obj)
                        {
                        case Multi _:
                        case Static _: offY = -44;

                            break;
                        //case Item _:
                        //    offY = 44;

                        //break;
                        default: offY = 0;

                            break;
                        }
                    }

                    for (int i = 0; i < obj.Overheads.Count; i++)
                    {
                        TextOverhead v = obj.Overheads[i];
                        v.Bounds.X      = (v.Texture.Width >> 1) - 22;
                        v.Bounds.Y      = offY + v.Texture.Height;
                        v.Bounds.Width  = v.Texture.Width;
                        v.Bounds.Height = v.Texture.Height;
                        Overheads.AddOverhead(v);
                        offY += v.Texture.Height;

                        if (_alphaChanged)
                        {
                            if (v.TimeToLive > 0 && v.TimeToLive <= Constants.TIME_FADEOUT_TEXT)
                            {
                                if (!v.IsOverlapped)
                                {
                                    v.ProcessAlpha(0);
                                }
                            }
                            else if (!v.IsOverlapped && v.AlphaHue != 0xFF)
                            {
                                v.ProcessAlpha(0xFF);
                            }
                        }
                    }
                }


                if (ismobile || iscorpse)
                {
                    AddOffsetCharacterTileToRenderList(obj, useObjectHandles);
                }
                else if (itemData.IsFoliage)
                {
                    if (obj is Static st)
                    {
                        bool check = World.Player.X <= worldX && World.Player.Y <= worldY;

                        if (!check)
                        {
                            check = World.Player.Y <= worldY && World.Player.Position.X <= worldX + 1;

                            if (!check)
                            {
                                check = World.Player.X <= worldX && World.Player.Y <= worldY + 1;
                            }
                        }

                        if (check)
                        {
                            Rectangle rect = new Rectangle((int)drawX - st.FrameInfo.X,
                                                           (int)drawY - st.FrameInfo.Y,
                                                           st.FrameInfo.Width,
                                                           st.FrameInfo.Height);


                            check = rect.InRect(World.Player.GetOnScreenRectangle());
                        }

                        st.CharacterIsBehindFoliage = check;
                    }
                    else if (obj is Multi m)
                    {
                        bool check = World.Player.X <= worldX && World.Player.Y <= worldY;

                        if (!check)
                        {
                            check = World.Player.Y <= worldY && World.Player.Position.X <= worldX + 1;

                            if (!check)
                            {
                                check = World.Player.X <= worldX && World.Player.Y <= worldY + 1;
                            }
                        }

                        if (check)
                        {
                            Rectangle rect = new Rectangle((int)drawX - m.FrameInfo.X,
                                                           (int)drawY - m.FrameInfo.Y,
                                                           m.FrameInfo.Width,
                                                           m.FrameInfo.Height);


                            check = rect.InRect(World.Player.GetOnScreenRectangle());
                        }

                        m.CharacterIsBehindFoliage = check;
                    }
                }

                if (_alphaChanged && !changinAlpha)
                {
                    if (itemData.IsTranslucent)
                    {
                        obj.ProcessAlpha(178);
                    }
                    else if (!itemData.IsFoliage && obj.AlphaHue != 0xFF)
                    {
                        obj.ProcessAlpha(0xFF);
                    }
                }

                if (_renderListCount >= _renderList.Length)
                {
                    int newsize = _renderList.Length + 1000;
                    Array.Resize(ref _renderList, newsize);
                }

                if (useObjectHandles)
                {
                    obj.UseObjectHandles = (ismobile || iscorpse || obj is Item it && !it.IsLocked && !it.IsMulti) && !obj.ClosedObjectHandles;
                    _objectHandlesCount++;
                }
                else if (obj.ClosedObjectHandles)
                {
                    obj.ClosedObjectHandles = false;
                    obj.ObjectHandlesOpened = false;
                }
                else if (obj.UseObjectHandles)
                {
                    obj.ObjectHandlesOpened = false;
                    obj.UseObjectHandles    = false;
                }


                _renderList[_renderListCount] = obj;
                //obj.UseInRender = (byte) _renderIndex;
                _renderListCount++;
            }
        }
Beispiel #23
0
 public virtual void Clear()
 {
     _firstNode   = new TextOverhead();
     _drawPointer = null;
 }
Beispiel #24
0
        public virtual void Draw(UltimaBatcher2D batcher, int startX, int startY, int renderIndex, bool isGump = false)
        {
            ProcessWorldText(false);

            int mouseX = Mouse.Position.X;
            int mouseY = Mouse.Position.Y;

            TextOverhead last = null;

            for (var o = _drawPointer; o != null; o = o.Left)
            {
                if (o.RenderedText == null || o.RenderedText.IsDestroyed || o.RenderedText.Texture == null || o.Time < Time.Ticks || (o.Owner.UseInRender != renderIndex && !isGump))
                {
                    continue;
                }

                ushort hue = 0;

                float alpha = 1f - o.Alpha / 255f;

                if (o.IsTransparent)
                {
                    if (o.Alpha == 0xFF)
                    {
                        alpha = 1f - 0x7F / 255f;
                    }
                }

                if (o.RenderedText.Texture.Contains(mouseX - startX - o.RealScreenPosition.X, mouseY - startY - o.RealScreenPosition.Y))
                {
                    SelectedObject.Object = o;
                    last = o;
                }

                if (!isGump && SelectedObject.LastObject == o)
                {
                    hue = 0x35;
                }

                o.RenderedText.Draw(batcher, startX + o.RealScreenPosition.X, startY + o.RealScreenPosition.Y, alpha, hue);
            }

            if (last != null)
            {
                if (last.Right != null)
                {
                    last.Right.Left = last.Left;
                }

                if (last.Left != null)
                {
                    last.Left.Right = last.Right;
                }

                last.Left = last.Right = null;


                var next = _firstNode.Right;
                _firstNode.Right = last;
                last.Left        = _firstNode;
                last.Right       = next;

                if (next != null)
                {
                    next.Left = last;
                }
            }
        }
Beispiel #25
0
        public static void HandleMessage(Entity parent, string text, string name, ushort hue, MessageType type, byte font, bool unicode = false, string lang = null)
        {
            if (ProfileManager.Current != null && ProfileManager.Current.OverrideAllFonts)
            {
                font    = ProfileManager.Current.ChatFont;
                unicode = ProfileManager.Current.OverrideAllFontsIsUnicode;
            }

            switch (type)
            {
            case MessageType.Spell:

            {
                //server hue color per default
                if (!string.IsNullOrEmpty(text) && SpellDefinition.WordToTargettype.TryGetValue(text, out SpellDefinition spell))
                {
                    if (ProfileManager.Current != null && ProfileManager.Current.EnabledSpellFormat && !string.IsNullOrWhiteSpace(ProfileManager.Current.SpellDisplayFormat))
                    {
                        StringBuilder sb = new StringBuilder(ProfileManager.Current.SpellDisplayFormat);
                        sb.Replace("{power}", spell.PowerWords);
                        sb.Replace("{spell}", spell.Name);
                        text = sb.ToString().Trim();
                    }

                    //server hue color per default if not enabled
                    if (ProfileManager.Current != null && ProfileManager.Current.EnabledSpellHue)
                    {
                        if (spell.TargetType == TargetType.Beneficial)
                        {
                            hue = ProfileManager.Current.BeneficHue;
                        }
                        else if (spell.TargetType == TargetType.Harmful)
                        {
                            hue = ProfileManager.Current.HarmfulHue;
                        }
                        else
                        {
                            hue = ProfileManager.Current.NeutralHue;
                        }
                    }
                }

                goto case MessageType.Label;
            }

            case MessageType.Focus:
            case MessageType.Whisper:
            case MessageType.Yell:
            case MessageType.Regular:
            case MessageType.Label:

                if (parent == null)
                {
                    break;
                }

                TextOverhead msg = CreateMessage(text, hue, font, unicode, type);
                msg.Owner = parent;

                if (parent is Item it && !it.OnGround)
                {
                    msg.X = Mouse.LastClickPosition.X;
                    msg.Y = Mouse.LastClickPosition.Y;

                    Gump gump = UIManager.GetGump <Gump>(it.Container);

                    if (gump is PaperDollGump paperDoll)
                    {
                        msg.X -= paperDoll.ScreenCoordinateX;
                        msg.Y -= paperDoll.ScreenCoordinateY;
                        paperDoll.AddText(msg);
                    }
                    else if (gump is ContainerGump container)
                    {
                        msg.X -= container.ScreenCoordinateX;
                        msg.Y -= container.ScreenCoordinateY;
                        container.AddText(msg);
                    }
                    else
                    {
                        Entity ent = World.Get(it.RootContainer);

                        if (ent == null || ent.IsDestroyed)
                        {
                            break;
                        }

                        var trade = UIManager.GetGump <TradingGump>(ent);

                        if (trade == null)
                        {
                            Item item = ent.Items.FirstOrDefault(s => s.Graphic == 0x1E5E);

                            if (item == null)
                            {
                                break;
                            }

                            trade = UIManager.Gumps.OfType <TradingGump>().FirstOrDefault(s => s.ID1 == item || s.ID2 == item);
                        }

                        if (trade != null)
                        {
                            msg.X -= trade.ScreenCoordinateX;
                            msg.Y -= trade.ScreenCoordinateY;
                            trade.AddText(msg);
                        }
                        else
                        {
                            Log.Warn("Missing label handler for this control: 'UNKNOWN'. Report it!!");
                        }
                    }
                }

                parent.AddMessage(msg);

                break;

            case MessageType.Emote:
                if (parent == null)
                {
                    break;
                }

                msg = CreateMessage($"*{text}*", hue, font, unicode, type);

                parent.AddMessage(msg);

                break;

            case MessageType.Command:

            case MessageType.Encoded:
            case MessageType.System:
            case MessageType.Party:
            case MessageType.Guild:
            case MessageType.Alliance:

                break;

            default:
                if (parent == null)
                {
                    break;
                }

                msg = CreateMessage(text, hue, font, unicode, type);

                parent.AddMessage(msg);

                break;
            }

            MessageReceived.Raise(new UOMessageEventArgs(parent, text, name, hue, type, font, unicode, lang), parent);
        }
Beispiel #26
0
        private void DrawTextOverheads(Batcher2D batcher, MouseOverList list)
        {
            if (_firstNode != null)
            {
                int skip = 0;

                for (TextOverhead overhead = _firstNode; overhead != null; overhead = (TextOverhead)overhead.Right)
                {
                    GameObject owner = overhead.Parent;

                    if (owner == null || overhead.IsDisposed || owner.IsDisposed)
                    {
                        continue;
                    }

                    Vector3 position = owner.RealScreenPosition;

                    if (owner is Mobile m)
                    {
                        GetAnimationDimensions(m, 0xFF, out int centerX, out int centerY, out int width, out int height);

                        position.X = position.X + m.Offset.X;
                        position.Y = position.Y + (m.Offset.Y - m.Offset.Z) - (height + centerY + 8);
                    }
                    else if (owner.Texture != null)
                    {
                        position.Y -= owner.Texture.Height / 2;
                    }


                    Rectangle current = new Rectangle((int)position.X - overhead.Bounds.X, (int)position.Y - overhead.Bounds.Y, overhead.Bounds.Width, overhead.Bounds.Height);

                    if (skip == 0)
                    {
                        for (TextOverhead ov = (TextOverhead)overhead.Right; ov != null; ov = (TextOverhead)ov.Right)
                        {
                            Vector3 pos2 = ov.Parent.RealScreenPosition;

                            if (ov.Parent is Mobile mm)
                            {
                                GetAnimationDimensions(mm, 0xFF, out int centerX, out int centerY, out int width, out int height);

                                pos2.X = pos2.X + mm.Offset.X;
                                pos2.Y = pos2.Y + (mm.Offset.Y - mm.Offset.Z) - (height + centerY + 8);
                            }
                            else if (ov.Parent.Texture != null)
                            {
                                pos2.Y -= ov.Parent.Texture.Height / 2;
                            }

                            Rectangle next = new Rectangle((int)pos2.X - ov.Bounds.X, (int)pos2.Y - ov.Bounds.Y, ov.Bounds.Width, ov.Bounds.Height);

                            overhead.IsOverlapped = current.Intersects(next);

                            if (overhead.IsOverlapped)
                            {
                                bool startSkip = false;
                                foreach (TextOverhead parentOverhead in owner.Overheads)
                                {
                                    parentOverhead.IsOverlapped = true;

                                    if (parentOverhead == overhead)
                                    {
                                        startSkip = true;
                                    }
                                    else if (startSkip)
                                    {
                                        skip++;
                                    }
                                }

                                break;
                            }
                        }
                    }
                    else
                    {
                        skip--;
                    }


                    overhead.Draw(batcher, position, list);
                }


                GameObject last = _firstNode;

                while (last != null)
                {
                    GameObject temp = last.Right;

                    last.Left  = null;
                    last.Right = null;

                    last = temp;
                }

                _firstNode.Left = _firstNode.Right = null;
                _firstNode      = null;
            }
        }