Quantcast

Added config widgets for normalizing weights and gem quality

Kevin Lyles [11-17-09 - 07:03]
Added config widgets for normalizing weights and gem quality
Filename
config.lua
config.xml
defaults.lua
diff --git a/config.lua b/config.lua
index 238f9a6..86f5a83 100644
--- a/config.lua
+++ b/config.lua
@@ -41,3 +41,22 @@ function printHelp()
 	print("  version    displays version information")
 	print("  help         displays this message")
 end
+
+function GemQualityDropDownInitialize(dropdown)
+	local info = {}
+
+	info.func = GemQualityDropDownOnClick
+	info.arg1 = dropdown
+	for num, name in ipairs(gemQualityNames) do
+		info.text = name
+		info.value = num
+		info.checked = nil
+		UIDropDownMenu_AddButton(info)
+	end
+end
+
+function GemQualityDropDownOnClick(choice, dropdown)
+	UIDropDownMenu_SetSelectedValue(dropdown, choice.value, false)
+	ww_vars.options.gemQualityLimit = choice.value
+	ww_weightIdealCache = {}
+end
diff --git a/config.xml b/config.xml
index abe19a8..f07d49f 100644
--- a/config.xml
+++ b/config.xml
@@ -1,6 +1,97 @@
 <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="config.lua"/>
 	<Frame name="ww_config" parent="UIParent" hidden="true" frameStrata="HIGH">
+		<Size>
+			<AbsDimension x="600" y="600"/>
+		</Size>
+		<Anchors>
+			<Anchor point="CENTER"/>
+		</Anchors>
+		<Layers>
+			<Layer level="BACKGROUND">
+				<Texture setAllPoints="true">
+					<!--Plain black background with 80% alpha-->
+					<Color r="0" g="0" b="0" a="0.8"/>
+				</Texture>
+			</Layer>
+			<Layer level="ARTWORK">
+				<FontString name="$parentGemQualityLabel" parentKey="gemQualityLabel" text="Maximum Ideal Gem Quality:" inherits="GameFontNormal">
+					<Anchors>
+<!-- 						Broken -->
+<!--						<Anchor point="TOPLEFT" relativePoint="BOTTOMLEFT" relativeTo="$parentNormalizeWeights"/>-->
+						<Anchor point="TOPLEFT">
+							<Offset>
+								<AbsDimension x="5" y="-40"/>
+							</Offset>
+						</Anchor>
+					</Anchors>
+				</FontString>
+			</Layer>
+		</Layers>
+		<Frames>
+			<Button name="$parentCloseButton" parentKey="closeButton" inherits="UIPanelCloseButton">
+				<Anchors>
+					<Anchor point="TOPRIGHT"/>
+				</Anchors>
+			</Button>
+			<CheckButton name="$parentNormalizeWeights" parentKey="normalizeWeights" inherits="UICheckButtonTemplate" text="Normalize weights">
+				<Size>
+					<AbsDimension x="25" y="25"/>
+				</Size>
+				<Anchors>
+					<Anchor point="TOPLEFT">
+						<Offset>
+							<AbsDimension x="10" y="-10"/>
+						</Offset>
+					</Anchor>
+				</Anchors>
+				<Scripts>
+					<OnClick>
+						if self:GetChecked() then
+							ww_vars.options.normalizeWeights = true
+						else
+							ww_vars.options.normalizeWeights = false
+						end
+						ww_weightCache = {}
+						ww_weightIdealCache = {}
+					</OnClick>
+					<OnEnter>
+						GameTooltip:SetOwner(self,"ANCHOR_RIGHT")
+						GameTooltip:AddLine("Divides item scores by the total of all stats' values in that weight", 1, 1, 1)
+						GameTooltip:Show()
+					</OnEnter>
+					<OnLeave>
+						GameTooltip:Hide()
+					</OnLeave>
+					<OnLoad>
+						getglobal(self:GetName() .. "Text"):SetText(self:GetText())
+					</OnLoad>
+					<OnShow>
+						self:SetChecked(ww_vars.options.normalizeWeights)
+					</OnShow>
+				</Scripts>
+			</CheckButton>
+			<Button name="$parentGemQuality" parentKey="gemQuality" inherits="UIDropDownMenuTemplate">
+				<Anchors>
+					<Anchor point="TOPLEFT" relativePoint="BOTTOMLEFT" relativeTo="$parentGemQualityLabel">
+						<Offset>
+							<AbsDimension y="-5"/>
+						</Offset>
+					</Anchor>
+				</Anchors>
+				<Scripts>
+					<OnLoad>
+						UIDropDownMenu_SetWidth(self, 200, 15)
+						UIDropDownMenu_JustifyText(self, "LEFT")
+					</OnLoad>
+					<OnShow>
+						UIDropDownMenu_Initialize(self, GemQualityDropDownInitialize)
+						UIDropDownMenu_SetSelectedValue(self, ww_vars.options.gemQualityLimit)
+					</OnShow>
+				</Scripts>
+			</Button>
+		</Frames>
 		<Scripts>
 			<OnLoad>
 				table.insert(UISpecialFrames, self:GetName());
diff --git a/defaults.lua b/defaults.lua
index f40684c..16d9ec0 100644
--- a/defaults.lua
+++ b/defaults.lua
@@ -86,6 +86,20 @@ classNames = {
 	["WARRIOR"] = "Warrior",
 }

+gemQualityNames = {
+	[1] = "Burning Crusade common",
+	[2] = "Burning Crusade uncommon",
+	[3] = "Burning Crusade rare",
+	[4] = "Burning Crusade epic",
+	[5] = "Burning Crusade unique-equipped",
+	[6] = "Wrath uncommon",
+	[7] = "Wrath perfect uncommon",
+	[8] = "Wrath rare",
+	[9] = "Wrath epic",
+	[10] = "Wrath unique-equipped",
+	[11] = "Wrath jewelcrafter-only",
+}
+
 keyDetectors = {
 	[true] = function() return true end,
 	[false] = function() return false end,