87 lines
4.4 KiB
Lua
87 lines
4.4 KiB
Lua
local root=assert(arg[1])
|
|
local P={}
|
|
function CopyTable(t)
|
|
if type(t)~='table'then return t end
|
|
local r={};for k,v in pairs(t)do r[k]=CopyTable(v)end;return r
|
|
end
|
|
Enum={EditModePresetLayouts={Modern=1}}
|
|
APIDocumentation={AddDocumentationTable=function(_,d)
|
|
for _,t in ipairs(d.Tables or {})do
|
|
if t.Type=='Enumeration'then
|
|
Enum[t.Name]={};for _,v in ipairs(t.Fields)do Enum[t.Name][v.Name]=v.EnumValue end
|
|
end
|
|
end
|
|
end}
|
|
dofile(assert(os.getenv('RUEN_NATIVE_UI'))..'/EditModeManagerConstantsDocumentation.lua')
|
|
local systems={}
|
|
for name,kind in pairs(Enum.EditModeSystem)do
|
|
local count=name=='UnitFrame' and 8 or name=='ActionBar' and 13 or name=='AuraFrame' and 2 or 1
|
|
for i=1,count do
|
|
systems[#systems+1]={system=kind,systemIndex=i,anchorInfo={point='TOPLEFT',relativeTo='UIParent',relativePoint='TOPLEFT',offsetX=kind,offsetY=-i},
|
|
settings={{setting=999,value='PRESERVE PREFERENCE'}}}
|
|
end
|
|
end
|
|
EditModePresetLayoutManager={GetCopyOfPresetLayouts=function()return {{systems=systems}}end}
|
|
assert(loadfile(root..'LayoutRecovery.lua'))('RuenUI',P)
|
|
local layout={systems=CopyTable(systems)}
|
|
for _,s in ipairs(layout.systems)do s.anchorInfo={offsetX=9999};s.anchorInfo2={offsetY=9999};s.isInDefaultPosition=false end
|
|
local report=P.ResetNativeLayoutPositions(layout)
|
|
assert(report.native==#systems and #report.unavailable==0)
|
|
for i,s in ipairs(layout.systems)do
|
|
assert(s.anchorInfo.offsetX==systems[i].anchorInfo.offsetX and s.anchorInfo.offsetY==systems[i].anchorInfo.offsetY)
|
|
assert(s.anchorInfo~=systems[i].anchorInfo and s.anchorInfo2==nil and s.isInDefaultPosition)
|
|
assert(s.settings[1].value=='PRESERVE PREFERENCE','position reset changed a functional setting')
|
|
end
|
|
layout.systems[1].anchorInfo.offsetX=222
|
|
assert(systems[1].anchorInfo.offsetX~=222,'reset retained shared native anchors')
|
|
-- New/unsupported native systems are reported; never assigned guessed points.
|
|
layout={systems={{system=999,anchorInfo={offsetX=123}}}}
|
|
report=P.ResetNativeLayoutPositions(layout)
|
|
assert(#report.unavailable==1 and layout.systems[1].anchorInfo.offsetX==123)
|
|
function EditModePresetLayoutManager:GetDefaultSystemAnchorInfo()return {offsetX=456}end
|
|
report=P.ResetNativeLayoutPositions(layout)
|
|
assert(report.native==1 and #report.unavailable==0 and layout.systems[1].anchorInfo.offsetX==456)
|
|
|
|
UIParent={}
|
|
local spokenReset=0
|
|
SpokenEnv={Options={ResetPositions=function()spokenReset=spokenReset+1 end}}
|
|
local window={}
|
|
function window:ClearAllPoints()self.point=nil end
|
|
function window:SetPoint(...)self.point={...}end
|
|
function window:SetUserPlaced(v)self.userPlaced=v end
|
|
SpokenCompendium={window=window}
|
|
local liveMap={x=999,scale=2,language='ruRU',key='N'}
|
|
local clicks=0
|
|
local button={tiptext='Click to reset the map position and scale to the game default.'}
|
|
function button:GetScript(event)
|
|
assert(event=='OnClick')
|
|
return function()clicks=clicks+1;liveMap.x=16;liveMap.scale=1 end
|
|
end
|
|
function button:IsEnabled()return true end
|
|
-- Random panel names and localized button labels must not affect discovery.
|
|
F123random={GetChildren=function()return button end}
|
|
UISpecialFrames={'F123random'}
|
|
C_AddOns={IsAddOnLoaded=function(name)return name=='Leatrix_Maps'end}
|
|
report={unavailable={},companions={}}
|
|
P.ResetCompanionPositions(report)
|
|
assert(spokenReset==1 and clicks==1 and #report.unavailable==0)
|
|
assert(window.point[1]=='CENTER' and window.userPlaced==false)
|
|
assert(liveMap.x==16 and liveMap.scale==1 and liveMap.language=='ruRU' and liveMap.key=='N')
|
|
function button:IsEnabled()return false end
|
|
P.ResetCompanionPositions(report)
|
|
assert(clicks==1 and report.unavailable[1]=='Leatrix Maps','locked map reset was not reported')
|
|
button.IsEnabled=nil;F123random.GetChildren=function()return end
|
|
P.ResetCompanionPositions(report)
|
|
assert(clicks==1 and #report.unavailable==2,'unavailable upstream reset was silently claimed')
|
|
|
|
local panels=0
|
|
BankFrame={SetUserPlaced=function(_,v)assert(v==false);panels=panels+1 end}
|
|
OtherFrame={IsForbidden=function()return true end,SetUserPlaced=function()error('forbidden frame touched')end}
|
|
UIPanelWindows={BankFrame={},OtherFrame={},UnloadedPanel={}}
|
|
local updates=0
|
|
function UpdateUIPanelPositions()updates=updates+1 end
|
|
local original=UIPanelWindows.BankFrame
|
|
P.ResetNativePanelPositions(report)
|
|
assert(panels==1 and updates==1 and UIPanelWindows.BankFrame==original,'panel reset replaced native bookkeeping')
|
|
print('PASS: all 31 native system kinds, indexed pet/boss/arena/aura/action frames, secondary anchors, native fallback, independent preferences, companion live reset and panel-manager handoff')
|