using System;
using Server;
using Server.Gumps;
using Server.Network;
using Server.Mobiles;
using Server.Commands;
public class MacroGump : Gump
{
private Mobile badBoy;
MGResponseTimer myTimer;
int tbutton = 2;
private static int StartX = Utility.Random( 10, 100 );
private static int StartY = Utility.Random( 10, 70 );
public MacroGump( Mobile m ) : base( StartX, StartY )
{
tbutton = Utility.Random( 1, 6 );
badBoy = m;
string Answer1 = "Я тута и нет у меня никакого макроса!";
string Answer2 = "Я на макросе и клал болт на ваши проверки!";
int TextColor1 = Utility.Random( 2, 1000 );
int TextColor2 = Utility.Random( 2, 1000 );
int TextColor3 = Utility.Random( 2, 1000 );
int Gump1 = Utility.Random( 23000, 15 );
int Gump2 = Utility.Random( 23000, 15 );
int Gump3 = Utility.Random( 23000, 15 );
int Gump4 = Utility.Random( 23000, 15 );
Closable = false;
Dragable = true;
AddPage( 0 );
AddBackground( 0, 0, 420, 320, 5054 );
AddImageTiled( 9, 65, 200, 120, Gump1 );
AddImageTiled( 209, 185, 200, 120, Gump2 );
AddImageTiled( 209, 65, 200, 120, Gump3 );
AddImageTiled( 9, 185, 200, 120, Gump4 );
//AddAlphaRegion( 9, 65, 400, 240 );
AddHtml( 16, 10, 410, 50, @"Это окно проверки на макрос. Если Вы не используете макрос подтвердите своё присутствие.", false, false );
AddButton( 20, 72, 2472, 2473, 5, GumpButtonType.Reply, 0 );
AddLabel( 50, 75, TextColor2, tbutton == 5 ? Answer1 : Answer2 );
AddButton( 20, 112, 2472, 2473, 1, GumpButtonType.Reply, 0 );
AddLabel( 50, 115, TextColor1, tbutton == 1 ? Answer1 : Answer2 );
AddButton( 20, 152, 2472, 2473, 2, GumpButtonType.Reply, 0 );
AddLabel( 50, 155, TextColor3, tbutton == 2 ? Answer1 : Answer2 );
AddButton( 20, 192, 2472, 2473, 3, GumpButtonType.Reply, 0 );
AddLabel( 50, 195, TextColor3, tbutton == 3 ? Answer1 : Answer2 );
AddButton( 20, 232, 2472, 2473, 4, GumpButtonType.Reply, 0 );
AddLabel( 50, 235, TextColor2, tbutton == 4 ? Answer1 : Answer2 );
AddButton( 20, 272, 2472, 2473, 6, GumpButtonType.Reply, 0 );
AddLabel( 50, 275, TextColor1, tbutton == 6 ? Answer1 : Answer2 );
myTimer = new MGResponseTimer( badBoy );
}
public override void OnResponse( NetState state, RelayInfo info )
{
Mobile m = state.Mobile;
if ( myTimer != null )
myTimer.Stop();
if( tbutton == info.ButtonID )
{
( ( PlayerMobile )m ).MacroUses = -100;
m.SendMessage( 0x59, "Спасибо. Извините за неудобства. Удачной игры." );
}
else
{
if ( state != null )
state.Dispose();
}
}
public class MGResponseTimer : Timer
{
private Mobile BadBoy;
public MGResponseTimer( Mobile m ) : base( TimeSpan.FromMinutes(2), TimeSpan.FromMinutes(2) )
{
BadBoy = m;
this.Start();
}
protected override void OnTick()
{
this.Stop();
if ( !BadBoy.Deleted && BadBoy.NetState != null )
BadBoy.NetState.Dispose();
}
}
public string Color( string text, int color )
{
return String.Format( "<BASEFONT COLOR=#{0:X6}>{1}</BASEFONT>", color, text );
}
}