Name | Type | is_array | initial_value |
--[[ TasFrameAction V1.3 by Tasyen
TasFrameAction is an Lua system to not have to care about Trigger and FrameEvents for FrameAction. All FrameEvents are binded to one trigger that trigger than calls the action for
handles frame Events in one trigger, care only about the actionFunction itself.
calls give Actions inside xpcall.
Supports only one Action per Event+Frame
Example
TasSliderAction(sliderFrame, function(frame, player, value)
print(BlzFrameGetName(frame), GetPlayerId(player), value)
end)
TasButtonAction(frame, function(frame, player))
wrapper for TasFrameAction meant for BUTTON just ControlClick
Removes focus & StopCamera
takes FRAMEEVENT_CONTROL_CLICK from TasFrameAction for this frame
TasSliderAction(frame, function(frame, player, value)[, StepSize, scrollTarget, allowPoll])
action happens when a Value is set
TasSliderAction.AvoidPoll (true) skip actions with the same value in a row by 1 player
set scrollTarget from the outside TasSliderAction.Target[frame] = scrollTarget
scrollTarget most likely removes the action from happen for frame.
takes FRAMEEVENT_MOUSE_WHEEL and FRAMEEVENT_SLIDER_VALUE_CHANGED from TasFrameAction for this frame
TasEditBoxAction(frame[, actionEnter, actionEdit])
skip an action to not have one for that event
function(frame, player, text)
TasDialogAction(frame, function(frame, player, accept))
TasCheckBoxAction(frame, function(frame, player, checked))
TasFrameMouseMoveAction(frame, actionEnter(frame, player), actionLeave(frame, player), actionWheel(frame, player, upwards))
TasFrameMouseUpAction(frame, function(frame, player, rightClick)
Happens when the mouse click is released over frame
rightClick does not work probably during Paused Games
takes FRAMEEVENT_MOUSE_UP
TasMenuAction(frame, function(frame, player, value))
for POPUPMENU
functions above use an entry in TasFrameAction
TasFrameAction(frame, action, frameEvent)
action = function(frame, player, value, text)
]]
TasFrameAction = setmetatable({
EVENTNAME= {
"CONTROL_CLICK", "MOUSE_ENTER", "MOUSE_LEAVE", "MOUSE_UP"
, "MOUSE_DOWN", "MOUSE_WHEEL", "CHECKBOX_CHECKED", "CHECKBOX_UNCHECKED"
, "EDITBOX_TEXT_CHANGED", "POPUPMENU_ITEM_CHANGED", "MOUSE_DOUBLECLICK", "SPRITE_ANIM_UPDATE"
, "SLIDER_VALUE_CHANGED", "DIALOG_CANCEL", "DIALOG_ACCEPT", "EDITBOX_ENTER"
}
,ERROR = function(x)
print("TasFrameAction - ERROR")
print("FrameName", BlzFrameGetName(BlzGetTriggerFrame()), TasFrameAction.EVENTNAME[GetHandleId(BlzGetTriggerFrameEvent())]
, "PlayerId:", GetPlayerId(GetTriggerPlayer())
-- , BlzGetTriggerFrameValue(), BlzGetTriggerFrameText()
)
print(x)
return x
end
}
,{
__call = function(table, frame, action, frameEvent)
-- first call?
if not TasFrameAction.Trigger then
-- FrameEventData
for i = 1, 16 do
TasFrameAction[ConvertFrameEventType(i)] = {}
end
-- yes, Create the Trigger and the click handler.
TasFrameAction.Trigger = CreateTrigger()
TriggerAddAction(TasFrameAction.Trigger, function()
local frame = BlzGetTriggerFrame()
local event = BlzGetTriggerFrameEvent()
-- call the action set for that frame&Event
if TasFrameAction[event][frame] then
xpcall(TasFrameAction[event][frame], TasFrameAction.ERROR, frame, GetTriggerPlayer(), BlzGetTriggerFrameValue(), BlzGetTriggerFrameText())
--TasFrameAction[event][frame](frame, GetTriggerPlayer(), BlzGetTriggerFrameValue(), BlzGetTriggerFrameText())
end
frame = nil
event = nil
end)
end
-- create the click event only when it does not exist yet.
if not TasFrameAction[frameEvent][frame] then
BlzTriggerRegisterFrameEvent(TasFrameAction.Trigger, frame, frameEvent)
end
-- Using [frameEvent][frame] brings a fixed amout of Tables.
TasFrameAction[frameEvent][frame] = action
end
})
TasSliderAction = setmetatable({
AvoidPoll = __jarray(true) -- default value (true) do not trigger the same value multiple times in a row
,StepSize = {}
,Target = { } -- some other Frame get scrolled?
,WHEEL = function(frame, player, value, text)
if GetLocalPlayer() == player then
local target = TasSliderAction.Target[frame]
if not target then target = frame end
if value > 0 then
BlzFrameSetValue(target, BlzFrameGetValue(target) + TasSliderAction.StepSize[frame])
else
BlzFrameSetValue(target, BlzFrameGetValue(target) - TasSliderAction.StepSize[frame])
end
end
end
,VALUE = function(frame, player, value, text)
if not TasSliderAction[frame] then return end
-- avoid Polling
if not TasSliderAction.AvoidPoll[frame] or TasSliderAction.AvoidPollData[player][frame] ~= value then
TasSliderAction.AvoidPollData[player][frame] = value
TasSliderAction[frame](frame, player, value)
end
end
}
,{__call = function(table, frame, action, stepSize, scrollTarget, allowPoll)
-- first call?
if not TasSliderAction.AvoidPollData then
TasSliderAction.AvoidPollData = {}
for i=0, bj_MAX_PLAYER_SLOTS - 1 do TasSliderAction.AvoidPollData[Player(i)] = __jarray(0.0) end
end
if allowPoll ~= nil then TasSliderAction.AvoidPoll[frame] = not allowPoll end
TasFrameAction(frame, TasSliderAction.WHEEL, FRAMEEVENT_MOUSE_WHEEL)
TasFrameAction(frame, TasSliderAction.VALUE, FRAMEEVENT_SLIDER_VALUE_CHANGED)
if type(action) =="function" then
TasSliderAction[frame] = action
end
TasSliderAction.StepSize[frame] = stepSize or 1
TasSliderAction.Target[frame] = scrollTarget
end
})
TasSliderAction.Set = TasSliderAction
TasButtonAction = setmetatable({
ACTION = function(frame, player, value, text)
-- remove Focus for the local clicking player
if player == GetLocalPlayer() then
BlzFrameSetEnable(frame, false)
BlzFrameSetEnable(frame, true)
StopCamera()
end
-- call the action set for that frame
if TasButtonAction[frame] then TasButtonAction[frame](frame, player) end
end
},{
__call = function(table, frame, action)
TasFrameAction(frame, TasButtonAction.ACTION, FRAMEEVENT_CONTROL_CLICK)
TasButtonAction[frame] = action
end
})
TasButtonAction.Set = TasButtonAction
TasEditBoxAction = setmetatable({
A = {}
,B = {}
,ENTER = function(frame, player, value, text)
if TasEditBoxAction.A[frame] then TasEditBoxAction.A[frame](frame, player, text) end
end
,EDIT = function(frame, player, value, text)
if TasEditBoxAction.B[frame] then TasEditBoxAction.B[frame](frame, player, text) end
end
},{
__call = function(table, frame, actionEnter, actionEdit)
if actionEnter then TasFrameAction(frame, TasEditBoxAction.ENTER, FRAMEEVENT_EDITBOX_ENTER) end
if actionEdit then TasFrameAction(frame, TasEditBoxAction.EDIT, FRAMEEVENT_EDITBOX_TEXT_CHANGED) end
TasEditBoxAction.A[frame] = actionEnter
TasEditBoxAction.B[frame] = actionEdit
end
})
TasEditBoxAction.Set = TasEditBoxAction
TasDialogAction = setmetatable({
ACTION = function(frame, player)
if TasDialogAction[frame] then TasDialogAction[frame](frame, player, BlzGetTriggerFrameEvent() == FRAMEEVENT_DIALOG_ACCEPT) end
end
},{
__call = function(table, frame, action)
TasFrameAction(frame, TasDialogAction.ACTION, FRAMEEVENT_DIALOG_ACCEPT)
TasFrameAction(frame, TasDialogAction.ACTION, FRAMEEVENT_DIALOG_CANCEL)
TasDialogAction[frame] = action
end
})
TasDialogAction.Set = TasDialogAction
TasCheckBoxAction = setmetatable({
ACTION = function(frame, player)
if TasCheckBoxAction[frame] then TasCheckBoxAction[frame](frame, player, BlzGetTriggerFrameEvent() == FRAMEEVENT_CHECKBOX_CHECKED) end
end
},{
__call = function(table, frame, action)
TasFrameAction(frame, TasCheckBoxAction.ACTION, FRAMEEVENT_CHECKBOX_CHECKED)
TasFrameAction(frame, TasCheckBoxAction.ACTION, FRAMEEVENT_CHECKBOX_UNCHECKED)
TasCheckBoxAction[frame] = action
end
})
TasCheckBoxAction.Set = TasCheckBoxAction
TasFrameMouseMoveAction = setmetatable({
A = {}
,B = {}
,C = {}
,ENTER = function(frame, player)
if TasFrameMouseMoveAction.A[frame] then TasFrameMouseMoveAction.A[frame](frame, player) end
end
,LEAVE = function(frame, player)
if TasFrameMouseMoveAction.B[frame] then TasFrameMouseMoveAction.B[frame](frame, player) end
end
,WHEEL = function(frame, player, value)
if TasFrameMouseMoveAction.C[frame] then TasFrameMouseMoveAction.C[frame](frame, player, value > 0) end
end
},{
__call = function(table, frame, actionEnter, actionLeave, actionWheel)
if actionEnter then TasFrameAction(frame, TasFrameMouseMoveAction.ENTER, FRAMEEVENT_MOUSE_ENTER) end
if actionLeave then TasFrameAction(frame, TasFrameMouseMoveAction.LEAVE, FRAMEEVENT_MOUSE_LEAVE) end
if actionWheel then TasFrameAction(frame, TasFrameMouseMoveAction.WHEEL, FRAMEEVENT_MOUSE_WHEEL) end
TasFrameMouseMoveAction.A[frame] = actionEnter
TasFrameMouseMoveAction.B[frame] = actionLeave
TasFrameMouseMoveAction.C[frame] = actionWheel
end
})
TasFrameMouseMoveAction.Set = TasFrameMouseMoveAction
TasFrameMouseUpAction = setmetatable({
TriggerCount = 0
,ACTION = function(frame, player)
-- during Pause EVENT_PLAYER_MOUSE_UP does not work, -> when The counter didn't increase since last Time do not allow this count as right click
local clickWorked = GetTriggerExecCount(TasFrameMouseUpAction.MouseTrigger) > TasFrameMouseUpAction.TriggerCount
if TasFrameMouseUpAction[frame] then TasFrameMouseUpAction[frame](frame, player, TasFrameMouseUpAction.RightClick[player] and clickWorked) end
TasFrameMouseUpAction.TriggerCount = GetTriggerExecCount(TasFrameMouseUpAction.MouseTrigger)
end
},{
__call = function(table, frame, action)
if not TasFrameMouseUpAction.MouseTrigger then
TasFrameMouseUpAction.RightClick = __jarray(false)
TasFrameMouseUpAction.MouseTrigger = CreateTrigger()
for i = 0, bj_MAX_PLAYERS - 1 do
TriggerRegisterPlayerEvent(TasFrameMouseUpAction.MouseTrigger, Player(i), EVENT_PLAYER_MOUSE_UP)
end
TriggerAddAction(TasFrameMouseUpAction.MouseTrigger, function()
TasFrameMouseUpAction.RightClick[GetTriggerPlayer()] = GetHandleId(BlzGetTriggerPlayerMouseButton()) == GetHandleId(MOUSE_BUTTON_TYPE_RIGHT)
end)
end
TasFrameAction(frame, TasFrameMouseUpAction.ACTION, FRAMEEVENT_MOUSE_UP)
TasFrameMouseUpAction[frame] = action
end
})
TasFrameMouseUpAction.Set = TasFrameMouseUpAction
TasMenuAction = setmetatable({
ACTION = function(frame, player, value)
if TasMenuAction[frame] then TasMenuAction[frame](frame, player, value) end
end
},{
__call = function(table, frame, action)
TasFrameAction(frame, TasMenuAction.ACTION, FRAMEEVENT_POPUPMENU_ITEM_CHANGED)
TasMenuAction[frame] = action
end
})
TasMenuAction.Set = TasMenuAction
--[[
TasFrameList Simple V1.2 by Tasyen
A Frame that contains 1 Col of Frames, a fraction of the added Frames is displayed at once. The user can change the shown frames by scrolling a slider.
FrameLists can also contain a TasFrameList.
The displayed amount of Frames depends on the TasFrameList size, this Size only changes when changed with BlzFrameSetSize or better the special version added into this.
TasFrameList Simple does not require a fdf
can use TasFrameAction
function TasFrameList.create([margin, parent, createContext, frame])
creates a new TasFrameList
no frame -> create a new frame for parent
function TasFrameList.define([margin, frame, createContext])
wrapper for .create(), make frame a TasFrameList
function TasFrameList.setSize(frameListTable, xSize, ySize)
a custom Width seter, it makes the slider more accurate without the slider can not be clicked correctly.
function TasFrameList.add(frameListTable, frame)
adds frame to as last element of frameListTable
function TasFrameList.remove(frameListTable, frame, noUpdate)
removes frame (can be a number) from frameListTable, skip noUpdate that is only used from TasFrameList.destory
function TasFrameList.update(frameListTable)
update the shown content, should be done automatic with user interaction
calls frameListTable.Action(frameListTable)
--]]
TasFrameList = {}
FrameList = TasFrameList --backwards compatible
function TasFrameList.create(margin, parent, createContext, frame)
local newObj = {}
if not createContext then createContext = 0 end
if not parent then parent = BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0) end
if not margin then margin = 0 end
if not frame then newObj.Frame = BlzCreateFrameByType("SLIDER", "FrameListFrame", parent, "", createContext)
else newObj.Frame = frame end
newObj.Slider = BlzCreateFrameByType("SLIDER", "FrameListSlider", newObj.Frame, "QuestMainListScrollBar", createContext)
newObj.Margin = margin
BlzFrameSetStepSize(newObj.Slider, 1)
BlzFrameClearAllPoints(newObj.Slider)
BlzFrameSetVisible(newObj.Slider, true)
BlzFrameSetMinMaxValue(newObj.Slider, 1, 1)
BlzFrameSetPoint(newObj.Slider, FRAMEPOINT_TOPRIGHT, newObj.Frame, FRAMEPOINT_TOPRIGHT, 0, 0)
local xSize, ySize= 0.012, 0.139
if frame then xSize, ySize = BlzFrameGetWidth(frame),BlzFrameGetHeight(frame) end
TasFrameList.setSize(newObj, xSize, ySize)
newObj.Content = {}
TasFrameList[newObj.Slider] = newObj
TasFrameList[newObj.Frame] = newObj
if TasSliderAction then -- have TasFraneAction?
TasSliderAction(newObj.Slider, TasFrameList.TasSliderAction, 1)
TasSliderAction(newObj.Frame, nil, 1, newObj.Slider)
else
if not TasFrameList.SliderTrigger then
TasFrameList.SliderTrigger = CreateTrigger()
TriggerAddAction(newObj.SliderTrigger, TasFrameList.SliderAction)
end
BlzTriggerRegisterFrameEvent(TasFrameList.SliderTrigger, newObj.Slider , FRAMEEVENT_SLIDER_VALUE_CHANGED)
BlzTriggerRegisterFrameEvent(TasFrameList.SliderTrigger, newObj.Slider , FRAMEEVENT_MOUSE_WHEEL)
end
return newObj
end
function TasFrameList.define(margin, frame, createContext) return TasFrameList.create(margin, nil, createContext, frame) end
function TasFrameList.update(frameListTable)
local sliderValue = R2I( BlzFrameGetValue(frameListTable.Slider))
local sizeFrameList = BlzFrameGetHeight(frameListTable.Frame)
local contentCount = #frameListTable.Content
for index = 1, contentCount, 1 do
local frame = frameListTable.Content[index]
if index < sliderValue then
--print("Hide Prev", index)
BlzFrameSetVisible(frame, false)
else
local sizeFrame = BlzFrameGetHeight(frame)
sizeFrameList = sizeFrameList - sizeFrame
BlzFrameClearAllPoints(frame)
if index == sliderValue then
BlzFrameSetVisible(frame, true)
BlzFrameSetPoint(frame, FRAMEPOINT_TOPRIGHT, frameListTable.Slider, FRAMEPOINT_TOPLEFT, 0, 0)
else
BlzFrameSetVisible(frame, sizeFrameList >= 0)
BlzFrameSetPoint(frame, FRAMEPOINT_TOPRIGHT, frameListTable.Content[index - 1], FRAMEPOINT_BOTTOMRIGHT, 0, -frameListTable.Margin)
end
end
end
if frameListTable.Action then frameListTable.Action(frameListTable) end
end
TasFrameList.setContentPoints = TasFrameList.update
function TasFrameList.setSize(frameListTable, xSize, ySize)
BlzFrameSetSize(frameListTable.Frame, xSize, ySize)
BlzFrameSetSize(frameListTable.Slider, 0.012, ySize)
end
function TasFrameList.add(frameListTable, frame)
table.insert(frameListTable.Content, frame)
BlzFrameSetParent(frame, frameListTable.Frame)
BlzFrameSetMinMaxValue(frameListTable.Slider, 1, #frameListTable.Content)
TasFrameList.update(frameListTable)
end
function TasFrameList.remove(frameListTable, frame, noUpdate)
local removed = nil
if not frameListTable or #frameListTable.Content == 0 then return false end
if not frame then
removed = table.remove(frameListTable.Content)
elseif type(frame) == "number" then
removed = table.remove( frameListTable.Content, frame)
else
for index, value in ipairs(frameListTable.Content)
do
if frame == value then
removed = table.remove(frameListTable.Content, index)
break
end
end
end
if removed then
BlzFrameClearAllPoints(removed)
BlzFrameSetVisible(removed, false)
if not noUpdate then
BlzFrameSetMinMaxValue(frameListTable.Slider, 1, #frameListTable.Content)
BlzFrameSetValue(frameListTable.Slider, 1)
TasFrameList.update(frameListTable)
end
end
return #frameListTable.Content
end
function TasFrameList.SliderAction()
local frame = BlzGetTriggerFrame()
if GetLocalPlayer() == GetTriggerPlayer() then
if BlzGetTriggerFrameEvent() == FRAMEEVENT_MOUSE_WHEEL then
if BlzGetTriggerFrameValue() > 0 then
BlzFrameSetValue(frame, BlzFrameGetValue(frame) + 1)
else
BlzFrameSetValue(frame, BlzFrameGetValue(frame) - 1)
end
end
TasFrameList.update(TasFrameList[frame])
end
end
function TasFrameList.TasSliderAction(frame, player, value)
if GetLocalPlayer() == player then
TasFrameList.update(TasFrameList[frame])
end
end
--[[
TasFrameFlow V1.1 by Tasyen
TasFrameFlow is a system that automatic fills a Frame from TopLeft with frames. Further frame try to be placed next to the previous one, if that fails TasFrameFlow starts a new row.
This new added Frame is the previous for the next frame regardless if it started a new Row or not.
The Frame using TasFrameFlow and the frames added need a size for this system to work.
function TasFrameFlow.create(frame[, addSlider, marginX, marginY])
creates a new TasFrameFlow for frame returns frameFlowTable.
Having marginX space between 2 frames in 1 row and marginY space between 2 rows
addSlider(true) creats a slider so the user can alter the frame shown at topLeft with that moves all Content.
The slider will take over the size of the frame on creation, when the size changes you or was not right on that moment use TasFrameFlow.updateSlider.
function TasFrameFlow.add(frameFlowTable, frame[, noUpdate])
adds frame to the frameFlowTable. noUpdate (true) does not fit the new Frame into the Frame managed by TasFrameFlow.
frame becomes a children of the Frame managed by frameFlowTable
function TasFrameFlow.remove(frameFlowTable, [frame, noUpdate])
removes frame (can be a number) from the frameFlowTable.
calling this will also call TasFrameFlow.fit(frameFlowTable, 1).
noUpdate (true) prevents calling TasFrameFlow.fit. Recommented when used multiple times in a row.
returns true if the frameFlowTable still contains frames
function TasFrameFlow.fit(frameFlowTable[, startingIndex])
update the position and visibility of all content of frameFlowTable.
starting with Content[startingIndex] at TopLeft.
Frames with a lower index are hidden.
no startingIndex is the same as 1.
Use this function to scroll or after the size of the parentFrame or one of the content changed.
This is also used after an TasFrameFlow
calls frameFlowTable.Action(frameFlowTable)
function TasFrameFlow.updateSlider(frameFlowTable)
updates the Size of the slider to the current Size of the Frame managed by this frameFlowTable
--]]
TasFrameFlow = {}
FrameFlow = TasFrameFlow
-- creates a new TasFrameFlow filling frame
function TasFrameFlow.create(frame, addSlider, marginX, marginY)
local frameFlowTable = {}
frameFlowTable.Frame = frame --the frame filled
frameFlowTable.Content = {} -- array of frames
if addSlider then
frameFlowTable.Slider = BlzCreateFrameByType("SLIDER", "FrameFlowSlider", frame, "QuestMainListScrollBar", 0)
-- frameFlowTable.Slider = BlzCreateFrame("QuestMainListScrollBar", frame, "", 0)
TasFrameFlow[frameFlowTable.Slider] = frameFlowTable
BlzFrameClearAllPoints(frameFlowTable.Slider)
BlzFrameSetStepSize(frameFlowTable.Slider, 1)
BlzFrameSetSize(frameFlowTable.Slider, 0.012, BlzFrameGetHeight(frame))
BlzFrameSetPoint(frameFlowTable.Slider, FRAMEPOINT_RIGHT, frame, FRAMEPOINT_RIGHT, 0, 0)
BlzFrameSetVisible(frameFlowTable.Slider, true)
BlzFrameSetMinMaxValue(frameFlowTable.Slider, 1, 1)
TasSliderAction(frameFlowTable.Slider, TasFrameFlow.SliderAction)
end
if not marginX then marginX = 0 end
frameFlowTable.MarginX = marginX --space between 2 frames in one row
if not marginY then marginY = 0 end
frameFlowTable.MarginY = marginY --additional space between 2 rows
return frameFlowTable
end
function TasFrameFlow.calc(frameFlowTable, frame, prevFrame)
local rowSizeX = frameFlowTable.CurrentRowRemainX
local rowSizeY = frameFlowTable.CurrentRowSizeY
local offsetY = frameFlowTable.CurrentOffsetY
local parentframeSizeX = BlzFrameGetWidth(frameFlowTable.Frame)
if frameFlowTable.Slider then --if there is an Slider reduce the used Space
parentframeSizeX = parentframeSizeX - BlzFrameGetWidth(frameFlowTable.Slider)
end
local parentframeSizeY = BlzFrameGetHeight(frameFlowTable.Frame)
rowSizeX = rowSizeX - BlzFrameGetWidth(frame) - frameFlowTable.MarginX
BlzFrameClearAllPoints(frame)
if rowSizeX >= 0 then
BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, prevFrame, FRAMEPOINT_TOPRIGHT, frameFlowTable.MarginX, 0)
rowSizeY = math.max( rowSizeY, BlzFrameGetHeight(frame))
elseif rowSizeX < 0 then
offsetY = offsetY + rowSizeY + frameFlowTable.MarginY
rowSizeX = parentframeSizeX - BlzFrameGetWidth(frame)
BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, frameFlowTable.Frame, FRAMEPOINT_TOPLEFT, 0, -offsetY)
rowSizeY = BlzFrameGetHeight(frame)
end
BlzFrameSetVisible(frame, offsetY + BlzFrameGetHeight(frame) <= parentframeSizeY)
prevFrame = frame
--save this values to simple down adding 1 frame
frameFlowTable.CurrentRowRemainX = rowSizeX
frameFlowTable.CurrentRowSizeY = rowSizeY
frameFlowTable.CurrentOffsetY = offsetY
end
--refits all frames, startingIndex is the index of frameFlowTable.Content being placed at TopLeft of the parent Frame
function TasFrameFlow.fit(frameFlowTable, startingIndex)
if not frameFlowTable.Content or #frameFlowTable.Content == 0 then return end
if not startingIndex then startingIndex = 1 end
--hide frames before the starting Index
for index = 1, startingIndex - 1, 1
do
BlzFrameSetVisible(frameFlowTable.Content[index], false)
end
local frame = frameFlowTable.Content[startingIndex]
BlzFrameClearAllPoints(frame)
BlzFrameSetVisible(frame, true)
BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, frameFlowTable.Frame, FRAMEPOINT_TOPLEFT, 0, 0)
local prevFrame = frame
--reset values
frameFlowTable.CurrentRowRemainX = BlzFrameGetWidth(frameFlowTable.Frame) - BlzFrameGetWidth(frame)
if frameFlowTable.Slider then --if there is an Slider reduce the used Space
frameFlowTable.CurrentRowRemainX = frameFlowTable.CurrentRowRemainX - BlzFrameGetWidth(frameFlowTable.Slider)
end
frameFlowTable.CurrentRowSizeY = BlzFrameGetHeight(frame)
frameFlowTable.CurrentOffsetY = 0
for index = startingIndex + 1, #frameFlowTable.Content, 1
do
local frame = frameFlowTable.Content[index]
TasFrameFlow.calc(frameFlowTable, frame, prevFrame)
prevFrame = frame
end
if frameFlowTable.Action then frameFlowTable.Action(frameFlowTable) end
end
--fit in a new frame at the end of the table
function TasFrameFlow.fitNewFrame(frameFlowTable, frame)
TasFrameFlow.calc(frameFlowTable, frame, frameFlowTable.Content[#frameFlowTable.Content - 1])
end
function TasFrameFlow.remove(frameFlowTable, frame, noUpdate)
local removed = nil
if not frameFlowTable or #frameFlowTable.Content == 0 then return false end
if not frame then
removed = table.remove(frameFlowTable.Content)
elseif type(frame) == "number" then
removed = table.remove( frameFlowTable.Content, frame)
else
for index, value in ipairs(frameFlowTable.Content)
do
if frame == value then
removed = table.remove(frameFlowTable.Content, index)
break
end
end
end
if removed then
BlzFrameClearAllPoints(removed)
BlzFrameSetVisible(removed, false)
BlzFrameSetMinMaxValue(frameFlowTable.Slider, 1, #frameFlowTable.Content)
if not noUpdate then
TasFrameFlow.fit(frameFlowTable, 1)
end
end
return #frameFlowTable.Content
end
function TasFrameFlow.add(frameFlowTable, frame, noUpdate)
table.insert(frameFlowTable.Content, frame)
BlzFrameSetParent(frame, frameFlowTable.Frame)
BlzFrameSetMinMaxValue(frameFlowTable.Slider, 1, #frameFlowTable.Content)
if not noUpdate then
if #frameFlowTable.Content == 1 then
TasFrameFlow.fit(frameFlowTable, 1)
else
TasFrameFlow.fitNewFrame(frameFlowTable, frame)
end
end
end
function TasFrameFlow.updateSlider(frameFlowTable)
if frameFlowTable.Slider then
BlzFrameSetSize(frameFlowTable.Slider, 0.012, BlzFrameGetHeight(frameFlowTable.Frame))
end
end
function TasFrameFlow.SliderAction(frame, player, value)
if GetLocalPlayer() == player then
TasFrameFlow.fit(TasFrameFlow[frame], value)
end
end
--[[
TasWindow V1.4 by Tasyen
The idea of TasWindow is to have a standart Frame in which you only have to care about how to manage your content onto the ContentPane without bothering the border etc.
nofdf has no window textures
windowTable
.WindowHead
.WindowCloseButton
.WindowCloseButtonType -- true -> hide false -> colapse
.ColapseResize -- true -> WindowPane ySize = 0.0001 on colapse. copies TasWindow.ColapseResize on creation
.WindowPane --ContentPane
.TasWindow --no fdf/variation nil -> same as .WindowPane with fdf this is the background & border
.UserAction --closeButton
.WindowSizeX -- use TasWindow.setSize
.WindowSizeY
function TasWindow.create([title, hide, createContext, parent], variation)
creates a window using the local players race border.
A TasWindow consists of a Pane, a Head, a Title a closeButton and a Border.
The Pane is mean to carry your custom Frame and contains only the space between the borders of the TasWindow.
The closeButton is part of the Head and has 2 modes:
hide(true) close the window and head when clicked for the local Player. In such a case the user needs a way to show the window.WindowHead again, if that is wanted.
hide (false or nil) The close Button toggles the visibility of the TasWindow, the WindowHead remains visibile.
createContext nil = 0, use a specific one, if you want to access frames over BlzGetFrameByName
parent nil = BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0).
The window is posed over windowTable.WindowHead, all other frames of window are linked based on the heads position.
variation is nil or 0 to 7 it chooses the background and border.
Without fdf/toc variation is not used.
returns the new created windowTable
function TasWindow.setAbsPoint(windowTable, framepoint, x, y)
function TasWindow.setSize(windowTable[, xSize, ySize, tempChange])
without any arguments reset the size to the last non tempChange one
without tempChange the window will change its current size and define a new default size
you can set an TasWindow action that happens when the Close Button is clicked, visible is an async value of the content Pane.
windowTable.UserAction = function(windowTable, player, visible) end
--]]
TasWindow = {
TocPath = "war3mapimported/window.toc" -- where is the file inside your map, (optional, works without)
,CharClose = "X"
,CharExpand = "v"
,CharColapse = "^"
,ColapseResize = false -- default value
,WindowSizeX = 0.18 -- default value
,WindowSizeY = 0.18 -- default value
}
Window = TasWindow -- backwards compatible remove when unneeded
function TasWindow.create(title, hide, createContext, parent, variation)
TasWindow.HasToc = BlzLoadTOCFile(TasWindow.TocPath)
local windowTable = {}
if not createContext then createContext = 0 end --user does not care use 0.
if not parent then parent = BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0) end
if TasWindow.HasToc then
windowTable.WindowHead = BlzCreateFrame("WindowHead", parent, 0, createContext)
windowTable.WindowHeadText = BlzGetFrameByName("WindowHeadText", createContext) --styling
windowTable.WindowHeadBackdrop = BlzGetFrameByName("WindowHeadBackdrop", createContext)
--windowTable.TasWindow = BlzGetFrameByName("TasWindow", createContext) --this is the background and border of the ContentPane
if variation then
windowTable.TasWindow = TasWindow.createAlternativeWindow(variation, windowTable.WindowHead)
windowTable.WindowPane = BlzCreateFrameByType("FRAME", "WindowPane", windowTable.TasWindow, "", createContext)
else
windowTable.TasWindow = BlzCreateFrameByType("FRAME", "WindowPane", windowTable.WindowHead, "", createContext)
windowTable.WindowPane = windowTable.TasWindow
end
windowTable.WindowCloseButton = BlzGetFrameByName("WindowCloseButton", createContext) --press this to hide the window
windowTable.WindowCloseButtonText = BlzGetFrameByName("WindowCloseButtonText", createContext) --styling
BlzFrameSetPoint(windowTable.TasWindow, FRAMEPOINT_TOPLEFT, windowTable.WindowHead, FRAMEPOINT_BOTTOMLEFT, 0, 0.001)
BlzFrameSetSize(windowTable.TasWindow, TasWindow.WindowSizeX + 0.02, TasWindow.WindowSizeY + 0.02)
BlzFrameSetPoint(windowTable.WindowPane, FRAMEPOINT_TOPLEFT, windowTable.TasWindow, FRAMEPOINT_TOPLEFT, 0.01, -0.01)
BlzFrameSetPoint(windowTable.WindowPane, FRAMEPOINT_BOTTOMRIGHT, windowTable.TasWindow, FRAMEPOINT_BOTTOMRIGHT, -0.01, 0.01)
else
-- Has No TOC/fdf
windowTable.WindowHead = BlzCreateFrameByType("GLUETEXTBUTTON", "WindowHead", parent, "ScriptDialogButton", createContext)
windowTable.WindowCloseButton = BlzCreateFrameByType("GLUETEXTBUTTON", "WindowCloseButton", windowTable.WindowHead, "ScriptDialogButton", createContext) --press this to hide the window
windowTable.WindowPane = BlzCreateFrameByType("SLIDER", "WindowPane", windowTable.WindowHead, "", createContext)
windowTable.TasWindow = windowTable.WindowPane
BlzFrameSetSize(windowTable.WindowCloseButton, 0.0275, 0.0275)
BlzFrameSetSize(windowTable.WindowHead, 0.1725, 0.0275)
BlzFrameSetPoint(windowTable.WindowPane, FRAMEPOINT_TOPLEFT, windowTable.WindowHead, FRAMEPOINT_BOTTOMLEFT, 0, 0.001)
BlzFrameSetPoint(windowTable.WindowCloseButton, FRAMEPOINT_LEFT, windowTable.WindowHead, FRAMEPOINT_RIGHT, -0.005, 0)
end
BlzFrameSetSize(windowTable.WindowPane, TasWindow.WindowSizeX, TasWindow.WindowSizeY)
if hide then BlzFrameSetText(windowTable.WindowCloseButton, TasWindow.CharClose) else BlzFrameSetText(windowTable.WindowCloseButton, TasWindow.CharColapse) end
windowTable.ColapseResize = TasWindow.ColapseResize
windowTable.WindowCloseButtonType = hide
if title then
BlzFrameSetText(windowTable.WindowHead, title)
end
windowTable.WindowSizeX = BlzFrameGetWidth(windowTable.TasWindow)
windowTable.WindowSizeY = BlzFrameGetHeight(windowTable.TasWindow)
TasWindow[windowTable.TasWindow] = windowTable --the TasWindow and the WindowHead know the table, the others know the TasWindow by using BlzFrameGetParent
TasWindow[windowTable.WindowHead] = windowTable
TasButtonAction(windowTable.WindowHead, TasWindow.HeadAction)
TasButtonAction(windowTable.WindowCloseButton, TasWindow.CloseButtonAction)
return windowTable
end
function TasWindow.setAbsPoint(windowTable, framepoint, x, y)
BlzFrameSetAbsPoint(windowTable.WindowHead, framepoint, x, y)
end
function TasWindow.createAlternativeWindow(variation, parent)
if not variation or variation == 0 then
return BlzCreateFrame("WindowTemplateRace", parent, 0, 0)
elseif variation == 1 then
return BlzCreateFrame("WindowTemplateHuman", parent, 0, 0)
elseif variation == 2 then
return BlzCreateFrame("WindowTemplateOrc", parent, 0, 0)
elseif variation == 3 then
return BlzCreateFrame("WindowTemplateUndead", parent, 0, 0)
elseif variation == 4 then
return BlzCreateFrame("WindowTemplateNightelf", parent, 0, 0)
elseif variation == 5 then
return BlzCreateFrame("WindowTemplateToolTip", parent, 0, 0)
elseif variation == 6 then
return BlzCreateFrame("WindowTemplateEscMenu", parent, 0, 0)
elseif variation == 7 then
return BlzCreateFrame("WindowTemplateGame", parent, 0, 0)
end
return BlzCreateFrame("WindowTemplateRace", parent, 0, 0)
end
function TasWindow.setSize(windowTable, xSize, ySize, tempChange)
if xSize then
BlzFrameSetSize(windowTable.TasWindow, xSize, ySize)
if windowTable.WindowPane ~= windowTable.TasWindow then BlzFrameSetSize(windowTable.WindowPane, xSize - 0.02, ySize - 0.02) end
BlzFrameSetSize(windowTable.WindowHead, xSize - 0.025, 0.0275) -- -0.025 is the closebutton
if not tempChange then
windowTable.WindowSizeX = xSize
windowTable.WindowSizeY = ySize
end
else
BlzFrameSetSize(windowTable.TasWindow, windowTable.WindowSizeX, windowTable.WindowSizeY)
if windowTable.WindowPane ~= windowTable.TasWindow then BlzFrameSetSize(windowTable.WindowPane, windowTable.WindowSizeX - 0.02, windowTable.WindowSizeY - 0.02) end
BlzFrameSetSize(windowTable.WindowHead, windowTable.WindowSizeX - 0.025 , 0.0275)
end
end
function TasWindow.HeadAction(frame, player)
--when the title is clicked(released)
end
--more of an attribute hence CamelCase
function TasWindow.CloseButtonAction(frame, player)
local windowTable = TasWindow[BlzFrameGetParent(frame)]
if GetLocalPlayer() == player then
if not windowTable.WindowCloseButtonType then
BlzFrameSetVisible(windowTable.TasWindow, not BlzFrameIsVisible(windowTable.TasWindow))
if BlzFrameIsVisible(windowTable.TasWindow) then
BlzFrameSetText(windowTable.WindowCloseButton, TasWindow.CharColapse)
if windowTable.ColapseResize then TasWindow.setSize(windowTable) end
else
BlzFrameSetText(windowTable.WindowCloseButton, TasWindow.CharExpand)
if windowTable.ColapseResize then TasWindow.setSize(windowTable, windowTable.WindowSizeX, 0.001, true) end
end
else
BlzFrameSetVisible(windowTable.WindowHead, false)
end
end
if windowTable.UserAction then windowTable.UserAction(windowTable, player, BlzFrameIsVisible(windowTable.TasWindow)) end
end
--[[ TasWindowTab Fused V1.4
plugin for TasWindow by Tasyen.
Instead of placing stuff onto the ContentPane one adds Frames as Tabs (pages). The current shown Tab is swaped by the user clicking TabButtons.
First Create a TasWindow then add a frame as Tab to the TasWindow.
Having a tab does not stopp one from placing something onto the ContentPane itself.
addition to TasWindow "class"
.Tabs[1 to x] -- each a windowTabTable
.TabActive
.TabPos -- Where the TabButtons are placed relative to the TasWindow. copies TasWindow.TabPos.Default when not set before addTab is called.
.IconButtonInherit -- new I
.IconButtonSize
windowTabTable
.Button
.Frame
.SizeX
.SizeY
.ShowAction -- set over setTabButtonAction
function TasWindow.addTabIcon(windowTable, frame, icon, doNotStretch, xSize, ySize)
wrapper for TasWindow.addTab that creates some icon button
uses TasWindow.IconButtonInherit & TasWindow.IconButtonSize
function TasWindow.addTab(windowTable, frame, [buttonText, doNotStretch, xSize, ySize])
adds frame as Tab to windowTable
buttonText is displayed on the Button to swap to this tab
buttonText can be a button which is than used as tabButton. sets TasButtonAction for it
doNotStretch(true) does not alter the size of frame, also pos it with its center to the WindowPane center
xSize and ySize when set, will alter the size of windowTable as long this tab is shown
Does not support SimpleFrames, directly.
frames parent, position, size (without doNotStretch) are altered in the process.
returns the new created windowTabtable
function TasWindow.setTabButtonAction(windowTabTable, actionFunction)
calls actionFunction when this button is clicked and shown.
Beaware that the action is called async.
actionFunction = function(windowTable, windowTabTable) end
Will instantly call the actionFunction if the tab is the current active tab
function TasWindow.showTab(windowTable, windowTabTable[, player])
show windowTabTable of windowTable to player
windowTabTable can be a index or a table, the table is expected to be a tabTable of the windowTable
player can be nil to affect all players
doesn't work that well with LeaderBoard, Multiboard, TimerDialog
Does not support simpleframes.
--]]
TasWindow.TabPos = {
Default = 1
-- {button1Pos, button1Relative, x2Pane, y2Pane , buttonXPos, ButtonXRelat, x2Prv, y2Prev, addgapToHead}
,{FRAMEPOINT_TOPRIGHT, FRAMEPOINT_TOPLEFT, 0, 0, FRAMEPOINT_TOPRIGHT, FRAMEPOINT_BOTTOMRIGHT, 0.000, 0.005} -- Left top -> Bot
,{FRAMEPOINT_BOTTOMRIGHT, FRAMEPOINT_BOTTOMLEFT, 0, 0, FRAMEPOINT_BOTTOMRIGHT, FRAMEPOINT_TOPRIGHT, 0.000, -0.005} -- Left Bot -> top
,{FRAMEPOINT_BOTTOMLEFT, FRAMEPOINT_TOPLEFT, 0, 0, FRAMEPOINT_BOTTOMLEFT, FRAMEPOINT_BOTTOMRIGHT, 0.005, 0.000, true} -- Top Left -> right
,{FRAMEPOINT_BOTTOMRIGHT, FRAMEPOINT_TOPRIGHT, 0, 0, FRAMEPOINT_BOTTOMRIGHT, FRAMEPOINT_BOTTOMLEFT, -0.005, 0.00, true} -- Top Right -> Left
,{FRAMEPOINT_TOPLEFT, FRAMEPOINT_BOTTOMLEFT, 0, 0, FRAMEPOINT_TOPLEFT, FRAMEPOINT_TOPRIGHT, 0.005, 0.000} -- Bottom Left -> Right
,{FRAMEPOINT_TOPRIGHT, FRAMEPOINT_BOTTOMRIGHT, 0, 0, FRAMEPOINT_TOPRIGHT, FRAMEPOINT_TOPLEFT, -0.005, 0.000} -- Bottom Right to Left
,{FRAMEPOINT_TOPLEFT, FRAMEPOINT_TOPRIGHT, 0, 0, FRAMEPOINT_TOPLEFT, FRAMEPOINT_BOTTOMLEFT, 0.000, 0.005} -- Right Top -> Bot
,{FRAMEPOINT_BOTTOMLEFT, FRAMEPOINT_BOTTOMRIGHT, 0, 0, FRAMEPOINT_BOTTOMLEFT, FRAMEPOINT_TOPLEFT, 0.000, -0.005} -- Right Bot -> Top
}
TasWindow.IconButtonInherit = "ScoreScreenTabButtonTemplate" -- Button Blueprint inherited, used without fdf
TasWindow.IconButtonSize = 0.025
function TasWindow.addTabIcon(windowTable, frame, icon, doNotStretch, xSize, ySize)
local tabButton
if TasWindow.HasToc then
tabButton = BlzCreateFrame("WindowTabIconButton", windowTable.WindowPane, 0, 0)
BlzFrameSetTexture(BlzGetFrameByName("WindowTabIconButtonBackdrop", 0), icon, 0, true)
BlzFrameSetTexture(BlzGetFrameByName("WindowTabIconButtonBackdropPushed", 0), icon, 0, true)
BlzFrameSetTexture(BlzGetFrameByName("WindowTabIconButtonBackdropDisabled", 0), icon, 0, true)
else
tabButton = BlzCreateFrameByType("BUTTON", "WindowTabButton", windowTable.WindowPane, TasWindow.IconButtonInherit, 0)
local iconframe = BlzCreateFrameByType("BACKDROP", "WindowTabIconButton", tabButton, "", 0)
BlzFrameClearAllPoints(tabButton)
BlzFrameSetAllPoints(iconframe, tabButton)
BlzFrameSetTexture(iconframe, icon, 0, true)
end
BlzFrameSetSize(tabButton, TasWindow.IconButtonSize, TasWindow.IconButtonSize)
return TasWindow.addTab(windowTable, frame, tabButton, doNotStretch, xSize, ySize)
end
function TasWindow.addTab(windowTable, frame, buttonText, doNotStretch, xSize, ySize)
--each Tab is an own Table
local windowTabTable = {}
if not windowTable.TabPos then windowTable.TabPos = TasWindow.TabPos.Default end
if not windowTable.Tabs then
--this is the first time this window gets tabs
windowTable.Tabs = {}
windowTable.TabActive = windowTabTable
end
--add the new TabTable into the array of windowTable
table.insert(windowTable.Tabs, windowTabTable)
local tabButton
if not buttonText or type(buttonText) == "string" then
if TasWindow.HasToc then
tabButton = BlzCreateFrame("WindowTabButton", windowTable.WindowPane, 0, 0)
else
tabButton = BlzCreateFrameByType("GLUETEXTBUTTON", "WindowTabButton", windowTable.WindowPane, "ScriptDialogButton", 0)
end
BlzFrameSetSize(tabButton, 0.06, 0.025)
if buttonText then
BlzFrameSetText(tabButton, buttonText)
else
BlzFrameSetText(tabButton, #windowTable.Tabs)
end
else
tabButton = buttonText
end
TasWindow[tabButton] = windowTabTable
TasWindow[windowTabTable] = windowTable
--fit the given frame into the Content Pane?
if not doNotStretch then
BlzFrameSetAllPoints(frame, windowTable.WindowPane)
BlzFrameSetSize(frame, BlzFrameGetWidth(windowTable.WindowPane), BlzFrameGetHeight(windowTable.WindowPane))
else
--only center it
BlzFrameClearAllPoints(frame)
BlzFrameSetPoint(frame, FRAMEPOINT_CENTER, windowTable.WindowPane, FRAMEPOINT_CENTER, 0, 0)
end
BlzFrameSetParent(frame, windowTable.WindowPane)
windowTabTable.Button = tabButton
windowTabTable.Frame = frame
windowTabTable.SizeX = xSize
windowTabTable.SizeY = ySize
TasButtonAction(tabButton, TasWindow.TabButtonAction)
local usedPos = windowTable.TabPos
local usedPosData = TasWindow.TabPos[usedPos]
--pos the tab button
if #windowTable.Tabs == 1 then
--the first button is located at Top Left of the TasWindow
BlzFrameSetVisible(frame, true)
BlzFrameSetPoint(tabButton, usedPosData[1], windowTable.TasWindow, usedPosData[2], usedPosData[3], usedPosData[4])
--hide the new tab button, there is nothing to choose yet.
BlzFrameSetVisible(windowTable.Tabs[1].Button, false)
TasWindow.showTab(windowTable, windowTabTable)
else
--further ones are located below to the previous one
--this is not the first added one hide it.
if usedPosData[9] then
BlzFrameSetPoint(windowTable.TasWindow, FRAMEPOINT_TOPLEFT, windowTable.WindowHead, FRAMEPOINT_BOTTOMLEFT, 0, 0.001 - BlzFrameGetHeight(tabButton))
end
BlzFrameSetVisible(frame, false)
BlzFrameSetPoint(tabButton, usedPosData[5], windowTable.Tabs[#windowTable.Tabs - 1].Button, usedPosData[6], usedPosData[7], usedPosData[8])
BlzFrameSetVisible(windowTable.Tabs[1].Button, true)
end
return windowTabTable
end
function TasWindow.setTabButtonAction(windowTabTable, actionFunction)
windowTabTable.ShowAction = actionFunction
if TasWindow[windowTabTable].TabActive == windowTabTable then
actionFunction(TasWindow[windowTabTable], windowTabTable)
end
end
function TasWindow.showTab(windowTable, windowTabTable, player)
if player and player ~= GetLocalPlayer() then return end
if windowTable.TabActive then
BlzFrameSetVisible(windowTable.TabActive.Frame, false)
end
if type(windowTabTable) == "number" then
windowTabTable = windowTable.Tabs[windowTabTable]
end
BlzFrameSetVisible(windowTabTable.Frame, true)
windowTable.TabActive = windowTabTable
if windowTabTable.SizeX then
TasWindow.setSize(windowTable, windowTabTable.SizeX + 0.02, windowTabTable.SizeY + 0.02, true)
BlzFrameSetSize(windowTabTable.Frame, BlzFrameGetWidth(windowTable.WindowPane), BlzFrameGetHeight(windowTable.WindowPane))
else
TasWindow.setSize(windowTable)
end
--custom user action when showing this Tab
if windowTabTable.ShowAction then
windowTabTable.ShowAction(windowTable, windowTabTable)
end
end
--more of an attribute hence CamelCase
function TasWindow.TabButtonAction(button, player)
local windowTable = TasWindow[BlzFrameGetParent(BlzFrameGetParent(button))]
local windowTabTable = TasWindow[button]
if GetLocalPlayer() == player then
TasWindow.showTab(windowTable, windowTabTable)
end
end
--[[
TasSliderControl V0.9 by Tasyen
This generates Sliders with a Label and tooltips showing min max current value. The idea is to simple down slider usage.
function TasSliderControl.new(valueChangeActionFunction[, min, max, default, step, labelText, sizeText, sizeSlider, name, parent, createContext])
this creates an slider with Label that executes valueChangeActionFunction when the value changes, the slider can be scrolled with the mouse whell.
valueChangeActionFunction is called for all players when the sliders value changes, the function has one argument the sliderObject, normal FrameEvent getters are valid here.
name is an suffix for all frames created by TasSliderControl, it only is relevant for BlzGetFrameByName or BlzFrameGetName
sizeText + sizeSlider is the total screensize this takes
default is the value reseted to when using TasSliderControl.reset
the Label and Slider are placed into a container FRAME. Use returnValue.Frame to move/use the container.
returns a table
function TasSliderControl.reset(sliderObject[, player])
sets the slider of that sliderObject to the default Value will evoke the action, when not using player all players are affected
--]]
TasSliderControl = {}
TasSliderControl.PercentChar = "\x25"
SliderControl = TasSliderControl
TasSliderControl.ValueAction = function(frame, player, value)
local sliderObject = TasSliderControl[frame]
--update the current text to the new value, but only if the local player was the player who changed the value
if GetLocalPlayer() == player then
BlzFrameSetText(sliderObject.TextCurrent, string.format(sliderObject.Format, BlzFrameGetValue(frame)))
end
--when there is an action call it
if sliderObject.Action then
sliderObject.Action(sliderObject)
end
end
function TasSliderControl.reset(sliderObject, player)
if not player or GetLocalPlayer() == GetTriggerPlayer() then
BlzFrameSetValue(sliderObject.Slider, sliderObject.Default)
end
end
function TasSliderControl.new(valueChangeActionFunction, min, max, default, step, labelText, sizeText, sizeSlider, name, parent, createContext)
BlzLoadTOCFile("war3mapimported\\templates.toc") --loads ui\framedef\ui\escmenutemplates.fdf
local newObject = {}
--setup unset data
if not createContext then createContext = 0 end
if not parent then parent = BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0) end
if not name then name = "" end
if not step then step = 1 end
if not sizeSlider then sizeSlider = 0.12 end
if not sizeText then sizeText = 0.12 end
if not min then min = 1 end
if not max then max = 100 end
if not default then default =max/2 end
if not step then step = 1 end
newObject.Format = TasSliderControl.PercentChar..".1f"
newObject.Action = valueChangeActionFunction
--this is the container of the Slider and Label
newObject.Frame = BlzCreateFrameByType("FRAME", "SliderControlFrame_"..name, parent, "", createContext)
BlzFrameSetSize(newObject.Frame, sizeText + sizeSlider, 0.013)
BlzFrameSetEnable(newObject.Frame, false)
newObject.Slider = BlzCreateFrameByType("SLIDER", "SliderControlSlider_"..name, newObject.Frame, "EscMenuSliderTemplate", createContext)
TasSliderControl[newObject.Slider] = newObject
BlzFrameSetSize(newObject.Slider, sizeSlider, 0.012)
BlzFrameSetMinMaxValue(newObject.Slider, min, max)
BlzFrameSetStepSize(newObject.Slider, step)
BlzFrameSetValue(newObject.Slider, default)
newObject.StepSize = step
newObject.Default = default
TasSliderAction(newObject.Slider, TasSliderControl.ValueAction, step)
newObject.Label = BlzCreateFrameByType("TEXT", "SliderControlLabel_"..name, newObject.Frame, "EscMenuMainPanelDialogTextTemplate", createContext)
BlzFrameSetText(newObject.Label, labelText)
newObject.Tooltip = BlzCreateFrameByType("FRAME", "SliderControlTooltip_"..name, newObject.Frame, "", createContext)
newObject.TextMin = BlzCreateFrameByType("TEXT", "SliderControlTextMin_"..name, newObject.Tooltip, "EscMenuMainPanelDialogTextTemplate", createContext)
newObject.TextMax = BlzCreateFrameByType("TEXT", "SliderControlTextMax_"..name, newObject.Tooltip, "EscMenuMainPanelDialogTextTemplate", createContext)
newObject.TextCurrent = BlzCreateFrameByType("TEXT", "SliderControlTextCurrent_"..name, newObject.Tooltip, "EscMenuMainPanelDialogTextTemplate", createContext)
BlzFrameSetText(newObject.TextMin, min)
BlzFrameSetText(newObject.TextMax, max)
BlzFrameSetText(newObject.TextCurrent, string.format(newObject.Format, BlzFrameGetValue(newObject.Slider)))
BlzFrameSetEnable(newObject.Tooltip, false)
BlzFrameSetTooltip(newObject.Slider, newObject.Tooltip)
BlzFrameSetPoint(newObject.TextMin, FRAMEPOINT_BOTTOM, newObject.Slider, FRAMEPOINT_TOPLEFT, 0, 0)
BlzFrameSetPoint(newObject.TextMax, FRAMEPOINT_BOTTOM, newObject.Slider, FRAMEPOINT_TOPRIGHT, 0, 0)
BlzFrameSetPoint(newObject.TextCurrent, FRAMEPOINT_BOTTOM, newObject.Slider, FRAMEPOINT_TOP, 0, 0)
BlzFrameSetPoint(newObject.Label, FRAMEPOINT_LEFT, newObject.Frame, FRAMEPOINT_LEFT, 0, 0)
BlzFrameSetPoint(newObject.Slider, FRAMEPOINT_RIGHT, newObject.Frame, FRAMEPOINT_RIGHT, 0, 0)
return newObject
end
function TryCall(func) if func then func() end end
function Demo()
xpcall(function()
TryCall(DemoFrameList)
TryCall(DemoFrameFlow)
TryCall(DemoWindow)
TryCall(DemoWindowTabed)
TryCall(DemoSliderWindow)
end, print)
end
function DemoFrameList()
xpcall(function()
print("Start")
local gameUI = BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0)
local frameListObject = FrameList.create()
-- print(GetHandleId(frameListObject.Frame))
-- print(GetHandleId(frameListObject.Slider))
BlzFrameSetAbsPoint(frameListObject.Frame, FRAMEPOINT_CENTER, 0.25, 0.3)
BlzFrameSetSize(frameListObject.Frame, 0.1,0.15)
local icon = BlzCreateFrameByType("BACKDROP", "MYIconPaladin", gameUI, "", 0)
BlzFrameSetTexture(icon, "ReplaceableTextures\\CommandButtons\\BTNHeroPaladin",0, false)
BlzFrameSetSize(icon, 0.08, 0.08)
FrameList.add(frameListObject, icon)
frameListObject.Action = function(frameListTable)
print("Update List bottomLeft")
print('Show Paladin',BlzFrameIsVisible(BlzGetFrameByName("MYIconPaladin", 0)))
end
icon = BlzCreateFrameByType("BACKDROP", "MYIcon", gameUI, "", 0)
BlzFrameSetTexture(icon, "ReplaceableTextures\\CommandButtons\\BTNHeroArchMage",0, false)
BlzFrameSetSize(icon, 0.08, 0.08)
FrameList.add(frameListObject, icon)
icon = BlzCreateFrameByType("BACKDROP", "MYIcon", gameUI, "", 0)
BlzFrameSetSize(icon, 0.1, 0.1)
BlzFrameSetTexture(icon, "ReplaceableTextures\\CommandButtons\\BTNHeroMountainKing",0, false)
FrameList.add(frameListObject, icon)
local subFrame = BlzCreateFrameByType("FRAME", "subFrame", gameUI, "", 0)
BlzFrameSetSize(subFrame, 0.1, 0.03)
for index = 1, 3 do
icon = BlzCreateFrameByType("BACKDROP", "MYIcon", subFrame, "", index)
BlzFrameSetTexture(icon, "ReplaceableTextures\\CommandButtons\\BTNHeroBloodElfPrince",0, false)
BlzFrameSetSize(icon, 0.03, 0.03)
BlzFrameSetPoint(icon, FRAMEPOINT_BOTTOMRIGHT, BlzGetFrameByName("MYIcon", index - 1), FRAMEPOINT_BOTTOMLEFT, 0, 0)
end
FrameList.add(frameListObject, subFrame)
BlzFrameSetPoint(BlzGetFrameByName("MYIcon", 1), FRAMEPOINT_BOTTOMRIGHT, subFrame, FRAMEPOINT_BOTTOMRIGHT, 0, 0)
subFrame = BlzCreateFrameByType("FRAME", "subFrame", gameUI, "", 0)
BlzFrameSetSize(subFrame, 0.1, 0.03)
for index = 1, 3 do
icon = BlzCreateFrameByType("BACKDROP", "MYIcon", subFrame, "", index)
BlzFrameSetTexture(icon, BlzGetAbilityIcon(FourCC('hfoo')),0, false)
BlzFrameSetSize(icon, 0.03, 0.03)
BlzFrameSetPoint(icon, FRAMEPOINT_BOTTOMRIGHT, BlzGetFrameByName("MYIcon", index - 1), FRAMEPOINT_BOTTOMLEFT, 0, 0)
end
FrameList.add(frameListObject, subFrame)
BlzFrameSetPoint(BlzGetFrameByName("MYIcon", 1), FRAMEPOINT_BOTTOMRIGHT, subFrame, FRAMEPOINT_BOTTOMRIGHT, 0, 0)
for index = 1, 30, 1 do
icon = BlzCreateFrameByType("TEXT", "MYIcon", gameUI, "", 0)
BlzFrameSetText(icon, index)
BlzFrameSetSize(icon, 0, 0.01)
FrameList.add(frameListObject, icon)
end
print("Done")
end,print)
end
function DemoFrameFlow()
xpcall(function()
local gameUI = BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0)
local parentFrame = BlzCreateFrameByType("FRAME", "", gameUI, "", 0)
BlzFrameSetAbsPoint(parentFrame, FRAMEPOINT_CENTER, 0.4, 0.3)
BlzFrameSetSize(parentFrame, 0.15, 0.22)
local frameFlowTable = FrameFlow.create(parentFrame, 0.0005, 0.001)
frameFlowTable.Action = function(frameFlowTable)
print('Show BloodElf',BlzFrameIsVisible(BlzGetFrameByName("MYIconElf", 0)))
end
for index = 1, 11, 1 do
local icon = BlzCreateFrameByType("BACKDROP", "MYIcon", gameUI, "", 0)
BlzFrameSetTexture(icon, "ReplaceableTextures\\CommandButtons\\BTNHeroPaladin",0, false)
BlzFrameSetSize(icon, 0.03, 0.03)
FrameFlow.add(frameFlowTable, icon)
end
icon = BlzCreateFrameByType("BACKDROP", "MYIcon", gameUI, "", 0)
BlzFrameSetTexture(icon, "ReplaceableTextures\\CommandButtons\\BTNHeroArchMage",0, false)
BlzFrameSetSize(icon, 0.08, 0.08)
FrameFlow.add(frameFlowTable, icon)
icon = BlzCreateFrameByType("BACKDROP", "MYIcon", gameUI, "", 0)
BlzFrameSetSize(icon, 0.1, 0.1)
BlzFrameSetTexture(icon, "ReplaceableTextures\\CommandButtons\\BTNHeroMountainKing",0, false)
FrameFlow.add(frameFlowTable, icon)
icon = BlzCreateFrameByType("BACKDROP", "MYIconElf", gameUI, "", 0)
BlzFrameSetTexture(icon, "ReplaceableTextures\\CommandButtons\\BTNHeroBloodElfPrince",0, false)
BlzFrameSetSize(icon, 0.08, 0.04)
FrameFlow.add(frameFlowTable, icon)
end,print)
end
function DemoWindow()
local windowObject = Window.create("Test Window", false)
Window.setAbsPoint(windowObject, FRAMEPOINT_TOPLEFT, 0.15, 0.53)
Window.setSize(windowObject, 0.15, 0.11)
local fhPane = windowObject.WindowPane
local button1 = BlzCreateFrameByType("GLUETEXTBUTTON", "MYBUtton", fhPane, "ScriptDialogButton", 0)
local button2 = BlzCreateFrameByType("GLUETEXTBUTTON", "MYBUtton", fhPane, "ScriptDialogButton", 0)
local button3 = BlzCreateFrameByType("GLUETEXTBUTTON", "MYBUtton", fhPane, "ScriptDialogButton", 0)
BlzFrameSetSize(button3 , 0.05, 0.0275)
BlzFrameSetSize(button2 , 0.05, 0.0275)
BlzFrameSetSize(button1 , 0.05, 0.0275)
BlzFrameSetPoint(button1, FRAMEPOINT_BOTTOMRIGHT, fhPane, FRAMEPOINT_BOTTOMRIGHT, 0, 0)
BlzFrameSetPoint(button2, FRAMEPOINT_LEFT, fhPane, FRAMEPOINT_LEFT, 0, 0)
BlzFrameSetPoint(button3, FRAMEPOINT_TOP, fhPane, FRAMEPOINT_TOP, 0, 0)
windowObject.UserAction = function(windowObject, player, shown) print("shown", shown) end
end
function DemoWindowTabed()
-- local windowObject = Window.create("Test Tabed Window", nil, nil, nil, GetRandomInt(0, 7))
local windowObject = Window.create("Test Tabed Window", nil, nil, nil, nil)
windowObject.TabPos = 3
Window.setSize(windowObject, 0.2, 0.2)
Window.setAbsPoint(windowObject, FRAMEPOINT_TOPRIGHT, 0.7, 0.5)
local gameUI = BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0)
local icon = BlzCreateFrameByType("BACKDROP", "MYIcon", gameUI, "", 0)
BlzFrameSetTexture(icon, "ReplaceableTextures\\CommandButtons\\BTNHeroPaladin",0, false)
Window.addTabIcon(windowObject, icon, "ReplaceableTextures\\CommandButtons\\BTNHeroPaladin", false, 0.08, 0.08)
icon = BlzCreateFrameByType("BACKDROP", "MYIcon", gameUI, "", 0)
BlzFrameSetTexture(icon, "ReplaceableTextures\\CommandButtons\\BTNHeroArchMage",0, false)
Window.addTab(windowObject, icon, "Archmage")
icon = BlzCreateFrameByType("BACKDROP", "MYIcon", gameUI, "", 0)
BlzFrameSetSize(icon, 0.1, 0.1)
BlzFrameSetTexture(icon, "ReplaceableTextures\\CommandButtons\\BTNHeroMountainKing",0, false)
Window.addTab(windowObject, icon, nil, true)
icon = BlzCreateFrameByType("BACKDROP", "MYIcon", gameUI, "", 0)
BlzFrameSetTexture(icon, "ReplaceableTextures\\CommandButtons\\BTNHeroBloodElfPrince",0, false)
Window.addTab(windowObject, icon)
TimerStart(CreateTimer(), 3, false, function()
--Window.removeTab(windowObject, 3)
icon = BlzCreateFrameByType("BACKDROP", "MYIcon", gameUI, "", 0)
BlzFrameSetTexture(icon, "ReplaceableTextures\\CommandButtons\\BTNHeroFarseer",0, false)
Window.addTabIcon(windowObject, icon, "ReplaceableTextures\\CommandButtons\\BTNHeroFarseer")
end)
icon = BlzCreateFrameByType("BACKDROP", "MYIcon", gameUI, "", 0)
BlzFrameSetSize(icon, 0.039, 0.039)
BlzFrameSetTexture(icon, "ReplaceableTextures\\CommandButtons\\BTNHeroLich",0, false)
BlzFrameSetPoint(icon, FRAMEPOINT_TOP, windowObject.TasWindow, FRAMEPOINT_BOTTOM, 0, 0)
windowObject.ColapseResize = true
end
CamControl = {}
VolumeGroupControl = {}
ResetButton = {}
ApplyButton = {}
HandicapControl = {}
function CamControl.Action(sliderObject)
SetCameraFieldForPlayer(GetTriggerPlayer(), CamControl[sliderObject], BlzFrameGetValue(sliderObject.Slider), 0)
print(BlzFrameGetValue(sliderObject.Slider), BlzFrameGetText(sliderObject.Label))
end
function ResetButton.create(parentFrame, sliderObjectArray)
local button = BlzCreateFrameByType("GLUETEXTBUTTON", "", parentFrame, "ScriptDialogButton", 0)
BlzFrameSetPoint(button, FRAMEPOINT_BOTTOMRIGHT, parentFrame, FRAMEPOINT_BOTTOMRIGHT, 0, 0)
BlzFrameSetSize(button, 0.07, 0.025)
BlzFrameSetText(button, "Reset")
ResetButton[button] = sliderObjectArray
TasButtonAction(button, ResetButton.Action)
end
function ResetButton.Action()
print("ResetButtonAction")
local frame = BlzGetTriggerFrame()
for index, value in ipairs(ResetButton[frame])
do
SliderControl.reset(value, GetTriggerPlayer())
end
BlzFrameSetEnable(frame, false)
BlzFrameSetEnable(frame, true)
end
function ApplyButton.create(parentFrame, sliderObjectArray)
local button = BlzCreateFrameByType("GLUETEXTBUTTON", "", parentFrame, "ScriptDialogButton", 0)
BlzFrameSetPoint(button, FRAMEPOINT_BOTTOMLEFT, parentFrame, FRAMEPOINT_BOTTOMLEFT, 0, 0)
BlzFrameSetSize(button, 0.07, 0.025)
BlzFrameSetText(button, "Apply")
ApplyButton[button] = sliderObjectArray
TasButtonAction(button, ApplyButton.Action)
end
function ApplyButton.Action()
print("ApplyButton.Action")
local frame = BlzGetTriggerFrame()
for index, value in ipairs(ApplyButton[frame])
do
if value.Action then
value.Action(value)
end
end
BlzFrameSetEnable(frame, false)
BlzFrameSetEnable(frame, true)
end
function VolumeGroupControl.Action(sliderObject)
VolumeGroupSetVolumeForPlayerBJ(GetTriggerPlayer(), VolumeGroupControl[sliderObject], BlzFrameGetValue(sliderObject.Slider)*0.01 )
print(BlzFrameGetValue(sliderObject.Slider), BlzFrameGetText(sliderObject.Label))
end
function CreateCamControl(windowObject)
xpcall(function()
print("CamControl")
local data = {
-- min max default step, LabelText, CameraField
{100, 8000, GetCameraField(CAMERA_FIELD_TARGET_DISTANCE), 50, "TARGET_DISTANCE", CAMERA_FIELD_TARGET_DISTANCE},
{100, 10000, GetCameraField(CAMERA_FIELD_FARZ), 50, "FARZ", CAMERA_FIELD_FARZ},
{0, 360, bj_RADTODEG * GetCameraField(CAMERA_FIELD_ANGLE_OF_ATTACK), 1, "ANGLE_OF_ATTACK", CAMERA_FIELD_ANGLE_OF_ATTACK},
{20, 120, bj_RADTODEG * GetCameraField(CAMERA_FIELD_FIELD_OF_VIEW), 1, "FIELD_OF_VIEW", CAMERA_FIELD_FIELD_OF_VIEW},
{0, 360, bj_RADTODEG * GetCameraField(CAMERA_FIELD_ROLL), 1, "ROLL", CAMERA_FIELD_ROLL},
{0, 360, bj_RADTODEG * GetCameraField(CAMERA_FIELD_ROTATION), 1, "ROTATION", CAMERA_FIELD_ROTATION},
{0, 5000, GetCameraField(CAMERA_FIELD_ZOFFSET), 50, "ZOFFSET", CAMERA_FIELD_ZOFFSET},
--{0, 5000, GetCameraField(CAMERA_FIELD_NEARZ), 1, "NEARZ", CAMERA_FIELD_NEARZ},
--{0, 360, bj_RADTODEG * GetCameraField(CAMERA_FIELD_LOCAL_PITCH), 1, "LOCAL_PITCH", CAMERA_FIELD_LOCAL_PITCH},
--{0, 360, bj_RADTODEG * GetCameraField(CAMERA_FIELD_LOCAL_YAW), 1, "LOCAL_YAW", CAMERA_FIELD_LOCAL_YAW},
--{0, 360, bj_RADTODEG * GetCameraField(CAMERA_FIELD_LOCAL_ROLL), 1, "LOCAL_ROLL", CAMERA_FIELD_LOCAL_ROLL}
}
local parentFrame = BlzCreateFrameByType("FRAME", "", windowObject.WindowPane, "", 0)
local sliderSize = 0.09
local textSize = 0.15 --doesnt matter much cause the position is overwritten by the points
local frameList = TasFrameList.define(nil, parentFrame)
local x,y = sliderSize+textSize, 0.1
TasFrameList.setSize(frameList, x,y)
for index, value in ipairs(data) do
local sliderObject = SliderControl.new(CamControl.Action, value[1], value[2], value[3], value[4], value[5], textSize, sliderSize, "", parentFrame)
CamControl[sliderObject] = value[6]
table.insert(CamControl, sliderObject)
TasFrameList.add(frameList, sliderObject.Frame)
end
ResetButton.create(parentFrame, CamControl)
ApplyButton.create(parentFrame, CamControl)
Window.addTab(windowObject, parentFrame, "Camera", false, x,y)
print("Done")
end,print)
end
function CreateVolumGroupControl(windowObject)
xpcall(function()
print("VolumGroupControl")
local data = {
--label , volumegroup
{"UnitMovement", SOUND_VOLUMEGROUP_UNITMOVEMENT},
{"UnitSound", SOUND_VOLUMEGROUP_UNITSOUNDS},
{"Combat", SOUND_VOLUMEGROUP_COMBAT},
{"Spells", SOUND_VOLUMEGROUP_SPELLS},
{"User Interface", SOUND_VOLUMEGROUP_UI},
{"Music", SOUND_VOLUMEGROUP_MUSIC},
{"Ambient", SOUND_VOLUMEGROUP_AMBIENTSOUNDS},
{"Fire", SOUND_VOLUMEGROUP_FIRE}
}
local parentFrame = BlzCreateFrameByType("FRAME", "", windowObject.WindowPane, "", 0)
local sliderSize = 0.09
local textSize = 0.09 --doesnt matter much cause the position is overwritten by the points
local frameList = TasFrameList.define(nil, parentFrame)
local x,y = sliderSize+textSize, 0.12
TasFrameList.setSize(frameList, x,y)
for index, value in ipairs(data) do
local sliderObject = SliderControl.new(VolumeGroupControl.Action, 0, 100, 100, 1, value[1], textSize, sliderSize, "", parentFrame)
VolumeGroupControl[sliderObject] = value[2]
prev = sliderObject.Frame
table.insert( VolumeGroupControl, sliderObject )
TasFrameList.add(frameList, sliderObject.Frame)
end
ResetButton.create(parentFrame, VolumeGroupControl)
ApplyButton.create(parentFrame, VolumeGroupControl)
Window.addTab(windowObject, parentFrame, "Sound", false, x,y)
print("Done")
end,print)
end
function HandicapControl.Action(sliderObject)
--HandicapControl[sliderObject]
SetPlayerHandicap(HandicapControl[sliderObject], BlzFrameGetValue(sliderObject.Slider)*0.01)
print(BlzFrameGetValue(sliderObject.Slider), BlzFrameGetText(sliderObject.Label))
end
function CreatePlayerHandicap(windowObject)
xpcall(function()
print("CreatePlayerHandicap")
local parentFrame = BlzCreateFrameByType("FRAME", "", windowObject.WindowPane, "", 0)
local sliderSize = 0.09
local textSize = 0.09 --doesnt matter much cause the position is overwritten by the points
local frameList = TasFrameList.define(nil, parentFrame)
local x,y = sliderSize+textSize, 0.12
TasFrameList.setSize(frameList, x,y)
for playerIndex = 0, bj_MAX_PLAYER_SLOTS do
local sliderObject = SliderControl.new(HandicapControl.Action, 0, 1000, 100, 1, GetPlayerName(Player(playerIndex)).."("..playerIndex..")", textSize, sliderSize, "", parentFrame)
HandicapControl[sliderObject] = Player(playerIndex)
table.insert( HandicapControl, sliderObject)
TasFrameList.add(frameList, sliderObject.Frame)
end
ResetButton.create(parentFrame, HandicapControl)
ApplyButton.create(parentFrame, HandicapControl)
Window.addTab(windowObject, parentFrame, "Handicap", false, x,y)
print("Done")
end,print)
end
function DemoSliderWindow()
local windowObject = Window.create("Options")
Window.setSize(windowObject, 0.25, 0.2)
Window.setAbsPoint(windowObject, FRAMEPOINT_CENTER, 0.4, 0.5)
CreateCamControl(windowObject)
CreateVolumGroupControl(windowObject)
CreatePlayerHandicap(windowObject)
print(BlzFrameGetHeight(windowObject.Window),BlzFrameGetHeight(windowObject.Window))
end