using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.IO;
using Server;
using Server.Mobiles;
using Server.Regions;
using Server.Gumps;
using Server.Network;
using Server.Spells;
namespace Server.AutoPVP
{
public class AutoPVP_AdminRestrictionsUI : Gump
{
public enum Buttons
{
Null = 0,
PreviousSkills = 1,
NextSkills = 2,
PreviousSpells = 3,
NextSpells = 4
}
private PlayerMobile _User = null;
private AutoPVP_AdminBattlesUI _BattleUI = null;
private AutoPVP_Battle _Battle = null;
private int
_SkillsPerPage = 9,
_SkillYSpacer = 35,
_SkillsPage = 0,
_SpellsPerPage = 9,
_SpellsYSpacer = 35,
_SpellsPage = 0,
_FontHue = 84,
_ErrorHue = 237,
_IndexBase = 10000,
_SkillsLength = 0,
_SpellsLength = 0;
public AutoPVP_AdminRestrictionsUI(PlayerMobile user, AutoPVP_AdminBattlesUI battlesUI, AutoPVP_Battle battle)
: this(user, battlesUI, battle, 0, 0)
{ }
public AutoPVP_AdminRestrictionsUI(PlayerMobile user, AutoPVP_AdminBattlesUI battlesUI, AutoPVP_Battle battle, int skillPage, int spellPage)
: base(0, 0)
{
if (user == null || battlesUI == null || battle == null)
{ return; }
_User = user;
_BattleUI = battlesUI;
_Battle = battle;
if (skillPage < 0)
{ skillPage = 0; }
_SkillsPage = skillPage;
if (spellPage < 0)
{ spellPage = 0; }
_SpellsPage = spellPage;
this.Closable = true;
this.Disposable = true;
this.Dragable = true;
this.Resizable = false;
AddPage(0);
AddBackground(75, 75, 300, 50, 9270);
AddLabel(95, 90, _FontHue, AutoPVP_System.GetMessage(_User, 542));
AddBackground(75, 125, 300, 345, 9270);
BuildSkillsList();
if (_SkillsPage > 0)
{ AddButton(180, 460, 2468, 2467, (int)Buttons.PreviousSkills, GumpButtonType.Reply, 0); }
else
{ AddImage(180, 460, 2468, _ErrorHue); }
if (_SkillsPage + 1 < (int)Math.Ceiling((double)_SkillsLength / _SkillsPerPage))
{ AddButton(265, 460, 2471, 2470, (int)Buttons.NextSkills, GumpButtonType.Reply, 0); }
else
{ AddImage(265, 460, 2471, _ErrorHue); }
AddBackground(375, 75, 300, 50, 9270);
AddLabel(395, 90, _FontHue, AutoPVP_System.GetMessage(_User, 543));
AddBackground(375, 125, 300, 345, 9270);
BuildSpellsList();
if (_SpellsPage > 0)
{ AddButton(480, 460, 2468, 2467, (int)Buttons.PreviousSpells, GumpButtonType.Reply, 0); }
else
{ AddImage(480, 460, 2468, _ErrorHue); }
if (_SpellsPage + 1 < (int)Math.Ceiling((double)_SpellsLength / _SpellsPerPage))
{ AddButton(565, 460, 2471, 2470, (int)Buttons.NextSpells, GumpButtonType.Reply, 0); }
else
{ AddImage(565, 460, 2471, _ErrorHue); }
}
private void BuildSkillsList()
{
int count = SkillInfo.Table.Length;
for (int i = 0, index = _SkillsPage * _SkillsPerPage; i < _SkillsPerPage && index < count; i++, index++)
{
int yPos = 145 + (i * _SkillYSpacer);
SkillName skill = (SkillName)index;
bool restricted1 = _Battle.AdvancedOptions.PreparingRules.IsRestricted(skill);
bool restricted2 = _Battle.AdvancedOptions.GameRules.IsRestricted(skill);
AddCheck(100, yPos, 2152, 2154, restricted1, (_IndexBase * 2) + (int)skill);
AddCheck(140, yPos, 2152, 2154, restricted2, (_IndexBase * 3) + (int)skill);
AddLabel(180, yPos + 5, _FontHue, skill.ToString());
_SkillsLength++;
}
}
private void BuildSpellsList()
{
for (int i = 0, index = _SpellsPage * _SpellsPerPage; i < _SpellsPerPage && index < SpellRegistry.Types.Length; i++, index++)
{
Spell spell;
try { spell = SpellRegistry.NewSpell(index, null, null); }
catch
{
i--;
continue;
}
if (spell == null)
{
i--;
continue;
}
int yPos = 145 + (i * _SpellsYSpacer);
bool restricted1 = _Battle.AdvancedOptions.PreparingRules.IsRestricted(spell);
bool restricted2 = _Battle.AdvancedOptions.GameRules.IsRestricted(spell);
AddCheck(400, yPos, 2152, 2154, restricted1, (_IndexBase * 4) + index);
AddCheck(440, yPos, 2152, 2154, restricted2, (_IndexBase * 5) + index);
AddLabel(480, yPos + 5, _FontHue, spell.Name);
_SpellsLength++;
}
}
public void Close()
{ Close(true); }
public void Close(bool all)
{
if (_User.HasGump(typeof(AutoPVP_AdminRestrictionsUI)))
{ _User.CloseGump(typeof(AutoPVP_AdminRestrictionsUI)); }
if (!all)
{ _BattleUI.ResendGump(); }
}
public void ResendGump(int skillPage, int spellPage)
{
if (_User.HasGump(typeof(AutoPVP_AdminRestrictionsUI)))
{ _User.CloseGump(typeof(AutoPVP_AdminRestrictionsUI)); }
_User.SendGump(new AutoPVP_AdminRestrictionsUI(_User, _BattleUI, _Battle, skillPage, spellPage));
}
public override void OnResponse(NetState sender, RelayInfo info)
{
for (int i = 0, index = _SkillsPage * _SkillsPerPage; i < _SpellsPerPage && index < SkillInfo.Table.Length; i++, index++)
{
int switchID1 = (_IndexBase * 2) + index, switchID2 = (_IndexBase * 3) + index;
_Battle.AdvancedOptions.PreparingRules.SkillRestrictions[index] = info.IsSwitched(switchID1);
_Battle.AdvancedOptions.GameRules.SkillRestrictions[index] = info.IsSwitched(switchID2);
}
for (int i = 0, index = _SpellsPage * _SpellsPerPage; i < _SpellsPerPage && index < SpellRegistry.Types.Length; i++, index++)
{
int switchID1 = (_IndexBase * 4) + index, switchID2 = (_IndexBase * 5) + index;
_Battle.AdvancedOptions.PreparingRules.SpellRestrictions[index] = info.IsSwitched(switchID1);
_Battle.AdvancedOptions.GameRules.SpellRestrictions[index] = info.IsSwitched(switchID2);
}
Mobile from = sender.Mobile;
int bid = info.ButtonID;
switch (bid)
{
default:
case (int)Buttons.Null: { Close(false); } break;
case (int)Buttons.PreviousSkills: { ResendGump(_SkillsPage - 1, _SpellsPage); } break;
case (int)Buttons.NextSkills: { ResendGump(_SkillsPage + 1, _SpellsPage); } break;
case (int)Buttons.PreviousSpells: { ResendGump(_SkillsPage, _SpellsPage - 1); } break;
case (int)Buttons.NextSpells: { ResendGump(_SkillsPage, _SpellsPage + 1); } break;
}
}
}
}