Ejemplo n.º 1
0
        public static void SendAdvancedAction(uint gumpid, int buttonid, List <int> switchs, List <int> entryID, List <string> entryS)
        {
            if (entryID.Count == entryS.Count)
            {
                int             i       = 0;
                GumpTextEntry[] entries = new GumpTextEntry[entryID.Count];

                foreach (int entry in entryID)
                {
                    GumpTextEntry entrie = new GumpTextEntry(0, string.Empty);
                    entrie.EntryID = (ushort)entry;
                    entrie.Text    = entryS[i];
                    entries[i]     = entrie;
                }

                if (gumpid == 0)
                {
                    Assistant.Client.Instance.SendToClientWait(new CloseGump(World.Player.CurrentGumpI));
                    Assistant.Client.Instance.SendToServerWait(new GumpResponse(World.Player.CurrentGumpS, World.Player.CurrentGumpI, buttonid, switchs.ToArray(), entries));
                }
                else
                {
                    Assistant.Client.Instance.SendToClientWait(new CloseGump(gumpid));
                    Assistant.Client.Instance.SendToServerWait(new GumpResponse(World.Player.CurrentGumpS, gumpid, buttonid, switchs.ToArray(), entries));
                }

                World.Player.HasGump = false;
                World.Player.CurrentGumpStrings.Clear();
            }
            else
            {
                Scripts.SendMessageScriptError("Script Error: SendAdvancedAction: entryID and entryS lenght not match");
            }
        }
Ejemplo n.º 2
0
        //AutoDoc concatenates description coming from Overloaded methods
        /// <summary>
        /// This method can also be used only Switches, without Text fileds.
        /// </summary>
        public static void SendAdvancedAction(uint gumpid, int buttonid, List <int> switchs)
        {
            GumpTextEntry[] entries = new GumpTextEntry[0];

            if (gumpid == 0)
            {
                Assistant.Client.Instance.SendToClientWait(new CloseGump(World.Player.CurrentGumpI));
                Assistant.Client.Instance.SendToServerWait(new GumpResponse(World.Player.CurrentGumpS, World.Player.CurrentGumpI, buttonid, switchs.ToArray(), entries));
            }
            else
            {
                Assistant.Client.Instance.SendToClientWait(new CloseGump(gumpid));
                GumpResponse gumpResp = new GumpResponse(World.Player.CurrentGumpS, gumpid, buttonid, switchs.ToArray(), entries);
                if (m_gumpData.ContainsKey(gumpid))
                {
                    PacketReader           p    = new PacketReader(gumpResp.ToArray(), false);
                    PacketHandlerEventArgs args = new PacketHandlerEventArgs();
                    p.ReadByte();  // through away the packet id
                    p.ReadInt16(); // throw away the packet length
                    Assistant.PacketHandlers.ClientGumpResponse(p, args);
                }
                else
                {
                    Assistant.Client.Instance.SendToServerWait(gumpResp);
                }
            }

            World.Player.HasGump = false;
            World.Player.CurrentGumpStrings.Clear();
            World.Player.CurrentGumpTile.Clear();
        }
Ejemplo n.º 3
0
 public virtual void HandleTextInput(GumpTextEntry input, string text)
 {
     if (TextInputHandler != null)
     {
         TextInputHandler(input, text);
     }
     else if (TextInputs[input] != null)
     {
         TextInputs[input](input, text);
     }
 }
Ejemplo n.º 4
0
        protected void AddTextEntry(GumpTextEntry input, Action <GumpTextEntry, string> handler)
        {
            if (input == null)
            {
                return;
            }

            TextInputs[input] = handler;

            Add(input);
        }
Ejemplo n.º 5
0
        public static void AppendTo(this GumpTextEntry g, IGumpWriter disp, List <string> strings)
        {
            disp.AppendLayout(GumpTextEntry.LayoutName);
            disp.AppendLayout(g.X);
            disp.AppendLayout(g.Y);
            disp.AppendLayout(g.Width);
            disp.AppendLayout(g.Height);
            disp.AppendLayout(g.Hue);
            disp.AppendLayout(g.EntryID);
            disp.AppendLayout(strings.Intern(g.InitialText));

            disp.TextEntries++;
        }
Ejemplo n.º 6
0
 public virtual void Write(string name, GumpTextEntry e)
 {
     CreateElement(e);
     SetAttribute("name", name);
     SetAttribute("x", e.X);
     SetAttribute("y", e.Y);
     SetAttribute("width", e.Width);
     SetAttribute("height", e.Height);
     SetAttribute("entryid", e.EntryID);
     SetAttribute("hue", e.Hue);
     SetValue(e.InitialText);
     Append();
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Send a Gump response, with gumpid and buttonid and advanced switch in gumps.
        /// This function is intended for more complex Gumps, with not only Buttons, but also Switches, CheckBoxes and Text fileds.
        /// </summary>
        /// <param name="gumpid">ID of the gump.</param>
        /// <param name="buttonid">ID of the Button.</param>
        /// <param name="switchlist_id">List of ID of ON/Active switches. (empty: all Switches OFF)</param>
        /// <param name="textlist_id">List of ID of Text fileds. (empty: all text fileds empty )</param>
        /// <param name="textlist_str">List of the contents of the Text fields, provided in the same order as textlist_id.</param>
        public static void SendAdvancedAction(uint gumpid, int buttonid, List <int> switchlist_id, List <int> textlist_id, List <string> textlist_str)
        {
            if (textlist_id.Count == textlist_str.Count)
            {
                int             i       = 0;
                GumpTextEntry[] entries = new GumpTextEntry[textlist_id.Count];

                foreach (int entry in textlist_id)
                {
                    GumpTextEntry entrie = new GumpTextEntry(0, string.Empty)
                    {
                        EntryID = (ushort)entry,
                        Text    = textlist_str[i]
                    };
                    entries[i] = entrie;
                    i++;
                }

                if (gumpid == 0)
                {
                    Assistant.Client.Instance.SendToClientWait(new CloseGump(World.Player.CurrentGumpI));
                    Assistant.Client.Instance.SendToServerWait(new GumpResponse(World.Player.CurrentGumpS, World.Player.CurrentGumpI, buttonid, switchlist_id.ToArray(), entries));
                }
                else
                {
                    Assistant.Client.Instance.SendToClientWait(new CloseGump(gumpid));
                    GumpResponse gumpResp = new GumpResponse(World.Player.CurrentGumpS, gumpid, buttonid, switchlist_id.ToArray(), entries);
                    if (m_gumpData.ContainsKey(gumpid))
                    {
                        PacketReader           p    = new PacketReader(gumpResp.ToArray(), false);
                        PacketHandlerEventArgs args = new PacketHandlerEventArgs();
                        p.ReadByte();  // through away the packet id
                        p.ReadInt16(); // throw away the packet length
                        Assistant.PacketHandlers.ClientGumpResponse(p, args);
                    }
                    else
                    {
                        Assistant.Client.Instance.SendToServerWait(gumpResp);
                    }
                }

                World.Player.HasGump = false;
                World.Player.CurrentGumpStrings.Clear();
            }
            else
            {
                Scripts.SendMessageScriptError("Script Error: SendAdvancedAction: entryID and entryS lenght not match");
            }
        }
Ejemplo n.º 8
0
        public void OnTextIdTextEntryUpdate(IGumpComponent gumpComponent, object param)
        {
            GumpTextEntry entry = gumpComponent as GumpTextEntry;

            if (entry != null)
            {
                try
                {
                    Text = entry.InitialText;
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 9
0
        public void OnHueTextEntryUpdate(IGumpComponent gumpComponent, object param)
        {
            GumpTextEntry entry = gumpComponent as GumpTextEntry;

            if (entry != null)
            {
                try
                {
                    Hue = Convert.ToInt32(entry.InitialText);
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 10
0
 public void onGumpNameEntryUpdate(GumpTextEntry entry, string param)
 {
     if (entry != null)
     {
         var gumpname = entry.InitialText;
         if (gumpname.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)
         {
             m_displayErrorMessage = true;
         }
         else
         {
             m_gumpName            = gumpname;
             m_displayErrorMessage = false;
         }
     }
 }
Ejemplo n.º 11
0
        public void onGumpNameEntryUpdate(IGumpComponent gumpComponent, object param)
        {
            GumpTextEntry entry = gumpComponent as GumpTextEntry;

            if (entry != null)
            {
                string gumpname = entry.InitialText;
                if (gumpname.IndexOfAny(System.IO.Path.GetInvalidFileNameChars()) >= 0)
                {
                    m_displayErrorMessage = true;
                }
                else
                {
                    m_gumpName            = gumpname;
                    m_displayErrorMessage = false;
                }
            }
        }
Ejemplo n.º 12
0
        public static void SendAdvancedAction(uint gumpid, int buttonid, List <int> switchs)
        {
            GumpTextEntry[] entries = new GumpTextEntry[0];

            ClientCommunication.SendToClientWait(new CloseGump(World.Player.CurrentGumpI));

            if (gumpid == 0)
            {
                ClientCommunication.SendToServerWait(new GumpResponse(World.Player.CurrentGumpS, World.Player.CurrentGumpI, buttonid, switchs.ToArray(), entries));
            }
            else
            {
                ClientCommunication.SendToServerWait(new GumpResponse(World.Player.CurrentGumpS, gumpid, buttonid, switchs.ToArray(), entries));
            }

            World.Player.HasGump = false;
            World.Player.CurrentGumpStrings.Clear();
        }
Ejemplo n.º 13
0
        protected void AddTextEntry(GumpTextEntry input, Action <GumpTextEntry, string> handler)
        {
            if (input == null)
            {
                return;
            }

            if (!TextInputs.ContainsKey(input))
            {
                TextInputs.Add(input, handler);
            }
            else
            {
                TextInputs[input] = handler;
            }

            Add(input);
        }
Ejemplo n.º 14
0
        public static void SendAction(uint gumpid, int buttonid)
        {
            int[]           nullswitch  = new int[0];
            GumpTextEntry[] nullentries = new GumpTextEntry[0];

            ClientCommunication.SendToClientWait(new CloseGump(World.Player.CurrentGumpI));

            if (gumpid == 0)
            {
                ClientCommunication.SendToServerWait(new GumpResponse(World.Player.CurrentGumpS, World.Player.CurrentGumpI, buttonid, nullswitch, nullentries));
            }
            else
            {
                ClientCommunication.SendToServerWait(new GumpResponse(World.Player.CurrentGumpS, gumpid, buttonid, nullswitch, nullentries));
            }

            World.Player.HasGump = false;
            World.Player.CurrentGumpStrings.Clear();
            World.Player.CurrentGumpI = 0;
        }
Ejemplo n.º 15
0
		public void onGumpNameEntryUpdate(GumpTextEntry entry, string param)
		{
			if (entry != null)
			{
				var gumpname = entry.InitialText;
				if (gumpname.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)
				{
					m_displayErrorMessage = true;
				}
				else
				{
					m_gumpName = gumpname;
					m_displayErrorMessage = false;
				}
			}
		}
Ejemplo n.º 16
0
 public GumpResponseAction( int button, int[] switches, GumpTextEntry[] entries )
 {
     m_ButtonID = button;
     m_Switches = switches;
     m_TextEntries = entries;
 }
Ejemplo n.º 17
0
 protected virtual void ParseInput(GumpTextEntry entry, string text)
 {
     ParseInput(text);
 }
Ejemplo n.º 18
0
 public virtual bool CanDisplay(GumpTextEntry input)
 {
     return(input != null);
 }
Ejemplo n.º 19
0
        protected override void CompileLayout(SuperGumpLayout layout)
        {
            base.CompileLayout(layout);

            if (Sources == null)
            {
                return;
            }

            Sources.ForEach(
                source =>
            {
                if (source == null || source.IsDisposed || !source.Compiled || !source.IsOpen)
                {
                    return;
                }

                source.Entries.For(
                    (i, src) =>
                {
                    if (src is GumpPage)
                    {
                        GumpPage e = (GumpPage)src;
                        layout.Add(source.Serial + "/" + i + "/GumpPage", () => AddPage(e.Page));
                    }
                    else if (src is GumpTooltip)
                    {
                        GumpTooltip e = (GumpTooltip)src;
                        layout.Add(source.Serial + "/" + i + "/GumpTooltip", () => AddTooltip(e.Number));
                    }
                    else if (src is GumpBackground)
                    {
                        GumpBackground e = (GumpBackground)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpBackground", () => AddBackground(e.X, e.Y, e.Width, e.Height, e.GumpID));
                    }
                    else if (src is GumpAlphaRegion)
                    {
                        GumpAlphaRegion e = (GumpAlphaRegion)src;
                        layout.Add(source.Serial + "/" + i + "/GumpAlphaRegion", () => AddAlphaRegion(e.X, e.Y, e.Width, e.Height));
                    }
                    else if (src is GumpItem)
                    {
                        GumpItem e = (GumpItem)src;
                        layout.Add(source.Serial + "/" + i + "/GumpItem", () => AddItem(e.X, e.Y, e.ItemID, e.Hue));
                    }
                    else if (src is GumpImage)
                    {
                        GumpImage e = (GumpImage)src;
                        layout.Add(source.Serial + "/" + i + "/GumpImage", () => AddImage(e.X, e.Y, e.GumpID, e.Hue));
                    }
                    else if (src is GumpImageTiled)
                    {
                        GumpImageTiled e = (GumpImageTiled)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpImageTiled", () => AddImageTiled(e.X, e.Y, e.Width, e.Height, e.GumpID));
                    }
                    else if (src is GumpImageTileButton)
                    {
                        GumpImageTileButton e = (GumpImageTileButton)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpImageTileButton",
                            () =>
                            AddImageTiledButton(
                                e.X, e.Y, e.NormalID, e.PressedID, e.ButtonID, e.Type, e.Param, e.ItemID, e.Hue, e.Width, e.Height));
                    }
                    else if (src is GumpLabel)
                    {
                        GumpLabel e = (GumpLabel)src;
                        layout.Add(source.Serial + "/" + i + "/GumpLabel", () => AddLabel(e.X, e.Y, e.Hue, e.Text));
                    }
                    else if (src is GumpLabelCropped)
                    {
                        GumpLabelCropped e = (GumpLabelCropped)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpLabelCropped",
                            () => AddLabelCropped(e.X, e.Y, e.Width, e.Height, e.Hue, e.Text));
                    }
                    else if (src is GumpHtml)
                    {
                        GumpHtml e = (GumpHtml)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpHtml",
                            () => AddHtml(e.X, e.Y, e.Width, e.Height, e.Text, e.Background, e.Scrollbar));
                    }
                    else if (src is GumpHtmlLocalized)
                    {
                        GumpHtmlLocalized e = (GumpHtmlLocalized)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpHtmlLocalized",
                            () => AddHtmlLocalized(e.X, e.Y, e.Width, e.Height, e.Number, e.Args, e.Color, e.Background, e.Scrollbar));
                    }
                    else if (src is GumpButton)
                    {
                        GumpButton e = (GumpButton)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpButton",
                            () => AddButton(e.X, e.Y, e.NormalID, e.PressedID, e.ButtonID, source.Buttons.GetValue(e)));
                    }
                    else if (src is GumpCheck)
                    {
                        GumpCheck e = (GumpCheck)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpCheck",
                            () => AddCheck(e.X, e.Y, e.InactiveID, e.ActiveID, e.SwitchID, e.InitialState, source.Switches.GetValue(e)));
                    }
                    else if (src is GumpRadio)
                    {
                        GumpRadio e = (GumpRadio)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpRadio",
                            () => AddRadio(e.X, e.Y, e.InactiveID, e.ActiveID, e.SwitchID, e.InitialState, source.Radios.GetValue(e)));
                    }
                    else if (src is GumpTextEntry)
                    {
                        GumpTextEntry e = (GumpTextEntry)src;
                        layout.Add(
                            source.Serial + "/" + i + "/GumpTextEntry",
                            () => AddTextEntry(e.X, e.Y, e.Width, e.Height, e.Hue, e.EntryID, e.InitialText, source.TextInputs.GetValue(e)));
                    }
                    else if (src is GumpTextEntryLimited)
                    {
                        GumpTextEntryLimited e = (GumpTextEntryLimited)src;
                        var action             = source.LimitedTextInputs.GetValue(e);

                        layout.Add(
                            source.Serial + "/" + i + "/GumpTextEntryLimited",
                            () => AddTextEntryLimited(e.X, e.Y, e.Width, e.Height, e.Hue, e.EntryID, e.InitialText, e.Size, action));
                    }
                });

                layout.Add(
                    source.Serial + "/frame",
                    () =>
                {
                    AddImageTiled(source.X, source.Y, source.OuterWidth, 2, 11340);                                     //top
                    AddImageTiled(source.X + source.OuterWidth, source.Y, 2, source.OuterHeight, 11340);                //right
                    AddImageTiled(source.X, source.Y + source.OuterHeight, source.OuterWidth, 2, 11340);                //bottom
                    AddImageTiled(source.X, source.Y, 2, source.OuterHeight, 11340);                                    //left
                });
            });
        }