#W# Initial Commit: Avatars Conquest

This commit is contained in:
WarrentyExpired 2026-07-04 10:35:30 -04:00
commit 5df497787a
7510 changed files with 416048 additions and 0 deletions

View file

@ -0,0 +1,140 @@
using System;
using Server;
using Server.Items;
using Server.Network;
using Server.Commands;
namespace Server.Gumps
{
public class AddDoorGump : Gump
{
private int m_Type;
public AddDoorGump() : this( -1 )
{
}
public void AddBlueBack( int width, int height )
{
AddBackground ( 0, 0, width-00, height-00, 0xE10 );
AddBackground ( 8, 5, width-16, height-11, 0x053 );
AddImageTiled ( 15, 14, width-29, height-29, 0xE14 );
AddAlphaRegion( 15, 14, width-29, height-29 );
}
public AddDoorGump( int type ) : base( 50, 40 )
{
m_Type = type;
AddPage( 0 );
if ( m_Type >= 0 && m_Type < m_Types.Length )
{
AddBlueBack( 155, 174 );
int baseID = m_Types[m_Type].m_BaseID;
AddItem( 25, 24, baseID );
AddButton( 26, 37, 0x5782, 0x5782, 1, GumpButtonType.Reply, 0 );
AddItem( 47, 45, baseID + 2 );
AddButton( 43, 57, 0x5783, 0x5783, 2, GumpButtonType.Reply, 0 );
AddItem( 87, 22, baseID + 10 );
AddButton( 116, 35, 0x5785, 0x5785, 6, GumpButtonType.Reply, 0 );
AddItem( 65, 45, baseID + 8 );
AddButton( 96, 55, 0x5784, 0x5784, 5, GumpButtonType.Reply, 0 );
AddButton( 73, 36, 0x2716, 0x2716, 9, GumpButtonType.Reply, 0 );
}
else
{
AddBlueBack( 1010, 145 );
for ( int i = 0; i < m_Types.Length; ++i )
{
AddButton( 30 + (i * 49), 13, 0x2624, 0x2625, i + 1, GumpButtonType.Reply, 0 );
AddItem( 22 + (i * 49), 20, m_Types[i].m_BaseID );
}
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
int button = info.ButtonID - 1;
if ( m_Type == -1 )
{
if ( button >= 0 && button < m_Types.Length )
from.SendGump( new AddDoorGump( button ) );
}
else
{
if ( button >= 0 && button < 8 )
{
from.SendGump( new AddDoorGump( m_Type ) );
CommandSystem.Handle( from, String.Format( "{0}Add {1} {2}", CommandSystem.Prefix, m_Types[m_Type].m_Type.Name, (DoorFacing) button ) );
}
else if ( button == 8 )
{
from.SendGump( new AddDoorGump( m_Type ) );
CommandSystem.Handle( from, String.Format( "{0}Link", CommandSystem.Prefix ) );
}
else
{
from.SendGump( new AddDoorGump() );
}
}
}
public static void Initialize()
{
CommandSystem.Register( "AddDoor", AccessLevel.GameMaster, new CommandEventHandler( AddDoor_OnCommand ) );
}
[Usage( "AddDoor" )]
[Description( "Displays a menu from which you can interactively add doors." )]
public static void AddDoor_OnCommand( CommandEventArgs e )
{
e.Mobile.SendGump( new AddDoorGump() );
}
public static DoorInfo[] m_Types = new DoorInfo[]
{
new DoorInfo( typeof( MetalDoor ), 0x675 ),
new DoorInfo( typeof( MetalDoor2), 0x6C5 ),
new DoorInfo( typeof( RattanDoor ), 0x695 ),
new DoorInfo( typeof( DarkWoodDoor ), 0x6A5 ),
new DoorInfo( typeof( LightWoodDoor ), 0x6D5 ),
new DoorInfo( typeof( StrongWoodDoor ), 0x6E5 ),
new DoorInfo( typeof( LightWoodGate ), 0x839 ),
new DoorInfo( typeof( DarkWoodGate ), 0x866 ),
new DoorInfo( typeof( MediumWoodDoor ), 0x6B5 ),
new DoorInfo( typeof( SecretLightWoodDoor ), 0x344 ),
new DoorInfo( typeof( SecretWoodenDoor ), 0x334 ),
new DoorInfo( typeof( SecretDungeonDoor), 0x314 ),
new DoorInfo( typeof( SecretStoneDoor1 ), 0xE8 ),
new DoorInfo( typeof( SecretStoneDoor2 ), 0x324 ),
new DoorInfo( typeof( SecretStoneDoor3 ), 0x354 ),
new DoorInfo( typeof( IronGateShort ), 0x84C ),
new DoorInfo( typeof( IronGate ), 0x824 ),
new DoorInfo( typeof( BarredMetalDoor ), 0x685 ),
new DoorInfo( typeof( BarredMetalDoor2 ), 0x1FED ),
new DoorInfo( typeof( SecretBookDoor ), 0x20F8 )
};
}
public class DoorInfo
{
public Type m_Type;
public int m_BaseID;
public DoorInfo( Type type, int baseID )
{
m_Type = type;
m_BaseID = baseID;
}
}
}

257
Scripts/Gumps/AddGump.cs Normal file
View file

@ -0,0 +1,257 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server;
using Server.Commands;
using Server.Network;
using Server.Targeting;
namespace Server.Gumps
{
public class AddGump : Gump
{
private string m_SearchString;
private Type[] m_SearchResults;
private int m_Page;
public static void Initialize()
{
CommandSystem.Register( "AddMenu", AccessLevel.GameMaster, new CommandEventHandler( AddMenu_OnCommand ) );
}
[Usage( "AddMenu [searchString]" )]
[Description( "Opens an add menu, with an optional initial search string. This menu allows you to search for Items or Mobiles and add them interactively." )]
private static void AddMenu_OnCommand( CommandEventArgs e )
{
string val = e.ArgString.Trim();
Type[] types;
bool explicitSearch = false;
if ( val.Length == 0 )
{
types = Type.EmptyTypes;
}
else if ( val.Length < 3 )
{
e.Mobile.SendMessage( "Invalid search string." );
types = Type.EmptyTypes;
}
else
{
types = Match( val ).ToArray();
explicitSearch = true;
}
e.Mobile.SendGump( new AddGump( e.Mobile, val, 0, types, explicitSearch ) );
}
public AddGump( Mobile from, string searchString, int page, Type[] searchResults, bool explicitSearch ) : base( 50, 50 )
{
m_SearchString = searchString;
m_SearchResults = searchResults;
m_Page = page;
from.CloseGump( typeof( AddGump ) );
AddPage( 0 );
AddBackground( 0, 0, 420, 280, 5054 );
AddImageTiled( 10, 10, 400, 20, 2624 );
AddAlphaRegion( 10, 10, 400, 20 );
AddImageTiled( 41, 11, 184, 18, 0xBBC );
AddImageTiled( 42, 12, 182, 16, 2624 );
AddAlphaRegion( 42, 12, 182, 16 );
AddButton( 10, 9, 4011, 4013, 1, GumpButtonType.Reply, 0 );
AddTextEntry( 44, 10, 180, 20, 0x480, 0, searchString );
AddHtmlLocalized( 230, 10, 100, 20, 3010005, 0x7FFF, false, false );
AddImageTiled( 10, 40, 400, 200, 2624 );
AddAlphaRegion( 10, 40, 400, 200 );
if ( searchResults.Length > 0 )
{
for ( int i = (page * 10); i < ((page + 1) * 10) && i < searchResults.Length; ++i )
{
int index = i % 10;
AddLabel( 44, 39 + (index * 20), 0x480, searchResults[i].Name );
AddButton( 10, 39 + (index * 20), 4023, 4025, 4 + i, GumpButtonType.Reply, 0 );
}
}
else
{
AddLabel( 15, 44, 0x480, explicitSearch ? "Nothing matched your search terms." : "No results to display." );
}
AddImageTiled( 10, 250, 400, 20, 2624 );
AddAlphaRegion( 10, 250, 400, 20 );
if ( m_Page > 0 )
AddButton( 10, 249, 4014, 4016, 2, GumpButtonType.Reply, 0 );
else
AddImage( 10, 249, 4014 );
AddHtmlLocalized( 44, 250, 170, 20, 1061028, m_Page > 0 ? 0x7FFF : 0x5EF7, false, false ); // Previous page
if ( ((m_Page + 1) * 10) < searchResults.Length )
AddButton( 210, 249, 4005, 4007, 3, GumpButtonType.Reply, 0 );
else
AddImage( 210, 249, 4005 );
AddHtmlLocalized( 244, 250, 170, 20, 1061027, ((m_Page + 1) * 10) < searchResults.Length ? 0x7FFF : 0x5EF7, false, false ); // Next page
}
private static Type typeofItem = typeof( Item ), typeofMobile = typeof( Mobile );
private static void Match( string match, Type[] types, List<Type> results )
{
if ( match.Length == 0 )
return;
match = match.ToLower();
for ( int i = 0; i < types.Length; ++i )
{
Type t = types[i];
if ( (typeofMobile.IsAssignableFrom( t ) || typeofItem.IsAssignableFrom( t )) && t.Name.ToLower().IndexOf( match ) >= 0 && !results.Contains( t ) )
{
ConstructorInfo[] ctors = t.GetConstructors();
for ( int j = 0; j < ctors.Length; ++j )
{
if ( ctors[j].GetParameters().Length == 0 && ctors[j].IsDefined( typeof( ConstructableAttribute ), false ) )
{
results.Add( t );
break;
}
}
}
}
}
public static List<Type> Match( string match )
{
List<Type> results = new List<Type>();
Type[] types;
Assembly[] asms = ScriptCompiler.Assemblies;
for ( int i = 0; i < asms.Length; ++i )
{
types = ScriptCompiler.GetTypeCache( asms[i] ).Types;
Match( match, types, results );
}
types = ScriptCompiler.GetTypeCache( Core.Assembly ).Types;
Match( match, types, results );
results.Sort( new TypeNameComparer() );
return results;
}
private class TypeNameComparer : IComparer<Type>
{
public int Compare( Type x, Type y )
{
return x.Name.CompareTo( y.Name );
}
}
public class InternalTarget : Target
{
private Type m_Type;
private Type[] m_SearchResults;
private string m_SearchString;
private int m_Page;
public InternalTarget( Type type, Type[] searchResults, string searchString, int page ) : base( -1, true, TargetFlags.None )
{
m_Type = type;
m_SearchResults = searchResults;
m_SearchString = searchString;
m_Page = page;
}
protected override void OnTarget( Mobile from, object o )
{
IPoint3D p = o as IPoint3D;
if ( p != null )
{
if ( p is Item )
p = ((Item)p).GetWorldTop();
else if ( p is Mobile )
p = ((Mobile)p).Location;
Server.Commands.Add.Invoke( from, new Point3D( p ), new Point3D( p ), new string[]{ m_Type.Name } );
from.Target = new InternalTarget( m_Type, m_SearchResults, m_SearchString, m_Page );
}
}
protected override void OnTargetCancel( Mobile from, TargetCancelType cancelType )
{
if ( cancelType == TargetCancelType.Canceled )
from.SendGump( new AddGump( from, m_SearchString, m_Page, m_SearchResults, true ) );
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
switch ( info.ButtonID )
{
case 1: // Search
{
TextRelay te = info.GetTextEntry( 0 );
string match = ( te == null ? "" : te.Text.Trim() );
if ( match.Length < 3 )
{
from.SendMessage( "Invalid search string." );
from.SendGump( new AddGump( from, match, m_Page, m_SearchResults, false ) );
}
else
{
from.SendGump( new AddGump( from, match, 0, Match( match ).ToArray(), true ) );
}
break;
}
case 2: // Previous page
{
if ( m_Page > 0 )
from.SendGump( new AddGump( from, m_SearchString, m_Page - 1, m_SearchResults, true ) );
break;
}
case 3: // Next page
{
if ( (m_Page + 1) * 10 < m_SearchResults.Length )
from.SendGump( new AddGump( from, m_SearchString, m_Page + 1, m_SearchResults, true ) );
break;
}
default:
{
int index = info.ButtonID - 4;
if ( index >= 0 && index < m_SearchResults.Length )
{
from.SendMessage( "Where do you wish to place this object? <ESC> to cancel." );
from.Target = new InternalTarget( m_SearchResults[index], m_SearchResults, m_SearchString, m_Page );
}
break;
}
}
}
}
}

2896
Scripts/Gumps/AdminGump.cs Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,260 @@
using System;
using System.Net;
using System.Text;
using System.Collections;
using System.Diagnostics;
using Server;
using Server.Items;
using Server.Prompts;
using Server.Network;
using Server.Accounting;
using Server.Commands;
namespace Server.Gumps
{
public class BanDurationGump : Gump
{
private ArrayList m_List;
public void AddButtonLabeled( int x, int y, int buttonID, string text )
{
AddButton( x, y - 1, 4005, 4007, buttonID, GumpButtonType.Reply, 0 );
AddHtml( x + 35, y, 240, 20, text, false, false );
}
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 static ArrayList MakeList( object obj )
{
ArrayList list = new ArrayList( 1 );
list.Add( obj );
return list;
}
public BanDurationGump( Account a ) : this( MakeList( a ) )
{
}
public BanDurationGump( ArrayList list ) : base( (640 - 500) / 2, (480 - 305) / 2 )
{
m_List = list;
int width = 500;
int height = 305;
AddPage( 0 );
AddBackground( 0, 0, width, height, 5054 );
//AddImageTiled( 10, 10, width - 20, 20, 2624 );
//AddAlphaRegion( 10, 10, width - 20, 20 );
AddHtml( 10, 10, width - 20, 20, "<CENTER>Ban Duration</CENTER>", false, false );
//AddImageTiled( 10, 40, width - 20, height - 50, 2624 );
//AddAlphaRegion( 10, 40, width - 20, height - 50 );
AddButtonLabeled( 15, 45, 1, "Infinite" );
AddButtonLabeled( 15, 65, 2, "From D:H:M:S" );
AddInput( 3, 0, "Days" );
AddInput( 4, 1, "Hours" );
AddInput( 5, 2, "Minutes" );
AddInput( 6, 3, "Seconds" );
AddHtml( 170, 45, 240, 20, "Comments:", false, false );
AddTextField( 170, 65, 315, height - 80, 10 );
}
public void AddInput( int bid, int idx, string name )
{
int x = 15;
int y = 95 + (idx * 50);
AddButtonLabeled( x, y, bid, name );
AddTextField( x + 35, y + 20, 100, 20, idx );
}
public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
if ( from.AccessLevel < AccessLevel.Administrator )
return;
TextRelay d = info.GetTextEntry( 0 );
TextRelay h = info.GetTextEntry( 1 );
TextRelay m = info.GetTextEntry( 2 );
TextRelay s = info.GetTextEntry( 3 );
TextRelay c = info.GetTextEntry( 10 );
TimeSpan duration;
bool shouldSet;
string fromString = from.ToString();
switch ( info.ButtonID )
{
case 0:
{
for ( int i = 0; i < m_List.Count; ++i )
{
Account a = (Account)m_List[i];
a.SetUnspecifiedBan( from );
}
from.SendMessage( "Duration unspecified." );
return;
}
case 1: // infinite
{
duration = TimeSpan.MaxValue;
shouldSet = true;
break;
}
case 2: // From D:H:M:S
{
if ( d != null && h != null && m != null && s != null )
{
try
{
duration = new TimeSpan( Utility.ToInt32( d.Text ), Utility.ToInt32( h.Text ), Utility.ToInt32( m.Text ), Utility.ToInt32( s.Text ) );
shouldSet = true;
break;
}
catch
{
}
}
duration = TimeSpan.Zero;
shouldSet = false;
break;
}
case 3: // From D
{
if ( d != null )
{
try
{
duration = TimeSpan.FromDays( Utility.ToDouble( d.Text ) );
shouldSet = true;
break;
}
catch
{
}
}
duration = TimeSpan.Zero;
shouldSet = false;
break;
}
case 4: // From H
{
if ( h != null )
{
try
{
duration = TimeSpan.FromHours( Utility.ToDouble( h.Text ) );
shouldSet = true;
break;
}
catch
{
}
}
duration = TimeSpan.Zero;
shouldSet = false;
break;
}
case 5: // From M
{
if ( m != null )
{
try
{
duration = TimeSpan.FromMinutes( Utility.ToDouble( m.Text ) );
shouldSet = true;
break;
}
catch
{
}
}
duration = TimeSpan.Zero;
shouldSet = false;
break;
}
case 6: // From S
{
if ( s != null )
{
try
{
duration = TimeSpan.FromSeconds( Utility.ToDouble( s.Text ) );
shouldSet = true;
break;
}
catch
{
}
}
duration = TimeSpan.Zero;
shouldSet = false;
break;
}
default: return;
}
if ( shouldSet ) {
string comment = null;
if ( c != null ) {
comment = c.Text.Trim();
if ( comment.Length == 0 )
comment = null;
}
for ( int i = 0; i < m_List.Count; ++i )
{
Account a = (Account)m_List[i];
a.SetBanTags( from, DateTime.Now, duration );
if ( comment != null )
a.Comments.Add( new AccountComment( from.RawName, String.Format( "Duration: {0}, Comment: {1}", (( duration == TimeSpan.MaxValue )? "Infinite" : duration.ToString()), comment ) ) );
}
if ( duration == TimeSpan.MaxValue )
from.SendMessage( "Ban Duration: Infinite" );
else
from.SendMessage( "Ban Duration: {0}", duration );
}
else
{
from.SendMessage( "Time values were improperly formatted." );
from.SendGump( new BanDurationGump( m_List ) );
}
}
}
}

View file

@ -0,0 +1,79 @@
using System;
using Server;
using Server.Items;
using Server.Mobiles;
namespace Server.Gumps
{
public class BaseConfirmGump : Gump
{
public virtual int TitleNumber{ get{ return 1075083; } } // <center>Warning!</center>
public virtual int LabelNumber{ get{ return 1074975; } } // Are you sure you wish to select this?
private enum Buttons
{
Close,
Break,
Confirm
}
public BaseConfirmGump() : base( 120, 50 )
{
Closable = false;
Disposable = true;
Dragable = true;
Resizable = false;
AddPage( 0 );
AddImageTiled( 0, 0, 348, 262, 0xA8E );
AddAlphaRegion( 0, 0, 348, 262 );
AddImage( 0, 15, 0x27A8 );
AddImageTiled( 0, 30, 17, 200, 0x27A7 );
AddImage( 0, 230, 0x27AA );
AddImage( 15, 230, 0x280C );
AddImageTiled( 30, 0, 300, 17, 0x280A );
AddImage( 315, 0, 0x280E );
AddImage( 15, 244, 0x280C );
AddImageTiled( 30, 244, 300, 17, 0x280A );
AddImage( 315, 244, 0x280E );
AddImage( 330, 15, 0x27A8 );
AddImageTiled( 330, 30, 17, 200, 0x27A7 );
AddImage( 330, 230, 0x27AA );
AddImage( 333, 2, 0x2716 );
AddImage( 315, 248, 0x2716 );
AddImage( 2, 248, 0x2716 );
AddImage( 2, 2, 0x2716 );
AddHtmlLocalized( 25, 25, 200, 20, TitleNumber, 0x7D00, false, false );
AddImage( 25, 40, 0xBBF );
AddHtmlLocalized( 25, 55, 300, 120, LabelNumber, 0xFFFFFF, false, false );
AddRadio( 25, 175, 0x25F8, 0x25FB, true, (int) Buttons.Break );
AddRadio( 25, 210, 0x25F8, 0x25FB, false, (int) Buttons.Close );
AddHtmlLocalized( 60, 180, 280, 20, 1074976, 0xFFFFFF, false, false );
AddHtmlLocalized( 60, 215, 280, 20, 1074977, 0xFFFFFF, false, false );
AddButton( 265, 220, 0xF7, 0xF8, (int) Buttons.Confirm, GumpButtonType.Reply, 0 );
}
public override void OnResponse( Server.Network.NetState state, RelayInfo info )
{
if ( info.ButtonID == (int) Buttons.Confirm )
{
if ( info.IsSwitched( (int) Buttons.Break ) )
Confirm( state.Mobile );
else
Refuse( state.Mobile );
}
}
public virtual void Confirm( Mobile from )
{
}
public virtual void Refuse( Mobile from )
{
}
}
}

View file

@ -0,0 +1,197 @@
using System;
namespace Server.Gumps
{
public abstract class BaseGridGump : Gump
{
private int m_CurrentX, m_CurrentY;
private int m_CurrentPage;
protected GumpBackground m_Background;
protected GumpImageTiled m_Offset;
public int CurrentPage
{
get{ return m_CurrentPage; }
}
public int CurrentX
{
get{ return m_CurrentX; }
}
public int CurrentY
{
get{ return m_CurrentY; }
}
public BaseGridGump( int x, int y ) : base( x, y )
{
}
public virtual int BorderSize{ get{ return 10; } }
public virtual int OffsetSize{ get{ return 1; } }
public virtual int EntryHeight{ get{ return 20; } }
public virtual int OffsetGumpID{ get{ return 0x0A40; } }
public virtual int HeaderGumpID{ get{ return 0x0E14; } }
public virtual int EntryGumpID{ get{ return 0x0BBC; } }
public virtual int BackGumpID{ get{ return 0x13BE; } }
public virtual int TextHue{ get{ return 0; } }
public virtual int TextOffsetX{ get{ return 2; } }
public const int ArrowLeftID1 = 0x15E3;
public const int ArrowLeftID2 = 0x15E7;
public const int ArrowLeftWidth = 16;
public const int ArrowLeftHeight = 16;
public const int ArrowRightID1 = 0x15E1;
public const int ArrowRightID2 = 0x15E5;
public const int ArrowRightWidth = 16;
public const int ArrowRightHeight = 16;
public string Center( string text )
{
return String.Format( "<CENTER>{0}</CENTER>", text );
}
public string Color( string text, int color )
{
return String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text );
}
public int GetButtonID( int typeCount, int type, int index )
{
return 1 + (index * typeCount) + type;
}
public bool SplitButtonID( int buttonID, int typeCount, out int type, out int index )
{
if ( buttonID < 1 )
{
type = 0;
index = 0;
return false;
}
buttonID -= 1;
type = buttonID % typeCount;
index = buttonID / typeCount;
return true;
}
public void FinishPage()
{
if ( m_Background != null )
m_Background.Height = m_CurrentY + EntryHeight + OffsetSize + BorderSize;
if ( m_Offset != null )
m_Offset.Height = m_CurrentY + EntryHeight + OffsetSize - BorderSize;
}
public void AddNewPage()
{
FinishPage();
m_CurrentX = BorderSize + OffsetSize;
m_CurrentY = BorderSize + OffsetSize;
AddPage( ++m_CurrentPage );
m_Background = new GumpBackground( 0, 0, 100, 100, BackGumpID );
Add( m_Background );
m_Offset = new GumpImageTiled( BorderSize, BorderSize, 100, 100, OffsetGumpID );
Add( m_Offset );
}
public void AddNewLine()
{
m_CurrentY += EntryHeight + OffsetSize;
m_CurrentX = BorderSize + OffsetSize;
}
public void IncreaseX( int width )
{
m_CurrentX += width + OffsetSize;
width = m_CurrentX + BorderSize;
if ( m_Background != null && width > m_Background.Width )
m_Background.Width = width;
width = m_CurrentX - BorderSize;
if ( m_Offset != null && width > m_Offset.Width )
m_Offset.Width = width;
}
public void AddEntryLabel( int width, string text )
{
AddImageTiled( m_CurrentX, m_CurrentY, width, EntryHeight, EntryGumpID );
AddLabelCropped( m_CurrentX + TextOffsetX, m_CurrentY, width - TextOffsetX, EntryHeight, TextHue, text );
IncreaseX( width );
}
public void AddEntryHtml( int width, string text )
{
AddImageTiled( m_CurrentX, m_CurrentY, width, EntryHeight, EntryGumpID );
AddHtml( m_CurrentX + TextOffsetX, m_CurrentY, width - TextOffsetX, EntryHeight, text, false, false );
IncreaseX( width );
}
public void AddEntryHeader( int width )
{
AddEntryHeader( width, 1 );
}
public void AddEntryHeader( int width, int spannedEntries )
{
AddImageTiled( m_CurrentX, m_CurrentY, width, (EntryHeight * spannedEntries) + (OffsetSize * (spannedEntries - 1)), HeaderGumpID );
IncreaseX( width );
}
public void AddBlankLine()
{
if ( m_Offset != null )
AddImageTiled( m_Offset.X, m_CurrentY, m_Offset.Width, EntryHeight, BackGumpID + 4 );
AddNewLine();
}
public void AddEntryButton( int width, int normalID, int pressedID, int buttonID, int buttonWidth, int buttonHeight )
{
AddEntryButton( width, normalID, pressedID, buttonID, buttonWidth, buttonHeight, 1 );
}
public void AddEntryButton( int width, int normalID, int pressedID, int buttonID, int buttonWidth, int buttonHeight, int spannedEntries )
{
AddImageTiled( m_CurrentX, m_CurrentY, width, (EntryHeight * spannedEntries) + (OffsetSize * (spannedEntries - 1)), HeaderGumpID );
AddButton( m_CurrentX + ((width - buttonWidth) / 2), m_CurrentY + (((EntryHeight * spannedEntries) + (OffsetSize * (spannedEntries - 1)) - buttonHeight) / 2), normalID, pressedID, buttonID, GumpButtonType.Reply, 0 );
IncreaseX( width );
}
public void AddEntryPageButton( int width, int normalID, int pressedID, int page, int buttonWidth, int buttonHeight )
{
AddImageTiled( m_CurrentX, m_CurrentY, width, EntryHeight, HeaderGumpID );
AddButton( m_CurrentX + ((width - buttonWidth) / 2), m_CurrentY + ((EntryHeight - buttonHeight) / 2), normalID, pressedID, 0, GumpButtonType.Page, page );
IncreaseX( width );
}
public void AddEntryText( int width, int entryID, string initialText )
{
AddImageTiled( m_CurrentX, m_CurrentY, width, EntryHeight, EntryGumpID );
AddTextEntry( m_CurrentX + TextOffsetX, m_CurrentY, width - TextOffsetX, EntryHeight, TextHue, entryID, initialText );
IncreaseX( width );
}
}
}

View file

@ -0,0 +1,131 @@
using System;
using Server;
using Server.Network;
using System.Collections;
namespace Server.Gumps
{
public class ImageTileButtonInfo
{
private int m_ItemID;
private int m_Hue;
private int m_LocalizedTooltip;
private TextDefinition m_Label;
public virtual int ItemID
{
get{ return m_ItemID; }
set{ m_ItemID = value; }
}
public virtual int Hue
{
get{ return m_Hue; }
set{ m_Hue = value; }
}
public virtual int LocalizedTooltip
{
get{ return m_LocalizedTooltip; }
set{ m_LocalizedTooltip = value; }
}
public virtual TextDefinition Label
{
get{ return m_Label; }
set{ m_Label = value; }
}
public ImageTileButtonInfo( int itemID, int hue, TextDefinition label, int localizedTooltip )
{
m_Hue = hue;
m_ItemID = itemID;
m_Label = label;
m_LocalizedTooltip = localizedTooltip;
}
public ImageTileButtonInfo( int itemID, int hue, TextDefinition label ) : this( itemID, hue, label, -1 )
{
}
}
public class BaseImageTileButtonsGump : Gump
{
private ImageTileButtonInfo[] m_Buttons;
protected ImageTileButtonInfo[] Buttons { get { return m_Buttons; } }
protected virtual int XItems{ get{ return 2; } }
protected virtual int YItems{ get { return 5; } }
public BaseImageTileButtonsGump( TextDefinition header, ArrayList buttons ) : this( header, (ImageTileButtonInfo[])buttons.ToArray( typeof( ImageTileButtonInfo ) ) )
{
}
public BaseImageTileButtonsGump( TextDefinition header, ImageTileButtonInfo[] buttons ) : base( 10, 10 ) //Coords are 0, o on OSI, intentional difference
{
m_Buttons = buttons;
AddPage( 0 );
int x = XItems * 250;
int y = YItems * 64;
AddBackground( 0, 0, x+20, y+84, 0x13BE );
AddImageTiled( 10, 10, x, 20, 0xA40 );
AddImageTiled( 10, 40, x, y+4, 0xA40 );
AddImageTiled( 10, y+54, x, 20, 0xA40 );
AddAlphaRegion( 10, 10, x, y+64 );
AddButton( 10, y+54, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0 ); //Cancel Button
AddHtmlLocalized( 45, y+56, x-50, 20, 1060051, 0x7FFF, false, false ); // CANCEL
TextDefinition.AddHtmlText( this, 14, 12, x, 20, header, false, false, 0x7FFF, 0xFFFFFF );
AddPage( 1 );
int itemsPerPage = XItems * YItems;
for( int i = 0; i < buttons.Length; i++ )
{
int position = i % itemsPerPage;
int innerX = (position % XItems) * 250 + 14;
int innerY = (position / XItems) * 64 + 44;
int pageNum = i / itemsPerPage + 1;
if( position == 0 && i != 0 )
{
AddButton( x-100, y+54, 0xFA5, 0xFA7, 0, GumpButtonType.Page, pageNum );
AddHtmlLocalized( x-60, y+56, 60, 20, 1043353, 0x7FFF, false, false ); // Next
AddPage( pageNum );
AddButton( x-200, y+54, 0xFAE, 0xFB0, 0, GumpButtonType.Page, pageNum - 1 );
AddHtmlLocalized( x-160, y+56, 60, 20, 1011393, 0x7FFF, false, false ); // Back
}
ImageTileButtonInfo b = buttons[i];
AddImageTiledButton( innerX, innerY, 0x918, 0x919, 100 + i, GumpButtonType.Reply, 0, b.ItemID, b.Hue, 15, 10, b.LocalizedTooltip );
TextDefinition.AddHtmlText( this, innerX + 84, innerY, 250, 60, b.Label, false, false, 0x7FFF, 0xFFFFFF );
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
int adjustedID = info.ButtonID - 100;
if( adjustedID >= 0 && adjustedID < Buttons.Length )
HandleButtonResponse( sender, adjustedID, Buttons[adjustedID] );
else
HandleCancel( sender );
}
public virtual void HandleButtonResponse( NetState sender, int adjustedButton, ImageTileButtonInfo buttonInfo )
{
}
public virtual void HandleCancel( NetState sender )
{
}
}
}

View file

@ -0,0 +1,386 @@
using System;
using System.IO;
using System.Xml;
using System.Collections;
using Server.Network;
using Server.Commands;
namespace Server.Gumps
{
public abstract class CAGNode
{
public abstract string Caption{ get; }
public abstract void OnClick( Mobile from, int page );
}
public class CAGObject : CAGNode
{
private Type m_Type;
private int m_ItemID;
private int m_Hue;
private CAGCategory m_Parent;
public Type Type{ get{ return m_Type; } }
public int ItemID{ get{ return m_ItemID; } }
public int Hue{ get{ return m_Hue; } }
public CAGCategory Parent{ get{ return m_Parent; } }
public override string Caption{ get{ return ( m_Type == null ? "bad type" : m_Type.Name ); } }
public override void OnClick( Mobile from, int page )
{
if ( m_Type == null )
{
from.SendMessage( "That is an invalid type name." );
}
else
{
CommandSystem.Handle( from, String.Format( "{0}Add {1}", CommandSystem.Prefix, m_Type.Name ) );
from.SendGump( new CategorizedAddGump( from, m_Parent, page ) );
}
}
public CAGObject( CAGCategory parent, XmlTextReader xml )
{
m_Parent = parent;
if ( xml.MoveToAttribute( "type" ) )
m_Type = ScriptCompiler.FindTypeByFullName( xml.Value, false );
if ( xml.MoveToAttribute( "gfx" ) )
m_ItemID = XmlConvert.ToInt32( xml.Value );
if ( xml.MoveToAttribute( "hue" ) )
m_Hue = XmlConvert.ToInt32( xml.Value );
}
}
public class CAGCategory : CAGNode
{
private string m_Title;
private CAGNode[] m_Nodes;
private CAGCategory m_Parent;
public string Title{ get{ return m_Title; } }
public CAGNode[] Nodes{ get{ return m_Nodes; } }
public CAGCategory Parent{ get{ return m_Parent; } }
public override string Caption{ get{ return m_Title; } }
public override void OnClick( Mobile from, int page )
{
from.SendGump( new CategorizedAddGump( from, this, 0 ) );
}
private CAGCategory()
{
m_Title = "no data";
m_Nodes = new CAGNode[0];
}
public CAGCategory( CAGCategory parent, XmlTextReader xml )
{
m_Parent = parent;
if ( xml.MoveToAttribute( "title" ) )
m_Title = xml.Value;
else
m_Title = "empty";
if ( m_Title == "Docked" )
m_Title = "Docked 2";
if ( xml.IsEmptyElement )
{
m_Nodes = new CAGNode[0];
}
else
{
ArrayList nodes = new ArrayList();
while ( xml.Read() && xml.NodeType != XmlNodeType.EndElement )
{
if ( xml.NodeType == XmlNodeType.Element && xml.Name == "object" )
nodes.Add( new CAGObject( this, xml ) );
else if ( xml.NodeType == XmlNodeType.Element && xml.Name == "category" )
{
if( !xml.IsEmptyElement )
nodes.Add( new CAGCategory( this, xml ) );
}
else
xml.Skip();
}
m_Nodes = (CAGNode[])nodes.ToArray( typeof( CAGNode ) );
}
}
private static CAGCategory m_Root;
public static CAGCategory Root
{
get
{
if ( m_Root == null )
m_Root = Load( "Data/Config/objects.xml" );
return m_Root;
}
}
public static CAGCategory Load( string path )
{
if ( File.Exists( path ) )
{
XmlTextReader xml = new XmlTextReader( path );
xml.WhitespaceHandling = WhitespaceHandling.None;
while ( xml.Read() )
{
if ( xml.Name == "category" && xml.NodeType == XmlNodeType.Element )
{
CAGCategory cat = new CAGCategory( null, xml );
xml.Close();
return cat;
}
}
}
return new CAGCategory();
}
}
public class CategorizedAddGump : Gump
{
public static bool OldStyle = PropsConfig.OldStyle;
public static readonly int EntryHeight = 24;//PropsConfig.EntryHeight;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int BorderSize = PropsConfig.BorderSize;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY + (((EntryHeight - 20) / 2) / 2);
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY + (((EntryHeight - 20) / 2) / 2);
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY + (((EntryHeight - 20) / 2) / 2);
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
private static bool PrevLabel = false, NextLabel = false;
private static readonly int PrevLabelOffsetX = PrevWidth + 1;
private static readonly int PrevLabelOffsetY = 0;
private static readonly int NextLabelOffsetX = -29;
private static readonly int NextLabelOffsetY = 0;
private static readonly int EntryWidth = 180;
private static readonly int EntryCount = 15;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (EntryCount + 1));
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
private Mobile m_Owner;
private CAGCategory m_Category;
private int m_Page;
public CategorizedAddGump( Mobile owner ) : this( owner, CAGCategory.Root, 0 )
{
}
public CategorizedAddGump( Mobile owner, CAGCategory category, int page ) : base( GumpOffsetX, GumpOffsetY )
{
owner.CloseGump( typeof( WhoGump ) );
m_Owner = owner;
m_Category = category;
Initialize( page );
}
public void Initialize( int page )
{
m_Page = page;
CAGNode[] nodes = m_Category.Nodes;
int count = nodes.Length - (page * EntryCount);
if ( count < 0 )
count = 0;
else if ( count > EntryCount )
count = EntryCount;
int totalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (count + 1));
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight, OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
if ( OldStyle )
AddImageTiled( x, y, TotalWidth - (OffsetSize * 3) - SetWidth, EntryHeight, HeaderGumpID );
else
AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );
if ( m_Category.Parent != null )
{
AddButton( x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1, GumpButtonType.Reply, 0 );
if ( PrevLabel )
AddLabel( x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous" );
}
x += PrevWidth + OffsetSize;
int emptyWidth = TotalWidth - (PrevWidth * 2) - NextWidth - (OffsetSize * 5) - (OldStyle ? SetWidth + OffsetSize : 0);
if ( !OldStyle )
AddImageTiled( x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, EntryGumpID );
AddHtml( x + TextOffsetX, y + ((EntryHeight - 20) / 2), emptyWidth - TextOffsetX, EntryHeight, String.Format( "<center>{0}</center>", m_Category.Caption ), false, false );
x += emptyWidth + OffsetSize;
if ( OldStyle )
AddImageTiled( x, y, TotalWidth - (OffsetSize * 3) - SetWidth, EntryHeight, HeaderGumpID );
else
AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );
if ( page > 0 )
{
AddButton( x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 2, GumpButtonType.Reply, 0 );
if ( PrevLabel )
AddLabel( x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous" );
}
x += PrevWidth + OffsetSize;
if ( !OldStyle )
AddImageTiled( x, y, NextWidth, EntryHeight, HeaderGumpID );
if ( (page + 1) * EntryCount < nodes.Length )
{
AddButton( x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 3, GumpButtonType.Reply, 1 );
if ( NextLabel )
AddLabel( x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next" );
}
for ( int i = 0, index = page * EntryCount; i < EntryCount && index < nodes.Length; ++i, ++index )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
CAGNode node = nodes[index];
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y + ((EntryHeight - 20) / 2), EntryWidth - TextOffsetX, EntryHeight, TextHue, node.Caption );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 4, GumpButtonType.Reply, 0 );
if ( node is CAGObject )
{
CAGObject obj = (CAGObject)node;
int itemID = obj.ItemID;
Rectangle2D bounds = ItemBounds.Table[itemID];
if ( itemID != 1 && bounds.Height < (EntryHeight * 2) )
{
if ( bounds.Height < EntryHeight )
AddItem( x - OffsetSize - 22 - ((i % 2) * 44) - (bounds.Width / 2) - bounds.X, y + (EntryHeight / 2) - (bounds.Height / 2) - bounds.Y, itemID );
else
AddItem( x - OffsetSize - 22 - ((i % 2) * 44) - (bounds.Width / 2) - bounds.X, y + EntryHeight - 1 - bounds.Height - bounds.Y, itemID );
}
}
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = m_Owner;
switch ( info.ButtonID )
{
case 0: // Closed
{
return;
}
case 1: // Up
{
if ( m_Category.Parent != null )
{
int index = Array.IndexOf( m_Category.Parent.Nodes, m_Category ) / EntryCount;
if ( index < 0 )
index = 0;
from.SendGump( new CategorizedAddGump( from, m_Category.Parent, index ) );
}
break;
}
case 2: // Previous
{
if ( m_Page > 0 )
from.SendGump( new CategorizedAddGump( from, m_Category, m_Page - 1 ) );
break;
}
case 3: // Next
{
if ( (m_Page + 1) * EntryCount < m_Category.Nodes.Length )
from.SendGump( new CategorizedAddGump( from, m_Category, m_Page + 1 ) );
break;
}
default:
{
int index = (m_Page * EntryCount) + (info.ButtonID - 4);
if ( index >= 0 && index < m_Category.Nodes.Length )
m_Category.Nodes[index].OnClick( from, m_Page );
break;
}
}
}
}
}

298
Scripts/Gumps/ClientGump.cs Normal file
View file

@ -0,0 +1,298 @@
using System;
using System.Net;
using Server;
using Server.Accounting;
using Server.Network;
using Server.Targets;
using Server.Commands;
using Server.Commands.Generic;
namespace Server.Gumps
{
public class ClientGump : Gump
{
private NetState m_State;
private void Resend( Mobile to, RelayInfo info )
{
TextRelay te = info.GetTextEntry( 0 );
to.SendGump( new ClientGump( to, m_State, te == null ? "" : te.Text ) );
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( m_State == null )
return;
Mobile focus = m_State.Mobile;
Mobile from = state.Mobile;
if ( focus == null )
{
from.SendMessage( "That character is no longer online." );
return;
}
else if ( focus.Deleted )
{
from.SendMessage( "That character no longer exists." );
return;
}
else if ( from != focus && focus.Hidden && from.AccessLevel < focus.AccessLevel )
{
from.SendMessage( "That character is no longer visible." );
return;
}
switch ( info.ButtonID )
{
case 1: // Tell
{
TextRelay text = info.GetTextEntry( 0 );
if ( text != null )
{
focus.SendMessage( 0x482, "{0} tells you:", from.Name );
focus.SendMessage( 0x482, text.Text );
CommandLogging.WriteLine( from, "{0} {1} telling {2} \"{3}\" ", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( focus ), text.Text );
}
from.SendGump( new ClientGump( from, m_State ) );
break;
}
case 4: // Props
{
Resend( from, info );
if ( !BaseCommand.IsAccessible( from, focus ) )
from.SendMessage( "That is not accessible." );
else
{
from.SendGump( new PropertiesGump( from, focus ) );
CommandLogging.WriteLine( from, "{0} {1} opening properties gump of {2} ", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( focus ) );
}
break;
}
case 5: // Go to
{
if ( focus.Map == null || focus.Map == Map.Internal )
{
from.SendMessage( "That character is not in the world." );
}
else
{
from.MoveToWorld( focus.Location, focus.Map );
Resend( from, info );
CommandLogging.WriteLine( from, "{0} {1} going to {2}, Location {3}, Map {4}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( focus ), focus.Location, focus.Map );
}
break;
}
case 6: // Get
{
if ( from.Map == null || from.Map == Map.Internal )
{
from.SendMessage( "You cannot bring that person here." );
}
else
{
focus.MoveToWorld( from.Location, from.Map );
Resend( from, info );
CommandLogging.WriteLine( from, "{0} {1} bringing {2} to Location {3}, Map {4}", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( focus ), from.Location, from.Map );
}
break;
}
case 7: // Move
{
from.Target = new MoveTarget( focus );
Resend( from, info );
break;
}
case 8: // Kick
{
if ( from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > focus.AccessLevel )
{
focus.Say( "I've been kicked!" );
m_State.Dispose();
CommandLogging.WriteLine( from, "{0} {1} kicking {2} ", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( focus ) );
}
break;
}
case 9: // Kill
{
if ( from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > focus.AccessLevel )
{
focus.Kill();
CommandLogging.WriteLine( from, "{0} {1} killing {2} ", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( focus ) );
}
Resend( from, info );
break;
}
case 10: //Res
{
if ( from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > focus.AccessLevel )
{
focus.PlaySound( 0x214 );
focus.FixedEffect( 0x376A, 10, 16 );
focus.Resurrect();
CommandLogging.WriteLine( from, "{0} {1} resurrecting {2} ", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( focus ) );
}
Resend( from, info );
break;
}
case 11: // Skills
{
Resend( from, info );
if ( from.AccessLevel > focus.AccessLevel )
{
from.SendGump( new SkillsGump( from, (Mobile)focus ) );
CommandLogging.WriteLine( from, "{0} {1} Opening Skills gump of {2} ", from.AccessLevel, CommandLogging.Format( from ), CommandLogging.Format( focus ) );
}
break;
}
}
}
public ClientGump( Mobile from, NetState state ) : this( from, state, "" )
{
}
private const int LabelColor32 = 0xFFFFFF;
public string Center( string text )
{
return String.Format( "<CENTER>{0}</CENTER>", text );
}
public string Color( string text, int color )
{
return String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text );
}
public ClientGump( Mobile from, NetState state, string initialText ) : base( 30, 20 )
{
if ( state == null )
return;
m_State = state;
AddPage( 0 );
AddBackground( 0, 0, 400, 274, 5054 );
AddImageTiled( 10, 10, 380, 19, 0xA40 );
AddAlphaRegion( 10, 10, 380, 19 );
AddImageTiled( 10, 32, 380, 232, 0xA40 );
AddAlphaRegion( 10, 32, 380, 232 );
AddHtml( 10, 10, 380, 20, Color( Center( "User Information" ), LabelColor32 ), false, false );
int line = 0;
AddHtml( 14, 36 + (line * 20), 200, 20, Color( "Address:", LabelColor32 ), false, false );
AddHtml( 70, 36 + (line++ * 20), 200, 20, Color( state.ToString(), LabelColor32 ), false, false );
AddHtml( 14, 36 + (line * 20), 200, 20, Color( "Client:", LabelColor32 ), false, false );
AddHtml( 70, 36 + (line++ * 20), 200, 20, Color( state.Version == null ? "(null)" : state.Version.ToString(), LabelColor32 ), false, false );
AddHtml( 14, 36 + (line * 20), 200, 20, Color( "Version:", LabelColor32 ), false, false );
ExpansionInfo info = state.ExpansionInfo;
string expansionName = info.Name;
AddHtml( 70, 36 + (line++ * 20), 200, 20, Color( expansionName, LabelColor32 ), false, false );
Account a = state.Account as Account;
Mobile m = state.Mobile;
if ( from.AccessLevel >= AccessLevel.GameMaster && a != null )
{
AddHtml( 14, 36 + (line * 20), 200, 20, Color( "Account:", LabelColor32 ), false, false );
AddHtml( 70, 36 + (line++ * 20), 200, 20, Color( a.Username, LabelColor32 ), false, false );
}
if ( m != null )
{
AddHtml( 14, 36 + (line * 20), 200, 20, Color( "Mobile:", LabelColor32 ), false, false );
AddHtml( 70, 36 + (line++ * 20), 200, 20, Color( String.Format( "{0} (0x{1:X})", m.Name, m.Serial.Value ), LabelColor32 ), false, false );
AddHtml( 14, 36 + (line * 20), 200, 20, Color( "Location:", LabelColor32 ), false, false );
AddHtml( 70, 36 + (line++ * 20), 200, 20, Color( String.Format( "{0} [{1}]", m.Location, m.Map ), LabelColor32 ), false, false );
AddButton( 13, 157, 0xFAB, 0xFAD, 1, GumpButtonType.Reply, 0 );
AddHtml( 48, 158, 200, 20, Color( "Send Message", LabelColor32 ), false, false );
AddImageTiled( 12, 182, 376, 80, 0xA40 );
AddImageTiled( 13, 183, 374, 78, 0xBBC );
AddTextEntry( 15, 183, 372, 78, 0x480, 0, "" );
AddImageTiled( 245, 35, 142, 144, 5058 );
AddImageTiled( 246, 36, 140, 142, 0xA40 );
AddAlphaRegion( 246, 36, 140, 142 );
line = 0;
if ( BaseCommand.IsAccessible( from, m ) )
{
AddButton( 246, 36 + (line * 20), 0xFA5, 0xFA7, 4, GumpButtonType.Reply, 0 );
AddHtml( 280, 38 + (line++ * 20), 100, 20, Color( "Properties", LabelColor32 ), false, false );
}
if ( from != m )
{
AddButton( 246, 36 + (line * 20), 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0 );
AddHtml( 280, 38 + (line++ * 20), 100, 20, Color( "Go to them", LabelColor32 ), false, false );
AddButton( 246, 36 + (line * 20), 0xFA5, 0xFA7, 6, GumpButtonType.Reply, 0 );
AddHtml( 280, 38 + (line++ * 20), 100, 20, Color( "Bring them here", LabelColor32 ), false, false );
}
AddButton( 246, 36 + (line * 20), 0xFA5, 0xFA7, 7, GumpButtonType.Reply, 0 );
AddHtml( 280, 38 + (line++ * 20), 100, 20, Color( "Move to target", LabelColor32 ), false, false );
if ( from.AccessLevel >= AccessLevel.GameMaster && from.AccessLevel > m.AccessLevel )
{
AddButton( 246, 36 + (line * 20), 0xFA5, 0xFA7, 8, GumpButtonType.Reply, 0 );
AddHtml( 280, 38 + (line++ * 20), 100, 20, Color( "Disconnect", LabelColor32 ), false, false );
if ( m.Alive )
{
AddButton( 246, 36 + (line * 20), 0xFA5, 0xFA7, 9, GumpButtonType.Reply, 0 );
AddHtml( 280, 38 + (line++ * 20), 100, 20, Color( "Kill", LabelColor32 ), false, false );
}
else
{
AddButton( 246, 36 + (line * 20), 0xFA5, 0xFA7, 10, GumpButtonType.Reply, 0 );
AddHtml( 280, 38 + (line++ * 20), 100, 20, Color( "Resurrect", LabelColor32 ), false, false );
}
}
if ( from.AccessLevel >= AccessLevel.Counselor && from.AccessLevel > m.AccessLevel )
{
AddButton( 246, 36 + (line * 20), 0xFA5, 0xFA7, 11, GumpButtonType.Reply, 0 );
AddHtml( 280, 38 + (line++ * 20), 100, 20, Color( "Skills browser", LabelColor32 ), false, false );
}
}
}
}
}

View file

@ -0,0 +1,154 @@
using System;
using Server;
using Server.Items;
using Server.Multis;
using Server.Multis.Deeds;
using Server.Network;
using Server.Mobiles;
namespace Server.Gumps
{
public class ConfirmHouseResize : Gump
{
private Mobile m_Mobile;
private BaseHouse m_House;
private TempNoHousingRegion m_Temp;
public ConfirmHouseResize( Mobile mobile, BaseHouse house ) : base( 110, 100 )
{
m_Mobile = mobile;
m_House = house;
mobile.CloseGump( typeof( ConfirmHouseResize ) );
Closable = false;
AddPage( 0 );
AddBackground( 0, 0, 420, 280, 0x13BE );
AddImageTiled( 10, 10, 400, 20, 0xA40 );
AddAlphaRegion( 10, 10, 400, 20 );
AddHtmlLocalized( 10, 10, 400, 20, 1060635, 0x7800, false, false ); // <CENTER>WARNING</CENTER>
AddImageTiled( 10, 40, 400, 200, 0xA40 );
AddAlphaRegion( 10, 40, 400, 200 );
/* You are attempting to resize your house. You will be refunded the house's
value directly to your inn chest. All items in the house will *remain behind*
and can be *freely picked up by anyone*. Once the house is demolished, however,
only this account will be able to place on the land for one hour. This *will*
circumvent the normal 7-day waiting period (if it applies to you). This action
will not un-condemn any other houses on your account. If you have other,
grandfathered houses, this action *WILL* condemn them. Are you sure you wish
to continue?*/
AddHtmlLocalized( 10, 40, 400, 200, 1080196, 0x7F00, false, true );
AddImageTiled( 10, 250, 400, 20, 0xA40 );
AddAlphaRegion( 10, 250, 400, 20 );
AddButton( 10, 250, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 );
AddButton( 210, 250, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 40, 250, 170, 20, 1011036, 0x7FFF, false, false ); // OKAY
AddHtmlLocalized( 240, 250, 170, 20, 1011012, 0x7FFF, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( info.ButtonID == 1 && !m_House.Deleted )
{
if ( m_House.IsOwner( m_Mobile ) )
{
if ( m_House.MovingCrate != null || m_House.InternalizedVendors.Count > 0 )
{
m_Mobile.SendLocalizedMessage( 1080455 ); // You can not resize your house at this time. Please remove all items fom the moving crate and try again.
return;
}
else if( !Guilds.Guild.NewGuildSystem && m_House.FindGuildstone() != null )
{
m_Mobile.SendLocalizedMessage( 501389 ); // You cannot redeed a house with a guildstone inside.
return;
}
/*else if ( m_House.PlayerVendors.Count > 0 )
{
m_Mobile.SendLocalizedMessage( 503236 ); // You need to collect your vendor's belongings before moving.
return;
}*/
else if ( m_House.HasRentedVendors && m_House.VendorInventories.Count > 0 )
{
m_Mobile.SendLocalizedMessage( 1062679 ); // You cannot do that that while you still have contract vendors or unclaimed contract vendor inventory in your house.
return;
}
else if ( m_House.HasRentedVendors )
{
m_Mobile.SendLocalizedMessage( 1062680 ); // You cannot do that that while you still have contract vendors in your house.
return;
}
else if ( m_House.VendorInventories.Count > 0 )
{
m_Mobile.SendLocalizedMessage( 1062681 ); // You cannot do that that while you still have unclaimed contract vendor inventory in your house.
return;
}
if ( m_Mobile.AccessLevel >= AccessLevel.GameMaster )
{
m_Mobile.SendMessage( "You do not get a refund for your house as you are not a player" );
m_House.RemoveKeys(m_Mobile);
m_House.Delete();
}
else
{
Item toGive = null;
if ( m_House.IsAosRules )
{
if ( m_House.Price > 0 )
toGive = new GoldDeed( m_House.Price );
else
toGive = m_House.GetDeed();
}
else
{
toGive = m_House.GetDeed();
if ( toGive == null && m_House.Price > 0 )
toGive = new GoldDeed( m_House.Price );
}
if ( toGive != null )
{
InnBox box = m_Mobile.InnBox;
if ( box.TryDropItem( m_Mobile, toGive, false ) )
{
if ( toGive is GoldDeed )
m_Mobile.SendLocalizedMessage( 1060397, ( (GoldDeed)toGive ).Worth.ToString() ); // ~1_AMOUNT~ gold has been deposited into your inn chest.
m_House.RemoveKeys( m_Mobile );
new TempNoHousingRegion( m_House, m_Mobile );
m_House.Delete();
}
else
{
toGive.Delete();
m_Mobile.SendLocalizedMessage( 500390 ); // Your inn chest is full.
}
}
else
{
m_Mobile.SendMessage( "Unable to refund house." );
}
}
}
else
{
m_Mobile.SendLocalizedMessage( 501320 ); // Only the house owner may do this.
}
}
else if ( info.ButtonID == 0 )
{
m_Mobile.CloseGump( typeof( ConfirmHouseResize ) );
m_Mobile.SendGump( new HouseGumpAOS( HouseGumpPageAOS.Customize, m_Mobile, m_House ) );
}
}
}
}

View file

@ -0,0 +1,48 @@
using System;
using Server;
using Server.Mobiles;
namespace Server.Gumps
{
public class ConfirmReleaseGump : Gump
{
private Mobile m_From;
private BaseCreature m_Pet;
public ConfirmReleaseGump( Mobile from, BaseCreature pet ) : base( 50, 50 )
{
m_From = from;
m_Pet = pet;
m_From.CloseGump( typeof( ConfirmReleaseGump ) );
AddPage( 0 );
AddBackground( 0, 0, 270, 120, 5054 );
AddBackground( 10, 10, 250, 100, 3000 );
AddHtmlLocalized( 20, 15, 230, 60, 1046257, true, true ); // Are you sure you want to release your pet?
AddButton( 20, 80, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 80, 75, 20, 1011011, false, false ); // CONTINUE
AddButton( 135, 80, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 170, 80, 75, 20, 1011012, false, false ); // CANCEL
}
public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
{
if ( info.ButtonID == 2 )
{
if ( !m_Pet.Deleted && m_Pet.Controlled && m_From == m_Pet.ControlMaster && m_From.CheckAlive() /*&& m_Pet.CheckControlChance( m_From )*/ )
{
if ( m_Pet.Map == m_From.Map && m_Pet.InRange( m_From, 14 ) )
{
m_Pet.ControlTarget = null;
m_Pet.ControlOrder = OrderType.Release;
}
}
}
}
}
}

View file

@ -0,0 +1,81 @@
using System;
using System.Xml;
using Server;
namespace Server.Gumps
{
public class ChildNode
{
private ParentNode m_Parent;
private string m_Name;
private Point3D m_Location;
private Map m_Map;
public ChildNode( XmlTextReader xml, ParentNode parent )
{
m_Parent = parent;
Parse( xml );
}
private void Parse( XmlTextReader xml )
{
if ( xml.MoveToAttribute( "name" ) )
m_Name = xml.Value;
else
m_Name = "empty";
int x = 0, y = 0, z = 0; m_Map = Map.Britannia;
if ( xml.MoveToAttribute( "x" ) )
x = Utility.ToInt32( xml.Value );
if ( xml.MoveToAttribute( "y" ) )
y = Utility.ToInt32( xml.Value );
if ( xml.MoveToAttribute( "z" ) )
z = Utility.ToInt32( xml.Value );
if ( xml.MoveToAttribute( "map" ) )
{
if ( xml.Value == "Britannia" ){ m_Map = Map.Britannia; }
else if ( xml.Value == "Underworld" ){ m_Map = Map.Underworld; }
}
m_Location = new Point3D( x, y, z );
}
public ParentNode Parent
{
get
{
return m_Parent;
}
}
public string Name
{
get
{
return m_Name;
}
}
public Point3D Location
{
get
{
return m_Location;
}
}
public Map World
{
get
{
return m_Map;
}
}
}
}

235
Scripts/Gumps/Go/GoGump.cs Normal file
View file

@ -0,0 +1,235 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
namespace Server.Gumps
{
public class GoGump : Gump
{
public static readonly LocationTree Listing = new LocationTree( "Config/go.xml" );
public static bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static bool PrevLabel = false, NextLabel = false;
private static readonly int PrevLabelOffsetX = PrevWidth + 1;
private static readonly int PrevLabelOffsetY = 0;
private static readonly int NextLabelOffsetX = -29;
private static readonly int NextLabelOffsetY = 0;
private static readonly int EntryWidth = 180;
private static readonly int EntryCount = 15;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (EntryCount + 1));
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
public static void DisplayTo( Mobile from )
{
LocationTree tree = Listing;
ParentNode branch = null;
tree.LastBranch.TryGetValue( from, out branch );
if ( branch == null )
branch = tree.Root;
if ( branch != null )
from.SendGump( new GoGump( 0, from, tree, branch ) );
}
private LocationTree m_Tree;
private ParentNode m_Node;
private int m_Page;
private GoGump( int page, Mobile from, LocationTree tree, ParentNode node ) : base( 50, 50 )
{
from.CloseGump( typeof( GoGump ) );
tree.LastBranch[from] = node;
m_Page = page;
m_Tree = tree;
m_Node = node;
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
int count = node.Children.Length - (page * EntryCount);
if ( count < 0 )
count = 0;
else if ( count > EntryCount )
count = EntryCount;
int totalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (count + 1));
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight, OffsetGumpID );
if ( OldStyle )
AddImageTiled( x, y, TotalWidth - (OffsetSize * 3) - SetWidth, EntryHeight, HeaderGumpID );
else
AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );
if ( node.Parent != null )
{
AddButton( x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1, GumpButtonType.Reply, 0 );
if ( PrevLabel )
AddLabel( x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous" );
}
x += PrevWidth + OffsetSize;
int emptyWidth = TotalWidth - (PrevWidth * 2) - NextWidth - (OffsetSize * 5) - (OldStyle ? SetWidth + OffsetSize : 0);
if ( !OldStyle )
AddImageTiled( x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, EntryGumpID );
AddHtml( x + TextOffsetX, y, emptyWidth - TextOffsetX, EntryHeight, String.Format( "<center>{0}</center>", node.Name ), false, false );
x += emptyWidth + OffsetSize;
if ( OldStyle )
AddImageTiled( x, y, TotalWidth - (OffsetSize * 3) - SetWidth, EntryHeight, HeaderGumpID );
else
AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );
if ( page > 0 )
{
AddButton( x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 2, GumpButtonType.Reply, 0 );
if ( PrevLabel )
AddLabel( x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous" );
}
x += PrevWidth + OffsetSize;
if ( !OldStyle )
AddImageTiled( x, y, NextWidth, EntryHeight, HeaderGumpID );
if ( (page + 1) * EntryCount < node.Children.Length )
{
AddButton( x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 3, GumpButtonType.Reply, 1 );
if ( NextLabel )
AddLabel( x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next" );
}
for ( int i = 0, index = page * EntryCount; i < EntryCount && index < node.Children.Length; ++i, ++index )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
object child = node.Children[index];
string name = "";
if ( child is ParentNode )
name = ((ParentNode)child).Name;
else if ( child is ChildNode )
name = ((ChildNode)child).Name;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, name );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, index + 4, GumpButtonType.Reply, 0 );
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
switch ( info.ButtonID )
{
case 1:
{
if ( m_Node.Parent != null )
from.SendGump( new GoGump( 0, from, m_Tree, m_Node.Parent ) );
break;
}
case 2:
{
if ( m_Page > 0 )
from.SendGump( new GoGump( m_Page - 1, from, m_Tree, m_Node ) );
break;
}
case 3:
{
if ( (m_Page + 1) * EntryCount < m_Node.Children.Length )
from.SendGump( new GoGump( m_Page + 1, from, m_Tree, m_Node ) );
break;
}
default:
{
int index = info.ButtonID - 4;
if ( index >= 0 && index < m_Node.Children.Length )
{
object o = m_Node.Children[index];
if ( o is ParentNode )
{
from.SendGump( new GoGump( 0, from, m_Tree, (ParentNode)o ) );
}
else
{
ChildNode n = (ChildNode)o;
from.MoveToWorld( n.Location, n.World );
}
}
break;
}
}
}
}
}

View file

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using Server;
namespace Server.Gumps
{
public class LocationTree
{
private ParentNode m_Root;
private Dictionary<Mobile, ParentNode> m_LastBranch;
public LocationTree( string fileName )
{
m_LastBranch = new Dictionary<Mobile, ParentNode>();
string path = Path.Combine( "Data/", fileName );
if ( File.Exists( path ) )
{
XmlTextReader xml = new XmlTextReader( new StreamReader( path ) );
xml.WhitespaceHandling = WhitespaceHandling.None;
m_Root = Parse( xml );
xml.Close();
}
}
public Dictionary<Mobile, ParentNode> LastBranch
{
get
{
return m_LastBranch;
}
}
public ParentNode Root
{
get
{
return m_Root;
}
}
private ParentNode Parse( XmlTextReader xml )
{
xml.Read();
xml.Read();
xml.Read();
return new ParentNode( xml, null );
}
}
}

View file

@ -0,0 +1,79 @@
using System;
using System.Xml;
using System.Collections;
using Server;
namespace Server.Gumps
{
public class ParentNode
{
private ParentNode m_Parent;
private object[] m_Children;
private string m_Name;
public ParentNode( XmlTextReader xml, ParentNode parent )
{
m_Parent = parent;
Parse( xml );
}
private void Parse( XmlTextReader xml )
{
if ( xml.MoveToAttribute( "name" ) )
m_Name = xml.Value;
else
m_Name = "empty";
if ( xml.IsEmptyElement )
{
m_Children = new object[0];
}
else
{
ArrayList children = new ArrayList();
while ( xml.Read() && xml.NodeType == XmlNodeType.Element )
{
if ( xml.Name == "child" )
{
ChildNode n = new ChildNode( xml, this );
children.Add( n );
}
else
{
children.Add( new ParentNode( xml, this ) );
}
}
m_Children = children.ToArray();
}
}
public ParentNode Parent
{
get
{
return m_Parent;
}
}
public object[] Children
{
get
{
return m_Children;
}
}
public string Name
{
get
{
return m_Name;
}
}
}
}

View file

@ -0,0 +1,148 @@
using System;
using Server;
using Server.Items;
using Server.Multis;
using Server.Multis.Deeds;
using Server.Network;
using Server.Mobiles;
namespace Server.Gumps
{
public class HouseDemolishGump : Gump
{
private Mobile m_Mobile;
private BaseHouse m_House;
public HouseDemolishGump( Mobile mobile, BaseHouse house ) : base( 110, 100 )
{
m_Mobile = mobile;
m_House = house;
mobile.CloseGump( typeof( HouseDemolishGump ) );
Closable = false;
AddPage( 0 );
AddBackground( 0, 0, 420, 280, 5054 );
AddImageTiled( 10, 10, 400, 20, 2624 );
AddAlphaRegion( 10, 10, 400, 20 );
AddHtmlLocalized( 10, 10, 400, 20, 1060635, 30720, false, false ); // <CENTER>WARNING</CENTER>
AddImageTiled( 10, 40, 400, 200, 2624 );
AddAlphaRegion( 10, 40, 400, 200 );
AddHtmlLocalized( 10, 40, 400, 200, 1061795, 32512, false, true ); /* You are about to demolish your house.
* You will be refunded the house's value directly to your inn chest.
* All items in the house will remain behind and can be freely picked up by anyone.
* Once the house is demolished, anyone can attempt to place a new house on the vacant land.
* This action will not un-condemn any other houses on your account, nor will it end your 7-day waiting period (if it applies to you).
* Are you sure you wish to continue?
*/
AddImageTiled( 10, 250, 400, 20, 2624 );
AddAlphaRegion( 10, 250, 400, 20 );
AddButton( 10, 250, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 40, 250, 170, 20, 1011036, 32767, false, false ); // OKAY
AddButton( 210, 250, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 240, 250, 170, 20, 1011012, 32767, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( info.ButtonID == 1 && !m_House.Deleted )
{
if ( m_House.IsOwner( m_Mobile ) )
{
if ( m_House.MovingCrate != null || m_House.InternalizedVendors.Count > 0 )
{
return;
}
else if( !Guilds.Guild.NewGuildSystem && m_House.FindGuildstone() != null )
{
m_Mobile.SendLocalizedMessage( 501389 ); // You cannot redeed a house with a guildstone inside.
return;
}
/*else if ( m_House.PlayerVendors.Count > 0 )
{
m_Mobile.SendLocalizedMessage( 503236 ); // You need to collect your vendor's belongings before moving.
return;
}*/
else if ( m_House.HasRentedVendors && m_House.VendorInventories.Count > 0 )
{
m_Mobile.SendLocalizedMessage( 1062679 ); // You cannot do that that while you still have contract vendors or unclaimed contract vendor inventory in your house.
return;
}
else if ( m_House.HasRentedVendors )
{
m_Mobile.SendLocalizedMessage( 1062680 ); // You cannot do that that while you still have contract vendors in your house.
return;
}
else if ( m_House.VendorInventories.Count > 0 )
{
m_Mobile.SendLocalizedMessage( 1062681 ); // You cannot do that that while you still have unclaimed contract vendor inventory in your house.
return;
}
if ( m_Mobile.AccessLevel >= AccessLevel.GameMaster )
{
m_Mobile.SendMessage( "You do not get a refund for your house as you are not a player" );
m_House.RemoveKeys(m_Mobile);
m_House.Delete();
}
else
{
Item toGive = null;
if ( m_House.IsAosRules )
{
if ( m_House.Price > 0 )
toGive = new GoldDeed( m_House.Price );
else
toGive = m_House.GetDeed();
}
else
{
toGive = m_House.GetDeed();
if ( toGive == null && m_House.Price > 0 )
toGive = new GoldDeed( m_House.Price );
}
if ( toGive != null )
{
InnBox box = m_Mobile.InnBox;
if ( box.TryDropItem( m_Mobile, toGive, false ) )
{
if ( toGive is GoldDeed )
m_Mobile.SendLocalizedMessage( 1060397, ( (GoldDeed)toGive ).Worth.ToString() ); // ~1_AMOUNT~ gold has been deposited into your inn chest.
m_House.RemoveKeys( m_Mobile );
m_House.Delete();
}
else
{
toGive.Delete();
m_Mobile.SendLocalizedMessage( 500390 ); // Your inn chest is full.
}
}
else
{
m_Mobile.SendMessage( "Unable to refund house." );
}
}
}
else
{
m_Mobile.SendLocalizedMessage( 501320 ); // Only the house owner may do this.
}
}
}
}
}

755
Scripts/Gumps/HouseGump.cs Normal file
View file

@ -0,0 +1,755 @@
using System;
using System.Reflection;
using System.Collections;
using Server.Network;
using Server.Prompts;
using Server.Multis;
using Server.Multis.Deeds;
using Server.Items;
namespace Server.Gumps
{
public class HouseListGump : Gump
{
private BaseHouse m_House;
public HouseListGump( int number, ArrayList list, BaseHouse house, bool accountOf ) : base( 20, 30 )
{
if ( house.Deleted )
return;
m_House = house;
AddPage( 0 );
AddBackground( 0, 0, 420, 430, 5054 );
AddBackground( 10, 10, 400, 410, 3000 );
AddButton( 20, 388, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 388, 300, 20, 1011104, false, false ); // Return to previous menu
AddHtmlLocalized( 20, 20, 350, 20, number, false, false );
if ( list != null )
{
for ( int i = 0; i < list.Count; ++i )
{
if ( (i % 16) == 0 )
{
if ( i != 0 )
{
// Next button
AddButton( 370, 20, 4005, 4007, 0, GumpButtonType.Page, (i / 16) + 1 );
}
AddPage( (i / 16) + 1 );
if ( i != 0 )
{
// Previous button
AddButton( 340, 20, 4014, 4016, 0, GumpButtonType.Page, i / 16 );
}
}
Mobile m = (Mobile)list[i];
string name;
if ( m == null || (name = m.Name) == null || (name = name.Trim()).Length <= 0 )
continue;
AddLabel( 55, 55 + ((i % 16) * 20), 0, accountOf && m.Player && m.Account != null ? String.Format( "Account of {0}", name ) : name );
}
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( m_House.Deleted )
return;
Mobile from = state.Mobile;
from.SendGump( new HouseGump( from, m_House ) );
}
}
public class HouseRemoveGump : Gump
{
private BaseHouse m_House;
private ArrayList m_List, m_Copy;
private int m_Number;
private bool m_AccountOf;
public HouseRemoveGump( int number, ArrayList list, BaseHouse house, bool accountOf ) : base( 20, 30 )
{
if ( house.Deleted )
return;
m_House = house;
m_List = list;
m_Number = number;
m_AccountOf = accountOf;
AddPage( 0 );
AddBackground( 0, 0, 420, 430, 5054 );
AddBackground( 10, 10, 400, 410, 3000 );
AddButton( 20, 388, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 388, 300, 20, 1011104, false, false ); // Return to previous menu
AddButton( 20, 365, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 365, 300, 20, 1011270, false, false ); // Remove now!
AddHtmlLocalized( 20, 20, 350, 20, number, false, false );
if ( list != null )
{
m_Copy = new ArrayList( list );
for ( int i = 0; i < list.Count; ++i )
{
if ( (i % 15) == 0 )
{
if ( i != 0 )
{
// Next button
AddButton( 370, 20, 4005, 4007, 0, GumpButtonType.Page, (i / 15) + 1 );
}
AddPage( (i / 15) + 1 );
if ( i != 0 )
{
// Previous button
AddButton( 340, 20, 4014, 4016, 0, GumpButtonType.Page, i / 15 );
}
}
Mobile m = (Mobile)list[i];
string name;
if ( m == null || (name = m.Name) == null || (name = name.Trim()).Length <= 0 )
continue;
AddCheck( 34, 52 + ((i % 15) * 20), 0xD2, 0xD3, false, i );
AddLabel( 55, 52 + ((i % 15) * 20), 0, accountOf && m.Player && m.Account != null ? String.Format( "Account of {0}", name ) : name );
}
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( m_House.Deleted )
return;
Mobile from = state.Mobile;
if ( m_List != null && info.ButtonID == 1 ) // Remove now
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
for ( int i = 0; i < switches.Length; ++i )
{
int index = switches[i];
if ( index >= 0 && index < m_Copy.Count )
m_List.Remove( m_Copy[index] );
}
if ( m_List.Count > 0 )
{
from.CloseGump( typeof( HouseGump ) );
from.CloseGump( typeof( HouseListGump ) );
from.CloseGump( typeof( HouseRemoveGump ) );
from.SendGump( new HouseRemoveGump( m_Number, m_List, m_House, m_AccountOf ) );
return;
}
}
}
from.SendGump( new HouseGump( from, m_House ) );
}
}
public class HouseGump : Gump
{
private BaseHouse m_House;
private ArrayList Wrap( string value )
{
if ( value == null || (value = value.Trim()).Length <= 0 )
return null;
string[] values = value.Split( ' ' );
ArrayList list = new ArrayList();
string current = "";
for ( int i = 0; i < values.Length; ++i )
{
string val = values[i];
string v = current.Length == 0 ? val : current + ' ' + val;
if ( v.Length < 10 )
{
current = v;
}
else if ( v.Length == 10 )
{
list.Add( v );
if ( list.Count == 6 )
return list;
current = "";
}
else if ( val.Length <= 10 )
{
list.Add( current );
if ( list.Count == 6 )
return list;
current = val;
}
else
{
while ( v.Length >= 10 )
{
list.Add( v.Substring( 0, 10 ) );
if ( list.Count == 6 )
return list;
v = v.Substring( 10 );
}
current = v;
}
}
if ( current.Length > 0 )
list.Add( current );
return list;
}
public HouseGump( Mobile from, BaseHouse house ) : base( 20, 30 )
{
if ( house.Deleted )
return;
m_House = house;
from.CloseGump( typeof( HouseGump ) );
from.CloseGump( typeof( HouseListGump ) );
from.CloseGump( typeof( HouseRemoveGump ) );
bool isCombatRestricted = house.IsCombatRestricted( from );
bool isOwner = m_House.IsOwner( from );
bool isCoOwner = isOwner || m_House.IsCoOwner( from );
bool isFriend = isCoOwner || m_House.IsFriend( from );
if ( isCombatRestricted )
isFriend = isCoOwner = isOwner = false;
AddPage( 0 );
if ( isFriend )
{
AddBackground( 0, 0, 420, 430, 5054 );
AddBackground( 10, 10, 400,410, 3000 );
}
AddImage( 130, 0, 100 );
if ( m_House.Sign != null )
{
ArrayList lines = Wrap( m_House.Sign.GetName() );
if ( lines != null )
{
for ( int i = 0, y = (101 - (lines.Count * 14)) / 2; i < lines.Count; ++i, y += 14 )
{
string s = (string)lines[i];
AddLabel( 130 + ((143 - (s.Length * 8)) / 2), y, 0, s );
}
}
}
if ( !isFriend )
return;
AddHtmlLocalized( 55, 103, 75, 20, 1011233, false, false ); // INFO
AddButton( 20, 103, 4005, 4007, 0, GumpButtonType.Page, 1 );
AddHtmlLocalized( 170, 103, 75, 20, 1011234, false, false ); // FRIENDS
AddButton( 135, 103, 4005, 4007, 0, GumpButtonType.Page, 2 );
AddHtmlLocalized( 295, 103, 75, 20, 1011235, false, false ); // OPTIONS
AddButton( 260, 103, 4005, 4007, 0, GumpButtonType.Page, 3 );
AddHtmlLocalized( 295, 390, 75, 20, 1011441, false, false ); // EXIT
AddButton( 260, 390, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 390, 200, 20, 1011236, false, false ); // Change this house's name!
AddButton( 20, 390, 4005, 4007, 1, GumpButtonType.Reply, 0 );
// Info page
AddPage( 1 );
AddHtmlLocalized( 20, 135, 100, 20, 1011242, false, false ); // Owned by:
AddHtml( 120, 135, 100, 20, GetOwnerName(), false, false );
AddHtmlLocalized( 20, 170, 275, 20, 1011237, false, false ); // Number of locked down items:
AddHtml( 320, 170, 50, 20, m_House.LockDownCount.ToString(), false, false );
AddHtmlLocalized( 20, 190, 275, 20, 1011238, false, false ); // Maximum locked down items:
AddHtml( 320, 190, 50, 20, m_House.MaxLockDowns.ToString(), false, false );
AddHtmlLocalized( 20, 210, 275, 20, 1011239, false, false ); // Number of secure containers:
AddHtml( 320, 210, 50, 20, m_House.SecureCount.ToString(), false, false );
AddHtmlLocalized( 20, 230, 275, 20, 1011240, false, false ); // Maximum number of secure containers:
AddHtml( 320, 230, 50, 20, m_House.MaxSecures.ToString(), false, false );
AddHtmlLocalized( 20, 260, 400, 20, 1018032, false, false ); // This house is properly placed.
AddHtmlLocalized( 20, 280, 400, 20, 1018035, false, false ); // This house is of modern design.
if ( m_House.Public )
{
// TODO: Validate exact placement
AddHtmlLocalized( 20, 305, 275, 20, 1011241, false, false ); // Number of visits this building has had
AddHtml( 320, 305, 50, 20, m_House.Visits.ToString(), false, false );
}
// Friends page
AddPage( 2 );
AddHtmlLocalized( 45, 130, 150, 20, 1011266, false, false ); // List of co-owners
AddButton( 20, 130, 2714, 2715, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 150, 150, 20, 1011267, false, false ); // Add a co-owner
AddButton( 20, 150, 2714, 2715, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 170, 150, 20, 1018036, false, false ); // Remove a co-owner
AddButton( 20, 170, 2714, 2715, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 190, 150, 20, 1011268, false, false ); // Clear co-owner list
AddButton( 20, 190, 2714, 2715, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 225, 130, 155, 20, 1011243, false, false ); // List of Friends
AddButton( 200, 130, 2714, 2715, 6, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 225, 150, 155, 20, 1011244, false, false ); // Add a Friend
AddButton( 200, 150, 2714, 2715, 7, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 225, 170, 155, 20, 1018037, false, false ); // Remove a Friend
AddButton( 200, 170, 2714, 2715, 8, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 225, 190, 155, 20, 1011245, false, false ); // Clear Friends list
AddButton( 200, 190, 2714, 2715, 9, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 120, 215, 280, 20, 1011258, false, false ); // Ban someone from the house
AddButton( 95, 215, 2714, 2715, 10, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 120, 235, 280, 20, 1011259, false, false ); // Eject someone from the house
AddButton( 95, 235, 2714, 2715, 11, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 120, 255, 280, 20, 1011260, false, false ); // View a list of banned people
AddButton( 95, 255, 2714, 2715, 12, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 120, 275, 280, 20, 1011261, false, false ); // Lift a ban
AddButton( 95, 275, 2714, 2715, 13, GumpButtonType.Reply, 0 );
// Options page
AddPage( 3 );
AddHtmlLocalized( 45, 150, 355, 30, 1011248, false, false ); // Transfer ownership of the house
AddButton( 20, 150, 2714, 2715, 14, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 180, 355, 30, 1011249, false, false ); // Demolish house and get deed back
AddButton( 20, 180, 2714, 2715, 15, GumpButtonType.Reply, 0 );
if ( !m_House.Public )
{
AddHtmlLocalized( 45, 210, 355, 30, 1011247, false, false ); // Change the house locks
AddButton( 20, 210, 2714, 2715, 16, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 240, 350, 90, 1011253, false, false ); // Declare this building to be public. This will make your front door unlockable.
AddButton( 20, 240, 2714, 2715, 17, GumpButtonType.Reply, 0 );
}
else
{
//AddHtmlLocalized( 45, 280, 350, 30, 1011250, false, false ); // Change the sign type
AddHtmlLocalized( 45, 210, 350, 30, 1011250, false, false ); // Change the sign type
AddButton( 20, 210, 2714, 2715, 0, GumpButtonType.Page, 4 );
AddHtmlLocalized( 45, 240, 350, 30, 1011252, false, false ); // Declare this building to be private.
AddButton( 20, 240, 2714, 2715, 17, GumpButtonType.Reply, 0 );
// Change the sign type
AddPage( 4 );
for ( int i = 0; i < 24; ++i )
{
AddRadio( 53 + ((i / 4) * 50), 137 + ((i % 4) * 35), 210, 211, false, i + 1 );
AddItem( 60 + ((i / 4) * 50), 130 + ((i % 4) * 35), 2980 + (i * 2) );
}
AddHtmlLocalized( 200, 305, 129, 20, 1011254, false, false ); // Guild sign choices
AddButton( 350, 305, 252, 253, 0, GumpButtonType.Page, 5 );
AddHtmlLocalized( 200, 340, 355, 30, 1011277, false, false ); // Okay that is fine.
AddButton( 350, 340, 4005, 4007, 18, GumpButtonType.Reply, 0 );
AddPage( 5 );
for ( int i = 0; i < 29; ++i )
{
AddRadio( 53 + ((i / 5) * 50), 137 + ((i % 5) * 35), 210, 211, false, i + 25 );
AddItem( 60 + ((i / 5) * 50), 130 + ((i % 5) * 35), 3028 + (i * 2) );
}
AddHtmlLocalized( 200, 305, 129, 20, 1011255, false, false ); // Shop sign choices
AddButton( 350, 305, 250, 251, 0, GumpButtonType.Page, 4 );
AddHtmlLocalized( 200, 340, 355, 30, 1011277, false, false ); // Okay that is fine.
AddButton( 350, 340, 4005, 4007, 18, GumpButtonType.Reply, 0 );
}
}
private string GetOwnerName()
{
Mobile m = m_House.Owner;
if ( m == null )
return "(unowned)";
string name;
if ( (name = m.Name) == null || (name = name.Trim()).Length <= 0 )
name = "(no name)";
return name;
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( m_House.Deleted )
return;
Mobile from = sender.Mobile;
bool isCombatRestricted = m_House.IsCombatRestricted( from );
bool isOwner = m_House.IsOwner( from );
bool isCoOwner = isOwner || m_House.IsCoOwner( from );
bool isFriend = isCoOwner || m_House.IsFriend( from );
if ( isCombatRestricted )
isFriend = isCoOwner = isOwner = false;
if ( !isFriend || !from.Alive )
return;
Item sign = m_House.Sign;
if ( sign == null || from.Map != sign.Map || !from.InRange( sign.GetWorldLocation(), 18 ) )
return;
switch ( info.ButtonID )
{
case 1: // Rename sign
{
from.Prompt = new RenamePrompt( m_House );
from.SendLocalizedMessage( 501302 ); // What dost thou wish the sign to say?
break;
}
case 2: // List of co-owners
{
from.CloseGump( typeof( HouseGump ) );
from.CloseGump( typeof( HouseListGump ) );
from.CloseGump( typeof( HouseRemoveGump ) );
from.SendGump( new HouseListGump( 1011275, m_House.CoOwners, m_House, false ) );
break;
}
case 3: // Add co-owner
{
if ( isOwner )
{
from.SendLocalizedMessage( 501328 ); // Target the person you wish to name a co-owner of your household.
from.Target = new CoOwnerTarget( true, m_House );
}
else
{
from.SendLocalizedMessage( 501327 ); // Only the house owner may add Co-owners.
}
break;
}
case 4: // Remove co-owner
{
if ( isOwner )
{
from.CloseGump( typeof( HouseGump ) );
from.CloseGump( typeof( HouseListGump ) );
from.CloseGump( typeof( HouseRemoveGump ) );
from.SendGump( new HouseRemoveGump( 1011274, m_House.CoOwners, m_House, false ) );
}
else
{
from.SendLocalizedMessage( 501329 ); // Only the house owner may remove co-owners.
}
break;
}
case 5: // Clear co-owners
{
if ( isOwner )
{
if ( m_House.CoOwners != null )
m_House.CoOwners.Clear();
from.SendLocalizedMessage( 501333 ); // All co-owners have been removed from this house.
}
else
{
from.SendLocalizedMessage( 501330 ); // Only the house owner may remove co-owners.
}
break;
}
case 6: // List friends
{
from.CloseGump( typeof( HouseGump ) );
from.CloseGump( typeof( HouseListGump ) );
from.CloseGump( typeof( HouseRemoveGump ) );
from.SendGump( new HouseListGump( 1011273, m_House.Friends, m_House, false ) );
break;
}
case 7: // Add friend
{
if ( isCoOwner )
{
from.SendLocalizedMessage( 501317 ); // Target the person you wish to name a friend of your household.
from.Target = new HouseFriendTarget( true, m_House );
}
else
{
from.SendLocalizedMessage( 501316 ); // Only the house owner may add friends.
}
break;
}
case 8: // Remove friend
{
if ( isCoOwner )
{
from.CloseGump( typeof( HouseGump ) );
from.CloseGump( typeof( HouseListGump ) );
from.CloseGump( typeof( HouseRemoveGump ) );
from.SendGump( new HouseRemoveGump( 1011272, m_House.Friends, m_House, false ) );
}
else
{
from.SendLocalizedMessage( 501318 ); // Only the house owner may remove friends.
}
break;
}
case 9: // Clear friends
{
if ( isCoOwner )
{
if ( m_House.Friends != null )
m_House.Friends.Clear();
from.SendLocalizedMessage( 501332 ); // All friends have been removed from this house.
}
else
{
from.SendLocalizedMessage( 501319 ); // Only the house owner may remove friends.
}
break;
}
case 10: // Ban
{
from.SendLocalizedMessage( 501325 ); // Target the individual to ban from this house.
from.Target = new HouseBanTarget( true, m_House );
break;
}
case 11: // Eject
{
from.SendLocalizedMessage( 501326 ); // Target the individual to eject from this house.
from.Target = new HouseKickTarget( m_House );
break;
}
case 12: // List bans
{
from.CloseGump( typeof( HouseGump ) );
from.CloseGump( typeof( HouseListGump ) );
from.CloseGump( typeof( HouseRemoveGump ) );
from.SendGump( new HouseListGump( 1011271, m_House.Bans, m_House, true ) );
break;
}
case 13: // Remove ban
{
from.CloseGump( typeof( HouseGump ) );
from.CloseGump( typeof( HouseListGump ) );
from.CloseGump( typeof( HouseRemoveGump ) );
from.SendGump( new HouseRemoveGump( 1011269, m_House.Bans, m_House, true ) );
break;
}
case 14: // Transfer ownership
{
if ( isOwner )
{
from.SendLocalizedMessage( 501309 ); // Target the person to whom you wish to give this house.
from.Target = new HouseOwnerTarget( m_House );
}
else
{
from.SendLocalizedMessage( 501310 ); // Only the house owner may do this.
}
break;
}
case 15: // Demolish house
{
if ( isOwner )
{
if ( !Guilds.Guild.NewGuildSystem && m_House.FindGuildstone() != null )
{
from.SendLocalizedMessage( 501389 ); // You cannot redeed a house with a guildstone inside.
}
else
{
from.CloseGump( typeof( HouseDemolishGump ) );
from.SendGump( new HouseDemolishGump( from, m_House ) );
}
}
else
{
from.SendLocalizedMessage( 501320 ); // Only the house owner may do this.
}
break;
}
case 16: // Change locks
{
if ( m_House.Public )
{
from.SendLocalizedMessage( 501669 );// Public houses are always unlocked.
}
else
{
if ( isOwner )
{
m_House.RemoveKeys( from );
m_House.ChangeLocks( from );
from.SendLocalizedMessage( 501306 ); // The locks on your front door have been changed, and new master keys have been placed in your inn chest and your backpack.
}
else
{
from.SendLocalizedMessage( 501303 ); // Only the house owner may change the house locks.
}
}
break;
}
case 17: // Declare public/private
{
if ( isOwner )
{
if ( m_House.Public && m_House.PlayerVendors.Count > 0 )
{
from.SendLocalizedMessage( 501887 ); // You have vendors working out of this building. It cannot be declared private until there are no vendors in place.
break;
}
m_House.Public = !m_House.Public;
if ( !m_House.Public )
{
m_House.ChangeLocks( from );
from.SendLocalizedMessage( 501888 ); // This house is now private.
from.SendLocalizedMessage( 501306 ); // The locks on your front door have been changed, and new master keys have been placed in your inn chest and your backpack.
}
else
{
m_House.RemoveKeys( from );
m_House.RemoveLocks();
from.SendLocalizedMessage( 501886 );//This house is now public. Friends of the house my now have vendors working out of this building.
}
}
else
{
from.SendLocalizedMessage( 501307 ); // Only the house owner may do this.
}
break;
}
case 18: // Change type
{
if ( isOwner )
{
if ( m_House.Public && info.Switches.Length > 0 )
{
int index = info.Switches[0] - 1;
if ( index >= 0 && index < 53 )
m_House.ChangeSignType( 2980 + (index * 2) );
}
}
else
{
from.SendLocalizedMessage( 501307 ); // Only the house owner may do this.
}
break;
}
}
}
}
}
namespace Server.Prompts
{
public class RenamePrompt : Prompt
{
private BaseHouse m_House;
public RenamePrompt( BaseHouse house )
{
m_House = house;
}
public override void OnResponse( Mobile from, string text )
{
if ( m_House.IsFriend( from ) )
{
if ( m_House.Sign != null )
m_House.Sign.Name = text;
from.SendMessage( "Sign changed." );
}
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,66 @@
using System;
using Server;
using Server.Items;
using Server.Multis;
using Server.Multis.Deeds;
using Server.Network;
namespace Server.Gumps
{
public class HouseTransferGump : Gump
{
private Mobile m_From, m_To;
private BaseHouse m_House;
public HouseTransferGump( Mobile from, Mobile to, BaseHouse house ) : base( 110, 100 )
{
m_From = from;
m_To = to;
m_House = house;
Closable = false;
AddPage( 0 );
AddBackground( 0, 0, 420, 280, 5054 );
AddImageTiled( 10, 10, 400, 20, 2624 );
AddAlphaRegion( 10, 10, 400, 20 );
AddHtmlLocalized( 10, 10, 400, 20, 1060635, 30720, false, false ); // <CENTER>WARNING</CENTER>
AddImageTiled( 10, 40, 400, 200, 2624 );
AddAlphaRegion( 10, 40, 400, 200 );
/* Another player is attempting to initiate a house trade with you.
* In order for you to see this window, both you and the other person are standing within two paces of the house to be traded.
* If you click OKAY below, a house trade scroll will appear in your trade window and you can complete the transaction.
* This scroll is a distinctive blue color and will show the name of the house, the name of the owner of that house, and the sextant coordinates of the center of the house when you hover your mouse over it.
* In order for the transaction to be successful, you both must accept the trade and you both must remain within two paces of the house sign.
* <BR><BR>Accepting this house in trade will <a href = "?ForceTopic97">condemn</a> any and all of your other houses that you may have.
* All of your houses on <U>all shards</U> will be affected.
* <BR><BR>In addition, you will not be able to place another house or have one transferred to you for one (1) real-life week.<BR><BR>
* Once you accept these terms, these effects cannot be reversed.
* Re-deeding or transferring your new house will <U>not</U> uncondemn your other house(s) nor will the one week timer be removed.<BR><BR>
* If you are absolutely certain you wish to proceed, click the button next to OKAY below.
* If you do not wish to trade for this house, click CANCEL.
*/
AddHtmlLocalized( 10, 40, 400, 200, 1062086, 32512, false, true );
AddImageTiled( 10, 250, 400, 20, 2624 );
AddAlphaRegion( 10, 250, 400, 20 );
AddButton( 10, 250, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 40, 250, 170, 20, 1011036, 32767, false, false ); // OKAY
AddButton( 210, 250, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 240, 250, 170, 20, 1011012, 32767, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( info.ButtonID == 1 && !m_House.Deleted )
m_House.EndConfirmTransfer( m_From, m_To );
}
}
}

View file

@ -0,0 +1,48 @@
using System;
using Server;
namespace Server.Gumps
{
public delegate void NoticeGumpCallback( Mobile from, object state );
public class NoticeGump : Gump
{
private NoticeGumpCallback m_Callback;
private object m_State;
public NoticeGump( int header, int headerColor, object content, int contentColor, int width, int height, NoticeGumpCallback callback, object state ) : base( (640 - width) / 2, (480 - height) / 2 )
{
m_Callback = callback;
m_State = state;
Closable = false;
AddPage( 0 );
AddBackground( 0, 0, width, height, 5054 );
AddImageTiled( 10, 10, width - 20, 20, 2624 );
AddAlphaRegion( 10, 10, width - 20, 20 );
AddHtmlLocalized( 10, 10, width - 20, 20, header, headerColor, false, false );
AddImageTiled( 10, 40, width - 20, height - 80, 2624 );
AddAlphaRegion( 10, 40, width - 20, height - 80 );
if ( content is int )
AddHtmlLocalized( 10, 40, width - 20, height - 80, (int)content, contentColor, false, true );
else if ( content is string )
AddHtml( 10, 40, width - 20, height - 80, String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", contentColor, content ), false, true );
AddImageTiled( 10, height - 30, width - 20, 20, 2624 );
AddAlphaRegion( 10, height - 30, width - 20, 20 );
AddButton( 10, height - 30, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 40, height - 30, 120, 20, 1011036, 32767, false, false ); // OKAY
}
public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
{
if ( info.ButtonID == 1 && m_Callback != null )
m_Callback( sender.Mobile, m_State );
}
}
}

View file

@ -0,0 +1,79 @@
using System;
using Server;
using Server.Mobiles;
using Server.Network;
using Server.Gumps;
namespace Server.Gumps
{
public class PetResurrectGump : Gump
{
private BaseCreature m_Pet;
private double m_HitsScalar;
public PetResurrectGump( Mobile from, BaseCreature pet )
: this( from, pet, 0.0 )
{
}
public PetResurrectGump( Mobile from, BaseCreature pet, double hitsScalar ) : base( 50, 50 )
{
from.CloseGump( typeof( PetResurrectGump ) );
m_Pet = pet;
m_HitsScalar = hitsScalar;
AddPage( 0 );
AddBackground( 10, 10, 265, 140, 0x242C );
AddItem( 205, 40, 0x4 );
AddItem( 227, 40, 0x5 );
AddItem( 180, 78, 0xCAE );
AddItem( 195, 90, 0xCAD );
AddItem( 218, 95, 0xCB0 );
AddHtmlLocalized( 30, 30, 150, 75, 1049665, false, false ); // <div align=center>Wilt thou sanctify the resurrection of:</div>
AddHtml( 30, 70, 150, 25, String.Format( "<div align=CENTER>{0}</div>", pet.Name ), true, false );
AddButton( 40, 105, 0x81A, 0x81B, 0x1, GumpButtonType.Reply, 0 ); // Okay
AddButton( 110, 105, 0x819, 0x818, 0x2, GumpButtonType.Reply, 0 ); // Cancel
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( m_Pet.Deleted || !m_Pet.IsBonded || !m_Pet.IsDeadPet )
return;
Mobile from = state.Mobile;
if ( info.ButtonID == 1 )
{
if ( m_Pet.Map == null || !m_Pet.Map.CanFit( m_Pet.Location, 16, false, false ) )
{
from.SendLocalizedMessage( 503256 ); // You fail to resurrect the creature.
return;
}
m_Pet.PlaySound( 0x214 );
m_Pet.FixedEffect( 0x376A, 10, 16 );
m_Pet.ResurrectPet();
double decreaseAmount;
if( from == m_Pet.ControlMaster )
decreaseAmount = 0.1;
else
decreaseAmount = 0.2;
for ( int i = 0; i < m_Pet.Skills.Length; ++i ) //Decrease all skills on pet.
m_Pet.Skills[i].Base -= decreaseAmount;
if( !m_Pet.IsDeadPet && m_HitsScalar > 0 )
m_Pet.Hits = (int)(m_Pet.HitsMax * m_HitsScalar);
}
}
}
}

View file

@ -0,0 +1,977 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using Server;
using Server.Mobiles;
using Server.Items;
using Server.Network;
using Server.HuePickers;
using Server.Multis;
namespace Server.Gumps
{
public class PlayerVendorBuyGump : Gump
{
private PlayerVendor m_Vendor;
private VendorItem m_VI;
public PlayerVendorBuyGump( PlayerVendor vendor, VendorItem vi ) : base( 100, 200 )
{
m_Vendor = vendor;
m_VI = vi;
AddBackground( 100, 10, 300, 150, 5054 );
AddHtmlLocalized( 125, 20, 250, 24, 1019070, false, false ); // You have agreed to purchase:
if ( !String.IsNullOrEmpty( vi.Description ) )
AddLabel( 125, 45, 0, vi.Description );
else
AddHtmlLocalized( 125, 45, 250, 24, 1019072, false, false ); // an item without a description
AddHtmlLocalized( 125, 70, 250, 24, 1019071, false, false ); // for the amount of:
AddLabel( 125, 95, 0, vi.Price.ToString() );
AddButton( 250, 130, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 282, 130, 100, 24, 1011012, false, false ); // CANCEL
AddButton( 120, 130, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 152, 130, 100, 24, 1011036, false, false ); // OKAY
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
if ( !m_Vendor.CanInteractWith( from, false ) )
return;
if ( m_Vendor.IsOwner( from ) )
{
m_Vendor.SayTo( from, 503212 ); // You own this shop, just take what you want.
return;
}
if ( info.ButtonID == 1 )
{
m_Vendor.Say( from.Name );
if ( !m_VI.Valid || !m_VI.Item.IsChildOf( m_Vendor.Backpack ) )
{
m_Vendor.SayTo( from, 503216 ); // You can't buy that.
return;
}
int totalGold = 0;
if ( from.Backpack != null )
totalGold += from.Backpack.GetAmount( typeof( Gold ) );
totalGold += Innkeeper.GetBalance( from );
if ( totalGold < m_VI.Price )
{
m_Vendor.SayTo( from, 503205 ); // You cannot afford this item.
}
else if ( !from.PlaceInBackpack( m_VI.Item ) )
{
m_Vendor.SayTo( from, 503204 ); // You do not have room in your backpack for this.
}
else
{
int leftPrice = m_VI.Price;
if ( from.Backpack != null )
leftPrice -= from.Backpack.ConsumeUpTo( typeof( Gold ), leftPrice );
if ( leftPrice > 0 )
Innkeeper.Withdraw( from, leftPrice );
m_Vendor.HoldGold += m_VI.Price;
from.SendLocalizedMessage( 503201 ); // You take the item.
}
}
else
{
from.SendLocalizedMessage( 503207 ); // Cancelled purchase.
}
}
}
public class PlayerVendorOwnerGump : Gump
{
private PlayerVendor m_Vendor;
public PlayerVendorOwnerGump( PlayerVendor vendor ) : base( 50, 200 )
{
m_Vendor = vendor;
int perDay = m_Vendor.ChargePerDay;
AddPage( 0 );
AddBackground( 25, 10, 530, 140, 5054 );
AddHtmlLocalized( 425, 25, 120, 20, 1019068, false, false ); // See goods
AddButton( 390, 25, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 425, 48, 120, 20, 1019069, false, false ); // Customize
AddButton( 390, 48, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 425, 72, 120, 20, 1011012, false, false ); // CANCEL
AddButton( 390, 71, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 40, 72, 260, 20, 1038321, false, false ); // Gold held for you:
AddLabel( 300, 72, 0, m_Vendor.HoldGold.ToString() );
AddHtmlLocalized( 40, 96, 260, 20, 1038322, false, false ); // Gold held in my account:
AddLabel( 300, 96, 0, m_Vendor.BankAccount.ToString() );
//AddHtmlLocalized( 40, 120, 260, 20, 1038324, false, false ); // My charge per day is:
// Localization has changed, we must use a string here
AddHtml( 40, 120, 260, 20, "My charge per day is:", false, false );
AddLabel( 300, 120, 0, perDay.ToString() );
double days = (m_Vendor.HoldGold + m_Vendor.BankAccount) / ((double)perDay);
AddHtmlLocalized( 40, 25, 260, 20, 1038318, false, false ); // Amount of days I can work:
AddLabel( 300, 25, 0, ((int)days).ToString() );
AddHtmlLocalized( 40, 48, 260, 20, 1038319, false, false ); // Earth days:
AddLabel( 300, 48, 0, ((int)(days / 12.0)).ToString() );
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
if ( !m_Vendor.CanInteractWith( from, true ) )
return;
switch ( info.ButtonID )
{
case 1:
{
m_Vendor.OpenBackpack( from );
break;
}
case 2:
{
from.SendGump( new PlayerVendorCustomizeGump( m_Vendor, from ) );
break;
}
}
}
}
public class NewPlayerVendorOwnerGump : Gump
{
private PlayerVendor m_Vendor;
public NewPlayerVendorOwnerGump( PlayerVendor vendor ) : base( 50, 200 )
{
m_Vendor = vendor;
int perRealWorldDay = vendor.ChargePerRealWorldDay;
int goldHeld = vendor.HoldGold;
AddBackground( 25, 10, 530, 180, 0x13BE );
AddImageTiled( 35, 20, 510, 160, 0xA40 );
AddAlphaRegion( 35, 20, 510, 160 );
AddImage( 10, 0, 0x28DC );
AddImage( 537, 175, 0x28DC );
AddImage( 10, 175, 0x28DC );
AddImage( 537, 0, 0x28DC );
if ( goldHeld < perRealWorldDay )
{
int goldNeeded = perRealWorldDay - goldHeld;
AddHtmlLocalized( 40, 35, 260, 20, 1038320, 0x7FFF, false, false ); // Gold needed for 1 day of vendor salary:
AddLabel( 300, 35, 0x1F, goldNeeded.ToString() );
}
else
{
int days = goldHeld / perRealWorldDay;
AddHtmlLocalized( 40, 35, 260, 20, 1038318, 0x7FFF, false, false ); // # of days Vendor salary is paid for:
AddLabel( 300, 35, 0x480, days.ToString() );
}
AddHtmlLocalized( 40, 58, 260, 20, 1038324, 0x7FFF, false, false ); // My charge per real world day is:
AddLabel( 300, 58, 0x480, perRealWorldDay.ToString() );
AddHtmlLocalized( 40, 82, 260, 20, 1038322, 0x7FFF, false, false ); // Gold held in my account:
AddLabel( 300, 82, 0x480, goldHeld.ToString() );
AddHtmlLocalized( 40, 108, 260, 20, 1062509, 0x7FFF, false, false ); // Shop Name:
AddLabel( 140, 106, 0x66D, vendor.ShopName );
if ( vendor is RentedVendor )
{
int days, hours;
((RentedVendor)vendor).ComputeRentalExpireDelay( out days, out hours );
AddLabel( 38, 132, 0x480, String.Format( "Location rental will expire in {0} day{1} and {2} hour{3}.", days, days != 1 ? "s" : "", hours, hours != 1 ? "s" : "" ) );
}
AddButton( 390, 24, 0x15E1, 0x15E5, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 408, 21, 120, 20, 1019068, 0x7FFF, false, false ); // See goods
AddButton( 390, 44, 0x15E1, 0x15E5, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 408, 41, 120, 20, 1019069, 0x7FFF, false, false ); // Customize
AddButton( 390, 64, 0x15E1, 0x15E5, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 408, 61, 120, 20, 1062434, 0x7FFF, false, false ); // Rename Shop
AddButton( 390, 84, 0x15E1, 0x15E5, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 408, 81, 120, 20, 3006217, 0x7FFF, false, false ); // Rename Vendor
AddButton( 390, 104, 0x15E1, 0x15E5, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 408, 101, 120, 20, 3006123, 0x7FFF, false, false ); // Open Paperdoll
AddButton( 390, 124, 0x15E1, 0x15E5, 6, GumpButtonType.Reply, 0 );
AddLabel( 408, 121, 0x480, "Collect Gold" );
AddButton( 390, 144, 0x15E1, 0x15E5, 7, GumpButtonType.Reply, 0 );
AddLabel( 408, 141, 0x480, "Dismiss Vendor" );
AddButton( 390, 162, 0x15E1, 0x15E5, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 408, 161, 120, 20, 1011012, 0x7FFF, false, false ); // CANCEL
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
if ( info.ButtonID == 1 || info.ButtonID == 2 ) // See goods or Customize
m_Vendor.CheckTeleport( from );
if ( !m_Vendor.CanInteractWith( from, true ) )
return;
switch ( info.ButtonID )
{
case 1: // See goods
{
m_Vendor.OpenBackpack( from );
break;
}
case 2: // Customize
{
from.SendGump( new NewPlayerVendorCustomizeGump( m_Vendor ) );
break;
}
case 3: // Rename Shop
{
m_Vendor.RenameShop( from );
break;
}
case 4: // Rename Vendor
{
m_Vendor.Rename( from );
break;
}
case 5: // Open Paperdoll
{
m_Vendor.DisplayPaperdollTo( from );
break;
}
case 6: // Collect Gold
{
m_Vendor.CollectGold( from );
break;
}
case 7: // Dismiss Vendor
{
m_Vendor.Dismiss( from );
break;
}
}
}
}
public class PlayerVendorCustomizeGump : Gump
{
private Mobile m_Vendor;
private class CustomItem
{
private Type m_Type;
private int m_ItemID;
private int m_LocNum;
private int m_ArtNum;
private bool m_LongText;
public CustomItem( int itemID, int loc ) : this( null, itemID, loc, 0, false )
{
}
public CustomItem( int itemID, int loc, bool longText ) : this( null, itemID, loc, 0, longText )
{
}
public CustomItem( Type type, int loc ) : this( type, loc, 0 )
{
}
public CustomItem( Type type, int loc, int art ) : this( type, 0, loc, art, false )
{
}
public CustomItem( Type type, int itemID, int loc, int art, bool longText )
{
m_Type = type;
m_ItemID = itemID;
m_LocNum = loc;
m_ArtNum = art;
m_LongText = longText;
}
public Item Create()
{
if ( m_Type == null )
return null;
Item i = null;
try
{
ConstructorInfo ctor = m_Type.GetConstructor( new Type[0] );
if ( ctor != null )
i = ctor.Invoke( null ) as Item;
}
catch
{
}
return i;
}
public Type Type{ get{ return m_Type; } }
public int ItemID{ get{ return m_ItemID; } }
public int LocNumber{ get{ return m_LocNum; } }
public int ArtNumber{ get{ return m_ArtNum; } }
public bool LongText{ get{ return m_LongText; } }
}
private class CustomCategory
{
private CustomItem[] m_Entries;
private Layer m_Layer;
private bool m_CanDye;
private int m_LocNum;
public CustomCategory( Layer layer, int loc, bool canDye, CustomItem[] items )
{
m_Entries = items;
m_CanDye = canDye;
m_Layer = layer;
m_LocNum = loc;
}
public bool CanDye{ get{ return m_CanDye; } }
public CustomItem[] Entries{ get{ return m_Entries; } }
public Layer Layer{ get{ return m_Layer; } }
public int LocNumber{ get{ return m_LocNum; } }
}
private static CustomCategory[] Categories = new CustomCategory[]{
new CustomCategory( Layer.InnerTorso, 1011357, true, new CustomItem[]{// Upper Torso
new CustomItem( typeof( Shirt ), 1011359, 5399 ),
new CustomItem( typeof( FancyShirt ), 1011360, 7933 ),
new CustomItem( typeof( PlainDress ), 1011363, 7937 ),
new CustomItem( typeof( FancyDress ), 1011364, 7935 ),
new CustomItem( typeof( Robe ), 1011365, 7939 )
} ),
new CustomCategory( Layer.MiddleTorso, 1011371, true, new CustomItem[]{//Over chest
new CustomItem( typeof( Doublet ), 1011358, 8059 ),
new CustomItem( typeof( Tunic ), 1011361, 8097 ),
new CustomItem( typeof( JesterSuit ), 1011366, 8095 ),
new CustomItem( typeof( BodySash ), 1011372, 5441 ),
new CustomItem( typeof( Surcoat ), 1011362, 8189 ),
new CustomItem( typeof( HalfApron ), 1011373, 5435 ),
new CustomItem( typeof( FullApron ), 1011374, 5437 ),
} ),
new CustomCategory( Layer.Shoes, 1011388, true, new CustomItem[]{//Footwear
new CustomItem( typeof( Sandals ), 1011389, 5901 ),
new CustomItem( typeof( Shoes ), 1011390, 5904 ),
new CustomItem( typeof( Boots ), 1011391, 5899 ),
new CustomItem( typeof( ThighBoots ), 1011392, 5906 ),
} ),
new CustomCategory( Layer.Helm, 1011375, true, new CustomItem[]{//Hats
new CustomItem( typeof( SkullCap ), 1011376, 5444 ),
new CustomItem( typeof( Bandana ), 1011377, 5440 ),
new CustomItem( typeof( FloppyHat ), 1011378, 5907 ),
new CustomItem( typeof( WideBrimHat ), 1011379, 5908 ),
new CustomItem( typeof( Cap ), 1011380, 5909 ),
new CustomItem( typeof( TallStrawHat ), 1011382, 5910 )
} ),
new CustomCategory( Layer.Helm, 1015319, true, new CustomItem[]{//More Hats
new CustomItem( typeof( StrawHat ), 1011382, 5911 ),
new CustomItem( typeof( WizardsHat ), 1011383, 5912 ),
new CustomItem( typeof( Bonnet ), 1011384, 5913 ),
new CustomItem( typeof( FeatheredHat ), 1011385, 5914 ),
new CustomItem( typeof( TricorneHat ), 1011386, 5915 ),
new CustomItem( typeof( JesterHat ), 1011387, 5916 )
} ),
new CustomCategory( Layer.Pants, 1011367, true, new CustomItem[]{ //Lower Torso
new CustomItem( typeof( LongPants ), 1011368, 5433 ),
new CustomItem( typeof( Kilt ), 1011369, 5431 ),
new CustomItem( typeof( Skirt ), 1011370, 5398 ),
} ),
new CustomCategory( Layer.Cloak, 1011393, true, new CustomItem[]{ // Back
new CustomItem( typeof( Cloak ), 1011394, 5397 )
} ),
new CustomCategory( Layer.Hair, 1011395, true, new CustomItem[]{ // Hair
new CustomItem( 0x203B, 1011052 ),
new CustomItem( 0x203C, 1011053 ),
new CustomItem( 0x203D, 1011054 ),
new CustomItem( 0x2044, 1011055 ),
new CustomItem( 0x2045, 1011047 ),
new CustomItem( 0x204A, 1011050 ),
new CustomItem( 0x2047, 1011396 ),
new CustomItem( 0x2048, 1011048 ),
new CustomItem( 0x2049, 1011049 ),
} ),
new CustomCategory( Layer.FacialHair, 1015320, true, new CustomItem[]{//Facial Hair
new CustomItem( 0x2041, 1011062 ),
new CustomItem( 0x203F, 1011060 ),
new CustomItem( 0x204B, 1015321, true ),
new CustomItem( 0x203E, 1011061 ),
new CustomItem( 0x204C, 1015322, true ),
new CustomItem( 0x2040, 1015323 ),
new CustomItem( 0x204D, 1011401 ),
} ),
new CustomCategory( Layer.FirstValid, 1011397, false, new CustomItem[]{//Held items
new CustomItem( typeof( FishingPole ), 1011406, 3520 ),
new CustomItem( typeof( Pickaxe ), 1011407, 3717 ),
new CustomItem( typeof( Pitchfork ), 1011408, 3720 ),
new CustomItem( typeof( Cleaver ), 1015324, 3778 ),
new CustomItem( typeof( Mace ), 1011409, 3933 ),
new CustomItem( typeof( Torch ), 1011410, 3940 ),
new CustomItem( typeof( Hammer ), 1011411, 4020 ),
new CustomItem( typeof( Longsword ), 1011412, 3936 ),
new CustomItem( typeof( GnarledStaff ), 1011413, 5113 )
} ),
new CustomCategory( Layer.FirstValid, 1015325, false, new CustomItem[]{//More held items
new CustomItem( typeof( Crossbow ), 1011414, 3920 ),
new CustomItem( typeof( WarMace ), 1011415, 5126 ),
new CustomItem( typeof( TwoHandedAxe ), 1011416, 5186 ),
new CustomItem( typeof( Spear ), 1011417, 3939 ),
new CustomItem( typeof( Katana ), 1011418, 5118 ),
new CustomItem( typeof( Spellbook ), 1011419, 3834 )
} )
};
public PlayerVendorCustomizeGump( Mobile v, Mobile from ) : base( 30, 40 )
{
m_Vendor = v;
int x,y;
from.CloseGump( typeof( PlayerVendorCustomizeGump ) );
AddPage( 0 );
AddBackground( 0, 0, 585, 393, 5054 );
AddBackground( 195, 36, 387, 275, 3000 );
AddHtmlLocalized( 10, 10, 565, 18, 1011356, false, false ); // <center>VENDOR CUSTOMIZATION MENU</center>
AddHtmlLocalized( 60, 355, 150, 18, 1011036, false, false ); // OKAY
AddButton( 25, 355, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 320, 355, 150, 18, 1011012, false, false ); // CANCEL
AddButton( 285, 355, 4005, 4007, 0, GumpButtonType.Reply, 0 );
y = 35;
for ( int i=0;i<Categories.Length;i++ )
{
CustomCategory cat = (CustomCategory)Categories[i];
AddHtmlLocalized( 5, y, 150, 25, cat.LocNumber, true, false );
AddButton( 155, y, 4005, 4007, 0, GumpButtonType.Page, i+1 );
y += 25;
}
for ( int i=0;i<Categories.Length;i++ )
{
CustomCategory cat = (CustomCategory)Categories[i];
AddPage( i+1 );
for ( int c=0;c<cat.Entries.Length;c++ )
{
CustomItem entry = (CustomItem)cat.Entries[c];
x = 198 + (c%3)*129;
y = 38 + (c/3)*67;
AddHtmlLocalized( x, y, 100, entry.LongText ? 36 : 18, entry.LocNumber, false, false );
if ( entry.ArtNumber != 0 )
AddItem( x+20, y+25, entry.ArtNumber );
AddRadio( x, y + (entry.LongText ? 40 : 20), 210, 211, false, (c<<8) + i );
}
if ( cat.CanDye )
{
AddHtmlLocalized( 327, 239, 100, 18, 1011402, false, false ); // Color
AddRadio( 327, 259, 210, 211, false, 100+i );
}
AddHtmlLocalized( 456, 239, 100, 18, 1011403, false, false ); // Remove
AddRadio( 456, 259, 210, 211, false, 200+i );
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( m_Vendor.Deleted )
return;
Mobile from = state.Mobile;
if ( m_Vendor is PlayerVendor && !((PlayerVendor)m_Vendor).CanInteractWith( from, true ) )
return;
if ( m_Vendor is PlayerBarkeeper && !((PlayerBarkeeper)m_Vendor).IsOwner( from ) )
return;
if ( info.ButtonID == 0 )
{
if ( m_Vendor is PlayerVendor ) // do nothing for barkeeps
{
m_Vendor.Direction = m_Vendor.GetDirectionTo( from );
m_Vendor.Animate( 32, 5, 1, true, false, 0 );//bow
m_Vendor.SayTo( from, 1043310 + Utility.Random( 12 ) ); // a little random speech
}
}
else if ( info.ButtonID == 1 && info.Switches.Length > 0 )
{
int cnum = info.Switches[0];
int cat = cnum%256;
int ent = cnum>>8;
if ( cat < Categories.Length && cat >= 0 )
{
if ( ent < Categories[cat].Entries.Length && ent >= 0 )
{
Item item = m_Vendor.FindItemOnLayer( Categories[cat].Layer );
if ( item != null )
item.Delete();
List<Item> items = m_Vendor.Items;
for ( int i = 0; item == null && i < items.Count; ++i )
{
Item checkitem = items[i];
Type type = checkitem.GetType();
for ( int j = 0; item == null && j < Categories[cat].Entries.Length; ++j )
{
if ( type == Categories[cat].Entries[j].Type )
item = checkitem;
}
}
if ( item != null )
item.Delete();
if ( Categories[cat].Layer == Layer.FacialHair )
{
if ( m_Vendor.Female )
from.SendLocalizedMessage( 1010639 ); // You cannot place facial hair on a woman!
else
m_Vendor.FacialHairItemID = Categories[cat].Entries[ent].ItemID;
}
else if ( Categories[cat].Layer == Layer.Hair )
m_Vendor.HairItemID = Categories[cat].Entries[ent].ItemID;
else
{
item = Categories[cat].Entries[ent].Create();
if ( item != null )
{
item.Layer = Categories[cat].Layer;
if ( !m_Vendor.EquipItem( item ) )
item.Delete();
}
}
from.SendGump( new PlayerVendorCustomizeGump( m_Vendor, from ) );
}
}
else
{
cat -= 100;
if ( cat < 100 )
{
if ( cat < Categories.Length && cat >= 0 )
{
Item item = null;
List<Item> items = m_Vendor.Items;
for ( int i = 0; item == null && i < items.Count; ++i )
{
Item checkitem = items[i];
Type type = checkitem.GetType();
for ( int j = 0; item == null && j < Categories[cat].Entries.Length; ++j )
{
if ( type == Categories[cat].Entries[j].Type )
item = checkitem;
}
}
if ( item != null )
new PVHuePicker( item, m_Vendor, from ).SendTo( state );
}
}
else
{
cat -= 100;
if ( cat < Categories.Length && cat >= 0 )
{
Item item = null;
List<Item> items = m_Vendor.Items;
for ( int i = 0; item == null && i < items.Count; ++i )
{
Item checkitem = items[i];
Type type = checkitem.GetType();
for ( int j = 0; item == null && j < Categories[cat].Entries.Length; ++j )
{
if ( type == Categories[cat].Entries[j].Type )
item = checkitem;
}
}
if ( item != null )
item.Delete();
from.SendGump( new PlayerVendorCustomizeGump( m_Vendor, from ) );
}
}
}
}
}
private class PVHuePicker : HuePicker
{
private Item m_Item;
private Mobile m_Vendor;
private Mobile m_Mob;
public PVHuePicker( Item item, Mobile v, Mobile from ) : base( (item.Layer == Layer.Hair || item.Layer == Layer.FacialHair) ? 0xFAB : item.ItemID )
{
m_Vendor = v;
m_Item = item;
m_Mob = from;
}
public override void OnResponse( int hue )
{
if ( m_Item.Deleted )
return;
if ( m_Vendor is PlayerVendor && !((PlayerVendor)m_Vendor).CanInteractWith( m_Mob, true ) )
return;
if ( m_Vendor is PlayerBarkeeper && !((PlayerBarkeeper)m_Vendor).IsOwner( m_Mob ) )
return;
m_Item.Hue = hue;
m_Mob.SendGump( new PlayerVendorCustomizeGump( m_Vendor, m_Mob ) );
}
}
}
public class NewPlayerVendorCustomizeGump : Gump
{
private PlayerVendor m_Vendor;
private class HairOrBeard
{
private int m_ItemID;
private int m_Name;
public int ItemID{ get{ return m_ItemID; } }
public int Name{ get{ return m_Name; } }
public HairOrBeard( int itemID, int name )
{
m_ItemID = itemID;
m_Name = name;
}
}
private static HairOrBeard[] m_HairStyles = new HairOrBeard[]
{
new HairOrBeard( 0x203B, 1011052 ), // Short
new HairOrBeard( 0x203C, 1011053 ), // Long
new HairOrBeard( 0x203D, 1011054 ), // Ponytail
new HairOrBeard( 0x2044, 1011055 ), // Mohawk
new HairOrBeard( 0x2045, 1011047 ), // Pageboy
new HairOrBeard( 0x204A, 1011050 ), // Topknot
new HairOrBeard( 0x2047, 1011396 ), // Curly
new HairOrBeard( 0x2048, 1011048 ), // Receding
new HairOrBeard( 0x2049, 1011049 ) // 2-tails
};
private static HairOrBeard[] m_BeardStyles = new HairOrBeard[]
{
new HairOrBeard( 0x2041, 1011062 ), // Mustache
new HairOrBeard( 0x203F, 1011060 ), // Short beard
new HairOrBeard( 0x204B, 1015321 ), // Short Beard & Moustache
new HairOrBeard( 0x203E, 1011061 ), // Long beard
new HairOrBeard( 0x204C, 1015322 ), // Long Beard & Moustache
new HairOrBeard( 0x2040, 1015323 ), // Goatee
new HairOrBeard( 0x204D, 1011401 ) // Vandyke
};
public NewPlayerVendorCustomizeGump( PlayerVendor vendor ) : base( 50, 50 )
{
m_Vendor = vendor;
AddBackground( 0, 0, 370, 370, 0x13BE );
AddImageTiled( 10, 10, 350, 20, 0xA40 );
AddImageTiled( 10, 40, 350, 20, 0xA40 );
AddImageTiled( 10, 70, 350, 260, 0xA40 );
AddImageTiled( 10, 340, 350, 20, 0xA40 );
AddAlphaRegion( 10, 10, 350, 350 );
AddHtmlLocalized( 10, 12, 350, 18, 1011356, 0x7FFF, false, false ); // <center>VENDOR CUSTOMIZATION MENU</center>
AddHtmlLocalized( 10, 42, 150, 18, 1062459, 0x421F, false, false ); // <CENTER>HAIR</CENTER>
for ( int i = 0; i < m_HairStyles.Length; i++ )
{
HairOrBeard hair = m_HairStyles[i];
AddButton( 10, 70 + i * 20, 0xFA5, 0xFA7, 0x100 | i, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 72 + i * 20, 110, 18, hair.Name, 0x7FFF, false, false );
}
AddButton( 10, 70 + m_HairStyles.Length * 20, 0xFB1, 0xFB3, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 72 + m_HairStyles.Length * 20, 110, 18, 1011403, 0x7FFF, false, false ); // Remove
AddButton( 10, 70 + (m_HairStyles.Length + 1) * 20, 0xFA5, 0xFA7, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 72 + (m_HairStyles.Length + 1) * 20, 110, 18, 1011402, 0x7FFF, false, false ); // Color
if ( vendor.Female )
{
AddButton( 160, 290, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 195, 292, 160, 18, 1015327, 0x7FFF, false, false ); // Male
AddHtmlLocalized( 195, 312, 160, 18, 1015328, 0x421F, false, false ); // Female
}
else
{
AddHtmlLocalized( 160, 42, 210, 18, 1062460, 0x421F, false, false ); // <CENTER>BEARD</CENTER>
for ( int i = 0; i < m_BeardStyles.Length; i++ )
{
HairOrBeard beard = m_BeardStyles[i];
AddButton( 160, 70 + i * 20, 0xFA5, 0xFA7, 0x200 | i, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 195, 72 + i * 20, 160, 18, beard.Name, 0x7FFF, false, false );
}
AddButton( 160, 70 + m_BeardStyles.Length * 20, 0xFB1, 0xFB3, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 195, 72 + m_BeardStyles.Length * 20, 160, 18, 1011403, 0x7FFF, false, false ); // Remove
AddButton( 160, 70 + (m_BeardStyles.Length + 1) * 20, 0xFA5, 0xFA7, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 195, 72 + (m_BeardStyles.Length + 1) * 20, 160, 18, 1011402, 0x7FFF, false, false ); // Color
AddHtmlLocalized( 195, 292, 160, 18, 1015327, 0x421F, false, false ); // Male
AddButton( 160, 310, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 195, 312, 160, 18, 1015328, 0x7FFF, false, false ); // Female
}
AddButton( 10, 340, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 342, 305, 18, 1060675, 0x7FFF, false, false ); // CLOSE
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
if ( !m_Vendor.CanInteractWith( from, true ) )
return;
switch ( info.ButtonID )
{
case 0: // CLOSE
{
m_Vendor.Direction = m_Vendor.GetDirectionTo( from );
m_Vendor.Animate( 32, 5, 1, true, false, 0 ); // bow
m_Vendor.SayTo( from, 1043310 + Utility.Random( 12 ) ); // a little random speech
break;
}
case 1: // Female/Male
{
if ( m_Vendor.Female )
{
m_Vendor.BodyValue = 400;
m_Vendor.Female = false;
}
else
{
m_Vendor.BodyValue = 401;
m_Vendor.Female = true;
m_Vendor.FacialHairItemID = 0;
}
from.SendGump( new NewPlayerVendorCustomizeGump( m_Vendor ) );
break;
}
case 2: // Remove hair
{
m_Vendor.HairItemID = 0;
from.SendGump( new NewPlayerVendorCustomizeGump( m_Vendor ) );
break;
}
case 3: // Color hair
{
if ( m_Vendor.HairItemID > 0 )
{
new PVHuePicker( m_Vendor, false, from ).SendTo( from.NetState );
}
else
{
from.SendGump( new NewPlayerVendorCustomizeGump( m_Vendor ) );
}
break;
}
case 4: // Remove beard
{
m_Vendor.FacialHairItemID = 0;
from.SendGump( new NewPlayerVendorCustomizeGump( m_Vendor ) );
break;
}
case 5: // Color beard
{
if ( m_Vendor.FacialHairItemID > 0 )
{
new PVHuePicker( m_Vendor, true, from ).SendTo( from.NetState );
}
else
{
from.SendGump( new NewPlayerVendorCustomizeGump( m_Vendor ) );
}
break;
}
default:
{
int hairhue = 0;
if ( (info.ButtonID & 0x100) != 0 ) // Hair style selected
{
int index = info.ButtonID & 0xFF;
if ( index >= m_HairStyles.Length )
return;
HairOrBeard hairStyle = m_HairStyles[index];
hairhue = m_Vendor.HairHue;
m_Vendor.HairItemID = 0;
m_Vendor.ProcessDelta();
m_Vendor.HairItemID = hairStyle.ItemID;
m_Vendor.HairHue = hairhue;
from.SendGump( new NewPlayerVendorCustomizeGump( m_Vendor ) );
}
else if ( (info.ButtonID & 0x200) != 0 ) // Beard style selected
{
if ( m_Vendor.Female )
return;
int index = info.ButtonID & 0xFF;
if ( index >= m_BeardStyles.Length )
return;
HairOrBeard beardStyle = m_BeardStyles[index];
hairhue = m_Vendor.FacialHairHue;
m_Vendor.FacialHairItemID = 0;
m_Vendor.ProcessDelta();
m_Vendor.FacialHairItemID = beardStyle.ItemID;
m_Vendor.FacialHairHue = hairhue;
from.SendGump( new NewPlayerVendorCustomizeGump( m_Vendor ) );
}
break;
}
}
}
private class PVHuePicker : HuePicker
{
private PlayerVendor m_Vendor;
private bool m_FacialHair;
private Mobile m_From;
public PVHuePicker( PlayerVendor vendor, bool facialHair, Mobile from ) : base( 0xFAB )
{
m_Vendor = vendor;
m_FacialHair = facialHair;
m_From = from;
}
public override void OnResponse( int hue )
{
if ( !m_Vendor.CanInteractWith( m_From, true ) )
return;
if ( m_FacialHair )
m_Vendor.FacialHairHue = hue;
else
m_Vendor.HairHue = hue;
m_From.SendGump( new NewPlayerVendorCustomizeGump( m_Vendor ) );
}
}
}
}

View file

@ -0,0 +1,243 @@
using System;
using Server;
using Server.Network;
using Server.Targets;
using Server.Spells;
using Server.Spells.Seventh;
namespace Server.Gumps
{
public class PolymorphEntry
{
public static readonly PolymorphEntry Chicken = new PolymorphEntry( 208, 1015236, 15, 10 );
public static readonly PolymorphEntry Dog = new PolymorphEntry( 217, 1015237, 17, 10 );
public static readonly PolymorphEntry Wolf = new PolymorphEntry( 225, 1015238, 18, 10 );
public static readonly PolymorphEntry Panther = new PolymorphEntry( 214, 1015239, 20, 14 );
public static readonly PolymorphEntry Gorilla = new PolymorphEntry( 29, 1015240, 23, 10 );
public static readonly PolymorphEntry BlackBear = new PolymorphEntry( 211, 1015241, 22, 10 );
public static readonly PolymorphEntry GrizzlyBear = new PolymorphEntry( 212, 1015242, 22, 12 );
public static readonly PolymorphEntry PolarBear = new PolymorphEntry( 213, 1015243, 26, 10 );
public static readonly PolymorphEntry HumanMale = new PolymorphEntry( 0x190, 1015244, 29, 8 );
public static readonly PolymorphEntry HumanFemale = new PolymorphEntry( 0x191, 1015254, 29, 10 );
public static readonly PolymorphEntry Slime = new PolymorphEntry( 51, 1015246, 5, 10 );
public static readonly PolymorphEntry Orc = new PolymorphEntry( 17, 1015247, 29, 10 );
public static readonly PolymorphEntry LizardMan = new PolymorphEntry( 33, 1015248, 26, 10 );
public static readonly PolymorphEntry Gargoyle = new PolymorphEntry( 4, 1015249, 22, 10 );
public static readonly PolymorphEntry Ogre = new PolymorphEntry( 1, 1015250, 24, 9 );
public static readonly PolymorphEntry Troll = new PolymorphEntry( 54, 1015251, 25, 9 );
public static readonly PolymorphEntry Ettin = new PolymorphEntry( 2, 1015252, 25, 8 );
public static readonly PolymorphEntry Daemon = new PolymorphEntry( 9, 1015253, 25, 8 );
private int m_Body, m_Num, m_X, m_Y;
private PolymorphEntry( int Body, int LocNum, int X, int Y )
{
m_Body = Body;
m_Num = LocNum;
m_X = X;
m_Y = Y;
}
public int BodyID { get { return m_Body; } }
public int LocNumber{ get { return m_Num; } }
public int X{ get{ return m_X; } }
public int Y{ get{ return m_Y; } }
}
public class PolymorphGump : Gump
{
private class PolymorphCategory
{
private int m_Num;
private PolymorphEntry[] m_Entries;
public PolymorphCategory( int num, params PolymorphEntry[] entries )
{
m_Num = num;
m_Entries = entries;
}
public PolymorphEntry[] Entries{ get { return m_Entries; } }
public int LocNumber{ get { return m_Num; } }
}
private static PolymorphCategory[] Categories = new PolymorphCategory[]
{
new PolymorphCategory( 1015235, // Animals
PolymorphEntry.Chicken,
PolymorphEntry.Dog,
PolymorphEntry.Wolf,
PolymorphEntry.Panther,
PolymorphEntry.Gorilla,
PolymorphEntry.BlackBear,
PolymorphEntry.GrizzlyBear,
PolymorphEntry.PolarBear,
PolymorphEntry.HumanMale ),
new PolymorphCategory( 1015245, // Monsters
PolymorphEntry.Slime,
PolymorphEntry.Orc,
PolymorphEntry.LizardMan,
PolymorphEntry.Gargoyle,
PolymorphEntry.Ogre,
PolymorphEntry.Troll,
PolymorphEntry.Ettin,
PolymorphEntry.Daemon,
PolymorphEntry.HumanFemale )
};
private Mobile m_Caster;
private Item m_Scroll;
public PolymorphGump( Mobile caster, Item scroll ) : base( 50, 50 )
{
m_Caster = caster;
m_Scroll = scroll;
int x,y;
AddPage( 0 );
AddBackground( 0, 0, 585, 393, 5054 );
AddBackground( 195, 36, 387, 275, 3000 );
AddHtmlLocalized( 0, 0, 510, 18, 1015234, false, false ); // <center>Polymorph Selection Menu</center>
AddHtmlLocalized( 60, 355, 150, 18, 1011036, false, false ); // OKAY
AddButton( 25, 355, 4005, 4007, 1, GumpButtonType.Reply, 1 );
AddHtmlLocalized( 320, 355, 150, 18, 1011012, false, false ); // CANCEL
AddButton( 285, 355, 4005, 4007, 0, GumpButtonType.Reply, 2 );
y = 35;
for ( int i=0;i<Categories.Length;i++ )
{
PolymorphCategory cat = (PolymorphCategory)Categories[i];
AddHtmlLocalized( 5, y, 150, 25, cat.LocNumber, true, false );
AddButton( 155, y, 4005, 4007, 0, GumpButtonType.Page, i+1 );
y += 25;
}
for ( int i=0;i<Categories.Length;i++ )
{
PolymorphCategory cat = (PolymorphCategory)Categories[i];
AddPage( i+1 );
for ( int c=0;c<cat.Entries.Length;c++ )
{
PolymorphEntry entry = (PolymorphEntry)cat.Entries[c];
x = 198 + (c%3)*129;
y = 38 + (c/3)*67;
AddHtmlLocalized( x, y, 100, 18, entry.LocNumber, false, false );
AddRadio( x, y+20, 210, 211, false, (c<<8) + i );
}
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( info.ButtonID == 1 && info.Switches.Length > 0 )
{
int cnum = info.Switches[0];
int cat = cnum%256;
int ent = cnum>>8;
if ( cat >= 0 && cat < Categories.Length )
{
if ( ent >= 0 && ent < Categories[cat].Entries.Length )
{
Spell spell = new PolymorphSpell( m_Caster, m_Scroll, Categories[cat].Entries[ent].BodyID );
spell.Cast();
}
}
}
}
}
public class NewPolymorphGump : Gump
{
private static readonly PolymorphEntry[] m_Entries = new PolymorphEntry[]
{
PolymorphEntry.Chicken,
PolymorphEntry.Dog,
PolymorphEntry.Wolf,
PolymorphEntry.Panther,
PolymorphEntry.Gorilla,
PolymorphEntry.BlackBear,
PolymorphEntry.GrizzlyBear,
PolymorphEntry.PolarBear,
PolymorphEntry.HumanMale,
PolymorphEntry.HumanFemale,
PolymorphEntry.Slime,
PolymorphEntry.Orc,
PolymorphEntry.LizardMan,
PolymorphEntry.Gargoyle,
PolymorphEntry.Ogre,
PolymorphEntry.Troll,
PolymorphEntry.Ettin,
PolymorphEntry.Daemon
};
private Mobile m_Caster;
private Item m_Scroll;
public NewPolymorphGump( Mobile caster, Item scroll ) : base( 0, 0 )
{
m_Caster = caster;
m_Scroll = scroll;
AddPage( 0 );
AddBackground( 0, 0, 520, 404, 0x13BE );
AddImageTiled( 10, 10, 500, 20, 0xA40 );
AddImageTiled( 10, 40, 500, 324, 0xA40 );
AddImageTiled( 10, 374, 500, 20, 0xA40 );
AddAlphaRegion( 10, 10, 500, 384 );
AddHtmlLocalized( 14, 12, 500, 20, 1015234, 0x7FFF, false, false ); // <center>Polymorph Selection Menu</center>
AddButton( 10, 374, 0xFB1, 0xFB2, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 376, 450, 20, 1060051, 0x7FFF, false, false ); // CANCEL
for ( int i = 0; i < m_Entries.Length; i++ )
{
PolymorphEntry entry = m_Entries[i];
int page = i / 10 + 1;
int pos = i % 10;
if ( pos == 0 )
{
if ( page > 1 )
{
AddButton( 400, 374, 0xFA5, 0xFA7, 0, GumpButtonType.Page, page );
AddHtmlLocalized( 440, 376, 60, 20, 1043353, 0x7FFF, false, false ); // Next
}
AddPage( page );
if ( page > 1 )
{
AddButton( 300, 374, 0xFAE, 0xFB0, 0, GumpButtonType.Page, 1 );
AddHtmlLocalized( 340, 376, 60, 20, 1011393, 0x7FFF, false, false ); // Back
}
}
int x = ( pos % 2 == 0 ) ? 14 : 264;
int y = ( pos / 2 ) * 64 + 44;
AddHtmlLocalized( x + 84, y, 250, 60, entry.LocNumber, 0x7FFF, false, false );
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
int idx = info.ButtonID - 1;
if ( idx < 0 || idx >= m_Entries.Length )
return;
Spell spell = new PolymorphSpell( m_Caster, m_Scroll, m_Entries[idx].BodyID );
spell.Cast();
}
}
}

View file

@ -0,0 +1,42 @@
using System;
using Server;
namespace Server.Gumps
{
public class PropsConfig
{
public static readonly bool OldStyle = false;
public static readonly int GumpOffsetX = 30;
public static readonly int GumpOffsetY = 30;
public static readonly int TextHue = 0;
public static readonly int TextOffsetX = 2;
public static readonly int OffsetGumpID = 0x0A40; // Pure black
public static readonly int HeaderGumpID = OldStyle ? 0x0BBC : 0x0E14; // Light offwhite, textured : Dark navy blue, textured
public static readonly int EntryGumpID = 0x0BBC; // Light offwhite, textured
public static readonly int BackGumpID = 0x13BE; // Gray slate/stoney
public static readonly int SetGumpID = OldStyle ? 0x0000 : 0x0E14; // Empty : Dark navy blue, textured
public static readonly int SetWidth = 20;
public static readonly int SetOffsetX = OldStyle ? 4 : 2, SetOffsetY = 2;
public static readonly int SetButtonID1 = 0x15E1; // Arrow pointing right
public static readonly int SetButtonID2 = 0x15E5; // " pressed
public static readonly int PrevWidth = 20;
public static readonly int PrevOffsetX = 2, PrevOffsetY = 2;
public static readonly int PrevButtonID1 = 0x15E3; // Arrow pointing left
public static readonly int PrevButtonID2 = 0x15E7; // " pressed
public static readonly int NextWidth = 20;
public static readonly int NextOffsetX = 2, NextOffsetY = 2;
public static readonly int NextButtonID1 = 0x15E1; // Arrow pointing right
public static readonly int NextButtonID2 = 0x15E5; // " pressed
public static readonly int OffsetSize = 1;
public static readonly int EntryHeight = 20;
public static readonly int BorderSize = 10;
}
}

View file

@ -0,0 +1,761 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Commands.Generic;
using Server.Network;
using Server.Menus;
using Server.Menus.Questions;
using Server.Targeting;
using CPA = Server.CommandPropertyAttribute;
namespace Server.Gumps
{
public class PropertiesGump : Gump
{
private ArrayList m_List;
private int m_Page;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
public static readonly bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static bool PrevLabel = OldStyle, NextLabel = OldStyle;
private static readonly int PrevLabelOffsetX = PrevWidth + 1;
private static readonly int PrevLabelOffsetY = 0;
private static readonly int NextLabelOffsetX = -29;
private static readonly int NextLabelOffsetY = 0;
private static readonly int NameWidth = 107;
private static readonly int ValueWidth = 128;
private static readonly int EntryCount = 15;
private static readonly int TypeWidth = NameWidth + OffsetSize + ValueWidth;
private static readonly int TotalWidth = OffsetSize + NameWidth + OffsetSize + ValueWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (EntryCount + 1));
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
public PropertiesGump( Mobile mobile, object o ) : base( GumpOffsetX, GumpOffsetY )
{
m_Mobile = mobile;
m_Object = o;
m_List = BuildList();
Initialize( 0 );
}
public PropertiesGump( Mobile mobile, object o, Stack stack, StackEntry parent ) : base( GumpOffsetX, GumpOffsetY )
{
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_List = BuildList();
if ( parent != null )
{
if ( m_Stack == null )
m_Stack = new Stack();
m_Stack.Push( parent );
}
Initialize( 0 );
}
public PropertiesGump( Mobile mobile, object o, Stack stack, ArrayList list, int page ) : base( GumpOffsetX, GumpOffsetY )
{
m_Mobile = mobile;
m_Object = o;
m_List = list;
m_Stack = stack;
Initialize( page );
}
private void Initialize( int page )
{
m_Page = page;
int count = m_List.Count - (page * EntryCount);
if ( count < 0 )
count = 0;
else if ( count > EntryCount )
count = EntryCount;
int lastIndex = (page * EntryCount) + count - 1;
if ( lastIndex >= 0 && lastIndex < m_List.Count && m_List[lastIndex] == null )
--count;
int totalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (count + 1));
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight, OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
int emptyWidth = TotalWidth - PrevWidth - NextWidth - (OffsetSize * 4) - (OldStyle ? SetWidth + OffsetSize : 0);
if ( OldStyle )
AddImageTiled( x, y, TotalWidth - (OffsetSize * 3) - SetWidth, EntryHeight, HeaderGumpID );
else
AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );
if ( page > 0 )
{
AddButton( x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1, GumpButtonType.Reply, 0 );
if ( PrevLabel )
AddLabel( x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous" );
}
x += PrevWidth + OffsetSize;
if ( !OldStyle )
AddImageTiled( x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, HeaderGumpID );
x += emptyWidth + OffsetSize;
if ( !OldStyle )
AddImageTiled( x, y, NextWidth, EntryHeight, HeaderGumpID );
if ( (page + 1) * EntryCount < m_List.Count )
{
AddButton( x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 2, GumpButtonType.Reply, 1 );
if ( NextLabel )
AddLabel( x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next" );
}
for ( int i = 0, index = page * EntryCount; i < count && index < m_List.Count; ++i, ++index )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
object o = m_List[index];
if ( o == null )
{
AddImageTiled( x - OffsetSize, y, TotalWidth, EntryHeight, BackGumpID + 4 );
}
else if ( o is Type )
{
Type type = (Type)o;
AddImageTiled( x, y, TypeWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, TypeWidth - TextOffsetX, EntryHeight, TextHue, type.Name );
x += TypeWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
}
else if ( o is PropertyInfo )
{
PropertyInfo prop = (PropertyInfo)o;
AddImageTiled( x, y, NameWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, NameWidth - TextOffsetX, EntryHeight, TextHue, prop.Name );
x += NameWidth + OffsetSize;
AddImageTiled( x, y, ValueWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, ValueWidth - TextOffsetX, EntryHeight, TextHue, ValueToString( prop ) );
x += ValueWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
CPA cpa = GetCPA( prop );
if ( prop.CanWrite && cpa != null && m_Mobile.AccessLevel >= cpa.WriteLevel && !cpa.ReadOnly )
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 3, GumpButtonType.Reply, 0 );
}
}
}
public static string[] m_BoolNames = new string[]{ "True", "False" };
public static object[] m_BoolValues = new object[]{ true, false };
public static string[] m_PoisonNames = new string[]{ "None", "Lesser", "Regular", "Greater", "Deadly", "Lethal" };
public static object[] m_PoisonValues = new object[]{ null, Poison.Lesser, Poison.Regular, Poison.Greater, Poison.Deadly, Poison.Lethal };
public class StackEntry
{
public object m_Object;
public PropertyInfo m_Property;
public StackEntry( object obj, PropertyInfo prop )
{
m_Object = obj;
m_Property = prop;
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
if ( !BaseCommand.IsAccessible( from, m_Object ) )
{
from.SendMessage( "You may no longer access their properties." );
return;
}
switch ( info.ButtonID )
{
case 0: // Closed
{
if ( m_Stack != null && m_Stack.Count > 0 )
{
StackEntry entry = (StackEntry)m_Stack.Pop();
from.SendGump( new PropertiesGump( from, entry.m_Object, m_Stack, null ) );
}
break;
}
case 1: // Previous
{
if ( m_Page > 0 )
from.SendGump( new PropertiesGump( from, m_Object, m_Stack, m_List, m_Page - 1 ) );
break;
}
case 2: // Next
{
if ( (m_Page + 1) * EntryCount < m_List.Count )
from.SendGump( new PropertiesGump( from, m_Object, m_Stack, m_List, m_Page + 1 ) );
break;
}
default:
{
int index = (m_Page * EntryCount) + (info.ButtonID - 3);
if ( index >= 0 && index < m_List.Count )
{
PropertyInfo prop = m_List[index] as PropertyInfo;
if ( prop == null )
return;
CPA attr = GetCPA( prop );
if ( !prop.CanWrite || attr == null || from.AccessLevel < attr.WriteLevel || attr.ReadOnly )
return;
Type type = prop.PropertyType;
if ( IsType( type, typeofMobile ) || IsType( type, typeofItem ) )
from.SendGump( new SetObjectGump( prop, from, m_Object, m_Stack, type, m_Page, m_List ) );
else if ( IsType( type, typeofType ) )
from.Target = new SetObjectTarget( prop, from, m_Object, m_Stack, type, m_Page, m_List );
else if ( IsType( type, typeofPoint3D ) )
from.SendGump( new SetPoint3DGump( prop, from, m_Object, m_Stack, m_Page, m_List ) );
else if ( IsType( type, typeofPoint2D ) )
from.SendGump( new SetPoint2DGump( prop, from, m_Object, m_Stack, m_Page, m_List ) );
else if ( IsType( type, typeofTimeSpan ) )
from.SendGump( new SetTimeSpanGump( prop, from, m_Object, m_Stack, m_Page, m_List ) );
else if ( IsCustomEnum( type ) )
from.SendGump( new SetCustomEnumGump( prop, from, m_Object, m_Stack, m_Page, m_List, GetCustomEnumNames( type ) ) );
else if ( IsType( type, typeofEnum ) )
from.SendGump( new SetListOptionGump( prop, from, m_Object, m_Stack, m_Page, m_List, Enum.GetNames( type ), GetObjects( Enum.GetValues( type ) ) ) );
else if ( IsType( type, typeofBool ) )
from.SendGump( new SetListOptionGump( prop, from, m_Object, m_Stack, m_Page, m_List, m_BoolNames, m_BoolValues ) );
else if ( IsType( type, typeofString ) || IsType( type, typeofReal ) || IsType( type, typeofNumeric ) )
from.SendGump( new SetGump( prop, from, m_Object, m_Stack, m_Page, m_List ) );
else if ( IsType( type, typeofPoison ) )
from.SendGump( new SetListOptionGump( prop, from, m_Object, m_Stack, m_Page, m_List, m_PoisonNames, m_PoisonValues ) );
else if ( IsType( type, typeofMap ) )
from.SendGump( new SetListOptionGump( prop, from, m_Object, m_Stack, m_Page, m_List, Map.GetMapNames(), Map.GetMapValues() ) );
else if ( IsType( type, typeofSkills ) && m_Object is Mobile )
{
from.SendGump( new PropertiesGump( from, m_Object, m_Stack, m_List, m_Page ) );
from.SendGump( new SkillsGump( from, (Mobile)m_Object ) );
}
else if( HasAttribute( type, typeofPropertyObject, true ) )
{
object obj = prop.GetValue( m_Object, null );
if ( obj != null )
from.SendGump( new PropertiesGump( from, obj, m_Stack, new StackEntry( m_Object, prop ) ) );
else
from.SendGump( new PropertiesGump( from, m_Object, m_Stack, m_List, m_Page ) );
}
}
break;
}
}
}
private static object[] GetObjects( Array a )
{
object[] list = new object[a.Length];
for ( int i = 0; i < list.Length; ++i )
list[i] = a.GetValue( i );
return list;
}
private static bool IsCustomEnum( Type type )
{
return type.IsDefined( typeofCustomEnum, false );
}
public static void OnValueChanged( object obj, PropertyInfo prop, Stack stack )
{
if ( stack == null || stack.Count == 0 )
return;
if ( !prop.PropertyType.IsValueType )
return;
StackEntry peek = (StackEntry)stack.Peek();
if ( peek.m_Property.CanWrite )
peek.m_Property.SetValue( peek.m_Object, obj, null );
}
private static string[] GetCustomEnumNames( Type type )
{
object[] attrs = type.GetCustomAttributes( typeofCustomEnum, false );
if ( attrs.Length == 0 )
return new string[0];
CustomEnumAttribute ce = attrs[0] as CustomEnumAttribute;
if ( ce == null )
return new string[0];
return ce.Names;
}
private static bool HasAttribute( Type type, Type check, bool inherit )
{
object[] objs = type.GetCustomAttributes( check, inherit );
return ( objs != null && objs.Length > 0 );
}
private static bool IsType( Type type, Type check )
{
return type == check || type.IsSubclassOf( check );
}
private static bool IsType( Type type, Type[] check )
{
for ( int i = 0; i < check.Length; ++i )
if ( IsType( type, check[i] ) )
return true;
return false;
}
private static Type typeofMobile = typeof( Mobile );
private static Type typeofItem = typeof( Item );
private static Type typeofType = typeof( Type );
private static Type typeofPoint3D = typeof( Point3D );
private static Type typeofPoint2D = typeof( Point2D );
private static Type typeofTimeSpan = typeof( TimeSpan );
private static Type typeofCustomEnum = typeof( CustomEnumAttribute );
private static Type typeofEnum = typeof( Enum );
private static Type typeofBool = typeof( Boolean );
private static Type typeofString = typeof( String );
private static Type typeofPoison = typeof( Poison );
private static Type typeofMap = typeof( Map );
private static Type typeofSkills = typeof( Skills );
private static Type typeofPropertyObject = typeof( PropertyObjectAttribute );
private static Type typeofNoSort = typeof( NoSortAttribute );
private static Type[] typeofReal = new Type[]
{
typeof( Single ),
typeof( Double )
};
private static Type[] typeofNumeric = new Type[]
{
typeof( Byte ),
typeof( Int16 ),
typeof( Int32 ),
typeof( Int64 ),
typeof( SByte ),
typeof( UInt16 ),
typeof( UInt32 ),
typeof( UInt64 )
};
private string ValueToString( PropertyInfo prop )
{
return ValueToString( m_Object, prop );
}
public static string ValueToString( object obj, PropertyInfo prop )
{
try
{
return ValueToString( prop.GetValue( obj, null ) );
}
catch ( Exception e )
{
return String.Format( "!{0}!", e.GetType() );
}
}
public static string ValueToString( object o )
{
if ( o == null )
{
return "-null-";
}
else if ( o is string )
{
return String.Format( "\"{0}\"", (string)o );
}
else if ( o is bool )
{
return o.ToString();
}
else if ( o is char )
{
return String.Format( "0x{0:X} '{1}'", (int)(char)o, (char)o );
}
else if ( o is Serial )
{
Serial s = (Serial)o;
if ( s.IsValid )
{
if ( s.IsItem )
{
return String.Format( "(I) 0x{0:X}", s.Value );
}
else if ( s.IsMobile )
{
return String.Format( "(M) 0x{0:X}", s.Value );
}
}
return String.Format( "(?) 0x{0:X}", s.Value );
}
else if ( o is byte || o is sbyte || o is short || o is ushort || o is int || o is uint || o is long || o is ulong )
{
return String.Format( "{0} (0x{0:X})", o );
}
else if ( o is Mobile )
{
return String.Format( "(M) 0x{0:X} \"{1}\"", ((Mobile)o).Serial.Value, ((Mobile)o).Name );
}
else if ( o is Item )
{
return String.Format( "(I) 0x{0:X}", ((Item)o).Serial );
}
else if ( o is Type )
{
return ((Type)o).Name;
}
else
{
return o.ToString();
}
}
private ArrayList BuildList()
{
Type type = m_Object.GetType();
PropertyInfo[] props = type.GetProperties( BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public );
ArrayList groups = GetGroups( type, props );
ArrayList list = new ArrayList();
for ( int i = 0; i < groups.Count; ++i )
{
DictionaryEntry de = (DictionaryEntry)groups[i];
ArrayList groupList = (ArrayList)de.Value;
if ( !HasAttribute( (Type)de.Key, typeofNoSort, false ) )
groupList.Sort( PropertySorter.Instance );
if ( i != 0 )
list.Add( null );
list.Add( de.Key );
list.AddRange( groupList );
}
return list;
}
private static Type typeofCPA = typeof( CPA );
private static Type typeofObject = typeof( object );
private static CPA GetCPA( PropertyInfo prop )
{
object[] attrs = prop.GetCustomAttributes( typeofCPA, false );
if ( attrs.Length > 0 )
return attrs[0] as CPA;
else
return null;
}
private ArrayList GetGroups( Type objectType, PropertyInfo[] props )
{
Hashtable groups = new Hashtable();
for ( int i = 0; i < props.Length; ++i )
{
PropertyInfo prop = props[i];
if ( prop.CanRead )
{
CPA attr = GetCPA( prop );
if ( attr != null && m_Mobile.AccessLevel >= attr.ReadLevel )
{
Type type = prop.DeclaringType;
while ( true )
{
Type baseType = type.BaseType;
if ( baseType == null || baseType == typeofObject )
break;
if ( baseType.GetProperty( prop.Name, prop.PropertyType ) != null )
type = baseType;
else
break;
}
ArrayList list = (ArrayList)groups[type];
if ( list == null )
groups[type] = list = new ArrayList();
list.Add( prop );
}
}
}
ArrayList sorted = new ArrayList( groups );
sorted.Sort( new GroupComparer( objectType ) );
return sorted;
}
public static object GetObjectFromString( Type t, string s )
{
if ( t == typeof( string ) )
{
return s;
}
else if ( t == typeof( byte ) || t == typeof( sbyte ) || t == typeof( short ) || t == typeof( ushort ) || t == typeof( int ) || t == typeof( uint ) || t == typeof( long ) || t == typeof( ulong ) )
{
if ( s.StartsWith( "0x" ) )
{
if ( t == typeof( ulong ) || t == typeof( uint ) || t == typeof( ushort ) || t == typeof( byte ) )
{
return Convert.ChangeType( Convert.ToUInt64( s.Substring( 2 ), 16 ), t );
}
else
{
return Convert.ChangeType( Convert.ToInt64( s.Substring( 2 ), 16 ), t );
}
}
else
{
return Convert.ChangeType( s, t );
}
}
else if ( t == typeof( double ) || t == typeof( float ) )
{
return Convert.ChangeType( s, t );
}
else if ( t.IsDefined( typeof( ParsableAttribute ), false ) )
{
MethodInfo parseMethod = t.GetMethod( "Parse", new Type[]{ typeof( string ) } );
return parseMethod.Invoke( null, new object[]{ s } );
}
throw new Exception( "bad" );
}
private static string GetStringFromObject( object o )
{
if ( o == null )
{
return "-null-";
}
else if ( o is string )
{
return String.Format( "\"{0}\"", (string)o );
}
else if ( o is bool )
{
return o.ToString();
}
else if ( o is char )
{
return String.Format( "0x{0:X} '{1}'", (int)(char)o, (char)o );
}
else if ( o is Serial )
{
Serial s = (Serial)o;
if ( s.IsValid )
{
if ( s.IsItem )
{
return String.Format( "(I) 0x{0:X}", s.Value );
}
else if ( s.IsMobile )
{
return String.Format( "(M) 0x{0:X}", s.Value );
}
}
return String.Format( "(?) 0x{0:X}", s.Value );
}
else if ( o is byte || o is sbyte || o is short || o is ushort || o is int || o is uint || o is long || o is ulong )
{
return String.Format( "{0} (0x{0:X})", o );
}
else if ( o is Mobile )
{
return String.Format( "(M) 0x{0:X} \"{1}\"", ((Mobile)o).Serial.Value, ((Mobile)o).Name );
}
else if ( o is Item )
{
return String.Format( "(I) 0x{0:X}", ((Item)o).Serial );
}
else if ( o is Type )
{
return ((Type)o).Name;
}
else
{
return o.ToString();
}
}
private class PropertySorter : IComparer
{
public static readonly PropertySorter Instance = new PropertySorter();
private PropertySorter()
{
}
public int Compare( object x, object y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
PropertyInfo a = x as PropertyInfo;
PropertyInfo b = y as PropertyInfo;
if ( a == null || b == null )
throw new ArgumentException();
return a.Name.CompareTo( b.Name );
}
}
private class GroupComparer : IComparer
{
private Type m_Start;
public GroupComparer( Type start )
{
m_Start = start;
}
private static Type typeofObject = typeof( Object );
private int GetDistance( Type type )
{
Type current = m_Start;
int dist;
for ( dist = 0; current != null && current != typeofObject && current != type; ++dist )
current = current.BaseType;
return dist;
}
public int Compare( object x, object y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
if ( !(x is DictionaryEntry) || !(y is DictionaryEntry) )
throw new ArgumentException();
DictionaryEntry de1 = (DictionaryEntry)x;
DictionaryEntry de2 = (DictionaryEntry)y;
Type a = (Type)de1.Key;
Type b = (Type)de2.Key;
return GetDistance( a ).CompareTo( GetDistance( b ) );
}
}
}
}

View file

@ -0,0 +1,295 @@
using System;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Network;
using Server.HuePickers;
using Server.Commands;
namespace Server.Gumps
{
public class SetBodyGump : Gump
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private int m_Page;
private ArrayList m_List;
private int m_OurPage;
private ArrayList m_OurList;
private ModelBodyType m_OurType;
private const int LabelColor32 = 0xFFFFFF;
private const int SelectedColor32 = 0x8080FF;
private const int TextColor32 = 0xFFFFFF;
public SetBodyGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list )
: this( prop, mobile, o, stack, page, list, 0, null, ModelBodyType.Invalid )
{
}
public string Center( string text )
{
return String.Format( "<CENTER>{0}</CENTER>", text );
}
public string Color( string text, int color )
{
return String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text );
}
public void AddTypeButton( int x, int y, int buttonID, string text, ModelBodyType type )
{
bool isSelection = (m_OurType == type);
AddButton( x, y - 1, isSelection ? 4006 : 4005, 4007, buttonID, GumpButtonType.Reply, 0 );
AddHtml( x + 35, y, 200, 20, Color( text, isSelection ? SelectedColor32 : LabelColor32 ), false, false );
}
public SetBodyGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list, int ourPage, ArrayList ourList, ModelBodyType ourType )
: base( 20, 30 )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
m_OurPage = ourPage;
m_OurList = ourList;
m_OurType = ourType;
AddPage( 0 );
AddBackground( 0, 0, 525, 328, 5054 );
AddImageTiled( 10, 10, 505, 20, 0xA40 );
AddAlphaRegion( 10, 10, 505, 20 );
AddImageTiled( 10, 35, 505, 283, 0xA40 );
AddAlphaRegion( 10, 35, 505, 283 );
AddTypeButton( 10, 10, 1, "Monster", ModelBodyType.Monsters );
AddTypeButton( 130, 10, 2, "Animal", ModelBodyType.Animals );
AddTypeButton( 250, 10, 3, "Marine", ModelBodyType.Sea );
AddTypeButton( 370, 10, 4, "Human", ModelBodyType.Human );
AddImage( 480, 12, 0x25EA );
AddImage( 497, 12, 0x25E6 );
if( ourList == null )
{
AddLabel( 15, 40, 0x480, "Choose a body type above." );
}
else if( ourList.Count == 0 )
{
AddLabel( 15, 40, 0x480, "The server must have UO:3D installed to use this feature." );
}
else
{
for( int i = 0, index = (ourPage * 12); i < 12 && index >= 0 && index < ourList.Count; ++i, ++index )
{
InternalEntry entry = (InternalEntry)ourList[index];
int itemID = entry.ItemID;
Rectangle2D bounds = ItemBounds.Table[itemID & 0x3FFF];
int x = 15 + ((i % 4) * 125);
int y = 40 + ((i / 4) * 93);
AddItem( x + ((120 - bounds.Width) / 2) - bounds.X, y + ((69 - bounds.Height) / 2) - bounds.Y, itemID );
AddButton( x + 6, y + 66, 0x98D, 0x98D, 7 + index, GumpButtonType.Reply, 0 );
x += 6;
y += 67;
AddHtml( x + 0, y - 1, 108, 21, Center( entry.DisplayName ), false, false );
AddHtml( x + 0, y + 1, 108, 21, Center( entry.DisplayName ), false, false );
AddHtml( x - 1, y + 0, 108, 21, Center( entry.DisplayName ), false, false );
AddHtml( x + 1, y + 0, 108, 21, Center( entry.DisplayName ), false, false );
AddHtml( x + 0, y + 0, 108, 21, Color( Center( entry.DisplayName ), TextColor32 ), false, false );
}
if( ourPage > 0 )
AddButton( 480, 12, 0x15E3, 0x15E7, 5, GumpButtonType.Reply, 0 );
if( (ourPage + 1) * 12 < ourList.Count )
AddButton( 497, 12, 0x15E1, 0x15E5, 6, GumpButtonType.Reply, 0 );
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
int index = info.ButtonID - 1;
if( index == -1 )
{
m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
else if( index >= 0 && index < 4 )
{
if( m_Monster == null )
LoadLists();
ModelBodyType type;
ArrayList list;
switch( index )
{
default:
case 0: type = ModelBodyType.Monsters; list = m_Monster; break;
case 1: type = ModelBodyType.Animals; list = m_Animal; break;
case 2: type = ModelBodyType.Sea; list = m_Sea; break;
case 3: type = ModelBodyType.Human; list = m_Human; break;
}
m_Mobile.SendGump( new SetBodyGump( m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, 0, list, type ) );
}
else if( m_OurList != null )
{
index -= 4;
if( index == 0 && m_OurPage > 0 )
{
m_Mobile.SendGump( new SetBodyGump( m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, m_OurPage - 1, m_OurList, m_OurType ) );
}
else if( index == 1 && ((m_OurPage + 1) * 12) < m_OurList.Count )
{
m_Mobile.SendGump( new SetBodyGump( m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, m_OurPage + 1, m_OurList, m_OurType ) );
}
else
{
index -= 2;
if( index >= 0 && index < m_OurList.Count )
{
try
{
InternalEntry entry = (InternalEntry)m_OurList[index];
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, entry.Body.ToString() );
m_Property.SetValue( m_Object, entry.Body, null );
PropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
m_Mobile.SendGump( new SetBodyGump( m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List, m_OurPage, m_OurList, m_OurType ) );
}
}
}
}
private static ArrayList m_Monster, m_Animal, m_Sea, m_Human;
private static void LoadLists()
{
m_Monster = new ArrayList();
m_Animal = new ArrayList();
m_Sea = new ArrayList();
m_Human = new ArrayList();
List<BodyEntry> entries = Docs.LoadBodies();
for( int i = 0; i < entries.Count; ++i )
{
BodyEntry oldEntry = (BodyEntry)entries[i];
int bodyID = oldEntry.Body.BodyID;
if( ((Body)bodyID).IsEmpty )
continue;
ArrayList list = null;
switch( oldEntry.BodyType )
{
case ModelBodyType.Monsters: list = m_Monster; break;
case ModelBodyType.Animals: list = m_Animal; break;
case ModelBodyType.Sea: list = m_Sea; break;
case ModelBodyType.Human: list = m_Human; break;
}
if( list == null )
continue;
int itemID = ShrinkTable.Lookup( bodyID, -1 );
if( itemID != -1 )
list.Add( new InternalEntry( bodyID, itemID, oldEntry.Name ) );
}
m_Monster.Sort();
m_Animal.Sort();
m_Sea.Sort();
m_Human.Sort();
}
private class InternalEntry : IComparable
{
private int m_Body;
private int m_ItemID;
private string m_Name;
private string m_DisplayName;
public int Body { get { return m_Body; } }
public int ItemID { get { return m_ItemID; } }
public string Name { get { return m_Name; } }
public string DisplayName { get { return m_DisplayName; } }
private static string[] m_GroupNames = new string[]
{
"ogres_", "ettins_", "walking_dead_", "gargoyles_",
"orcs_", "flails_", "daemons_", "arachnids_",
"dragons_", "elementals_", "serpents_", "gazers_",
"liche_", "spirits_", "harpies_", "headless_",
"lizard_race_", "mongbat_", "rat_race_", "scorpions_",
"trolls_", "slimes_", "skeletons_", "ethereals_",
"terathan_", "imps_", "cyclops_", "krakens_",
"frogs_", "ophidians_", "centaurs_", "mages_",
"fey_race_", "genies_", "paladins_", "shadowlords_",
"succubi_", "lizards_", "rodents_", "birds_",
"bovines_", "bruins_", "canines_", "deer_",
"equines_", "felines_", "fowl_", "gorillas_",
"kirin_", "llamas_", "ostards_", "porcines_",
"ruminants_", "walrus_", "dolphins_", "sea_horse_",
"sea_serpents_", "character_", "h_", "titans_"
};
public InternalEntry( int body, int itemID, string name )
{
m_Body = body;
m_ItemID = itemID;
m_Name = name;
m_DisplayName = name.ToLower();
for( int i = 0; i < m_GroupNames.Length; ++i )
{
if( m_DisplayName.StartsWith( m_GroupNames[i] ) )
{
m_DisplayName = m_DisplayName.Substring( m_GroupNames[i].Length );
break;
}
}
m_DisplayName = m_DisplayName.Replace( '_', ' ' );
}
public int CompareTo( object obj )
{
InternalEntry comp = (InternalEntry)obj;
int v = m_Name.CompareTo( comp.m_Name );
if( v == 0 )
m_Body.CompareTo( comp.m_Body );
return v;
}
}
}
}

View file

@ -0,0 +1,50 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Network;
using Server.Commands;
namespace Server.Gumps
{
public class SetCustomEnumGump : SetListOptionGump
{
private string[] m_Names;
public SetCustomEnumGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int propspage, ArrayList list, string[] names ) : base( prop, mobile, o, stack, propspage, list, names, null )
{
m_Names = names;
}
public override void OnResponse( NetState sender, RelayInfo relayInfo )
{
int index = relayInfo.ButtonID - 1;
if ( index >= 0 && index < m_Names.Length )
{
try
{
MethodInfo info = m_Property.PropertyType.GetMethod( "Parse", new Type[]{ typeof( string ) } );
string result = "";
if ( info != null )
result = Properties.SetDirect( m_Mobile, m_Object, m_Object, m_Property, m_Property.Name, info.Invoke( null, new object[] { m_Names[index] } ), true );
else if ( m_Property.PropertyType == typeof( Enum ) || m_Property.PropertyType.IsSubclassOf( typeof( Enum ) ) )
result = Properties.SetDirect( m_Mobile, m_Object, m_Object, m_Property, m_Property.Name, Enum.Parse( m_Property.PropertyType, m_Names[index], false ), true );
m_Mobile.SendMessage( result );
if ( result == "Property has been set." )
PropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
}

View file

@ -0,0 +1,279 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Network;
using Server.HuePickers;
using Server.Commands;
namespace Server.Gumps
{
public class SetGump : Gump
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private int m_Page;
private ArrayList m_List;
public static readonly bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static readonly int EntryWidth = 212;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + (2 * (EntryHeight + OffsetSize));
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
public SetGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list ) : base( GumpOffsetX, GumpOffsetY )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
bool canNull = !prop.PropertyType.IsValueType;
bool canDye = prop.IsDefined( typeof( HueAttribute ), false );
bool isBody = prop.IsDefined( typeof( BodyAttribute ), false );
object val = prop.GetValue( m_Object, null );
string initialText;
if ( val == null )
initialText = "";
else
initialText = val.ToString();
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BackHeight + (canNull ? (EntryHeight + OffsetSize) : 0) + (canDye ? (EntryHeight + OffsetSize) : 0) + (isBody ? (EntryHeight + OffsetSize) : 0), BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight + (canNull ? (EntryHeight + OffsetSize) : 0) + (canDye ? (EntryHeight + OffsetSize) : 0) + (isBody ? (EntryHeight + OffsetSize) : 0), OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddTextEntry( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, 0, initialText );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0 );
if ( canNull )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Null" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2, GumpButtonType.Reply, 0 );
}
if ( canDye )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Hue Picker" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3, GumpButtonType.Reply, 0 );
}
if ( isBody )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Body Picker" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4, GumpButtonType.Reply, 0 );
}
}
private class InternalPicker : HuePicker
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private int m_Page;
private ArrayList m_List;
public InternalPicker( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list ) : base( ((IHued)o).HuedItemID )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
}
public override void OnResponse( int hue )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, hue.ToString() );
m_Property.SetValue( m_Object, hue, null );
PropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
object toSet;
bool shouldSet, shouldSend = true;
switch ( info.ButtonID )
{
case 1:
{
TextRelay text = info.GetTextEntry( 0 );
if ( text != null )
{
try
{
toSet = PropertiesGump.GetObjectFromString( m_Property.PropertyType, text.Text );
shouldSet = true;
}
catch
{
toSet = null;
shouldSet = false;
m_Mobile.SendMessage( "Bad format" );
}
}
else
{
toSet = null;
shouldSet = false;
}
break;
}
case 2: // Null
{
toSet = null;
shouldSet = true;
break;
}
case 3: // Hue Picker
{
toSet = null;
shouldSet = false;
shouldSend = false;
m_Mobile.SendHuePicker( new InternalPicker( m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List ) );
break;
}
case 4: // Body Picker
{
toSet = null;
shouldSet = false;
shouldSend = false;
m_Mobile.SendGump( new SetBodyGump( m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List ) );
break;
}
default:
{
toSet = null;
shouldSet = false;
break;
}
}
if ( shouldSet )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, toSet==null?"(null)":toSet.ToString() );
m_Property.SetValue( m_Object, toSet, null );
PropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
if ( shouldSend )
m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
}

View file

@ -0,0 +1,187 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Network;
using Server.Commands;
namespace Server.Gumps
{
public class SetListOptionGump : Gump
{
protected PropertyInfo m_Property;
protected Mobile m_Mobile;
protected object m_Object;
protected Stack m_Stack;
protected int m_Page;
protected ArrayList m_List;
public static readonly bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static readonly int EntryWidth = 212;
private static readonly int EntryCount = 13;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static bool PrevLabel = OldStyle, NextLabel = OldStyle;
private static readonly int PrevLabelOffsetX = PrevWidth + 1;
private static readonly int PrevLabelOffsetY = 0;
private static readonly int NextLabelOffsetX = -29;
private static readonly int NextLabelOffsetY = 0;
protected object[] m_Values;
public SetListOptionGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int propspage, ArrayList list, string[] names, object[] values ) : base( GumpOffsetX, GumpOffsetY )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = propspage;
m_List = list;
m_Values = values;
int pages = (names.Length + EntryCount - 1) / EntryCount;
int index = 0;
for ( int page = 1; page <= pages; ++page )
{
AddPage( page );
int start = (page - 1) * EntryCount;
int count = names.Length - start;
if ( count > EntryCount )
count = EntryCount;
int totalHeight = OffsetSize + ((count + 2) * (EntryHeight + OffsetSize));
int backHeight = BorderSize + totalHeight + BorderSize;
AddBackground( 0, 0, BackWidth, backHeight, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight, OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
int emptyWidth = TotalWidth - PrevWidth - NextWidth - (OffsetSize * 4) - (OldStyle ? SetWidth + OffsetSize : 0);
AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );
if ( page > 1 )
{
AddButton( x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 0, GumpButtonType.Page, page - 1 );
if ( PrevLabel )
AddLabel( x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous" );
}
x += PrevWidth + OffsetSize;
if ( !OldStyle )
AddImageTiled( x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, HeaderGumpID );
x += emptyWidth + OffsetSize;
if ( !OldStyle )
AddImageTiled( x, y, NextWidth, EntryHeight, HeaderGumpID );
if ( page < pages )
{
AddButton( x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 0, GumpButtonType.Page, page + 1 );
if ( NextLabel )
AddLabel( x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next" );
}
AddRect( 0, prop.Name, 0 );
for ( int i = 0; i < count; ++i )
AddRect( i + 1, names[index], ++index );
}
}
private void AddRect( int index, string str, int button )
{
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize + ((index + 1) * (EntryHeight + OffsetSize));
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, str );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
if ( button != 0 )
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, button, GumpButtonType.Reply, 0 );
}
public override void OnResponse( NetState sender, RelayInfo info )
{
int index = info.ButtonID - 1;
if ( index >= 0 && index < m_Values.Length )
{
try
{
object toSet = m_Values[index];
string result = Properties.SetDirect( m_Mobile, m_Object, m_Object, m_Property, m_Property.Name, toSet, true );
m_Mobile.SendMessage( result );
if ( result == "Property has been set." )
PropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
}

View file

@ -0,0 +1,308 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Commands.Generic;
using Server.Network;
using Server.Prompts;
using Server.Commands;
namespace Server.Gumps
{
public class SetObjectGump : Gump
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private Type m_Type;
private int m_Page;
private ArrayList m_List;
public static readonly bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static readonly int EntryWidth = 212;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + (5 * (EntryHeight + OffsetSize));
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
public SetObjectGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, Type type, int page, ArrayList list ) : base( GumpOffsetX, GumpOffsetY )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Type = type;
m_Page = page;
m_List = list;
string initialText = PropertiesGump.ValueToString( o, prop );
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BackHeight, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight, OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, initialText );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0 );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Change by Serial" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2, GumpButtonType.Reply, 0 );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Nullify" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3, GumpButtonType.Reply, 0 );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "View Properties" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 4, GumpButtonType.Reply, 0 );
}
private class InternalPrompt : Prompt
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private Type m_Type;
private int m_Page;
private ArrayList m_List;
public InternalPrompt( PropertyInfo prop, Mobile mobile, object o, Stack stack, Type type, int page, ArrayList list )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Type = type;
m_Page = page;
m_List = list;
}
public override void OnCancel( Mobile from )
{
m_Mobile.SendGump( new SetObjectGump( m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List ) );
}
public override void OnResponse( Mobile from, string text )
{
object toSet;
bool shouldSet;
try
{
int serial = Utility.ToInt32( text );
toSet = World.FindEntity( serial );
if ( toSet == null )
{
shouldSet = false;
m_Mobile.SendMessage( "No object with that serial was found." );
}
else if ( !m_Type.IsAssignableFrom( toSet.GetType() ) )
{
toSet = null;
shouldSet = false;
m_Mobile.SendMessage( "The object with that serial could not be assigned to a property of type : {0}", m_Type.Name );
}
else
{
shouldSet = true;
}
}
catch
{
toSet = null;
shouldSet = false;
m_Mobile.SendMessage( "Bad format" );
}
if ( shouldSet )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, toSet==null?"(null)":toSet.ToString() );
m_Property.SetValue( m_Object, toSet, null );
PropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
m_Mobile.SendGump( new SetObjectGump( m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List ) );
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
object toSet;
bool shouldSet, shouldSend = true;
object viewProps = null;
switch ( info.ButtonID )
{
case 0: // closed
{
m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
toSet = null;
shouldSet = false;
shouldSend = false;
break;
}
case 1: // Change by Target
{
m_Mobile.Target = new SetObjectTarget( m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List );
toSet = null;
shouldSet = false;
shouldSend = false;
break;
}
case 2: // Change by Serial
{
toSet = null;
shouldSet = false;
shouldSend = false;
m_Mobile.SendMessage( "Enter the serial you wish to find:" );
m_Mobile.Prompt = new InternalPrompt( m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List );
break;
}
case 3: // Nullify
{
toSet = null;
shouldSet = true;
break;
}
case 4: // View Properties
{
toSet = null;
shouldSet = false;
object obj = m_Property.GetValue( m_Object, null );
if ( obj == null )
m_Mobile.SendMessage( "The property is null and so you cannot view its properties." );
else if ( !BaseCommand.IsAccessible( m_Mobile, obj ) )
m_Mobile.SendMessage( "You may not view their properties." );
else
viewProps = obj;
break;
}
default:
{
toSet = null;
shouldSet = false;
break;
}
}
if ( shouldSet )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, toSet==null?"(null)":toSet.ToString() );
m_Property.SetValue( m_Object, toSet, null );
PropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
if ( shouldSend )
m_Mobile.SendGump( new SetObjectGump( m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List ) );
if ( viewProps != null )
m_Mobile.SendGump( new PropertiesGump( m_Mobile, viewProps ) );
}
}
}

View file

@ -0,0 +1,66 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Items;
using Server.Targeting;
using Server.Commands;
namespace Server.Gumps
{
public class SetObjectTarget : Target
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private Type m_Type;
private int m_Page;
private ArrayList m_List;
public SetObjectTarget( PropertyInfo prop, Mobile mobile, object o, Stack stack, Type type, int page, ArrayList list ) : base( -1, false, TargetFlags.None )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Type = type;
m_Page = page;
m_List = list;
}
protected override void OnTarget( Mobile from, object targeted )
{
try
{
if ( m_Type == typeof( Type ) )
targeted = targeted.GetType();
else if ( (m_Type == typeof( BaseAddon ) || m_Type.IsAssignableFrom( typeof( BaseAddon ) )) && targeted is AddonComponent )
targeted = ((AddonComponent)targeted).Addon;
if ( m_Type.IsAssignableFrom( targeted.GetType() ) )
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, targeted.ToString() );
m_Property.SetValue( m_Object, targeted, null );
PropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
else
{
m_Mobile.SendMessage( "That cannot be assigned to a property of type : {0}", m_Type.Name );
}
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
protected override void OnTargetFinish( Mobile from )
{
if ( m_Type == typeof( Type ) )
from.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
else
from.SendGump( new SetObjectGump( m_Property, m_Mobile, m_Object, m_Stack, m_Type, m_Page, m_List ) );
}
}
}

View file

@ -0,0 +1,237 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Targeting;
using Server.Network;
using Server.Commands;
namespace Server.Gumps
{
public class SetPoint2DGump : Gump
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private int m_Page;
private ArrayList m_List;
public static readonly bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static readonly int CoordWidth = 105;
private static readonly int EntryWidth = CoordWidth + OffsetSize + CoordWidth;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + (4 * (EntryHeight + OffsetSize));
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
public SetPoint2DGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list ) : base( GumpOffsetX, GumpOffsetY )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
Point2D p = (Point2D)prop.GetValue( o, null );
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BackHeight, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight, OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Use your location" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0 );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Target a location" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2, GumpButtonType.Reply, 0 );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, CoordWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "X:" );
AddTextEntry( x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 0, p.X.ToString() );
x += CoordWidth + OffsetSize;
AddImageTiled( x, y, CoordWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "Y:" );
AddTextEntry( x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 1, p.Y.ToString() );
x += CoordWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3, GumpButtonType.Reply, 0 );
}
private class InternalTarget : Target
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private int m_Page;
private ArrayList m_List;
public InternalTarget( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list ) : base( -1, true, TargetFlags.None )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
}
protected override void OnTarget( Mobile from, object targeted )
{
IPoint3D p = targeted as IPoint3D;
if ( p != null )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, new Point2D( p ).ToString() );
m_Property.SetValue( m_Object, new Point2D( p ), null );
PropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
}
protected override void OnTargetFinish( Mobile from )
{
m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Point2D toSet;
bool shouldSet, shouldSend;
switch ( info.ButtonID )
{
case 1: // Current location
{
toSet = new Point2D( m_Mobile.Location );
shouldSet = true;
shouldSend = true;
break;
}
case 2: // Pick location
{
m_Mobile.Target = new InternalTarget( m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List );
toSet = Point2D.Zero;
shouldSet = false;
shouldSend = false;
break;
}
case 3: // Use values
{
TextRelay x = info.GetTextEntry( 0 );
TextRelay y = info.GetTextEntry( 1 );
toSet = new Point2D( x == null ? 0 : Utility.ToInt32( x.Text ), y == null ? 0 : Utility.ToInt32( y.Text ) );
shouldSet = true;
shouldSend = true;
break;
}
default:
{
toSet = Point2D.Zero;
shouldSet = false;
shouldSend = true;
break;
}
}
if ( shouldSet )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, toSet.ToString() );
m_Property.SetValue( m_Object, toSet, null );
PropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
if ( shouldSend )
m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
}

View file

@ -0,0 +1,243 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Targeting;
using Server.Network;
using Server.Commands;
namespace Server.Gumps
{
public class SetPoint3DGump : Gump
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private int m_Page;
private ArrayList m_List;
public static readonly bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static readonly int CoordWidth = 70;
private static readonly int EntryWidth = CoordWidth + OffsetSize + CoordWidth + OffsetSize + CoordWidth;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + (4 * (EntryHeight + OffsetSize));
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
public SetPoint3DGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list ) : base( GumpOffsetX, GumpOffsetY )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
Point3D p = (Point3D)prop.GetValue( o, null );
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BackHeight, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight, OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, prop.Name );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Use your location" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0 );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, "Target a location" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 2, GumpButtonType.Reply, 0 );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, CoordWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "X:" );
AddTextEntry( x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 0, p.X.ToString() );
x += CoordWidth + OffsetSize;
AddImageTiled( x, y, CoordWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "Y:" );
AddTextEntry( x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 1, p.Y.ToString() );
x += CoordWidth + OffsetSize;
AddImageTiled( x, y, CoordWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, CoordWidth - TextOffsetX, EntryHeight, TextHue, "Z:" );
AddTextEntry( x + 16, y, CoordWidth - 16, EntryHeight, TextHue, 2, p.Z.ToString() );
x += CoordWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 3, GumpButtonType.Reply, 0 );
}
private class InternalTarget : Target
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private int m_Page;
private ArrayList m_List;
public InternalTarget( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list ) : base( -1, true, TargetFlags.None )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
}
protected override void OnTarget( Mobile from, object targeted )
{
IPoint3D p = targeted as IPoint3D;
if ( p != null )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, new Point3D( p ).ToString() );
m_Property.SetValue( m_Object, new Point3D( p ), null );
PropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
}
protected override void OnTargetFinish( Mobile from )
{
m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Point3D toSet;
bool shouldSet, shouldSend;
switch ( info.ButtonID )
{
case 1: // Current location
{
toSet = m_Mobile.Location;
shouldSet = true;
shouldSend = true;
break;
}
case 2: // Pick location
{
m_Mobile.Target = new InternalTarget( m_Property, m_Mobile, m_Object, m_Stack, m_Page, m_List );
toSet = Point3D.Zero;
shouldSet = false;
shouldSend = false;
break;
}
case 3: // Use values
{
TextRelay x = info.GetTextEntry( 0 );
TextRelay y = info.GetTextEntry( 1 );
TextRelay z = info.GetTextEntry( 2 );
toSet = new Point3D( x == null ? 0 : Utility.ToInt32( x.Text ), y == null ? 0 : Utility.ToInt32( y.Text ), z == null ? 0 : Utility.ToInt32( z.Text ) );
shouldSet = true;
shouldSend = true;
break;
}
default:
{
toSet = Point3D.Zero;
shouldSet = false;
shouldSend = true;
break;
}
}
if ( shouldSet )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, toSet.ToString() );
m_Property.SetValue( m_Object, toSet, null );
PropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
if ( shouldSend )
m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
}

View file

@ -0,0 +1,238 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
using Server.Network;
using Server.Commands;
namespace Server.Gumps
{
public class SetTimeSpanGump : Gump
{
private PropertyInfo m_Property;
private Mobile m_Mobile;
private object m_Object;
private Stack m_Stack;
private int m_Page;
private ArrayList m_List;
public static readonly bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static readonly int EntryWidth = 212;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + (7 * (EntryHeight + OffsetSize));
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
public SetTimeSpanGump( PropertyInfo prop, Mobile mobile, object o, Stack stack, int page, ArrayList list ) : base( GumpOffsetX, GumpOffsetY )
{
m_Property = prop;
m_Mobile = mobile;
m_Object = o;
m_Stack = stack;
m_Page = page;
m_List = list;
TimeSpan ts = (TimeSpan)prop.GetValue( o, null );
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BackHeight, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight, OffsetGumpID );
AddRect( 0, prop.Name, 0, -1 );
AddRect( 1, ts.ToString(), 0, -1 );
AddRect( 2, "Zero", 1, -1 );
AddRect( 3, "From H:M:S", 2, -1 );
AddRect( 4, "H:", 3, 0 );
AddRect( 5, "M:", 4, 1 );
AddRect( 6, "S:", 5, 2 );
}
private void AddRect( int index, string str, int button, int text )
{
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize + (index * (EntryHeight + OffsetSize));
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, str );
if ( text != -1 )
AddTextEntry( x + 16 + TextOffsetX, y, EntryWidth - TextOffsetX - 16, EntryHeight, TextHue, text, "" );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
if ( button != 0 )
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, button, GumpButtonType.Reply, 0 );
}
public override void OnResponse( NetState sender, RelayInfo info )
{
TimeSpan toSet;
bool shouldSet, shouldSend;
TextRelay h = info.GetTextEntry( 0 );
TextRelay m = info.GetTextEntry( 1 );
TextRelay s = info.GetTextEntry( 2 );
switch ( info.ButtonID )
{
case 1: // Zero
{
toSet = TimeSpan.Zero;
shouldSet = true;
shouldSend = true;
break;
}
case 2: // From H:M:S
{
bool successfulParse = false;
if( h != null && m != null && s != null )
{
successfulParse = TimeSpan.TryParse( h.Text + ":" + m.Text + ":" + s.Text, out toSet );
}
else
{
toSet = TimeSpan.Zero;
}
shouldSet = shouldSend = successfulParse;
break;
}
case 3: // From H
{
if ( h != null )
{
try
{
toSet = TimeSpan.FromHours( Utility.ToDouble( h.Text ) );
shouldSet = true;
shouldSend = true;
break;
}
catch
{
}
}
toSet = TimeSpan.Zero;
shouldSet = false;
shouldSend = false;
break;
}
case 4: // From M
{
if ( m != null )
{
try
{
toSet = TimeSpan.FromMinutes( Utility.ToDouble( m.Text ) );
shouldSet = true;
shouldSend = true;
break;
}
catch
{
}
}
toSet = TimeSpan.Zero;
shouldSet = false;
shouldSend = false;
break;
}
case 5: // From S
{
if ( s != null )
{
try
{
toSet = TimeSpan.FromSeconds( Utility.ToDouble( s.Text ) );
shouldSet = true;
shouldSend = true;
break;
}
catch
{
}
}
toSet = TimeSpan.Zero;
shouldSet = false;
shouldSend = false;
break;
}
default:
{
toSet = TimeSpan.Zero;
shouldSet = false;
shouldSend = true;
break;
}
}
if ( shouldSet )
{
try
{
CommandLogging.LogChangeProperty( m_Mobile, m_Object, m_Property.Name, toSet.ToString() );
m_Property.SetValue( m_Object, toSet, null );
PropertiesGump.OnValueChanged( m_Object, m_Property, m_Stack );
}
catch
{
m_Mobile.SendMessage( "An exception was caught. The property may not have changed." );
}
}
if ( shouldSend )
m_Mobile.SendGump( new PropertiesGump( m_Mobile, m_Object, m_Stack, m_List, m_Page ) );
}
}
}

View file

@ -0,0 +1,79 @@
using System;
using System.Collections;
using Server;
using Server.Network;
using Server.Multis;
namespace Server.Gumps
{
public class ReclaimVendorGump : Gump
{
private BaseHouse m_House;
private ArrayList m_Vendors;
public ReclaimVendorGump( BaseHouse house ) : base( 50, 50 )
{
m_House = house;
m_Vendors = new ArrayList( house.InternalizedVendors );
AddBackground( 0, 0, 170, 50 + m_Vendors.Count * 20, 0x13BE );
AddImageTiled( 10, 10, 150, 20, 0xA40 );
AddHtmlLocalized( 10, 10, 150, 20, 1061827, 0x7FFF, false, false ); // <CENTER>Reclaim Vendor</CENTER>
AddImageTiled( 10, 40, 150, m_Vendors.Count * 20, 0xA40 );
for ( int i = 0; i < m_Vendors.Count; i++ )
{
Mobile m = (Mobile) m_Vendors[i];
int y = 40 + i * 20;
AddButton( 10, y, 0xFA5, 0xFA7, i + 1, GumpButtonType.Reply, 0 );
AddLabel( 45, y, 0x481, m.Name );
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
if ( info.ButtonID == 0 || !m_House.IsActive || !m_House.IsInside( from ) || !m_House.IsOwner( from ) || !from.CheckAlive() )
return;
int index = info.ButtonID - 1;
if ( index < 0 || index >= m_Vendors.Count )
return;
Mobile mob = (Mobile) m_Vendors[index];
if ( !m_House.InternalizedVendors.Contains( mob ) )
return;
if ( mob.Deleted )
{
m_House.InternalizedVendors.Remove( mob );
}
else
{
bool vendor, contract;
BaseHouse.IsThereVendor( from.Location, from.Map, out vendor, out contract );
if ( vendor )
{
from.SendLocalizedMessage( 1062677 ); // You cannot place a vendor or barkeep at this location.
}
else if ( contract )
{
from.SendLocalizedMessage( 1062678 ); // You cannot place a vendor or barkeep on top of a rental contract!
}
else
{
m_House.InternalizedVendors.Remove( mob );
mob.MoveToWorld( from.Location, from.Map );
}
}
}
}
}

View file

@ -0,0 +1,187 @@
using System;
using System.Collections.Generic;
using Server.Misc;
using Server.Network;
using Server.Mobiles;
namespace Server.Gumps
{
public class ReportMurdererGump : Gump
{
private int m_Idx;
private List<Mobile> m_Killers;
private Mobile m_Victum;
public static void Initialize()
{
EventSink.PlayerDeath += new PlayerDeathEventHandler( EventSink_PlayerDeath );
}
public static void EventSink_PlayerDeath( PlayerDeathEventArgs e )
{
Mobile m = e.Mobile;
List<Mobile> killers = new List<Mobile>();
List<Mobile> toGive = new List<Mobile>();
foreach ( AggressorInfo ai in m.Aggressors )
{
if ( ai.Attacker.Player && ai.CanReportMurder && !ai.Reported )
{
killers.Add(ai.Attacker);
ai.Reported = true;
ai.CanReportMurder = false;
}
if ( ai.Attacker.Player && (DateTime.Now - ai.LastCombatTime) < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Attacker ) )
toGive.Add( ai.Attacker );
}
foreach ( AggressorInfo ai in m.Aggressed )
{
if ( ai.Defender.Player && (DateTime.Now - ai.LastCombatTime) < TimeSpan.FromSeconds( 30.0 ) && !toGive.Contains( ai.Defender ) )
toGive.Add( ai.Defender );
}
foreach ( Mobile g in toGive )
{
int n = Notoriety.Compute( g, m );
int theirKarma = m.Karma, ourKarma = g.Karma;
bool innocent = ( n == Notoriety.Innocent );
bool criminal = ( n == Notoriety.Criminal || n == Notoriety.Murderer );
int fameAward = m.Fame / 200;
int karmaAward = 0;
if ( innocent )
karmaAward = ( ourKarma > -2500 ? -850 : -110 - (m.Karma / 100) );
else if ( criminal )
karmaAward = 50;
Titles.AwardFame( g, fameAward, false );
Titles.AwardKarma( g, karmaAward, true );
}
if ( m is PlayerMobile && ((PlayerMobile)m).NpcGuild == NpcGuild.ThievesGuild )
return;
if ( killers.Count > 0 )
new GumpTimer( m, killers ).Start();
}
private class GumpTimer : Timer
{
private Mobile m_Victim;
private List<Mobile> m_Killers;
public GumpTimer( Mobile victim, List<Mobile> killers ) : base( TimeSpan.FromSeconds( 4.0 ) )
{
m_Victim = victim;
m_Killers = killers;
}
protected override void OnTick()
{
m_Victim.SendGump( new ReportMurdererGump( m_Victim, m_Killers ) );
}
}
public ReportMurdererGump( Mobile victum, List<Mobile> killers ) : this( victum, killers, 0 )
{
}
private ReportMurdererGump( Mobile victum, List<Mobile> killers, int idx ) : base( 0, 0 )
{
m_Killers = killers;
m_Victum = victum;
m_Idx = idx;
BuildGump();
}
private void BuildGump()
{
AddBackground( 265, 205, 320, 290, 5054 );
Closable = false;
Resizable = false;
AddPage( 0 );
AddImageTiled( 225, 175, 50, 45, 0xCE ); //Top left corner
AddImageTiled( 267, 175, 315, 44, 0xC9 ); //Top bar
AddImageTiled( 582, 175, 43, 45, 0xCF ); //Top right corner
AddImageTiled( 225, 219, 44, 270, 0xCA ); //Left side
AddImageTiled( 582, 219, 44, 270, 0xCB ); //Right side
AddImageTiled( 225, 489, 44, 43, 0xCC ); //Lower left corner
AddImageTiled( 267, 489, 315, 43, 0xE9 ); //Lower Bar
AddImageTiled( 582, 489, 43, 43, 0xCD ); //Lower right corner
AddPage( 1 );
AddHtml( 260, 234, 300, 140, ((Mobile)m_Killers[m_Idx]).Name, false, false ); // Player's Name
AddHtmlLocalized( 260, 254, 300, 140, 1049066, false, false ); // Would you like to report...
AddButton( 260, 300, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 300, 300, 300, 50, 1046362, false, false ); // Yes
AddButton( 360, 300, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 400, 300, 300, 50, 1046363, false, false ); // No
}
public static void ReportedListExpiry_Callback( object state )
{
object[] states = (object[])state;
PlayerMobile from = (PlayerMobile)states[0];
Mobile killer = (Mobile)states[1];
if (from.RecentlyReported.Contains(killer))
{
from.RecentlyReported.Remove(killer);
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
switch ( info.ButtonID )
{
case 1:
{
Mobile killer = m_Killers[m_Idx];
if ( killer != null && !killer.Deleted )
{
killer.Kills++;
if (killer is PlayerMobile)
{
PlayerMobile pk = (PlayerMobile)killer;
pk.ResetKillTime();
pk.SendLocalizedMessage(1049067);//You have been reported for murder!
if (pk.Kills == 5)
{
pk.SendLocalizedMessage(502134);//You are now known as a murderer!
}
if ( pk.Kills > 4 && pk.NpcGuild != NpcGuild.None && pk.NpcGuild != NpcGuild.AssassinsGuild && pk.NpcGuild != NpcGuild.ThievesGuild )
{
pk.SendMessage( "You have been suspended from your local guild!" );
pk.NpcGuild = NpcGuild.None;
}
}
}
break;
}
case 2:
{
break;
}
}
m_Idx++;
if ( m_Idx < m_Killers.Count )
from.SendGump( new ReportMurdererGump( from, m_Killers, m_Idx ) );
}
}
}

View file

@ -0,0 +1,193 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Items;
using Server.Network;
using Server.Mobiles;
namespace Server.Gumps
{
public enum ResurrectMessage
{
ChaosShrine = 0,
VirtueShrine = 1,
Healer = 2,
Generic = 3,
}
public class ResurrectGump : Gump
{
private Mobile m_Healer;
private int m_Price;
private double m_HitsScalar;
public ResurrectGump( Mobile owner )
: this( owner, owner, ResurrectMessage.Generic, false )
{
}
public ResurrectGump( Mobile owner, double hitsScalar )
: this( owner, owner, ResurrectMessage.Generic, false, hitsScalar )
{
}
public ResurrectGump( Mobile owner, bool checkBool )
: this( owner, owner, ResurrectMessage.Generic, checkBool )
{
}
public ResurrectGump( Mobile owner, Mobile healer )
: this( owner, healer, ResurrectMessage.Generic, false )
{
}
public ResurrectGump( Mobile owner, ResurrectMessage msg )
: this( owner, owner, msg, false )
{
}
public ResurrectGump( Mobile owner, Mobile healer, ResurrectMessage msg )
: this( owner, healer, msg, false )
{
}
public ResurrectGump( Mobile owner, Mobile healer, ResurrectMessage msg, bool checkBool )
: this( owner, healer, msg, checkBool, 0.0 )
{
}
public ResurrectGump( Mobile owner, Mobile healer, ResurrectMessage msg, bool checkBool, double hitsScalar )
: base( 100, 0 )
{
m_Healer = healer;
m_HitsScalar = hitsScalar;
AddPage( 0 );
AddBackground( 0, 0, 400, 350, 2600 );
AddHtmlLocalized( 0, 20, 400, 35, 1011022, false, false ); // <center>Resurrection</center>
AddHtmlLocalized( 50, 55, 300, 140, 1011023 + (int)msg, true, true ); /* It is possible for you to be resurrected here by this healer. Do you wish to try?<br>
* CONTINUE - You chose to try to come back to life now.<br>
* CANCEL - You prefer to remain a ghost for now.
*/
AddButton( 200, 227, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 235, 230, 110, 35, 1011012, false, false ); // CANCEL
AddButton( 65, 227, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 100, 230, 110, 35, 1011011, false, false ); // CONTINUE
}
public ResurrectGump( Mobile owner, Mobile healer, int price )
: base( 150, 50 )
{
m_Healer = healer;
m_Price = price;
Closable = false;
AddPage( 0 );
AddImage( 0, 0, 3600 );
AddImageTiled( 0, 14, 15, 200, 3603 );
AddImageTiled( 380, 14, 14, 200, 3605 );
AddImage( 0, 201, 3606 );
AddImageTiled( 15, 201, 370, 16, 3607 );
AddImageTiled( 15, 0, 370, 16, 3601 );
AddImage( 380, 0, 3602 );
AddImage( 380, 201, 3608 );
AddImageTiled( 15, 15, 365, 190, 2624 );
AddRadio( 30, 140, 9727, 9730, true, 1 );
AddHtmlLocalized( 65, 145, 300, 25, 1060015, 0x7FFF, false, false ); // Grudgingly pay the money
AddRadio( 30, 175, 9727, 9730, false, 0 );
AddHtmlLocalized( 65, 178, 300, 25, 1060016, 0x7FFF, false, false ); // I'd rather stay dead, you scoundrel!!!
AddHtmlLocalized( 30, 20, 360, 35, 1060017, 0x7FFF, false, false ); // Wishing to rejoin the living, are you? I can restore your body... for a price of course...
AddHtmlLocalized( 30, 105, 345, 40, 1060018, 0x5B2D, false, false ); // Do you accept the fee, which will be withdrawn from your inn chest?
AddImage( 65, 72, 5605 );
AddImageTiled( 80, 90, 200, 1, 9107 );
AddImageTiled( 95, 92, 200, 1, 9157 );
AddLabel( 90, 70, 1645, price.ToString() );
AddHtmlLocalized( 140, 70, 100, 25, 1023823, 0x7FFF, false, false ); // gold coins
AddButton( 290, 175, 247, 248, 2, GumpButtonType.Reply, 0 );
AddImageTiled( 15, 14, 365, 1, 9107 );
AddImageTiled( 380, 14, 1, 190, 9105 );
AddImageTiled( 15, 205, 365, 1, 9107 );
AddImageTiled( 15, 14, 1, 190, 9105 );
AddImageTiled( 0, 0, 395, 1, 9157 );
AddImageTiled( 394, 0, 1, 217, 9155 );
AddImageTiled( 0, 216, 395, 1, 9157 );
AddImageTiled( 0, 0, 1, 217, 9155 );
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
from.CloseGump( typeof( ResurrectGump ) );
if( info.ButtonID == 1 || info.ButtonID == 2 )
{
if( from.Map == null || !from.Map.CanFit( from.Location, 16, false, false ) )
{
from.SendLocalizedMessage( 502391 ); // Thou can not be resurrected there!
return;
}
if( m_Price > 0 )
{
if( info.IsSwitched( 1 ) )
{
if( Innkeeper.Withdraw( from, m_Price ) )
{
from.SendLocalizedMessage( 1060398, m_Price.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your inn chest.
from.SendLocalizedMessage( 1060022, Innkeeper.GetBalance( from ).ToString() ); // You have ~1_AMOUNT~ gold in cash remaining in your inn chest.
}
else
{
from.SendLocalizedMessage( 1060020 ); // Unfortunately, you do not have enough cash in your inn chest to cover the cost of the healing.
return;
}
}
else
{
from.SendLocalizedMessage( 1060019 ); // You decide against paying the healer, and thus remain dead.
return;
}
}
from.PlaySound( 0x214 );
from.FixedEffect( 0x376A, 10, 16 );
from.Resurrect();
if( from.Fame > 0 )
{
int amount = from.Fame / 10;
Misc.Titles.AwardFame( from, -amount, true );
}
if( from.Alive && m_HitsScalar > 0 )
from.Hits = (int)(from.HitsMax * m_HitsScalar);
}
}
}
}

View file

@ -0,0 +1,93 @@
using System;
using Server;
using Server.Multis;
using Server.Network;
using Server.Guilds;
namespace Server.Gumps
{
public interface ISecurable
{
SecureLevel Level{ get; set; }
}
public class SetSecureLevelGump : Gump
{
private ISecurable m_Info;
public SetSecureLevelGump( Mobile owner, ISecurable info, BaseHouse house ) : base( 50, 50 )
{
m_Info = info;
AddPage( 0 );
int offset = ( Guild.NewGuildSystem )? 20 : 0;
AddBackground( 0, 0, 220, 160 + offset, 5054 );
AddImageTiled( 10, 10, 200, 20, 5124 );
AddImageTiled( 10, 40, 200, 20, 5124 );
AddImageTiled( 10, 70, 200, 80 + offset, 5124 );
AddAlphaRegion( 10, 10, 200, 140 );
AddHtmlLocalized( 10, 10, 200, 20, 1061276, 32767, false, false ); // <CENTER>SET ACCESS</CENTER>
AddHtmlLocalized( 10, 40, 100, 20, 1041474, 32767, false, false ); // Owner:
AddLabel( 110, 40, 1152, owner == null ? "" : owner.Name );
AddButton( 10, 70, GetFirstID( SecureLevel.Owner ), 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 70, 150, 20, 1061277, GetColor( SecureLevel.Owner ), false, false ); // Owner Only
AddButton( 10, 90, GetFirstID( SecureLevel.CoOwners ), 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 90, 150, 20, 1061278, GetColor( SecureLevel.CoOwners ), false, false ); // Co-Owners
AddButton( 10, 110, GetFirstID( SecureLevel.Friends ), 4007, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 110, 150, 20, 1061279, GetColor( SecureLevel.Friends ), false, false ); // Friends
Mobile houseOwner = house.Owner;
if( Guild.NewGuildSystem && house != null && houseOwner != null && houseOwner.Guild != null && ((Guild)houseOwner.Guild).Leader == houseOwner ) //Only the actual House owner AND guild master can set guild secures
{
AddButton( 10, 130, GetFirstID( SecureLevel.Guild ), 4007, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 130, 150, 20, 1063455, GetColor( SecureLevel.Guild ), false, false ); // Guild Members
}
AddButton( 10, 130 + offset, GetFirstID( SecureLevel.Anyone ), 4007, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 130 + offset, 150, 20, 1061626, GetColor( SecureLevel.Anyone ), false, false ); // Anyone
}
public int GetColor( SecureLevel level )
{
return ( m_Info.Level == level ) ? 0x7F18 : 0x7FFF;
}
public int GetFirstID( SecureLevel level )
{
return ( m_Info.Level == level ) ? 4006 : 4005;
}
public override void OnResponse( NetState state, RelayInfo info )
{
SecureLevel level = m_Info.Level;
switch ( info.ButtonID )
{
case 1: level = SecureLevel.Owner; break;
case 2: level = SecureLevel.CoOwners; break;
case 3: level = SecureLevel.Friends; break;
case 4: level = SecureLevel.Anyone; break;
case 5: level = SecureLevel.Guild; break;
}
if ( m_Info.Level == level )
{
state.Mobile.SendLocalizedMessage( 1061281 ); // Access level unchanged.
}
else
{
m_Info.Level = level;
state.Mobile.SendLocalizedMessage( 1061280 ); // New access level set.
}
}
}
}

507
Scripts/Gumps/SkillsGump.cs Normal file
View file

@ -0,0 +1,507 @@
using System;
using System.Collections;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Commands;
namespace Server.Gumps
{
public class EditSkillGump : Gump
{
public static readonly bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static readonly int EntryWidth = 160;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + (2 * (EntryHeight + OffsetSize));
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
private Mobile m_From;
private Mobile m_Target;
private Skill m_Skill;
private SkillsGumpGroup m_Selected;
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( info.ButtonID == 1 )
{
try
{
if ( m_From.AccessLevel >= AccessLevel.GameMaster )
{
TextRelay text = info.GetTextEntry( 0 );
if ( text != null )
{
m_Skill.Base = Convert.ToDouble( text.Text );
CommandLogging.LogChangeProperty( m_From, m_Target, String.Format( "{0}.Base", m_Skill ), m_Skill.Base.ToString() );
}
}
else
{
m_From.SendMessage( "You may not change that." );
}
m_From.SendGump( new SkillsGump( m_From, m_Target, m_Selected ) );
}
catch
{
m_From.SendMessage( "Bad format. ###.# expected." );
m_From.SendGump( new EditSkillGump( m_From, m_Target, m_Skill, m_Selected ) );
}
}
else
{
m_From.SendGump( new SkillsGump( m_From, m_Target, m_Selected ) );
}
}
public EditSkillGump( Mobile from, Mobile target, Skill skill, SkillsGumpGroup selected ) : base( GumpOffsetX, GumpOffsetY )
{
m_From = from;
m_Target = target;
m_Skill = skill;
m_Selected = selected;
string initialText = m_Skill.Base.ToString( "F1" );
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BackHeight, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), TotalHeight, OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, skill.Name );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddTextEntry( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, TextHue, 0, initialText );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, 1, GumpButtonType.Reply, 0 );
}
}
public class SkillsGump : Gump
{
public static bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
/*
private static bool PrevLabel = OldStyle, NextLabel = OldStyle;
private static readonly int PrevLabelOffsetX = PrevWidth + 1;
private static readonly int PrevLabelOffsetY = 0;
private static readonly int NextLabelOffsetX = -29;
private static readonly int NextLabelOffsetY = 0;
* */
private static readonly int NameWidth = 107;
private static readonly int ValueWidth = 128;
private static readonly int EntryCount = 15;
private static readonly int TypeWidth = NameWidth + OffsetSize + ValueWidth;
private static readonly int TotalWidth = OffsetSize + NameWidth + OffsetSize + ValueWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (EntryCount + 1));
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
private static readonly int IndentWidth = 12;
private Mobile m_From;
private Mobile m_Target;
private SkillsGumpGroup[] m_Groups;
private SkillsGumpGroup m_Selected;
public override void OnResponse( NetState sender, RelayInfo info )
{
int buttonID = info.ButtonID - 1;
int index = buttonID / 3;
int type = buttonID % 3;
switch ( type )
{
case 0:
{
if ( index >= 0 && index < m_Groups.Length )
{
SkillsGumpGroup newSelection = m_Groups[index];
if ( m_Selected != newSelection )
m_From.SendGump( new SkillsGump( m_From, m_Target, newSelection ) );
else
m_From.SendGump( new SkillsGump( m_From, m_Target, null ) );
}
break;
}
case 1:
{
if ( m_Selected != null && index >= 0 && index < m_Selected.Skills.Length )
{
Skill sk = m_Target.Skills[m_Selected.Skills[index]];
if ( sk != null )
{
if ( m_From.AccessLevel >= AccessLevel.GameMaster )
{
m_From.SendGump( new EditSkillGump( m_From, m_Target, sk, m_Selected ) );
}
else
{
m_From.SendMessage( "You may not change that." );
m_From.SendGump( new SkillsGump( m_From, m_Target, m_Selected ) );
}
}
else
{
m_From.SendGump( new SkillsGump( m_From, m_Target, m_Selected ) );
}
}
break;
}
case 2:
{
if ( m_Selected != null && index >= 0 && index < m_Selected.Skills.Length )
{
Skill sk = m_Target.Skills[m_Selected.Skills[index]];
if ( sk != null )
{
if ( m_From.AccessLevel >= AccessLevel.GameMaster )
{
switch ( sk.Lock )
{
case SkillLock.Up: sk.SetLockNoRelay( SkillLock.Down ); sk.Update(); break;
case SkillLock.Down: sk.SetLockNoRelay( SkillLock.Locked ); sk.Update(); break;
case SkillLock.Locked: sk.SetLockNoRelay( SkillLock.Up ); sk.Update(); break;
}
}
else
{
m_From.SendMessage( "You may not change that." );
}
m_From.SendGump( new SkillsGump( m_From, m_Target, m_Selected ) );
}
}
break;
}
}
}
public int GetButtonID( int type, int index )
{
return 1 + (index * 3) + type;
}
public SkillsGump( Mobile from, Mobile target ) : this( from, target, null )
{
}
public SkillsGump( Mobile from, Mobile target, SkillsGumpGroup selected ) : base( GumpOffsetX, GumpOffsetY )
{
m_From = from;
m_Target = target;
m_Groups = SkillsGumpGroup.Groups;
m_Selected = selected;
int count = m_Groups.Length;
if ( selected != null )
count += selected.Skills.Length;
int totalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (count + 1));
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight, OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
int emptyWidth = TotalWidth - PrevWidth - NextWidth - (OffsetSize * 4) - (OldStyle ? SetWidth + OffsetSize : 0);
if ( OldStyle )
AddImageTiled( x, y, TotalWidth - (OffsetSize * 3) - SetWidth, EntryHeight, HeaderGumpID );
else
AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );
x += PrevWidth + OffsetSize;
if ( !OldStyle )
AddImageTiled( x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, HeaderGumpID );
x += emptyWidth + OffsetSize;
if ( !OldStyle )
AddImageTiled( x, y, NextWidth, EntryHeight, HeaderGumpID );
for ( int i = 0; i < m_Groups.Length; ++i )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
SkillsGumpGroup group = m_Groups[i];
AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );
if ( group == selected )
AddButton( x + PrevOffsetX, y + PrevOffsetY, 0x15E2, 0x15E6, GetButtonID( 0, i ), GumpButtonType.Reply, 0 );
else
AddButton( x + PrevOffsetX, y + PrevOffsetY, 0x15E1, 0x15E5, GetButtonID( 0, i ), GumpButtonType.Reply, 0 );
x += PrevWidth + OffsetSize;
x -= (OldStyle ? OffsetSize : 0);
AddImageTiled( x, y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, EntryGumpID );
AddLabel( x + TextOffsetX, y, TextHue, group.Name );
x += emptyWidth + (OldStyle ? OffsetSize * 2 : 0);
x += OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
if ( group == selected )
{
int indentMaskX = BorderSize;
int indentMaskY = y + EntryHeight + OffsetSize;
for ( int j = 0; j < group.Skills.Length; ++j )
{
Skill sk = target.Skills[group.Skills[j]];
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
x += OffsetSize;
x += IndentWidth;
AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );
AddButton( x + PrevOffsetX, y + PrevOffsetY, 0x15E1, 0x15E5, GetButtonID( 1, j ), GumpButtonType.Reply, 0 );
x += PrevWidth + OffsetSize;
x -= (OldStyle ? OffsetSize : 0);
AddImageTiled( x, y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0) - OffsetSize - IndentWidth, EntryHeight, EntryGumpID );
AddLabel( x + TextOffsetX, y, TextHue, sk == null ? "(null)" : sk.Name );
x += emptyWidth + (OldStyle ? OffsetSize * 2 : 0) - OffsetSize - IndentWidth;
x += OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
if ( sk != null )
{
int buttonID1, buttonID2;
int xOffset, yOffset;
switch ( sk.Lock )
{
default:
case SkillLock.Up: buttonID1 = 0x983; buttonID2 = 0x983; xOffset = 6; yOffset = 4; break;
case SkillLock.Down: buttonID1 = 0x985; buttonID2 = 0x985; xOffset = 6; yOffset = 4; break;
case SkillLock.Locked: buttonID1 = 0x82C; buttonID2 = 0x82C; xOffset = 5; yOffset = 2; break;
}
AddButton( x + xOffset, y + yOffset, buttonID1, buttonID2, GetButtonID( 2, j ), GumpButtonType.Reply, 0 );
y += 1;
x -= OffsetSize;
x -= 1;
x -= 50;
AddImageTiled( x, y, 50, EntryHeight - 2, OffsetGumpID );
x += 1;
y += 1;
AddImageTiled( x, y, 48, EntryHeight - 4, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y - 1, 48 - TextOffsetX, EntryHeight - 3, TextHue, sk.Base.ToString( "F1" ) );
y -= 2;
}
}
AddImageTiled( indentMaskX, indentMaskY, IndentWidth + OffsetSize, (group.Skills.Length * (EntryHeight + OffsetSize)) - (i < (m_Groups.Length - 1) ? OffsetSize : 0), BackGumpID + 4 );
}
}
}
}
public class SkillsGumpGroup
{
private string m_Name;
private SkillName[] m_Skills;
public string Name{ get{ return m_Name; } }
public SkillName[] Skills{ get{ return m_Skills; } }
public SkillsGumpGroup( string name, SkillName[] skills )
{
m_Name = name;
m_Skills = skills;
Array.Sort( m_Skills, new SkillNameComparer() );
}
private class SkillNameComparer : IComparer
{
public SkillNameComparer()
{
}
public int Compare( object x, object y )
{
SkillName a = (SkillName)x;
SkillName b = (SkillName)y;
string aName = SkillInfo.Table[(int)a].Name;
string bName = SkillInfo.Table[(int)b].Name;
return aName.CompareTo( bName );
}
}
private static SkillsGumpGroup[] m_Groups = new SkillsGumpGroup[]
{
new SkillsGumpGroup( "Bardic", new SkillName[]
{
SkillName.Discordance,
SkillName.Musicianship,
SkillName.Peacemaking,
SkillName.Provocation
} ),
new SkillsGumpGroup( "Magical", new SkillName[]
{
SkillName.Concentration,
SkillName.Magery,
SkillName.MagicResist,
SkillName.Meditation
} ),
new SkillsGumpGroup( "Combat", new SkillName[]
{
SkillName.Archery,
SkillName.Fencing,
SkillName.Bludgeoning,
SkillName.Parry,
SkillName.Swords,
SkillName.Tactics,
SkillName.HandToHand
} ),
new SkillsGumpGroup( "Actions", new SkillName[]
{
SkillName.Healing,
SkillName.Hiding,
SkillName.Lockpicking,
SkillName.Poisoning,
SkillName.RemoveTrap,
SkillName.Searching,
SkillName.Stealing,
SkillName.Stealth,
SkillName.Tracking
} )
};
public static SkillsGumpGroup[] Groups
{
get{ return m_Groups; }
}
}
}

View file

@ -0,0 +1,119 @@
using System;
using System.Collections;
using Server;
using Server.Network;
using Server.Multis;
using Server.Mobiles;
namespace Server.Gumps
{
public class VendorInventoryGump : Gump
{
private BaseHouse m_House;
private ArrayList m_Inventories;
public VendorInventoryGump( BaseHouse house, Mobile from ) : base( 50, 50 )
{
m_House = house;
m_Inventories = new ArrayList( house.VendorInventories );
AddBackground( 0, 0, 420, 50 + 20 * m_Inventories.Count, 0x13BE );
AddImageTiled( 10, 10, 400, 20, 0xA40 );
AddHtmlLocalized( 15, 10, 200, 20, 1062435, 0x7FFF, false, false ); // Reclaim Vendor Inventory
AddHtmlLocalized( 330, 10, 50, 20, 1062465, 0x7FFF, false, false ); // Expires
AddImageTiled( 10, 40, 400, 20 * m_Inventories.Count, 0xA40 );
for ( int i = 0; i < m_Inventories.Count; i++ )
{
VendorInventory inventory = (VendorInventory) m_Inventories[i];
int y = 40 + 20 * i;
if ( inventory.Owner == from )
AddButton( 10, y, 0xFA5, 0xFA7, i + 1, GumpButtonType.Reply, 0 );
AddLabel( 45, y, 0x481, String.Format( "{0} ({1})", inventory.ShopName, inventory.VendorName ) );
TimeSpan expire = inventory.ExpireTime - DateTime.Now;
int hours = (int) expire.TotalHours;
AddLabel( 320, y, 0x481, hours.ToString() );
AddHtmlLocalized( 350, y, 50, 20, 1062466, 0x7FFF, false, false ); // hour(s)
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( info.ButtonID == 0 )
return;
Mobile from = sender.Mobile;
HouseSign sign = m_House.Sign;
if ( m_House.Deleted || sign == null || sign.Deleted || !from.CheckAlive() )
return;
if ( from.Map != sign.Map || !from.InRange( sign, 5 ) )
{
from.SendLocalizedMessage( 1062429 ); // You must be within five paces of the house sign to use this option.
return;
}
int index = info.ButtonID - 1;
if ( index < 0 || index >= m_Inventories.Count )
return;
VendorInventory inventory = (VendorInventory) m_Inventories[index];
if ( inventory.Owner != from || !m_House.VendorInventories.Contains( inventory ) )
return;
int totalItems = 0;
int givenToBackpack = 0;
int givenToInnBox = 0;
for ( int i = inventory.Items.Count - 1; i >= 0; i-- )
{
Item item = inventory.Items[i];
if ( item.Deleted )
{
inventory.Items.RemoveAt( i );
continue;
}
totalItems += 1 + item.TotalItems;
if ( from.PlaceInBackpack( item ) )
{
inventory.Items.RemoveAt( i );
givenToBackpack += 1 + item.TotalItems;
}
else if ( from.InnBox.TryDropItem( from, item, false ) )
{
inventory.Items.RemoveAt( i );
givenToInnBox += 1 + item.TotalItems;
}
}
from.SendLocalizedMessage( 1062436, totalItems.ToString() + "\t" + inventory.Gold.ToString() ); // The vendor you selected had ~1_COUNT~ items in its inventory, and ~2_AMOUNT~ gold in its account.
int givenGold = Innkeeper.DepositUpTo( from, inventory.Gold );
inventory.Gold -= givenGold;
from.SendLocalizedMessage( 1060397, givenGold.ToString() ); // ~1_AMOUNT~ gold has been deposited into your inn chest.
from.SendLocalizedMessage( 1062437, givenToBackpack.ToString() + "\t" + givenToInnBox.ToString() ); // ~1_COUNT~ items have been removed from the shop inventory and placed in your backpack. ~2_BANKCOUNT~ items were removed from the shop inventory and placed in your inn chest.
if ( inventory.Gold > 0 || inventory.Items.Count > 0 )
{
from.SendLocalizedMessage( 1062440 ); // Some of the shop inventory would not fit in your backpack or inn chest. Please free up some room and try again.
}
else
{
inventory.Delete();
from.SendLocalizedMessage( 1062438 ); // The shop is now empty of inventory and funds, so it has been deleted.
}
}
}
}

View file

@ -0,0 +1,616 @@
using System;
using Server;
using Server.Items;
using Server.Network;
using Server.Prompts;
using Server.Mobiles;
using Server.Targeting;
using Server.Multis;
namespace Server.Gumps
{
public abstract class BaseVendorRentalGump : Gump
{
protected enum GumpType
{
UnlockedContract,
LockedContract,
Offer,
VendorLandlord,
VendorRenter
}
protected BaseVendorRentalGump( GumpType type, VendorRentalDuration duration, int price, int renewalPrice,
Mobile landlord, Mobile renter, bool landlordRenew, bool renterRenew, bool renew ) : base( 100, 100 )
{
if ( type == GumpType.Offer )
Closable = false;
AddPage( 0 );
AddImage( 0, 0, 0x1F40 );
AddImageTiled( 20, 37, 300, 308, 0x1F42 );
AddImage( 20, 325, 0x1F43 );
AddImage( 35, 8, 0x39 );
AddImageTiled( 65, 8, 257, 10, 0x3A );
AddImage( 290, 8, 0x3B );
AddImageTiled( 70, 55, 230, 2, 0x23C5 );
AddImage( 32, 33, 0x2635 );
AddHtmlLocalized( 70, 35, 270, 20, 1062353, 0x1, false, false ); // Vendor Rental Contract
AddPage( 1 );
if ( type != GumpType.UnlockedContract )
{
AddImage( 65, 60, 0x827 );
AddHtmlLocalized( 79, 58, 270, 20, 1062370, 0x1, false, false ); // Landlord:
AddLabel( 150, 58, 0x64, landlord != null ? landlord.Name : "" );
AddImageTiled( 70, 80, 230, 2, 0x23C5 );
}
if ( type == GumpType.UnlockedContract || type == GumpType.LockedContract )
AddButton( 30, 96, 0x15E1, 0x15E5, 0, GumpButtonType.Page, 2 );
AddHtmlLocalized( 50, 95, 150, 20, 1062354, 0x1, false, false ); // Contract Length
AddHtmlLocalized( 230, 95, 270, 20, duration.Name, 0x1, false, false );
if ( type == GumpType.UnlockedContract || type == GumpType.LockedContract )
AddButton( 30, 116, 0x15E1, 0x15E5, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 50, 115, 150, 20, 1062356, 0x1, false, false ); // Price Per Rental
AddLabel( 230, 115, 0x64, price > 0 ? price.ToString() : "FREE" );
AddImageTiled( 50, 160, 250, 2, 0x23BF );
if ( type == GumpType.Offer )
{
AddButton( 67, 180, 0x482, 0x483, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 100, 180, 270, 20, 1049011, 0x28, false, false ); // I accept!
AddButton( 67, 210, 0x47F, 0x480, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 100, 210, 270, 20, 1049012, 0x28, false, false ); // No thanks, I decline.
}
else
{
AddImage( 49, 170, 0x61 );
AddHtmlLocalized( 60, 170, 250, 20, 1062355, 0x1, false, false ); // Renew On Expiration?
if ( type == GumpType.LockedContract || type == GumpType.UnlockedContract || type == GumpType.VendorLandlord )
AddButton( 30, 192, 0x15E1, 0x15E5, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 85, 190, 250, 20, 1062359, 0x1, false, false ); // Landlord:
AddHtmlLocalized( 230, 190, 270, 20, landlordRenew ? 1049717 : 1049718, 0x1, false, false ); // YES / NO
if ( type == GumpType.VendorRenter )
AddButton( 30, 212, 0x15E1, 0x15E5, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 85, 210, 250, 20, 1062360, 0x1, false, false ); // Renter:
AddHtmlLocalized( 230, 210, 270, 20, renterRenew ? 1049717 : 1049718, 0x1, false, false ); // YES / NO
if ( renew )
{
AddImage( 49, 233, 0x939 );
AddHtmlLocalized( 70, 230, 250, 20, 1062482, 0x1, false, false ); // Contract WILL renew
}
else
{
AddImage( 49, 233, 0x938 );
AddHtmlLocalized( 70, 230, 250, 20, 1062483, 0x1, false, false ); // Contract WILL NOT renew
}
}
AddImageTiled( 30, 283, 257, 30, 0x5D );
AddImage( 285, 283, 0x5E );
AddImage( 20, 288, 0x232C );
if ( type == GumpType.LockedContract )
{
AddButton( 67, 295, 0x15E1, 0x15E5, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 85, 294, 270, 20, 1062358, 0x28, false, false ); // Offer Contract To Someone
}
else if ( type == GumpType.VendorLandlord || type == GumpType.VendorRenter )
{
if ( type == GumpType.VendorLandlord )
AddButton( 30, 250, 0x15E1, 0x15E1, 6, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 85, 250, 250, 20, 1062499, 0x1, false, false ); // Renewal Price
AddLabel( 230, 250, 0x64, renewalPrice.ToString() );
AddHtmlLocalized( 60, 294, 270, 20, 1062369, 0x1, false, false ); // Renter:
AddLabel( 120, 293, 0x64, renter != null ? renter.Name : "" );
}
if ( type == GumpType.UnlockedContract || type == GumpType.LockedContract )
{
AddPage( 2 );
for ( int i = 0; i < VendorRentalDuration.Instances.Length; i++ )
{
VendorRentalDuration durationItem = VendorRentalDuration.Instances[i];
AddButton( 30, 76 + i * 20, 0x15E1, 0x15E5, 0x10 | i, GumpButtonType.Reply, 1 );
AddHtmlLocalized( 50, 75 + i * 20, 150, 20, durationItem.Name, 0x1, false, false );
}
}
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
if ( !IsValidResponse( from ) )
return;
if ( (info.ButtonID & 0x10) != 0 ) // Contract duration
{
int index = info.ButtonID & 0xF;
if ( index < VendorRentalDuration.Instances.Length )
{
SetContractDuration( from, VendorRentalDuration.Instances[index] );
}
}
else
{
switch ( info.ButtonID )
{
case 1: // Price Per Rental
SetPricePerRental( from );
break;
case 2: // Accept offer
AcceptOffer( from );
break;
case 3: // Renew on expiration - landlord
LandlordRenewOnExpiration( from );
break;
case 4: // Renew on expiration - renter
RenterRenewOnExpiration( from );
break;
case 5: // Offer Contract To Someone
OfferContract( from );
break;
case 6: // Renewal price
SetRenewalPrice( from );
break;
default:
Cancel( from );
break;
}
}
}
protected abstract bool IsValidResponse( Mobile from );
protected virtual void SetContractDuration( Mobile from, VendorRentalDuration duration )
{
}
protected virtual void SetPricePerRental( Mobile from )
{
}
protected virtual void AcceptOffer( Mobile from )
{
}
protected virtual void LandlordRenewOnExpiration( Mobile from )
{
}
protected virtual void RenterRenewOnExpiration( Mobile from )
{
}
protected virtual void OfferContract( Mobile from )
{
}
protected virtual void SetRenewalPrice( Mobile from )
{
}
protected virtual void Cancel( Mobile from )
{
}
}
public class VendorRentalContractGump : BaseVendorRentalGump
{
private VendorRentalContract m_Contract;
public VendorRentalContractGump( VendorRentalContract contract, Mobile from ) : base(
contract.IsLockedDown ? GumpType.LockedContract : GumpType.UnlockedContract, contract.Duration,
contract.Price, contract.Price, from, null, contract.LandlordRenew, false, false )
{
m_Contract = contract;
}
protected override bool IsValidResponse( Mobile from )
{
return m_Contract.IsUsableBy( from, true, true, true, true );
}
protected override void SetContractDuration( Mobile from, VendorRentalDuration duration )
{
m_Contract.Duration = duration;
from.SendGump( new VendorRentalContractGump( m_Contract, from ) );
}
protected override void SetPricePerRental( Mobile from )
{
from.SendLocalizedMessage( 1062365 ); // Please enter the amount of gold that should be charged for this contract (ESC to cancel):
from.Prompt = new PricePerRentalPrompt( m_Contract );
}
protected override void LandlordRenewOnExpiration( Mobile from )
{
m_Contract.LandlordRenew = !m_Contract.LandlordRenew;
from.SendGump( new VendorRentalContractGump( m_Contract, from ) );
}
protected override void OfferContract( Mobile from )
{
if ( m_Contract.IsLandlord( from ) )
{
from.SendLocalizedMessage( 1062371 ); // Please target the person you wish to offer this contract to.
from.Target = new OfferContractTarget( m_Contract );
}
}
private class PricePerRentalPrompt : Prompt
{
private VendorRentalContract m_Contract;
public PricePerRentalPrompt( VendorRentalContract contract )
{
m_Contract = contract;
}
public override void OnResponse( Mobile from, string text )
{
if ( !m_Contract.IsUsableBy( from, true, true, true, true ) )
return;
text = text.Trim();
int price;
if ( !int.TryParse( text, out price ) )
price = -1;
if ( price < 0 )
{
from.SendLocalizedMessage( 1062485 ); // Invalid entry. Rental fee set to 0.
m_Contract.Price = 0;
}
else if ( price > 5000000 )
{
m_Contract.Price = 5000000;
}
else
{
m_Contract.Price = price;
}
from.SendGump( new VendorRentalContractGump( m_Contract, from ) );
}
public override void OnCancel( Mobile from )
{
if ( m_Contract.IsUsableBy( from, true, true, true, true ) )
from.SendGump( new VendorRentalContractGump( m_Contract, from ) );
}
}
private class OfferContractTarget : Target
{
private VendorRentalContract m_Contract;
public OfferContractTarget( VendorRentalContract contract ) : base( -1, false, TargetFlags.None )
{
m_Contract = contract;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( !m_Contract.IsUsableBy( from, true, false, true, true ) )
return;
Mobile mob = targeted as Mobile;
if ( mob == null || !mob.Player || !mob.Alive || mob == from )
{
from.SendLocalizedMessage(1071984); //That is not a valid target for a rental contract!
}
else if ( !mob.InRange( m_Contract, 5 ) )
{
from.SendLocalizedMessage( 501853 ); // Target is too far away.
}
else
{
from.SendLocalizedMessage( 1062372 ); // Please wait while that person considers your offer.
mob.SendLocalizedMessage( 1062373, from.Name ); // ~1_NAME~ is offering you a vendor rental. If you choose to accept this offer, you have 30 seconds to do so.
mob.SendGump( new VendorRentalOfferGump( m_Contract, from ) );
m_Contract.Offeree = mob;
}
}
protected override void OnTargetCancel( Mobile from, TargetCancelType cancelType )
{
from.SendLocalizedMessage( 1062380 ); // You decide against offering the contract to anyone.
}
}
}
public class VendorRentalOfferGump : BaseVendorRentalGump
{
private VendorRentalContract m_Contract;
private Mobile m_Landlord;
public VendorRentalOfferGump( VendorRentalContract contract, Mobile landlord ) : base(
GumpType.Offer, contract.Duration, contract.Price, contract.Price,
landlord, null, contract.LandlordRenew, false, false )
{
m_Contract = contract;
m_Landlord = landlord;
}
protected override bool IsValidResponse( Mobile from )
{
return m_Contract.IsUsableBy( m_Landlord, true, false, false, false ) && from.CheckAlive() && m_Contract.Offeree == from;
}
protected override void AcceptOffer( Mobile from )
{
m_Contract.Offeree = null;
if ( !m_Contract.Map.CanFit( m_Contract.Location, 16, false, false ) )
{
m_Landlord.SendLocalizedMessage( 1062486 ); // A vendor cannot exist at that location. Please try again.
return;
}
BaseHouse house = BaseHouse.FindHouseAt( m_Contract );
if ( house == null )
return;
int price = m_Contract.Price;
int goldToGive;
if ( price > 0 )
{
if ( Innkeeper.Withdraw( from, price ) )
{
from.SendLocalizedMessage( 1060398, price.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your inn chest.
int depositedGold = Innkeeper.DepositUpTo( m_Landlord, price );
goldToGive = price - depositedGold;
if ( depositedGold > 0 )
m_Landlord.SendLocalizedMessage( 1060397, price.ToString() ); // ~1_AMOUNT~ gold has been deposited into your inn chest.
if ( goldToGive > 0 )
m_Landlord.SendLocalizedMessage( 500390 ); // Your inn chest is full.
}
else
{
from.SendLocalizedMessage( 1062378 ); // You do not have enough gold in your inn chest to cover the cost of the contract.
m_Landlord.SendLocalizedMessage( 1062374, from.Name ); // ~1_NAME~ has declined your vendor rental offer.
return;
}
}
else
{
goldToGive = 0;
}
PlayerVendor vendor = new RentedVendor( from, house, m_Contract.Duration, price, m_Contract.LandlordRenew, goldToGive );
vendor.MoveToWorld( m_Contract.Location, m_Contract.Map );
m_Contract.Delete();
from.SendLocalizedMessage( 1062377 ); // You have accepted the offer and now own a vendor in this house. Rental contract options and details may be viewed on this vendor via the 'Contract Options' context menu.
m_Landlord.SendLocalizedMessage( 1062376, from.Name ); // ~1_NAME~ has accepted your vendor rental offer. Rental contract details and options may be viewed on this vendor via the 'Contract Options' context menu.
}
protected override void Cancel( Mobile from )
{
m_Contract.Offeree = null;
from.SendLocalizedMessage( 1062375 ); // You decline the offer for a vendor space rental.
m_Landlord.SendLocalizedMessage( 1062374, from.Name ); // ~1_NAME~ has declined your vendor rental offer.
}
}
public class RenterVendorRentalGump : BaseVendorRentalGump
{
private RentedVendor m_Vendor;
public RenterVendorRentalGump( RentedVendor vendor ) : base(
GumpType.VendorRenter, vendor.RentalDuration, vendor.RentalPrice, vendor.RenewalPrice,
vendor.Landlord, vendor.Owner, vendor.LandlordRenew, vendor.RenterRenew, vendor.Renew )
{
m_Vendor = vendor;
}
protected override bool IsValidResponse( Mobile from )
{
return m_Vendor.CanInteractWith( from, true );
}
protected override void RenterRenewOnExpiration( Mobile from )
{
m_Vendor.RenterRenew = !m_Vendor.RenterRenew;
from.SendGump( new RenterVendorRentalGump( m_Vendor ) );
}
}
public class LandlordVendorRentalGump : BaseVendorRentalGump
{
private RentedVendor m_Vendor;
public LandlordVendorRentalGump( RentedVendor vendor ) : base(
GumpType.VendorLandlord, vendor.RentalDuration, vendor.RentalPrice, vendor.RenewalPrice,
vendor.Landlord, vendor.Owner, vendor.LandlordRenew, vendor.RenterRenew, vendor.Renew )
{
m_Vendor = vendor;
}
protected override bool IsValidResponse( Mobile from )
{
return m_Vendor.CanInteractWith( from, false ) && m_Vendor.IsLandlord( from );
}
protected override void LandlordRenewOnExpiration( Mobile from )
{
m_Vendor.LandlordRenew = !m_Vendor.LandlordRenew;
from.SendGump( new LandlordVendorRentalGump( m_Vendor ) );
}
protected override void SetRenewalPrice( Mobile from )
{
from.SendLocalizedMessage( 1062500 ); // Enter contract renewal price:
from.Prompt = new ContractRenewalPricePrompt( m_Vendor );
}
private class ContractRenewalPricePrompt : Prompt
{
private RentedVendor m_Vendor;
public ContractRenewalPricePrompt( RentedVendor vendor )
{
m_Vendor = vendor;
}
public override void OnResponse( Mobile from, string text )
{
if ( !m_Vendor.CanInteractWith( from, false ) || !m_Vendor.IsLandlord( from ) )
return;
text = text.Trim();
int price;
if ( !int.TryParse( text, out price ) )
price = -1;
if ( price < 0 )
{
from.SendLocalizedMessage( 1062485 ); // Invalid entry. Rental fee set to 0.
m_Vendor.RenewalPrice = 0;
}
else if ( price > 5000000 )
{
m_Vendor.RenewalPrice = 5000000;
}
else
{
m_Vendor.RenewalPrice = price;
}
m_Vendor.RenterRenew = false;
from.SendGump( new LandlordVendorRentalGump( m_Vendor ) );
}
public override void OnCancel( Mobile from )
{
if ( m_Vendor.CanInteractWith( from, false ) && m_Vendor.IsLandlord( from ) )
from.SendGump( new LandlordVendorRentalGump( m_Vendor ) );
}
}
}
public class VendorRentalRefundGump : Gump
{
private RentedVendor m_Vendor;
private Mobile m_Landlord;
private int m_RefundAmount;
public VendorRentalRefundGump( RentedVendor vendor, Mobile landlord, int refundAmount ) : base( 50, 50 )
{
m_Vendor = vendor;
m_Landlord = landlord;
m_RefundAmount = refundAmount;
AddBackground( 0, 0, 420, 320, 0x13BE );
AddImageTiled( 10, 10, 400, 300, 0xA40 );
AddAlphaRegion( 10, 10, 400, 300 );
/* The landlord for this vendor is offering you a partial refund of your rental fee
* in exchange for immediate termination of your rental contract.<BR><BR>
*
* If you accept this offer, the vendor will be immediately dismissed. You will then
* be able to claim the inventory and any funds the vendor may be holding for you via
* a context menu on the house sign for this house.
*/
AddHtmlLocalized( 10, 10, 400, 150, 1062501, 0x7FFF, false, true );
AddHtmlLocalized( 10, 180, 150, 20, 1062508, 0x7FFF, false, false ); // Vendor Name:
AddLabel( 160, 180, 0x480, vendor.Name );
AddHtmlLocalized( 10, 200, 150, 20, 1062509, 0x7FFF, false, false ); // Shop Name:
AddLabel( 160, 200, 0x480, vendor.ShopName );
AddHtmlLocalized( 10, 220, 150, 20, 1062510, 0x7FFF, false, false ); // Refund Amount:
AddLabel( 160, 220, 0x480, refundAmount.ToString() );
AddButton( 10, 268, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 268, 350, 20, 1062511, 0x7FFF, false, false ); // Agree, and <strong>dismiss vendor</strong>
AddButton( 10, 288, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 288, 350, 20, 1062512, 0x7FFF, false, false ); // No, I want to <strong>keep my vendor</strong>
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
if ( !m_Vendor.CanInteractWith( from, true ) || !m_Vendor.CanInteractWith( m_Landlord, false ) || !m_Vendor.IsLandlord( m_Landlord ) )
return;
if ( info.ButtonID == 1 )
{
if ( Innkeeper.Withdraw( m_Landlord, m_RefundAmount ) )
{
m_Landlord.SendLocalizedMessage( 1060398, m_RefundAmount.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your inn chest.
int depositedGold = Innkeeper.DepositUpTo( from, m_RefundAmount );
if ( depositedGold > 0 )
from.SendLocalizedMessage( 1060397, depositedGold.ToString() ); // ~1_AMOUNT~ gold has been deposited into your inn chest.
m_Vendor.HoldGold += m_RefundAmount - depositedGold;
m_Vendor.Destroy( false );
from.SendLocalizedMessage(1071990); //Remember to claim your vendor's belongings from the house sign!
}
else
{
m_Landlord.SendLocalizedMessage( 1062507 ); // You do not have that much money in your inn chest.
}
}
else
{
m_Landlord.SendLocalizedMessage( 1062513 ); // The renter declined your offer.
}
}
}
}

View file

@ -0,0 +1,64 @@
using System;
using Server;
namespace Server.Gumps
{
public delegate void WarningGumpCallback( Mobile from, bool okay, object state );
public class WarningGump : Gump
{
private WarningGumpCallback m_Callback;
private object m_State;
private bool m_CancelButton;
public WarningGump( int header, int headerColor, object content, int contentColor, int width, int height, WarningGumpCallback callback, object state )
: this( header, headerColor, content, contentColor, width, height, callback, state, true )
{
}
public WarningGump( int header, int headerColor, object content, int contentColor, int width, int height, WarningGumpCallback callback, object state, bool cancelButton ) : base( (640 - width) / 2, (480 - height) / 2 )
{
m_Callback = callback;
m_State = state;
m_CancelButton = cancelButton;
Closable = false;
AddPage( 0 );
AddBackground( 0, 0, width, height, 5054 );
AddImageTiled( 10, 10, width - 20, 20, 2624 );
AddAlphaRegion( 10, 10, width - 20, 20 );
AddHtmlLocalized( 10, 10, width - 20, 20, header, headerColor, false, false );
AddImageTiled( 10, 40, width - 20, height - 80, 2624 );
AddAlphaRegion( 10, 40, width - 20, height - 80 );
if ( content is int )
AddHtmlLocalized( 10, 40, width - 20, height - 80, (int)content, contentColor, false, true );
else if ( content is string )
AddHtml( 10, 40, width - 20, height - 80, String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", contentColor, content ), false, true );
AddImageTiled( 10, height - 30, width - 20, 20, 2624 );
AddAlphaRegion( 10, height - 30, width - 20, 20 );
AddButton( 10, height - 30, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 40, height - 30, 170, 20, 1011036, 32767, false, false ); // OKAY
if( m_CancelButton )
{
AddButton( 10 + ((width - 20) / 2), height - 30, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 40 + ((width - 20) / 2), height - 30, 170, 20, 1011012, 32767, false, false ); // CANCEL
}
}
public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
{
if ( info.ButtonID == 1 && m_Callback != null )
m_Callback( sender.Mobile, true, m_State );
else if ( m_Callback != null )
m_Callback( sender.Mobile, false, m_State );
}
}
}

300
Scripts/Gumps/WhoGump.cs Normal file
View file

@ -0,0 +1,300 @@
using System;
using System.Collections.Generic;
using Server.Commands;
using Server.Mobiles;
using Server.Network;
namespace Server.Gumps
{
public class WhoGump : Gump
{
public static void Initialize()
{
CommandSystem.Register( "Who", AccessLevel.Counselor, new CommandEventHandler( WhoList_OnCommand ) );
CommandSystem.Register( "WhoList", AccessLevel.Counselor, new CommandEventHandler( WhoList_OnCommand ) );
}
[Usage( "WhoList [filter]" )]
[Aliases( "Who" )]
[Description( "Lists all connected clients. Optionally filters results by name." )]
private static void WhoList_OnCommand( CommandEventArgs e )
{
e.Mobile.SendGump( new WhoGump( e.Mobile, e.ArgString ) );
}
public static bool OldStyle = PropsConfig.OldStyle;
public static readonly int GumpOffsetX = PropsConfig.GumpOffsetX;
public static readonly int GumpOffsetY = PropsConfig.GumpOffsetY;
public static readonly int TextHue = PropsConfig.TextHue;
public static readonly int TextOffsetX = PropsConfig.TextOffsetX;
public static readonly int OffsetGumpID = PropsConfig.OffsetGumpID;
public static readonly int HeaderGumpID = PropsConfig.HeaderGumpID;
public static readonly int EntryGumpID = PropsConfig.EntryGumpID;
public static readonly int BackGumpID = PropsConfig.BackGumpID;
public static readonly int SetGumpID = PropsConfig.SetGumpID;
public static readonly int SetWidth = PropsConfig.SetWidth;
public static readonly int SetOffsetX = PropsConfig.SetOffsetX, SetOffsetY = PropsConfig.SetOffsetY;
public static readonly int SetButtonID1 = PropsConfig.SetButtonID1;
public static readonly int SetButtonID2 = PropsConfig.SetButtonID2;
public static readonly int PrevWidth = PropsConfig.PrevWidth;
public static readonly int PrevOffsetX = PropsConfig.PrevOffsetX, PrevOffsetY = PropsConfig.PrevOffsetY;
public static readonly int PrevButtonID1 = PropsConfig.PrevButtonID1;
public static readonly int PrevButtonID2 = PropsConfig.PrevButtonID2;
public static readonly int NextWidth = PropsConfig.NextWidth;
public static readonly int NextOffsetX = PropsConfig.NextOffsetX, NextOffsetY = PropsConfig.NextOffsetY;
public static readonly int NextButtonID1 = PropsConfig.NextButtonID1;
public static readonly int NextButtonID2 = PropsConfig.NextButtonID2;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = PropsConfig.EntryHeight;
public static readonly int BorderSize = PropsConfig.BorderSize;
private static bool PrevLabel = false, NextLabel = false;
private static readonly int PrevLabelOffsetX = PrevWidth + 1;
private static readonly int PrevLabelOffsetY = 0;
private static readonly int NextLabelOffsetX = -29;
private static readonly int NextLabelOffsetY = 0;
private static readonly int EntryWidth = 180;
private static readonly int EntryCount = 15;
private static readonly int TotalWidth = OffsetSize + EntryWidth + OffsetSize + SetWidth + OffsetSize;
private static readonly int TotalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (EntryCount + 1));
private static readonly int BackWidth = BorderSize + TotalWidth + BorderSize;
private static readonly int BackHeight = BorderSize + TotalHeight + BorderSize;
private Mobile m_Owner;
private List<Mobile> m_Mobiles;
private int m_Page;
private class InternalComparer : IComparer<Mobile>
{
public static readonly IComparer<Mobile> Instance = new InternalComparer();
public InternalComparer()
{
}
public int Compare( Mobile x, Mobile y )
{
if ( x == null || y == null )
throw new ArgumentException();
if ( x.AccessLevel > y.AccessLevel )
return -1;
else if ( x.AccessLevel < y.AccessLevel )
return 1;
else
return Insensitive.Compare( x.Name, y.Name );
}
}
public WhoGump( Mobile owner, string filter ) : this( owner, BuildList( owner, filter ), 0 )
{
}
public WhoGump( Mobile owner, List<Mobile> list, int page ) : base( GumpOffsetX, GumpOffsetY )
{
owner.CloseGump( typeof( WhoGump ) );
m_Owner = owner;
m_Mobiles = list;
Initialize( page );
}
public static List<Mobile> BuildList( Mobile owner, string filter )
{
if ( filter != null && (filter = filter.Trim()).Length == 0 )
filter = null;
else
filter = filter.ToLower();
List<Mobile> list = new List<Mobile>();
List<NetState> states = NetState.Instances;
for ( int i = 0; i < states.Count; ++i )
{
Mobile m = states[i].Mobile;
if ( m != null && (m == owner || !m.Hidden || owner.AccessLevel > m.AccessLevel || (m is PlayerMobile && ((PlayerMobile)m).VisibilityList.Contains( owner ) ) ) )
{
if ( filter != null && ( m.Name == null || m.Name.ToLower().IndexOf( filter ) < 0 ) )
continue;
list.Add( m );
}
}
list.Sort( InternalComparer.Instance );
return list;
}
public void Initialize( int page )
{
m_Page = page;
int count = m_Mobiles.Count - (page * EntryCount);
if ( count < 0 )
count = 0;
else if ( count > EntryCount )
count = EntryCount;
int totalHeight = OffsetSize + ((EntryHeight + OffsetSize) * (count + 1));
AddPage( 0 );
AddBackground( 0, 0, BackWidth, BorderSize + totalHeight + BorderSize, BackGumpID );
AddImageTiled( BorderSize, BorderSize, TotalWidth - (OldStyle ? SetWidth + OffsetSize : 0), totalHeight, OffsetGumpID );
int x = BorderSize + OffsetSize;
int y = BorderSize + OffsetSize;
int emptyWidth = TotalWidth - PrevWidth - NextWidth - (OffsetSize * 4) - (OldStyle ? SetWidth + OffsetSize : 0);
if ( !OldStyle )
AddImageTiled( x - (OldStyle ? OffsetSize : 0), y, emptyWidth + (OldStyle ? OffsetSize * 2 : 0), EntryHeight, EntryGumpID );
AddLabel( x + TextOffsetX, y, TextHue, String.Format( "Page {0} of {1} ({2})", page+1, (m_Mobiles.Count + EntryCount - 1) / EntryCount, m_Mobiles.Count ) );
x += emptyWidth + OffsetSize;
if ( OldStyle )
AddImageTiled( x, y, TotalWidth - (OffsetSize * 3) - SetWidth, EntryHeight, HeaderGumpID );
else
AddImageTiled( x, y, PrevWidth, EntryHeight, HeaderGumpID );
if ( page > 0 )
{
AddButton( x + PrevOffsetX, y + PrevOffsetY, PrevButtonID1, PrevButtonID2, 1, GumpButtonType.Reply, 0 );
if ( PrevLabel )
AddLabel( x + PrevLabelOffsetX, y + PrevLabelOffsetY, TextHue, "Previous" );
}
x += PrevWidth + OffsetSize;
if ( !OldStyle )
AddImageTiled( x, y, NextWidth, EntryHeight, HeaderGumpID );
if ( (page + 1) * EntryCount < m_Mobiles.Count )
{
AddButton( x + NextOffsetX, y + NextOffsetY, NextButtonID1, NextButtonID2, 2, GumpButtonType.Reply, 1 );
if ( NextLabel )
AddLabel( x + NextLabelOffsetX, y + NextLabelOffsetY, TextHue, "Next" );
}
for ( int i = 0, index = page * EntryCount; i < EntryCount && index < m_Mobiles.Count; ++i, ++index )
{
x = BorderSize + OffsetSize;
y += EntryHeight + OffsetSize;
Mobile m = m_Mobiles[index];
AddImageTiled( x, y, EntryWidth, EntryHeight, EntryGumpID );
AddLabelCropped( x + TextOffsetX, y, EntryWidth - TextOffsetX, EntryHeight, GetHueFor( m ), m.Deleted ? "(deleted)" : m.Name );
x += EntryWidth + OffsetSize;
if ( SetGumpID != 0 )
AddImageTiled( x, y, SetWidth, EntryHeight, SetGumpID );
if ( m.NetState != null && !m.Deleted )
AddButton( x + SetOffsetX, y + SetOffsetY, SetButtonID1, SetButtonID2, i + 3, GumpButtonType.Reply, 0 );
}
}
private static int GetHueFor( Mobile m )
{
switch ( m.AccessLevel )
{
case AccessLevel.Owner:
case AccessLevel.Developer:
case AccessLevel.Administrator: return 0x516;
case AccessLevel.Seer: return 0x144;
case AccessLevel.GameMaster: return 0x21;
case AccessLevel.Counselor: return 0x2;
case AccessLevel.Player: default:
{
if ( m.Kills >= 5 )
return 0x21;
else if ( m.Criminal )
return 0x3B1;
return 0x58;
}
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
switch ( info.ButtonID )
{
case 0: // Closed
{
return;
}
case 1: // Previous
{
if ( m_Page > 0 )
from.SendGump( new WhoGump( from, m_Mobiles, m_Page - 1 ) );
break;
}
case 2: // Next
{
if ( (m_Page + 1) * EntryCount < m_Mobiles.Count )
from.SendGump( new WhoGump( from, m_Mobiles, m_Page + 1 ) );
break;
}
default:
{
int index = (m_Page * EntryCount) + (info.ButtonID - 3);
if ( index >= 0 && index < m_Mobiles.Count )
{
Mobile m = m_Mobiles[index];
if ( m.Deleted )
{
from.SendMessage( "That player has deleted their character." );
from.SendGump( new WhoGump( from, m_Mobiles, m_Page ) );
}
else if ( m.NetState == null )
{
from.SendMessage( "That player is no longer online." );
from.SendGump( new WhoGump( from, m_Mobiles, m_Page ) );
}
else if ( m == from || !m.Hidden || from.AccessLevel > m.AccessLevel || (m is PlayerMobile && ((PlayerMobile)m).VisibilityList.Contains( from )))
{
from.SendGump( new ClientGump( from, m.NetState ) );
}
else
{
from.SendMessage( "You cannot see them." );
from.SendGump( new WhoGump( from, m_Mobiles, m_Page ) );
}
}
break;
}
}
}
}
}