-- AI Research Grid Addon for Elder Scrolls Online -- Author: Stormknight/LCAmethyst -- "All" and "Relative" functionality by His Dad -- Dwemer Motif by rkuhnjr -- Dwemer Motif By garkin -- French Translation by Motsah -- Fixes by mpavlinsky -- Close on Esc code by Wandamey -- Glass, Xivkyn, Ancient Orc, and Mercenary Akaviri added in by Scinutz local _ AIRG = {} AIRG.name = "AIResearchGrid" AIRG.version = "3.4.0" AIRG.initialised = false AIRG.processing = false AIRG.all = " #ALL" -- Default displayname for Virtual character, overrwritten by Localised version AIRG.ShowRelative = false -- State of Button AIRG.relative= {} AIRG.L = {} -- declare language strings -- Set-up the defaults options for saved variables. AIRG.defaults = { showMotifs = true, } function AIRG.PlayerActivated() -- somehow somewhere it sometimes happens that the data is not correct completely for whatever reason -- so we force a reload of the current character data when we are actually loaded into the world. AIRG.PopulateMatrix() AIRG.PopulateStyleData() AIRG.DisplayStyles() AIRG.PopulateAll() -- do last end function AIRG.ToggleMainWindow() if (AIResearchGrid:IsHidden()) then AIRG.OnCraftSelected() -- Redisplay data for the current profession end SCENE_MANAGER:ToggleTopLevel(AIResearchGrid) -- Thanks Wandamey end -- AIRG.ToggleMainWindow -- Invoked by EVENT_SMITHING_TRAIT_RESEARCH_STARTED -- (integer eventCode, integer craftingSkillType, luaindex researchLineIndex, luaindex traitIndex) function AIRG.ResearchStarted(eventCode, craftingSkillType, researchLineIndex, traitIndex) AIRG.PopulateMatrix() AIRG.PopulateAll() AIRG.OnCraftSelected() -- Redisplay data for the current profession end -- AIRG.ResearchStarted -- Invoked by EVENT_SMITHING_TRAIT_RESEARCH_COMPLETED -- (integer eventCode, integer craftingSkillType, luaindex researchLineIndex, luaindex traitIndex) function AIRG.ResearchCompleted() AIRG.PopulateMatrix() AIRG.PopulateAll() AIRG.OnCraftSelected() -- Redisplay data for the current profession end -- AIRG.ResearchEnded function AIRG.StyleLearned(eventCode, StyleIndex) AIRG.PopulateStyleData() AIRG.DisplayStyles() AIRG.PopulateAll() end -- AIRG.StyleLearned -- Invoked from AIRG.Initialise but lengthy so in it's own function to not clutter Initialise function AIRG.initUI() -- Some local variable declaration local tType, tDesc, rowNum -- Initialise a table to hold all the lua generated components AIRG.UI = {} -- Set the main window title AIRG.UI.WindowTitle = WINDOW_MANAGER:CreateControl("AIResearchGridWindowTitle", AIResearchGrid, CT_LABEL) AIRG.UI.WindowTitle:SetAnchor(TOPLEFT, AIResearchGrid, TOPLEFT, 0, 0) AIRG.UI.WindowTitle:SetFont("ZoFontAnnounceMedium") AIRG.UI.WindowTitle:SetHorizontalAlignment(TEXT_ALIGN_LEFT) AIRG.UI.WindowTitle:SetText("|c8080ffAI|r RESEARCH GRID") -- Set the main window subtitle AIRG.UI.WindowSubTitle = WINDOW_MANAGER:CreateControl("AIResearchGridWindowSubTitle", AIResearchGrid, CT_LABEL) AIRG.UI.WindowSubTitle:SetAnchor(LEFT, AIRG.UI.WindowTitle, RIGHT, 10, 0) AIRG.UI.WindowSubTitle:SetFont("ZoFontAnnounceMedium") AIRG.UI.WindowSubTitle:SetHorizontalAlignment(TEXT_ALIGN_LEFT) AIRG.UI.WindowSubTitle:SetColor(0, 1, 0, 1); -- green AIRG.UI.WindowSubTitle:SetText("") -- Nice little line under the main title AIRG.UI.TopDivider = WINDOW_MANAGER:CreateControl("AIResearchGridTopDivider", AIResearchGrid, CT_TEXTURE) AIRG.UI.TopDivider:SetDimensions(750, 5) AIRG.UI.TopDivider:SetAnchor(TOPLEFT, AIResearchGrid, TOPLEFT, 25, 32) AIRG.UI.TopDivider:SetTexture("/esoui/art/quest/questjournal_divider.dds") -- Nice little line under the grid AIRG.UI.BottomDivider = WINDOW_MANAGER:CreateControl("AIResearchGridBottomDivider", AIResearchGrid, CT_TEXTURE) AIRG.UI.BottomDivider:SetDimensions(750, 5) AIRG.UI.BottomDivider:SetAnchor(TOPLEFT, AIResearchGrid, TOPLEFT, 25, 636) AIRG.UI.BottomDivider:SetTexture("/esoui/art/quest/questjournal_divider.dds") AIRG.UI.BottomDivider:SetHidden(not AIRG.vars.showMotifs) -- CREATE BUTTON FOR CLOSE ADDON AT TOP_RIGHT AIRG.UI.btnCloseAddonFrame = WINDOW_MANAGER:CreateControl("AIResearchGridButtonCloseAddon", AIResearchGrid, CT_BUTTON) AIRG.UI.btnCloseAddonFrame:SetDimensions(28, 28) AIRG.UI.btnCloseAddonFrame:SetAnchor(TOPRIGHT, AIResearchGrid, TOPRIGHT, 5 , 0) AIRG.UI.btnCloseAddonFrame:SetState(BSTATE_NORMAL) AIRG.UI.btnCloseAddonFrame:SetMouseOverBlendMode(0) -- AIRG.UI.btnCloseAddonFrame:SetHidden(false) AIRG.UI.btnCloseAddonFrame:SetEnabled(true) -- AIRG.UI.btnCloseAddonFrame:SetClickSound(SOUNDS.WOODWORKER_EXTRACTED_BOOSTER) AIRG.UI.btnCloseAddonFrame:SetNormalTexture("/esoui/art/buttons/clearslot_down.dds") AIRG.UI.btnCloseAddonFrame:SetMouseOverTexture("/esoui/art/buttons/clearslot_up.dds") AIRG.UI.btnCloseAddonFrame:SetHandler("OnClicked", function(self) AIRG.ToggleMainWindow() end) -- CREATE the DROPDOWN BOX for CHARACTER SELECT -- Uses code based on example from Seerah AIRG.UI.charDropdown = WINDOW_MANAGER:CreateControlFromVirtual("AIResearchGridDropdownCharacter", AIResearchGrid, "ZO_StatsDropdownRow") AIRG.UI.charDropdown:SetWidth(205) -- Defaults to 607!!! AIRG.UI.charDropdown:SetAnchor(TOPRIGHT, AIResearchGrid, TOPRIGHT, -32, 0) AIRG.UI.charDropdown:GetNamedChild("Dropdown"):SetWidth(200) AIRG.UI.charDropdown.dropdown:SetSelectedItem(AIRG.curCharacter) -- Set the current character as selected local function OnItemSelect(_, choiceText, choice) --this is the callback function for when an item gets selected in the dropdown AIRG.OnCharacterSelect(choiceText) end for charName, _ in pairs(AIRG.vars.char) do local entry = AIRG.UI.charDropdown.dropdown:CreateItemEntry(charName, OnItemSelect) AIRG.UI.charDropdown.dropdown:AddItem(entry) end -- CREATE BUTTON FOR "Relative to" AT TOP_RIGHT AIRG.UI.btnUpdateOther = WINDOW_MANAGER:CreateControlFromVirtual("AIResearchGridButtonUpdateOther", AIResearchGrid, "ZO_DefaultButton") --Attempt to adjust button size to content, but units are different. May not be fixable. leave for meantime. local textlen = 0 if string.len(AIRG.L["btnRelativeOn"]) > string.len(AIRG.L["btnRelativeOff"]) then textlen = string.len(AIRG.L["btnRelativeOn"]) else textlen = string.len(AIRG.L["btnRelativeOff"]) end AIRG.UI.btnUpdateOther:SetDimensions(140+textlen, 30) AIRG.UI.btnUpdateOther:SetAnchor(RIGHT, AIRG.UI.charDropdown, LEFT, 0, 0) AIRG.UI.btnUpdateOther:SetState(BSTATE_NORMAL) AIRG.UI.btnUpdateOther:SetMouseOverBlendMode(0) -- AIRG.UI.btnUpdateOther:SetNormalTexture("/esoui/art/icons/ability_tradecraft_008.dds") AIRG.UI.btnUpdateOther:SetMouseOverTexture("esoui/art/buttons/generic_highlight.dds") AIRG.UI.btnUpdateOther:SetClickSound("Click") AIRG.UI.btnUpdateOther:SetDisabledFontColor(ZO_DEFAULT_DISABLED_COLOR:UnpackRGBA()) AIRG.UI.btnUpdateOther:SetFont("ZoFontGame") AIRG.UI.btnUpdateOther:SetText(AIRG.L["btnRelativeOff"]) AIRG.UI.btnUpdateOther:SetEnabled(false) -- starts pointing to current character, which can't use this AIRG.UI.btnUpdateOther:SetHidden(false) -- enabled at end of function AIRG.UI.btnUpdateOther:SetHandler("OnClicked", function(self) AIRG.ShowRelative = not AIRG.ShowRelative if AIRG.ShowRelative then self:SetText(AIRG.L["btnRelativeOn"]) -- Lime green -- else self:SetText(AIRG.btnUpdateOtherText1 ) else self:SetText(AIRG.L["btnRelativeOff"]) end AIRG.OnCraftSelected() --redisplay end) AIRG.UI.btnUpdateOther:SetMouseEnabled(true) -- CREATE BUTTON FOR PROFESSION: BLACKSMITHING AIRG.UI.btnBlacksmithing = WINDOW_MANAGER:CreateControl("AIResearchGridButtonBlacksmithing", AIResearchGrid, CT_BUTTON) AIRG.UI.btnBlacksmithing:SetDimensions(48, 48) AIRG.UI.btnBlacksmithing:SetAnchor(TOPLEFT, AIResearchGrid, TOPLEFT, 8 , 44) AIRG.UI.btnBlacksmithing:SetState(BSTATE_NORMAL) AIRG.UI.btnBlacksmithing:SetMouseOverBlendMode(0) AIRG.UI.btnBlacksmithing:SetHidden(false) AIRG.UI.btnBlacksmithing:SetEnabled(true) AIRG.UI.btnBlacksmithing:SetClickSound(SOUNDS.WOODWORKER_EXTRACTED_BOOSTER) AIRG.UI.btnBlacksmithing:SetNormalTexture("/esoui/art/icons/ability_smith_007.dds") AIRG.UI.btnBlacksmithing:SetMouseOverTexture("esoui/art/buttons/generic_highlight.dds") AIRG.UI.btnBlacksmithing:SetHandler("OnClicked", function(self) AIRG:OnCraftSelected(CRAFTING_TYPE_BLACKSMITHING) end) -- CREATE BUTTON FOR PROFESSION: WOODWORKING AIRG.UI.btnWoodworking = WINDOW_MANAGER:CreateControl("AIResearchGridButtonWoodworking", AIResearchGrid, CT_BUTTON) AIRG.UI.btnWoodworking:SetDimensions(48, 48) AIRG.UI.btnWoodworking:SetAnchor(TOPLEFT, AIRG.UI.btnBlacksmithing, TOPRIGHT, 12 , 0) AIRG.UI.btnWoodworking:SetState(BSTATE_NORMAL) AIRG.UI.btnWoodworking:SetMouseOverBlendMode(0) AIRG.UI.btnWoodworking:SetHidden(false) AIRG.UI.btnWoodworking:SetEnabled(true) AIRG.UI.btnWoodworking:SetClickSound(SOUNDS.BLACKSMITH_EXTRACTED_BOOSTER) AIRG.UI.btnWoodworking:SetNormalTexture("/esoui/art/icons/ability_tradecraft_009.dds") AIRG.UI.btnWoodworking:SetMouseOverTexture("esoui/art/buttons/generic_highlight.dds") AIRG.UI.btnWoodworking:SetHandler("OnClicked", function(self) AIRG:OnCraftSelected(CRAFTING_TYPE_WOODWORKING) end) -- CREATE BUTTON FOR PROFESSION: CLOTHING AIRG.UI.btnClothing = WINDOW_MANAGER:CreateControl("AIResearchGridButtonClothing", AIResearchGrid, CT_BUTTON) AIRG.UI.btnClothing:SetDimensions(48, 48) AIRG.UI.btnClothing:SetAnchor(TOPLEFT, AIRG.UI.btnWoodworking, TOPRIGHT, 12 , 0) AIRG.UI.btnClothing:SetState(BSTATE_NORMAL) AIRG.UI.btnClothing:SetMouseOverBlendMode(0) AIRG.UI.btnClothing:SetHidden(false) AIRG.UI.btnClothing:SetEnabled(true) AIRG.UI.btnClothing:SetClickSound(SOUNDS.CLOTHIER_EXTRACTED_BOOSTER) AIRG.UI.btnClothing:SetNormalTexture("/esoui/art/icons/ability_tradecraft_008.dds") AIRG.UI.btnClothing:SetMouseOverTexture("esoui/art/buttons/generic_highlight.dds") AIRG.UI.btnClothing:SetHandler("OnClicked", function(self) AIRG:OnCraftSelected(CRAFTING_TYPE_CLOTHIER) end) -- BUILD THE TRAIT LABELS ON THE LEFT-SIDE using built-in language strings AIRG.UI.rowLabels = {} for thisTrait, j in pairs(AIRG.gridTraits) do AIRG.UI.rowLabels[j] = WINDOW_MANAGER:CreateControl("AIResearchGridRowLabel" .. tostring(j), AIResearchGrid, CT_LABEL) AIRG.UI.rowLabels[j]:SetAnchor(TOPLEFT, AIResearchGrid, TOPLEFT, 5, 28*j + 70) AIRG.UI.rowLabels[j]:SetText(GetString("SI_ITEMTRAITTYPE",thisTrait)) -- This is the text displayed on the screen as it's a label AIRG.UI.rowLabels[j]:SetDimensions(180, 24) AIRG.UI.rowLabels[j]:SetFont("ZoFontGame") AIRG.UI.rowLabels[j]:SetHorizontalAlignment(TEXT_ALIGN_RIGHT) AIRG.UI.rowLabels[j]:SetVerticalAlignment(TEXT_ALIGN_CENTER) AIRG.UI.rowLabels[j]:SetMouseEnabled(true) AIRG.UI.rowLabels[j]:SetHandler("OnMouseEnter", function (self) ZO_Tooltips_ShowTextTooltip(self, TOP, self.tooltipText) end) AIRG.UI.rowLabels[j]:SetHandler("OnMouseExit", function (self) ZO_Tooltips_HideTextTooltip() end) end -- Now add tooltip text to the row labels. -- The tooltip functionality is automatic as part of the label control. for j = 1, 9 do tType, tDesc, _ = GetSmithingResearchLineTraitInfo(CRAFTING_TYPE_BLACKSMITHING,1,j) -- weapons rowNum = AIRG.gridTraits[tType] AIRG.UI.rowLabels[rowNum].tooltipText = tDesc tType, tDesc, _ = GetSmithingResearchLineTraitInfo(CRAFTING_TYPE_BLACKSMITHING,9,j) -- armour rowNum = AIRG.gridTraits[tType] AIRG.UI.rowLabels[rowNum].tooltipText = tDesc end -- BUILD THE COLUMNS & GRID -- Determine the maximum number of item types across all three professions. This is currently always 14 AIRG.maxColumns= math.max(GetNumSmithingResearchLines(CRAFTING_TYPE_BLACKSMITHING), GetNumSmithingResearchLines(CRAFTING_TYPE_CLOTHIER), GetNumSmithingResearchLines(CRAFTING_TYPE_WOODWORKING)) AIRG.UI.columnButtons = {} AIRG.UI.gridButtons = {} AIRG.UI.columnFooters = {} for i = 1, AIRG.maxColumns do -- BUILD THE COLUMN BUTTONS AIRG.UI.columnButtons[i] = WINDOW_MANAGER:CreateControl("AIResearchGridHeaderButton" .. tostring(i), AIResearchGrid, CT_BUTTON) AIRG.UI.columnButtons[i]:SetDimensions(36, 36) AIRG.UI.columnButtons[i]:SetState(BSTATE_NORMAL) AIRG.UI.columnButtons[i]:SetAnchor(TOPLEFT, AIResearchGrid, TOPLEFT, 40*i + 150, 55) AIRG.UI.columnButtons[i]:SetHidden(true) AIRG.UI.columnButtons[i]:SetEnabled(true) AIRG.UI.columnButtons[i]:SetMouseOverTexture("esoui/art/buttons/generic_highlight.dds") AIRG.UI.columnButtons[i].text = i -- placeholder AIRG.UI.columnButtons[i]:SetHandler("OnMouseEnter", function (self) ZO_Tooltips_ShowTextTooltip(self, TOP, self.text) end) AIRG.UI.columnButtons[i]:SetHandler("OnMouseExit", function (self) ZO_Tooltips_HideTextTooltip() end) -- BUILD THE GRID -- There are a total of 18 traits possible. 9 armour and 9 weapon (Infused, Training and Nirnhoned on both) AIRG.UI.gridButtons[i] = {} for j = 1, 18 do AIRG.UI.gridButtons[i][j] = WINDOW_MANAGER:CreateControl("AIResearchGridGridButton" .. tostring(i) .. "x" .. tostring(j), AIResearchGrid, CT_TEXTURE) AIRG.UI.gridButtons[i][j]:SetDimensions(24, 24) AIRG.UI.gridButtons[i][j]:SetAnchor(TOP, AIRG.UI.columnButtons[i], BOTTOM, 0, 28*j -20) AIRG.UI.gridButtons[i][j]:SetTexture("/esoui/art/buttons/swatchframe_down.dds") -- little square box AIRG.UI.gridButtons[i][j]:SetColor(1, 1, 1, 0.4) AIRG.UI.gridButtons[i][j]:SetHidden(false) AIRG.UI.gridButtons[i][j]:SetMouseEnabled(false) -- Following tooltip code uses ideas contributed by Krysstof AIRG.UI.gridButtons[i][j]:SetHandler("OnMouseEnter", function (self) -- if (self.tooltipText > 0) then -- Check the item is being researched and has a timestamp if (self.Known > 0) then -- Check the item is being researched and has a timestamp local tRemaining = tonumber(self.Known) - GetTimeStamp() local tFormatted = FormatTimeSeconds(tRemaining, TIME_FORMAT_STYLE_DESCRIPTIVE_SHORT, TIME_FORMAT_PRECISION_SECONDS, TIME_FORMAT_DIRECTION_DESCENDING) ZO_Tooltips_ShowTextTooltip(self, RIGHT, tFormatted) -- loop with "registerforupdate" once per second EVENT_MANAGER:RegisterForUpdate(self.name, 1000, function() local tRemaining = tonumber(self.Known) - GetTimeStamp() local tFormatted = FormatTimeSeconds(tRemaining, TIME_FORMAT_STYLE_DESCRIPTIVE_SHORT, TIME_FORMAT_PRECISION_SECONDS, TIME_FORMAT_DIRECTION_DESCENDING) ZO_Tooltips_ShowTextTooltip(self, RIGHT, tFormatted) end) else ZO_Tooltips_ShowTextTooltip(self, RIGHT, self.tooltipText) end end) AIRG.UI.gridButtons[i][j]:SetHandler("OnMouseExit", function (self) -- unregister the update event or it keeps on displaying EVENT_MANAGER:UnregisterForUpdate(self.name) ZO_Tooltips_HideTextTooltip() end) end -- BUILD THE COLUMN FOOTERS AIRG.UI.columnFooters[i] = WINDOW_MANAGER:CreateControl("AIResearchGridColumnFooterLabel" .. tostring(i), AIResearchGrid, CT_LABEL) AIRG.UI.columnFooters[i]:SetAnchor(TOP, AIRG.UI.columnButtons[i], BOTTOM, 0, 516) AIRG.UI.columnFooters[i]:SetDimensions(36, 24) AIRG.UI.columnFooters[i]:SetFont("ZoFontGame") AIRG.UI.columnFooters[i]:SetHorizontalAlignment(TEXT_ALIGN_CENTER) AIRG.UI.columnFooters[i]:SetVerticalAlignment(TEXT_ALIGN_CENTER) AIRG.UI.columnFooters[i]:SetColor(1, 1, 0.4, 1); -- faded yellow end -- BUILD LABEL FOR COLUMN FOOTER "TRAIT LINE" AIRG.UI.columnFooterTitle = WINDOW_MANAGER:CreateControl("AIResearchGridColumnFooterTitleLabel", AIResearchGrid, CT_LABEL) AIRG.UI.columnFooterTitle:SetAnchor(TOPLEFT, AIResearchGrid, TOPLEFT, 5, 606) AIRG.UI.columnFooterTitle:SetDimensions(180, 24) AIRG.UI.columnFooterTitle:SetFont("ZoFontGame") AIRG.UI.columnFooterTitle:SetHorizontalAlignment(TEXT_ALIGN_RIGHT) AIRG.UI.columnFooterTitle:SetVerticalAlignment(TEXT_ALIGN_CENTER) AIRG.UI.columnFooterTitle:SetColor(1, 1, 0.4, 1); -- faded yellow -- AIRG.UI.columnFooterTitle:SetText(GetString(SI_SMITHING_RESEARCH_LINE_HEADER)) AIRG.UI.columnFooterTitle:SetText(GetString(SI_CRAFTING_COMPONENT_TOOLTIP_TRAITS)) -- "Traits" AIResearchGrid:SetHeight(AIRG.vars.showMotifs and 756 or 636) -- BUILD THE MOTIF ICONS ACROSS THE BOTTOM -- It's set-up inside a container frame to make hiding or showing the whole lot simpler. AIRG.UI.motifSection = WINDOW_MANAGER:CreateControl("AIResearchMotifSection", AIResearchGrid, CT_CONTROL) AIRG.UI.motifSection:SetDimensions(750, 100) AIRG.UI.motifSection:SetAnchor(BOTTOMLEFT, AIResearchGrid, BOTTOMLEFT, 0, 0) AIRG.UI.motifSection:SetHidden(not AIRG.vars.showMotifs) AIRG.UI.StyleSingleButtons = {} for StyleIndex, Style in ipairs(AIRG.StyleSingleDat) do AIRG.UI.StyleSingleButtons[StyleIndex] = WINDOW_MANAGER:CreateControl("AIRGStyleSingleButton" .. tostring(StyleIndex), AIRG.UI.motifSection, CT_TEXTURE) AIRG.UI.StyleSingleButtons[StyleIndex]:SetDimensions(40, 40) AIRG.UI.StyleSingleButtons[StyleIndex]:SetAnchor(TOPLEFT, AIRG.UI.motifSection, TOPLEFT, 40*StyleIndex , 0) AIRG.UI.StyleSingleButtons[StyleIndex]:SetTexture(Style[3] .. "up.dds") AIRG.UI.StyleSingleButtons[StyleIndex]:SetMouseEnabled(true) tDesc ,_,_,_,_ = GetSmithingStyleItemInfo( Style[2] ) --Mat name AIRG.UI.StyleSingleButtons[StyleIndex].tooltipText = zo_strformat("<<t:1>>\n<<t:2>>", GetString("SI_ITEMSTYLE",Style[1]), tDesc) AIRG.UI.StyleSingleButtons[StyleIndex]:SetHandler("OnMouseEnter", function (self) ZO_Tooltips_ShowTextTooltip(self, TOP, self.tooltipText) end) AIRG.UI.StyleSingleButtons[StyleIndex]:SetHandler("OnMouseExit", function (self) ZO_Tooltips_HideTextTooltip() end) end AIRG.UI.StyleChapterButtons = {} for StyleIndex, Style in ipairs(AIRG.StyleChapterDat) do AIRG.UI.StyleChapterButtons[StyleIndex] = WINDOW_MANAGER:CreateControl("AIRGStyleChapterButton" .. tostring(StyleIndex), AIRG.UI.motifSection, CT_TEXTURE) AIRG.UI.StyleChapterButtons[StyleIndex]:SetDimensions(40, 40) AIRG.UI.StyleChapterButtons[StyleIndex]:SetAnchor(TOPLEFT, AIRG.UI.motifSection, TOPLEFT, 40*StyleIndex , 40) AIRG.UI.StyleChapterButtons[StyleIndex]:SetTexture(Style[3] .. "up.dds") AIRG.UI.StyleChapterButtons[StyleIndex]:SetMouseEnabled(true) -- tDesc ,_,_,_,_ = GetSmithingStyleItemInfo( Style[2] ) --Mat name -- AIRG.UI.StyleChapterButtons[StyleIndex].tooltipText = zo_strformat("<<t:1>>\n<<t:2>>", GetString("SI_ITEMSTYLE",Style[1]), tDesc) AIRG.UI.StyleChapterButtons[StyleIndex].tooltipText = "" AIRG.UI.StyleChapterButtons[StyleIndex]:SetHandler("OnMouseEnter", function (self) ZO_Tooltips_ShowTextTooltip(self, TOP, self.tooltipText) end) AIRG.UI.StyleChapterButtons[StyleIndex]:SetHandler("OnMouseExit", function (self) ZO_Tooltips_HideTextTooltip() end) end -- BUILD LABEL FOR STYLES AIRG.UI.StyleLabel = WINDOW_MANAGER:CreateControl("AIResearchStylelabel", AIRG.UI.motifSection, CT_LABEL) AIRG.UI.StyleLabel:SetAnchor(TOPLEFT, AIRG.UI.motifSection, TOPLEFT, 5, 6) AIRG.UI.StyleLabel:SetText("") AIRG.UI.StyleLabel:SetDimensions(150, 24) AIRG.UI.StyleLabel:SetFont("ZoFontGame") AIRG.UI.StyleLabel:SetHorizontalAlignment(TEXT_ALIGN_RIGHT) end -- AIRG.initUI -- User has clicked on one of the profession buttons -- or we just want to refresh the display with current data function AIRG.OnCraftSelected(_,thisCraft) if (thisCraft == nil) then if (AIRG.curCraft == nil) then return else thisCraft = AIRG.curCraft end end AIRG.UI.WindowSubTitle:SetText(AIRG.craftNames[thisCraft]) local busy local traitCount,alltraits, tooltiptext local maxLines = GetNumSmithingResearchLines(thisCraft) -- the number of columns for this profession AIRG.curCraft = thisCraft alltraits = 0 for i = 1, AIRG.maxColumns do busy = false -- "blank" the grid for j = 1, 18 do AIRG.UI.gridButtons[i][j]:SetColor(1, 1, 1, 0.4) AIRG.UI.gridButtons[i][j]:SetTexture("/esoui/art/buttons/swatchframe_down.dds") AIRG.UI.gridButtons[i][j]:SetMouseEnabled(false) -- effectively disable tooltip for this grid item. end if (i > maxLines) then AIRG.UI.columnButtons[i]:SetHidden(true) AIRG.UI.columnFooters[i]:SetText("") else local name, icon, _, _ = GetSmithingResearchLineInfo(thisCraft, i) -- Get info on that specific item AIRG.UI.columnButtons[i]:SetNormalTexture(icon) AIRG.UI.columnButtons[i]:SetHidden(false) AIRG.UI.columnButtons[i].text = name traitCount = 0 --Check for research expiry for rowNum,tKnown in pairs(AIRG.vars.char[AIRG.curCharacter].traits[thisCraft][i]) do if (tKnown > 0 and tKnown < GetTimeStamp()) then AIRG.vars.char[AIRG.curCharacter].traits[thisCraft][i][rowNum] = -1 -- Change to known end end if AIRG.ShowRelative then -- Great! relative mode! we need to address a matter of practical usage. -- We need to see that we actually can research that now, because we can't research more than one item type at a time. -- So we need to pre-check for item research and set the colours (of the texture) appropriately for rowNum,tKnown in pairs(AIRG.vars.char[AIRG.curCharacter].traits[thisCraft][i]) do if (tKnown > 0) then -- researching busy = true end end for rowNum,tKnown in pairs(AIRG.relative[AIRG.curCharacter][thisCraft][i]) do AIRG.UI.gridButtons[i][rowNum].Known = tKnown if (tKnown == -1) then -- Trait is known if (busy) then AIRG.UI.gridButtons[i][rowNum]:SetColor(0.7, 0.6, 0.6, .8) -- Dull Reddish else AIRG.UI.gridButtons[i][rowNum]:SetColor(0.2, 1, 0.2, 1) -- Green AIRG.UI.gridButtons[i][rowNum]:SetMouseEnabled(true) end tooltiptext = zo_strjoin(" ",AIRG.UI.rowLabels[rowNum]:GetText() , AIRG.UI.columnButtons[i].text) AIRG.UI.gridButtons[i][rowNum].tooltipText = tooltiptext AIRG.UI.gridButtons[i][rowNum]:SetTexture("/esoui/art/loot/loot_finesseitem.dds") traitCount = traitCount + 1 end end else -- not relative for rowNum,tKnown in pairs(AIRG.vars.char[AIRG.curCharacter].traits[thisCraft][i]) do AIRG.UI.gridButtons[i][rowNum].Known = tKnown if (tKnown == -1) then -- Trait is known AIRG.UI.gridButtons[i][rowNum]:SetColor(0.2, 1, 0.2, 1) -- Green AIRG.UI.gridButtons[i][rowNum]:SetTexture("/esoui/art/loot/loot_finesseitem.dds") traitCount = traitCount + 1 tooltiptext = zo_strjoin(" ",AIRG.UI.rowLabels[rowNum]:GetText() , AIRG.UI.columnButtons[i].text) AIRG.UI.gridButtons[i][rowNum].tooltipText = tooltiptext AIRG.UI.gridButtons[i][rowNum]:SetMouseEnabled(true) elseif (tKnown > 0) then -- Trait is being researched AIRG.UI.gridButtons[i][rowNum]:SetTexture("/esoui/art/miscellaneous/gamepad/gp_icon_timer32.dds") AIRG.UI.gridButtons[i][rowNum]:SetColor(0.0, .5, .75, 1) -- Blue AIRG.UI.gridButtons[i][rowNum]:SetMouseEnabled(true) else -- Trait is NOT known AIRG.UI.gridButtons[i][rowNum]:SetColor(1, 0.2, 0.2, 1) -- Red AIRG.UI.gridButtons[i][rowNum]:SetTexture("esoui/art/buttons/decline_up.dds") -- an "X". end end end --Relative AIRG.UI.columnFooters[i]:SetText(traitCount) alltraits = alltraits + traitCount end end AIRG.UI.columnFooterTitle:SetText(GetString(SI_CRAFTING_COMPONENT_TOOLTIP_TRAITS) .. "(" .. tostring(alltraits) .. ")") -- "Traits" end -- AIRG:OnCraftSelected -- Invoked when the user selected a character from the dropdown box function AIRG.OnCharacterSelect(charName) if (charName == nil) then return end AIRG.curCharacter = charName -- The Relative Button doesn't make sense if selecting these if charName == AIRG.all or charName == AIRG.playerName then AIRG.UI.btnUpdateOther:SetEnabled(false) AIRG.ShowRelative = false else AIRG.UI.btnUpdateOther:SetEnabled(true) end AIRG.DisplayStyles() AIRG.OnCraftSelected() end -- AIRG.OnCharacterSelect -- Deletes data for the named character from the saved data and removes them from the dropdown box. function AIRG.DeleteCharacter(charName) -- Can't delete the current character if (charName == AIRG.curCharacter) then d(AIRG.L["DeleteFalse"]) else if (AIRG.vars.char[charName] ~= nil) then AIRG.vars.char[charName] = nil d(AIRG.L["DeleteTrue"] .. charName) end AIRG.PopulateAll() --this part is new, Thank you Garkin for i, item in ipairs(AIRG.UI.charDropdown.dropdown.m_sortedItems) do if item.name == charName then table.remove(AIRG.UI.charDropdown.dropdown.m_sortedItems, i) break end end AIRG.UI.charDropdown.dropdown:UpdateItems() end end -- AIRG.DeleteCharacter -- This function cycles through all three professions and populates the data matrix for this characters -- This is carried out when the addon loads to ensure the current character data is up-to-date. -- The "if" logic in this function guesses at which profession should be default to display as the one with most research in. function AIRG.PopulateMatrix() local curCount = 0 local thisCount AIRG.curCraft = CRAFTING_TYPE_BLACKSMITHING --Default for new chars thisCount = AIRG.CreateDataMatrix(CRAFTING_TYPE_BLACKSMITHING) if (thisCount > curCount) then AIRG.curCraft = CRAFTING_TYPE_BLACKSMITHING curCount = thisCount end thisCount = AIRG.CreateDataMatrix(CRAFTING_TYPE_CLOTHIER) if (thisCount > curCount) then AIRG.curCraft = CRAFTING_TYPE_CLOTHIER curCount = thisCount end thisCount = AIRG.CreateDataMatrix(CRAFTING_TYPE_WOODWORKING) if (thisCount > curCount) then AIRG.curCraft = CRAFTING_TYPE_WOODWORKING curCount = thisCount end AIRG.CreateDataMatrixRelative(CRAFTING_TYPE_BLACKSMITHING) AIRG.CreateDataMatrixRelative(CRAFTING_TYPE_WOODWORKING) AIRG.CreateDataMatrixRelative(CRAFTING_TYPE_CLOTHIER) end -- AIRG.PopulateMatrix -- Lookup the style data for the current character and send it to saved vars. function AIRG.PopulateStyleData() for StyleIndex, Style in ipairs (AIRG.StyleSingleDat) do AIRG.vars.char[AIRG.curCharacter].StyleSingle[StyleIndex] = IsSmithingStyleKnown(Style[2], 1) --patternIndex set to 1, temporary workaround for changes introduced in Update 4 end --Chapter Styles AIRG.vars.char[AIRG.curCharacter].StyleChapter = {} -- Table for each style for StyleIndex, Style in ipairs (AIRG.StyleChapterDat) do AIRG.vars.char[AIRG.curCharacter].StyleChapter[StyleIndex] = {} -- Table for each Chapter (weapon/clothing) for ChapterIndex, Chapter in ipairs(AIRG.styleChaptersLookup) do local desc, numCompleted = GetAchievementCriterion(Style[4], Chapter) if numCompleted == 1 then -- d(ChapterIndex .. " " .. Chapter .. ": Completed: " .. desc) end AIRG.vars.char[AIRG.curCharacter].StyleChapter[StyleIndex][Chapter] = numCompleted == 1 end end end -- AIRG.PopulateStyleData -- When any character data changes we have to go through and create our virtual "All" from the beginning. -- its simplified by not having to reset to unknown as traits can't be forgotton. -- The ALL char data was erased at startup function AIRG.PopulateAll() local craft, item, trait, thisname for thisname, _ in pairs(AIRG.vars.char) do --iterate over all characters if thisname ~= AIRG.all then --skip our virtual for craft, _ in pairs(AIRG.vars.char[thisname].traits) do --iterate over all crafts for item, _ in pairs(AIRG.vars.char[thisname].traits[craft]) do --iterate over all weapons/armour for trait, _ in pairs(AIRG.vars.char[thisname].traits[craft][item]) do --iterate over all traits if AIRG.vars.char[thisname].traits[craft][item][trait] ~= 0 then -- researching counts as learned. AIRG.vars.char[AIRG.all].traits[craft][item][trait] = -1 end end end end -- Fix crash for empty data. if type (AIRG.vars.char[thisname].StyleSingle) ~= "table" then AIRG.vars.char[thisname].StyleSingle = {} end if type (AIRG.vars.char[thisname].StyleChapter) ~= "table" then AIRG.vars.char[thisname].StyleChapter = {} -- no contents, but ipairs doesnt mind- runs zero times end -- Loop through my Singles for i, Known in ipairs(AIRG.vars.char[thisname].StyleSingle) do if Known then AIRG.vars.char[AIRG.all].StyleSingle[i] = true end end -- Loop through my Chapters for i, Style in ipairs(AIRG.vars.char[thisname].StyleChapter) do for j, Known in ipairs (Style) do if Known then AIRG.vars.char[AIRG.all].StyleChapter[i][j] = true end end end end -- thisname ~= AIRG.all end --for end -- AIRG.PopulateAll -- Set the icon highlights for the currently selected character function AIRG.DisplayStyles() -- Single Styles for StyleIndex, known in ipairs(AIRG.vars.char[AIRG.curCharacter].StyleSingle) do if (known) then AIRG.UI.StyleSingleButtons[StyleIndex]:SetTexture(AIRG.StyleSingleDat[StyleIndex][3] .. "down.dds") AIRG.UI.StyleSingleButtons[StyleIndex]:SetColor(0.2, 1, 0.2, 1) -- Green else AIRG.UI.StyleSingleButtons[StyleIndex]:SetTexture(AIRG.StyleSingleDat[StyleIndex][3] .. "up.dds") AIRG.UI.StyleSingleButtons[StyleIndex]:SetColor(1, 1, 1, 0.7) -- grey end end -- ================= -- Chapter Styles for StyleIndex, Style in ipairs(AIRG.vars.char[AIRG.curCharacter].StyleChapter) do local tooltipText = "" local itemStyle,tDesc local KnownCount = 0 local AllKnown = true -- Run through the complete list in AIRG.styleChaptersLookup, and look up to see which we have. -- check how many chapters are known and build tooltip for ChapterIndex, chapter in ipairs(AIRG.styleChaptersLookup) do if (AIRG.vars.char[AIRG.curCharacter].StyleChapter[StyleIndex][ChapterIndex]) then tooltipText = zo_strjoin(nil, tooltipText, "\n|cFFFFFF", GetString("SI_ITEMSTYLECHAPTER", chapter), "|r") KnownCount = KnownCount +1 else AllKnown = false tooltipText = zo_strjoin(nil, tooltipText, "\n|c806060", GetString("SI_ITEMSTYLECHAPTER", chapter), "|r") end end if KnownCount == 0 then AIRG.UI.StyleChapterButtons[StyleIndex]:SetTexture(AIRG.StyleChapterDat[StyleIndex][3] .. "up.dds") AIRG.UI.StyleChapterButtons[StyleIndex]:SetColor(1, 1, 1, 0.7) -- grey else AIRG.UI.StyleChapterButtons[StyleIndex]:SetTexture(AIRG.StyleChapterDat[StyleIndex][3] .. "down.dds") if AllKnown then AIRG.UI.StyleChapterButtons[StyleIndex]:SetColor(0.2, 1, 0.2, 1) -- Green else AIRG.UI.StyleChapterButtons[StyleIndex]:SetColor(1, 1, 0.6, 1) -- yellow end end itemStyle = AIRG.StyleChapterDat[StyleIndex][1] tDesc = GetSmithingStyleItemLink(AIRG.StyleChapterDat[StyleIndex][2]) AIRG.UI.StyleChapterButtons[StyleIndex].tooltipText = zo_strjoin(nil, zo_strformat("<<t:1>> (<<2>>/14)\n<<t:3>>\n", GetString("SI_ITEMSTYLE", itemStyle), KnownCount, tDesc), tooltipText) end end -- AIRG.DisplayStyles() -- Look up all the data on this profession and commit to saved variables for this character. function AIRG.CreateDataMatrix(thisCraft) -- for current player, not the selected local tType, tKnown, tRemain, rowNum, tTargetStamp local rCount = 0 local maxLines = GetNumSmithingResearchLines(thisCraft) -- the number of columns for this profession AIRG.vars.char[AIRG.playerName].traits[thisCraft] = {} -- create a table for this profession for real traits -- Not relative updates, show all for Current Character -- Cycle through items for this profession for i = 1, maxLines do AIRG.vars.char[AIRG.playerName].traits[thisCraft][i] = {} -- create a table for this item -- Cycle through the traits for this item for j = 1, 9 do tType,_,tKnown = GetSmithingResearchLineTraitInfo(thisCraft,i,j) _,tRemain = GetSmithingResearchLineTraitTimes(thisCraft,i,j) rowNum = AIRG.gridTraits[tType] if (tKnown) then AIRG.vars.char[AIRG.playerName].traits[thisCraft][i][rowNum] = -1 -- this trait is known rCount = rCount + 1 else if (tRemain) then tTargetStamp = GetTimeStamp() + tRemain AIRG.vars.char[AIRG.playerName].traits[thisCraft][i][rowNum] = tTargetStamp -- this trait is being currently researched -- The value we are setting this to is the timestamp for when the research will be complete. else AIRG.vars.char[AIRG.playerName].traits[thisCraft][i][rowNum] = 0 -- this trait is NOT known end end end end return rCount -- the total number of traits already researched in this profession end -- AIRG.CreateDataMatrix function AIRG.CreateDataMatrixRelative(thisCraft) -- for the current selected player, relative to the real player for thisname, _ in pairs(AIRG.vars.char) do --iterate over all characters if thisname ~= AIRG.all then --skip our virtual AIRG.relative[thisname] = {} for craft, _ in pairs(AIRG.vars.char[thisname].traits) do --iterate over all crafts AIRG.relative[thisname][craft] = {} for item, _ in pairs(AIRG.vars.char[thisname].traits[craft]) do --iterate over all weapons/armour AIRG.relative[thisname][craft][item] = {} for trait, _ in pairs(AIRG.vars.char[thisname].traits[craft][item]) do --iterate over all traits AIRG.relative[thisname][craft][item][trait] = {} if AIRG.vars.char[thisname].traits[craft][item][trait] == 0 then -- thischar doesn't have traits if AIRG.vars.char[AIRG.playerName].traits[craft][item][trait] == -1 ---PLayer Does then AIRG.relative[thisname][craft][item][trait] = -1 else AIRG.relative[thisname][craft][item][trait] = nil end end end end end end end end -- AIRG.CreateDataMatrix function AIRG.LoadStatic() -- Translates the traitType to the correct ROW of the grid AIRG.gridTraits = {} AIRG.gridTraits[ITEM_TRAIT_TYPE_WEAPON_POWERED] = 1 AIRG.gridTraits[ITEM_TRAIT_TYPE_WEAPON_CHARGED] = 2 AIRG.gridTraits[ITEM_TRAIT_TYPE_WEAPON_PRECISE] = 3 AIRG.gridTraits[ITEM_TRAIT_TYPE_WEAPON_INFUSED] = 4 AIRG.gridTraits[ITEM_TRAIT_TYPE_WEAPON_DEFENDING] = 5 AIRG.gridTraits[ITEM_TRAIT_TYPE_WEAPON_TRAINING] = 6 AIRG.gridTraits[ITEM_TRAIT_TYPE_WEAPON_SHARPENED] = 7 AIRG.gridTraits[ITEM_TRAIT_TYPE_WEAPON_WEIGHTED] = 8 AIRG.gridTraits[ITEM_TRAIT_TYPE_WEAPON_NIRNHONED] = 9 AIRG.gridTraits[ITEM_TRAIT_TYPE_ARMOR_STURDY] = 10 AIRG.gridTraits[ITEM_TRAIT_TYPE_ARMOR_IMPENETRABLE] = 11 AIRG.gridTraits[ITEM_TRAIT_TYPE_ARMOR_REINFORCED] = 12 AIRG.gridTraits[ITEM_TRAIT_TYPE_ARMOR_WELL_FITTED] = 13 AIRG.gridTraits[ITEM_TRAIT_TYPE_ARMOR_TRAINING] = 14 AIRG.gridTraits[ITEM_TRAIT_TYPE_ARMOR_INFUSED] = 15 AIRG.gridTraits[ITEM_TRAIT_TYPE_ARMOR_EXPLORATION] = 16 AIRG.gridTraits[ITEM_TRAIT_TYPE_ARMOR_DIVINES] = 17 AIRG.gridTraits[ITEM_TRAIT_TYPE_ARMOR_NIRNHONED] = 18 AIRG.styleChaptersLookup = {} -- Display Order AIRG.styleChaptersLookup[1] = ITEM_STYLE_CHAPTER_AXES --10 --Axe AIRG.styleChaptersLookup[2] = ITEM_STYLE_CHAPTER_BELTS --6 --Belt AIRG.styleChaptersLookup[3] = ITEM_STYLE_CHAPTER_BOOTS --Boots AIRG.styleChaptersLookup[4] = ITEM_STYLE_CHAPTER_BOWS --Bows AIRG.styleChaptersLookup[5] = ITEM_STYLE_CHAPTER_CHESTS --5 --Chests AIRG.styleChaptersLookup[6] = ITEM_STYLE_CHAPTER_DAGGERS -- 11 --Daggers AIRG.styleChaptersLookup[7] = ITEM_STYLE_CHAPTER_GLOVES -- 2 --Gloves AIRG.styleChaptersLookup[8] = ITEM_STYLE_CHAPTER_HELMETS --Helmets AIRG.styleChaptersLookup[9] = ITEM_STYLE_CHAPTER_LEGS -- 4 --Legs AIRG.styleChaptersLookup[10] = ITEM_STYLE_CHAPTER_MACES --Maces AIRG.styleChaptersLookup[11] = ITEM_STYLE_CHAPTER_SHIELDS -- 13 --Shields AIRG.styleChaptersLookup[12] = ITEM_STYLE_CHAPTER_SHOULDERS --Shoulders AIRG.styleChaptersLookup[13] = ITEM_STYLE_CHAPTER_STAVES -- 12 --Staves AIRG.styleChaptersLookup[14] = ITEM_STYLE_CHAPTER_SWORDS --Swords --These tables contain records of Styles in Display Order -- Style Number for name,Mat Number, Icon -- NOTE for testing if known put the MATNUMBER NOT THE STYLE NUMBER into IsSmithingStyleKnown(<VAL>,1) -- Determined by trying them all AIRG.StyleSingleDat ={ -- Styles without Chapters. {ITEMSTYLE_RACIAL_HIGH_ELF, 8, "esoui/art/charactercreate/charactercreate_altmericon_"}, {ITEMSTYLE_RACIAL_DARK_ELF, 5, "esoui/art/charactercreate/charactercreate_dunmericon_"}, {ITEMSTYLE_RACIAL_WOOD_ELF, 9, "esoui/art/charactercreate/charactercreate_bosmericon_"}, {ITEMSTYLE_RACIAL_NORD, 6, "esoui/art/charactercreate/charactercreate_nordicon_"}, {ITEMSTYLE_RACIAL_BRETON, 2, "esoui/art/charactercreate/charactercreate_bretonicon_"}, {ITEMSTYLE_RACIAL_REDGUARD, 3, "esoui/art/charactercreate/charactercreate_redguardicon_"}, {ITEMSTYLE_RACIAL_KHAJIIT, 10, "esoui/art/charactercreate/charactercreate_khajiiticon_"}, {ITEMSTYLE_RACIAL_ORC, 4, "esoui/art/charactercreate/charactercreate_orcicon_"}, {ITEMSTYLE_RACIAL_ARGONIAN, 7, "esoui/art/charactercreate/charactercreate_argonianicon_"}, {ITEMSTYLE_RACIAL_IMPERIAL, 35, "esoui/art/charactercreate/charactercreate_imperialicon_"}, {ITEMSTYLE_AREA_ANCIENT_ELF, 16, "esoui/art/progression/progression_indexicon_weapons_"}, {ITEMSTYLE_AREA_REACH, 18, "esoui/art/progression/progression_indexicon_weapons_"}, -- Barbaric {ITEMSTYLE_ENEMY_DAEDRIC, 21, "esoui/art/progression/progression_indexicon_weapons_"}, {ITEMSTYLE_ENEMY_PRIMITIVE, 20, "esoui/art/progression/progression_indexicon_weapons_"}, -- Primal {ITEMSTYLE_AREA_SOUL_SHRIVEN, 31, "esoui/art/progression/progression_indexicon_weapons_"} } -- Style Number,Mat Number, Icon, Achievment ID AIRG.StyleChapterDat ={ {ITEMSTYLE_AREA_DWEMER, 15, "esoui/art/progression/progression_indexicon_weapons_", 1144}, {ITEMSTYLE_GLASS, 29, "esoui/art/progression/progression_indexicon_weapons_", 1319}, {ITEMSTYLE_AREA_XIVKYN, 30, "esoui/art/progression/progression_indexicon_weapons_", 1181}, {ITEMSTYLE_AREA_ANCIENT_ORC, 23, "esoui/art/progression/progression_indexicon_weapons_", 1341}, {ITEMSTYLE_AREA_AKAVIRI, 34, "esoui/art/progression/progression_indexicon_weapons_", 1318}, {ITEMSTYLE_UNDAUNTED, 27, "esoui/art/progression/progression_indexicon_weapons_",1348}, --Mercenary {ITEMSTYLE_DEITY_MALACATH, 14, "esoui/art/progression/progression_indexicon_weapons_", 1412}, {ITEMSTYLE_DEITY_TRINIMAC, 21, "esoui/art/progression/progression_indexicon_weapons_", 1411}, {47, 48, "esoui/art/progression/progression_indexicon_weapons_", 1417}, -- Outlaw {ITEMSTYLE_ALLIANCE_EBONHEART, 25, "esoui/art/progression/progression_indexicon_weapons_",1414}, {ITEMSTYLE_ALLIANCE_ALDMERI, 26, "esoui/art/progression/progression_indexicon_weapons_", 1415}, {ITEMSTYLE_ALLIANCE_DAGGERFALL, 24, "esoui/art/progression/progression_indexicon_weapons_", 1416} } end -- AIRG.LoadStatic function AIRG.Initialise(eventCode, addOnName) -- Only initialize our own addon if (AIRG.name ~= addOnName) then return end -- Language text AIRG.InitialiseLanguage() -- Load the saved variables AIRG.vars = ZO_SavedVars:NewAccountWide("AIRG_SavedVariables", 3, nil, AIRG.defaults) AIRG.all = AIRG.L["ALL"] -- replace Default with localise string -- Register Keybinding ZO_CreateStringId("SI_BINDING_NAME_TOGGLE_AIRG", "Toggle AI Research Grid") -- Set-up some variables we'll want to refer to. AIRG.craftNames = {} AIRG.relative = {} AIRG.craftNames[CRAFTING_TYPE_BLACKSMITHING] = AIRG.L["BS"] AIRG.craftNames[CRAFTING_TYPE_CLOTHIER] = AIRG.L["Clothing"] AIRG.craftNames[CRAFTING_TYPE_WOODWORKING] = AIRG.L["Woodwork"] AIRG.curCraft= CRAFTING_TYPE_WOODWORKING AIRG.playerName = GetUnitName("player") AIRG.curCharacter = GetUnitName("player") -- Default the display to the current character AIRG.LoadStatic() -- tables for new Data on version 3.4.0 if type(AIRG.vars.char) ~= "table" then AIRG.vars.char = {} end -- Remove "ALL" data, we will recreate it. AIRG.vars.char[AIRG.all]= {} AIRG.vars.char[AIRG.all].traits = {} AIRG.vars.char[AIRG.all].StyleChapter = {} AIRG.vars.char[AIRG.all].StyleSingle = {} -- Remove player data, we will reload it. AIRG.vars.char[AIRG.playerName] = {} AIRG.vars.char[AIRG.playerName].traits = {} -- create a table for this character's matrix AIRG.vars.char[AIRG.playerName].StyleChapter = {} AIRG.vars.char[AIRG.playerName].StyleSingle = {} -- Create Empty data for "ALL" set to 0, (Not known) AIRG.vars.char[AIRG.all].traits[CRAFTING_TYPE_BLACKSMITHING] = {} -- Cycle through items for this profession for i = 1, 7 do -- Weapons AIRG.vars.char[AIRG.all].traits[CRAFTING_TYPE_BLACKSMITHING][i] = {} -- Cycle through the traits for this item for j = 1, 9 do AIRG.vars.char[AIRG.all].traits[CRAFTING_TYPE_BLACKSMITHING][i][j] = 0 -- set to not known end end for i = 8, 14 do -- Armour AIRG.vars.char[AIRG.all].traits[CRAFTING_TYPE_BLACKSMITHING][i] = {} -- Cycle through the traits for this item for j = 10, 18 do AIRG.vars.char[AIRG.all].traits[CRAFTING_TYPE_BLACKSMITHING][i][j] = 0 -- set to not known end end AIRG.vars.char[AIRG.all].traits[CRAFTING_TYPE_CLOTHIER] = {} -- Cycle through items for this profession for i = 1, 14 do AIRG.vars.char[AIRG.all].traits[CRAFTING_TYPE_CLOTHIER][i] = {} -- Cycle through the traits for this item for j = 10, 18 do AIRG.vars.char[AIRG.all].traits[CRAFTING_TYPE_CLOTHIER][i][j] = 0 -- set to not known end end AIRG.vars.char[AIRG.all].traits[CRAFTING_TYPE_WOODWORKING] = {} -- Cycle through items for this profession for i = 1, 5 do AIRG.vars.char[AIRG.all].traits[CRAFTING_TYPE_WOODWORKING][i] = {} -- Cycle through the traits for this item for j = 1, 9 do AIRG.vars.char[AIRG.all].traits[CRAFTING_TYPE_WOODWORKING][i][j] = 0 -- set to not known end end for i = 6, 6 do --Shields AIRG.vars.char[AIRG.all].traits[CRAFTING_TYPE_WOODWORKING][i] = {} -- Cycle through the traits for this item for j = 10, 18 do AIRG.vars.char[AIRG.all].traits[CRAFTING_TYPE_WOODWORKING][i][j] = 0 -- set to not known end end for i,_ in ipairs(AIRG.StyleSingleDat) do AIRG.vars.char[AIRG.all].StyleSingle[i] = false end for i,_ in ipairs(AIRG.StyleChapterDat) do AIRG.vars.char[AIRG.all].StyleChapter[i] = {} for j,_ in ipairs(AIRG.styleChaptersLookup) do AIRG.vars.char[AIRG.all].StyleChapter[i][j] = false end end -- UI set-up. Create frames, position labels & buttons etc. AIRG.initUI() -- Create the configuration/settings menu. AIRG.CreateConfigMenu() -- REGISTER for events that aren't initialise. EVENT_MANAGER:RegisterForEvent("AIRG", EVENT_SMITHING_TRAIT_RESEARCH_STARTED, AIRG.ResearchStarted) EVENT_MANAGER:RegisterForEvent("AIRG", EVENT_SMITHING_TRAIT_RESEARCH_COMPLETED, AIRG.ResearchCompleted) EVENT_MANAGER:RegisterForEvent("AIRG", EVENT_STYLE_LEARNED, AIRG.StyleLearned) EVENT_MANAGER:RegisterForEvent("AIRG", EVENT_PLAYER_ACTIVATED, AIRG.PlayerActivated) SCENE_MANAGER:RegisterTopLevel(AIResearchGrid, false) -- enables close on Esc AIRG.initialised = true end -- AIRG.Initialise -- SLASH COMMAND FUNCTIONALITY function AIRGslash(extra) AIRG.ToggleMainWindow() end -- AIRGslash SLASH_COMMANDS["/airg"] = AIRGslash --SLASH_COMMANDS["/test"] = AIRG.DisplayStyles EVENT_MANAGER:RegisterForEvent("AIRG", EVENT_ADD_ON_LOADED, AIRG.Initialise) -- EOF