initial commit
This commit is contained in:
360
Core/UI/MainUI/Operations/Auctioning.lua
Normal file
360
Core/UI/MainUI/Operations/Auctioning.lua
Normal file
@@ -0,0 +1,360 @@
|
||||
-- ------------------------------------------------------------------------------ --
|
||||
-- TradeSkillMaster --
|
||||
-- https://tradeskillmaster.com --
|
||||
-- All Rights Reserved - Detailed license information included with addon. --
|
||||
-- ------------------------------------------------------------------------------ --
|
||||
|
||||
local _, TSM = ...
|
||||
local Auctioning = TSM.MainUI.Operations:NewPackage("Auctioning")
|
||||
local L = TSM.Include("Locale").GetTable()
|
||||
local String = TSM.Include("Util.String")
|
||||
local Money = TSM.Include("Util.Money")
|
||||
local Vararg = TSM.Include("Util.Vararg")
|
||||
local CustomPrice = TSM.Include("Service.CustomPrice")
|
||||
local UIElements = TSM.Include("UI.UIElements")
|
||||
local private = {
|
||||
currentOperationName = nil,
|
||||
currentTab = nil,
|
||||
}
|
||||
local IGNORE_DURATION_OPTIONS = {
|
||||
L["None"],
|
||||
AUCTION_TIME_LEFT1.." ("..AUCTION_TIME_LEFT1_DETAIL..")",
|
||||
AUCTION_TIME_LEFT2.." ("..AUCTION_TIME_LEFT2_DETAIL..")",
|
||||
AUCTION_TIME_LEFT3.." ("..AUCTION_TIME_LEFT3_DETAIL..")",
|
||||
}
|
||||
local BELOW_MIN_ITEMS = { L["Don't Post Items"], L["Post at Minimum Price"], L["Post at Maximum Price"], L["Post at Normal Price"], L["Ignore Auctions Below Min"] }
|
||||
local BELOW_MIN_KEYS = { "none", "minPrice", "maxPrice", "normalPrice", "ignore" }
|
||||
local ABOVE_MAX_ITEMS = { L["Don't Post Items"], L["Post at Minimum Price"], L["Post at Maximum Price"], L["Post at Normal Price"] }
|
||||
local ABOVE_MAX_KEYS = { "none", "minPrice", "maxPrice", "normalPrice" }
|
||||
local BAD_PRICE_SOURCES = { auctioningopmin = true, auctioningopmax = true, auctioningopnormal = true }
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Module Functions
|
||||
-- ============================================================================
|
||||
|
||||
function Auctioning.OnInitialize()
|
||||
TSM.MainUI.Operations.RegisterModule("Auctioning", private.GetAuctioningOperationSettings)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Auctioning Operation Settings UI
|
||||
-- ============================================================================
|
||||
|
||||
function private.GetAuctioningOperationSettings(operationName)
|
||||
TSM.UI.AnalyticsRecordPathChange("main", "operations", "auctioning")
|
||||
private.currentOperationName = operationName
|
||||
private.currentTab = private.currentTab or L["Details"]
|
||||
return UIElements.New("TabGroup", "tabs")
|
||||
:SetMargin(0, 0, 8, 0)
|
||||
:SetNavCallback(private.GetAuctioningSettings)
|
||||
:AddPath(L["Details"])
|
||||
:AddPath(L["Posting"])
|
||||
:AddPath(L["Canceling"])
|
||||
:SetPath(private.currentTab)
|
||||
end
|
||||
|
||||
function private.GetDetailsSettings()
|
||||
TSM.UI.AnalyticsRecordPathChange("main", "operations", "auctioning", "details")
|
||||
local operation = TSM.Operations.GetSettings("Auctioning", private.currentOperationName)
|
||||
return UIElements.New("ScrollFrame", "settings")
|
||||
:SetPadding(8, 8, 8, 0)
|
||||
:SetBackgroundColor("PRIMARY_BG")
|
||||
:AddChild(TSM.MainUI.Operations.CreateExpandableSection("Auctioning", "generalOptions", L["General Options"], L["Adjust some general settings."])
|
||||
:AddChild(UIElements.New("Frame", "content")
|
||||
:SetLayout("VERTICAL")
|
||||
:AddChildrenWithFunction(private.AddMaxStackSizeSetting)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("ignoreLowDuration", L["Ignore auctions by duration"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 16)
|
||||
:AddChild(UIElements.New("SelectionDropdown", "dropdown")
|
||||
:SetHeight(24)
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Auctioning", private.currentOperationName, "ignoreLowDuration"))
|
||||
:SetItems(IGNORE_DURATION_OPTIONS)
|
||||
:SetSelectedItemByKey(operation.ignoreLowDuration + 1, true)
|
||||
:SetScript("OnSelectionChanged", private.IgnoreLowDurationOnSelectionChanged)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("blacklist", L["Blacklisted players"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetHeight(24)
|
||||
:SetBackgroundColor("ACTIVE_BG")
|
||||
:SetHintText(L["Enter player name"])
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Auctioning", private.currentOperationName, "blacklist"))
|
||||
:SetScript("OnEnterPressed", private.BlacklistInputOnEnterPressed)
|
||||
)
|
||||
)
|
||||
:AddChildrenWithFunction(private.AddBlacklistPlayers)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.GetOperationManagementElements("Auctioning", private.currentOperationName))
|
||||
end
|
||||
|
||||
function private.AddMaxStackSizeSetting(frame)
|
||||
if TSM.IsWowClassic() then
|
||||
frame:AddChild(private.CreateToggleLine("matchStackSize", L["Match stack size"]))
|
||||
end
|
||||
end
|
||||
|
||||
function private.GetPostingSettings()
|
||||
TSM.UI.AnalyticsRecordPathChange("main", "operations", "auctioning", "posting")
|
||||
local operation = TSM.Operations.GetSettings("Auctioning", private.currentOperationName)
|
||||
return UIElements.New("ScrollFrame", "settings")
|
||||
:SetPadding(8, 8, 8, 0)
|
||||
:SetBackgroundColor("PRIMARY_BG")
|
||||
:AddChild(TSM.MainUI.Operations.CreateExpandableSection("Auctioning", "postingSettings", L["Posting Options"], L["Adjust the settings below to set how groups attached to this operation will be auctioned."])
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("duration", L["Auction duration"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("SelectionDropdown", "dropdown")
|
||||
:SetHeight(24)
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Auctioning", private.currentOperationName, "duration"))
|
||||
:SetItems(TSM.CONST.AUCTION_DURATIONS)
|
||||
:SetSelectedItemByKey(operation.duration)
|
||||
:SetScript("OnSelectionChanged", private.SetAuctioningDuration)
|
||||
)
|
||||
|
||||
)
|
||||
:AddChild(private.CreateInputLine("postCap", L["Post cap"], false, true))
|
||||
:AddChildrenWithFunction(private.AddStackSizeSettings)
|
||||
:AddChild(private.CreateInputLine("keepQuantity", L["Amount kept in bags"], false, true))
|
||||
:AddChild(private.CreateInputLine("maxExpires", L["Don't post after this many expires"]))
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateExpandableSection("Auctioning", "priceSettings", L["Posting Price"], L["Adjust the settings below to set how groups attached to this operation will be priced."])
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("bidPercent", L["Set bid as percentage of buyout"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("Frame", "content")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(24)
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetBackgroundColor("ACTIVE_BG")
|
||||
:SetValidateFunc(private.BidPercentValidateFunc)
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Auctioning", private.currentOperationName, "bidPercent"))
|
||||
:SetValue((operation.bidPercent * 100).."%")
|
||||
:SetScript("OnValueChanged", private.BidPercentOnValueChanged)
|
||||
)
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("BODY_BODY3")
|
||||
:SetFormattedText(L["Enter a value from %d - %d%%"], 0, 100)
|
||||
:SetTextColor(TSM.Operations.HasRelationship("Auctioning", private.currentOperationName, "bidPercent") and "TEXT_DISABLED" or "TEXT")
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedPriceInput("undercut", L["Undercut amount"], 66, private.CheckUndercut)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedPriceInput("minPrice", L["Minimum price"], 126, BAD_PRICE_SOURCES))
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("priceReset", L["When below minimum:"])
|
||||
:SetMargin(0, 0, 12, 12)
|
||||
:AddChild(UIElements.New("SelectionDropdown", "dropdown")
|
||||
:SetWidth(240)
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Auctioning", private.currentOperationName, "priceReset"))
|
||||
:SetItems(BELOW_MIN_ITEMS, BELOW_MIN_KEYS)
|
||||
:SetSettingInfo(operation, "priceReset")
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedPriceInput("maxPrice", L["Maximum price"], 126, BAD_PRICE_SOURCES))
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("aboveMax", L["When above maximum:"])
|
||||
:SetMargin(0, 0, 12, 12)
|
||||
:AddChild(UIElements.New("SelectionDropdown", "dropdown")
|
||||
:SetWidth(240)
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Auctioning", private.currentOperationName, "aboveMax"))
|
||||
:SetItems(ABOVE_MAX_ITEMS, ABOVE_MAX_KEYS)
|
||||
:SetSettingInfo(operation, "aboveMax")
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedPriceInput("normalPrice", L["Normal price"], 126, BAD_PRICE_SOURCES))
|
||||
)
|
||||
end
|
||||
|
||||
function private.AddStackSizeSettings(frame)
|
||||
if not TSM.IsWowClassic() then
|
||||
return
|
||||
end
|
||||
frame:AddChild(private.CreateInputLine("stackSize", L["Stack size"], false, true))
|
||||
frame:AddChild(private.CreateToggleLine("stackSizeIsCap", L["Allow partial stack"]))
|
||||
end
|
||||
|
||||
function private.GetCancelingSettings()
|
||||
TSM.UI.AnalyticsRecordPathChange("main", "operations", "auctioning", "canceling")
|
||||
return UIElements.New("ScrollFrame", "settings")
|
||||
:SetPadding(8, 8, 8, 0)
|
||||
:AddChild(TSM.MainUI.Operations.CreateExpandableSection("Auctioning", "priceSettings", L["Canceling Options"], L["Adjust the settings below to set how groups attached to this operation will be cancelled."])
|
||||
:AddChild(private.CreateToggleLine("cancelUndercut", L["Cancel undercut auctions"]))
|
||||
:AddChild(private.CreateToggleLine("cancelRepost", L["Cancel to repost higher"]))
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedPriceInput("cancelRepostThreshold", L["Repost threshold"], 66))
|
||||
)
|
||||
end
|
||||
|
||||
function private.GetAuctioningSettings(self, button)
|
||||
private.currentTab = button
|
||||
if button == L["Details"] then
|
||||
return private.GetDetailsSettings()
|
||||
elseif button == L["Posting"] then
|
||||
return private.GetPostingSettings()
|
||||
elseif button == L["Canceling"] then
|
||||
return private.GetCancelingSettings()
|
||||
else
|
||||
error("Unknown button!")
|
||||
end
|
||||
end
|
||||
|
||||
function private.AddBlacklistPlayers(frame)
|
||||
local operation = TSM.Operations.GetSettings("Auctioning", private.currentOperationName)
|
||||
if operation.blacklist == "" then return end
|
||||
local containerFrame = UIElements.New("Frame", "blacklistFrame")
|
||||
:SetLayout("FLOW")
|
||||
for index, player in Vararg.Iterator(strsplit(",", operation.blacklist)) do
|
||||
containerFrame:AddChild(UIElements.New("Frame", "blacklist" .. index)
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetSize(100, 20)
|
||||
:SetMargin(0, 12, 0, 0)
|
||||
:AddChild(UIElements.New("Text", "text")
|
||||
:SetWidth("AUTO")
|
||||
:SetMargin(0, 2, 0, 0)
|
||||
:SetFont("BODY_BODY2_MEDIUM")
|
||||
:SetText(player)
|
||||
)
|
||||
:AddChild(UIElements.New("Button", "removeBtn")
|
||||
:SetBackgroundAndSize("iconPack.14x14/Close/Circle")
|
||||
:SetContext(player)
|
||||
:SetScript("OnClick", private.RemoveBlacklistOnClick)
|
||||
)
|
||||
:AddChild(UIElements.New("Spacer", "spacer"))
|
||||
)
|
||||
end
|
||||
frame:AddChild(containerFrame)
|
||||
end
|
||||
|
||||
function private.CreateInputLine(key, label, disabled, margin)
|
||||
local operation = TSM.Operations.GetSettings("Auctioning", private.currentOperationName)
|
||||
local hasRelationship = TSM.Operations.HasRelationship("Auctioning", private.currentOperationName, key)
|
||||
return TSM.MainUI.Operations.CreateLinkedSettingLine(key, label, disabled)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, margin and 12 or 4)
|
||||
:AddChild(UIElements.New("Frame", "content")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(24)
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetBackgroundColor("ACTIVE_BG")
|
||||
:SetContext(key)
|
||||
:SetDisabled(hasRelationship or disabled)
|
||||
:SetValidateFunc("CUSTOM_PRICE")
|
||||
:SetSettingInfo(operation, key)
|
||||
)
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("BODY_BODY3")
|
||||
:SetTextColor((hasRelationship or disabled) and "TEXT_DISABLED" or "TEXT")
|
||||
:SetFormattedText(L["Supported value range: %d - %d"], TSM.Operations.Auctioning.GetMinMaxValues(key))
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
function private.CreateToggleLine(key, label)
|
||||
local operation = TSM.Operations.GetSettings("Auctioning", private.currentOperationName)
|
||||
return TSM.MainUI.Operations.CreateLinkedSettingLine(key, label)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("ToggleOnOff", "toggle")
|
||||
:SetHeight(18)
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Auctioning", private.currentOperationName, key))
|
||||
:SetSettingInfo(operation, key)
|
||||
)
|
||||
end
|
||||
|
||||
function private.CheckUndercut(_, value)
|
||||
if not TSM.IsWowClassic() and Money.FromString(Money.ToString(value) or value) == 0 then
|
||||
return true
|
||||
elseif not TSM.IsWowClassic() and (Money.FromString(Money.ToString(value) or value) or math.huge) < COPPER_PER_SILVER then
|
||||
return false, L["Invalid undercut. To post below the cheapest auction without a significant undercut, set your undercut to 0c."]
|
||||
else
|
||||
local isValid, err = CustomPrice.Validate(value)
|
||||
if isValid then
|
||||
return true
|
||||
end
|
||||
return false, L["Invalid custom price."].." "..err
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Local Script Handlers
|
||||
-- ============================================================================
|
||||
|
||||
function private.IgnoreLowDurationOnSelectionChanged(self)
|
||||
local operation = TSM.Operations.GetSettings("Auctioning", private.currentOperationName)
|
||||
operation.ignoreLowDuration = self:GetSelectedItemKey() - 1
|
||||
end
|
||||
|
||||
function private.BlacklistInputOnEnterPressed(input)
|
||||
local newPlayer = input:GetValue()
|
||||
if newPlayer == "" or strfind(newPlayer, ",") or newPlayer ~= String.Escape(newPlayer) then
|
||||
-- this is an invalid player name
|
||||
return
|
||||
end
|
||||
local operation = TSM.Operations.GetSettings("Auctioning", private.currentOperationName)
|
||||
local found = false
|
||||
for _, player in Vararg.Iterator(strsplit(",", operation.blacklist)) do
|
||||
if newPlayer == player then
|
||||
-- this player is already added
|
||||
input:SetValue("")
|
||||
found = true
|
||||
end
|
||||
end
|
||||
if found then
|
||||
return
|
||||
end
|
||||
operation.blacklist = (operation.blacklist == "") and newPlayer or (operation.blacklist..","..newPlayer)
|
||||
input:GetElement("__parent.__parent.__parent.__parent.__parent.__parent"):ReloadContent()
|
||||
end
|
||||
|
||||
function private.RemoveBlacklistOnClick(button)
|
||||
local player = button:GetContext()
|
||||
-- FIXME: This sort of logic should go within some Auctioning-specific operation setting wrapper code
|
||||
local operation = TSM.Operations.GetSettings("Auctioning", private.currentOperationName)
|
||||
if operation.blacklist == player then
|
||||
operation.blacklist = ""
|
||||
else
|
||||
-- handle cases where this entry is at the start, in the middle, and at the end
|
||||
operation.blacklist = gsub(operation.blacklist, "^"..player..",", "")
|
||||
operation.blacklist = gsub(operation.blacklist, ","..player..",", ",")
|
||||
operation.blacklist = gsub(operation.blacklist, ","..player.."$", "")
|
||||
end
|
||||
button:GetElement("__parent.__parent.__parent.__parent.__parent.__parent.__parent"):ReloadContent()
|
||||
end
|
||||
|
||||
function private.SetAuctioningDuration(dropdown)
|
||||
local operation = TSM.Operations.GetSettings("Auctioning", private.currentOperationName)
|
||||
operation.duration = dropdown:GetSelectedItemKey()
|
||||
end
|
||||
|
||||
function private.BidPercentValidateFunc(_, value)
|
||||
value = strmatch(value, "^([0-9]+) *%%?$")
|
||||
value = tonumber(value)
|
||||
if not value or value < 0 or value > 100 then
|
||||
return false, L["Bid percent must be between 0 and 100."]
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function private.BidPercentOnValueChanged(input)
|
||||
local operation = TSM.Operations.GetSettings("Auctioning", private.currentOperationName)
|
||||
local value = strmatch(input:GetValue(), "^([0-9]+) *%%?$")
|
||||
value = tonumber(value) / 100
|
||||
operation.bidPercent = value
|
||||
end
|
||||
867
Core/UI/MainUI/Operations/Core.lua
Normal file
867
Core/UI/MainUI/Operations/Core.lua
Normal file
@@ -0,0 +1,867 @@
|
||||
-- ------------------------------------------------------------------------------ --
|
||||
-- TradeSkillMaster --
|
||||
-- https://tradeskillmaster.com --
|
||||
-- All Rights Reserved - Detailed license information included with addon. --
|
||||
-- ------------------------------------------------------------------------------ --
|
||||
|
||||
local _, TSM = ...
|
||||
local Operations = TSM.MainUI:NewPackage("Operations")
|
||||
local L = TSM.Include("Locale").GetTable()
|
||||
local Log = TSM.Include("Util.Log")
|
||||
local Theme = TSM.Include("Util.Theme")
|
||||
local Money = TSM.Include("Util.Money")
|
||||
local TempTable = TSM.Include("Util.TempTable")
|
||||
local Settings = TSM.Include("Service.Settings")
|
||||
local UIElements = TSM.Include("UI.UIElements")
|
||||
local private = {
|
||||
settings = nil,
|
||||
moduleNames = {},
|
||||
moduleCollapsed = {},
|
||||
moduleCallbacks = {},
|
||||
currentModule = nil,
|
||||
currentOperationName = nil,
|
||||
playerList = {},
|
||||
linkMenuEntries = {},
|
||||
}
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Module Functions
|
||||
-- ============================================================================
|
||||
|
||||
function Operations.OnInitialize()
|
||||
private.settings = Settings.NewView()
|
||||
:AddKey("global", "mainUIContext", "operationsDividedContainer")
|
||||
:AddKey("global", "mainUIContext", "operationsSummaryScrollingTable")
|
||||
TSM.MainUI.RegisterTopLevelPage(L["Operations"], private.GetOperationsFrame)
|
||||
end
|
||||
|
||||
function Operations.RegisterModule(name, callback)
|
||||
tinsert(private.moduleNames, name)
|
||||
private.moduleCallbacks[name] = callback
|
||||
end
|
||||
|
||||
function Operations.ShowOperationSettings(baseFrame, moduleName, operationName)
|
||||
baseFrame:SetSelectedNavButton(L["Operations"], true)
|
||||
baseFrame:GetElement("content.operations.selection.operationTree"):SetSelectedOperation(moduleName, operationName)
|
||||
end
|
||||
|
||||
function Operations.GetOperationManagementElements(moduleName, operationName)
|
||||
local operation = TSM.Operations.GetSettings(private.currentModule, private.currentOperationName)
|
||||
wipe(private.playerList)
|
||||
for factionrealm in TSM.db:GetConnectedRealmIterator("factionrealm") do
|
||||
for _, character in TSM.db:FactionrealmCharacterIterator(factionrealm) do
|
||||
tinsert(private.playerList, character.." - "..factionrealm)
|
||||
end
|
||||
end
|
||||
return UIElements.New("Frame", "management")
|
||||
:SetLayout("VERTICAL")
|
||||
:AddChild(Operations.CreateExpandableSection(moduleName, "managementOptions", L["Management Options"], L["Below you can ignore this operation on certain characters or realms."])
|
||||
:AddChild(Operations.CreateSettingLine("ignoreFactionRealms", L["Ignore operation on faction-realms"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("MultiselectionDropdown", "dropdown")
|
||||
:SetHeight(24)
|
||||
:SetItems(TSM.db:GetScopeKeys("factionrealm"), TSM.db:GetScopeKeys("factionrealm"))
|
||||
:SetSelectionText(L["No Faction-Realms"], L["%d Faction-Realms"], L["All Faction-Realms"])
|
||||
:SetSettingInfo(operation, "ignoreFactionrealm")
|
||||
)
|
||||
)
|
||||
:AddChild(Operations.CreateSettingLine("ignoreCharacters", L["Ignore operation on characters"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:AddChild(UIElements.New("MultiselectionDropdown", "dropdown")
|
||||
:SetHeight(24)
|
||||
:SetItems(private.playerList, private.playerList)
|
||||
:SetSelectionText(L["No Characters"], L["%d Characters"], L["All Characters"])
|
||||
:SetSettingInfo(operation, "ignorePlayer")
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(Operations.CreateExpandableSection(moduleName, "groupManagement", L["Group Management"], L["Here you can add/remove what groups this operation is attached to."])
|
||||
:AddChild(Operations.CreateSettingLine("applyNewGroup", L["Apply operation to group"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:AddChild(UIElements.New("GroupSelector", "group")
|
||||
:SetHintText(L["Add operation to groups"])
|
||||
:SetScript("OnSelectionChanged", private.GroupSelectionChanged)
|
||||
)
|
||||
)
|
||||
:AddChildrenWithFunction(private.AddOperationGroups)
|
||||
)
|
||||
end
|
||||
|
||||
function Operations.CreateExpandableSection(moduleName, id, text, description)
|
||||
return UIElements.New("CollapsibleContainer", id)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetMargin(0, 0, 0, 8)
|
||||
:SetContextTable(private.moduleCollapsed, moduleName..text)
|
||||
:SetHeadingText(text)
|
||||
:AddChild(UIElements.New("Text", "description")
|
||||
:SetHeight(20)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:SetFont("BODY_BODY3")
|
||||
:SetText(description)
|
||||
)
|
||||
end
|
||||
|
||||
function Operations.CreateLinkedSettingLine(settingKey, labelText, disabled, alternateName)
|
||||
local relationshipSet = TSM.Operations.HasRelationship(private.currentModule, private.currentOperationName, settingKey)
|
||||
return UIElements.New("Frame", alternateName or settingKey)
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(24)
|
||||
:SetMargin(0, 0, 0, 4)
|
||||
:AddChild(UIElements.New("Frame", "line")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("BODY_BODY2_MEDIUM")
|
||||
:SetTextColor((relationshipSet or disabled) and "TEXT_DISABLED" or "TEXT")
|
||||
:SetText(labelText)
|
||||
)
|
||||
:AddChild(private.CreateLinkButton(disabled, settingKey))
|
||||
:AddChild(UIElements.New("Spacer", "spacer"))
|
||||
)
|
||||
end
|
||||
|
||||
function Operations.CreateSettingLine(id, labelText, disabled)
|
||||
return UIElements.New("Frame", id)
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(24)
|
||||
:SetMargin(0, 0, 0, 4)
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetFont("BODY_BODY2_MEDIUM")
|
||||
:SetTextColor(disabled and "TEXT_DISABLED" or "TEXT")
|
||||
:SetText(labelText)
|
||||
)
|
||||
end
|
||||
|
||||
function Operations.CreateLinkedPriceInput(settingKey, label, height, validate, defaultValue)
|
||||
local isDisabled = TSM.Operations.HasRelationship(private.currentModule, private.currentOperationName, settingKey)
|
||||
local operation = TSM.Operations.GetSettings(private.currentModule, private.currentOperationName)
|
||||
local value = operation[settingKey]
|
||||
if defaultValue ~= nil and (not value or value == "") then
|
||||
isDisabled = true
|
||||
value = defaultValue
|
||||
end
|
||||
local validateFunc, validateContext = nil, nil
|
||||
if type(validate) == "table" then
|
||||
validateFunc = "CUSTOM_PRICE"
|
||||
validateContext = validate
|
||||
elseif type(validate) == "function" then
|
||||
validateFunc = validate
|
||||
elseif validate == nil then
|
||||
validateFunc = "CUSTOM_PRICE"
|
||||
else
|
||||
error("Invalid validate: "..tostring(validate))
|
||||
end
|
||||
return Operations.CreateLinkedSettingLine(settingKey, label)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(height)
|
||||
:AddChild(UIElements.New("MultiLineInput", "input")
|
||||
:SetHeight(height - 24)
|
||||
:SetDisabled(isDisabled)
|
||||
:SetValidateFunc(validateFunc, validateContext)
|
||||
:SetSettingInfo(operation, settingKey)
|
||||
:SetValue(Money.ToString(value) or value)
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Operations UI
|
||||
-- ============================================================================
|
||||
|
||||
function private.GetOperationsFrame()
|
||||
TSM.UI.AnalyticsRecordPathChange("main", "operations")
|
||||
local frame = UIElements.New("DividedContainer", "operations")
|
||||
:SetSettingsContext(private.settings, "operationsDividedContainer")
|
||||
:SetMinWidth(250, 250)
|
||||
:SetLeftChild(UIElements.New("Frame", "selection")
|
||||
:SetLayout("VERTICAL")
|
||||
:SetBackgroundColor("PRIMARY_BG_ALT")
|
||||
:AddChild(UIElements.New("Input", "search")
|
||||
:SetHeight(24)
|
||||
:SetMargin(8, 8, 8, 16)
|
||||
:SetIconTexture("iconPack.18x18/Search")
|
||||
:SetClearButtonEnabled(true)
|
||||
:AllowItemInsert(true)
|
||||
:SetHintText(L["Search Operations"])
|
||||
:SetScript("OnValueChanged", private.OperationSearchOnValueChanged)
|
||||
)
|
||||
:AddChild(UIElements.New("OperationTree", "operationTree")
|
||||
:SetScript("OnOperationAdded", private.OperationTreeOnOperationAdded)
|
||||
:SetScript("OnOperationDeleted", private.OperationTreeOnOperationConfirmDelete)
|
||||
:SetScript("OnOperationSelected", private.OperationTreeOnOperationSelected)
|
||||
)
|
||||
)
|
||||
:SetRightChild(UIElements.New("ViewContainer", "content")
|
||||
:SetNavCallback(private.GetOperationsContent)
|
||||
:AddPath("none", true)
|
||||
:AddPath("summary")
|
||||
:AddPath("operation")
|
||||
)
|
||||
return frame
|
||||
end
|
||||
|
||||
function private.GetOperationsContent(_, path)
|
||||
if path == "none" then
|
||||
return UIElements.New("Frame", "settings")
|
||||
:SetLayout("VERTICAL")
|
||||
:SetWidth("EXPAND")
|
||||
:SetBackgroundColor("PRIMARY_BG")
|
||||
:AddChild(UIElements.New("Frame", "title")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(40)
|
||||
:SetPadding(8)
|
||||
:AddChild(UIElements.New("Texture", "icon")
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetTextureAndSize(TSM.UI.TexturePacks.GetColoredKey("iconPack.18x18/Operation", "TEXT"))
|
||||
)
|
||||
:AddChild(UIElements.New("Text", "text")
|
||||
:SetFont("BODY_BODY1_BOLD")
|
||||
:SetText(L["No Operation Selected"])
|
||||
)
|
||||
)
|
||||
:AddChild(UIElements.New("Spacer", "spacer"))
|
||||
elseif path == "summary" then
|
||||
return UIElements.New("Frame", "settings")
|
||||
:SetLayout("VERTICAL")
|
||||
:SetWidth("EXPAND")
|
||||
:SetBackgroundColor("PRIMARY_BG")
|
||||
:AddChild(UIElements.New("Frame", "title")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(40)
|
||||
:SetPadding(8)
|
||||
:AddChild(UIElements.New("Text", "text")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("BODY_BODY1_BOLD")
|
||||
)
|
||||
:AddChild(UIElements.New("Spacer"))
|
||||
:AddChild(UIElements.New("Button", "addBtn")
|
||||
:SetWidth("AUTO")
|
||||
:SetMargin(12, 12, 0, 0)
|
||||
:SetFont("BODY_BODY2_MEDIUM")
|
||||
:SetIcon("iconPack.14x14/Add/Circle", "LEFT")
|
||||
:SetText(L["Create New"])
|
||||
:SetScript("OnClick", private.CreateNewOperationOnClick)
|
||||
)
|
||||
)
|
||||
:AddChild(UIElements.New("Frame", "content")
|
||||
:SetLayout("VERTICAL")
|
||||
-- will be filled in by the operation selection callback
|
||||
)
|
||||
elseif path == "operation" then
|
||||
return UIElements.New("Frame", "settings")
|
||||
:SetLayout("VERTICAL")
|
||||
:SetWidth("EXPAND")
|
||||
:SetBackgroundColor("PRIMARY_BG")
|
||||
:AddChild(UIElements.New("Frame", "title")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(40)
|
||||
:SetPadding(8)
|
||||
:AddChild(UIElements.New("Texture", "icon")
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetTextureAndSize(TSM.UI.TexturePacks.GetColoredKey("iconPack.18x18/Operation", "TEXT"))
|
||||
)
|
||||
:AddChild(UIElements.New("EditableText", "text")
|
||||
:SetWidth("AUTO")
|
||||
:AllowItemInsert(true)
|
||||
:SetFont("BODY_BODY1_BOLD")
|
||||
:SetText(L["No Operation Selected"])
|
||||
:SetScript("OnValueChanged", private.OperationNameChanged)
|
||||
:SetScript("OnEditingChanged", private.NameOnEditingChanged)
|
||||
)
|
||||
:AddChild(UIElements.New("Spacer"))
|
||||
:AddChild(UIElements.New("Button", "renameBtn")
|
||||
:SetWidth("AUTO")
|
||||
:SetMargin(12, 12, 0, 0)
|
||||
:SetFont("BODY_BODY2_MEDIUM")
|
||||
:SetIcon("iconPack.14x14/Edit", "LEFT")
|
||||
:SetText(L["Rename"])
|
||||
:SetScript("OnClick", private.RenameOperationOnClick)
|
||||
)
|
||||
:AddChild(UIElements.New("Button", "resetBtn")
|
||||
:SetWidth("AUTO")
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetFont("BODY_BODY2_MEDIUM")
|
||||
:SetIcon("iconPack.14x14/Reset", "LEFT")
|
||||
:SetText(L["Reset"])
|
||||
:SetScript("OnClick", private.ResetOperationOnClick)
|
||||
)
|
||||
)
|
||||
:AddChild(UIElements.New("Frame", "content")
|
||||
:SetLayout("VERTICAL")
|
||||
-- will be filled in by the operation selection callback
|
||||
)
|
||||
else
|
||||
error("Invalid path: "..tostring(path))
|
||||
end
|
||||
end
|
||||
|
||||
function private.GetSummaryContent()
|
||||
local query = TSM.Operations.CreateQuery()
|
||||
:Equal("moduleName", private.currentModule)
|
||||
:VirtualField("numGroups", "number", private.NumGroupsVirtualField)
|
||||
:VirtualField("numItems", "number", private.NumItemsVirtualField)
|
||||
:OrderBy("operationName", true)
|
||||
local mostGroupsName, mostGroupsValue = "---", -math.huge
|
||||
local leastGroupsName, leastGroupsValue = "---", math.huge
|
||||
local mostItemsName, mostItemsValue = "---", -math.huge
|
||||
local leastItemsName, leastItemsValue = "---", math.huge
|
||||
for _, row in query:Iterator() do
|
||||
local operationName, numGroups, numItems = row:GetFields("operationName", "numGroups", "numItems")
|
||||
if numGroups > mostGroupsValue then
|
||||
mostGroupsValue = numGroups
|
||||
mostGroupsName = operationName
|
||||
end
|
||||
if numGroups < leastGroupsValue then
|
||||
leastGroupsValue = numGroups
|
||||
leastGroupsName = operationName
|
||||
end
|
||||
if numItems > mostItemsValue then
|
||||
mostItemsValue = numItems
|
||||
mostItemsName = operationName
|
||||
end
|
||||
if numItems < leastItemsValue then
|
||||
leastItemsValue = numItems
|
||||
leastItemsName = operationName
|
||||
end
|
||||
end
|
||||
return UIElements.New("Frame", "summary")
|
||||
:SetLayout("VERTICAL")
|
||||
:SetBackgroundColor("PRIMARY_BG")
|
||||
:AddChild(UIElements.New("Frame", "summary")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(8, 8, 0, 16)
|
||||
:SetBackgroundColor("PRIMARY_BG_ALT", true)
|
||||
:AddChild(UIElements.New("Frame", "groups")
|
||||
:SetLayout("VERTICAL")
|
||||
:SetPadding(8, 8, 2, 2)
|
||||
:AddChild(UIElements.New("Frame", "most")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(20)
|
||||
:SetMargin(0, 0, 0, 4)
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("TABLE_TABLE1")
|
||||
:SetTextColor("ACTIVE_BG_ALT")
|
||||
:SetText(L["MOST GROUPS"])
|
||||
)
|
||||
:AddChild(UIElements.New("Spacer", "spacer"))
|
||||
:AddChild(UIElements.New("Text", "value")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("TABLE_TABLE1")
|
||||
:SetJustifyH("RIGHT")
|
||||
:SetText(mostGroupsName)
|
||||
)
|
||||
)
|
||||
:AddChild(UIElements.New("Frame", "least")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(20)
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("TABLE_TABLE1")
|
||||
:SetTextColor("ACTIVE_BG_ALT")
|
||||
:SetText(L["LEAST GROUPS"])
|
||||
)
|
||||
:AddChild(UIElements.New("Spacer", "spacer"))
|
||||
:AddChild(UIElements.New("Text", "value")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("TABLE_TABLE1")
|
||||
:SetJustifyH("RIGHT")
|
||||
:SetText(leastGroupsName)
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(UIElements.New("Texture", "line1")
|
||||
:SetWidth(1)
|
||||
:SetTexture("ACTIVE_BG")
|
||||
)
|
||||
:AddChild(UIElements.New("Frame", "items")
|
||||
:SetLayout("VERTICAL")
|
||||
:SetPadding(8, 8, 2, 2)
|
||||
:AddChild(UIElements.New("Frame", "most")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(20)
|
||||
:SetMargin(0, 0, 0, 4)
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("TABLE_TABLE1")
|
||||
:SetTextColor("ACTIVE_BG_ALT")
|
||||
:SetText(L["MOST ITEMS"])
|
||||
)
|
||||
:AddChild(UIElements.New("Spacer", "spacer"))
|
||||
:AddChild(UIElements.New("Text", "value")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("TABLE_TABLE1")
|
||||
:SetJustifyH("RIGHT")
|
||||
:SetText(mostItemsName)
|
||||
)
|
||||
)
|
||||
:AddChild(UIElements.New("Frame", "least")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(20)
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("TABLE_TABLE1")
|
||||
:SetTextColor("ACTIVE_BG_ALT")
|
||||
:SetText(L["LEAST ITEMS"])
|
||||
)
|
||||
:AddChild(UIElements.New("Spacer", "spacer"))
|
||||
:AddChild(UIElements.New("Text", "value")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("TABLE_TABLE1")
|
||||
:SetJustifyH("RIGHT")
|
||||
:SetText(leastItemsName)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(UIElements.New("SelectionScrollingTable", "list")
|
||||
:SetSettingsContext(private.settings, "operationsSummaryScrollingTable")
|
||||
:GetScrollingTableInfo()
|
||||
:NewColumn("name")
|
||||
:SetTitle(L["Operation"])
|
||||
:SetFont("TABLE_TABLE1")
|
||||
:SetJustifyH("LEFT")
|
||||
:SetTextInfo("operationName")
|
||||
:SetSortInfo("operationName")
|
||||
:SetActionIconInfo(1, 12, private.GetConfigureIcon, true)
|
||||
:SetActionIconClickHandler(private.OnConfigureIconClick)
|
||||
:DisableHiding()
|
||||
:Commit()
|
||||
:NewColumn("groups")
|
||||
:SetTitle(L["Groups Using"])
|
||||
:SetFont("TABLE_TABLE1")
|
||||
:SetJustifyH("LEFT")
|
||||
:SetTextInfo("numGroups")
|
||||
:SetSortInfo("numGroups")
|
||||
:Commit()
|
||||
:NewColumn("items")
|
||||
:SetTitle(L["Items Using"])
|
||||
:SetFont("TABLE_TABLE1")
|
||||
:SetJustifyH("LEFT")
|
||||
:SetTextInfo("numItems", private.GetNumItemsText)
|
||||
:SetSortInfo("numItems")
|
||||
:SetTooltipInfo("numItems", private.GetNumItemsTooltip)
|
||||
:Commit()
|
||||
:Commit()
|
||||
:SetQuery(query)
|
||||
:SetContext(query)
|
||||
:SetAutoReleaseQuery(true)
|
||||
:SetScript("OnSelectionChanged", private.OperationListOnSelectionChanged)
|
||||
)
|
||||
:AddChild(UIElements.New("Texture", "line")
|
||||
:SetHeight(2)
|
||||
:SetTexture("ACTIVE_BG")
|
||||
)
|
||||
:AddChild(UIElements.New("Frame", "footer")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(40)
|
||||
:SetPadding(8)
|
||||
:SetBackgroundColor("PRIMARY_BG_ALT")
|
||||
:AddChild(UIElements.New("ActionButton", "deleteSelected")
|
||||
:SetHeight(24)
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetDisabled(true)
|
||||
:SetText(L["Delete Operations"])
|
||||
:SetScript("OnClick", private.DeleteSelectedOnClick)
|
||||
)
|
||||
:AddChild(UIElements.New("Button", "selectAll")
|
||||
:SetSize("AUTO", 20)
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetFont("BODY_BODY3_MEDIUM")
|
||||
:SetText(L["Select All"])
|
||||
:SetScript("OnClick", private.SelectAllOnClick)
|
||||
)
|
||||
:AddChild(UIElements.New("Texture", "line")
|
||||
:SetSize(2, 20)
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetTexture("ACTIVE_BG")
|
||||
)
|
||||
:AddChild(UIElements.New("Button", "clearAll")
|
||||
:SetSize("AUTO", 20)
|
||||
:SetFont("BODY_BODY3_MEDIUM")
|
||||
:SetText(L["Clear All"])
|
||||
:SetDisabled(true)
|
||||
:SetScript("OnClick", private.ClearAllOnClick)
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
function private.AddOperationGroups(frame)
|
||||
for _, groupPath in TSM.Operations.GroupIterator(private.currentModule, private.currentOperationName, true) do
|
||||
frame:AddChild(private.CreateGroupOperationLine(groupPath))
|
||||
end
|
||||
end
|
||||
|
||||
function private.CreateGroupOperationLine(groupPath)
|
||||
local groupName = groupPath == TSM.CONST.ROOT_GROUP_PATH and L["Base Group"] or TSM.Groups.Path.GetName(groupPath)
|
||||
local level = select('#', strsplit(TSM.CONST.GROUP_SEP, groupPath))
|
||||
return UIElements.New("Frame", "group")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(20)
|
||||
:SetMargin(2, 0, 0, 0)
|
||||
:AddChild(UIElements.New("Text", "text")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("BODY_BODY2")
|
||||
:SetTextColor(Theme.GetGroupColor(level))
|
||||
:SetText(groupName)
|
||||
)
|
||||
:AddChild(UIElements.New("Button", "viewBtn")
|
||||
:SetMargin(2, 2, 0, 0)
|
||||
:SetBackgroundAndSize("iconPack.14x14/Groups")
|
||||
:SetContext(groupPath)
|
||||
:SetScript("OnClick", private.ViewGroupOnClick)
|
||||
)
|
||||
:AddChild(UIElements.New("Button", "removeBtn")
|
||||
:SetBackgroundAndSize("iconPack.14x14/Close/Default")
|
||||
:SetContext(groupPath)
|
||||
:SetScript("OnClick", private.RemoveOperationGroupOnClick)
|
||||
)
|
||||
:AddChild(UIElements.New("Spacer", "spacer"))
|
||||
end
|
||||
|
||||
function private.CreateLinkButton(disabled, settingKey)
|
||||
local relationshipSet = TSM.Operations.HasRelationship(private.currentModule, private.currentOperationName, settingKey)
|
||||
local linkTexture = nil
|
||||
if disabled and relationshipSet then
|
||||
linkTexture = TSM.UI.TexturePacks.GetColoredKey("iconPack.14x14/Link", "INDICATOR_DISABLED")
|
||||
elseif disabled then
|
||||
linkTexture = TSM.UI.TexturePacks.GetColoredKey("iconPack.14x14/Link", "TEXT_DISABLED")
|
||||
elseif relationshipSet then
|
||||
linkTexture = TSM.UI.TexturePacks.GetColoredKey("iconPack.14x14/Link", "INDICATOR")
|
||||
else
|
||||
linkTexture = TSM.UI.TexturePacks.GetColoredKey("iconPack.14x14/Link", "TEXT")
|
||||
end
|
||||
return UIElements.New("Button", "linkBtn")
|
||||
:SetMargin(4, 4, 0, 0)
|
||||
:SetBackgroundAndSize(linkTexture)
|
||||
:SetDisabled(disabled)
|
||||
:SetContext(settingKey)
|
||||
:SetScript("OnClick", private.LinkBtnOnClick)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Local Script Handlers
|
||||
-- ============================================================================
|
||||
|
||||
function private.OperationSearchOnValueChanged(input)
|
||||
local filter = strlower(input:GetValue())
|
||||
input:GetElement("__parent.operationTree"):SetOperationNameFilter(filter)
|
||||
end
|
||||
|
||||
function private.OperationTreeOnOperationAdded(operationTree, moduleName, operationName, copyOperationName)
|
||||
-- clear the filter
|
||||
operationTree:GetElement("__parent.search")
|
||||
:SetValue("")
|
||||
:Draw()
|
||||
operationTree:SetOperationNameFilter("")
|
||||
TSM.Operations.Create(moduleName, operationName)
|
||||
if copyOperationName then
|
||||
TSM.Operations.Copy(moduleName, operationName, copyOperationName)
|
||||
end
|
||||
end
|
||||
|
||||
function private.OperationTreeOnOperationConfirmDelete(self, moduleName, operationName)
|
||||
self:GetBaseElement():ShowConfirmationDialog(L["Delete Operation?"], L["Are you sure you want to delete this operation?"], private.OperationTreeOnOperationDeleted, self, moduleName, operationName)
|
||||
end
|
||||
|
||||
function private.OperationTreeOnOperationDeleted(self, moduleName, operationName)
|
||||
TSM.Operations.Delete(moduleName, operationName)
|
||||
local operationTree = self:GetElement("__parent.operationTree")
|
||||
operationTree:SetSelectedOperation(moduleName, nil)
|
||||
:Draw()
|
||||
end
|
||||
|
||||
function private.OperationTreeOnOperationSelected(self, moduleName, operationName)
|
||||
private.currentModule = moduleName
|
||||
private.currentOperationName = operationName
|
||||
|
||||
local viewContainer = self:GetParentElement():GetParentElement():GetElement("content")
|
||||
if moduleName and operationName then
|
||||
TSM.Operations.Update(moduleName, operationName)
|
||||
viewContainer:SetPath("operation")
|
||||
viewContainer:GetElement("settings.title.text"):SetText(operationName)
|
||||
local contentFrame = viewContainer:GetElement("settings.content")
|
||||
contentFrame:ReleaseAllChildren()
|
||||
contentFrame:AddChild(private.moduleCallbacks[moduleName](operationName))
|
||||
elseif moduleName then
|
||||
local numOperations = 0
|
||||
for _ in TSM.Operations.OperationIterator(moduleName) do
|
||||
numOperations = numOperations + 1
|
||||
end
|
||||
TSM.UI.AnalyticsRecordPathChange("main", "operations", "summary")
|
||||
viewContainer:SetPath("summary")
|
||||
viewContainer:GetElement("settings.title.text"):SetText(format(L["%s %s Operations"], Theme.GetColor("INDICATOR"):ColorText(numOperations), moduleName))
|
||||
local contentFrame = viewContainer:GetElement("settings.content")
|
||||
contentFrame:ReleaseAllChildren()
|
||||
contentFrame:AddChild(private.GetSummaryContent())
|
||||
else
|
||||
TSM.UI.AnalyticsRecordPathChange("main", "operations", "none")
|
||||
viewContainer:SetPath("none")
|
||||
viewContainer:GetElement("settings.title.text"):SetText(L["No Operation Selected"])
|
||||
end
|
||||
viewContainer:Draw()
|
||||
end
|
||||
|
||||
function private.CreateNewOperationOnClick(button)
|
||||
local operationName = "New Operation"
|
||||
local num = 1
|
||||
while TSM.Operations.Exists(private.currentModule, operationName.." "..num) do
|
||||
num = num + 1
|
||||
end
|
||||
operationName = operationName .. " " .. num
|
||||
TSM.Operations.Create(private.currentModule, operationName)
|
||||
button:GetElement("__parent.__parent.__parent.__parent.selection.operationTree")
|
||||
:SetSelectedOperation(private.currentModule, operationName)
|
||||
:Draw()
|
||||
end
|
||||
|
||||
function private.OperationNameChanged(text, newValue)
|
||||
newValue = strtrim(newValue)
|
||||
if newValue == private.currentOperationName then
|
||||
-- didn't change
|
||||
text:Draw()
|
||||
elseif newValue == "" then
|
||||
Log.PrintUser(L["Invalid operation name."])
|
||||
text:Draw()
|
||||
elseif TSM.Operations.Exists(private.currentModule, newValue) then
|
||||
Log.PrintUser(L["Group already exists."])
|
||||
text:Draw()
|
||||
else
|
||||
TSM.Operations.Rename(private.currentModule, private.currentOperationName, newValue)
|
||||
text:GetElement("__parent.__parent.__parent.__parent.selection.operationTree")
|
||||
:SetSelectedOperation(private.currentModule, newValue)
|
||||
:Draw()
|
||||
end
|
||||
end
|
||||
|
||||
function private.NameOnEditingChanged(text, editing)
|
||||
if editing then
|
||||
text:GetElement("__parent.renameBtn"):Hide()
|
||||
else
|
||||
text:GetElement("__parent.renameBtn"):Show()
|
||||
end
|
||||
end
|
||||
|
||||
function private.RenameOperationOnClick(button)
|
||||
button:GetElement("__parent.text"):SetEditing(true)
|
||||
end
|
||||
|
||||
function private.ResetOperationOnClick(button)
|
||||
button:GetBaseElement():ShowConfirmationDialog(L["Reset Operation?"], L["Resetting the operation will return all inputs back to default and cannot be unddone. Click confirm to reset."], private.ConfirmResetOnClick, button)
|
||||
end
|
||||
|
||||
function private.ConfirmResetOnClick(button)
|
||||
TSM.Operations.Reset(private.currentModule, private.currentOperationName)
|
||||
local settingsFrame = button:GetBaseElement():GetElement("content.operations.content.settings")
|
||||
local contentFrame = settingsFrame:GetElement("content")
|
||||
contentFrame:ReleaseAllChildren()
|
||||
TSM.Operations.Update(private.currentModule, private.currentOperationName)
|
||||
contentFrame:AddChild(private.moduleCallbacks[private.currentModule](private.currentOperationName))
|
||||
button:GetBaseElement():HideDialog()
|
||||
settingsFrame:Draw()
|
||||
Log.PrintfUser(L["%s - %s has been reset to default values."], private.currentModule, Theme.GetColor("INDICATOR_ALT"):ColorText(private.currentOperationName))
|
||||
end
|
||||
|
||||
function private.GroupSelectionChanged(groupSelector)
|
||||
for groupPath in groupSelector:SelectedGroupIterator() do
|
||||
if not TSM.Operations.GroupHasOperation(private.currentModule, groupPath, private.currentOperationName) then
|
||||
local parentElement = groupSelector:GetParentElement():GetParentElement()
|
||||
if groupPath ~= TSM.CONST.ROOT_GROUP_PATH then
|
||||
TSM.Groups.SetOperationOverride(groupPath, private.currentModule, true)
|
||||
end
|
||||
local numOperations = 0
|
||||
local lastOperationName = nil
|
||||
for _, groupOperationName in TSM.Groups.OperationIterator(groupPath, private.currentModule) do
|
||||
lastOperationName = groupOperationName
|
||||
numOperations = numOperations + 1
|
||||
end
|
||||
if numOperations == TSM.Operations.GetMaxNumber(private.currentModule) then
|
||||
-- replace the last operation since we're already at the max number of operations
|
||||
TSM.Groups.RemoveOperation(groupPath, private.currentModule, numOperations)
|
||||
Log.PrintfUser(L["%s previously had the max number of operations, so removed %s."], Log.ColorUserAccentText(TSM.Groups.Path.Format(groupPath)), Log.ColorUserAccentText(lastOperationName))
|
||||
end
|
||||
TSM.Groups.AppendOperation(groupPath, private.currentModule, private.currentOperationName)
|
||||
Log.PrintfUser(L["Added %s to %s."], Log.ColorUserAccentText(private.currentOperationName), Log.ColorUserAccentText(groupPath == TSM.CONST.ROOT_GROUP_PATH and L["Base Group"] or TSM.Groups.Path.Format(groupPath)))
|
||||
parentElement:AddChild(private.CreateGroupOperationLine(groupPath))
|
||||
end
|
||||
end
|
||||
groupSelector:ClearSelectedGroups(true)
|
||||
groupSelector:GetParentElement():GetParentElement():GetParentElement():GetParentElement():GetParentElement():GetParentElement():Draw()
|
||||
end
|
||||
|
||||
function private.ViewGroupOnClick(button)
|
||||
local baseFrame = button:GetBaseElement()
|
||||
TSM.MainUI.Groups.ShowGroupSettings(baseFrame, button:GetContext())
|
||||
end
|
||||
|
||||
function private.RemoveOperationGroupOnClick(self)
|
||||
local groupPath = self:GetContext()
|
||||
TSM.Groups.RemoveOperationByName(groupPath, private.currentModule, private.currentOperationName)
|
||||
|
||||
-- remove the line for this group
|
||||
local removeElement = self:GetParentElement()
|
||||
local removeElementParent = removeElement:GetParentElement()
|
||||
removeElementParent:RemoveChild(removeElement)
|
||||
removeElement:Release()
|
||||
removeElementParent:GetParentElement():GetParentElement():GetParentElement():Draw()
|
||||
end
|
||||
|
||||
function private.LinkBtnOnClick(button)
|
||||
local settingKey = button:GetContext()
|
||||
wipe(private.linkMenuEntries)
|
||||
for _, operationName in TSM.Operations.OperationIterator(private.currentModule) do
|
||||
if operationName ~= private.currentOperationName and not TSM.Operations.IsCircularRelationship(private.currentModule, private.currentOperationName, settingKey) then
|
||||
tinsert(private.linkMenuEntries, operationName)
|
||||
end
|
||||
end
|
||||
sort(private.linkMenuEntries)
|
||||
button:GetBaseElement():ShowDialogFrame(UIElements.New("PopupFrame", "linkDialog")
|
||||
:SetLayout("VERTICAL")
|
||||
:SetSize(263, 243)
|
||||
:AddAnchor("TOPRIGHT", button:_GetBaseFrame(), "BOTTOM", 22, -16)
|
||||
:AddChild(UIElements.New("Frame", "titleFrame")
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(37)
|
||||
:AddChild(UIElements.New("Text", "title")
|
||||
:SetFont("BODY_BODY2_MEDIUM")
|
||||
:SetJustifyH("CENTER")
|
||||
:SetText(L["Link to Another Operation"])
|
||||
)
|
||||
)
|
||||
:AddChild(UIElements.New("Texture", "line")
|
||||
:SetHeight(2)
|
||||
:SetTexture("TEXT")
|
||||
)
|
||||
:AddChild(UIElements.New("SelectionList", "list")
|
||||
:SetContext(settingKey)
|
||||
:SetMargin(2, 2, 0, 3)
|
||||
:SetEntries(private.linkMenuEntries, TSM.Operations.GetRelationship(private.currentModule, private.currentOperationName, settingKey))
|
||||
:SetScript("OnEntrySelected", private.ListOnEntrySelected)
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
function private.ListOnEntrySelected(list, operationName)
|
||||
local settingKey = list:GetContext()
|
||||
local previousValue = TSM.Operations.GetRelationship(private.currentModule, private.currentOperationName, settingKey)
|
||||
if operationName == previousValue then
|
||||
TSM.Operations.SetRelationship(private.currentModule, private.currentOperationName, settingKey, nil)
|
||||
else
|
||||
TSM.Operations.SetRelationship(private.currentModule, private.currentOperationName, settingKey, operationName)
|
||||
end
|
||||
|
||||
local baseFrame = list:GetBaseElement()
|
||||
baseFrame:HideDialog()
|
||||
Operations.ShowOperationSettings(baseFrame, private.currentModule, private.currentOperationName)
|
||||
end
|
||||
|
||||
function private.OperationListOnSelectionChanged(scrollingTable)
|
||||
local selectionCleared = scrollingTable:IsSelectionCleared()
|
||||
local numSelected = 0
|
||||
for _ in scrollingTable:SelectionIterator() do
|
||||
numSelected = numSelected + 1
|
||||
end
|
||||
local footer = scrollingTable:GetElement("__parent.footer")
|
||||
footer:GetElement("deleteSelected")
|
||||
:SetText(numSelected > 0 and format(L["Delete %d Operations"], numSelected) or L["Delete Operations"])
|
||||
:SetDisabled(selectionCleared)
|
||||
footer:GetElement("selectAll")
|
||||
:SetDisabled(scrollingTable:IsAllSelected())
|
||||
footer:GetElement("clearAll")
|
||||
:SetDisabled(selectionCleared)
|
||||
footer:Draw()
|
||||
end
|
||||
|
||||
function private.SelectAllOnClick(button)
|
||||
button:GetElement("__parent.__parent.list"):SelectAll()
|
||||
end
|
||||
|
||||
function private.ClearAllOnClick(button)
|
||||
button:GetElement("__parent.__parent.list"):ClearSelection()
|
||||
end
|
||||
|
||||
function private.DeleteSelectedOnClick(button)
|
||||
local scrollingTable = button:GetElement("__parent.__parent.list")
|
||||
button:GetBaseElement():ShowConfirmationDialog(L["Delete Operations?"], L["Are you sure you want to delete the selected operations?"], private.DeleteSelectedOperations, scrollingTable)
|
||||
end
|
||||
|
||||
function private.DeleteSelectedOperations(scrollingTable)
|
||||
local toDelete = TempTable.Acquire()
|
||||
for _, row in scrollingTable:SelectionIterator() do
|
||||
local moduleName, operationName = row:GetFields("moduleName", "operationName")
|
||||
assert(moduleName == private.currentModule)
|
||||
tinsert(toDelete, operationName)
|
||||
end
|
||||
TSM.Operations.DeleteList(private.currentModule, toDelete)
|
||||
TempTable.Release(toDelete)
|
||||
scrollingTable:UpdateData(true)
|
||||
private.OperationListOnSelectionChanged(scrollingTable)
|
||||
scrollingTable:GetElement("__parent.__parent.__parent.__parent.__parent.selection.operationTree"):UpdateData(true)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Private Helper Functions
|
||||
-- ============================================================================
|
||||
|
||||
function private.NumGroupsVirtualField(row)
|
||||
local num = 0
|
||||
for _ in TSM.Operations.GroupIterator(row:GetField("moduleName"), row:GetField("operationName")) do
|
||||
num = num + 1
|
||||
end
|
||||
return num
|
||||
end
|
||||
|
||||
function private.NumItemsVirtualField(row)
|
||||
local includesBaseGroup = false
|
||||
local num = 0
|
||||
for _, groupPath in TSM.Operations.GroupIterator(row:GetField("moduleName"), row:GetField("operationName")) do
|
||||
if groupPath == TSM.CONST.ROOT_GROUP_PATH then
|
||||
includesBaseGroup = true
|
||||
else
|
||||
num = num + TSM.Groups.GetNumItems(groupPath)
|
||||
end
|
||||
end
|
||||
if includesBaseGroup then
|
||||
num = num + 0.9
|
||||
end
|
||||
return num
|
||||
end
|
||||
|
||||
function private.GetConfigureIcon(_, _, iconIndex)
|
||||
assert(iconIndex == 1)
|
||||
return true, "iconPack.12x12/Popout", false
|
||||
end
|
||||
|
||||
function private.OnConfigureIconClick(scrollingTable, data, iconIndex)
|
||||
assert(iconIndex == 1)
|
||||
local operationName = scrollingTable:GetContext():GetResultRowByUUID(data):GetField("operationName")
|
||||
scrollingTable:GetElement("__parent.__parent.__parent.__parent.__parent.selection.operationTree")
|
||||
:SetSelectedOperation(private.currentModule, operationName)
|
||||
end
|
||||
|
||||
function private.GetNumItemsText(numItems)
|
||||
if numItems == floor(numItems) then
|
||||
return numItems
|
||||
else
|
||||
return floor(numItems).."*"
|
||||
end
|
||||
end
|
||||
|
||||
function private.GetNumItemsTooltip(numItems)
|
||||
if numItems == floor(numItems) then
|
||||
return nil
|
||||
end
|
||||
return L["This operation is applied to the base group which includes every item not in another group."]
|
||||
end
|
||||
159
Core/UI/MainUI/Operations/Crafting.lua
Normal file
159
Core/UI/MainUI/Operations/Crafting.lua
Normal file
@@ -0,0 +1,159 @@
|
||||
-- ------------------------------------------------------------------------------ --
|
||||
-- TradeSkillMaster --
|
||||
-- https://tradeskillmaster.com --
|
||||
-- All Rights Reserved - Detailed license information included with addon. --
|
||||
-- ------------------------------------------------------------------------------ --
|
||||
|
||||
local _, TSM = ...
|
||||
local Crafting = TSM.MainUI.Operations:NewPackage("Crafting")
|
||||
local L = TSM.Include("Locale").GetTable()
|
||||
local UIElements = TSM.Include("UI.UIElements")
|
||||
local private = {
|
||||
currentOperationName = nil,
|
||||
}
|
||||
local BAD_CRAFT_VALUE_PRICE_SOURCES = {
|
||||
crafting = true,
|
||||
}
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Module Functions
|
||||
-- ============================================================================
|
||||
|
||||
function Crafting.OnInitialize()
|
||||
TSM.MainUI.Operations.RegisterModule("Crafting", private.GetCraftingOperationSettings)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Crafting Operation Settings UI
|
||||
-- ============================================================================
|
||||
|
||||
function private.GetCraftingOperationSettings(operationName)
|
||||
TSM.UI.AnalyticsRecordPathChange("main", "operations", "crafting")
|
||||
private.currentOperationName = operationName
|
||||
local operation = TSM.Operations.GetSettings("Crafting", private.currentOperationName)
|
||||
local frame = UIElements.New("ScrollFrame", "settings")
|
||||
:SetPadding(8, 8, 8, 0)
|
||||
:AddChild(TSM.MainUI.Operations.CreateExpandableSection("Crafting", "restockQuantity", L["Restock Options"], L["Adjust how crafted items are restocked."])
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("minRestock", L["Min restock quantity"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("Frame", "content")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(24)
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetBackgroundColor("ACTIVE_BG")
|
||||
:SetValidateFunc("CUSTOM_PRICE")
|
||||
:SetSettingInfo(operation, "minRestock")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Crafting", private.currentOperationName, "minRestock"))
|
||||
)
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("BODY_BODY3")
|
||||
:SetTextColor(TSM.Operations.HasRelationship("Crafting", private.currentOperationName, "minRestock") and "TEXT_DISABLED" or "TEXT")
|
||||
:SetFormattedText(L["Supported range: %d - %d"], TSM.Operations.Crafting.GetRestockRange())
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("maxRestock", L["Max restock quantity"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("Frame", "content")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(24)
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetBackgroundColor("ACTIVE_BG")
|
||||
:SetValidateFunc("CUSTOM_PRICE")
|
||||
:SetSettingInfo(operation, "maxRestock")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Crafting", private.currentOperationName, "maxRestock"))
|
||||
)
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("BODY_BODY3")
|
||||
:SetTextColor(TSM.Operations.HasRelationship("Crafting", private.currentOperationName, "maxRestock") and "TEXT_DISABLED" or "TEXT")
|
||||
:SetFormattedText(L["Supported range: %d - %d"], TSM.Operations.Crafting.GetRestockRange())
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("minProfit", L["Set min profit"], nil, "minProfitToggle")
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(42)
|
||||
:AddChild(UIElements.New("ToggleOnOff", "toggle")
|
||||
:SetHeight(18)
|
||||
:SetValue(operation.minProfit ~= "")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Crafting", private.currentOperationName, "minProfit"))
|
||||
:SetScript("OnValueChanged", private.MinProfitToggleOnValueChanged)
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateExpandableSection("Crafting", "priceSettings", L["Crafting Value"], L["Adjust how TSM values crafted items when calculating profit."])
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("craftPriceMethod", L["Override default craft value"], nil, "craftPriceMethodToggle")
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(42)
|
||||
:AddChild(UIElements.New("ToggleOnOff", "toggle")
|
||||
:SetHeight(18)
|
||||
:SetValue(operation.craftPriceMethod ~= "")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Crafting", private.currentOperationName, "craftPriceMethod"))
|
||||
:SetScript("OnValueChanged", private.CraftPriceToggleOnValueChanged)
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.GetOperationManagementElements("Crafting", private.currentOperationName))
|
||||
|
||||
if operation.minProfit ~= "" then
|
||||
frame:GetElement("restockQuantity.content.minProfitToggle"):SetMargin(0, 0, 0, 12)
|
||||
frame:GetElement("restockQuantity"):AddChild(TSM.MainUI.Operations.CreateLinkedPriceInput("minProfit", L["Min profit amount"], 80))
|
||||
end
|
||||
if operation.craftPriceMethod ~= "" then
|
||||
frame:GetElement("priceSettings.content.craftPriceMethodToggle"):SetMargin(0, 0, 0, 12)
|
||||
frame:GetElement("priceSettings"):AddChild(TSM.MainUI.Operations.CreateLinkedPriceInput("craftPriceMethod", L["Craft Value"], 80, BAD_CRAFT_VALUE_PRICE_SOURCES, TSM.db.global.craftingOptions.defaultCraftPriceMethod))
|
||||
end
|
||||
|
||||
return frame
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Local Script Handlers
|
||||
-- ============================================================================
|
||||
|
||||
function private.MinProfitToggleOnValueChanged(toggle, value)
|
||||
local operation = TSM.Operations.GetSettings("Crafting", private.currentOperationName)
|
||||
local defaultValue = TSM.Operations.GetSettingDefault("Crafting", "minProfit")
|
||||
operation.minProfit = value and defaultValue or ""
|
||||
local settingsFrame = toggle:GetParentElement():GetParentElement()
|
||||
if value then
|
||||
settingsFrame:GetElement("minProfitToggle"):SetMargin(0, 0, 0, 12)
|
||||
settingsFrame:GetParentElement():AddChild(TSM.MainUI.Operations.CreateLinkedPriceInput("minProfit", L["Min profit amount"], 80))
|
||||
else
|
||||
settingsFrame:GetElement("minProfitToggle"):SetMargin(0, 0, 0, 0)
|
||||
local linkedPriceLine = settingsFrame:GetElement("minProfit")
|
||||
settingsFrame:RemoveChild(linkedPriceLine)
|
||||
linkedPriceLine:Release()
|
||||
end
|
||||
settingsFrame:GetParentElement():GetParentElement():Draw()
|
||||
end
|
||||
|
||||
function private.CraftPriceToggleOnValueChanged(toggle, value)
|
||||
local operation = TSM.Operations.GetSettings("Crafting", private.currentOperationName)
|
||||
operation.craftPriceMethod = value and TSM.db.global.craftingOptions.defaultCraftPriceMethod or ""
|
||||
local settingsFrame = toggle:GetParentElement():GetParentElement()
|
||||
if value then
|
||||
settingsFrame:GetElement("craftPriceMethodToggle"):SetMargin(0, 0, 0, 12)
|
||||
settingsFrame:GetParentElement():AddChild(TSM.MainUI.Operations.CreateLinkedPriceInput("craftPriceMethod", L["Craft Value"], 80, BAD_CRAFT_VALUE_PRICE_SOURCES, TSM.db.global.craftingOptions.defaultCraftPriceMethod))
|
||||
else
|
||||
settingsFrame:GetElement("craftPriceMethodToggle"):SetMargin(0, 0, 0, 0)
|
||||
local linkedPriceLine = settingsFrame:GetElement("craftPriceMethod")
|
||||
settingsFrame:RemoveChild(linkedPriceLine)
|
||||
linkedPriceLine:Release()
|
||||
end
|
||||
settingsFrame:GetParentElement():GetParentElement():Draw()
|
||||
end
|
||||
220
Core/UI/MainUI/Operations/Mailing.lua
Normal file
220
Core/UI/MainUI/Operations/Mailing.lua
Normal file
@@ -0,0 +1,220 @@
|
||||
-- ------------------------------------------------------------------------------ --
|
||||
-- TradeSkillMaster --
|
||||
-- https://tradeskillmaster.com --
|
||||
-- All Rights Reserved - Detailed license information included with addon. --
|
||||
-- ------------------------------------------------------------------------------ --
|
||||
|
||||
local _, TSM = ...
|
||||
local Mailing = TSM.MainUI.Operations:NewPackage("Mailing")
|
||||
local PlayerInfo = TSM.Include("Service.PlayerInfo")
|
||||
local L = TSM.Include("Locale").GetTable()
|
||||
local UIElements = TSM.Include("UI.UIElements")
|
||||
local private = {
|
||||
currentOperationName = nil,
|
||||
}
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Module Functions
|
||||
-- ============================================================================
|
||||
|
||||
function Mailing.OnInitialize()
|
||||
TSM.MainUI.Operations.RegisterModule("Mailing", private.GetMailingOperationSettings)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Mailing Operation Settings UI
|
||||
-- ============================================================================
|
||||
|
||||
function private.GetMailingOperationSettings(operationName)
|
||||
TSM.UI.AnalyticsRecordPathChange("main", "operations", "mailing")
|
||||
private.currentOperationName = operationName
|
||||
local operation = TSM.Operations.GetSettings("Mailing", private.currentOperationName)
|
||||
return UIElements.New("ScrollFrame", "content")
|
||||
:SetPadding(8, 8, 8, 0)
|
||||
:AddChild(TSM.MainUI.Operations.CreateExpandableSection("Mailing", "generalOptions", L["General Options"], L["Adjust how items are mailed."])
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("target", L["Target character"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("Frame", "content")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetHeight(24)
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetHintText(L["Enter player name"])
|
||||
:SetAutoComplete(PlayerInfo.GetConnectedAlts())
|
||||
:SetClearButtonEnabled(true)
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Mailing", private.currentOperationName, "target"))
|
||||
:SetSettingInfo(operation, "target")
|
||||
)
|
||||
:AddChild(UIElements.New("ActionButton", "contacts")
|
||||
:SetSize(152, 24)
|
||||
:SetFont("BODY_BODY2_MEDIUM")
|
||||
:SetText(L["Contacts"])
|
||||
:SetScript("OnClick", private.ContactsBtnOnClick)
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("keepQty", L["Keep this amount"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("Frame", "content")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(24)
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetBackgroundColor("ACTIVE_BG")
|
||||
:SetValidateFunc("NUMBER", "0:50000")
|
||||
:SetSettingInfo(operation, "keepQty")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Mailing", private.currentOperationName, "keepQty"))
|
||||
)
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("BODY_BODY3")
|
||||
:SetTextColor(TSM.Operations.HasRelationship("Mailing", private.currentOperationName, "keepQty") and "TEXT_DISABLED" or "TEXT")
|
||||
:SetFormattedText(L["Enter a value from %d - %d"], 0, 50000)
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("maxQtyEnabled", L["Set max quantity"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(42)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("ToggleOnOff", "toggle")
|
||||
:SetHeight(18)
|
||||
:SetSettingInfo(operation, "maxQtyEnabled")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Mailing", private.currentOperationName, "maxQtyEnabled"))
|
||||
:SetScript("OnValueChanged", private.MaxQuantityToggleOnValueChanged)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("maxQty", L["Max quantity"], not operation.maxQtyEnabled)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("Frame", "content")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(24)
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetBackgroundColor("ACTIVE_BG")
|
||||
:SetValidateFunc("NUMBER", "1:50000")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Mailing", private.currentOperationName, "maxQty") or not operation.maxQtyEnabled)
|
||||
:SetSettingInfo(operation, "maxQty")
|
||||
)
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("BODY_BODY3")
|
||||
:SetTextColor((TSM.Operations.HasRelationship("Mailing", private.currentOperationName, "maxQty") or not operation.maxQtyEnabled) and "TEXT_DISABLED" or "TEXT")
|
||||
:SetFormattedText(L["Enter a value from %d - %d"], 1, 50000)
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("restock", L["Restock target to max quantity"], not operation.maxQtyEnabled)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(42)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("ToggleOnOff", "toggle")
|
||||
:SetHeight(18)
|
||||
:SetSettingInfo(operation, "restock")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Mailing", private.currentOperationName, "restock") or not operation.maxQtyEnabled)
|
||||
:SetScript("OnValueChanged", private.RestockToggleOnValueChanged)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("restockSources", L["Sources to include for restock"], not operation.restock or not operation.maxQtyEnabled)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:AddChild(UIElements.New("MultiselectionDropdown", "dropdown")
|
||||
:SetHeight(24)
|
||||
:AddItem(BANK, "bank")
|
||||
:AddItem(GUILD, "guild")
|
||||
:SetSettingInfo(operation, "restockSources")
|
||||
:SetSelectionText(L["No Sources"], L["%d Sources"], L["All Sources"])
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Mailing", private.currentOperationName, "restockSources") or not operation.restock or not operation.maxQtyEnabled)
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.GetOperationManagementElements("Mailing", private.currentOperationName))
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Local Script Handlers
|
||||
-- ============================================================================
|
||||
|
||||
function private.ContactsBtnOnClick(button)
|
||||
TSM.UI.Util.Contacts.ShowDialog(button, button:GetElement("__parent.input"))
|
||||
end
|
||||
|
||||
|
||||
function private.MaxQuantityToggleOnValueChanged(toggle, value)
|
||||
local settingsFrame = toggle:GetElement("__parent.__parent")
|
||||
local restockValue = settingsFrame:GetElement("restock.toggle"):GetValue()
|
||||
local relationshipSet, linkTexture, textColor = TSM.Operations.GetRelationshipColors("Mailing", private.currentOperationName, "maxQty", value)
|
||||
settingsFrame:GetElement("maxQty.line.linkBtn")
|
||||
:SetBackground(linkTexture)
|
||||
:SetDisabled(not value)
|
||||
settingsFrame:GetElement("maxQty.line.label")
|
||||
:SetTextColor(textColor)
|
||||
settingsFrame:GetElement("maxQty.content.label")
|
||||
:SetTextColor(textColor)
|
||||
settingsFrame:GetElement("maxQty.content.input")
|
||||
:SetDisabled(relationshipSet or not value)
|
||||
|
||||
relationshipSet, linkTexture, textColor = TSM.Operations.GetRelationshipColors("Mailing", private.currentOperationName, "restock", value)
|
||||
settingsFrame:GetElement("restock.line.linkBtn")
|
||||
:SetBackground(linkTexture)
|
||||
:SetDisabled(not value)
|
||||
settingsFrame:GetElement("restock.line.label")
|
||||
:SetTextColor(textColor)
|
||||
settingsFrame:GetElement("restock.toggle")
|
||||
:SetDisabled(relationshipSet or not value)
|
||||
|
||||
relationshipSet = TSM.Operations.HasRelationship("Mailing", private.currentOperationName, "restockSources")
|
||||
if relationshipSet and value and restockValue then
|
||||
linkTexture = TSM.UI.TexturePacks.GetColoredKey("iconPack.14x14/Link", "INDICATOR")
|
||||
elseif (relationshipSet and not value and restockValue) or (relationshipSet and value and not restockValue) or (relationshipSet and not value and not restockValue) then
|
||||
linkTexture = TSM.UI.TexturePacks.GetColoredKey("iconPack.14x14/Link", "INDICATOR_DISABLED")
|
||||
elseif (value and not restockValue) or (not value and restockValue) or (not value and not restockValue) then
|
||||
linkTexture = TSM.UI.TexturePacks.GetColoredKey("iconPack.14x14/Link", "TEXT_DISABLED")
|
||||
else
|
||||
linkTexture = TSM.UI.TexturePacks.GetColoredKey("iconPack.14x14/Link", "TEXT")
|
||||
end
|
||||
settingsFrame:GetElement("restockSources.line.linkBtn")
|
||||
:SetBackground(linkTexture)
|
||||
:SetDisabled(not value)
|
||||
settingsFrame:GetElement("restockSources.line.label")
|
||||
:SetTextColor(relationshipSet and "TEXT_DISABLED" or ((value and restockValue) and "TEXT" or "TEXT_DISABLED"))
|
||||
settingsFrame:GetElement("restockSources.dropdown")
|
||||
:SetDisabled(relationshipSet or not value or not restockValue)
|
||||
settingsFrame:Draw()
|
||||
end
|
||||
|
||||
function private.RestockToggleOnValueChanged(toggle, value)
|
||||
local settingsFrame = toggle:GetElement("__parent.__parent")
|
||||
local maxQtyEnabled = settingsFrame:GetElement("maxQtyEnabled.toggle"):GetValue()
|
||||
local relationshipSet = TSM.Operations.HasRelationship("Mailing", private.currentOperationName, "restockSources")
|
||||
local linkTexture = nil
|
||||
if relationshipSet and value and maxQtyEnabled then
|
||||
linkTexture = TSM.UI.TexturePacks.GetColoredKey("iconPack.14x14/Link", "INDICATOR")
|
||||
elseif (relationshipSet and not value and maxQtyEnabled) or (relationshipSet and value and not maxQtyEnabled) or (relationshipSet and not value and not maxQtyEnabled) then
|
||||
linkTexture = TSM.UI.TexturePacks.GetColoredKey("iconPack.14x14/Link", "INDICATOR_DISABLED")
|
||||
elseif (value and not maxQtyEnabled) or (not value and maxQtyEnabled) or (not value and not maxQtyEnabled) then
|
||||
linkTexture = TSM.UI.TexturePacks.GetColoredKey("iconPack.14x14/Link", "TEXT_DISABLED")
|
||||
else
|
||||
linkTexture = TSM.UI.TexturePacks.GetColoredKey("iconPack.14x14/Link", "TEXT")
|
||||
end
|
||||
settingsFrame:GetElement("restockSources.line.linkBtn")
|
||||
:SetBackground(linkTexture)
|
||||
:SetDisabled(not value)
|
||||
settingsFrame:GetElement("restockSources.line.label")
|
||||
:SetTextColor(relationshipSet and "TEXT_DISABLED" or ((value and maxQtyEnabled) and "TEXT" or "TEXT_DISABLED"))
|
||||
settingsFrame:GetElement("restockSources.dropdown")
|
||||
:SetDisabled(relationshipSet or not value or not maxQtyEnabled)
|
||||
settingsFrame:Draw()
|
||||
end
|
||||
88
Core/UI/MainUI/Operations/Shopping.lua
Normal file
88
Core/UI/MainUI/Operations/Shopping.lua
Normal file
@@ -0,0 +1,88 @@
|
||||
-- ------------------------------------------------------------------------------ --
|
||||
-- TradeSkillMaster --
|
||||
-- https://tradeskillmaster.com --
|
||||
-- All Rights Reserved - Detailed license information included with addon. --
|
||||
-- ------------------------------------------------------------------------------ --
|
||||
|
||||
local _, TSM = ...
|
||||
local Shopping = TSM.MainUI.Operations:NewPackage("Shopping")
|
||||
local L = TSM.Include("Locale").GetTable()
|
||||
local UIElements = TSM.Include("UI.UIElements")
|
||||
local private = {
|
||||
currentOperationName = nil,
|
||||
}
|
||||
local RESTOCK_SOURCES = { L["Alts"], L["Auctions"], BANK, GUILD }
|
||||
local RESTOCK_SOURCES_KEYS = { "alts", "auctions", "bank", "guild" }
|
||||
local BAD_PRICE_SOURCES = { shoppingopmax = true }
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Module Functions
|
||||
-- ============================================================================
|
||||
|
||||
function Shopping.OnInitialize()
|
||||
TSM.MainUI.Operations.RegisterModule("Shopping", private.GetShoppingOperationSettings)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Shopping Operation Settings UI
|
||||
-- ============================================================================
|
||||
|
||||
function private.GetShoppingOperationSettings(operationName)
|
||||
TSM.UI.AnalyticsRecordPathChange("main", "operations", "shopping")
|
||||
private.currentOperationName = operationName
|
||||
local operation = TSM.Operations.GetSettings("Shopping", private.currentOperationName)
|
||||
return UIElements.New("ScrollFrame", "settings")
|
||||
:SetPadding(8, 8, 8, 0)
|
||||
:SetBackgroundColor("PRIMARY_BG")
|
||||
:AddChild(TSM.MainUI.Operations.CreateExpandableSection("Shopping", "generalOptions", L["General Options"], L["Set what items are shown during a Shopping scan."])
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedPriceInput("maxPrice", L["Maximum auction price"], 124, BAD_PRICE_SOURCES))
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("showAboveMaxPrice", L["Show auctions above max price"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 12, 12)
|
||||
:AddChild(UIElements.New("ToggleOnOff", "toggle")
|
||||
:SetHeight(18)
|
||||
:SetSettingInfo(operation, "showAboveMaxPrice")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Shopping", private.currentOperationName, "showAboveMaxPrice"))
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("restockQuantity", L["Maximum restock quantity"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("Frame", "content")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(24)
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetBackgroundColor("ACTIVE_BG")
|
||||
:SetValidateFunc("CUSTOM_PRICE")
|
||||
:SetSettingInfo(operation, "restockQuantity")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Shopping", private.currentOperationName, "restockQuantity"))
|
||||
)
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("BODY_BODY3")
|
||||
:SetTextColor(TSM.Operations.HasRelationship("Shopping", private.currentOperationName, "restockQuantity") and "TEXT_DISABLED" or "TEXT")
|
||||
:SetFormattedText(L["Supported range: %d - %d"], TSM.Operations.Shopping.GetRestockRange())
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("restockSources", L["Sources to include for restock"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:AddChild(UIElements.New("MultiselectionDropdown", "dropdown")
|
||||
:SetHeight(24)
|
||||
:SetItems(RESTOCK_SOURCES, RESTOCK_SOURCES_KEYS)
|
||||
:SetSettingInfo(operation, "restockSources")
|
||||
:SetSelectionText(L["No Sources"], L["%d Sources"], L["All Sources"])
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Shopping", private.currentOperationName, "restockSources"))
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.GetOperationManagementElements("Shopping", private.currentOperationName))
|
||||
end
|
||||
42
Core/UI/MainUI/Operations/Sniper.lua
Normal file
42
Core/UI/MainUI/Operations/Sniper.lua
Normal file
@@ -0,0 +1,42 @@
|
||||
-- ------------------------------------------------------------------------------ --
|
||||
-- TradeSkillMaster --
|
||||
-- https://tradeskillmaster.com --
|
||||
-- All Rights Reserved - Detailed license information included with addon. --
|
||||
-- ------------------------------------------------------------------------------ --
|
||||
|
||||
local _, TSM = ...
|
||||
local Sniper = TSM.MainUI.Operations:NewPackage("Sniper")
|
||||
local L = TSM.Include("Locale").GetTable()
|
||||
local UIElements = TSM.Include("UI.UIElements")
|
||||
local private = {
|
||||
currentOperationName = nil,
|
||||
}
|
||||
local BAD_PRICE_SOURCES = { sniperopmax = true }
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Module Functions
|
||||
-- ============================================================================
|
||||
|
||||
function Sniper.OnInitialize()
|
||||
TSM.MainUI.Operations.RegisterModule("Sniper", private.GetSniperOperationSettings)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Sniper Operation Settings UI
|
||||
-- ============================================================================
|
||||
|
||||
function private.GetSniperOperationSettings(operationName)
|
||||
TSM.UI.AnalyticsRecordPathChange("main", "operations", "sniper")
|
||||
private.currentOperationName = operationName
|
||||
return UIElements.New("ScrollFrame", "settings")
|
||||
:SetPadding(8, 8, 8, 0)
|
||||
:SetBackgroundColor("PRIMARY_BG")
|
||||
:AddChild(TSM.MainUI.Operations.CreateExpandableSection("Sniper", "settings", L["General Options"], L["Set what items are shown during a Sniper scan."])
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedPriceInput("belowPrice", L["Maximum price"], 124, BAD_PRICE_SOURCES))
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.GetOperationManagementElements("Sniper", private.currentOperationName))
|
||||
end
|
||||
268
Core/UI/MainUI/Operations/Vendoring.lua
Normal file
268
Core/UI/MainUI/Operations/Vendoring.lua
Normal file
@@ -0,0 +1,268 @@
|
||||
-- ------------------------------------------------------------------------------ --
|
||||
-- TradeSkillMaster --
|
||||
-- https://tradeskillmaster.com --
|
||||
-- All Rights Reserved - Detailed license information included with addon. --
|
||||
-- ------------------------------------------------------------------------------ --
|
||||
|
||||
local _, TSM = ...
|
||||
local Vendoring = TSM.MainUI.Operations:NewPackage("Vendoring")
|
||||
local L = TSM.Include("Locale").GetTable()
|
||||
local UIElements = TSM.Include("UI.UIElements")
|
||||
local private = {
|
||||
currentOperationName = nil,
|
||||
}
|
||||
local RESTOCK_SOURCES = { BANK, GUILD, L["Alts"], L["Alts AH"], L["AH"], L["Mail"] }
|
||||
local RESTOCK_SOURCES_KEYS = { "bank", "guild", "alts", "alts_ah", "ah", "mail" }
|
||||
local SETTING_INFO = {
|
||||
restockQty = "INPUT_LABEL",
|
||||
restockSources = "DROPDOWN",
|
||||
keepQty = "INPUT_LABEL",
|
||||
sellAfterExpired = "INPUT_LABEL",
|
||||
vsMarketValue = "INPUT",
|
||||
vsMaxMarketValue = "INPUT",
|
||||
vsDestroyValue = "INPUT",
|
||||
vsMaxDestroyValue = "INPUT",
|
||||
sellSoulbound = "TOGGLE",
|
||||
}
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Module Functions
|
||||
-- ============================================================================
|
||||
|
||||
function Vendoring.OnInitialize()
|
||||
TSM.MainUI.Operations.RegisterModule("Vendoring", private.GetVendoringOperationSettings)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Vendoring Operation Settings UI
|
||||
-- ============================================================================
|
||||
|
||||
function private.GetVendoringOperationSettings(operationName)
|
||||
TSM.UI.AnalyticsRecordPathChange("main", "operations", "vendoring")
|
||||
private.currentOperationName = operationName
|
||||
|
||||
local operation = TSM.Operations.GetSettings("Vendoring", private.currentOperationName)
|
||||
return UIElements.New("ScrollFrame", "settings")
|
||||
:SetPadding(8, 8, 8, 0)
|
||||
:AddChild(TSM.MainUI.Operations.CreateExpandableSection("Vendoring", "buyOptionsHeading", L["Buy Options"], L["Set what is bought from a vendor."])
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("enableBuy", L["Enable buying"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("ToggleOnOff", "toggle")
|
||||
:SetHeight(18)
|
||||
:SetSettingInfo(operation, "enableBuy")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Vendoring", private.currentOperationName, "enableBuy"))
|
||||
:SetScript("OnValueChanged", private.EnableBuyingToggleOnValueChanged)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("restockQty", L["Restock quantity"], not operation.enableBuy)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("Frame", "content")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(24)
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetBackgroundColor("ACTIVE_BG")
|
||||
:SetValidateFunc("NUMBER", "0:50000")
|
||||
:SetSettingInfo(operation, "restockQty")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Vendoring", private.currentOperationName, "restockQty") or not operation.enableBuy)
|
||||
)
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("BODY_BODY3")
|
||||
:SetTextColor((TSM.Operations.HasRelationship("Vendoring", private.currentOperationName, "restockQty") or not operation.enableBuy) and "TEXT_DISABLED" or "TEXT")
|
||||
:SetFormattedText(L["Enter a value from %d - %d"], 0, 50000)
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("restockSources", L["Sources to include for restock"], not operation.enableBuy)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:AddChild(UIElements.New("MultiselectionDropdown", "dropdown")
|
||||
:SetHeight(24)
|
||||
:SetItems(RESTOCK_SOURCES, RESTOCK_SOURCES_KEYS)
|
||||
:SetSettingInfo(operation, "restockSources")
|
||||
:SetSelectionText(L["No Sources"], L["%d Sources"], L["All Sources"])
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Vendoring", private.currentOperationName, "restockSources") or not operation.enableBuy)
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateExpandableSection("Vendoring", "sellOptionsHeading", L["Sell Options"], L["Set what is sold to a vendor."])
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("enableSell", L["Enable selling"])
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("ToggleOnOff", "toggle")
|
||||
:SetHeight(18)
|
||||
:SetSettingInfo(operation, "enableSell")
|
||||
:SetScript("OnValueChanged", private.EnableSellingToggleOnValueChanged)
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Vendoring", private.currentOperationName, "enableSell"))
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("keepQty", L["Keep quantity"], not operation.enableSell)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("Frame", "content")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(24)
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetBackgroundColor("ACTIVE_BG")
|
||||
:SetValidateFunc("NUMBER", "0:50000")
|
||||
:SetSettingInfo(operation, "keepQty")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Vendoring", private.currentOperationName, "keepQty") or not operation.enableSell)
|
||||
)
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("BODY_BODY3")
|
||||
:SetTextColor((TSM.Operations.HasRelationship("Vendoring", private.currentOperationName, "keepQty") or not operation.enableSell) and "TEXT_DISABLED" or "TEXT")
|
||||
:SetFormattedText(L["Enter a value from %d - %d"], 0, 50000)
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("sellAfterExpired", L["Min number of expires"], not operation.enableSell)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("Frame", "content")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(24)
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetBackgroundColor("ACTIVE_BG")
|
||||
:SetValidateFunc("NUMBER", "0:50000")
|
||||
:SetSettingInfo(operation, "sellAfterExpired")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Vendoring", private.currentOperationName, "sellAfterExpired") or not operation.enableSell)
|
||||
)
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("BODY_BODY3")
|
||||
:SetTextColor((TSM.Operations.HasRelationship("Vendoring", private.currentOperationName, "sellAfterExpired") or not operation.enableSell) and "TEXT_DISABLED" or "TEXT")
|
||||
:SetFormattedText(L["Enter a value from %d - %d"], 0, 50000)
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("vsMarketValue", L["Market value"], not operation.enableSell)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetHeight(24)
|
||||
:SetBackgroundColor("ACTIVE_BG")
|
||||
:SetValidateFunc("CUSTOM_PRICE")
|
||||
:SetSettingInfo(operation, "vsMarketValue")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Vendoring", private.currentOperationName, "vsMarketValue") or not operation.enableSell)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("vsMaxMarketValue", L["Max market value (Enter '0c' to disable)"], not operation.enableSell)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetHeight(24)
|
||||
:SetBackgroundColor("ACTIVE_BG")
|
||||
:SetValidateFunc("CUSTOM_PRICE")
|
||||
:SetSettingInfo(operation, "vsMaxMarketValue")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Vendoring", private.currentOperationName, "vsMaxMarketValue") or not operation.enableSell)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("vsDestroyValue", L["Destroy value"], not operation.enableSell)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetHeight(24)
|
||||
:SetBackgroundColor("ACTIVE_BG")
|
||||
:SetValidateFunc("CUSTOM_PRICE")
|
||||
:SetSettingInfo(operation, "vsDestroyValue")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Vendoring", private.currentOperationName, "vsDestroyValue") or not operation.enableSell)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("vsMaxDestroyValue", L["Max destroy value (Enter '0c' to disable)"], not operation.enableSell)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetHeight(24)
|
||||
:SetBackgroundColor("ACTIVE_BG")
|
||||
:SetValidateFunc("CUSTOM_PRICE")
|
||||
:SetSettingInfo(operation, "vsMaxDestroyValue")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Vendoring", private.currentOperationName, "vsMaxDestroyValue") or not operation.enableSell)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine("sellSoulbound", L["Sell soulbound items"], not operation.enableSell)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 0)
|
||||
:AddChild(UIElements.New("ToggleOnOff", "toggle")
|
||||
:SetHeight(18)
|
||||
:SetSettingInfo(operation, "sellSoulbound")
|
||||
:SetDisabled(TSM.Operations.HasRelationship("Vendoring", private.currentOperationName, "sellSoulbound") or not operation.enableSell)
|
||||
)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.GetOperationManagementElements("Vendoring", private.currentOperationName))
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Local Script Handlers
|
||||
-- ============================================================================
|
||||
|
||||
function private.UpdateSettingState(settingsFrame, key, operation, value)
|
||||
local relationshipSet, linkTexture, textColor = TSM.Operations.GetRelationshipColors("Vendoring", private.currentOperationName, key, value)
|
||||
local settingKeyFrame = settingsFrame:GetElement(key)
|
||||
settingKeyFrame:GetElement("line.linkBtn")
|
||||
:SetBackground(linkTexture)
|
||||
:SetDisabled(not value)
|
||||
settingKeyFrame:GetElement("line.label")
|
||||
:SetTextColor(textColor)
|
||||
local settingType = SETTING_INFO[key]
|
||||
if settingType == "INPUT_LABEL" then
|
||||
settingKeyFrame:GetElement("content.input")
|
||||
:SetDisabled(relationshipSet or not value)
|
||||
:SetValue(operation[key] or "")
|
||||
settingKeyFrame:GetElement("content.label")
|
||||
:SetTextColor(textColor)
|
||||
elseif settingType == "INPUT" then
|
||||
settingKeyFrame:GetElement("input")
|
||||
:SetDisabled(relationshipSet or not value)
|
||||
elseif settingType == "TOGGLE" then
|
||||
settingKeyFrame:GetElement("toggle")
|
||||
:SetDisabled(relationshipSet or not value)
|
||||
elseif settingType == "DROPDOWN" then
|
||||
settingKeyFrame:GetElement("dropdown")
|
||||
:SetDisabled(relationshipSet or not value)
|
||||
else
|
||||
error("Invalid settingType: "..tostring(settingType))
|
||||
end
|
||||
end
|
||||
|
||||
function private.EnableBuyingToggleOnValueChanged(toggle, value)
|
||||
local operation = TSM.Operations.GetSettings("Vendoring", private.currentOperationName)
|
||||
local settingsFrame = toggle:GetElement("__parent.__parent")
|
||||
private.UpdateSettingState(settingsFrame, "restockQty", operation, value)
|
||||
private.UpdateSettingState(settingsFrame, "restockSources", operation, value)
|
||||
settingsFrame:Draw()
|
||||
end
|
||||
|
||||
function private.EnableSellingToggleOnValueChanged(toggle, value)
|
||||
local operation = TSM.Operations.GetSettings("Vendoring", private.currentOperationName)
|
||||
local settingsFrame = toggle:GetElement("__parent.__parent")
|
||||
for key in pairs(SETTING_INFO) do
|
||||
if key ~= "restockQty" and key ~= "restockSources" then
|
||||
private.UpdateSettingState(settingsFrame, key, operation, value)
|
||||
end
|
||||
end
|
||||
settingsFrame:Draw()
|
||||
end
|
||||
108
Core/UI/MainUI/Operations/Warehousing.lua
Normal file
108
Core/UI/MainUI/Operations/Warehousing.lua
Normal file
@@ -0,0 +1,108 @@
|
||||
-- ------------------------------------------------------------------------------ --
|
||||
-- TradeSkillMaster --
|
||||
-- https://tradeskillmaster.com --
|
||||
-- All Rights Reserved - Detailed license information included with addon. --
|
||||
-- ------------------------------------------------------------------------------ --
|
||||
|
||||
local _, TSM = ...
|
||||
local Warehousing = TSM.MainUI.Operations:NewPackage("Warehousing")
|
||||
local L = TSM.Include("Locale").GetTable()
|
||||
local UIElements = TSM.Include("UI.UIElements")
|
||||
local private = { currentOperationName = nil }
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Module Functions
|
||||
-- ============================================================================
|
||||
|
||||
function Warehousing.OnInitialize()
|
||||
TSM.MainUI.Operations.RegisterModule("Warehousing", private.GetWarehousingOperationSettings)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Warehousing Operation Settings UI
|
||||
-- ============================================================================
|
||||
|
||||
function private.GetWarehousingOperationSettings(operationName)
|
||||
TSM.UI.AnalyticsRecordPathChange("main", "operations", "warehousing")
|
||||
private.currentOperationName = operationName
|
||||
return UIElements.New("ScrollFrame", "settings")
|
||||
:SetPadding(8, 8, 8, 0)
|
||||
:AddChild(TSM.MainUI.Operations.CreateExpandableSection("Warehousing", "moveSettings", L["Move Quantity Options"], L["Set how items are moved out of the bank."])
|
||||
:AddChild(private.CreateEnabledSettingLine("moveQuantity", L["Set move quantity"], L["Quantity to move"], 0, 50000, true))
|
||||
:AddChild(private.CreateEnabledSettingLine("stackSize", L["Set stack size"], L["Stack size multiple"], 0, 200, true))
|
||||
:AddChild(private.CreateEnabledSettingLine("keepBagQuantity", L["Set keep in bags quantity"], L["Keep in bags quantity"], 0, 50000, true))
|
||||
:AddChild(private.CreateEnabledSettingLine("keepBankQuantity", L["Set keep in bank quantity"], L["Keep in bank quantity"], 0, 50000))
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateExpandableSection("Warehousing", "restockSettings", L["Restock Options"], L["Set how items are restocked from the bank."])
|
||||
:AddChild(private.CreateEnabledSettingLine("restockQuantity", L["Enable restock"], L["Restock quantity"], 0, 50000, true))
|
||||
:AddChild(private.CreateEnabledSettingLine("restockStackSize", L["Set stack size for restock"], L["Stack size multiple"], 0, 200, true))
|
||||
:AddChild(private.CreateEnabledSettingLine("restockKeepBankQuantity", L["Set keep in bank quantity"], L["Keep in bank quantity"], 0, 50000))
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.GetOperationManagementElements("Warehousing", private.currentOperationName))
|
||||
end
|
||||
|
||||
function private.CreateEnabledSettingLine(key, enableText, text, minValue, maxValue, margin)
|
||||
local operation = TSM.Operations.GetSettings("Warehousing", private.currentOperationName)
|
||||
local hasRelationship = TSM.Operations.HasRelationship("Warehousing", private.currentOperationName, key)
|
||||
return UIElements.New("Frame", "content")
|
||||
:SetLayout("VERTICAL")
|
||||
:AddChild(TSM.MainUI.Operations.CreateLinkedSettingLine(key, text)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, 12)
|
||||
:AddChild(UIElements.New("ToggleOnOff", "toggle")
|
||||
:SetHeight(18)
|
||||
:SetValue(operation[key] ~= 0)
|
||||
:SetDisabled(hasRelationship)
|
||||
:SetContext(key)
|
||||
:SetScript("OnValueChanged", private.EnabledSettingEnableOnValueChanged)
|
||||
)
|
||||
)
|
||||
:AddChild(TSM.MainUI.Operations.CreateSettingLine("content", text, hasRelationship or operation[key] == 0)
|
||||
:SetLayout("VERTICAL")
|
||||
:SetHeight(48)
|
||||
:SetMargin(0, 0, 0, margin and 12 or 4)
|
||||
:AddChild(UIElements.New("Frame", "content")
|
||||
:SetLayout("HORIZONTAL")
|
||||
:SetHeight(24)
|
||||
:AddChild(UIElements.New("Input", "input")
|
||||
:SetMargin(0, 8, 0, 0)
|
||||
:SetBackgroundColor("ACTIVE_BG")
|
||||
:SetValidateFunc("NUMBER", minValue..":"..maxValue)
|
||||
:SetSettingInfo(operation, key)
|
||||
:SetDisabled(hasRelationship or operation[key] == 0)
|
||||
)
|
||||
:AddChild(UIElements.New("Text", "label")
|
||||
:SetWidth("AUTO")
|
||||
:SetFont("BODY_BODY3")
|
||||
:SetTextColor((hasRelationship or operation[key] == 0) and "TEXT_DISABLED" or "TEXT")
|
||||
:SetFormattedText(L["Enter a value from %d - %d"], minValue, maxValue)
|
||||
)
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- ============================================================================
|
||||
-- Local Script Handlers
|
||||
-- ============================================================================
|
||||
|
||||
function private.EnabledSettingEnableOnValueChanged(toggle, value)
|
||||
local key = toggle:GetContext()
|
||||
local operation = TSM.Operations.GetSettings("Warehousing", private.currentOperationName)
|
||||
operation[key] = value and 1 or 0
|
||||
local settingFrame = toggle:GetElement("__parent.__parent.content")
|
||||
settingFrame:GetElement("label")
|
||||
:SetTextColor(value and "TEXT" or "TEXT_DISABLED")
|
||||
settingFrame:GetElement("content.input")
|
||||
:SetDisabled(not value)
|
||||
:SetValue(operation[key])
|
||||
settingFrame:GetElement("content.label")
|
||||
:SetTextColor(value and "TEXT" or "TEXT_DISABLED")
|
||||
settingFrame:Draw()
|
||||
end
|
||||
Reference in New Issue
Block a user