CustomRegion.cs
| CODE | using Server; using System; using Server.Items; using Server.Spells; using Server.Mobiles;
namespace Server.Regions { public class CustomRegion : GuardedRegion { RegionControl m_Controller;
public CustomRegion( RegionControl m, Map map ) : base( "", "Custom Region", map, typeof( WarriorGuard ) ) { LoadFromXml = false; m_Controller = m; }
public override bool IsDisabled() { if( base.Disabled != !m_Controller.GetFlag( RegionFlag.IsGuarded ) ) { m_Controller.IsGuarded = !Disabled; }
return Disabled; }
public override bool AllowBenificial( Mobile from, Mobile target ) { if( ( !m_Controller.AllowBenifitPlayer && target is PlayerMobile ) || ( !m_Controller.AllowBenifitNPC && target is BaseCreature )) { from.SendMessage( "You cannot perform benificial acts on your target." ); return false; }
return base.AllowBenificial( from, target ); }
public override bool AllowHarmful( Mobile from, Mobile target ) { if( ( !m_Controller.AllowHarmPlayer && target is PlayerMobile ) || ( !m_Controller.AllowHarmNPC && target is BaseCreature )) { from.SendMessage( "You cannot perform harmful acts on your target." ); return false; }
return base.AllowHarmful( from, target ); }
public override bool AllowHousing( Mobile from, Point3D p ) { return m_Controller.AllowHousing; }
public override bool AllowSpawn() { return m_Controller.AllowSpawn; }
public override bool CanUseStuckMenu( Mobile m ) { if ( ! m_Controller.CanUseStuckMenu ) m.SendMessage( "You cannot use the Stuck menu here." ); return m_Controller.CanUseStuckMenu; }
public override bool OnDamage( Mobile m, ref int Damage ) { if ( !m_Controller.CanBeDamaged ) { m.SendMessage( "You cannot be damaged here." ); }
return m_Controller.CanBeDamaged; } public override bool OnResurrect( Mobile m ) { if ( ! m_Controller.CanRessurect && m.AccessLevel == AccessLevel.Player) m.SendMessage( "You cannot ressurect here." ); return m_Controller.CanRessurect; }
public override bool OnBeginSpellCast( Mobile from, ISpell s ) { if ( from.AccessLevel == AccessLevel.Player ) { bool restricted = m_Controller.IsRestrictedSpell( s ); if ( restricted ) { from.SendMessage( "You cannot cast that spell here." ); return false; }
//if ( s is EtherealSpell && !CanMountEthereal ) Grr, EthereealSpell is private :< if ( ! m_Controller.CanMountEthereal && ((Spell)s).Info.Name == "Ethereal Mount" ) //Hafta check with a name compare of the string to see if ethy { from.SendMessage( "You cannot mount your ethereal here." ); return false; } }
//Console.WriteLine( m_Controller.GetRegistryNumber( s ) );
//return base.OnBeginSpellCast( from, s ); return true; //Let users customize spells, not rely on weather it's guarded or not. }
public override bool OnDecay( Item item ) { return m_Controller.ItemDecay; }
public override bool OnHeal( Mobile m, ref int Heal ) { if ( !m_Controller.CanHeal ) { m.SendMessage( "You cannot be healed here." ); }
return m_Controller.CanHeal; }
public override bool OnSkillUse( Mobile m, int skill ) { bool restricted = m_Controller.IsRestrictedSkill( skill ); if ( restricted && m.AccessLevel == AccessLevel.Player ) { m.SendMessage( "You cannot use that skill here." ); return false; }
return base.OnSkillUse( m, skill ); }
public override void OnExit( Mobile m ) { if ( m_Controller.ShowExitMessage ) m.SendMessage("You have left {0}", this.Name );
base.OnExit( m );
}
public override void OnEnter( Mobile m ) { if ( m_Controller.ShowEnterMessage ) m.SendMessage("You have entered {0}", this.Name );
base.OnEnter( m ); }
public override bool OnMoveInto( Mobile m, Direction d, Point3D newLocation, Point3D oldLocation ) { if( m_Controller.CannotEnter && ! this.Contains( oldLocation ) ) { m.SendMessage( "You cannot enter this area." ); return false; }
return true; }
public override TimeSpan GetLogoutDelay( Mobile m ) { if( m.AccessLevel == AccessLevel.Player ) return m_Controller.PlayerLogoutDelay;
return base.GetLogoutDelay( m ); }
public override bool OnDoubleClick( Mobile m, object o ) { if( o is BasePotion && !m_Controller.CanUsePotions ) { m.SendMessage( "You cannot drink potions here." ); return false; } if( o is Corpse ) { Corpse c = (Corpse)o;
bool canLoot;
if( c.Owner == m ) canLoot = m_Controller.CannotLootOwnCorpse; else if ( c.Owner is PlayerMobile ) canLoot = m_Controller.CanLootPlayerCorpse; else canLoot = m_Controller.CanLootNPCCorpse;
if( !canLoot ) m.SendMessage( "You cannot loot that corpse here." );
if ( m.AccessLevel >= AccessLevel.GameMaster && !canLoot ) { m.SendMessage( "This is unlootable but you are able to open that with your Godly powers." ); return true; } return canLoot; }
return base.OnDoubleClick( m, o ); }
public override void AlterLightLevel( Mobile m, ref int global, ref int personal ) { if( m_Controller.LightLevel > 0 ) global = m_Controller.LightLevel; else base.AlterLightLevel( m, ref global, ref personal ); } } }
|
RegionControlGump.cs
| CODE | using System; using Server; using Server.Gumps; using Server.Items; using Server.Network;
namespace Server.Gumps { public class RegionControlGump : Gump { RegionControl m_Controller; public RegionControlGump( RegionControl r ) : base( 25, 25 ) { m_Controller = r;
Closable=true; Dragable=true; Resizable=false;
AddPage(0);
AddBackground(23, 32, 412, 256, 9270); AddAlphaRegion(19, 29, 418, 263); AddButton(55, 46, 5569, 5570, (int)Buttons.SpellButton, GumpButtonType.Reply, 0); AddButton(55, 128, 5581, 5582, (int)Buttons.SkillButton, GumpButtonType.Reply, 0); AddButton(50, 205, 7006, 7006, (int)Buttons.AreaButton, GumpButtonType.Reply, 0);
AddLabel(152, 70, 1152, "Edit Restricted Spells"); AddLabel(152, 153, 1152, "Edit Restricted Skills"); AddLabel(152, 234, 1152, "Add Region Area"); AddImage(353, 54, 3953); AddImage(353, 180, 3955);
} public enum Buttons { SpellButton = 1, SkillButton, AreaButton }
public override void OnResponse( NetState sender, RelayInfo info ) { if( m_Controller == null || m_Controller.Deleted ) return;
Mobile m = sender.Mobile;
switch( info.ButtonID ) { case 1: { //m_Controller.SendRestrictGump( m, RestrictType.Spells ); m.CloseGump( typeof( SpellRestrictGump ) ); m.SendGump( new SpellRestrictGump( m_Controller.RestrictedSpells ) );
m.CloseGump( typeof( RegionControlGump ) ); m.SendGump( new RegionControlGump( m_Controller )); break; } case 2: { //m_Controller.SendRestrictGump( m, RestrictType.Skills );
m.CloseGump( typeof( SkillRestrictGump ) ); m.SendGump( new SkillRestrictGump( m_Controller.RestrictedSkills ) );
m.CloseGump( typeof( RegionControlGump ) ); m.SendGump( new RegionControlGump( m_Controller )); break; } case 3: { m.CloseGump( typeof( RegionControlGump ) ); m.SendGump( new RegionControlGump( m_Controller ) );
m.CloseGump( typeof( RemoveAreaGump ) );
m.SendGump( new RemoveAreaGump( m_Controller ) );
m_Controller.ChooseArea( m ); break; } } } } }
|
RegionStone.cs
| CODE | using System; using Server; using Server.Mobiles; using Server.Spells; using Server.Items; using Server.Regions; using System.Collections; using Server.SkillHandlers; using Server.Gumps;
namespace Server.Items { public enum RegionFlag { None = 0x00000000, AllowBenifitPlayer = 0x00000001, AllowHarmPlayer = 0x00000002, AllowHousing = 0x00000004, AllowSpawn = 0x00000008,
CanBeDamaged = 0x00000010, CanHeal = 0x00000020, CanRessurect = 0x00000040, CanUseStuckMenu = 0x00000080, ItemDecay = 0x00000100,
ShowEnterMessage = 0x00000200, ShowExitMessage = 0x00000400,
AllowBenifitNPC = 0x00000800, AllowHarmNPC = 0x00001000,
CanMountEthereal = 0x000002000, CannotEnter = 0x000004000,
CanLootPlayerCorpse = 0x000008000, CanLootNPCCorpse = 0x000010000, CannotLootOwnCorpse = 0x000020000,
CanUsePotions = 0x000040000,
IsGuarded = 0x000080000 }
public enum CustomRegionPriority { HighestPriority = 0x96, HousePriority = 0x96, HighPriority = 0x90, MediumPriority = 0x64, LowPriority = 0x60, InnPriority = 0x33, TownPriority = 0x32, LowestPriority = 0x0 }
public class RegionControl : Item { #region Flags
public bool GetFlag( RegionFlag flag ) { return ( (m_Flags & flag) != 0 ); }
public void SetFlag( RegionFlag flag, bool value ) { if ( value ) m_Flags |= flag; else m_Flags &= ~flag; }
public RegionFlag Flags { get{ return m_Flags; } set{ m_Flags = value; } }
[CommandProperty( AccessLevel.GameMaster )] public bool AllowBenifitPlayer { get{ return GetFlag( RegionFlag.AllowBenifitPlayer ); } set{ SetFlag( RegionFlag.AllowBenifitPlayer, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool AllowHarmPlayer { get{ return GetFlag( RegionFlag.AllowHarmPlayer ); } set{ SetFlag( RegionFlag.AllowHarmPlayer, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool AllowHousing { get{ return GetFlag( RegionFlag.AllowHousing ); } set{ SetFlag( RegionFlag.AllowHousing, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool AllowSpawn { get{ return GetFlag( RegionFlag.AllowSpawn ); } set{ SetFlag( RegionFlag.AllowSpawn, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool CanBeDamaged { get{ return GetFlag( RegionFlag.CanBeDamaged ); } set{ SetFlag( RegionFlag.CanBeDamaged, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool CanMountEthereal { get{ return GetFlag( RegionFlag.CanMountEthereal ); } set{ SetFlag( RegionFlag.CanMountEthereal, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool CannotEnter { get{ return GetFlag( RegionFlag.CannotEnter ); } set{ SetFlag( RegionFlag.CannotEnter, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool CanHeal { get{ return GetFlag( RegionFlag.CanHeal ); } set{ SetFlag( RegionFlag.CanHeal, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool CanRessurect { get{ return GetFlag( RegionFlag.CanRessurect ); } set{ SetFlag( RegionFlag.CanRessurect, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool CanUseStuckMenu { get{ return GetFlag( RegionFlag.CanUseStuckMenu ); } set{ SetFlag( RegionFlag.CanUseStuckMenu, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool ItemDecay { get{ return GetFlag( RegionFlag.ItemDecay ); } set{ SetFlag( RegionFlag.ItemDecay, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool AllowBenifitNPC { get{ return GetFlag( RegionFlag.AllowBenifitNPC ); } set{ SetFlag( RegionFlag.AllowBenifitNPC, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool AllowHarmNPC { get{ return GetFlag( RegionFlag.AllowHarmNPC ); } set{ SetFlag( RegionFlag.AllowHarmNPC, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool ShowEnterMessage { get{ return GetFlag( RegionFlag.ShowEnterMessage ); } set{ SetFlag( RegionFlag.ShowEnterMessage, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool ShowExitMessage { get{ return GetFlag( RegionFlag.ShowExitMessage ); } set{ SetFlag( RegionFlag.ShowExitMessage, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool CanLootPlayerCorpse { get{ return GetFlag( RegionFlag.CanLootPlayerCorpse ); } set{ SetFlag( RegionFlag.CanLootPlayerCorpse, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool CanLootNPCCorpse { get{ return GetFlag( RegionFlag.CanLootNPCCorpse ); } set{ SetFlag( RegionFlag.CanLootNPCCorpse, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool CannotLootOwnCorpse { get{ return GetFlag( RegionFlag.CannotLootOwnCorpse ); } set{ SetFlag( RegionFlag.CannotLootOwnCorpse, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool CanUsePotions { get{ return GetFlag( RegionFlag.CanUsePotions ); } set{ SetFlag( RegionFlag.CanUsePotions, value ); } }
[CommandProperty( AccessLevel.GameMaster )] public bool IsGuarded { get{ if( m_Region != null ) return !m_Region.IsDisabled(); else return GetFlag( RegionFlag.IsGuarded ); } set{ SetFlag( RegionFlag.IsGuarded, value );
if( m_Region != null ) m_Region.Disabled = !value; } }
#endregion
private CustomRegion m_Region; // private Rectangle2D m_Area; private RegionFlag m_Flags; private BitArray m_RestrictedSpells; private BitArray m_RestrictedSkills; private string m_RegionName; private CustomRegionPriority m_Priority;
private MusicName m_Music;
private TimeSpan m_PlayerLogoutDelay;
private ArrayList m_Coords;
private int m_LightLevel;
public BitArray RestrictedSpells { get{ return m_RestrictedSpells; } }
public BitArray RestrictedSkills { get{ return m_RestrictedSkills; } }
[CommandProperty( AccessLevel.GameMaster )] public TimeSpan PlayerLogoutDelay { get{ return m_PlayerLogoutDelay; } set{ m_PlayerLogoutDelay = value; } }
public ArrayList Coords { get{ return m_Coords; } set{ m_Coords = value; UpdateRegion(); } }
[CommandProperty( AccessLevel.GameMaster )] public string RegionName { get{ return m_RegionName; } set{ m_RegionName = value; if( m_Region != null ) m_Region.Name = value; } }
[CommandProperty( AccessLevel.GameMaster )] public MusicName Music { get{ return m_Music; } set { m_Music = value; if( m_Region != null ) m_Region.Music = value; } }
[CommandProperty( AccessLevel.GameMaster )] public int LightLevel { get{ return m_LightLevel; } set{ m_LightLevel = value; } }
[CommandProperty( AccessLevel.GameMaster )] public CustomRegionPriority Priority { get{ return m_Priority; } set { m_Priority = value; if( m_Region != null ) m_Region.Priority = (int)value; } }
[Constructable] public RegionControl() : base ( 5609 ) { Visible = false; Movable = false; Name = "Region Controller"; m_RegionName = "Custom Region"; m_Priority = CustomRegionPriority.HighPriority;
m_RestrictedSpells = new BitArray( SpellRegistry.Types.Length ); m_RestrictedSkills = new BitArray( SkillInfo.Table.Length );
Coords = new ArrayList(); UpdateRegion(); }
[Constructable] public RegionControl( Rectangle2D rect ) : base ( 5609 ) { Coords = new ArrayList();
Coords.Add( rect );
m_RestrictedSpells = new BitArray( SpellRegistry.Types.Length ); m_RestrictedSkills = new BitArray( SkillInfo.Table.Length );
Visible = false; Movable = false; Name = "Region Controller"; m_RegionName = "Custom Region"; m_Priority = CustomRegionPriority.HighPriority;
UpdateRegion(); }
public RegionControl( Serial serial ) : base( serial ) { }
public override void OnDoubleClick( Mobile m ) { if( m.AccessLevel >= AccessLevel.GameMaster) { // m.SendGump( new RestrictGump( m_RestrictedSpells, RestrictType.Spells ) ); // m.SendGump( new RestrictGump( m_RestrictedSkills, RestrictType.Skills ) );
m.CloseGump( typeof( RegionControlGump ) ); m.SendGump( new RegionControlGump( this ) ); m.SendMessage( "Don't forget to props this object for more options!" );
m.CloseGump( typeof( RemoveAreaGump ) ); m.SendGump( new RemoveAreaGump( this ) ); } }
public override void OnMapChange() { if( m_Region != null ) m_Region.Map = this.Map;
base.OnMapChange(); }
public override void Serialize( GenericWriter writer ) { base.Serialize( writer );
writer.Write( (int) 3 ); // version
writer.Write( (int)m_LightLevel );
writer.Write( (int) m_Music );
WriteRect2DArray( writer, Coords ); writer.Write( (int)m_Priority ); writer.Write( (TimeSpan)m_PlayerLogoutDelay );
//writer.Write( m_Area ); WriteBitArray( writer, m_RestrictedSpells ); WriteBitArray( writer, m_RestrictedSkills );
writer.Write( (int) m_Flags ); writer.Write( m_RegionName ); } #region Serialization Helpers public static void WriteBitArray( GenericWriter writer, BitArray ba ) { writer.Write( ba.Length );
for( int i = 0; i < ba.Length; i++ ) { writer.Write( ba[i] ); } return; }
public static BitArray ReadBitArray( GenericReader reader ) { int size = reader.ReadInt(); BitArray newBA = new BitArray( size );
for( int i = 0; i < size; i++ ) { newBA[i] = reader.ReadBool(); }
return newBA; }
public static void WriteRect2DArray( GenericWriter writer, ArrayList ary ) { writer.Write( ary.Count );
for( int i = 0; i < ary.Count; i++ ) { writer.Write( (Rectangle2D)ary[i] ); //Rect2D } return; }
public static ArrayList ReadRect2DArray( GenericReader reader ) { int size = reader.ReadInt(); ArrayList newAry = new ArrayList();
for( int i = 0; i < size; i++ ) { newAry.Add( reader.ReadRect2D() ); } return newAry; }
#endregion public override void Deserialize( GenericReader reader ) { base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version ) { case 3: { m_LightLevel = reader.ReadInt(); goto case 2; } case 2: { m_Music = (MusicName)reader.ReadInt(); goto case 1; } case 1: { Coords = ReadRect2DArray( reader ); m_Priority = (CustomRegionPriority) reader.ReadInt(); m_PlayerLogoutDelay = reader.ReadTimeSpan();
m_RestrictedSpells = ReadBitArray( reader ); m_RestrictedSkills = ReadBitArray( reader ); m_Flags = (RegionFlag)reader.ReadInt();
m_RegionName = reader.ReadString(); break; } case 0: { Coords = new ArrayList();
Coords.Add( reader.ReadRect2D() ); m_RestrictedSpells = ReadBitArray( reader ); m_RestrictedSkills = ReadBitArray( reader ); m_Flags = (RegionFlag)reader.ReadInt();
m_RegionName = reader.ReadString(); break; } }
UpdateRegion();
}
public void UpdateRegion() { if( Coords != null && Coords.Count != 0 ) { if( m_Region == null ) { m_Region = new CustomRegion( this, this.Map ); Region.AddRegion( m_Region ); }
m_Region.Priority = (int)m_Priority; m_Region.Coords = Coords;
m_Region.Name = m_RegionName; m_Region.Map = this.Map;
m_Region.Music = Music; //m_Region.Disabled = !IsGuarded; m_Region.Disabled = !(GetFlag( RegionFlag.IsGuarded )); }
return; }
public static int GetRegistryNumber( ISpell s ) { Type[] t = SpellRegistry.Types;
for( int i = 0; i < t.Length; i++ ) { if( s.GetType() == t[i] ) return i; }
return -1; }
public bool IsRestrictedSpell( ISpell s ) { int regNum = GetRegistryNumber( s ); if( regNum < 0 ) //Happens with unregistered Spells return false;
return m_RestrictedSpells[regNum]; }
public bool IsRestrictedSkill( int skill ) { if( skill < 0 ) return false;
return m_RestrictedSkills[skill]; }
/* public void SendRestrictGump( Mobile m, RestrictType t ) { if( t == RestrictType.Spells ) { m.SendGump( new RestrictGump( m_RestrictedSpells, RestrictType.Spells ) ); } else { m.SendGump( new RestrictGump( m_RestrictedSkills, RestrictType.Skills ) ); } } */
public void ChooseArea( Mobile m ) { BoundingBoxPicker.Begin( m, new BoundingBoxCallback( CustomRegion_Callback ), this ); }
private static void CustomRegion_Callback( Mobile from, Map map, Point3D start, Point3D end, object state ) { DoChooseArea( from, map, start, end, state ); }
private static void DoChooseArea( Mobile from, Map map, Point3D start, Point3D end, object control ) { RegionControl r = (RegionControl)control; Rectangle2D rect = new Rectangle2D( start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1 );
r.m_Coords.Add( rect );
r.UpdateRegion(); }
public override void OnDelete() { if( m_Region != null ) Region.RemoveRegion( m_Region );
base.OnDelete(); } } }
|
RemoveAreaGump.cs
| CODE | using System; using Server; using Server.Gumps; using Server.Items; using System.Collections; using Server.Network;
namespace Server.Gumps { public class RemoveAreaGump : Gump { RegionControl m_Control;
public RemoveAreaGump( RegionControl r ) : base( 25, 300 ) { m_Control = r;
Closable=true; Dragable=true; Resizable=false;
AddPage(0); AddBackground(23, 32, 412, 256, 9270); AddAlphaRegion(19, 29, 418, 263);
AddLabel(186, 45, 1152, "Remove Area");
//+25 between 'em.
int itemsThisPage = 0; int nextPageNumber = 1;
for( int i = 0; i < r.Coords.Count; i++ ) { Rectangle2D rect;
if( r.Coords[i] is Rectangle2D ) rect = (Rectangle2D)r.Coords[i]; else continue;
if( itemsThisPage >= 8 || itemsThisPage == 0) { itemsThisPage = 0;
if( nextPageNumber != 1) { AddButton(393, 45, 4007, 4009, 0, GumpButtonType.Page, nextPageNumber); //Forward button -> #0 }
AddPage( nextPageNumber++ );
if( nextPageNumber != 2) { AddButton(35, 45, 4014, 4016, 1, GumpButtonType.Page, nextPageNumber-2 ); //Back Button -> #1 } }
AddButton(70, 75 + 25 * itemsThisPage, 4017, 4019, 100 + i, GumpButtonType.Reply, 0); //Button is 100 + i
//AddLabel(116, 77 + 25*i, 0, "(1234, 5678)"); AddLabel(116, 77 + 25 * itemsThisPage, 1152, String.Format("({0}, {1})", rect.X, rect.Y ) );
AddLabel(232, 78 + 25 * itemsThisPage, 1152, "<-->");
//AddLabel(294, 77 + 25*i, 0, "(9876, 5432)"); AddLabel(294, 77 + 25 * itemsThisPage, 1152, String.Format("({0}, {1})", rect.X + rect.Width, rect.Y + rect.Height ));
itemsThisPage++;
}
}
public override void OnResponse( NetState sender, RelayInfo info ) { if( info.ButtonID >= 100 ) { m_Control.Coords.RemoveAt( info.ButtonID - 100 );
sender.Mobile.CloseGump( typeof( RemoveAreaGump ) );
sender.Mobile.SendGump( new RemoveAreaGump( m_Control ) ); } } } }
|
RestrictGump.cs
| CODE | using System; using Server; using Server.Gumps; using Server.Spells; using Server.Network; using System.Collections;
public enum RestrictType { Spells, Skills }
namespace Server.Gumps { public abstract class RestrictGump : Gump { BitArray m_Restricted;
RestrictType m_type;
public RestrictGump( BitArray ba, RestrictType t ) : base( 50, 50 ) { m_Restricted = ba; m_type = t;
Closable=true; Dragable=true; Resizable=false;
AddPage(0);
AddBackground(10, 10, 225, 425, 9380); AddLabel(73, 15, 1152, (t == RestrictType.Spells) ? "Restrict Spells" : "Restrict Skills" ); AddButton(91, 411, 247, 248, 1, GumpButtonType.Reply, 0); //Okay Button -> # 1
int itemsThisPage = 0; int nextPageNumber = 1; Object[] ary;// = (t == RestrictType.Skills) ? SkillInfo.Table : SpellRegistry.Types;
if( t == RestrictType.Skills ) ary = SkillInfo.Table; else ary = SpellRegistry.Types;
for( int i = 0; i < ary.Length; i++ ) { if( ary[i] != null ) { if( itemsThisPage >= 8 || itemsThisPage == 0) { itemsThisPage = 0;
if( nextPageNumber != 1) { AddButton(190, 412, 4005, 4007, 2, GumpButtonType.Page, nextPageNumber); //Forward button -> #2 }
AddPage( nextPageNumber++ );
if( nextPageNumber != 2) { AddButton(29, 412, 4014, 4016, 3, GumpButtonType.Page, nextPageNumber-2); //Back Button -> #3 } }
AddCheck(40, 55 + ( 45 * itemsThisPage ), 210, 211, ba[i], i + ((t == RestrictType.Spells) ? 100 : 500) ); //checkbox -> ID = 100 + i for spells, 500 + i for skills //Console.WriteLine( ary[i].GetType().ToString() ); AddLabel(70, 55 + ( 45 * itemsThisPage ) , 0, ((t == RestrictType.Spells) ? ((Type)(ary[i])).Name : ((SkillInfo)(ary[i])).Name )); itemsThisPage++; } } }
public override void OnResponse( NetState sender, RelayInfo info ) { if( info.ButtonID == 1 ) { for( int i = 0; i < m_Restricted.Length; i++ ) { m_Restricted[ i ] = info.IsSwitched( i + ((m_type == RestrictType.Spells) ? 100 : 500 )); //This way is faster after looking at decompiled BitArray.SetAll( bool ) } } } }
public class SpellRestrictGump : RestrictGump { public SpellRestrictGump( BitArray ba ) : base( ba, RestrictType.Spells ) {
} }
public class SkillRestrictGump : RestrictGump { public SkillRestrictGump( BitArray ba ) : base( ba, RestrictType.Skills ) {
} } }
|
|