library TasFullScreenFrame initializer Init
/* TasFullScreenFrame V2 by Tasyen
This helps in creating Frames that can Leave 4:3 of Screen and helps in attaching to the left/right border of the window. Works in Warcraft 3 V1.31.1 and V1.36.
Creates 2 Frames TasFullScreenFrame & TasFullScreenParent.
TasFullScreenFrame can be used as relative Frame in BlzFrameSetPoint. It can not be a parent as it is hidden.
TasFullScreenParent is used as parent in CreateFrame to make your Frames able to leave 4:3. Do not use it for SimpleFrames.
TasFullScreenParentScaled like TasFullScreenParent but scales with UI scale option.
when Leaderboard/Multiboard are the anchestor, then they need to be visible otherwise your frames will not be visible. They can be hidden when your frame shows&creates Leaderboard/Multiboard after TasFullScreenFrameInit run.
Multiboard is used when there already exists a Multiboard when TasFullScreenFrameInit runs.
credits Niklas, ScrewTheTrees
Example
function Test takes nothing returns nothing
local framehandle frame = BlzCreateFrame("ScriptDialogButton", TasFullScreenParent, 0, 0)
call BlzFrameSetAbsPoint(frame, FRAMEPOINT_TOP, 0, 0.3)
set frame = BlzCreateFrame("ScriptDialogButton", TasFullScreenParentScaled, 0, 0)
call BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, TasFullScreenFrame, FRAMEPOINT_LEFT, 0, 0.10)
endfunction
*/
globals
framehandle TasFullScreenParent = null
framehandle TasFullScreenParentScaled = null
framehandle TasFullScreenFrame = null
public boolean AutoRun = true //(true) will create Itself at 0s, (false) you need to TasFullScreenFrameInit()
public real UpdateRate = 0.5 // How fast to update the size of TasFullScreenFrame
public real lastXSize = 0.0
endglobals
// provides the parent that can Leave 4:3 and with that our frames
public function GetParent takes nothing returns framehandle
// try to use "ConsoleUIBackdrop" can not happen in V1.31.1
local framehandle parent = BlzGetFrameByName("ConsoleUIBackdrop", 0)
if GetHandleId(parent) > 0 then
return parent
endif
// ConsoleUIBackdrop failed, therefore use a Multiboard
set parent = BlzGetFrameByName("Multiboard", 0)
if GetHandleId(parent) > 0 then
return parent
endif
// Multiboard failed, therefore use a Leaderboard
// try attaching to a existing one
set parent = BlzGetFrameByName("Leaderboard", 0)
if GetHandleId(parent) > 0 then
return parent
endif
// create a Leaderboard and make it not seeable
call CreateLeaderboardBJ(bj_FORCE_ALL_PLAYERS, "title")
set parent = BlzGetFrameByName("Leaderboard", 0)
call BlzFrameSetSize(parent, 0, 0)
call BlzFrameSetVisible(BlzGetFrameByName("LeaderboardBackdrop", 0), false)
call BlzFrameSetVisible(BlzGetFrameByName("LeaderboardTitle", 0), false)
return parent
endfunction
public function Update takes nothing returns nothing
// update the full screen frame to current Resolution
local real y = BlzGetLocalClientHeight()
if y != 0 then
call BlzFrameSetSize(TasFullScreenFrame, BlzGetLocalClientWidth()/y*0.6, 0.6)
endif
set y = BlzFrameGetWidth(BlzGetFrameByName("ConsoleUIBackdrop", 0))
if y != lastXSize then
set lastXSize = y
call BlzFrameSetScale(TasFullScreenParent, 1)
call BlzFrameSetScale(TasFullScreenParentScaled, y/0.8)
endif
endfunction
public function InitFrames takes nothing returns nothing
// Make the TasFullScreenFrames
// to allow TasFullScreenParent to expand over 4:3 it needs a Parent that can do such GetParent() gives us that one
local framehandle parent = GetParent()
call BlzGetFrameByName("ConsoleUIBackdrop", 0)
set TasFullScreenParent = BlzCreateFrameByType("FRAME", "TasFullScreenParent", parent, "", 0)
set TasFullScreenParentScaled = BlzCreateFrameByType("FRAME", "TasFullScreenParentScaled", parent, "", 0)
call BlzFrameSetScale(TasFullScreenParent, 1)
// Lets make another Frame which size is the whole screen
// it is hidden to not take control and dont have visuals.
// as child of TasFullScreenParent it can expand outside of 4:3
set TasFullScreenFrame = BlzCreateFrameByType("FRAME", "TasFullScreenFrame", TasFullScreenParent, "", 0)
call BlzFrameSetVisible(TasFullScreenFrame, false)
call BlzFrameSetSize(TasFullScreenFrame, 0.8, 0.6)
call BlzFrameSetAbsPoint(TasFullScreenFrame, FRAMEPOINT_BOTTOM, 0.4, 0)
endfunction
// this would be an outside thing that calls the others
function TasFullScreenFrameInit takes nothing returns nothing
local timer t = GetExpiredTimer()
if t == null then
set t = CreateTimer()
endif
call InitFrames()
static if LIBRARY_FrameLoader then
call FrameLoaderAdd(function InitFrames)
endif
call TimerStart(t, UpdateRate, true, function Update)
endfunction
public function Init takes nothing returns nothing
if AutoRun then
call TimerStart(CreateTimer(), 0.01, false, function TasFullScreenFrameInit)
endif
endfunction
endlibrary