Skip to content

Commit

Permalink
Refactor editbox skinning
Browse files Browse the repository at this point in the history
  • Loading branch information
Kkthnx committed Sep 16, 2024
1 parent 9eb396d commit ecc90f1
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 125 deletions.
29 changes: 29 additions & 0 deletions KkthnxUI/Core/API.lua
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,31 @@ local function SkinCheckBox(self, forceSaturation)
self.forceSaturation = forceSaturation
end

local function SkinEditBox(frame, width, height)
frame:DisableDrawLayer("BACKGROUND")

frame:CreateBackdrop()

local frameName = frame.GetName and frame:GetName()
if frameName and (frameName:find("Gold") or frameName:find("Silver") or frameName:find("Copper")) then
if frameName:find("Gold") then
frame.KKUI_Backdrop:SetPoint("TOPLEFT", -3, 1)
frame.KKUI_Backdrop:SetPoint("BOTTOMRIGHT", -3, 0)
else
frame.KKUI_Backdrop:SetPoint("TOPLEFT", -3, 1)
frame.KKUI_Backdrop:SetPoint("BOTTOMRIGHT", -13, 0)
end
end

if width then
frame:SetWidth(width)
end

if height then
frame:SetHeight(height)
end
end

-- Hide Backdrop
local function HideBackdrop(self)
if self.NineSlice then
Expand Down Expand Up @@ -562,6 +587,10 @@ local function addapi(object)
mt.SkinCheckBox = SkinCheckBox
end

if not object.SkinEditBox then
mt.SkinEditBox = SkinEditBox
end

if not object.SkinScrollBar then
mt.SkinScrollBar = SkinScrollBar
end
Expand Down
2 changes: 1 addition & 1 deletion KkthnxUI/Modules/Automation/Elements/Screenshot.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local Screenshot = Screenshot
-- Achievement screenshot
local ScreenShotFrame

local function ScreenShotOnEvent(_, alreadyEarnedOnAccount)
local function ScreenShotOnEvent(alreadyEarnedOnAccount)
print(alreadyEarnedOnAccount)
if alreadyEarnedOnAccount then
return
Expand Down
194 changes: 70 additions & 124 deletions KkthnxUI/Modules/Skins/Blizzard/FrameXML/StaticPopup.lua
Original file line number Diff line number Diff line change
@@ -1,144 +1,90 @@
local K, C = KkthnxUI[1], KkthnxUI[2]
local r, g, b = K.r, K.g, K.b

local function colorMinimize(f)
if f:IsEnabled() then
f.minimize:SetVertexColor(r, g, b)
end
end

local function clearMinimize(f)
f.minimize:SetVertexColor(1, 1, 1)
end

local function updateMinorButtonState(button)
if button:GetChecked() then
button.bg:SetBackdropColor(1, 0.8, 0, 0.25)
else
button.bg:SetBackdropColor(0, 0, 0, 0.25)
end
end

tinsert(C.defaultThemes, function()
if not C["Skins"].BlizzardFrames then
return
end

for i = 1, 4 do
local frame = _G["StaticPopup" .. i]
local bu = _G["StaticPopup" .. i .. "ItemFrame"]
local icon = _G["StaticPopup" .. i .. "ItemFrameIconTexture"]
local close = _G["StaticPopup" .. i .. "CloseButton"]

local gold = _G["StaticPopup" .. i .. "MoneyInputFrameGold"]
local silver = _G["StaticPopup" .. i .. "MoneyInputFrameSilver"]
local copper = _G["StaticPopup" .. i .. "MoneyInputFrameCopper"]

_G["StaticPopup" .. i .. "ItemFrameNameFrame"]:Hide()

bu:SetNormalTexture(0)
bu:SetHighlightTexture(0)
bu:SetPushedTexture(0)
-- bu.bg = B.ReskinIcon(icon)
-- B.ReskinIconBorder(bu.IconBorder)

local bg = CreateFrame("Frame", nil, bu)
bg:SetPoint("TOPLEFT", bu.bg, "TOPRIGHT", 2, 0)
bg:SetPoint("BOTTOMRIGHT", bu.bg, 115, 0)
bg:SetFrameLevel(gold:GetFrameLevel())
bg:CreateBorder()

silver:SetPoint("LEFT", gold, "RIGHT", 1, 0)
copper:SetPoint("LEFT", silver, "RIGHT", 1, 0)

frame.Border:Hide()
frame:CreateBorder()
-- Helper function to skin popup buttons
local function SkinPopupButtons(popup)
for j = 1, 4 do
frame["button" .. j]:SkinButton()
local button = _G[popup .. "Button" .. j]
if button then
button:SkinButton()
end
end
frame.extraButton:SkinButton()
close:SkinCloseButton()

-- close.minimize = close:CreateTexture(nil, "OVERLAY")
-- close.minimize:SetSize(9, C.mult)
-- close.minimize:SetPoint("CENTER")
-- close.minimize:SetTexture(DB.bdTex)
-- close.minimize:SetVertexColor(1, 1, 1)
-- close:HookScript("OnEnter", colorMinimize)
-- close:HookScript("OnLeave", clearMinimize)

_G["StaticPopup" .. i .. "EditBox"].bg = CreateFrame("Frame", nil, _G["StaticPopup" .. i .. "EditBox"], "BackdropTemplate")
_G["StaticPopup" .. i .. "EditBox"].bg:SetAllPoints(_G["StaticPopup" .. i .. "EditBox"])
_G["StaticPopup" .. i .. "EditBox"].bg:SetFrameLevel(_G["StaticPopup" .. i .. "EditBox"]:GetFrameLevel())
_G["StaticPopup" .. i .. "EditBox"].bg:CreateBorder()

gold.bg = CreateFrame("Frame", nil, gold)
gold.bg:SetAllPoints(gold)
gold.bg:SetFrameLevel(gold:GetFrameLevel())
gold.bg:CreateBorder()

silver.bg = CreateFrame("Frame", nil, silver)
silver.bg:SetAllPoints(silver)
silver.bg:SetFrameLevel(silver:GetFrameLevel())
silver.bg:CreateBorder()

copper.bg = CreateFrame("Frame", nil, copper)
copper.bg:SetAllPoints(copper)
copper.bg:SetFrameLevel(copper:GetFrameLevel())
copper.bg:CreateBorder()
end

hooksecurefunc("StaticPopup_Show", function(which, _, _, data)
local info = StaticPopupDialogs[which]

if not info then
return
-- Helper function to skin popup edit boxes
local function SkinPopupEditBoxes(popup)
local editBox = _G[popup .. "EditBox"]
if editBox then
editBox:SkinEditBox()
editBox.KKUI_Backdrop:SetPoint("TOPLEFT", -3, -6)
editBox.KKUI_Backdrop:SetPoint("BOTTOMRIGHT", -3, 6)
end

local dialog = nil
dialog = StaticPopup_FindVisible(which, data)

if not dialog then
local index = 1
if info.preferredIndex then
index = info.preferredIndex
end
for i = index, STATICPOPUP_NUMDIALOGS do
local frame = _G["StaticPopup" .. i]
if not frame:IsShown() then
dialog = frame
break
end
end
local goldBox = _G[popup .. "MoneyInputFrameGold"]
local silverBox = _G[popup .. "MoneyInputFrameSilver"]
local copperBox = _G[popup .. "MoneyInputFrameCopper"]

if not dialog and info.preferredIndex then
for i = 1, info.preferredIndex do
local frame = _G["StaticPopup" .. i]
if not frame:IsShown() then
dialog = frame
break
end
end
end
if goldBox then
goldBox:SkinEditBox()
goldBox.KKUI_Backdrop:SetPoint("TOPLEFT", -3, 0)
end

if not dialog then
return
if silverBox then
silverBox:SkinEditBox()
silverBox.KKUI_Backdrop:SetPoint("TOPLEFT", -3, 0)
end
if copperBox then
copperBox:SkinEditBox()
copperBox.KKUI_Backdrop:SetPoint("TOPLEFT", -3, 0)
end
end

if info.closeButton then
local closeButton = _G[dialog:GetName() .. "CloseButton"]

closeButton:SetNormalTexture(0)
closeButton:SetPushedTexture(0)

if info.closeButtonIsHide then
closeButton.__texture:Hide()
closeButton.minimize:Show()
else
closeButton.__texture:Show()
closeButton.minimize:Hide()
-- Helper function to skin popup item frame
local function SkinPopupItemFrame(popup)
local itemFrame = _G[popup .. "ItemFrame"]
if itemFrame then
_G[popup .. "ItemFrameNameFrame"]:Kill()
itemFrame:GetNormalTexture():Kill()
itemFrame:CreateBorder()
itemFrame:StyleButton()
itemFrame.IconBorder:SetAlpha(0)

local iconTexture = itemFrame.IconTexture
if iconTexture then -- Check if iconTexture exists
iconTexture:SetTexCoord(0.1, 0.9, 0.1, 0.9)
iconTexture:ClearAllPoints()
iconTexture:SetPoint("TOPLEFT", 2, -2)
iconTexture:SetPoint("BOTTOMRIGHT", -2, 2)
end
end
end)
end

-- Skin StaticPopup frames
for i = 1, 4 do
local popup = "StaticPopup" .. i
SkinPopupButtons(popup)

local frame = _G[popup]
frame:StripTextures()
frame.Border:StripTextures()
frame:CreateBackdrop()
frame.KKUI_Backdrop:SetPoint("TOPLEFT", 2, -2)
frame.KKUI_Backdrop:SetPoint("BOTTOMRIGHT", -2, 2)

SkinPopupEditBoxes(popup)
SkinPopupItemFrame(popup)

local closeButton = _G[popup .. "CloseButton"]
closeButton:SetNormalTexture(0)
closeButton.SetNormalTexture = K.Noop
closeButton:SetPushedTexture(0)
closeButton.SetPushedTexture = K.Noop
closeButton:SkinCloseButton()
end

-- Skin the extra button on StaticPopup1
_G["StaticPopup1ExtraButton"]:SkinButton()
end)

0 comments on commit ecc90f1

Please sign in to comment.