public ChangeHairstyleGump(Mobile from, int price, bool facialHair, ChangeHairstyleEntry[] entries) : base(50, 50) { m_From = from; m_Price = price; m_FacialHair = facialHair; m_Entries = entries; int tableWidth = (m_FacialHair ? 2 : 3); int tableHeight = ((entries.Length + tableWidth - (m_FacialHair ? 1 : 2)) / tableWidth); const int offsetWidth = 123; int offsetHeight = (m_FacialHair ? 70 : 65); AddPage(0); AddBackground(0, 0, 81 + (tableWidth * offsetWidth), 105 + (tableHeight * offsetHeight), 2600); AddButton(45, 45 + (tableHeight * offsetHeight), 4005, 4007, 1, GumpButtonType.Reply, 0); AddHtmlLocalized(77, 45 + (tableHeight * offsetHeight), 90, 35, 1006044, false, false); // Ok AddButton(81 + (tableWidth * offsetWidth) - 180, 45 + (tableHeight * offsetHeight), 4005, 4007, 0, GumpButtonType.Reply, 0); AddHtmlLocalized(81 + (tableWidth * offsetWidth) - 148, 45 + (tableHeight * offsetHeight), 90, 35, 1006045, false, false); // Cancel if (!facialHair) AddHtmlLocalized(50, 15, 350, 20, 1018353, false, false); // <center>New Hairstyle</center> else AddHtmlLocalized(55, 15, 200, 20, 1018354, false, false); // <center>New Beard</center> for (int i = 0; i < entries.Length; ++i) { int xTable = i % tableWidth; int yTable = i / tableWidth; if (entries[i].GumpID != 0) { AddRadio(40 + (xTable * offsetWidth), 70 + (yTable * offsetHeight), 208, 209, false, i); AddBackground(87 + (xTable * offsetWidth), 50 + (yTable * offsetHeight), 50, 50, 2620); AddImage(87 + (xTable * offsetWidth) + entries[i].X, 50 + (yTable * offsetHeight) + entries[i].Y, entries[i].GumpID); } else if (!facialHair) { AddRadio(40 + ((xTable + 1) * offsetWidth), 240, 208, 209, false, i); AddHtmlLocalized(60 + ((xTable + 1) * offsetWidth), 240, 85, 35, 1011064, false, false); // Bald } else { AddRadio(40 + (xTable * offsetWidth), 70 + (yTable * offsetHeight), 208, 209, false, i); AddHtmlLocalized(60 + (xTable * offsetWidth), 70 + (yTable * offsetHeight), 85, 35, 1011064, false, false); // Bald } } }
public override void OnResponse(NetState sender, RelayInfo info) { if (!m_FacialHair || !m_Female) { if (info.ButtonID == 1) { int[] switches = info.Switches; if (switches.Length > 0) { int index = switches[0]; bool female = m_Female; if (index >= 0 && index < m_Entries.Length) { ChangeHairstyleEntry entry = m_Entries[index]; if (m_From is PlayerMobile) { ((PlayerMobile)m_From).SetHairMods(-1, -1); } int hairID = m_From.HairItemID; int facialHairID = m_From.FacialHairItemID; int itemID = female ? entry.ItemID_Female : entry.ItemID_Male; if (itemID == 0) { bool invalid = m_FacialHair ? (facialHairID == 0) : (hairID == 0); if (!invalid) { if (m_Token != null) { m_Token.OnChangeHairstyle(m_From, m_FacialHair, 0); return; } if (Banker.Withdraw(m_From, m_Price, true)) { if (m_FacialHair) { m_From.FacialHairItemID = 0; } else { m_From.HairItemID = 0; } } else { if (m_Vendor != null) { m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1042293, m_From.NetState); // You cannot afford my services for that style. } else { m_From.SendLocalizedMessage(1042293); } } } } else { bool invalid = m_FacialHair ? facialHairID > 0 && facialHairID == itemID : hairID > 0 && hairID == itemID; if (!invalid) { if (m_Price <= 0 || Banker.Withdraw(m_From, m_Price)) { if (m_Token != null) { m_Token.OnChangeHairstyle(m_From, m_FacialHair, itemID); return; } if (m_FacialHair) { var old = m_From.FacialHairItemID; m_From.FacialHairItemID = itemID; if (itemID != 0 && old == 0) { m_From.FacialHairHue = m_From.HairHue; } } else { m_From.HairItemID = itemID; } } else { if (m_Vendor != null) { m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1042293, m_From.NetState); // You cannot afford my services for that style. } else { m_From.SendLocalizedMessage(1042293); } } } } } } else { if (m_Vendor != null) { // You decide not to change your hairstyle. m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1013009, m_From.NetState); } else { m_From.SendLocalizedMessage(1013009); // You decide not to change your hairstyle. } } } else { if (m_Vendor != null) { // You decide not to change your hairstyle. m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1013009, m_From.NetState); } else { m_From.SendLocalizedMessage(1013009); // You decide not to change your hairstyle. } } } if (m_Token != null) { m_Token.OnFailedHairstyle(m_From, m_FacialHair); } }
public override void OnResponse(NetState sender, RelayInfo info) { if (m_FacialHair && (m_From.Female || m_From.Body.IsFemale)) { return; } if (m_From.Race == Race.Elf) { m_From.SendMessage("This isn't implemented for elves yet. Sorry!"); return; } if (info.ButtonID == 1) { int[] switches = info.Switches; if (switches.Length > 0) { int index = switches[0]; if (index >= 0 && index < m_Entries.Length) { ChangeHairstyleEntry entry = m_Entries[index]; if (m_From is PlayerMobile) { ((PlayerMobile)m_From).SetHairMods(-1, -1); } int hairID = m_From.HairItemID; int facialHairID = m_From.FacialHairItemID; if (entry.ItemID == 0) { if (m_FacialHair ? (facialHairID == 0) : (hairID == 0)) { return; } if (Banker.Withdraw(m_From, m_Price)) { if (m_FacialHair) { m_From.FacialHairItemID = 0; } else { m_From.HairItemID = 0; } } else { m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1042293, m_From.NetState); // You cannot afford my services for that style. } } else { if (m_FacialHair) { if (facialHairID > 0 && facialHairID == entry.ItemID) { return; } } else { if (hairID > 0 && hairID == entry.ItemID) { return; } } if (Banker.Withdraw(m_From, m_Price)) { if (m_FacialHair) { m_From.FacialHairItemID = entry.ItemID; } else { m_From.HairItemID = entry.ItemID; } } else { m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1042293, m_From.NetState); // You cannot afford my services for that style. } } } } else { // You decide not to change your hairstyle. m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1013009, m_From.NetState); } } else { // You decide not to change your hairstyle. m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1013009, m_From.NetState); } }
public override void OnResponse(NetState sender, RelayInfo info) { if (m_Layer == Layer.FacialHair && (m_From.Female || m_From.Body.IsFemale)) { return; } if (info.ButtonID == 1) { int[] switches = info.Switches; if (switches.Length > 0) { int index = switches[0]; if (index >= 0 && index < m_Entries.Length) { ChangeHairstyleEntry entry = m_Entries[index]; if (m_From is PlayerMobile) { ((PlayerMobile)m_From).SetHairMods(-1, -1); } Item hair = m_From.FindItemOnLayer(m_Layer); if (entry.ItemType == null) { if (hair == null) { return; } if (Banker.Withdraw(m_From, m_Price)) { hair.Delete(); } else { m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1042293, m_From.NetState); // You cannot afford my services for that style. } } else { if (hair != null && hair.GetType() == entry.ItemType) { return; } Item newHair = null; try { newHair = Activator.CreateInstance(entry.ItemType, null) as Item; } catch (Exception ex) { EventSink.InvokeLogException(new LogExceptionEventArgs(ex)); } if (newHair == null) { return; } if (Banker.Withdraw(m_From, m_Price)) { if (hair != null) { newHair.Hue = hair.Hue; hair.Delete(); } m_From.AddItem(newHair); } else { newHair.Delete(); m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1042293, m_From.NetState); // You cannot afford my services for that style. } } } } else { // You decide not to change your hairstyle. m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1013009, m_From.NetState); } } else { // You decide not to change your hairstyle. m_Vendor.PrivateOverheadMessage(MessageType.Regular, 0x3B2, 1013009, m_From.NetState); } }
public ChangeHairstyleGump( Mobile from, Mobile vendor, int price, Layer layer, ChangeHairstyleEntry[] entries ) : base(50, 50) { m_From = from; m_Vendor = vendor; m_Price = price; m_Layer = layer; m_Entries = entries; from.CloseGump( typeof( HairstylistBuyGump ) ); from.CloseGump( typeof( ChangeHairHueGump ) ); from.CloseGump( typeof( ChangeHairstyleGump ) ); int tableWidth = ( layer == Layer.Hair ? 3 : 2 ); int tableHeight = ( (entries.Length + tableWidth - ( layer == Layer.Hair ? 2 : 1 )) / tableWidth ); int offsetWidth = 123; int offsetHeight = ( layer == Layer.Hair ? 65 : 70 ); AddPage( 0 ); AddBackground( 0, 0, 81 + (tableWidth * offsetWidth), 105 + (tableHeight * offsetHeight), 2600 ); AddButton( 45, 45 + (tableHeight * offsetHeight), 4005, 4007, 1, GumpButtonType.Reply, 0 ); AddHtmlLocalized( 77, 45 + (tableHeight * offsetHeight), 90, 35, 1006044, false, false ); // Ok AddButton( 81 + (tableWidth * offsetWidth) - 180, 45 + (tableHeight * offsetHeight), 4005, 4007, 0, GumpButtonType.Reply, 0 ); AddHtmlLocalized( 81 + (tableWidth * offsetWidth) - 148, 45 + (tableHeight * offsetHeight), 90, 35, 1006045, false, false ); // Cancel if ( layer == Layer.Hair ) AddHtmlLocalized( 50, 15, 350, 20, 1018353, false, false ); // <center>New Hairstyle</center> else AddHtmlLocalized( 55, 15, 200, 20, 1018354, false, false ); // <center>New Beard</center> for ( int i = 0; i < entries.Length; ++i ) { int xTable = i % tableWidth; int yTable = i / tableWidth; if ( entries[i].GumpID != 0 ) { AddRadio( 40 + (xTable * offsetWidth), 70 + (yTable * offsetHeight), 208, 209, false, i ); AddBackground( 87 + (xTable * offsetWidth), 50 + (yTable * offsetHeight), 50, 50, 2620 ); AddImage( 87 + (xTable * offsetWidth) + entries[i].X, 50 + (yTable * offsetHeight) + entries[i].Y, entries[i].GumpID ); } else if ( layer == Layer.Hair ) { AddRadio( 40 + ((xTable + 1) * offsetWidth), 240, 208, 209, false, i ); AddHtmlLocalized( 60 + ((xTable + 1) * offsetWidth), 240, 85, 35, 1011064, false, false ); // Bald } else { AddRadio( 40 + (xTable * offsetWidth), 70 + (yTable * offsetHeight), 208, 209, false, i ); AddHtmlLocalized( 60 + (xTable * offsetWidth), 70 + (yTable * offsetHeight), 85, 35, 1011064, false, false ); // Bald } } }
public ChangeHairstyleGump( Mobile from, Mobile vendor, int price, bool facialHair, ChangeHairstyleEntry[] entries ) : base(50, 50) { /* Gump structure is not totally OSI accurate. Anyway it looks fine! :) */ m_From = from; m_Vendor = vendor; m_Price = price; m_FacialHair = facialHair; m_Entries = entries; from.CloseGump( typeof( HairstylistBuyGump ) ); from.CloseGump( typeof( ChangeHairHueGump ) ); from.CloseGump( typeof( ChangeHairstyleGump ) ); int tableWidth = ( m_FacialHair ? 2 : 3 ); int tableHeight = ( ( entries.Length + tableWidth - ( m_FacialHair ? 1 : 2 ) ) / tableWidth ); int offsetWidth = 123; int offsetHeight = ( m_FacialHair ? 70 : 65 ); AddPage( 0 ); AddBackground( 0, 0, 81 + ( tableWidth * offsetWidth ), 105 + ( tableHeight * offsetHeight ), 2600 ); AddButton( 45, 45 + ( tableHeight * offsetHeight ), 4005, 4007, 1, GumpButtonType.Reply, 0 ); AddHtmlLocalized( 77, 45 + ( tableHeight * offsetHeight ), 90, 35, 1006044, false, false ); // Ok AddButton( 81 + ( tableWidth * offsetWidth ) - 120, 45 + ( tableHeight * offsetHeight ), 4005, 4007, 0, GumpButtonType.Reply, 0 ); AddHtmlLocalized( 81 + ( tableWidth * offsetWidth ) - 88, 45 + ( tableHeight * offsetHeight ), 90, 35, 1006045, false, false ); // Cancel if ( !facialHair ) AddHtmlLocalized( 50, 15, 350, 20, 1018353, false, false ); // <center>New Hairstyle</center> else AddHtmlLocalized( 55, 15, 200, 20, 1018354, false, false ); // <center>New Beard</center> for ( int i = 0; i < entries.Length; ++i ) { int xTable = i % tableWidth; int yTable = i / tableWidth; if ( entries[i].GumpID != 0 ) { AddRadio( 40 + ( xTable * offsetWidth ), 70 + ( yTable * offsetHeight ), 208, 209, false, i ); AddBackground( 87 + ( xTable * offsetWidth ), 50 + ( yTable * offsetHeight ), 50, 50, 2620 ); AddImage( 87 + ( xTable * offsetWidth ) + entries[i].X, 50 + ( yTable * offsetHeight ) + entries[i].Y, entries[i].GumpID ); } else { int number = facialHair ? 1075521 // Clean Shaven : 1078149; // Bald (You will lose your hair color.) if ( xTable == 0 ) { AddRadio( 40 + offsetWidth, 240, 208, 209, false, i ); AddHtmlLocalized( 60 + offsetWidth, 240, 120, 35, number, false, false ); } else { AddRadio( 40 + ( xTable * offsetWidth ), 70 + ( yTable * offsetHeight ), 208, 209, false, i ); AddHtmlLocalized( 60 + ( xTable * offsetWidth ), 70 + ( yTable * offsetHeight ), 120, 35, number, false, false ); } } } }