RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Gumps not closing completely

mdavis93

Sorceror
Okay, updating now. Just keep in mind, the gump closes perfectly fine when exited through the gump. I run into problems when the command is used to close the gump.
 

mdavis93

Sorceror
daat99 said:
Try to add this line to the case 0 in the OnResponce of the gumps (use similar line for toolkit):
Code:
state.Mobile.CloseGump( typeof( GMMiniKit ) );

Didn't work. Still looped when exited by the command.


Admin Vorspie said:
private static void GMToolKit_OnCommand( CommandEventArgs e)
{
Mobile from = e.Mobile;
if( from.HasGump( typeof( GMToolKit)) )
{
from.SendMessage( "GM Tool-Kit is open, closing..." );
from.CloseGump( typeof( GMToolKit) );
}

if ( from.HasGump( typeof( GMMiniKit )) )
{
from.SendMessage( "GM Mini-Kit is open, closing..." );
from.CloseGump( typeof( GMMiniKit ) );
}
else
{
from.SendMessage( "GM Mini-Kit is closed, opening..." );
from.SendGump( new GMMiniKit() );
}
return;
}
}
}​


Does not work, loops "GMMiniKit is open, now closing..."​
 

mdavis93

Sorceror
Updated Code

CommandEvent Code:
Code:
private static void ToolKit_OnCommand( CommandEventArgs e)
{
    Mobile from = e.Mobile;
    if( from.HasGump( typeof( GMToolKit)) )
    {
        from.SendMessage( "GM Tool-Kit is open, closing..." );
        from.CloseGump( typeof( GMToolKit) );
    }
 
    else if ( from.HasGump( typeof( GMMiniKit )) )
    {
        from.SendMessage( "GM Mini-Kit is open, closing..." );
        from.CloseGump( typeof( GMMiniKit ) );
    }
    else
    {
        from.SendMessage( "GMToolKit is closed, opening..." );
        from.SendGump( new GMToolKit() );    
    }
}

Gump Code:
Code:
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
namespace Server.Gumps
{
public class GMToolKit : Gump
{
public GMToolKit()
: base( 0, 0 )
{
this.Closable = true;
this.Disposable = true;
this.Dragable = true;
this.Resizable = false;
this.AddPage( 0 );
this.AddBackground( 234, 97, 295, 388, 9400 );
this.AddButton( 495, 459, 4005, 4007, (int)Buttons.btn_Shrink, GumpButtonType.Reply, 1 );
this.AddButton( 338, 288, 2443, 2444, (int)Buttons.btn_Say, GumpButtonType.Reply, 2 );
this.AddButton( 338, 456, 2443, 2444, (int)Buttons.btn_Emote, GumpButtonType.Reply, 3 );
this.AddLabel( 356, 290, 0, @"Say" );
this.AddLabel( 348, 458, 0, @"Emote" );
this.AddImageTiled( 235, 278, 292, 5, 9401 );
this.AddImageTiled( 326, 100, 1, 181, 9403 );
this.AddImageTiled( 427, 101, 1, 181, 9403 );
this.AddButton( 445, 111, 2443, 2444, (int)Buttons.btn_GMSwap, GumpButtonType.Reply, 4 );
this.AddLabel( 451, 113, 0, @"+/- GM" );
this.AddButton( 445, 138, 2443, 2444, (int)Buttons.btn_AnimDead, GumpButtonType.Reply, 5 );
this.AddLabel( 458, 140, 0, @"A.D.U" );
this.AddButton( 445, 165, 2443, 2444, (int)Buttons.btn_Stuck, GumpButtonType.Reply, 6 );
this.AddLabel( 456, 167, 0, @"Stuck" );
this.AddButton( 445, 192, 2443, 2444, (int)Buttons.btn_Pages, GumpButtonType.Reply, 7 );
this.AddLabel( 456, 194, 0, @"Pages" );
this.AddButton( 445, 219, 2443, 2444, (int)Buttons.btn_ViewEquip, GumpButtonType.Reply, 8 );
this.AddLabel( 460, 221, 0, @"View" );
this.AddButton( 445, 246, 2443, 2444, (int)Buttons.btn_SpeechLog, GumpButtonType.Reply, 9 );
this.AddLabel( 450, 247, 0, @"SpchLog" );
this.AddButton( 345, 111, 2443, 2444, (int)Buttons.btn_Attack, GumpButtonType.Reply, 10 );
this.AddLabel( 353, 113, 0, @"Attack" );
this.AddButton( 345, 138, 2443, 2444, (int)Buttons.btn_Bank, GumpButtonType.Reply, 11 );
this.AddLabel( 359, 140, 0, @"Bank" );
this.AddButton( 345, 165, 2443, 2444, (int)Buttons.btn_Remove, GumpButtonType.Reply, 12 );
this.AddLabel( 353, 168, 0, @"Remove" );
this.AddButton( 345, 192, 2443, 2444, (int)Buttons.btn_Move, GumpButtonType.Reply, 13 );
this.AddLabel( 358, 194, 0, @"Move" );
this.AddButton( 345, 219, 2443, 2444, (int)Buttons.btn_Squelch, GumpButtonType.Reply, 14 );
this.AddLabel( 352, 221, 0, @"Squelch" );
this.AddButton( 345, 246, 2443, 2444, (int)Buttons.btn_Props, GumpButtonType.Reply, 15 );
this.AddLabel( 356, 248, 0, @"Props" );
this.AddButton( 248, 246, 2443, 2444, (int)Buttons.btn_Mortal, GumpButtonType.Reply, 16 );
this.AddLabel( 257, 248, 0, @"Mortal" );
this.AddButton( 248, 219, 2443, 2444, (int)Buttons.btn_Invul, GumpButtonType.Reply, 17 );
this.AddLabel( 264, 221, 0, @"Invul" );
this.AddButton( 248, 165, 2443, 2444, (int)Buttons.btn_Unhide, GumpButtonType.Reply, 18 );
this.AddLabel( 258, 168, 0, @"UnHide" );
this.AddButton( 248, 192, 2443, 2444, (int)Buttons.btn_Tele, GumpButtonType.Reply, 19 );
this.AddLabel( 265, 194, 0, @"Tele" );
this.AddButton( 248, 138, 2443, 2444, (int)Buttons.btn_Hide, GumpButtonType.Reply, 20 );
this.AddLabel( 267, 140, 0, @"Hide" );
this.AddButton( 248, 111, 2443, 2444, (int)Buttons.btn_Kill, GumpButtonType.Reply, 21 );
this.AddLabel( 268, 113, 0, @"Kill" );
this.AddBackground( 244, 318, 275, 130, 3000 );
this.AddTextEntry( 246, 321, 270, 124, 0, (int)Buttons.TextEntry1, @"" );
}
public enum Buttons
{
Close,
btn_Shrink,
btn_Say,
btn_Emote,
btn_GMSwap,
btn_AnimDead,
btn_Stuck,
btn_Pages,
btn_ViewEquip,
btn_SpeechLog,
btn_Attack,
btn_Bank,
btn_Remove,
btn_Move,
btn_Squelch,
btn_Props,
btn_Mortal,
btn_Invul,
btn_Unhide,
btn_Tele,
btn_Hide,
btn_Kill,
TextEntry1,
}
public override void OnResponse( NetState state, RelayInfo info )
{
switch( info.ButtonID )
{
case 0:
{
state.Mobile.SendMessage( "You pushed button: " + info.ButtonID );
state.Mobile.CloseGump( typeof( GMToolKit ) );
break;
}
default:
{
Mobile from = state.Mobile;
from.CloseGump( typeof( GMToolKit ) );
from.SendGump( new GMMiniKit() );
break;
}
}
}
}
 
public class GMMiniKit : Gump
{
public GMMiniKit()
: base( ( 640 / 2 ), ( 480 / 2 ) )
{
this.Closable=false;
this.Disposable=true;
this.Dragable=true;
this.Resizable=false;
this.AddPage(0);
this.AddBackground( 0, 0, 51, 57, 9400 );
this.AddButton( 10, 14, 10830, 10830, (int)Buttons.Button1, GumpButtonType.Reply, 1 );
}
 
public enum Buttons
{
Close,
Button1,
}
public override void OnResponse( NetState state, RelayInfo info )
{
switch( info.ButtonID )
{
case 0:
{
state.Mobile.SendMessage( "You pushed button: " + info.ButtonID );
state.Mobile.CloseGump( typeof( GMMiniKit ) );
return;
}
default:
{
Mobile from = state.Mobile;
state.Mobile.SendMessage( "You pushed button: " + info.ButtonID );
from.CloseGump( typeof( GMMiniKit ) );
from.SendGump( new GMToolKit() );
break;
}
}
}
}
}
 

daat99

Moderator
Staff member
mdavis93 said:
Nope, still loops the "GMToolKit is open, now closing..." message.
Ok, first it doesn't looping.
When you say looping that means that you type the command once and it tell you the message several times.
So if it say it once every time than it does not loop.
Second why do you add useless code again???
Please read back what I said to vorspir to know what I'm talking about.
 

mdavis93

Sorceror
I know, the return does absolutely nothing.

I updated the post to show that it's taken out. I'm begining to think that the CloseGump doesn't work if not called by an OnResponse function..


No it's not a repeated loops.. it's just every time I type the command it says the gump is open, which means that the if( from.HasGump( typeof( GMToolKit ) ) check is passing true, when it shouldn't be that way.. it should have been closed by the CloseGump statement.
 

daat99

Moderator
Staff member
mdavis93 said:
I know, the return does absolutely nothing.

I updated the post to show that it's taken out. I'm begining to think that the CloseGump doesn't work if not called by an OnResponse function..


No it's not a repeated loops.. it's just every time I type the command it says the gump is open, which means that the if( from.HasGump( typeof( GMToolKit ) ) check is passing true, when it shouldn't be that way.. it should have been closed by the CloseGump statement.
I don't think there's any more suggestions that I can give you over the forums that I didn't already.
It seems wiered to me and it shouldn't work like you describe it.
 

mdavis93

Sorceror
OKay, I'm at a loss. I have attatched the two files needed for this gump. If anyone knows what is causing the problems, please let me know.

Files Included:

MageGM: This file has the Handler for the ToolKit Command
GMToolKit: This is the actual gump file.

No configuration should be needed.
 

Attachments

  • Custom.zip
    1.9 KB · Views: 6

A_Li_N

Knight
Yoink!

This works, although it might be hack/slash and maybe something the devs should look into? *Posted a new topic about it in this forum*

For some reason, the CloseGump and CloseAllGumps do not remove the gump from the NetState's GumpCollection. I have no idea the reason for this. Don't know if it's just not needed, or just an oversight?
 

Attachments

  • GMToolkit.cs
    5.6 KB · Views: 7
  • MakeGM.cs
    1.6 KB · Views: 6
Top