Пример #1
0
 public bool Equals(Hue other)
 {
     return(_value == other._value);
 }
Пример #2
0
        public static void HandleMessage(Entity parent, string text, string name, Hue hue, MessageType type, MessageFont font, bool unicode = false, string lang = null)
        {
            switch (type)
            {
            case MessageType.Focus:
            case MessageType.Whisper:
            case MessageType.Yell:
            case MessageType.Spell:
            case MessageType.Regular:
            case MessageType.Label:

                if (parent == null)
                {
                    break;
                }

                if (parent is Item it && !it.OnGround)
                {
                    Gump gump = Engine.UI.GetByLocalSerial <Gump>(it.Container);

                    if (gump is PaperDollGump paperDoll)
                    {
                        var inter = paperDoll
                                    .FindControls <PaperDollInteractable>()
                                    .FirstOrDefault();

                        var f = inter?.FindControls <ItemGump>()
                                .SingleOrDefault(s => s.Item == it);

                        if (f != null)
                        {
                            f.AddLabel(text, hue, (byte)font, unicode);
                        }
                        else
                        {
                            paperDoll.FindControls <EquipmentSlot>()?
                            .SelectMany(s => s.Children)
                            .OfType <ItemGump>()
                            .SingleOrDefault(s => s.Item == it)?
                            .AddLabel(text, hue, (byte)font, unicode);
                        }
                    }
                    else if (gump is ContainerGump container)
                    {
                        container
                        .FindControls <ItemGump>()?
                        .SingleOrDefault(s => s.Item == it)?
                        .AddLabel(text, hue, (byte)font, unicode);
                    }
                    else
                    {
                        Entity ent = World.Get(it.RootContainer);

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

                        gump = Engine.UI.GetByLocalSerial <TradingGump>(ent);
                        if (gump != null)
                        {
                            gump.FindControls <DataBox>()?
                            .SelectMany(s => s.Children)
                            .OfType <ItemGump>()
                            .SingleOrDefault(s => s.Item == it)?
                            .AddLabel(text, hue, (byte)font, unicode);
                        }
                        else
                        {
                            Item item = ent.Items.FirstOrDefault(s => s.Graphic == 0x1E5E);

                            if (item == null)
                            {
                                break;
                            }

                            gump = Engine.UI.Gumps.OfType <TradingGump>().FirstOrDefault(s => s.ID1 == item || s.ID2 == item);

                            if (gump != null)
                            {
                                gump.FindControls <DataBox>()?
                                .SelectMany(s => s.Children)
                                .OfType <ItemGump>()
                                .SingleOrDefault(s => s.Item == it)?
                                .AddLabel(text, hue, (byte)font, unicode);
                            }
                            else
                            {
                                Log.Message(LogTypes.Warning, "Missing label handler for this control: 'UNKNOWN'. Report it!!");
                            }
                        }
                    }
                }
                else
                {
                    parent.AddOverhead(type, text, (byte)font, hue, unicode);
                }
                break;
Пример #3
0
        public static void HandleMessage(Entity parent, string text, string name, Hue hue, MessageType type, byte font, bool unicode = false, string lang = null)
        {
            switch (type)
            {
            case MessageType.Spell:

            {
                //server hue color per default
                if (!string.IsNullOrEmpty(text) && SpellDefinition.WordToTargettype.TryGetValue(text, out SpellDefinition spell))
                {
                    if (Engine.Profile.Current.EnabledSpellFormat && !string.IsNullOrWhiteSpace(Engine.Profile.Current.SpellDisplayFormat))
                    {
                        StringBuilder sb = new StringBuilder(Engine.Profile.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 (Engine.Profile.Current.EnabledSpellHue)
                    {
                        if (spell.TargetType == TargetType.Beneficial)
                        {
                            hue = Engine.Profile.Current.BeneficHue;
                        }
                        else if (spell.TargetType == TargetType.Harmful)
                        {
                            hue = Engine.Profile.Current.HarmfulHue;
                        }
                        else
                        {
                            hue = Engine.Profile.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;
                }

                if (parent is Item it && !it.OnGround)
                {
                    Gump gump = Engine.UI.GetControl <Gump>(it.Container);

                    if (gump is PaperDollGump paperDoll)
                    {
                        paperDoll.AddLabel(text, hue, font, unicode);
                    }
                    else if (gump is ContainerGump container)
                    {
                        container.AddLabel(text, hue, font, unicode);
                    }
                    else
                    {
                        Entity ent = World.Get(it.RootContainer);

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

                        var trade = Engine.UI.GetControl <TradingGump>(ent);

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

                            if (item == null)
                            {
                                break;
                            }

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

                        if (trade != null)
                        {
                            trade.AddLabel(text, hue, font, unicode);
                        }
                        else
                        {
                            Log.Message(LogTypes.Warning, "Missing label handler for this control: 'UNKNOWN'. Report it!!");
                        }
                    }
                }
                else
                {
                    parent.AddOverhead(type, text, font, hue, unicode);
                }

                break;
Пример #4
0
        public static void HandleMessage(Entity parent, string text, string name, Hue hue, MessageType type, byte font, bool unicode = false, string lang = null)
        {
            if (Engine.Profile.Current != null && Engine.Profile.Current.OverrideAllFonts)
            {
                font    = Engine.Profile.Current.ChatFont;
                unicode = Engine.Profile.Current.OverrideAllFontsIsUnicode;
            }

            switch (type)
            {
            case MessageType.Spell:

            {
                //server hue color per default
                if (!string.IsNullOrEmpty(text) && SpellDefinition.WordToTargettype.TryGetValue(text, out SpellDefinition spell))
                {
                    if (Engine.Profile.Current != null && Engine.Profile.Current.EnabledSpellFormat && !string.IsNullOrWhiteSpace(Engine.Profile.Current.SpellDisplayFormat))
                    {
                        StringBuilder sb = new StringBuilder(Engine.Profile.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 (Engine.Profile.Current != null && Engine.Profile.Current.EnabledSpellHue)
                    {
                        if (spell.TargetType == TargetType.Beneficial)
                        {
                            hue = Engine.Profile.Current.BeneficHue;
                        }
                        else if (spell.TargetType == TargetType.Harmful)
                        {
                            hue = Engine.Profile.Current.HarmfulHue;
                        }
                        else
                        {
                            hue = Engine.Profile.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;
                }

                MessageInfo 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 = Engine.UI.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 = Engine.UI.GetGump <TradingGump>(ent);

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

                            if (item == null)
                            {
                                break;
                            }

                            trade = Engine.UI.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.Message(LogTypes.Warning, "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);
        }
Пример #5
0
 public bool Equals(Hue hue)
 {
     return(_value == hue._value);
 }