diff --git a/LeoTrainer.lua b/LeoTrainer.lua
index bee556c..a1d3991 100644
--- a/LeoTrainer.lua
+++ b/LeoTrainer.lua
@@ -176,6 +176,9 @@ function LeoTrainer.Initialize()
if not LeoTrainer.savedVariables.onlyResearchFCO then
LeoTrainer.savedVariables.onlyResearchFCO = false
end
+ if not LeoTrainer.savedVariables.defaultTrainer then
+ LeoTrainer.savedVariables.defaultTrainer = "Anyone"
+ end
for i, char in ipairs(LeoAltholic.ExportCharacters()) do
if LeoTrainer.savedVariables.trackedTraits[char.bio.name] == nil then
LeoTrainer.savedVariables.trackedTraits[char.bio.name] = {}
@@ -196,6 +199,8 @@ function LeoTrainer.Initialize()
{0,1000,10000,"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=Y9KM4PZU2UZ6A"},
"If you found a bug, have a request or a suggestion, or simply wish to donate, send a mail.")
LeoTrainer.feedback = feedbackWindow
+ LeoTrainer.feedback:SetDrawLayer(DL_OVERLAY)
+ LeoTrainer.feedback:SetDrawTier(DT_MEDIUM)
LeoTrainerWindowTitle:SetText(LeoTrainer.displayName .. " v" .. LeoTrainer.version)
diff --git a/LeoTrainer.txt b/LeoTrainer.txt
index 0e18544..bc7a280 100644
--- a/LeoTrainer.txt
+++ b/LeoTrainer.txt
@@ -1,6 +1,7 @@
## Title: Leo's Trainer
## APIVersion: 100024 100025
-## Version: 1.1.3
+## Version: 1.2.0
+## AddOnVersion: 120
## Author: |c39B027@LeandroSilva|r
## SavedVariables: LeoTrainerSavedVariables
## DependsOn: LeoAltholic
diff --git a/LeoTrainer.xml b/LeoTrainer.xml
index 9f3c732..a287286 100644
--- a/LeoTrainer.xml
+++ b/LeoTrainer.xml
@@ -881,7 +881,7 @@
<Label name="$(parent)Trainer" font="LeoTrainerNormalFont" color="ffffff" verticalAlignment="CENTER" mouseEnabled="true">
<Dimensions x="150" y="32" />
<Anchor point="TOPLEFT" relativeTo="$(parent)BG" relativePoint="TOPLEFT"/>
- <!--<OnMouseUp> LeoGM.UserClick(self, button, upInside) </OnMouseUp>-->
+ <OnMouseExit> ClearTooltip(InformationTooltip) </OnMouseExit>
</Label>
<Label name="$(parent)Trainee" font="LeoTrainerNormalFont" verticalAlignment="CENTER">
<Dimensions x="150" y="32" />
@@ -899,9 +899,7 @@
ItemTooltip:SetLink(self:GetText())
ItemTooltip:AddLine(zo_iconTextFormat("esoui/art/icons/icon_rmb.dds", 26, 26, "Remove from Queue"), "ZoFontGame", 1, 1, 1, LEFT, MODIFY_TEXT_TYPE_NONE, TEXT_ALIGN_CENTER, true)
</OnMouseEnter>
- <OnMouseExit>
- ClearTooltip(ItemTooltip)
- </OnMouseExit>
+ <OnMouseExit> ClearTooltip(ItemTooltip) </OnMouseExit>
</Label>
</Controls>
diff --git a/LeoTrainerConst.lua b/LeoTrainerConst.lua
index 1d94ef5..34ef02b 100644
--- a/LeoTrainerConst.lua
+++ b/LeoTrainerConst.lua
@@ -3,7 +3,7 @@ LeoTrainer = {}
LeoTrainerUI = {}
LeoTrainer.name = "LeoTrainer"
LeoTrainer.displayName = "Leo's Trainer"
-LeoTrainer.version = "1.1.3"
+LeoTrainer.version = "1.2.0"
LeoTrainer.chatPrefix = "|c39B027" .. LeoTrainer.name .. "|r: "
LeoTrainer.setting = nil
LeoTrainer.hidden = true
diff --git a/LeoTrainerUI.lua b/LeoTrainerUI.lua
index 2cc1ce9..6752af6 100644
--- a/LeoTrainerUI.lua
+++ b/LeoTrainerUI.lua
@@ -1,6 +1,25 @@
LeoTrainerUI.hidden = true
+local function addLine(tooltip, text, color, alignment)
+ if not color then color = ZO_TOOLTIP_DEFAULT_COLOR end
+ local r, g, b = color:UnpackRGB()
+ tooltip:AddLine(text, "LeoTrainerNormalFont", r, g, b, CENTER, MODIFY_TEXT_TYPE_NONE, alignment, alignment ~= TEXT_ALIGN_LEFT)
+end
+
+local function addLineTitle(tooltip, text, color)
+ if not color then color = ZO_SELECTED_TEXT end
+ local r, g, b = color:UnpackRGB()
+ tooltip:AddLine(text, "ZoFontHeader3", r, g, b, CENTER, MODIFY_TEXT_TYPE_NONE, TEXT_ALIGN_CENTER, true)
+end
+
+local function addLineSubTitle(tooltip, text, color, alignment)
+ if not color then color = ZO_SELECTED_TEXT end
+ if not alignment then alignment = TEXT_ALIGN_CENTER end
+ local r, g, b = color:UnpackRGB()
+ tooltip:AddLine(text, "ZoFontWinH3", r, g, b, CENTER, MODIFY_TEXT_TYPE_NONE, alignment, true)
+end
+
function LeoTrainerUI:OnWindowMoveStop()
LeoTrainer.savedVariables.position = {
left = LeoTrainerWindow:GetLeft(),
@@ -95,6 +114,37 @@ function LeoTrainerQueueList:SetupEntry(control, data)
control.trainer = GetControl(control, "Trainer")
control.trainer:SetText(data.trainer)
+ control.trainer.knownList = data.knownList
+ if #data.knownList > 1 then
+ control.trainer:SetHandler('OnMouseEnter', function(self)
+ InitializeTooltip(InformationTooltip, self, LEFT, 5, 0)
+ addLineTitle(InformationTooltip, "Trainers", ZO_TOOLTIP_DEFAULT_COLOR)
+ ZO_Tooltip_AddDivider(InformationTooltip)
+
+ for _, knowName in pairs(data.knownList) do
+ addLine(InformationTooltip, knowName, LeoTrainer.const.colors.green)
+ end
+
+ addLine(InformationTooltip, zo_iconTextFormat("esoui/art/icons/icon_lmb.dds", 26, 26, "Change Trainer"))
+ InformationTooltip:SetHidden(false)
+ end)
+ control.trainer:SetHandler('OnMouseUp', function(control, button, upInside)
+ if not upInside or (button ~= MOUSE_BUTTON_INDEX_RIGHT and button ~= MOUSE_BUTTON_INDEX_LEFT) then return end
+ local newTrainer
+ for trainerIndex, trainer in pairs(data.knownList) do
+ if trainer == data.trainer then
+ if trainerIndex < #data.knownList then
+ newTrainer = data.knownList[trainerIndex + 1]
+ else
+ newTrainer = data.knownList[1]
+ end
+ break
+ end
+ end
+ LeoTrainer.savedVariables.queue[data.queueIndex].trainer = newTrainer
+ LeoTrainer.queueScroll:RefreshData()
+ end)
+ end
control.trainee = GetControl(control, "Trainee")
control.trainee:SetText(data.trainee)
@@ -142,36 +192,15 @@ function LeoTrainerQueueList:FilterScrollList()
if canShow == true and LeoTrainer.inStation > 0 and data.craft ~= LeoTrainer.inStation then
canShow = false
end
+ if LeoTrainer.inStation > 0 and data.trainer ~= "Anyone" and data.trainer ~= LeoAltholic.CharName then
+ canShow = false
+ end
if canShow then
table.insert(scrollData, ZO_ScrollList_CreateDataEntry(1, data))
end
end
end
-local function addLine(tooltip, text, color, alignment)
- if not color then color = ZO_TOOLTIP_DEFAULT_COLOR end
- local r, g, b = color:UnpackRGB()
- tooltip:AddLine(text, "LeoTrainerNormalFont", r, g, b, CENTER, MODIFY_TEXT_TYPE_NONE, alignment, alignment ~= TEXT_ALIGN_LEFT)
-end
-
-local function addLineCenter(tooltip, text, color)
- if not color then color = ZO_TOOLTIP_DEFAULT_COLOR end
- addLine(tooltip, text, color, TEXT_ALIGN_CENTER)
-end
-
-local function addLineTitle(tooltip, text, color)
- if not color then color = ZO_SELECTED_TEXT end
- local r, g, b = color:UnpackRGB()
- tooltip:AddLine(text, "ZoFontHeader3", r, g, b, CENTER, MODIFY_TEXT_TYPE_NONE, TEXT_ALIGN_CENTER, true)
-end
-
-local function addLineSubTitle(tooltip, text, color, alignment)
- if not color then color = ZO_SELECTED_TEXT end
- if not alignment then alignment = TEXT_ALIGN_CENTER end
- local r, g, b = color:UnpackRGB()
- tooltip:AddLine(text, "ZoFontWinH3", r, g, b, CENTER, MODIFY_TEXT_TYPE_NONE, alignment, true)
-end
-
local function getResearchData(link)
if not link then return false end
@@ -247,13 +276,56 @@ local function scanItems(bag)
item = itemLink,
craft = craft,
line = line,
- trait = trait
+ trait = trait,
+ selected = false
})
end
end
return list
end
+local function getTraitResearchData(research, craft, line, trait)
+ local isKnown = research.done[craft][line][trait] or false
+ local isResearching = false
+ local doneAt
+ if isKnown == false then
+ for _, researching in pairs(research.doing[craft]) do
+ if researching.line == line and researching.trait == trait then
+ doneAt = researching.doneAt
+ isResearching = true
+ break
+ end
+ end
+ end
+ return isKnown, isResearching, doneAt
+end
+
+local function getNumOngoingResearches(research, craft)
+ local num = 0
+ for _, researching in pairs(research.doing[craft]) do
+ if researching.doneAt - GetTimeStamp() > 0 then
+ num = num + 1
+ end
+ end
+ return num
+end
+
+local function getFirstUnknownTraitCanBeTrained(craft, line, unknownTraits, trainer)
+ for _, trait in pairs(unknownTraits) do
+
+ if trainer == nil and #LeoTrainer.knowledge[craft][line][trait] > 0 then
+ return trait, LeoTrainer.knowledge[craft][line][trait]
+ elseif trainer ~= nil then
+ for _, charName in pairs(LeoTrainer.knowledge[craft][line][trait]) do
+ if charName == trainer then
+ return trait, LeoTrainer.knowledge[craft][line][trait]
+ end
+ end
+ end
+ end
+ return nil, {}
+end
+
function LeoTrainer.CreateUI()
local traitIcons = {}
for traitItemIndex = 1, GetNumSmithingTraitItems() do
@@ -453,29 +525,42 @@ function LeoTrainer.UpdateUI(charName)
addLine(InformationTooltip, GetString(SI_CURRENCYLOCATION1) ..": ".. inBank, LeoTrainer.const.colors.green)
end
if not allKnown and not isUnknown then
- text = "Queue for EACH trainee"
- addLine(InformationTooltip, zo_iconTextFormat("esoui/art/icons/icon_lmb.dds", 26, 26, text))
- --addLine(InformationTooltip, zo_iconTextFormat("esoui/art/icons/icon_rmb.dds", 26, 26, "Choose trainees"))
+ addLine(InformationTooltip, zo_iconTextFormat("esoui/art/icons/icon_lmb.dds", 26, 26, "Queue 1"))
+ addLine(InformationTooltip, zo_iconTextFormat("esoui/art/icons/icon_rmb.dds", 26, 26, "Queue All"))
end
InformationTooltip:SetHidden(false)
end)
if isKnown then
t:SetHandler('OnMouseUp', function(control, button, upInside)
- if not upInside then return end
- if button == MOUSE_BUTTON_INDEX_RIGHT then
- return
- end
- if button == MOUSE_BUTTON_INDEX_LEFT and #LeoTrainer.missingKnowledge[craft][line][trait] > 0 then
+ if not upInside or (button ~= MOUSE_BUTTON_INDEX_RIGHT and button ~= MOUSE_BUTTON_INDEX_LEFT) then return end
+ if #LeoTrainer.missingKnowledge[craft][line][trait] > 0 then
--local matReq = LeoTrainer.const.materialRequirements[craft][line]
local styleId = LeoTrainer.maxStyle(line)
if trait == 9 and LeoTrainer.savedVariables.trainNirnhoned == false then
LeoTrainer.log("Nirnhoned training is disabled in settings.")
return
end
+
+ local trainerName
+ local _, knownList = getFirstUnknownTraitCanBeTrained(craft, line, {trait}, trainer)
+ for _, knownName in pairs(knownList) do
+ if knownName == LeoTrainer.savedVariables.defaultTrainer then
+ trainerName = knownName
+ break
+ end
+ end
+ if traitName == nil then
+ trainerName = knownList[1]
+ end
+
for _, charName in pairs(LeoTrainer.missingKnowledge[craft][line][trait]) do
+ local traineeName = "Anyone"
+ if button == MOUSE_BUTTON_INDEX_RIGHT then
+ traineeName = charName
+ end
LeoTrainer.AddToQueue({
- trainer = "Anyone",
- trainee = charName,
+ trainer = trainerName,
+ trainee = traineeName,
craft = craft,
line = line,
trait = trait,
@@ -488,6 +573,9 @@ function LeoTrainer.UpdateUI(charName)
researchName = lineName .. " " .. traitName,
itemLink = LeoTrainer.const.craftItems[craft][line][trait]
})
+ if button == MOUSE_BUTTON_INDEX_LEFT then
+ break
+ end
end
LeoTrainer.queueScroll:RefreshData()
end
@@ -522,6 +610,12 @@ function LeoTrainer.ClearQueue()
end
function LeoTrainer.AddToQueue(data)
+ for _, item in pairs(LeoTrainer.savedVariables.queue) do
+ if data.trainer ~= "Anyone" and data.trainee ~= "Anyone" and item.trainer == data.trainer and item.trainee == data.trainee and item.craft == data.craft and
+ item.line == data.line and item.trait == data.trait then
+ return
+ end
+ end
table.insert(LeoTrainer.savedVariables.queue, data)
end
@@ -530,53 +624,6 @@ function LeoTrainer.RemoveFromQueue(pos)
LeoTrainer.queueScroll:RefreshData()
end
-local function getTraitResearchData(research, craft, line, trait)
- local isKnown = research.done[craft][line][trait] or false
- local isResearching = false
- local doneAt
- if isKnown == false then
- for _, researching in pairs(research.doing[craft]) do
- if researching.line == line and researching.trait == trait then
- doneAt = researching.doneAt
- isResearching = true
- break
- end
- end
- end
- return isKnown, isResearching, doneAt
-end
-
-local function getNumOngoingResearches(research, craft)
- local num = 0
- for _, researching in pairs(research.doing[craft]) do
- if researching.doneAt - GetTimeStamp() > 0 then
- num = num + 1
- end
- end
- return num
-end
-
-local function getFirstUnknownTraitCanBeTrained(craft, line, unknownTraits, trainer)
- if trainer == nil then
- for _, trait in pairs(unknownTraits) do
- if #LeoTrainer.knowledge[craft][line][trait] > 0 then
- return trait, LeoTrainer.knowledge[craft][line][trait]
- end
- end
- return nil, {}
- end
-
- for _, trait in pairs(unknownTraits) do
- for _, charName in pairs(LeoTrainer.knowledge[craft][line][trait]) do
- if charName == trainer then
- return trait, LeoTrainer.knowledge[craft][line][trait]
- end
- end
- end
- return nil, {}
-
-end
-
function LeoTrainer.FillMySlots()
LeoTrainer.FillSlots(nil, LeoAltholic.CharName)
end
@@ -590,6 +637,10 @@ function LeoTrainer.FillSlots(trainer, trainee)
local researchingLines = {}
local knownCount = {}
local unknownTraits = {}
+ local items = {}
+ if LeoTrainer.savedVariables.researchItems then
+ items = scanItems()
+ end
for _, char in pairs(charList) do
if (trainee == nil or trainee == char.bio.name) and trainer == nil or (trainer ~= nil and trainer ~= char.bio.name) then
knownCount[char.bio.name] = {}
@@ -632,28 +683,59 @@ function LeoTrainer.FillSlots(trainer, trainee)
for j, lineData in ipairs(lineList) do
if not lineData.added then
local trait, knownList = getFirstUnknownTraitCanBeTrained(craft, lineData.line, lineData.unknownTraits, trainer)
+ local hasItem = false
+ if trait ~= nil then
+ for itemIndex, itemData in ipairs(items) do
+ if itemData.selected == false and itemData.craft == craft and itemData.line == lineData.line and itemData.trait == trait then
+ if not LeoTrainer.savedVariables.onlyResearchFCO or
+ (FCOIS and FCOIS.IsIconEnabled(FCOIS_CON_ICON_RESEARCH) and
+ FCOIS.IsMarked(itemData.bagId, itemData.slot, FCOIS_CON_ICON_RESEARCH)) then
+ hasItem = true
+ items[itemIndex].selected = true
+ break
+ end
+ end
+ end
+ end
if trait ~= nil then
- local traitType = GetSmithingResearchLineTraitInfo(craft, lineData.line, trait)
- local traitName = GetString('SI_ITEMTRAITTYPE', traitType)
- if not styleId then styleId = LeoTrainer.maxStyle(lineData.line) end
- local data = {
- trainer = "Anyone",
- trainee = char.bio.name,
- craft = craft,
- line = lineData.line,
- trait = trait,
- patternIndex = -1,
- materialIndex = 1,
- materialQuantity = -1,
- itemStyleId = styleId,
- traitIndex = traitType,
- useUniversalStyleItem = false,
- researchName = lineData.lineName .. " " .. traitName,
- itemLink = LeoTrainer.const.craftItems[craft][lineData.line][trait]
- }
- if trainer ~= nil then data.trainer = trainer end
- if trainee ~= nil then data.trainee = trainee end
- LeoTrainer.AddToQueue(data)
+ if not hasItem then
+ local traitType = GetSmithingResearchLineTraitInfo(craft, lineData.line, trait)
+ local traitName = GetString('SI_ITEMTRAITTYPE', traitType)
+ if not styleId then styleId = LeoTrainer.maxStyle(lineData.line) end
+ local trainerName
+ if trainer ~= nil then
+ trainerName = trainer
+ else
+ for _, knownName in pairs(knownList) do
+ if knownName == LeoTrainer.savedVariables.defaultTrainer then
+ trainerName = knownName
+ break
+ end
+ end
+ if trainerName == nil then
+ trainerName = knownList[1]
+ end
+ end
+ local data = {
+ trainer = trainerName,
+ trainee = char.bio.name,
+ craft = craft,
+ line = lineData.line,
+ trait = trait,
+ patternIndex = -1,
+ materialIndex = 1,
+ materialQuantity = -1,
+ itemStyleId = styleId,
+ traitIndex = traitType,
+ useUniversalStyleItem = false,
+ researchName = lineData.lineName .. " " .. traitName,
+ itemLink = LeoTrainer.const.craftItems[craft][lineData.line][trait],
+ knownList = knownList
+ }
+ if trainer ~= nil then data.trainer = trainer end
+ if trainee ~= nil then data.trainee = trainee end
+ LeoTrainer.AddToQueue(data)
+ end
lineList[j].added = true
break
end
diff --git a/Settings.lua b/Settings.lua
index 591a3a0..fd22fe3 100644
--- a/Settings.lua
+++ b/Settings.lua
@@ -29,6 +29,13 @@ function LeoTrainer_Settings:CreatePanel()
}
LAM:RegisterAddonPanel(OptionsName, panelData)
+ local charNames = {
+ "Anyone"
+ }
+ for _, char in pairs(LeoAltholic.GetCharacters()) do
+ table.insert(charNames, char.bio.name)
+ end
+
local optionsData = {
{
type = "header",
@@ -38,32 +45,34 @@ function LeoTrainer_Settings:CreatePanel()
name = zo_strformat(GetString(SI_GAMEPAD_ALCHEMY_USE_REAGENT), GetString(SI_ITEMTRAITTYPE25)),
default = false,
getFunc = function() return LeoTrainer.savedVariables.trainNirnhoned end,
- setFunc = function(value)
- LeoTrainer.savedVariables.trainNirnhoned = value
- end,
+ setFunc = function(value) LeoTrainer.savedVariables.trainNirnhoned = value end,
},{
type = "checkbox",
name = "Look for items in bags and bank",
default = false,
getFunc = function() return LeoTrainer.savedVariables.researchItems end,
- setFunc = function(value)
- LeoTrainer.savedVariables.researchItems = value
- end,
+ setFunc = function(value) LeoTrainer.savedVariables.researchItems = value end,
},{
type = "checkbox",
name = "Only marked with research by FCOItemSaver",
default = false,
getFunc = function() return LeoTrainer.savedVariables.onlyResearchFCO end,
- setFunc = function(value)
- LeoTrainer.savedVariables.onlyResearchFCO = value
- end,
- },{
+ setFunc = function(value) LeoTrainer.savedVariables.onlyResearchFCO = value end,
+ }, {
type = "header",
name = "|c3f7fffCharacters|r"
},{
+ type = "dropdown",
+ name = "Prefered Trainer",
+ tooltip = "This character will be selected as the default trainer if knows the trait.",
+ choices = charNames,
+ default = "Anyone",
+ getFunc = function() return LeoTrainer.savedVariables.defaultTrainer end,
+ setFunc = function(value) LeoTrainer.savedVariables.defaultTrainer = value end
+ },{
type = "description",
text = "Select which crafting skills will be available for each char and which ones will be used when filling empty research slots"
- }, {
+ },{
type = "custom",
reference = OptionsName .. "Characters"
}