Skip to content

Commit

Permalink
SharedMedia support!
Browse files Browse the repository at this point in the history
Idk if this is even right but it works?
  • Loading branch information
Kkthnx committed Sep 3, 2024
1 parent 329f73f commit a0a8b22
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 351 deletions.
71 changes: 47 additions & 24 deletions KkthnxUI/Core/GUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -827,18 +827,20 @@ local DropdownButtonOnMouseUp = function(self, button)
self.Parent.Value = Value

if self.Parent.Type == "Texture" then
self.Parent.Texture:SetTexture(K.GetTexture(Value))
if C["Media"].Statusbars[Value] then
self.Parent.Texture:SetTexture(K.GetTexture(Value))
elseif K.LibSharedMedia then
self.Parent.Texture:SetTexture(K.LibSharedMedia:Fetch("statusbar", Value))
end
end

self.Parent.Current:SetText(self.Parent.Value)

SetValue(self.Parent.Group, self.Parent.Option, self.Parent.Value)
end
end

local DropdownButtonOnMouseDown = function(self)
local Red, Green, Blue = unpack(BrightColor)

self.Parent.Texture:SetVertexColor(Red * 0.85, Green * 0.85, Blue * 0.85)
end

Expand All @@ -850,24 +852,22 @@ local MenuItemOnMouseUp = function(self)

if self.GrandParent.Type then
SetValue(self.Group, self.Option, self.Key)

self.GrandParent.Value = self.Key

if self.GrandParent.Hook then
self.GrandParent.Hook(self.Key, self.Group)
if self.GrandParent.Type == "Texture" then
if C["Media"].Statusbars[self.Key] then
self.GrandParent.Texture:SetTexture(K.GetTexture(self.Key))
elseif K.LibSharedMedia then
self.GrandParent.Texture:SetTexture(K.LibSharedMedia:Fetch("statusbar", self.Key))
end
end
else
SetValue(self.Group, self.Option, self.Value)

self.GrandParent.Value = self.Value

if self.GrandParent.Hook then
self.GrandParent.Hook(self.Value, self.Group)
end
end

if self.GrandParent.Type == "Texture" then
self.GrandParent.Texture:SetTexture(K.GetTexture(self.Key))
if self.GrandParent.Hook then
self.GrandParent.Hook(self.Key, self.Group)
end

self.GrandParent.Current:SetText(self.Key)
Expand Down Expand Up @@ -1012,13 +1012,25 @@ end

local CreateDropdown = function(self, group, option, text, custom, tooltip, hook)
local Value
local Selections
local Selections = {}

if custom then
Value = C[group][option]

if custom == "Texture" then
Selections = C["Media"].Statusbars
-- Start with your existing textures
for k, v in pairs(C["Media"].Statusbars) do
Selections[k] = v
end

-- Check if LibSharedMedia-3.0 is available
if K.LibSharedMedia then
-- Add textures from LibSharedMedia-3.0
local sharedMediaTextures = K.LibSharedMedia:List("statusbar")
for _, textureName in ipairs(sharedMediaTextures) do
Selections[textureName] = textureName
end
end
end
else
Value = C[group][option].Value
Expand Down Expand Up @@ -1154,12 +1166,24 @@ local CreateDropdown = function(self, group, option, text, custom, tooltip, hook

MenuItem.Texture = MenuItem:CreateTexture(nil, "ARTWORK")
MenuItem.Texture:SetAllPoints()
MenuItem.Texture:SetTexture(K.GetTexture(C["General"].Texture))
MenuItem.Texture:SetVertexColor(BrightColor[1], BrightColor[2], BrightColor[3])

MenuItem.Selected = MenuItem:CreateTexture(nil, "OVERLAY")
MenuItem.Selected:SetAllPoints()
MenuItem.Selected:SetTexture(K.GetTexture(C["General"].Texture))

if custom == "Texture" then
if C["Media"].Statusbars[k] then
MenuItem.Texture:SetTexture(K.GetTexture(k)) -- For existing textures
MenuItem.Selected:SetTexture(K.GetTexture(k)) -- For existing textures
elseif K.LibSharedMedia then
MenuItem.Texture:SetTexture(K.LibSharedMedia:Fetch("statusbar", v)) -- For LibSharedMedia textures
MenuItem.Selected:SetTexture(K.LibSharedMedia:Fetch("statusbar", v)) -- For LibSharedMedia textures
end
else
MenuItem.Texture:SetTexture(K.GetTexture(C["General"].Texture))
MenuItem.Selected:SetTexture(K.GetTexture(C["General"].Texture))
end

MenuItem.Texture:SetVertexColor(BrightColor[1], BrightColor[2], BrightColor[3])
MenuItem.Selected:SetVertexColor(R, G, B)

MenuItem.Text = MenuItem:CreateFontString(nil, "OVERLAY")
Expand All @@ -1169,11 +1193,6 @@ local CreateDropdown = function(self, group, option, text, custom, tooltip, hook
MenuItem.Text:SetJustifyH("LEFT")
MenuItem.Text:SetText(k)

if custom == "Texture" then
MenuItem.Texture:SetTexture(K.GetTexture(k))
MenuItem.Selected:SetTexture(K.GetTexture(k))
end

if custom then
if MenuItem.Key == MenuItem.GrandParent.Value then
MenuItem.Selected:Show()
Expand Down Expand Up @@ -1206,7 +1225,11 @@ local CreateDropdown = function(self, group, option, text, custom, tooltip, hook
end

if custom == "Texture" then
Dropdown.Texture:SetTexture(K.GetTexture(Value))
if C["Media"].Statusbars[Value] then
Dropdown.Texture:SetTexture(K.GetTexture(Value)) -- For custom textures
elseif K.LibSharedMedia then
Dropdown.Texture:SetTexture(K.LibSharedMedia:Fetch("statusbar", Value)) -- For LibSharedMedia textures
end
else
Dropdown.Texture:SetTexture(K.GetTexture(C["General"].Texture))
end
Expand Down
2 changes: 1 addition & 1 deletion KkthnxUI/Init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ K.LibBase64 = LibStub("LibBase64-1.0-KkthnxUI")
K.LibActionButton = LibStub("LibActionButton-1.0-KkthnxUI")
K.LibChangeLog = LibStub("LibChangelog-KkthnxUI")
K.LibDeflate = LibStub("LibDeflate-KkthnxUI")
K.LibSharedMedia = LibStub("LibSharedMedia-3.0", true)
K.LibSharedMedia = LibStub("LibSharedMedia-3.0")
K.LibRangeCheck = LibStub("LibRangeCheck-3.0-KkthnxUI")
K.LibSerialize = LibStub("LibSerialize-KkthnxUI")
K.LibCustomGlow = LibStub("LibCustomGlow-1.0-KkthnxUI", true)
Expand Down
Loading

1 comment on commit a0a8b22

@Lithevampy
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we can use sharedmedia addons with KKT now?

Please sign in to comment.