public override void OnResponse(NetState sender, RelayInfo relayInfo)
        {
            int index = relayInfo.ButtonID - 1;

            if (index >= 0 && index < m_Names.Length)
            {
                try
                {
                    MethodInfo info = m_Property.PropertyType.GetMethod("Parse", new Type[] { typeof(string) });

                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, m_Names[index]);

                    if (info != null)
                    {
                        m_Property.SetValue(m_Object, info.Invoke(null, new object[] { m_Names[index] }), null);
                    }
                    else if (m_Property.PropertyType == typeof(Enum) || m_Property.PropertyType.IsSubclassOf(typeof(Enum)))
                    {
                        m_Property.SetValue(m_Object, Enum.Parse(m_Property.PropertyType, m_Names[index], false), null);
                    }

                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
        }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            int index = info.ButtonID - 1;

            if (index >= 0 && index < m_Values.Length)
            {
                try
                {
                    object toSet = m_Values[index];

                    string result = Properties.SetDirect(m_Mobile, m_Object, m_Object, m_Property, m_Property.Name, toSet, true);

                    m_Mobile.SendMessage(result);

                    if (result == "Property has been set.")
                    {
                        PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
                    }
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
        }
Exemple #3
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            int index = info.ButtonID - 1;

            if (index >= 0 && index < m_Values.Length)
            {
                try
                {
                    object toSet = m_Values[index];
                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, (toSet == null ? "(-null-)" : toSet.ToString()));
                    m_Property.SetValue(m_Object, toSet, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            if (m_List.Count != 0)
            {
                m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
            }
            else
            {
                var stackEntry = (PropertiesGump.IStackEntry)m_Stack.Pop();
                stackEntry.SendGump(m_Mobile, m_Stack);
            }
        }
Exemple #4
0
        protected override void OnTarget(Mobile from, object targeted)
        {
            try
            {
                if (m_Type == typeof(Type))
                {
                    targeted = targeted.GetType();
                }
                else if ((m_Type == typeof(BaseAddon) || m_Type.IsAssignableFrom(typeof(BaseAddon))) &&
                         targeted is AddonComponent addonComponent)
                {
                    targeted = addonComponent.Addon;
                }

                if (m_Type.IsInstanceOfType(targeted))
                {
                    CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, targeted.ToString());
                    m_Property.SetValue(m_Object, targeted, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
                }
                else
                {
                    m_Mobile.SendMessage("That cannot be assigned to a property of type : {0}", m_Type.Name);
                }
            }
            catch
            {
                m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
            }
        }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            int index = info.ButtonID - 1;

            if (index >= 0 && index < m_Values.Length)
            {
                try
                {
                    object toSet = m_Values[index];
                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, (toSet == null ? "(-null-)" : toSet.ToString()));
                    m_Property.SetValue(m_Object, toSet, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                    if (Miscellanious.ValidateLabeling(m_Object))
                    {
                        if (m_Object is Item)
                        {
                            ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                        }

                        if (m_Object is Mobile)
                        {
                            ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                        }
                    }
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
        }
            protected override void OnTarget(Mobile from, object targeted)
            {
                IPoint3D p = targeted as IPoint3D;

                if (p != null)
                {
                    try
                    {
                        Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, new Point2D(p).ToString());
                        m_Property.SetValue(m_Object, new Point2D(p), null);
                        PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                        if (Miscellanious.ValidateLabeling(m_Object))
                        {
                            if (m_Object is Item)
                            {
                                ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                            }

                            if (m_Object is Mobile)
                            {
                                ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                            }
                        }
                    }
                    catch
                    {
                        m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                    }
                }
            }
        public SetTimeSpanGump(
            PropertyInfo prop, Mobile mobile, object o, PropertiesGump propertiesGump
            )
            : base(GumpOffsetX, GumpOffsetY)
        {
            m_PropertiesGump = propertiesGump;
            m_Property       = prop;
            m_Mobile         = mobile;
            m_Object         = o;

            var ts = (TimeSpan)(prop?.GetValue(o, null) ?? new TimeSpan());

            AddPage(0);

            AddBackground(0, 0, BackWidth, BackHeight, BackGumpID);
            AddImageTiled(
                BorderSize,
                BorderSize,
                TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0),
                TotalHeight,
                OffsetGumpID
                );

            AddRect(0, prop?.Name, 0, -1);
            AddRect(1, ts.ToString(), 0, -1);
            AddRect(2, "Zero", 1, -1);
            AddRect(3, "From H:M:S", 2, -1);
            AddRect(4, "H:", 3, 0);
            AddRect(5, "M:", 4, 1);
            AddRect(6, "S:", 5, 2);
        }
Exemple #8
0
 public InternalPicker(
     PropertyInfo prop, Mobile mobile, object o, PropertiesGump propertiesGump) : base(((IHued)o).HuedItemID)
 {
     m_Property       = prop;
     m_Mobile         = mobile;
     m_Object         = o;
     m_PropertiesGump = propertiesGump;
 }
Exemple #9
0
 public InternalTarget(
     PropertyInfo prop, Mobile mobile, object o, PropertiesGump propertiesGump
     ) : base(-1, true, TargetFlags.None)
 {
     m_Property       = prop;
     m_Mobile         = mobile;
     m_Object         = o;
     m_PropertiesGump = propertiesGump;
 }
Exemple #10
0
            public override void OnResponse(Mobile from, string text)
            {
                object toSet;
                bool   shouldSet;

                try
                {
                    int serial = Utility.ToInt32(text);

                    toSet = World.FindEntity(serial);

                    if (toSet == null)
                    {
                        shouldSet = false;
                        m_Mobile.SendMessage("No object with that serial was found.");
                    }
                    else if (!m_Type.IsAssignableFrom(toSet.GetType()))
                    {
                        toSet     = null;
                        shouldSet = false;
                        m_Mobile.SendMessage(
                            "The object with that serial could not be assigned to a property of type : {0}",
                            m_Type.Name);
                    }
                    else
                    {
                        shouldSet = true;
                    }
                }
                catch
                {
                    toSet     = null;
                    shouldSet = false;
                    m_Mobile.SendMessage("Bad format");
                }

                if (shouldSet)
                {
                    try
                    {
                        CommandLogging.LogChangeProperty(
                            m_Mobile,
                            m_Object,
                            m_Property.Name,
                            "(null)");
                        m_Property.SetValue(m_Object, toSet, null);
                        PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
                    }
                    catch
                    {
                        m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                    }
                }

                m_Mobile.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List));
            }
Exemple #11
0
 public InternalPrompt(
     PropertyInfo prop, Mobile mobile, object o, Type type, PropertiesGump propertiesGump
     )
 {
     m_PropertiesGump = propertiesGump;
     m_Property       = prop;
     m_Mobile         = mobile;
     m_Object         = o;
     m_Type           = type;
 }
Exemple #12
0
 public SetObjectTarget(
     PropertyInfo prop, Mobile mobile, object o, Type type, PropertiesGump propertiesGump
     ) : base(-1, false, TargetFlags.None)
 {
     m_PropertiesGump = propertiesGump;
     m_Property       = prop;
     m_Mobile         = mobile;
     m_Object         = o;
     m_Type           = type;
 }
Exemple #13
0
        public override void OnResponse(NetState sender, RelayInfo relayInfo)
        {
            int index = relayInfo.ButtonID - 1;

            if (index >= 0 && index < _Names.Length)
            {
                try
                {
                    MethodInfo info = m_Property.PropertyType.GetMethod("Parse", new[] { typeof(string) });

                    string result = "";

                    if (info != null)
                    {
                        result = Properties.SetDirect(
                            m_Mobile, m_Object, m_Object, m_Property, m_Property.Name, info.Invoke(null, new object[] { _Names[index] }), true);
                    }
                    else if (m_Property.PropertyType == typeof(Enum) || m_Property.PropertyType.IsSubclassOf(typeof(Enum)))
                    {
                        result = Properties.SetDirect(
                            m_Mobile,
                            m_Object,
                            m_Object,
                            m_Property,
                            m_Property.Name,
                            Enum.Parse(m_Property.PropertyType, _Names[index], false),
                            true);
                    }
                    else if (typeofIDynamicEnum.IsAssignableFrom(m_Property.PropertyType))
                    {
                        IDynamicEnum ienum = (IDynamicEnum)m_Property.GetValue(m_Object, null);

                        if (ienum != null)
                        {
                            ienum.Value = _Names[index];
                        }

                        result = Properties.SetDirect(m_Mobile, m_Object, m_Object, m_Property, m_Property.Name, ienum, true);
                    }

                    m_Mobile.SendMessage(result);

                    if (result == "Property has been set.")
                    {
                        PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
                    }
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
        }
Exemple #14
0
            public override void OnResponse(int hue)
            {
                try
                {
                    CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, hue.ToString());
                    m_Property.SetValue(m_Object, hue, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }

                m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
            }
Exemple #15
0
 protected override void OnTarget(Mobile from, object targeted)
 {
     if (targeted is IPoint3D p)
     {
         try
         {
             CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, new Point2D(p).ToString());
             m_Property.SetValue(m_Object, new Point2D(p), null);
             PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
         }
         catch
         {
             m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
         }
     }
 }
Exemple #16
0
            public override void OnResponse(Mobile from, string text)
            {
                try
                {
                    var serial = Utility.ToUInt32(text);

                    var toSet = World.FindEntity(serial);

                    if (toSet == null)
                    {
                        m_Mobile.SendMessage("No object with that serial was found.");
                    }
                    else if (!m_Type.IsInstanceOfType(toSet))
                    {
                        m_Mobile.SendMessage(
                            "The object with that serial could not be assigned to a property of type : {0}",
                            m_Type.Name
                            );
                    }
                    else
                    {
                        try
                        {
                            CommandLogging.LogChangeProperty(
                                m_Mobile,
                                m_Object,
                                m_Property.Name,
                                toSet.ToString()
                                );
                            m_Property.SetValue(m_Object, toSet, null);
                            PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
                        }
                        catch
                        {
                            m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                        }
                    }
                }
                catch
                {
                    m_Mobile.SendMessage("Bad format");
                }

                m_Mobile.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List));
            }
Exemple #17
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                IPoint3D p = targeted as IPoint3D;

                if (p != null)
                {
                    try
                    {
                        object getval = m_Property.GetValue(m_Object, null);
                        CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, getval == null ? "(null)" : getval.ToString(), new Point3D(p).ToString());
                        m_Property.SetValue(m_Object, new Point3D(p), null);
                        PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
                    }
                    catch
                    {
                        m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                    }
                }
            }
        protected override void OnTarget(Mobile from, object targeted)
        {
            try
            {
                if (m_Type == typeof(Type))
                {
                    targeted = targeted.GetType();
                }
                else if ((m_Type == typeof(BaseAddon) || m_Type.IsAssignableFrom(typeof(BaseAddon))) && targeted is AddonComponent)
                {
                    targeted = ((AddonComponent)targeted).Addon;
                }

                if (m_Type.IsAssignableFrom(targeted.GetType()))
                {
                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, targeted.ToString());
                    m_Property.SetValue(m_Object, targeted, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                    if (Miscellanious.ValidateLabeling(m_Object))
                    {
                        if (m_Object is Item)
                        {
                            ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                        }

                        if (m_Object is Mobile)
                        {
                            ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                        }
                    }
                }
                else
                {
                    m_Mobile.SendMessage("That cannot be assigned to a property of type : {0}", m_Type.Name);
                }
            }
            catch
            {
                m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
            }
        }
        public override void OnResponse(NetState sender, RelayInfo relayInfo)
        {
            int index = relayInfo.ButtonID - 1;

            if (index >= 0 && index < this.m_Names.Length)
            {
                try
                {
                    MethodInfo info = this.m_Property.PropertyType.GetMethod("Parse", new Type[] { typeof(string) });

                    string result = "";

                    if (info != null)
                    {
                        result = Properties.SetDirect(this.m_Mobile, this.m_Object, this.m_Object, this.m_Property, this.m_Property.Name, info.Invoke(null, new object[] { this.m_Names[index] }), true);
                    }
                    else if (this.m_Property.PropertyType == typeof(Enum) || this.m_Property.PropertyType.IsSubclassOf(typeof(Enum)))
                    {
                        result = Properties.SetDirect(this.m_Mobile, this.m_Object, this.m_Object, this.m_Property, this.m_Property.Name, Enum.Parse(this.m_Property.PropertyType, this.m_Names[index], false), true);
                    }

                    this.m_Mobile.SendMessage(result);

                    if (result == "Property has been set.")
                    {
                        PropertiesGump.OnValueChanged(this.m_Object, this.m_Property, this.m_Stack);
                    }
                }
                catch
                {
                    this.m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            this.m_Mobile.SendGump(new PropertiesGump(this.m_Mobile, this.m_Object, this.m_Stack, this.m_List, this.m_Page));
        }
Exemple #20
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            TimeSpan toSet;
            bool     shouldSet, shouldSend;

            TextRelay h = info.GetTextEntry(0);
            TextRelay m = info.GetTextEntry(1);
            TextRelay s = info.GetTextEntry(2);

            switch (info.ButtonID)
            {
            case 1: // Zero
            {
                toSet      = TimeSpan.Zero;
                shouldSet  = true;
                shouldSend = true;

                break;
            }

            case 2: // From H:M:S
            {
                bool successfulParse = false;
                if (h != null && m != null && s != null)
                {
                    successfulParse = TimeSpan.TryParse($"{h.Text}:{m.Text}:{s.Text}", out toSet);
                }
                else
                {
                    toSet = TimeSpan.Zero;
                }

                shouldSet = shouldSend = successfulParse;

                break;
            }

            case 3: // From H
            {
                if (h != null)
                {
                    try
                    {
                        toSet      = TimeSpan.FromHours(Utility.ToDouble(h.Text));
                        shouldSet  = true;
                        shouldSend = true;

                        break;
                    }
                    catch
                    {
                        // ignored
                    }
                }

                toSet      = TimeSpan.Zero;
                shouldSet  = false;
                shouldSend = false;

                break;
            }

            case 4: // From M
            {
                if (m != null)
                {
                    try
                    {
                        toSet      = TimeSpan.FromMinutes(Utility.ToDouble(m.Text));
                        shouldSet  = true;
                        shouldSend = true;

                        break;
                    }
                    catch
                    {
                        // ignored
                    }
                }

                toSet      = TimeSpan.Zero;
                shouldSet  = false;
                shouldSend = false;

                break;
            }

            case 5: // From S
            {
                if (s != null)
                {
                    try
                    {
                        toSet      = TimeSpan.FromSeconds(Utility.ToDouble(s.Text));
                        shouldSet  = true;
                        shouldSend = true;

                        break;
                    }
                    catch
                    {
                        // ignored
                    }
                }

                toSet      = TimeSpan.Zero;
                shouldSet  = false;
                shouldSend = false;

                break;
            }

            default:
            {
                toSet      = TimeSpan.Zero;
                shouldSet  = false;
                shouldSend = true;

                break;
            }
            }

            if (shouldSet)
            {
                try
                {
                    CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString());
                    m_Property.SetValue(m_Object, toSet, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            if (shouldSend)
            {
                m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
            }
        }
Exemple #21
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            object toSet;
            bool   shouldSet, shouldSend = true;

            switch (info.ButtonID)
            {
            case 1:
            {
                TextRelay text = info.GetTextEntry(0);

                if (text != null)
                {
                    try
                    {
                        toSet     = PropertiesGump.GetObjectFromString(m_Property.PropertyType, text.Text);
                        shouldSet = true;
                    }
                    catch
                    {
                        toSet     = null;
                        shouldSet = false;
                        m_Mobile.SendMessage("Bad format");
                    }
                }
                else
                {
                    toSet     = null;
                    shouldSet = false;
                }

                break;
            }

            case 2:     // Null
            {
                toSet     = null;
                shouldSet = true;

                break;
            }

            case 3:     // Hue Picker
            {
                toSet      = null;
                shouldSet  = false;
                shouldSend = false;

                m_Mobile.SendHuePicker(new InternalPicker(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List));

                break;
            }

            case 4:     // Body Picker
            {
                toSet      = null;
                shouldSet  = false;
                shouldSend = false;

                m_Mobile.SendGump(new SetBodyGump(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List));

                break;
            }

            default:
            {
                toSet     = null;
                shouldSet = false;

                break;
            }
            }

            if (shouldSet)
            {
                try
                {
                    CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet == null ? "(null)" : toSet.ToString());
                    m_Property.SetValue(m_Object, toSet, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            if (shouldSend)
            {
                m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
            }
        }
Exemple #22
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Point3D toSet;
            bool    shouldSet, shouldSend;

            switch (info.ButtonID)
            {
            case 1:     // Current location
            {
                toSet      = m_Mobile.Location;
                shouldSet  = true;
                shouldSend = true;

                break;
            }

            case 2:     // Pick location
            {
                m_Mobile.Target = new InternalTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List);

                toSet      = Point3D.Zero;
                shouldSet  = false;
                shouldSend = false;

                break;
            }

            case 3:     // Use values
            {
                TextRelay x = info.GetTextEntry(0);
                TextRelay y = info.GetTextEntry(1);
                TextRelay z = info.GetTextEntry(2);

                toSet      = new Point3D(x == null ? 0 : Utility.ToInt32(x.Text), y == null ? 0 : Utility.ToInt32(y.Text), z == null ? 0 : Utility.ToInt32(z.Text));
                shouldSet  = true;
                shouldSend = true;

                break;
            }

            default:
            {
                toSet      = Point3D.Zero;
                shouldSet  = false;
                shouldSend = true;

                break;
            }
            }

            if (shouldSet)
            {
                try
                {
                    CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString());
                    m_Property.SetValue(m_Object, toSet, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            if (shouldSend)
            {
                m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
            }
        }
Exemple #23
0
        public SetPoint2DGump(
            PropertyInfo prop, Mobile mobile, object o, PropertiesGump propertiesGump
            )
            : base(GumpOffsetX, GumpOffsetY)
        {
            m_PropertiesGump = propertiesGump;
            m_Property       = prop;
            m_Mobile         = mobile;
            m_Object         = o;

            var p = (Point2D)(prop?.GetValue(o, null) ?? new Point2D());

            AddPage(0);

            AddBackground(0, 0, BackWidth, BackHeight, BackGumpID);
            AddImageTiled(
                BorderSize,
                BorderSize,
                TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0),
                TotalHeight,
                OffsetGumpID
                );

            var x = BorderSize + OffsetSize;
            var y = BorderSize + OffsetSize;

            AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
            AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop?.Name);
            x += EntryWidth + OffsetSize;

            if (SetGumpID != 0)
            {
                AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
            }

            x  = BorderSize + OffsetSize;
            y += EntryHeight + OffsetSize;

            AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
            AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Use your location");
            x += EntryWidth + OffsetSize;

            if (SetGumpID != 0)
            {
                AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
            }

            AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1);

            x  = BorderSize + OffsetSize;
            y += EntryHeight + OffsetSize;

            AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
            AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Target a location");
            x += EntryWidth + OffsetSize;

            if (SetGumpID != 0)
            {
                AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
            }

            AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2);

            x  = BorderSize + OffsetSize;
            y += EntryHeight + OffsetSize;

            AddImageTiled(x, y, CoordWidth, EntryHeight, EntryGumpID);
            AddLabelCropped(x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "X:");
            AddTextEntry(x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 0, p.X.ToString());
            x += CoordWidth + OffsetSize;

            AddImageTiled(x, y, CoordWidth, EntryHeight, EntryGumpID);
            AddLabelCropped(x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "Y:");
            AddTextEntry(x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 1, p.Y.ToString());
            x += CoordWidth + OffsetSize;

            if (SetGumpID != 0)
            {
                AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
            }

            AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3);
        }
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            TimeSpan toSet;
            bool     shouldSet, shouldSend;

            TextRelay h = info.GetTextEntry(0);
            TextRelay m = info.GetTextEntry(1);
            TextRelay s = info.GetTextEntry(2);

            switch (info.ButtonID)
            {
            case 1:                     // Zero
            {
                toSet      = TimeSpan.Zero;
                shouldSet  = true;
                shouldSend = true;

                break;
            }

            case 2:                     // From H:M:S
            {
                if (h != null && m != null && s != null)
                {
                    try
                    {
                        toSet      = TimeSpan.Parse(h.Text + ":" + m.Text + ":" + s.Text);
                        shouldSet  = true;
                        shouldSend = true;

                        break;
                    }
                    catch
                    {
                    }
                }

                toSet      = TimeSpan.Zero;
                shouldSet  = false;
                shouldSend = false;

                break;
            }

            case 3:                     // From H
            {
                if (h != null)
                {
                    try
                    {
                        toSet      = TimeSpan.FromHours(Utility.ToDouble(h.Text));
                        shouldSet  = true;
                        shouldSend = true;

                        break;
                    }
                    catch
                    {
                    }
                }

                toSet      = TimeSpan.Zero;
                shouldSet  = false;
                shouldSend = false;

                break;
            }

            case 4:                     // From M
            {
                if (m != null)
                {
                    try
                    {
                        toSet      = TimeSpan.FromMinutes(Utility.ToDouble(m.Text));
                        shouldSet  = true;
                        shouldSend = true;

                        break;
                    }
                    catch
                    {
                    }
                }

                toSet      = TimeSpan.Zero;
                shouldSet  = false;
                shouldSend = false;

                break;
            }

            case 5:                     // From S
            {
                if (s != null)
                {
                    try
                    {
                        toSet      = TimeSpan.FromSeconds(Utility.ToDouble(s.Text));
                        shouldSet  = true;
                        shouldSend = true;

                        break;
                    }
                    catch
                    {
                    }
                }

                toSet      = TimeSpan.Zero;
                shouldSet  = false;
                shouldSend = false;

                break;
            }

            default:
            {
                toSet      = TimeSpan.Zero;
                shouldSet  = false;
                shouldSend = true;

                break;
            }
            }

            if (shouldSet)
            {
                try
                {
                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString());
                    m_Property.SetValue(m_Object, toSet, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);

                    if (Miscellanious.ValidateLabeling(m_Object))
                    {
                        if (m_Object is Item)
                        {
                            ((Item)m_Object).Cheater_Name = String.Format("This item modified by GM {0}", m_Mobile.Name);
                        }

                        if (m_Object is Mobile)
                        {
                            ((Mobile)m_Object).Cheater_Name = String.Format("This mobile modified by GM {0}", m_Mobile.Name);
                        }
                    }
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            if (shouldSend)
            {
                m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
            }
        }
Exemple #25
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            int index = info.ButtonID - 1;

            if (index == -1)
            {
                this.m_Mobile.SendGump(new PropertiesGump(this.m_Mobile, this.m_Object, this.m_Stack, this.m_List, this.m_Page));
            }
            else if (index >= 0 && index < 4)
            {
                if (m_Monster == null)
                {
                    LoadLists();
                }

                ModelBodyType type;
                ArrayList     list;

                switch (index)
                {
                default:
                case 0:
                    type = ModelBodyType.Monsters;
                    list = m_Monster;
                    break;

                case 1:
                    type = ModelBodyType.Animals;
                    list = m_Animal;
                    break;

                case 2:
                    type = ModelBodyType.Sea;
                    list = m_Sea;
                    break;

                case 3:
                    type = ModelBodyType.Human;
                    list = m_Human;
                    break;
                }

                this.m_Mobile.SendGump(new SetBodyGump(this.m_Property, this.m_Mobile, this.m_Object, this.m_Stack, this.m_Page, this.m_List, 0, list, type));
            }
            else if (this.m_OurList != null)
            {
                index -= 4;

                if (index == 0 && this.m_OurPage > 0)
                {
                    this.m_Mobile.SendGump(new SetBodyGump(this.m_Property, this.m_Mobile, this.m_Object, this.m_Stack, this.m_Page, this.m_List, this.m_OurPage - 1, this.m_OurList, this.m_OurType));
                }
                else if (index == 1 && ((this.m_OurPage + 1) * 12) < this.m_OurList.Count)
                {
                    this.m_Mobile.SendGump(new SetBodyGump(this.m_Property, this.m_Mobile, this.m_Object, this.m_Stack, this.m_Page, this.m_List, this.m_OurPage + 1, this.m_OurList, this.m_OurType));
                }
                else
                {
                    index -= 2;

                    if (index >= 0 && index < this.m_OurList.Count)
                    {
                        try
                        {
                            InternalEntry entry = (InternalEntry)this.m_OurList[index];

                            CommandLogging.LogChangeProperty(this.m_Mobile, this.m_Object, this.m_Property.Name, entry.Body.ToString());
                            this.m_Property.SetValue(this.m_Object, entry.Body, null);
                            PropertiesGump.OnValueChanged(this.m_Object, this.m_Property, this.m_Stack);
                        }
                        catch
                        {
                            this.m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                        }

                        this.m_Mobile.SendGump(new SetBodyGump(this.m_Property, this.m_Mobile, this.m_Object, this.m_Stack, this.m_Page, this.m_List, this.m_OurPage, this.m_OurList, this.m_OurType));
                    }
                }
            }
        }
Exemple #26
0
        public SetObjectGump(PropertyInfo prop, Mobile mobile, object o, Stack stack, Type type, int page, ArrayList list)
            : base(GumpOffsetX, GumpOffsetY)
        {
            m_Property = prop;
            m_Mobile   = mobile;
            m_Object   = o;
            m_Stack    = stack;
            m_Type     = type;
            m_Page     = page;
            m_List     = list;

            string initialText = PropertiesGump.ValueToString(o, prop);

            AddPage(0);

            AddBackground(0, 0, BackWidth, BackHeight, BackGumpID);
            AddImageTiled(BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight, OffsetGumpID);

            int x = BorderSize + OffsetSize;
            int y = BorderSize + OffsetSize;

            AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
            AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name);
            x += EntryWidth + OffsetSize;

            if (SetGumpID != 0)
            {
                AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
            }

            x  = BorderSize + OffsetSize;
            y += EntryHeight + OffsetSize;

            AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
            AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, initialText);
            x += EntryWidth + OffsetSize;

            if (SetGumpID != 0)
            {
                AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
            }

            AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0);

            x  = BorderSize + OffsetSize;
            y += EntryHeight + OffsetSize;

            AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
            AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Change by Serial");
            x += EntryWidth + OffsetSize;

            if (SetGumpID != 0)
            {
                AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
            }

            AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2, GumpButtonType.Reply, 0);

            x  = BorderSize + OffsetSize;
            y += EntryHeight + OffsetSize;

            AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
            AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Nullify");
            x += EntryWidth + OffsetSize;

            if (SetGumpID != 0)
            {
                AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
            }

            AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3, GumpButtonType.Reply, 0);

            x  = BorderSize + OffsetSize;
            y += EntryHeight + OffsetSize;

            AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
            AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "View Properties");
            x += EntryWidth + OffsetSize;

            if (SetGumpID != 0)
            {
                AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
            }

            AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4, GumpButtonType.Reply, 0);
        }
Exemple #27
0
        public override void OnResponse(GameClient sender, RelayInfo info)
        {
            object toSet;
            bool   shouldSet, shouldSend = true;
            object viewProps = null;

            switch (info.ButtonID)
            {
            case 0:                     // closed
            {
                m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));

                toSet      = null;
                shouldSet  = false;
                shouldSend = false;

                break;
            }

            case 1:                     // Change by Target
            {
                m_Mobile.Target = new SetObjectTarget(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List);
                toSet           = null;
                shouldSet       = false;
                shouldSend      = false;
                break;
            }

            case 2:                     // Change by Serial
            {
                toSet      = null;
                shouldSet  = false;
                shouldSend = false;

                m_Mobile.SendMessage("Enter the serial you wish to find:");
                m_Mobile.Prompt = new InternalPrompt(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List);

                break;
            }

            case 3:                     // Nullify
            {
                toSet     = null;
                shouldSet = true;

                break;
            }

            case 4:                     // View Properties
            {
                toSet     = null;
                shouldSet = false;

                object obj = m_Property.GetValue(m_Object, null);

                if (obj == null)
                {
                    m_Mobile.SendMessage("The property is null and so you cannot view its properties.");
                }
                else if (!Scripts.Commands.BaseCommand.IsAccessible(m_Mobile, obj))
                {
                    m_Mobile.SendMessage("You may not view their properties.");
                }
                else
                {
                    viewProps = obj;
                }

                break;
            }

            default:
            {
                toSet     = null;
                shouldSet = false;

                break;
            }
            }

            if (shouldSet)
            {
                try
                {
                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet == null ? "(null)" : toSet.ToString());
                    m_Property.SetValue(m_Object, toSet, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            if (shouldSend)
            {
                m_Mobile.SendGump(new SetObjectGump(m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List));
            }

            if (viewProps != null)
            {
                m_Mobile.SendGump(new PropertiesGump(m_Mobile, viewProps));
            }
        }
Exemple #28
0
        public override void OnResponse(GameClient sender, RelayInfo info)
        {
            DateTime toSet;
            bool     shouldSet, shouldSend;

            string Y = "";

            if (info.ButtonID == 2 || info.ButtonID == 3 || info.ButtonID == 5)
            {
                Y = info.GetTextEntry(0).Text;
            }

            string M = "";

            if (info.ButtonID == 2 || info.ButtonID == 3 || info.ButtonID == 6)
            {
                M = info.GetTextEntry(1).Text;
            }

            string D = "";

            if (info.ButtonID == 2 || info.ButtonID == 3 || info.ButtonID == 7)
            {
                D = info.GetTextEntry(2).Text;
            }

            string h = "";

            if (info.ButtonID == 2 || info.ButtonID == 4 || info.ButtonID == 8)
            {
                h = info.GetTextEntry(3).Text;
            }

            string m = "";

            if (info.ButtonID == 2 || info.ButtonID == 4 || info.ButtonID == 9)
            {
                m = info.GetTextEntry(4).Text;
            }

            switch (info.ButtonID)
            {
            case 1:                     // MinValue
            {
                toSet      = DateTime.MinValue;
                shouldSet  = true;
                shouldSend = true;

                break;
            }

            case 2:                     // From YYYY MM DD H:M
            {
                string toApply = String.Format("{0}/{1}/{2} {3}:{4}:00",
                                               (Y != string.Empty ? Y : String.Format("{0:yyyy}", m_OldDateTime)),
                                               (M != string.Empty ? M : String.Format("{0:MM}", m_OldDateTime)), (D != string.Empty ? D : String.Format("{0:dd}", m_OldDateTime)),
                                               (h != string.Empty ? h : String.Format("{0:HH}", m_OldDateTime)), (m != string.Empty ? m : String.Format("{0:mm}", m_OldDateTime)));

                bool successfulParse = DateTime.TryParse(toApply, out toSet);
                shouldSet = shouldSend = successfulParse;

                break;
            }

            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            {
                goto case 2;
            }

            case 10:
            {
                toSet      = DateTime.MaxValue;
                shouldSet  = true;
                shouldSend = true;

                break;
            }

            default:
            {
                toSet      = DateTime.MinValue;
                shouldSet  = false;
                shouldSend = true;

                break;
            }
            }

            if (shouldSet)
            {
                try
                {
                    Server.Scripts.Commands.CommandLogging.LogChangeProperty(m_Mobile, m_Object, m_Property.Name, toSet.ToString());
                    m_Property.SetValue(m_Object, toSet, null);
                    PropertiesGump.OnValueChanged(m_Object, m_Property, m_Stack);
                }
                catch
                {
                    m_Mobile.SendMessage("An exception was caught. The property may not have changed.");
                }
            }

            if (shouldSend)
            {
                m_Mobile.SendGump(new PropertiesGump(m_Mobile, m_Object, m_Stack, m_List, m_Page));
            }
        }
Exemple #29
0
        public SetGump(PropertyInfo prop, Mobile from, object o, PropertiesGump propertiesGump) : base(GumpOffsetX, GumpOffsetY)
        {
            m_Mobile         = from;
            m_Object         = o;
            m_Property       = prop;
            m_PropertiesGump = propertiesGump;

            var canNull = !prop.PropertyType.IsValueType;
            var canDye  = prop.IsDefined(typeof(HueAttribute), false);

            var val         = prop.GetValue(m_Object, null);
            var initialText = val switch
            {
                null => "",
                TextDefinition definition => definition.GetValue(),
                _ => val.ToString()
            };

            AddPage(0);

            AddBackground(
                0,
                0,
                BackWidth,
                BackHeight + (canNull ? EntryHeight + OffsetSize : 0) + (canDye ? EntryHeight + OffsetSize : 0),
                BackGumpID
                );
            AddImageTiled(
                BorderSize,
                BorderSize,
                TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0),
                TotalHeight + (canNull ? EntryHeight + OffsetSize : 0) + (canDye ? EntryHeight + OffsetSize : 0),
                OffsetGumpID
                );

            var x = BorderSize + OffsetSize;
            var y = BorderSize + OffsetSize;

            AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
            AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name);
            x += EntryWidth + OffsetSize;

            if (SetGumpID != 0)
            {
                AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
            }

            x  = BorderSize + OffsetSize;
            y += EntryHeight + OffsetSize;

            AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
            AddTextEntry(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, 0, initialText);
            x += EntryWidth + OffsetSize;

            if (SetGumpID != 0)
            {
                AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
            }

            AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1);

            if (canNull)
            {
                x  = BorderSize + OffsetSize;
                y += EntryHeight + OffsetSize;

                AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
                AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Null");
                x += EntryWidth + OffsetSize;

                if (SetGumpID != 0)
                {
                    AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
                }

                AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2);
            }

            if (canDye)
            {
                x  = BorderSize + OffsetSize;
                y += EntryHeight + OffsetSize;

                AddImageTiled(x, y, EntryWidth, EntryHeight, EntryGumpID);
                AddLabelCropped(x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Hue Picker");
                x += EntryWidth + OffsetSize;

                if (SetGumpID != 0)
                {
                    AddImageTiled(x, y, SetWidth, EntryHeight, SetGumpID);
                }

                AddButton(x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3);
            }
        }
Exemple #30
0
        public SetBodyGump(
            PropertyInfo prop, Mobile mobile, object o, PropertiesGump propertiesGump,
            int ourPage = 0, List <InternalEntry> ourList = null, ModelBodyType ourType = ModelBodyType.Invalid
            )
            : base(20, 30)
        {
            m_PropertiesGump = propertiesGump;
            m_Property       = prop;
            m_Mobile         = mobile;
            m_Object         = o;
            m_OurPage        = ourPage;
            m_OurList        = ourList;
            m_OurType        = ourType;

            AddPage(0);

            AddBackground(0, 0, 525, 328, 5054);

            AddImageTiled(10, 10, 505, 20, 0xA40);
            AddAlphaRegion(10, 10, 505, 20);

            AddImageTiled(10, 35, 505, 283, 0xA40);
            AddAlphaRegion(10, 35, 505, 283);

            AddTypeButton(10, 10, 1, "Monster", ModelBodyType.Monsters);
            AddTypeButton(130, 10, 2, "Animal", ModelBodyType.Animals);
            AddTypeButton(250, 10, 3, "Marine", ModelBodyType.Sea);
            AddTypeButton(370, 10, 4, "Human", ModelBodyType.Human);

            AddImage(480, 12, 0x25EA);
            AddImage(497, 12, 0x25E6);

            if (ourList == null)
            {
                AddLabel(15, 40, 0x480, "Choose a body type above.");
            }
            else if (ourList.Count == 0)
            {
                AddLabel(15, 40, 0x480, "The server must have UO:3D installed to use this feature.");
            }
            else
            {
                for (int i = 0, index = ourPage * 12; i < 12 && index >= 0 && index < ourList.Count; ++i, ++index)
                {
                    var entry  = ourList[index];
                    var itemID = entry.ItemID;

                    var bounds = ItemBounds.Table[itemID & 0x3FFF];

                    var x = 15 + i % 4 * 125;
                    var y = 40 + i / 4 * 93;

                    AddItem(x + (120 - bounds.Width) / 2 - bounds.X, y + (69 - bounds.Height) / 2 - bounds.Y, itemID);
                    AddButton(x + 6, y + 66, 0x98D, 0x98D, 7 + index);

                    x += 6;
                    y += 67;

                    AddHtml(x + 0, y - 1, 108, 21, Center(entry.DisplayName));
                    AddHtml(x + 0, y + 1, 108, 21, Center(entry.DisplayName));
                    AddHtml(x - 1, y + 0, 108, 21, Center(entry.DisplayName));
                    AddHtml(x + 1, y + 0, 108, 21, Center(entry.DisplayName));
                    AddHtml(x + 0, y + 0, 108, 21, Color(Center(entry.DisplayName), TextColor32));
                }

                if (ourPage > 0)
                {
                    AddButton(480, 12, 0x15E3, 0x15E7, 5);
                }

                if ((ourPage + 1) * 12 < ourList.Count)
                {
                    AddButton(497, 12, 0x15E1, 0x15E5, 6);
                }
            }
        }