Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ls- committed Mar 25, 2024
2 parents a05ecac + f6748c9 commit cc40ceb
Show file tree
Hide file tree
Showing 12 changed files with 164 additions and 58 deletions.
8 changes: 7 additions & 1 deletion .luacheckrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
std = "none"
max_line_length = false
max_comment_line_length = 120
max_comment_line_length = 100
self = false

exclude_files = {
Expand All @@ -26,12 +26,17 @@ globals = {
-- Lua
"getfenv",
"print",

-- FrameXML
"SlashCmdList",
}

read_globals = {
"AddonCompartmentFrame",
"BattlePetTooltip",
"BattlePetToolTip_ShowLink",
"C_AddOns",
"ChatFontNormal",
"ChatFrame1",
"ChatFrame2",
"ChatFrameChannelButton",
Expand All @@ -42,6 +47,7 @@ read_globals = {
"CreateFrame",
"CreateObjectPool",
"DEFAULT_TAB_SELECTED_COLOR_TABLE",
"GameFontNormalSmall",
"GameTooltip",
"GeneralDockManager",
"GetLocale",
Expand Down
2 changes: 2 additions & 0 deletions .luacheckrc_build.ps1
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Set-Location $PSScriptRoot

$luacheckrc = ".\.luacheckrc"

$out = ""
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
Binary file added ls_Glass/assets/logo-32.TGA
Binary file not shown.
14 changes: 8 additions & 6 deletions ls_Glass/core/changelog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 :>
]]
4 changes: 4 additions & 0 deletions ls_Glass/core/components/fonts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
39 changes: 29 additions & 10 deletions ls_Glass/core/components/messageline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
22 changes: 12 additions & 10 deletions ls_Glass/core/components/slidingmessageframe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions ls_Glass/embeds/AceDB-3.0/AceDB-3.0.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
92 changes: 68 additions & 24 deletions ls_Glass/embeds/AceGUI-3.0/widgets/AceGUIWidget-ColorPicker.lua
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit cc40ceb

Please sign in to comment.