This commit is contained in:
mark 2006-06-15 04:14:30 +00:00
commit 47711d616e
2644 changed files with 479454 additions and 0 deletions

View file

@ -0,0 +1,125 @@
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( 265, 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( RattanDoor ), 0x695 ),
new DoorInfo( typeof( DarkWoodDoor ), 0x6A5 ),
new DoorInfo( typeof( LightWoodDoor ), 0x6D5 ),
new DoorInfo( typeof( StrongWoodDoor ), 0x6E5 )
};
}
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;
}
}
}
}
}

2933
Scripts/Gumps/AdminGump.cs Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,244 @@
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 - 170) / 2, (480 - 305) / 2 )
{
m_List = list;
int width = 170;
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" );
}
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 );
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 )
{
for ( int i = 0; i < m_List.Count; ++i )
{
Account a = (Account)m_List[i];
a.SetBanTags( from, DateTime.Now, duration );
}
if ( duration == TimeSpan.MaxValue )
from.SendMessage( "Duration is infinite." );
else
from.SendMessage( "Duration is {0}.", duration );
}
else
{
from.SendMessage( "Values improperly formatted." );
from.SendGump( new BanDurationGump( m_List ) );
}
}
}
}

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,383 @@
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" )
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/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 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;
public static readonly int OffsetSize = PropsConfig.OffsetSize;
public static readonly int EntryHeight = 24;//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 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;
}
}
}
}
}

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

@ -0,0 +1,302 @@
using System;
using System.Net;
using Server;
using Server.Accounting;
using Server.Network;
using Server.Targets;
using Server.Gumps;
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;
if ( info.ID == (int)Expansion.None )
expansionName = (((state.Flags & 0x04) != 0) ? "Blackthorn's Revenge" : ((state.Flags & 0x02) != 0) ? "Third Dawn" : ((state.Flags & 0x01) != 0) ? "Renaissance" : "The Second Age" );
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,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,66 @@
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;
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;
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 );
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;
}
}
}
}

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

@ -0,0 +1,358 @@
using System;
using System.Collections;
using Server;
using Server.Network;
using Server.Gumps;
namespace Server.Gumps
{
public class GoGump : Gump
{
public static readonly LocationTree Felucca = new LocationTree( "felucca.xml", Map.Felucca );
public static readonly LocationTree Trammel = new LocationTree( "trammel.xml", Map.Trammel );
public static readonly LocationTree Ilshenar = new LocationTree( "ilshenar.xml", Map.Ilshenar );
public static readonly LocationTree Malas = new LocationTree( "malas.xml", Map.Malas );
public static readonly LocationTree Tokuno = new LocationTree( "tokuno.xml", Map.Tokuno );
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;
if ( from.Map == Map.Ilshenar )
tree = Ilshenar;
else if ( from.Map == Map.Felucca )
tree = Felucca;
else if ( from.Map == Map.Trammel )
tree = Trammel;
else if ( from.Map == Map.Malas )
tree = Malas;
else
tree = Tokuno;
ParentNode branch = (ParentNode)tree.LastBranch[from];
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, m_Tree.Map );
}
}
break;
}
}
}
public static bool MoveToLocation( Mobile m, string text )
{
string[] args = text.Split( '.' );
if ( args.Length == 0 )
return false;
for ( int i = 0; i < args.Length; ++i )
args[i].Trim();
ArrayList trees = new ArrayList();
// The mobile's map is to be checked first.
if ( m.Map == Map.Ilshenar )
trees.Add( Ilshenar );
else if ( m.Map == Map.Felucca )
trees.Add( Felucca );
else if ( m.Map == Map.Trammel )
trees.Add( Trammel );
else if ( m.Map == Map.Malas )
trees.Add( Malas );
else
trees.Add( Tokuno );
// The other maps follow.
if ( !trees.Contains( Trammel ) )
trees.Add( Trammel );
if ( !trees.Contains( Felucca ) )
trees.Add( Felucca );
if ( !trees.Contains( Ilshenar ) )
trees.Add( Ilshenar );
if ( !trees.Contains( Malas ) )
trees.Add( Malas );
if ( !trees.Contains( Tokuno ) )
trees.Add( Tokuno );
LocationTree tree;
for ( int i = 0; i < trees.Count; ++i )
{
tree = (LocationTree)trees[i];
// If a specific tree was requested, it's the only one we need to parse.
if ( Insensitive.Equals( args[0], tree.Map.Name ) )
{
if ( args.Length < 2 )
return false;
return ParseNode( tree.Root, args, 1, m, tree.Map );
}
}
for ( int i = 0; i < trees.Count; ++i )
{
tree = (LocationTree)trees[i];
// Parse all trees.
if ( ParseNode( tree.Root, args, 0, m, tree.Map ) )
return true;
}
return false;
}
public static bool ParseNode( ParentNode node, string[] args, int argsIndex, Mobile m, Map map )
{
if ( args[argsIndex].Length == 0 )
return false;
for ( int i = 0; i < node.Children.Length; ++i )
{
object child = node.Children[i];
if ( child is ParentNode )
{
if ( Insensitive.Equals( ((ParentNode)child).Name, args[argsIndex] ) )
{
if ( (argsIndex + 1) >= args.Length )
return false;
if ( args[argsIndex + 1].Length == 0 )
return false;
return ParseNode( (ParentNode)child, args, argsIndex + 1, m, map );
}
else
{
if ( ParseNode( (ParentNode)child, args, argsIndex, m, map ) )
return true;
}
}
else if ( child is ChildNode )
{
if ( Insensitive.Equals( ((ChildNode)child).Name, args[argsIndex] ) )
{
m.MoveToWorld( ((ChildNode)child).Location, map );
return true;
}
}
}
return false;
}
}
}

View file

@ -0,0 +1,67 @@
using System;
using System.IO;
using System.Xml;
using System.Collections;
using Server;
namespace Server.Gumps
{
public class LocationTree
{
private Map m_Map;
private ParentNode m_Root;
private Hashtable m_LastBranch;
public LocationTree( string fileName, Map map )
{
m_LastBranch = new Hashtable();
m_Map = map;
string path = Path.Combine( "Data/Locations/", fileName );
if ( File.Exists( path ) )
{
XmlTextReader xml = new XmlTextReader( new StreamReader( path ) );
xml.WhitespaceHandling = WhitespaceHandling.None;
m_Root = Parse( xml );
xml.Close();
}
}
public Hashtable LastBranch
{
get
{
return m_LastBranch;
}
}
public Map Map
{
get
{
return m_Map;
}
}
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,54 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class DeclareFealtyGump : GuildMobileListGump
{
public DeclareFealtyGump( Mobile from, Guild guild ) : base( from, guild, true, guild.Members )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1011097, false, false ); // Declare your fealty
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 250, 35, 1011098, false, false ); // I have selected my new lord.
AddButton( 300, 400, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadMember( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Mobile m = (Mobile)m_List[index];
if ( m != null && !m.Deleted )
{
state.Mobile.GuildFealty = m;
}
}
}
}
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
}
}
}

View file

@ -0,0 +1,57 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GrantGuildTitleGump : GuildMobileListGump
{
public GrantGuildTitleGump( Mobile from, Guild guild ) : base( from, guild, true, guild.Members )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1011118, false, false ); // Grant a title to another member.
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 245, 30, 1011127, false, false ); // I dub thee...
AddButton( 300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Mobile m = (Mobile)m_List[index];
if ( m != null && !m.Deleted )
{
m_Mobile.SendLocalizedMessage( 1013074 ); // New title (20 characters max):
m_Mobile.Prompt = new GuildTitlePrompt( m_Mobile, m, m_Guild );
}
}
}
}
else if ( info.ButtonID == 2 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,55 @@
using System;
using Server;
using Server.Guilds;
using Server.Prompts;
namespace Server.Gumps
{
public class GuildAbbrvPrompt : Prompt
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildAbbrvPrompt( Mobile m, Guild g )
{
m_Mobile = m;
m_Guild = g;
}
public override void OnCancel( Mobile from )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
public override void OnResponse( Mobile from, string text )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
text = text.Trim();
if ( text.Length > 3 )
text = text.Substring( 0, 3 );
if ( text.Length > 0 )
{
if ( Guild.FindByAbbrev( text ) != null )
{
m_Mobile.SendMessage( "{0} conflicts with the abbreviation of an existing guild.", text );
}
else
{
m_Guild.Abbreviation = text;
m_Guild.GuildMessage( 1018025, true, text ); // Your guild abbreviation has changed:
}
}
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}

View file

@ -0,0 +1,67 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildAcceptWarGump : GuildListGump
{
public GuildAcceptWarGump( Mobile from, Guild guild ) : base( from, guild, true, guild.WarInvitations )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1011147, false, false ); // Select the guild to accept the invitations:
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 245, 30, 1011100, false, false ); // Accept war invitations.
AddButton( 300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Guild g = (Guild)m_List[index];
if ( g != null )
{
m_Guild.WarInvitations.Remove( g );
g.WarDeclarations.Remove( m_Guild );
m_Guild.AddEnemy( g );
m_Guild.GuildMessage( 1018020, true, "{0} ({1})", g.Name, g.Abbreviation );
GuildGump.EnsureClosed( m_Mobile );
if ( m_Guild.WarInvitations.Count > 0 )
m_Mobile.SendGump( new GuildAcceptWarGump( m_Mobile, m_Guild ) );
else
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}
else if ( info.ButtonID == 2 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,126 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
using Server.Factions;
namespace Server.Gumps
{
public class GuildAdminCandidatesGump : GuildMobileListGump
{
public GuildAdminCandidatesGump( Mobile from, Guild guild ) : base( from, guild, true, guild.Candidates )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1013075, false, false ); // Accept or Refuse candidates for membership
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 245, 30, 1013076, false, false ); // Accept
AddButton( 300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1013077, false, false ); // Refuse
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
switch ( info.ButtonID )
{
case 0:
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
break;
}
case 1: // Accept
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Mobile m = (Mobile)m_List[index];
if ( m != null && !m.Deleted )
{
#region Factions
PlayerState guildState = PlayerState.Find( m_Guild.Leader );
PlayerState targetState = PlayerState.Find( m );
Faction guildFaction = ( guildState == null ? null : guildState.Faction );
Faction targetFaction = ( targetState == null ? null : targetState.Faction );
if ( guildFaction != targetFaction )
{
if ( guildFaction == null )
m_Mobile.SendLocalizedMessage( 1013027 ); // That player cannot join a non-faction guild.
else if ( targetFaction == null )
m_Mobile.SendLocalizedMessage( 1013026 ); // That player must be in a faction before joining this guild.
else
m_Mobile.SendLocalizedMessage( 1013028 ); // That person has a different faction affiliation.
break;
}
else if ( targetState != null && targetState.IsLeaving )
{
// OSI does this quite strangely, so we'll just do it this way
m_Mobile.SendMessage( "That person is quitting their faction and so you may not recruit them." );
break;
}
#endregion
m_Guild.Candidates.Remove( m );
m_Guild.Accepted.Add( m );
GuildGump.EnsureClosed( m_Mobile );
if ( m_Guild.Candidates.Count > 0 )
m_Mobile.SendGump( new GuildAdminCandidatesGump( m_Mobile, m_Guild ) );
else
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
break;
}
case 2: // Refuse
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Mobile m = (Mobile)m_List[index];
if ( m != null && !m.Deleted )
{
m_Guild.Candidates.Remove( m );
GuildGump.EnsureClosed( m_Mobile );
if ( m_Guild.Candidates.Count > 0 )
m_Mobile.SendGump( new GuildAdminCandidatesGump( m_Mobile, m_Guild ) );
else
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
break;
}
}
}
}
}

View file

@ -0,0 +1,34 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildCandidatesGump : GuildMobileListGump
{
public GuildCandidatesGump( Mobile from, Guild guild ) : base( from, guild, false, guild.Candidates )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 500, 35, 1013030, false, false ); // <center> Candidates </center>
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 300, 35, 1011120, false, false ); // Return to the main menu.
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadMember( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,84 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using Server.Network;
using Server.Factions;
namespace Server.Gumps
{
public class GuildChangeTypeGump : Gump
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildChangeTypeGump( Mobile from, Guild guild ) : base( 20, 30 )
{
m_Mobile = from;
m_Guild = guild;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 550, 400, 5054 );
AddBackground( 10, 10, 530, 380, 3000 );
AddHtmlLocalized( 20, 15, 510, 30, 1013062, false, false ); // <center>Change Guild Type Menu</center>
AddHtmlLocalized( 50, 50, 450, 30, 1013066, false, false ); // Please select the type of guild you would like to change to
AddButton( 20, 100, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 85, 100, 300, 30, 1013063, false, false ); // Standard guild
AddButton( 20, 150, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddItem( 50, 143, 7109 );
AddHtmlLocalized( 85, 150, 300, 300, 1013064, false, false ); // Order guild
AddButton( 20, 200, 4005, 4007, 3, GumpButtonType.Reply, 0 );
AddItem( 45, 200, 7107 );
AddHtmlLocalized( 85, 200, 300, 300, 1013065, false, false ); // Chaos guild
AddButton( 300, 360, 4005, 4007, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 360, 150, 30, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
PlayerState pl = PlayerState.Find( m_Mobile );
if ( pl != null )
{
m_Mobile.SendLocalizedMessage( 1010405 ); // You cannot change guild types while in a Faction!
}
else if ( m_Guild.TypeLastChange.AddDays( 7 ) > DateTime.Now )
{
m_Mobile.SendLocalizedMessage( 1005292 ); // Your guild type will be changed in one week.
}
else
{
GuildType newType;
switch ( info.ButtonID )
{
default: return; // Close
case 1: newType = GuildType.Regular; break;
case 2: newType = GuildType.Order; break;
case 3: newType = GuildType.Chaos; break;
}
if ( m_Guild.Type == newType )
return;
m_Guild.Type = newType;
m_Guild.GuildMessage( 1018022, true, newType.ToString() ); // Guild Message: Your guild type has changed:
}
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}

View file

@ -0,0 +1,73 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildCharterGump : Gump
{
private Mobile m_Mobile;
private Guild m_Guild;
private const string DefaultWebsite = "http://www.runuo.com/";
public GuildCharterGump( Mobile from, Guild guild ) : base( 20, 30 )
{
m_Mobile = from;
m_Guild = guild;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 550, 400, 5054 );
AddBackground( 10, 10, 530, 380, 3000 );
AddButton( 20, 360, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 360, 300, 35, 1011120, false, false ); // Return to the main menu.
string charter;
if ( (charter = guild.Charter) == null || (charter = charter.Trim()).Length <= 0 )
AddHtmlLocalized( 20, 20, 400, 35, 1013032, false, false ); // No charter has been defined.
else
AddHtml( 20, 20, 510, 75, charter, true, true );
AddButton( 20, 200, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 200, 300, 20, 1011122, false, false ); // Visit the guild website :
string website;
if ( (website = guild.Website) == null || (website = website.Trim()).Length <= 0 )
website = DefaultWebsite;
AddHtml( 55, 220, 300, 20, website, false, false );
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadMember( m_Mobile, m_Guild ) )
return;
switch ( info.ButtonID )
{
case 0: return; // Close
case 1: break; // Return to main menu
case 2:
{
string website;
if ( (website = m_Guild.Website) == null || (website = website.Trim()).Length <= 0 )
website = DefaultWebsite;
m_Mobile.LaunchBrowser( website );
break;
}
}
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
}
}
}

View file

@ -0,0 +1,48 @@
using System;
using Server;
using Server.Guilds;
using Server.Prompts;
namespace Server.Gumps
{
public class GuildCharterPrompt : Prompt
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildCharterPrompt( Mobile m, Guild g )
{
m_Mobile = m;
m_Guild = g;
}
public override void OnCancel( Mobile from )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
public override void OnResponse( Mobile from, string text )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
text = text.Trim();
if ( text.Length > 50 )
text = text.Substring( 0, 50 );
if ( text.Length > 0 )
m_Guild.Charter = text;
m_Mobile.SendLocalizedMessage( 1013072 ); // Enter the new website for the guild (50 characters max):
m_Mobile.Prompt = new GuildWebsitePrompt( m_Mobile, m_Guild );
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}

View file

@ -0,0 +1,64 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildDeclarePeaceGump : GuildListGump
{
public GuildDeclarePeaceGump( Mobile from, Guild guild ) : base( from, guild, true, guild.Enemies )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1011137, false, false ); // Select the guild you wish to declare peace with.
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 245, 30, 1011138, false, false ); // Send the olive branch.
AddButton( 300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Guild g = (Guild)m_List[index];
if ( g != null )
{
m_Guild.RemoveEnemy( g );
m_Guild.GuildMessage( 1018018, true, "{0} ({1})", g.Name, g.Abbreviation ); // Guild Message: You are now at peace with this guild:
GuildGump.EnsureClosed( m_Mobile );
if ( m_Guild.Enemies.Count > 0 )
m_Mobile.SendGump( new GuildDeclarePeaceGump( m_Mobile, m_Guild ) );
else
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}
else if ( info.ButtonID == 2 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,88 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using Server.Network;
using Server.Factions;
using System.Collections.Generic;
namespace Server.Gumps
{
public class GuildDeclareWarGump : GuildListGump
{
public GuildDeclareWarGump( Mobile from, Guild guild, List<Guild> list )
: base( from, guild, true, list )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1011065, false, false ); // Select the guild you wish to declare war on.
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 245, 30, 1011068, false, false ); // Send the challenge!
AddButton( 300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Guild g = m_List[index];
if ( g != null )
{
if ( g == m_Guild )
{
m_Mobile.SendLocalizedMessage( 501184 ); // You cannot declare war against yourself!
}
else if ( (g.WarInvitations.Contains( m_Guild ) && m_Guild.WarDeclarations.Contains( g )) || m_Guild.IsWar( g ) )
{
m_Mobile.SendLocalizedMessage( 501183 ); // You are already at war with that guild.
}
else if( Faction.Find( m_Guild.Leader ) != null )
{
m_Mobile.SendLocalizedMessage( 1005288 ); // You cannot declare war while you are in a faction
}
else
{
if ( !m_Guild.WarDeclarations.Contains( g ) )
{
m_Guild.WarDeclarations.Add( g );
m_Guild.GuildMessage( 1018019, true, "{0} ({1})", g.Name, g.Abbreviation ); // Guild Message: Your guild has sent an invitation for war:
}
if ( !g.WarInvitations.Contains( m_Guild ) )
{
g.WarInvitations.Add( m_Guild );
g.GuildMessage( 1018021, true, "{0} ({1})", m_Guild.Name, m_Guild.Abbreviation ); // Guild Message: Your guild has received an invitation to war:
}
}
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildWarAdminGump( m_Mobile, m_Guild ) );
}
}
}
}
else if ( info.ButtonID == 2 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,59 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using Server.Prompts;
using System.Collections.Generic;
namespace Server.Gumps
{
public class GuildDeclareWarPrompt : Prompt
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildDeclareWarPrompt( Mobile m, Guild g )
{
m_Mobile = m;
m_Guild = g;
}
public override void OnCancel( Mobile from )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildWarAdminGump( m_Mobile, m_Guild ) );
}
public override void OnResponse( Mobile from, string text )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
text = text.Trim();
if ( text.Length >= 3 )
{
List<Guild> guilds = Utility.CastConvertList<BaseGuild, Guild>( Guild.Search( text ) );
GuildGump.EnsureClosed( m_Mobile );
if ( guilds.Count > 0 )
{
m_Mobile.SendGump( new GuildDeclareWarGump( m_Mobile, m_Guild, guilds ) );
}
else
{
m_Mobile.SendGump( new GuildWarAdminGump( m_Mobile, m_Guild ) );
m_Mobile.SendLocalizedMessage( 1018003 ); // No guilds found matching - try another name in the search
}
}
else
{
m_Mobile.SendMessage( "Search string must be at least three letters in length." );
}
}
}
}

View file

@ -0,0 +1,62 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildDismissGump : GuildMobileListGump
{
public GuildDismissGump ( Mobile from, Guild guild ) : base( from, guild, true, guild.Members )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1011124, false, false ); // Whom do you wish to dismiss?
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 245, 30, 1011125, false, false ); // Kick them out!
AddButton( 300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Mobile m = (Mobile)m_List[index];
if ( m != null && !m.Deleted )
{
m_Guild.RemoveMember( m );
if ( m_Mobile.AccessLevel >= AccessLevel.GameMaster || m_Mobile == m_Guild.Leader )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}
}
else if ( info.ButtonID == 2 && (m_Mobile.AccessLevel >= AccessLevel.GameMaster || m_Mobile == m_Guild.Leader) )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,225 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using Server.Network;
using Server.Prompts;
using Server.Targeting;
namespace Server.Gumps
{
public class GuildGump : Gump
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildGump( Mobile beholder, Guild guild ) : base( 20, 30 )
{
m_Mobile = beholder;
m_Guild = guild;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 550, 400, 5054 );
AddBackground( 10, 10, 530, 380, 3000 );
AddHtml( 20, 15, 200, 35, guild.Name, false, false );
Mobile leader = guild.Leader;
if ( leader != null )
{
string leadTitle;
if ( (leadTitle = leader.GuildTitle) != null && (leadTitle = leadTitle.Trim()).Length > 0 )
leadTitle += ": ";
else
leadTitle = "";
string leadName;
if ( (leadName = leader.Name) == null || (leadName = leadName.Trim()).Length <= 0 )
leadName = "(empty)";
AddHtml( 220, 15, 250, 35, leadTitle + leadName, false, false );
}
AddButton( 20, 50, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 50, 100, 20, 1013022, false, false ); // Loyal to
Mobile fealty = beholder.GuildFealty;
if ( fealty == null || !guild.IsMember( fealty ) )
fealty = leader;
if ( fealty == null )
fealty = beholder;
string fealtyName;
if ( fealty == null || (fealtyName = fealty.Name) == null || (fealtyName = fealtyName.Trim()).Length <= 0 )
fealtyName = "(empty)";
if ( beholder == fealty )
AddHtmlLocalized( 55, 70, 470, 20, 1018002, false, false ); // yourself
else
AddHtml( 55, 70, 470, 20, fealtyName, false, false );
AddButton( 215, 50, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 250, 50, 170, 20, 1013023, false, false ); // Display guild abbreviation
AddHtmlLocalized( 250, 70, 50, 20, beholder.DisplayGuildTitle ? 1011262 : 1011263, false, false ); // on/off
AddButton( 20, 100, 4005, 4007, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 100, 470, 30, 1011086, false, false ); // View the current roster.
AddButton( 20, 130, 4005, 4007, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 130, 470, 30, 1011085, false, false ); // Recruit someone into the guild.
if ( guild.Candidates.Count > 0 )
{
AddButton( 20, 160, 4005, 4007, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 160, 470, 30, 1011093, false, false ); // View list of candidates who have been sponsored to the guild.
}
else
{
AddImage( 20, 160, 4020 );
AddHtmlLocalized( 55, 160, 470, 30, 1013031, false, false ); // There are currently no candidates for membership.
}
AddButton( 20, 220, 4005, 4007, 6, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 220, 470, 30, 1011087, false, false ); // View the guild's charter.
AddButton( 20, 250, 4005, 4007, 7, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 250, 470, 30, 1011092, false, false ); // Resign from the guild.
AddButton( 20, 280, 4005, 4007, 8, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 280, 470, 30, 1011095, false, false ); // View list of guilds you are at war with.
if ( beholder.AccessLevel >= AccessLevel.GameMaster || beholder == leader )
{
AddButton( 20, 310, 4005, 4007, 9, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 310, 470, 30, 1011094, false, false ); // Access guildmaster functions.
}
else
{
AddImage( 20, 310, 4020 );
AddHtmlLocalized( 55, 310, 470, 30, 1018013, false, false ); // Reserved for guildmaster
}
AddButton( 20, 360, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 360, 470, 30, 1011441, false, false ); // EXIT
}
public static void EnsureClosed( Mobile m )
{
m.CloseGump( typeof( DeclareFealtyGump ) );
m.CloseGump( typeof( GrantGuildTitleGump ) );
m.CloseGump( typeof( GuildAdminCandidatesGump ) );
m.CloseGump( typeof( GuildCandidatesGump ) );
m.CloseGump( typeof( GuildChangeTypeGump ) );
m.CloseGump( typeof( GuildCharterGump ) );
m.CloseGump( typeof( GuildDismissGump ) );
m.CloseGump( typeof( GuildGump ) );
m.CloseGump( typeof( GuildmasterGump ) );
m.CloseGump( typeof( GuildRosterGump ) );
m.CloseGump( typeof( GuildWarGump ) );
}
public static bool BadLeader( Mobile m, Guild g )
{
if ( m.Deleted || g.Disbanded || (m.AccessLevel < AccessLevel.GameMaster && g.Leader != m) )
return true;
Item stone = g.Guildstone;
return ( stone == null || stone.Deleted || !m.InRange( stone.GetWorldLocation(), 2 ) );
}
public static bool BadMember( Mobile m, Guild g )
{
if ( m.Deleted || g.Disbanded || (m.AccessLevel < AccessLevel.GameMaster && !g.IsMember( m )) )
return true;
Item stone = g.Guildstone;
return ( stone == null || stone.Deleted || !m.InRange( stone.GetWorldLocation(), 2 ) );
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if ( BadMember( m_Mobile, m_Guild ) )
return;
switch ( info.ButtonID )
{
case 1: // Loyalty
{
EnsureClosed( m_Mobile );
m_Mobile.SendGump( new DeclareFealtyGump( m_Mobile, m_Guild ) );
break;
}
case 2: // Toggle display abbreviation
{
m_Mobile.DisplayGuildTitle = !m_Mobile.DisplayGuildTitle;
EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
break;
}
case 3: // View the current roster
{
EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildRosterGump( m_Mobile, m_Guild ) );
break;
}
case 4: // Recruit
{
m_Mobile.Target = new GuildRecruitTarget( m_Mobile, m_Guild );
break;
}
case 5: // Membership candidates
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildCandidatesGump( m_Mobile, m_Guild ) );
break;
}
case 6: // View charter
{
EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildCharterGump( m_Mobile, m_Guild ) );
break;
}
case 7: // Resign
{
m_Guild.RemoveMember( m_Mobile );
break;
}
case 8: // View wars
{
EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildWarGump( m_Mobile, m_Guild ) );
break;
}
case 9: // Guildmaster functions
{
if ( m_Mobile.AccessLevel >= AccessLevel.GameMaster || m_Guild.Leader == m_Mobile )
{
EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
break;
}
}
}
}
}

View file

@ -0,0 +1,67 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using System.Collections.Generic;
namespace Server.Gumps
{
public abstract class GuildListGump : Gump
{
protected Mobile m_Mobile;
protected Guild m_Guild;
protected List<Guild> m_List;
public GuildListGump( Mobile from, Guild guild, bool radio, List<Guild> list ) : base( 20, 30 )
{
m_Mobile = from;
m_Guild = guild;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 550, 440, 5054 );
AddBackground( 10, 10, 530, 420, 3000 );
Design();
m_List = new List<Guild>( list );
for ( int i = 0; i < m_List.Count; ++i )
{
if ( (i % 11) == 0 )
{
if ( i != 0 )
{
AddButton( 300, 370, 4005, 4007, 0, GumpButtonType.Page, (i / 11) + 1 );
AddHtmlLocalized( 335, 370, 300, 35, 1011066, false, false ); // Next page
}
AddPage( (i / 11) + 1 );
if ( i != 0 )
{
AddButton( 20, 370, 4014, 4016, 0, GumpButtonType.Page, (i / 11) );
AddHtmlLocalized( 55, 370, 300, 35, 1011067, false, false ); // Previous page
}
}
if ( radio )
AddRadio( 20, 35 + ((i % 11) * 30), 208, 209, false, i );
Guild g = m_List[i];
string name;
if ( (name = g.Name) != null && (name = name.Trim()).Length <= 0 )
name = "(empty)";
AddLabel( (radio ? 55 : 20), 35 + ((i % 11) * 30), 0, name );
}
}
protected virtual void Design()
{
}
}
}

View file

@ -0,0 +1,68 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using System.Collections.Generic;
namespace Server.Gumps
{
public abstract class GuildMobileListGump : Gump
{
protected Mobile m_Mobile;
protected Guild m_Guild;
protected List<Mobile> m_List;
public GuildMobileListGump( Mobile from, Guild guild, bool radio, List<Mobile> list )
: base( 20, 30 )
{
m_Mobile = from;
m_Guild = guild;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 550, 440, 5054 );
AddBackground( 10, 10, 530, 420, 3000 );
Design();
m_List = new List<Mobile>( list );
for ( int i = 0; i < m_List.Count; ++i )
{
if ( (i % 11) == 0 )
{
if ( i != 0 )
{
AddButton( 300, 370, 4005, 4007, 0, GumpButtonType.Page, (i / 11) + 1 );
AddHtmlLocalized( 335, 370, 300, 35, 1011066, false, false ); // Next page
}
AddPage( (i / 11) + 1 );
if ( i != 0 )
{
AddButton( 20, 370, 4014, 4016, 0, GumpButtonType.Page, (i / 11) );
AddHtmlLocalized( 55, 370, 300, 35, 1011067, false, false ); // Previous page
}
}
if ( radio )
AddRadio( 20, 35 + ((i % 11) * 30), 208, 209, false, i );
Mobile m = m_List[i];
string name;
if ( (name = m.Name) != null && (name = name.Trim()).Length <= 0 )
name = "(empty)";
AddLabel( (radio ? 55 : 20), 35 + ((i % 11) * 30), 0, name );
}
}
protected virtual void Design()
{
}
}
}

View file

@ -0,0 +1,55 @@
using System;
using Server;
using Server.Guilds;
using Server.Prompts;
namespace Server.Gumps
{
public class GuildNamePrompt : Prompt
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildNamePrompt( Mobile m, Guild g )
{
m_Mobile = m;
m_Guild = g;
}
public override void OnCancel( Mobile from )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
public override void OnResponse( Mobile from, string text )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
text = text.Trim();
if ( text.Length > 40 )
text = text.Substring( 0, 40 );
if ( text.Length > 0 )
{
if ( Guild.FindByName( text ) != null )
{
m_Mobile.SendMessage( "{0} conflicts with the name of an existing guild.", text );
}
else
{
m_Guild.Name = text;
m_Guild.GuildMessage( 1018024, true, text ); // The name of your guild has changed:
}
}
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}

View file

@ -0,0 +1,64 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildRejectWarGump : GuildListGump
{
public GuildRejectWarGump( Mobile from, Guild guild ) : base( from, guild, true, guild.WarInvitations )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1011148, false, false ); // Select the guild to reject their invitations:
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 245, 30, 1011101, false, false ); // Reject war invitations.
AddButton( 300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Guild g = (Guild)m_List[index];
if ( g != null )
{
m_Guild.WarInvitations.Remove( g );
g.WarDeclarations.Remove( m_Guild );
GuildGump.EnsureClosed( m_Mobile );
if ( m_Guild.WarInvitations.Count > 0 )
m_Mobile.SendGump( new GuildRejectWarGump( m_Mobile, m_Guild ) );
else
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}
else if ( info.ButtonID == 2 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,64 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildRescindDeclarationGump : GuildListGump
{
public GuildRescindDeclarationGump( Mobile from, Guild guild ) : base( from, guild, true, guild.WarDeclarations )
{
}
protected override void Design()
{
AddHtmlLocalized( 20, 10, 400, 35, 1011150, false, false ); // Select the guild to rescind our invitations:
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 245, 30, 1011102, false, false ); // Rescind your war declarations.
AddButton( 300, 400, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 400, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
int[] switches = info.Switches;
if ( switches.Length > 0 )
{
int index = switches[0];
if ( index >= 0 && index < m_List.Count )
{
Guild g = (Guild)m_List[index];
if ( g != null )
{
m_Guild.WarDeclarations.Remove( g );
g.WarInvitations.Remove( m_Guild );
GuildGump.EnsureClosed( m_Mobile );
if ( m_Guild.WarDeclarations.Count > 0 )
m_Mobile.SendGump( new GuildRescindDeclarationGump( m_Mobile, m_Guild ) );
else
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}
else if ( info.ButtonID == 2 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,34 @@
using System;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildRosterGump : GuildMobileListGump
{
public GuildRosterGump( Mobile from, Guild guild ) : base( from, guild, false, guild.Members )
{
}
protected override void Design()
{
AddHtml( 20, 10, 500, 35, String.Format( "<center>{0}</center>", m_Guild.Name ), false, false );
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 300, 35, 1011120, false, false ); // Return to the main menu.
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadMember( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,50 @@
using System;
using Server;
using Server.Guilds;
using Server.Prompts;
namespace Server.Gumps
{
public class GuildTitlePrompt : Prompt
{
private Mobile m_Leader, m_Target;
private Guild m_Guild;
public GuildTitlePrompt( Mobile leader, Mobile target, Guild g )
{
m_Leader = leader;
m_Target = target;
m_Guild = g;
}
public override void OnCancel( Mobile from )
{
if ( GuildGump.BadLeader( m_Leader, m_Guild ) )
return;
else if ( m_Target.Deleted || !m_Guild.IsMember( m_Target ) )
return;
GuildGump.EnsureClosed( m_Leader );
m_Leader.SendGump( new GuildmasterGump( m_Leader, m_Guild ) );
}
public override void OnResponse( Mobile from, string text )
{
if ( GuildGump.BadLeader( m_Leader, m_Guild ) )
return;
else if ( m_Target.Deleted || !m_Guild.IsMember( m_Target ) )
return;
text = text.Trim();
if ( text.Length > 20 )
text = text.Substring( 0, 20 );
if ( text.Length > 0 )
m_Target.GuildTitle = text;
GuildGump.EnsureClosed( m_Leader );
m_Leader.SendGump( new GuildmasterGump( m_Leader, m_Guild ) );
}
}
}

View file

@ -0,0 +1,121 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildWarAdminGump : Gump
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildWarAdminGump( Mobile from, Guild guild ) : base( 20, 30 )
{
m_Mobile = from;
m_Guild = guild;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 550, 440, 5054 );
AddBackground( 10, 10, 530, 420, 3000 );
AddHtmlLocalized( 20, 10, 510, 35, 1011105, false, false ); // <center>WAR FUNCTIONS</center>
AddButton( 20, 40, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 40, 400, 30, 1011099, false, false ); // Declare war through guild name search.
int count = 0;
if ( guild.Enemies.Count > 0 )
{
AddButton( 20, 160 + (count * 30), 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 160 + (count++ * 30), 400, 30, 1011103, false, false ); // Declare peace.
}
else
{
AddHtmlLocalized( 20, 160 + (count++ * 30), 400, 30, 1013033, false, false ); // No current wars
}
if ( guild.WarInvitations.Count > 0 )
{
AddButton( 20, 160 + (count * 30), 4005, 4007, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 160 + (count++ * 30), 400, 30, 1011100, false, false ); // Accept war invitations.
AddButton( 20, 160 + (count * 30), 4005, 4007, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 160 + (count++ * 30), 400, 30, 1011101, false, false ); // Reject war invitations.
}
else
{
AddHtmlLocalized( 20, 160 + (count++ * 30), 400, 30, 1018012, false, false ); // No current invitations received for war.
}
if ( guild.WarDeclarations.Count > 0 )
{
AddButton( 20, 160 + (count * 30), 4005, 4007, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 160 + (count++ * 30), 400, 30, 1011102, false, false ); // Rescind your war declarations.
}
else
{
AddHtmlLocalized( 20, 160 + (count++ * 30), 400, 30, 1013055, false, false ); // No current war declarations
}
AddButton( 20, 400, 4005, 4007, 6, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 400, 35, 1011104, false, false ); // Return to the previous menu.
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
switch ( info.ButtonID )
{
case 1: // Declare war
{
m_Mobile.SendLocalizedMessage( 1018001 ); // Declare war through search - Enter Guild Name:
m_Mobile.Prompt = new GuildDeclareWarPrompt( m_Mobile, m_Guild );
break;
}
case 2: // Declare peace
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildDeclarePeaceGump( m_Mobile, m_Guild ) );
break;
}
case 3: // Accept war
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildAcceptWarGump( m_Mobile, m_Guild ) );
break;
}
case 4: // Reject war
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildRejectWarGump( m_Mobile, m_Guild ) );
break;
}
case 5: // Rescind declarations
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildRescindDeclarationGump( m_Mobile, m_Guild ) );
break;
}
case 6: // Return
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
break;
}
}
}
}
}

View file

@ -0,0 +1,116 @@
using System;
using System.Collections;
using Server;
using Server.Guilds;
using Server.Network;
using System.Collections.Generic;
namespace Server.Gumps
{
public class GuildWarGump : Gump
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildWarGump( Mobile from, Guild guild ) : base( 20, 30 )
{
m_Mobile = from;
m_Guild = guild;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 550, 440, 5054 );
AddBackground( 10, 10, 530, 420, 3000 );
AddHtmlLocalized( 20, 10, 500, 35, 1011133, false, false ); // <center>WARFARE STATUS</center>
AddButton( 20, 400, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 400, 300, 35, 1011120, false, false ); // Return to the main menu.
AddPage( 1 );
AddButton( 375, 375, 5224, 5224, 0, GumpButtonType.Page, 2 );
AddHtmlLocalized( 410, 373, 100, 25, 1011066, false, false ); // Next page
AddHtmlLocalized( 20, 45, 400, 20, 1011134, false, false ); // We are at war with:
List<Guild> enemies = guild.Enemies;
if ( enemies.Count == 0 )
{
AddHtmlLocalized( 20, 65, 400, 20, 1013033, false, false ); // No current wars
}
else
{
for ( int i = 0; i < enemies.Count; ++i )
{
Guild g = enemies[i];
AddHtml( 20, 65 + (i * 20), 300, 20, g.Name, false, false );
}
}
AddPage( 2 );
AddButton( 375, 375, 5224, 5224, 0, GumpButtonType.Page, 3 );
AddHtmlLocalized( 410, 373, 100, 25, 1011066, false, false ); // Next page
AddButton( 30, 375, 5223, 5223, 0, GumpButtonType.Page, 1 );
AddHtmlLocalized( 65, 373, 150, 25, 1011067, false, false ); // Previous page
AddHtmlLocalized( 20, 45, 400, 20, 1011136, false, false ); // Guilds that we have declared war on:
List<Guild> declared = guild.WarDeclarations;
if ( declared.Count == 0 )
{
AddHtmlLocalized( 20, 65, 400, 20, 1018012, false, false ); // No current invitations received for war.
}
else
{
for ( int i = 0; i < declared.Count; ++i )
{
Guild g = (Guild)declared[i];
AddHtml( 20, 65 + (i * 20), 300, 20, g.Name, false, false );
}
}
AddPage( 3 );
AddButton( 30, 375, 5223, 5223, 0, GumpButtonType.Page, 2 );
AddHtmlLocalized( 65, 373, 150, 25, 1011067, false, false ); // Previous page
AddHtmlLocalized( 20, 45, 400, 20, 1011135, false, false ); // Guilds that have declared war on us:
List<Guild> invites = guild.WarInvitations;
if ( invites.Count == 0 )
{
AddHtmlLocalized( 20, 65, 400, 20, 1013055, false, false ); // No current war declarations
}
else
{
for ( int i = 0; i < invites.Count; ++i )
{
Guild g = invites[i];
AddHtml( 20, 65 + (i * 20), 300, 20, g.Name, false, false );
}
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadMember( m_Mobile, m_Guild ) )
return;
if ( info.ButtonID == 1 )
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
}
}
}
}

View file

@ -0,0 +1,45 @@
using System;
using Server;
using Server.Guilds;
using Server.Prompts;
namespace Server.Gumps
{
public class GuildWebsitePrompt : Prompt
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildWebsitePrompt( Mobile m, Guild g )
{
m_Mobile = m;
m_Guild = g;
}
public override void OnCancel( Mobile from )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
public override void OnResponse( Mobile from, string text )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
text = text.Trim();
if ( text.Length > 50 )
text = text.Substring( 0, 50 );
if ( text.Length > 0 )
m_Guild.Website = text;
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
}
}
}

View file

@ -0,0 +1,184 @@
using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Guilds;
using Server.Network;
namespace Server.Gumps
{
public class GuildmasterGump : Gump
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildmasterGump( Mobile from, Guild guild ) : base( 20, 30 )
{
m_Mobile = from;
m_Guild = guild;
Dragable = false;
AddPage( 0 );
AddBackground( 0, 0, 550, 400, 5054 );
AddBackground( 10, 10, 530, 380, 3000 );
AddHtmlLocalized( 20, 15, 510, 35, 1011121, false, false ); // <center>GUILDMASTER FUNCTIONS</center>
AddButton( 20, 40, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 40, 470, 30, 1011107, false, false ); // Set the guild name.
AddButton( 20, 70, 4005, 4007, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 70, 470, 30, 1011109, false, false ); // Set the guild's abbreviation.
AddButton( 20, 100, 4005, 4007, 4, GumpButtonType.Reply, 0 );
switch ( m_Guild.Type )
{
case GuildType.Regular:
AddHtmlLocalized( 55, 100, 470, 30, 1013059, false, false ); // Change guild type: Currently Standard
break;
case GuildType.Order:
AddHtmlLocalized( 55, 100, 470, 30, 1013057, false, false ); // Change guild type: Currently Order
break;
case GuildType.Chaos:
AddHtmlLocalized( 55, 100, 470, 30, 1013058, false, false ); // Change guild type: Currently Chaos
break;
}
AddButton( 20, 130, 4005, 4007, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 130, 470, 30, 1011112, false, false ); // Set the guild's charter.
AddButton( 20, 160, 4005, 4007, 6, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 160, 470, 30, 1011113, false, false ); // Dismiss a member.
AddButton( 20, 190, 4005, 4007, 7, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 190, 470, 30, 1011114, false, false ); // Go to the WAR menu.
if ( m_Guild.Candidates.Count > 0 )
{
AddButton( 20, 220, 4005, 4007, 8, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 220, 470, 30, 1013056, false, false ); // Administer the list of candidates
}
else
{
AddImage( 20, 220, 4020 );
AddHtmlLocalized( 55, 220, 470, 30, 1013031, false, false ); // There are currently no candidates for membership.
}
AddButton( 20, 250, 4005, 4007, 9, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 250, 470, 30, 1011117, false, false ); // Set the guildmaster's title.
AddButton( 20, 280, 4005, 4007, 10, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 280, 470, 30, 1011118, false, false ); // Grant a title to another member.
AddButton( 20, 310, 4005, 4007, 11, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 310, 470, 30, 1011119, false, false ); // Move this guildstone.
AddButton( 20, 360, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 55, 360, 245, 30, 1011120, false, false ); // Return to the main menu.
AddButton( 300, 360, 4005, 4007, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 335, 360, 100, 30, 1011441, false, false ); // EXIT
}
public override void OnResponse( NetState state, RelayInfo info )
{
if ( GuildGump.BadLeader( m_Mobile, m_Guild ) )
return;
switch ( info.ButtonID )
{
case 1: // Main menu
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
break;
}
case 2: // Set guild name
{
m_Mobile.SendLocalizedMessage( 1013060 ); // Enter new guild name (40 characters max):
m_Mobile.Prompt = new GuildNamePrompt( m_Mobile, m_Guild );
break;
}
case 3: // Set guild abbreviation
{
m_Mobile.SendLocalizedMessage( 1013061 ); // Enter new guild abbreviation (3 characters max):
m_Mobile.Prompt = new GuildAbbrvPrompt( m_Mobile, m_Guild );
break;
}
case 4: // Change guild type
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildChangeTypeGump( m_Mobile, m_Guild ) );
break;
}
case 5: // Set charter
{
m_Mobile.SendLocalizedMessage( 1013071 ); // Enter the new guild charter (50 characters max):
m_Mobile.Prompt = new GuildCharterPrompt( m_Mobile, m_Guild );
break;
}
case 6: // Dismiss member
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildDismissGump( m_Mobile, m_Guild ) );
break;
}
case 7: // War menu
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildWarAdminGump( m_Mobile, m_Guild ) );
break;
}
case 8: // Administer candidates
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildAdminCandidatesGump( m_Mobile, m_Guild ) );
break;
}
case 9: // Set guildmaster's title
{
m_Mobile.SendLocalizedMessage( 1013073 ); // Enter new guildmaster title (20 characters max):
m_Mobile.Prompt = new GuildTitlePrompt( m_Mobile, m_Mobile, m_Guild );
break;
}
case 10: // Grant title
{
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GrantGuildTitleGump( m_Mobile, m_Guild ) );
break;
}
case 11: // Move guildstone
{
if ( m_Guild.Guildstone != null )
{
GuildTeleporter item = new GuildTeleporter( m_Guild.Guildstone );
if ( m_Guild.Teleporter != null )
m_Guild.Teleporter.Delete();
m_Mobile.SendLocalizedMessage( 501133 ); // Use the teleporting object placed in your backpack to move this guildstone.
m_Mobile.AddToBackpack( item );
m_Guild.Teleporter = item;
}
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildmasterGump( m_Mobile, m_Guild ) );
break;
}
}
}
}
}

View file

@ -0,0 +1,75 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
namespace Server.Guilds
{
public delegate void SearchSelectionCallback( GuildDisplayType display );
public class GuildAdvancedSearchGump : BaseGuildGump
{
private GuildDisplayType m_Display;
private SearchSelectionCallback m_Callback;
public GuildAdvancedSearchGump( PlayerMobile pm, Guild g, GuildDisplayType display, SearchSelectionCallback callback ) : base( pm, g )
{
m_Callback = callback;
m_Display = display;
PopulateGump();
}
public override void PopulateGump()
{
base.PopulateGump();
AddHtmlLocalized( 431, 43, 110, 26, 1062978, 0xF, false, false ); // Diplomacy
AddHtmlLocalized( 65, 80, 480, 26, 1063124, 0xF, true, false ); // <i>Advanced Search Options</i>
AddHtmlLocalized( 65, 110, 480, 26, 1063136 + (int)m_Display, 0xF, false, false ); // Showing All Guilds/w/Relation/Waiting Relation
AddGroup( 1 );
AddRadio( 75, 140, 0xD2, 0xD3, false, 2 );
AddHtmlLocalized( 105, 140, 200, 26, 1063006, 0x0, false, false ); // Show Guilds with Relationship
AddRadio( 75, 170, 0xD2, 0xD3, false, 1 );
AddHtmlLocalized( 105, 170, 200, 26, 1063005, 0x0, false, false ); // Show Guilds Awaiting Action
AddRadio( 75, 200, 0xD2, 0xD3, false, 0 );
AddHtmlLocalized( 105, 200, 200, 26, 1063007, 0x0, false, false ); // Show All Guilds
AddBackground( 450, 370, 100, 26, 0x2486 );
AddButton( 455, 375, 0x845, 0x846, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 480, 373, 60, 26, 1006044, 0x0, false, false ); // OK
AddBackground( 340, 370, 100, 26, 0x2486 );
AddButton( 345, 375, 0x845, 0x846, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 370, 373, 60, 26, 1006045, 0x0, false, false ); // Cancel
}
public override void OnResponse( NetState sender, RelayInfo info )
{
base.OnResponse( sender, info );
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( pm == null || !IsMember( pm, guild ) )
return;
GuildDisplayType display = m_Display;
if( info.ButtonID == 5 )
{
for( int i = 0; i < 3; i++ )
{
if( info.IsSwitched( i ) )
{
display = (GuildDisplayType)i;
m_Callback( display );
break;
}
}
}
}
}
}

View file

@ -0,0 +1,144 @@
using System;
using Server;
using Server.Mobiles;
using Server.Gumps;
using Server.Network;
using Server.Factions;
using Server.Misc;
namespace Server.Guilds
{
public abstract class BaseGuildGump : Gump
{
private Guild m_Guild;
private PlayerMobile m_Player;
protected Guild guild{ get{ return m_Guild; } }
protected PlayerMobile player{ get{ return m_Player; } }
public BaseGuildGump( PlayerMobile pm, Guild g ) : this( pm, g, 10, 10 )
{
}
public BaseGuildGump( PlayerMobile pm, Guild g, int x, int y ) : base( x, y )
{
m_Guild = g;
m_Player = pm;
pm.CloseGump( typeof( BaseGuildGump ) );
}
//There's prolly a way to have all the vars set of inherited classes before something is called in the Ctor... but... I can't think of it right now, and I can't use Timer.DelayCall here :<
public virtual void PopulateGump()
{
AddPage( 0 );
AddBackground( 0, 0, 600, 440, 0x24AE );
AddBackground( 66, 40, 150, 26, 0x2486 );
AddButton( 71, 45, 0x845, 0x846, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 96, 43, 110, 26, 1063014, 0x0, false, false ); // My Guild
AddBackground( 236, 40, 150, 26, 0x2486 );
AddButton( 241, 45, 0x845, 0x846, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 266, 43, 110, 26, 1062974, 0x0, false, false ); // Guild Roster
AddBackground( 401, 40, 150, 26, 0x2486 );
AddButton( 406, 45, 0x845, 0x846, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 431, 43, 110, 26, 1062978, 0x0, false, false ); // Diplomacy
AddPage( 1 );
}
public override void OnResponse( NetState sender, RelayInfo info )
{
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( !IsMember( pm, guild ) )
return;
switch( info.ButtonID )
{
case 1:
{
pm.SendGump( new GuildInfoGump( pm, guild ) );
break;
}
case 2:
{
pm.SendGump( new GuildRosterGump( pm, guild ) );
break;
}
case 3:
{
pm.SendGump( new GuildDiplomacyGump( pm, guild ) );
break;
}
}
}
public static bool IsLeader( Mobile m, Guild g )
{
return !( m.Deleted || g.Disbanded || !( m is PlayerMobile ) || (m.AccessLevel < AccessLevel.GameMaster && g.Leader != m) );
}
public static bool IsMember( Mobile m, Guild g )
{
return !( m.Deleted || g.Disbanded || !( m is PlayerMobile ) || (m.AccessLevel < AccessLevel.GameMaster && !g.IsMember( m )) );
}
public static bool CheckProfanity( string s )
{
return CheckProfanity( s, 50 );
}
public static bool CheckProfanity( string s, int maxLength )
{
//return NameVerification.Validate( s, 1, 50, true, true, false, int.MaxValue, ProfanityProtection.Exceptions, ProfanityProtection.Disallowed, ProfanityProtection.StartDisallowed ); //What am I doing wrong, this still allows chars like the <3 symbol... 3 AM. someone change this to use this
//With testing on OSI, Guild stuff seems to follow a 'simpler' method of profanity protection
if( s.Length < 1 || s.Length > maxLength )
return false;
char[] exceptions = ProfanityProtection.Exceptions;
s = s.ToLower();
for ( int i = 0; i < s.Length; ++i )
{
char c = s[i];
if ( (c < 'a' || c > 'z') && (c < '0' || c > '9'))
{
bool except = false;
for( int j = 0; !except && j < exceptions.Length; j++ )
if( c == exceptions[j] )
except = true;
if( !except )
return false;
}
}
string[] disallowed = ProfanityProtection.Disallowed;
for( int i = 0; i < disallowed.Length; i++ )
{
if ( s.IndexOf( disallowed[i] ) != -1 )
return false;
}
return true;
}
public void AddHtmlText( int x, int y, int width, int height, TextDefinition text, bool back, bool scroll )
{
if ( text != null && text.Number > 0 )
AddHtmlLocalized( x, y, width, height, text.Number, back, scroll );
else if ( text != null && text.String != null )
AddHtml( x, y, width, height, text.String, back, scroll );
}
public static string Color( string text, int color )
{
return String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text );
}
}
}

View file

@ -0,0 +1,209 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using System.Collections;
using System.Collections.Generic;
namespace Server.Guilds
{
public abstract class BaseGuildListGump<T> : BaseGuildGump
{
List<T> m_List;
IComparer<T> m_Comparer;
InfoField<T>[] m_Fields;
bool m_Ascending;
string m_Filter;
int m_StartNumber;
private const int itemsPerPage = 8;
public BaseGuildListGump( PlayerMobile pm, Guild g, List<T> list, IComparer<T> currentComparer, bool ascending, string filter, int startNumber, InfoField<T>[] fields )
: base( pm, g )
{
m_Filter = filter.Trim();
m_Comparer = currentComparer;
m_Fields = fields;
m_Ascending = ascending;
m_StartNumber = startNumber;
m_List = list;
}
public virtual bool WillFilter{ get{ return (m_Filter.Length >= 0); } }
public override void PopulateGump()
{
base.PopulateGump();
List<T> list = m_List;
if( WillFilter )
{
m_List = new List<T>();
for( int i = 0; i < list.Count; i++ )
{
if( !IsFiltered( list[i], m_Filter ) )
m_List.Add( list[i] );
}
}
else
{
m_List = new List<T>( list );
}
m_List.Sort( m_Comparer );
m_StartNumber = Math.Max( Math.Min( m_StartNumber, m_List.Count - 1 ), 0 );
AddBackground( 130, 75, 385, 30, 0xBB8 );
AddTextEntry( 135, 80, 375, 30, 0x481, 1, m_Filter );
AddButton( 520, 75, 0x867, 0x868, 5, GumpButtonType.Reply, 0 ); //Filter Button
int width = 0;
for( int i = 0; i < m_Fields.Length; i++ )
{
InfoField<T> f = m_Fields[i];
AddImageTiled( 65 + width, 110, f.Width + 10, 26, 0xA40 );
AddImageTiled( 67 + width, 112, f.Width + 6, 22, 0xBBC );
AddHtmlText( 70 + width, 113, f.Width, 20, f.Name, false, false );
bool isComparer = ( m_Fields[i].Comparer.GetType() == m_Comparer.GetType() );
int ButtonID = ( isComparer ) ? ( m_Ascending ? 0x983 : 0x985 ) : 0x2716;
AddButton( 59 + width + f.Width, 117, ButtonID, ButtonID + (isComparer ? 1 : 0) , 100 + i, GumpButtonType.Reply, 0 );
width += (f.Width + 12);
}
if( m_StartNumber <= 0 )
AddButton( 65, 80, 0x15E3, 0x15E7, 0, GumpButtonType.Page, 0 );
else
AddButton( 65, 80, 0x15E3, 0x15E7, 6, GumpButtonType.Reply, 0 ); // Back
if( m_StartNumber + itemsPerPage > m_List.Count )
AddButton( 95, 80, 0x15E1, 0x15E5, 0, GumpButtonType.Page, 0 );
else
AddButton( 95, 80, 0x15E1, 0x15E5, 7, GumpButtonType.Reply, 0 ); // Forward
int itemNumber = 0;
if( m_Ascending )
for( int i = m_StartNumber; i < m_StartNumber + itemsPerPage && i < m_List.Count; i++ )
DrawEntry( m_List[i], i, itemNumber++ );
else //descending, go from bottom of list to the top
for( int i = m_List.Count - 1 - m_StartNumber; i >= 0 && i >= (m_List.Count - itemsPerPage - m_StartNumber); i-- )
DrawEntry( m_List[i], i, itemNumber++ );
DrawEndingEntry( itemNumber );
}
public virtual void DrawEndingEntry( int itemNumber )
{
}
public virtual bool HasRelationship( T o )
{
return false;
}
public virtual void DrawEntry( T o, int index, int itemNumber )
{
int width = 0;
for( int j = 0; j < m_Fields.Length; j++ )
{
InfoField<T> f = m_Fields[j];
AddImageTiled( 65 + width, 138 + itemNumber * 28, f.Width + 10, 26, 0xA40 );
AddImageTiled( 67 + width, 140 + itemNumber * 28, f.Width + 6, 22, 0xBBC );
AddHtmlText( 70 + width, 141 + itemNumber * 28, f.Width, 20, GetValuesFor( o, m_Fields.Length )[j], false, false );
width += (f.Width + 12);
}
if( HasRelationship( o ) )
AddButton( 40, 143 + itemNumber * 28, 0x8AF, 0x8AF, 200 + index, GumpButtonType.Reply, 0 ); //Info Button
else
AddButton( 40, 143 + itemNumber * 28, 0x4B9, 0x4BA, 200 + index, GumpButtonType.Reply, 0 ); //Info Button
}
protected abstract TextDefinition[] GetValuesFor( T o, int aryLength );
protected abstract bool IsFiltered( T o, string filter );
public override void OnResponse( NetState sender, RelayInfo info )
{
base.OnResponse( sender, info );
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( pm == null || !IsMember( pm, guild ) )
return;
int id = info.ButtonID;
switch( id )
{
case 5: //Filter
{
TextRelay t = info.GetTextEntry( 1 );
pm.SendGump( GetResentGump( player, guild, m_Comparer, m_Ascending, ( t == null ) ? "" : t.Text, 0 ) );
break;
}
case 6: //Back
{
pm.SendGump( GetResentGump( player, guild, m_Comparer, m_Ascending, m_Filter, m_StartNumber - itemsPerPage ) );
break;
}
case 7: //Forward
{
pm.SendGump( GetResentGump( player, guild, m_Comparer, m_Ascending, m_Filter, m_StartNumber + itemsPerPage ) );
break;
}
}
if( id >= 100 && id < (100 + m_Fields.Length) )
{
IComparer<T> comparer = m_Fields[id-100].Comparer;
if( m_Comparer.GetType() == comparer.GetType() )
m_Ascending = !m_Ascending;
pm.SendGump( GetResentGump( player, guild, comparer, m_Ascending, m_Filter, 0 ) );
}
else if( id >= 200 && id < ( 200 + m_List.Count ) )
{
pm.SendGump( GetObjectInfoGump( player, guild, m_List[id - 200] ) );
}
}
public abstract Gump GetResentGump( PlayerMobile pm, Guild g, IComparer<T> comparer, bool ascending, string filter, int startNumber );
public abstract Gump GetObjectInfoGump( PlayerMobile pm, Guild g, T o );
public void ResendGump()
{
player.SendGump( GetResentGump( player, guild, m_Comparer, m_Ascending, m_Filter, m_StartNumber ) );
}
}
public struct InfoField<T>
{
private TextDefinition m_Name;
private int m_Width;
private IComparer<T> m_Comparer;
public TextDefinition Name{ get{ return m_Name; } }
public int Width{ get{ return m_Width; } }
public IComparer<T> Comparer { get { return m_Comparer; } }
public InfoField( TextDefinition name, int width, IComparer<T> comparer )
{
m_Name = name;
m_Width = width;
m_Comparer = comparer;
}
}
}

View file

@ -0,0 +1,101 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
namespace Server.Guilds
{
public class CreateGuildGump : Gump
{
public CreateGuildGump( PlayerMobile pm ) : this( pm, "Guild Name", "" )
{
}
public CreateGuildGump( PlayerMobile pm, string guildName, string guildAbbrev ) : base( 10, 10 )
{
pm.CloseGump( typeof( CreateGuildGump ) );
pm.CloseGump( typeof( BaseGuildGump ) );
AddPage( 0 );
AddBackground( 0, 0, 500, 300, 0x2422 );
AddHtmlLocalized( 25, 20, 450, 25, 1062939, 0x0, true, false ); // <center>GUILD MENU</center>
AddHtmlLocalized( 25, 60, 450, 60, 1062940, 0x0, false, false ); // As you are not a member of any guild, you can create your own by providing a unique guild name and paying the standard guild registration fee.
AddHtmlLocalized( 25, 135, 120, 25, 1062941, 0x0, false, false ); // Registration Fee:
AddLabel( 155, 135, 0x481, Guild.RegistrationFee.ToString() );
AddHtmlLocalized( 25, 165, 120, 25, 1011140, 0x0, false, false ); // Enter Guild Name:
AddBackground( 155, 160, 320, 26, 0xBB8 );
AddTextEntry( 160, 163, 315, 21, 0x481, 5, guildName );
AddHtmlLocalized( 25, 191, 120, 26, 1063035, 0x0, false, false ); // Abbreviation:
AddBackground( 155, 186, 320, 26, 0xBB8 );
AddTextEntry( 160, 189, 315, 21, 0x481, 6, guildAbbrev );
AddButton( 415, 217, 0xF7, 0xF8, 1, GumpButtonType.Reply, 0 );
AddButton( 345, 217, 0xF2, 0xF1, 0, GumpButtonType.Reply, 0 );
if( pm.AcceptGuildInvites )
AddButton( 20, 260, 0xD2, 0xD3, 2, GumpButtonType.Reply, 0 );
else
AddButton( 20, 260, 0xD3, 0xD2, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 260, 200, 30, 1062943, 0x0, false, false ); // <i>Ignore Guild Invites</i>
}
public override void OnResponse( NetState sender, RelayInfo info )
{
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( pm == null || pm.Guild != null )
return; //Sanity
switch( info.ButtonID )
{
case 1:
{
TextRelay tName = info.GetTextEntry( 5 );
TextRelay tAbbrev = info.GetTextEntry( 6 );
string guildName = (tName == null) ? "" : tName.Text;
string guildAbbrev = (tAbbrev == null) ? "" : tAbbrev.Text;
guildName = Utility.FixHtml( guildName.Trim() );
guildAbbrev = Utility.FixHtml( guildAbbrev.Trim() );
if( guildName.Length <= 0 )
pm.SendLocalizedMessage( 1070884 ); // Guild name cannot be blank.
else if( guildAbbrev.Length <= 0 )
pm.SendLocalizedMessage( 1070885 ); // You must provide a guild abbreviation.
else if( guildName.Length > Guild.NameLimit )
pm.SendLocalizedMessage( 1063036, Guild.NameLimit.ToString() ); // A guild name cannot be more than ~1_val~ characters in length.
else if( guildAbbrev.Length > Guild.AbbrevLimit )
pm.SendLocalizedMessage( 1063037, Guild.AbbrevLimit.ToString() ); // An abbreviation cannot exceed ~1_val~ characters in length.
else if( Guild.FindByAbbrev( guildAbbrev ) != null || !BaseGuildGump.CheckProfanity( guildAbbrev ) )
pm.SendLocalizedMessage( 501153 ); // That abbreviation is not available.
else if( Guild.FindByName( guildName ) != null || !BaseGuildGump.CheckProfanity( guildName ) )
pm.SendLocalizedMessage( 1063000 ); // That guild name is not available.
else if( !Banker.Withdraw( pm, Guild.RegistrationFee ) )
pm.SendLocalizedMessage( 1063001, Guild.RegistrationFee.ToString() ); // You do not possess the ~1_val~ gold piece fee required to create a guild.
else
{
pm.SendLocalizedMessage( 1060398, Guild.RegistrationFee.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
pm.SendLocalizedMessage( 1063238 ); // Your new guild has been founded.
pm.Guild = new Guild( pm, guildName, guildAbbrev );
}
break;
}
case 2:
{
pm.AcceptGuildInvites = !pm.AcceptGuildInvites;
if( pm.AcceptGuildInvites )
pm.SendLocalizedMessage( 1070699 ); // You are now accepting guild invitations.
else
pm.SendLocalizedMessage( 1070698 ); // You are now ignoring guild invitations.
break;
}
}
}
}
}

View file

@ -0,0 +1,280 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using System.Collections;
using System.Collections.Generic;
namespace Server.Guilds
{
public enum GuildDisplayType
{
All,
AwaitingAction,
Relations
}
public class GuildDiplomacyGump : BaseGuildListGump<Guild>
{
protected virtual bool AllowAdvancedSearch{ get{ return true; } }
#region Comparers
private class NameComparer : IComparer<Guild>
{
public static readonly IComparer<Guild> Instance = new NameComparer();
public NameComparer()
{
}
public int Compare( Guild x, Guild y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
return Insensitive.Compare( x.Name, y.Name );
}
}
private class StatusComparer : IComparer<Guild>
{
private enum GuildCompareStatus
{
Peace,
Ally,
War
}
private Guild m_Guild;
public StatusComparer( Guild g )
{
m_Guild = g;
}
public int Compare( Guild x, Guild y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
GuildCompareStatus aStatus = GuildCompareStatus.Peace;
GuildCompareStatus bStatus = GuildCompareStatus.Peace;
if( m_Guild.IsAlly( x ) )
aStatus = GuildCompareStatus.Ally;
else if( m_Guild.IsWar( x ) )
aStatus = GuildCompareStatus.War;
if( m_Guild.IsAlly( y ) )
bStatus = GuildCompareStatus.Ally;
else if( m_Guild.IsWar( y ) )
bStatus = GuildCompareStatus.War;
return ((int)aStatus).CompareTo( (int)bStatus );
}
}
private class AbbrevComparer : IComparer<Guild>
{
public static readonly IComparer<Guild> Instance = new AbbrevComparer();
public AbbrevComparer()
{
}
public int Compare( Guild x, Guild y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
return Insensitive.Compare( x.Abbreviation, y.Abbreviation );
}
}
#endregion
GuildDisplayType m_Display;
TextDefinition m_LowerText;
public GuildDiplomacyGump( PlayerMobile pm, Guild g )
: this( pm, g, GuildDiplomacyGump.NameComparer.Instance, true, "", 0, GuildDisplayType.All, Utility.CastConvertList<BaseGuild, Guild>( new List<BaseGuild>( Guild.List.Values ) ), (1063136 + (int)GuildDisplayType.All) )
{
}
public GuildDiplomacyGump( PlayerMobile pm, Guild g, IComparer<Guild> currentComparer, bool ascending, string filter, int startNumber, GuildDisplayType display )
: this( pm, g, currentComparer, ascending, filter, startNumber, display, Utility.CastConvertList<BaseGuild, Guild>( new List<BaseGuild>( Guild.List.Values ) ), (1063136 + (int)display) )
{
}
public GuildDiplomacyGump( PlayerMobile pm, Guild g, IComparer<Guild> currentComparer, bool ascending, string filter, int startNumber, List<Guild> list, TextDefinition lowerText )
: this( pm, g, currentComparer, ascending, filter, startNumber, GuildDisplayType.All, list, lowerText )
{
}
public GuildDiplomacyGump( PlayerMobile pm, Guild g, bool ascending, string filter, int startNumber, List<Guild> list, TextDefinition lowerText )
: this( pm, g, GuildDiplomacyGump.NameComparer.Instance, ascending, filter, startNumber, GuildDisplayType.All, list, lowerText )
{
}
public GuildDiplomacyGump( PlayerMobile pm, Guild g, IComparer<Guild> currentComparer, bool ascending, string filter, int startNumber, GuildDisplayType display, List<Guild> list, TextDefinition lowerText )
: base( pm, g, list, currentComparer, ascending, filter, startNumber,
new InfoField<Guild>[]
{
new InfoField<Guild>( 1062954, 280, GuildDiplomacyGump.NameComparer.Instance ), //Guild Name
new InfoField<Guild>( 1062957, 50, GuildDiplomacyGump.AbbrevComparer.Instance ), //Abbrev
new InfoField<Guild>( 1062958, 120, new GuildDiplomacyGump.StatusComparer( g ) ) //Guild Title
})
{
m_Display = display;
m_LowerText = lowerText;
PopulateGump();
}
public override void PopulateGump()
{
base.PopulateGump();
AddHtmlLocalized( 431, 43, 110, 26, 1062978, 0xF, false, false ); // Diplomacy
}
protected override TextDefinition[] GetValuesFor( Guild g, int aryLength )
{
TextDefinition[] defs = new TextDefinition[aryLength];
defs[0] = ( g == guild ) ? Color( g.Name, 0x006600 ) : g.Name;
defs[1] = g.Abbreviation;
defs[2] = 3000085; //Peace
if( guild.IsAlly( g ) )
{
if( guild.Alliance.Leader == g )
defs[2] = 1063237; // Alliance Leader
else
defs[2] = 1062964; // Ally
}
else if( guild.IsWar( g ) )
{
defs[2] = 3000086; // War
}
return defs;
}
public override bool HasRelationship( Guild g )
{
if( g == guild )
return false;
if( guild.FindPendingWar( g ) != null )
return true;
AllianceInfo alliance = guild.Alliance;
if( alliance != null && alliance.IsPendingMember( g ) )
return true;
return false;
}
public override void DrawEndingEntry( int itemNumber )
{
//AddHtmlLocalized( 66, 153 + itemNumber * 28, 280, 26, 1063136 + (int)m_Display, 0xF, false, false ); // Showing All Guilds/Awaiting Action/ w/Relation Ship
//AddHtmlText( 66, 153 + itemNumber * 28, 280, 26, m_LowerText, false, false );
if ( m_LowerText != null && m_LowerText.Number > 0 )
AddHtmlLocalized( 66, 153 + itemNumber * 28, 280, 26, m_LowerText.Number, 0xF, false, false );
else if ( m_LowerText != null && m_LowerText.String != null )
AddHtml( 66, 153 + itemNumber * 28, 280, 26, Color( m_LowerText.String, 0x99 ), false, false );
if( AllowAdvancedSearch )
{
AddBackground( 350, 148 + itemNumber * 28, 200, 26, 0x2486 );
AddButton( 355, 153 + itemNumber * 28, 0x845, 0x846, 8, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 380, 151 + itemNumber * 28, 160, 26, 1063083, 0x0, false, false ); // Advanced Search
}
}
protected override bool IsFiltered( Guild g, string filter )
{
if( g == null )
return true;
switch( m_Display )
{
case GuildDisplayType.Relations:
{
//if( !( guild.IsWar( g ) || guild.IsAlly( g ) ) )
if( !( guild.FindActiveWar( g ) != null || guild.IsAlly( g ) ) ) //As per OSI, only the guild leader wars show up under the sorting by relation
return true;
return false;
}
case GuildDisplayType.AwaitingAction:
{
return !HasRelationship( g );
}
}
return !( Insensitive.Contains( g.Name, filter ) || Insensitive.Contains( g.Abbreviation, filter ) );
}
public override bool WillFilter
{
get
{
if( m_Display == GuildDisplayType.All )
return base.WillFilter;
return true;
}
}
public override Gump GetResentGump( PlayerMobile pm, Guild g, IComparer<Guild> comparer, bool ascending, string filter, int startNumber )
{
return new GuildDiplomacyGump( pm, g, comparer, ascending, filter, startNumber, m_Display );
}
public override Gump GetObjectInfoGump( PlayerMobile pm, Guild g, Guild o )
{
if( guild == o )
return new GuildInfoGump( pm, g );
return new OtherGuildInfo( pm, g, (Guild)o ) ;
}
public override void OnResponse( NetState sender, RelayInfo info )
{
base.OnResponse( sender, info );
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( pm == null || !IsMember( pm, guild ) )
return;
if( AllowAdvancedSearch && info.ButtonID == 8 )
pm.SendGump( new GuildAdvancedSearchGump( pm, guild, m_Display, new SearchSelectionCallback( AdvancedSearch_Callback ) ));
}
public void AdvancedSearch_Callback( GuildDisplayType display )
{
m_Display = display;
ResendGump();
}
}
}

View file

@ -0,0 +1,175 @@
using System;
using Server;
using Server.Mobiles;
using Server.Gumps;
using Server.Network;
using Server.Factions;
using Server.Prompts;
namespace Server.Guilds
{
public class GuildInfoGump : BaseGuildGump
{
private bool m_IsResigning;
public GuildInfoGump( PlayerMobile pm, Guild g ) : this( pm, g, false )
{
}
public GuildInfoGump( PlayerMobile pm, Guild g, bool isResigning ) : base( pm, g )
{
m_IsResigning = isResigning;
PopulateGump();
}
public override void PopulateGump()
{
bool isLeader = IsLeader( player, guild );
base.PopulateGump();
AddHtmlLocalized( 96, 43, 110, 26, 1063014, 0xF, false, false ); // My Guild
AddImageTiled( 65, 80, 160, 26, 0xA40 );
AddImageTiled( 67, 82, 156, 22, 0xBBC );
AddHtmlLocalized( 70, 83, 150, 20, 1062954, 0x0, false, false ); // <i>Guild Name</i>
AddHtml( 233, 84, 320, 26, guild.Name, false, false );
AddImageTiled( 65, 114, 160, 26, 0xA40 );
AddImageTiled( 67, 116, 156, 22, 0xBBC );
AddHtmlLocalized( 70, 117, 150, 20, 1063025, 0x0, false, false ); // <i>Alliance</i>
if( guild.Alliance != null && guild.Alliance.IsMember( guild ) )
{
AddHtml( 233, 118, 320, 26, guild.Alliance.Name, false, false );
AddButton( 40, 120, 0x4B9, 0x4BA, 6, GumpButtonType.Reply, 0 ); //Alliance Roster
}
AddImageTiled( 65, 148, 160, 26, 0xA40 );
AddImageTiled( 67, 150, 156, 22, 0xBBC );
AddHtmlLocalized( 70, 151, 150, 20, 1063084, 0x0, false, false ); // <i>Guild Faction</i>
Faction f = Faction.Find( guild.Leader );
if( f != null )
AddHtml( 233, 152, 320, 26, f.ToString(), false, false );
AddImageTiled( 65, 196, 480, 4, 0x238D );
string s = guild.Charter;
if( s == null || s == "" )
s = "The guild leader has not yet set the guild charter.";
AddHtml( 65, 216, 480, 80, s, true, true );
if( isLeader )
AddButton( 40, 251, 0x4B9, 0x4BA, 4, GumpButtonType.Reply, 0 ); //Charter Edit button
s = guild.Website;
if( s == null || s == "" )
s = "Guild website not yet set.";
AddHtml( 65, 306, 480, 30, s, true, false );
if( isLeader )
AddButton( 40, 313, 0x4B9, 0x4BA, 5, GumpButtonType.Reply, 0 ); //Website Edit button
AddCheck( 65, 370, 0xD2, 0xD3, player.DisplayGuildTitle, 0 );
AddHtmlLocalized( 95, 370, 150, 26, 1063085, 0x0, false, false ); // Show Guild Title
AddBackground( 450, 370, 100, 26, 0x2486 );
AddButton( 455, 375, 0x845, 0x846, 7, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 480, 373, 60, 26, 3006115, (m_IsResigning) ? 0x5000 : 0, false, false ); // Resign
}
public override void OnResponse( NetState sender, RelayInfo info )
{
base.OnResponse( sender, info );
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( !IsMember( pm, guild ) )
return;
pm.DisplayGuildTitle = info.IsSwitched( 0 );
switch( info.ButtonID )
{
//1-3 handled by base.OnResponse
case 4:
{
if( IsLeader( pm, guild ) )
{
pm.SendLocalizedMessage( 1013071 ); // Enter the new guild charter (50 characters max):
pm.BeginPrompt( new PromptCallback( SetCharter_Callback ), true ); //Have the same callback handle both canceling and deletion cause the 2nd callback would just get a text of ""
}
break;
}
case 5:
{
if( IsLeader( pm, guild ) )
{
pm.SendLocalizedMessage( 1013072 ); // Enter the new website for the guild (50 characters max):
pm.BeginPrompt( new PromptCallback( SetWebsite_Callback ), true ); //Have the same callback handle both canceling and deletion cause the 2nd callback would just get a text of ""
}
break;
}
case 6:
{
//Alliance Roster
if( guild.Alliance != null && guild.Alliance.IsMember( guild ) )
pm.SendGump( new AllianceInfo.AllianceRosterGump( pm, guild, guild.Alliance ) );
break;
}
case 7:
{
//Resign
if( !m_IsResigning )
{
pm.SendLocalizedMessage( 1063332 ); // Are you sure you wish to resign from your guild?
pm.SendGump( new GuildInfoGump( pm, guild, true ) );
}
else
{
guild.RemoveMember( pm, 1063411 ); // You resign from your guild.
}
break;
}
}
}
public void SetCharter_Callback( Mobile from, string text )
{
if( !IsLeader( from, guild ) )
return;
string charter = Utility.FixHtml( text.Trim() );
if( charter.Length > 50 )
{
from.SendLocalizedMessage( 1070774, "50" ); // Your guild charter cannot exceed ~1_val~ characters.
}
else
{
guild.Charter = charter;
from.SendLocalizedMessage( 1070775 ); // You submit a new guild charter.
return;
}
}
public void SetWebsite_Callback( Mobile from, string text )
{
if( !IsLeader( from, guild ) )
return;
string site = Utility.FixHtml( text.Trim() );
if( site.Length > 50 )
from.SendLocalizedMessage( 1070777, "50" ); // Your guild website cannot exceed ~1_val~ characters.
else
{
guild.Website = site;
from.SendLocalizedMessage( 1070778 ); // You submit a new guild website.
return;
}
}
}
}

View file

@ -0,0 +1,63 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
namespace Server.Guilds
{
public class GuildInvitationRequest : BaseGuildGump
{
PlayerMobile m_Inviter;
public GuildInvitationRequest( PlayerMobile pm, Guild g, PlayerMobile inviter ) : base( pm, g )
{
m_Inviter = inviter;
PopulateGump();
}
public override void PopulateGump()
{
AddPage( 0 );
AddBackground( 0, 0, 350, 170, 0x2422 );
AddHtmlLocalized( 25, 20, 300, 45, 1062946, 0x0, true, false ); // <center>You have been invited to join a guild! (Warning: Accepting will make you attackable!)</center>
AddHtml( 25, 75, 300, 25, String.Format( "<center>{0}</center>", guild.Name ), true, false );
AddButton( 265, 130, 0xF7, 0xF8, 1, GumpButtonType.Reply, 0 );
AddButton( 195, 130, 0xF2, 0xF1, 0, GumpButtonType.Reply, 0 );
AddButton( 20, 130, 0xD2, 0xD3, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 45, 130, 150, 30, 1062943, 0x0, false, false ); // <i>Ignore Guild Invites</i>
}
public override void OnResponse( NetState sender, RelayInfo info )
{
if( guild.Disbanded || player.Guild != null )
return;
switch( info.ButtonID )
{
case 0:
{
m_Inviter.SendLocalizedMessage( 1063250, String.Format( "{0}\t{1}", player.Name, guild.Name ) ); // ~1_val~ has declined your invitation to join ~2_val~.
break;
}
case 1:
{
guild.AddMember( player );
player.SendLocalizedMessage( 1063056, guild.Name ); // You have joined ~1_val~.
m_Inviter.SendLocalizedMessage( 1063249, String.Format( "{0}\t{1}", player.Name, guild.Name ) ); // ~1_val~ has accepted your invitation to join ~2_val~.
break;
}
case 2:
{
player.AcceptGuildInvites = false;
player.SendLocalizedMessage( 1070698 ); // You are now ignoring guild invitations.
break;
}
}
}
}
}

View file

@ -0,0 +1,231 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using Server.Targeting;
using Server.Prompts;
namespace Server.Guilds
{
public class GuildMemberInfoGump : BaseGuildGump
{
PlayerMobile m_Member;
bool m_ToLeader, m_toKick;
public GuildMemberInfoGump( PlayerMobile pm, Guild g, PlayerMobile member, bool toKick, bool toPromoteToLeader ) : base( pm, g, 10, 40 )
{
m_ToLeader = toPromoteToLeader;
m_toKick = toKick;
m_Member = (PlayerMobile)member;
PopulateGump();
}
public override void PopulateGump()
{
AddPage( 0 );
AddBackground( 0, 0, 350, 255, 0x242C );
AddHtmlLocalized( 20, 15, 310, 26, 1063018, 0x0, false, false ); // <div align=center><i>Guild Member Information</i></div>
AddImageTiled( 20, 40, 310, 2, 0x2711 );
AddHtmlLocalized( 20, 50, 150, 26, 1062955, 0x0, true, false ); // <i>Name</i>
AddHtml( 180, 53, 150, 26, m_Member.Name, false, false );
AddHtmlLocalized( 20, 80, 150, 26, 1062956, 0x0, true, false ); // <i>Rank</i>
AddHtmlLocalized( 180, 83, 150, 26, m_Member.GuildRank.Name, 0x0, false, false );
AddHtmlLocalized( 20, 110, 150, 26, 1062953, 0x0, true, false ); // <i>Guild Title</i>
AddHtml( 180, 113, 150, 26, m_Member.GuildTitle, false, false );
AddImageTiled( 20, 142, 310, 2, 0x2711 );
AddBackground( 20, 150, 310, 26, 0x2486 );
AddButton( 25, 155, 0x845, 0x846, 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 50, 153, 270, 26, (m_Member == player.GuildFealty && guild.Leader != m_Member) ? 1063082 : 1062996, 0x0, false, false ); // Clear/Cast Vote For This Member
AddBackground( 20, 180, 150, 26, 0x2486 );
AddButton( 25, 185, 0x845, 0x846, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 50, 183, 110, 26, 1062993, (m_ToLeader)? 0x990000 : 0, false, false ); // Promote
AddBackground( 180, 180, 150, 26, 0x2486 );
AddButton( 185, 185, 0x845, 0x846, 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 210, 183, 110, 26, 1062995, 0x0, false, false ); // Set Guild Title
AddBackground( 20, 210, 150, 26, 0x2486 );
AddButton( 25, 215, 0x845, 0x846, 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 50, 213, 110, 26, 1062994, 0x0, false, false ); // Demote
AddBackground( 180, 210, 150, 26, 0x2486 );
AddButton( 185, 215, 0x845, 0x846, 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 210, 213, 110, 26, 1062997, (m_toKick)? 0x5000 : 0, false, false ); // Kick
}
public override void OnResponse( NetState sender, RelayInfo info )
{
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( pm == null || !IsMember( pm, guild ) || !IsMember( m_Member, guild ) )
return;
RankDefinition playerRank = pm.GuildRank;
RankDefinition targetRank = m_Member.GuildRank;
switch( info.ButtonID )
{
case 1: //Promote
{
if( playerRank.GetFlag( RankFlags.CanPromoteDemote ) && ((playerRank.Rank -1 ) > targetRank.Rank || ( playerRank == RankDefinition.Leader && playerRank.Rank > targetRank.Rank )) )
{
targetRank = RankDefinition.Ranks[targetRank.Rank + 1];
if( targetRank == RankDefinition.Leader )
{
if( m_ToLeader )
{
m_Member.GuildRank = targetRank;
pm.SendLocalizedMessage( 1063156, m_Member.Name ); // The guild information for ~1_val~ has been updated.
pm.SendLocalizedMessage( 1063156, pm.Name ); // The guild information for ~1_val~ has been updated.
guild.Leader = m_Member;
}
else
{
pm.SendLocalizedMessage( 1063144 ); // Are you sure you wish to make this member the new guild leader?
pm.SendGump( new GuildMemberInfoGump( player, guild, m_Member, false, true ) );
}
}
else
{
m_Member.GuildRank = targetRank;
pm.SendLocalizedMessage( 1063156, m_Member.Name ); // The guild information for ~1_val~ has been updated.
}
}
else
pm.SendLocalizedMessage( 1063143 ); // You don't have permission to promote this member.
break;
}
case 2: //Demote
{
if( playerRank.GetFlag( RankFlags.CanPromoteDemote ) && playerRank.Rank > targetRank.Rank )
{
if( targetRank == RankDefinition.Lowest )
{
if( RankDefinition.Lowest.Name.Number == 1062963 )
pm.SendLocalizedMessage( 1063333 ); // You can't demote a ronin.
else
pm.SendMessage( "You can't demote a {0}.", RankDefinition.Lowest.Name );
}
else
{
m_Member.GuildRank = RankDefinition.Ranks[targetRank.Rank - 1];
pm.SendLocalizedMessage( 1063156, m_Member.Name ); // The guild information for ~1_val~ has been updated.
}
}
else
pm.SendLocalizedMessage( 1063146 ); // You don't have permission to demote this member.
break;
}
case 3: //Set Guild title
{
if( playerRank.GetFlag( RankFlags.CanSetGuildTitle ) && ( playerRank.Rank > targetRank.Rank || m_Member == player))
{
pm.SendLocalizedMessage( 1011128 ); // Enter the new title for this guild member or 'none' to remove a title:
pm.BeginPrompt( new PromptCallback( SetTitle_Callback ) );
}
else if( m_Member.GuildTitle == null || m_Member.GuildTitle.Length <= 0 )
{
pm.SendLocalizedMessage( 1070746 ); // You don't have the permission to set that member's guild title.
}
else
{
pm.SendLocalizedMessage( 1063148 ); // You don't have permission to change this member's guild title.
}
break;
}
case 4: //Vote
{
if( m_Member == pm.GuildFealty && guild.Leader != m_Member )
pm.SendLocalizedMessage( 1063158 ); // You have cleared your vote for guild leader.
else if( playerRank.GetFlag( RankFlags.CanVote ) )
{
if( m_Member == guild.Leader )
pm.SendLocalizedMessage( 1063424 ); // You can't vote for the current guild leader.
else if( guild.CanBeVotedFor( m_Member ) )
pm.SendLocalizedMessage( 1063425 ); // You can't vote for an inactive guild member.
else
{
pm.GuildFealty = m_Member;
pm.SendLocalizedMessage( 1063159, m_Member.Name ); // You cast your vote for ~1_val~ for guild leader.
}
}
else
pm.SendLocalizedMessage( 1063149 ); // You don't have permission to vote.
break;
}
case 5: //Kick
{
if( ( playerRank.GetFlag( RankFlags.RemovePlayers ) && playerRank.Rank > targetRank.Rank ) || ( playerRank.GetFlag( RankFlags.RemoveLowestRank ) && targetRank == RankDefinition.Lowest ) )
{
if( m_toKick )
{
guild.RemoveMember( m_Member );
pm.SendLocalizedMessage( 1063157 ); // The member has been removed from your guild.
}
else
{
pm.SendLocalizedMessage( 1063152 ); // Are you sure you wish to kick this member from the guild?
pm.SendGump( new GuildMemberInfoGump( player, guild, m_Member, true, false ) );
}
}
else
pm.SendLocalizedMessage( 1063151 ); // You don't have permission to remove this member.
break;
}
}
}
public void SetTitle_Callback( Mobile from, string text )
{
PlayerMobile pm = from as PlayerMobile;
PlayerMobile targ = m_Member;
if( pm == null || targ == null )
return;
Guild g = targ.Guild as Guild;
if( g == null || !IsMember( pm, g ) || !(pm.GuildRank.GetFlag( RankFlags.CanSetGuildTitle ) && (pm.GuildRank.Rank > targ.GuildRank.Rank || pm == targ)) )
{
if( m_Member.GuildTitle == null || m_Member.GuildTitle.Length <= 0 )
pm.SendLocalizedMessage( 1070746 ); // You don't have the permission to set that member's guild title.
else
pm.SendLocalizedMessage( 1063148 ); // You don't have permission to change this member's guild title.
return;
}
string title = Utility.FixHtml( text.Trim() );
if( title.Length > 20 )
from.SendLocalizedMessage( 501178 ); // That title is too long.
else if( !BaseGuildGump.CheckProfanity( title ) )
from.SendLocalizedMessage( 501179 ); // That title is disallowed.
else
{
if( Insensitive.Equals( title, "none" ) )
targ.GuildTitle = null;
else
targ.GuildTitle = title;
pm.SendLocalizedMessage( 1063156, targ.Name ); // The guild information for ~1_val~ has been updated.
}
}
}
}

View file

@ -0,0 +1,266 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using System.Collections;
using Server.Targets;
using Server.Factions;
using System.Collections.Generic;
namespace Server.Guilds
{
public class GuildRosterGump : BaseGuildListGump<PlayerMobile> //TODO: Convert to <PlayerMobile>
{
#region Comparers
private class NameComparer : IComparer<PlayerMobile>
{
public static readonly IComparer<PlayerMobile> Instance = new NameComparer();
public NameComparer()
{
}
public int Compare( PlayerMobile x, PlayerMobile y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
return Insensitive.Compare( x.Name, y.Name );
}
}
private class LastOnComparer : IComparer<PlayerMobile>
{
public static readonly IComparer<PlayerMobile> Instance = new LastOnComparer();
public LastOnComparer()
{
}
public int Compare( PlayerMobile x, PlayerMobile y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
NetState aState = x.NetState;
NetState bState = y.NetState;
if ( aState == null && bState == null )
return x.LastOnline.CompareTo( y.LastOnline );
else if ( aState == null )
return 1;
else if ( bState == null )
return -1;
else
return 0;
}
}
private class TitleComparer : IComparer<PlayerMobile>
{
public static readonly IComparer<PlayerMobile> Instance = new TitleComparer();
public TitleComparer()
{
}
public int Compare( PlayerMobile x, PlayerMobile y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
return Insensitive.Compare( x.GuildTitle, y.GuildTitle );
}
}
private class RankComparer : IComparer<PlayerMobile>
{
public static readonly IComparer<PlayerMobile> Instance = new RankComparer();
public RankComparer()
{
}
public int Compare( PlayerMobile x, PlayerMobile y )
{
if ( x == null && y == null )
return 0;
else if ( x == null )
return -1;
else if ( y == null )
return 1;
return x.GuildRank.Rank.CompareTo( y.GuildRank.Rank );
}
}
#endregion
private static InfoField<PlayerMobile>[] m_Fields =
new InfoField<PlayerMobile>[]
{
new InfoField<PlayerMobile>( 1062955, 130, GuildRosterGump.NameComparer.Instance ), //Name
new InfoField<PlayerMobile>( 1062956, 80, GuildRosterGump.RankComparer.Instance ), //Rank
new InfoField<PlayerMobile>( 1062952, 80, GuildRosterGump.LastOnComparer.Instance), //Last On
new InfoField<PlayerMobile>( 1062953, 150, GuildRosterGump.TitleComparer.Instance ) //Guild Title
};
public GuildRosterGump( PlayerMobile pm, Guild g ) : this( pm, g, GuildRosterGump.LastOnComparer.Instance, true, "", 0 )
{
}
public GuildRosterGump( PlayerMobile pm, Guild g, IComparer<PlayerMobile> currentComparer, bool ascending, string filter, int startNumber )
: base( pm, g, Utility.SafeConvertList<Mobile, PlayerMobile>( g.Members ), currentComparer, ascending, filter, startNumber, m_Fields )
{
PopulateGump();
}
public override void PopulateGump()
{
base.PopulateGump();
AddHtmlLocalized( 266, 43, 110, 26, 1062974, 0xF, false, false ); // Guild Roster
}
public override void DrawEndingEntry( int itemNumber )
{
AddBackground( 225, 148 + itemNumber * 28, 150, 26, 0x2486 );
AddButton( 230, 153 + itemNumber * 28, 0x845, 0x846, 8, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 255, 151 + itemNumber * 28, 110, 26, 1062992, 0x0, false, false ); // Invite Player
}
protected override TextDefinition[] GetValuesFor( PlayerMobile pm, int aryLength )
{
TextDefinition[] defs = new TextDefinition[aryLength];
string name = String.Format( "{0}{1}", pm.Name, ( player.GuildFealty == pm && player.GuildFealty != guild.Leader ) ? " *" : "" );
if( pm == player )
name = Color( name, 0x006600 );
else if( pm.NetState != null )
name = Color( name, 0x000066 );
defs[0] = name;
defs[1] = pm.GuildRank.Name;
defs[2] = (pm.NetState != null) ? new TextDefinition( 1063015 ): new TextDefinition( pm.LastOnline.ToString( "yyyy-MM-dd" ) );
defs[3] = (pm.GuildTitle == null) ? "" : pm.GuildTitle;
return defs;
}
protected override bool IsFiltered( PlayerMobile pm, string filter )
{
if( pm == null )
return true;
return !Insensitive.Contains( pm.Name, filter );
}
public override Gump GetResentGump( PlayerMobile pm, Guild g, IComparer<PlayerMobile> comparer, bool ascending, string filter, int startNumber )
{
return new GuildRosterGump( pm, g, comparer, ascending, filter, startNumber );
}
public override Gump GetObjectInfoGump( PlayerMobile pm, Guild g, PlayerMobile o )
{
return new GuildMemberInfoGump( pm, g, o, false, false ) ;
}
public override void OnResponse( NetState sender, RelayInfo info )
{
base.OnResponse( sender, info );
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( pm == null || !IsMember( pm, guild ) )
return;
if( info.ButtonID == 8 )
{
if( pm.GuildRank.GetFlag( RankFlags.CanInvitePlayer ) )
{
pm.SendLocalizedMessage( 1063048 ); // Whom do you wish to invite into your guild?
pm.BeginTarget( -1, false, Targeting.TargetFlags.None, new TargetStateCallback( InvitePlayer_Callback ), guild );
}
else
pm.SendLocalizedMessage( 503301 ); // You don't have permission to do that.
}
}
public void InvitePlayer_Callback( Mobile from, object targeted, object state )
{
PlayerMobile pm = from as PlayerMobile;
PlayerMobile targ = targeted as PlayerMobile;
Guild g = state as Guild;
PlayerState guildState = PlayerState.Find( g.Leader );
PlayerState targetState = PlayerState.Find( targ );
Faction guildFaction = ( guildState == null ? null : guildState.Faction );
Faction targetFaction = ( targetState == null ? null : targetState.Faction );
if( pm == null || !IsMember( pm, guild ) || !pm.GuildRank.GetFlag( RankFlags.CanInvitePlayer ) )
{
pm.SendLocalizedMessage( 503301 ); // You don't have permission to do that.
}
else if( targ == null )
{
pm.SendLocalizedMessage( 1063334 ); // That isn't a valid player.
}
else if( !targ.AcceptGuildInvites )
{
pm.SendLocalizedMessage( 1063049, targ.Name ); // ~1_val~ is not accepting guild invitations.
}
else if( g.IsMember( targ ) )
{
pm.SendLocalizedMessage( 1063050, targ.Name ); // ~1_val~ is already a member of your guild!
}
else if( targ.Guild != null )
{
pm.SendLocalizedMessage( 1063051, targ.Name ); // ~1_val~ is already a member of a guild.
}
else if( targ.HasGump( typeof( BaseGuildGump ) ) || targ.HasGump( typeof( CreateGuildGump ) )) //TODO: Check message if CreateGuildGump Open
{
pm.SendLocalizedMessage( 1063052, targ.Name ); // ~1_val~ is currently considering another guild invitation.
}
#region Factions
else if( targ.Young && guildFaction != null )
{
pm.SendLocalizedMessage( 1070766 ); // You cannot invite a young player to your faction-aligned guild.
}
else if ( guildFaction != targetFaction )
{
if ( guildFaction == null )
pm.SendLocalizedMessage( 1013027 ); // That player cannot join a non-faction guild.
else if ( targetFaction == null )
pm.SendLocalizedMessage( 1013026 ); // That player must be in a faction before joining this guild.
else
pm.SendLocalizedMessage( 1013028 ); // That person has a different faction affiliation.
}
else if ( targetState != null && targetState.IsLeaving )
{
// OSI does this quite strangely, so we'll just do it this way
pm.SendMessage( "That person is quitting their faction and so you may not recruit them." );
}
#endregion
else
{
pm.SendLocalizedMessage( 1063053, targ.Name ); // You invite ~1_val~ to join your guild.
targ.SendGump( new GuildInvitationRequest( targ, guild, pm ) );
}
}
}
}

View file

@ -0,0 +1,602 @@
using System;
using Server;
using Server.Mobiles;
using Server.Gumps;
using Server.Network;
using Server.Factions;
using Server.Prompts;
namespace Server.Guilds
{
public class OtherGuildInfo : BaseGuildGump
{
private Guild m_Other;
public OtherGuildInfo( PlayerMobile pm, Guild g, Guild otherGuild ) : base( pm, g, 10, 40 )
{
m_Other = otherGuild;
g.CheckExpiredWars();
PopulateGump();
}
public void AddButtonAndBackground( int x, int y, int buttonID, int locNum )
{
AddBackground( x, y, 225, 26, 0x2486 );
AddButton( x+5, y+5, 0x845, 0x846, buttonID, GumpButtonType.Reply, 0 );
AddHtmlLocalized( x+30, y+3, 185, 26, locNum, 0x0, false, false );
}
public override void PopulateGump()
{
WarDeclaration war = guild.FindPendingWar( m_Other );
WarDeclaration activeWar = guild.FindActiveWar( m_Other );
AllianceInfo alliance = guild.Alliance;
AllianceInfo otherAlliance = m_Other.Alliance;
//NOTE TO SELF: Only only alliance leader can see pending guild alliance statuses
bool PendingWar = (war != null);
bool ActiveWar = (activeWar != null);
AddPage( 0 );
AddBackground( 0, 0, 520, 335, 0x242C );
AddHtmlLocalized( 20, 15, 480, 26, 1062975, 0x0, false, false ); // <div align=center><i>Guild Relationship</i></div>
AddImageTiled( 20, 40, 480, 2, 0x2711 );
AddHtmlLocalized( 20, 50, 120, 26, 1062954, 0x0, true, false ); // <i>Guild Name</i>
AddHtml( 150, 53, 360, 26, m_Other.Name, false, false );
AddHtmlLocalized( 20, 80, 120, 26, 1063025, 0x0, true, false ); // <i>Alliance</i>
if( otherAlliance != null )
{
if( otherAlliance.IsMember( m_Other ))
{
AddHtml( 150, 83, 360, 26, otherAlliance.Name, false, false );
}
//else if( otherAlliance.Leader == guild && ( otherAlliance.IsPendingMember( m_Other ) || otherAlliance.IsPendingMember( guild ) ) )
/* else if( (otherAlliance.Leader == guild && otherAlliance.IsPendingMember( m_Other ) ) || ( otherAlliance.Leader == m_Other && otherAlliance.IsPendingMember( guild ) ) )
{
AddHtml( 150, 83, 360, 26, Color( alliance.Name, 0xF), false, false );
}
//AddHtml( 150, 83, 360, 26, ( alliance.PendingMembers.Contains( guild ) || alliance.PendingMembers.Contains( m_Other ) ) ? String.Format( "<basefont color=#blue>{0}</basefont>", alliance.Name ) : alliance.Name, false, false );
//AddHtml( 150, 83, 360, 26, ( otherAlliance == alliance && otherAlliance.PendingMembers.Contains( guild ) || otherAlliance.PendingMembers.Contains( m_Other ) ) ? String.Format( "<basefont color=#blue>{0}</basefont>", otherAlliance.Name ) : otherAlliance.Name, false, false );
*/
}
AddHtmlLocalized( 20, 110, 120, 26, 1063139, 0x0, true, false ); // <i>Abbreviation</i>
AddHtml( 150, 113, 120, 26, m_Other.Abbreviation, false, false );
string kills = "0/0";
string time = "00:00";
string otherKills = "0/0";
WarDeclaration otherWar;
if( ActiveWar )
{
kills = String.Format( "{0}/{1}", activeWar.Kills, activeWar.MaxKills );
TimeSpan timeRemaining = TimeSpan.Zero;
if( activeWar.WarLength != TimeSpan.Zero && (activeWar.WarBeginning + activeWar.WarLength) > DateTime.Now )
timeRemaining = (activeWar.WarBeginning + activeWar.WarLength) - DateTime.Now;
//time = String.Format( "{0:D2}:{1:D2}", timeRemaining.Hours.ToString(), timeRemaining.Subtract( TimeSpan.FromHours( timeRemaining.Hours ) ).Minutes ); //Is there a formatter for htis? it's 2AM and I'm tired and can't find it
time = String.Format( "{0:D2}:{1:mm}", timeRemaining.Hours, DateTime.MinValue + timeRemaining );
otherWar = m_Other.FindActiveWar( guild );
if( otherWar != null )
otherKills = String.Format( "{0}/{1}", otherWar.Kills, otherWar.MaxKills );
}
else if( PendingWar )
{
kills = Color( String.Format( "{0}/{1}", war.Kills, war.MaxKills ), 0x990000 );
//time = Color( String.Format( "{0}:{1}", war.WarLength.Hours, ((TimeSpan)(war.WarLength - TimeSpan.FromHours( war.WarLength.Hours ))).Minutes ), 0xFF0000 );
time = Color( String.Format( "{0:D2}:{1:mm}", war.WarLength.Hours, DateTime.MinValue + war.WarLength ), 0x990000 );
otherWar = m_Other.FindPendingWar( guild );
if( otherWar != null )
otherKills = Color( String.Format( "{0}/{1}", otherWar.Kills, otherWar.MaxKills ), 0x990000 );
}
AddHtmlLocalized( 280, 110, 120, 26, 1062966, 0x0, true, false ); // <i>Your Kills</i>
AddHtml( 410, 113, 120, 26, kills , false, false );
AddHtmlLocalized( 20, 140, 120, 26, 1062968, 0x0, true, false ); // <i>Time Remaining</i>
AddHtml( 150, 143, 120, 26, time, false, false );
AddHtmlLocalized( 280, 140, 120, 26, 1062967, 0x0, true, false ); // <i>Their Kills</i>
AddHtml( 410, 143, 120, 26, otherKills, false, false );
AddImageTiled( 20, 172, 480, 2, 0x2711 );
int number = 1062973;// <div align=center>You are at peace with this guild.</div>
if( PendingWar )
{
if( war.WarRequester )
{
number = 1063027; // <div align=center>You have challenged this guild to war!</div>
}
else
{
number = 1062969; // <div align=center>This guild has challenged you to war!</div>
AddButtonAndBackground( 20, 260, 5, 1062981 ); // Accept Challenge
AddButtonAndBackground( 275, 260, 6, 1062983 ); //Modify Terms
}
AddButtonAndBackground( 20, 290, 7, 1062982 ); // Dismiss Challenge
}
else if( ActiveWar )
{
number = 1062965; // <div align=center>You are at war with this guild!</div>
AddButtonAndBackground( 20, 290, 8, 1062980 ); // Surrender
}
else if ( alliance != null && alliance == otherAlliance ) //alliance, Same Alliance
{
if( alliance.IsMember( guild ) && alliance.IsMember( m_Other ) ) //Both in Same alliance, full members
{
number = 1062970; // <div align=center>You are allied with this guild.</div>
if( alliance.Leader == guild )
{
AddButtonAndBackground( 20, 260, 12, 1062984 ); // Remove Guild from Alliance
AddButtonAndBackground( 275, 260, 13, 1063433 ); // Promote to Alliance Leader //Note: No 'confirmation' like the other leader guild promotion things
//Remove guild from alliance //Promote to Alliance Leader
}
//Show roster, Centered, up
AddButtonAndBackground( 148, 215, 10, 1063164 ); //Show Alliance Roster
//Leave Alliance
AddButtonAndBackground( 20, 290, 11, 1062985 ); // Leave Alliance
}
else if( alliance.Leader == guild && alliance.IsPendingMember( m_Other ) )
{
number = 1062971; // <div align=center>You have requested an alliance with this guild.</div>
//Show Alliance Roster, Centered, down.
AddButtonAndBackground( 148, 245, 10, 1063164 ); //Show Alliance Roster
//Withdraw Request
AddButtonAndBackground( 20, 290, 14, 1062986 ); // Withdraw Request
AddHtml( 150, 83, 360, 26, Color( alliance.Name, 0x99 ), false, false );
}
else if( alliance.Leader == m_Other && alliance.IsPendingMember( guild ) )
{
number = 1062972; // <div align=center>This guild has requested an alliance.</div>
//Show alliance Roster, top
AddButtonAndBackground( 148, 215, 10, 1063164 ); //Show Alliance Roster
//Deny Request
//Accept Request
AddButtonAndBackground( 20, 260, 15, 1062988 ); // Deny Request
AddButtonAndBackground( 20, 290, 16, 1062987 ); // Accept Request
AddHtml( 150, 83, 360, 26, Color( alliance.Name, 0x99 ), false, false );
}
}
else
{
AddButtonAndBackground( 20, 260, 2, 1062990 ); // Request Alliance
AddButtonAndBackground( 20, 290, 1, 1062989 ); // Declare War!
}
AddButtonAndBackground( 275, 290, 0, 3000091 ); //Cancel
AddHtmlLocalized( 20, 180, 480, 30, number, 0x0, true, false );
AddImageTiled( 20, 245, 480, 2, 0x2711 );
}
public override void OnResponse( NetState sender, RelayInfo info )
{
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( !IsMember( pm, guild ) )
return;
RankDefinition playerRank = pm.GuildRank;
WarDeclaration war = guild.FindPendingWar( m_Other );
WarDeclaration activeWar = guild.FindActiveWar( m_Other );
WarDeclaration otherWar = m_Other.FindPendingWar( guild );
AllianceInfo alliance = guild.Alliance;
AllianceInfo otherAlliance = m_Other.Alliance;
switch( info.ButtonID )
{
#region War
case 5: //Accept the war
{
if( war != null && !war.WarRequester && activeWar == null )
{
if( !playerRank.GetFlag( RankFlags.ControlWarStatus ) )
{
pm.SendLocalizedMessage( 1063440 ); // You don't have permission to negotiate wars.
}
else
{
//Accept the war
guild.PendingWars.Remove( war );
war.WarBeginning = DateTime.Now;
guild.AcceptedWars.Add( war );
if( guild.Alliance != null && guild.Alliance.IsMember( guild ) )
{
guild.Alliance.AllianceMessage( 1070769, ((m_Other.Alliance != null) ? m_Other.Alliance.Name : m_Other.Name) ); // Guild Message: Your guild is now at war with ~1_GUILDNAME~
guild.Alliance.InvalidateMemberProperties();
}
else
{
guild.GuildMessage( 1070769, ((m_Other.Alliance != null) ? m_Other.Alliance.Name : m_Other.Name) ); // Guild Message: Your guild is now at war with ~1_GUILDNAME~
guild.InvalidateMemberProperties();
}
//Technically SHOULD say Your guild is now at war w/out any info, intentional diff.
m_Other.PendingWars.Remove( otherWar );
otherWar.WarBeginning = DateTime.Now;
m_Other.AcceptedWars.Add( otherWar );
if( m_Other.Alliance != null && m_Other.Alliance.IsMember( m_Other ) )
{
m_Other.Alliance.AllianceMessage( 1070769, ((guild.Alliance != null) ? guild.Alliance.Name : guild.Name) ); // Guild Message: Your guild is now at war with ~1_GUILDNAME~
m_Other.Alliance.InvalidateMemberProperties();
}
else
{
m_Other.GuildMessage( 1070769, ((guild.Alliance != null) ? guild.Alliance.Name : guild.Name) ); // Guild Message: Your guild is now at war with ~1_GUILDNAME~
m_Other.InvalidateMemberProperties();
}
}
}
break;
}
case 6: //Modify war terms
{
if( war != null && !war.WarRequester && activeWar == null )
{
if( !playerRank.GetFlag( RankFlags.ControlWarStatus ) )
{
pm.SendLocalizedMessage( 1063440 ); // You don't have permission to negotiate wars.
}
else
{
pm.SendGump( new WarDeclarationGump( pm, guild, m_Other ) );
}
}
break;
}
case 7: //Dismiss war
{
if( war != null )
{
if( !playerRank.GetFlag( RankFlags.ControlWarStatus ) )
{
pm.SendLocalizedMessage( 1063440 ); // You don't have permission to negotiate wars.
}
else
{
//Dismiss the war
guild.PendingWars.Remove( war );
m_Other.PendingWars.Remove( otherWar );
pm.SendLocalizedMessage( 1070752 ); // The proposal has been updated.
//Messages to opposing guild? (Testing on OSI says no)
}
}
break;
}
case 8: //Surrender
{
if( !playerRank.GetFlag( RankFlags.ControlWarStatus ) )
{
pm.SendLocalizedMessage( 1063440 ); // You don't have permission to negotiate wars.
}
else
{
if( activeWar != null )
{
if( guild.Alliance != null && guild.Alliance.IsMember( guild ) )
{
guild.Alliance.AllianceMessage( 1070740, ((m_Other.Alliance != null) ? m_Other.Alliance.Name : m_Other.Name) );// You have lost the war with ~1_val~.
guild.Alliance.InvalidateMemberProperties();
}
else
{
guild.GuildMessage( 1070740, ((m_Other.Alliance != null) ? m_Other.Alliance.Name : m_Other.Name) );// You have lost the war with ~1_val~.
guild.InvalidateMemberProperties();
}
guild.AcceptedWars.Remove( activeWar );
if( m_Other.Alliance != null && m_Other.Alliance.IsMember( m_Other ) )
{
m_Other.Alliance.AllianceMessage( 1070739, ((guild.Alliance != null) ? guild.Alliance.Name : guild.Name) );// You have won the war against ~1_val~!
m_Other.Alliance.InvalidateMemberProperties();
}
else
{
m_Other.GuildMessage( 1070739, ((guild.Alliance != null) ? guild.Alliance.Name : guild.Name) );// You have won the war against ~1_val~!
m_Other.InvalidateMemberProperties();
}
m_Other.AcceptedWars.Remove( m_Other.FindActiveWar( guild ) );
}
}
break;
}
case 1: //Declare War
{
if( war == null && activeWar == null )
{
if( !playerRank.GetFlag( RankFlags.ControlWarStatus ) )
{
pm.SendLocalizedMessage( 1063440 ); // You don't have permission to negotiate wars.
}
else if( alliance != null && alliance.Leader != guild )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", guild.Name, alliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
pm.SendLocalizedMessage( 1070707, alliance.Leader.Name ); // You need to negotiate via ~1_val~ instead.
}
else if( otherAlliance != null && otherAlliance.Leader != m_Other )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", m_Other.Name, otherAlliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
pm.SendLocalizedMessage( 1070707, otherAlliance.Leader.Name ); // You need to negotiate via ~1_val~ instead.
}
else
{
pm.SendGump( new WarDeclarationGump( pm, guild, m_Other ) );
}
}
break;
}
#endregion
case 2: //Request Alliance
{
#region New alliance
if( alliance == null )
{
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1070747 ); // You don't have permission to create an alliance.
}
else if( Faction.Find( guild.Leader ) != Faction.Find( m_Other.Leader ) )
{
pm.SendLocalizedMessage( 1070758 ); // You cannot propose an alliance to a guild with a different faction allegiance.
}
else if( otherAlliance != null )
{
if( otherAlliance.IsPendingMember( m_Other ) )
pm.SendLocalizedMessage( 1063416, m_Other.Name ); // ~1_val~ is currently considering another alliance proposal.
else
pm.SendLocalizedMessage( 1063426, m_Other.Name ); // ~1_val~ already belongs to an alliance.
}
else if( m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0 )
{
pm.SendLocalizedMessage( 1063427, m_Other.Name ); // ~1_val~ is currently involved in a guild war.
}
else if( guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0 )
{
pm.SendLocalizedMessage( 1063427, guild.Name ); // ~1_val~ is currently involved in a guild war.
}
else
{
pm.SendLocalizedMessage( 1063439 ); // Enter a name for the new alliance:
pm.BeginPrompt( new PromptCallback( CreateAlliance_Callback ) );
}
}
#endregion
#region Existing Alliance
else
{
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1063436 ); // You don't have permission to negotiate an alliance.
}
else if( alliance.Leader != guild )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", guild.Name, alliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
}
else if( otherAlliance != null )
{
if( otherAlliance.IsPendingMember( m_Other ) )
pm.SendLocalizedMessage( 1063416, m_Other.Name ); // ~1_val~ is currently considering another alliance proposal.
else
pm.SendLocalizedMessage( 1063426, m_Other.Name ); // ~1_val~ already belongs to an alliance.
}
else if( alliance.IsPendingMember( guild ) )
{
pm.SendLocalizedMessage( 1063416, guild.Name ); // ~1_val~ is currently considering another alliance proposal.
}
else if( m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0 )
{
pm.SendLocalizedMessage( 1063427, m_Other.Name ); // ~1_val~ is currently involved in a guild war.
}
else if( guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0 )
{
pm.SendLocalizedMessage( 1063427, guild.Name ); // ~1_val~ is currently involved in a guild war.
}
else if( Faction.Find( guild.Leader ) != Faction.Find( m_Other.Leader ) )
{
pm.SendLocalizedMessage( 1070758 ); // You cannot propose an alliance to a guild with a different faction allegiance.
}
else
{
pm.SendLocalizedMessage( 1070750, m_Other.Name ); // An invitation to join your alliance has been sent to ~1_val~.
m_Other.GuildMessage( 1070780, guild.Name ); // ~1_val~ has proposed an alliance.
m_Other.Alliance = alliance; //Calls addPendingGuild
//alliance.AddPendingGuild( m_Other );
}
}
#endregion
break;
}
case 10: //Show Alliance Roster
{
if( alliance != null && alliance == otherAlliance )
pm.SendGump( new AllianceInfo.AllianceRosterGump( pm, guild, alliance ) );
break;
}
case 11: //Leave Alliance
{
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1063436 ); // You don't have permission to negotiate an alliance.
}
else if( alliance != null && alliance.IsMember( guild ) )
{
guild.Alliance = null; //Calls alliance.Removeguild
// alliance.RemoveGuild( guild );
}
break;
}
case 12: //Remove Guild from alliance
{
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1063436 ); // You don't have permission to negotiate an alliance.
}
else if( alliance != null && alliance.Leader != guild )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", guild.Name, alliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
}
else if( alliance != null && alliance.IsMember( guild ) && alliance.IsMember( m_Other ) )
{
m_Other.Alliance = null;
}
break;
}
case 13: //Promote to Alliance leader
{
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1063436 ); // You don't have permission to negotiate an alliance.
}
else if( alliance != null && alliance.Leader != guild )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", guild.Name, alliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
}
else if( alliance != null && alliance.IsMember( guild ) && alliance.IsMember( m_Other ) )
{
pm.SendLocalizedMessage( 1063434, String.Format( "{0}\t{1}", m_Other.Name, alliance.Name ) ); // ~1_val~ is now the leader of ~2_val~.
alliance.Leader = m_Other;
}
break;
}
case 14: //Withdraw Request
{
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1063436 ); // You don't have permission to negotiate an alliance.
}
else if( alliance != null && alliance.Leader == guild && alliance.IsPendingMember( m_Other ) )
{
m_Other.Alliance = null;
pm.SendLocalizedMessage( 1070752 ); // The proposal has been updated.
}
break;
}
case 15: //Deny Alliance Request
{
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1063436 ); // You don't have permission to negotiate an alliance.
}
else if( alliance != null && otherAlliance != null && alliance.Leader == m_Other && otherAlliance.IsPendingMember( guild ) )
{
pm.SendLocalizedMessage( 1070752 ); // The proposal has been updated.
//m_Other.GuildMessage( 1070782 ); // ~1_val~ has responded to your proposal. //Per OSI commented out.
guild.Alliance = null;
}
break;
}
case 16: //Accept Alliance Request
{
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1063436 ); // You don't have permission to negotiate an alliance.
}
else if( otherAlliance != null && otherAlliance.Leader == m_Other && otherAlliance.IsPendingMember( guild ) )
{
pm.SendLocalizedMessage( 1070752 ); // The proposal has been updated.
otherAlliance.TurnToMember( m_Other ); //No need to verify it's in the guild or already a member, the function does this
otherAlliance.TurnToMember( guild );
}
break;
}
}
}
public void CreateAlliance_Callback( Mobile from, string text )
{
PlayerMobile pm = from as PlayerMobile;
AllianceInfo alliance = guild.Alliance;
AllianceInfo otherAlliance = m_Other.Alliance;
if( !IsMember( from, guild ) || alliance != null )
return;
RankDefinition playerRank = pm.GuildRank;
if( !playerRank.GetFlag( RankFlags.AllianceControl ) )
{
pm.SendLocalizedMessage( 1070747 ); // You don't have permission to create an alliance.
}
else if( Faction.Find( guild.Leader ) != Faction.Find( m_Other.Leader ) )
{
//Notes about this: OSI only cares/checks when proposing, you can change your faction all you want later.
pm.SendLocalizedMessage( 1070758 ); // You cannot propose an alliance to a guild with a different faction allegiance.
}
else if( otherAlliance != null )
{
if( otherAlliance.IsPendingMember( m_Other ) )
pm.SendLocalizedMessage( 1063416, m_Other.Name ); // ~1_val~ is currently considering another alliance proposal.
else
pm.SendLocalizedMessage( 1063426, m_Other.Name ); // ~1_val~ already belongs to an alliance.
}
else if( m_Other.AcceptedWars.Count > 0 || m_Other.PendingWars.Count > 0 )
{
pm.SendLocalizedMessage( 1063427, m_Other.Name ); // ~1_val~ is currently involved in a guild war.
}
else if( guild.AcceptedWars.Count > 0 || guild.PendingWars.Count > 0 )
{
pm.SendLocalizedMessage( 1063427, guild.Name ); // ~1_val~ is currently involved in a guild war.
}
else
{
string name = Utility.FixHtml( text.Trim() );
if( !BaseGuildGump.CheckProfanity( name ) )
pm.SendLocalizedMessage( 1070886 ); // That alliance name is not allowed.
else if( name.Length > Guild.NameLimit )
pm.SendLocalizedMessage( 1070887, Guild.NameLimit.ToString() ); // An alliance name cannot exceed ~1_val~ characters in length.
else if( AllianceInfo.Alliances.Contains( name.ToLower() ) )
pm.SendLocalizedMessage( 1063428 ); // That alliance name is not available.
else
{
pm.SendLocalizedMessage( 1070750, m_Other.Name ); // An invitation to join your alliance has been sent to ~1_val~.
m_Other.GuildMessage( 1070780, guild.Name ); // ~1_val~ has proposed an alliance.
new AllianceInfo( guild, name, m_Other );
}
}
}
}
}

View file

@ -0,0 +1,130 @@
using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
namespace Server.Guilds
{
public class WarDeclarationGump : BaseGuildGump
{
private Guild m_Other;
public WarDeclarationGump( PlayerMobile pm, Guild g, Guild otherGuild ) : base( pm, g )
{
m_Other = otherGuild;
WarDeclaration war = g.FindPendingWar( otherGuild );
AddPage( 0 );
AddBackground( 0, 0, 500, 340, 0x24AE );
AddBackground( 65, 50, 370, 30, 0x2486 );
AddHtmlLocalized( 75, 55, 370, 26, 1062979, 0x3C00, false, false ); // <div align=center><i>Declaration of War</i></div>
AddImage( 410, 45, 0x232C );
AddHtmlLocalized( 65, 95, 200, 20, 1063009, 0x14AF, false, false ); // <i>Duration of War</i>
AddHtmlLocalized( 65, 120, 400, 20, 1063010, 0x0, false, false ); // Enter the number of hours the war will last.
AddBackground( 65, 150, 40, 30, 0x2486 );
AddTextEntry( 70, 154, 50, 30, 0x481, 10, (war != null) ? war.WarLength.Hours.ToString() : "0" );
AddHtmlLocalized( 65, 195, 200, 20, 1063011, 0x14AF, false, false ); // <i>Victory Condition</i>
AddHtmlLocalized( 65, 220, 400, 20, 1063012, 0x0, false, false ); // Enter the winning number of kills.
AddBackground( 65, 250, 40, 30, 0x2486 );
AddTextEntry( 70, 254, 50, 30, 0x481, 11, (war != null) ? war.MaxKills.ToString() : "0" );
AddBackground( 190, 270, 130, 26, 0x2486 );
AddButton( 195, 275, 0x845, 0x846, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 220, 273, 90, 26, 1006045, 0x0, false, false ); // Cancel
AddBackground( 330, 270, 130, 26, 0x2486 );
AddButton( 335, 275, 0x845, 0x846, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 360, 273, 90, 26, 1062989, 0x5000, false, false ); // Declare War!
}
public override void OnResponse( NetState sender, RelayInfo info )
{
PlayerMobile pm = sender.Mobile as PlayerMobile;
if( !IsMember( pm, guild ) )
return;
RankDefinition playerRank = pm.GuildRank;
switch( info.ButtonID )
{
case 1:
{
AllianceInfo alliance = guild.Alliance;
AllianceInfo otherAlliance = m_Other.Alliance;
if( !playerRank.GetFlag( RankFlags.ControlWarStatus ) )
{
pm.SendLocalizedMessage( 1063440 ); // You don't have permission to negotiate wars.
}
else if( alliance != null && alliance.Leader != guild )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", guild.Name, alliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
pm.SendLocalizedMessage( 1070707, alliance.Leader.Name ); // You need to negotiate via ~1_val~ instead.
}
else if( otherAlliance != null && otherAlliance.Leader != m_Other )
{
pm.SendLocalizedMessage( 1063239, String.Format( "{0}\t{1}", m_Other.Name, otherAlliance.Name ) ); // ~1_val~ is not the leader of the ~2_val~ alliance.
pm.SendLocalizedMessage( 1070707, otherAlliance.Leader.Name ); // You need to negotiate via ~1_val~ instead.
}
else
{
WarDeclaration activeWar = guild.FindActiveWar( m_Other );
if( activeWar == null )
{
WarDeclaration war = guild.FindPendingWar( m_Other );
WarDeclaration otherWar = m_Other.FindPendingWar( guild );
//Note: OSI differs from what it says on website. unlimited war = 0 kills/ 0 hrs. Not > 999. (sidenote: they both cap at 65535, 7.5 years, but, still.)
TextRelay tKills = info.GetTextEntry( 11 );
TextRelay tWarLength = info.GetTextEntry( 10 );
int maxKills = (tKills == null)? 0 : Math.Max( Math.Min( Utility.ToInt32( info.GetTextEntry( 11 ).Text ), 0xFFFF ), 0 );
TimeSpan warLength = TimeSpan.FromHours( (tWarLength == null) ? 0 : Math.Max( Math.Min( Utility.ToInt32( info.GetTextEntry( 10 ).Text ), 0xFFFF ), 0 ) );
if( war != null )
{
war.MaxKills = maxKills;
war.WarLength = warLength;
war.WarRequester = true;
}
else
{
guild.PendingWars.Add( new WarDeclaration( guild, m_Other, maxKills, warLength, true ) );
}
if( otherWar != null )
{
otherWar.MaxKills = maxKills;
otherWar.WarLength = warLength;
otherWar.WarRequester = false;
}
else
{
m_Other.PendingWars.Add( new WarDeclaration( m_Other, guild, maxKills, warLength, false ) );
}
if( war != null )
{
pm.SendLocalizedMessage( 1070752 ); // The proposal has been updated.
//m_Other.GuildMessage( 1070782 ); // ~1_val~ has responded to your proposal.
}
else
m_Other.GuildMessage( 1070781, ((guild.Alliance != null ) ? guild.Alliance.Name : guild.Name ) ); // ~1_val~ has proposed a war.
pm.SendLocalizedMessage( 1070751, ((m_Other.Alliance != null ) ? m_Other.Alliance.Name : m_Other.Name ) ); // War proposal has been sent to ~1_val~.
}
}
break;
}
default:
{
pm.SendGump( new OtherGuildInfo( pm, guild, m_Other ) );
break;
}
}
}
}
}

View file

@ -0,0 +1,95 @@
using System;
using Server;
using Server.Guilds;
using Server.Targeting;
using Server.Factions;
namespace Server.Gumps
{
public class GuildRecruitTarget : Target
{
private Mobile m_Mobile;
private Guild m_Guild;
public GuildRecruitTarget( Mobile m, Guild guild ) : base( 10, false, TargetFlags.None )
{
m_Mobile = m;
m_Guild = guild;
}
protected override void OnTarget( Mobile from, object targeted )
{
if ( GuildGump.BadMember( m_Mobile, m_Guild ) )
return;
if ( targeted is Mobile )
{
Mobile m = (Mobile)targeted;
PlayerState guildState = PlayerState.Find( m_Guild.Leader );
PlayerState targetState = PlayerState.Find( m );
Faction guildFaction = ( guildState == null ? null : guildState.Faction );
Faction targetFaction = ( targetState == null ? null : targetState.Faction );
if ( !m.Player )
{
m_Mobile.SendLocalizedMessage( 501161 ); // You may only recruit players into the guild.
}
else if ( !m.Alive )
{
m_Mobile.SendLocalizedMessage( 501162 ); // Only the living may be recruited.
}
else if ( m_Guild.IsMember( m ) )
{
m_Mobile.SendLocalizedMessage( 501163 ); // They are already a guildmember!
}
else if ( m_Guild.Candidates.Contains( m ) )
{
m_Mobile.SendLocalizedMessage( 501164 ); // They are already a candidate.
}
else if ( m_Guild.Accepted.Contains( m ) )
{
m_Mobile.SendLocalizedMessage( 501165 ); // They have already been accepted for membership, and merely need to use the Guildstone to gain full membership.
}
else if ( m.Guild != null )
{
m_Mobile.SendLocalizedMessage( 501166 ); // You can only recruit candidates who are not already in a guild.
}
#region Factions
else if ( guildFaction != targetFaction )
{
if ( guildFaction == null )
m_Mobile.SendLocalizedMessage( 1013027 ); // That player cannot join a non-faction guild.
else if ( targetFaction == null )
m_Mobile.SendLocalizedMessage( 1013026 ); // That player must be in a faction before joining this guild.
else
m_Mobile.SendLocalizedMessage( 1013028 ); // That person has a different faction affiliation.
}
else if ( targetState != null && targetState.IsLeaving )
{
// OSI does this quite strangely, so we'll just do it this way
m_Mobile.SendMessage( "That person is quitting their faction and so you may not recruit them." );
}
#endregion
else if ( m_Mobile.AccessLevel >= AccessLevel.GameMaster || m_Guild.Leader == m_Mobile )
{
m_Guild.Accepted.Add( m );
}
else
{
m_Guild.Candidates.Add( m );
}
}
}
protected override void OnTargetFinish( Mobile from )
{
if ( GuildGump.BadMember( m_Mobile, m_Guild ) )
return;
GuildGump.EnsureClosed( m_Mobile );
m_Mobile.SendGump( new GuildGump( m_Mobile, m_Guild ) );
}
}
}

View file

@ -0,0 +1,138 @@
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 bank box.
* 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;
}
Item toGive = null;
if ( m_House.IsAosRules )
{
if ( m_House.Price > 0 )
toGive = new BankCheck( m_House.Price );
else
toGive = m_House.GetDeed();
}
else
{
toGive = m_House.GetDeed();
if ( toGive == null && m_House.Price > 0 )
toGive = new BankCheck( m_House.Price );
}
if ( toGive != null )
{
BankBox box = m_Mobile.BankBox;
if ( box != null && box.TryDropItem( m_Mobile, toGive, false ) )
{
if ( toGive is BankCheck )
m_Mobile.SendLocalizedMessage( 1060397, ((BankCheck)toGive).Worth.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box.
m_House.RemoveKeys( m_Mobile );
m_House.Delete();
}
else
{
toGive.Delete();
m_Mobile.SendLocalizedMessage( 500390 ); // Your bank box 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 bank 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 bank 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,69 @@
using System;
using Server;
using Server.Mobiles;
using Server.Network;
using Server.Gumps;
namespace Server.Gumps
{
public class PetResurrectGump : Gump
{
private BaseCreature m_Pet;
public PetResurrectGump( Mobile from, BaseCreature pet ) : base( 50, 50 )
{
from.CloseGump( typeof( PetResurrectGump ) );
m_Pet = pet;
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;
}
}
}
}

View file

@ -0,0 +1,960 @@
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 ( vi.Description != null && 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 )
{
if ( !m_VI.Valid )
{
m_Vendor.SayTo( from, 503216 ); // You can't buy that.
return;
}
int totalGold = 0;
if ( from.Backpack != null )
totalGold += from.Backpack.GetAmount( typeof( Gold ) );
if ( from.BankBox != null )
totalGold += from.BankBox.GetAmount( typeof( Gold ) );
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 && from.BankBox != null )
from.BankBox.ConsumeUpTo( typeof( Gold ), 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:
{
if ( (info.ButtonID & 0x100) != 0 ) // Hair style selected
{
int index = info.ButtonID & 0xFF;
if ( index >= m_HairStyles.Length )
return;
HairOrBeard hairStyle = m_HairStyles[index];
m_Vendor.HairItemID = hairStyle.ItemID;
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];
m_Vendor.FacialHairItemID = beardStyle.ItemID;
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,249 @@
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( 8401, 0xD0, 1015236, 15, 10 );
public static readonly PolymorphEntry Dog = new PolymorphEntry( 8405, 0xD9, 1015237, 17, 10 );
public static readonly PolymorphEntry Wolf = new PolymorphEntry( 8426, 0xE1, 1015238, 18, 10 );
public static readonly PolymorphEntry Panther = new PolymorphEntry( 8473, 0xD6, 1015239, 20, 14 );
public static readonly PolymorphEntry Gorilla = new PolymorphEntry( 8437, 0x1D, 1015240, 23, 10 );
public static readonly PolymorphEntry BlackBear = new PolymorphEntry( 8399, 0xD3, 1015241, 22, 10 );
public static readonly PolymorphEntry GrizzlyBear = new PolymorphEntry( 8411, 0xD4, 1015242, 22, 12 );
public static readonly PolymorphEntry PolarBear = new PolymorphEntry( 8417, 0xD5, 1015243, 26, 10 );
public static readonly PolymorphEntry HumanMale = new PolymorphEntry( 8397, 0x190, 1015244, 29, 8 );
public static readonly PolymorphEntry HumanFemale = new PolymorphEntry( 8398, 0x191, 1015254, 29, 10 );
public static readonly PolymorphEntry Slime = new PolymorphEntry( 8424, 0x33, 1015246, 5, 10 );
public static readonly PolymorphEntry Orc = new PolymorphEntry( 8416, 0x11, 1015247, 29, 10 );
public static readonly PolymorphEntry LizardMan = new PolymorphEntry( 8414, 0x21, 1015248, 26, 10 );
public static readonly PolymorphEntry Gargoyle = new PolymorphEntry( 8409, 0x04, 1015249, 22, 10 );
public static readonly PolymorphEntry Ogre = new PolymorphEntry( 8415, 0x01, 1015250, 24, 9 );
public static readonly PolymorphEntry Troll = new PolymorphEntry( 8425, 0x36, 1015251, 25, 9 );
public static readonly PolymorphEntry Ettin = new PolymorphEntry( 8408, 0x02, 1015252, 25, 8 );
public static readonly PolymorphEntry Daemon = new PolymorphEntry( 8403, 0x09, 1015253, 25, 8 );
private int m_Art, m_Body, m_Num, m_X, m_Y;
private PolymorphEntry( int Art, int Body, int LocNum, int X, int Y )
{
m_Art = Art;
m_Body = Body;
m_Num = LocNum;
m_X = X;
m_Y = Y;
}
public int ArtID { get { return m_Art; } }
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 );
AddItem( x+20, y+25, entry.ArtID );
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;
AddImageTiledButton( x, y, 0x918, 0x919, i + 1, GumpButtonType.Reply, 0, entry.ArtID, 0x0, entry.X, entry.Y );
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,758 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
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 )
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 ( !Server.Commands.Generic.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 )
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 o = prop.GetValue( m_Object, null );
if( o != null )
from.SendGump( new PropertiesGump( from, o, m_Stack, new StackEntry( m_Object, prop ) ) );
}
}
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.Value );
}
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.Value );
}
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,292 @@
using System;
using System.Reflection;
using System.Collections;
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();
ArrayList 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,307 @@
using System;
using System.Reflection;
using System.Collections;
using Server;
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 ( !Server.Commands.Generic.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,239 @@
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,169 @@
using System;
using System.Collections;
using Server;
using Server.Misc;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
namespace Server.Gumps
{
public class ReportMurdererGump : Gump
{
private int m_Idx;
private ArrayList 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;
ArrayList killers = new ArrayList();
ArrayList toGive = new ArrayList();
foreach ( AggressorInfo ai in m.Aggressors )
{
if ( ai.Attacker.Player && ai.CanReportMurder && !ai.Reported )
{
killers.Add( ai.Attacker );
ai.Reported = true;
}
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 ArrayList m_Killers;
public GumpTimer( Mobile victim, ArrayList 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, ArrayList killers ) : this( victum, killers, 0 )
{
}
private ReportMurdererGump( Mobile victum, ArrayList 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 override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
switch ( info.ButtonID )
{
case 1:
{
Mobile killer = (Mobile)m_Killers[m_Idx];
if ( killer != null && !killer.Deleted )
{
killer.Kills++;
killer.ShortTermMurders++;
if ( killer is PlayerMobile )
((PlayerMobile)killer).ResetKillTime();
killer.SendLocalizedMessage( 1049067 );//You have been reported for murder!
if ( killer.Kills == 5 )
killer.SendLocalizedMessage( 502134 );//You are now known as a murderer!
else if ( SkillHandlers.Stealing.SuspendOnMurder && killer.Kills == 1 && killer is PlayerMobile && ((PlayerMobile)killer).NpcGuild == NpcGuild.ThievesGuild )
killer.SendLocalizedMessage( 501562 ); // You have been suspended by the Thieves Guild.
}
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,225 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Server;
using Server.Items;
using Server.Gumps;
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 bool m_FromSacrifice;
public ResurrectGump( Mobile owner ) : this( owner, owner, ResurrectMessage.Generic, false )
{
}
public ResurrectGump( Mobile owner, bool fromSacrifice ) : this( owner, owner, ResurrectMessage.Generic, fromSacrifice )
{
}
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, bool fromSacrifice ) : base( 100, 0 )
{
m_Healer = healer;
m_FromSacrifice = fromSacrifice;
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 bank?
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;
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 ( Banker.Withdraw( from, m_Price ) )
{
from.SendLocalizedMessage( 1060398, m_Price.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
from.SendLocalizedMessage( 1060022, Banker.GetBalance( from ).ToString() ); // You have ~1_AMOUNT~ gold in cash remaining in your bank box.
}
else
{
from.SendLocalizedMessage( 1060020 ); // Unfortunately, you do not have enough cash in your bank 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 ( m_Healer != null && from != m_Healer )
{
VirtueLevel level = VirtueHelper.GetLevel( m_Healer, VirtueName.Compassion );
switch ( level )
{
case VirtueLevel.Seeker: from.Hits = AOS.Scale( from.HitsMax, 20 ); break;
case VirtueLevel.Follower: from.Hits = AOS.Scale( from.HitsMax, 40 ); break;
case VirtueLevel.Knight: from.Hits = AOS.Scale( from.HitsMax, 80 ); break;
}
}
if ( m_FromSacrifice && !from.Criminal && from is PlayerMobile )
{
((PlayerMobile)from).AvailableResurrects -= 1;
Container pack = from.Backpack;
Container corpse = from.Corpse;
if ( pack != null && corpse != null )
{
List<Item> items = new List<Item>( corpse.Items );
for ( int i = 0; i < items.Count; ++i )
{
Item item = items[i];
if ( item.Layer != Layer.Hair && item.Layer != Layer.FacialHair && item.Movable )
pack.DropItem( item );
}
}
}
if ( from.Fame > 0 )
{
int amount = from.Fame / 10;
Misc.Titles.AwardFame( from, -amount, true );
}
if ( !Core.AOS && from.ShortTermMurders >= 5 )
{
double loss = (100.0 - ( 4.0 + (from.ShortTermMurders / 5.0))) / 100.0; // 5 to 15% loss
if ( loss < 0.85 )
loss = 0.85;
else if ( loss > 0.95 )
loss = 0.95;
if ( from.RawStr * loss > 10 )
from.RawStr = (int)(from.RawStr * loss);
if ( from.RawInt * loss > 10 )
from.RawInt = (int)(from.RawInt * loss);
if ( from.RawDex * loss > 10 )
from.RawDex = (int)(from.RawDex * loss);
for ( int s = 0; s < from.Skills.Length; s++ )
{
if ( from.Skills[s].Base * loss > 35 )
from.Skills[s].Base *= loss;
}
}
}
}
}
}

View file

@ -0,0 +1,433 @@
using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Network;
using Server.Spells;
using Server.Spells.Fourth;
using Server.Spells.Seventh;
using Server.Spells.Chivalry;
using Server.Prompts;
namespace Server.Gumps
{
public class RunebookGump : Gump
{
private Runebook m_Book;
public Runebook Book{ get{ return m_Book; } }
public int GetMapHue( Map map )
{
if ( map == Map.Trammel )
return 10;
else if ( map == Map.Felucca )
return 81;
else if ( map == Map.Ilshenar )
return 1102;
else if ( map == Map.Malas )
return 1102;
else if ( map == Map.Tokuno )
return 1154;
return 0;
}
public string GetName( string name )
{
if ( name == null || (name = name.Trim()).Length <= 0 )
return "(indescript)";
return name;
}
private void AddBackground()
{
AddPage( 0 );
// Background image
AddImage( 100, 10, 2200 );
// Two seperators
for ( int i = 0; i < 2; ++i )
{
int xOffset = 125 + (i * 165);
AddImage( xOffset, 50, 57 );
xOffset += 20;
for ( int j = 0; j < 6; ++j, xOffset += 15 )
AddImage( xOffset, 50, 58 );
AddImage( xOffset - 5, 50, 59 );
}
// First four page buttons
for ( int i = 0, xOffset = 130, gumpID = 2225; i < 4; ++i, xOffset += 35, ++gumpID )
AddButton( xOffset, 187, gumpID, gumpID, 0, GumpButtonType.Page, 2 + i );
// Next four page buttons
for ( int i = 0, xOffset = 300, gumpID = 2229; i < 4; ++i, xOffset += 35, ++gumpID )
AddButton( xOffset, 187, gumpID, gumpID, 0, GumpButtonType.Page, 6 + i );
// Charges
AddHtmlLocalized( 140, 40, 80, 18, 1011296, false, false ); // Charges:
AddHtml( 220, 40, 30, 18, m_Book.CurCharges.ToString(), false, false );
// Max charges
AddHtmlLocalized( 300, 40, 100, 18, 1011297, false, false ); // Max Charges:
AddHtml( 400, 40, 30, 18, m_Book.MaxCharges.ToString(), false, false );
}
private void AddIndex()
{
// Index
AddPage( 1 );
// Rename button
AddButton( 125, 15, 2472, 2473, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 158, 22, 100, 18, 1011299, false, false ); // Rename book
// List of entries
ArrayList entries = m_Book.Entries;
for ( int i = 0; i < 16; ++i )
{
string desc;
int hue;
if ( i < entries.Count )
{
desc = GetName( ((RunebookEntry)entries[i]).Description );
hue = GetMapHue( ((RunebookEntry)entries[i]).Map );
}
else
{
desc = "Empty";
hue = 0;
}
// Use charge button
AddButton( 130 + ((i / 8) * 160), 65 + ((i % 8) * 15), 2103, 2104, 2 + (i * 6) + 0, GumpButtonType.Reply, 0 );
// Description label
AddLabelCropped( 145 + ((i / 8) * 160), 60 + ((i % 8) * 15), 115, 17, hue, desc );
}
// Turn page button
AddButton( 393, 14, 2206, 2206, 0, GumpButtonType.Page, 2 );
}
private void AddDetails( int index, int half )
{
// Use charge button
AddButton( 130 + (half * 160), 65, 2103, 2104, 2 + (index * 6) + 0, GumpButtonType.Reply, 0 );
string desc;
int hue;
if ( index < m_Book.Entries.Count )
{
RunebookEntry e = (RunebookEntry)m_Book.Entries[index];
desc = GetName( e.Description );
hue = GetMapHue( e.Map );
// Location labels
int xLong = 0, yLat = 0;
int xMins = 0, yMins = 0;
bool xEast = false, ySouth = false;
if ( Sextant.Format( e.Location, e.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth ) )
{
AddLabel( 135 + (half * 160), 80, 0, String.Format( "{0}° {1}'{2}", yLat, yMins, ySouth ? "S" : "N" ) );
AddLabel( 135 + (half * 160), 95, 0, String.Format( "{0}° {1}'{2}", xLong, xMins, xEast ? "E" : "W" ) );
}
// Drop rune button
AddButton( 135 + (half * 160), 115, 2437, 2438, 2 + (index * 6) + 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 150 + (half * 160), 115, 100, 18, 1011298, false, false ); // Drop rune
if ( e != m_Book.Default )
{
// Set as default button
AddButton( 160 + (half * 140), 20, 2361, 2361, 2 + (index * 6) + 2, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 175 + (half * 140), 15, 100, 18, 1011300, false, false ); // Set default
}
if ( Core.AOS )
{
AddButton( 135 + (half * 160), 140, 2103, 2104, 2 + (index * 6) + 3, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 150 + (half * 160), 136, 110, 20, 1062722, false, false ); // Recall
AddButton( 135 + (half * 160), 158, 2103, 2104, 2 + (index * 6) + 4, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 150 + (half * 160), 154, 110, 20, 1062723, false, false ); // Gate Travel
AddButton( 135 + (half * 160), 176, 2103, 2104, 2 + (index * 6) + 5, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 150 + (half * 160), 172, 110, 20, 1062724, false, false ); // Sacred Journey
}
else
{
// Recall button
AddButton( 135 + (half * 160), 140, 2271, 2271, 2 + (index * 6) + 3, GumpButtonType.Reply, 0 );
// Gate button
AddButton( 205 + (half * 160), 140, 2291, 2291, 2 + (index * 6) + 4, GumpButtonType.Reply, 0 );
}
}
else
{
desc = "Empty";
hue = 0;
}
// Description label
AddLabelCropped( 145 + (half * 160), 60, 115, 17, hue, desc );
}
public RunebookGump( Mobile from, Runebook book ) : base( 150, 200 )
{
m_Book = book;
AddBackground();
AddIndex();
for ( int page = 0; page < 8; ++page )
{
AddPage( 2 + page );
AddButton( 125, 14, 2205, 2205, 0, GumpButtonType.Page, 1 + page );
if ( page < 7 )
AddButton( 393, 14, 2206, 2206, 0, GumpButtonType.Page, 3 + page );
for ( int half = 0; half < 2; ++half )
AddDetails( (page * 2) + half, half );
}
}
public static bool HasSpell( Mobile from, int spellID )
{
Spellbook book = Spellbook.Find( from, spellID );
return ( book != null && book.HasSpell( spellID ) );
}
private class InternalPrompt : Prompt
{
private Runebook m_Book;
public InternalPrompt( Runebook book )
{
m_Book = book;
}
public override void OnResponse( Mobile from, string text )
{
if ( m_Book.Deleted || !from.InRange( m_Book.GetWorldLocation(), 1 ) )
return;
if ( m_Book.CheckAccess( from ) )
{
m_Book.Description = Utility.FixHtml( text.Trim() );
from.CloseGump( typeof( RunebookGump ) );
from.SendGump( new RunebookGump( from, m_Book ) );
from.SendMessage( "The book's title has been changed." );
}
else
{
from.SendLocalizedMessage( 502416 ); // That cannot be done while the book is locked down.
}
}
public override void OnCancel( Mobile from )
{
from.SendLocalizedMessage( 502415 ); // Request cancelled.
if ( !m_Book.Deleted && from.InRange( m_Book.GetWorldLocation(), 1 ) )
{
from.CloseGump( typeof( RunebookGump ) );
from.SendGump( new RunebookGump( from, m_Book ) );
}
}
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile from = state.Mobile;
if ( m_Book.Deleted || !from.InRange( m_Book.GetWorldLocation(), 1 ) || !Multis.DesignContext.Check( from ) )
return;
int buttonID = info.ButtonID;
if ( buttonID == 1 ) // Rename book
{
if ( m_Book.CheckAccess( from ) )
{
from.SendLocalizedMessage( 502414 ); // Please enter a title for the runebook:
from.Prompt = new InternalPrompt( m_Book );
}
else
{
from.SendLocalizedMessage( 502413 ); // That cannot be done while the book is locked down.
}
}
else
{
buttonID -= 2;
int index = buttonID / 6;
int type = buttonID % 6;
if ( index >= 0 && index < m_Book.Entries.Count )
{
RunebookEntry e = (RunebookEntry)m_Book.Entries[index];
switch ( type )
{
case 0: // Use charges
{
if ( m_Book.CurCharges <= 0 )
{
from.CloseGump( typeof( RunebookGump ) );
from.SendGump( new RunebookGump( from, m_Book ) );
from.SendLocalizedMessage( 502412 ); // There are no charges left on that item.
}
else
{
int xLong = 0, yLat = 0;
int xMins = 0, yMins = 0;
bool xEast = false, ySouth = false;
if ( Sextant.Format( e.Location, e.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth ) )
{
string location = String.Format( "{0}° {1}'{2}, {3}° {4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W" );
from.SendMessage( location );
}
m_Book.OnTravel();
new RecallSpell( from, m_Book, e, m_Book ).Cast();
}
break;
}
case 1: // Drop rune
{
if ( m_Book.CheckAccess( from ) )
{
m_Book.DropRune( from, e, index );
from.CloseGump( typeof( RunebookGump ) );
from.SendGump( new RunebookGump( from, m_Book ) );
}
else
{
from.SendLocalizedMessage( 502413 ); // That cannot be done while the book is locked down.
}
break;
}
case 2: // Set default
{
if ( m_Book.CheckAccess( from ) )
{
m_Book.Default = e;
from.CloseGump( typeof( RunebookGump ) );
from.SendGump( new RunebookGump( from, m_Book ) );
from.SendLocalizedMessage( 502417 ); // New default location set.
}
else
{
from.SendLocalizedMessage( 502413 ); // That cannot be done while the book is locked down.
}
break;
}
case 3: // Recall
{
if ( HasSpell( from, 31 ) )
{
int xLong = 0, yLat = 0;
int xMins = 0, yMins = 0;
bool xEast = false, ySouth = false;
if ( Sextant.Format( e.Location, e.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth ) )
{
string location = String.Format( "{0}° {1}'{2}, {3}° {4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W" );
from.SendMessage( location );
}
m_Book.OnTravel();
new RecallSpell( from, null, e, null ).Cast();
}
else
{
from.SendLocalizedMessage( 500015 ); // You do not have that spell!
}
break;
}
case 4: // Gate
{
if ( HasSpell( from, 51 ) )
{
int xLong = 0, yLat = 0;
int xMins = 0, yMins = 0;
bool xEast = false, ySouth = false;
if ( Sextant.Format( e.Location, e.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth ) )
{
string location = String.Format( "{0}° {1}'{2}, {3}° {4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W" );
from.SendMessage( location );
}
m_Book.OnTravel();
new GateTravelSpell( from, null, e ).Cast();
}
else
{
from.SendLocalizedMessage( 500015 ); // You do not have that spell!
}
break;
}
case 5: // Sacred Journey
{
if ( Core.AOS )
{
if ( HasSpell( from, 209 ) )
{
int xLong = 0, yLat = 0;
int xMins = 0, yMins = 0;
bool xEast = false, ySouth = false;
if ( Sextant.Format( e.Location, e.Map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth ) )
{
string location = String.Format( "{0}° {1}'{2}, {3}° {4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W" );
from.SendMessage( location );
}
m_Book.OnTravel();
new SacredJourneySpell( from, null, e, null ).Cast();
}
else
{
from.SendLocalizedMessage( 500015 ); // You do not have that spell!
}
}
break;
}
}
}
}
}
}
}

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.
}
}
}
}

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

@ -0,0 +1,546 @@
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( "Crafting", new SkillName[]
{
SkillName.Alchemy,
SkillName.Blacksmith,
SkillName.Cartography,
SkillName.Carpentry,
SkillName.Cooking,
SkillName.Fletching,
SkillName.Inscribe,
SkillName.Tailoring,
SkillName.Tinkering
} ),
new SkillsGumpGroup( "Bardic", new SkillName[]
{
SkillName.Discordance,
SkillName.Musicianship,
SkillName.Peacemaking,
SkillName.Provocation
} ),
new SkillsGumpGroup( "Magical", new SkillName[]
{
SkillName.Chivalry,
SkillName.EvalInt,
SkillName.Magery,
SkillName.MagicResist,
SkillName.Meditation,
SkillName.Necromancy,
SkillName.SpiritSpeak,
SkillName.Ninjitsu,
SkillName.Bushido
} ),
new SkillsGumpGroup( "Miscellaneous", new SkillName[]
{
SkillName.Camping,
SkillName.Fishing,
SkillName.Focus,
SkillName.Healing,
SkillName.Herding,
SkillName.Lockpicking,
SkillName.Lumberjacking,
SkillName.Mining,
SkillName.Snooping,
SkillName.Veterinary
} ),
new SkillsGumpGroup( "Combat Ratings", new SkillName[]
{
SkillName.Archery,
SkillName.Fencing,
SkillName.Macing,
SkillName.Parry,
SkillName.Swords,
SkillName.Tactics,
SkillName.Wrestling
} ),
new SkillsGumpGroup( "Actions", new SkillName[]
{
SkillName.AnimalTaming,
SkillName.Begging,
SkillName.DetectHidden,
SkillName.Hiding,
SkillName.RemoveTrap,
SkillName.Poisoning,
SkillName.Stealing,
SkillName.Stealth,
SkillName.Tracking
} ),
new SkillsGumpGroup( "Lore & Knowledge", new SkillName[]
{
SkillName.Anatomy,
SkillName.AnimalLore,
SkillName.ArmsLore,
SkillName.Forensics,
SkillName.ItemID,
SkillName.TasteID
} )
};
public static SkillsGumpGroup[] Groups
{
get{ return m_Groups; }
}
}
}

View file

@ -0,0 +1,125 @@
using System;
using Server;
using Server.Items;
using Server.Network;
namespace Server.Gumps
{
public class TithingGump : Gump
{
private Mobile m_From;
private int m_Offer;
public TithingGump( Mobile from, int offer ) : base( 160, 40 )
{
int totalGold = from.TotalGold;
if ( offer > totalGold )
offer = totalGold;
else if ( offer < 0 )
offer = 0;
m_From = from;
m_Offer = offer;
AddPage( 0 );
AddImage( 30, 30, 102 );
AddHtmlLocalized( 95, 100, 120, 100, 1060198, 0, false, false ); // May your wealth bring blessings to those in need, if tithed upon this most sacred site.
AddLabel( 57, 274, 0, "Gold:" );
AddLabel( 87, 274, 53, (totalGold - offer).ToString() );
AddLabel( 137, 274, 0, "Tithe:" );
AddLabel( 172, 274, 53, offer.ToString() );
AddButton( 105, 230, 5220, 5220, 2, GumpButtonType.Reply, 0 );
AddButton( 113, 230, 5222, 5222, 2, GumpButtonType.Reply, 0 );
AddLabel( 108, 228, 0, "<" );
AddLabel( 112, 228, 0, "<" );
AddButton( 127, 230, 5223, 5223, 1, GumpButtonType.Reply, 0 );
AddLabel( 131, 228, 0, "<" );
AddButton( 147, 230, 5224, 5224, 3, GumpButtonType.Reply, 0 );
AddLabel( 153, 228, 0, ">" );
AddButton( 168, 230, 5220, 5220, 4, GumpButtonType.Reply, 0 );
AddButton( 176, 230, 5222, 5222, 4, GumpButtonType.Reply, 0 );
AddLabel( 172, 228, 0, ">" );
AddLabel( 176, 228, 0, ">" );
AddButton( 217, 272, 4023, 4024, 5, GumpButtonType.Reply, 0 );
}
public override void OnResponse( NetState sender, RelayInfo info )
{
switch ( info.ButtonID )
{
case 0:
{
// You have decided to tithe no gold to the shrine.
m_From.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1060193 );
break;
}
case 1:
case 2:
case 3:
case 4:
{
int offer = 0;
switch ( info.ButtonID )
{
case 1: offer = m_Offer - 100; break;
case 2: offer = 0; break;
case 3: offer = m_Offer + 100; break;
case 4: offer = m_From.TotalGold; break;
}
m_From.SendGump( new TithingGump( m_From, offer ) );
break;
}
case 5:
{
int totalGold = m_From.TotalGold;
if ( m_Offer > totalGold )
m_Offer = totalGold;
else if ( m_Offer < 0 )
m_Offer = 0;
if ( (m_From.TithingPoints + m_Offer) > 100000 ) // TODO: What's the maximum?
m_Offer = (100000 - m_From.TithingPoints);
if ( m_Offer <= 0 )
{
// You have decided to tithe no gold to the shrine.
m_From.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1060193 );
break;
}
Container pack = m_From.Backpack;
if ( pack != null && pack.ConsumeTotal( typeof( Gold ), m_Offer ) )
{
// You tithe gold to the shrine as a sign of devotion.
m_From.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1060195 );
m_From.TithingPoints += m_Offer;
m_From.PlaySound( 0x243 );
m_From.PlaySound( 0x2E6 );
}
else
{
// You do not have enough gold to tithe that amount!
m_From.LocalOverheadMessage( MessageType.Regular, 0x3B2, 1060194 );
}
break;
}
}
}
}
}

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 givenToBankBox = 0;
for ( int i = inventory.Items.Count - 1; i >= 0; i-- )
{
Item 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.BankBox != null && from.BankBox.TryDropItem( from, item, false ) )
{
inventory.Items.RemoveAt( i );
givenToBankBox += 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 = Banker.DepositUpTo( from, inventory.Gold );
inventory.Gold -= givenGold;
from.SendLocalizedMessage( 1060397, givenGold.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box.
from.SendLocalizedMessage( 1062437, givenToBackpack.ToString() + "\t" + givenToBankBox.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 bank box.
if ( inventory.Gold > 0 || inventory.Items.Count > 0 )
{
from.SendLocalizedMessage( 1062440 ); // Some of the shop inventory would not fit in your backpack or bank box. 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,628 @@
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;
try
{
price = Convert.ToInt32( text );
}
catch
{
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.SendMessage( "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 ( Banker.Withdraw( from, price ) )
{
from.SendLocalizedMessage( 1060398, price.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
int depositedGold = Banker.DepositUpTo( m_Landlord, price );
goldToGive = price - depositedGold;
if ( depositedGold > 0 )
m_Landlord.SendLocalizedMessage( 1060397, price.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box.
if ( goldToGive > 0 )
m_Landlord.SendLocalizedMessage( 500390 ); // Your bank box is full.
}
else
{
from.SendLocalizedMessage( 1062378 ); // You do not have enough gold in your bank account 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;
try
{
price = Convert.ToInt32( text );
}
catch
{
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 ( Banker.Withdraw( m_Landlord, m_RefundAmount ) )
{
m_Landlord.SendLocalizedMessage( 1060398, m_RefundAmount.ToString() ); // ~1_AMOUNT~ gold has been withdrawn from your bank box.
int depositedGold = Banker.DepositUpTo( from, m_RefundAmount );
if ( depositedGold > 0 )
from.SendLocalizedMessage( 1060397, depositedGold.ToString() ); // ~1_AMOUNT~ gold has been deposited into your bank box.
m_Vendor.HoldGold += m_RefundAmount - depositedGold;
m_Vendor.Destroy( false );
from.SendMessage( "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 bank account.
}
}
else
{
m_Landlord.SendLocalizedMessage( 1062513 ); // The renter declined your offer.
}
}
}
}

View file

@ -0,0 +1,302 @@
using System;
using System.Collections;
using Server;
using Server.Items;
using Server.Multis;
using Server.Targeting;
using Server.Accounting;
using Server.Commands;
namespace Server.Gumps
{
public class ViewHousesGump : Gump
{
public static void Initialize()
{
CommandSystem.Register( "ViewHouses", AccessLevel.GameMaster, new CommandEventHandler( ViewHouses_OnCommand ) );
}
[Usage( "ViewHouses" )]
[Description( "Displays a menu listing all houses of a targeted player. The menu also contains specific house details, and options to: go to house, open house menu, and demolish house." )]
public static void ViewHouses_OnCommand( CommandEventArgs e )
{
e.Mobile.BeginTarget( -1, false, TargetFlags.None, new TargetCallback( ViewHouses_OnTarget ) );
}
public static void ViewHouses_OnTarget( Mobile from, object targeted )
{
if ( targeted is Mobile )
from.SendGump( new ViewHousesGump( from, GetHouses( (Mobile)targeted ), null ) );
}
private class HouseComparer : IComparer
{
public static readonly IComparer Instance = new HouseComparer();
public int Compare( object x, object y )
{
return ((BaseHouse)x).BuiltOn.CompareTo( ((BaseHouse)y).BuiltOn );
}
}
public static ArrayList GetHouses( Mobile owner )
{
ArrayList list = new ArrayList();
Account acct = owner.Account as Account;
if ( acct == null )
{
list.AddRange( BaseHouse.GetHouses( owner ) );
}
else
{
for ( int i = 0; i < acct.Length; ++i )
{
Mobile mob = acct[i];
if ( mob != null )
list.AddRange( BaseHouse.GetHouses( mob ) );
}
}
list.Sort( HouseComparer.Instance );
return list;
}
private Mobile m_From;
private ArrayList m_List;
private BaseHouse m_Selection;
public ViewHousesGump( Mobile from, ArrayList list, BaseHouse sel ) : base( 50, 40 )
{
m_From = from;
m_List = list;
m_Selection = sel;
from.CloseGump( typeof( ViewHousesGump ) );
AddPage( 0 );
AddBackground( 0, 0, 240, 360, 5054 );
AddBlackAlpha( 10, 10, 220, 340 );
if ( sel == null || sel.Deleted )
{
m_Selection = null;
AddHtml( 35, 15, 120, 20, Color( "House Type", White ), false, false );
if ( list.Count == 0 )
AddHtml( 35, 40, 160, 40, Color( "There were no houses found for that player.", White ), false, false );
AddImage( 190, 17, 0x25EA );
AddImage( 207, 17, 0x25E6 );
int page = 0;
for ( int i = 0; i < list.Count; ++i )
{
if ( (i % 15) == 0 )
{
if ( page > 0 )
AddButton( 207, 17, 0x15E1, 0x15E5, 0, GumpButtonType.Page, page+1 );
AddPage( ++page );
if ( page > 1 )
AddButton( 190, 17, 0x15E3, 0x15E7, 0, GumpButtonType.Page, page-1 );
}
object name = FindHouseName( (BaseHouse)list[i] );
AddHtml( 15, 40 + ((i % 15) * 20), 20, 20, Color( String.Format( "{0}.", i+1 ), White ), false, false );
if ( name is int )
AddHtmlLocalized( 35, 40 + ((i % 15) * 20), 160, 20, (int)name, White16, false, false );
else if ( name is string )
AddHtml( 35, 40 + ((i % 15) * 20), 160, 20, Color( (string)name, White ), false, false );
AddButton( 198, 39 + ((i % 15) * 20), 4005, 4007, i+1, GumpButtonType.Reply, 0 );
}
}
else
{
string houseName, owner, location;
Map map = sel.Map;
houseName = (sel.Sign == null) ? "An Unnamed House" : sel.Sign.GetName();
owner = (sel.Owner == null) ? "nobody" : sel.Owner.Name;
int xLong = 0, yLat = 0, xMins = 0, yMins = 0;
bool xEast = false, ySouth = false;
bool valid = Sextant.Format( sel.Location, map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth );
if ( valid )
location = String.Format( "{0}° {1}'{2}, {3}° {4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W" );
else
location = "unknown";
AddHtml( 10, 15, 220, 20, Color( Center( "House Properties" ), White ), false, false );
AddHtml( 15, 40, 210, 20, Color( "Facet:", White ), false, false );
AddHtml( 15, 40, 210, 20, Color( Right( map == null ? "(null)" : map.Name ), White ), false, false );
AddHtml( 15, 60, 210, 20, Color( "Location:", White ), false, false );
AddHtml( 15, 60, 210, 20, Color( Right( sel.Location.ToString() ), White ), false, false );
AddHtml( 15, 80, 210, 20, Color( "Sextant:", White ), false, false );
AddHtml( 15, 80, 210, 20, Color( Right( location ), White ), false, false );
AddHtml( 15, 100, 210, 20, Color( "Owner:", White ), false, false );
AddHtml( 15, 100, 210, 20, Color( Right( owner ), White ), false, false );
AddHtml( 15, 120, 210, 20, Color( "Name:", White ), false, false );
AddHtml( 15, 120, 210, 20, Color( Right( houseName ), White ), false, false );
AddHtml( 15, 140, 210, 20, Color( "Friends:", White ), false, false );
AddHtml( 15, 140, 210, 20, Color( Right( sel.Friends.Count.ToString() ), White ), false, false );
AddHtml( 15, 160, 210, 20, Color( "Co-Owners:", White ), false, false );
AddHtml( 15, 160, 210, 20, Color( Right( sel.CoOwners.Count.ToString() ), White ), false, false );
AddHtml( 15, 180, 210, 20, Color( "Bans:", White ), false, false );
AddHtml( 15, 180, 210, 20, Color( Right( sel.Bans.Count.ToString() ), White ), false, false );
AddHtml( 15, 200, 210, 20, Color( "Decays:", White ), false, false );
AddHtml( 15, 200, 210, 20, Color( Right( sel.CanDecay ? "Yes" : "No" ), White ), false, false );
AddHtml( 15, 220, 210, 20, Color( "Decay Level:", White ), false, false );
AddHtml( 15, 220, 210, 20, Color( Right( sel.DecayLevel.ToString() ), White ), false, false );
AddButton( 15, 245, 4005, 4007, 1, GumpButtonType.Reply, 0 );
AddHtml( 50, 245, 120, 20, Color( "Go to house", White ), false, false );
AddButton( 15, 265, 4005, 4007, 2, GumpButtonType.Reply, 0 );
AddHtml( 50, 265, 120, 20, Color( "Open house menu", White ), false, false );
AddButton( 15, 285, 4005, 4007, 3, GumpButtonType.Reply, 0 );
AddHtml( 50, 285, 120, 20, Color( "Demolish house", White ), false, false );
AddButton( 15, 305, 4005, 4007, 4, GumpButtonType.Reply, 0 );
AddHtml( 50, 305, 120, 20, Color( "Refresh house", White ), false, false );
}
}
public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
{
if ( m_Selection == null )
{
int v = info.ButtonID - 1;
if ( v >= 0 && v < m_List.Count )
m_From.SendGump( new ViewHousesGump( m_From, m_List, (BaseHouse)m_List[v] ) );
}
else if ( !m_Selection.Deleted )
{
switch ( info.ButtonID )
{
case 0:
{
m_From.SendGump( new ViewHousesGump( m_From, m_List, null ) );
break;
}
case 1:
{
Map map = m_Selection.Map;
if ( map != null && map != Map.Internal )
m_From.MoveToWorld( m_Selection.BanLocation, map );
m_From.SendGump( new ViewHousesGump( m_From, m_List, m_Selection ) );
break;
}
case 2:
{
m_From.SendGump( new ViewHousesGump( m_From, m_List, m_Selection ) );
HouseSign sign = m_Selection.Sign;
if ( sign != null && !sign.Deleted )
sign.OnDoubleClick( m_From );
break;
}
case 3:
{
m_From.SendGump( new ViewHousesGump( m_From, m_List, m_Selection ) );
m_From.SendGump( new HouseDemolishGump( m_From, m_Selection ) );
break;
}
case 4:
{
m_Selection.RefreshDecay();
m_From.SendGump( new ViewHousesGump( m_From, m_List, m_Selection ) );
break;
}
}
}
}
public object FindHouseName( BaseHouse house )
{
int multiID = house.ItemID & 0x3FFF;
HousePlacementEntry[] entries;
entries = HousePlacementEntry.ClassicHouses;
for ( int i = 0; i < entries.Length; ++i )
{
if ( entries[i].MultiID == multiID )
return entries[i].Description;
}
entries = HousePlacementEntry.TwoStoryFoundations;
for ( int i = 0; i < entries.Length; ++i )
{
if ( entries[i].MultiID == multiID )
return entries[i].Description;
}
entries = HousePlacementEntry.ThreeStoryFoundations;
for ( int i = 0; i < entries.Length; ++i )
{
if ( entries[i].MultiID == multiID )
return entries[i].Description;
}
return house.GetType().Name;
}
private const int White16 = 0x7FFF;
private const int White = 0xFFFFFF;
public string Right( string text )
{
return String.Format( "<div align=right>{0}</div>", text );
}
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 AddBlackAlpha( int x, int y, int width, int height )
{
AddImageTiled( x, y, width, height, 2624 );
AddAlphaRegion( x, y, width, height );
}
}
}

View file

@ -0,0 +1,54 @@
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;
public WarningGump( int header, int headerColor, object content, int contentColor, int width, int height, WarningGumpCallback 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, 170, 20, 1011036, 32767, false, false ); // OKAY
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 );
}
}
}

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

@ -0,0 +1,311 @@
using System;
using System.Collections;
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 ArrayList m_Mobiles;
private int m_Page;
private class InternalComparer : IComparer
{
public static readonly IComparer Instance = new InternalComparer();
public InternalComparer()
{
}
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;
Mobile a = x as Mobile;
Mobile b = y as Mobile;
if ( a == null || b == null )
throw new ArgumentException();
if ( a.AccessLevel > b.AccessLevel )
return -1;
else if ( a.AccessLevel < b.AccessLevel )
return 1;
else
return Insensitive.Compare( a.Name, b.Name );
}
}
public WhoGump( Mobile owner, string filter ) : this( owner, BuildList( owner, filter ), 0 )
{
}
public WhoGump( Mobile owner, ArrayList list, int page ) : base( GumpOffsetX, GumpOffsetY )
{
owner.CloseGump( typeof( WhoGump ) );
m_Owner = owner;
m_Mobiles = list;
Initialize( page );
}
public static ArrayList BuildList( Mobile owner, string filter )
{
if ( filter != null && (filter = filter.Trim()).Length == 0 )
filter = null;
else
filter = filter.ToLower();
ArrayList list = new ArrayList();
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 = (Mobile)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 = (Mobile)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;
}
}
}
}
}

View file

@ -0,0 +1,98 @@
using System;
using Server;
using Server.Network;
using Server.Mobiles;
using Server.Accounting;
namespace Server.Gumps
{
public class YoungDungeonWarning : Gump
{
public YoungDungeonWarning() : base( 150, 200 )
{
AddBackground( 0, 0, 250, 170, 0xA28 );
AddHtmlLocalized( 20, 43, 215, 70, 1018030, true, true ); // Warning: monsters may attack you on site down here in the dungeons!
AddButton( 70, 123, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 105, 125, 100, 35, 1011036, false, false ); // OKAY
}
}
public class YoungDeathNotice : Gump
{
public YoungDeathNotice() : base( 100, 15 )
{
Closable = false;
AddBackground( 25, 10, 425, 444, 0x13BE );
AddImageTiled( 33, 20, 407, 425, 0xA40 );
AddAlphaRegion( 33, 20, 407, 425 );
AddHtmlLocalized( 190, 24, 120, 20, 1046287, 0x7D00, false, false ); // You have died.
// As a ghost you cannot interact with the world. You cannot touch items nor can you use them.
AddHtmlLocalized( 50, 50, 380, 40, 1046288, 0xFFFFFF, false, false );
// You can pass through doors as though they do not exist. However, you cannot pass through walls.
AddHtmlLocalized( 50, 100, 380, 45, 1046289, 0xFFFFFF, false, false );
// Since you are a new player, any items you had on your person at the time of your death will be in your backpack upon resurrection.
AddHtmlLocalized( 50, 140, 380, 60, 1046291, 0xFFFFFF, false, false );
// To be resurrected you must find a healer in town or wandering in the wilderness. Some powerful players may also be able to resurrect you.
AddHtmlLocalized( 50, 204, 380, 65, 1046292, 0xFFFFFF, false, false );
// While you are still in young status, you will be transported to the nearest healer (along with your items) at the time of your death.
AddHtmlLocalized( 50, 269, 380, 65, 1046293, 0xFFFFFF, false, false );
// To rejoin the world of the living simply walk near one of the NPC healers, and they will resurrect you as long as you are not marked as a criminal.
AddHtmlLocalized( 50, 334, 380, 70, 1046294, 0xFFFFFF, false, false );
AddButton( 195, 410, 0xF8, 0xF9, 0, GumpButtonType.Reply, 0 );
}
}
public class RenounceYoungGump : Gump
{
public RenounceYoungGump() : base( 150, 50 )
{
AddBackground( 0, 0, 450, 400, 0xA28 );
AddHtmlLocalized( 0, 30, 450, 35, 1013004, false, false ); // <center> Renouncing 'Young Player' Status</center>
/* As a 'Young' player, you are currently under a system of protection that prevents
* you from being attacked by other players and certain monsters.<br><br>
*
* If you choose to renounce your status as a 'Young' player, you will lose this protection.
* You will become vulnerable to other players, and many monsters that had only glared
* at you menacingly before will now attack you on sight!<br><br>
*
* Select OKAY now if you wish to renounce your status as a 'Young' player, otherwise
* press CANCEL.
*/
AddHtmlLocalized( 30, 70, 390, 210, 1013005, true, true );
AddButton( 45, 298, 0xFA5, 0xFA7, 1, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 78, 300, 100, 35, 1011036, false, false ); // OKAY
AddButton( 178, 298, 0xFA5, 0xFA7, 0, GumpButtonType.Reply, 0 );
AddHtmlLocalized( 211, 300, 100, 35, 1011012, false, false ); // CANCEL
}
public override void OnResponse( NetState sender, RelayInfo info )
{
Mobile from = sender.Mobile;
if ( info.ButtonID == 1 )
{
Account acc = from.Account as Account;
if ( acc != null )
{
acc.RemoveYoungStatus( 502085 ); // You have chosen to renounce your `Young' player status.
}
}
else
{
from.SendLocalizedMessage( 502086 ); // You have chosen not to renounce your `Young' player status.
}
}
}
}