adam@0: local _, AskMrRobot = ... yellowfive@11: local L = AskMrRobot.L; adam@0: adam@0: AskMrRobot.SummaryTab = AskMrRobot.inheritsFrom(AskMrRobot.Frame) adam@0: adam@0: function AskMrRobot.SummaryTab:new(parent) adam@0: adam@0: local tab = AskMrRobot.Frame:new(nil, parent) adam@0: setmetatable(tab, { __index = AskMrRobot.SummaryTab }) adam@0: tab:SetPoint("TOPLEFT") adam@0: tab:SetPoint("BOTTOMRIGHT") adam@0: tab:Hide() adam@0: adam@0: adam@0: tab.importDate = "" adam@0: adam@0: local text = tab:CreateFontString("AmrSummaryText1", "ARTWORK", "GameFontNormalLarge") adam@0: text:SetPoint("TOPLEFT", 0, -5) yellowfive@11: text:SetFormattedText(L.AMR_SUMMARYTAB_TITLE) adam@0: adam@0: -- error text adam@0: tab.errorText1 = tab:CreateFontString("AmrSummaryErrorText1", "ARTWORK", "GameFontRedLarge") adam@0: tab.errorText1:SetPoint("TOPLEFT", "AmrSummaryText1", "BOTTOMLEFT", 0, -20) yellowfive@11: tab.errorText1:SetText(L.AMR_SUMMARYTAB_NO_IMPORT) adam@0: tab.errorText1:SetPoint("RIGHT", -20, 0) adam@0: tab.errorText1:SetWidth(tab.errorText1:GetWidth()) adam@0: tab.errorText1:SetWordWrap(true) adam@0: tab.errorText1:SetJustifyH("LEFT") adam@0: adam@0: tab.errorText2 = tab:CreateFontString("AmrSummaryErrorText2", "ARTWORK", "GameFontWhite") adam@0: tab.errorText2:SetPoint("TOPLEFT", "AmrSummaryErrorText1", "BOTTOMLEFT", 0, -15) adam@0: tab.errorText2:SetPoint("RIGHT", -20, 0) adam@0: tab.errorText2:SetWidth(tab.errorText2:GetWidth()) adam@0: tab.errorText2:SetJustifyH("LEFT") yellowfive@11: tab.errorText2:SetText(L.AMR_SUMMARYTAB_GET_STARTED) adam@0: adam@0: -- bad items adam@0: tab.badItemSlots = {} adam@0: tab.badItemNames = {} adam@0: adam@0: local itemText = tab:CreateFontString("AmrBadItemSlot0", "ARTWORK", "GameFontNormal") adam@0: itemText:SetPoint("TOPLEFT", "AmrSummaryErrorText2", "BOTTOMLEFT", 0, -20) adam@0: itemText:SetText("Slot") adam@0: itemText:SetWidth(100) adam@0: itemText:SetJustifyH("LEFT") adam@0: itemText:Hide() adam@0: tinsert(tab.badItemSlots, itemText) adam@0: adam@0: itemText = tab:CreateFontString("AmrBadItemName0", "ARTWORK", "GameFontNormal") adam@0: itemText:SetPoint("TOPLEFT", "AmrBadItemSlot0", "TOPLEFT", 120, 0) adam@0: itemText:SetPoint("RIGHT", -30, 0) adam@0: itemText:SetText("Item Name") adam@0: itemText:SetJustifyH("LEFT") adam@0: itemText:Hide() adam@0: tinsert(tab.badItemNames, itemText) adam@0: adam@0: itemText = tab:CreateFontString(nil, "ARTWORK", "GameFontWhite") adam@0: itemText:SetPoint("LEFT", 0, 0) adam@0: itemText:SetPoint("RIGHT", -30, 0) adam@0: itemText:SetPoint("TOP", "AmrBadItemSlot0", "TOP", 0, 0 ) yellowfive@11: itemText:SetText(L.AMR_SUMMARYTAB_GO_UPGRADE) adam@0: itemText:SetJustifyH("LEFT") adam@0: itemText:Hide() adam@0: tab.upgradeInstructions = itemText adam@0: adam@0: itemText = tab:CreateFontString(nil, "ARTWORK", "GameFontNormal") adam@0: itemText:SetPoint("LEFT", "AmrBadItemSlot0", "LEFT", 0, -20) adam@0: itemText:SetPoint("RIGHT", "AmrBadItemSlot0", "RIGHT", 0, -20) adam@0: itemText:SetPoint("TOP", tab.upgradeInstructions, "BOTTOM", 0, -10 ) adam@0: itemText:SetHeight(20) yellowfive@11: itemText:SetText(L.AMR_SUMMARYTAB_SLOT) adam@0: itemText:SetJustifyH("LEFT") adam@0: itemText:Hide() adam@0: tab.upgradeSlotHeader = itemText adam@0: adam@0: itemText = tab:CreateFontString(nil, "ARTWORK", "GameFontNormal") adam@0: itemText:SetPoint("LEFT", "AmrBadItemName0", "LEFT", 0, 0) adam@0: itemText:SetPoint("RIGHT", "AmrBadItemName0", "RIGHT", 0, 0) adam@0: itemText:SetPoint("TOP", tab.upgradeSlotHeader, "TOP", 0, 0) adam@0: itemText:SetPoint("BOTTOM", tab.upgradeSlotHeader, "BOTTOM", 0, 0) yellowfive@11: itemText:SetText(L.AMR_SUMMARYTAB_ITEM_NAME) adam@0: itemText:SetJustifyH("LEFT") adam@0: itemText:Hide() adam@0: tab.upgradeItemHeader = itemText adam@0: adam@17: for i = 1, #AskMrRobot.slotIds do adam@0: local itemText = tab:CreateFontString("AmrBadItemSlot" .. i, "ARTWORK", "GameFontWhite") adam@0: itemText:SetPoint("TOPLEFT", "AmrBadItemSlot" .. (i-1), "BOTTOMLEFT", 0, -5) adam@0: itemText:SetPoint("TOPRIGHT", "AmrBadItemSlot" .. (i-1), "BOTTOMRIGHT", 0, -5) adam@0: itemText:SetJustifyH("LEFT") adam@0: itemText:Hide() adam@0: tinsert(tab.badItemSlots, itemText) adam@0: adam@0: itemText = AskMrRobot.ItemLinkText:new(nil, tab) adam@0: itemText:SetPoint("LEFT", "AmrBadItemName0", "TOPLEFT", 0, 0) adam@0: itemText:SetPoint("RIGHT", "AmrBadItemName0", "BOTTOMRIGHT", 0, 0) adam@0: itemText:SetPoint("TOP", "AmrBadItemSlot" .. i, 0, 0) adam@0: itemText:SetPoint("BOTTOM", "AmrBadItemSlot" .. i, 0, 0) adam@0: itemText:Hide() adam@0: tinsert(tab.badItemNames, itemText) adam@0: end adam@0: adam@0: tab.upgradeItemSlots = {} adam@0: tab.upgradeItemNames = {} adam@17: for i = 1, #AskMrRobot.slotIds do adam@0: local itemText = tab:CreateFontString(nil, "ARTWORK", "GameFontWhite") adam@0: if i == 1 then adam@0: itemText:SetPoint("TOPLEFT", tab.upgradeSlotHeader, "BOTTOMLEFT", 0, -5) adam@0: itemText:SetPoint("TOPRIGHT", tab.upgradeSlotHeader, "BOTTOMRIGHT", 0, -5) adam@0: else adam@0: itemText:SetPoint("TOPLEFT", tab.upgradeItemSlots[i-1], "BOTTOMLEFT", 0, -5) adam@0: itemText:SetPoint("TOPRIGHT", tab.upgradeItemSlots[i-1], "BOTTOMRIGHT", 0, -5) adam@0: end adam@0: itemText:SetJustifyH("LEFT") adam@0: itemText:Hide() adam@0: tinsert(tab.upgradeItemSlots, itemText) adam@0: adam@0: itemText = AskMrRobot.ItemLinkText:new(nil, tab) adam@0: itemText:SetFormat("|cff00ff00Upgrade|r %s") adam@0: itemText:SetPoint("LEFT", tab.upgradeItemHeader, "LEFT", 0, 0) adam@0: itemText:SetPoint("RIGHT", tab.upgradeItemHeader, "RIGHT", 0, 0) adam@0: itemText:SetPoint("TOP", tab.upgradeItemSlots[i], 0, 0) adam@0: itemText:SetPoint("BOTTOM", tab.upgradeItemSlots[i], 0, 0) adam@0: itemText:Hide() adam@0: tinsert(tab.upgradeItemNames, itemText) adam@0: end adam@0: adam@0: tab.importInfo = tab:CreateFontString(nil, "ARTWORK", "GameFontNormal") yellowfive@11: tab.importInfo:SetText(L.AMR_SUMMARYTAB_LAST_IMPORT) adam@0: tab.importInfo:SetPoint("TOPLEFT", text, "BOTTOMLEFT", 0, -20) adam@0: tab.importInfo:SetJustifyH("LEFT") adam@0: tab.importInfo:Hide() adam@0: adam@0: tab.specIcon = tab:CreateTexture(nil, "BACKGROUND") adam@0: tab.specIcon:SetPoint("TOPLEFT") adam@0: tab.specIcon:SetWidth(64) adam@0: tab.specIcon:SetHeight(64) adam@0: tab.specIcon:SetPoint("TOPLEFT", tab.importInfo, "BOTTOMLEFT", 0, -10) adam@0: tab.specIcon:Hide() adam@0: adam@0: tab.stamp = AskMrRobot.RobotStamp:new(nil, tab) adam@0: tab.stamp:Hide() yellowfive@11: tab.stamp.smallText:SetText(L.AMR_SUMMARYTAB_OPTIMAL) adam@0: tab.stamp:SetPoint("TOPLEFT", tab.specIcon, "BOTTOMLEFT", 2, -25) adam@0: tab.stamp:SetPoint("RIGHT", tab, "RIGHT", -20, 0) adam@0: tab.stamp:Hide() adam@0: adam@0: tab.specText = tab:CreateFontString(nil, "ARTWORK", "GameFontHighlightLarge") adam@0: local Path, Size, Flags = tab.specText:GetFont() adam@0: tab.specText:SetFont(Path, 24, Flags); adam@0: tab.specText:SetPoint("LEFT", tab.specIcon, "RIGHT", 10, 0) adam@0: tab.specText:SetText("?") adam@0: tab.specText:Hide() adam@0: adam@0: tab.optimizationSummary = tab:CreateFontString(nil, "ARTWORK", "GameFontNormal") adam@0: tab.optimizationSummary:SetPoint("TOPLEFT", tab.specIcon, "BOTTOMLEFT", 0, -15) yellowfive@11: tab.optimizationSummary:SetText(L.AMR_SUMMARYTAB_OPTIMIZATIONS_TO_GO) adam@0: tab.optimizationSummary:Hide() adam@0: adam@0: tab.gemCount = tab:CreateFontString(nil, "ARTWORK", "GameFontWhite") adam@0: tab.gemCount:SetPoint("TOPLEFT", tab.optimizationSummary, "BOTTOMLEFT", 0, -15) yellowfive@11: tab.gemCount:SetText(L.AMR_SUMMARYTAB_GEMS_TO_GO) adam@0: tab.gemCount:Hide() adam@0: adam@0: tab.enchantCount = tab:CreateFontString(nil, "ARTWORK", "GameFontWhite") adam@0: tab.enchantCount:SetPoint("TOPLEFT", tab.gemCount, "BOTTOMLEFT", 0, -5) yellowfive@11: tab.enchantCount:SetText(L.AMR_SUMMARYTAB_ENCHANTS_TO_GO) adam@0: tab.enchantCount:Hide() adam@0: adam@0: tab.instructions = tab:CreateFontString(nil, "ARTWORK", "GameFontWhite") adam@17: tab.instructions:SetPoint("TOPLEFT", tab.enchantCount, "BOTTOMLEFT", 0, -15) yellowfive@11: tab.instructions:SetText(L.AMR_SUMMARYTAB_VIEW_TABS) yellowfive@49: tab.instructions:SetPoint("RIGHT", -20, 0) yellowfive@49: tab.instructions:SetWidth(tab.instructions:GetWidth()) yellowfive@49: tab.instructions:SetWordWrap(true) yellowfive@49: tab.instructions:SetJustifyH("LEFT") adam@0: tab.instructions:Hide() adam@0: adam@0: return tab adam@0: end adam@0: adam@0: function AskMrRobot.SummaryTab:getSpecIcon(specId) adam@0: for i = 1, GetNumSpecializations() do adam@0: local id, _, _, icon = GetSpecializationInfo(i) adam@0: if id == specId then adam@0: return icon adam@0: end adam@0: end adam@0: return nil adam@0: end adam@0: adam@0: function AskMrRobot.SummaryTab:showBadItems() adam@0: local i = 2 adam@0: adam@17: -- for all slots adam@17: for iSlot = 1, #AskMrRobot.slotIds do adam@17: local slotId = AskMrRobot.slotIds[iSlot] adam@17: local badItem = AskMrRobot.ComparisonResult.items[slotId] adam@17: if badItem ~= nil and not badItem.needsUpgrade then adam@17: self.badItemSlots[i]:SetText(AskMrRobot.slotDisplayText[slotId]) adam@0: self.badItemSlots[i]:Show() adam@0: if badItem.optimized then yellowfive@31: self.badItemNames[i]:SetItem(badItem.optimized) adam@0: else yellowfive@31: self.badItemNames[i]:SetItem(nil) adam@0: end adam@0: self.badItemNames[i]:Show() adam@0: i = i + 1 adam@0: end adam@0: end adam@0: adam@0: -- for all the upgrade items adam@0: local j = 1 adam@17: for iSlot = 1, #AskMrRobot.slotIds do adam@17: local slotId = AskMrRobot.slotIds[iSlot] adam@17: local badItem = AskMrRobot.ComparisonResult.items[slotId] adam@17: if badItem ~= nil and badItem.needsUpgrade then adam@17: self.upgradeItemSlots[j]:SetText(AskMrRobot.slotDisplayText[slotId]) adam@0: self.upgradeItemSlots[j]:Show() adam@0: if badItem.optimized then yellowfive@31: self.upgradeItemNames[j]:SetItem(badItem) adam@0: else yellowfive@31: self.upgradeItemNames[j]:SetItem(nil) adam@0: end adam@0: self.upgradeItemNames[j]:Show() adam@0: j = j + 1 adam@0: end adam@0: end adam@0: adam@0: -- hide / show the headers adam@0: if i == 2 and j == 1 then adam@0: self.badItemSlots[1]:Hide() adam@0: self.badItemNames[1]:Hide() adam@0: self:showImportError(nil) adam@0: self.importInfo:Show() adam@0: self.specIcon:Show() adam@0: self.optimizationSummary:Show() adam@0: self.gemCount:Show() adam@0: self.enchantCount:Show() adam@0: self.instructions:Show() adam@0: self.specText:Show() adam@0: adam@0: local gemCount = 0 adam@17: for slotNum, badGems in pairs(AskMrRobot.ComparisonResult.gems) do adam@17: --for k, v in pairs(badGems.badGems) do adam@17: --gemCount = gemCount + 1 adam@17: --end adam@17: for g = 1, 3 do adam@17: if not AskMrRobot.AreGemsCompatible(badGems.current[g], badGems.optimized[g]) then adam@17: gemCount = gemCount + 1 adam@17: end adam@0: end adam@0: end adam@0: yellowfive@11: self.gemCount:SetFormattedText(L.AMR_SUMMARYTAB_GEMCOUNT, gemCount) adam@0: adam@0: local enchantCount = 0 adam@17: for slotNum, badEnchant in pairs(AskMrRobot.ComparisonResult.enchants) do adam@0: enchantCount = enchantCount + 1 adam@0: end adam@0: yellowfive@11: self.enchantCount:SetFormattedText(L.AMR_SUMMARYTAB_ENCHANTCOUNT, enchantCount) adam@0: adam@17: self.optimizationSummary:SetFormattedText(L.AMR_SUMMARYTAB_OPTIMIZATIONCOUNT, gemCount + enchantCount) adam@0: adam@17: if gemCount + enchantCount == 0 then adam@0: self.stamp:Show() adam@0: self.optimizationSummary:Hide() adam@0: self.enchantCount:Hide() adam@0: self.instructions:Hide() adam@0: self.gemCount:Hide() adam@0: else adam@0: self.stamp:Hide() adam@0: self.optimizationSummary:Show() adam@0: self.enchantCount:Show() adam@0: self.instructions:Show() adam@0: self.gemCount:Show() adam@0: end adam@0: adam@0: local activeSpecGroup = GetActiveSpecGroup() adam@0: adam@0: if activeSpecGroup == nil then adam@17: self.importInfo:SetFormattedText(L.AMR_SUMMARYTAB_LAST_IMPORT_1, AmrDb.LastCharacterImportDate, UnitName("player")) adam@0: else adam@17: self.importInfo:SetFormattedText(L.AMR_SUMMARYTAB_LAST_IMPORT_2, AmrDb.LastCharacterImportDate, UnitName("player")) adam@0: local spec = GetSpecialization(false, false, group); adam@0: if spec then adam@0: local _, name, _, icon = GetSpecializationInfo(spec); adam@0: if activeSpecGroup == 1 then yellowfive@11: self.specText:SetFormattedText(L.AMR_SUMMARYTAB_LAST_IMPORT_PSPEC, name) adam@0: else yellowfive@11: self.specText:SetFormattedText(L.AMR_SUMMARYTAB_LAST_IMPORT_SSPEC, name) adam@0: end adam@0: self.specIcon:SetTexture(icon) adam@0: end adam@0: end adam@0: adam@0: adam@0: --local currentSpec = GetAmrSpecialization(GetActiveSpecGroup()) adam@0: --return (not currentSpec and not spec) or tostring(currentSpec) == spec adam@0: else adam@0: self.importInfo:Hide() adam@0: self.specIcon:Hide() adam@0: self.optimizationSummary:Hide() adam@0: self.gemCount:Hide() adam@0: self.enchantCount:Hide() adam@0: self.instructions:Hide() adam@0: self.specText:Hide() adam@0: end adam@0: adam@0: if i == 2 then adam@0: self.badItemSlots[1]:Hide() adam@0: self.badItemNames[1]:Hide() adam@0: else adam@0: self.badItemSlots[1]:Show() adam@0: self.badItemNames[1]:Show() adam@0: local warnings = {} adam@0: if self.badRealm then yellowfive@11: tinsert(warnings, L.AMR_SUMMARYTAB_DIFF_REALM:format(self.badRealm)) adam@0: end adam@0: if self.badTalents then yellowfive@11: tinsert(warnings, L.AMR_SUMMARYTAB_DIFF_TALENT) adam@0: end adam@0: if self.badGlyphs then yellowfive@11: tinsert(warnings, L.AMR_SUMMARYTAB_DIFF_GLYPHS) adam@0: end yellowfive@11: local message = L.AMR_SUMMARYTAB_DIFF_GEAR adam@0: if #warnings > 0 then yellowfive@11: message = message .. " (".. L.AMR_SUMMARYTAB_DIFF_AND.." " adam@0: for k = 1, #warnings do adam@0: if k > 1 then adam@0: message = message .. ', ' adam@0: end adam@0: message = message .. warnings[k] adam@0: end adam@0: message = message .. ")" adam@0: end yellowfive@11: message = message .. L.AMR_SUMMARYTAB_DIFF_PLEASE_EQ yellowfive@11: self:showImportWarning(L.AMR_SUMMARYTAB_DIFF_CHECK_CHAR, message) adam@0: end adam@0: adam@0: if j == 1 then adam@0: self.upgradeItemHeader:Hide() adam@0: self.upgradeSlotHeader:Hide() adam@0: self.upgradeInstructions:Hide() adam@0: else adam@0: if i == 2 then adam@0: local warnings = {} adam@0: if self.badRealm then yellowfive@11: tinsert(warnings, L.AMR_SUMMARYTAB_DIFF_REALM:format(self.badRealm)) adam@0: end adam@0: if self.badTalents then yellowfive@11: tinsert(warnings, L.AMR_SUMMARYTAB_DIFF_TALENT) adam@0: end adam@0: if self.badGlyphs then yellowfive@11: tinsert(warnings, L.AMR_SUMMARYTAB_DIFF_GLYPHS) adam@0: end adam@0: local message = nil adam@0: if #warnings > 0 then yellowfive@11: message = L.AMR_SUMMARYTAB_DIFF_OPTIMIZED_FOR adam@0: for k = 1, #warnings do adam@0: if k > 1 then adam@0: message = message .. ', ' adam@0: end adam@0: message = message .. warnings[k] adam@0: end adam@0: message = message .. "." adam@0: end yellowfive@11: self:showImportWarning(L.AMR_SUMMARYTAB_DIFF_CHECK_CHAR, message) adam@0: end adam@0: self.upgradeItemHeader:Show() adam@0: self.upgradeSlotHeader:Show() adam@0: self.upgradeInstructions:Show() adam@0: if i == 2 then adam@0: self.upgradeInstructions:SetPoint("TOP", self.badItemSlots[1], "TOP", 0, 0) adam@0: self.errorText2:Hide() adam@0: else adam@0: self.upgradeInstructions:SetPoint("TOP", self.badItemSlots[i], "BOTTOM", 0, -20) adam@0: end adam@0: end adam@0: adam@0: -- hide the remaining slots adam@0: while i <= #self.badItemSlots do adam@0: self.badItemSlots[i]:Hide() adam@0: self.badItemNames[i]:Hide() adam@0: i = i + 1 adam@0: end adam@0: adam@0: -- hide the remaining slots adam@0: while j <= #self.upgradeItemSlots do adam@0: self.upgradeItemSlots[j]:Hide() adam@0: self.upgradeItemNames[j]:Hide() adam@0: j = j + 1 adam@0: end adam@0: end adam@0: adam@0: adam@0: function AskMrRobot.SummaryTab:showImportError(text, text2) adam@0: self.stamp:Hide() adam@0: self.gemCount:Hide() adam@0: self.instructions:Hide() adam@0: self.enchantCount:Hide() adam@0: self.optimizationSummary:Hide() adam@0: if text then adam@0: self.errorText1:Show() yellowfive@11: self.errorText1:SetText(L.AMR_SUMMARYTAB_IMPORT_NOT_WORK:format(text)) adam@0: self.errorText1:Show() adam@0: self.errorText2:SetText(text2) adam@0: self.errorText2:Show() adam@0: self.importInfo:Hide() adam@0: self.upgradeSlotHeader:Hide() adam@0: self.upgradeItemHeader:Hide() adam@0: self.upgradeInstructions:Hide() adam@0: self.specIcon:Hide() adam@0: self.specText:Hide() adam@0: else adam@0: self.errorText1:Hide() adam@0: self.errorText2:Hide() adam@0: self.importInfo:Show() adam@0: end adam@17: for i = 1, #self.badItemSlots do adam@0: self.badItemSlots[i]:Hide() adam@0: self.badItemNames[i]:Hide() adam@0: end adam@17: for i = 1, #self.upgradeItemSlots do adam@0: self.upgradeItemSlots[i]:Hide() adam@0: self.upgradeItemNames[i]:Hide() adam@0: end adam@0: end adam@0: adam@0: function AskMrRobot.SummaryTab:showImportWarning (text, text2) adam@0: self.stamp:Hide() adam@0: self.hasImportError = false adam@0: self.gemCount:Hide() adam@0: self.instructions:Hide() adam@0: self.enchantCount:Hide() adam@0: self.specIcon:Hide() adam@0: self.specText:Hide() adam@0: self.optimizationSummary:Hide() adam@0: if text then adam@0: self.errorText1:SetText(text) adam@0: self.errorText1:Show() adam@0: self.errorText2:SetText(text2) adam@0: self.errorText2:Show() adam@0: else adam@0: self.errorText1:Hide() adam@0: self.errorText2:Hide() adam@0: end adam@0: end