<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">

	<Script file="localization.lua"/>
	<Script file="localization.deDE.lua"/>
	<Script file="localization.frFR.lua"/>
	<Script file="localization.esES.lua"/>
	<Script file="localization.zhCN.lua"/>
	<Script file="localization.zhTW.lua"/>
	<Script file="localization.koKR.lua"/>
	<Script file="localization.ruRU.lua"/>
	<Script file="XPerl_Globals.lua"/>
	<Script file="XPerl_Init.lua"/>
	<Script file="XPerl_Voice.lua"/>
	<Script file="XPerl_Slash.lua"/>

	<Button name="XPerl_BasicButton" virtual="true">
		<Scripts>
			<OnEnter>
				if (this.tooltipText) then
					local str1 = getglobal(this.tooltipText)
					local str2
					if (not str1) then
						str1 = getglobal(this.tooltipText.."1")
						str2 = getglobal(this.tooltipText.."2")
					end
					if (not str1) then
						str1 = this.tooltipText
						str2 = nil
					end

					GameTooltip:SetOwner(this, "ANCHOR_RIGHT")

					if (str2) then
						GameTooltip:SetText(str1, HIGHLIGHT_FONT_COLOR.r, HIGHLIGHT_FONT_COLOR.g, HIGHLIGHT_FONT_COLOR.b)
						GameTooltip:AddLine(str2, NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b, 1)
						GameTooltip:Show()
					else
						GameTooltip:SetText(str1, nil, nil, nil, nil, 1)
					end
				end
			</OnEnter>
			<OnLeave>
				GameTooltip:Hide()
			</OnLeave>
		</Scripts>
		<NormalFont inherits="GameFontHighlightSmall"/>
		<HighlightFont inherits="GameFontHighlightSmall"/>
		<DisabledFont inherits="GameFontDisableSmall"/>
	</Button>

	<Frame name="XPerl_Globals">
		<Scripts>
			<OnLoad>
				self:RegisterEvent("ADDON_LOADED")
				self:RegisterEvent("VARIABLES_LOADED")
				self:RegisterEvent("PLAYER_REGEN_ENABLED")
				self:RegisterEvent("UNIT_SPELLCAST_SENT")
				self:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED")
				self:RegisterEvent("UNIT_SPELLCAST_START")
				--self:RegisterEvent("ADDON_ACTION_BLOCKED")
				self:RegisterEvent("PLAYER_ENTERING_WORLD")
				self:SetScript("OnEvent", XPerl_Globals_OnEvent)
			</OnLoad>
		</Scripts>
	</Frame>

	<Frame name="XPerl_BorderStyleTemplate" virtual="true">
		<Backdrop bgFile="Interface\Addons\XPerl\Images\XPerl_FrameBack" edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true">
			<EdgeSize>
				<AbsValue val="16"/>
			</EdgeSize>
			<TileSize>
				<AbsValue val="32"/>
			</TileSize>
			<BackgroundInsets>
				<AbsInset left="4" right="4" top="4" bottom="4"/>
			</BackgroundInsets>
		</Backdrop>
	</Frame>

	<Frame name="XPerl_Portrait_Template" inherits="XPerl_BorderStyleTemplate" virtual="true">
		<Size>
			<AbsDimension x="60" y="62"/>
		</Size>
		<Frames>
			<PlayerModel name="$parentportrait3D">
				<Size>
					<AbsDimension x="51" y="52"/>
				</Size>
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset><AbsDimension x="5" y="-5"/></Offset>
					</Anchor>
					<Anchor point="BOTTOMRIGHT">
						<Offset><AbsDimension x="-5" y="5"/></Offset>
					</Anchor>
				</Anchors>
			</PlayerModel>
		</Frames>
		<Layers>
			<Layer level="ARTWORK">
				<Texture name="$parentportrait" hidden="true">
					<Size><AbsDimension x="50" y="50"/></Size>
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset><AbsDimension x="6" y="-5"/></Offset>
						</Anchor>
						<Anchor point="BOTTOMRIGHT">
							<Offset><AbsDimension x="-4" y="4"/></Offset>
						</Anchor>
					</Anchors>
				</Texture>
			</Layer>
		</Layers>
		<Scripts>
			<OnLoad>
				XPerl_SetChildMembers(self)
			</OnLoad>
		</Scripts>
	</Frame>

	<StatusBar name="XPerlStatusBar" virtual="true">
		<BarTexture name="$parenttex" file="Interface\TargetingFrame\UI-StatusBar"/>
		<Layers>
			<!-- Text -->
			<Layer level="OVERLAY">
				<FontString name="$parenttext" inherits="GameFontNormalSmall">
					<Anchors>
						<Anchor point="TOPLEFT"/>
						<Anchor point="BOTTOMRIGHT">
							<Offset>
								<AbsDimension x="0" y="1"/>
							</Offset>
						</Anchor>
					</Anchors>
					<Color r="1" g="1" b="1"/>
				</FontString>
				<FontString name="$parentpercent" inherits="GameFontNormalSmall" justifyH="LEFT" hidden="true">
					<Size>
						<AbsDimension x="50" y="12"/>
					</Size>
					<Anchors>
						<Anchor point="LEFT" relativePoint="RIGHT">
							<Offset>
								<AbsDimension x="0" y="1"/>
							</Offset>
						</Anchor>
					</Anchors>
					<Color r="1" g="1" b="1"/>
				</FontString>
			</Layer>
			<Layer level="BORDER">
				<Texture name="$parentbg" file="Interface\TargetingFrame\UI-TargetingFrame-BarFill" setAllPoints="true"/>
			</Layer>
		</Layers>
		<Scripts>
			<OnLoad>
				XPerl_SetChildMembers(self)
				XPerl_RegisterBar(self)
				self:SetScript("OnLoad", nil)
				if (not XPerl_OldStatusBarSetValue) then
					XPerl_OldStatusBarSetValue = self.SetValue
				end
				self.SetValue = XPerl_StatusBarSetValue
				XPerl_RegisterUnitText(self.text)
				XPerl_RegisterUnitText(self.percent)
			</OnLoad>
		</Scripts>
	</StatusBar>

	<!-- Stats Template -->
	<Frame name="XPerl_Stats_Template" inherits="XPerl_BorderStyleTemplate" virtual="true">
		<Size>
			<AbsDimension x="160" y="40"/>
		</Size>
		<Frames>
			<!-- Health Bar -->
			<StatusBar name="$parenthealthBar" drawLayer="BACKGROUND" inherits="XPerlStatusBar">
				<Size>
					<AbsDimension x="112" y="10"/>
				</Size>
				<Anchors>
					<Anchor point="TOPLEFT" relativePoint="TOPLEFT">
						<Offset>
							<AbsDimension x="8" y="-9"/>
						</Offset>
					</Anchor>
				</Anchors>
				<BarColor r="0" g="0.8" b="0"/>
			</StatusBar>

			<StatusBar name="$parentexpectedHealth" drawLayer="OVERLAY" hidden="true">
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="$parenthealthBar">
						<Offset>
							<AbsDimension x="0" y="-2"/>
						</Offset>
					</Anchor>
					<Anchor point="BOTTOMRIGHT" relativeTo="$parenthealthBar">
						<Offset>
							<AbsDimension x="0" y="2"/>
						</Offset>
					</Anchor>
				</Anchors>
				<BarTexture name="$parenttex" file="Interface\TargetingFrame\UI-StatusBar"/>
				<BarColor r="0" g="1" b="1"/>
				<Scripts>
					<OnLoad>
						XPerl_SetChildMembers(self)
						XPerl_RegisterBar(self)
						self:SetFrameLevel(getglobal(self:GetParent():GetName().."healthBar"):GetFrameLevel() - 1)
					</OnLoad>
				</Scripts>
			</StatusBar>

			<!-- Mana Bar -->
			<StatusBar name="$parentmanaBar" drawLayer="BACKGROUND" inherits="XPerlStatusBar">
				<Size>
					<AbsDimension x="112" y="10"/>
				</Size>
				<Anchors>
					<Anchor point="TOP" relativePoint="BOTTOM" relativeTo="$parenthealthBar">
						<Offset>
							<AbsDimension x="0" y="-2"/>
						</Offset>
					</Anchor>
				</Anchors>
				<BarColor r="0" g="0" b="1"/>
			</StatusBar>
		</Frames>
		<Scripts>
			<OnLoad>
				XPerl_StatsFrame_Setup(self)
			</OnLoad>
		</Scripts>
	</Frame>

	<Frame name="XPerl_StatsXP_Template" inherits="XPerl_Stats_Template" virtual="true">
		<Frames>
			<StatusBar name="$parentxpBar" inherits="XPerlStatusBar" hidden="true">
				<Size>
					<AbsDimension x="112" y="10"/>
				</Size>
				<Anchors>
					<Anchor point="TOP" relativePoint="BOTTOM" relativeTo="$parentmanaBar"/>
				</Anchors>
				<BarColor r="0" g="0.8" b="0"/>
			</StatusBar>
			<StatusBar name="$parentxpRestBar" hidden="true">
				<Size>
					<AbsDimension x="112" y="10"/>
				</Size>
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="$parentxpBar"/>
					<Anchor point="BOTTOMRIGHT" relativeTo="$parentxpBar"/>
				</Anchors>
				<BarTexture name="$parentTex" file="Interface\TargetingFrame\UI-StatusBar"/>
				<BarColor r="0" g="0.8" b="0"/>
				<Scripts>
					<OnLoad>
						XPerl_SetChildMembers(self)
						XPerl_RegisterBar(self)
					</OnLoad>
				</Scripts>
			</StatusBar>
		</Frames>
	</Frame>

	<Button name="XPerl_BuffTemplate" virtual="true">
		<Size>
			<AbsDimension x="32" y="32"/>
		</Size>
		<Layers>
			<Layer level="ARTWORK">
				<Texture name="$parenticon" setAllPoints="true" />
			</Layer>
			<Layer level="OVERLAY">
				<FontString name="$parentcount" inherits="NumberFontNormalLarge" justifyV="BOTTOM" justifyH="RIGHT">
					<FontHeight>
						<AbsValue val="24"/>
					</FontHeight>
					<Anchors>
						<Anchor point="TOPLEFT"/>
						<Anchor point="BOTTOMRIGHT">
							<Offset>
								<AbsDimension x="-2" y="2"/>
							</Offset>
						</Anchor>
					</Anchors>
				</FontString>
			</Layer>
		</Layers>
		<Scripts>
			<OnLoad>
				XPerl_SetChildMembers(self)
				self:SetScript("OnLoad", nil)
			</OnLoad>
		</Scripts>
	</Button>

	<Button name="XPerl_Cooldown_BuffTemplate" inherits="XPerl_BuffTemplate" virtual="true">
		<Frames>
			<Cooldown name="$parentcooldown" inherits="CooldownFrameTemplate" setAllPoints="true" reverse="true" drawEdge="true" hidden="true">
				<Layers>
					<Layer level="OVERLAY">
						<FontString name="$parentcountdown" inherits="GameFontNormalHuge">
							<Anchors>
								<Anchor point="TOPLEFT"/>
								<Anchor point="BOTTOMRIGHT">
									<Offset>
										<AbsDimension x="-1" y="2"/>
									</Offset>
								</Anchor>
							</Anchors>
							<Color r="1" g="1" b="0"/>
						</FontString>
					</Layer>
				</Layers>
			</Cooldown>
		</Frames>
	</Button>

	<Button name="XPerl_DeBuffTemplate" virtual="true" inherits="XPerl_BuffTemplate">
		<Size>
			<AbsDimension x="32" y="32"/>
		</Size>
		<Layers>
			<Layer level="OVERLAY">
				<Texture name="$parentborder" file="Interface\Buttons\UI-Debuff-Overlays" setAllPoints="true">
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset>
								<AbsDimension x="-1" y="1"/>
							</Offset>
						</Anchor>
						<Anchor point="BOTTOMRIGHT"/>
					</Anchors>
					<TexCoords left="0.296875" right="0.5703125" top="0" bottom="0.515625"/>
				</Texture>
			</Layer>
		</Layers>
		<Scripts>
			<OnLoad>
				XPerl_SetChildMembers(self)
				self:SetScript("OnLoad", nil)
			</OnLoad>
		</Scripts>
	</Button>

	<Button name="XPerl_Cooldown_DeBuffTemplate" inherits="XPerl_DeBuffTemplate" virtual="true">
		<Frames>
			<Cooldown name="$parentcooldown" inherits="CooldownFrameTemplate" setAllPoints="true" reverse="true" drawEdge="true" hidden="true">
				<Layers>
					<Layer level="OVERLAY">
						<FontString name="$parentcountdown" inherits="GameFontNormalHuge" setAllPoints="true" hidden="true">
							<Anchors>
								<Anchor point="TOPLEFT"/>
								<Anchor point="BOTTOMRIGHT">
									<Offset>
										<AbsDimension x="-1" y="2"/>
									</Offset>
								</Anchor>
							</Anchors>
							<Color r="1" g="1" b="0"/>
						</FontString>
					</Layer>
				</Layers>
			</Cooldown>
		</Frames>
	</Button>

	<Frame name="XPerl_HighlightTemplate" virtual="true">
		<Scripts>
			<OnLoad>
				XPerl_SetChildMembers(self)

				local p = self:GetParent()
				local f = getglobal(p:GetName().."statsFrame")
				if (f) then
					self:SetFrameLevel(f:GetFrameLevel() + 1)
				end

				p.highlight = self

				if (not p:GetScript("OnEnter")) then
					p:SetScript("OnEnter", function(self)
						if (self.highlight) then
							self.highlight:Select()
						end
						XPerl_PlayerTip(self)
					end)
				end
				if (not p:GetScript("OnLeave")) then
					p:SetScript("OnLeave", function(self)
						if (self.highlight) then
							self.highlight:Deselect()
						end
						XPerl_PlayerTipHide()
					end)
				end

				self.Select = function(self)
					if (XPerlDB.highlightSelection) then
						self.sel = true
						self.tex:Show()
						XPerl_Highlight:SetHighlight(self:GetParent())
					end
				end

				self.Deselect = function(self)
					if (XPerlDB.highlightSelection) then
						self.sel = nil
						self.tex:Hide()
						XPerl_Highlight:SetHighlight(self:GetParent())
					end
				end
			</OnLoad>
		</Scripts>
		<Layers>
			<Layer level="OVERLAY">
				<Texture name="$parenttex" hidden="true" file="Interface\Addons\XPerl\images\XPerl_Highlight" alphaMode="ADD">
					<TexCoords left="0.25" right="0.75" top="0" bottom="0.5"/>
				</Texture>
			</Layer>
		</Layers>
	</Frame>
</Ui>
