示例#1
0
        public static GumpInfo GetNextInfo(Mobile m, GumpInfo info)
        {
            if (s_Infos[m] == null)
            {
                s_Infos[m] = new Hashtable();
            }

            ArrayList list = new ArrayList(((Hashtable)s_Infos[m]).Values);

            for (int i = 0; i < list.Count; ++i)
            {
                if (!(list[i] is GumpInfo))
                {
                    continue;
                }

                if (list[i] == info)
                {
                    if (i == list.Count - 1)
                    {
                        return((GumpInfo)list[0]);
                    }

                    return((GumpInfo)list[i + 1]);
                }
            }

            return(info);
        }
		public OverrideGump( Mobile m, Type type, TimerCallback callback ) : base( m, 100, 100 )
		{
			c_Callback = callback;
			c_Info = GumpInfo.GetInfo( m, type );

			Override = false;

			NewGump();
		}
示例#3
0
        public OverrideGump(Mobile m, Type type, TimerCallback callback) : base(m, 100, 100)
        {
            c_Callback = callback;
            c_Info     = GumpInfo.GetInfo(m, type);

            Override = false;

            NewGump();
        }
示例#4
0
        public static void RemoveInfo(Mobile m, GumpInfo info)
        {
            if (s_Infos[m] == null)
            {
                s_Infos[m] = new Hashtable();
            }

            if (((Hashtable)s_Infos[m])[info.Type] == null)
            {
                return;
            }

            ((Hashtable)s_Infos[m])[info.Type] = null;
        }
示例#5
0
        public static GumpInfo GetInfo(Mobile m, Type type)
        {
            if (s_Infos[m] == null)
            {
                s_Infos[m] = new Hashtable();
            }

            Hashtable table = (Hashtable)s_Infos[m];

            if (table[type] == null)
            {
                table[type] = new GumpInfo(m, type);
            }

            return((GumpInfo)table[type]);
        }
示例#6
0
        private static void OnLoad()
        {
            try{
                if (!File.Exists(Path.Combine("Saves/Gumps/", "Gumps.bin")))
                {
                    return;
                }

                using (FileStream bin = new FileStream(Path.Combine("Saves/Gumps/", "Gumps.bin"), FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    GenericReader reader = new BinaryFileReader(new BinaryReader(bin));

                    int version = reader.ReadInt();

                    if (version >= 0)
                    {
                        int      count = reader.ReadInt();
                        GumpInfo info;

                        for (int i = 0; i < count; ++i)
                        {
                            info = new GumpInfo();
                            info.Load(reader);

                            if (info.Mobile == null || info.Type == null)
                            {
                                continue;
                            }

                            if (s_Infos[info.Mobile] == null)
                            {
                                s_Infos[info.Mobile] = new Hashtable();
                            }

                            ((Hashtable)s_Infos[info.Mobile])[info.Type] = info;
                        }
                    }

                    reader.End();
                }
            }catch { Errors.Report("GumpInfo-> OnLoad"); }
        }
		private void NextTemplate()
		{
			c_Info = GumpInfo.GetNextInfo( Owner, c_Info );

			NewGump();
		}
		private void PreviousTemplate()
		{
			c_Info = GumpInfo.GetPreviousInfo( Owner, c_Info );

			NewGump();
		}
示例#9
0
        public static GumpInfo GetInfo( Mobile m, Type type )
        {
            if ( s_Infos[m] == null )
                s_Infos[m] = new Hashtable();

            Hashtable table = (Hashtable)s_Infos[m];

            if ( table[type] == null )
                table[type] = new GumpInfo( m, type );

            return (GumpInfo)table[type];
        }
示例#10
0
        private void Default()
        {
            GumpInfo.RemoveInfo(Owner, c_Info);

            c_Callback.Invoke();
        }
示例#11
0
        public static void RemoveInfo( Mobile m, GumpInfo info )
        {
            if ( s_Infos[m] == null )
                s_Infos[m] = new Hashtable();

            if ( ((Hashtable)s_Infos[m])[info.Type] == null )
                return;

            ((Hashtable)s_Infos[m])[info.Type] = null;
        }
示例#12
0
        public static GumpInfo GetPreviousInfo( Mobile m, GumpInfo info )
        {
            if ( s_Infos[m] == null )
                s_Infos[m] = new Hashtable();

            ArrayList list = new ArrayList( ((Hashtable)s_Infos[m]).Values );

            for( int i = 0; i < list.Count; ++i )
            {
                if ( !(list[i] is GumpInfo) )
                    continue;

                if ( list[i] == info )
                {
                    if ( i == 0 )
                        return (GumpInfo)list[list.Count-1];

                    return (GumpInfo)list[i-1];
                }
            }

            return info;
        }
示例#13
0
        private void ModifyGump()
        {
            try{
                AddPage(0);

                int            maxWidth  = 0;
                int            maxHeight = 0;
                GumpBackground bg;

                foreach (GumpEntry entry in Entries)
                {
                    if (entry is GumpBackground)
                    {
                        bg = (GumpBackground)entry;

                        if (bg.X + bg.Width > maxWidth)
                        {
                            maxWidth = bg.X + bg.Width;
                        }
                        if (bg.Y + bg.Height > maxHeight)
                        {
                            maxHeight = bg.Y + bg.Height;
                        }
                    }
                }

                AddImage(maxWidth, maxHeight, 0x28DC, 0x387);
                AddButton(maxWidth + 10, maxHeight + 4, 0x93A, 0x93A, "Transparency", new TimerCallback(Trans));
                AddButton(maxWidth + 10, maxHeight + 15, 0x938, 0x938, "Default", new TimerCallback(Default));
                AddButton(maxWidth - 5, maxHeight + 2, 0x2626, 0x2627, "BackgroundDown", new TimerCallback(BackDown));
                AddButton(maxWidth + 19, maxHeight + 2, 0x2622, 0x2623, "BackgroundUp", new TimerCallback(BackUp));
                AddButton(maxWidth - 5, maxHeight + 13, 0x2626, 0x2627, "TextColorDown", new TimerCallback(TextDown));
                AddButton(maxWidth + 19, maxHeight + 13, 0x2622, 0x2623, "TextColorUp", new TimerCallback(TextUp));

                if (!GumpInfo.HasMods(c_Owner, GetType()))
                {
                    return;
                }

                ArrayList backs = new ArrayList();

                foreach (GumpEntry entry in new ArrayList(Entries))
                {
                    if (entry is GumpBackground)
                    {
                        if (Info.Background != -1)
                        {
                            ((GumpBackground)entry).GumpID = Info.Background;
                        }

                        backs.Add(entry);
                    }
                    else if (entry is GumpAlphaRegion && !Info.DefaultTrans && !Info.Transparent)
                    {
                        ((GumpAlphaRegion)entry).Width  = 0;
                        ((GumpAlphaRegion)entry).Height = 0;
                    }
                    else if (entry is HtmlPlus)
                    {
                        if (!((HtmlPlus)entry).Override || Info.TextColorRGB == "")
                        {
                            continue;
                        }

                        string text   = ((HtmlPlus)entry).Text;
                        int    num    = 0;
                        int    length = 0;
                        char[] chars;

                        if (text == null)
                        {
                            continue;
                        }

                        while ((num = text.ToLower().IndexOf("<basefont")) != -1 || (num = text.ToLower().IndexOf("</font")) != -1)
                        {
                            length = 0;
                            chars  = text.ToCharArray();

                            for (int i = num; i < chars.Length; ++i)
                            {
                                if (chars[i] == '>')
                                {
                                    length = i - num + 1;
                                    break;
                                }
                            }

                            if (length == 0)
                            {
                                break;
                            }

                            text = text.Substring(0, num) + text.Substring(num + length, text.Length - num - length);
                        }

                        ((HtmlPlus)entry).Text = Info.TextColor + text;
                    }
                }

                if (!Info.DefaultTrans && Info.Transparent)
                {
                    foreach (GumpBackground back in backs)
                    {
                        AddAlphaRegion(back.X, back.Y, back.Width, back.Height);
                    }
                }

                SortEntries();
            }catch { Errors.Report("GumpPlus-> ModifyGump-> " + GetType()); }
        }
示例#14
0
        private void ModifyGump()
        {
            try{
                AddPage(0);

                int            maxWidth  = 0;
                int            maxHeight = 0;
                GumpBackground bg;

                foreach (GumpEntry entry in Entries)
                {
                    if (entry is GumpBackground)
                    {
                        bg = (GumpBackground)entry;

                        if (bg.X + bg.Width > maxWidth)
                        {
                            maxWidth = bg.X + bg.Width;
                        }
                        if (bg.Y + bg.Height > maxHeight)
                        {
                            maxHeight = bg.Y + bg.Height;
                        }
                    }
                }

                AddImage(maxWidth, maxHeight, 0x28DC, 0x387);
                AddItem(maxWidth, maxHeight, 0xFC1);
                AddButton(maxWidth + 2, maxHeight + 16, 0x93A, 0x93A, "Gump Art", new TimerCallback(GumpArt));

                if (!GumpInfo.HasMods(c_Owner, GetType()))
                {
                    return;
                }

                GumpInfo  info  = GumpInfo.GetInfo(c_Owner, GetType());
                ArrayList backs = new ArrayList();

                foreach (GumpEntry entry in new ArrayList(Entries))
                {
                    if (entry is GumpBackground)
                    {
                        if (info.Background != -1)
                        {
                            ((GumpBackground)entry).GumpID = info.Background;
                        }

                        backs.Add(entry);
                    }
                    else if (entry is GumpAlphaRegion && !info.DefaultTrans && !info.Transparent)
                    {
                        ((GumpAlphaRegion)entry).Width  = 0;
                        ((GumpAlphaRegion)entry).Height = 0;
                    }
                    else if (entry is HtmlPlus)
                    {
                        if ((int)((HtmlPlus)entry).Template != -1)
                        {
                            ButtonTemplate.RemoveTemplate((HtmlPlus)entry, ((HtmlPlus)entry).Template);
                            ButtonTemplate.ApplyTemplate((HtmlPlus)entry, info.Template);
                        }

                        if (!((HtmlPlus)entry).Override || info.TextColorRGB == "")
                        {
                            continue;
                        }

                        string text   = ((HtmlPlus)entry).Text;
                        int    num    = 0;
                        int    length = 0;
                        char[] chars;

                        if (text == null)
                        {
                            continue;
                        }

                        while ((num = text.ToLower().IndexOf("<basefont")) != -1 || (num = text.ToLower().IndexOf("</font")) != -1)
                        {
                            length = 0;
                            chars  = text.ToCharArray();

                            for (int i = num; i < chars.Length; ++i)
                            {
                                if (chars[i] == '>')
                                {
                                    length = i - num + 1;
                                    break;
                                }
                            }

                            if (length == 0)
                            {
                                break;
                            }

                            text = text.Substring(0, num) + text.Substring(num + length, text.Length - num - length);
                        }

                        ((HtmlPlus)entry).Text = info.TextColor + text;
                    }
                    else if (entry is ButtonPlus && (int)((ButtonPlus)entry).Template != -1)
                    {
                        ButtonTemplate.RemoveTemplate((ButtonPlus)entry, ((ButtonPlus)entry).Template);
                        ButtonTemplate.ApplyTemplate((ButtonPlus)entry, info.Template);
                    }
                }

                if (!info.DefaultTrans && info.Transparent)
                {
                    foreach (GumpBackground back in backs)
                    {
                        AddAlphaRegion(back.X, back.Y, back.Width, back.Height);
                    }
                }

                SortEntries();
            }catch { Errors.Report("GumpPlus-> ModifyGump-> " + GetType()); }
        }
示例#15
0
        private void PreviousTemplate()
        {
            c_Info = GumpInfo.GetPreviousInfo(Owner, c_Info);

            NewGump();
        }
示例#16
0
        private static void OnLoad()
        {
            try{

            if ( !File.Exists( Path.Combine( "Saves/Gumps/", "Gumps.bin" ) ) )
                return;

            using ( FileStream bin = new FileStream( Path.Combine( "Saves/Gumps/", "Gumps.bin" ), FileMode.Open, FileAccess.Read, FileShare.Read ) )
            {
                GenericReader reader = new BinaryFileReader( new BinaryReader( bin ) );

                int version = reader.ReadInt();

                if ( version >= 0 )
                {
                    int count = reader.ReadInt();
                    GumpInfo info;

                    for( int i = 0; i < count; ++i )
                    {
                        info = new GumpInfo();
                        info.Load( reader );

                        if ( info.Mobile == null || info.Type == null )
                            continue;

                        if ( s_Infos[info.Mobile] == null )
                            s_Infos[info.Mobile] = new Hashtable();

                        ((Hashtable)s_Infos[info.Mobile])[info.Type] = info;
                    }
                }

                reader.End();
            }

            }catch{ Errors.Report( "GumpInfo-> OnLoad" ); }
        }
示例#17
0
        private void NextTemplate()
        {
            c_Info = GumpInfo.GetNextInfo(Owner, c_Info);

            NewGump();
        }