Browse Source

update crafting and warehousing

dev
Jørgen Lien Sellæg 4 months ago
parent
commit
7952573bab
  1. 2
      TradeSkillMaster/TradeSkillMaster.toc
  2. 4
      TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc
  3. 5
      TradeSkillMaster_Crafting/Locale/enUS.lua
  4. 428
      TradeSkillMaster_Crafting/Modules/CraftingGUI.lua
  5. 6
      TradeSkillMaster_Crafting/TradeSkillMaster_Crafting.lua
  6. 5
      TradeSkillMaster_Warehousing/Locale/enUS.lua
  7. 15
      TradeSkillMaster_Warehousing/Modules/bankui.lua
  8. 53
      TradeSkillMaster_Warehousing/Modules/move.lua

2
TradeSkillMaster/TradeSkillMaster.toc

@ -2,7 +2,7 @@
## Title: |cff00fe00TradeSkillMaster: Revived|r ## Title: |cff00fe00TradeSkillMaster: Revived|r
## Notes: Core addon for the TradeSkillMaster suite, revived for Wrath of the Lich King. Does nothing without modules installed. ## Notes: Core addon for the TradeSkillMaster suite, revived for Wrath of the Lich King. Does nothing without modules installed.
## Author: Sapu94, Bart39, Gnomezilla [Warmane-Icecrown(A)], BlueAo [Warmane], andrew6180, Yoshiyuka, DimaSheiko, and other contributors... ## Author: Sapu94, Bart39, Gnomezilla [Warmane-Icecrown(A)], BlueAo [Warmane], andrew6180, Yoshiyuka, DimaSheiko, and other contributors...
## Version: 2.3.22 ## Version: 2.3.23
## SavedVariables: TradeSkillMasterAppDB, AscensionTSMDB ## SavedVariables: TradeSkillMasterAppDB, AscensionTSMDB
## OptionalDeps: AccurateTime, Ace3, LibDataBroker-1.1, LibDBIcon-1.0, LibExtraTip, TipHelper, LibParse, LibCompress, LibGraph-2.0, SharedMedia, TheUndermineJournal, TheUndermineJournalGE ## OptionalDeps: AccurateTime, Ace3, LibDataBroker-1.1, LibDBIcon-1.0, LibExtraTip, TipHelper, LibParse, LibCompress, LibGraph-2.0, SharedMedia, TheUndermineJournal, TheUndermineJournalGE
## X-Embeds: AccurateTime, Ace3, LibDataBroker-1.1, LibDBIcon-1.0, LibExtraTip, TipHelper, LibParse, LibCompress, LibGraph-2.0 ## X-Embeds: AccurateTime, Ace3, LibDataBroker-1.1, LibDBIcon-1.0, LibExtraTip, TipHelper, LibParse, LibCompress, LibGraph-2.0

4
TradeSkillMaster_AuctionDB/TradeSkillMaster_AuctionDB.toc

@ -2,10 +2,10 @@
## Title: |cff00ff00TradeSkillMaster_AuctionDB|r ## Title: |cff00ff00TradeSkillMaster_AuctionDB|r
## Notes: Stores auction house data and calculates market prices. ## Notes: Stores auction house data and calculates market prices.
## Author: Sapu94, Bart39 ## Author: Sapu94, Bart39
## Version: 2.3.22 ## Version: 2.3.23
## SavedVariables: AscensionTSM_AuctionDB ## SavedVariables: AscensionTSM_AuctionDB
## Dependency: TradeSkillMaster ## Dependency: TradeSkillMaster
## X-Curse-Packaged-Version: 2.3.22 ## X-Curse-Packaged-Version: 2.3.23
## X-Curse-Project-Name: TradeSkillMaster_AuctionDB ## X-Curse-Project-Name: TradeSkillMaster_AuctionDB
## X-Curse-Project-ID: tradeskillmaster_auctiondb ## X-Curse-Project-ID: tradeskillmaster_auctiondb
## X-Curse-Repository-ID: wow/tradeskillmaster_auctiondb/mainline ## X-Curse-Repository-ID: wow/tradeskillmaster_auctiondb/mainline

5
TradeSkillMaster_Crafting/Locale/enUS.lua

@ -40,6 +40,9 @@ L["Craft Value Method"] = true
L["Craft Queue"] = true L["Craft Queue"] = true
L["Crafter"] = true L["Crafter"] = true
L["Crafts"] = true L["Crafts"] = true
L["All Professions"] = true
L["Available"] = true
L["Cost"] = true
L["Crafting Cost"] = true L["Crafting Cost"] = true
L["Crafting Material Cost"] = true L["Crafting Material Cost"] = true
L["Crafting operations contain settings for restocking the items in a group. Type the name of the new operation into the box below and hit 'enter' to create a new Crafting operation."] = true L["Crafting operations contain settings for restocking the items in a group. Type the name of the new operation into the box below and hit 'enter' to create a new Crafting operation."] = true
@ -175,4 +178,4 @@ L["Would you like to automatically create some TradeSkillMaster groups for this
L["You can click on one of the rows of the scrolling table below to view or adjust how the price of a material is calculated."] = true L["You can click on one of the rows of the scrolling table below to view or adjust how the price of a material is calculated."] = true
L["You can left/right click on a row to add/remove a craft from the crafting queue."] = true L["You can left/right click on a row to add/remove a craft from the crafting queue."] = true
L["Your craft value method for '%s' was invalid so it has been returned to the default. Details: %s"] = true L["Your craft value method for '%s' was invalid so it has been returned to the default. Details: %s"] = true
L["Your default craft value method was invalid so it has been returned to the default. Details: %s"] = true L["Your default craft value method was invalid so it has been returned to the default. Details: %s"] = true

428
TradeSkillMaster_Crafting/Modules/CraftingGUI.lua

@ -140,7 +140,12 @@ function GUI:ShowProfessionWindow()
GUI:UpdateTradeSkills(GetTradeSkillLine()) GUI:UpdateTradeSkills(GetTradeSkillLine())
TradeSkillFrame:SetScript("OnHide", nil) TradeSkillFrame:SetScript("OnHide", nil)
HideUIPanel(TradeSkillFrame) HideUIPanel(TradeSkillFrame)
TradeSkillFrame:SetScript("OnHide", function() if not GUI.noClose then GUI.switchBtn:Hide() CloseTradeSkill() end end) TradeSkillFrame:SetScript("OnHide", function()
if not GUI.noClose and not GUI.switchingProfession then
GUI.switchBtn:Hide()
CloseTradeSkill()
end
end)
priceTextCache.lastClear = 0 priceTextCache.lastClear = 0
GUI.switchBtn:Update() GUI.switchBtn:Update()
@ -202,6 +207,7 @@ function GUI:EventHandler(event, ...)
local unittest = ... local unittest = ...
if unittest == "player" or unittest==nil then --Changing tradeskill frames and stuff has "nil" unit, when other players cast this also triggers with nil if unittest == "player" or unittest==nil then --Changing tradeskill frames and stuff has "nil" unit, when other players cast this also triggers with nil
if event == "TRADE_SKILL_CLOSE" then if event == "TRADE_SKILL_CLOSE" then
if GUI.switchingProfession then return end
GUI.frame:Hide() GUI.frame:Hide()
elseif event == "TRADE_SKILL_UPDATE" or event == "TRADE_SKILL_FILTER_UPDATE" then elseif event == "TRADE_SKILL_UPDATE" or event == "TRADE_SKILL_FILTER_UPDATE" then
if GetTradeSkillLine() ~= GUI.currentTradeSkill or select(2, IsTradeSkillLinked()) ~= GUI.currentLinkedPlayer then if GetTradeSkillLine() ~= GUI.currentTradeSkill or select(2, IsTradeSkillLinked()) ~= GUI.currentLinkedPlayer then
@ -475,13 +481,13 @@ function GUI:CreateGUI()
local frameDefaults = { local frameDefaults = {
x = 100, x = 100,
y = 300, y = 300,
width = 450, width = 520,
height = 500, height = 500,
scale = 1, scale = 1,
} }
local frame = TSMAPI:CreateMovableFrame("TSMCraftingTradeSkillFrame", frameDefaults) local frame = TSMAPI:CreateMovableFrame("TSMCraftingTradeSkillFrame", frameDefaults)
frame:SetResizable(true) frame:SetResizable(true)
frame:SetMinResize(450, 400) frame:SetMinResize(520, 400)
TSMAPI.Design:SetFrameBackdropColor(frame) TSMAPI.Design:SetFrameBackdropColor(frame)
frame:Show() frame:Show()
frame:SetScript("OnHide", function() if not GUI.noClose then GUI.switchBtn:Hide() TradeSkillFrame:Show() CloseTradeSkill() end end) frame:SetScript("OnHide", function() if not GUI.noClose then GUI.switchBtn:Hide() TradeSkillFrame:Show() CloseTradeSkill() end end)
@ -900,17 +906,52 @@ function GUI:CreateProfessionsTab(parent)
local currentSelection local currentSelection
local player = UnitName("player") local player = UnitName("player")
local function SetNoClose()
GUI.noClose = true
GUI.switchingProfession = true
TSMAPI:CreateTimeDelay("craftingNoCloseClear", 0.6, function() GUI.noClose = nil end)
TSMAPI:CreateTimeDelay("craftingSwitchingClear", 0.8, function() GUI.switchingProfession = nil end)
end
local function SelectSpellInProfession(profession, spellID)
if GetTradeSkillLine() ~= profession then
local link = TSM.db.realm.tradeSkills[player] and TSM.db.realm.tradeSkills[player][profession] and TSM.db.realm.tradeSkills[player][profession].link
if not link then return end
local tradeString = strsub(select(3, ("|"):split(link)), 2)
SetNoClose()
SetItemRef(tradeString, link, "LeftButton", ChatFrame1)
return
end
for i = 1, GetNumTradeSkills() do
if TSM.Util:GetSpellID(i) == spellID then
TradeSkillFrame_SetSelection(i)
TradeSkillFrame_Update()
GUI:UpdateSelectedTradeSkill(true)
return
end
end
end
local HaveMatsCheckBox
local function UpdateProfession(self) local function UpdateProfession(self)
local list = {} local list = {}
list["ALL"] = L["All Professions"]
for playerName, professionData in pairs(TSM.db.realm.tradeSkills) do for playerName, professionData in pairs(TSM.db.realm.tradeSkills) do
for name, data in pairs(professionData) do for name, data in pairs(professionData) do
if not data.isSecondary and playerName == player then -- only display current player profs until blizz fix it if playerName == player then -- only display current player profs until blizz fix it
list[playerName .. "~" .. name] = format("%s %d/%d - %s", name, data.level or "?", data.maxLevel or "?", playerName) list[playerName .. "~" .. name] = format("%s %d/%d - %s", name, data.level or "?", data.maxLevel or "?", playerName)
end end
end end
end end
self.dropdown:SetList(list) self.dropdown:SetList(list)
if TSM.db.global.showAllProfessions then
self.dropdown:SetValue("ALL")
self.dropdown:SetText(L["All Professions"])
return
end
local playerName = select(2, IsTradeSkillLinked()) or player local playerName = select(2, IsTradeSkillLinked()) or player
local professionName, level, maxLevel = GetTradeSkillLine() local professionName, level, maxLevel = GetTradeSkillLine()
local professionString = format("%s %d/%d - %s", professionName, level, maxLevel, playerName) local professionString = format("%s %d/%d - %s", professionName, level, maxLevel, playerName)
@ -925,13 +966,36 @@ function GUI:CreateProfessionsTab(parent)
frame:SetScript("OnShow", UpdateProfession) frame:SetScript("OnShow", UpdateProfession)
local function OnValueChanged(_, _, index) local function OnValueChanged(_, _, index)
if index == "ALL" then
TSM.db.global.showAllProfessions = true
frame:UpdateProfession()
GUI:UpdateProfessionsTabST()
return
end
if TSM.db.global.showAllProfessions then
SetNoClose()
TSM.db.global.showAllProfessions = false
end
local playerName, profession = ("~"):split(index) local playerName, profession = ("~"):split(index)
local currentPlayer = select(2, IsTradeSkillLinked()) or player
local currentProfession = GetTradeSkillLine()
if playerName == currentPlayer and profession == currentProfession then
frame:UpdateProfession()
GUI:ShowProfessionsTab()
currentSelection = index
return
end
if playerName == player then if playerName == player then
if profession == "Mining" then local link = TSM.db.realm.tradeSkills[playerName] and TSM.db.realm.tradeSkills[playerName][profession] and TSM.db.realm.tradeSkills[playerName][profession].link
CastSpellByName("Smelting") if not link then
else TSM:Printf(L["Profession data not found for %s on %s. Logging into this player and opening the profession may solve this issue."], profession, playerName)
CastSpellByName(profession) return OnValueChanged(_, _, currentSelection)
end end
local tradeString = strsub(select(3, ("|"):split(link)), 2)
SetNoClose()
SetItemRef(tradeString, link, "LeftButton", ChatFrame1)
else else
local link = TSM.db.realm.tradeSkills[playerName][profession].link local link = TSM.db.realm.tradeSkills[playerName][profession].link
if not link then if not link then
@ -939,7 +1003,8 @@ function GUI:CreateProfessionsTab(parent)
return OnValueChanged(_, _, currentSelection) return OnValueChanged(_, _, currentSelection)
end end
local tradeString = strsub(select(3, ("|"):split(link)), 2) local tradeString = strsub(select(3, ("|"):split(link)), 2)
SetItemRef(tradeString, link) SetNoClose()
SetItemRef(tradeString, link, "LeftButton", ChatFrame1)
end end
currentSelection = index currentSelection = index
end end
@ -951,15 +1016,19 @@ function GUI:CreateProfessionsTab(parent)
dd:SetCallback("OnValueChanged", OnValueChanged) dd:SetCallback("OnValueChanged", OnValueChanged)
frame.dropdown = dd frame.dropdown = dd
local HaveMatsCheckBox = TSMAPI.GUI:CreateCheckBox(frame) HaveMatsCheckBox = TSMAPI.GUI:CreateCheckBox(frame)
HaveMatsCheckBox:SetLabel(" Have Mats") HaveMatsCheckBox:SetLabel(" Have Mats")
HaveMatsCheckBox:SetPoint("TOPLEFT", 252, -4) HaveMatsCheckBox:SetPoint("TOPLEFT", 252, -4)
HaveMatsCheckBox:SetWidth(90) HaveMatsCheckBox:SetWidth(90)
HaveMatsCheckBox:SetHeight(26) HaveMatsCheckBox:SetHeight(26)
frame.HaveMatsCheckBox = HaveMatsCheckBox frame.HaveMatsCheckBox = HaveMatsCheckBox
HaveMatsCheckBox:SetCallback("OnValueChanged", function(_, _, value) HaveMatsCheckBox:SetCallback("OnValueChanged", function(_, _, value)
TradeSkillFrameAvailableFilterCheckButton:SetChecked(value) if TSM.db.global.showAllProfessions then
TradeSkillOnlyShowMakeable(value) GUI:UpdateProfessionsTabST()
else
TradeSkillFrameAvailableFilterCheckButton:SetChecked(value)
TradeSkillOnlyShowMakeable(value)
end
end) end)
local RestockBtn = TSMAPI.GUI:CreateButton(frame, 14) local RestockBtn = TSMAPI.GUI:CreateButton(frame, 14)
@ -971,6 +1040,7 @@ function GUI:CreateProfessionsTab(parent)
QuickRestock = true QuickRestock = true
GUI.ShowGroupsTab() GUI.ShowGroupsTab()
end) end)
frame.restockBtn = RestockBtn
local linkBtn = TSMAPI.GUI:CreateButton(frame, 14) local linkBtn = TSMAPI.GUI:CreateButton(frame, 14)
linkBtn:SetPoint("TOPRIGHT", -5, -4) linkBtn:SetPoint("TOPRIGHT", -5, -4)
@ -1029,7 +1099,9 @@ function GUI:CreateProfessionsTab(parent)
end) end)
searchBar:SetScript("OnTextChanged", function(self) searchBar:SetScript("OnTextChanged", function(self)
local text = self:GetText() local text = self:GetText()
SetTradeSkillItemNameFilter(text == SEARCH and "" or text) if not TSM.db.global.showAllProfessions then
SetTradeSkillItemNameFilter(text == SEARCH and "" or text)
end
GUI:UpdateProfessionsTabST() GUI:UpdateProfessionsTabST()
end) end)
searchBar:SetScript("OnEnterPressed", searchBar.ClearFocus) searchBar:SetScript("OnEnterPressed", searchBar.ClearFocus)
@ -1070,7 +1142,17 @@ function GUI:CreateProfessionsTab(parent)
TSMAPI.GUI:CreateHorizontalLine(frame, -64) TSMAPI.GUI:CreateHorizontalLine(frame, -64)
local function OnSTRowClick(_, data, _, button) local function OnSTRowClick(_, data, _, button)
if data.isCollapseAll then if TSM.db.global.showAllProfessions and data.spellID then
if IsModifiedClick() then
local itemID = TSM.db.realm.crafts[data.spellID] and TSM.db.realm.crafts[data.spellID].itemID
if itemID then
HandleModifiedItemClick(itemID)
end
else
SelectSpellInProfession(data.profession, data.spellID)
end
return
elseif data.isCollapseAll then
TradeSkillCollapseAllButton:Click() TradeSkillCollapseAllButton:Click()
GUI:UpdateProfessionsTabST() GUI:UpdateProfessionsTabST()
elseif button == "LeftButton" then elseif button == "LeftButton" then
@ -1084,24 +1166,27 @@ function GUI:CreateProfessionsTab(parent)
end end
end end
local function GetPriceColumnText()
if TSM.db.global.priceColumn == 1 then
return L["Crafting Cost"]
elseif TSM.db.global.priceColumn == 2 then
return L["Item Value"]
elseif TSM.db.global.priceColumn == 3 then
return L["Profit"]
end
end
local function OnSTColumnClick(self) local function OnSTColumnClick(self)
if self.colNum == 2 then if TSM.db.global.showAllProfessions then
TSM.db.global.priceColumn = TSM.db.global.priceColumn + 1 local sortKey
TSM.db.global.priceColumn = TSM.db.global.priceColumn > 3 and 1 or TSM.db.global.priceColumn if self.colNum == 1 then
self:SetText(GetPriceColumnText()) sortKey = "available"
wipe(priceTextCache) elseif self.colNum == 3 then
priceTextCache.lastClear = time() sortKey = "cost"
GUI:UpdateProfessionsTabST() elseif self.colNum == 4 then
sortKey = "profit"
elseif self.colNum == 5 then
sortKey = "profitPercent"
end
if sortKey then
if TSM.db.global.showAllProfessionsSortKey ~= sortKey then
TSM.db.global.showAllProfessionsSortKey = sortKey
TSM.db.global.showAllProfessionsSortDescending = true
else
TSM.db.global.showAllProfessionsSortDescending = not TSM.db.global.showAllProfessionsSortDescending
end
GUI:UpdateProfessionsTabST()
end
end end
end end
@ -1112,11 +1197,11 @@ function GUI:CreateProfessionsTab(parent)
TSMAPI.Design:SetFrameColor(stContainer) TSMAPI.Design:SetFrameColor(stContainer)
local stCols = { local stCols = {
-- { name = L["Name"], width = 0.725, align = "LEFT" }, { name = "#", width = 0.08, align = "LEFT", headAlign = "LEFT" },
-- { name = GetPriceColumnText(), width = 0.275, align = "LEFT" }, { name = L["Name"], width = 0.40, align = "LEFT", headAlign = "LEFT" },
{ name = L["Name"], width = 0.7, align = "LEFT" }, { name = L["Cost"], width = 0.16, align = "LEFT", headAlign = "LEFT" },
{ name = GetPriceColumnText(), width = 0.2, align = "LEFT" }, { name = L["Profit"], width = 0.18, align = "LEFT", headAlign = "LEFT" },
{ name = "P. %", width = 0.1, align = "LEFT" } { name = "%", width = 0.08, align = "LEFT", headAlign = "LEFT" }
} }
frame.st = TSMAPI:CreateScrollingTable(stContainer, stCols, { OnClick = OnSTRowClick, OnColumnClick = OnSTColumnClick }) frame.st = TSMAPI:CreateScrollingTable(stContainer, stCols, { OnClick = OnSTRowClick, OnColumnClick = OnSTColumnClick })
@ -1510,6 +1595,8 @@ function GUI:UpdateProfessionsTabST()
local stData = {} local stData = {}
TSM:UpdateCraftReverseLookup() TSM:UpdateCraftReverseLookup()
local showAll = TSM.db.global.showAllProfessions
local player = UnitName("player")
local function RGBPercToHex(tbl) local function RGBPercToHex(tbl)
local r = tbl.r local r = tbl.r
@ -1526,25 +1613,206 @@ function GUI:UpdateProfessionsTabST()
priceTextCache.lastClear = time() priceTextCache.lastClear = time()
end end
local function GetInventoryTotals()
local totals = {}
local bags = TSMAPI:ModuleAPI("ItemTracker", "playerbags", player)
local bank = TSMAPI:ModuleAPI("ItemTracker", "playerbank", player)
if bags or bank then
for itemString, quantity in pairs(bags or {}) do
totals[itemString] = (totals[itemString] or 0) + quantity
end
for itemString, quantity in pairs(bank or {}) do
totals[itemString] = (totals[itemString] or 0) + quantity
end
return totals
end
return select(4, TSM.Inventory:GetTotals())
end
local ts = ""
local numAvailableAllCache = {}
local inventoryTotals = GetInventoryTotals()
if showAll then
local searchText = GUI.frame and GUI.frame.content and GUI.frame.content.professionsTab and GUI.frame.content.professionsTab.searchBar and GUI.frame.content.professionsTab.searchBar:GetText() or ""
if searchText == SEARCH then
searchText = ""
end
searchText = strlower(searchText or "")
local filterHaveMats = GUI.frame and GUI.frame.content and GUI.frame.content.professionsTab and GUI.frame.content.professionsTab.HaveMatsCheckBox and GUI.frame.content.professionsTab.HaveMatsCheckBox:GetValue()
local craftList = {}
for spellID, data in pairs(TSM.db.realm.crafts) do
if data.players and data.players[UnitName("player")] then
tinsert(craftList, {
spellID = spellID,
name = data.name or "",
profession = data.profession or UNKNOWN,
numResult = data.numResult or 1,
})
end
end
for _, craft in ipairs(craftList) do
craft.cost, craft.buyout, craft.profit = TSM.Cost:GetCraftPrices(craft.spellID)
if craft.profit and craft.cost and craft.cost > 0 then
craft.profitPercent = (craft.profit / craft.cost) * 100
else
craft.profitPercent = nil
end
local available = math.huge
if TSM.db.realm.crafts[craft.spellID] then
for itemString, quantity in pairs(TSM.db.realm.crafts[craft.spellID].mats) do
available = min(available, floor((inventoryTotals[itemString] or 0) / quantity))
end
end
craft.available = available ~= math.huge and available or 0
end
if searchText ~= "" or filterHaveMats then
local filtered = {}
for _, craft in ipairs(craftList) do
if (searchText == "" or strfind(strlower(craft.name or ""), searchText, 1, true)) and (not filterHaveMats or craft.available > 0) then
tinsert(filtered, craft)
end
end
craftList = filtered
end
if TSM.db.global.showAllProfessionsSortKey == "cost" then
sort(craftList, function(a, b)
local aValue = tonumber(a.cost) or math.huge
local bValue = tonumber(b.cost) or math.huge
if aValue == bValue then
return a.name < b.name
end
if TSM.db.global.showAllProfessionsSortDescending then
return aValue > bValue
end
return aValue < bValue
end)
elseif TSM.db.global.showAllProfessionsSortKey == "profit" then
sort(craftList, function(a, b)
local aValue = tonumber(a.profit) or -math.huge
local bValue = tonumber(b.profit) or -math.huge
if aValue == bValue then
return a.name < b.name
end
if TSM.db.global.showAllProfessionsSortDescending then
return aValue > bValue
end
return aValue < bValue
end)
elseif TSM.db.global.showAllProfessionsSortKey == "available" then
sort(craftList, function(a, b)
local aValue = tonumber(a.available) or -math.huge
local bValue = tonumber(b.available) or -math.huge
if aValue == bValue then
return a.name < b.name
end
if TSM.db.global.showAllProfessionsSortDescending then
return aValue > bValue
end
return aValue < bValue
end)
elseif TSM.db.global.showAllProfessionsSortKey == "profitPercent" then
sort(craftList, function(a, b)
local aValue = tonumber(a.profitPercent) or -math.huge
local bValue = tonumber(b.profitPercent) or -math.huge
if aValue == bValue then
return a.name < b.name
end
if TSM.db.global.showAllProfessionsSortDescending then
return aValue > bValue
end
return aValue < bValue
end)
else
sort(craftList, function(a, b)
if TSM.db.global.showAllProfessionsSortDescending then
return a.name > b.name
end
return a.name < b.name
end)
end
for _, craft in ipairs(craftList) do
local spellID = craft.spellID
local craftName = craft.name
if not numAvailableAllCache[spellID] then
local numAvailableAll = math.huge
if spellID and TSM.db.realm.crafts[spellID] then
for itemString, quantity in pairs(TSM.db.realm.crafts[spellID].mats) do
numAvailableAll = min(numAvailableAll, floor((inventoryTotals[itemString] or 0) / quantity))
end
end
if numAvailableAll ~= math.huge then
numAvailableAllCache[spellID] = numAvailableAll
end
end
local available = craft.available or 0
local displayName = craftName
local costText
local profitText
local cost, _, profit = craft.cost, craft.buyout, craft.profit
if cost and cost > 0 then
costText = TSMAPI:FormatTextMoney(cost, TSMAPI.Design:GetInlineColor("link"))
else
costText = "---"
end
if profit then
if profit < 0 then
profitText = "|cffff0000-|r" .. TSMAPI:FormatTextMoney(-profit, "|cffff0000")
else
profitText = TSMAPI:FormatTextMoney(profit, "|cff00ff00")
end
else
profitText = "---"
end
local profitPercent = "---"
if profit and cost and cost > 0 then
profitPercent = craft.profitPercent
if profit < 0 then
profitPercent = format("%s%.0f%%|r", "|cffff0000", profitPercent)
else
profitPercent = format("%s%.0f%%|r", "|cff00ff00", profitPercent)
end
end
tinsert(stData, {
cols = {
{ value = available },
{ value = displayName },
{ value = costText or "" },
{ value = profitText or "" },
{ value = profitPercent or "" },
},
spellID = spellID,
profession = craft.profession,
})
end
local frame = GUI.frame.content.professionsTab
frame.st:SetData(stData)
return
end
local collapseAllRow = { local collapseAllRow = {
cols = { cols = {
{ value = "" },
{ {
value = "|cff" .. RGBPercToHex(TradeSkillTypeColor.header) .. ALL .. " [" .. (TradeSkillCollapseAllButton.collapsed and "+" or "-") .. "]|r", value = "|cff" .. RGBPercToHex(TradeSkillTypeColor.header) .. ALL .. " [" .. (TradeSkillCollapseAllButton.collapsed and "+" or "-") .. "]|r",
}, },
{ { value = "" },
value = "", { value = "" },
}, { value = "" },
{
value = "",
},
}, },
isCollapseAll = true, isCollapseAll = true,
} }
tinsert(stData, collapseAllRow) tinsert(stData, collapseAllRow)
local ts = ""
local numAvailableAllCache = {}
local inventoryTotals = select(4, TSM.Inventory:GetTotals())
for i = 1, GetNumTradeSkills() do for i = 1, GetNumTradeSkills() do
-- local skillName, skillType, numAvailable, isExpanded, _, numSkillUps, _, showProgressBar, currentRank, maxRank = GetTradeSkillInfo(i) -- local skillName, skillType, numAvailable, isExpanded, _, numSkillUps, _, showProgressBar, currentRank, maxRank = GetTradeSkillInfo(i)
local skillName, skillType, numAvailable, isExpanded, _ = GetTradeSkillInfo(i) local skillName, skillType, numAvailable, isExpanded, _ = GetTradeSkillInfo(i)
@ -1580,50 +1848,29 @@ function GUI:UpdateProfessionsTabST()
end end
end end
if numAvailable > 0 or (numAvailableAllCache[spellID] and numAvailableAllCache[spellID] > 0) then local available = numAvailableAllCache[spellID] or 0
local availableText = numAvailable .. " (" .. (numAvailableAllCache[spellID] or 0) .. ")" skillName = ts .. "|cff" .. RGBPercToHex(TradeSkillTypeColor[skillType]) .. skillName .. "|r"
skillName = ts .. "|cff" .. RGBPercToHex(TradeSkillTypeColor[skillType]) .. skillName .. " [" .. availableText .. "]|r"
local costText
local profitText
local cost, _, profit = TSM.Cost:GetCraftPrices(spellID)
if cost and cost > 0 then
costText = TSMAPI:FormatTextMoney(cost, TSMAPI.Design:GetInlineColor("link"))
else else
skillName = ts .. "|cff" .. RGBPercToHex(TradeSkillTypeColor[skillType]) .. skillName .. "|r" costText = "---"
end end
if profit then
local priceText = priceTextCache[spellID] if profit < 0 then
local cost, buyout, profit = TSM.Cost:GetCraftPrices(spellID) profitText = "|cffff0000-|r" .. TSMAPI:FormatTextMoney(-profit, "|cffff0000")
if spellID and not priceText then
--local cost, buyout, profit = TSM.Cost:GetCraftPrices(spellID)
if TSM.db.global.priceColumn == 1 then -- Crafting Cost
if cost and cost > 0 then
priceText = TSMAPI:FormatTextMoney(cost, TSMAPI.Design:GetInlineColor("link"))
end
elseif TSM.db.global.priceColumn == 2 then -- Item Value
if buyout and buyout > 0 then
priceText = TSMAPI:FormatTextMoney(buyout, TSMAPI.Design:GetInlineColor("link"))
end
elseif TSM.db.global.priceColumn == 3 then -- Profit
if profit then
-- if profit < 0 then
-- priceText = "|cffff0000-|r" .. TSMAPI:FormatTextMoney(-profit, "|cffff0000") .. format(" (%s%.0f%%|r)", "|cffff0000", profitPercent)
-- else
-- priceText = TSMAPI:FormatTextMoney(profit, "|cff00ff00") .. format(" (%s%.0f%%|r)", "|cff00ff00", profitPercent)
-- end
if profit < 0 then
priceText = "|cffff0000-|r" .. TSMAPI:FormatTextMoney(-profit, "|cffff0000")
else
priceText = TSMAPI:FormatTextMoney(profit, "|cff00ff00")
end
end
end
if priceText then
priceTextCache[spellID] = priceText
else else
priceText = "---" profitText = TSMAPI:FormatTextMoney(profit, "|cff00ff00")
end end
else
profitText = "---"
end end
local profitPercent = "---" local profitPercent = "---"
if profit then if profit and cost and cost > 0 then
profitPercent = profit / cost * 100 profitPercent = profit / cost * 100
if profit < 0 then if profit < 0 then
profitPercent = format("%s%.0f%%|r", "|cffff0000", profitPercent) profitPercent = format("%s%.0f%%|r", "|cffff0000", profitPercent)
@ -1634,11 +1881,17 @@ function GUI:UpdateProfessionsTabST()
local row = { local row = {
cols = { cols = {
{
value = spellID and available or "",
},
{ {
value = skillName, value = skillName,
}, },
{ {
value = spellID and priceText or "", value = spellID and costText or "",
},
{
value = spellID and profitText or "",
}, },
{ {
value = spellID and profitPercent or "", value = spellID and profitPercent or "",
@ -1665,7 +1918,12 @@ function GUI:UpdateSelectedTradeSkill(forceUpdate)
local frame = GUI.frame.content.professionsTab local frame = GUI.frame.content.professionsTab
TradeSkillFrame.selectedSkill = TradeSkillFrame.selectedSkill or 1 TradeSkillFrame.selectedSkill = TradeSkillFrame.selectedSkill or 1
if forceUpdate or frame.st:GetSelection() - 1 ~= TradeSkillFrame.selectedSkill then if TSM.db.global.showAllProfessions then
frame.craftInfoFrame:SetTradeSkillIndex(TradeSkillFrame.selectedSkill)
return
end
local selection = frame.st:GetSelection() or 0
if forceUpdate or selection - 1 ~= TradeSkillFrame.selectedSkill then
frame.st:SetSelection(TradeSkillFrame.selectedSkill + 1) frame.st:SetSelection(TradeSkillFrame.selectedSkill + 1)
frame.craftInfoFrame:SetTradeSkillIndex(TradeSkillFrame.selectedSkill) frame.craftInfoFrame:SetTradeSkillIndex(TradeSkillFrame.selectedSkill)
end end

6
TradeSkillMaster_Crafting/TradeSkillMaster_Crafting.lua

@ -29,12 +29,16 @@ local savedDBDefaults = {
frameQueueOpen = nil, frameQueueOpen = nil,
showingDefaultFrame = nil, showingDefaultFrame = nil,
matsInTooltip = true, matsInTooltip = true,
showAllProfessions = false,
showAllProfessionsSortKey = "name",
showAllProfessionsSortDescending = false,
}, },
realm = { realm = {
tradeSkills = {}, tradeSkills = {},
crafts = {}, crafts = {},
mats = {}, mats = {},
queueStatus = { collapsed = {} }, queueStatus = { collapsed = {} },
professionsTabCollapsed = {},
sourceStatus = { collapsed = {} }, sourceStatus = { collapsed = {} },
gathering = { crafter = nil, professions = {}, neededMats = {}, availableMats = {}, gatheredMats = false, gatherAll = false, destroyingMats = {}, destroyDisable = false, evenStacks = true }, gathering = { crafter = nil, professions = {}, neededMats = {}, availableMats = {}, gatheredMats = false, gatherAll = false, destroyingMats = {}, destroyDisable = false, evenStacks = true },
craftingCostCache = {} craftingCostCache = {}
@ -360,4 +364,4 @@ function TSM:RestockHelp(link)
end end
print("This item will be added to the queue when you restock its group. If this isn't happening, make a post on the TSM forums with a screenshot of the item's tooltip, operation settings, and your general TSM_Crafting options.") print("This item will be added to the queue when you restock its group. If this isn't happening, make a post on the TSM forums with a screenshot of the item's tooltip, operation settings, and your general TSM_Crafting options.")
end end

5
TradeSkillMaster_Warehousing/Locale/enUS.lua

@ -55,14 +55,17 @@ L["Nothing to Move"] = true
L["Nothing to Move"] = true L["Nothing to Move"] = true
L["Nothing to Move"] = true L["Nothing to Move"] = true
L["Nothing to Restock"] = true L["Nothing to Restock"] = true
L["No Auctions found for %s"] = true
L["Operation Name"] = true L["Operation Name"] = true
L["Operations"] = true L["Operations"] = true
L["Preparing to Move"] = true L["Preparing to Move"] = true
L["Preparing to Move"] = true L["Preparing to Move"] = true
L["Preparing to Move"] = true L["Preparing to Move"] = true
L["Please switch to the Shopping tab to restock from the auction house."] = true
L["Puts items matching the itemstring, itemID or partial text entered into the bank or guild bank."] = true L["Puts items matching the itemstring, itemID or partial text entered into the bank or guild bank."] = true
L["Relationships"] = true L["Relationships"] = true
L["Restock Bags"] = true L["Restock Bags"] = true
L["Restock from AH"] = true
L["Restock Quantity"] = true L["Restock Quantity"] = true
L["Restock Settings"] = true L["Restock Settings"] = true
L["Restock Settings"] = true L["Restock Settings"] = true
@ -104,4 +107,4 @@ L["Warehousing will only move items in multiples of the stack size set when movi
L["Warehousing will restock your bags up to this number of items"] = true L["Warehousing will restock your bags up to this number of items"] = true
L["Warehousing will try to get the right number of items, if there are not enough in the bank to fill out the order, it will grab all that there is."] = true L["Warehousing will try to get the right number of items, if there are not enough in the bank to fill out the order, it will grab all that there is."] = true
L["You can toggle the Bank UI by typing the command "] = true L["You can toggle the Bank UI by typing the command "] = true
L["You can use the following slash commands to get items from or put items into your bank or guildbank."] = true L["You can use the following slash commands to get items from or put items into your bank or guildbank."] = true

15
TradeSkillMaster_Warehousing/Modules/bankui.lua

@ -74,13 +74,16 @@ function bankui:createTab(parent)
buttonFrame:SetPoint("BOTTOMRIGHT") buttonFrame:SetPoint("BOTTOMRIGHT")
buttonFrame.btnToBags = createButton(L["Move Group To Bags"], buttonFrame, nil) buttonFrame.btnToBags = createButton(L["Move Group To Bags"], buttonFrame, nil)
buttonFrame.btnToBags:SetPoint("BOTTOM", buttonFrame, "BOTTOM", 0, 75) buttonFrame.btnToBags:SetPoint("BOTTOM", buttonFrame, "BOTTOM", 0, 85)
buttonFrame.btnToBank = createButton(L["Move Group To Bank"], buttonFrame, nil) buttonFrame.btnToBank = createButton(L["Move Group To Bank"], buttonFrame, nil)
buttonFrame.btnToBank:SetPoint("BOTTOM", buttonFrame, "BOTTOM", 0, 95) buttonFrame.btnToBank:SetPoint("BOTTOM", buttonFrame, "BOTTOM", 0, 105)
buttonFrame.btnRestock = createButton(L["Restock Bags"], buttonFrame, nil) buttonFrame.btnRestock = createButton(L["Restock Bags"], buttonFrame, nil)
buttonFrame.btnRestock:SetPoint("BOTTOM", buttonFrame, "BOTTOM", 0, 45) buttonFrame.btnRestock:SetPoint("BOTTOM", buttonFrame, "BOTTOM", 0, 65)
buttonFrame.btnRestockAH = createButton(L["Restock from AH"], buttonFrame, nil)
buttonFrame.btnRestockAH:SetPoint("BOTTOM", buttonFrame, "BOTTOM", 0, 45)
buttonFrame.btnEmpty = createButton(L["Empty Bags"], buttonFrame, nil) buttonFrame.btnEmpty = createButton(L["Empty Bags"], buttonFrame, nil)
buttonFrame.btnEmpty:SetPoint("BOTTOM", buttonFrame, "BOTTOM", 0, 25) buttonFrame.btnEmpty:SetPoint("BOTTOM", buttonFrame, "BOTTOM", 0, 25)
@ -124,4 +127,8 @@ function bankui:updateButtons()
TSM.move:restockGroup(groupTree:GetSelectedGroupInfo()) TSM.move:restockGroup(groupTree:GetSelectedGroupInfo())
end) end)
end buttonFrame.btnRestockAH:SetScript("OnClick", function(self)
TSM.move:restockGroupAuction(groupTree:GetSelectedGroupInfo())
end)
end

53
TradeSkillMaster_Warehousing/Modules/move.lua

@ -13,6 +13,34 @@ local L = LibStub("AceLocale-3.0"):GetLocale("TradeSkillMaster_Warehousing")
local TSM = select(2, ...) local TSM = select(2, ...)
local move = TSM:NewModule("move", "AceEvent-3.0") local move = TSM:NewModule("move", "AceEvent-3.0")
local AceGUI = LibStub("AceGUI-3.0") -- load the AceGUI libraries local AceGUI = LibStub("AceGUI-3.0") -- load the AceGUI libraries
local private = { shoppingItems = {} }
local function ShoppingNextSearch()
if next(private.shoppingItems) then
move:ShoppingSearch(private.shoppingItems[1].itemString, private.shoppingItems[1].quantity)
end
end
local function ShoppingCallback(remainingQty, boughtItem)
if not boughtItem then
if next(private.shoppingItems) then
local name = TSMAPI:GetSafeItemInfo(private.shoppingItems[1].itemString)
TSM:Print(format(L["No Auctions found for %s"], name or private.shoppingItems[1].itemString))
tremove(private.shoppingItems, 1)
TSMAPI:CreateTimeDelay("warehousingShoppingSearchThrottle", 0.5, ShoppingNextSearch)
end
elseif math.max(remainingQty or 0, 0) == 0 and next(private.shoppingItems) then
tremove(private.shoppingItems, 1)
TSMAPI:CreateTimeDelay("warehousingShoppingSearchThrottle", 0.5, ShoppingNextSearch)
end
end
function move:ShoppingSearch(itemString, need)
if not itemString or not need or need <= 0 then return end
local name = TSMAPI:GetSafeItemInfo(itemString)
if not name then return end
TSMAPI:ModuleAPI("Shopping", "runSearch", name .. "/exact/x" .. need, ShoppingCallback)
end
function move:restockGroup(grpInfo) function move:restockGroup(grpInfo)
local restockItems, next = TSM.data:unIndexRestockGroupTree(grpInfo), next local restockItems, next = TSM.data:unIndexRestockGroupTree(grpInfo), next
@ -24,6 +52,29 @@ function move:restockGroup(grpInfo)
end end
end end
function move:restockGroupAuction(grpInfo)
if not TSMAPI:AHTabIsVisible("Shopping") then
TSM:Print(L["Please switch to the Shopping tab to restock from the auction house."])
return
end
local restockItems = TSM.data:unIndexRestockGroupTree(grpInfo)
private.shoppingItems = {}
for itemString, quantity in pairs(restockItems) do
if quantity > 0 then
tinsert(private.shoppingItems, { itemString = itemString, quantity = quantity })
end
end
if next(private.shoppingItems) == nil then
TSM:Print(L["Nothing to Restock"])
return
end
TSM:Print(L["Restocking"])
move:ShoppingSearch(private.shoppingItems[1].itemString, private.shoppingItems[1].quantity)
end
function move:groupTree(grpInfo, src) function move:groupTree(grpInfo, src)
local moveItems, next = TSM.data:unIndexMoveGroupTree(grpInfo, src), next local moveItems, next = TSM.data:unIndexMoveGroupTree(grpInfo, src), next
if next(moveItems) == nil then if next(moveItems) == nil then
@ -157,4 +208,4 @@ end
function TSM.PrintMsg(message) function TSM.PrintMsg(message)
TSM:Print(message) TSM:Print(message)
end end

Loading…
Cancel
Save