Kamras
Member
On my gump I have an exit button which works fine however I also want the option to just right click on it. (may end up removing the exit button). However when I right click on it as of now, it just throws me to the next button action indicated on Line 254. Anyone able to show me why this just doesn't close when being right clicked?
Here is the script.
Here is the script.
Code:
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Items;
using Server.Commands;
using Server.Engines.Craft;
namespace Server.Gumps
{
[Flipable(0x1EB8, 0x1EB9)]
public class MultiTool : Item
{
[Constructable]
public MultiTool() : base( 0x1EB8 )
{
Movable = true;
// Weight = 0.0;
Name = "Multi Tool";
LootType = LootType.Blessed;
}
public override void OnDoubleClick( Mobile m )
{
m.SendGump( new CraftTools());
}
public MultiTool( Serial serial ) : base( serial )
{
}
public virtual bool Accepted
{
get
{
return this.Deleted;
}
}
public override bool DropToWorld(Mobile from, Point3D p)
{
bool ret = base.DropToWorld(from, p);
if (ret && !this.Accepted && this.Parent != from.Backpack)
{
if (from.IsStaff())
{
return true;
}
else
{
from.LocalOverheadMessage(MessageType.Emote, 0x22, true, "You feel silly for wanting to drop something so useful...");
return false;
}
}
else
{
return ret;
}
}
public override bool DropToMobile(Mobile from, Mobile target, Point3D p)
{
bool ret = base.DropToMobile(from, target, p);
if (ret && !this.Accepted && this.Parent != from.Backpack)
{
if (from.IsStaff())
{
return true;
}
else
{
from.LocalOverheadMessage(MessageType.Emote, 0x22, true, "This cannot be traded!");
return false;
}
}
else
{
return ret;
}
}
public override bool DropToItem(Mobile from, Item target, Point3D p)
{
bool ret = base.DropToItem(from, target, p);
if (ret && !this.Accepted && this.Parent != from.Backpack)
{
if (from.IsStaff())
{
return true;
}
else
{
from.LocalOverheadMessage(MessageType.Emote, 0x22, true, "This can only exist on the top level of the backpack!");
return false;
}
}
else
{
return ret;
}
}
public override void AddNameProperty(ObjectPropertyList list)
{
base.AddNameProperty( list );
list.Add( "<BASEFONT COLOR=#7FCAE7>" + "Handy Crafting Tool" + "<BASEFONT COLOR=#FFFFFF>"/*Back to White*/ );
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
}
}
public class CraftTools : Gump
{
Mobile caller;
public static void Initialize()
{
CommandSystem.Register("CraftTools", AccessLevel.Administrator, new CommandEventHandler(CraftTools_OnCommand));
}
[Usage("CraftTools")]
[Description("Makes a call to your custom gump.")]
public static void CraftTools_OnCommand(CommandEventArgs e)
{
Mobile from = e.Mobile;
if (from.HasGump(typeof(CraftTools)))
from.CloseGump(typeof(CraftTools));
from.SendGump(new CraftTools(from));
}
public CraftTools(Mobile from) : this()
{
caller = from;
}
public CraftTools() : base( 0, 0 )
{
this.Closable=true;
this.Disposable=true;
this.Dragable=true;
this.Resizable=false;
AddPage(0);
AddBackground(84, 103, 486, 230, 9200);
AddAlphaRegion(84, 103, 485, 231);
AddBackground(461, 333, 106, 32, 9200);
AddAlphaRegion(458, 335, 109, 29);
AddBackground(89, 333, 106, 32, 9200);
AddAlphaRegion(86, 335, 109, 29);
AddPage(1);
AddBackground(416, 224, 96, 21, 9200);
AddBackground(416, 191, 96, 21, 9200);
AddBackground(414, 156, 96, 21, 9200);
AddBackground(413, 123, 96, 21, 9200);
AddBackground(138, 223, 136, 21, 9200);
AddBackground(138, 191, 96, 21, 9200);
AddBackground(136, 158, 96, 21, 9200);
AddBackground(136, 123, 96, 21, 9200);
AddBackground(270, 113, 98, 31, 9200);
AddBackground(466, 339, 59, 21, 9200);
AddBackground(138, 257, 109, 21, 9200);
AddBackground(138, 292, 113, 21, 9200);
AddBackground(416, 259, 96, 21, 9200);
AddBackground(416, 293, 96, 21, 9200);
AddImage(294, 156, 2096);
//Buttons
AddButton(98, 113, 2642, 2643, (int)Buttons.blacksmithy, GumpButtonType.Reply, 0);//blacksmithy
AddButton(98, 148, 2642, 2643, (int)Buttons.tinkering, GumpButtonType.Reply, 0);//tinkering
AddButton(98, 183, 2642, 2643, (int)Buttons.woodworking, GumpButtonType.Reply, 0);//woodworking
AddButton(98, 218, 2642, 2643, (int)Buttons.fletching, GumpButtonType.Reply, 0);//fletching / bowcraft
AddButton(514, 113, 2642, 2643, (int)Buttons.tailoring, GumpButtonType.Reply, 0);//tailoring
AddButton(514, 148, 2642, 2643, (int)Buttons.cooking, GumpButtonType.Reply, 0);//cooking
AddButton(514, 183, 2642, 2643, (int)Buttons.alchemy, GumpButtonType.Reply, 0);//alchemy
AddButton(514, 218, 2642, 2643, (int)Buttons.imbue, GumpButtonType.Reply, 0);//imbuing
AddButton(530, 339, 4018, 4019, (int)Buttons.exit, GumpButtonType.Reply, 0);//exit
AddButton(98, 252, 2642, 2643, (int)Buttons.mountcrafting, GumpButtonType.Reply, 0);//mountcrafting
AddButton(98, 287, 2642, 2643, (int)Buttons.firecraft, GumpButtonType.Reply, 0);//firecraft
AddButton(514, 253, 2642, 2643, (int)Buttons.powersew, GumpButtonType.Reply, 0);//powersew
AddButton(514, 287, 2642, 2643, (int)Buttons.waxcraft, GumpButtonType.Reply, 0);//waxcraft
AddButton(156, 338, 4005, 4006, 0, GumpButtonType.Page, 2);
// Button Labels
AddLabel(143, 123, 1284, @"Blacksmithy");
AddLabel(141, 224, 1284, @"Bowcraft/Fletching");
AddLabel(143, 191, 1284, @"Wood Working");
AddLabel(434, 158, 1284, @"Cooking");
AddLabel(433, 123, 1284, @"Tailoring");
AddLabel(433, 191, 1284, @"Alchemy");
AddLabel(433, 225, 1284, @"Imbuing");
AddLabel(281, 119, 1284, @"Craft Tools");
AddLabel(480, 340, 1284, @"EXIT");
AddLabel(141, 258, 1284, @"Mount Crafting");
AddLabel(141, 293, 1284, @"Fire Rock Craft");
AddLabel(422, 259, 1284, @"Power Sewing");
AddLabel(429, 293, 1284, @"Wax Craft");
AddLabel(144, 158, 1284, @"Tinkering");
AddLabel(299, 213, 1284, @"Page 1");
AddPage(2);
AddBackground(413, 123, 96, 21, 9200);
AddBackground(136, 123, 96, 21, 9200);
AddButton(98, 113, 2642, 2643, 0, GumpButtonType.Reply, 0);
AddButton(514, 113, 2642, 2643, 0, GumpButtonType.Reply, 0);
AddLabel(150, 123, 1284, @"Masonry");
AddLabel(420, 123, 1284, @"Glass Blowing");
AddBackground(270, 113, 98, 31, 9200);
AddLabel(281, 119, 1284, @"Craft Tools");
AddButton(530, 339, 4018, 4019, 0, GumpButtonType.Reply, 0);
AddBackground(466, 339, 59, 21, 9200);
AddLabel(480, 340, 1284, @"EXIT");
AddImage(294, 156, 2096);
AddButton(98, 338, 4014, 4015, 0, GumpButtonType.Page, 1);
AddLabel(299, 213, 1284, @"Page 2");
}
public enum Buttons
{
imbue, //AddButton(514, 218, 2642, 2643, (int)Buttons.imbue, GumpButtonType.Reply, 0);//imbuing
alchemy, //AddButton(514, 183, 2642, 2643, (int)Buttons.alchemy, GumpButtonType.Reply, 0);//alchemy
cooking, //AddButton(514, 148, 2642, 2643, (int)Buttons.cooking, GumpButtonType.Reply, 0);//cooking
tailoring, //AddButton(514, 113, 2642, 2643, (int)Buttons.tailoring, GumpButtonType.Reply, 0);//tailoring
fletching, //AddButton(98, 218, 2642, 2643, (int)Buttons.fletching, GumpButtonType.Reply, 0);//fletching / bowcraft
woodworking, //AddButton(98, 183, 2642, 2643, (int)Buttons.woodworking, GumpButtonType.Reply, 0);//woodworking
tinkering, //AddButton(98, 148, 2642, 2643, (int)Buttons.tinkering, GumpButtonType.Reply, 0);//tinkering
blacksmithy, //AddButton(98, 113, 2642, 2643, (int)Buttons.blacksmithy, GumpButtonType.Reply, 0);//blacksmithy
mountcrafting, //AddButton(98, 252, 2642, 2643, (int)Buttons.mountcrafting, GumpButtonType.Reply, 0);//mountcrafting
firecraft, //AddButton(98, 287, 2642, 2643, (int)Buttons.firecraft, GumpButtonType.Reply, 0);//firecraft
powersew, //AddButton(514, 253, 2642, 2643, (int)Buttons.powersew, GumpButtonType.Reply, 0);//powersew
waxcraft, //AddButton(514, 287, 2642, 2643, (int)Buttons.waxcraft, GumpButtonType.Reply, 0);//waxcraft
exit, //AddButton(527, 298, 4018, 4019, (int)Buttons.exit, GumpButtonType.Reply, 0);//exit
}
public override void OnResponse(NetState sender, RelayInfo info)
{
Mobile from = sender.Mobile;
switch (info.ButtonID)
{
case (int)Buttons.exit:
{
// from.SendMessage("Check back for Updates!");
from.CloseGump(typeof(CraftTools));
break;
}
case (int)Buttons.imbue:
{
from.AddToBackpack(new RuneChiselHidden(1)); //add to backpack
BaseTool tool = from.Backpack.FindItemByType( typeof( RuneChiselHidden ), true ) as RuneChiselHidden;
if ( tool != null )
{
from.SendGump(new CraftGump(from, DefCrystalCrafting.CraftSystem, tool, null));
tool.Consume();//deletes item after imbue menu opens, player should not see tool at all!
}
break;
}
case (int)Buttons.alchemy:
{
from.AddToBackpack(new MortarPestleMulti(1)); //add to backpack
BaseTool tool = from.Backpack.FindItemByType( typeof( MortarPestleMulti ), true ) as MortarPestleMulti;
if ( tool != null )
{
from.SendGump(new CraftGump(from, DefAlchemy.CraftSystem, tool, null));
tool.Consume();
}
break;
}
case (int)Buttons.cooking:
{
from.AddToBackpack(new RollingPinMulti(1)); //add to backpack
BaseTool tool = from.Backpack.FindItemByType( typeof( RollingPinMulti ), true ) as RollingPinMulti;
if ( tool != null )
{
from.SendGump(new CraftGump(from, DefCooking.CraftSystem, tool, null));
tool.Consume();
}
break;
}
case (int)Buttons.tailoring:
{
from.AddToBackpack(new SewingKitMulti(1)); //add to backpack
BaseTool tool = from.Backpack.FindItemByType( typeof( SewingKitMulti ), true ) as SewingKitMulti;
if ( tool != null )
{
from.SendGump(new CraftGump(from, DefTailoring.CraftSystem, tool, null));
tool.Consume();
}
break;
}
case (int)Buttons.fletching:
{
from.AddToBackpack(new FletcherToolsMulti(1)); //add to backpack
BaseTool tool = from.Backpack.FindItemByType( typeof( FletcherToolsMulti ), true ) as FletcherToolsMulti;
if ( tool != null )
{
from.SendGump(new CraftGump(from, DefBowFletching.CraftSystem, tool, null));
tool.Consume();
}
break;
}
case (int)Buttons.woodworking:
{
from.AddToBackpack(new SawMulti(1)); //add to backpack
BaseTool tool = from.Backpack.FindItemByType( typeof( SawMulti ), true ) as SawMulti;
if ( tool != null )
{
from.SendGump(new CraftGump(from, DefCarpentry.CraftSystem, tool, null));
tool.Consume();
}
break;
}
case (int)Buttons.tinkering:
{
from.AddToBackpack(new TinkersToolsMulti(1)); //add to backpack
BaseTool tool = from.Backpack.FindItemByType( typeof( TinkersToolsMulti ), true ) as TinkersToolsMulti;
if ( tool != null )
{
from.SendGump(new CraftGump(from, DefTinkering.CraftSystem, tool, null));
tool.Consume();
}
break;
}
case (int)Buttons.blacksmithy:
{
from.AddToBackpack(new SmithHammerMulti(1)); //add to backpack
BaseTool tool = from.Backpack.FindItemByType( typeof( SmithHammerMulti ), true ) as SmithHammerMulti;
if ( tool != null )
{
from.SendGump(new CraftGump(from, DefBlacksmithy.CraftSystem, tool, null));
tool.Consume();
}
break;
}
case (int)Buttons.mountcrafting:
{
if (from.Race !=Race.Leprechaun )
{
if (from.AccessLevel >= AccessLevel.GameMaster)
{
from.SendMessage ( "Your access level bypasses Racial Restriction.");
from.AddToBackpack(new MountTinkerToolsMulti(1)); //add to backpack
BaseTool tool2 = from.Backpack.FindItemByType( typeof( MountTinkerToolsMulti ), true ) as MountTinkerToolsMulti;
if ( tool2 != null )
{
from.SendGump(new CraftGump(from, DefMountTinkering.CraftSystem, tool2, null));
tool2.Consume();
}
}
else
from.SendMessage ( "Only a Leprechaun will know how to create metal mounts!");
return;
}
from.AddToBackpack(new MountTinkerToolsMulti(1)); //add to backpack
BaseTool tool = from.Backpack.FindItemByType( typeof( MountTinkerToolsMulti ), true ) as MountTinkerToolsMulti;
if ( tool != null )
{
from.SendGump(new CraftGump(from, DefMountTinkering.CraftSystem, tool, null));
tool.Consume();
}
break;
}
case (int)Buttons.firecraft:
{
if (from.Race !=Race.Leprechaun )
{
if (from.AccessLevel >= AccessLevel.GameMaster)
{
from.SendMessage ( "Your access level bypasses Racial Restriction.");
from.AddToBackpack(new FireRockCraftToolMulti(1)); //add to backpack
BaseTool tool1 = from.Backpack.FindItemByType( typeof( FireRockCraftToolMulti ), true ) as FireRockCraftToolMulti;
if ( tool1 != null )
{
from.SendGump(new CraftGump(from, DefFireRockCraft.CraftSystem, tool1, null));
tool1.Consume();
}
}
else
from.SendMessage ( "Only a Leprechaun will know how to Forge Fire Rock!");
return;
}
from.AddToBackpack(new FireRockCraftToolMulti(1)); //add to backpack
BaseTool tool = from.Backpack.FindItemByType( typeof( FireRockCraftToolMulti ), true ) as FireRockCraftToolMulti;
if ( tool != null )
{
from.SendGump(new CraftGump(from, DefFireRockCraft.CraftSystem, tool, null));
tool.Consume();
}
break;
}
case (int)Buttons.powersew:
{
from.AddToBackpack(new SewingShearsMulti(1)); //add to backpack
BaseTool tool = from.Backpack.FindItemByType( typeof( SewingShearsMulti ), true ) as SewingShearsMulti;
if ( tool != null )
{
from.SendGump(new CraftGump(from, DefSewing.CraftSystem, tool, null));
tool.Consume();
}
break;
}
case (int)Buttons.waxcraft:
{
from.AddToBackpack(new WaxCraftingPotMulti(1)); //add to backpack
BaseTool tool = from.Backpack.FindItemByType( typeof( WaxCraftingPotMulti ), true ) as WaxCraftingPotMulti;
if ( tool != null )
{
from.SendGump(new CraftGump(from, DefWaxCrafting.CraftSystem, tool, null));
tool.Consume();
}
break;
}
}
}
}
}