Quantcast

just init pos at firstrun

rawoil [09-29-21 - 02:31]
just init pos at firstrun
Filename
rSkin/init.lua
rSkin/modules/BigWigs.lua
rSkin/modules/DBM.lua
rSkin/modules/Details.lua
rSkin/modules/WeakAuras.lua
rSkin/modules/ls_Toasts.lua
rSkin/rSkin.toc
diff --git a/rSkin/init.lua b/rSkin/init.lua
index c5c9eff..b81e7eb 100644
--- a/rSkin/init.lua
+++ b/rSkin/init.lua
@@ -5,47 +5,51 @@ local A, L = ...
 -----------------------------
 rSkin = CreateFrame("Frame")
 rSkin.addonName = A
-rSkin.skinName = "ZorkUI"
 -- init skins table
 rSkin.skins = {}

-local Hider = CreateFrame("Frame", nil, UIParent) Hider:Hide()
+L.C = {
+	style = "ZrokUI",
+	backdrop = rLib.CopyTable(oUF_SimpleConfig.backdrop),			-- default bd
+	font = oUF_SimpleConfig.fonts.expressway,						-- font
+	scale = oUF_SimpleConfig.globalscale,							-- scale
+	bar = {
+		small = {150, 20},											-- small size
+		big = rLib.CopyTable(oUF_SimpleConfig.target.size),			-- big size
+		tex = oUF_SimpleConfig.textures.statusbar,					-- bar texture
+		space = {
+			small = 4,
+			big = 8,
+		}
+	},
+	button = rLib.CopyTable(rButtonTemplate_Zork_ActionButtonConfig), -- btn
+	thin = rLib.CopyTable(oUF_SimpleConfig.backdrop),				-- thin bd
+}

-local function ThrowError(err, message)
-	if not err then return end
-
-	err = format("%s: %s Error\n%s", A, message, err)
-
-	if _G.BaudErrorFrameHandler then
-		_G.BaudErrorFrameHandler(err)
-	else
-		_G.ScriptErrorsFrame:OnError(err, false, false)
-	end
-end
+L.C.thin.edgeSize = 2
+L.C.thin.inset = 2
+L.C.thin.insets = {left=2,right=2,top=2,bottom=2}
+L.C.thin.bgColor = {0.23,0.23,0.23,0.7}
+L.C.thin.edgeColor = {0,0,0,1}

--- Kills --
-local function Kill(self)
-	if (self.UnregisterAllEvents) then
-		self:UnregisterAllEvents()
-		self:SetParent(Hider)
-	else
-		self.Show = self.Hide
-	end
+L.C.button.backdrop.bgColor = L.C.button.backdrop.backgroundColor
+L.C.button.backdrop.edgeColor = L.C.button.backdrop.borderColor
+L.C.button.backdrop.inset = 3

-	self:Hide()
-end
-L.Kill = Kill
+-- defaults vars
+local defaults = {
+	resets = {
+		bigwigs = true,
+		dbm = true,
+		details = true,
+		weakauras = true,
+		lstoasts = true,
+	}
+}

-local function StripTextures(self)
-	for i = 1, self:GetNumRegions() do
-		local Region = select(i, self:GetRegions())
-		if (Region and Region:GetObjectType() == "Texture") then
-			Region:SetTexture(nil)
-			Kill(Region)
-		end
-	end
+if (not rSkinDB) then
+	rSkinDB = rLib.CopyTable(defaults)
 end
-L.StripTextures = StripTextures

 --CreateBackdrop
 local function CreateBackdrop(self, relativeTo, anotherBackdrop)
@@ -70,6 +74,18 @@ L.CreateBackdrop = CreateBackdrop
 local function Dummy() return end
 L.Dummy = Dummy

+local function ThrowError(err, message)
+	if not err then return end
+
+	err = format("%s: %s Error\n%s", A, message, err)
+
+	if _G.BaudErrorFrameHandler then
+		_G.BaudErrorFrameHandler(err)
+	else
+		_G.ScriptErrorsFrame:OnError(err, false, false)
+	end
+end
+
 function rSkin:RegisterSkin(name, func)
     if not self.skins[name] then
 		self.skins[name] = func
diff --git a/rSkin/modules/BigWigs.lua b/rSkin/modules/BigWigs.lua
index 0369665..81f9e4a 100644
--- a/rSkin/modules/BigWigs.lua
+++ b/rSkin/modules/BigWigs.lua
@@ -1,8 +1,8 @@
 local A, L = ...

-local styleName = rSkin.skinName
+local styleName = L.C.style

-local backdropBorder = oUF_SimpleConfig.backdrop
+local backdrop = L.C.backdrop

 local function RemoveStyle(bar)
     bar.candyBarBackdrop:Hide()
@@ -34,13 +34,13 @@ local function StyleBar(bar)
     bar:SetHeight(height/2)

     local bd = bar.candyBarBackdrop
-    bd:SetBackdrop(backdropBorder)
-    bd:SetBackdropColor(unpack(backdropBorder.bgColor))
-    bd:SetBackdropBorderColor(unpack(backdropBorder.edgeColor))
+    bd:SetBackdrop(backdrop)
+    bd:SetBackdropColor(unpack(backdrop.bgColor))
+    bd:SetBackdropBorderColor(unpack(backdrop.edgeColor))

     bd:ClearAllPoints()
-    bd:SetPoint("TOPLEFT", bar, "TOPLEFT", -backdropBorder.inset, backdropBorder.inset)
-    bd:SetPoint("BOTTOMRIGHT", bar, "BOTTOMRIGHT", backdropBorder.inset, -backdropBorder.inset)
+    bd:SetPoint("TOPLEFT", bar, "TOPLEFT", -backdrop.inset, backdrop.inset)
+    bd:SetPoint("BOTTOMRIGHT", bar, "BOTTOMRIGHT", backdrop.inset, -backdrop.inset)
     bd:Show()

     local tex = bar:GetIcon()
@@ -58,13 +58,13 @@ local function StyleBar(bar)
         bar:Set("bigwigs:restoreicon", tex)

         local iconBd = bar.candyBarIconFrameBackdrop
-        iconBd:SetBackdrop(backdropBorder)
-        iconBd:SetBackdropColor(unpack(backdropBorder.bgColor))
-        iconBd:SetBackdropBorderColor(unpack(backdropBorder.edgeColor))
+        iconBd:SetBackdrop(backdrop)
+        iconBd:SetBackdropColor(unpack(backdrop.bgColor))
+        iconBd:SetBackdropBorderColor(unpack(backdrop.edgeColor))

         iconBd:ClearAllPoints()
-        iconBd:SetPoint("TOPLEFT", icon, -backdropBorder.inset, backdropBorder.inset)
-        iconBd:SetPoint("BOTTOMRIGHT", icon, backdropBorder.inset, -backdropBorder.inset)
+        iconBd:SetPoint("TOPLEFT", icon, -backdrop.inset, backdrop.inset)
+        iconBd:SetPoint("BOTTOMRIGHT", icon, backdrop.inset, -backdrop.inset)
         iconBd:Show()
     end

@@ -74,14 +74,14 @@ local function StyleBar(bar)

     bar.candyBarDuration:ClearAllPoints()
     bar.candyBarDuration:SetPoint("BOTTOMRIGHT", bar.candyBarBar, "TOPRIGHT", -2, 2)
-    bar.candyBarDuration:SetFont(oUF_SimpleConfig.fonts.expressway, 10, "OUTLINE")
+    bar.candyBarDuration:SetFont(L.C.font, 10, "OUTLINE")
 end

-local w, h = unpack(oUF_SimpleConfig.target.size)
+local w, h = unpack(L.C.bar.big)
 local styleData = {
     apiVersion = 1,
     version = 10,
-    barHeight = h*oUF_SimpleConfig.globalscale,
+    barHeight = h*L.C.scale,
     fontSizeNormal = 10,
     fontSizeEmphasized = 11,
     GetSpacing = function(bar) return bar:GetHeight()+6 end,
@@ -94,16 +94,19 @@ local function SkinBigWigsPlugins()
 	if not IsAddOnLoaded("BigWigs_Plugins") then return end
 	if not BigWigsAPI then return end

-	BigWigsAPI:RegisterBarStyle(styleName, styleData)
-
-	-- Force to use style
-	local pending = true
-	hooksecurefunc(BigWigsAPI, "GetBarStyle", function()
-		if pending then
-			BigWigsAPI.GetBarStyle = function() return styleData end
-			pending = nil
-		end
-	end)
+    if rSkinDB.resets.bigwigs then
+	    BigWigsAPI:RegisterBarStyle(styleName, styleData)
+        rSkinDB.resets.bigwigs = false
+    end
+
+    -- Force to use style
+    local pending = true
+    hooksecurefunc(BigWigsAPI, "GetBarStyle", function()
+        if pending then
+            BigWigsAPI.GetBarStyle = function() return styleData end
+            pending = nil
+        end
+    end)
 end

 -- rSkin:RegisterSkin("BigWigs", SkinBigWigs)
diff --git a/rSkin/modules/DBM.lua b/rSkin/modules/DBM.lua
index 356db79..1485f5e 100644
--- a/rSkin/modules/DBM.lua
+++ b/rSkin/modules/DBM.lua
@@ -1,11 +1,6 @@
 local A, L = ...

-local thinBackdrop = rLib.CopyTable(oUF_SimpleConfig.backdrop)
-thinBackdrop.edgeSize = 2
-thinBackdrop.inset = 2
-thinBackdrop.insets = {left=2,right=2,top=2,bottom=2}
-thinBackdrop.bgColor = {0.23,0.23,0.23,0.7}
-thinBackdrop.edgeColor = {0,0,0,1}
+local thinBackdrop = L.C.thin

 local function HideDBMSpark(self)
 	local spark = _G[self.frame:GetName().."BarSpark"]
@@ -30,7 +25,7 @@ local function ApplyDBMStyle(self)
 	local timer = _G[frame_name.."BarTimer"]

 	-- tex
-	if texture then texture:SetTexture(oUF_SimpleConfig.textures.statusbar) end
+	if texture then texture:SetTexture(L.C.bar.tex) end

 	-- reset backdrop
 	ResetBackdrop(tbar)
@@ -54,7 +49,7 @@ local function ApplyDBMStyle(self)
 	tbar:SetPoint("BOTTOMLEFT", frame, "BOTTOMLEFT", 0, 0)

 	-- frame
-	frame:SetScale(oUF_SimpleConfig.globalscale)
+	frame:SetScale(L.C.scale)

 	-- backdrop
 	local iconOffsetX = 0
@@ -118,46 +113,49 @@ local function SkinDBM()
 		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 rSkinDB.resets.dbm then
+		-- 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

-	local hugeBarWidth, hugeBarHeight = unpack(oUF_SimpleConfig.target.castbar.size)
-    local barWidth, barheight = 150, 20
-	if not DBT_AllPersistentOptions["Default"] then DBT_AllPersistentOptions["Default"] = {} end
-
-	-- place on top of details
-	local Details = _G.Details
-	local timerX, timerY = (-(barWidth/2)-10+1)*oUF_SimpleConfig.globalscale, Details and 185 or 69
-
-	-- normal bar
-	DBT_AllPersistentOptions["Default"]["DBM"].BarYOffset = 4
-	DBT_AllPersistentOptions["Default"]["DBM"].Height = barheight
-	DBT_AllPersistentOptions["Default"]["DBM"].Width = barWidth
-	DBT_AllPersistentOptions["Default"]["DBM"].ExpandUpwards = true
-	DBT_AllPersistentOptions["Default"]["DBM"].TimerPoint = "BOTTOMRIGHT"
-	DBT_AllPersistentOptions["Default"]["DBM"].TimerX = timerX
-	DBT_AllPersistentOptions["Default"]["DBM"].TimerY = timerY
-
-	-- huge bar
-	DBT_AllPersistentOptions["Default"]["DBM"].HugeBarYOffset = 8
-	DBT_AllPersistentOptions["Default"]["DBM"].ExpandUpwardsLarge = true
-	DBT_AllPersistentOptions["Default"]["DBM"].HugeHeight = hugeBarHeight
-    DBT_AllPersistentOptions["Default"]["DBM"].HugeWidth = hugeBarWidth
-	if _G.oUF_SimpleTarget then
-		local point, _, _, xOfs, yOfs = _G.oUF_SimpleTarget:GetPoint(1)
-		DBT_AllPersistentOptions["Default"]["DBM"].HugeTimerPoint = point
-		DBT_AllPersistentOptions["Default"]["DBM"].HugeTimerX = xOfs*oUF_SimpleConfig.globalscale
-		DBT_AllPersistentOptions["Default"]["DBM"].HugeTimerY = yOfs+hugeBarHeight*3+18
-	end
+		local hugeBarWidth, hugeBarHeight = unpack(L.C.bar.big)
+		local barWidth, barheight = unpack(L.C.bar.small)
+		if not DBT_AllPersistentOptions["Default"] then DBT_AllPersistentOptions["Default"] = {} end
+
+		-- place on top of details
+		local Details = _G.Details
+		local timerX, timerY = (-(barWidth/2)-10+1)*L.C.scale, Details and 185 or 69
+
+		-- normal bar
+		DBT_AllPersistentOptions["Default"]["DBM"].BarYOffset = L.C.bar.space.small
+		DBT_AllPersistentOptions["Default"]["DBM"].Height = barheight
+		DBT_AllPersistentOptions["Default"]["DBM"].Width = barWidth
+		DBT_AllPersistentOptions["Default"]["DBM"].ExpandUpwards = true
+		DBT_AllPersistentOptions["Default"]["DBM"].TimerPoint = "BOTTOMRIGHT"
+		DBT_AllPersistentOptions["Default"]["DBM"].TimerX = timerX
+		DBT_AllPersistentOptions["Default"]["DBM"].TimerY = timerY
+
+		-- huge bar
+		DBT_AllPersistentOptions["Default"]["DBM"].HugeBarYOffset = L.C.bar.space.big
+		DBT_AllPersistentOptions["Default"]["DBM"].ExpandUpwardsLarge = true
+		DBT_AllPersistentOptions["Default"]["DBM"].HugeHeight = hugeBarHeight
+		DBT_AllPersistentOptions["Default"]["DBM"].HugeWidth = hugeBarWidth
+		if _G.oUF_SimpleTarget then
+			local point, _, _, xOfs, yOfs = _G.oUF_SimpleTarget:GetPoint(1)
+			DBT_AllPersistentOptions["Default"]["DBM"].HugeTimerPoint = point
+			DBT_AllPersistentOptions["Default"]["DBM"].HugeTimerX = xOfs*L.C.scale
+			DBT_AllPersistentOptions["Default"]["DBM"].HugeTimerY = yOfs+hugeBarHeight*3+18
+		end

-	-- rearrange
-	DBT:Rearrange()
+		-- rearrange
+		DBT:Rearrange()
+		rSkinDB.resets.dbm = false
+	end
 end

 rSkin:RegisterSkin('DBM', SkinDBM)
diff --git a/rSkin/modules/Details.lua b/rSkin/modules/Details.lua
index 247a3d4..b69e856 100644
--- a/rSkin/modules/Details.lua
+++ b/rSkin/modules/Details.lua
@@ -1,5 +1,7 @@
 local A, L = ...

+local w, h = unpack(L.C.bar.small)
+
 local function SetupInstance(instance)
     if instance.styled then return end
     if not instance.baseframe then return end
@@ -13,23 +15,23 @@ local function SetupInstance(instance)
 	instance:SetBackgroundAlpha(0)
 	instance:InstanceColor(0, 0, 0, 0)
 	instance:SetBarFollowPlayer(true)
-	instance:SetWindowScale(oUF_SimpleConfig.globalscale, true)
+	instance:SetWindowScale(L.C.scale, true)
     -- instance:MenuAnchor(16, 3)
     -- instance:ToolbarMenuButtonsSize(1)
     instance:AttributeMenu(false)
 	instance:SetBarSettings(
-		20,						-- bar height
+		h,						-- bar height
 		"Blizzard Raid Bar",	-- bar texture name of medialib
 		true,					-- use class color
 		{0, 0, 0, 0},			-- fixed color
 		"Solid",				-- bg texture name of medialib
 		false, 					-- bg use class color
-		{0.23, 0.23, 0.23, 0.7},	-- fixed bg color
+		L.C.thin.bgColor,		-- fixed bg color
 		0,						-- alpha
 		"",						-- icon file
 		true,					-- start after icon
-		4,						-- bar space
-		""						-- custom texture file, u can use oUF_SimpleConfig.textures.statusbar or "" as default
+		L.C.bar.space.small,	-- bar space
+		""						-- custom texture file, u can use L.C.bar.tex or "" as default
 	)

 	instance:SetBarBackdropSettings(true, 1, {0,0,0,1}, "1 Pixel")
@@ -74,12 +76,17 @@ local function Details()
 	local instance1 = Details:GetInstance(1)
 	local instance2 = Details:GetInstance(2)

-	local height = 124
-	local width = 150
-	if instance1 then
-		EmbedWindow(instance1, -10, 50, width, height)
-		if instance2 then
-			EmbedWindow(instance2, -15-width, 50, width, height)
+	local height = (h+L.C.bar.space.small)*5 + 4
+	local width = w
+
+	if rSkinDB.resets.details then
+		if instance1 then
+			EmbedWindow(instance1, -10, 50, width, height)
+			if instance2 then
+				EmbedWindow(instance2, -15-width, 50, width, height)
+			end
+
+			rSkinDB.resets.details = false
 		end
 	end

diff --git a/rSkin/modules/WeakAuras.lua b/rSkin/modules/WeakAuras.lua
index d5f9cb3..fa0bf9d 100644
--- a/rSkin/modules/WeakAuras.lua
+++ b/rSkin/modules/WeakAuras.lua
@@ -2,17 +2,8 @@ local A, L = ...

 -- credit: ndui
 local pairs, unpack = pairs, unpack
-local buttonConfig = rLib.CopyTable(rButtonTemplate_Zork_ActionButtonConfig)
-buttonConfig.backdrop.bgColor = buttonConfig.backdrop.backgroundColor
-buttonConfig.backdrop.edgeColor = buttonConfig.backdrop.borderColor
-buttonConfig.backdrop.inset = 3
-
-local thinBackdrop = rLib.CopyTable(oUF_SimpleConfig.backdrop)
-thinBackdrop.edgeSize = 2
-thinBackdrop.inset = 2
-thinBackdrop.insets = {left=2,right=2,top=2,bottom=2}
-thinBackdrop.bgColor = {0.23,0.23,0.23,0.7}
-thinBackdrop.edgeColor = {0,0,0,1}
+local buttonConfig = L.C.button
+local thinBackdrop = L.C.thin

 local function IconBgOnUpdate(self)
 	self:SetAlpha(self.__icon:GetAlpha())
diff --git a/rSkin/modules/ls_Toasts.lua b/rSkin/modules/ls_Toasts.lua
index 082851c..58d7d35 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(strlower(rSkin.skinName), {
-		name = rSkin.skinName,
+	LE:RegisterSkin(strlower(L.C.style), {
+		name = L.C.style,
 		border = {
 			color = {0, 0, 0},
 			offset = 0,
@@ -13,7 +13,7 @@ local function ls_Toasts()
 			texture = {1, 1, 1, 1},
 		},
 		icon = {
-			tex_coords = rButtonTemplate_Zork_ActionButtonConfig.icon.texCoord,
+			tex_coords = L.C.button.icon.texCoord,
 		},
 		icon_border = {
 			color = {0, 0, 0},
@@ -22,7 +22,7 @@ local function ls_Toasts()
 			texture = {1, 1, 1, 1},
 		},
 		slot = {
-			tex_coords = rButtonTemplate_Zork_ActionButtonConfig.icon.texCoord,
+			tex_coords = L.C.button.icon.texCoord,
 		},
 		slot_border = {
 			color = {0, 0, 0},
@@ -57,7 +57,7 @@ local function ls_Toasts()
 		},
 	})

-	LC.db.profile.skin = strlower(rSkin.skinName)
+	LC.db.profile.skin = strlower(L.C.style)
 	LC.options.args.general.args.skin.disabled = true

 	local function reskinFunc()
@@ -66,7 +66,6 @@ local function ls_Toasts()
 		while toast do
 			if toast.BG and not toast.styled then
 				toast.BG:SetTexture(nil)
-				-- B.SetBD(toast)
 				L.CreateBackdrop(toast)
 				toast.SetBackground = L.Dummy
 				toast.styled = true
diff --git a/rSkin/rSkin.toc b/rSkin/rSkin.toc
index a6978a6..0a409ae 100644
--- a/rSkin/rSkin.toc
+++ b/rSkin/rSkin.toc
@@ -4,6 +4,7 @@
 ## Notes: Reskin other addons to fit zorkui's L&F
 ## RequiredDeps: rLib, rButtonTemplate_Zork, oUF_SimpleConfig
 ## OptionalDeps: DBM-Core, WeakAuras, ls_Toasts, Details, BigWigs_Plugins
+## SavedVariablesPerCharacter: rSkinDB

 init.lua
 modules\ls_Toasts.lua