Quantcast
<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="weights.lua"/>
	<!-- virtual frame used for classes in tiered lists -->
	<Frame name="ww_classFrame" virtual="true">
		<Size>
			<AbsDimension x="0" y="22"/>
		</Size>
		<Anchors>
			<Anchor point="RIGHT"/>
		</Anchors>
		<Frames>
			<Button name="$parentText" parentKey="text">
				<Size>
					<AbsDimension x="0" y="20"/>
				</Size>
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset>
							<AbsDimension x="5" y="-1"/>
						</Offset>
					</Anchor>
					<Anchor point="RIGHT"/>
				</Anchors>
				<NormalTexture file="Interface\Buttons\UI-MinusButton-UP">
					<Size>
						<AbsDimension x="16" y="16"/>
					</Size>
					<Anchors>
						<Anchor point="LEFT"/>
					</Anchors>
				</NormalTexture>
				<PushedTexture file="Interface\Buttons\UI-MinusButton-DOWN">
					<Size>
						<AbsDimension x="16" y="16"/>
					</Size>
					<Anchors>
						<Anchor point="LEFT"/>
					</Anchors>
				</PushedTexture>
				<HighlightTexture file="Interface\Buttons\UI-PlusButton-Hilight" alphaMode="ADD">
					<Size>
						<AbsDimension x="16" y="16"/>
					</Size>
					<Anchors>
						<Anchor point="LEFT"/>
					</Anchors>
				</HighlightTexture>
				<Scripts>
					<OnLoad>
						local fontString = self:CreateFontString(nil, "OVERLAY", "GameFontNormal")
						fontString:SetPoint("LEFT", 20, 0)
						self:SetFontString(fontString)
					</OnLoad>
					<OnClick>
						ww_toggleCollapse(self:GetParent(), self:GetParent():GetParent():GetParent().scrollFrame)
						if self:GetParent().collapsed then
							self:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-UP")
							self:SetPushedTexture("Interface\\Buttons\\UI-PlusButton-DOWN")
						else
							self:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-UP")
							self:SetPushedTexture("Interface\\Buttons\\UI-MinusButton-DOWN")
						end
					</OnClick>
				</Scripts>
			</Button>
		</Frames>
	</Frame>
	<!-- virtual frame used for categories in tiered lists -->
	<Frame name="ww_categoryFrame" virtual="true">
		<Size>
			<AbsDimension x="0" y="22"/>
		</Size>
		<Anchors>
			<Anchor point="RIGHT"/>
		</Anchors>
		<Frames>
			<Button name="$parentText" parentKey="text">
				<Size>
					<AbsDimension x="0" y="20"/>
				</Size>
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset>
							<AbsDimension x="0" y="-1"/>
						</Offset>
					</Anchor>
					<Anchor point="RIGHT"/>
				</Anchors>
				<NormalTexture file="Interface\Buttons\UI-MinusButton-UP">
					<Size>
						<AbsDimension x="16" y="16"/>
					</Size>
					<Anchors>
						<Anchor point="LEFT"/>
					</Anchors>
				</NormalTexture>
				<PushedTexture file="Interface\Buttons\UI-MinusButton-DOWN">
					<Size>
						<AbsDimension x="16" y="16"/>
					</Size>
					<Anchors>
						<Anchor point="LEFT"/>
					</Anchors>
				</PushedTexture>
				<HighlightTexture file="Interface\Buttons\UI-PlusButton-Hilight" alphaMode="ADD">
					<Size>
						<AbsDimension x="16" y="16"/>
					</Size>
					<Anchors>
						<Anchor point="LEFT"/>
					</Anchors>
				</HighlightTexture>
				<Scripts>
					<OnLoad>
						local fontString = self:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
						fontString:SetPoint("LEFT", 20, 0)
						self:SetFontString(fontString)
					</OnLoad>
					<OnClick>
						ww_toggleCollapse(self:GetParent())
						if self:GetParent().collapsed then
							self:SetNormalTexture("Interface\\Buttons\\UI-PlusButton-UP")
							self:SetPushedTexture("Interface\\Buttons\\UI-PlusButton-DOWN")
						else
							self:SetNormalTexture("Interface\\Buttons\\UI-MinusButton-UP")
							self:SetPushedTexture("Interface\\Buttons\\UI-MinusButton-DOWN")
						end
					</OnClick>
				</Scripts>
			</Button>
		</Frames>
	</Frame>
	<!--virtual frame used to allow for script generated frames with stat information-->
	<Frame name="ww_statFrame" virtual="true">
		<Size>
			<AbsDimension x="0" y="22"/>
		</Size>
		<Anchors>
			<Anchor point="RIGHT">
				<Offset>
					<AbsDimension x="-5" y="0"/>
				</Offset>
			</Anchor>
		</Anchors>
		<Layers>
			<Layer level="OVERLAY">
				<FontString name="$parentText" parentKey="text" inherits="GameFontNormal">
					<Size>
						<AbsDimension x="0" y="20"/>
					</Size>
					<Anchors>
						<Anchor point="LEFT"/>
					</Anchors>
				</FontString>
			</Layer>
		</Layers>
		<Frames>
			<Frame name="$parentHighlightFrame" parentKey="highlightFrame" inherits="ww_highlightedFrame">
				<Anchors>
					<Anchor point="TOPLEFT">
						<Offset>
							<AbsDimension x="-5" y="-1"/>
						</Offset>
					</Anchor>
					<Anchor point="BOTTOMRIGHT">
						<Offset>
							<AbsDimension x="-132" y="-1"/>
						</Offset>
					</Anchor>
				</Anchors>
			</Frame>
			<EditBox letters="16" name="$parentStatValue" parentKey="statValue" autoFocus="false">
				<Size>
					<AbsDimension x="130" y="22"/>
				</Size>
				<Anchors>
					<Anchor point="RIGHT"/>
				</Anchors>
				<Backdrop edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true">
					<EdgeSize>
						<AbsValue val="10"/>
					</EdgeSize>
					<TileSize>
						<AbsValue val="10"/>
					</TileSize>
					<BackgroundInsets>
						<AbsInset left="0" right="0" top="5" bottom="5"/>
					</BackgroundInsets>
				</Backdrop>
				<FontString inherits="GameFontNormal">
					<Anchors>
						<Anchor point="LEFT"/>
					</Anchors>
				</FontString>
				<Scripts>
					<OnLoad>
						self:SetTextInsets(5, 5, 0, 0)
					</OnLoad>
					<OnTextChanged>
						local text = self:GetText()
						local number = tonumber(text)
						if number then
							self.number = number
						elseif text:match("^[0.]*$") then
							self.number = 0
						end
						if number == ww_weights.rightPanel.statList[self:GetParent().statName] or (number == 0 and ww_weights.rightPanel.statList[self:GetParent().statName] == nil) then
							ww_weights.rightPanel.changedStats[self] = nil
							local changed = false
							for _ in pairs(ww_weights.rightPanel.changedStats) do
								changed = true
								break
							end
							for _ in pairs(ww_weights.rightPanel.changedTriggers) do
								changed = true
								break
							end
							if not changed then
								ww_weights.rightPanel.saveButton:Disable()
								ww_weights.rightPanel.resetButton:Disable()
							end
						else
							ww_weights.rightPanel.changedStats[self] = self:GetParent().statName
							ww_weights.rightPanel.saveButton:Enable()
							ww_weights.rightPanel.resetButton:Enable()
						end
					</OnTextChanged>
					<OnChar>
						if ww_validateNumber(text, self:GetText()) then
							self.number = tonumber(self:GetText()) or 0
						else
							local cursorPosition = self:GetCursorPosition() - 1
							self:SetText(self.number)
							self:SetCursorPosition(cursorPosition)
						end
					</OnChar>
					<OnEditFocusGained>
						self:GetParent().highlightFrame:Show()
						self:HighlightText()
					</OnEditFocusGained>
					<OnEditFocusLost>
						self:GetParent().highlightFrame:Hide()
						self:HighlightText(0,0)
					</OnEditFocusLost>
					<OnTabPressed>
						ww_changeFocus(self:GetParent())
					</OnTabPressed>
					<OnEscapePressed>
						self:ClearFocus()
					</OnEscapePressed>
				</Scripts>
			</EditBox>
		</Frames>
	</Frame>
	<!--virtual frame used to allow for script generated frames with trigger information-->
	<Frame name="ww_triggerFrame" virtual="true">
		<Size>
			<AbsDimension x="0" y="22"/>
		</Size>
		<Anchors>
			<Anchor point="RIGHT">
				<Offset>
					<AbsDimension x="-5" y="0"/>
				</Offset>
			</Anchor>
		</Anchors>
		<Layers>
			<Layer level="OVERLAY">
				<FontString name="$parentText" parentKey="text" inherits="GameFontNormal">
					<Size>
						<AbsDimension x="0" y="20"/>
					</Size>
					<Anchors>
						<Anchor point="LEFT"/>
					</Anchors>
				</FontString>
			</Layer>
		</Layers>
		<Frames>
			<CheckButton name="$parentActive" parentKey="active" inherits="UICheckButtonTemplate">
				<Size>
					<AbsDimension x="20" y="20"/>
				</Size>
				<Anchors>
					<Anchor point="RIGHT">
						<Offset>
							<AbsDimension x="-112" y="0"/>
						</Offset>
					</Anchor>
				</Anchors>
				<Scripts>
					<OnClick>
						-- The nots convert things to boolean (instead of 1/nil)
						if not self:GetChecked() == not ww_weights.rightPanel.statList.triggers[self:GetText()] then
							ww_weights.rightPanel.changedTriggers[self] = nil
							local changed = false
							for _ in pairs(ww_weights.rightPanel.changedStats) do
								changed = true
								break
							end
							for _ in pairs(ww_weights.rightPanel.changedTriggers) do
								changed = true
								break
							end
							if not changed then
								ww_weights.rightPanel.saveButton:Disable()
								ww_weights.rightPanel.resetButton:Disable()
							end
						else
							ww_weights.rightPanel.changedTriggers[self] = self:GetText()
							ww_weights.rightPanel.saveButton:Enable()
							ww_weights.rightPanel.resetButton:Enable()
						end
					</OnClick>
				</Scripts>
			</CheckButton>
		</Frames>
	</Frame>
	<!--virtual frame used to allow for script generated frames with stat information-->
	<Frame name="ww_weightFrame" virtual="true">
		<Size>
			<AbsDimension x="0" y="22"/>
		</Size>
		<Anchors>
			<Anchor point="RIGHT"/>
		</Anchors>
		<Frames>
			<CheckButton name="$parentCheckButton" parentKey="checkButton" inherits="UICheckButtonTemplate">
				<Size>
					<AbsDimension x="20" y="20"/>
				</Size>
				<Anchors>
					<Anchor point="LEFT">
						<Offset>
							<AbsDimension x="0" y="0"/>
						</Offset>
					</Anchor>
				</Anchors>
				<Scripts>
					<OnClick>
						local parent = self:GetParent()
						local class = parent.category.class

						if not ww_charVars.activeWeights[class] then
							ww_charVars.activeWeights[class] = {}
							table.insert(ww_charVars.activeWeights, class)
						end
						if self:GetChecked() then
							table.insert(ww_charVars.activeWeights[class], parent.name)
						else
							for i, weight in ipairs(ww_charVars.activeWeights[class]) do
								if weight == parent.name then
									table.remove(ww_charVars.activeWeights[class], i)
									break
								end
							end
						end
					</OnClick>
					<OnEnter>
						GameTooltip:SetOwner(self,"ANCHOR_RIGHT")
						GameTooltip:AddLine(ww_localization["WATCH_TT"], 1, 1, 1)
						GameTooltip:Show()
					</OnEnter>
					<OnLeave>
						GameTooltip:Hide()
					</OnLeave>
				</Scripts>
			</CheckButton>
			<Button name="$parentText" parentKey="text">
				<Size>
					<AbsDimension x="0" y="20"/>
				</Size>
				<Anchors>
					<Anchor point="LEFT">
						<Offset>
							<AbsDimension x="25" y="0"/>
						</Offset>
					</Anchor>
					<Anchor point="RIGHT"/>
				</Anchors>
				<HighlightTexture file="Interface\Buttons\UI-Listbox-Highlight2" alphaMode="ADD">
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset>
								<AbsDimension x="-3" y="-2"/>
							</Offset>
						</Anchor>
						<Anchor point="BOTTOMRIGHT">
							<Offset>
								<AbsDimension x="-7" y="0"/>
							</Offset>
						</Anchor>
					</Anchors>
				</HighlightTexture>
				<Frames>
					<Frame name="$parentHighlightFrame" parentKey="highlightFrame" inherits="ww_highlightedFrame">
						<Anchors>
							<Anchor point="TOPLEFT">
								<Offset>
									<AbsDimension x="-5" y="-1"/>
								</Offset>
							</Anchor>
							<Anchor point="BOTTOMRIGHT">
								<Offset>
									<AbsDimension x="-5" y="-1"/>
								</Offset>
							</Anchor>
						</Anchors>
					</Frame>
				</Frames>
				<Scripts>
					<OnClick>
						ww_configDiscardChanges(function()
								ww_configSelectWeight(self:GetParent())
							end)
					</OnClick>
					<OnLoad>
						self:SetFontString(self:CreateFontString(nil, "OVERLAY", "ww_defaultString"))
					</OnLoad>
				</Scripts>
			</Button>
		</Frames>
<!--		<Scripts>
			<OnHide>
				self.checkButton:Hide()
				self.text:Hide()
			</OnHide>
			<OnShow>
				self.checkButton:Show()
				self.text:Show()
				error()
			</OnShow>
		</Scripts> -->
	</Frame>
	<!-- The frame containing all weight-related content -->
	<Frame name="ww_weights" parent="UIParent" hidden="true" frameStrata="HIGH">
		<Size>
			<AbsDimension x="650" y="600"/>
		</Size>
		<Anchors>
			<Anchor point="CENTER"/>
		</Anchors>
		<Layers>
			<Layer level="OVERLAY">
				<FontString name="$parentTitle" parentKey="title" inherits="GameFontNormalLarge" text="WEIGHTS_TITLE">
					<Anchors>
						<Anchor point="TOP">
							<Offset>
								<AbsDimension x="0" y="-5"/>
							</Offset>
						</Anchor>
					</Anchors>
				</FontString>
				<!--Mr. Robot weight attribution-->
				<FontString name="$parentWeightsAttribution" parentKey="weightsAttribution" inherits="GameFontNormal" text="WEIGHTS_ATTRIBUTION">
					<Anchors>
						<Anchor point="BOTTOM">
							<Offset>
								<AbsDimension x="20" y="5"/>
							</Offset>
						</Anchor>
					</Anchors>
				</FontString>
			</Layer>
			<Layer level="BACKGROUND">
				<Texture setAllPoints="true">
					<!--Plain black background with 50% alpha-->
					<Color r="0" g="0" b="0" a="0.8"/>
				</Texture>
			</Layer>
		</Layers>
		<!--list of objects within the configuartion window-->
		<Frames>
			<!--The Class Selection Frame-->
			<Frame name="$parentLeftPanel" parentKey="leftPanel">
				<Size>
					<AbsDimension x="150" y="0"/>
				</Size>
				<Anchors>
					<Anchor point="TOP">
						<Offset>
							<AbsDimension x="0" y="-25"/>
						</Offset>
					</Anchor>
					<Anchor point="LEFT"/>
					<Anchor point="BOTTOM">
						<Offset>
							<AbsDimension x="0" y="25"/>
						</Offset>
					</Anchor>
				</Anchors>
				<Backdrop edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true">
					<EdgeSize>
						<AbsValue val="10"/>
					</EdgeSize>
					<TileSize>
						<AbsValue val="10"/>
					</TileSize>
					<BackgroundInsets>
						<AbsInset left="0" right="0" top="5" bottom="5"/>
					</BackgroundInsets>
				</Backdrop>
				<Frames>
					<!--used to hold a series of stat frames to maintain absolute position when scrolling-->
					<Frame name="$parentScrollContainer" parentKey="scrollContainer">
						<Anchors>
							<Anchor point="LEFT"/>
							<Anchor point="RIGHT"/>
						</Anchors>
					</Frame>
					<!--Invisible frame with scroll bar that does the scrolling-->
					<ScrollFrame name="$parentScrollFrame" parentKey="scrollFrame" inherits="FauxScrollFrameTemplate">
						<Anchors>
							<Anchor point="TOPLEFT"/>
							<Anchor point="BOTTOMRIGHT">
								<Offset>
									<AbsDimension x="-5" y="0"/>
								</Offset>
							</Anchor>
						</Anchors>
						<Scripts>
							<OnShow>
								ww_scrollBarUpdate(self, ww_weights.leftPanel.scrollContainer, 22, 0, 25)
							</OnShow>
							<OnVerticalScroll>
								FauxScrollFrame_OnVerticalScroll(self, offset, 22, self:GetScript("OnShow"))
							</OnVerticalScroll>
						</Scripts>
					</ScrollFrame>
				</Frames>
			</Frame>
			<!--Right Frame for viewing the weights for each class-->
			<Frame name="$parentRightPanel" parentKey="rightPanel" hidden="true">
				<Anchors>
					<Anchor point="TOPLEFT" relativeTo="$parentLeftPanel" relativePoint="TOPRIGHT">
						<Offset>
							<AbsDimension x="20" y="0"/>
						</Offset>
					</Anchor>
					<Anchor point="BOTTOM" relativeTo="$parentLeftPanel"/>
					<Anchor point="RIGHT">
						<Offset>
							<AbsDimension x="-20" y="0"/>
						</Offset>
					</Anchor>
				</Anchors>
				<Layers>
					<Layer level="OVERLAY">
						<FontString name="$parentHeader" parentKey="header" inherits="GameFontNormal">
							<Anchors>
								<Anchor point="TOP">
									<Offset>
										<AbsDimension x="0" y="-5"/>
									</Offset>
								</Anchor>
							</Anchors>
						</FontString>
					</Layer>
				</Layers>
				<Backdrop edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true">
					<EdgeSize>
						<AbsValue val="10"/>
					</EdgeSize>
					<TileSize>
						<AbsValue val="10"/>
					</TileSize>
					<BackgroundInsets>
						<AbsInset left="0" right="0" top="5" bottom="5"/>
					</BackgroundInsets>
				</Backdrop>
				<Frames>
					<!--Save button-->
					<Button name="$parentSaveButton" parentKey="saveButton" inherits="ww_localizedButton" text="Save">
						<Size>
							<AbsDimension x="80" y="22"/>
						</Size>
						<Anchors>
							<Anchor point="BOTTOMLEFT">
								<Offset>
									<AbsDimension x="5" y="5"/>
								</Offset>
							</Anchor>
						</Anchors>
						<Scripts>
							<OnClick>
								ww_configSaveWeight()
							</OnClick>
						</Scripts>
					</Button>
					<!--Copy button-->
					<!-- Cannot inherit localized button as it needs its own onload handler -->
					<Button name="$parentCopyButton" parentKey="copyButton" inherits="UIPanelButtonTemplate" text="Copy">
						<Size>
							<AbsDimension x="80" y="22"/>
						</Size>
						<Scripts>
							<OnClick>
								ww_configNewWeight(self:GetParent().weightFrame.category.class, string.format(ww_localization["DEFAULT_COPY_NAME"], self:GetParent().weightFrame.name), self:GetParent().statList)
							</OnClick>
							<OnLoad>
								self:SetText(ww_localization[self:GetText()])
								local relTo = self:GetParent().saveButton
								local _, _, _, relToXOffset = relTo:GetPoint(1)
								self:SetPoint("CENTER", relTo, (self:GetParent():GetWidth() - self:GetWidth() - 2 * relToXOffset) / 3, 0)
							</OnLoad>
						</Scripts>
					</Button>
					<!--Reset button-->
					<Button name="$parentResetButton" parentKey="resetButton" inherits="ww_localizedButton" text="Reset">
						<Size>
							<AbsDimension x="80" y="22"/>
						</Size>
						<Anchors>
							<Anchor point="BOTTOMRIGHT">
								<Offset>
									<AbsDimension x="-5" y="5"/>
								</Offset>
							</Anchor>
						</Anchors>
						<Scripts>
							<OnClick>
								ww_configResetWeight()
							</OnClick>
						</Scripts>
					</Button>
					<!--Delete button-->
					<!-- Cannot inherit localized button as it needs its own onload handler -->
					<Button name="$parentDeleteButton" parentKey="deleteButton" inherits="UIPanelButtonTemplate" text="Delete">
						<Size>
							<AbsDimension x="80" y="22"/>
						</Size>
						<Scripts>
							<OnClick>
								ww_configDeleteWeight()
							</OnClick>
							<OnLoad>
								self:SetText(ww_localization[self:GetText()])
								local relTo = self:GetParent().resetButton
								local _, _, _, relToXOffset = relTo:GetPoint(1)
								self:SetPoint("CENTER", relTo, (self:GetWidth() - 2 * relToXOffset - self:GetParent():GetWidth()) / 3, 0)
							</OnLoad>
						</Scripts>
					</Button>
					<!--used to hold a series of stat frames to maintain absolute position when scrolling-->
					<Frame name="$parentScrollContainer" parentKey="scrollContainer">
						<Anchors>
							<Anchor point="LEFT"/>
							<Anchor point="RIGHT"/>
						</Anchors>
					</Frame>
					<!--Invisible frame with scroll bar that does the scrolling-->
					<ScrollFrame name="$parentScrollFrame" parentKey="scrollFrame" inherits="FauxScrollFrameTemplate">
						<Anchors>
							<Anchor point="TOPLEFT"/>
							<Anchor point="BOTTOMRIGHT">
								<Offset>
									<AbsDimension x="-5" y="0"/>
								</Offset>
							</Anchor>
						</Anchors>
						<Scripts>
							<OnShow>
								ww_scrollBarUpdate(self, ww_weights.rightPanel.scrollContainer, 22, -30, 22)
							</OnShow>
							<OnVerticalScroll>
								FauxScrollFrame_OnVerticalScroll(self, offset, 22, self:GetScript("OnShow"))
							</OnVerticalScroll>
						</Scripts>
					</ScrollFrame>
				</Frames>
				<Scripts>
					<OnShow>
						if not ww_weights.popup then
							ww_changeFocus(self.scrollContainer.stats[#(self.scrollContainer.stats)])
						end
					</OnShow>
				</Scripts>
			</Frame>
			<!--Close Button for the configuration window-->
			<Button name="$parentCloseButton" parentKey="closeButton" inherits="UIPanelCloseButton">
				<Anchors>
					<Anchor point="TOPRIGHT"/>
				</Anchors>
			</Button>
			<!--restore default button-->
			<Button name="$parentDefaultsButton" parentKey="defaultsButton" inherits="ww_localizedButton" text="Restore Defaults">
				<Size>
					<AbsDimension x="150" y="22"/>
				</Size>
				<Anchors>
					<Anchor point="BOTTOMLEFT"/>
				</Anchors>
				<Scripts>
					<OnClick>
						if ww_weights.rightPanel.weightFrame and ww_defaultVars.weightsList[ww_weights.rightPanel.weightFrame.category.class][ww_weights.rightPanel.weightFrame.name] then
							StaticPopup_Show("WW_CONFIRM_RESTORE_DEFAULT_WEIGHTS")
						else
							ww_configDiscardChanges(function()
									StaticPopup_Show("WW_CONFIRM_RESTORE_DEFAULT_WEIGHTS")
								end)
						end
					</OnClick>
				</Scripts>
			</Button>
			<!--Create new weight button-->
			<Button name="$parentNewWeightButton" parentKey="newWeightButton" inherits="ww_localizedButton" text="New Weight">
				<Size>
					<AbsDimension x="100" y="22"/>
				</Size>
				<Anchors>
					<Anchor point="BOTTOMRIGHT"/>
				</Anchors>
				<Scripts>
					<OnClick>
						ww_configNewWeight()
					</OnClick>
				</Scripts>
			</Button>
		</Frames>
		<Scripts>
			<OnLoad>
				self.title:SetText(ww_localization[self.title:GetText()])
				self.weightsAttribution:SetText(ww_localization[self.weightsAttribution:GetText()])
				table.insert(UISpecialFrames, self:GetName())
				function self:SmartHide(func)
						self.afterHide = func
						self:Hide()
					end
			</OnLoad>
			<OnHide>
				if self.reallyClose then
					self.reallyClose = nil
					if self.afterHide then
						self.afterHide()
					end
					self.afterHide = nil
				else
					self.popup = true
					self:Show()
					ww_configDiscardChanges(function()
							self.reallyClose = true
							<!-- Safe because ww_configDiscardChanges will save the weight first -->
							if self.rightPanel:IsShown() then
								ww_configResetWeight()
							end
							self:Hide()
							if self.afterHide then
								self.afterHide()
							end
							self.afterHide = nil
						end)
					self.popup = nil
				end
			</OnHide>
		</Scripts>
	</Frame>
	<Frame name="ww_newWeight" parent="UIParent" hidden="true" frameStrata="DIALOG">
		<Size>
			<AbsDimension x="420" y="120"/>
		</Size>
		<Anchors>
			<Anchor point="CENTER"/>
		</Anchors>
		<Layers>
			<Layer level="ARTWORK">
				<FontString name="$parentText" parentKey="text" inherits="GameFontHighlight" text="CHOOSE_WEIGHT_NAME">
					<Size>
						<AbsDimension x="380" y="0"/>
					</Size>
					<Anchors>
						<Anchor point="TOP">
							<Offset>
								<AbsDimension x="0" y="-16"/>
							</Offset>
						</Anchor>
					</Anchors>
				</FontString>
			</Layer>
			<Layer level="BACKGROUND">
				<Texture setAllPoints="true">
					<!--Plain black background with 50% alpha-->
					<Color r="0" g="0" b="0" a="0.5"/>
				</Texture>
			</Layer>
		</Layers>
		<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
			<BackgroundInsets>
				<AbsInset left="11" right="12" top="12" bottom="11"/>
			</BackgroundInsets>
			<TileSize>
				<AbsValue val="32"/>
			</TileSize>
			<EdgeSize>
				<AbsValue val="32"/>
			</EdgeSize>
		</Backdrop>
		<Frames>
			<Button name="$parentDropDown" parentKey="dropdown" inherits="UIDropDownMenuTemplate">
				<Anchors>
					<Anchor point="LEFT"/>
				</Anchors>
				<Scripts>
					<OnShow>
						UIDropDownMenu_Initialize(self, ww_ClassDropDownInitialize)
						UIDropDownMenu_SetSelectedValue(self, WeightsWatcher.player.class)
					</OnShow>
				</Scripts>
			</Button>
			<EditBox letters="50" name="$parentEditBox" parentKey="editBox">
				<Size>
					<AbsDimension x="0" y="32"/>
				</Size>
				<Anchors>
					<Anchor point="BOTTOM" >
						<Offset>
							<AbsDimension x="0" y="45"/>
						</Offset>
					</Anchor>
					<Anchor point="RIGHT">
						<Offset>
							<AbsDimension x="-25" y="0"/>
						</Offset>
					</Anchor>
					<Anchor point="LEFT" relativeTo="$parentDropDown" relativePoint="RIGHT">
						<Offset>
							<AbsDimension x="125" y="0"/>
						</Offset>
					</Anchor>
				</Anchors>
				<FontString inherits="ChatFontNormal"/>
				<Layers>
					<Layer level="BACKGROUND">
						<Texture file="Interface\ChatFrame\UI-ChatInputBorder-Left">
							<Size>
								<AbsDimension x="128" y="32"/>
							</Size>
							<Anchors>
								<Anchor point="LEFT">
									<Offset>
										<AbsDimension x="-10" y="0"/>
									</Offset>
								</Anchor>
							</Anchors>
							<TexCoords left="0" right="0.5" top="0" bottom="1.0"/>
						</Texture>
						<Texture file="Interface\ChatFrame\UI-ChatInputBorder-Right">
							<Size>
								<AbsDimension x="128" y="32"/>
							</Size>
							<Anchors>
								<Anchor point="RIGHT">
									<Offset>
										<AbsDimension x="10" y="0"/>
									</Offset>
								</Anchor>
							</Anchors>
							<TexCoords left="0.5" right="1.0" top="0" bottom="1.0"/>
						</Texture>
					</Layer>
				</Layers>
				<Scripts>
					<OnLoad>
						self:SetTextInsets(5, 5, 0, 0)
					</OnLoad>
					<OnTextChanged>
						if self:GetText() == "" then
							self:GetParent().createButton:Disable()
						else
							self:GetParent().createButton:Enable()
						end
					</OnTextChanged>
					<OnEnterPressed>
						if StaticPopup_Visible("WW_WEIGHT_EXISTS") then
							StaticPopup_Hide("WW_WEIGHT_EXISTS")
						else
							self:GetParent().createButton:Click()
						end
					</OnEnterPressed>
					<OnEscapePressed>
						if StaticPopup_Visible("WW_WEIGHT_EXISTS") then
							StaticPopup_Hide("WW_WEIGHT_EXISTS")
						else
							self:GetParent().cancelButton:Click()
						end
					</OnEscapePressed>
				</Scripts>
			</EditBox>
			<Button name="$parentCreateButton" parentKey="createButton" inherits="ww_localizedButton" text="Create">
				<Size>
					<AbsDimension x="128" y="20"/>
				</Size>
				<Anchors>
					<Anchor point="BOTTOMRIGHT" relativePoint="BOTTOM">
						<Offset>
							<AbsDimension x="-6" y="16"/>
						</Offset>
					</Anchor>
				</Anchors>
				<Scripts>
					<OnClick>
						local class = UIDropDownMenu_GetSelectedValue(self:GetParent().dropdown)
						local name = self:GetParent().editBox:GetText()
						if ww_vars.weightsList[class][name] then
							local error = StaticPopup_Show("WW_WEIGHT_EXISTS", ww_classDisplayNames[class], name)
						else
							ww_setWeight(class, name, self:GetParent().statList)
							ww_selectWeight(class, name)
							self:GetParent():Hide()
						end
					</OnClick>
				</Scripts>
			</Button>
			<Button name="$parentCancelButton" parentKey="cancelButton" inherits="ww_localizedButton" text="Cancel">
				<Size>
					<AbsDimension x="128" y="20"/>
				</Size>
				<Anchors>
					<Anchor point="BOTTOMLEFT" relativePoint="BOTTOM">
						<Offset>
							<AbsDimension x="6" y="16"/>
						</Offset>
					</Anchor>
				</Anchors>
				<Scripts>
					<OnClick>
						self:GetParent():Hide()
					</OnClick>
				</Scripts>
			</Button>
		</Frames>
		<Scripts>
			<OnLoad>
				self.text:SetText(ww_localization[self.text:GetText()])
			</OnLoad>
			<OnShow>
				self.editBox:SetFocus()
			</OnShow>
		</Scripts>
	</Frame>
</Ui>