@@ -20,6 +20,8 @@ ACHIEVEMENTUI_PROGRESSIVEWIDTH = 42; ACHIEVEMENTUI_MAX_SUMMARY_ACHIEVEMENTS = 4; ACHIEVEMENTUI_MAXCONTENTWIDTH = 330; +local ACHIEVEMENTUI_FONTHEIGHT; -- set in AchievementButton_OnLoad +local ACHIEVEMENTUI_MAX_LINES_COLLAPSED = 3; -- can show 3 lines of text when achievement is collapsed ACHIEVEMENTUI_DEFAULTSUMMARYACHIEVEMENTS = {6, 503, 116, 545, 1017}; @@ -437,7 +439,7 @@ function AchievementFrameCategories_Upd end for _, button in next, AchievementFrameCategoriesContainer.buttons do - if ( MouseIsOver(button) and button.showTooltipFunc ) then + if ( button:IsMouseOver() and button.showTooltipFunc ) then button:showTooltipFunc(); break; end @@ -653,6 +655,7 @@ function AchievementFrameAchievements_O local button = AchievementFrameAchievementsObjectives:GetParent(); AchievementFrameAchievementsObjectives.id = nil; AchievementButton_DisplayObjectives(button, id, button.completed); + AchievementFrameAchievements_Update(); else AchievementFrameAchievementsObjectives.id = nil; -- Force redraw end @@ -747,13 +750,15 @@ function AchievementFrameAchievements_C AchievementButton_ResetObjectives(); for _, button in next, AchievementFrameAchievements.buttons do button:Collapse(); - if ( not MouseIsOver(button) ) then + if ( not button:IsMouseOver() ) then button.highlight:Hide(); end button.selected = nil; if ( not button.tracked:GetChecked() ) then button.tracked:Hide(); end + button.description:Show(); + button.hiddenDescription:Hide(); end AchievementFrameAchievements.selection = nil; @@ -904,7 +909,6 @@ end function AchievementButton_OnLoad (self) local name = self:GetName(); - self.label = _G[name .. "Label"]; self.description = _G[name .. "Description"]; self.hiddenDescription = _G[name .. "HiddenDescription"]; @@ -921,6 +925,13 @@ function AchievementButton_OnLoad (self self.dateCompleted:ClearAllPoints(); self.dateCompleted:SetPoint("TOP", self.shield, "BOTTOM", -3, 6); + if ( not ACHIEVEMENTUI_FONTHEIGHT ) then + local _, fontHeight = self.description:GetFont(); + ACHIEVEMENTUI_FONTHEIGHT = fontHeight; + end + self.description:SetHeight(ACHIEVEMENTUI_FONTHEIGHT * ACHIEVEMENTUI_MAX_LINES_COLLAPSED); + self.description:SetWidth(ACHIEVEMENTUI_MAXCONTENTWIDTH); + self.hiddenDescription:SetWidth(ACHIEVEMENTUI_MAXCONTENTWIDTH); self:SetBackdropBorderColor(ACHIEVEMENTUI_REDBORDER_R, ACHIEVEMENTUI_REDBORDER_G, ACHIEVEMENTUI_REDBORDER_B, ACHIEVEMENTUI_REDBORDER_A); self.Collapse = AchievementButton_Collapse; @@ -950,7 +961,7 @@ function AchievementButton_OnClick (sel end if ( self.selected ) then - if ( not MouseIsOver(self) ) then + if ( not self:IsMouseOver() ) then self.highlight:Hide(); end AchievementFrameAchievements_ClearSelection() @@ -978,10 +989,7 @@ function AchievementButton_ToggleTracki local count = GetNumTrackedAchievements(); - if ( WatchFrame_GetRemainingSpace() < WatchFrame_GetHeightNeededForAchievement(id) ) then - UIErrorsFrame:AddMessage(OBJECTIVES_WATCH_TOO_MANY, 1.0, 0.1, 0.1, 1.0); - return - elseif ( count >= WATCHFRAME_MAXACHIEVEMENTS ) then + if ( count >= WATCHFRAME_MAXACHIEVEMENTS ) then UIErrorsFrame:AddMessage(format(ACHIEVEMENT_WATCH_TOO_MANY, WATCHFRAME_MAXACHIEVEMENTS), 1.0, 0.1, 0.1, 1.0); return; end @@ -1028,15 +1036,9 @@ function AchievementButton_DisplayAchie else button.shield.icon:SetTexture([[Interface\AchievementFrame\UI-Achievement-Shields-NoPoints]]); end - button.description:SetText(description); button.hiddenDescription:SetText(description); - if ( button.hiddenDescription:GetWidth() > ACHIEVEMENTUI_MAXCONTENTWIDTH ) then - button.description:SetWidth(ACHIEVEMENTUI_MAXCONTENTWIDTH); - else - button.description:SetWidth(0); - end - + button.numLines = ceil(button.hiddenDescription:GetHeight() / ACHIEVEMENTUI_FONTHEIGHT); button.icon.texture:SetTexture(icon); if ( completed and not button.completed ) then button.completed = true; @@ -1097,10 +1099,12 @@ function AchievementButton_DisplayAchie end elseif ( button.selected ) then button.selected = nil; - if ( not MouseIsOver(button) ) then + if ( not button:IsMouseOver() ) then button.highlight:Hide(); end button:Collapse(); + button.description:Show(); + button.hiddenDescription:Hide(); end return id; @@ -1130,13 +1134,13 @@ function AchievementButton_DisplayObjec local ACHIEVEMENTMODE_CRITERIA = 1; if ( objectives.mode == ACHIEVEMENTMODE_CRITERIA ) then if ( objectives:GetHeight() > 0 ) then - objectives:SetPoint("TOP", "$parentDescription", "BOTTOM", 0, -8); + objectives:SetPoint("TOP", "$parentHiddenDescription", "BOTTOM", 0, -8); objectives:SetPoint("LEFT", "$parentIcon", "RIGHT", -5, 0); objectives:SetPoint("RIGHT", "$parentShield", "LEFT", -10, 0); end height = ACHIEVEMENTBUTTON_COLLAPSEDHEIGHT + objectives:GetHeight(); else - objectives:SetPoint("TOP", "$parentDescription", "BOTTOM", 0, -8); + objectives:SetPoint("TOP", "$parentHiddenDescription", "BOTTOM", 0, -8); height = ACHIEVEMENTBUTTON_COLLAPSEDHEIGHT + objectives:GetHeight(); end elseif ( completed and GetPreviousAchievement(id) ) then @@ -1146,7 +1150,7 @@ function AchievementButton_DisplayObjec AchievementButton_ResetMiniAchievements(); AchievementButton_ResetMetas(); AchievementObjectives_DisplayProgressiveAchievement(objectives, id); - objectives:SetPoint("TOP", "$parentDescription", "BOTTOM", 0, -8); + objectives:SetPoint("TOP", "$parentHiddenDescription", "BOTTOM", 0, -8); height = ACHIEVEMENTBUTTON_COLLAPSEDHEIGHT + objectives:GetHeight(); else objectives:SetHeight(0); @@ -1156,19 +1160,21 @@ function AchievementButton_DisplayObjec AchievementButton_ResetMetas(); AchievementObjectives_DisplayCriteria(objectives, id); if ( objectives:GetHeight() > 0 ) then - objectives:SetPoint("TOP", "$parentDescription", "BOTTOM", 0, -8); + objectives:SetPoint("TOP", "$parentHiddenDescription", "BOTTOM", 0, -8); objectives:SetPoint("LEFT", "$parentIcon", "RIGHT", -5, -25); objectives:SetPoint("RIGHT", "$parentShield", "LEFT", -10, 0); end height = ACHIEVEMENTBUTTON_COLLAPSEDHEIGHT + objectives:GetHeight(); end - if ( height ~= ACHIEVEMENTBUTTON_COLLAPSEDHEIGHT ) then - local descriptionHeight = button.description:GetHeight(); + if ( height ~= ACHIEVEMENTBUTTON_COLLAPSEDHEIGHT or button.numLines > ACHIEVEMENTUI_MAX_LINES_COLLAPSED ) then + button.hiddenDescription:Show(); + button.description:Hide(); + local descriptionHeight = button.hiddenDescription:GetHeight(); height = height + descriptionHeight - ACHIEVEMENTBUTTON_DESCRIPTIONHEIGHT; if ( button.reward:IsShown() ) then height = height + 4; - end + end end objectives.id = id; @@ -2096,7 +2102,8 @@ function AchievementFrame_SelectAchieve if ( not shown ) then local _, maxVal = AchievementFrameCategoriesContainerScrollBar:GetMinMaxValues(); if ( AchievementFrameCategoriesContainerScrollBar:GetValue() == maxVal ) then - assert(false) + --assert(false) + return; else HybridScrollFrame_OnMouseWheel(AchievementFrameCategoriesContainer, -1); end @@ -2105,7 +2112,8 @@ function AchievementFrame_SelectAchieve -- Remove me if everything's working fine i = i + 1; if ( i > 100 ) then - assert(false); + --assert(false); + return; end end @@ -2134,7 +2142,8 @@ function AchievementFrame_SelectAchieve AchievementFrameAchievementsContainerScrollBar:SetValue(newHeight); else if ( AchievementFrameAchievementsContainerScrollBar:GetValue() == maxVal ) then - assert(false, "Failed to find achievement " .. id .. " while jumping!") + --assert(false, "Failed to find achievement " .. id .. " while jumping!") + return; else HybridScrollFrame_OnMouseWheel(AchievementFrameAchievementsContainer, -1); end @@ -2877,4 +2886,4 @@ function AchievementFrame_LoadTextures( _G[v.name]:SetTexture(v.file); end end -end +en \ No newline at end of fil