adam@0: local _, AskMrRobot = ... 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) adam@0: text:SetFormattedText("Summary") 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) adam@0: tab.errorText1:SetText("You have no optimizations imported.") 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") adam@0: tab.errorText2:SetText('Click the "Import" tab to 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 ) adam@0: itemText:SetText("Please upgrade the following items:") 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) adam@0: itemText:SetText("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) adam@0: itemText:SetText("Item Name") adam@0: itemText:SetJustifyH("LEFT") adam@0: itemText:Hide() adam@0: tab.upgradeItemHeader = itemText adam@0: adam@0: for i = 1, #AskMrRobot.slotNames 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@0: for i = 1, #AskMrRobot.slotNames 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") adam@0: tab.importInfo:SetText("Last import: ?\rThese optimizations are for ?") 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() adam@0: tab.stamp.smallText:SetText("Congratulations! You are 100% 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) adam@0: tab.optimizationSummary:SetText("You have ? optimizations to make:") 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) adam@0: tab.gemCount:SetText("? gems") 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) adam@0: tab.enchantCount:SetText("? enchants") adam@0: tab.enchantCount:Hide() adam@0: adam@0: tab.reforgeCount = tab:CreateFontString(nil, "ARTWORK", "GameFontWhite") adam@0: tab.reforgeCount:SetPoint("TOPLEFT", tab.enchantCount, "BOTTOMLEFT", 0, -5) adam@0: tab.reforgeCount:SetText("? reforges") adam@0: tab.reforgeCount:Hide() adam@0: adam@0: tab.instructions = tab:CreateFontString(nil, "ARTWORK", "GameFontWhite") adam@0: tab.instructions:SetPoint("TOPLEFT", tab.reforgeCount, "BOTTOMLEFT", 0, -15) adam@0: tab.instructions:SetText("View the Gem, Enchant and Reforge tabs for suggested optimizations.") 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 badItems = AskMrRobot.itemDiffs.items adam@0: adam@0: local i = 2 adam@0: adam@0: -- for all the bad items adam@0: for slotNum, badItem in AskMrRobot.sortSlots(badItems) do adam@0: if not badItem.needsUpgrade then adam@0: self.badItemSlots[i]:SetText(_G[strupper(AskMrRobot.slotNames[slotNum])]) adam@0: self.badItemSlots[i]:Show() adam@0: if badItem.optimized then adam@0: self.badItemNames[i]:SetItemId(badItem.optimized.itemId, badItem.optimized.upgradeId, badItem.optimized.suffixId) adam@0: else adam@0: self.badItemNames[i]:SetItemId(nil, 0, 0) 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@0: for slotNum, badItem in AskMrRobot.sortSlots(badItems) do adam@0: if badItem.needsUpgrade then adam@0: self.upgradeItemSlots[j]:SetText(_G[strupper(AskMrRobot.slotNames[slotNum])]) adam@0: self.upgradeItemSlots[j]:Show() adam@0: if badItem.optimized then adam@0: self.upgradeItemNames[j]:SetItemId(badItem.optimized.itemId, badItem.optimized.upgradeId, badItem.optimized.suffixId) adam@0: else adam@0: self.upgradeItemNames[j]:SetItemId(nil, 0, 0) 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.reforgeCount:Show() adam@0: self.instructions:Show() adam@0: self.specText:Show() adam@0: adam@0: local gemCount = 0 adam@0: for slotNum, badGems in pairs(AskMrRobot.itemDiffs.gems) do adam@0: for k, v in pairs(badGems.badGems) do adam@0: gemCount = gemCount + 1 adam@0: end adam@0: end adam@0: adam@0: self.gemCount:SetFormattedText("%d \1244gem:gems;", gemCount) adam@0: adam@0: local enchantCount = 0 adam@0: for slotNum, badEnchant in pairs(AskMrRobot.itemDiffs.enchants) do adam@0: enchantCount = enchantCount + 1 adam@0: end adam@0: adam@0: self.enchantCount:SetFormattedText("%d \1244enchant:enchants;", enchantCount) adam@0: adam@0: local reforgeCount = 0 adam@0: for slotNum, badReforge in pairs(AskMrRobot.itemDiffs.reforges) do adam@0: reforgeCount = reforgeCount + 1 adam@0: end adam@0: adam@0: self.reforgeCount:SetFormattedText("%d \1244reforge:reforges;", reforgeCount) adam@0: self.optimizationSummary:SetFormattedText("You have %d \1244optimization:optimizations; to make:", gemCount + enchantCount + reforgeCount) adam@0: adam@0: if gemCount + enchantCount + reforgeCount == 0 then adam@0: self.stamp:Show() adam@0: self.optimizationSummary:Hide() adam@0: self.enchantCount:Hide() adam@0: self.reforgeCount: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.reforgeCount: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@0: self.importInfo:SetFormattedText("Last import: %s\rThese optimizations are for %s", self.importDate, UnitName("player")) adam@0: else adam@0: self.importInfo:SetFormattedText("Last import: %s\rThese optimizations are for %s's...", self.importDate, 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 adam@0: self.specText:SetFormattedText("Primary Spec - %s", name) adam@0: else adam@0: self.specText:SetFormattedText("Secondary Spec - %s", 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.reforgeCount: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 adam@0: tinsert(warnings, "a different realm: " .. self.badRealm) adam@0: end adam@0: if self.badTalents then adam@0: tinsert(warnings, "different talents") adam@0: end adam@0: if self.badGlyphs then adam@0: tinsert(warnings, "different glyphs") adam@0: end adam@0: local message = "Mr. Robot optimized a different set of gear" adam@0: if #warnings > 0 then adam@0: message = message .. " (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 adam@0: message = message .. ". Please equip the following items before proceeding with the optimizations." adam@0: self:showImportWarning("WARNING: Please check your character before proceeding:", 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 adam@0: tinsert(warnings, "a different realm: " .. self.badRealm) adam@0: end adam@0: if self.badTalents then adam@0: tinsert(warnings, "different talents") adam@0: end adam@0: if self.badGlyphs then adam@0: tinsert(warnings, "different glyphs") adam@0: end adam@0: local message = nil adam@0: if #warnings > 0 then adam@0: message = "Mr. Robot 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 adam@0: self:showImportWarning("WARNING: Please check your character before proceeding:", 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.reforgeCount:Hide() adam@0: self.enchantCount:Hide() adam@0: self.optimizationSummary:Hide() adam@0: if text then adam@0: self.errorText1:Show() adam@0: self.errorText1:SetText('Error! Your import did not work:|n|n' .. 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@0: for i = 1, #AskMrRobot.slotNames + 1 do adam@0: self.badItemSlots[i]:Hide() adam@0: self.badItemNames[i]:Hide() adam@0: end adam@0: for i = 1, #AskMrRobot.slotNames 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.reforgeCount: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