Go Back   RunUO - Ultima Online Emulation > RunUO > Script Support

Script Support Get support for modifying RunUO Scripts, or writing your own!

Reply
 
Thread Tools Display Modes
Old 08-31-2007, 09:55 PM   #1 (permalink)
Newbie
 
Join Date: Jan 2004
Age: 21
Posts: 34
Default Revamp Hue deed problem

Here is the problem as you can rememer I made a skinhue deed awhile back the problem is now, I want to add support for custom hues.. I created the gump where you can enter the number to a hue but my problem is I dont know how to get the text field to link with the hue that was entered. I made a lil note where the button/ textfield is below, its the full script.. I tried many times with diffrent ideas and just wont work. Atleast give me some suggestions, the others have failed.


Code:
//This script was created by Robert Cadle aka Antiodontalgic 
//Edit how you wish, just keep the credit of the script to me.
using System;
using System.Text;
using Server.Gumps;
using Server.Network;

namespace Server.Items
{
	public class SkinHue : Item
	{
		[Constructable]
		public SkinHue() : base( 5360 )
		{
			Weight = 1.0;
            Name = "Skin Hue Deed";
            Hue = 1327;
		}

        public SkinHue(Serial serial): base(serial)
		{
		}
		
		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 0 ); 
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();
		}

		public override void OnDoubleClick( Mobile from )
		{
			if ( from.InRange( this.GetWorldLocation(), 1 ) )
			{
				from.CloseGump( typeof( SkinHueGump ) );
				from.SendGump( new SkinHueGump( this ) );
			}
			else
			{
				from.LocalOverheadMessage( MessageType.Regular, 906, 1019045 ); 
			}	
		}
	}

	public class SkinHueGump : Gump
	{
		private SkinHue m_SkinHue;

		private class SkinHueEntry
		{
			private string m_Name;
			private int m_HueStart;
			private int m_HueCount;

			public string Name
			{
				get
				{
					return m_Name;
				}
			}

			public int HueStart
			{
				get
				{
					return m_HueStart;
				}
			}

			public int HueCount
			{
				get
				{
					return m_HueCount;
				}
			}

			public SkinHueEntry( string name, int hueStart, int hueCount )
			{
				m_Name = name;
				m_HueStart = hueStart;
				m_HueCount = hueCount;
			}
		}

		private static SkinHueEntry[] m_Entries = new SkinHueEntry[]
			{
                //The first number is the starting hue, The second is how
                //many hues after the starting hue will show up on the page.
				new SkinHueEntry( "*****", 1602, 26 ),
				new SkinHueEntry( "*****", 1628, 27 ),
				new SkinHueEntry( "*****", 1502, 32 ),
				new SkinHueEntry( "*****", 1302, 32 ),
				new SkinHueEntry( "*****", 1402, 32 ),
				new SkinHueEntry( "*****", 1202, 24 ),
				new SkinHueEntry( "*****", 2402, 29 ),
				new SkinHueEntry( "*****", 2213, 6 ),
				new SkinHueEntry( "*****", 1102, 8 ),
				new SkinHueEntry( "*****", 1110, 8 ),
				new SkinHueEntry( "*****", 1118, 16 ),
				new SkinHueEntry( "*****", 1134, 16 )
			};


		public void AddTextField( int x, int y, int width, int height, int index )
		{
			AddBackground( x - 2, y - 2, width + 4, height + 4, 0x2486 );
			AddTextEntry( x + 2, y + 2, width - 4, height - 4, 0, index, "" );
		}


		public SkinHueGump( SkinHue dye ) : base( 50, 50 )
		{
			m_SkinHue = dye;

			AddPage( 0 );

			AddBackground( 100, 10, 350, 355, 2600 );
			AddBackground( 120, 54, 110, 270, 5100 );

			
           		AddLabel(160, -5, 33, @"Skin Hue System By: Antiodontalgic");
           		AddLabel(150, 25, 400, @"Enter Hue Number:"); 
            		AddTextField( 280, 25, 50, 20, 1 ); //This is where the button is just cant get it to work.. It can be linked to the same button as buttom as it is now all I care. I just want the number entered to hue the skin if they dont make a seletion.
			AddButton( 340, 25, 4011, 4013, 1, GumpButtonType.Reply, 0 ); 



			AddButton( 149, 328, 4005, 4007, 1 , GumpButtonType.Reply, 0 );
            		AddLabel(185, 329, 250, @"Hue my skin this color!");

			for ( int i = 0; i < m_Entries.Length; ++i )
			{
				AddLabel( 130, 59 + (i * 22), m_Entries[i].HueStart - 1, m_Entries[i].Name );
				AddButton( 207, 60 + (i * 22), 5224, 5224, 0, GumpButtonType.Page, i + 1 );
			}

			for ( int i = 0; i < m_Entries.Length; ++i )
			{
				SkinHueEntry e = m_Entries[i];

				AddPage( i + 1 );

				for ( int j = 0; j < e.HueCount; ++j )
				{
					AddLabel( 278 + ((j / 16) * 80), 52 + ((j % 16) * 17), e.HueStart + j - 1, "*****" );
					AddRadio( 260 + ((j / 16) * 80), 52 + ((j % 16) * 17), 210, 211, false, (i * 100) + j );
				}
			}
		}

		public override void OnResponse( NetState from, RelayInfo info )
		{


		if ( m_SkinHue.Deleted )
				return;

			Mobile m = from.Mobile;
			int[] switches = info.Switches;

			if ( !m_SkinHue.IsChildOf( m.Backpack ) ) 
			{
				m.SendLocalizedMessage( 1042010 );
				return;
			}

			if ( info.ButtonID != 0 && switches.Length > 0 )
			{
				Item backpack = m.Backpack;

				if ( backpack == null )
				{
					m.SendMessage( "You must have a backpack to use this!" );
}
				else
				{

					int entryIndex = switches[0] / 100;
					int hueOffset = switches[0] % 100;

					if ( entryIndex >= 0 && entryIndex < m_Entries.Length )
					{
						SkinHueEntry e = m_Entries[entryIndex];

						if ( hueOffset >= 0 && hueOffset < e.HueCount )
						{
							int hue = e.HueStart + hueOffset;

                            				m.Hue = hue;
							m.SendMessage( "You hue your skin!" );
							m_SkinHue.Delete();
							m.PlaySound( 0x4E );
						}
					}
				}
			}
			else
			{
                m.SendMessage("You decide not to hue your skin");
			}
            }
        }
    }
__________________
Ownage? Oh, Please t'is but a scratch.
cadle is offline   Reply With Quote
Old 09-03-2007, 01:17 AM   #2 (permalink)
Forum Expert
 
Join Date: Sep 2004
Location: Florida
Age: 25
Posts: 457
Send a message via AIM to remnant
Default

You would handle that in your OnResponse method.
remnant is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5