Пример #1
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (info.ButtonID == (int)Buttons.Delete)
            {
                currentAllianceParsed.Sanitize();

                if (AllianceDefinition.Alliances.Count > 0)
                {
                    foreach (BaseAlliance a in AllianceDefinition.Alliances)
                    {
                        alliancesToParse.Add(a);
                    }

                    currentAllianceParsed = alliancesToParse[key.Value];
                    sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key));
                }

                sender.Mobile.SendMessage("Selected alliance has been purged.");
            }

            if (info.ButtonID == (int)Buttons.Next)
            {
                if (key.Value < alliancesToParse.Count - 1)
                {
                    sender.Mobile.CloseGump(typeof(AllianceInterface));
                    key.Value++;
                    sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key));
                }
            }

            if (info.ButtonID == (int)Buttons.Previous)
            {
                if (key.Value > 0)
                {
                    sender.Mobile.CloseGump(typeof(AllianceInterface));
                    key.Value--;
                    sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key));
                }
            }

            if (info.ButtonID == (int)Buttons.PrimeHueButton)
            {
                if (!String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.PrimeHueEntry).Text))
                {
                    int newHue = 0;

                    if (!String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.PrimeHueEntry).Text))
                    {
                        try { newHue = Int32.Parse(info.GetTextEntry((int)Buttons.PrimeHueEntry).Text); }

                        catch
                        {
                            sender.Mobile.SendMessage("Invalid hue entry, please try again.");
                            sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key));
                            return;
                        }

                        if (newHue <= 0 || newHue > 3000)
                        {
                            sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key));
                            sender.Mobile.SendMessage("Hue value out of range (1-3000)");
                            return;
                        }

                        if (newHue > 0 && newHue < 3000)
                        {
                            currentAllianceParsed.primaryHue = newHue;
                        }

                        sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key));
                    }
                }
            }

            if (info.ButtonID == (int)Buttons.SecondHueButton)
            {
                if (!String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.SecondHueEntry).Text))
                {
                    int newHue = 0;

                    if (!String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.SecondHueEntry).Text))
                    {
                        try { newHue = Int32.Parse(info.GetTextEntry((int)Buttons.SecondHueEntry).Text); }

                        catch
                        {
                            sender.Mobile.SendMessage("Invalid hue entry, please try again.");
                            sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key));
                            return;
                        }

                        if (newHue <= 0 || newHue > 3000)
                        {
                            sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key));
                            sender.Mobile.SendMessage("Hue value out of range (1-3000)");
                            return;
                        }

                        if (newHue > 0 && newHue < 3000)
                        {
                            currentAllianceParsed.secondaryHue = newHue;
                        }

                        sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key));
                    }
                }
            }

            if (info.ButtonID == (int)Buttons.AllianceLimitButton)
            {
                int newLimit = 0;

                if (!String.IsNullOrEmpty(info.GetTextEntry((int)Buttons.AllianceLimitEntry).Text))
                {
                    try
                    {
                        newLimit = Int32.Parse(info.GetTextEntry((int)Buttons.AllianceLimitEntry).Text);
                    }

                    catch
                    {
                        sender.Mobile.SendMessage("You have entered invalid characters.");
                        sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key));
                        return;
                    }

                    if (newLimit <= 0)
                    {
                        sender.Mobile.SendMessage("The alliance limit must be a number larger than 0");
                        sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key));
                        return;
                    }

                    if (newLimit < AllianceDefinition.Alliances.Count)
                    {
                        sender.Mobile.SendMessage("The alliance limit can not be less than the number of active alliances.");
                        sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key));
                        return;
                    }

                    if (newLimit > 0 && newLimit >= AllianceDefinition.Alliances.Count)
                    {
                        AllianceDefinition.AllianceLimit = newLimit;
                        sender.Mobile.SendMessage("The maximum number of alliances has been changed.");
                        sender.Mobile.SendGump(new AllianceInterface(sender.Mobile, key));
                    }
                }
            }
        }