Quantcast

dbm is in progress

rawoil [09-27-21 - 10:33]
dbm is in progress
Filename
rSkin/init.lua
rSkin/modules/BigWigs.lua
rSkin/modules/DBM.lua
rSkin/modules/ls_Toasts.lua
rSkin/rSkin.toc
diff --git a/rSkin/init.lua b/rSkin/init.lua
index da754ca..2364b59 100644
--- a/rSkin/init.lua
+++ b/rSkin/init.lua
@@ -5,6 +5,7 @@ local A, L = ...
 -----------------------------
 rSkin = CreateFrame("Frame")
 rSkin.addonName = A
+rSkin.skinName = "ZorkUI"
 -- init skins table
 rSkin.skins = {}

@@ -49,8 +50,14 @@ L.StripTextures = StripTextures
 --CreateBackdrop
 local function CreateBackdrop(self, relativeTo)
   local backdrop = oUF_SimpleConfig.backdrop
-  local bd = CreateFrame("Frame", nil, self, BackdropTemplateMixin and "BackdropTemplate")
-  bd:SetFrameLevel(self:GetFrameLevel()-1 or 0)
+  local parent = self.IsObjectType and self:IsObjectType('Texture') and self:GetParent() or self
+  local bd = CreateFrame("Frame", nil, parent, BackdropTemplateMixin and "BackdropTemplate")
+  if (parent:GetFrameLevel() - 1) >= 0 then
+	bd:SetFrameLevel(parent:GetFrameLevel() - 1)
+  else
+	bd:SetFrameLevel(0)
+  end
+--   bd:SetFrameLevel(parent:GetFrameLevel()-1 or 0)
   bd:SetPoint("TOPLEFT", relativeTo or self, "TOPLEFT", -backdrop.inset, backdrop.inset)
   bd:SetPoint("BOTTOMRIGHT", relativeTo or self, "BOTTOMRIGHT", backdrop.inset, -backdrop.inset)
   bd:SetBackdrop(backdrop)
diff --git a/rSkin/modules/BigWigs.lua b/rSkin/modules/BigWigs.lua
index fb8c0de..0369665 100644
--- a/rSkin/modules/BigWigs.lua
+++ b/rSkin/modules/BigWigs.lua
@@ -1,6 +1,6 @@
 local A, L = ...

-local styleName = "ZorkUI"
+local styleName = rSkin.skinName

 local backdropBorder = oUF_SimpleConfig.backdrop

diff --git a/rSkin/modules/DBM.lua b/rSkin/modules/DBM.lua
new file mode 100644
index 0000000..223af12
--- /dev/null
+++ b/rSkin/modules/DBM.lua
@@ -0,0 +1,155 @@
+local A, L = ...
+
+local function HideIcon(icon)
+    if not icon then return end
+    if not icon.__hided then
+        if icon.Backdrop then
+            icon.Backdrop:Hide()
+        end
+        icon:Hide()
+        icon.__hided = true
+    end
+end
+
+local function ShowIcon(icon, frame, size, left)
+    if not icon then return end
+    if not icon.__styled then
+        icon:ClearAllPoints()
+        if left then
+            icon:SetPoint('BOTTOMRIGHT', frame, 'BOTTOMLEFT', -5, 0)
+        else
+            icon:SetPoint('BOTTOMLEFT', frame, 'BOTTOMRIGHT', 5, 0)
+        end
+        icon:SetSize(size, size)
+        if not icon.Backdrop then
+            icon.Backdrop = L.CreateBackdrop(icon)
+        end
+        icon:Show()
+        icon.Backdrop:Show()
+
+        icon.__styled = true
+    end
+end
+
+local function ReskinDBMBar(bar, check, border)
+	if not bar then return end
+	if not bar[check] then
+        local inset = border or 1
+        bar.Backdrop:SetPoint("TOPLEFT", bar, "TOPLEFT", -inset, inset)
+        bar.Backdrop:SetPoint("BOTTOMRIGHT", bar, "BOTTOMRIGHT", inset, -inset)
+		bar[check] = true
+	end
+end
+
+local function HideDBMSpark(self)
+	local spark = _G[self.frame:GetName().."BarSpark"]
+	spark:SetAlpha(0)
+	spark:SetTexture(nil)
+end
+
+local function ApplyDBMStyle(self)
+	local frame = self.frame
+	local frame_name = frame:GetName()
+	local tbar = _G[frame_name.."Bar"]
+	local texture = _G[frame_name.."BarTexture"]
+	local icon1 = _G[frame_name.."BarIcon1"]
+	local icon2 = _G[frame_name.."BarIcon2"]
+	local name = _G[frame_name.."BarName"]
+	local timer = _G[frame_name.."BarTimer"]
+
+    local barHeight = self.enlarged and self.owner.Options.HugeHeight/2 or self.owner.Options.Height
+    local iconSize = frame:GetHeight()
+
+    if not tbar.Backdrop then
+        tbar.Backdrop = L.CreateBackdrop(tbar)
+    end
+    ReskinDBMBar(tbar, self.enlarged and "__style_huge" or "__style_normal", self.enlarged and oUF_SimpleConfig.backdrop.inset or 1)
+
+	if self.enlarged then
+		frame:SetWidth(self.owner.Options.HugeWidth)
+		tbar:SetWidth(self.owner.Options.HugeWidth)
+        ShowIcon(icon1, frame, iconSize, true)
+        ShowIcon(icon2, frame, iconSize, false)
+	else
+		frame:SetWidth(self.owner.Options.Width)
+		tbar:SetWidth(self.owner.Options.Width)
+        HideIcon(icon1)
+        HideIcon(icon2)
+	end
+
+    frame:SetHeight(barHeight)
+	frame:SetScale(oUF_SimpleConfig.globalscale)
+    tbar:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 0, 0)
+
+	if texture then texture:SetTexture(oUF_SimpleConfig.textures.statusbar) end
+
+	name:ClearAllPoints()
+    timer:ClearAllPoints()
+    if self.enlarged then
+        name:SetPoint("BOTTOMLEFT", tbar, "TOPLEFT", 2, 2)
+        timer:SetPoint("BOTTOMRIGHT", tbar, "TOPRIGHT", -2, 2)
+    else
+        name:SetPoint("LEFT", frame, "LEFT", 2, 0)
+        timer:SetPoint("RIGHT", frame, "RIGHT", -2, 0)
+    end
+    timer:SetFont(oUF_SimpleConfig.fonts.expressway, 10, "OUTLINE")
+
+    -- if DBT.Options.IconLeft then icon1.Backdrop:Show() else icon1.Backdrop:Hide() end
+    -- if DBT.Options.IconRight then icon2.Backdrop:Show() else icon2.Backdrop:Hide() end
+end
+
+function SkinDBM()
+    -- Default notice message
+	local RaidNotice_AddMessage_ = RaidNotice_AddMessage
+	RaidNotice_AddMessage = function(noticeFrame, textString, colorInfo)
+		if strfind(textString, "|T") then
+			if strmatch(textString, ":(%d+):(%d+)") then
+				local size1, size2 = strmatch(textString, ":(%d+):(%d+)")
+				size1, size2 = size1 + 3, size2 + 3
+				textString = gsub(textString,":(%d+):(%d+)",":"..size1..":"..size2..":0:0:64:64:5:59:5:59")
+			elseif strmatch(textString, ":(%d+)|t") then
+				local size = strmatch(textString, ":(%d+)|t")
+				size = size + 3
+				textString = gsub(textString,":(%d+)|t",":"..size..":"..size..":0:0:64:64:5:59:5:59|t")
+			end
+		end
+		return RaidNotice_AddMessage_(noticeFrame, textString, colorInfo)
+	end
+
+    if not IsAddOnLoaded("DBM-Core") then return end
+
+    hooksecurefunc(DBT, "CreateBar", function(self)
+		for bar in self:GetBarIterator() do
+			if not bar.injected then
+				hooksecurefunc(bar, "Update", HideDBMSpark)
+				hooksecurefunc(bar, "ApplyStyle", ApplyDBMStyle)
+				bar:ApplyStyle()
+
+				bar.injected = true
+			end
+		end
+	end)
+
+	-- Force Settings
+	if not DBM_AllSavedOptions["Default"] then DBM_AllSavedOptions["Default"] = {} end
+	-- DBM_AllSavedOptions["Default"]["BlockVersionUpdateNotice"] = true
+	DBM_AllSavedOptions["Default"]["EventSoundVictory"] = "None"
+	if IsAddOnLoaded("DBM-VPYike") then
+		DBM_AllSavedOptions["Default"]["CountdownVoice"] = "VP:Yike"
+		DBM_AllSavedOptions["Default"]["ChosenVoicePack"] = "Yike"
+	end
+	if not DBT_AllPersistentOptions["Default"] then DBT_AllPersistentOptions["Default"] = {} end
+	DBT_AllPersistentOptions["Default"]["DBM"].BarYOffset = 3
+	DBT_AllPersistentOptions["Default"]["DBM"].HugeBarYOffset = 8
+	DBT_AllPersistentOptions["Default"]["DBM"].ExpandUpwards = false
+	DBT_AllPersistentOptions["Default"]["DBM"].ExpandUpwardsLarge = true
+
+    local hugeBarWidth, hugeBarHeight = unpack(oUF_SimpleConfig.target.size)
+    local barWidth, barheight = 150, 20
+    DBT_AllPersistentOptions["Default"]["DBM"].Height = barheight
+	DBT_AllPersistentOptions["Default"]["DBM"].HugeHeight = hugeBarHeight
+    DBT_AllPersistentOptions["Default"]["DBM"].Width = barWidth
+    DBT_AllPersistentOptions["Default"]["DBM"].HugeWidth = hugeBarWidth
+end
+
+rSkin:RegisterSkin('DBM', SkinDBM)
diff --git a/rSkin/modules/ls_Toasts.lua b/rSkin/modules/ls_Toasts.lua
index a3e0dab..082851c 100644
--- a/rSkin/modules/ls_Toasts.lua
+++ b/rSkin/modules/ls_Toasts.lua
@@ -4,8 +4,8 @@ local function ls_Toasts()
 	if not IsAddOnLoaded("ls_Toasts") then return end

 	local LE, LC, LL = unpack(_G.ls_Toasts)
-	LE:RegisterSkin("zorkui", {
-		name = "ZorkUI",
+	LE:RegisterSkin(strlower(rSkin.skinName), {
+		name = rSkin.skinName,
 		border = {
 			color = {0, 0, 0},
 			offset = 0,
@@ -57,7 +57,7 @@ local function ls_Toasts()
 		},
 	})

-	LC.db.profile.skin = "zorkui"
+	LC.db.profile.skin = strlower(rSkin.skinName)
 	LC.options.args.general.args.skin.disabled = true

 	local function reskinFunc()
diff --git a/rSkin/rSkin.toc b/rSkin/rSkin.toc
index 7ce098b..a18827f 100644
--- a/rSkin/rSkin.toc
+++ b/rSkin/rSkin.toc
@@ -3,9 +3,10 @@
 ## Title: rSkin |cff1a9fc0BCC|r
 ## Notes: Reskin other addons to fit zorkui's L&F
 ## RequiredDeps: rLib, rButtonTemplate_Zork, oUF_SimpleConfig
-## OptionalDeps: DBM, WeakAuras, ls_Toasts, Details, BigWigs_Plugins
+## OptionalDeps: DBM-Core, WeakAuras, ls_Toasts, Details, BigWigs_Plugins

 init.lua
 modules\ls_Toasts.lua
 modules\Details.lua
-modules\BigWigs.lua
\ No newline at end of file
+modules\BigWigs.lua
+modules\DBM.lua
\ No newline at end of file