Beispiel #1
0
        public void AddSubRes2(Type type, int name, double reqSkill, int genericName, object message)
        {
            CraftSubRes craftSubRes = new CraftSubRes(type, name, reqSkill, genericName, message);

            m_CraftSubRes2.Add(craftSubRes);
        }
Beispiel #2
0
        public void AddSubRes2(Type type, string name, double reqSkill, object message)
        {
            CraftSubRes craftSubRes = new CraftSubRes(type, name, reqSkill, message);

            m_CraftSubRes2.Add(craftSubRes);
        }
Beispiel #3
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID <= 0)
            {
                return;                 // Canceled
            }
            int buttonID = info.ButtonID - 1;
            int type     = buttonID % 7;
            int index    = buttonID / 7;

            CraftSystem   system  = m_CraftSystem;
            CraftGroupCol groups  = system.CraftGroups;
            CraftContext  context = system.GetContext(m_From);

            switch (type)
            {
            case 0:                     // Show group
            {
                if (context == null)
                {
                    break;
                }

                if (index >= 0 && index < groups.Count)
                {
                    context.LastGroupIndex = index;
                    m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                }

                break;
            }

            case 1:                     // Create item
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    CraftGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.CraftItems.Count)
                    {
                        CraftItem(group.CraftItems.GetAt(index));
                    }
                }

                break;
            }

            case 2:                     // Item details
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    CraftGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.CraftItems.Count)
                    {
                        m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems.GetAt(index), m_Tool, context));
                    }
                }

                break;
            }

            case 3:                     // Create item (last 10)
            {
                if (context == null)
                {
                    break;
                }

                List <CraftItem> lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    CraftItem(lastTen[index]);
                }

                break;
            }

            case 4:                     // Item details (last 10)
            {
                if (context == null)
                {
                    break;
                }

                List <CraftItem> lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    m_From.SendGump(new CraftGumpItem(m_From, system, lastTen[index], m_Tool));
                }

                break;
            }

            case 5:                     // Resource selected
            {
                if (m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count)
                {
                    int groupIndex = (context == null ? -1 : context.LastGroupIndex);

                    CraftSubRes res = system.CraftSubRes.GetAt(index);

                    if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex = index;
                        }

                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                    }
                }
                else if (m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count)
                {
                    int groupIndex = (context == null ? -1 : context.LastGroupIndex);

                    CraftSubRes res = system.CraftSubRes2.GetAt(index);

                    if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex2 = index;
                        }

                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                    }
                }

                break;
            }

            case 6:                     // Misc. buttons
            {
                switch (index)
                {
                case 0:                                 // Resource selection
                {
                    if (system.CraftSubRes.Init)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource));
                    }

                    break;
                }

                case 1:                                 // Smelt item
                {
                    if (system.Resmelt)
                    {
                        Resmelt.Do(m_From, system, m_Tool);
                    }

                    break;
                }

                case 2:                                 // Make last
                {
                    if (context == null)
                    {
                        break;
                    }

                    CraftItem item = context.LastMade;

                    if (item != null)
                    {
                        CraftItem(item);
                    }
                    else
                    {
                        m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, 1044165, m_Page));                                             // You haven't made anything yet.
                    }
                    break;
                }

                case 3:                                 // Last 10
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.LastGroupIndex = 501;
                    m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));

                    break;
                }

                case 4:                                 // Toggle use resource hue
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.DoNotColor = !context.DoNotColor;

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 5:                                 // Repair item
                {
                    if (system.Repair)
                    {
                        Repair.Do(m_From, system, m_Tool);
                    }

                    break;
                }

                case 6:                                 // Toggle mark option
                {
                    if (context == null || !system.MarkOption)
                    {
                        break;
                    }

                    switch (context.MarkOption)
                    {
                    case CraftMarkOption.MarkItem: context.MarkOption = CraftMarkOption.DoNotMark; break;

                    case CraftMarkOption.DoNotMark: context.MarkOption = CraftMarkOption.PromptForMark; break;

                    case CraftMarkOption.PromptForMark: context.MarkOption = CraftMarkOption.MarkItem; break;
                    }

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 7:                                 // Resource selection 2
                {
                    if (system.CraftSubRes2.Init)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource2));
                    }

                    break;
                }

                case 8:                                 // Enhance item
                {
                    if (system.CanEnhance)
                    {
                        Enhance.BeginTarget(m_From, system, m_Tool);
                    }

                    break;
                }
                }

                break;
            }
            }
        }
 public void Add(CraftSubRes craftSubRes)
 {
     List.Add(craftSubRes);
 }
Beispiel #5
0
        private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page)
            : base(40, 40)
        {
            this.m_From        = from;
            this.m_CraftSystem = craftSystem;
            this.m_Tool        = tool;
            this.m_Page        = page;

            CraftContext context = craftSystem.GetContext(from);

            from.CloseGump(typeof(CraftGump));
            from.CloseGump(typeof(CraftGumpItem));

            this.AddPage(0);

            this.AddBackground(0, 0, 550, 587, 5054);
            this.AddImageTiled(10, 10, 530, 22, 2624);   //Section for Gump Heading
            this.AddImageTiled(10, 375, 132, 45, 2624);  //Section for Notices
            this.AddImageTiled(146, 375, 395, 45, 2624); //Section across from Notices
            this.AddImageTiled(10, 422, 530, 155, 2624); //Section where Exit is
            this.AddImageTiled(10, 37, 200, 335, 2624);  //Section for Categories
            this.AddImageTiled(215, 37, 325, 335, 2624); //Section for Sublisted Items
            this.AddAlphaRegion(10, 10, 530, 567);

            if (craftSystem.GumpTitleNumber > 0)
            {
                this.AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                this.AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
            }

            this.AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false);  // <CENTER>CATEGORIES</CENTER>
            this.AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER>
            this.AddHtmlLocalized(10, 385, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER>

            this.AddButton(15, 542, 4017, 4019, 0, GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(50, 545, 150, 18, 1011441, LabelColor, false, false); // EXIT

            this.AddButton(270, 542, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(305, 545, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST

            this.AddButton(270, 502, 4005, 4007, GetButtonID(6, 9), GumpButtonType.Reply, 0);
            this.AddLabel(304, 505, 1152, @"ALTER ITEM (GARGOYLE)");

            this.AddButton(270, 522, 4005, 4007, GetButtonID(6, 10), GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(305, 525, 150, 18, 1112533 + (context == null ? 0 : (int)context.QuestOption), LabelColor, false, false); // QUEST ITEM

            this.AddButton(115, 542, 4017, 4019, GetButtonID(6, 11), GumpButtonType.Reply, 0);
            this.AddHtmlLocalized(150, 545, 150, 18, 1112698, LabelColor, false, false); // CANCEL MAKE

            // Mark option
            if (craftSystem.MarkOption)
            {
                this.AddButton(270, 462, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0);
                this.AddHtmlLocalized(305, 465, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false); // MARK ITEM
            }
            // ****************************************

            // Resmelt option
            if (craftSystem.Resmelt)
            {
                this.AddButton(15, 442, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0);
                this.AddHtmlLocalized(50, 445, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM
            }
            // ****************************************

            // Repair option
            if (craftSystem.Repair)
            {
                this.AddButton(270, 442, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0);
                this.AddHtmlLocalized(305, 445, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM
            }
            // ****************************************

            // Enhance option
            if (craftSystem.CanEnhance)
            {
                this.AddButton(270, 482, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0);
                this.AddHtmlLocalized(305, 485, 150, 18, 1061001, LabelColor, false, false); // ENHANCE ITEM
            }
            // ****************************************

            if (notice is int && (int)notice > 0)
            {
                this.AddHtmlLocalized(170, 377, 350, 40, (int)notice, LabelColor, false, false);
            }
            else if (notice is string)
            {
                this.AddHtml(170, 377, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false);
            }

            // If the system has more than one resource
            if (craftSystem.CraftSubRes.Init)
            {
                string nameString = craftSystem.CraftSubRes.NameString;
                int    nameNumber = craftSystem.CraftSubRes.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex);

                Type resourceType = craftSystem.CraftSubRes.ResType;

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                }

                this.AddButton(15, 462, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    this.AddHtmlLocalized(50, 465, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    this.AddLabel(50, 465, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }
            // ****************************************

            // For dragon scales
            if (craftSystem.CraftSubRes2.Init)
            {
                string nameString = craftSystem.CraftSubRes2.NameString;
                int    nameNumber = craftSystem.CraftSubRes2.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex2);

                Type resourceType = craftSystem.CraftSubRes2.ResType;

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                }

                this.AddButton(15, 482, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    this.AddHtmlLocalized(50, 485, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    this.AddLabel(50, 485, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }
            // ****************************************

            this.CreateGroupList();

            if (page == CraftPage.PickResource)
            {
                this.CreateResList(false, from);
            }
            else if (page == CraftPage.PickResource2)
            {
                this.CreateResList(true, from);
            }
            else if (context != null && context.LastGroupIndex > -1)
            {
                this.CreateItemList(context.LastGroupIndex);
            }
        }
Beispiel #6
0
        static int EXTRA_CATS = 40;//extra space to add
        private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page) : base(40, 40)
        {
            m_From        = from;
            m_CraftSystem = craftSystem;
            m_Tool        = tool;
            m_Page        = page;

            CraftContext context = craftSystem.GetContext(from);

            from.CloseGump(typeof(CraftGump));
            from.CloseGump(typeof(CraftGumpItem));

            AddPage(0);

            AddBackground(0, 0, 530, 437 + EXTRA_CATS, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 292 + EXTRA_CATS, 150, 45, 2624);              //NOTICES BG
            AddImageTiled(165, 292 + EXTRA_CATS, 355, 45, 2624);             //MSG AREA
            AddImageTiled(10, 342 + EXTRA_CATS, 510, 85, 2624);              //large main sec bot
            AddImageTiled(10, 37, 200, 250 + EXTRA_CATS, 2624);              // bg under the cats
            AddImageTiled(215, 37, 305, 250 + EXTRA_CATS, 2624);
            AddAlphaRegion(10, 10, 510, 417 + EXTRA_CATS);

            if (craftSystem.GumpTitleNumber > 0)
            {
                AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
            }

            AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false);               // <CENTER>CATEGORIES</CENTER>
            AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false);              // <CENTER>SELECTIONS</CENTER>
            AddHtmlLocalized(10, 302 + EXTRA_CATS, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER>

            AddButton(15, 402 + EXTRA_CATS, 4017, 4019, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 405 + EXTRA_CATS, 150, 18, 1011441, LabelColor, false, false);               // EXIT

            AddButton(270, 402 + EXTRA_CATS, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0);
            AddHtmlLocalized(305, 405 + EXTRA_CATS, 150, 18, 1044013, LabelColor, false, false);               // MAKE LAST

            // Mark option
            if (craftSystem.MarkOption)
            {
                AddButton(270, 362 + EXTRA_CATS, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 365 + EXTRA_CATS, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false);                   // MARK ITEM
            }
            // ****************************************

            // Resmelt option
            if (craftSystem.Resmelt)
            {
                AddButton(15, 342 + EXTRA_CATS, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0);
                AddHtmlLocalized(50, 345 + EXTRA_CATS, 150, 18, 1044259, LabelColor, false, false);                   // SMELT ITEM
            }
            // ****************************************

            // Repair option
            if (craftSystem.Repair)
            {
                AddButton(270, 342 + EXTRA_CATS, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 345 + EXTRA_CATS, 150, 18, 1044260, LabelColor, false, false);                   // REPAIR ITEM
            }
            // ****************************************

            // Enhance option
            if (craftSystem.CanEnhance)
            {
                AddButton(270, 382 + EXTRA_CATS, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 385 + EXTRA_CATS, 150, 18, 1061001, LabelColor, false, false);                   // ENHANCE ITEM
            }
            // ****************************************

            if (notice is int && (int)notice > 0)
            {
                AddHtmlLocalized(170, 295 + EXTRA_CATS, 350, 40, (int)notice, LabelColor, false, false);
            }
            else if (notice is string)
            {
                AddHtml(170, 295 + EXTRA_CATS, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false);
            }

            // If the system has more than one resource
            if (craftSystem.CraftSubRes.Init)
            {
                string nameString = craftSystem.CraftSubRes.NameString;
                int    nameNumber = craftSystem.CraftSubRes.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex);

                Type resourceType = craftSystem.CraftSubRes.ResType;

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                }

                AddButton(15, 362 + EXTRA_CATS, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 365 + EXTRA_CATS, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 362 + EXTRA_CATS, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }
            // ****************************************

            // For dragon scales
            if (craftSystem.CraftSubRes2.Init)
            {
                string nameString = craftSystem.CraftSubRes2.NameString;
                int    nameNumber = craftSystem.CraftSubRes2.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex2);

                Type resourceType = craftSystem.CraftSubRes2.ResType;

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                }

                AddButton(15, 382, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 385, LabelHue, String.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }
            // ****************************************

            CreateGroupList();

            if (page == CraftPage.PickResource)
            {
                CreateResList(false, from);
            }
            else if (page == CraftPage.PickResource2)
            {
                CreateResList(true, from);
            }
            else if (context != null && context.LastGroupIndex > -1)
            {
                CreateItemList(context.LastGroupIndex);
            }
        }
Beispiel #7
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID <= 0)
            {
                return; // Canceled
            }

            int buttonID = info.ButtonID - 1;
            int type     = buttonID % 7;
            int index    = buttonID / 7;

            CraftSystem   system  = m_CraftSystem;
            CraftGroupCol groups  = system.CraftGroups;
            CraftContext  context = system.GetContext(m_From);

            #region Stygian Abyss
            if (Locked)
            {
                if (type == 6 && index == 11)
                {
                    // Cancel Make
                    AutoCraftTimer.EndTimer(m_From);
                }
                return;
            }
            #endregion

            switch (type)
            {
            case 0:     // Show group
            {
                if (context == null)
                {
                    break;
                }

                if (index >= 0 && index < groups.Count)
                {
                    context.LastGroupIndex = index;
                    m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                }

                break;
            }

            case 1:     // Create item
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    CraftGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.CraftItems.Count)
                    {
                        CraftItem(group.CraftItems.GetAt(index));
                    }
                }

                break;
            }

            case 2:     // Item details
            {
                if (context == null)
                {
                    break;
                }

                int groupIndex = context.LastGroupIndex;

                if (groupIndex >= 0 && groupIndex < groups.Count)
                {
                    CraftGroup group = groups.GetAt(groupIndex);

                    if (index >= 0 && index < group.CraftItems.Count)
                    {
                        m_From.SendGump(new CraftGumpItem(m_From, system, group.CraftItems.GetAt(index), m_Tool));
                    }
                }

                break;
            }

            case 3:     // Create item (last 10)
            {
                if (context == null)
                {
                    break;
                }

                List <CraftItem> lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    CraftItem(lastTen[index]);
                }

                break;
            }

            case 4:     // Item details (last 10)
            {
                if (context == null)
                {
                    break;
                }

                List <CraftItem> lastTen = context.Items;

                if (index >= 0 && index < lastTen.Count)
                {
                    m_From.SendGump(new CraftGumpItem(m_From, system, lastTen[index], m_Tool));
                }

                break;
            }

            case 5:     // Resource selected
            {
                if (m_Page == CraftPage.PickResource && index >= 0 && index < system.CraftSubRes.Count)
                {
                    _ = context == null ? -1 : context.LastGroupIndex;

                    CraftSubRes res = system.CraftSubRes.GetAt(index);

                    if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex = index;
                        }

                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                    }
                }
                else if (m_Page == CraftPage.PickResource2 && index >= 0 && index < system.CraftSubRes2.Count)
                {
                    _ = context == null ? -1 : context.LastGroupIndex;

                    CraftSubRes res = system.CraftSubRes2.GetAt(index);

                    if (m_From.Skills[system.MainSkill].Base < res.RequiredSkill)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, res.Message));
                    }
                    else
                    {
                        if (context != null)
                        {
                            context.LastResourceIndex2 = index;
                        }

                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));
                    }
                }

                break;
            }

            case 6:     // Misc. buttons
            {
                switch (index)
                {
                case 0:             // Resource selection
                {
                    if (system.CraftSubRes.Init)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource));
                    }

                    break;
                }

                case 1:             // Smelt item
                {
                    if (system.Resmelt)
                    {
                        Resmelt.Do(m_From, system, m_Tool);
                    }

                    break;
                }

                case 2:             // Make last
                {
                    if (context == null)
                    {
                        break;
                    }

                    CraftItem item = context.LastMade;

                    if (item != null)
                    {
                        CraftItem(item);
                    }
                    else
                    {
                        m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, 1044165, m_Page));                 // You haven't made anything yet.
                    }

                    break;
                }

                case 3:             // Last 10
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.LastGroupIndex = 501;
                    m_From.SendGump(new CraftGump(m_From, system, m_Tool, null));

                    break;
                }

                case 4:             // Toggle use resource hue
                {
                    if (context == null)
                    {
                        break;
                    }

                    context.DoNotColor = !context.DoNotColor;

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 5:             // Repair item
                {
                    if (system.Repair)
                    {
                        Repair.Do(m_From, system, m_Tool);
                    }

                    break;
                }

                case 6:             // Toggle mark option
                {
                    if (context == null || !system.MarkOption)
                    {
                        break;
                    }

                    switch (context.MarkOption)
                    {
                    case CraftMarkOption.MarkItem:
                        context.MarkOption = CraftMarkOption.DoNotMark;
                        break;

                    case CraftMarkOption.DoNotMark:
                        context.MarkOption = CraftMarkOption.PromptForMark;
                        break;

                    case CraftMarkOption.PromptForMark:
                        context.MarkOption = CraftMarkOption.MarkItem;
                        break;
                    }

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 7:             // Resource selection 2
                {
                    if (system.CraftSubRes2.Init)
                    {
                        m_From.SendGump(new CraftGump(m_From, system, m_Tool, null, CraftPage.PickResource2));
                    }

                    break;
                }

                case 8:             // Enhance item
                {
                    if (system.CanEnhance)
                    {
                        Enhance.BeginTarget(m_From, system, m_Tool);
                    }

                    break;
                }

                case 9:             // Alter Item (Gargoyle)
                {
                    if (system.CanAlter)
                    {
                        if (SkillHandlers.Imbuing.CheckSoulForge(m_From, 1, false))
                        {
                            AlterItem.BeginTarget(m_From, system, m_Tool);
                        }
                        else
                        {
                            m_From.SendLocalizedMessage(1111867);                 // You must be near a soulforge to alter an item.
                        }
                    }
                    break;
                }

                case 10:             // Quest Item/Non Quest Item toggle
                {
                    //if (context == null || !system.QuestOption)
                    //break;
                    switch (context.QuestOption)
                    {
                    case CraftQuestOption.QuestItem:
                        context.QuestOption = CraftQuestOption.NonQuestItem;
                        break;

                    case CraftQuestOption.NonQuestItem:
                        context.QuestOption = CraftQuestOption.QuestItem;
                        break;
                    }

                    m_From.SendGump(new CraftGump(m_From, m_CraftSystem, m_Tool, null, m_Page));

                    break;
                }

                case 11:             // Cancel Make
                {
                    AutoCraftTimer.EndTimer(m_From);
                    break;
                }
                }
                break;
            }
            }
        }
Beispiel #8
0
 public void AddSubRes2(Type type, int name, double reqSkill, int genericName, object message)
 {
     CraftSubRes craftSubRes = new CraftSubRes(type, name, reqSkill, genericName, message);
     this.m_CraftSubRes2.Add(craftSubRes);
 }
Beispiel #9
0
        public void CreateResList(bool opt, Mobile from)
        {
            CraftSubResCol res = (opt ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);

            for (int i = 0; i < res.Count; ++i)
            {
                int index = i % 10;

                CraftSubRes subResource = res.GetAt(i);

                if (index == 0)
                {
                    if (i > 0)
                    {
                        AddButton(485, 290, 4005, 4007, 0, GumpButtonType.Page, (i / 10) + 1);
                    }

                    AddPage((i / 10) + 1);

                    if (i > 0)
                    {
                        AddButton(455, 290, 4014, 4015, 0, GumpButtonType.Page, i / 10);
                    }

                    CraftContext context = m_CraftSystem.GetContext(m_From);

                    AddButton(220, 260, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0);
                    AddHtmlLocalized(255, 260, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false);
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(subResource.ItemType, true);

                    for (int j = 0; j < items.Length; ++j)
                    {
                        resourceCount += items[j].Amount;
                    }

                    Type alt = GetAltType(subResource.ItemType);

                    if (alt != null)
                    {
                        Item[] items2 = m_From.Backpack.FindItemsByType(alt, true);

                        for (int j = 0; j < items2.Length; ++j)
                        {
                            resourceCount += items2[j].Amount;
                        }
                    }
                }

                AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0);

                if (subResource.NameNumber > 0)
                {
                    AddHtmlLocalized(255, 63 + (index * 20), 250, 18, subResource.NameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    AddLabel(255, 60 + (index * 20), LabelHue, $"{subResource.NameString} ({resourceCount})");
                }
            }
        }
Beispiel #10
0
        private CraftGump(Mobile from, CraftSystem craftSystem, ITool tool, object notice, CraftPage page)
            : base(40, 40)
        {
            m_From        = from;
            m_CraftSystem = craftSystem;
            m_Tool        = tool;
            m_Page        = page;

            CraftContext context = craftSystem.GetContext(from);

            from.CloseGump(typeof(CraftGump));
            from.CloseGump(typeof(CraftGumpItem));

            AddPage(0);

            AddBackground(0, 0, 530, 497, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 292, 150, 45, 2624);
            AddImageTiled(165, 292, 355, 45, 2624);
            AddImageTiled(10, 342, 510, 145, 2624);
            AddImageTiled(10, 37, 200, 250, 2624);
            AddImageTiled(215, 37, 305, 250, 2624);
            AddAlphaRegion(10, 10, 510, 477);

            if (craftSystem.GumpTitleNumber > 0)
            {
                AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
            }

            AddHtmlLocalized(10, 37, 200, 22, 1044010, LabelColor, false, false);  // <CENTER>CATEGORIES</CENTER>
            AddHtmlLocalized(215, 37, 305, 22, 1044011, LabelColor, false, false); // <CENTER>SELECTIONS</CENTER>
            AddHtmlLocalized(10, 302, 150, 25, 1044012, LabelColor, false, false); // <CENTER>NOTICES</CENTER>

            AddButton(15, 442, 4017, 4019, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 445, 150, 18, 1011441, LabelColor, false, false); // EXIT

            AddButton(115, 442, 4017, 4019, GetButtonID(6, 11), GumpButtonType.Reply, 0);
            AddHtmlLocalized(150, 445, 150, 18, 1112698, LabelColor, false, false); // CANCEL MAKE

            if (m_CraftSystem.Repair)
            {
                AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false); // REPAIR ITEM
            }

            if (m_CraftSystem.MarkOption)
            {
                AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false); // MARK ITEM
            }

            if (m_CraftSystem.CanEnhance)
            {
                AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false); // ENHANCE ITEM
            }

            #region SA
            // Alter option
            if (Core.SA && m_CraftSystem.CanAlter)
            {
                AddButton(270, 402, 4005, 4007, GetButtonID(6, 9), GumpButtonType.Reply, 0);
                AddHtmlLocalized(304, 405, 250, 18, 1094726, LabelColor, false, false); // ALTER ITEM (Gargoyle)
            }
            // ****************************************

            // Quest item
            if (Core.SA)
            {
                AddButton(270, 422, 4005, 4007, GetButtonID(6, 10), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 425, 150, 18, context != null && context.QuestOption == CraftQuestOption.QuestItem ? 1112534 : 1112533, LabelColor, false, false); // QUEST ITEM
            }
            // ****************************************
            #endregion

            AddButton(270, 442, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0);
            AddHtmlLocalized(305, 445, 150, 18, 1044013, LabelColor, false, false); // MAKE LAST

            #region Stygian Abyss
            int total = 1;
            int made  = 0;

            if (Locked && AutoCraftTimer.AutoCraftTable.ContainsKey(m_From))
            {
                AutoCraftTimer timer = AutoCraftTimer.AutoCraftTable[m_From];

                if (timer != null)
                {
                    total = timer.Amount;
                    made  = timer.Attempts;
                }
                else
                {
                    if (context != null)
                    {
                        total = context.MakeTotal;
                    }
                }
            }

            string args = string.Format("{0}\t{1}", made.ToString(), total.ToString());

            AddHtmlLocalized(270, 468, 150, 18, 1079443, args, LabelColor, false, false); //~1_DONE~/~2_TOTAL~ COMPLETED
            #endregion

            // Resmelt option
            if (m_CraftSystem.Resmelt)
            {
                AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0);
                AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false); // SMELT ITEM
            }

            if (notice is int && (int)notice > 0)
            {
                AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false);
            }
            else if (notice is string)
            {
                AddHtml(170, 295, 350, 40, string.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false);
            }

            // If the system has more than one resource
            if (craftSystem.CraftSubRes.Init)
            {
                string nameString = craftSystem.CraftSubRes.NameString;
                int    nameNumber = craftSystem.CraftSubRes.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex);

                Type resourceType = craftSystem.CraftSubRes.ResType;

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                Type resourceType2 = GetAltType(resourceType);
                int  resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }

                    if (resourceType2 != null)
                    {
                        Item[] items2 = m_From.Backpack.FindItemsByType(resourceType2, true);

                        for (int i = 0; i < items2.Length; ++i)
                        {
                            resourceCount += items2[i].Amount;
                        }
                    }
                }

                AddButton(15, 362, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    if (context.DoNotColor)
                    {
                        AddLabel(50, 365, LabelHue, "*");
                    }

                    AddHtmlLocalized(50 + (context.DoNotColor ? 13 : 0), 365, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 362, LabelHue, (context.DoNotColor ? "*" : "") + string.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }

            // For dragon scales
            if (craftSystem.CraftSubRes2.Init)
            {
                string nameString = craftSystem.CraftSubRes2.NameString;
                int    nameNumber = craftSystem.CraftSubRes2.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex2);

                Type resourceType = craftSystem.CraftSubRes2.ResType;

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex);

                    nameString   = subResource.NameString;
                    nameNumber   = subResource.NameNumber;
                    resourceType = subResource.ItemType;
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(resourceType, true);

                    for (int i = 0; i < items.Length; ++i)
                    {
                        resourceCount += items[i].Amount;
                    }
                }

                AddButton(15, 382, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 385, 250, 18, nameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 385, LabelHue, string.Format("{0} ({1} Available)", nameString, resourceCount));
                }
            }

            CreateGroupList();

            if (page == CraftPage.PickResource)
            {
                CreateResList(false, from);
            }
            else if (page == CraftPage.PickResource2)
            {
                CreateResList(true, from);
            }
            else if (context != null && context.LastGroupIndex > -1)
            {
                CreateItemList(context.LastGroupIndex);
            }
        }
        public void AddSubRes(Type type, int name, double reqSkill, object message)
        {
            CraftSubRes craftSubRes = new CraftSubRes(type, name, reqSkill, message);

            this.m_CraftSubRes.Add(craftSubRes);
        }
Beispiel #12
0
        public CraftGumpItem(Mobile from, CraftSystem craftSystem, CraftItem craftItem, BaseTool tool)
            : base(50, 50)
        {
            m_From        = from;
            m_CraftSystem = craftSystem;
            m_CraftItem   = craftItem;
            m_Tool        = tool;

            from.CloseGump(typeof(CraftGump));
            from.CloseGump(typeof(CraftGumpItem));

            AddPage(0);
            AddBackground(0, 0, 530, 417, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 37, 150, 148, 2624);
            AddImageTiled(165, 37, 355, 90, 2624);
            AddImageTiled(10, 190, 155, 22, 2624);
            AddImageTiled(10, 237, 155, 53, 2624);
            AddImageTiled(165, 132, 355, 80, 2624);
            AddImageTiled(10, 275, 155, 22, 2624);
            AddImageTiled(10, 322, 155, 53, 2624);
            AddImageTiled(165, 217, 355, 80, 2624);
            AddImageTiled(10, 360, 155, 22, 2624);
            AddImageTiled(165, 302, 355, 80, 2624);
            AddImageTiled(10, 387, 510, 22, 2624);
            AddAlphaRegion(10, 10, 510, 397);

            AddHtmlLocalized(170, 40, 150, 20, 1044053, LabelColor, false, false);               // ITEM
            AddHtmlLocalized(10, 215, 150, 22, 1044055, LabelColor, false, false);               // <CENTER>MATERIALS</CENTER>
            AddHtmlLocalized(10, 300, 150, 22, 1044056, LabelColor, false, false);               // <CENTER>OTHER</CENTER>

            if (craftSystem.GumpTitleNumber > 0)
            {
                AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
            }

            AddButton(15, 387, 4014, 4016, 9999, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 390, 150, 18, 1044150, LabelColor, false, false);               // BACK

            // Draw Item
            Type type = m_CraftItem.ItemType;

            if (m_CraftItem.IsMarkable(type))
            {
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1044059, LabelColor, false, false);                      // This item may hold its maker's mark
                m_ShowExceptionalChance = true;
            }

            if (craftItem.NameNumber > 0)
            {
                AddHtmlLocalized(330, 40, 180, 18, craftItem.NameNumber, LabelColor, false, false);
            }
            else
            {
                AddLabel(330, 40, LabelHue, craftItem.NameString);
            }

            AddItem(20, 50, CraftItem.ItemIDOf(type));
            // ***********************************

            // Draw Skills
            for (int i = 0; i < m_CraftItem.Skills.Count; i++)
            {
                CraftSkill skill    = m_CraftItem.Skills.GetAt(i);
                double     minSkill = skill.MinSkill;

                if (minSkill < 0)
                {
                    minSkill = 0;
                }

                AddHtmlLocalized(170, 132 + (i * 20), 200, 18, 1044060 + (int)skill.SkillToMake, LabelColor, false, false);
                AddLabel(430, 132 + (i * 20), LabelHue, String.Format("{0:F1}", minSkill).Replace(",", "."));
            }
            // ***********************************

            // Draw Ressource
            bool retainedColor = false;

            CraftContext context = m_CraftSystem.GetContext(m_From);

            CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
            int            resIndex = -1;

            if (context != null)
            {
                resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
            }

            bool cropScroll = (m_CraftItem.Ressources.Count > 1) && m_CraftItem.Ressources.GetAt(m_CraftItem.Ressources.Count - 1).ItemType == typeofBlankScroll && typeofSpellScroll.IsAssignableFrom(m_CraftItem.ItemType);

            for (int i = 0; i < m_CraftItem.Ressources.Count - (cropScroll ? 1 : 0) && i < 4; i++)
            {
                Type   _type;
                string nameString;
                int    nameNumber;

                CraftRes craftResource = m_CraftItem.Ressources.GetAt(i);

                _type      = craftResource.ItemType;
                nameString = craftResource.NameString;
                nameNumber = craftResource.NameNumber;
                int amount = craftResource.Amount;

                // Resource Mutation
                if (_type == res.ResType && resIndex > -1)
                {
                    CraftSubRes subResource = res.GetAt(resIndex);

                    _type = subResource.ItemType;

                    nameString = subResource.NameString;
                    nameNumber = subResource.GenericNameNumber;

                    if (nameNumber <= 0)
                    {
                        nameNumber = subResource.NameNumber;
                    }
                }
                // ******************

                if (m_CraftItem.NameNumber == 1044458)                   // cut-up cloth
                {
                    amount = 0;

                    AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 360, 18, 1044460, LabelColor, false, false);                          // Cut bolts of cloth into pieces of ready cloth.
                    AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1048176, LabelColor, false, false);                          // Makes as many as possible at once
                }

                if (m_CraftItem.NameNumber == 1044459)                   //combine cloth
                {
                    amount = 0;

                    AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 360, 18, 1044461, LabelColor, false, false);                          // Combine available cloth into piles by color.
                    AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1048176, LabelColor, false, false);                          // Makes as many as possible at once
                }

                if (!retainedColor && m_CraftItem.RetainsColorFrom(m_CraftSystem, _type))
                {
                    retainedColor = true;
                    AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1044152, LabelColor, false, false);                          // * The item retains the color of this material
                    AddLabel(500, 219 + (i * 20), LabelHue, "*");
                }

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(170, 219 + (i * 20), 310, 18, nameNumber, LabelColor, false, false);
                }
                else
                {
                    AddLabel(170, 219 + (i * 20), LabelHue, nameString);
                }

                AddHtml(430, 219 + (i * 20), 40, 20, String.Format("<basefont color=#FFFFFF><div align=right>{0}</basefont></div>", amount.ToString()), false, false);
            }

            if (m_CraftItem.NameNumber == 1041267)               // runebook
            {
                AddHtmlLocalized(170, 219 + (m_CraftItem.Ressources.Count * 20), 310, 18, 1044447, LabelColor, false, false);
                AddHtml(430, 219 + (m_CraftItem.Ressources.Count * 20), 40, 20, String.Format("<basefont color=#FFFFFF><div align=right>{0}</basefont></div>", "1"), false, false);
            }
            // ***********************************

            if (craftItem.UseAllRes)
            {
                // Makes as many as possible at once
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1048176, LabelColor, false, false);
            }

            if (craftItem.RequiresSE)
            {
                // * Requires the "Samurai Empire" expansion
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1063363, LabelColor, false, false);
            }

            if (craftItem.RequiresML)
            {
                // * Requires the "Mondain's Legacy" expansion
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1072651, LabelColor, false, false);
            }

            if (craftItem.RequiresSA)
            {
                // * Requires the "Stygian Abyss" expansion
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1094732, LabelColor, false, false);
            }

            if (craftItem.RequiresHS)
            {
                // * Requires the "High Seas" booster
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1116296, LabelColor, false, false);
            }

            bool needsRecipe = (craftItem.Recipe != null && from is PlayerMobile && !((PlayerMobile)from).HasRecipe(craftItem.Recipe));

            if (needsRecipe)
            {
                // You have not learned this recipe.
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1073620, RedLabelColor, false, false);
            }

            if (cropScroll)
            {
                // Inscribing scrolls also requires a blank scroll and mana.
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 360, 18, 1044379, LabelColor, false, false);
            }

            if (needsRecipe)
            {
                AddButton(135, 387, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 0);
                AddHtmlLocalized(180, 390, 150, 18, 1112624, 0x3DEF, false, false);                   // MAKE MAX

                AddButton(255, 387, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 0);
                AddHtmlLocalized(300, 390, 150, 18, 1112623, 0x3DEF, false, false);                   // MAKE NUMBER

                AddButton(405, 387, 4005, 4007, 0, GumpButtonType.Page, 0);
                AddHtmlLocalized(450, 390, 150, 18, 1044151, GreyLabelColor, false, false);                   // MAKE NOW
            }
            else
            {
                AddButton(135, 387, 0xFAE, 0xFB0, craftItem.CraftId + 11000, GumpButtonType.Reply, 0);
                AddHtmlLocalized(180, 390, 150, 18, 1112624, 0x7FFF, false, false);                   // MAKE MAX

                AddButton(255, 387, 0xFAE, 0xFB0, craftItem.CraftId + 10000, GumpButtonType.Reply, 0);
                AddHtmlLocalized(300, 390, 150, 18, 1112623, 0x7FFF, false, false);                   // MAKE NUMBER

                AddButton(405, 387, 4005, 4007, craftItem.CraftId, GumpButtonType.Reply, 0);
                AddHtmlLocalized(450, 390, 150, 18, 1044151, LabelColor, false, false);                   // MAKE NOW
            }

            // Draw Chances
            DrawChances();
            // ***********************************
        }
Beispiel #13
0
        public bool ConsumeRes(Mobile from, Type typeRes, CraftSystem craftSystem, ref int resHue, ref int maxAmount, ConsumeType consumeType, ref object message, bool isFailure)
        {
            Container ourPack = from.Backpack;

            if (ourPack == null)
            {
                return(false);
            }

            if (m_NeedHeat && !Find(from, m_HeatSources))
            {
                message = 1044487; // You must be near a fire source to cook.
                return(false);
            }

            if (m_NeedOven && !Find(from, m_Ovens))
            {
                message = 1044493; // You must be near an oven to bake that.
                return(false);
            }

            if (m_NeedMill && !Find(from, m_Mills))
            {
                message = 1044491; // You must be near a flour mill to do that.
                return(false);
            }

            Type[][] types   = new Type[m_arCraftRes.Count][];
            int[]    amounts = new int[m_arCraftRes.Count];

            maxAmount = int.MaxValue;

            CraftSubResCol resCol = (m_UseSubRes2 ? craftSystem.CraftSubRes2 : craftSystem.CraftSubRes);

            for (int i = 0; i < types.Length; ++i)
            {
                CraftRes craftRes = m_arCraftRes.GetAt(i);
                Type     baseType = craftRes.ItemType;

                // Resource Mutation
                if ((baseType == resCol.ResType) && (typeRes != null))
                {
                    baseType = typeRes;

                    CraftSubRes subResource = resCol.SearchFor(baseType);

                    if (subResource != null && from.Skills[craftSystem.MainSkill].Base < subResource.RequiredSkill)
                    {
                        message = subResource.Message;
                        return(false);
                    }
                }
                // ******************

                for (int j = 0; types[i] == null && j < m_TypesTable.Length; ++j)
                {
                    if (m_TypesTable[j][0] == baseType)
                    {
                        types[i] = m_TypesTable[j];
                    }
                }

                if (types[i] == null)
                {
                    types[i] = new Type[] { baseType }
                }
                ;

                amounts[i] = craftRes.Amount;

                // For stackable items that can ben crafted more than one at a time
                if (UseAllRes)
                {
                    int tempAmount = ourPack.GetAmount(types[i]);
                    tempAmount /= amounts[i];
                    if (tempAmount < maxAmount)
                    {
                        maxAmount = tempAmount;

                        if (maxAmount == 0)
                        {
                            CraftRes res = m_arCraftRes.GetAt(i);

                            if (res.MessageNumber > 0)
                            {
                                message = res.MessageNumber;
                            }
                            else if (!String.IsNullOrEmpty(res.MessageString))
                            {
                                message = res.MessageString;
                            }
                            else
                            {
                                message = 502925; // You don't have the resources required to make that item.
                            }
                            return(false);
                        }
                    }
                }
                // ****************************

                if (isFailure && !craftSystem.ConsumeOnFailure(from, types[i][0], this))
                {
                    amounts[i] = 0;
                }
            }

            // We adjust the amount of each resource to consume the max posible
            if (UseAllRes)
            {
                for (int i = 0; i < amounts.Length; ++i)
                {
                    amounts[i] *= maxAmount;
                }
            }
            else
            {
                maxAmount = -1;
            }

            Item consumeExtra = null;

            if (m_NameNumber == 1041267)
            {
                // Runebooks are a special case, they need a blank recall rune

                List <RecallRune> runes = ourPack.FindItemsByType <RecallRune>();

                for (int i = 0; i < runes.Count; ++i)
                {
                    RecallRune rune = runes[i];

                    if (rune != null && !rune.Marked)
                    {
                        consumeExtra = rune;
                        break;
                    }
                }

                if (consumeExtra == null)
                {
                    message = 1044253; // You don't have the components needed to make that.
                    return(false);
                }
            }

            int index = 0;

            // Consume ALL
            if (consumeType == ConsumeType.All)
            {
                m_ResHue = 0; m_ResAmount = 0; m_System = craftSystem;

                if (IsQuantityType(types))
                {
                    index = ConsumeQuantity(ourPack, types, amounts);
                }
                else
                {
                    index = ourPack.ConsumeTotalGrouped(types, amounts, true, new OnItemConsumed(OnResourceConsumed), new CheckItemGroup(CheckHueGrouping));
                }

                resHue = m_ResHue;
            }

            // Consume Half ( for use all resource craft type )
            else if (consumeType == ConsumeType.Half)
            {
                for (int i = 0; i < amounts.Length; i++)
                {
                    amounts[i] /= 2;

                    if (amounts[i] < 1)
                    {
                        amounts[i] = 1;
                    }
                }

                m_ResHue = 0; m_ResAmount = 0; m_System = craftSystem;

                if (IsQuantityType(types))
                {
                    index = ConsumeQuantity(ourPack, types, amounts);
                }
                else
                {
                    index = ourPack.ConsumeTotalGrouped(types, amounts, true, new OnItemConsumed(OnResourceConsumed), new CheckItemGroup(CheckHueGrouping));
                }

                resHue = m_ResHue;
            }

            else // ConstumeType.None ( it's basicaly used to know if the crafter has enough resource before starting the process )
            {
                index = -1;

                if (IsQuantityType(types))
                {
                    for (int i = 0; i < types.Length; i++)
                    {
                        if (GetQuantity(ourPack, types[i]) < amounts[i])
                        {
                            index = i;
                            break;
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < types.Length; i++)
                    {
                        if (ourPack.GetBestGroupAmount(types[i], true, new CheckItemGroup(CheckHueGrouping)) < amounts[i])
                        {
                            index = i;
                            break;
                        }
                    }
                }
            }

            if (index == -1)
            {
                if (consumeType != ConsumeType.None)
                {
                    if (consumeExtra != null)
                    {
                        consumeExtra.Delete();
                    }
                }

                return(true);
            }
            else
            {
                CraftRes res = m_arCraftRes.GetAt(index);

                if (res.MessageNumber > 0)
                {
                    message = res.MessageNumber;
                }
                else if (res.MessageString != null && res.MessageString != String.Empty)
                {
                    message = res.MessageString;
                }
                else
                {
                    message = 502925; // You don't have the resources required to make that item.
                }
                return(false);
            }
        }
Beispiel #14
0
		public void Add( CraftSubRes craftSubRes )
		{
			List.Add( craftSubRes );
		}
        public void DrawResource()
        {
            bool retainedColor = false;

            CraftContext context = m_CraftSystem.GetContext(m_From);

            CraftSubResCol res      = (m_CraftItem.UseSubRes2 ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);
            int            resIndex = -1;

            if (context != null)
            {
                resIndex = (m_CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);
            }

            bool cropScroll = (m_CraftItem.Ressources.Count > 1) &&
                              m_CraftItem.Ressources.GetAt(m_CraftItem.Ressources.Count - 1).ItemType == typeofBlankScroll &&
                              typeofSpellScroll.IsAssignableFrom(m_CraftItem.ItemType);

            for (int i = 0; i < m_CraftItem.Ressources.Count - (cropScroll ? 1 : 0) && i < 4; i++)
            {
                Type   type;
                string nameString;
                int    nameNumber;

                CraftRes craftResource = m_CraftItem.Ressources.GetAt(i);

                type       = craftResource.ItemType;
                nameString = craftResource.NameString;
                nameNumber = craftResource.NameNumber;

                // Resource Mutation
                if (type == res.ResType && resIndex > -1)
                {
                    CraftSubRes subResource = res.GetAt(resIndex);

                    type = subResource.ItemType;

                    nameString = subResource.NameString;
                    nameNumber = subResource.GenericNameNumber;

                    if (nameNumber <= 0)
                    {
                        nameNumber = subResource.NameNumber;
                    }
                }
                // ******************

                if (!retainedColor && m_CraftItem.RetainsColorFrom(m_CraftSystem, type))
                {
                    retainedColor = true;
                    AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 310, 18, 1044152, LabelColor, false, false);                        // * The item retains the color of this material
                    AddLabel(500, 219 + (i * 20), LabelHue, "*");
                }

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(170, 219 + (i * 20), 310, 18, nameNumber, LabelColor, false, false);
                }
                else
                {
                    AddLabel(170, 219 + (i * 20), LabelHue, nameString);
                }

                AddLabel(460, 219 + (i * 20), LabelHue, craftResource.Amount.ToString());
            }

            if (m_CraftItem.NameNumber == 1041267)               // runebook
            {
                AddHtmlLocalized(170, 219 + (m_CraftItem.Ressources.Count * 20), 310, 18, 1044447, LabelColor, false, false);
                AddLabel(460, 219 + (m_CraftItem.Ressources.Count * 20), LabelHue, "1");
            }

            if (cropScroll)
            {
                AddHtmlLocalized(170, 302 + (m_OtherCount++ *20), 360, 18, 1044379, LabelColor, false, false);                    // Inscribing scrolls also requires a blank scroll and mana.
            }
        }
Beispiel #16
0
		public void AddSubRes( Type type, int name, double reqSkill, object message )
		{
			CraftSubRes craftSubRes = new CraftSubRes( type, name, reqSkill, message );
			m_CraftSubRes.Add( craftSubRes );
		}
Beispiel #17
0
        public void CreateResList(bool opt, Mobile from)
        {
            CraftSubResCol res = (opt ? m_CraftSystem.CraftSubRes2 : m_CraftSystem.CraftSubRes);

            for (int i = 0; i < res.Count; ++i)
            {
                int index = i % numitemsPerPage;

                CraftSubRes subResource = res.GetAt(i);

                if (index == 0)
                {
                    if (i > 0)
                    {
                        AddButton(485, 320, 4005, 4007, 0, GumpButtonType.Page, (i / numitemsPerPage) + 1);
                    }

                    AddPage((i / numitemsPerPage) + 1);

                    if (i > 0)
                    {
                        AddButton(455, 320, 4014, 4015, 0, GumpButtonType.Page, i / numitemsPerPage);
                    }

                    CraftContext context = m_CraftSystem.GetContext(m_From);

                    AddButton(220, 320, 4005, 4007, GetButtonID(6, 4), GumpButtonType.Reply, 0);
                    AddHtmlLocalized(255, 323, 200, 18, (context == null || !context.DoNotColor) ? 1061591 : 1061590, LabelColor, false, false);
                }

                int resourceCount = 0;

                if (from.Backpack != null)
                {
                    Item[] items = from.Backpack.FindItemsByType(subResource.ItemType, true);

                    for (int j = 0; j < items.Length; ++j)
                    {
                        resourceCount += items[j].Amount;
                    }
                }

                AddButton(220, 60 + (index * 20), 4005, 4007, GetButtonID(5, i), GumpButtonType.Reply, 0);

                if (subResource.NameNumber > 0)
                {
                    AddHtmlLocalized(255, 63 + (index * 20), 250, 18, subResource.NameNumber, resourceCount.ToString(), LabelColor, false, false);
                }
                else
                {
                    if (m_From.NetState.Version.Major <= 3)
                    {
                        AddHtml(255, 63 + (index * 20), 250, 18, String.Format("<BASEFONT COLOR=BLACK>{0}", subResource.NameString), false, false);
                    }
                    else
                    {
                        AddHtml(255, 63 + (index * 20), 250, 18, String.Format("<BASEFONT COLOR=WHITE>{0}", subResource.NameString), false, false);
                    }
                    //else
                    //    AddHtml(255, 63 + (index * 20), 250, 18, String.Format("{0} ({1})", subResource.NameString, resourceCount), false, false);
                }
                //AddLabel( 255, 60 + ( index * 20 ), LabelHue, String.Format( "{0} ({1})", subResource.NameString, resourceCount ) );
            }
        }
Beispiel #18
0
 public void AddSubRes2(Type type, string name, double reqSkill, object message)
 {
     CraftSubRes craftSubRes = new CraftSubRes(type, name, reqSkill, message);
     this.m_CraftSubRes2.Add(craftSubRes);
 }
Beispiel #19
0
        private CraftGump(Mobile from, CraftSystem craftSystem, BaseTool tool, object notice, CraftPage page) : base(30, 30)             // eddited by sam for woodworking changes
        {
            m_From        = from;
            m_CraftSystem = craftSystem;
            m_Tool        = tool;
            m_Page        = page;

            CraftContext context = craftSystem.GetContext(from);

            from.CloseGump(typeof(CraftGump));
            from.CloseGump(typeof(CraftGumpItem));

            AddPage(0);               //edited by sam

            AddBackground(0, 0, 530, 437, 5054);
            AddImageTiled(10, 10, 510, 22, 2624);
            AddImageTiled(10, 292, 150, 45, 2624);
            AddImageTiled(165, 292, 355, 45, 2624);
            AddImageTiled(10, 342, 510, 85, 2624);
            AddImageTiled(10, 37, 300, 380, 2624);              //edited by sam to fix gump
            AddImageTiled(215, 37, 305, 380, 2624);             //edited by sam to fix gump
            AddAlphaRegion(10, 10, 510, 417);


            if (craftSystem.GumpTitleNumber > 0)
            {
                AddHtmlLocalized(10, 12, 510, 20, craftSystem.GumpTitleNumber, LabelColor, false, false);
            }
            else
            {
                AddHtml(10, 12, 510, 20, craftSystem.GumpTitleString, false, false);
            }

            AddHtmlLocalized(10, 50, 200, 100, 1044010, LabelColor, false, false);               // <CENTER>CATEGORIES</CENTER>
            AddHtmlLocalized(215, 50, 305, 100, 1044011, LabelColor, false, false);              // <CENTER>SELECTIONS</CENTER>
            //edited by sam removed notice tab

            AddButton(15, 400, 4017, 4019, 0, GumpButtonType.Reply, 0);
            AddHtmlLocalized(50, 400, 150, 18, 1011441, LabelColor, false, false);               // EXIT

            AddButton(270, 400, 4005, 4007, GetButtonID(6, 2), GumpButtonType.Reply, 0);
            AddHtmlLocalized(305, 400, 150, 18, 1044013, LabelColor, false, false);               // MAKE LAST

            // Mark option
            if (craftSystem.MarkOption)
            {
                AddButton(270, 362, 4005, 4007, GetButtonID(6, 6), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 365, 150, 18, 1044017 + (context == null ? 0 : (int)context.MarkOption), LabelColor, false, false);                   // MARK ITEM
            }
            // ****************************************

            // Resmelt option
            if (craftSystem.Resmelt)
            {
                AddButton(15, 342, 4005, 4007, GetButtonID(6, 1), GumpButtonType.Reply, 0);
                AddHtmlLocalized(50, 345, 150, 18, 1044259, LabelColor, false, false);                   // SMELT ITEM
            }
            // ****************************************

            // Repair option
            if (craftSystem.Repair)
            {
                AddButton(270, 342, 4005, 4007, GetButtonID(6, 5), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 345, 150, 18, 1044260, LabelColor, false, false);                   // REPAIR ITEM
            }
            // ****************************************

            // Enhance option
            if (craftSystem.CanEnhance)
            {
                AddButton(270, 382, 4005, 4007, GetButtonID(6, 8), GumpButtonType.Reply, 0);
                AddHtmlLocalized(305, 385, 150, 18, 1061001, LabelColor, false, false);                   // ENHANCE ITEM
            }
            // ****************************************

            if (notice is int && (int)notice > 0)
            {
                AddHtmlLocalized(170, 295, 350, 40, (int)notice, LabelColor, false, false);
            }
            else if (notice is string)
            {
                AddHtml(170, 295, 350, 40, String.Format("<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", FontColor, notice), false, false);
            }

            // If the system has more than one resource
            if (craftSystem.CraftSubRes.Init)
            {
                string nameString = craftSystem.CraftSubRes.NameString;
                int    nameNumber = craftSystem.CraftSubRes.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex);

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes.GetAt(resIndex);

                    nameString = subResource.NameString;
                    nameNumber = subResource.NameNumber;
                }

                AddButton(15, 362, 4005, 4007, GetButtonID(6, 0), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 365, 250, 18, nameNumber, LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 362, LabelHue, nameString);
                }
            }
            // ****************************************

            // For dragon scales
            if (craftSystem.CraftSubRes2.Init)
            {
                string nameString = craftSystem.CraftSubRes2.NameString;
                int    nameNumber = craftSystem.CraftSubRes2.NameNumber;

                int resIndex = (context == null ? -1 : context.LastResourceIndex2);

                if (resIndex > -1)
                {
                    CraftSubRes subResource = craftSystem.CraftSubRes2.GetAt(resIndex);

                    nameString = subResource.NameString;
                    nameNumber = subResource.NameNumber;
                }

                AddButton(15, 382, 4005, 4007, GetButtonID(6, 7), GumpButtonType.Reply, 0);

                if (nameNumber > 0)
                {
                    AddHtmlLocalized(50, 385, 250, 18, nameNumber, LabelColor, false, false);
                }
                else
                {
                    AddLabel(50, 385, LabelHue, nameString);
                }
            }
            // ****************************************

            CreateGroupList();

            if (page == CraftPage.PickResource)
            {
                CreateResList(false);
            }
            else if (page == CraftPage.PickResource2)
            {
                CreateResList(true);
            }
            else if (context != null && context.LastGroupIndex > -1)
            {
                CreateItemList(context.LastGroupIndex);
            }
        }