mirror of
https://github.com/parnic/RepairBroker.git
synced 2025-06-16 09:40:12 -05:00
Add ability to change durability tier colors
This commit is contained in:
1
.pkgmeta
1
.pkgmeta
@ -3,5 +3,6 @@ package-as: RepairBroker
|
||||
externals:
|
||||
libs/CallbackHandler-1.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/CallbackHandler-1.0
|
||||
libs/LibStub: svn://svn.wowace.com/wow/libstub/mainline/trunk
|
||||
libs/AceConfig-3.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceConfig-3.0
|
||||
libs/AceLocale-3.0: svn://svn.wowace.com/wow/ace3/mainline/trunk/AceLocale-3.0
|
||||
libs/LibQTip-1.0: https://repos.wowace.com/wow/libqtip-1-0
|
||||
|
@ -40,4 +40,20 @@ L["Repair"] = true
|
||||
L["GuildRepair"] = true
|
||||
L["Shift-RightMouse"] = true
|
||||
L["Reputation requirement: "] = true
|
||||
L["Faction repair "] = true
|
||||
L["Faction repair "] = true
|
||||
L["Settings"] = true
|
||||
L["Max durability color"] = true
|
||||
L["The color to show for items that are at 100% durability."] = true
|
||||
L["High durability color"] = true
|
||||
L["The color to show for items that are at 90%-99% durability."] = true
|
||||
L["Medium durability color"] = true
|
||||
L["The color to show for items that are at 51%-89% durability."] = true
|
||||
L["Low durability color"] = true
|
||||
L["The color to show for items that are at 21%-50% durability."] = true
|
||||
L["Broken durability color"] = true
|
||||
L["The color to show for items that are at 0%-20% durability."] = true
|
||||
L["Reset"] = true
|
||||
L["Reset to defaults"] = true
|
||||
L["Resets all settings to defaults."] = true
|
||||
L["Open settings"] = true
|
||||
L["Shift-LeftMouse"] = true
|
||||
|
@ -40,3 +40,19 @@ L["GuildRepair"] = "길드 수리"
|
||||
L["Shift-RightMouse"] = "Shift-오른쪽마우스"
|
||||
L["Reputation requirement: "] = "평판 요구사항: "
|
||||
L["Faction repair "] = "수리 진영 "
|
||||
L["Settings"] = true -- needs translation
|
||||
L["Max durability color"] = true -- needs translation
|
||||
L["The color to show for items that are at 100% durability."] = true -- needs translation
|
||||
L["High durability color"] = true -- needs translation
|
||||
L["The color to show for items that are at 90%-99% durability."] = true -- needs translation
|
||||
L["Medium durability color"] = true -- needs translation
|
||||
L["The color to show for items that are at 51%-89% durability."] = true -- needs translation
|
||||
L["Low durability color"] = true -- needs translation
|
||||
L["The color to show for items that are at 21%-50% durability."] = true -- needs translation
|
||||
L["Broken durability color"] = true -- needs translation
|
||||
L["The color to show for items that are at 0%-20% durability."] = true -- needs translation
|
||||
L["Reset"] = true -- needs translation
|
||||
L["Reset to defaults"] = true -- needs translation
|
||||
L["Resets all settings to defaults."] = true -- needs translation
|
||||
L["Open settings"] = true -- needs translation
|
||||
L["Shift-LeftMouse"] = true -- needs translation
|
||||
|
@ -26,3 +26,19 @@ L["Force durability check."] = "强制耐久检查"
|
||||
L["Shift-RightMouse"] = true -- needs translation
|
||||
L["Reputation requirement: "] = true -- needs translation
|
||||
L["Faction repair "] = true -- needs translation
|
||||
L["Settings"] = true -- needs translation
|
||||
L["Max durability color"] = true -- needs translation
|
||||
L["The color to show for items that are at 100% durability."] = true -- needs translation
|
||||
L["High durability color"] = true -- needs translation
|
||||
L["The color to show for items that are at 90%-99% durability."] = true -- needs translation
|
||||
L["Medium durability color"] = true -- needs translation
|
||||
L["The color to show for items that are at 51%-89% durability."] = true -- needs translation
|
||||
L["Low durability color"] = true -- needs translation
|
||||
L["The color to show for items that are at 21%-50% durability."] = true -- needs translation
|
||||
L["Broken durability color"] = true -- needs translation
|
||||
L["The color to show for items that are at 0%-20% durability."] = true -- needs translation
|
||||
L["Reset"] = true -- needs translation
|
||||
L["Reset to defaults"] = true -- needs translation
|
||||
L["Resets all settings to defaults."] = true -- needs translation
|
||||
L["Open settings"] = true -- needs translation
|
||||
L["Shift-LeftMouse"] = true -- needs translation
|
||||
|
@ -38,3 +38,19 @@ L["Ranged"] = "聖物"
|
||||
L["Shift-RightMouse"] = true -- needs translation
|
||||
L["Reputation requirement: "] = true -- needs translation
|
||||
L["Faction repair "] = true -- needs translation
|
||||
L["Settings"] = true -- needs translation
|
||||
L["Max durability color"] = true -- needs translation
|
||||
L["The color to show for items that are at 100% durability."] = true -- needs translation
|
||||
L["High durability color"] = true -- needs translation
|
||||
L["The color to show for items that are at 90%-99% durability."] = true -- needs translation
|
||||
L["Medium durability color"] = true -- needs translation
|
||||
L["The color to show for items that are at 51%-89% durability."] = true -- needs translation
|
||||
L["Low durability color"] = true -- needs translation
|
||||
L["The color to show for items that are at 21%-50% durability."] = true -- needs translation
|
||||
L["Broken durability color"] = true -- needs translation
|
||||
L["The color to show for items that are at 0%-20% durability."] = true -- needs translation
|
||||
L["Reset"] = true -- needs translation
|
||||
L["Reset to defaults"] = true -- needs translation
|
||||
L["Resets all settings to defaults."] = true -- needs translation
|
||||
L["Open settings"] = true -- needs translation
|
||||
L["Shift-LeftMouse"] = true -- needs translation
|
||||
|
152
RepairBroker.lua
152
RepairBroker.lua
@ -26,6 +26,8 @@ local autoRepairLine = nil
|
||||
local guildRepairLine = nil
|
||||
local factionRepairLine=nil
|
||||
|
||||
local optionsFrame = {}
|
||||
|
||||
local GetInventorySlotInfo, GetContainerItemDurability, ipairs, print, UnitReaction, GetContainerNumSlots
|
||||
= GetInventorySlotInfo, GetContainerItemDurability, ipairs, print, UnitReaction, GetContainerNumSlots
|
||||
|
||||
@ -151,23 +153,145 @@ function Repair:OnLoad()
|
||||
-- Register @ LibBrokers
|
||||
Repair = LibDataBroker:NewDataObject(name, Repair)
|
||||
RepairBroker = Repair -- Register globaly
|
||||
|
||||
LibStub("AceConfig-3.0"):RegisterOptionsTable(L["RepairBroker"], Repair:GetOptions(), "repairbroker")
|
||||
optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions(L["RepairBroker"])
|
||||
end
|
||||
|
||||
function Repair:GetOptions()
|
||||
local opts = {
|
||||
name = L["RepairBroker"],
|
||||
type = "group",
|
||||
args = {
|
||||
mainSettings = {
|
||||
name = L["Settings"],
|
||||
type = "group",
|
||||
order = 1,
|
||||
args = {
|
||||
durabilityColorMax = {
|
||||
type = "color",
|
||||
name = L["Max durability color"],
|
||||
desc = L["The color to show for items that are at 100% durability."],
|
||||
get = function(info)
|
||||
local color = RepairBrokerDB["durabilityColorMax"] or {R = nil, G = nil, B = nil}
|
||||
return color.R or 0x0, color.G or 1.0 * 0x55 / 255, color.B or 0x0
|
||||
end,
|
||||
set = function(info, r, g, b)
|
||||
local color = {R = r, G = g, B = b}
|
||||
RepairBrokerDB["durabilityColorMax"] = color
|
||||
Repair:UpdateEquippedDurability()
|
||||
end,
|
||||
order = 1
|
||||
},
|
||||
durabilityColorHigh = {
|
||||
type = "color",
|
||||
name = L["High durability color"],
|
||||
desc = L["The color to show for items that are at 90%-99% durability."],
|
||||
get = function(info)
|
||||
local color = RepairBrokerDB["durabilityColorHigh"] or {R = nil, G = nil, B = nil}
|
||||
return color.R or 0x0, color.G or 1.0 * 0xAA / 255, color.B or 0x0
|
||||
end,
|
||||
set = function(info, r, g, b)
|
||||
local color = {R = r, G = g, B = b}
|
||||
RepairBrokerDB["durabilityColorHigh"] = color
|
||||
Repair:UpdateEquippedDurability()
|
||||
end,
|
||||
order = 2
|
||||
},
|
||||
durabilityColorMed = {
|
||||
type = "color",
|
||||
name = L["Medium durability color"],
|
||||
desc = L["The color to show for items that are at 51%-89% durability."],
|
||||
get = function(info)
|
||||
local color = RepairBrokerDB["durabilityColorMed"] or {R = nil, G = nil, B = nil}
|
||||
return color.R or 1.0 * 0xFF / 255, color.G or 1.0 * 0xFF / 255, color.B or 0x0
|
||||
end,
|
||||
set = function(info, r, g, b)
|
||||
local color = {R = r, G = g, B = b}
|
||||
RepairBrokerDB["durabilityColorMed"] = color
|
||||
Repair:UpdateEquippedDurability()
|
||||
end,
|
||||
order = 3
|
||||
},
|
||||
durabilityColorLow = {
|
||||
type = "color",
|
||||
name = L["Low durability color"],
|
||||
desc = L["The color to show for items that are at 21%-50% durability."],
|
||||
get = function(info)
|
||||
local color = RepairBrokerDB["durabilityColorLow"] or {R = nil, G = nil, B = nil}
|
||||
return color.R or 1.0 * 0xFF / 255, color.G or 1.0 * 0x99 / 255, color.B or 0x0
|
||||
end,
|
||||
set = function(info, r, g, b)
|
||||
local color = {R = r, G = g, B = b}
|
||||
RepairBrokerDB["durabilityColorLow"] = color
|
||||
Repair:UpdateEquippedDurability()
|
||||
end,
|
||||
order = 4
|
||||
},
|
||||
durabilityColorBroken = {
|
||||
type = "color",
|
||||
name = L["Broken durability color"],
|
||||
desc = L["The color to show for items that are at 0%-20% durability."],
|
||||
get = function(info)
|
||||
local color = RepairBrokerDB["durabilityColorBroken"] or {R = nil, G = nil, B = nil}
|
||||
return color.R or 1.0 * 0xFF / 255, color.G or 0x0, color.B or 0x0
|
||||
end,
|
||||
set = function(info, r, g, b)
|
||||
local color = {R = r, G = g, B = b}
|
||||
RepairBrokerDB["durabilityColorBroken"] = color
|
||||
Repair:UpdateEquippedDurability()
|
||||
end,
|
||||
order = 5
|
||||
},
|
||||
},
|
||||
},
|
||||
reset = {
|
||||
name = L["Reset"],
|
||||
type = "group",
|
||||
order = 2,
|
||||
args = {
|
||||
resetToDefaults = {
|
||||
type = 'execute',
|
||||
name = L["Reset to defaults"],
|
||||
desc = L["Resets all settings to defaults."],
|
||||
func = function(info)
|
||||
RepairBrokerDB["durabilityColorMax"] = nil
|
||||
RepairBrokerDB["durabilityColorHigh"] = nil
|
||||
RepairBrokerDB["durabilityColorMed"] = nil
|
||||
RepairBrokerDB["durabilityColorLow"] = nil
|
||||
RepairBrokerDB["durabilityColorBroken"] = nil
|
||||
Repair:UpdateEquippedDurability()
|
||||
end,
|
||||
order = 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
return opts
|
||||
end
|
||||
|
||||
---------------------------------
|
||||
-- Support functions
|
||||
---------------------------------
|
||||
local FormatColor = function(settingName, fallbackColor)
|
||||
local color = RepairBrokerDB[settingName]
|
||||
return color and string.format("|cFF%02X%02X%02X", color.R * 255, color.G * 255, color.B * 255) or fallbackColor
|
||||
end
|
||||
|
||||
local DurabilityColor = function(perc)
|
||||
if not perc or perc < 0 then return "|cFF555555" end
|
||||
if perc == 1 then
|
||||
return "|cFF005500" -- Dark green
|
||||
return FormatColor("durabilityColorMax", "|cFF005500") -- Dark green
|
||||
elseif perc >= .9 then
|
||||
return "|cFF00AA00" -- Green
|
||||
return FormatColor("durabilityColorHigh", "|cFF00AA00") -- Green
|
||||
elseif perc > .5 then
|
||||
return "|cFFFFFF00" -- Yellow
|
||||
return FormatColor("durabilityColorMed", "|cFFFFFF00") -- Yellow
|
||||
elseif perc > .2 then
|
||||
return "|cFFFF9900" -- Orange
|
||||
return FormatColor("durabilityColorLow", "|cFFFF9900") -- Orange
|
||||
else
|
||||
return "|cFFFF0000" -- Red
|
||||
return FormatColor("durabilityColorBroken", "|cFFFF0000") -- Red
|
||||
end
|
||||
end
|
||||
|
||||
@ -248,6 +372,8 @@ function Repair:CreateTooltipSkeleton()
|
||||
guildRepairLine = tooltip:AddLine(guildRepairState.color..L["Toggle guild bank-repair"], " ", L["MiddleMouse"])
|
||||
end
|
||||
factionRepairLine=tooltip:AddLine(factionRepairState.color..L["Reputation requirement: "] .. factionRepairState.status, " ", L["Shift-RightMouse"])
|
||||
|
||||
tooltip:AddLine(textColor..L["Open settings"], " ", L["Shift-LeftMouse"])
|
||||
end
|
||||
|
||||
do
|
||||
@ -505,7 +631,7 @@ function Repair:OnClick(button)
|
||||
tooltip:SetCell(autoRepairLine, 1, state.color..L["Toggle auto-repair"])
|
||||
end
|
||||
end
|
||||
elseif guildRepairLine and (button == "MiddleButton" or (IsShiftKeyDown() and button == "LeftButton")) then
|
||||
elseif guildRepairLine and button == "MiddleButton" then
|
||||
local state = Repair:SetNextState("guildRepair")
|
||||
|
||||
-- Ex: Guild bank-repair [green]Enable
|
||||
@ -516,9 +642,17 @@ function Repair:OnClick(button)
|
||||
tooltip:SetCell(guildRepairLine, 1, state.color..L["Toggle guild bank-repair"])
|
||||
end
|
||||
else
|
||||
print("|cFF00FF00"..L["Force durability check."])
|
||||
refreshTooltip = 0
|
||||
--Repair.OnEnter(anchorTo)
|
||||
if IsShiftKeyDown() then
|
||||
if InterfaceOptionsFrame_OpenToCategory then
|
||||
InterfaceOptionsFrame_OpenToCategory(optionsFrame)
|
||||
else
|
||||
Settings.OpenToCategory(L["RepairBroker"])
|
||||
end
|
||||
else
|
||||
print("|cFF00FF00"..L["Force durability check."])
|
||||
refreshTooltip = 0
|
||||
--Repair.OnEnter(anchorTo)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
<!--@non-debug@
|
||||
<Script file="libs\LibStub\LibStub.lua"/>
|
||||
<Script file="libs\CallbackHandler-1.0\CallbackHandler-1.0.lua"/>
|
||||
<Include file="libs\AceConfig-3.0\AceConfig-3.0.xml"/>
|
||||
<Include file="libs\AceLocale-3.0\AceLocale-3.0.xml"/>
|
||||
<Include file="libs\LibQTip-1.0\LibQTip-1.0.lua"/>
|
||||
@end-non-debug@-->
|
||||
|
Reference in New Issue
Block a user