diff --git a/LeoTrainer.lua b/LeoTrainer.lua
index af7cf74..346f6ab 100644
--- a/LeoTrainer.lua
+++ b/LeoTrainer.lua
@@ -201,6 +201,14 @@ function LeoTrainer.setTrackingSkill(charName, craftId, tracking)
LeoTrainer.savedVariables.trackedTraits[charName][craftId] = tracking
end
+function LeoTrainer.canFillSlotWithSkill(charName, craftId)
+ return LeoTrainer.savedVariables.fillSlot[charName][craftId]
+end
+
+function LeoTrainer.setFillSlotWithSkill(charName, craftId, tracking)
+ LeoTrainer.savedVariables.fillSlot[charName][craftId] = tracking
+end
+
function LeoTrainer.Initialize()
LeoTrainer.savedVariables = ZO_SavedVars:NewAccountWide("LeoTrainerSavedVariables", 1, nil, nil, GetWorldName())
@@ -210,12 +218,19 @@ function LeoTrainer.Initialize()
if not LeoTrainer.savedVariables.queue then
LeoTrainer.savedVariables.queue = {}
end
+ if not LeoTrainer.savedVariables.fillSlot then
+ LeoTrainer.savedVariables.fillSlot = {}
+ end
for i, char in ipairs(LeoAltholic.GetCharacters()) do
if LeoTrainer.savedVariables.trackedTraits[char.bio.name] == nil then
LeoTrainer.savedVariables.trackedTraits[char.bio.name] = {}
end
+ if not LeoTrainer.savedVariables.fillSlot[char.bio.name] then
+ LeoTrainer.savedVariables.fillSlot[char.bio.name] = {}
+ end
for _, craftId in pairs(LeoAltholic.craftResearch) do
LeoTrainer.savedVariables.trackedTraits[char.bio.name][craftId] = LeoTrainer.savedVariables.trackedTraits[char.bio.name][craftId] or false
+ LeoTrainer.savedVariables.fillSlot[char.bio.name][craftId] = LeoTrainer.savedVariables.fillSlot[char.bio.name][craftId] or false
end
end
@@ -229,6 +244,10 @@ function LeoTrainer.Initialize()
LeoTrainerWindowTitle:SetText(LeoTrainer.displayName .. " v" .. LeoTrainer.version)
+ SLASH_COMMANDS["/leotrainer"] = function(cmd)
+ LeoTrainer:ShowUI()
+ end
+
if GetDisplayName() == "@LeandroSilva" then
SLASH_COMMANDS["/rr"] = function(cmd)
ReloadUI()
diff --git a/LeoTrainer.txt b/LeoTrainer.txt
index 36dd134..6bf37ac 100644
--- a/LeoTrainer.txt
+++ b/LeoTrainer.txt
@@ -1,6 +1,6 @@
## Title: Leo's Trainer
## APIVersion: 100024 100025
-## Version: 0.9.2
+## Version: 1.0.0
## Author: |c39B027@LeandroSilva|r
## SavedVariables: LeoTrainerSavedVariables
## DependsOn: LeoAltholic
diff --git a/LeoTrainer.xml b/LeoTrainer.xml
index 5e19315..c425a54 100644
--- a/LeoTrainer.xml
+++ b/LeoTrainer.xml
@@ -46,8 +46,28 @@
</Backdrop>
</Controls>
</Button>
+ <Button name="$(parent)SettingsButton" clickSound="Click">
+ <Anchor point="TOPRIGHT" relativePoint="TOPLEFT" relativeTo="$(parent)FeedbackButton" offsetX="-5"/>
+ <Dimensions x="40" y="40"/>
+ <OnMouseEnter>ZO_Tooltips_ShowTextTooltip(self, TOP, 'Settings')</OnMouseEnter>
+ <OnMouseExit>ZO_Tooltips_HideTextTooltip()</OnMouseExit>
+ <OnClicked>
+ SCENE_MANAGER:HideTopLevel(LeoTrainerWindow)
+ DoCommand("/leotraineroptions")
+ </OnClicked>
+ <Controls>
+ <Backdrop name="$(parent)BG" centerColor="101010" edgeColor="202020">
+ <AnchorFill/>
+ <Edge edgeSize="1"/>
+ </Backdrop>
+ <Texture name="$(parent)Texture" textureFile="esoui/art/chatwindow/chat_options_up.dds">
+ <Dimensions y="35" x="35"/>
+ <Anchor point="128"/>
+ </Texture>
+ </Controls>
+ </Button>
<Button name="$(parent)WoodworkingButton" clickSound="Click">
- <Anchor point="TOPRIGHT" relativePoint="TOPLEFT" relativeTo="$(parent)FeedbackButton" offsetX="-5" />
+ <Anchor point="TOPRIGHT" relativePoint="TOPLEFT" relativeTo="$(parent)SettingsButton" offsetX="-5" />
<Dimensions x="56" y="40"/>
<OnMouseEnter>ZO_Tooltips_ShowTextTooltip(self, TOP, 'Woodworking and Jewel Crafting')</OnMouseEnter>
<OnMouseExit>ZO_Tooltips_HideTextTooltip()</OnMouseExit>
@@ -835,7 +855,7 @@
<Dimensions x="150" y="30" />
<Anchor point="TOPLEFT" relativeTo="$(parent)CraftAll" relativePoint="TOPRIGHT" offsetX="0" offsetY="0"/>
<OnClicked>
- <!--LeoTrainer.FillSlots()-->
+ LeoTrainer.FillSlots()
</OnClicked>
</Button>
<Button name="$(parent)Clear" inherits="ZO_DefaultButton" font="ZoFontWinH4" text="Clear Queue">
diff --git a/LeoTrainerConst.lua b/LeoTrainerConst.lua
index 27ce663..57d8eab 100644
--- a/LeoTrainerConst.lua
+++ b/LeoTrainerConst.lua
@@ -2,7 +2,7 @@
LeoTrainer = {}
LeoTrainer.name = "LeoTrainer"
LeoTrainer.displayName = "Leo's Trainer"
-LeoTrainer.version = "0.9.2"
+LeoTrainer.version = "1.0.0"
LeoTrainer.chatPrefix = "|c39B027" .. LeoTrainer.name .. "|r: "
LeoTrainer.setting = nil
LeoTrainer.hidden = true
diff --git a/LeoTrainerUI.lua b/LeoTrainerUI.lua
index 5f8e21f..8814312 100644
--- a/LeoTrainerUI.lua
+++ b/LeoTrainerUI.lua
@@ -293,3 +293,87 @@ function LeoTrainer.RemoveFromQueue(pos)
table.remove(LeoTrainer.savedVariables.queue, pos)
LeoTrainer.queueScroll:RefreshData()
end
+
+function LeoTrainer.FillSlots()
+ local knownCount = {}
+ for _, char in pairs(LeoAltholic.GetCharacters()) do
+ knownCount[char.bio.name] = {}
+ for _,craft in pairs(LeoAltholic.craftResearch) do
+ if LeoTrainer.isTrackingSkill(char.bio.name, craft) and LeoTrainer.canFillSlotWithSkill(char.bio.name, craft) then
+ local researching = 0
+ knownCount[char.bio.name][craft] = {}
+ local lower = {}
+ for line = 1, GetNumSmithingResearchLines(craft) do
+ local lineName, lineIcon = GetSmithingResearchLineInfo(craft, line)
+ knownCount[char.bio.name][craft][line] = 0
+ local firstUnknownTrait = {
+ id = 0,
+ name = ''
+ }
+ for trait = 1, LeoAltholic.maxTraits do
+ local traitType = GetSmithingResearchLineTraitInfo(craft, line, trait)
+ local traitData = char.research[craft][line][trait] or false
+ local traitName = GetString('SI_ITEMTRAITTYPE', traitType)
+
+ local myself, known, unknown, all = LeoTrainer.GetCharKnowsTrait(craft, line, trait)
+ if type(traitData) == 'number' then
+ researching = researching + 1
+ elseif traitData == true then
+ knownCount[char.bio.name][craft][line] = knownCount[char.bio.name][craft][line] + 1
+ elseif traitData == false and firstUnknownTrait.id == 0 then
+ firstUnknownTrait.id = trait
+ firstUnknownTrait.name = traitName
+ end
+ end
+ if #lower < char.research[craft].max then
+ table.insert(lower, {
+ line = line,
+ lineName = lineName,
+ count = knownCount[char.bio.name][craft][line],
+ trait = firstUnknownTrait.id,
+ traitName = firstUnknownTrait.name
+ })
+ else
+ local changed = false
+ for i = 1, #lower do
+ if changed == false and lower[i].count > knownCount[char.bio.name][craft][line] then
+ lower[i].line = line
+ lower[i].lineName = lineName
+ lower[i].count = knownCount[char.bio.name][craft][line]
+ lower[i].trait = firstUnknownTrait.id
+ lower[i].traitName = firstUnknownTrait.name
+ changed = true
+ end
+ end
+ end
+ end
+ if researching < char.research[craft].max then
+ table.sort(lower, function(a, b)
+ return a.count < b.count
+ end)
+ local styleId = LeoTrainer.maxStyle(lower.line)
+ local max = char.research[craft].max-researching
+ for i = 1, max do
+ local traitType = GetSmithingResearchLineTraitInfo(craft, lower[i].line, lower[i].trait)
+ LeoTrainer.AddToQueue({
+ trainer = "Anyone",
+ trainee = char.bio.name,
+ craft = craft,
+ line = lower[i].line,
+ trait = lower[i].trait,
+ patternIndex = -1,
+ materialIndex = 1,
+ materialQuantity = -1,
+ itemStyleId = styleId,
+ traitIndex = traitType,
+ useUniversalStyleItem = false,
+ researchName = lower[i].lineName .. " " .. lower[i].traitName,
+ itemLink = LeoTrainer.const.craftItems[craft][lower[i].line][lower[i].trait]
+ })
+ end
+ LeoTrainer.queueScroll:RefreshData()
+ end
+ end
+ end
+ end
+end
diff --git a/Settings.lua b/Settings.lua
index 5a30eee..3b64b68 100644
--- a/Settings.lua
+++ b/Settings.lua
@@ -14,100 +14,113 @@ function LeoTrainer_Settings:Initialize()
end
function LeoTrainer_Settings:CreatePanel()
- local OptionsName = "LeoTrainerOptions"
- local panelData = {
- type = "panel",
- name = LeoTrainer.name,
- displayName = "|cff8800"..LeoTrainer.displayName.."|r",
- author = "@LeandroSilva",
- version = LeoTrainer.version,
- registerForRefresh = false,
- registerForDefaults = false,
- --slashCommand = "/leotrainer",
- website = "http://www.esoui.com/downloads/"
- }
- LAM:RegisterAddonPanel(OptionsName, panelData)
+ local OptionsName = "LeoTrainerOptions"
+ local panelData = {
+ type = "panel",
+ name = LeoTrainer.name,
+ displayName = "|c39B027"..LeoTrainer.displayName.."|r",
+ author = "@LeandroSilva",
+ version = LeoTrainer.version,
+ registerForRefresh = false,
+ registerForDefaults = false,
+ slashCommand = "/leotraineroptions",
+ website = "http://www.esoui.com/downloads/info2162-LeosTrainer.html",
+ --resetFunc = function() end
+ }
+ LAM:RegisterAddonPanel(OptionsName, panelData)
- local optionsData = {
- {
- type = "header",
- name = "|c3f7fffCharacters|r"
- },{
- type = "description",
- text = "desc"
- },{
- type = "custom",
- reference = OptionsName.."Characters"
- }
- }
- LAM:RegisterOptionControls(OptionsName, optionsData)
+ local optionsData = {
+ {
+ type = "header",
+ name = "|c3f7fffCharacters|r"
+ },{
+ 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"
+ }
+ }
+ LAM:RegisterOptionControls(OptionsName, optionsData)
end
function LeoTrainer_Settings:AddCharacters()
- if LeoTrainerOptionsCharactersSection then return end
- local control = CreateControlFromVirtual("$(parent)", LeoTrainerOptionsCharacters, "LeoTrainer_SettingsCharacters", "Section")
- self.container = control:GetNamedChild("Container")
- local last
- for i, char in ipairs(LeoAltholic.GetCharacters()) do
- last = self:AddCharacter(i, char, last)
- end
+ if LeoTrainerOptionsCharactersSection then return end
+ local control = CreateControlFromVirtual("$(parent)", LeoTrainerOptionsCharacters, "LeoTrainer_SettingsCharacters", "Section")
+ self.container = control:GetNamedChild("Container")
+ local last
+ for i, char in ipairs(LeoAltholic.GetCharacters()) do
+ last = self:AddCharacter(i, char, last)
+ end
end
function LeoTrainer_Settings_OnMouseEnter(control, tooltip)
- InitializeTooltip(InformationTooltip, control, BOTTOMLEFT, 0, -2, TOPLEFT)
- SetTooltipText(InformationTooltip, tooltip)
+ InitializeTooltip(InformationTooltip, control, BOTTOMLEFT, 0, -2, TOPLEFT)
+ SetTooltipText(InformationTooltip, tooltip)
end
local function Toggle(checkbox, checked)
- local control = checkbox:GetParent()
+ local control = checkbox:GetParent()
LeoTrainer.setTrackingSkill(control.data.charName, checkbox.data.craftId, checked)
end
+local function ToggleFill(checkbox, checked)
+ local control = checkbox:GetParent()
+ LeoTrainer.setFillSlotWithSkill(control.data.charName, checkbox.data.craftId, checked)
+end
+
function LeoTrainer_Settings:AddCharacter(id, char, last)
- local control = CreateControlFromVirtual("$(parent)", self.container, "LeoTrainer_SettingsCharacter", id)
- if last then
- control:SetAnchor(TOPLEFT, last, BOTTOMLEFT, 0, 0)
- control:SetAnchor(BOTTOMRIGHT, last, BOTTOMRIGHT, 0, 30)
- else
- control:SetAnchor(TOPLEFT, nil, TOPLEFT, 0, 0)
- control:SetAnchor(BOTTOMRIGHT, nil, TOPRIGHT, 0, 30)
- end
- control.data = control.data or {}
- control.data.charName = char.bio.name
- control.label = control:GetNamedChild("Name")
- control.label:SetText(char.bio.name)
+ local control = CreateControlFromVirtual("$(parent)", self.container, "LeoTrainer_SettingsCharacter", id)
+ if last then
+ control:SetAnchor(TOPLEFT, last, BOTTOMLEFT, 0, 0)
+ control:SetAnchor(BOTTOMRIGHT, last, BOTTOMRIGHT, 0, 30)
+ else
+ control:SetAnchor(TOPLEFT, LeoTrainer_SettingsCharactersIconsST_Label, TOPLEFT, 0, 30)
+ control:SetAnchor(BOTTOMRIGHT, LeoTrainer_SettingsCharactersIconsST_Label, TOPRIGHT, 0, 60)
+ end
+ control.data = control.data or {}
+ control.data.charName = char.bio.name
+ control.label = control:GetNamedChild("Name")
+ control.label:SetText(char.bio.name)
control.label:SetColor(ZO_SELECTED_TEXT:UnpackRGBA())
- for k,craftId in pairs(LeoAltholic.craftResearch) do
- local checkbox = control:GetNamedChild("ST_" .. craftId)
- checkbox.data = checkbox.data or {}
+ for k,craftId in pairs(LeoAltholic.craftResearch) do
+ local checkbox = control:GetNamedChild("ST_" .. craftId)
+ checkbox.data = checkbox.data or {}
+ checkbox.data.craftId = craftId
+ checkbox.data.tooltipText = nil
+ ZO_CheckButton_SetCheckState(checkbox, LeoTrainer.isTrackingSkill(char.bio.name, craftId))
+ ZO_CheckButton_SetToggleFunction(checkbox, Toggle)
+
+ checkbox = control:GetNamedChild("FS_" .. craftId)
+ checkbox.data = checkbox.data or {}
checkbox.data.craftId = craftId
- checkbox.data.tooltipText = nil
- ZO_CheckButton_SetCheckState(checkbox, LeoTrainer.isTrackingSkill(char.bio.name, craftId))
- ZO_CheckButton_SetToggleFunction(checkbox, Toggle)
- end
- return control
+ checkbox.data.tooltipText = nil
+ ZO_CheckButton_SetCheckState(checkbox, LeoTrainer.canFillSlotWithSkill(char.bio.name, craftId))
+ ZO_CheckButton_SetToggleFunction(checkbox, ToggleFill)
+ end
+ return control
end
function LeoTrainer_Settings:ClearCharacter(id)
- if self.container then
- local control = self.container:GetNamedChild(id)
- if control then
- control:SetHidden(true)
- end
- end
+ if self.container then
+ local control = self.container:GetNamedChild(id)
+ if control then
+ control:SetHidden(true)
+ end
+ end
end
function LeoTrainer_Settings:OnSettingsControlsCreated(panel)
- --Each time an options panel is created, once for each addon viewed
- if panel:GetName() == "LeoTrainerOptions" then
- self:AddCharacters()
- end
+ --Each time an options panel is created, once for each addon viewed
+ if panel:GetName() == "LeoTrainerOptions" then
+ self:AddCharacters()
+ end
end
function LeoTrainer_Settings:IsCreated()
- if self.container then
- return true
- else
- return false
- end
+ if self.container then
+ return true
+ else
+ return false
+ end
end
diff --git a/Settings.xml b/Settings.xml
index 9e8fe35..a9cd806 100644
--- a/Settings.xml
+++ b/Settings.xml
@@ -8,8 +8,12 @@
<Anchor point="TOPLEFT" relativeTo="$(parent)" relativePoint="TOPLEFT" offsetX="280"/>
<Anchor point="BOTTOMRIGHT" relativeTo="$(parent)" relativePoint="TOPRIGHT" offsetY="36"/>
<Controls>
+ <Label name="$(parent)ST_Label" text="Can be trained" font="ZoFontWinH4" wrapMode="ELLIPSIS">
+ <Anchor point="LEFT" relativeTo="$(parent)" relativePoint="LEFT" offsetX="10"/>
+ <Dimensions x="290" y="26"/>
+ </Label>
<Texture name="$(parent)ST_1" textureFile="esoui/art/inventory/inventory_tabicon_craftbag_blacksmithing_up.dds" mouseEnabled="true">
- <Anchor point="LEFT" relativeTo="$(parent)" relativePoint="LEFT"/>
+ <Anchor point="LEFT" relativeTo="$(parent)" relativePoint="LEFT" offsetY="30"/>
<Dimensions x="36" y="36"/>
<OnMouseEnter>LeoTrainer_Settings_OnMouseEnter(self, zo_strformat(SI_ABILITY_NAME, ZO_GetCraftingSkillName(CRAFTING_TYPE_BLACKSMITHING)))</OnMouseEnter>
<OnMouseExit>ZO_Options_OnMouseExit(self)</OnMouseExit>
@@ -32,6 +36,35 @@
<OnMouseEnter>LeoTrainer_Settings_OnMouseEnter(self, zo_strformat(SI_ABILITY_NAME, ZO_GetCraftingSkillName(CRAFTING_TYPE_JEWELRYCRAFTING)))</OnMouseEnter>
<OnMouseExit>ZO_Options_OnMouseExit(self)</OnMouseExit>
</Texture>
+
+ <Label name="$(parent)FS_Label" text="Fill empty slots" font="ZoFontWinH4" wrapMode="ELLIPSIS">
+ <Anchor point="LEFT" relativeTo="$(parent)" relativePoint="LEFT" offsetX="200"/>
+ <Dimensions x="290" y="26"/>
+ </Label>
+ <Texture name="$(parent)FS_1" textureFile="esoui/art/inventory/inventory_tabicon_craftbag_blacksmithing_up.dds" mouseEnabled="true">
+ <Anchor point="LEFT" relativeTo="$(parent)" relativePoint="LEFT" offsetX="190" offsetY="30"/>
+ <Dimensions x="36" y="36"/>
+ <OnMouseEnter>LeoTrainer_Settings_OnMouseEnter(self, zo_strformat(SI_ABILITY_NAME, ZO_GetCraftingSkillName(CRAFTING_TYPE_BLACKSMITHING)))</OnMouseEnter>
+ <OnMouseExit>ZO_Options_OnMouseExit(self)</OnMouseExit>
+ </Texture>
+ <Texture name="$(parent)FS_2" textureFile="esoui/art/inventory/inventory_tabicon_craftbag_clothing_up.dds" mouseEnabled="true">
+ <Anchor point="LEFT" relativeTo="$(parent)FS_1" relativePoint="RIGHT" offsetX="-4"/>
+ <Dimensions x="36" y="36"/>
+ <OnMouseEnter>LeoTrainer_Settings_OnMouseEnter(self, zo_strformat(SI_ABILITY_NAME, ZO_GetCraftingSkillName(CRAFTING_TYPE_CLOTHIER)))</OnMouseEnter>
+ <OnMouseExit>ZO_Options_OnMouseExit(self)</OnMouseExit>
+ </Texture>
+ <Texture name="$(parent)FS_6" textureFile="esoui/art/inventory/inventory_tabicon_craftbag_woodworking_up.dds" mouseEnabled="true">
+ <Anchor point="LEFT" relativeTo="$(parent)FS_2" relativePoint="RIGHT" offsetX="-4"/>
+ <Dimensions x="36" y="36"/>
+ <OnMouseEnter>LeoTrainer_Settings_OnMouseEnter(self, zo_strformat(SI_ABILITY_NAME, ZO_GetCraftingSkillName(CRAFTING_TYPE_WOODWORKING)))</OnMouseEnter>
+ <OnMouseExit>ZO_Options_OnMouseExit(self)</OnMouseExit>
+ </Texture>
+ <Texture name="$(parent)FS_7" textureFile="esoui/art/inventory/inventory_tabicon_craftbag_jewelrycrafting_up.dds" mouseEnabled="true">
+ <Anchor point="LEFT" relativeTo="$(parent)FS_6" relativePoint="RIGHT" offsetX="-4"/>
+ <Dimensions x="36" y="36"/>
+ <OnMouseEnter>LeoTrainer_Settings_OnMouseEnter(self, zo_strformat(SI_ABILITY_NAME, ZO_GetCraftingSkillName(CRAFTING_TYPE_JEWELRYCRAFTING)))</OnMouseEnter>
+ <OnMouseExit>ZO_Options_OnMouseExit(self)</OnMouseExit>
+ </Texture>
</Controls>
</Control>
<Control name="$(parent)Container" resizeToFitDescendents="true">
@@ -71,6 +104,31 @@
<OnMouseEnter>ZO_Options_OnMouseEnter(self)</OnMouseEnter>
<OnMouseExit>ZO_Options_OnMouseExit(self)</OnMouseExit>
</Button>
+
+ <Button name="$(parent)FS_1" inherits="ZO_CheckButton">
+ <Anchor point="LEFT" relativeTo="$(parent)ST_7" relativePoint="RIGHT" offsetX="70"/>
+ <Dimensions x="22" y="22"/>
+ <OnMouseEnter>ZO_Options_OnMouseEnter(self)</OnMouseEnter>
+ <OnMouseExit>ZO_Options_OnMouseExit(self)</OnMouseExit>
+ </Button>
+ <Button name="$(parent)FS_2" inherits="ZO_CheckButton">
+ <Anchor point="LEFT" relativeTo="$(parent)FS_1" relativePoint="RIGHT" offsetX="10"/>
+ <Dimensions x="22" y="22"/>
+ <OnMouseEnter>ZO_Options_OnMouseEnter(self)</OnMouseEnter>
+ <OnMouseExit>ZO_Options_OnMouseExit(self)</OnMouseExit>
+ </Button>
+ <Button name="$(parent)FS_6" inherits="ZO_CheckButton">
+ <Anchor point="LEFT" relativeTo="$(parent)FS_2" relativePoint="RIGHT" offsetX="10"/>
+ <Dimensions x="22" y="22"/>
+ <OnMouseEnter>ZO_Options_OnMouseEnter(self)</OnMouseEnter>
+ <OnMouseExit>ZO_Options_OnMouseExit(self)</OnMouseExit>
+ </Button>
+ <Button name="$(parent)FS_7" inherits="ZO_CheckButton">
+ <Anchor point="LEFT" relativeTo="$(parent)FS_6" relativePoint="RIGHT" offsetX="10"/>
+ <Dimensions x="22" y="22"/>
+ <OnMouseEnter>ZO_Options_OnMouseEnter(self)</OnMouseEnter>
+ <OnMouseExit>ZO_Options_OnMouseExit(self)</OnMouseExit>
+ </Button>
</Controls>
</Control>
</Controls>