In OWLTR BOBFilterGump.cs, the custom ores & leathers arent showing due to no CliLocs & I really dont want to have to create them considering it would add to how much owners would have to change things for their servers & the patches it would create. So... I would like to convert the int to string so that they show up, but I'm not sure how. I know the string text would be "*****", but I'm stuck past that and it throws the old "cant convert int to string" error if I add the string text. Any help would be great. Thx
 

Attachments

  • BOBFilterGump.cs
    12.8 KB · Views: 4
I don't know if this will help you just a suggestion on this topic.

int num = 10;
string str = Convert.ToString(num);

The ToString method of any object is supposed to return a string representation of that object.

int var1 = 2;

string var2 = var1.ToString();

or

string s = Convert.ToString(num);
or

string str = intVar.ToString();

In some conditions, yo do not have to use ToString()

string str = "hi " + intVar;

or

using System.ComponentModel;

TypeConverter converter = TypeDescriptor.GetConverter(typeof(int));
string s = (string)converter.ConvertTo(i, typeof(string));
 
Sorry Viwinfii but if you have more suggestions I think you should post ;) all information on C# is a great for any reader gives them all kinds of options.
 
I think what Hammerhand was looking for was not converting int to string, in the traditional sense, but how to get the gump to properly apply filters on int[,] types when he needs to do { "Blaze", 0 } instead of { 1056789, 0 } (because there is no cliloc for "Blaze" and he does not want to add custom cliloc entries.

This will require rewriting the gump code to accept object[,] arrays just for the OWLTR parts, which I am working on. If I don't finish soon, I will post my progress, and let someone else pick it up.
 
Try this, or someone with better understanding of Bulk Orders can pick it up from here.

Code:
using System;
using Server.Gumps;
using Server.Mobiles;

namespace Server.Engines.BulkOrders
{
    class OWLTRBobFilterGump : Gump
    {
        private PlayerMobile m_From;
        private BulkOrderBook m_Book;

        private const int LabelColor = 0x7FFF;

        private static int[,] m_MaterialFilters = new int[,]
            {
                { 1044067,  1 }, // Blacksmithy
                { 1062226,  3 }, // Iron
                { 1018332,  4 }, // Dull Copper
                { 1018333,  5 }, // Shadow Iron
                { 1018334,  6 }, // Copper
                { 1018335,  7 }, // Bronze

                {       0,  0 }, // --Blank--
                { 1018336,  8 }, // Golden
                { 1018337,  9 }, // Agapite
                { 1018338, 10 }, // Verite
                { 1018339, 11 }, // Valorite
                {       0,  0 }, // --Blank--

                { 1044094,  2 }, // Tailoring
                { 1044286, 12 }, // Cloth
                { 1062235, 13 }, // Leather
                { 1062236, 14 }, // Spined
                { 1062237, 15 }, // Horned
                { 1062238, 16 }, // Barbed
            };

        private static object[,] m_OwltrMaterialFilters = new object[,]
            {
                //daat99 OWLTR start - custom ores
                {       "Blaze", 1 }, // Blaze
                {       "Ice", 2 }, // Ice
                {       "Toxic", 3 }, // Toxic
                {       "Electrum", 4 }, // Electrum
                {       "Platinum", 5 }, // Platinum

                //daat99 OWLTR start - custom leather
                {       "",  0 }, // --Blank--
                {        "Polar", 6 }, // Polar
                {        "Synthetic", 7 }, // Synthetic
                {        "BlazeL", 8 }, // BlazeL
                {        "Daemonic", 9 }, // Daemonic
                {       "Shadow", 10 }, // Shadow
               
                {       "",  0 }, // --Blank--
                {        "Frost", 11 }, // Frost
                {        "Ethereal", 12 }, // Ethereal
                {       "",  0 }, // --Blank--
                {       "",  0 }     // --Blank--

            };

        private static int[,] m_TypeFilters = new int[,]
            {
                { 1062229, 0 }, // All
                { 1062224, 1 }, // Small
                { 1062225, 2 }  // Large
            };

        private static int[,] m_QualityFilters = new int[,]
            {
                { 1062229, 0 }, // All
                { 1011542, 1 }, // Normal
                { 1060636, 2 }  // Exceptional
            };

        private static int[,] m_AmountFilters = new int[,]
            {
                { 1062229, 0 }, // All
                { 1049706, 1 }, // 10
                { 1016007, 2 }, // 15
                { 1062239, 3 }  // 20
            };

        private static int[][,] m_Filters = new int[][,]
            {
                m_TypeFilters,
                m_QualityFilters,
                m_MaterialFilters,
                m_AmountFilters
            };

        private static int[] m_XOffsets_Type = new int[]{ 0, 75, 170 };
        private static int[] m_XOffsets_Quality = new int[]{ 0, 75, 170 };
        private static int[] m_XOffsets_Amount = new int[]{ 0, 75, 180, 275 };
        private static int[] m_XOffsets_Material = new int[]{ 0, 105, 210, 305, 390, 485 };

        private static int[] m_XWidths_Small = new int[]{ 50, 50, 70, 50 };
        private static int[] m_XWidths_Large = new int[] { 80, 50, 50, 50, 50, 50 };

        private void AddFilterList(int x, int y, int[] xOffsets, int yOffset, object[,] owltrFilters, int[] xWidths, string filterValue, int filterIndex)
        {
            for (int i = 0; i < owltrFilters.GetLength(0); ++i)
            {
                string text = (string)owltrFilters[i, 0];

                if (text == "")
                    continue;

                bool isSelected = ((string)owltrFilters[i, 1] == filterValue);

                if (!isSelected && (i % xOffsets.Length) == 0)
                    isSelected = (filterValue == "");

                this.AddHtml(x + 35 + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), xWidths[i % xOffsets.Length], 32, Color(text, isSelected ? 16927 : LabelColor), false, false);
                this.AddButton(x + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), 4005, 4007, 4 + filterIndex + (i * 4), GumpButtonType.Reply, 0);
            }
        }

        public string Color(string text, int color)
        {
            return String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text);
        }

        private void AddFilterList( int x, int y, int[] xOffsets, int yOffset, int[,] filters, int[] xWidths, int filterValue, int filterIndex )
        {
            for ( int i = 0; i < filters.GetLength( 0 ); ++i )
            {
                int number = filters[i, 0];

                if ( number == 0 )
                    continue;

                bool isSelected = ( filters[i, 1] == filterValue );

                if ( !isSelected && (i % xOffsets.Length) == 0 )
                    isSelected = ( filterValue == 0 );

                AddHtmlLocalized( x + 35 + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), xWidths[i % xOffsets.Length], 32, number, isSelected ? 16927 : LabelColor, false, false );
                AddButton( x + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), 4005, 4007, 4 + filterIndex + (i * 4), GumpButtonType.Reply, 0 );
            }
        }

        public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
        {
            BOBFilter f = ( m_From.UseOwnFilter ? m_From.BOBFilter : m_Book.Filter );

            int index = info.ButtonID;

            switch ( index )
            {
                case 0: // Apply
                {
                    m_From.SendGump( new BOBGump( m_From, m_Book ) );

                    break;
                }
                case 1: // Set Book Filter
                {
                    m_From.UseOwnFilter = false;
                    m_From.SendGump( new BOBFilterGump( m_From, m_Book ) );

                    break;
                }
                case 2: // Set Your Filter
                {
                    m_From.UseOwnFilter = true;
                    m_From.SendGump( new BOBFilterGump( m_From, m_Book ) );

                    break;
                }
                case 3: // Clear Filter
                {
                    f.Clear();
                    m_From.SendGump( new BOBFilterGump( m_From, m_Book ) );

                    break;
                }
                default:
                {
                    index -= 4;

                    int type = index % 4;
                    index /= 4;

                    if ( type >= 0 && type < m_Filters.Length )
                    {
                        int[,] filters = m_Filters[type];

                        if ( index >= 0 && index < filters.GetLength( 0 ) )
                        {
                            //daat99 OWLTR start - custom ores
                            if ( filters[index, 0] == 0 && filters[index, 1] == 0 )
                            //daat99 OWLTR end - custom ores
                                break;

                            switch ( type )
                            {
                                case 0: f.Type = filters[index, 1]; break;
                                case 1: f.Quality = filters[index, 1]; break;
                                case 2: f.Material = filters[index, 1]; break;
                                case 3: f.Quantity = filters[index, 1]; break;
                            }

                            m_From.SendGump( new BOBFilterGump( m_From, m_Book ) );
                        }
                    }

                    break;
                }
            }
        }

        // Not sure about this method....
        private string GetFilterValue(int index)
        {
            return (string)m_OwltrMaterialFilters[index, 0];
        }

        public OWLTRBobFilterGump(PlayerMobile from, BulkOrderBook book)
            : base(12, 24)
        {
            from.CloseGump( typeof( BOBGump ) );
            from.CloseGump( typeof( BOBFilterGump ) );

            m_From = from;
            m_Book = book;

            BOBFilter f = ( from.UseOwnFilter ? from.BOBFilter : book.Filter );

            AddPage( 0 );
           
            //daat99 OWLTR start - bigger gump
            AddBackground( 10, 10, 630, 439, 5054 );

            AddImageTiled( 18, 20, 613, 420, 2624 );
            AddAlphaRegion( 18, 20, 613, 420 );

            AddImage( 5, 5, 10460 );
            AddImage( 615, 5, 10460 );
            AddImage( 5, 424, 10460 );
            AddImage( 615, 424, 10460 );

            AddHtmlLocalized( 270, 20, 200, 32, 1062223, LabelColor, false, false ); // Filter Preference

            AddHtmlLocalized( 26, 35, 120, 32, 1062228, LabelColor, false, false ); // Bulk Order Type
            AddFilterList( 25, 61, m_XOffsets_Type, 40, m_TypeFilters, m_XWidths_Small, f.Type, 0 );

            AddHtmlLocalized( 320, 35, 50, 32, 1062215, LabelColor, false, false ); // Quality
            AddFilterList( 320, 61, m_XOffsets_Quality, 40, m_QualityFilters, m_XWidths_Small, f.Quality, 1 );

            if (f.Material > (int) BulkMaterialType.Barbed)
            {
                AddHtmlLocalized(26, 100, 120, 32, 1062232, LabelColor, false, false); // Material Type
                AddFilterList(25, 132, m_XOffsets_Material, 40, m_MaterialFilters, m_XWidths_Large, f.Material, 2);
            }
            else
            {
                AddHtmlLocalized(26, 100, 120, 32, 1062232, LabelColor, false, false); // Material Type
                AddFilterList(25, 132, m_XOffsets_Material, 40, m_OwltrMaterialFilters, m_XWidths_Large,
                    GetFilterValue(f.Material), 2);
            }

            AddHtmlLocalized( 26, 350, 120, 32, 1062217, LabelColor, false, false ); // Amount
            AddFilterList( 25, 372, m_XOffsets_Amount, 40, m_AmountFilters, m_XWidths_Small, f.Quantity, 3 );
            //daat99 OWLTR end - bigger gump

            AddHtmlLocalized( 75, 416, 120, 32, 1062477, ( from.UseOwnFilter ? LabelColor : 16927 ), false, false ); // Set Book Filter
            AddButton( 40, 416, 4005, 4007, 1, GumpButtonType.Reply, 0 );

            AddHtmlLocalized( 235, 416, 120, 32, 1062478, ( from.UseOwnFilter ? 16927 : LabelColor ), false, false ); // Set Your Filter
            AddButton( 200, 416, 4005, 4007, 2, GumpButtonType.Reply, 0 );

            AddHtmlLocalized( 405, 416, 120, 32, 1062231, LabelColor, false, false ); // Clear Filter
            AddButton( 370, 416, 4005, 4007, 3, GumpButtonType.Reply, 0 );

            AddHtmlLocalized( 540, 416, 50, 32, 1011046, LabelColor, false, false ); // APPLY
            AddButton( 505, 416, 4017, 4018, 0, GumpButtonType.Reply, 0 );
        }
    }
}
 
By the way, I renamed the gump to prevent errors on my server, but you can rename it back to BOBFilterGump again. Sorry.
 
Sort of went *Boom*... :(
Code:
Exception:
System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'.
   at Server.Engines.BulkOrders.BOBFilterGump.AddFilterList(Int32 x, Int32 y, Int32[] xOffsets, Int32 yOffset, Object[,] owltrFilters, Int32[] xWidths, String filterValue, Int32 filterIndex) in d:\RunUO 2.3 w OWLTR 3.01.00\Scripts\Engines\BulkOrders\Books\BOBFilterGump.cs:line 100
   at Server.Engines.BulkOrders.BOBFilterGump..ctor(PlayerMobile from, BulkOrderBook book) in d:\RunUO 2.3 w OWLTR 3.01.00\Scripts\Engines\BulkOrders\Books\BOBFilterGump.cs:line 250
   at Server.Engines.BulkOrders.BOBGump.OnResponse(NetState sender, RelayInfo info) in d:\RunUO 2.3 w OWLTR 3.01.00\Scripts\Engines\BulkOrders\Books\BOBGump.cs:line 387
   at Server.Network.PacketHandlers.DisplayGumpResponse(NetState state, PacketReader pvSrc)
   at Server.Network.MessagePump.HandleReceive(NetState ns)
   at Server.Network.MessagePump.Slice()
   at Server.Core.Main(String[] args)
Line 100
Code:
bool isSelected = ((string)owltrFilters[i, 1] == filterValue);
Line 250
Code:
AddFilterList(25, 132, m_XOffsets_Material, 40, m_OwltrMaterialFilters, m_XWidths_Large,
Line 387 with whole section in BODGump.cs
Code:
                case 1: // Set Filter
                {
                    m_From.SendGump( new BOBFilterGump2( m_From, m_Book ) );
 
                    break;
                }
Why cant things just be a nice & easy 1 & done? :(
 
This is basically how it should look (in a way)..
This
Code:
        private static int[,] m_MaterialFilters = new int[,]
            {
                { 1044067,  1 }, // Blacksmithy
                { 1062226,  3 }, // Iron
                { 1018332,  4 }, // Dull Copper
                { 1018333,  5 }, // Shadow Iron
                { 1018334,  6 }, // Copper
                { 1018335,  7 }, // Bronze
 
                {       0,  0 }, // --Blank--
                { 1018336,  8 }, // Golden
                { 1018337,  9 }, // Agapite
                { 1018338, 10 }, // Verite
                { 1018339, 11 }, // Valorite
                //daat99 OWLTR start - custom ores
                {       0, 12 }, // Blaze
            
                {       0,  0 }, // --Blank--
                {       0, 13 }, // Ice
                {       0, 14 }, // Toxic
                {       0, 15 }, // Electrum
                {       0, 16 }, // Platinum
                //daat99 OWLTR end - custom ores
and this
Code:
                //daat99 OWLTR start - filter
                if ( filters[i, 1] == 0 )
                    continue;
                else
                {
                    switch (filters[i, 1])
                    {
                         case 12:
                         {
                             AddHtml( x + 35 + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), xWidths[i % xOffsets.Length], 32, isSelected ? "<basefont color=#8484FF>Blaze" : "<basefont color=#FFFFFF>Blaze", false, false );
                             AddButton( x + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), 4005, 4007, filterIndex + ((filters[i, 1]) * 4), GumpButtonType.Reply, 0 ); continue;
                         }
                         case 13:
                         {
                             AddHtml( x + 35 + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), xWidths[i % xOffsets.Length], 32, isSelected ? "<basefont color=#8484FF>Ice" : "<basefont color=#FFFFFF>Ice", false, false );
                             AddButton( x + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), 4005, 4007, 4 + filterIndex + ((filters[i, 1]) * 4), GumpButtonType.Reply, 0 ); continue;
                         }
                         case 14:
                         {
                             AddHtml( x + 35 + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), xWidths[i % xOffsets.Length], 32, isSelected ? "<basefont color=#8484FF>Toxic" : "<basefont color=#FFFFFF>Toxic", false, false );
                             AddButton( x + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), 4005, 4007, 4 + filterIndex + ((filters[i, 1]) * 4), GumpButtonType.Reply, 0 ); continue;
                         }
                         case 15:
                         {
                             AddHtml( x + 35 + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), xWidths[i % xOffsets.Length], 32, isSelected ? "<basefont color=#8484FF>Electrum" : "<basefont color=#FFFFFF>Electrum", false, false );
                             AddButton( x + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), 4005, 4007, 4 + filterIndex + ((filters[i, 1]) * 4), GumpButtonType.Reply, 0 ); continue;
                         }
                         case 16:
                         {
                             AddHtml( x + 35 + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), xWidths[i % xOffsets.Length], 32, isSelected ? "<basefont color=#8484FF>Platinum" : "<basefont color=#FFFFFF>Platinum", false, false );
                             AddButton( x + xOffsets[i % xOffsets.Length], y + ((i / xOffsets.Length) * yOffset), 4005, 4007, 4 + filterIndex + ((filters[i, 1]) * 4), GumpButtonType.Reply, 0 ); continue;
                         }
Should show similiar to the edited pic.
ScreenHunter_26 Apr. 28 15.59.jpg
 
Nice way to store the bulk orders-really like how they are divided to the type instead of the normal where -example-all large does not matter the type would go together :)
 
Its just the old BoD Book gump. Just trying to get it to show the OWLTR resources. Filters can be set for Large or Small, Normal or Exceptional, by Amount (10, 15 or 20 count BoDs) or by resource type. Thats all default. It will just work better if it shows the OWLTR resources as well.
 
Well, I sort of got it working... All the custom resources show up in the SetFilter gump like they should... only 1 small problem remaining with it. When you select a filter for resource type & apply it, it shows nothing in the BOD gump. But its a definet improvement.
All I did was change
Code:
        private void AddFilterList( int x, int y, int[] xOffsets, int yOffset, int[,] filters, int[] xWidths, int filterValue, int filterIndex )
        {
            for ( int i = 0; i < filters.GetLength( 0 ); ++i )
            {
                int number = filters[i, 0];
 
                if ( number == 0 )
                    continue;
 
                bool isSelected = ( filters[i, 1] == filterValue );
 
                if ( !isSelected && (i % xOffsets.Length) == 0 )
                    isSelected = ( filterValue == 0 );
                  
                //daat99 OWLTR start - filter  
                if ( filters[i, 1] == 0 )
                    continue;
                else
                {
                    switch (filters[i, 1])
                    {
to
Code:
        private void AddFilterList( int x, int y, int[] xOffsets, int yOffset, int[,] filters, int[] xWidths, int filterValue, int filterIndex )
        {
            for (int i = 0; i < filters.GetLength(0); ++i)
            {
                int number = filters[i, 0];
 
                bool isSelected = (filters[i, 1] == filterValue);
 
                if (!isSelected && (i % xOffsets.Length) == 0)
                    isSelected = (filterValue == 0);
 
                if (number == 0 && filters[i, 1] == 0)
                    continue;
                else switch (filters[i, 1])
                    {
and I got..
ScreenHunter_30 May. 03 08.48.jpg
 
*grumble* Every single one of the filters are working except for the Material filters. You can even select between Blacksmithy & Tailoring & have them all work on either one (as long as you use the Set Book Filter.. the Set Your Filter seems to blank them out, but I think it always did)... just not the Material filters. Guess its back to beating my head on the keyboard (again)..
 
I now know why the material filters arent working, just not exactly how to fix it. They are apparently offest just a tad.
BoDs in book
ScreenHunter_31 May. 03 11.51.jpg
Select Agapite
ScreenHunter_32 May. 03 11.52.jpg
Shows the Copper BoD
ScreenHunter_33 May. 03 11.52.jpg

Same with the Tailor ones.. Select Cloth & get Toxic
 
Its the Materials in the BOBFilterGump that are offset by 3. Gotta do another day shift today, so I'm not left with much more time until I'm gone for 9+ hours (again)..
 

Attachments

  • BOBFilterGump.cs
    13.9 KB · Views: 9
*Solved!!!!!* It now works properly. I had accidently added in the wrong numbers in another script that it ties into. Got that sorted out & it started working just fine. :D
 
I know this is old, but so is everything else I want to do haha.. Wondering if anyone has done this with any of the newer repos. I.E. Pub 57. If not and someone is willing to update this I would be willing to donate for your time :)
 
Back