This commit is contained in:
Robin 2021-01-13 16:20:09 +01:00
commit 545a997276
9 changed files with 316 additions and 0 deletions

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "Common"]
path = Common
url = https://git.grml.de/rilgamon/Common.git

1
Common Submodule

@ -0,0 +1 @@
Subproject commit 762c59c6c6abc6ecaa71f3e36bb2c6dd16b8e0ed

196
core.lua Normal file
View File

@ -0,0 +1,196 @@
local name, addon = ...
local parentName = addon['parentName'] or "BrokerPack"
local childName = "zz_Repair"
local defaults = {
["autorepair"] = true,
["listall"] = true,
}
local options = {
}
local db
local ldbicon = LibStub:GetLibrary("LibDBIcon-1.0")
local L = LibStub("AceLocale-3.0"):GetLocale(childName, true)
local slotNames = { "HeadSlot","NeckSlot","ShoulderSlot","BackSlot","ChestSlot","ShirtSlot","TabardSlot",
"WristSlot","HandsSlot","WaistSlot","LegsSlot","FeetSlot","Finger0Slot","Finger1Slot",
"Trinket0Slot","Trinket1Slot","MainHandSlot","SecondaryHandSlot",
"Bag0Slot","Bag1Slot","Bag2Slot","Bag3Slot"
}
local statusItem = {}
local player = UnitName('player')
local realm = GetRealmName()
local function OnText(message)
addon:OnText(childName, message)
end
local function pickColor(v)
local col = 'ffffff'
if(v > 90) then
col = '00ff00' -- grün
elseif(v > 40) then
col = 'ffff00' -- gelb
elseif(v > 0) then
col = 'ff9900' -- orange
else
col = 'ff0000' -- rot
end
return col
end
local function OnDataUpdate()
local percent = 0
local total = 0
local cur = 0
local lowest = 100
wipe(statusItem)
for k,v in pairs(slotNames) do
local val, max = GetInventoryItemDurability(GetInventorySlotInfo(v))
if(max) then
total = total + max
cur = cur + val
statusItem[v] = addon:round(val / (max/100),0)
if(statusItem[v] < lowest) then
lowest = statusItem[v]
end
end
end
if(db['showlowest']) then
percent = lowest
else
percent = addon:round(cur / (total/100),0)
end
percent = addon:colorize(percent,pickColor(percent))
OnText(percent.." %")
end
local function getGBLimit()
local amount = GetGuildBankWithdrawMoney()
local guildBankMoney = GetGuildBankMoney()
if ( amount == -1 ) then
amount = guildBankMoney
else
amount = min(amount, guildBankMoney)
end
return amount
end
local function MERCHANT_SHOW()
if(CanMerchantRepair()) then
local m = GetMoney()
local r = GetRepairAllCost()
local gbr = false
if(db['guildbankrepair']) then
if(CanGuildBankRepair()) then
gbr = true
end
end
if(r > 0 and (m > r or gbr) and db['autorepair']) then
if(gbr) then
if(getGBLimit() >= r) then
RepairAllItems(1)
addon:Print(L['repaircostgb'](r))
else
if(m > r) then
RepairAllItems()
addon:Print(L['repaircost'](r))
else
addon:Print(addon:colorize(L['Money low'],"ff0000"))
end
end
else
RepairAllItems()
addon:Print(L['repaircost'](r))
end
db['repairstats'] = db['repairstats'] or {}
db['repairstats'][player] = db['repairstats'][player] or 0
db['repairstats'][player] = db['repairstats'][player] + r
end
end
end
local function OnClick(self, button)
if(IsShiftKeyDown() and button == "LeftButton") then
addon['db']['global']['ldbicons'][childName]['hide'] = not addon['db']['global']['ldbicons'][childName]['hide']
if(ldbicon) then
if(addon['db']['global']['ldbicons'][childName]['hide']) then
ldbicon:Hide(childName)
else
ldbicon:Show(childName)
end
end
else
if(InterfaceOptionsFrame:IsVisible() and not InCombatLockdown()) then
InterfaceOptionsFrame:Hide()
else
InterfaceOptionsFrame_OpenToCategory(childName)
InterfaceOptionsFrame_OpenToCategory(childName) -- Twice because of a bug in InterfaceOptionsFrame_OpenToCategory
end
end
end
local function OnTooltip(tip)
tip:AddLine(childName)
for k,v in pairs(statusItem) do
local stat = statusItem[k]
if(db['listall'] or stat < 100) then
stat = addon:colorize(stat,pickColor(stat))
tip:AddDoubleLine(L[k], stat.." %")
end
end
tip:AddLine(" ")
tip:AddLine(L["Repair Charts"])
local tmp = {}
if(addon['db']['sv']['profileKeys']) then
for k,v in pairs(addon['db']['sv']['profileKeys']) do
local n,_,m = strsplit(' ',k,3)
if(n) then
if(m == realm) then
if(db['repairstats'] and db['repairstats'][n] and db['repairstats'][n] > 0) then
tmp[n] = db['repairstats'][n]
end
end
end
end
end
for _,v in pairs(addon:sortArray(tmp,false)) do
tip:AddDoubleLine(addon:classcolor(v,db['classes'][v]), addon:buildMoneyString(db['repairstats'][v] or 0))
end
tip:AddLine(" ")
tip:AddLine(L['HINT3'])
end
local function getPref(info)
return db[info[#info]]
end
local function setPref(info,value)
db[info[#info]] = value
OnDataUpdate()
end
local function init()
realm = GetRealmName()
options = addon:InitConfig(childName, true, {
['name'] = childName,
['type'] = "data source",
['OnClick'] = OnClick,
['OnTooltipShow'] = OnTooltip,
}, getPref, setPref)
db = addon['db']['profile'][childName]
db['classes'] = db['classes'] or {}
local _, class, _ = UnitClass('player')
db['classes'][player] = class
db['repairstats'] = db['repairstats'] or {}
addon:AddConfigEntry(childName,"toggle","autorepair",L['Autorepair'],nil,1,nil,nil,nil,nil,options['args'][childName])
addon:AddConfigEntry(childName,"toggle","showlowest",L['Show lowest'],L['Show durability of your lowest item only'],1,nil,nil,nil,nil,options['args'][childName])
addon:AddConfigEntry(childName,"toggle","listall",L['Show all slots'],L['Show all slots in the tooltip instead of damaged only'],1,nil,nil,nil,nil,options['args'][childName])
addon:AddConfigEntry(childName,"toggle","guildbankrepair",L['Allow Guildbank Repair'],nil,1,nil,nil,nil,nil,options['args'][childName])
addon:RegisterFunc({'MERCHANT_SHOW'},"OnEvent", MERCHANT_SHOW)
addon:RegisterEventThrottle(childName,{"UPDATE_INVENTORY_DURABILITY","UPDATE_INVENTORY_ALERTS","UNIT_INVENTORY_CHANGED"}, 2, OnDataUpdate)
OnDataUpdate()
end
addon:startup(name, childName, init, true, defaults)

BIN
icon2.tga Normal file

Binary file not shown.

6
license.txt Normal file
View File

@ -0,0 +1,6 @@
The following license excludes the libraries (Libs) included. See the libraries directory or website.
This AddOn is public domain. That means you can change it, rename it or paint it yellow.
My name (Rilgamon) is valid only for WoWInterface.com and curse.com.
If you use/offer this addon on another website please remove my name.
If you want to give me credit you can replace it with a link to my profile on WoWInterface.com.

48
locale_deDE.lua Normal file
View File

@ -0,0 +1,48 @@
local addonname, addon = ...
local name = "zz_Repair"
local L = LibStub("AceLocale-3.0"):NewLocale(name, "deDE", false)
if L then
L[name] = name
L[name..' Settings'] = name..' Einstellungen'
L['Autorepair'] = 'Automatisch reparieren'
L['Show lowest'] = 'Zeige Niedrigstes'
L['Show durability of your lowest item only'] = 'Zeigt die Haltbarkeit des niedrigsten Ausr\195\188stungsgegenstands statt dem Durchschnitt'
L['Show all slots'] = 'Zeige alle Slots'
L['Show all slots in the tooltip instead of damaged only'] ='Zeigt im Tooltip auch nicht besch\195\164digte Items'
L["HeadSlot"] = 'Kopf'
L["NeckSlot"] = 'Hals'
L["ShoulderSlot"] = 'Schulter'
L["BackSlot"] = 'R\195\188cken'
L["ChestSlot"] = 'Brust'
L["ShirtSlot"] = 'Hemd'
L["TabardSlot"] = 'Wappenrock'
L["WristSlot"] = 'Handgelenk'
L["HandsSlot"] = 'H\195\164nde'
L["WaistSlot"] = 'Taille'
L["LegsSlot"] = 'Beine'
L["FeetSlot"] = 'F\195\188\195\159e'
L["Finger0Slot"] = 'Erster Ring'
L["Finger1Slot"] = 'Zweiter Ring'
L["Trinket0Slot"] = 'Erstes Schmuckst\195\188ck'
L["Trinket1Slot"] = 'Zweites Schmuckst\195\188ck'
L["MainHandSlot"] = 'Waffenhand'
L["SecondaryHandSlot"] = 'Nebenhand'
L["RangedSlot"] = 'Fernkampf'
L["AmmoSlot"] = 'Munition'
L["Bag0Slot"] = 'Erste Tasche'
L["Bag1Slot"] = 'Zweite Tasche'
L["Bag2Slot"] = 'Dritte Tasche'
L["Bag3Slot"] = 'Vierte Tasche'
L['repaircost'] = function(r) return "Verschwendete Reparaturkosten: "..addon:buildMoneyString(r) end
L['repaircostgb'] = function(r) return "Verschwendete Reparaturkosten zu Lasten der Gildenbank: "..addon:buildMoneyString(r) end
L["Repair Charts"] = "Repair Charts"
L['Allow Guildbank Repair'] = "Repariere aus Gildenbank"
L['Money low'] = "Nicht genug Geld f\195\188r Reparatur!"
L['HINT3'] = "|c0000ff00Shift-Linksklick|r |c00ffffffschaltet Minimapicon an/aus|r"
end
-- ö \195\182 ß \195\159
-- ü \195\188 ä \195\164
-- Ä \195\132
-- ö \195\182
-- Ü \195\156

42
locale_enUS.lua Normal file
View File

@ -0,0 +1,42 @@
local addonname, addon = ...
local name = "zz_Repair"
local L = LibStub("AceLocale-3.0"):NewLocale(name, "enUS", true)
if L then
L[name] = name
L[name..' Settings'] = name..' Settings'
L['Autorepair'] = 'Automatic repair'
L['Show lowest'] = 'Show lowest'
L['Show durability of your lowest item only'] = 'Show durability of your lowest item only'
L['Show all slots'] = 'Show all slots'
L['Show all slots in the tooltip instead of damaged only'] ='Show all slots in the tooltip instead of damaged only'
L["HeadSlot"] = 'Head'
L["NeckSlot"] = 'Neck'
L["ShoulderSlot"] = 'Shoulder'
L["BackSlot"] = 'Back'
L["ChestSlot"] = 'Chest'
L["ShirtSlot"] = 'Shirt'
L["TabardSlot"] = 'Tabard'
L["WristSlot"] = 'Wrist'
L["HandsSlot"] = 'Hands'
L["WaistSlot"] = 'Waist'
L["LegsSlot"] = 'Legs'
L["FeetSlot"] = 'Feet'
L["Finger0Slot"] = 'First Ring'
L["Finger1Slot"] = 'Second Ring'
L["Trinket0Slot"] = 'First Trinket'
L["Trinket1Slot"] = 'Second Trinket'
L["MainHandSlot"] = 'Main Hand'
L["SecondaryHandSlot"] = 'Offhand'
L["RangedSlot"] = 'Ranged'
L["AmmoSlot"] = 'Munition'
L["Bag0Slot"] = 'First Bag'
L["Bag1Slot"] = 'Second Bag'
L["Bag2Slot"] = 'Third Bag'
L["Bag3Slot"] = 'Fourth Bag'
L['repaircost'] = function(r) return "Wasted money for repairs: "..addon:buildMoneyString(r) end
L['repaircostgb'] = function(r) return "Wasted guildvaults money for repairs: "..addon:buildMoneyString(r) end
L["Repair Charts"] = "Repair Charts"
L['Allow Guildbank Repair'] = true
L['Money low'] = "No fund for repair!"
L['HINT3'] = "|c0000ff00Shift-Leftclick|r |c00fffffftoggles minimap icon|r"
end

5
pack.xml Normal file
View File

@ -0,0 +1,5 @@
<Ui xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\FrameXML\UI.xsd">
<script file="locale_deDE.lua"/>
<script file="locale_enUS.lua"/>
<Script file="core.lua"/>
</Ui>

15
zz_Repair.toc Normal file
View File

@ -0,0 +1,15 @@
## Interface: 90002
## X-Repository: https://svn.grml.de/zz_Repair
## X-WoWI-ID: 15491
## X-Curse-Project-ID: 39023
## X-TOC-Classic: 11302
## Title: Repair
## Notes: Broker to display your durability
## Notes-deDE: Broker zur Anzeige der Haltbarkeit
## Author: Rilgamon
## SavedVariables: zz_RepairDB
## LoadManagers: AddonLoader
## X-LoadOn-Always: delayed
## OptionalDeps: Ace3,BrokerPack,zzLibCommon
Common\common.xml
pack.xml