Example #1
0
        private void RenderCategory(RewardCategory category, int index)
        {
            //bool twopages = false;
            int num_pages = 1;

            AddPage(2 + index);

            ArrayList entries = category.Entries;

            for (int idx = 0; idx < entries.Count; ++idx)
            {
                //int i = twopages ? idx - 24 : idx;
                int i = num_pages > 1 ? idx - (24 * (num_pages - 1)) : idx;


                RewardEntry entry = (RewardEntry)entries[idx];

                if (!RewardSystem.HasAccess(m_From, entry))
                {
                    break;
                }

                AddButton(55 + ((i / 12) * 250), 80 + ((i % 12) * 25), 5540, 5541, GetButtonID(index, idx), GumpButtonType.Reply, 0);

                if (entry.NameString != null)
                {
                    AddHtml(80 + ((i / 12) * 250), 80 + ((i % 12) * 25), 250, 20, entry.NameString, false, false);
                }
                else
                {
                    AddHtmlLocalized(80 + ((i / 12) * 250), 80 + ((i % 12) * 25), 250, 20, entry.Name, false, false);
                }

                if (i == 23)
                {
                    AddButton(315, 415, 0xFA5, 0xFA7, 0, GumpButtonType.Page, 7 + index + (num_pages - 1) + (index > 1 ? 2 : 0));
                    AddHtmlLocalized(350, 415, 200, 20, 1011066, false, false);

                    AddPage(7 + index + (num_pages - 1) + (index > 1 ? 2 : 0));

                    AddButton(190, 415, 0xFAE, 0xFB0, 0, GumpButtonType.Page, num_pages == 1 ? index + 2 : 5 + index + num_pages);
                    AddHtmlLocalized(225, 415, 200, 20, 1011067, false, false);

                    //twopages = true;
                    num_pages++;
                }



                //if (num_pages > 1) //(idx == entries.Count - 1 && num_pages > 1) // twopages )
                //{
                //    AddButton(270, 415, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 2 + index);
                //    AddHtmlLocalized(305, 415, 200, 20, 1011067, false, false);
                //}
            }
        }
Example #2
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                if (!RewardSystem.HasAccess(m_From, m_Entry))
                {
                    return;
                }

                Item item = m_Entry.Construct();

                if (item != null)
                {
                    if (item is Items.RedSoulstone)
                    {
                        ((Items.RedSoulstone)item).Account = m_From.Account.Username;
                    }

                    if (item is Items.LighthouseAddonDeed)
                    {
                        ((Items.LighthouseAddonDeed)item).Account = m_From.Account.Username;
                    }

                    if (RewardSystem.ConsumeRewardPoint(m_From))
                    {
                        #region TOL
                        if (item is Auction.AuctionSafeDeed)
                        {
                            for (int i = 0; i < 2; i++)
                            {
                                Item it = m_Entry.Construct();
                                m_From.AddToBackpack(it);
                            }
                        }
                        #endregion

                        m_From.AddToBackpack(item);
                    }
                    else
                    {
                        item.Delete();
                    }
                }
            }

            int cur, max;

            RewardSystem.ComputeRewardInfo(m_From, out cur, out max);

            if (cur < max)
            {
                m_From.SendGump(new RewardNoticeGump(m_From));
            }
        }
Example #3
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            int buttonID = info.ButtonID - 1;

            if (buttonID == 0)
            {
                RewardSystem.ComputeRewardInfo(m_From, out int cur, out int max);

                if (cur < max)
                {
                    m_From.SendGump(new RewardNoticeGump(m_From));
                }
            }
            else if (info.ButtonID == 1000)
            {
                m_From.SendGump(new RewardChoiceGump(m_From, m_CategoryIndex, m_Page + 1));
            }
            else if (info.ButtonID == 1001)
            {
                m_From.SendGump(new RewardChoiceGump(m_From, m_CategoryIndex, m_Page - 1));
            }
            else if (buttonID >= 19999)
            {
                m_From.SendGump(new RewardChoiceGump(m_From, buttonID - 19999, 0));
            }
            else
            {
                --buttonID;

                int type  = (buttonID % 20);
                int index = (buttonID / 20);

                RewardCategory[] categories = RewardSystem.Categories;

                if (type >= 0 && type < categories.Length)
                {
                    RewardCategory category = categories[type];

                    if (index >= 0 && index < category.Entries.Count)
                    {
                        RewardEntry entry = category.Entries[index];

                        if (!RewardSystem.HasAccess(m_From, entry))
                        {
                            return;
                        }

                        m_From.SendGump(new RewardConfirmGump(m_From, entry));
                    }
                }
            }
        }
Example #4
0
        private void RenderBackground()
        {
            AddPage(0);

            AddBackground(0, 0, 820, 620, 0x6DB);
            AddHtmlLocalized(10, 10, 800, 18, 1114513, "#1159424", 0x43FF, false, false); // Ultima Online Veteran Rewards Program
            AddHtmlLocalized(10, 37, 800, 72, 1114513, "#1159425", 0x43FF, false, false); // Thank you for being part of the Ultima Online community! As a token of our appreciation, you may select from the following in-game reward items listed below. The gift items will be attributed to the character you have logged-in with on the shard you are on when you choose the item(s). The number of rewards you are entitled to are listed below and are for your entire account. To read more about these rewards before making a selection, feel free to visit the <A HREF="https://uo.com/wiki/ultima-online-wiki/items/veteran-rewards/">uo.com website</A>.

            RewardSystem.ComputeRewardInfo(m_From, out int cur, out int max);

            AddHtmlLocalized(160, 118, 650, 18, 1159426, string.Format("{0}@{1}", cur.ToString(), (max - cur).ToString()), 0x7FF0, false, false); // You have already chosen ~1_COUNT~ rewards.  You have ~2_COUNT~ remaining rewards to choose.
            AddECHandleInput();
        }
Example #5
0
        public static bool HasAccess(Mobile mob, RewardCategory category)
        {
            List <RewardEntry> entries = category.Entries;

            for (int j = 0; j < entries.Count; ++j)
            {
                //RewardEntry entry = entries[j];
                if (RewardSystem.HasAccess(mob, entries[j]))
                {
                    return(true);
                }
            }
            return(false);
        }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                if (!RewardSystem.HasAccess(m_From, m_Entry))
                {
                    return;
                }

                Item item = m_Entry.Construct();

                //ItemID Mods Begin
                if (item is Server.Items.BaseWeapon)
                {
                    ((Server.Items.BaseWeapon)item).Identified = true;
                }
                else if (item is Server.Items.BaseArmor)
                {
                    ((Server.Items.BaseArmor)item).Identified = true;
                }
                //ItemID Mods end

                if (item != null)
                {
                    if (item is Server.Items.RedSoulstone)
                    {
                        ((Server.Items.RedSoulstone)item).Account = m_From.Account.Username;
                    }

                    if (RewardSystem.ConsumeRewardPoint(m_From))
                    {
                        m_From.AddToBackpack(item);
                    }
                    else
                    {
                        item.Delete();
                    }
                }
            }

            int cur, max;

            RewardSystem.ComputeRewardInfo(m_From, out cur, out max);

            if (cur < max)
            {
                m_From.SendGump(new RewardNoticeGump(m_From));
            }
        }
Example #7
0
        private int PagesPerCategory(RewardCategory category)
        {
            var entries = category.Entries;
            var i       = 0;

            for (var j = 0; j < entries.Count; j++)
            {
                if (RewardSystem.HasAccess(m_From, entries[j]))
                {
                    i++;
                }
            }

            return((int)Math.Ceiling(i / 24.0));
        }
        private int PagesPerCategory(RewardCategory category)
        {
            List <RewardEntry> entries = category.Entries;
            int j = 0, i = 0;

            for (j = 0; j < entries.Count; j++)
            {
                if (RewardSystem.HasAccess(this.m_From, entries[j]))
                {
                    i++;
                }
            }

            return((int)Math.Ceiling(i / 24.0));
        }
Example #9
0
        private void RenderCategory(RewardCategory category, int index, ref int page)
        {
            AddPage(page);

            List <RewardEntry> entries = category.Entries;

            #region Veteran Rewards
            int i = 0;

            for (int j = 0; j < entries.Count; ++j)
            {
                RewardEntry entry = entries[j];

                if (!RewardSystem.HasAccess(m_From, entry))
                {
                    continue;
                }

                if (i == 24)
                {
                    AddButton(305, 415, 0xFA5, 0xFA7, 0, GumpButtonType.Page, ++page);
                    AddHtmlLocalized(340, 415, 200, 20, 1011066, false, false);                       // Next page

                    AddPage(page);

                    AddButton(270, 415, 0xFAE, 0xFB0, 0, GumpButtonType.Page, page - 1);
                    AddHtmlLocalized(185, 415, 200, 20, 1011067, false, false);                       // Previous page

                    i = 0;
                }

                AddButton(55 + ((i / 12) * 250), 80 + ((i % 12) * 25), 5540, 5541, GetButtonID(index, j), GumpButtonType.Reply, 0);

                if (entry.NameString != null)
                {
                    AddHtml(80 + ((i / 12) * 250), 80 + ((i % 12) * 25), 250, 20, entry.NameString, false, false);
                }
                else
                {
                    AddHtmlLocalized(80 + ((i / 12) * 250), 80 + ((i % 12) * 25), 250, 20, entry.Name, false, false);
                }
                ++i;
            }

            page += 1;
            #endregion
        }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (((sender.Mobile.Region is CustomRegion) && (((CustomRegion)sender.Mobile.Region).Controller.CannotTakeRewards)) || sender.Mobile.Region is GameRegion)
            {
                return;
            }

            int buttonID = info.ButtonID - 1;

            if (buttonID == 0)
            {
                int cur, max;

                RewardSystem.ComputeRewardInfo(m_From, out cur, out max);

                if (cur < max)
                {
                    m_From.SendGump(new RewardNoticeGump(m_From));
                }
            }
            else
            {
                --buttonID;

                int type  = (buttonID % 20);
                int index = (buttonID / 20);

                RewardCategory[] categories = RewardSystem.Categories;

                if (type >= 0 && type < categories.Length)
                {
                    RewardCategory category = categories[type];

                    if (index >= 0 && index < category.Entries.Count)
                    {
                        RewardEntry entry = category.Entries[index];

                        if (!RewardSystem.HasAccess(m_From, entry))
                        {
                            return;
                        }

                        m_From.SendGump(new RewardConfirmGump(m_From, entry));
                    }
                }
            }
        }
Example #11
0
        private void RenderCategory(RewardCategory category, int index, ref int page)
        {
            AddPage(page);

            var entries = category.Entries;

            var i = 0;

            for (var j = 0; j < entries.Count; ++j)
            {
                var entry = entries[j];

                if (!RewardSystem.HasAccess(m_From, entry))
                {
                    continue;
                }

                if (i == 24)
                {
                    AddButton(305, 415, 0xFA5, 0xFA7, 0, GumpButtonType.Page, ++page);
                    AddHtmlLocalized(340, 415, 200, 20, 1011066); // Next page

                    AddPage(page);

                    AddButton(270, 415, 0xFAE, 0xFB0, 0, GumpButtonType.Page, page - 1);
                    AddHtmlLocalized(185, 415, 200, 20, 1011067); // Previous page

                    i = 0;
                }

                AddButton(55 + i / 12 * 250, 80 + i % 12 * 25, 5540, 5541, GetButtonID(index, j));

                if (entry.NameString != null)
                {
                    AddHtml(80 + i / 12 * 250, 80 + i % 12 * 25, 250, 20, entry.NameString);
                }
                else
                {
                    AddHtmlLocalized(80 + i / 12 * 250, 80 + i % 12 * 25, 250, 20, entry.Name);
                }

                ++i;
            }

            page += 1;
        }
Example #12
0
        private void RenderCategory(RewardCategory category)
        {
            List <RewardEntry> entries = category.Entries;

            Dictionary <int, RewardEntry> l = new Dictionary <int, RewardEntry>();

            for (int j = 0; j < entries.Count; ++j)
            {
                RewardEntry entry = entries[j];

                if (!RewardSystem.HasAccess(m_From, entry))
                {
                    continue;
                }

                l[j] = entry;
            }

            int rewardcount = l.Count;

            if ((m_Page + 1) * 60 < rewardcount)
            {
                AddButton(554, 10, 0x15E1, 0x15E5, 1000, GumpButtonType.Reply, 0); // Next Page Button
            }
            if (m_Page > 0)
            {
                AddButton(554, 10, 0x15E3, 0x15E7, 1001, GumpButtonType.Reply, 0); // Previous Page Button
            }
            for (int i = 0, index = m_Page * 60; i < 60 && index < rewardcount; ++i, ++index)
            {
                var         item  = l.ElementAt(index);
                RewardEntry entry = item.Value;

                if (entry.NameString != null)
                {
                    AddHtml(50 + ((i / 20) * 250), 200 + ((i % 20) * 18), 200, 18, entry.NameString, false, false);
                }
                else
                {
                    AddHtmlLocalized(50 + ((i / 20) * 250), 200 + ((i % 20) * 18), 200, 18, entry.Name, 0x7FFF, false, false);
                }

                AddButton(30 + ((i / 20) * 250), 200 + ((i % 20) * 18), 0x845, 0x846, GetButtonID(m_CategoryIndex, item.Key), GumpButtonType.Reply, 0);
            }
        }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                if (!RewardSystem.HasAccess(this.m_From, this.m_Entry))
                {
                    return;
                }

                Item item = this.m_Entry.Construct();

                if (item != null)
                {
                    if (item is Server.Items.RedSoulstone)
                    {
                        ((Server.Items.RedSoulstone)item).Account = this.m_From.Account.Username;
                    }

                    if (item is Server.Items.LighthouseAddonDeed)
                    {
                        ((Server.Items.LighthouseAddonDeed)item).Account = this.m_From.Account.Username;
                    }

                    if (RewardSystem.ConsumeRewardPoint(this.m_From))
                    {
                        this.m_From.AddToBackpack(item);
                    }
                    else
                    {
                        item.Delete();
                    }
                }
            }

            int cur, max;

            RewardSystem.ComputeRewardInfo(this.m_From, out cur, out max);

            if (cur < max)
            {
                this.m_From.SendGump(new RewardNoticeGump(this.m_From));
            }
        }
Example #14
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (((sender.Mobile.Region is CustomRegion) && (((CustomRegion)sender.Mobile.Region).Controller.CannotTakeRewards)) || sender.Mobile.Region is GameRegion)
            {
                return;
            }

            if (info.ButtonID == 1)
            {
                if (!RewardSystem.HasAccess(m_From, m_Entry))
                {
                    return;
                }

                Item item = m_Entry.Construct();

                if (item != null)
                {
                    if (item is Server.Items.RedSoulstone)
                    {
                        ((Server.Items.RedSoulstone)item).Account = m_From.Account.Username;
                    }

                    if (RewardSystem.ConsumeRewardPoint(m_From))
                    {
                        m_From.AddToBackpack(item);
                    }
                    else
                    {
                        item.Delete();
                    }
                }
            }

            int cur, max;

            RewardSystem.ComputeRewardInfo(m_From, out cur, out max);

            if (cur < max)
            {
                m_From.SendGump(new RewardNoticeGump(m_From));
            }
        }
Example #15
0
        public override void OnResponse(GameClient sender, RelayInfo info)
        {
            int buttonID = info.ButtonID - 1;

            if (buttonID == 0)
            {
                int cur, max;

                RewardSystem.ComputeRewardInfo(m_From, out cur, out max);

                if (cur < max)
                {
                    m_From.SendGump(new RewardNoticeGump(m_From));
                }
            }
            else
            {
                --buttonID;

                int type  = (buttonID % 20);
                int index = (buttonID / 20);

                RewardCategory[] categories = RewardSystem.Categories;

                if (type >= 0 && type < categories.Length)
                {
                    RewardCategory category = categories[type];

                    if (index >= 0 && index < category.Entries.Count)
                    {
                        RewardEntry entry = (RewardEntry)category.Entries[index];

                        if (!RewardSystem.HasAccess(m_From, entry))
                        {
                            return;
                        }

                        m_From.SendGump(new RewardConfirmGump(m_From, entry));
                    }
                }
            }
        }
Example #16
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            var buttonID = info.ButtonID - 1;

            if (buttonID == 0)
            {
                RewardSystem.ComputeRewardInfo(m_From, out var cur, out var max);

                if (cur < max)
                {
                    m_From.SendGump(new RewardNoticeGump(m_From));
                }
            }
            else
            {
                --buttonID;

                var type  = buttonID % 20;
                var index = buttonID / 20;

                var categories = RewardSystem.Categories;

                if (type >= 0 && type < categories.Length)
                {
                    var category = categories[type];

                    if (index >= 0 && index < category.Entries.Count)
                    {
                        var entry = category.Entries[index];

                        if (!RewardSystem.HasAccess(m_From, entry))
                        {
                            return;
                        }

                        m_From.SendGump(new RewardConfirmGump(m_From, entry));
                    }
                }
            }
        }
Example #17
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                if (!RewardSystem.HasAccess(m_From, m_Entry))
                {
                    return;
                }

                Item item = m_Entry.Construct();

                if (item != null)
                {
                    if (item is RedSoulstone soulstone)
                    {
                        soulstone.Account = m_From.Account.Username;
                    }

                    if (RewardSystem.ConsumeRewardPoint(m_From))
                    {
                        m_From.AddToBackpack(item);
                    }
                    else
                    {
                        item.Delete();
                    }
                }
            }

            RewardSystem.ComputeRewardInfo(m_From, out int cur, out int max);

            if (cur < max)
            {
                m_From.SendGump(new RewardNoticeGump(m_From));
            }
        }
Example #18
0
        public override void OnResponse(GameClient sender, RelayInfo info)
        {
            if (info.ButtonID == 1)
            {
                if (!RewardSystem.HasAccess(m_From, m_Entry))
                {
                    return;
                }

                Item item = m_Entry.Construct();

                if (item != null)
                {
                    //if ( item is Server.Items.RedSoulstone )
                    //	( (Server.Items.RedSoulstone) item ).Account = m_From.Account.Username;

                    if (RewardSystem.ConsumeRewardPoint(m_From))
                    {
                        m_From.AddToBackpack(item);
                    }
                    else
                    {
                        item.Delete();
                    }
                }
            }

            int cur, max;

            RewardSystem.ComputeRewardInfo(m_From, out cur, out max);

            if (cur < max)
            {
                m_From.SendGump(new RewardNoticeGump(m_From));
            }
        }
        private void RenderCategories()
        {
            TimeSpan rewardInterval = RewardSystem.RewardInterval;

            string intervalAsString;

            if (rewardInterval == TimeSpan.FromDays(30.0))
            {
                intervalAsString = "month";
            }
            else if (rewardInterval == TimeSpan.FromDays(60.0))
            {
                intervalAsString = "two months";
            }
            else if (rewardInterval == TimeSpan.FromDays(90.0))
            {
                intervalAsString = "three months";
            }
            else if (rewardInterval == TimeSpan.FromDays(365.0))
            {
                intervalAsString = "year";
            }
            else
            {
                intervalAsString = String.Format("{0} day{1}", rewardInterval.TotalDays, rewardInterval.TotalDays == 1 ? "" : "s");
            }

            this.AddPage(1);

            this.AddHtml(60, 35, 500, 70, "<B>Ultima Online Rewards Program</B><BR>" +
                         "Thank you for being a part of the Ultima Online community for a full " + intervalAsString + ".  " +
                         "As a token of our appreciation,  you may select from the following in-game reward items listed below.  " +
                         "The gift items will be attributed to the character you have logged-in with on the shard you are on when you chose the item(s).  " +
                         "The number of rewards you are entitled to are listed below and are for your entire account.  " +
                         "To read more about these rewards before making a selection, feel free to visit the uo.com site at " +
                         "<A HREF=\"http://www.uo.com/rewards\">http://www.uo.com/rewards</A>.", true, true);

            int cur, max;

            RewardSystem.ComputeRewardInfo(this.m_From, out cur, out max);

            this.AddHtmlLocalized(60, 105, 300, 35, 1006006, false, false); // Your current total of rewards to choose:
            this.AddLabel(370, 107, 50, (max - cur).ToString());

            this.AddHtmlLocalized(60, 140, 300, 35, 1006007, false, false); // You have already chosen:
            this.AddLabel(370, 142, 50, cur.ToString());

            RewardCategory[] categories = RewardSystem.Categories;

            int page = 2;

            for (int i = 0; i < categories.Length; ++i)
            {
                if (!RewardSystem.HasAccess(this.m_From, categories[i]))
                {
                    page += 1;
                    continue;
                }

                this.AddButton(100, 180 + (i * 40), 4005, 4005, 0, GumpButtonType.Page, page);

                page += this.PagesPerCategory(categories[i]);

                if (categories[i].NameString != null)
                {
                    this.AddHtml(135, 180 + (i * 40), 300, 20, categories[i].NameString, false, false);
                }
                else
                {
                    this.AddHtmlLocalized(135, 180 + (i * 40), 300, 20, categories[i].Name, false, false);
                }
            }

            page = 2;

            for (int i = 0; i < categories.Length; ++i)
            {
                this.RenderCategory(categories[i], i, ref page);
            }
        }
Example #20
0
        private void RenderCategories()
        {
            int cur, max;

            RewardSystem.ComputeRewardInfo(m_From, out cur, out max);

            Intern((max - cur).ToString());
            Intern(cur.ToString());

            TimeSpan rewardInterval = RewardSystem.RewardInterval;

            object interval;

            if (rewardInterval == TimeSpan.FromDays(90.0))
            {
                interval = "three months";
            }
            else if (rewardInterval == TimeSpan.FromDays(360.0))
            {
                interval = 1006003;
            }
            else if (rewardInterval == TimeSpan.FromDays(720.0))
            {
                interval = 1006004;
            }
            else if (rewardInterval == TimeSpan.FromDays(1080.0))
            {
                interval = 1006005;
            }
            else
            {
                interval = String.Format("{0} day{1}", rewardInterval.TotalDays, rewardInterval.TotalDays == 1 ? "" : "s");
            }

            AddPage(1);

            if (interval is int)
            {
                AddHtmlLocalized(60, 35, 500, 70, (int)interval, true, true);
            }
            else if (interval is String)
            {
                AddHtmlLocalized(60, 35, 500, 70, 1034379, true, true);
                AddHtml(60, 35, 500, 70, "<B>Ultima Online Rewards Program</B><BR>" +
                        "Thank you for being a part of the Ultima Online community for a full " + (string)interval + ".  " +
                        "As a token of our appreciation,  you may select from the following in-game reward items listed below.  " +
                        "The gift items will be attributed to the character you have logged-in with on the shard you are on when you chose the item(s).  " +
                        "The number of rewards you are entitled to are listed below and are for your entire account.  " +
                        "To read more about these rewards before making a selection, feel free to visit the uo.com site at " +
                        "<A HREF=\"http://www.uo.com/rewards\">http://www.uo.com/rewards</A>.", true, true);
            }

            AddHtmlLocalized(60, 105, 300, 35, 1006006, false, false);               // Your current total of rewards to choose:
            AddHtmlLocalized(60, 140, 300, 35, 1006007, false, false);               // You have already chosen:

            AddLabelIntern(370, 107, 50, 0);
            AddLabelIntern(370, 142, 50, 1);

            RewardCategory[] categories = RewardSystem.Categories;

            for (int i = 0; i < categories.Length; ++i)
            {
                if (categories[i].Entries.Count == 0)
                {
                    continue;
                }

                if (!RewardSystem.HasAccess(m_From, (RewardEntry)categories[i].Entries[0]))
                {
                    continue;
                }

                AddButton(100, 180 + (i * 40), 4005, 4005, 0, GumpButtonType.Page, 2 + i);

                if (categories[i].NameString != null)
                {
                    AddHtml(135, 180 + (i * 40), 300, 20, categories[i].NameString, false, false);
                }
                else
                {
                    AddHtmlLocalized(135, 180 + (i * 40), 300, 20, categories[i].Name, false, false);
                }
            }

            for (int i = 0; i < categories.Length; ++i)
            {
                RenderCategory(categories[i], i);
            }
        }
Example #21
0
        private void RenderCategories()
        {
            TimeSpan rewardInterval = RewardSystem.RewardInterval;

            string intervalAsString;

            if (rewardInterval == TimeSpan.FromDays(30.0))
            {
                intervalAsString = "month";
            }
            else if (rewardInterval == TimeSpan.FromDays(60.0))
            {
                intervalAsString = "two months";
            }
            else if (rewardInterval == TimeSpan.FromDays(90.0))
            {
                intervalAsString = "three months";
            }
            else if (rewardInterval == TimeSpan.FromDays(365.0))
            {
                intervalAsString = "year";
            }
            else
            {
                intervalAsString = String.Format("{0} day{1}", rewardInterval.TotalDays, rewardInterval.TotalDays == 1 ? "" : "s");
            }

            AddPage(1);

            AddHtml(60, 35, 500, 70, String.Format(m_ThankYouMessage, intervalAsString), true, true);

            int cur, max;

            RewardSystem.ComputeRewardInfo(m_From, out cur, out max);

            AddHtmlLocalized(60, 105, 300, 35, 1006006, false, false);               // Your current total of rewards to choose:
            AddLabel(370, 107, 50, (max - cur).ToString());

            AddHtmlLocalized(60, 140, 300, 35, 1006007, false, false);               // You have already chosen:
            AddLabel(370, 142, 50, cur.ToString());

            RewardCategory[] categories = RewardSystem.Categories;

            int page = 2;

            for (int i = 0; i < categories.Length; ++i)
            {
                if (!RewardSystem.HasAccess(m_From, categories[i]))
                {
                    page += 1;
                    m_From.SendMessage("You do not have access to {0} {1}", categories[i].Name, categories[1].NameString);
                    continue;
                }

                AddButton(100, 180 + (i * 40), 4005, 4005, 0, GumpButtonType.Page, page);

                page += PagesPerCategory(categories[i]);

                if (String.IsNullOrEmpty(categories[i].NameString))
                {
                    AddHtmlLocalized(135, 180 + (i * 40), 300, 20, categories[i].Name, false, false);
                }
                else
                {
                    AddHtml(135, 180 + (i * 40), 300, 20, categories[i].NameString, false, false);
                }
            }

            page = 2;

            for (int i = 0; i < categories.Length; ++i)
            {
                RenderCategory(categories[i], i, ref page);
            }
        }