diff --git a/.luacheckrc b/.luacheckrc index 0a82e86..9b41255 100755 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,6 +1,6 @@ std = "none" max_line_length = false -max_comment_line_length = 120 +max_comment_line_length = 100 self = false exclude_files = { @@ -26,12 +26,17 @@ globals = { -- Lua "getfenv", "print", + + -- FrameXML + "SlashCmdList", } read_globals = { + "AddonCompartmentFrame", "BattlePetTooltip", "BattlePetToolTip_ShowLink", "C_AddOns", + "ChatFontNormal", "ChatFrame1", "ChatFrame2", "ChatFrameChannelButton", @@ -42,6 +47,7 @@ read_globals = { "CreateFrame", "CreateObjectPool", "DEFAULT_TAB_SELECTED_COLOR_TABLE", + "GameFontNormalSmall", "GameTooltip", "GeneralDockManager", "GetLocale", diff --git a/.luacheckrc_build.ps1 b/.luacheckrc_build.ps1 index e256aca..36eaa1d 100644 --- a/.luacheckrc_build.ps1 +++ b/.luacheckrc_build.ps1 @@ -1,3 +1,5 @@ +Set-Location $PSScriptRoot + $luacheckrc = ".\.luacheckrc" $out = "" diff --git a/CHANGELOG.md b/CHANGELOG.md index 94fc9f5..3481a74 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # CHANGELOG +## Version 100206.01 + +- Added 10.2.6 support. +- Fixed an issue where the chat frame would disappear after it's previously hidden. +- Fixed an issue where some messages would appear truncated. +- Fixed an issue where some characters would appear as squares. The addon now properly mimics the default chat's + behaviour which also includes all the bugs that come with it. For instance, depending on the alphabet those characters + belong to, those messages will completely ignore various chat settings like font size, outline, etc. It is this way + due to limitation on Blizz end. +- Set minimal Y padding to 0. Yes, no more gaps in the TomCats' messages :> + ## Version 100105.01 - Added 10.1.5 support. diff --git a/ls_Glass/assets/logo-32.TGA b/ls_Glass/assets/logo-32.TGA new file mode 100644 index 0000000..1d10f75 Binary files /dev/null and b/ls_Glass/assets/logo-32.TGA differ diff --git a/ls_Glass/core/changelog.lua b/ls_Glass/core/changelog.lua index 8aa072c..6878eec 100644 --- a/ls_Glass/core/changelog.lua +++ b/ls_Glass/core/changelog.lua @@ -6,10 +6,12 @@ local _G = getfenv(0) -- Mine E.CHANGELOG = [[ -- Added 10.1.5 support. - -### Known Issues - -I'm still in the process of rewriting the addon, so for the time being I'm not fixing any bugs. It takes time because -real life keeps getting in the way. +- Added 10.2.6 support. +- Fixed an issue where the chat frame would disappear after it's previously hidden. +- Fixed an issue where some messages would appear truncated. +- Fixed an issue where some characters would appear as squares. The addon now properly mimics the default chat's + behaviour which also includes all the bugs that come with it. For instance, depending on the alphabet those characters + belong to, those messages will completely ignore various chat settings like font size, outline, etc. It is this way + due to limitation on Blizz end. +- Set minimal Y padding to 0. Yes, no more gaps in the TomCats' messages :> ]] diff --git a/ls_Glass/core/components/fonts.lua b/ls_Glass/core/components/fonts.lua index 2c87be9..f8af1d0 100644 --- a/ls_Glass/core/components/fonts.lua +++ b/ls_Glass/core/components/fonts.lua @@ -9,6 +9,8 @@ local LSM = LibStub("LibSharedMedia-3.0") function E:CreateFonts() local messageFont = CreateFont("LSGlassMessageFont") + messageFont:CopyFontObject(ChatFontNormal) + messageFont:SetFont( LSM:Fetch("font", C.db.profile.font), C.db.profile.chat.font.size, @@ -38,6 +40,8 @@ function E:CreateFonts() messageFont:SetIndentedWordWrap(true) local editBoxFont = CreateFont("LSGlassEditBoxFont") + editBoxFont:CopyFontObject(GameFontNormalSmall) + editBoxFont:SetFont( LSM:Fetch("font", C.db.profile.font), -- ? Add a separate font? C.db.profile.dock.font.size, diff --git a/ls_Glass/core/components/messageline.lua b/ls_Glass/core/components/messageline.lua index 1f1a446..f84d7bc 100644 --- a/ls_Glass/core/components/messageline.lua +++ b/ls_Glass/core/components/messageline.lua @@ -19,6 +19,15 @@ do self.Text:SetTextColor(r or 1, g or 1, b or 1, a) self:SetHeight(self.Text:GetStringHeight() + C.db.profile.chat.y_padding * 2) + + -- realistically, it should be height == 0, but given how this API works, it could be + -- 0.00000001 for all I know, it happens when nil or "" messages are being rendered + local height = self.Text:GetStringHeight() + if height < 1 then + height = C.db.profile.chat.font.size + end + + self:SetHeight(height + C.db.profile.chat.y_padding * 2) end function message_line_proto:UpdateGradient() @@ -30,7 +39,7 @@ do end local function createMessageLine(parent) - local width = parent:GetWidth() + local width = E:Round(parent:GetWidth()) local frame = Mixin(CreateFrame("Frame", nil, parent, "LSGlassHyperlinkPropagator"), message_line_proto) frame:SetSize(width, C.db.profile.chat.font.size + C.db.profile.chat.y_padding * 2) @@ -40,8 +49,10 @@ local function createMessageLine(parent) E:CreateGradientBackground(frame, E:Round(width * 0.1), E:Round(width * 0.5), 0, 0, 0, C.db.profile.chat.alpha) frame.Text = frame:CreateFontString(nil, "ARTWORK", "LSGlassMessageFont") - frame.Text:SetPoint("LEFT", C.db.profile.chat.x_padding, 0) - frame.Text:SetPoint("RIGHT", -C.db.profile.chat.x_padding, 0) + frame.Text:SetPoint("LEFT", C.db.profile.chat.x_padding, -C.db.profile.chat.y_padding) + frame.Text:SetWidth(width - C.db.profile.chat.x_padding * 2) + frame.Text:SetIndentedWordWrap(true) + frame.Text:SetNonSpaceWrap(true) return frame end @@ -85,25 +96,33 @@ end function E:UpdateMessageLinesHeights() for _, pool in next, pools do for messageLine in pool:EnumerateActive() do - messageLine:SetHeight(messageLine.Text:GetStringHeight() + C.db.profile.chat.y_padding * 2) + local height = messageLine.Text:GetStringHeight() + if height < 1 then + height = C.db.profile.chat.font.size + end + + messageLine:SetHeight(height + C.db.profile.chat.y_padding * 2) end for _, messageLine in pool:EnumerateInactive() do - messageLine:SetHeight(messageLine.Text:GetStringHeight() + C.db.profile.chat.y_padding * 2) + local height = messageLine.Text:GetStringHeight() + if height < 1 then + height = C.db.profile.chat.font.size + end + + messageLine:SetHeight(height + C.db.profile.chat.y_padding * 2) end end end -function E:UpdateMessageLinesHorizPadding() +function E:UpdateMessageLinesPadding() for _, pool in next, pools do for messageLine in pool:EnumerateActive() do - messageLine.Text:SetPoint("LEFT", C.db.profile.chat.x_padding, 0) - messageLine.Text:SetPoint("RIGHT", -C.db.profile.chat.x_padding, 0) + messageLine.Text:SetPoint("LEFT", C.db.profile.chat.x_padding, -C.db.profile.chat.y_padding) end for _, messageLine in pool:EnumerateInactive() do - messageLine.Text:SetPoint("LEFT", C.db.profile.chat.x_padding, 0) - messageLine.Text:SetPoint("RIGHT", -C.db.profile.chat.x_padding, 0) + messageLine.Text:SetPoint("LEFT", C.db.profile.chat.x_padding, -C.db.profile.chat.y_padding) end end end diff --git a/ls_Glass/core/components/slidingmessageframe.lua b/ls_Glass/core/components/slidingmessageframe.lua index 7935ebb..8bb9b58 100644 --- a/ls_Glass/core/components/slidingmessageframe.lua +++ b/ls_Glass/core/components/slidingmessageframe.lua @@ -47,7 +47,7 @@ local function chatFrame_OnSizeChanged(self, width, height) end for _, messageLine in slidingFrame.messageFramePool:EnumerateInactive() do - messageLine:SetWidth(width) + messageLine:SetWidth(width - C.db.profile.chat.x_padding * 2) messageLine:SetGradientBackgroundSize(E:Round(width * 0.1), E:Round(width * 0.4)) end end @@ -58,15 +58,17 @@ local function chatFrame_OnSizeChanged(self, width, height) end end -local function chatFrame_ShowHook(self) - self.FontStringContainer:Hide() +local function chatFrame_SetShownHook(self, isShown) + if isShown then + self.FontStringContainer:Hide() - local slidingFrame = E:GetSlidingFrameForChatFrame(self) - if slidingFrame then - -- FCF indiscriminately calls :Show() when adding new tabs, I don't need to do - -- anything when that happens - if not slidingFrame:IsShown() then - slidingFrame:Show() + local slidingFrame = E:GetSlidingFrameForChatFrame(self) + if slidingFrame then + -- FCF indiscriminately calls :SetShown(true) when adding new tabs, I don't need to do + -- anything when that happens + if not slidingFrame:IsShown() then + slidingFrame:Show() + end end end end @@ -176,7 +178,7 @@ function object_proto:CaptureChatFrame(chatFrame) if not hookedChatFrames[chatFrame] then chatFrame:HookScript("OnSizeChanged", chatFrame_OnSizeChanged) - hooksecurefunc(chatFrame, "Show", chatFrame_ShowHook) + hooksecurefunc(chatFrame, "SetShown", chatFrame_SetShownHook) hooksecurefunc(chatFrame, "Hide", chatFrame_HideHook) -- it's more convenient than hooking chatFrame.historyBuffer:PushFront() diff --git a/ls_Glass/embeds/AceDB-3.0/AceDB-3.0.lua b/ls_Glass/embeds/AceDB-3.0/AceDB-3.0.lua index d2a5a94..e9c98c1 100644 --- a/ls_Glass/embeds/AceDB-3.0/AceDB-3.0.lua +++ b/ls_Glass/embeds/AceDB-3.0/AceDB-3.0.lua @@ -41,7 +41,7 @@ -- @class file -- @name AceDB-3.0.lua -- @release $Id$ -local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 28 +local ACEDB_MAJOR, ACEDB_MINOR = "AceDB-3.0", 29 local AceDB = LibStub:NewLibrary(ACEDB_MAJOR, ACEDB_MINOR) if not AceDB then return end -- No upgrade needed @@ -606,8 +606,8 @@ end -- profile. -- @param defaultProfile The profile name to use as the default function DBObjectLib:ResetDB(defaultProfile) - if defaultProfile and type(defaultProfile) ~= "string" then - error(("Usage: AceDBObject:ResetDB(defaultProfile): 'defaultProfile' - string or nil expected, got %q."):format(type(defaultProfile)), 2) + if defaultProfile and type(defaultProfile) ~= "string" and defaultProfile ~= true then + error(("Usage: AceDBObject:ResetDB(defaultProfile): 'defaultProfile' - string or true expected, got %q."):format(type(defaultProfile)), 2) end local sv = self.sv diff --git a/ls_Glass/embeds/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua b/ls_Glass/embeds/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua index d57b008..ec811d0 100644 --- a/ls_Glass/embeds/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua +++ b/ls_Glass/embeds/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua @@ -1,7 +1,7 @@ --[[----------------------------------------------------------------------------- ColorPicker Widget -------------------------------------------------------------------------------]] -local Type, Version = "ColorPicker", 25 +local Type, Version = "ColorPicker", 28 local AceGUI = LibStub and LibStub("AceGUI-3.0", true) if not AceGUI or (AceGUI:GetWidgetVersion(Type) or 0) >= Version then return end @@ -11,13 +11,24 @@ local pairs = pairs -- WoW APIs local CreateFrame, UIParent = CreateFrame, UIParent +-- Unfortunately we have no way to realistically detect if a client uses inverted alpha +-- as no API will tell you. Wrath uses the old colorpicker, era uses the new one, both are inverted +local INVERTED_ALPHA = (WOW_PROJECT_ID ~= WOW_PROJECT_MAINLINE) + --[[----------------------------------------------------------------------------- Support functions -------------------------------------------------------------------------------]] local function ColorCallback(self, r, g, b, a, isAlpha) + if INVERTED_ALPHA and a then + a = 1 - a + end if not self.HasAlpha then a = 1 end + -- no change, skip update + if r == self.r and g == self.g and b == self.b and a == self.a then + return + end self:SetColor(r, g, b, a) if ColorPickerFrame:IsVisible() then --colorpicker is still open @@ -50,30 +61,63 @@ local function ColorSwatch_OnClick(frame) ColorPickerFrame:SetFrameLevel(frame:GetFrameLevel() + 10) ColorPickerFrame:SetClampedToScreen(true) - ColorPickerFrame.func = function() - local r, g, b = ColorPickerFrame:GetColorRGB() - local a = 1 - OpacitySliderFrame:GetValue() - ColorCallback(self, r, g, b, a) - end - - ColorPickerFrame.hasOpacity = self.HasAlpha - ColorPickerFrame.opacityFunc = function() - local r, g, b = ColorPickerFrame:GetColorRGB() - local a = 1 - OpacitySliderFrame:GetValue() - ColorCallback(self, r, g, b, a, true) - end - - local r, g, b, a = self.r, self.g, self.b, self.a - if self.HasAlpha then - ColorPickerFrame.opacity = 1 - (a or 0) - end - ColorPickerFrame:SetColorRGB(r, g, b) - - ColorPickerFrame.cancelFunc = function() - ColorCallback(self, r, g, b, a, true) + if ColorPickerFrame.SetupColorPickerAndShow then -- 10.2.5 color picker overhaul + local r2, g2, b2, a2 = self.r, self.g, self.b, (self.a or 1) + if INVERTED_ALPHA then + a2 = 1 - a2 + end + + local info = { + swatchFunc = function() + local r, g, b = ColorPickerFrame:GetColorRGB() + local a = ColorPickerFrame:GetColorAlpha() + ColorCallback(self, r, g, b, a) + end, + + hasOpacity = self.HasAlpha, + opacityFunc = function() + local r, g, b = ColorPickerFrame:GetColorRGB() + local a = ColorPickerFrame:GetColorAlpha() + ColorCallback(self, r, g, b, a, true) + end, + opacity = a2, + + cancelFunc = function() + ColorCallback(self, r2, g2, b2, a2, true) + end, + + r = r2, + g = g2, + b = b2, + } + + ColorPickerFrame:SetupColorPickerAndShow(info) + else + ColorPickerFrame.func = function() + local r, g, b = ColorPickerFrame:GetColorRGB() + local a = OpacitySliderFrame:GetValue() + ColorCallback(self, r, g, b, a) + end + + ColorPickerFrame.hasOpacity = self.HasAlpha + ColorPickerFrame.opacityFunc = function() + local r, g, b = ColorPickerFrame:GetColorRGB() + local a = OpacitySliderFrame:GetValue() + ColorCallback(self, r, g, b, a, true) + end + + local r, g, b, a = self.r, self.g, self.b, 1 - (self.a or 1) + if self.HasAlpha then + ColorPickerFrame.opacity = a + end + ColorPickerFrame:SetColorRGB(r, g, b) + + ColorPickerFrame.cancelFunc = function() + ColorCallback(self, r, g, b, a, true) + end + + ColorPickerFrame:Show() end - - ColorPickerFrame:Show() end AceGUI:ClearFocus() end diff --git a/ls_Glass/init.lua b/ls_Glass/init.lua index aca8917..935d893 100644 --- a/ls_Glass/init.lua +++ b/ls_Glass/init.lua @@ -81,6 +81,8 @@ function E:OnInitialize() E:UpdateMessageFont() E:UpdateEditBoxFont() + E:UpdateMessageLinesHeights() + E:UpdateMessageLinesPadding() end }, spacer2 = { @@ -122,7 +124,7 @@ function E:OnInitialize() if C.db.profile.chat.x_padding ~= value then C.db.profile.chat.x_padding = value - E:UpdateMessageLinesHorizPadding() + E:UpdateMessageLinesPadding() end end, }, @@ -130,12 +132,13 @@ function E:OnInitialize() order = 3, type = "range", name = L["Y_PADDING"], - min = 1, max = 10, step = 1, + min = 0, max = 10, step = 1, set = function(_, value) if C.db.profile.chat.y_padding ~= value then C.db.profile.chat.y_padding = value E:UpdateMessageLinesHeights() + E:UpdateMessageLinesPadding() end end, }, @@ -547,6 +550,18 @@ function E:OnInitialize() Settings.RegisterAddOnCategory(Settings.RegisterCanvasLayoutCategory(panel, L["LS_GLASS"])) + AddonCompartmentFrame:RegisterAddon({ + text = L["LS_GLASS"], + icon = "Interface\\AddOns\\ls_Glass\\assets\\logo-32", + notCheckable = true, + registerForAnyClick = true, + func = function() + if not InCombatLockdown() then + LibStub("AceConfigDialog-3.0"):Open(addonName) + end + end, + }) + SLASH_LSGLASS1 = "/lsglass" SLASH_LSGLASS2 = "/lsg" SlashCmdList["LSGLASS"] = function(msg) @@ -619,6 +634,7 @@ function E:OnEnable() expectedChatFrames[chatType] = {} end + -- the PET_BATTLE_COMBAT_LOG chatType doesn't have chatTarget if chatTarget then expectedChatFrames[chatType][chatTarget] = chatFrame else diff --git a/ls_Glass/ls_Glass.toc b/ls_Glass/ls_Glass.toc index 3486580..61f1d35 100644 --- a/ls_Glass/ls_Glass.toc +++ b/ls_Glass/ls_Glass.toc @@ -1,6 +1,6 @@ -## Interface: 100105 +## Interface: 100206 ## Author: lightspark -## Version: 100105.01 +## Version: 100206.01 ## Title: LS: |cffe0bc5bGlass|r ## Notes: Smooth as glass.