forked from Dusk/ShaguTweaks-ClassicAPI
50 lines
3.1 KiB
Lua
50 lines
3.1 KiB
Lua
local root=(arg[1] or '.') .. '/'
|
|
assert(loadfile(root..'mods/unitframes-classcolor.lua'))
|
|
local modules={}
|
|
ShaguTweaks={T=setmetatable({},{__index=function(t,k) return k end})}
|
|
function ShaguTweaks.GetGlobalEnv() return _G end
|
|
function ShaguTweaks:register(module) modules[module.title]=module; return module end
|
|
function ShaguTweaks.hooksecurefunc(object,name,callback)
|
|
if type(object)~='table' then return end
|
|
local original=object[name]; object[name]=function(self,a,b,c,d) original(self,a,b,c,d); callback(self,a,b,c,d) end
|
|
end
|
|
MAX_PARTY_MEMBERS=0
|
|
local deferred
|
|
function CreateFrame() return {SetScript=function(self,event,callback) if callback then deferred={frame=self,callback=callback} end end,Hide=function() end} end
|
|
function UnitClass() return 'Warlock','WARLOCK' end
|
|
function TargetFrame_CheckFaction() end
|
|
local function texture()
|
|
return {SetTexture=function(self,p) self.path=p end,SetVertexColor=function(self,r,g,b,a) self.r=r end}
|
|
end
|
|
PlayerFrameNameBackground=texture(); TargetFrameNameBackground=texture()
|
|
PlayerFrameHealthBar={SetStatusBarTexture=function(self,p) self.path=p end,GetStatusBarColor=function() return 1,1,1,1 end,SetStatusBarColor=function() end}
|
|
dofile(root..'mods/unitframes-classcolor.lua')
|
|
modules['Modern Class Colors']:enable()
|
|
this=deferred.frame; deferred.callback(); this=nil
|
|
local expected='Interface\\AddOns\\ShaguTweaks\\img\\BlizzardRetailBar'
|
|
assert(PlayerFrameNameBackground.path==expected and TargetFrameNameBackground.path==expected and PlayerFrameHealthBar.path==expected)
|
|
print('Lua 5.0: matching modern name/health artwork passed')
|
|
-- Hiding the player name never affects the grouped player frame.
|
|
dofile(root..'mods/unitframes-hide-player-name.lua')
|
|
local nameHidden=false
|
|
ShaguTweaks.PlayerFrameResourcesLayout={name={Hide=function() nameHidden=true end}}
|
|
ShaguTweaks_config={['Hide Player Frame Resources']=0}
|
|
modules['Hide Player Name']:enable();assert(not nameHidden)
|
|
ShaguTweaks_config['Hide Player Frame Resources']=1
|
|
modules['Hide Player Name']:enable();assert(nameHidden)
|
|
print('Hide Player Name: hide-resources guard passed')
|
|
-- Removed options must not be loaded or retain saved switches.
|
|
local file=assert(io.open(root..'ShaguTweaks.toc'));local toc=file:read('*a');file:close()
|
|
assert(not string.find(toc,'unitframes-hide-player-portrait.lua',1,true))
|
|
assert(not string.find(toc,'unitframes-standalone-player.lua',1,true))
|
|
file=assert(io.open(root..'main.lua'));local source=file:read('*a');file:close()
|
|
local first=assert(string.find(source,' -- Gold numbers belong',1,true))
|
|
local last=assert(string.find(source,' -- Split the former shared setting',first,true))
|
|
local retire=assert(loadstring(string.sub(source,first,last-1)))
|
|
ShaguTweaks_config={['Hide Player Portrait']=1,['Unit Frame Health Colors']=1,
|
|
['Hide Player Frame Resources']=1,['Personal Resource Display']=1}
|
|
retire()
|
|
assert(not ShaguTweaks_config['Hide Player Portrait'] and not ShaguTweaks_config['Unit Frame Health Colors'])
|
|
assert(ShaguTweaks_config['Hide Player Frame Resources']==1 and ShaguTweaks_config['Personal Resource Display']==1)
|
|
print('Removed player options: absent from manifest and saved toggles retired without changing current options')
|