ServUO Version
Publish 57
Ultima Expansion
Endless Journey
So just curious does anything have a better way of doing this?

C#:
        public override void GetContextMenuEntries(Mobile from, List<ContextMenuEntry> list)
        {
            if (from.Alive)
                list.Add(new AlaskanMalamute(this));
                list.Add(new Beetle(this));
                list.Add(new BlackRussianTerrier(this));
                list.Add(new Boura(this));
                list.Add(new ChargerOfTheFallen(this));
                list.Add(new Chimera(this));
                list.Add(new CuSidhe(this));
                list.Add(new DesertOstard(this));
                list.Add(new FrenziedOstard(this));
                list.Add(new GreatDane(this));
                list.Add(new Hiryu(this));
                list.Add(new Horse(this));
                list.Add(new Kirin(this));
                list.Add(new Lasher(this));
                list.Add(new Llama(this));
                list.Add(new Newfoundland(this));
                list.Add(new Ostard(this));
                list.Add(new PolarBear(this));
                list.Add(new Reptalon(this));
                list.Add(new Ridgeback(this));
                list.Add(new Rottweiler(this));
                list.Add(new SaintBernard(this));
                list.Add(new SeaHorse(this));
                list.Add(new SkeletalMount(this));
                list.Add(new SwampDragon(this));
                list.Add(new Tarantula(this));
                list.Add(new Tiger(this));
                list.Add(new Unicorn(this));
                list.Add(new WarBoar(this));
                list.Add(new Windrunner(this));
            base.GetContextMenuEntries(from, list);
        }

        private class AlaskanMalamute : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public AlaskanMalamute(InstantEthereal instantEthereal) : base(1159756, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.AlaskanMalamute;
            }
        }

        private class AncientHellHound : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public AncientHellHound(InstantEthereal instantEthereal) : base(1029622, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.AncientHellHound;
            }
        }

        private class Beetle : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Beetle(InstantEthereal instantEthereal) : base(1072453, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Beetle;
            }
        }

        private class BlackRussianTerrier : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public BlackRussianTerrier(InstantEthereal instantEthereal) : base(1159759, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.BlackRussianTerrier;
            }
        }

        private class Boura : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Boura(InstantEthereal instantEthereal) : base(1095905, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Boura;
            }
        }

        private class ChargerOfTheFallen : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public ChargerOfTheFallen(InstantEthereal instantEthereal) : base(1075187, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.ChargerOfTheFallen;
            }
        }

        private class Chimera : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Chimera(InstantEthereal instantEthereal) : base(1031069, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Chimera;
            }
        }

        private class CuSidhe : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public CuSidhe(InstantEthereal instantEthereal) : base(1031670, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.CuSidhe;
            }
        }

        private class DesertOstard : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public DesertOstard(InstantEthereal instantEthereal) : base(1029650, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.DesertOstard;
            }
        }

        private class FrenziedOstard : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public FrenziedOstard(InstantEthereal instantEthereal) : base(1028502, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.FrenziedOstard;
            }
        }

        private class GreatDane : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public GreatDane(InstantEthereal instantEthereal) : base(1159757, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.GreatDane;
            }
        }

        private class Hiryu : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Hiryu(InstantEthereal instantEthereal) : base(1030090, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Hiryu;
            }
        }

        private class Horse : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Horse(InstantEthereal instantEthereal) : base(1018263, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Horse;
            }
        }

        private class Kirin : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Kirin(InstantEthereal instantEthereal) : base(1029632, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Kirin;
            }
        }

        private class Lasher : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Lasher(InstantEthereal instantEthereal) : base(1124525, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Lasher;
            }
        }

        private class Llama : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Llama(InstantEthereal instantEthereal) : base(1018283, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Llama;
            }
        }

        private class Newfoundland : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Newfoundland(InstantEthereal instantEthereal) : base(1159755, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Newfoundland;
            }
        }

        private class Ostard : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Ostard(InstantEthereal instantEthereal) : base(1018273, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Ostard;
            }
        }

        private class PolarBear : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public PolarBear(InstantEthereal instantEthereal) : base(1015243, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.PolarBear;
            }
        }

        private class Reptalon : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Reptalon(InstantEthereal instantEthereal) : base(1075202, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Reptalon;
            }
        }

        private class Ridgeback : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Ridgeback(InstantEthereal instantEthereal) : base(1029749, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Ridgeback;
            }
        }

        private class Rottweiler : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Rottweiler(InstantEthereal instantEthereal) : base(1159760, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Rottweiler;
            }
        }

        private class SaintBernard : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public SaintBernard(InstantEthereal instantEthereal) : base(1159758, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.SaintBernard;
            }
        }

        private class SeaHorse : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public SeaHorse(InstantEthereal instantEthereal) : base(1035120, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.SeaHorse;
            }
        }

        private class SkeletalMount : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public SkeletalMount(InstantEthereal instantEthereal) : base(1029751, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.SkeletalMount;
            }
        }

        private class SwampDragon : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public SwampDragon(InstantEthereal instantEthereal) : base(1029753, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.SwampDragon;
            }
        }

        private class Tarantula : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Tarantula(InstantEthereal instantEthereal) : base(1124430, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Tarantula;
            }
        }

        private class Tiger : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Tiger(InstantEthereal instantEthereal) : base(1123004, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Tiger;
            }
        }

        private class Unicorn : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Unicorn(InstantEthereal instantEthereal) : base(1029678, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Unicorn;
            }
        }

        private class WarBoar : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public WarBoar(InstantEthereal instantEthereal) : base(1126348, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.WarBoar;
            }
        }

        private class Windrunner : ContextMenuEntry
        {
            private InstantEthereal instantEthereal;

            public Windrunner(InstantEthereal instantEthereal) : base(1124685, 5)
            {
                this.instantEthereal = instantEthereal;
            }

            public override void OnClick()
            {
                instantEthereal.EthyType = EtherealTypes.Windrunner;
            }

The goal is to allow the player to select which type of ethereal they want from the list. It works as is but it's messy.. because I'm having to use Clilocs I can only work with what's available so some are caps, some are lowercase, some are as close as I could get so don't exactly match haha..
 
The best approach for this would be to use a gump.

There are of course a few ways to do it, you could copy one of the existing gumps like the polymorph spell, or you can go basic and use the existing BaseGridGump and build the menu like the props gump.

With Vita-Nex, you can use a MenuGump...

(You will need to import the appropriate namespaces with the 'using' directive)
C#:
// Define a single context menu entry
private class PolymorphEntry : ContextMenuEntry
{
    private Mobile player;
    private InstantEthereal instantEthereal;

    public PolymorphEntry(Mobile player, InstantEthereal instantEthereal)
        : base(1015218, 5)
    {
        this.player = player;
        this.instantEthereal = instantEthereal;
    }

    public override void OnClick( )
    {
        instantEthereal.BeginSelectType( player );
    }
}

public override void GetContextMenuEntries( Mobile from, List<ContextMenuEntry> list )
{
    if ( from.Alive )
        list.Add( new PolymorphEntry( from, this ) );

    base.GetContextMenuEntries( from, list );
}

private void BeginSelectType( Mobile from )
{
    var menu = new MenuGump( from );

    var types = default( EtherealTypes ).EnumerateValues<EtherealTypes>( );

    // generate a list of all possible types from the enum
    foreach ( EtherealTypes type in types )
        menu.AddOption( type.ToString( true ), b => EndSelectType( from, type ) );

    menu.Send( );
}

private void EndSelectType( Mobile from, EtherealTypes type )
{
    this.EthyType = type;
}
 
Back