View Single Post
01-28-18, 11:25 PM   #1
tehmoku
A Fallenroot Satyr
Join Date: May 2007
Posts: 27
Making my own BossFrames with XML - Need help with show states

Since it seems I cannot move the default Boss1TargetFrame without running in to issues in combat, I've just decided to recreate the boss frames in XML with BossTargetFrameTemplate. XML is uncharted territory for me, so be gentle.

I have essentially gotten the frames to look how I want them to look, and function how I want them to function with the exception of their show state.

I can get them to hide when there's no bosses around, but I cannot get them to mirror the "normal" bossframes, especially when more than 1 boss gets pulled.

Here is my current code:

Basic XML

Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\FrameXML\UI.xsd">
	<Script file="mBossframes.lua"/>
	<Button name="mBoss1TargetFrame" inherits="BossTargetFrameTemplate" id="1">
		<Anchors>
			<Anchor point="TOPRIGHT" x="-310" y="-510"/>
		</Anchors>
	</Button>
	<Button name="mBoss2TargetFrame" inherits="BossTargetFrameTemplate" id="2">
		<Anchors>
			<Anchor point="TOPLEFT" relativeTo="mBoss1TargetFrame" relativePoint="BOTTOMLEFT" x="0" y="-30"/>
		</Anchors>
	</Button>
	<Button name="mBoss3TargetFrame" inherits="BossTargetFrameTemplate" id="3">
		<Anchors>
			<Anchor point="TOPLEFT" relativeTo="mBoss2TargetFrame" relativePoint="BOTTOMLEFT" x="0" y="-30"/>
		</Anchors>
	</Button>
	<Button name="mBoss4TargetFrame" inherits="BossTargetFrameTemplate" id="4">
		<Anchors>
			<Anchor point="TOPLEFT" relativeTo="mBoss3TargetFrame" relativePoint="BOTTOMLEFT" x="0" y="-30"/>
		</Anchors>
	</Button>
	<Button name="mBoss5TargetFrame" inherits="BossTargetFrameTemplate" id="5">
		<Anchors>
			<Anchor point="TOPLEFT" relativeTo="mBoss4TargetFrame" relativePoint="BOTTOMLEFT" x="0" y="-30"/>
		</Anchors>
	</Button>
</Ui>
And Lua:

Lua Code:
  1. function IsBossFrameShown()
  2.     for i = 1, MAX_BOSS_FRAMES do
  3.     local b = _G["Boss"..i.."TargetFrame"]
  4.         if b and b:IsShown() then
  5.           return true
  6.         end
  7.     end
  8.     return false
  9. end
  10.  
  11. function UpdateView()
  12.     for i = 1, MAX_BOSS_FRAMES do
  13.         local t = _G["mBoss"..i.."TargetFrame"]
  14.     if mBoss1TargetFrame:IsShown() and IsBossFrameShown() then
  15.         return
  16.     elseif not mBoss1TargetFrame:IsShown() and IsBossFrameShown() then
  17.         mBoss1TargetFrame:Show()
  18.     elseif (t) then
  19.             t:Hide()
  20.     end
  21.     end
  22. end
  23.  
  24. for i = 1, MAX_BOSS_FRAMES do
  25.     local b = _G["Boss"..i.."TargetFrame"]
  26.     b:HookScript("OnShow",function() UpdateView() end)
  27.     b:HookScript("OnHide",function() UpdateView() end)
  28. end
  Reply With Quote