horadryn
Apprentice
Posts: 8
Likes Given: 2
Likes Received: 0 in 0 posts
Joined: Nov 2012
Reputation: 0
|
RE: [UPDATED]Paperdoll & Web
Can someone translate this?
Code:
using System;
using System.Collections;
namespace Server.Engines.MyRunUO
{
public class LayerComparer : IComparer
{
private static Layer PlateArms = (Layer)255;
private static Layer ChainTunic = (Layer)254;
private static Layer LeatherShorts = (Layer)253;
private static Layer[] m_DesiredLayerOrder = new Layer[]
{
Layer.Cloak,
Layer.Bracelet,
Layer.Ring,
Layer.Shirt,
Layer.Pants,
Layer.InnerLegs,
Layer.Shoes,
LeatherShorts,
Layer.Arms,
Layer.InnerTorso,
LeatherShorts,
PlateArms,
Layer.MiddleTorso,
Layer.OuterLegs,
Layer.Neck,
Layer.Waist,
Layer.Gloves,
Layer.OuterTorso,
Layer.OneHanded,
Layer.TwoHanded,
Layer.FacialHair,
Layer.Hair,
Layer.Helm,
Layer.Talisman
};
private static int[] m_TranslationTable;
public static int[] TranslationTable
{
get{ return m_TranslationTable; }
}
static LayerComparer()
{
m_TranslationTable = new int[256];
for ( int i = 0; i < m_DesiredLayerOrder.Length; ++i )
m_TranslationTable[(int)m_DesiredLayerOrder[i]] = m_DesiredLayerOrder.Length - i;
}
public static bool IsValid( Item item )
{
return ( m_TranslationTable[(int)item.Layer] > 0 );
}
public static readonly IComparer Instance = new LayerComparer();
public LayerComparer()
{
}
public Layer Fix( int itemID, Layer oldLayer )
{
if ( itemID == 0x1410 || itemID == 0x1417 ) // platemail arms
return PlateArms;
if ( itemID == 0x13BF || itemID == 0x13C4 ) // chainmail tunic
return ChainTunic;
if ( itemID == 0x1C08 || itemID == 0x1C09 ) // leather skirt
return LeatherShorts;
if ( itemID == 0x1C00 || itemID == 0x1C01 ) // leather shorts
return LeatherShorts;
return oldLayer;
}
public int Compare( object x, object y )
{
Item a = (Item)x;
Item b = (Item)y;
Layer aLayer = a.Layer;
Layer bLayer = b.Layer;
aLayer = Fix( a.ItemID, aLayer );
bLayer = Fix( b.ItemID, bLayer );
return m_TranslationTable[(int)bLayer] - m_TranslationTable[(int)aLayer];
}
}
}
|
|
06-15-2014 09:14 PM |
|
|
Feeh
Sphere Developer
Posts: 156
Likes Given: 6
Likes Received: 40 in 29 posts
Joined: Sep 2012
Reputation: 4
|
RE: [UPDATED]Paperdoll & Web
(06-15-2014 09:14 PM)horadryn Wrote: Can someone translate this?
Code:
using System;
using System.Collections;
...
That's a layer comparer as the class name says.
RunUO does use it to place in order every gump piece of your paperdoll.
There is no easy translation to that, depends on what context you will be using, and may even be better to create a new way to compare depending on what you will use it.
I've played with RunUO for a long time and I can say its code is made to fit their specific needs, it can tell you what is needed to do something, but will not tell you how to do it
So, if you're playing with Sphere scripts, this class will take a totally different form than C#, the same for PHP, C++, etc...
(06-10-2014 06:39 PM)admin phoenix Wrote: I think it will be very easy to do this one if we have ingame a command which will show us the link from art to gump.
At the moment you have to find it out with a lot of work arounds and def names.
don´t know if it is hardcoded in the client?
I never saw anything inside the client files that link an item art with gump art.
UO client always had (at least for me) a fame to be badly coded with lots of workarounds. UO community have a incredible vast amount of knowledge around UO classic client that if there were something like that the community would already have found it, unless EA made it well hidden
Even UltimaXNA and other custom clients does use a very same method to draw the gump in order
Feeh/Epila - Nightly releases / SphereWiki / Github Issues / Sphere's GitHub
(This post was last modified: 06-16-2014 03:25 AM by Feeh.)
|
|
06-16-2014 03:24 AM |
|
|
horadryn
Apprentice
Posts: 8
Likes Given: 2
Likes Received: 0 in 0 posts
Joined: Nov 2012
Reputation: 0
|
RE: [UPDATED]Paperdoll & Web
I think this is the part that establishes the hierarchy of the layers ... To avoid seeing the pants over the armor ...
although, looking deeply, I think this is the right part
Code:
public void InsertItems( Mobile mob )
{
ArrayList items = m_Items;
items.AddRange( mob.Items );
string serial = mob.Serial.Value.ToString();
items.Sort( LayerComparer.Instance );
int index = 0;
bool hidePants = false;
bool alive = mob.Alive;
bool hideHair = !alive;
for ( int i = 0; i < items.Count; ++i )
{
Item item = (Item)items[i];
if ( !LayerComparer.IsValid( item ) )
break;
if ( !alive && item.ItemID != 8270 )
continue;
if ( item.ItemID == 0x1411 || item.ItemID == 0x141A ) // plate legs
hidePants = true;
else if ( hidePants && item.Layer == Layer.Pants )
continue;
if ( !hideHair && item.Layer == Layer.Helm )
hideHair = true;
InsertItem( serial, index++, item.ItemID, item.Hue );
}
if ( mob.FacialHairItemID != 0 && alive )
InsertItem( serial, index++, mob.FacialHairItemID, mob.FacialHairHue );
if ( mob.HairItemID != 0 && !hideHair )
InsertItem( serial, index++, mob.HairItemID, mob.HairHue );
items.Clear();
}
(This post was last modified: 06-16-2014 04:11 AM by horadryn.)
|
|
06-16-2014 03:43 AM |
|
|