KR Gump stuff

Diskussion und Informationen über UO:KR
Nachricht
Autor
pmouse

KR Gump stuff

#1 Beitrag von pmouse » 06 Jul 2007 04:52

Hey Guys,
From my understanding all KR Gump is done locally on the client side via lua scripts. This really prevents the server from creating any new customized contents :(
But my question is, I cannot seem to figure out how KR knows which interface script to use. I know that it seems to be mapping the gump type id with the scripts, but where exactly does the client side define all the IDs? Is there a list of ID we can use to implement the necessary functions for normal game play?

Thanks!

pmouse

#2 Beitrag von pmouse » 06 Jul 2007 05:11

nvm...I answered my own question

take a look at GGManager.Lua (in interface.uop, Block 6 #77)
everything is there :D

pmouse

#3 Beitrag von pmouse » 06 Jul 2007 05:45

Here's the suggest fix for RunUO to support the basic gumps :

1. In Gump.cs, add:

Code: Alles auswählen

private static Dictionary<Type> _typeIdTable = new Dictionary<Type>();

public static void RegisterType(Type t, int id)
{
    if (!_typeIdTable.ContainsKey(t))
        _typeIdTable.Add(t, id);
    else
        _typeIdTable[t] = id;
}
and them modify the GetGumpID function to:

Code: Alles auswählen

public static int GetTypeID( Type type )
{
        if (_typeIdTable.ContainsKey(type))
            return _typeIdTable[type];
        else
        {
            int hash = type.FullName.GetHashCode();
            _typeIdTable.Add(type, hash);
            return hash;
        }
}
then finally, for each of the gump you want to support, add its gump id at Initialize(). For example, to support the resurrect gump, add:

Code: Alles auswählen

public static void Initialize()
{
    RegisterType(typeof(ResurrectGump), 2223);
}
in RessurectGump.cs

Of course, you also must read the interface scripts for string table and button id matching. Most of the time it just works.
Zuletzt geändert von pmouse am 06 Jul 2007 19:41, insgesamt 5-mal geändert.

Solar

#4 Beitrag von Solar » 06 Jul 2007 10:01

If anyone has some gumps fixed, please, upload them somewhere to download. Thank you!

Rimmon

#5 Beitrag von Rimmon » 06 Jul 2007 12:03

unpacked_b6_77.raw seems not to be a lua script... how can i view it?

Rimmon

#6 Beitrag von Rimmon » 06 Jul 2007 16:11

sorry :)
UO KR beta client 2.45.1.5 has open lua scripts in comparison with 2.45.4.4 client version

Theoderic

#7 Beitrag von Theoderic » 06 Jul 2007 18:54

Hmm its not worked :/

Rimmon

#8 Beitrag von Rimmon » 06 Jul 2007 19:01

it worked for the simpliest gumps such as resurrection confirmation gump, but i don't know for example how to fill the runebook gump, or crafting skills gumps

more gump packet info needed...

pmouse

#9 Beitrag von pmouse » 06 Jul 2007 19:10

Rimmon: I unpacked the oldest KR client, that's the only one I have.
For each update they might change the uop contents, so you can do a text search when you unpack it.

Here's what can be directly supported:
all "Two Button Gumps" and "One Button Gumps" such as confirmations (res, moongate, pet release...)

public moongate gump can be seen, but the text are somewhat screwed up

Here's what cannot be directly supported:
all complex gumps such as runebook, craft system, House Menu Window, etc...

To support these someone must read the lua script for each of them and figure out their string table order :( Of course RunUO doesn't allow you to specify string indices, this has to be modified as well...

Finally, adding server side gumps seems not longer possible. You must also have client side support...damn :(

Jeremy

#10 Beitrag von Jeremy » 06 Jul 2007 19:24

private static Dictionary<Type,int _typeIdTable = new Dictionary<Type,int ();

pmouse

#11 Beitrag von pmouse » 06 Jul 2007 19:36

Aye, thanks for the correction.

I didn't notice the ,int got ripped by the forum :P

for some reason i cannot type it

Link_of_Hyrule

#12 Beitrag von Link_of_Hyrule » 06 Jul 2007 20:11

So we can maybe allow players to do anything on runuo that they can do on osi but we will have to admin from 2d unless we can modify the files in someway is what im understanding from this?

nazghul

#13 Beitrag von nazghul » 06 Jul 2007 21:40

If your players are limited to defauzlt OSI gumps, items, anims etc - yes.

I just ran a quick check for "[DIALOG" (Sphere) on my server - 363 hits, meaning 121 custom gump dialogs -> KR is no option at all.

pmouse

#14 Beitrag von pmouse » 06 Jul 2007 22:37

In order to implement custom gumps, you much patch interface.uop

(and possibilty stringtable, for file name matching)

If you can implement all default OSI gumps, this should give minimal playable experience, which is good enough for KR adapters - if you choose fancy interface, the price to pay is less functionality (same thing happened on OSI, lots of menus/dialogs are not implemented yet).

Link_of_Hyrule

#15 Beitrag von Link_of_Hyrule » 07 Jul 2007 07:10

can you post the modified files rather then just code snipets? it would help a lot thanks :D

I tried to modify it and it tells me i need 2 > but im sure its because im putting it in the wrong area or something thanks

Syntax error, '>' expected (CS1003) - Gump.cs:48,77
Syntax error, '>' expected (CS1003) - Gump.cs:48,38

Code: Alles auswählen

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using Server;
using Server.Network;

namespace Server.Gumps
{
	public class Gump
	{
		private List<GumpEntry> m_Entries;
		private List<string> m_Strings;

		internal int m_TextEntries, m_Switches;

		private static int m_NextSerial = 1;

		private int m_Serial;
		private int m_TypeID;
		private int m_X, m_Y;

		private bool m_Dragable = true;
		private bool m_Closable = true;
		private bool m_Resizable = true;
		private bool m_Disposable = true;

		private static Dictionary<Type,int _typeIdTable = new Dictionary<Type,int (); 
		
		public static void RegisterType(Type t, int id) 
		{ 
 		   if (!_typeIdTable.ContainsKey(t)) 
        		_typeIdTable.Add(t, id); 
    		else 
   		     _typeIdTable[t] = id; 
		}
		
		public static int GetTypeID( Type type ) 
		{ 
    		    if (_typeIdTable.ContainsKey(type)) 
   		         return _typeIdTable[type]; 
        		else 
		        { 
		            int hash = type.FullName.GetHashCode(); 
	            _typeIdTable.Add(type, hash); 
	            return hash; 
     		  } 
		}
		
		public Gump( int x, int y )
		{
			do
			{
				m_Serial = m_NextSerial++;
			} while ( m_Serial == 0 ); // standard client apparently doesn't send a gump response packet if serial == 0

			m_X = x;
			m_Y = y;

			m_TypeID = GetTypeID( this.GetType() );

			m_Entries = new List<GumpEntry>();
			m_Strings = new List<string>();
		}

		public void Invalidate()
		{
			//if ( m_Strings.Count > 0 )
			//	m_Strings.Clear();
		}

		public int TypeID
		{
			get
			{
				return m_TypeID;
			}
		}

		public List<GumpEntry> Entries
		{
			get{ return m_Entries; }
		}

		public int Serial
		{
			get
			{
				return m_Serial;
			}
			set
			{
				if ( m_Serial != value )
				{
					m_Serial = value;
					Invalidate();
				}
			}
		}

		public int X
		{
			get
			{
				return m_X;
			}
			set
			{
				if ( m_X != value )
				{
					m_X = value;
					Invalidate();
				}
			}
		}

		public int Y
		{
			get
			{
				return m_Y;
			}
			set
			{
				if ( m_Y != value )
				{
					m_Y = value;
					Invalidate();
				}
			}
		}

		public bool Disposable
		{
			get
			{
				return m_Disposable;
			}
			set
			{
				if ( m_Disposable != value )
				{
					m_Disposable = value;
					Invalidate();
				}
			}
		}

		public bool Resizable
		{
			get
			{
				return m_Resizable;
			}
			set
			{
				if ( m_Resizable != value )
				{
					m_Resizable = value;
					Invalidate();
				}
			}
		}

		public bool Dragable
		{
			get
			{
				return m_Dragable;
			}
			set
			{
				if ( m_Dragable != value )
				{
					m_Dragable = value;
					Invalidate();
				}
			}
		}

		public bool Closable
		{
			get
			{
				return m_Closable;
			}
			set
			{
				if ( m_Closable != value )
				{
					m_Closable = value;
					Invalidate();
				}
			}
		}

		public void AddPage( int page )
		{
			Add( new GumpPage( page ) );
		}

		public void AddAlphaRegion( int x, int y, int width, int height )
		{
			Add( new GumpAlphaRegion( x, y, width, height ) );
		}

		public void AddBackground( int x, int y, int width, int height, int gumpID )
		{
			Add( new GumpBackground( x, y, width, height, gumpID ) );
		}

		public void AddButton( int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, int param )
		{
			Add( new GumpButton( x, y, normalID, pressedID, buttonID, type, param ) );
		}

		public void AddCheck( int x, int y, int inactiveID, int activeID, bool initialState, int switchID )
		{
			Add( new GumpCheck( x, y, inactiveID, activeID, initialState, switchID ) );
		}

		public void AddGroup( int group )
		{
			Add( new GumpGroup( group ) );
		}

		public void AddTooltip( int number )
		{
			Add( new GumpTooltip( number ) );
		}

		public void AddHtml( int x, int y, int width, int height, string text, bool background, bool scrollbar )
		{
			Add( new GumpHtml( x, y, width, height, text, background, scrollbar ) );
		}

		public void AddHtmlLocalized( int x, int y, int width, int height, int number, bool background, bool scrollbar )
		{
			Add( new GumpHtmlLocalized( x, y, width, height, number, background, scrollbar ) );
		}

		public void AddHtmlLocalized( int x, int y, int width, int height, int number, int color, bool background, bool scrollbar )
		{
			Add( new GumpHtmlLocalized( x, y, width, height, number, color, background, scrollbar ) );
		}

		public void AddHtmlLocalized( int x, int y, int width, int height, int number, string args, int color, bool background, bool scrollbar )
		{
			Add( new GumpHtmlLocalized( x, y, width, height, number, args, color, background, scrollbar ) );
		}

		public void AddImage( int x, int y, int gumpID )
		{
			Add( new GumpImage( x, y, gumpID ) );
		}

		public void AddImage( int x, int y, int gumpID, int hue )
		{
			Add( new GumpImage( x, y, gumpID, hue ) );
		}

		public void AddImageTiled( int x, int y, int width, int height, int gumpID )
		{
			Add( new GumpImageTiled( x, y, width, height, gumpID ) );
		}

		public void AddImageTiledButton( int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, int param, int itemID, int hue, int width, int height )
		{
			Add( new GumpImageTileButton( x, y, normalID, pressedID, buttonID, type, param, itemID, hue, width, height ) );
		}
		public void AddImageTiledButton( int x, int y, int normalID, int pressedID, int buttonID, GumpButtonType type, int param, int itemID, int hue, int width, int height, int localizedTooltip )
		{
			Add( new GumpImageTileButton( x, y, normalID, pressedID, buttonID, type, param, itemID, hue, width, height, localizedTooltip ) );
		}

		public void AddItem( int x, int y, int itemID )
		{
			Add( new GumpItem( x, y, itemID ) );
		}

		public void AddItem( int x, int y, int itemID, int hue )
		{
			Add( new GumpItem( x, y, itemID, hue ) );
		}

		public void AddLabel( int x, int y, int hue, string text )
		{
			Add( new GumpLabel( x, y, hue, text ) );
		}

		public void AddLabelCropped( int x, int y, int width, int height, int hue, string text )
		{
			Add( new GumpLabelCropped( x, y, width, height, hue, text ) );
		}

		public void AddRadio( int x, int y, int inactiveID, int activeID, bool initialState, int switchID )
		{
			Add( new GumpRadio( x, y, inactiveID, activeID, initialState, switchID ) );
		}

		public void AddTextEntry( int x, int y, int width, int height, int hue, int entryID, string initialText )
		{
			Add( new GumpTextEntry( x, y, width, height, hue, entryID, initialText ) );
		}

		public void AddTextEntry( int x, int y, int width, int height, int hue, int entryID, string initialText, int size ) {
			Add( new GumpTextEntryLimited( x, y, width, height, hue, entryID, initialText, size ) );
		}

		public void Add( GumpEntry g )
		{
			if ( g.Parent != this )
			{
				g.Parent = this;
			}
			else if ( !m_Entries.Contains( g ) )
			{
				Invalidate();
				m_Entries.Add( g );
			}
		}

		public void Remove( GumpEntry g )
		{
			Invalidate();
			m_Entries.Remove( g );
			g.Parent = null;
		}

		public int Intern( string value )
		{
			int indexOf = m_Strings.IndexOf( value );

			if ( indexOf >= 0 )
			{
				return indexOf;
			}
			else
			{
				Invalidate();
				m_Strings.Add( value );
				return m_Strings.Count - 1;
			}
		}

		public void SendTo( NetState state )
		{
			state.AddGump( this );
			state.Send( Compile( state ) );
		}

		public static byte[] StringToBuffer( string str )
		{
			return Encoding.ASCII.GetBytes( str );
		}

		private static byte[] m_BeginLayout = StringToBuffer( "{ " );
		private static byte[] m_EndLayout = StringToBuffer( " }" );

		private static byte[] m_NoMove = StringToBuffer( "{ nomove }" );
		private static byte[] m_NoClose = StringToBuffer( "{ noclose }" );
		private static byte[] m_NoDispose = StringToBuffer( "{ nodispose }" );
		private static byte[] m_NoResize = StringToBuffer( "{ noresize }" );

		public static readonly ClientVersion UnpackVersion = new ClientVersion( "5.0.0a" );

		private Packet Compile()
		{
			return Compile( null );
		}

		private Packet Compile( NetState ns )
		{
			IGumpWriter disp;

			if ( ns != null && ns.Version != null && ns.Version >= UnpackVersion )
				disp = new DisplayGumpPacked( this );
			else
				disp = new DisplayGumpFast( this );

			if ( !m_Dragable )
				disp.AppendLayout( m_NoMove );

			if ( !m_Closable )
				disp.AppendLayout( m_NoClose );

			if ( !m_Disposable )
				disp.AppendLayout( m_NoDispose );

			if ( !m_Resizable )
				disp.AppendLayout( m_NoResize );

			int count = m_Entries.Count;
			GumpEntry e;

			for ( int i = 0; i < count; ++i )
			{
				e = m_Entries[i];

				disp.AppendLayout( m_BeginLayout );
				e.AppendTo( disp );
				disp.AppendLayout( m_EndLayout );
			}

			disp.WriteStrings( m_Strings );

			disp.Flush();

			m_TextEntries = disp.TextEntries;
			m_Switches = disp.Switches;

			return disp as Packet;
		}

		public virtual void OnResponse( NetState sender, RelayInfo info )
		{
		}

		public virtual void OnServerClose( NetState owner ) {
		}
	}
}

Antworten