Overwrite
Complete Overwrite of the Folder with the free shard. ServUO 57.3 has been added.
This commit is contained in:
258
Scripts/SubSystem/Utilities v1.03/Commands/Commands.cs
Normal file
258
Scripts/SubSystem/Utilities v1.03/Commands/Commands.cs
Normal file
@@ -0,0 +1,258 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using Server;
|
||||
using Server.Commands;
|
||||
using Server.Commands.Generic;
|
||||
|
||||
namespace Knives.Utils
|
||||
{
|
||||
public class Commands
|
||||
{
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register( "Commands", AccessLevel.Administrator, new CommandEventHandler( OnCommands ) );
|
||||
EventSink.Login += new LoginEventHandler( OnLogin );
|
||||
}
|
||||
|
||||
private static void OnCommands( CommandEventArgs e )
|
||||
{
|
||||
CommandsGump.SendTo( e.Mobile );
|
||||
}
|
||||
|
||||
private static Hashtable s_Defaults = new Hashtable();
|
||||
private static ArrayList s_InitInfo = new ArrayList();
|
||||
private static bool s_Inited;
|
||||
|
||||
public static bool HasMod( string command )
|
||||
{
|
||||
return s_Defaults[command] != null && new ArrayList(CommandSystem.Entries.Keys).Contains(command);
|
||||
}
|
||||
|
||||
public static void RestoreCommand( string command )
|
||||
{try{
|
||||
|
||||
if ( !HasMod( command ) )
|
||||
{
|
||||
s_Defaults.Remove( command );
|
||||
CommandSystem.Entries.Remove( command );
|
||||
return;
|
||||
}
|
||||
|
||||
DefaultInfo info = (DefaultInfo)s_Defaults[command];
|
||||
CommandEntry entry = new CommandEntry(info.OldCommand, ((CommandEntry)CommandSystem.Entries[command]).Handler, info.OldAccess);
|
||||
CommandSystem.Entries.Remove(command);
|
||||
|
||||
if ( HasMod( info.OldCommand ) )
|
||||
RestoreCommand( info.OldCommand );
|
||||
|
||||
CommandSystem.Entries[info.OldCommand] = entry;
|
||||
|
||||
s_Defaults.Remove( command );
|
||||
|
||||
foreach( BaseCommandImplementor imp in BaseCommandImplementor.Implementors )
|
||||
foreach( string str in new ArrayList( imp.Commands.Keys ) )
|
||||
if ( str == command )
|
||||
{
|
||||
imp.Commands[info.OldCommand] = imp.Commands[str];
|
||||
((BaseCommand)imp.Commands[str]).AccessLevel = info.OldAccess;
|
||||
|
||||
if ( str != info.OldCommand )
|
||||
imp.Commands.Remove( str );
|
||||
}
|
||||
|
||||
}
|
||||
catch{ Errors.Report("Commands-> RestoreDefault"); }
|
||||
}
|
||||
|
||||
public static void ApplyCommand( string old, string txt )
|
||||
{try{
|
||||
|
||||
if (CommandSystem.Entries[txt] != null
|
||||
|| CommandSystem.Entries[old] == null)
|
||||
return;
|
||||
|
||||
if ( HasMod( old ) )
|
||||
{
|
||||
((DefaultInfo)s_Defaults[old]).NewCommand = txt;
|
||||
s_Defaults[txt] = s_Defaults[old];
|
||||
s_Defaults.Remove( old );
|
||||
}
|
||||
else
|
||||
{
|
||||
DefaultInfo info = new DefaultInfo();
|
||||
info.OldCommand = old;
|
||||
info.NewCommand = txt;
|
||||
info.NewAccess = ((CommandEntry)CommandSystem.Entries[old]).AccessLevel;
|
||||
info.OldAccess = info.NewAccess;
|
||||
s_Defaults[txt] = info;
|
||||
}
|
||||
|
||||
CommandSystem.Entries[txt] = CommandSystem.Entries[old];
|
||||
CommandSystem.Entries.Remove(old);
|
||||
|
||||
foreach( BaseCommandImplementor imp in BaseCommandImplementor.Implementors )
|
||||
foreach( string str in new ArrayList( imp.Commands.Keys ) )
|
||||
if ( str == old )
|
||||
{
|
||||
imp.Commands[txt] = imp.Commands[str];
|
||||
imp.Commands.Remove( str );
|
||||
}
|
||||
|
||||
}catch{ Errors.Report( "Commands-> ApplyCommand" ); } }
|
||||
|
||||
public static void Access( string command, int num )
|
||||
{try{
|
||||
|
||||
if (CommandSystem.Entries[command] == null)
|
||||
return;
|
||||
|
||||
DefaultInfo info = new DefaultInfo();
|
||||
|
||||
if ( !HasMod( command ) )
|
||||
{
|
||||
info = new DefaultInfo();
|
||||
info.OldCommand = command;
|
||||
info.NewCommand = command;
|
||||
info.NewAccess = ((CommandEntry)CommandSystem.Entries[command]).AccessLevel + num;
|
||||
info.OldAccess = ((CommandEntry)CommandSystem.Entries[command]).AccessLevel;
|
||||
s_Defaults[command] = info;
|
||||
}
|
||||
else
|
||||
{
|
||||
info = (DefaultInfo)s_Defaults[command];
|
||||
info.NewAccess = info.NewAccess+num;
|
||||
}
|
||||
|
||||
CommandEntry entry = new CommandEntry(command, ((CommandEntry)CommandSystem.Entries[command]).Handler, info.NewAccess);
|
||||
CommandSystem.Entries[command] = entry;
|
||||
|
||||
foreach( BaseCommandImplementor imp in BaseCommandImplementor.Implementors )
|
||||
foreach( string str in new ArrayList( imp.Commands.Keys ) )
|
||||
if ( str == command )
|
||||
((BaseCommand)imp.Commands[str]).AccessLevel = info.NewAccess;
|
||||
|
||||
}catch{ Errors.Report( "Commands-> Access-> Int" ); } }
|
||||
|
||||
public static void Access( string command, AccessLevel level )
|
||||
{try{
|
||||
|
||||
if (CommandSystem.Entries[command] == null)
|
||||
return;
|
||||
|
||||
DefaultInfo info = new DefaultInfo();
|
||||
|
||||
if ( !HasMod( command ) )
|
||||
{
|
||||
info = new DefaultInfo();
|
||||
info.OldCommand = command;
|
||||
info.NewCommand = command;
|
||||
info.NewAccess = level;
|
||||
info.OldAccess = ((CommandEntry)CommandSystem.Entries[command]).AccessLevel;
|
||||
s_Defaults[command] = info;
|
||||
}
|
||||
else
|
||||
{
|
||||
info = (DefaultInfo)s_Defaults[command];
|
||||
info.NewAccess = level;
|
||||
}
|
||||
|
||||
CommandEntry entry = new CommandEntry(command, ((CommandEntry)CommandSystem.Entries[command]).Handler, info.NewAccess);
|
||||
CommandSystem.Entries[command] = entry;
|
||||
|
||||
foreach( BaseCommandImplementor imp in BaseCommandImplementor.Implementors )
|
||||
foreach( string str in new ArrayList( imp.Commands.Keys ) )
|
||||
if ( str == command )
|
||||
((BaseCommand)imp.Commands[str]).AccessLevel = info.NewAccess;
|
||||
|
||||
}catch{ Errors.Report( "Commands-> Access-> AccessLevel" ); } }
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
EventSink.WorldLoad += new WorldLoadEventHandler( OnLoad );
|
||||
EventSink.WorldSave += new WorldSaveEventHandler( OnSave );
|
||||
}
|
||||
|
||||
private static void OnSave( WorldSaveEventArgs e )
|
||||
{try{
|
||||
|
||||
if ( !Directory.Exists( "Saves/Commands/" ) )
|
||||
Directory.CreateDirectory( "Saves/Commands/" );
|
||||
|
||||
GenericWriter writer = new BinaryFileWriter( Path.Combine( "Saves/Commands/", "Commands.bin" ), true );
|
||||
|
||||
writer.Write( 0 ); // version
|
||||
|
||||
ArrayList list = new ArrayList( s_Defaults.Values );
|
||||
|
||||
writer.Write( list.Count );
|
||||
|
||||
foreach( DefaultInfo info in list )
|
||||
{
|
||||
writer.Write( info.NewCommand );
|
||||
writer.Write( info.OldCommand );
|
||||
writer.Write( (int)info.NewAccess );
|
||||
}
|
||||
|
||||
writer.Close();
|
||||
|
||||
}catch{ Errors.Report( "Commands-> OnSave" ); } }
|
||||
|
||||
private static void OnLoad()
|
||||
{try{
|
||||
|
||||
if ( !File.Exists( Path.Combine( "Saves/Commands/", "Commands.bin" ) ) )
|
||||
return;
|
||||
|
||||
using ( FileStream bin = new FileStream( Path.Combine( "Saves/Commands/", "Commands.bin" ), FileMode.Open, FileAccess.Read, FileShare.Read ) )
|
||||
{
|
||||
GenericReader reader = new BinaryFileReader( new BinaryReader( bin ) );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
int count = reader.ReadInt();
|
||||
|
||||
object[] obj;
|
||||
for( int i = 0; i < count; ++i )
|
||||
{
|
||||
obj = new object[3];
|
||||
obj[0] = reader.ReadString();
|
||||
obj[1] = reader.ReadString();
|
||||
obj[2] = reader.ReadInt();
|
||||
s_InitInfo.Add( obj );
|
||||
}
|
||||
}
|
||||
}catch{ Errors.Report( "Commands-> OnLoad" ); } }
|
||||
|
||||
private static void OnLogin( LoginEventArgs e )
|
||||
{
|
||||
if ( s_Inited )
|
||||
return;
|
||||
|
||||
s_Inited = true;
|
||||
|
||||
foreach( object[] obj in s_InitInfo )
|
||||
{
|
||||
ApplyCommand( obj[1].ToString(), obj[0].ToString() );
|
||||
Access( obj[0].ToString(), (AccessLevel)obj[2] );
|
||||
}
|
||||
}
|
||||
|
||||
private class DefaultInfo
|
||||
{
|
||||
private string c_NewCommand;
|
||||
private string c_OldCommand;
|
||||
private AccessLevel c_NewAccess;
|
||||
private AccessLevel c_OldAccess;
|
||||
|
||||
public string NewCommand{ get{ return c_NewCommand; } set{ c_NewCommand = value; } }
|
||||
public string OldCommand{ get{ return c_OldCommand; } set{ c_OldCommand = value; } }
|
||||
public AccessLevel NewAccess{ get{ return c_NewAccess; } set{ c_NewAccess = value; } }
|
||||
public AccessLevel OldAccess{ get{ return c_OldAccess; } set{ c_OldAccess = value; } }
|
||||
|
||||
public DefaultInfo()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
187
Scripts/SubSystem/Utilities v1.03/Commands/CommandsGump.cs
Normal file
187
Scripts/SubSystem/Utilities v1.03/Commands/CommandsGump.cs
Normal file
@@ -0,0 +1,187 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Commands;
|
||||
|
||||
namespace Knives.Utils
|
||||
{
|
||||
public class CommandsGump : GumpPlus
|
||||
{
|
||||
public static void SendTo( Mobile m )
|
||||
{
|
||||
new CommandsGump( m );
|
||||
}
|
||||
|
||||
private static string s_Help = " With this interface, you can modify every command and the Access Level required to use it! Should I warn you about changing some of these? Sure, why not. "
|
||||
+ "Remember to only allow staff levels you can trust access to certain commands! This system won't let you run two commands from a single input, nor can you input a blank command or one with spaces. "
|
||||
+ "If you get lost, simple hit the red button just to the left of the command to reset it. Enjoy!";
|
||||
|
||||
private const int Width = 250;
|
||||
private const int Height = 350;
|
||||
|
||||
public ArrayList c_List = new ArrayList();
|
||||
public int c_Page = 0;
|
||||
|
||||
public CommandsGump( Mobile m ) : base( m, 100, 100 )
|
||||
{
|
||||
NewGump();
|
||||
}
|
||||
|
||||
protected override void BuildGump()
|
||||
{
|
||||
AddBackground( 0, 0, Width, Height, 0x13BE );
|
||||
|
||||
AddButton( Width-20, Height-20, 0x5689, 0x5689, "Help", new TimerCallback( Help ) );
|
||||
|
||||
BuildList();
|
||||
DisplayList();
|
||||
}
|
||||
|
||||
private void BuildList()
|
||||
{
|
||||
c_List.Clear();
|
||||
|
||||
foreach( string str in CommandSystem.Entries.Keys )
|
||||
if ( ((CommandEntry)CommandSystem.Entries[str]).AccessLevel <= Owner.AccessLevel )
|
||||
c_List.Add( str );
|
||||
|
||||
c_List.Sort( new InternalSorter() );
|
||||
}
|
||||
|
||||
private void DisplayList()
|
||||
{
|
||||
int toList = 10;
|
||||
|
||||
int beginAt = toList*c_Page;
|
||||
|
||||
while( c_Page > 0 )
|
||||
{
|
||||
if ( beginAt > c_List.Count )
|
||||
beginAt = toList * --c_Page;
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
if ( c_Page != 0 )
|
||||
AddButton( Width/2-7, 30, 0x15E0, 0x15E4, "Next Page", new TimerCallback( PageDown ) );
|
||||
|
||||
if ( c_Page < (c_List.Count-1)/toList )
|
||||
AddButton( Width/2-7, Height-25, 0x15E2, 0x15E6, "Previous Page", new TimerCallback( PageUp ) );
|
||||
|
||||
int y = 30;
|
||||
int x = 20;
|
||||
|
||||
AddHtml( 20, 10, Width-40, 21, "<CENTER>Command Mod Menu", false, false );
|
||||
|
||||
for( int i = beginAt; i < c_List.Count && i < beginAt+toList; ++i )
|
||||
{
|
||||
AddImageTiled( x, y+=25, 100, 21, 0xBBA );
|
||||
AddTextField( x, y, 100, 21, 0x480, i, c_List[i].ToString() );
|
||||
AddButton( x+105, y+3, 0x93A, 0x93A, "Submit Command Name", new TimerStateCallback( ApplyCommand ), i );
|
||||
|
||||
if( Commands.HasMod( c_List[i].ToString() ) )
|
||||
AddButton( 5, y+3, 0x29F6, 0x29F6, "Restore Default", new TimerStateCallback( RestoreDefault ), i );
|
||||
|
||||
AddHtml( x+130, y, 100, 21, ((CommandEntry)CommandSystem.Entries[c_List[i].ToString()]).AccessLevel.ToString(), false, false );
|
||||
|
||||
if ( ((CommandEntry)CommandSystem.Entries[c_List[i].ToString()]).AccessLevel < AccessLevel.Administrator )
|
||||
AddButton( x+210, y, 0x983, 0x983, "Access Up", new TimerStateCallback( AccessUp ), i );
|
||||
|
||||
if ( ((CommandEntry)CommandSystem.Entries[c_List[i].ToString()]).AccessLevel > AccessLevel.Player )
|
||||
AddButton( x+210, y+10, 0x985, 0x985, "Access Down", new TimerStateCallback( AccessDown ), i );
|
||||
}
|
||||
}
|
||||
|
||||
private void Help()
|
||||
{
|
||||
NewGump();
|
||||
InfoGump.SendTo( Owner, 300, 300, s_Help, true );
|
||||
}
|
||||
|
||||
private void PageUp()
|
||||
{
|
||||
c_Page++;
|
||||
NewGump();
|
||||
}
|
||||
|
||||
private void PageDown()
|
||||
{
|
||||
c_Page--;
|
||||
NewGump();
|
||||
}
|
||||
|
||||
private void RestoreDefault( object obj )
|
||||
{
|
||||
if ( !(obj is int) )
|
||||
return;
|
||||
|
||||
if ( Commands.HasMod( c_List[(int)obj].ToString() ) )
|
||||
Commands.RestoreCommand( c_List[(int)obj].ToString() );
|
||||
|
||||
NewGump();
|
||||
}
|
||||
|
||||
private void ApplyCommand( object obj )
|
||||
{
|
||||
if ( !(obj is int) )
|
||||
return;
|
||||
|
||||
if ( GetTextField( (int)obj ) == "" || GetTextField( (int)obj ).IndexOf( " " ) != -1 )
|
||||
{
|
||||
NewGump();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( CommandSystem.Entries[GetTextField( (int)obj )] != null )
|
||||
Owner.SendMessage( "That command already exists." );
|
||||
else
|
||||
Commands.ApplyCommand( c_List[(int)obj].ToString(), GetTextField( (int)obj ) );
|
||||
|
||||
NewGump();
|
||||
}
|
||||
|
||||
private void AccessUp( object obj )
|
||||
{
|
||||
if ( !(obj is int) )
|
||||
return;
|
||||
|
||||
Commands.Access( c_List[(int)obj].ToString(), 1 );
|
||||
NewGump();
|
||||
}
|
||||
|
||||
private void AccessDown( object obj )
|
||||
{
|
||||
if ( !(obj is int) )
|
||||
return;
|
||||
|
||||
Commands.Access( c_List[(int)obj].ToString(), -1 );
|
||||
NewGump();
|
||||
}
|
||||
|
||||
|
||||
private class InternalSorter : IComparer
|
||||
{
|
||||
public InternalSorter()
|
||||
{
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
string a = x as string;
|
||||
string b = y as string;
|
||||
|
||||
if ( a == null || b == null )
|
||||
return 0;
|
||||
|
||||
return Insensitive.Compare( a, b );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
69
Scripts/SubSystem/Utilities v1.03/Error Reporting/Errors.cs
Normal file
69
Scripts/SubSystem/Utilities v1.03/Error Reporting/Errors.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Commands;
|
||||
using Server.Network;
|
||||
|
||||
namespace Knives.Utils
|
||||
{
|
||||
public class Errors
|
||||
{
|
||||
private static ArrayList s_ErrorLog = new ArrayList();
|
||||
private static ArrayList s_Checked = new ArrayList();
|
||||
|
||||
public static ArrayList ErrorLog{ get{ return s_ErrorLog; } }
|
||||
public static ArrayList Checked{ get{ return s_Checked; } }
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
CommandSystem.Register("Errors", AccessLevel.Counselor, new CommandEventHandler(OnErrors));
|
||||
|
||||
EventSink.Login += new LoginEventHandler( OnLogin );
|
||||
}
|
||||
|
||||
private static void OnErrors( CommandEventArgs e )
|
||||
{
|
||||
if ( e.ArgString == null || e.ArgString == "" )
|
||||
ErrorsGump.SendTo( e.Mobile );
|
||||
else
|
||||
Report( e.ArgString + " - " + e.Mobile.Name );
|
||||
}
|
||||
|
||||
private static void OnLogin( LoginEventArgs e )
|
||||
{
|
||||
if ( e.Mobile.AccessLevel != AccessLevel.Player
|
||||
&& s_ErrorLog.Count != 0
|
||||
&& !s_Checked.Contains( e.Mobile ) )
|
||||
ErrorsNotifyGump.SendTo( e.Mobile );
|
||||
}
|
||||
|
||||
public static void Report( string error )
|
||||
{
|
||||
s_ErrorLog.Add( String.Format( "<B>{0}</B><BR>{1}<BR>", DateTime.Now, error ) );
|
||||
|
||||
s_Checked.Clear();
|
||||
|
||||
Notify();
|
||||
}
|
||||
|
||||
private static void Notify()
|
||||
{
|
||||
foreach( NetState state in NetState.Instances )
|
||||
{
|
||||
if ( state.Mobile == null )
|
||||
continue;
|
||||
|
||||
if ( state.Mobile.AccessLevel != AccessLevel.Player )
|
||||
Notify( state.Mobile );
|
||||
}
|
||||
}
|
||||
|
||||
public static void Notify( Mobile m )
|
||||
{
|
||||
if ( m.HasGump( typeof( ErrorsGump ) ) )
|
||||
ErrorsGump.SendTo( m );
|
||||
else
|
||||
ErrorsNotifyGump.SendTo( m );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Network;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Knives.Utils
|
||||
{
|
||||
public class ErrorsGump : GumpPlus
|
||||
{
|
||||
private static string s_Help = " Errors reported by either this chat system or other staff members! Administrators have the power to clear this list. All staff members can report an error using the [errors <text> command.";
|
||||
|
||||
public static void SendTo( Mobile m )
|
||||
{
|
||||
new ErrorsGump( m );
|
||||
Errors.Checked.Add( m );
|
||||
}
|
||||
|
||||
private const int Width = 400;
|
||||
private const int Height = 400;
|
||||
|
||||
public ErrorsGump( Mobile m ) : base( m, 100, 100 )
|
||||
{
|
||||
m.CloseGump( typeof( ErrorsGump ) );
|
||||
|
||||
NewGump();
|
||||
}
|
||||
|
||||
protected override void BuildGump()
|
||||
{try{
|
||||
|
||||
AddBackground( 0, 0, Width, Height, 0xE10 );
|
||||
|
||||
AddButton( Width-20, Height-20, 0x5689, 0x5689, "Help", new TimerCallback( Help ) );
|
||||
|
||||
int y = 0;
|
||||
|
||||
AddHtml( 0, y+=15, Width, 45, HTML.White + "<CENTER>Error Log", false, false );
|
||||
AddBackground( 30, y+=20, Width-60, 3, 0x13BE );
|
||||
|
||||
string str = HTML.Black;
|
||||
foreach( string text in Errors.ErrorLog )
|
||||
str += text;
|
||||
|
||||
AddHtml( 20, y+=20, Width-40, Height-y-50, str, true, true );
|
||||
|
||||
if ( Owner.AccessLevel >= AccessLevel.Administrator )
|
||||
{
|
||||
AddButton( Width/2-30, Height-40, 0x98B, 0x98B, "Clear log", new TimerCallback( ClearLog ) );
|
||||
AddHtml( Width/2-23, Height-37, 51, 20, HTML.White + "<CENTER>Clear", false, false );
|
||||
}
|
||||
|
||||
}catch{ Errors.Report( String.Format( "ErrorsGump-> BuildGump-> |{0}|", Owner ) ); } }
|
||||
|
||||
private void Help()
|
||||
{
|
||||
NewGump();
|
||||
InfoGump.SendTo( Owner, 300, 300, HTML.White + s_Help, true );
|
||||
}
|
||||
|
||||
private void ClearLog()
|
||||
{
|
||||
Errors.ErrorLog.Clear();
|
||||
Owner.SendMessage( "The error log is now clear." );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Knives.Utils
|
||||
{
|
||||
public class ErrorsNotifyGump : GumpPlus
|
||||
{
|
||||
public static void SendTo( Mobile m )
|
||||
{
|
||||
new ErrorsNotifyGump( m );
|
||||
}
|
||||
|
||||
public ErrorsNotifyGump( Mobile m ) : base( m, 100, 100 )
|
||||
{
|
||||
m.CloseGump( typeof( ErrorsNotifyGump ) );
|
||||
|
||||
Override = false;
|
||||
|
||||
NewGump();
|
||||
}
|
||||
|
||||
protected override void BuildGump()
|
||||
{
|
||||
AddItem( 0, 2, 0x25C6 );
|
||||
AddButton( 33, 40, 0x1523, 0x1523, "Errors", new TimerCallback( Errors ) );
|
||||
}
|
||||
|
||||
private void Errors()
|
||||
{
|
||||
ErrorsGump.SendTo( Owner );
|
||||
}
|
||||
}
|
||||
}
|
||||
37
Scripts/SubSystem/Utilities v1.03/Gumps Plus/ButtonPlus.cs
Normal file
37
Scripts/SubSystem/Utilities v1.03/Gumps Plus/ButtonPlus.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Knives.Utils
|
||||
{
|
||||
public class ButtonPlus : GumpButton
|
||||
{
|
||||
private string c_Name;
|
||||
private object c_Callback;
|
||||
private object c_Param;
|
||||
|
||||
public string Name{ get{ return c_Name; } }
|
||||
|
||||
public ButtonPlus( int x, int y, int normalID, int pressedID, int buttonID, string name, TimerCallback back ) : base( x, y, normalID, pressedID, buttonID, GumpButtonType.Reply, 0 )
|
||||
{
|
||||
c_Name = name;
|
||||
c_Callback = back;
|
||||
c_Param = "";
|
||||
}
|
||||
|
||||
public ButtonPlus( int x, int y, int normalID, int pressedID, int buttonID, string name, TimerStateCallback back, object param ) : base( x, y, normalID, pressedID, buttonID, GumpButtonType.Reply, 0 )
|
||||
{
|
||||
c_Name = name;
|
||||
c_Callback = back;
|
||||
c_Param = param;
|
||||
}
|
||||
|
||||
public void Invoke()
|
||||
{
|
||||
if ( c_Callback is TimerCallback )
|
||||
((TimerCallback)c_Callback).Invoke();
|
||||
else if ( c_Callback is TimerStateCallback )
|
||||
((TimerStateCallback)c_Callback).Invoke( c_Param );
|
||||
}
|
||||
}
|
||||
}
|
||||
75
Scripts/SubSystem/Utilities v1.03/Gumps Plus/ChoiceGump.cs
Normal file
75
Scripts/SubSystem/Utilities v1.03/Gumps Plus/ChoiceGump.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Knives.Utils
|
||||
{
|
||||
public class ChoiceGump : GumpPlus
|
||||
{
|
||||
public static void SendTo( Mobile m, string title, int width, TimerStateCallback callback, Hashtable table )
|
||||
{
|
||||
new ChoiceGump( m, title, width, callback, table );
|
||||
}
|
||||
|
||||
private string c_Title;
|
||||
private int c_Width;
|
||||
private TimerStateCallback c_Callback;
|
||||
private Hashtable c_Table;
|
||||
|
||||
public ChoiceGump( Mobile m, string title, int width, TimerStateCallback callback, Hashtable table ) : base( m, 100, 100 )
|
||||
{
|
||||
c_Title = title;
|
||||
c_Width = width;
|
||||
c_Callback = callback;
|
||||
c_Table = table;
|
||||
|
||||
NewGump();
|
||||
}
|
||||
|
||||
protected override void BuildGump()
|
||||
{try{
|
||||
|
||||
int height = 50+(25*c_Table.Count);
|
||||
|
||||
if ( c_Title == "" )
|
||||
height-=20;
|
||||
|
||||
AddBackground( 0, 0, c_Width, height, 0x13BE );
|
||||
|
||||
int y = 10;
|
||||
|
||||
if ( c_Title != "" )
|
||||
AddHtml( 0, 10, c_Width, 25, HTML.White + "<CENTER>" + c_Title, false, false );
|
||||
else
|
||||
y = -10;
|
||||
|
||||
ArrayList list = new ArrayList( c_Table.Values );
|
||||
|
||||
for( int i = 0; i < list.Count; ++i )
|
||||
{
|
||||
AddHtml( 40, y+=25, c_Width, 20, HTML.White + list[i].ToString(), false, false );
|
||||
AddButton( 15, y+2, 0x93A, 0x93A, "Respond", new TimerStateCallback( Respond ), i );
|
||||
}
|
||||
|
||||
}catch{ Errors.Report( "ChoiceGump-> BuildGump" ); } }
|
||||
|
||||
private void Respond( object obj )
|
||||
{
|
||||
if ( !(obj is int))
|
||||
return;
|
||||
|
||||
ArrayList list = new ArrayList( c_Table.Keys );
|
||||
|
||||
if ( list[(int)obj] != null )
|
||||
c_Callback.Invoke( list[(int)obj] );
|
||||
else
|
||||
c_Callback.Invoke( -1 );
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
c_Callback.Invoke( -1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
311
Scripts/SubSystem/Utilities v1.03/Gumps Plus/GumpInfo.cs
Normal file
311
Scripts/SubSystem/Utilities v1.03/Gumps Plus/GumpInfo.cs
Normal file
@@ -0,0 +1,311 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using Server;
|
||||
using Server.Accounting;
|
||||
|
||||
namespace Knives.Utils
|
||||
{
|
||||
public class GumpInfo
|
||||
{
|
||||
private static Hashtable s_Infos = new Hashtable();
|
||||
private static ArrayList s_Backgrounds = new ArrayList();
|
||||
private static ArrayList s_TextColors = new ArrayList();
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
EventSink.WorldLoad += new WorldLoadEventHandler( OnLoad );
|
||||
EventSink.WorldSave += new WorldSaveEventHandler( OnSave );
|
||||
}
|
||||
|
||||
public static void Initialize()
|
||||
{
|
||||
s_Backgrounds.Add( 0xA3C );
|
||||
s_Backgrounds.Add( 0x53 );
|
||||
s_Backgrounds.Add( 0x2486 );
|
||||
s_Backgrounds.Add( 0xDAC );
|
||||
s_Backgrounds.Add( 0xE10 );
|
||||
s_Backgrounds.Add( 0x13EC );
|
||||
s_Backgrounds.Add( 0x1400 );
|
||||
s_Backgrounds.Add( 0x2422 );
|
||||
s_Backgrounds.Add( 0x242C );
|
||||
s_Backgrounds.Add( 0x13BE );
|
||||
s_Backgrounds.Add( 0x2436 );
|
||||
s_Backgrounds.Add( 0x2454 );
|
||||
s_Backgrounds.Add( 0x251C );
|
||||
s_Backgrounds.Add( 0x254E );
|
||||
s_Backgrounds.Add( 0x24A4 );
|
||||
s_Backgrounds.Add( 0x24AE );
|
||||
|
||||
s_TextColors.Add("FFFFFF");
|
||||
s_TextColors.Add("111111");
|
||||
s_TextColors.Add("FF0000");
|
||||
s_TextColors.Add("FF9999");
|
||||
s_TextColors.Add("00FF00");
|
||||
s_TextColors.Add("0000FF");
|
||||
s_TextColors.Add("999999");
|
||||
s_TextColors.Add("333333");
|
||||
s_TextColors.Add("FFFF00");
|
||||
s_TextColors.Add("990099");
|
||||
s_TextColors.Add("CC00FF");
|
||||
}
|
||||
|
||||
private static void OnSave( WorldSaveEventArgs e )
|
||||
{try{
|
||||
|
||||
if ( !Directory.Exists( "Saves/Gumps/" ) )
|
||||
Directory.CreateDirectory( "Saves/Gumps/" );
|
||||
|
||||
GenericWriter writer = new BinaryFileWriter( Path.Combine( "Saves/Gumps/", "Gumps.bin" ), true );
|
||||
|
||||
writer.Write( 0 ); // version
|
||||
|
||||
ArrayList list = new ArrayList();
|
||||
GumpInfo info;
|
||||
|
||||
foreach( object o in new ArrayList( s_Infos.Values ) )
|
||||
{
|
||||
if ( !(o is Hashtable) )
|
||||
continue;
|
||||
|
||||
foreach( object ob in new ArrayList( ((Hashtable)o).Values ) )
|
||||
{
|
||||
if ( !(ob is GumpInfo ) )
|
||||
continue;
|
||||
|
||||
info = (GumpInfo)ob;
|
||||
|
||||
if ( info.Mobile != null
|
||||
&& info.Mobile.Player
|
||||
&& !info.Mobile.Deleted
|
||||
&& info.Mobile.Account != null
|
||||
&& ((Account)info.Mobile.Account).LastLogin > DateTime.Now - TimeSpan.FromDays( 30 ) )
|
||||
list.Add( ob );
|
||||
}
|
||||
}
|
||||
|
||||
writer.Write( list.Count );
|
||||
|
||||
foreach( GumpInfo ginfo in list )
|
||||
ginfo.Save( writer );
|
||||
|
||||
writer.Close();
|
||||
|
||||
}catch{ Errors.Report( "GumpInfo-> OnSave" ); } }
|
||||
|
||||
private static void OnLoad()
|
||||
{try{
|
||||
|
||||
if ( !File.Exists( Path.Combine( "Saves/Gumps/", "Gumps.bin" ) ) )
|
||||
return;
|
||||
|
||||
using ( FileStream bin = new FileStream( Path.Combine( "Saves/Gumps/", "Gumps.bin" ), FileMode.Open, FileAccess.Read, FileShare.Read ) )
|
||||
{
|
||||
GenericReader reader = new BinaryFileReader( new BinaryReader( bin ) );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if ( version >= 0 )
|
||||
{
|
||||
int count = reader.ReadInt();
|
||||
GumpInfo info;
|
||||
|
||||
for( int i = 0; i < count; ++i )
|
||||
{
|
||||
info = new GumpInfo();
|
||||
info.Load( reader );
|
||||
|
||||
if ( info.Mobile == null || info.Type == null )
|
||||
continue;
|
||||
|
||||
if ( s_Infos[info.Mobile] == null )
|
||||
s_Infos[info.Mobile] = new Hashtable();
|
||||
|
||||
((Hashtable)s_Infos[info.Mobile])[info.Type] = info;
|
||||
}
|
||||
}
|
||||
|
||||
reader.End();
|
||||
}
|
||||
|
||||
}catch{ Errors.Report( "GumpInfo-> OnLoad" ); } }
|
||||
|
||||
public static GumpInfo GetInfo( Mobile m, Type type )
|
||||
{
|
||||
if ( s_Infos[m] == null )
|
||||
s_Infos[m] = new Hashtable();
|
||||
|
||||
Hashtable table = (Hashtable)s_Infos[m];
|
||||
|
||||
if ( table[type] == null )
|
||||
table[type] = new GumpInfo( m, type );
|
||||
|
||||
return (GumpInfo)table[type];
|
||||
}
|
||||
|
||||
public static bool HasMods( Mobile m, Type type )
|
||||
{
|
||||
if ( s_Infos[m] == null )
|
||||
s_Infos[m] = new Hashtable();
|
||||
|
||||
if ( ((Hashtable)s_Infos[m])[type] == null )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private Mobile c_Mobile;
|
||||
private Type c_Type;
|
||||
private bool c_Transparent, c_DefaultTrans;
|
||||
private string c_TextColorRGB;
|
||||
private int c_Background;
|
||||
|
||||
public Mobile Mobile{ get{ return c_Mobile; } }
|
||||
public Type Type{ get{ return c_Type; } }
|
||||
public bool Transparent { get { return c_Transparent; } set { c_Transparent = value; c_DefaultTrans = false; } }
|
||||
public bool DefaultTrans{ get{ return c_DefaultTrans; } set{ c_DefaultTrans = value; } }
|
||||
public string TextColorRGB{ get{ return c_TextColorRGB; } set{ c_TextColorRGB = value; } }
|
||||
public string TextColor{ get{ return String.Format( "<BASEFONT COLOR=#{0}>", c_TextColorRGB ); } }
|
||||
public int Background{ get{ return c_Background; } }
|
||||
|
||||
public GumpInfo()
|
||||
{
|
||||
}
|
||||
|
||||
public GumpInfo( Mobile m, Type type )
|
||||
{
|
||||
c_Mobile = m;
|
||||
c_Type = type;
|
||||
c_TextColorRGB = "";
|
||||
c_Background = -1;
|
||||
c_DefaultTrans = true;
|
||||
}
|
||||
|
||||
public void BackgroundUp()
|
||||
{
|
||||
if (c_Background == -1)
|
||||
{
|
||||
c_Background = (int)s_Backgrounds[0];
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < s_Backgrounds.Count; ++i)
|
||||
if (c_Background == (int)s_Backgrounds[i])
|
||||
{
|
||||
if (i == s_Backgrounds.Count - 1)
|
||||
{
|
||||
c_Background = (int)s_Backgrounds[0];
|
||||
return;
|
||||
}
|
||||
|
||||
c_Background = (int)s_Backgrounds[i + 1];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void BackgroundDown()
|
||||
{
|
||||
if (c_Background == -1)
|
||||
{
|
||||
c_Background = (int)s_Backgrounds[s_Backgrounds.Count - 1];
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < s_Backgrounds.Count; ++i)
|
||||
if (c_Background == (int)s_Backgrounds[i])
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
c_Background = (int)s_Backgrounds[s_Backgrounds.Count - 1];
|
||||
return;
|
||||
}
|
||||
|
||||
c_Background = (int)s_Backgrounds[i - 1];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void TextColorUp()
|
||||
{
|
||||
if (c_TextColorRGB == "")
|
||||
{
|
||||
c_TextColorRGB = s_TextColors[0].ToString();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < s_TextColors.Count; ++i)
|
||||
if (c_TextColorRGB == s_TextColors[i].ToString())
|
||||
{
|
||||
if (i == s_TextColors.Count - 1)
|
||||
{
|
||||
c_TextColorRGB = s_TextColors[0].ToString();
|
||||
return;
|
||||
}
|
||||
|
||||
c_TextColorRGB = s_TextColors[i + 1].ToString();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void TextColorDown()
|
||||
{
|
||||
if (c_TextColorRGB == "")
|
||||
{
|
||||
c_TextColorRGB = s_TextColors[s_TextColors.Count - 1].ToString();
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < s_TextColors.Count; ++i)
|
||||
if (c_TextColorRGB == s_TextColors[i].ToString())
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
c_TextColorRGB = s_TextColors[s_TextColors.Count - 1].ToString();
|
||||
return;
|
||||
}
|
||||
|
||||
c_TextColorRGB = s_TextColors[i - 1].ToString();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void Default()
|
||||
{
|
||||
if (c_Mobile == null || s_Infos[c_Mobile] == null)
|
||||
return;
|
||||
|
||||
((Hashtable)s_Infos[c_Mobile]).Remove(c_Type);
|
||||
}
|
||||
|
||||
private void Save(GenericWriter writer)
|
||||
{try{
|
||||
|
||||
writer.Write( 0 ); // version
|
||||
|
||||
// Version 0
|
||||
writer.Write( c_Mobile );
|
||||
writer.Write( c_Type.ToString() );
|
||||
writer.Write( c_Transparent );
|
||||
writer.Write( c_DefaultTrans );
|
||||
writer.Write( c_TextColorRGB );
|
||||
writer.Write( c_Background );
|
||||
|
||||
}catch{ Errors.Report( "GumpInfo -> Save" ); } }
|
||||
|
||||
private void Load( GenericReader reader )
|
||||
{try{
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if ( version >= 0 )
|
||||
{
|
||||
c_Mobile = reader.ReadMobile();
|
||||
c_Type = ScriptCompiler.FindTypeByFullName( reader.ReadString() );
|
||||
c_Transparent = reader.ReadBool();
|
||||
c_DefaultTrans = reader.ReadBool();
|
||||
c_TextColorRGB = reader.ReadString();
|
||||
c_Background = reader.ReadInt();
|
||||
}
|
||||
|
||||
}catch{ Errors.Report( "GumpInfo -> Load" ); } }
|
||||
}
|
||||
}
|
||||
324
Scripts/SubSystem/Utilities v1.03/Gumps Plus/GumpPlus.cs
Normal file
324
Scripts/SubSystem/Utilities v1.03/Gumps Plus/GumpPlus.cs
Normal file
@@ -0,0 +1,324 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
using Server.Network;
|
||||
|
||||
namespace Knives.Utils
|
||||
{
|
||||
public class GumpPlus : Gump
|
||||
{
|
||||
private Mobile c_Owner;
|
||||
private Hashtable c_Buttons, c_Fields;
|
||||
private bool c_Override;
|
||||
|
||||
public Mobile Owner{ get{ return c_Owner; } }
|
||||
public GumpInfo Info { get { return GumpInfo.GetInfo(c_Owner, this.GetType()); } }
|
||||
public bool Override{ get{ return c_Override; } set{ c_Override = value; } }
|
||||
|
||||
public GumpPlus( Mobile m, int x, int y ) : base( x, y )
|
||||
{
|
||||
c_Owner = m;
|
||||
|
||||
c_Buttons = new Hashtable();
|
||||
c_Fields = new Hashtable();
|
||||
c_Override = true;
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
Entries.Clear();
|
||||
c_Buttons.Clear();
|
||||
c_Fields.Clear();
|
||||
}
|
||||
|
||||
public void NewGump()
|
||||
{
|
||||
NewGump( true );
|
||||
}
|
||||
|
||||
public void NewGump( bool clear )
|
||||
{
|
||||
if ( clear )
|
||||
Clear();
|
||||
|
||||
BuildGump();
|
||||
|
||||
if ( c_Override )
|
||||
ModifyGump();
|
||||
|
||||
c_Owner.SendGump( this );
|
||||
}
|
||||
|
||||
public void SameGump()
|
||||
{
|
||||
c_Owner.SendGump( this );
|
||||
}
|
||||
|
||||
protected virtual void BuildGump()
|
||||
{
|
||||
}
|
||||
|
||||
private void ModifyGump()
|
||||
{try{
|
||||
|
||||
AddPage( 0 );
|
||||
|
||||
int maxWidth = 0;
|
||||
int maxHeight = 0;
|
||||
GumpBackground bg;
|
||||
|
||||
foreach( GumpEntry entry in Entries )
|
||||
if ( entry is GumpBackground )
|
||||
{
|
||||
bg = (GumpBackground)entry;
|
||||
|
||||
if ( bg.X + bg.Width > maxWidth )
|
||||
maxWidth = bg.X + bg.Width;
|
||||
if ( bg.Y + bg.Height > maxHeight )
|
||||
maxHeight = bg.Y + bg.Height;
|
||||
}
|
||||
|
||||
AddImage( maxWidth, maxHeight, 0x28DC, 0x387 );
|
||||
AddButton(maxWidth + 10, maxHeight + 4, 0x93A, 0x93A, "Transparency", new TimerCallback(Trans));
|
||||
AddButton(maxWidth + 10, maxHeight + 15, 0x938, 0x938, "Default", new TimerCallback(Default));
|
||||
AddButton(maxWidth - 5, maxHeight + 2, 0x2626, 0x2627, "BackgroundDown", new TimerCallback(BackDown));
|
||||
AddButton(maxWidth + 19, maxHeight + 2, 0x2622, 0x2623, "BackgroundUp", new TimerCallback(BackUp));
|
||||
AddButton(maxWidth - 5, maxHeight + 13, 0x2626, 0x2627, "TextColorDown", new TimerCallback(TextDown));
|
||||
AddButton(maxWidth + 19, maxHeight + 13, 0x2622, 0x2623, "TextColorUp", new TimerCallback(TextUp));
|
||||
|
||||
if ( !GumpInfo.HasMods( c_Owner, GetType() ) )
|
||||
return;
|
||||
|
||||
ArrayList backs = new ArrayList();
|
||||
|
||||
foreach( GumpEntry entry in new ArrayList( Entries ) )
|
||||
{
|
||||
if ( entry is GumpBackground )
|
||||
{
|
||||
if ( Info.Background != -1 )
|
||||
((GumpBackground)entry).GumpID = Info.Background;
|
||||
|
||||
backs.Add( entry );
|
||||
}
|
||||
else if ( entry is GumpAlphaRegion && !Info.DefaultTrans && !Info.Transparent )
|
||||
{
|
||||
((GumpAlphaRegion)entry).Width = 0;
|
||||
((GumpAlphaRegion)entry).Height = 0;
|
||||
}
|
||||
else if ( entry is HtmlPlus )
|
||||
{
|
||||
if ( !((HtmlPlus)entry).Override || Info.TextColorRGB == "" )
|
||||
continue;
|
||||
|
||||
string text = ((HtmlPlus)entry).Text;
|
||||
int num = 0;
|
||||
int length = 0;
|
||||
char[] chars;
|
||||
|
||||
if ( text == null )
|
||||
continue;
|
||||
|
||||
while( (num = text.ToLower().IndexOf( "<basefont" )) != -1 || (num = text.ToLower().IndexOf( "</font" )) != -1 )
|
||||
{
|
||||
length = 0;
|
||||
chars = text.ToCharArray();
|
||||
|
||||
for( int i = num; i < chars.Length; ++i )
|
||||
if ( chars[i] == '>' )
|
||||
{
|
||||
length = i-num+1;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( length == 0 )
|
||||
break;
|
||||
|
||||
text = text.Substring( 0, num ) + text.Substring( num+length, text.Length-num-length );
|
||||
}
|
||||
|
||||
((HtmlPlus)entry).Text = Info.TextColor + text;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !Info.DefaultTrans && Info.Transparent )
|
||||
foreach( GumpBackground back in backs )
|
||||
AddAlphaRegion( back.X, back.Y, back.Width, back.Height );
|
||||
|
||||
SortEntries();
|
||||
|
||||
}catch{ Errors.Report( "GumpPlus-> ModifyGump-> " + GetType() ); } }
|
||||
|
||||
private void SortEntries()
|
||||
{
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
foreach( GumpEntry entry in new ArrayList( Entries ) )
|
||||
if ( entry is GumpBackground )
|
||||
{
|
||||
list.Add( entry );
|
||||
Entries.Remove( entry );
|
||||
}
|
||||
|
||||
foreach( GumpEntry entry in new ArrayList( Entries ) )
|
||||
if ( entry is GumpAlphaRegion )
|
||||
{
|
||||
list.Add( entry );
|
||||
Entries.Remove( entry );
|
||||
}
|
||||
|
||||
list.AddRange( Entries );
|
||||
|
||||
Entries.Clear();
|
||||
|
||||
foreach (GumpEntry entry in list)
|
||||
Entries.Add(entry);
|
||||
//Entries.AddRange( list );
|
||||
}
|
||||
|
||||
private int UniqueButton()
|
||||
{
|
||||
int random = 0;
|
||||
|
||||
do
|
||||
{
|
||||
random = Utility.Random( 20000 );
|
||||
|
||||
}while( c_Buttons[random] != null );
|
||||
|
||||
return random;
|
||||
}
|
||||
|
||||
public void AddButton( int x, int y, int up, int down, TimerCallback callback )
|
||||
{
|
||||
AddButton( x, y, up, down, "None", callback );
|
||||
}
|
||||
|
||||
public void AddButton( int x, int y, int up, int down, string name, TimerCallback callback )
|
||||
{
|
||||
int id = UniqueButton();
|
||||
|
||||
ButtonPlus button = new ButtonPlus( x, y, up, down, id, name, callback );
|
||||
|
||||
Add( button );
|
||||
|
||||
c_Buttons[id] = button;
|
||||
}
|
||||
|
||||
public void AddButton( int x, int y, int up, int down, TimerStateCallback callback, object arg )
|
||||
{
|
||||
AddButton( x, y, up, down, "None", callback, arg );
|
||||
}
|
||||
|
||||
public void AddButton( int x, int y, int up, int down, string name, TimerStateCallback callback, object arg )
|
||||
{
|
||||
int id = UniqueButton();
|
||||
|
||||
ButtonPlus button = new ButtonPlus( x, y, up, down, id, name, callback, arg );
|
||||
|
||||
Add( button );
|
||||
|
||||
c_Buttons[id] = button;
|
||||
}
|
||||
|
||||
public new void AddHtml( int x, int y, int width, int height, string text, bool back, bool scroll )
|
||||
{
|
||||
AddHtml( x, y, width, height, text, back, scroll, true );
|
||||
}
|
||||
|
||||
public void AddHtml( int x, int y, int width, int height, string text, bool back, bool scroll, bool over )
|
||||
{
|
||||
HtmlPlus html = new HtmlPlus( x, y, width, height, text, back, scroll, over );
|
||||
|
||||
Add( html );
|
||||
}
|
||||
|
||||
public void AddTextField( int x, int y, int width, int height, int color, int id, string text )
|
||||
{
|
||||
base.AddTextEntry( x, y, width, height, color, id, text );
|
||||
|
||||
c_Fields[id] = text;
|
||||
}
|
||||
|
||||
public string GetTextField( int id )
|
||||
{
|
||||
if ( c_Fields[id] == null )
|
||||
return "";
|
||||
|
||||
return c_Fields[id].ToString();
|
||||
}
|
||||
|
||||
protected virtual void OnClose()
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnResponse( NetState state, RelayInfo info )
|
||||
{
|
||||
string name = "";
|
||||
|
||||
try{
|
||||
|
||||
if ( info.ButtonID == -5 )
|
||||
{
|
||||
NewGump();
|
||||
return;
|
||||
}
|
||||
|
||||
foreach( TextRelay t in info.TextEntries )
|
||||
c_Fields[t.EntryID] = t.Text;
|
||||
|
||||
if ( info.ButtonID == 0 )
|
||||
OnClose();
|
||||
|
||||
if ( c_Buttons[info.ButtonID] == null || !(c_Buttons[info.ButtonID] is ButtonPlus) )
|
||||
return;
|
||||
|
||||
name = ((ButtonPlus)c_Buttons[info.ButtonID]).Name;
|
||||
|
||||
((ButtonPlus)c_Buttons[info.ButtonID]).Invoke();
|
||||
|
||||
}catch{ Errors.Report( String.Format( "GumpPlus-> OnResponse-> |{0}|-> {1}-> {2}", c_Owner, GetType(), name ) ); } }
|
||||
|
||||
private void Trans()
|
||||
{
|
||||
Info.Transparent = !Info.Transparent;
|
||||
|
||||
NewGump();
|
||||
}
|
||||
|
||||
private void BackUp()
|
||||
{
|
||||
Info.BackgroundUp();
|
||||
|
||||
NewGump();
|
||||
}
|
||||
|
||||
private void BackDown()
|
||||
{
|
||||
Info.BackgroundDown();
|
||||
|
||||
NewGump();
|
||||
}
|
||||
|
||||
private void TextUp()
|
||||
{
|
||||
Info.TextColorUp();
|
||||
|
||||
NewGump();
|
||||
}
|
||||
|
||||
private void TextDown()
|
||||
{
|
||||
Info.TextColorDown();
|
||||
|
||||
NewGump();
|
||||
}
|
||||
|
||||
private void Default()
|
||||
{
|
||||
Info.Default();
|
||||
|
||||
NewGump();
|
||||
}
|
||||
}
|
||||
}
|
||||
20
Scripts/SubSystem/Utilities v1.03/Gumps Plus/HTML.cs
Normal file
20
Scripts/SubSystem/Utilities v1.03/Gumps Plus/HTML.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using Server;
|
||||
|
||||
namespace Knives.Utils
|
||||
{
|
||||
public class HTML
|
||||
{
|
||||
public static string White{ get { return "<BASEFONT COLOR=#FFFFFF>"; } }
|
||||
public static string Red{ get { return "<BASEFONT COLOR=#FF0000>"; } }
|
||||
public static string AshRed{ get { return "<BASEFONT COLOR=#FF9999>"; } }
|
||||
public static string Green{ get { return "<BASEFONT COLOR=#00FF00>"; } }
|
||||
public static string Blue{ get { return "<BASEFONT COLOR=#0000FF>"; } }
|
||||
public static string Gray{ get { return "<BASEFONT COLOR=#999999>"; } }
|
||||
public static string DarkGray{ get { return "<BASEFONT COLOR=#222222>"; } }
|
||||
public static string Black{ get { return "<BASEFONT COLOR=#111111>"; } }
|
||||
public static string Yellow{ get { return "<BASEFONT COLOR=#FFFF00>"; } }
|
||||
public static string Purple{ get { return "<BASEFONT COLOR=#990099>"; } }
|
||||
public static string LightPurple{ get { return "<BASEFONT COLOR=#CC00FF>"; } }
|
||||
}
|
||||
}
|
||||
23
Scripts/SubSystem/Utilities v1.03/Gumps Plus/HtmlPlus.cs
Normal file
23
Scripts/SubSystem/Utilities v1.03/Gumps Plus/HtmlPlus.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Knives.Utils
|
||||
{
|
||||
public class HtmlPlus : GumpHtml
|
||||
{
|
||||
private bool c_Override;
|
||||
|
||||
public bool Override{ get{ return c_Override; } set{ c_Override = value; } }
|
||||
|
||||
public HtmlPlus( int x, int y, int width, int height, string text, bool back, bool scroll ) : base( x, y, width, height, text, back, scroll )
|
||||
{
|
||||
c_Override = true;
|
||||
}
|
||||
|
||||
public HtmlPlus( int x, int y, int width, int height, string text, bool back, bool scroll, bool over ) : base( x, y, width, height, text, back, scroll )
|
||||
{
|
||||
c_Override = over;
|
||||
}
|
||||
}
|
||||
}
|
||||
35
Scripts/SubSystem/Utilities v1.03/Gumps Plus/InfoGump.cs
Normal file
35
Scripts/SubSystem/Utilities v1.03/Gumps Plus/InfoGump.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Knives.Utils
|
||||
{
|
||||
public class InfoGump : GumpPlus
|
||||
{
|
||||
public static void SendTo( Mobile m, int width, int height, string text, bool scroll )
|
||||
{
|
||||
new InfoGump( m, width, height, text, scroll );
|
||||
}
|
||||
|
||||
private int c_Width, c_Height;
|
||||
private string c_Text;
|
||||
private bool c_Scroll;
|
||||
|
||||
public InfoGump( Mobile m, int width, int height, string text, bool scroll ) : base( m, 100, 100 )
|
||||
{
|
||||
c_Width = width;
|
||||
c_Height = height;
|
||||
c_Text= text;
|
||||
c_Scroll = scroll;
|
||||
|
||||
NewGump();
|
||||
}
|
||||
|
||||
protected override void BuildGump()
|
||||
{
|
||||
AddBackground( 0, 0, c_Width, c_Height, 0x13BE );
|
||||
|
||||
AddHtml( 20, 20, c_Width-40, c_Height-40, HTML.White + c_Text, false, c_Scroll );
|
||||
}
|
||||
}
|
||||
}
|
||||
52
Scripts/SubSystem/Utilities v1.03/Gumps Plus/ResponseGump.cs
Normal file
52
Scripts/SubSystem/Utilities v1.03/Gumps Plus/ResponseGump.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using Server;
|
||||
using Server.Gumps;
|
||||
|
||||
namespace Knives.Utils
|
||||
{
|
||||
public class ResponseGump : GumpPlus
|
||||
{
|
||||
public static void SendTo( Mobile m, int width, int height, string text, string title, TimerStateCallback callback )
|
||||
{
|
||||
new ResponseGump( m, width, height, text, title, callback );
|
||||
}
|
||||
|
||||
private int c_Width, c_Height;
|
||||
private string c_Text, c_Title;
|
||||
private TimerStateCallback c_Callback;
|
||||
|
||||
public ResponseGump( Mobile m, int width, int height, string text, string title, TimerStateCallback callback ) : base( m, 100, 100 )
|
||||
{
|
||||
c_Width = width;
|
||||
c_Height = height;
|
||||
c_Text = text;
|
||||
c_Title = title;
|
||||
c_Callback = callback;
|
||||
|
||||
NewGump();
|
||||
}
|
||||
|
||||
protected override void BuildGump()
|
||||
{
|
||||
AddBackground( 0, 0, c_Width, c_Height, 0x13BE );
|
||||
|
||||
AddHtml( 0, 10, c_Width, 25, HTML.White + "<CENTER>" + c_Title, false, false );
|
||||
|
||||
AddImageTiled( 20, 40, c_Width-40, c_Height-90, 0xBBC );
|
||||
AddTextField( 20, 40, c_Width-40, c_Height-90, 0x480, 0, c_Text );
|
||||
|
||||
AddButton( c_Width/2-30, c_Height-35, 0x98B, 0x98B, "Respond", new TimerCallback( Respond ) );
|
||||
AddHtml( c_Width/2-23, c_Height-32, 51, 20, HTML.White + "<CENTER>Submit", false, false );
|
||||
}
|
||||
|
||||
private void Respond()
|
||||
{
|
||||
c_Callback.Invoke( GetTextField( 0 ) );
|
||||
}
|
||||
|
||||
protected override void OnClose()
|
||||
{
|
||||
c_Callback.Invoke( c_Text );
|
||||
}
|
||||
}
|
||||
}
|
||||
121
Scripts/SubSystem/Utilities v1.03/LinkedBags.cs
Normal file
121
Scripts/SubSystem/Utilities v1.03/LinkedBags.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using Server.Items;
|
||||
using Server.Multis;
|
||||
using Server.Mobiles;
|
||||
using Server.Network;
|
||||
|
||||
namespace Server.Custom
|
||||
{
|
||||
public class LinkedBag : Bag
|
||||
{
|
||||
private LinkedBag mate;
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public LinkedBag Mate { get { return mate; } set { mate = value; } }
|
||||
|
||||
[Constructable]
|
||||
public LinkedBag()
|
||||
: base()
|
||||
{
|
||||
Name = "Linked Bag";
|
||||
Weight = 2.0;
|
||||
}
|
||||
|
||||
public LinkedBag(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override bool OnDragDrop(Mobile from, Item dropped)
|
||||
{
|
||||
return OnDragDropInto(from, dropped, new Point3D(20, 100, 0));
|
||||
}
|
||||
|
||||
public override bool OnDragDropInto(Mobile from, Item item, Point3D p)
|
||||
{
|
||||
if (item is LinkedBag) return false;
|
||||
if (mate == null) return base.OnDragDropInto(from, item, p);
|
||||
if (!mate.CheckHold(from, item, true, true))
|
||||
return false;
|
||||
try
|
||||
{
|
||||
mate.DropItem(item);
|
||||
}
|
||||
catch
|
||||
{
|
||||
from.SendMessage("Unable to do that.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
|
||||
writer.Write(mate);
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
mate = reader.ReadItem() as LinkedBag;
|
||||
}
|
||||
}
|
||||
|
||||
public class LinkedBagsBag : Bag
|
||||
{
|
||||
public override string DefaultName
|
||||
{
|
||||
get { return "a Bag of Linked Bags"; }
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public LinkedBagsBag()
|
||||
: base()
|
||||
{
|
||||
Movable = true;
|
||||
Hue = Utility.RandomBlueHue();
|
||||
}
|
||||
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
if (Items.Count == 0 && from.AccessLevel >= AccessLevel.Counselor)
|
||||
{
|
||||
LinkedBag bagA = new LinkedBag();
|
||||
LinkedBag bagB = new LinkedBag();
|
||||
bagA.Mate = bagB;
|
||||
bagB.Mate = bagA;
|
||||
bagA.Name = string.Format("{0}'s Linked Bag", from.Name);
|
||||
bagB.Name = string.Format("{0}'s Linked Bag", from.Name);
|
||||
DropItem(bagA);
|
||||
DropItem(bagB);
|
||||
}
|
||||
base.OnDoubleClick(from);
|
||||
}
|
||||
|
||||
public LinkedBagsBag(Serial serial)
|
||||
: base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write((int)0); // version
|
||||
}
|
||||
|
||||
public override void Deserialize(GenericReader reader)
|
||||
{
|
||||
base.Deserialize(reader);
|
||||
|
||||
int version = reader.ReadInt();
|
||||
}
|
||||
}
|
||||
}
|
||||
148
Scripts/SubSystem/Utilities v1.03/TrashPack.cs
Normal file
148
Scripts/SubSystem/Utilities v1.03/TrashPack.cs
Normal file
@@ -0,0 +1,148 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Server.Multis;
|
||||
|
||||
namespace Server.Items
|
||||
{
|
||||
public class TrashPack : Container
|
||||
{
|
||||
|
||||
public override int MaxWeight{ get{ return 0; } } // A value of 0 signals unlimited weight
|
||||
|
||||
public override int DefaultGumpID{ get{ return 0x3C; } }
|
||||
public override int DefaultDropSound{ get{ return 0x42; } }
|
||||
|
||||
public override Rectangle2D Bounds
|
||||
{
|
||||
get{ return new Rectangle2D( 44, 65, 142, 94 ); }
|
||||
}
|
||||
|
||||
public override bool IsDecoContainer
|
||||
{
|
||||
get{ return false; }
|
||||
}
|
||||
|
||||
[Constructable]
|
||||
public TrashPack() : base( 0x9B2 )
|
||||
{
|
||||
Name = "Trash Bag";
|
||||
Hue = 1593;
|
||||
Movable = true;
|
||||
}
|
||||
|
||||
public TrashPack( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
|
||||
writer.Write( (int) 0 ); // version
|
||||
}
|
||||
|
||||
public override void Deserialize( GenericReader reader )
|
||||
{
|
||||
base.Deserialize( reader );
|
||||
|
||||
int version = reader.ReadInt();
|
||||
|
||||
if ( Items.Count > 0 )
|
||||
{
|
||||
m_Timer = new EmptyTimer( this );
|
||||
m_Timer.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool OnDragDrop( Mobile from, Item dropped )
|
||||
{
|
||||
if ( !base.OnDragDrop( from, dropped ) )
|
||||
return false;
|
||||
|
||||
if ( TotalItems >= 10 )
|
||||
{
|
||||
Empty( 501478 ); // The trash is full! Emptying!
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage( "Items will delete in 30 seconds!" ); // The item will be deleted in three minutes
|
||||
|
||||
if ( m_Timer != null )
|
||||
m_Timer.Stop();
|
||||
else
|
||||
m_Timer = new EmptyTimer( this );
|
||||
|
||||
m_Timer.Start();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool OnDragDropInto( Mobile from, Item item, Point3D p )
|
||||
{
|
||||
if ( !base.OnDragDropInto( from, item, p ) )
|
||||
return false;
|
||||
|
||||
if ( TotalItems >= 10 )
|
||||
{
|
||||
Empty( 501478 ); // The trash is full! Emptying!
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendMessage( "Items will delete in 30 sconds!" ); // The item will be deleted in three minutes
|
||||
|
||||
if ( m_Timer != null )
|
||||
m_Timer.Stop();
|
||||
else
|
||||
m_Timer = new EmptyTimer( this );
|
||||
|
||||
m_Timer.Start();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public void Empty( int message )
|
||||
{
|
||||
List<Item> items = this.Items;
|
||||
|
||||
if ( items.Count > 0 )
|
||||
{
|
||||
PublicOverheadMessage( Network.MessageType.Regular, 0x3B2, message, "Trash Pack has been emptied" );
|
||||
|
||||
for ( int i = items.Count - 1; i >= 0; --i )
|
||||
{
|
||||
if ( i >= items.Count )
|
||||
continue;
|
||||
|
||||
items[i].Delete();
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_Timer != null )
|
||||
m_Timer.Stop();
|
||||
|
||||
m_Timer = null;
|
||||
}
|
||||
|
||||
private Timer m_Timer;
|
||||
|
||||
private class EmptyTimer : Timer
|
||||
{
|
||||
private TrashPack m_Pack;
|
||||
|
||||
public EmptyTimer( TrashPack pack ) : base( TimeSpan.FromMinutes( .5 ) )
|
||||
{
|
||||
m_Pack = pack;
|
||||
Priority = TimerPriority.FiveSeconds;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
m_Pack.Empty( 501479 ); // Trashcan Empty!
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user