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
--[[
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
--[[
TasButtonList15 by Tasyen
TasButtonList is a higher Level UI-Component to search, filter and select data using a fixed amount of buttons.
The UI-API part one has to do (as mapper using this system) is quite small.
Provides a built in Tooltip-Box
There can be many TasButtonList at the same Time.
Each player can have a different dataPool inside a TasButtonList.
Can differ between right click & left click (optional)
Supports differnt Buttons (they have to be defined in fdf)
ObjectEditor lists are handled with the default Actions, only need to define buttonAction in such a case.
TasButtonList.TooltipCreator = function CreateTasButtonTooltip(frameObject, parent[, button]) -- is used to create the tooltip
Structure
object.Data = {}, --an array each slot is the user data buttonListObject.Data[player][dataIndex] Count
object.Data[player].Count
object.DataFiltered = {Count = 0}, -- indexes of Data fitting the current search (async)
object.ViewPoint = 0,
object.Parent
object.Head -- hidden Frames the buttons are relative to the Head's bottom.
object.TotalFrame -- hidden Frames to manage positions better, covers the whole space of a TasButtonList
object.InputFrame -- search input
object.Slider
object.SliderText
object.SliderStep
object.Frames.GapCol -- has only a effect on new Rows
object.Frames.GapRow
object.Frames.Cols
object.Frames.Rows
object.Frames.ButtonName -- used to create buttons can be a name or function
object.Frames.CreateAction
object.Frames.Count -- total frameObject Count right now
object.Frames[1 to object.Frames.Count] = frameObject -- the frameObject each button is a frameobject
frameObject default this depends on the button created
frameObject.Button
frameObject.ToolTipFrame
frameObject.ToolTipFrameIcon
frameObject.ToolTipFrameName
frameObject.ToolTipFrameSeperator
frameObject.ToolTipFrameText
frameObject.Icon
frameObject.Text
frameObject.IconGold
frameObject.TextGold
frameObject.IconLumber
frameObject.TextLumber
TasButtonList actions
object.ButtonAction = function(data, buttonListObject, dataIndex, player) end
object.RightClickAction = function(data, buttonListObject, dataIndex, player) end
object.UpdateAction = function(frameObject, data) end
object.SearchAction = function(data, searchedText, buttonListObject) return true end
object.FilterAction = function(data, buttonListObject, isTextSearching) return true end
object.AsyncButtonAction = function(buttonListObject, data, frame) end
object.AsyncRightClickAction = function(buttonListObject, data, frame) end
function CreateTasButtonListEx2(buttonName, cols, rows[, colGap, rowGap, parent, createAction])
buttonName can be a string or a function, called for every button you wana create should return the interactive button
string -> fdf frameplueprint
function(buttonFrameObject, parent, index))
createAction function(frameObject, int, buttonCreated) use this to fill frameObject with the subFrames mostly for fdf also runs after the tooltips were created
returns the TasButtonList
function TasButtonListAddRow(buttonListObject[, buttonName, createAction])
add one more row to buttonListObject, reuses name & createAction used in CreateTasButtonList when not provided.
you should use TasButtonListSearch(buttonListObject) afterwards.
function CreateTasButtonListEx(buttonName, cols, rows, parent, buttonAction[, rightClickAction, updateAction, searchAction, filterAction, asyncButtonAction, asyncRightClickAction, colGap, rowGap])
create a new List
parent is the container of this Frame it will attach itself to its TOP.
buttonAction is the function that executes when an option is clicked. args: (clickedData, buttonListObject, dataIndex)
rightClickAction is the function that executes when an option is rightClicked. args: (clickedData, buttonListObject, dataIndex)
when your data are object Editor object-RawCodes (but not buffs) then updateAction & searchAction use a default one handling them.
updateAction runs for each Button and is used to set the diplayed content. args:(frameObject, data)
frameObject.Button
frameObject.ToolTipFrame
frameObject.ToolTipFrameIcon
frameObject.ToolTipFrameName
frameObject.ToolTipFrameSeperator
frameObject.ToolTipFrameText
frameObject.Icon
frameObject.Text
frameObject.IconGold
frameObject.TextGold
frameObject.IconLumber
frameObject.TextLumber
TasButtonList[frameObject] => buttonListObject
data is one entry of the TasButtonLists Data-Array.
searchAction is a function that returns true if the current data matches the searchText. Args: (data, searchedText, buttonListObject)
filterAction is meant to be used when one wants an addtional non text based filtering, with returning true allowing data or false rejecting it. Args: (data, buttonListObject, isTextSearching)
searchAction , udateAction & filterAction are async this functions should not do anything that alters the game state/flow.
function CreateTasButtonList(buttonCount, parent, buttonAction[, updateAction, searchAction, filterAction])
wrapper for CreateTasButtonListEx, 1 col, buttonCount rows.
function CreateTasButtonListV2(rowCount, parent, buttonAction[, updateAction, searchAction, filterAction])
wrapper for CreateTasButtonListEx, 2 Buttons each Row, takes more Height then the other Versions
function CreateTasButtonListV3(rowCount, parent, buttonAction[, updateAction, searchAction, filterAction])
wrapper for CreateTasButtonListEx, 3 Buttons each Row, only Icon, and Costs
Wrapper Creator for Lists having only Text in a Box
Default update & search: exepect data to be either a number (object Editor rawCode), a string or a table(title, text, icon)
function CreateTasButtonBoxedTextList(rowCount, colCount, parent, buttonAction[, updateAction, searchAction, filterAction])
function CreateTasButtonBoxedTextListBig(rowCount, colCount, parent, buttonAction[, updateAction, searchAction, filterAction])
Wrapper Creator for Lists having only Text
Default update & search: exepect data to be either a number (object Editor rawCode), a string or a table(title, text, icon)
function CreateTasButtonTextList(rowCount, colCount, parent, buttonAction[, updateAction, searchAction, filterAction])
function CreateTasButtonTextListBig(rowCount, colCount, parent, buttonAction[, updateAction, searchAction, filterAction])
function TasButtonListClearData(buttonListObject[, player])
remove all data
function TasButtonListRemoveData(buttonListObject, data[, player])
search for data and remove it
function TasButtonListAddData(buttonListObject, data[, player])
add data for one Button
function TasButtonListAddDataBatch(buttonListObject, player, ...)
calls TasButtonListAddData for each given arg after player
nil for player will add it for all players
you should not use FourCC in this, TasButtonList will do that for your
function TasButtonListAddDataBatchEx(buttonListObject, ...)
TasButtonListAddDataBatch with player nil (all players)
function TasButtonListCopyData(writeObject, readObject[, player])
writeObject uses the same data as readObject and calls UpdateButtonList.
The copier writeObject still has an own filtering and searching.
function UpdateTasButtonList(buttonListObject)
update the displayed Content should be done after Data was added or removed was used.
TasButtonListSearch(buttonListObject[, text])
The buttonList will search it's data for the given text, if nil is given as text it will search for what the user currently has in its box.
This will also update the buttonList
--]]
TasButtonList = {
Interpret4DigitString = true -- TasButtonListAddData will FourCC given 4 digit strings?
,DefaultOwnerFunc = function() return BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0) end -- when you dont give an parent the new parent is created for this
,TocPath ="war3mapimported\\TasButtonList.toc" -- where is the TasButtonList toc in your map
}
function TasButtonList.FirstInit()
BlzLoadTOCFile(TasButtonList.TocPath)
-- fix a save&Load bug in 1.31.1 and upto 1.32.10 (currently) which does not save&load frame-API actions
if FrameLoaderAdd then FrameLoaderAdd(function() BlzLoadTOCFile(TasButtonList.TocPath) end) end
TasButtonList.RightClickSound = CreateSound("Sound\\Interface\\MouseClick1.wav", false, false, false, 10, 10, "")
SetSoundParamsFromLabel(TasButtonList.RightClickSound, "InterfaceClick")
SetSoundDuration(TasButtonList.RightClickSound, 239)
TasButtonList.FirstInit = nil -- this only runes once
end
TasButtonList.SyncTriggerAction = function(frame, player, value)
local buttonListObject = TasButtonList[frame]
local dataIndex = R2I(value)
if buttonListObject.ButtonAction then
-- call the wanted action, 1 the current Data
buttonListObject.ButtonAction(buttonListObject.Data[player][dataIndex], buttonListObject, dataIndex, player)
end
UpdateTasButtonList(buttonListObject)
end
TasButtonList.SyncTriggerRightClickAction = function(frame, player, value)
local buttonListObject = TasButtonList[frame]
local dataIndex = R2I(value)
if buttonListObject.RightClickAction then
-- call the wanted action, 1 the current Data
buttonListObject.RightClickAction(buttonListObject.Data[player][dataIndex], buttonListObject, dataIndex, player)
end
UpdateTasButtonList(buttonListObject)
end
-- handles the clicking
TasButtonList.ButtonTriggerAction = function(frame, player)
local buttonIndex = TasButtonList[frame].Index
local buttonListObject = TasButtonList[TasButtonList[frame]]
local dataIndex = buttonListObject.DataFiltered[buttonListObject.ViewPoint + buttonIndex]
if GetLocalPlayer() == player then
if buttonListObject.AsyncButtonAction then
buttonListObject.AsyncButtonAction(buttonListObject, buttonListObject.Data[GetLocalPlayer()][R2I(dataIndex)], frame)
end
BlzFrameSetValue(buttonListObject.SyncFrame, dataIndex)
end
end
TasButtonList.ButtonTriggerRightClickAction = function(frame, player, rightClick)
local buttonListObject = TasButtonList[TasButtonList[frame]]
-- if there is no RightClick Action for this Buttonlist skip other actions
if not buttonListObject.RightClickAction and not buttonListObject.AsyncRightClickAction then return end
local buttonIndex = TasButtonList[frame].Index
local dataIndex = buttonListObject.DataFiltered[buttonListObject.ViewPoint + buttonIndex]
if rightClick and GetLocalPlayer() == player then
if buttonListObject.AsyncRightClickAction then
buttonListObject.AsyncRightClickAction(buttonListObject, buttonListObject.Data[GetLocalPlayer()][R2I(dataIndex)], frame)
end
StartSound(TasButtonList.RightClickSound)
BlzFrameSetValue(buttonListObject.SyncFrameRightClick, dataIndex)
end
end
TasButtonList.SearchTriggerAction = function(frame, player, text)
TasButtonListSearch(TasButtonList[frame], BlzFrameGetText(frame))
end
TasButtonList.SliderTriggerAction = function(frame, player, value)
local buttonListObject = TasButtonList[frame]
if GetLocalPlayer() == player then
-- when there is enough data use viewPoint. the Viewpoint is reduced from the data to make top being top.
if buttonListObject.DataFiltered.Count > buttonListObject.Frames.Count then
buttonListObject.ViewPoint = buttonListObject.DataFiltered.Count - R2I(value)
else
buttonListObject.ViewPoint = 0
end
UpdateTasButtonList(buttonListObject)
if buttonListObject.SliderText then
local min = math.tointeger(buttonListObject.DataFiltered.Count - BlzFrameGetValue(frame))
local max = math.tointeger(buttonListObject.DataFiltered.Count - buttonListObject.Frames.Count)
BlzFrameSetText(buttonListObject.SliderText, min .. "/" .. max )
end
end
end
--runs once for each button shown
function UpdateTasButtonListDefaultObject(frameObject, data)
BlzFrameSetTexture(frameObject.Icon, BlzGetAbilityIcon(data), 0, false)
BlzFrameSetText(frameObject.Text, GetObjectName(data))
BlzFrameSetTexture(frameObject.ToolTipFrameIcon, BlzGetAbilityIcon(data), 0, false)
BlzFrameSetText(frameObject.ToolTipFrameName, GetObjectName(data))
-- frameObject.ToolTipFrameSeperator
BlzFrameSetText(frameObject.ToolTipFrameText, BlzGetAbilityExtendedTooltip(data, 0))
if not IsUnitIdType(data, UNIT_TYPE_HERO) then
local lumber = GetUnitWoodCost(data)
local gold = GetUnitGoldCost(data)
if GetPlayerState(GetLocalPlayer(), PLAYER_STATE_RESOURCE_GOLD) >= gold then
BlzFrameSetText(frameObject.TextGold, GetUnitGoldCost(data))
else
BlzFrameSetText(frameObject.TextGold, "|cffff2010"..GetUnitGoldCost(data))
end
if GetPlayerState(GetLocalPlayer(), PLAYER_STATE_RESOURCE_LUMBER) >= lumber then
BlzFrameSetText(frameObject.TextLumber, GetUnitWoodCost(data))
else
BlzFrameSetText(frameObject.TextLumber, "|cffff2010"..GetUnitWoodCost(data))
end
else
BlzFrameSetText(frameObject.TextLumber, 0)
BlzFrameSetText(frameObject.TextGold, 0)
end
end
--runs once for each button shown
function UpdateTasButtonListDefaultText(frameObject, data)
if type(data) == "string" then
BlzFrameSetTexture(frameObject.ToolTipFrameIcon, "UI/Widgets/EscMenu/Human/blank-background", 0, true)
BlzFrameSetText(frameObject.Text, GetLocalizedString(data))
BlzFrameSetText(frameObject.ToolTipFrameName, GetLocalizedString(data))
-- frameObject.ToolTipFrameSeperator
BlzFrameSetText(frameObject.ToolTipFrameText, GetLocalizedString(data))
elseif type(data) == "number" then
UpdateTasButtonListDefaultObject(frameObject, data)
elseif type(data) == "table" then
BlzFrameSetText(frameObject.Text, data[1])
BlzFrameSetText(frameObject.ToolTipFrameName, GetLocalizedString(data[1]))
-- frameObject.ToolTipFrameSeperator
BlzFrameSetText(frameObject.ToolTipFrameText, GetLocalizedString(data[2]))
-- have icon data?
if data[3] then
BlzFrameSetTexture(frameObject.ToolTipFrameIcon, data[3], 0, true)
else
BlzFrameSetTexture(frameObject.ToolTipFrameIcon, "UI/Widgets/EscMenu/Human/blank-background", 0, true)
end
end
end
function SearchTasButtonListDefaultObject(data, searchedText, buttonListObject)
--return BlzGetAbilityTooltip(data, 0)
--return GetObjectName(data, 0)
--return string.find(GetObjectName(data), searchedText)
return string.find(string.lower(GetObjectName(data)), string.lower(searchedText))
end
function SearchTasButtonListDefaultText(data, searchedText, buttonListObject)
if type(data) == "number" then
return string.find(string.lower(GetObjectName(data)), string.lower(searchedText))
elseif type(data) == "string" then
return string.find(string.lower(GetLocalizedString(data)), string.lower(searchedText))
elseif type(data) == "table" then
return string.find(string.lower(GetLocalizedString(data[1])), string.lower(searchedText)) or string.find(string.lower(GetLocalizedString(data[2])), string.lower(searchedText))
else
return true
end
end
-- update the shown content
function UpdateTasButtonList(buttonListObject)
xpcall(function()
local data = buttonListObject.Data[GetLocalPlayer()]
BlzFrameSetVisible(buttonListObject.Slider, buttonListObject.DataFiltered.Count > buttonListObject.Frames.Count)
for int = 1, buttonListObject.Frames.Count do
local frameObject = buttonListObject.Frames[int]
if buttonListObject.DataFiltered.Count >= int then
buttonListObject.UpdateAction(frameObject, data[buttonListObject.DataFiltered[int + buttonListObject.ViewPoint]])
BlzFrameSetVisible(frameObject.Button, true)
else
BlzFrameSetVisible(frameObject.Button, false)
end
end
end, print)
end
-- for backwards compatibility rightClickAction is the last argument
function InitTasButtonListObject(parent, buttonAction, updateAction, searchAction, filterAction, rightClickAction, asyncButtonAction, asyncRightClickAction)
if TasButtonList.FirstInit then TasButtonList.FirstInit() end
local object = {
Data = {}, --an array each slot is the user data
DataFiltered = {Count = 0}, -- indexes of Data fitting the current search
ViewPoint = 0,
Frames = {},
Parent = parent
}
for index = 0, bj_MAX_PLAYER_SLOTS - 1 do
object.Data[Player(index)] = {Count = 0}
end
object.Head = BlzCreateFrameByType("FRAME", "TasButtonListHead", parent, "", 0)
BlzFrameSetSize(object.Head, 0.1, 0.005)
BlzFrameSetPoint(object.Head, FRAMEPOINT_TOPRIGHT, parent, FRAMEPOINT_TOPRIGHT, 0, 0)
BlzFrameSetVisible(object.Head, false)
object.TotalFrame = BlzCreateFrameByType("FRAME", "TasButtonListTotalFrame", parent, "", 0)
BlzFrameSetVisible(object.TotalFrame, false)
BlzFrameSetPoint(object.TotalFrame, FRAMEPOINT_TOPLEFT, object.Head, FRAMEPOINT_TOPLEFT, 0, 0)
object.ButtonAction = buttonAction --call this inside the SyncAction after a button is clicked
object.RightClickAction = rightClickAction -- this inside a SyncAction when the button is right clicked.
object.UpdateAction = updateAction --function defining how to display stuff (async)
object.SearchAction = searchAction --function to return the searched Text (async)
object.FilterAction = filterAction --
object.AsyncButtonAction = asyncButtonAction -- happens in the clicking event inside a LocalPlayer Block
object.AsyncRightClickAction = asyncRightClickAction -- happens in the clicking event inside a LocalPlayer Block
if not updateAction then object.UpdateAction = UpdateTasButtonListDefaultObject end
if not searchAction then object.SearchAction = SearchTasButtonListDefaultObject end
table.insert(TasButtonList, object) --index to TasButtonList
TasButtonList[object] = #TasButtonList -- TasButtonList to Index
object.SyncFrame = BlzCreateFrameByType("SLIDER", "", parent, "", 0)
BlzFrameSetMinMaxValue(object.SyncFrame, 0, 9999999)
BlzFrameSetStepSize(object.SyncFrame, 1.0)
TasSliderAction(object.SyncFrame, TasButtonList.SyncTriggerAction)
TasSliderAction.AvoidPoll[object.SyncFrame] = false
BlzFrameSetVisible(object.SyncFrame, false)
TasButtonList[object.SyncFrame] = object
-- do this only if the function IsRightClick exists
object.SyncFrameRightClick = BlzCreateFrameByType("SLIDER", "", parent, "", 0)
BlzFrameSetMinMaxValue(object.SyncFrameRightClick, 0, 9999999)
BlzFrameSetStepSize(object.SyncFrameRightClick, 1.0)
TasSliderAction(object.SyncFrameRightClick, TasButtonList.SyncTriggerRightClickAction)
TasSliderAction.AvoidPoll[object.SyncFrameRightClick] = false
BlzFrameSetVisible(object.SyncFrameRightClick, false)
TasButtonList[object.SyncFrameRightClick] = object
object.InputFrame = BlzCreateFrame("TasEditBox", parent, 0, 0)
TasEditBoxAction(object.InputFrame, nil, TasButtonList.SearchTriggerAction)
BlzFrameSetPoint(object.InputFrame, FRAMEPOINT_TOPRIGHT, object.Head, FRAMEPOINT_TOPRIGHT, 0, 0)
TasButtonList[object.InputFrame] = object
BlzFrameSetSize(object.Head, 0.1, BlzFrameGetHeight(object.InputFrame) +0.005)
return object
end
function InitTasButtonListSlider(object, stepSize, rowCount, colGap, rowGap)
if not colGap then colGap = 0 end
if not rowGap then rowGap = 0 end
object.Slider = BlzCreateFrameByType("SLIDER", "FrameListSlider", object.Parent, "QuestMainListScrollBar", 0)
TasButtonList[object.Slider] = object -- the slider nows the TasButtonListobject
object.SliderStep = stepSize
BlzFrameSetStepSize(object.Slider, stepSize)
BlzFrameClearAllPoints(object.Slider)
BlzFrameSetVisible(object.Slider, true)
BlzFrameSetMinMaxValue(object.Slider, 0, 0)
--BlzFrameSetPoint(object.Slider, FRAMEPOINT_TOPLEFT, object.Frames[stepSize].Button, FRAMEPOINT_TOPRIGHT, 0, 0)
BlzFrameSetPoint(object.Slider, FRAMEPOINT_TOPLEFT, object.Head, FRAMEPOINT_BOTTOMRIGHT, 0, 0)
TasSliderAction(object.Slider, TasButtonList.SliderTriggerAction, StepSize)
-- if the function CreateSimpleTooltip exists, create a Text displaying current Position in the list
if CreateSimpleTooltip then
object.SliderText = CreateSimpleTooltip(object.Slider, "1000/1000")
BlzFrameClearAllPoints(object.SliderText)
BlzFrameSetPoint(object.SliderText, FRAMEPOINT_BOTTOMRIGHT, object.Slider, FRAMEPOINT_TOPLEFT, 0, 0)
end
end
function TasButtonListAddDataEx(buttonListObject, data, player)
local oData = buttonListObject.Data[player]
local oDataFil = buttonListObject.DataFiltered
-- convert 'Hpal' into the number
-- print(TasButtonList.Interpret4DigitString) print( data) print(type(data)) print(string.len(data))
if TasButtonList.Interpret4DigitString and type(data) == "string" and string.len(data) == 4 then data = FourCC(data) end
oData.Count = oData.Count + 1
oData[oData.Count] = data
if GetLocalPlayer() == player then
-- filterData is a local thing
oDataFil.Count = oDataFil.Count + 1
oDataFil[oDataFil.Count] = oData.Count
BlzFrameSetMinMaxValue(buttonListObject.Slider, buttonListObject.Frames.Count, oDataFil.Count)
end
end
function TasButtonListAddData(buttonListObject, data, player)
-- only add for one player?
if player and type(player) == "userdata" then
TasButtonListAddDataEx(buttonListObject, data, player)
else
-- no player -> add for all Players
for i = 0, bj_MAX_PLAYER_SLOTS - 1 do
TasButtonListAddDataEx(buttonListObject, data, Player(i))
end
end
end
function TasButtonListAddDataBatch(buttonListObject, player, ...)
for _, k in ipairs({...}) do
print(k)
TasButtonListAddData(buttonListObject, k, player)
end
end
function TasButtonListAddDataBatchEx(buttonListObject, ...)
TasButtonListAddDataBatch(buttonListObject, nil, ...)
end
function TasButtonListRemoveDataEx(buttonListObject, data, player)
local oData = buttonListObject.Data[player]
for index = 1, oData.Count do
value = oData[index]
if value == data then
oData[index] = oData[oData.Count]
oData.Count = oData.Count - 1
break
end
end
if GetLocalPlayer() == player then
BlzFrameSetMinMaxValue(buttonListObject.Slider, buttonListObject.Frames.Count, oData.Count)
end
end
function TasButtonListRemoveData(buttonListObject, data, player)
if player and type(player) == "userdata" then
TasButtonListRemoveDataEx(buttonListObject, data, player)
else
for i = 0, bj_MAX_PLAYER_SLOTS - 1 do
TasButtonListRemoveDataEx(buttonListObject, data, Player(i))
end
end
end
function TasButtonListClearDataEx(buttonListObject, player)
buttonListObject.Data[player].Count = 0
if GetLocalPlayer() == player then
buttonListObject.DataFiltered.Count = 0
BlzFrameSetMinMaxValue(buttonListObject.Slider, 0, 0)
end
end
function TasButtonListClearData(buttonListObject, player)
if player and type(player) == "userdata" then
TasButtonListClearDataEx(buttonListObject, player)
else
for i = 0, bj_MAX_PLAYER_SLOTS - 1 do
TasButtonListClearDataEx(buttonListObject, Player(i))
end
end
end
function TasButtonListCopyDataEx(writeObject, readObject, player)
writeObject.Data[player] = readObject.Data[player]
for index = 1, readObject.DataFiltered.Count do writeObject.DataFiltered[index] = readObject.DataFiltered[index] end
writeObject.DataFiltered.Count = readObject.DataFiltered.Count
if GetLocalPlayer() == player then
BlzFrameSetMinMaxValue(writeObject.Slider, writeObject.Frames.Count, writeObject.Data[player].Count)
BlzFrameSetValue(writeObject.Slider,999999)
end
end
function TasButtonListCopyData(writeObject, readObject, player)
if player and type(player) == "userdata" then
TasButtonListCopyDataEx(writeObject, readObject, player)
else
for i = 0, bj_MAX_PLAYER_SLOTS - 1 do
TasButtonListCopyDataEx(writeObject, readObject, Player(i))
end
end
end
function TasButtonListSearch(buttonListObject, text)
if not text then text = BlzFrameGetText(buttonListObject.InputFrame) end
local filteredData = buttonListObject.DataFiltered
local oData = buttonListObject.Data[GetLocalPlayer()]
local value
if GetLocalPlayer() == GetTriggerPlayer() then
filteredData.Count = 0
if text ~= "" then
for index = 1, oData.Count do
value = oData[index]
if buttonListObject.SearchAction(value, text, buttonListObject) and (not buttonListObject.FilterAction or buttonListObject.FilterAction(value, buttonListObject, true)) then
filteredData.Count = filteredData.Count + 1
filteredData[filteredData.Count] = index
end
end
else
for index = 1, oData.Count do
value = oData[index]
if not buttonListObject.FilterAction or buttonListObject.FilterAction(value, buttonListObject, false) then
filteredData.Count = filteredData.Count + 1
filteredData[filteredData.Count] = index
end
end
end
--table.sort(filteredData, function(a, b) return GetObjectName(buttonListObject.Data[a]) < GetObjectName(buttonListObject.Data[b]) end )
--update Slider, with that also update
BlzFrameSetMinMaxValue(buttonListObject.Slider, buttonListObject.Frames.Count, math.max(filteredData.Count,0))
BlzFrameSetValue(buttonListObject.Slider, 999999)
end
end
-- demo Creators
function CreateTasButtonTooltip(frameObject, parent, button)
if not button then button = frameObject.Button end
-- create an empty FRAME parent for the box BACKDROP, otherwise it can happen that it gets limited to the 4:3 Screen.
frameObject.ToolTipFrameFrame = BlzCreateFrame("TasButtonListTooltipBoxFrame", button, 0, 0)
if GetHandleId(frameObject.ToolTipFrameFrame) == 0 then print("Error function CreateTasButtonTooltip Creating TasButtonListTooltipBoxFrame") end
frameObject.ToolTipFrame = BlzGetFrameByName("TasButtonListTooltipBox", 0)
frameObject.ToolTipFrameIcon = BlzGetFrameByName("TasButtonListTooltipIcon", 0)
frameObject.ToolTipFrameName = BlzGetFrameByName("TasButtonListTooltipName", 0)
frameObject.ToolTipFrameSeperator = BlzGetFrameByName("TasButtonListTooltipSeperator", 0)
frameObject.ToolTipFrameText = BlzGetFrameByName("TasButtonListTooltipText", 0)
BlzFrameSetPoint(frameObject.ToolTipFrameText, FRAMEPOINT_TOPRIGHT, parent, FRAMEPOINT_TOPLEFT, -0.001, -0.052)
BlzFrameSetPoint(frameObject.ToolTipFrame, FRAMEPOINT_TOPLEFT, frameObject.ToolTipFrameIcon, FRAMEPOINT_TOPLEFT, -0.005, 0.005)
BlzFrameSetPoint(frameObject.ToolTipFrame, FRAMEPOINT_BOTTOMRIGHT, frameObject.ToolTipFrameText, FRAMEPOINT_BOTTOMRIGHT, 0.005, -0.005)
BlzFrameSetTooltip(button, frameObject.ToolTipFrameFrame)
end
TasButtonList.TooltipCreator = CreateTasButtonTooltip
function TasButtonListAddRow(buttonListObject, buttonName, createAction)
local object = buttonListObject
if not buttonName then buttonName = object.Frames.ButtonName end
if not createAction then createAction = object.Frames.CreateAction end
if not buttonName then print("TasButtonListAddRow - Error - no Name/function") return object end
local newCount = object.Frames.Count + object.Frames.Cols
local first = true
local colGap = object.Frames.GapCol
local rowGap = object.Frames.GapRow
local parent = object.Parent
local cols = object.Frames.Cols
local rows = object.Frames.Rows + 1
object.Frames.Rows = rows
for int = object.Frames.Count + 1, newCount do
local frameObject = {}
frameObject.Index = int
if type(buttonName) == "string" then
frameObject.Button = BlzCreateFrame(buttonName, parent, 0, 0)
if GetHandleId(frameObject.Button) == 0 then print("TasButtonList - Error - can't create:", buttonName) end
elseif type(buttonName) == "function" then
frameObject.Button = buttonName(frameObject, parent, int)
end
TasButtonList.TooltipCreator(frameObject, object.Parent, frameObject.Button)
if createAction then createAction(frameObject, int, frameObject.Button)
elseif type(buttonName) == "string" then --default TasButtonList behaviour
frameObject.Icon = BlzGetFrameByName("TasButtonIcon", 0)
frameObject.Text = BlzGetFrameByName("TasButtonText", 0)
frameObject.IconGold = BlzGetFrameByName("TasButtonIconGold", 0)
frameObject.TextGold = BlzGetFrameByName("TasButtonTextGold", 0)
frameObject.IconLumber = BlzGetFrameByName("TasButtonIconLumber", 0)
frameObject.TextLumber = BlzGetFrameByName("TasButtonTextLumber", 0)
end
TasButtonList[frameObject.Button] = frameObject
TasButtonList[frameObject] = object
object.Frames[int] = frameObject
TasButtonAction(frameObject.Button, TasButtonList.ButtonTriggerAction)
TasFrameMouseUpAction(frameObject.Button, TasButtonList.ButtonTriggerRightClickAction)
TasSliderAction(frameObject.Button, nil, cols, object.Slider)
if int > 1 then
if first then
BlzFrameSetPoint(frameObject.Button, FRAMEPOINT_TOP, object.Frames[int - cols].Button, FRAMEPOINT_BOTTOM, 0, -rowGap)
first = false
else
BlzFrameSetPoint(frameObject.Button, FRAMEPOINT_LEFT, object.Frames[int - 1].Button, FRAMEPOINT_RIGHT, colGap, 0)
end
else
--print(-BlzFrameGetWidth(frameObject.Button)*cols - colGap*(cols-1))
first = false
BlzFrameSetSize(object.Head, BlzFrameGetWidth(frameObject.Button)*cols + colGap*(cols-1), BlzFrameGetHeight(object.Head))
--print(BlzFrameGetWidth(object.Head), BlzFrameGetHeight(object.Head))
if cols > 1 then
BlzFrameSetPoint(frameObject.Button, FRAMEPOINT_TOPLEFT, object.Head, FRAMEPOINT_BOTTOMLEFT, 0, 0)
else
BlzFrameSetPoint(frameObject.Button, FRAMEPOINT_TOPRIGHT, object.Head, FRAMEPOINT_BOTTOMRIGHT, 0, 0)
end
end
end
BlzFrameSetPoint(object.TotalFrame, FRAMEPOINT_BOTTOMRIGHT, object.Frames[newCount].Button, FRAMEPOINT_BOTTOMRIGHT, 0, 0)
object.Frames.Count = newCount
BlzFrameSetSize(object.Slider, 0.012, BlzFrameGetHeight(object.Frames[1].Button) * rows + rowGap * (rows - 1))
end
function CreateTasButtonListEx2(buttonName, cols, rows, colGap, rowGap, parent, createAction)
if not rowGap then rowGap = 0.0 end
if not colGap then colGap = 0.0 end
if not parent then parent = BlzCreateFrameByType("SLIDER", "TasButtonListParent", TasButtonList.DefaultOwnerFunc(), "", 0) end
local buttonCount = rows*cols
local object = InitTasButtonListObject(parent)
object.Frames.Count = 0
object.Frames.ButtonName = buttonName
object.Frames.CreateAction = createAction
object.Frames.Cols = cols
object.Frames.Rows = 0
object.Frames.GapCol = colGap
object.Frames.GapRow = rowGap
InitTasButtonListSlider(object, cols, rows, colGap, rowGap)
TasSliderAction(parent, nil, cols, object.Slider)
TasSliderAction.AvoidPoll[object.Slider] = false
for int = 1, rows do TasButtonListAddRow(object) end
BlzFrameSetSize(object.Slider, 0.012, BlzFrameGetHeight(object.Frames[1].Button) * rows + rowGap * (rows - 1))
return object
end
function CreateTasButtonListEx(buttonName, cols, rows, parent, buttonAction, rightClickAction, updateAction, searchAction, filterAction, asyncButtonAction, asyncRightClickAction, colGap, rowGap)
local object = CreateTasButtonListEx2(buttonName, cols, rows, colGap, rowGap, parent, createAction)
object.ButtonAction = buttonAction --call this inside the SyncAction after a button is clicked
object.RightClickAction = rightClickAction -- this inside a SyncAction when the button is right clicked.
object.UpdateAction = updateAction --function defining how to display stuff (async)
object.SearchAction = searchAction --function to return the searched Text (async)
object.FilterAction = filterAction --
object.AsyncButtonAction = asyncButtonAction -- happens in the clicking event inside a LocalPlayer Block
object.AsyncRightClickAction = asyncRightClickAction -- happens in the clicking event inside a LocalPlayer Block
if not updateAction then object.UpdateAction = UpdateTasButtonListDefaultObject end
if not searchAction then object.SearchAction = SearchTasButtonListDefaultObject end
return object
end
-- wrapper creators, they dont have async stuff
function CreateTasButtonList(buttonCount, parent, buttonAction, updateAction, searchAction, filterAction)
return CreateTasButtonListEx("TasButton", 1, buttonCount, parent, buttonAction, nil, updateAction, searchAction, filterAction)
end
function CreateTasButtonListV2(rowCount, parent, buttonAction, updateAction, searchAction, filterAction)
return CreateTasButtonListEx("TasButtonSmall", 2, rowCount, parent, buttonAction, nil, updateAction, searchAction, filterAction)
end
function CreateTasButtonListV3(rowCount, parent, buttonAction, updateAction, searchAction, filterAction)
return CreateTasButtonListEx("TasButtonGrid", 3, rowCount, parent, buttonAction, nil, updateAction, searchAction, filterAction)
end
function CreateTasButtonBoxedTextList(rowCount, colCount, parent, buttonAction, updateAction, searchAction, filterAction)
return CreateTasButtonListEx("TasBoxedTextButtonSmall", colCount, rowCount, parent, buttonAction, nil, updateAction or UpdateTasButtonListDefaultText, searchAction or SearchTasButtonListDefaultText, filterAction)
end
function CreateTasButtonBoxedTextListBig(rowCount, colCount, parent, buttonAction, updateAction, searchAction, filterAction)
return CreateTasButtonListEx("TasBoxedTextButton", colCount, rowCount, parent, buttonAction, nil, updateAction or UpdateTasButtonListDefaultText, searchAction or SearchTasButtonListDefaultText, filterAction)
end
function CreateTasButtonTextList(rowCount, colCount, parent, buttonAction, updateAction, searchAction, filterAction)
return CreateTasButtonListEx("TasTextButtonSmall", colCount, rowCount, parent, buttonAction, nil, updateAction or UpdateTasButtonListDefaultText, searchAction or SearchTasButtonListDefaultText, filterAction)
end
function CreateTasButtonTextListBig(rowCount, colCount, parent, buttonAction, updateAction, searchAction, filterAction)
return CreateTasButtonListEx("TasTextButton", colCount, rowCount, parent, buttonAction, nil, updateAction or UpdateTasButtonListDefaultText, searchAction or SearchTasButtonListDefaultText, filterAction)
end
--[[ TasHeroLearnEx V2e by Tasyen
A custom UI System to allow an Unit to have many skills to learn from.
TasHeroLearnEx.UpdateHeroData()
use this when you changed the HeroData from the outside or after InitBlizzard happened
function TasHeroLearnEx.CustomUnitLearnAbility(unit, abiCode)
Make Unit learn/improve abiCode and evoke a Learn Event
considers level requirments
overwrites TriggerRegisterAnyUnitEventBJ, DestroyTrigger (they still do what they should do)
and for a short time GetTriggerUnit, GetTriggerEventId, GetLearningUnit, GetLearnedSkill, GetLearnedSkillLevel, GetTriggerPlayer
only overwrites with hookEvent = true
Can use Hook version 7.0.1 by Bribe When provided
]]
do
local hookEvent = false --[[ Hook into Learn Event Triggers and Throw them? Only read at init
when you don't use hookEvent then you need to fill TasHeroLearnEx.Action with actionFunctions(unit, abiCode, abilityLevel, owner, unitCode)
TasHeroLearnEx.Action[FourCC('AHbz')] = function(unit, abiCode, abilityLevel, owner, unitCode) end
TasHeroLearnEx.Action[0] allways runs (hookEvent = false)
--]]
local AutoRun = true --(true) will create Itself at 0s, (false) you need to TasHeroLearnEx.Init()
local testSkill = FourCC'AHre' -- should not in the command card
local action
if CreateFourCCTable then action = CreateFourCCTable() else action = {} end
-- the none hookEvent approach runs for any skill learned by TasHeroLearnEx
action[0] = function(unit, abiCode, abilityLevel, owner, unitCode)
print("Action 0", GetUnitName(unit), GetAbilityName(abiCode))
end
TasHeroLearnEx = {
-- Where is the TOCFile in your map?
TocPath = "war3mapImported\\TasHeroLearnEx.toc"
,HookEvent = hookEvent
,Action = action
-- Data for each UnitCode
,HeroData = {
-- supported Keys unit, unitCode, Player, 0; unit > unitCode > Player > 0
-- [0] is used by everyone, if not one of the others is used currently.
-- [bj_lastCreatedUnit] = "AHfs,AHbn,AHdr,AHpx,AHhb,AHds,AHre,AHad"
-- [FourCC('Hblm')] = "AHfs,AHbn,AHdr,AHpx,AHhb,AHds,AHre,AHad"
-- [Player(0)] = "AHfs,AHbn,AHdr,AHpx,AHhb,AHds,AHre,AHad"
-- [0] = "AEmb,AEim,AEev,AEme,AEer,AEfn,AEah,AEtq"
-- you can set a field from outside of this system, But if you do you should use TasHeroLearnEx.UpdateHeroData() after setting your wanted data.
-- TasHeroLearnEx.HeroData[FourCC('Hblm')] = "AHfs,AHbn,AHdr,AHpx,AHhb,AHds,AHre,AHad"
[FourCC('Hblm')] = "AHfs,AHbn,AHdr,AHpx,AHhb,AHds,AHre,AHad,AHbz,AHab,AHwe,AHmt,AHtc,AHtb,AHbh,AHav,AOwk,AOcr,AOmi,AOww,AOfs,AOsf,AOcl,AOeq"
,[Player(1)] = "AUim,AUts,AUcb,AUls,AUfn,AUfu,AUdr,AUdd,AUav,AUsl,AUcs,AUin,AUdc,AUdp,AUau,AUan"
}
,HeroAbilityLevelSkip = 2 -- should match the map gameplay constant
,Filter = function(unit) -- used for HeroData[0]
if IsUnitIllusion(unit) then return false end
-- if not IsUnitType(unit, UNIT_TYPE_HERO) then return false end
--return true if this unit is allowed to use HeroData[0] HeroData[player]
return true
end
,Cols = 8 --amout of buttons in one Row
,Rows = 1 -- amount of Rows
,ShowEnemy = true -- can look into enemy builts false/true?
,HideMaxLevelSlot = false -- true shows empty slots for max Leveld skills.
,UserControl = false -- Show the Buttons to toggle ShowEnemy & HideMaxLevelSlot
,HideWithoutUser = true -- hide TasHeroLearnEx UI when currently nothing would be displayed.
,UseUIScale = true
--ToolTip
,ToolTipSizeX = 0.2
,ToolTipPosX = 0.79
,ToolTipPosY = 0.165
,ToolTipPos = FRAMEPOINT_BOTTOMRIGHT
-- Box
--Happens once at creation, decides how TasHeroLearnEx is posed
,PosBox = function(frame)
--BlzFrameSetAbsPoint(frame, FRAMEPOINT_BOTTOMLEFT, 0.195, 0.135)
BlzFrameSetPoint(frame, FRAMEPOINT_BOTTOMLEFT, BlzGetFrameByName("SimpleInfoPanelUnitDetail", 0), FRAMEPOINT_TOPLEFT, -0.1, 0.02)
end
-- ShowButton
,OpenButtonTexture = "ReplaceableTextures\\CommandButtons\\BTNSkillz.blp"
--Happens once at creation, decides where Open Button is posed
,PosOpen = function(frame)
--BlzFrameSetAbsPoint(frame, FRAMEPOINT_TOPRIGHT, 0.6, 0.15)
--BlzFrameSetPoint(frame, FRAMEPOINT_BOTTOMRIGHT, BlzGetFrameByName("SimpleInfoPanelUnitDetail", 0), FRAMEPOINT_TOPRIGHT, 0.1, 0.015)
BlzFrameSetPoint(frame, FRAMEPOINT_BOTTOMRIGHT, BlzGetFrameByName("SimpleInfoPanelUnitDetail", 0), FRAMEPOINT_TOPLEFT, 0.0, -0.01)
end
-- ParentFunc who you want as parent, this runs at InitBlizzard, if you need more control you need to modify the part that calls local function Init()
,ParentFunc = function() return BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0) end
-- how many LearnPoints an unit has to spent
,GetLearnPoints = function(unit)
return GetHeroSkillPoints(unit)
--return GetPlayerState(GetOwningPlayer(unit), PLAYER_STATE_RESOURCE_GOLD)//100
end
-- pay costs function is called inside TasHeroLearnEx.CustomUnitLearnAbility
,Costs = function(unit, abiCode)
-- can't pay return false
if TasHeroLearnEx.GetLearnPoints(unit) <= 0 then return false end
--SetPlayerState(GetOwningPlayer(unit), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(GetOwningPlayer(unit), PLAYER_STATE_RESOURCE_GOLD) - 100)
UnitModifySkillPoints(unit, -1)
return true
end
-- System stuff below
,Selected = {} -- current Selected Unit for [player]
,ViewOffset = __jarray(0) -- currentPage
,UpdateHeroData = function()
for key, value in pairs(TasHeroLearnEx.HeroData) do
if type(value) == "string" then
TasHeroLearnEx.HeroData[key] = this.IdString2IdArray(value)
end
end
end
-- supported DataMods
,SelectData = function(unit)
if TasHeroLearnEx.HeroData[unit] then return TasHeroLearnEx.HeroData[unit]
elseif TasHeroLearnEx.HeroData[GetUnitTypeId(unit)] then return TasHeroLearnEx.HeroData[GetUnitTypeId(unit)]
elseif TasHeroLearnEx.HeroData[GetOwningPlayer(unit)] and this.Filter(unit) then return TasHeroLearnEx.HeroData[GetOwningPlayer(unit)]
elseif TasHeroLearnEx.HeroData[0] and this.Filter(unit) then return TasHeroLearnEx.HeroData[0]
else return nil
end
end
,AbilityCache = {} -- makes performance better in V1.31 cause it lacks ParseTags and needs to do tooltip nonsense which with a cachce needs to be done only once.
,StringCache = {}
}
this = TasHeroLearnEx
this.UpdateButton = function(index, abiCode, level, levelMax)
BlzFrameSetVisible(BlzGetFrameByName("TasHeroLearnButton", index), true)
BlzFrameSetTexture(BlzGetFrameByName("TasHeroLearnButtonBackdrop", index), BlzGetAbilityIcon(abiCode), 0, false)
BlzFrameSetTexture(BlzGetFrameByName("TasHeroLearnButtonBackdropDisabled", index), TasHeroLearnEx.getDisabledIcon(BlzGetAbilityIcon(abiCode)), 0, false)
BlzFrameSetTexture(BlzGetFrameByName("TasHeroLearnButtonBackdropPushed", index), BlzGetAbilityIcon(abiCode), 0, false)
if level >= levelMax then
BlzFrameSetVisible(BlzGetFrameByName("TasHeroLearnButtonChargeBoxChecked", index), true)
BlzFrameSetText(BlzGetFrameByName("TasHeroLearnButtonChargeText", index), "")
else
BlzFrameSetVisible(BlzGetFrameByName("TasHeroLearnButtonChargeBoxChecked", index), false)
BlzFrameSetText(BlzGetFrameByName("TasHeroLearnButtonChargeText", index), level + 1)
end
end
this.EnforceUpdateOnce = true
local UpdateUILastData, UpdateUILastOffset, UpdateUILastUnit, UpdateUILastLevel, UpdateUILastPoints = 0,0,0,0, 0 -- buttons
local LastAbiCode, LastAbiLevel = 0,0 -- tooltip
this.UpdateUI = function()
--async
local foundTooltip = false
local unit = this.Selected[GetLocalPlayer()]
if this.HideWithoutUser then BlzFrameSetVisible(this.SuperParent, unit ~= nil) if not unit then return end end
local data = this.SelectData(unit)
if not data and this.HideWithoutUser then BlzFrameSetVisible(this.SuperParent, false) unit = nil return else BlzFrameSetVisible(this.SuperParent, true) end
local heroLevel = GetUnitLevel(unit)
local showCurrent = this.ShowEnemy or IsUnitAlly(unit, GetLocalPlayer())
local hasControl = IsUnitOwnedByPlayer(unit, GetLocalPlayer()) or GetPlayerAlliance(GetOwningPlayer(unit), GetLocalPlayer(), ALLIANCE_SHARED_CONTROL)
local learnPoints = this.GetLearnPoints(unit)
if (IsUnitAlly(unit, GetLocalPlayer()) or this.ShowEnemy) and data and learnPoints > 0 then
BlzFrameSetText(BlzGetFrameByName("TasHeroLearnButtonChargeText", 0), learnPoints)
BlzFrameSetVisible(BlzGetFrameByName("TasHeroLearnButtonChargeBox", 0), true)
BlzFrameSetVisible(BlzGetFrameByName("TasHeroLearnButtonSprite", 0), true)
else
BlzFrameSetVisible(BlzGetFrameByName("TasHeroLearnButtonChargeBox", 0), false)
BlzFrameSetVisible(BlzGetFrameByName("TasHeroLearnButtonSprite", 0), false)
end
local scale = BlzFrameGetWidth(BlzGetFrameByName("ConsoleUIBackdrop", 0))
if this.UseUIScale and scale > 0.1 then
scale = scale/0.8
BlzFrameSetScale(this.Parent, scale)
BlzFrameSetScale(this.Open, scale)
end
if BlzFrameIsVisible(this.Parent) then
-- skip visual updating the buttons when unneeded!!
local skipUpdate = UpdateUILastData == data
and UpdateUILastOffset == this.ViewOffset[GetLocalPlayer()]
and UpdateUILastUnit == GetHandleId(unit) -- compare GetHandleId to not keep a ref
and UpdateUILastLevel == heroLevel
and UpdateUILastPoints == learnPoints
if this.EnforceUpdateOnce then
this.EnforceUpdateOnce = false
skipUpdate = false
end
UpdateUILastData = data
UpdateUILastOffset = this.ViewOffset[GetLocalPlayer()]
UpdateUILastUnit = GetHandleId(unit)
UpdateUILastPoints = learnPoints
UpdateUILastLevel = heroLevel
for i = 1, this.Cols*this.Rows do
local skillIndex = i + this.ViewOffset[GetLocalPlayer()]
if data and data[skillIndex] then
local abiCode = data[skillIndex]
local level = GetUnitAbilityLevel(unit, abiCode)
local levelReq, levelSkipReq, levelMax
if level == 0 then
levelReq = this.GetAbilityData(abiCode, "reqLevel", S2I)
levelSkipReq = 0 -- does not matter much when one has currently level 0
levelMax = 1 -- Assume it can be learned atleast once
else
levelReq = this.GetAbilityData(abiCode, "reqLevel", S2I)
levelSkipReq = this.GetAbilityData(abiCode, "levelSkip", S2I)
levelMax = this.GetAbilityData(abiCode, "levels", S2I)
end
if levelSkipReq == 0 then levelSkipReq = this.HeroAbilityLevelSkip end
levelReq = levelSkipReq*level + levelReq
--print(heroLevel, levelReq, heroLevel >= levelReq)
--print(level)
-- tooltip
if BlzFrameIsVisible(BlzGetFrameByName("TasHeroLearnButtonTooltip", i)) then
foundTooltip = true
-- only update Tooltip when needed
if abiCode ~= LastAbiCode or level ~= LastAbiLevel then
LastAbiCode = abiCode
LastAbiLevel = level
BlzFrameSetTexture(BlzGetFrameByName("TasHeroLearnTooltipIcon", 0), BlzGetAbilityIcon(abiCode), 0, false)
if hasControl then
if heroLevel >= levelReq and level < levelMax then
BlzFrameSetText(BlzGetFrameByName("TasHeroLearnTooltipText", 0), BlzGetAbilityResearchExtendedTooltip(abiCode, 0))
BlzFrameSetText(BlzGetFrameByName("TasHeroLearnTooltipName", 0), BlzGetAbilityTooltip(abiCode, level))
elseif level >= levelMax then
BlzFrameSetText(BlzGetFrameByName("TasHeroLearnTooltipName", 0), BlzGetAbilityTooltip(abiCode, level - 1))
BlzFrameSetText(BlzGetFrameByName("TasHeroLearnTooltipText", 0), "|Cffffff00 - "..GetLocalizedString("QUESTCOMPLETED").."|r\n\n".. BlzGetAbilityResearchExtendedTooltip(abiCode, 0))
elseif heroLevel < levelReq then
BlzFrameSetText(BlzGetFrameByName("TasHeroLearnTooltipName", 0), BlzGetAbilityTooltip(abiCode, level))
BlzFrameSetText(BlzGetFrameByName("TasHeroLearnTooltipText", 0), GetLocalizedString("REQUIRESTOOLTIP") .."\n - "..GetLocalizedString("REQUIREDLEVELTOOLTIP").." ".. R2I(levelReq).."|r\n\n".. BlzGetAbilityResearchExtendedTooltip(abiCode, 0))
end
elseif showCurrent then
BlzFrameSetText(BlzGetFrameByName("TasHeroLearnTooltipName", 0), BlzGetAbilityTooltip(abiCode, level - 1))
BlzFrameSetText(BlzGetFrameByName("TasHeroLearnTooltipText", 0), BlzGetAbilityExtendedTooltip(abiCode, level - 1))
end
end
end
-- button
if abiCode and hasControl then
if not this.HideMaxLevelSlot or level < levelMax then
if not skipUpdate then this.UpdateButton(i, abiCode, level, levelMax) end
BlzFrameSetEnable(BlzGetFrameByName("TasHeroLearnButton", i), heroLevel >= levelReq and level < levelMax)
else
BlzFrameSetVisible(BlzGetFrameByName("TasHeroLearnButton", i), false)
end
elseif abiCode and showCurrent and level >= 1 then
BlzFrameSetEnable(BlzGetFrameByName("TasHeroLearnButton", i), false)
if not skipUpdate then this.UpdateButton(i, abiCode, level-1, levelMax) end
else
BlzFrameSetVisible(BlzGetFrameByName("TasHeroLearnButton", i), false)
end
else
BlzFrameSetVisible(BlzGetFrameByName("TasHeroLearnButton", i), false)
end
end
BlzFrameSetVisible(BlzGetFrameByName("TasHeroLearnTooltipBoxFrame", 0), foundTooltip)
end
unit = nil
end
local AbilityCache = this.AbilityCache
function this.GetAbilityData(abiCode, tag, convertFunc)
-- was this ability already parsed?
if not AbilityCache[abiCode] then
AbilityCache[abiCode] = {}
AbilityCache[abiCode].String = string.pack(">I4", abiCode) -- store the result
end
if not AbilityCache[abiCode][tag] then
-- calc it and store it
-- have ParseTags native?
if ParseTags then
this.AbilityCache[abiCode][tag] = ParseTags("<"..AbilityCache[abiCode].String..","..tag..">")
else
BlzSetAbilityExtendedTooltip(testSkill, "<"..AbilityCache[abiCode].String..","..tag..">", 0)
this.AbilityCache[abiCode][tag] = BlzGetAbilityExtendedTooltip(testSkill, 0)
end
if convertFunc then this.AbilityCache[abiCode][tag] = convertFunc(this.AbilityCache[abiCode][tag]) end
end
return this.AbilityCache[abiCode][tag]
end
function TasHeroLearnEx.getDisabledIcon(icon)
--ReplaceableTextures\CommandButtons\BTNHeroPaladin.tga -> ReplaceableTextures\CommandButtonsDisabled\DISBTNHeroPaladin.tga
if not this.StringCache[icon] and string.sub(icon,35,35) ~= "\\" then return icon end --this string has not enough chars return it
if not this.StringCache[icon] then
local old = icon
-- make it lower to reduce the amount of cases and for warcraft 3 FilePath case does not matter
icon = string.lower(icon)
if string.find(icon, "commandbuttons\\btn") then this.StringCache[old] = string.gsub(icon, "commandbuttons\\btn", "commandbuttonsdisabled\\disbtn" )
-- default wacraft 3 style
elseif string.find(icon, "passivebuttons\\pasbtn") then this.StringCache[old] = string.gsub(icon, "passivebuttons\\pasbtn", "commandbuttonsdisabled\\dispasbtn" )
--recommented by hiveworkshop
elseif string.find(icon, "passivebuttons\\pas") then this.StringCache[old] = string.gsub(icon, "passivebuttons\\pas", "commandbuttonsdisabled\\dispas" )
elseif string.find(icon, "commandbuttons\\atc") then this.StringCache[old] = string.gsub(icon, "commandbuttons\\atc", "commandbuttonsdisabled\\disbtn" ) end
icon = old
end
return this.StringCache[icon]
end
--[[ EvokeUnitEvent Skill by Tasyen
This system tries to let a custom system creator to start an unit event to give a simpler api.
]]
do
if TasHeroLearnEx.HookEvent then
local list = {}
-- hook into TriggerRegisterAnyUnitEventBJ to find triggers having the wanted event
local realAnyUnit = TriggerRegisterAnyUnitEventBJ
function TriggerRegisterAnyUnitEventBJ(whichTrigger, whichPlayerUnitEvent)
if GetHandleId(whichPlayerUnitEvent) == GetHandleId(EVENT_PLAYER_HERO_SKILL) then
table.insert(list, whichTrigger)
list[whichTrigger] = true
end
realAnyUnit(whichTrigger, whichPlayerUnitEvent)
end
-- remove triggers that are going to be destroyed
local realDestroyTrigger = DestroyTrigger
function DestroyTrigger(trig)
if list[trig] then
list[trig] = nil
for i = #list, 1, -1 do
if list[i] == trig then table.remove(list, i) break end
end
end
realDestroyTrigger(trig)
end
-- data used to replace default getters
local hero, skill, level, owner
local FuncGetTriggerUnit, FuncGetTriggerEventId, FuncGetLearningUnit, FuncGetLearnedSkill, FuncGetLearnedSkillLevel, FuncGetTriggerPlayer = GetTriggerUnit, GetTriggerEventId, GetLearningUnit, GetLearnedSkill, GetLearnedSkillLevel, GetTriggerPlayer
-- a learn trigger could evoke non learn triggers they still need to use the real getters
local function OGetTriggerUnit() if list[GetTriggeringTrigger()] then return hero else return FuncGetTriggerUnit() end end
local function OGetTriggerEventId() if list[GetTriggeringTrigger()] then return GetHandleId(EVENT_PLAYER_HERO_SKILL) else return FuncGetTriggerEventId() end end
local function OGetLearningUnit() if list[GetTriggeringTrigger()] then return hero else return FuncGetLearningUnit() end end
local function OGetLearnedSkill() if list[GetTriggeringTrigger()] then return skill else return FuncGetLearnedSkill() end end
local function OGetLearnedSkillLevel() if list[GetTriggeringTrigger()] then return level else return FuncGetLearnedSkillLevel() end end
local function OGetTriggerPlayer() if list[GetTriggeringTrigger()] then return owner else return FuncGetTriggerPlayer() end end
local hooks = {}
-- evoke custom Event
function this.EvokeUnitLevelEvent(unit, abiCode)
-- print("EvokeUnitLevelEvent", #list)
-- store data that replaces the getters
hero = unit
skill = abiCode
level = GetUnitAbilityLevel(unit, abiCode)
owner = GetOwningPlayer(unit)
if AddHook then
_ ,hooks[1] = AddHook("GetTriggerUnit", OGetTriggerUnit, 0)
_ ,hooks[2] = AddHook("GetTriggerEventId", OGetTriggerEventId, 0)
_ ,hooks[3] = AddHook("GetLearningUnit", OGetLearningUnit, 0)
_ ,hooks[4] = AddHook("GetLearnedSkill", OGetLearnedSkill, 0)
_ ,hooks[5] = AddHook("GetLearnedSkillLevel", OGetLearnedSkillLevel, 0)
_ ,hooks[6] = AddHook("GetTriggerPlayer", OGetTriggerPlayer, 0)
else
GetTriggerUnit = OGetTriggerUnit
GetTriggerEventId = OGetTriggerEventId
GetLearningUnit = OGetLearningUnit
GetLearnedSkill = OGetLearnedSkill
GetLearnedSkillLevel = OGetLearnedSkillLevel
GetTriggerPlayer = OGetTriggerPlayer
end
for _, trigger in ipairs(list) do
ConditionalTriggerExecute(trigger)
end
--restore the getters
if AddHook then
for i,v in ipairs(hooks) do
v()
end
while table.remove(hooks) do end
else
GetTriggerUnit = FuncGetTriggerUnit
GetTriggerEventId = FuncGetTriggerEventId
GetLearningUnit = FuncGetLearningUnit
GetLearnedSkill = FuncGetLearnedSkill
GetLearnedSkillLevel = FuncGetLearnedSkillLevel
GetTriggerPlayer = FuncGetTriggerPlayer
end
-- print("EvokeUnitLevelEvent Done")
end
else
function this.EvokeUnitLevelEvent(unit, abiCode)
if this.Action[0] then
this.Action[0](unit, abiCode, GetUnitAbilityLevel(unit, abiCode), GetOwningPlayer(unit), GetUnitTypeId(unit))
end
if this.Action[abiCode] then
this.Action[abiCode](unit, abiCode, GetUnitAbilityLevel(unit, abiCode), GetOwningPlayer(unit), GetUnitTypeId(unit))
end
end
end
end
-- Make Unit learn abiCode and evoke a Learn Event
function this.CustomUnitLearnAbility(unit, abiCode)
if not abiCode or abiCode <= 0 or not unit then return end
if GetUnitAbilityLevel(unit, abiCode) == 0 then
if this.GetAbilityData(abiCode, "reqLevel", S2I) > GetUnitLevel(unit) then return end
if not this.Costs(unit, abiCode) then return end
UnitAddAbility(unit, abiCode)
UnitMakeAbilityPermanent(unit, true, abiCode)
elseif GetUnitAbilityLevel(unit, abiCode) < BlzGetAbilityIntegerField(BlzGetUnitAbility(unit, abiCode), ABILITY_IF_LEVELS) then
local levelReq = this.GetAbilityData(abiCode, "reqLevel", S2I)
--levelSkipReq = BlzGetAbilityIntegerField(abi, ABILITY_IF_LEVEL_SKIP_REQUIREMENT)
local levelSkipReq = this.GetAbilityData(abiCode, "levelSkip", S2I)
if levelSkipReq == 0 then levelSkipReq = this.HeroAbilityLevelSkip end
levelReq = levelSkipReq*GetUnitAbilityLevel(unit, abiCode) + levelReq
if levelReq > GetUnitLevel(unit) then return end
if not this.Costs(unit, abiCode) then return end
IncUnitAbilityLevel(unit, abiCode)
UnitMakeAbilityPermanent(unit, true, abiCode)
else
--print("CustomUnitLearnEvent max Level", GetUnitName(unit), GetAbilityName(abiCode))
return
end
this.EvokeUnitLevelEvent(unit, abiCode)
end
-- "ACfb,AInv,A070" -> {FourCC('ACfb'),FourCC('AInv'),FourCC('A070')}
function this.IdString2IdArray(string)
local result = {}
local startIndex = 1
while startIndex + 3 <= string.len(string) do
local skillCode = string.sub(string, startIndex, startIndex + 3)
startIndex = startIndex + 5
skillCode = FourCC(skillCode)
table.insert(result, skillCode)
end
return result
end
do
local function InitFrames()
BlzGetFrameByName("ConsoleUIBackdrop", 0)
BlzLoadTOCFile(TasHeroLearnEx.TocPath)
TasHeroLearnEx.SuperParent = BlzCreateFrame("TasHeroLearnParentFrame", TasHeroLearnEx.ParentFunc(), 0, 0)
TasHeroLearnEx.Parent = BlzGetFrameByName("TasHeroLearnFrame", 0)
TasButtonAction(TasHeroLearnEx.Parent, function(frame, player) end) -- use the clear focus feature from TasButtonAction
TasHeroLearnEx.PosBox(TasHeroLearnEx.Parent)
BlzFrameSetSize(TasHeroLearnEx.Parent, 0.04, 0.04)
local frame = BlzCreateFrameByType("SLIDER", "TasHeroLearnSlider", TasHeroLearnEx.Parent, "QuestMainListScrollBar", 0)
BlzFrameClearAllPoints(frame)
BlzFrameSetPoint(frame, FRAMEPOINT_BOTTOMRIGHT, TasHeroLearnEx.Parent, FRAMEPOINT_BOTTOMRIGHT, -0.004, 0.008)
BlzFrameSetStepSize(frame, 1)
TasSliderAction(frame, function(frame, player, value)
this.ViewOffset[player] = R2I(value*this.Cols)
end)
TasSliderAction(TasHeroLearnEx.Parent, nil, 1, BlzGetFrameByName("TasHeroLearnSlider", 0))
frame = BlzCreateFrameByType("GLUETEXTBUTTON", "TasHeroLearnToggleA", TasHeroLearnEx.Parent, "ScriptDialogButton", 0)
BlzFrameSetSize(frame, 0.03, 0.03)
BlzFrameSetText(frame, "A")
BlzFrameSetPoint(frame, FRAMEPOINT_BOTTOMRIGHT, TasHeroLearnEx.Parent, FRAMEPOINT_TOPRIGHT, -0.004, 0.003)
TasButtonAction(frame, function(frame, player)
if GetLocalPlayer() == player then
this.HideMaxLevelSlot = not this.HideMaxLevelSlot
end
end)
BlzFrameSetVisible(frame, this.UserControl)
frame = BlzCreateFrameByType("GLUETEXTBUTTON", "TasHeroLearnToggleB", TasHeroLearnEx.Parent, "ScriptDialogButton", 0)
BlzFrameSetSize(frame, 0.03, 0.03)
BlzFrameSetText(frame, "B")
BlzFrameSetPoint(frame, FRAMEPOINT_RIGHT, BlzGetFrameByName("TasHeroLearnToggleA", 0), FRAMEPOINT_LEFT, -0.004, 0)
TasButtonAction(frame, function(frame, player)
if GetLocalPlayer() == player then
this.ShowEnemy = not this.ShowEnemy
end
end)
BlzFrameSetVisible(frame, this.UserControl)
if GetHandleId(TasHeroLearnEx.SuperParent) == 0 then print("Error - TasHeroLearnEx Create TasHeroLearnParentFrame") end
TasHeroLearnEx.Open = BlzCreateFrame("TasHeroLearnButton", TasHeroLearnEx.SuperParent, 0, 0)
BlzFrameSetTexture(BlzGetFrameByName("TasHeroLearnButtonBackdrop", 0), this.OpenButtonTexture, 0, false)
BlzFrameSetTexture(BlzGetFrameByName("TasHeroLearnButtonBackdropDisabled", 0), TasHeroLearnEx.getDisabledIcon(this.OpenButtonTexture), 0, false)
BlzFrameSetTexture(BlzGetFrameByName("TasHeroLearnButtonBackdropPushed", 0), this.OpenButtonTexture, 0, false)
BlzFrameSetVisible(BlzGetFrameByName("TasHeroLearnButtonChargeBox", 0), false)
BlzGetFrameByName("TasHeroLearnButtonChargeText", 0)
BlzFrameSetVisible(BlzGetFrameByName("TasHeroLearnButtonChargeBoxChecked", 0), false)
TasHeroLearnEx.PosOpen(TasHeroLearnEx.Open)
TasButtonAction(TasHeroLearnEx.Open, function(frame, player)
if GetLocalPlayer() == player then
BlzFrameSetVisible(TasHeroLearnEx.Parent, not BlzFrameIsVisible(TasHeroLearnEx.Parent))
end
end)
BlzFrameSetVisible(BlzGetFrameByName("TasHeroLearnButtonSprite", 0), false)
local count = 0
for i = 1, this.Rows*this.Cols do
frame = BlzCreateFrame("TasHeroLearnButton", TasHeroLearnEx.Parent, 0, i)
TasHeroLearnEx[frame] = i
-- reserve HandleIds to allow async access later
BlzGetFrameByName("TasHeroLearnButtonBackdrop", i)
BlzGetFrameByName("TasHeroLearnButtonBackdropDisabled", i)
BlzGetFrameByName("TasHeroLearnButtonBackdropPushed", i)
BlzGetFrameByName("TasHeroLearnButtonTooltip", i)
BlzGetFrameByName("TasHeroLearnButtonChargeBox", i)
BlzGetFrameByName("TasHeroLearnButtonChargeText", i)
BlzGetFrameByName("TasHeroLearnButtonChargeBoxChecked", i)
BlzFrameSetVisible(BlzGetFrameByName("TasHeroLearnButtonSprite", i), false)
count = count + 1
if count > this.Cols then
BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, BlzGetFrameByName("TasHeroLearnButton", i - this.Cols), FRAMEPOINT_BOTTOMLEFT, 0, -0.002)
count = 1
elseif i > 1 then
BlzFrameSetPoint(frame, FRAMEPOINT_LEFT, BlzGetFrameByName("TasHeroLearnButton", i - 1), FRAMEPOINT_RIGHT, 0.002, 0)
end
TasButtonAction(frame, function(frame, player)
local unit = TasHeroLearnEx.Selected[player]
if IsUnitType(unit, UNIT_TYPE_DEAD) or IsUnitPaused(unit) or IsUnitIllusion(unit) then return end
if IsUnitOwnedByPlayer(unit, player) or GetPlayerAlliance(GetOwningPlayer(unit), player, ALLIANCE_SHARED_CONTROL) then
local i = TasHeroLearnEx[frame]
local skillIndex = i + this.ViewOffset[player]
--print(i, skillIndex)
this.CustomUnitLearnAbility(TasHeroLearnEx.Selected[player], this.SelectData(TasHeroLearnEx.Selected[player])[skillIndex])
else
DisplayTextToPlayer(player, 0, 0, "Can't Learn - You have no control over this unit")
end
end)
TasSliderAction(frame, nil, 1, BlzGetFrameByName("TasHeroLearnSlider", 0))
end
BlzFrameSetPoint(BlzGetFrameByName("TasHeroLearnButton", 1), FRAMEPOINT_TOPLEFT, TasHeroLearnEx.Parent, FRAMEPOINT_TOPLEFT, 0.006, -0.006)
frame = BlzGetFrameByName("TasHeroLearnButton", 1)
BlzFrameSetSize(TasHeroLearnEx.Parent, BlzFrameGetWidth(frame)*this.Cols + (this.Cols - 1)*0.002 + 0.023, BlzFrameGetHeight(frame)*this.Rows + (this.Rows - 1)*0.002 + 0.012)
BlzFrameSetSize(BlzGetFrameByName("TasHeroLearnSlider", 0), BlzFrameGetWidth(BlzGetFrameByName("TasHeroLearnSlider", 0)), BlzFrameGetHeight(TasHeroLearnEx.Parent) - 0.02)
-- create one ToolTip which shows data for current hovered inside a timer.
-- also reserve handleIds to allow async usage
BlzCreateFrame("TasHeroLearnTooltipBoxFrame", TasHeroLearnEx.SuperParent, 0, 0)
BlzGetFrameByName("TasHeroLearnTooltipBox", 0)
BlzGetFrameByName("TasHeroLearnTooltipIcon", 0)
BlzGetFrameByName("TasHeroLearnTooltipName", 0)
BlzGetFrameByName("TasHeroLearnTooltipSeperator", 0)
BlzGetFrameByName("TasHeroLearnTooltipText", 0)
BlzFrameSetSize(BlzGetFrameByName("TasHeroLearnTooltipText", 0), this.ToolTipSizeX, 0)
BlzFrameSetAbsPoint(BlzGetFrameByName("TasHeroLearnTooltipText", 0), this.ToolTipPos, this.ToolTipPosX, this.ToolTipPosY)
BlzFrameSetPoint(BlzGetFrameByName("TasHeroLearnTooltipBox", 0), FRAMEPOINT_TOPLEFT, BlzGetFrameByName("TasHeroLearnTooltipIcon", 0), FRAMEPOINT_TOPLEFT, -0.005, 0.005)
BlzFrameSetPoint(BlzGetFrameByName("TasHeroLearnTooltipBox", 0), FRAMEPOINT_BOTTOMRIGHT, BlzGetFrameByName("TasHeroLearnTooltipText", 0), FRAMEPOINT_BOTTOMRIGHT, 0.005, -0.005)
BlzFrameSetVisible(BlzGetFrameByName("TasHeroLearnTooltipBoxFrame", 0), false)
BlzFrameSetVisible(this.Parent, false)
--BlzFrameSetVisible(TasHeroLearnEx.SuperParent, false)
end
function this.Init()
local trigger
this.UpdateHeroData()
trigger = CreateTrigger()
TriggerAddAction(trigger, function()
if GetLocalPlayer() == GetTriggerPlayer() then BlzFrameSetVisible(TasHeroLearnEx.Parent, false) end
end)
for i = 0, bj_MAX_PLAYERS - 1 do
TriggerRegisterPlayerEventEndCinematic(trigger, Player(i))
end
-- selection
trigger = CreateTrigger()
TriggerAddAction(trigger, function()
TasHeroLearnEx.Selected[GetTriggerPlayer()] = GetTriggerUnit()
local data = this.SelectData(GetTriggerUnit())
if data then
local skillCount = #data
--local max = R2I(math.max(0, (skillCount - 1)/(this.Cols)))
local max = R2I(math.max(0, (skillCount +this.Cols - this.Cols*this.Rows)/this.Cols) )
BlzFrameSetValue(BlzGetFrameByName("TasHeroLearnSlider", 0), math.min(max, BlzFrameGetValue(BlzGetFrameByName("TasHeroLearnSlider", 0))))
BlzFrameSetMinMaxValue(BlzGetFrameByName("TasHeroLearnSlider", 0), 0, max)
else
BlzFrameSetValue(BlzGetFrameByName("TasHeroLearnSlider", 0), 0)
BlzFrameSetMinMaxValue(BlzGetFrameByName("TasHeroLearnSlider", 0), 0, 0)
end
this.EnforceUpdateOnce = true
this.UpdateUI()
end)
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_SELECTED)
-- TooltipUpdate
TimerStart(CreateTimer(), 0.2, true, this.UpdateUI)
InitFrames()
if FrameLoaderAdd then FrameLoaderAdd(InitFrames) end
end
if AutoRun then
if OnInit then -- Total Initialization v5.2.0.1 by Bribe
OnInit.trig(this.Init)
else -- without
local real = InitBlizzard
function InitBlizzard()
real()
this.Init()
end
end
end
end
end
do
--[[ TasAbilityData
TasAbilityData.GetField(abiCode, tag, convertFunc, formatTag)
get 1 field using the object editor tooltiping parsing feature
TasAbilityData.GetField((FourCC'AHbz'), "Cost1")
TasAbilityData.GetField((FourCC'AHbz'), "Cast1", nil, ",.")
TasAbilityData.Extract([whiteList, blackList, outputFrame])
whiteList & blackList are tables with {key = true, key2 = true, ...}
without outputFrame it returns a the text as a string
with outputFrame it BlzFrameSetText the result onto outputFrame
TasAbilityData.Extract(nil, {Tooltip = true}, BlzGetFrameByName("CheatFrameInput", 0))
TasAbilityData.GetGenericFields(spellCode)
]]
local this = {}
TasAbilityData = this
this.MaxLevel = 5 -- only consider upto this amount of levels for display
this.Seperator = " / " -- shown between multilevel data 15 / 20 / 30 if data for all levels is the same only one number is shown
this.LinearLevel = 3 -- display "base + add x Level", if level 1, 2 & 3 fit and skill has atleast this amount of levels
this.StringMana = "Mana" -- Text for Mana tries to GetLocalizedString
this.StringRange = "Range"
this.StringArea = "Aoe"
this.StringCooldown = "Cooldown"
this.StringCastTime = "CastTime"
this.StringDur = "Dur"
this.StringDurHero = "DurHero"
this.StringLevel = "LEVEL"
this.Localize = true -- try to throw texts in to GetLocalizedString
this.DoLocalize = function(text) if this.Localize then return GetLocalizedString(text) else return text end end
local AbilityCache = {}
local testSkill = FourCC'AHre' -- should not be used in the map
this.Cache = AbilityCache
function this.Extract(whiteList, blackList, outputFrame)
local text = ""
local count
for skillCode, data in pairs(AbilityCache) do
text = text .. "\nTasAbilityData["..skillCode.."] = {"
count = 0
for key, value in pairs(data) do
if (not whiteList and not blackList) or (whiteList and whiteList[key]) or (blackList and not blackList[key]) then
count = count + 1
if count > 1 then text = text .. ", " end
text = text .. key .. "= '".. value.."'"
end
end
text = text .. "}"
end
if outputFrame then BlzFrameSetText(outputFrame, text)
else
return text
end
end
function this.GetField(abiCode, tag, convertFunc, formatTag)
if not formatTag then formatTag = "" end
-- was this ability already parsed?
if not AbilityCache[abiCode] then
AbilityCache[abiCode] = {}
AbilityCache[abiCode].String = string.pack(">I4", abiCode) -- store the result
end
if not AbilityCache[abiCode][tag] then
-- calc it and store it
-- have ParseTags native?
if ParseTags then
AbilityCache[abiCode][tag] = ParseTags("<"..AbilityCache[abiCode].String..","..tag..formatTag..">")
else
--local backup = BlzGetAbilityExtendedTooltip(abiCode, 0)
BlzSetAbilityExtendedTooltip(testSkill, "<"..AbilityCache[abiCode].String..","..tag..formatTag..">", 0)
AbilityCache[abiCode][tag] = BlzGetAbilityExtendedTooltip(testSkill, 0)
--BlzSetAbilityExtendedTooltip(abiCode, backup, 0)
end
if convertFunc then AbilityCache[abiCode][tag] = convertFunc(AbilityCache[abiCode][tag]) end
end
return AbilityCache[abiCode][tag]
end
local TempSpellData = {}
function this.GetDataEnum(spellCode, key, levels, convertFunc, formatTag)
local hasDif = false
for i = 1,levels do
TempSpellData[i] = this.GetField(spellCode, key..i, convertFunc, formatTag)
if not hasDif and i > 1 and TempSpellData[i] ~= TempSpellData[i - 1] then hasDif = true end
end
if not hasDif then
return TempSpellData[1]
else
if levels >= this.LinearLevel then
local value1, value2, value3 = tonumber(TempSpellData[1]), tonumber(TempSpellData[2]), tonumber(TempSpellData[3])
local add12 = value2 - value1
local add23 = value3 - value2
if add12 == add23 then
local sign = " + "
if add12 < 0 then sign = " - " end
if math.abs(add12) == 1 then
return (value1-add12)..sign..this.DoLocalize(this.StringLevel)
else
return (value1-add12)..sign..math.abs(add12).."x"..this.DoLocalize(this.StringLevel)
end
end
end
local text = TempSpellData[1]
for i=2,levels do text = text ..this.Seperator..TempSpellData[i] end
return text, true
end
end
function this.AddDataEnum(spellCode, preText, key, levels, convertFunc, formatTag)
local data, hasDif = this.GetDataEnum(spellCode, key, levels, convertFunc, formatTag)
if not hasDif and (TempSpellData[1] == "0" or tonumber(TempSpellData[1]) == 0) then return "" end
return "\n".. this.DoLocalize(preText).." " .. data , data
end
function this.GetGenericFields(spellCode)
if not AbilityCache[spellCode] or not AbilityCache[spellCode].Tooltip then
local addDataEnum = this.AddDataEnum
local text = "\n--------------"
local levelReq = this.GetField(spellCode, "reqLevel", S2I)
local levelMax = math.min(this.GetField(spellCode, "levels", S2I), this.MaxLevel)
if levelReq > 1 then
text = text.. "\n".. this.DoLocalize("REQUIRESTOOLTIP") .." "..this.DoLocalize("REQUIREDLEVELTOOLTIP").." ".. levelReq .."|r"
end
text = text.. addDataEnum(spellCode, this.StringRange, "Rng", levelMax)
text = text.. addDataEnum(spellCode, this.StringArea, "Area", levelMax)
text = text.. addDataEnum(spellCode, this.StringCastTime, "Cast", levelMax, nil, ",.")
text = text.. addDataEnum(spellCode, this.StringMana, "Cost", levelMax)
text = text.. addDataEnum(spellCode, this.StringCooldown, "Cool", levelMax)
local unitDurText, unitDur = addDataEnum(spellCode, this.StringDur, "Dur", levelMax)
text = text.. unitDurText
local heroDurText, heroDur = addDataEnum(spellCode, this.StringDurHero, "HeroDur", levelMax)
if heroDur ~= unitDur then text = text.. heroDurText end
AbilityCache[spellCode].Tooltip = text
return text
end
return AbilityCache[spellCode].Tooltip
end
end
--By Tasyen
---GetPlayerColorTexture
---@param player player
---@param enforcePlayerColor? boolean (true) ignore enemy ally color mode
---@return string
function GetPlayerColorTexture(player, enforcePlayerColor)
-- normal mode
if GetAllyColorFilterState() == 0 or enforcePlayerColor then
if GetHandleId(GetPlayerColor(player)) < 10 then
return "ReplaceableTextures\\TeamColor\\TeamColor0"..GetHandleId(GetPlayerColor(player))
else
return "ReplaceableTextures\\TeamColor\\TeamColor"..GetHandleId(GetPlayerColor(player))
end
else
-- enemy friend self mode
if player == GetLocalPlayer() then
return "ReplaceableTextures\\TeamColor\\TeamColor01"
elseif player == Player(PLAYER_NEUTRAL_AGGRESSIVE) then
return "ReplaceableTextures\\TeamColor\\TeamColor24"
elseif IsPlayerAlly(player, GetLocalPlayer()) then
return "ReplaceableTextures\\TeamColor\\TeamColor02"
elseif IsPlayerEnemy(player, GetLocalPlayer()) then
return "ReplaceableTextures\\TeamColor\\TeamColor00"
else
return "ReplaceableTextures\\TeamColor\\TeamColor00"
end
end
end
--[[ TasSkillSetPicker V1.2 by Tasyen
TasSkillSetPicker.DefineCategory(icon, text) -> number categoryValue
make a new category
categories need to be made before the UI is created.
TasSkillSetPicker.Add(spellCode, category)
add an new Spell as option with category.
i Suggest to store categories in variables and add them
TasSkillSetPicker.Add('AHhb', 1 + 2)
spellCode can be a Table expects some Keys {Icon = img, Text = bigText, Name = smallText}
you can add after the ui was created or before.
this can be used to set the category of already added choices
TasSkillSetPicker.LockCategory(buttonIndex, category)
the skill selected at buttonIndex needs to have this category, it can have other categories aswell.
buttonIndex starts with 1
TasSkillSetPicker.BanCategory(buttonIndex, category)
the skill selected at buttonIndex can not have this category.
TasSkillSetPicker.PlayerAccept(player)
finish player, fills unset slots with randoms
TasSkillSetPicker.ForcePickNow()
all players PLAYER_SLOT_STATE_PLAYING are forced to accept now, if they did not already.
TasSkillSetPicker.ResetPlayer([player])
players choosen data is removed and can use ui again
no player = all players
TasSkillSetPicker.ShowOtherPlayerBars([show, player])
TasSkillSetPicker.ClearData()
remove all choseable options.
requires
GetPlayerColorTexture
TasButtonList V14 or higher
TasWindow
TasFrameList
TasFrameAction
optional
TasAbilityData (ToolTipGenInfo = true)
]]
do
local this = {}
this.Show = true -- Show on Creation
this.TocPath = "war3mapImported\\TasSkillSetPicker.toc"
this.BarSlotCount = 6 -- The amount of Skills a Player picks & Buttons in one Bar. Expects 1 to 12. 6 are one Row, 12 are 2 Rows. You could choose more but more rows was not coded and therefore will look bad. Dont change this value after creation
this.ParentFunc = function() return BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0) end
this.PosX = 0.77
this.PosY = 0.55
this.SizeX = 0.51 -- total Size with Bars & editor
this.SizeY = 0.37
this.Pos = FRAMEPOINT_TOPRIGHT
this.ToolTipGenInfo = true -- (true) Add generic spell Fields to the displayed tooltip text (only for number choices). requires GetGenericSpellData
this.ShowBars = true -- preview other player builts (false) makes the UI smaller
this.ShowEnemy = true -- can look into enemy builts false/true?
this.Localize = true -- try to throw texts in to GetLocalizedString
-- These are images displayed over a category button that mets the conditions. Only one of them is displayed at once, or none of them.
-- They are displayed with reduced Alpha
this.FilterNotAllowed = "ui/widgets/battlenet/chaticons/bnet-squelch" -- TasSkillSetPicker.BanCategory
this.FilterNotUsed = "textures/black32" -- user does not search by this category
this.FilterEnforced = "ui/widgets/glues/gluescreen-checkbox-check" -- TasSkillSetPicker.LockCategory
-- accept/random/show Button
-- a button that allows the user to show a hidden TasSkillSetPicker
this.ShowButtonShow = true
this.ShowButtonParentFunc = function() return BlzGetFrameByName("InsideMainPanel", 0) end
this.ShowButtonText = "Skill Picker" --tries Localizing
this.ShowButtonPosX = 0.1
this.ShowButtonPosY = 0.55
-- Inside a SkillBar what to display for no/0 skill?
-- not used in table mode
this.NoSkillIcon = "replaceabletextures/commandbuttons/btntemp"
this.NoSkillTooltip = "No Skill"
-- accept/random Button
this.ControlButtonSizeX = 0.085
this.ControlButtonSizeY = 0.03
this.RandomButtonText = "RANDOM" --tries Localizing
this.AcceptButtonText = "ACCEPT" --tries Localizing
this.RandomButtonTooltip = "Randomize the current Slot" --tries Localizing
this.AcceptButtonTooltip = "Finish selection & Fills unused slots" --tries Localizing
this.FreeButtonText = "" --tries Localizing
this.FreeButtonTooltip = "" --tries Localizing
this.FreeButtonShow = false --show the free button which function you need to code function this.ActionButtonFree(frame, player)
this.EditorBarTitle = "SkillSet Editor"
this.EditorBarIcon = "replaceabletextures/commandbuttons/btnengineeringupgrade"
this.SearchBarTooltip = "Search in Ability Name & Text, Ignores Case"
this.AllowPlayer = function(player)
-- this should be edited for your maps need.
-- used by ForcePickNow & to consider if this player is added to the other players view
-- return false to reject a player
if GetPlayerSlotState(player) ~= PLAYER_SLOT_STATE_PLAYING then return false end
return true
end
this.DoLocalize = function(text) if this.Localize then return GetLocalizedString(text) else return text end end
this.PlayerDone = function(player, spellArray)
-- this function happens when a player finished the picking
this.PlayerHasDone[player] = true -- remember this player finished
this.EnableControl(player, false)
-- what to do with the choice
TasHeroLearnEx.HeroData[player] = spellArray
end
function this.ActionButtonFree(frame, player)
-- What happens when the Free button is pressed
print("Free Button")
end
-- how to display a choice in the list and its tooltip?
function this.ActionSpellListDraw(frameObject, data)
if not data then data = 0 end
if type(data) == "number" then
if data == 0 then
BlzFrameSetTexture(frameObject.Icon, this.NoSkillIcon, 0, false)
BlzFrameSetTexture(frameObject.IconPush, this.NoSkillIcon, 0, false)
BlzFrameSetTexture(frameObject.IconOff, this.NoSkillIcon, 0, false)
BlzFrameSetText(frameObject.Text, this.NoSkillTooltip)
BlzFrameSetTexture(frameObject.ToolTipFrameIcon, this.NoSkillIcon, 0, false)
BlzFrameSetText(frameObject.ToolTipFrameName, this.NoSkillTooltip)
BlzFrameSetText(frameObject.ToolTipFrameText, "")
else
BlzFrameSetTexture(frameObject.Icon, BlzGetAbilityIcon(data), 0, false)
BlzFrameSetTexture(frameObject.IconPush, BlzGetAbilityIcon(data), 0, false)
BlzFrameSetTexture(frameObject.IconOff, BlzGetAbilityIcon(data), 0, false)
BlzFrameSetText(frameObject.Text, GetObjectName(data))
BlzFrameSetTexture(frameObject.ToolTipFrameIcon, BlzGetAbilityIcon(data), 0, false)
BlzFrameSetText(frameObject.ToolTipFrameName, GetObjectName(data))
--BlzFrameSetText(frameObject.ToolTipFrameText, BlzGetAbilityResearchExtendedTooltip(data, 0))
if this.ToolTipGenInfo and data > 0 then
BlzFrameSetText(frameObject.ToolTipFrameText, BlzGetAbilityResearchExtendedTooltip(data, 0).. TasAbilityData.GetGenericFields(data))
else
BlzFrameSetText(frameObject.ToolTipFrameText, BlzGetAbilityResearchExtendedTooltip(data, 0))
end
end
elseif type(data) == "table" then
BlzFrameSetTexture(frameObject.Icon, data.Icon, 0, false)
BlzFrameSetTexture(frameObject.IconPush, data.Icon, 0, false)
BlzFrameSetTexture(frameObject.IconOff, data.Icon, 0, false)
BlzFrameSetText(frameObject.Text, data.Text)
BlzFrameSetTexture(frameObject.ToolTipFrameIcon, data.Icon, 0, false)
BlzFrameSetText(frameObject.ToolTipFrameName, data.Name)
BlzFrameSetText(frameObject.ToolTipFrameText, data.Text)
end
end
-- how to search
function this.ActionSpellListSearch(data, text, buttonListObject)
if not text or text == "" then return true end
text = string.lower(text)
if type(data) == "number" then
if string.find(string.lower(GetObjectName(data)), text, 1, true) then return true end
if string.find(string.lower(BlzGetAbilityTooltip(data, 0)), text, 1, true) then return true end
if string.find(string.lower(BlzGetAbilityResearchTooltip(data, 0)), text, 1, true) then return true end
if string.find(string.lower(BlzGetAbilityExtendedTooltip(data, 0)), text, 1, true) then return true end
if string.find(string.lower(BlzGetAbilityResearchExtendedTooltip(data, 0)), text, 1, true) then return true end
elseif type(data) == "table" then
if string.find(string.lower(data.Name), text, 1, true) then return true end
if string.find(string.lower(data.Text), text, 1, true) then return true end
end
return false
end
-- system stuff
this.PlayerHasDone = {} -- remembers player pressing okay
this.Bars = {}
this.Spells = {} -- array contains Abilities to learn, & [player] current selection
this.Category = {} -- 0 to 31 = {value, icon, text} , at ['AHbz'] = Category, [Player] = currentFilter
this.Category.Frames = {}
this.CurrentTargetIndex = {} --[player] what spot to modifiy
this.EnforcedFilter = {} -- [1] to [x] = categoryNeeded or [player] = current Enforce
this.NotAllowed = {} -- [1] to [x] = categoryNotAllowed or [player] = current NotAllowed
local categoryButtonSize = 0.021
local categoryButtonRowCount = 3
TasSkillSetPicker = this
this.ForcePickNow = function()
local player
for i = 0, bj_MAX_PLAYERS - 1 do
player = Player(i)
if this.AllowPlayer(player) and not this.PlayerHasDone[player] then
this.PlayerAccept(player)
end
end
end
this.LockCategory = function(index, category)
this.EnforcedFilter[index] = category
end
this.BanCategory = function(index, category)
this.NotAllowed[index] = category
end
this.ShowOtherPlayerBars = function(show, player)
if player and GetLocalPlayer() ~= player then return end
if show ~= nil then this.ShowBars = show end
local newSize = this.SizeX
if not this.ShowBars then
newSize = newSize - BlzFrameGetWidth(this.FrameList.Frame)
end
BlzFrameSetVisible(this.FrameList.Frame, this.ShowBars)
TasWindow.setSize(this.Window, newSize, this.SizeY)
end
this.DefineCategory = function(icon, text)
local newValue = 1
if #this.Category > 31 then print("TasSkillSetPicker - to many categories", text) end
if #this.Category > 0 then
newValue = this.Category[#this.Category][1]
newValue = newValue + newValue
end
local object = {newValue, icon, text}
table.insert(this.Category, object)
return newValue
end
this.Add = function(spellCode, category)
if type(spellCode) == "string" then spellCode = FourCC(spellCode) end
this.Category[spellCode] = category
if not this.Spells[spellCode] then
table.insert(this.Spells, spellCode)
this.Spells[spellCode] = true
if this.ToolTipGenInfo and type(spellCode) == "number" then
TasAbilityData.GetGenericFields(spellCode) -- preload tooltip
end
if this.ButtonList then TasButtonListAddData(this.ButtonList, spellCode) end
end
end
this.ActionButtonAccept = function(frame, player)
this.PlayerAccept(player)
end
this.ResetPlayer = function(player)
if player then
for i = 1, this.BarSlotCount do
this.Spells[player][i] = nil
end
this.SkillBarApplyArray(this.Bars.Master, this.Spells[GetLocalPlayer()])
if this.Bars[player] then this.SkillBarApplyArray(this.Bars[player], this.Spells[player]) end
this.EnableControl(player, true)
this.PlayerHasDone[player] = false
else
for i = 0, bj_MAX_PLAYERS - 1 do
player = Player(i)
this.ResetPlayer(Player(i))
end
end
end
this.ClearData = function()
TasButtonListClearData(this.ButtonList)
for key, spellCode in ipairs(this.Spells) do this.Spells[spellCode] = false end
end
this.ListPlayerCategory = function(player)
local catValue, spellCode, count
local count = 0
local result = ""
local first = true
for i = 1, #this.Category do
count = 0
catValue = this.Category[i][1]
for x = 1, this.BarSlotCount do
spellCode = this.Spells[player][x]
if spellCode and BlzBitAnd(this.Category[spellCode], catValue) > 0 then
count = count + 1
end
end
if count > 0 then
if not first then
result = result .."\n"
else first = false
end
result = result .. this.DoLocalize(this.Category[i][3]) .." "..count
end
end
return result
end
this.CreateCatButton = function(category)
local value, icon, text = category[1],category[2],category[3]
local frame = BlzCreateFrame("TasSkillSetPickerButton", this.Category.Frames.Parent, 0, 0)
local object = {}
local index = #this.Category.Frames +1
this.Category.Frames[index] = object
this.Category.Frames[frame] = object
object.Category = category
object.Button = frame
object.Icon = BlzGetFrameByName("TasSkillSetPickerButtonBackdrop", 0)
object.IconOff = BlzGetFrameByName("TasSkillSetPickerButtonBackdropDisabled", 0)
object.IconPush = BlzGetFrameByName("TasSkillSetPickerButtonBackdropPushed", 0)
object.Filter = BlzGetFrameByName("TasSkillSetPickerButtonFilter", 0)
BlzFrameSetSize(object.Button, categoryButtonSize, categoryButtonSize)
BlzFrameSetTexture(object.Icon, icon, 0, true)
BlzFrameSetTexture(object.IconOff, icon, 0, true)
BlzFrameSetTexture(object.IconPush, icon, 0, true)
if index == 1 then
BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, this.Category.Frames.Parent, FRAMEPOINT_TOPLEFT, 0.005, -0.005)
else
BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, this.Category.Frames[index - 1].Button, FRAMEPOINT_TOPRIGHT, 0.003, 0)
end
this.CreateTextTooltip(frame, this.DoLocalize(text))
TasButtonAction(frame, this.ActionCatButton)
--BlzFrameSetVisible(object.Filter, false)
return object
end
function this.UpdateSkillBar(bar)
if not bar.Player or this.ShowEnemy or IsPlayerAlly(bar.Player, GetLocalPlayer()) then
for i, frameObject in ipairs(bar) do this.ActionSpellListDraw(frameObject, frameObject.Spell) end
end
end
function this.SkillBarApplyArray(bar, spells)
for i, frameObject in ipairs(bar) do frameObject.Spell = spells[i] end
this.UpdateSkillBar(bar)
end
function this.EnableControl(player, enable)
if GetLocalPlayer() ~= player then return end
for i, frameObject in ipairs(this.Bars.Master) do
BlzFrameSetEnable(frameObject.Button, enable)
BlzFrameSetVisible(frameObject.Filter, not enable)
end
BlzFrameSetEnable(this.ButtonAccept, enable)
BlzFrameSetEnable(this.ButtonRandom, enable)
BlzFrameSetEnable(this.ButtonFree, enable)
end
function this.SkillBarActivadeSlot(player, index)
this.UpdateSkillBar(bar)
end
local function CreateSkillBar(parent, createContext)
local bar = {}
bar.Frame = BlzCreateFrame("TasSkillSetPicker", parent, 0, createContext)
bar.Button = bar.Frame
CreateTasButtonTooltip(bar, bar.Frame)
BlzFrameClearAllPoints(bar.ToolTipFrameText)
BlzFrameSetPoint(bar.ToolTipFrameText, FRAMEPOINT_TOPRIGHT, this.Parent, FRAMEPOINT_TOPLEFT, -0.006, -0.052)
TasSliderAction(bar.Frame, nil, 3, this.FrameList.Slider)
local prev
local context = createContext*this.BarSlotCount - 1
for i = 1, this.BarSlotCount do
context = context + 1
bar[i] = {}
bar[i].Index = i
this.Bars[bar[i]] = bar
bar[i].Slot = BlzCreateFrame("TasSkillSetPickerSlot", bar.Frame, 0, context)
bar[i].Button = BlzGetFrameByName("TasSkillSetPickerSlotButton", context)
TasSliderAction(bar[i].Button, nil, 3, this.FrameList.Slider)
this.Bars[bar[i].Button] = bar[i]
bar[i].Icon = BlzGetFrameByName("TasSkillSetPickerSlotButtonBackdrop", context)
bar[i].IconOff = BlzGetFrameByName("TasSkillSetPickerSlotButtonBackdropDisabled", context)
bar[i].IconPush = BlzGetFrameByName("TasSkillSetPickerSlotButtonBackdropPushed", context)
bar[i].Sprite = BlzGetFrameByName("TasSkillSetPickerSlotSprite", context)
bar[i].Filter = BlzGetFrameByName("TasSkillSetPickerSlotFilter", context)
BlzFrameSetVisible(bar[i].Filter, false)
CreateTasButtonTooltip(bar[i], bar.Frame)
TasButtonAction(bar[i].Button, this.ActionBarButton)
BlzFrameClearAllPoints(bar[i].ToolTipFrameText)
BlzFrameSetPoint(bar[i].ToolTipFrameText, FRAMEPOINT_TOPRIGHT, this.Parent, FRAMEPOINT_TOPLEFT, -0.006, -0.052)
BlzFrameSetVisible(bar[i].Sprite, false)
--BlzFrameSetVisible(bar[i].Sprite, false)
if prev then
BlzFrameSetPoint(bar[i].Slot, FRAMEPOINT_LEFT, prev, FRAMEPOINT_RIGHT, 0, 0)
end
prev = bar[i].Slot
end
BlzFrameSetPoint(bar[1].Slot, FRAMEPOINT_TOPLEFT, bar.Frame, FRAMEPOINT_TOPLEFT, 0.01, -0.01)
if this.BarSlotCount > 6 then
BlzFrameClearAllPoints(bar[7].Slot)
BlzFrameSetPoint(bar[7].Slot, FRAMEPOINT_TOPLEFT, bar[1].Slot, FRAMEPOINT_BOTTOMLEFT, 0, 0)
BlzFrameSetSize(bar.Frame, BlzFrameGetWidth(bar.Frame), BlzFrameGetHeight(bar.Frame) + BlzFrameGetHeight(bar[1].Slot)+0.005)
end
this.UpdateSkillBar(bar)
return bar
end
function this.UpdateCatButtons(player)
if GetLocalPlayer() ~= player then return end
local catPlayer = this.Category[player] or 0
local catEnforced = this.EnforcedFilter[player] or 0
local catDisabled = this.NotAllowed[player] or 0
local cat
for i, object in ipairs(this.Category.Frames) do
cat = object.Category[1]
-- not allowed?
if catDisabled > 0 and BlzBitAnd(cat, catDisabled) > 0 then
BlzFrameSetTexture(object.Filter, this.FilterNotAllowed, 0, true)
BlzFrameSetVisible(object.Filter, true)
-- need to have?
elseif catEnforced > 0 and BlzBitAnd(cat, catEnforced) > 0 then
BlzFrameSetTexture(object.Filter, this.FilterEnforced, 0, true)
BlzFrameSetVisible(object.Filter, true)
-- not used
elseif BlzBitAnd(catPlayer, cat) <= 0 then
BlzFrameSetTexture(object.Filter, this.FilterNotUsed, 0, true)
BlzFrameSetVisible(object.Filter, true)
else
BlzFrameSetVisible(object.Filter, false)
end
end
end
function this.ActionCatButton(frame, player)
local object = this.Category.Frames[frame]
local buttonValue = object.Category[1]
local playerValue = this.Category[player]
if this.NotAllowed[player] > 0 and BlzBitAnd(this.NotAllowed[player], buttonValue) > 0 then return end
if this.EnforcedFilter[player] > 0 and BlzBitAnd(this.EnforcedFilter[player], buttonValue) > 0 then return end
this.Category[player] = BlzBitXor(this.Category[player], buttonValue)
this.UpdateCatButtons(player)
TasButtonListSearch(this.ButtonList)
end
function this.ActionButtonRandom(frame, player)
for i = 1,9 do if this.SetPlayerSpell(player) then break end end
if this.CurrentTargetIndex[player] < this.BarSlotCount then
this.ActionBarButtonDoIt(this.CurrentTargetIndex[player] + 1, player)
end
end
function this.PlayerAccept(player)
for i = 1, this.BarSlotCount do
if not this.Spells[player][i] then
for x = 1,9 do if this.SetPlayerSpell(player, nil, i) then break end end
end
end
local text = this.ListPlayerCategory(player)
if GetLocalPlayer() == player then BlzFrameSetText(this.Bars.Master.ToolTipFrameText, text) end
if this.ShowEnemy or IsPlayerAlly(player, GetLocalPlayer()) then BlzFrameSetText(this.Bars[player].ToolTipFrameText, text) end
this.PlayerDone(player, this.Spells[player])
end
function this.ActionBarButtonDoIt(index, player)
local currentData = this.Spells[player][index]
local oldTargetIndex = this.CurrentTargetIndex[player]
this.CurrentTargetIndex[player] = index
if this.EnforcedFilter[index] then
this.EnforcedFilter[player] = this.EnforcedFilter[index]
this.Category[player] = this.EnforcedFilter[index]
else
this.EnforcedFilter[player] = 0
end
if this.NotAllowed[index] then
this.NotAllowed[player] = this.NotAllowed[index]
this.Category[player] = BlzBitAnd(this.Category[player], BlzBitXor(this.NotAllowed[index], math.maxinteger))
else
this.NotAllowed[player] = 0
end
TasButtonListSearch(this.ButtonList)
this.UpdateCatButtons(player)
if GetLocalPlayer() == player then
BlzFrameSetVisible(this.Bars.Master[oldTargetIndex].Sprite, false)
BlzFrameSetVisible(this.Bars.Master[index].Sprite, true)
end
this.SkillBarApplyArray(this.Bars.Master, this.Spells[GetLocalPlayer()])
this.SkillBarApplyArray(this.Bars[player], this.Spells[player])
end
function this.ActionBarButton(frame, player)
local frameObject = this.Bars[frame]
local bar = this.Bars[frameObject]
local index = frameObject.Index
if bar ~= this.Bars.Master then
return
end
this.ActionBarButtonDoIt(index, player)
end
function this.SpellCodeAllowed(player, index, spellCode)
local catEnforced, catDisabled, cat
if index then
catEnforced = this.EnforcedFilter[index] or 0
catDisabled = this.NotAllowed[index] or 0
else
catEnforced = this.EnforcedFilter[player] or 0
catDisabled = this.NotAllowed[player] or 0
end
local catPlayer = this.Category[player] or 0
cat = this.Category[spellCode] or 0
if catDisabled > 0 and BlzBitAnd(cat, catDisabled) > 0 then return false end -- not allowed
if catEnforced > 0 and BlzBitAnd(cat, catEnforced) <= 0 then return false end -- not wanted
for i = 1, this.BarSlotCount do
if this.Spells[player][i] and (spellCode == this.Spells[player][i]) then return false end
end
return true
end
local tempRandom = {Count = 0}
function this.GetRandomSpell(player, index)
tempRandom.Count = 0
for i, spellCode in ipairs(this.Spells) do
if this.SpellCodeAllowed(player, index, spellCode) then
tempRandom.Count = tempRandom.Count + 1
tempRandom[tempRandom.Count] = spellCode
end
end
if tempRandom.Count > 0 then
return tempRandom[GetRandomInt(1, tempRandom.Count)]
else
return nil
end
end
function this.SetPlayerSpell(player, data, index)
if not index then index = this.CurrentTargetIndex[player] end
if not data then data = this.GetRandomSpell(player, index) if not data then return false end end
for i = 1, this.BarSlotCount do
if this.Spells[player][i] and (data == this.Spells[player][i]) then return false end
end
this.Spells[player][index] = data
this.SkillBarApplyArray(this.Bars.Master, this.Spells[GetLocalPlayer()])
this.SkillBarApplyArray(this.Bars[player], this.Spells[player])
return true
end
local function ActionSpellListPress(data, buttonListObject, dataIndex, player)
if this.PlayerHasDone[player] then return end
this.SetPlayerSpell(player, data)
if this.CurrentTargetIndex[player] < this.BarSlotCount then
this.ActionBarButtonDoIt(this.CurrentTargetIndex[player] + 1, player)
end
local text = this.ListPlayerCategory(player)
if GetLocalPlayer() == player then BlzFrameSetText(this.Bars.Master.ToolTipFrameText, text) end
if this.ShowEnemy or IsPlayerAlly(player, GetLocalPlayer()) then BlzFrameSetText(this.Bars[player].ToolTipFrameText, text) end
end
local function ActionSpellListFilter(data, buttonListObject, isTextSearching)
local catPlayer = this.Category[GetLocalPlayer()] or 0
if catPlayer > 0 and BlzBitAnd(this.Category[data], catPlayer) ~= catPlayer then return false end
return this.SpellCodeAllowed(GetLocalPlayer(), nil, data)
end
local function ActionSpellListCreate(frameObject, int, buttonCreated)
frameObject.Icon = BlzGetFrameByName("TasSkillSetPickerButtonBackdrop", 0)
frameObject.IconOff = BlzGetFrameByName("TasSkillSetPickerButtonBackdropDisabled", 0)
frameObject.IconPush = BlzGetFrameByName("TasSkillSetPickerButtonBackdropPushed", 0)
frameObject.Filter = BlzGetFrameByName("TasSkillSetPickerButtonFilter", 0)
BlzFrameSetVisible(frameObject.Filter, false)
end
local InitFrames = function()
if not BlzLoadTOCFile(this.TocPath) then
print("|cffff0000TasSpellView - Error Reading Toc File at", this.TocPath)
end
this.Window = TasWindow.create("title", false, 0, this.ParentFunc())
TasWindow.setSize(this.Window, this.SizeX, this.SizeY)
TasWindow.setAbsPoint(this.Window, this.Pos, this.PosX, this.PosY)
this.Parent = this.Window.WindowPane
this.Box = BlzCreateFrame("TasSkillSetPickerBox", this.Parent, 0, 0)
BlzFrameSetAllPoints(this.Box, this.Parent)
this.FrameList = FrameList.create(0, this.Parent)
TasFrameList.setSize(this.FrameList, 0.24, 0.35)
BlzFrameSetPoint(this.FrameList.Frame, FRAMEPOINT_TOPLEFT, this.Parent, FRAMEPOINT_TOPLEFT, 0.01, -0.01)
this.ButtonAccept = BlzCreateFrame("TasSkillSetPickerTextButton", this.Parent, 0, 0)
this.ButtonRandom = BlzCreateFrame("TasSkillSetPickerTextButton", this.Parent, 0, 1)
this.ButtonFree = BlzCreateFrame("TasSkillSetPickerTextButton", this.Parent, 0, 2)
TasButtonAction.Set(this.ButtonAccept, this.ActionButtonAccept)
TasButtonAction.Set(this.ButtonRandom, this.ActionButtonRandom)
TasButtonAction.Set(this.ButtonFree, this.ActionButtonFree)
BlzFrameSetSize(this.ButtonAccept, this.ControlButtonSizeX, this.ControlButtonSizeY)
BlzFrameSetSize(this.ButtonRandom, this.ControlButtonSizeX, this.ControlButtonSizeY)
BlzFrameSetSize(this.ButtonFree, this.ControlButtonSizeX, this.ControlButtonSizeY)
BlzFrameSetText(this.ButtonAccept, this.DoLocalize(this.AcceptButtonText))
BlzFrameSetText(this.ButtonRandom, this.DoLocalize(this.RandomButtonText))
BlzFrameSetText(this.ButtonFree, this.DoLocalize(this.FreeButtonText))
BlzFrameSetPoint(this.ButtonAccept, FRAMEPOINT_BOTTOMRIGHT, this.Parent, FRAMEPOINT_BOTTOMRIGHT, 0, 0)
BlzFrameSetPoint(this.ButtonRandom, FRAMEPOINT_RIGHT, this.ButtonAccept, FRAMEPOINT_LEFT, 0, 0)
BlzFrameSetPoint(this.ButtonFree, FRAMEPOINT_RIGHT, this.ButtonRandom, FRAMEPOINT_LEFT, 0, 0)
local textFrame = this.CreateTextTooltip(this.ButtonAccept, this.DoLocalize(this.AcceptButtonTooltip))
BlzFrameClearAllPoints(textFrame)
BlzFrameSetPoint(textFrame, FRAMEPOINT_BOTTOMRIGHT, this.ButtonAccept, FRAMEPOINT_TOPRIGHT, 0, 0.008)
this.CreateTextTooltip(this.ButtonRandom, this.DoLocalize(this.RandomButtonTooltip))
this.CreateTextTooltip(this.ButtonFree, this.DoLocalize(this.FreeButtonTooltip))
BlzFrameSetVisible(this.ButtonFree, this.FreeButtonShow)
this.ButtonShow = BlzCreateFrame("TasSkillSetPickerTextButton", this.ShowButtonParentFunc(), 0, 3)
BlzFrameSetSize(this.ButtonShow, this.ControlButtonSizeX, this.ControlButtonSizeY)
BlzFrameSetAbsPoint(this.ButtonShow, FRAMEPOINT_TOPLEFT, this.ShowButtonPosX, this.ShowButtonPosY)
BlzFrameSetText(this.ButtonShow, this.DoLocalize(this.ShowButtonText))
BlzFrameSetVisible(this.ButtonShow, this.ShowButtonShow)
TasButtonAction.Set(this.ButtonShow, function(frame, player) if GetLocalPlayer() == player then BlzFrameSetVisible(this.Window.WindowHead, not BlzFrameIsVisible(this.Window.WindowHead)) end end)
for i = 0, bj_MAX_PLAYERS - 1 do
if this.AllowPlayer(Player(i)) then
this.Bars[i] = CreateSkillBar(this.FrameList.Frame, i)
BlzFrameSetTexture(BlzGetFrameByName("TasSkillSetPickerColor1", i), GetPlayerColorTexture(Player(i), true), 0, true)
BlzFrameSetTexture(BlzGetFrameByName("TasSkillSetPickerColor2", i), GetPlayerColorTexture(Player(i), true), 0, true)
BlzFrameSetText(this.Bars[i].ToolTipFrameName, GetPlayerName(Player(i)))
BlzFrameSetTexture(this.Bars[i].ToolTipFrameIcon, GetPlayerColorTexture(Player(i), true), 0, true)
FrameList.add(this.FrameList, this.Bars[i].Frame)
this.Bars[Player(i)] = this.Bars[i]
this.Bars[i].Player = Player(i)
--BlzFrameSetVisible(tooltipFrame, false)
end
end
this.Bars.Master = CreateSkillBar(this.Parent, 1)
BlzFrameSetVisible(BlzGetFrameByName("TasSkillSetPickerColor1", 1), false)
BlzFrameSetVisible(BlzGetFrameByName("TasSkillSetPickerColor2", 1), false)
BlzFrameSetText(this.Bars.Master.ToolTipFrameName, this.DoLocalize(this.EditorBarTitle) )
BlzFrameSetTexture(this.Bars.Master.ToolTipFrameIcon, this.DoLocalize(this.EditorBarIcon), 0, true)
this.Bars.Master.Player = GetLocalPlayer()
BlzFrameSetPoint(this.Bars.Master.Frame, FRAMEPOINT_TOPRIGHT, this.Parent, FRAMEPOINT_TOPRIGHT, -0.01, -0.01)
BlzFrameSetVisible(this.Bars.Master[this.CurrentTargetIndex[GetLocalPlayer()]].Sprite, true)
if GetHandleId(BlzGetFrameByName("TasSkillSetPicker", 1)) == 0 then
print("|cffff0000TasSkillSetPicker - Error Create TasSkillSetPicker|r")
print(" Check Imported toc & fdf & TocPath in Map script")
print(" Imported toc needs to have empty ending line")
print(" fdf path in toc needs to match map imported path")
print(" TocPath in Map script needs to match map imported path")
end
local frame = BlzCreateFrameByType("FRAME", "", this.Parent, "",0)
BlzFrameSetSize(frame, 0.25, 0.001)
this.ButtonList = CreateTasButtonListEx2("TasSkillSetPickerButton", 7, 5, 0.003, 0.003, frame, ActionSpellListCreate)
for i = 1, this.ButtonList.Frames.Count do
BlzFrameClearAllPoints(this.ButtonList.Frames[i].ToolTipFrameText)
--BlzFrameSetPoint(this.ButtonList.Frames[i].ToolTipFrameText, FRAMEPOINT_TOPLEFT, this.Bars[1].Frame, FRAMEPOINT_TOPRIGHT, 0.006, -0.052)
BlzFrameSetPoint(this.ButtonList.Frames[i].ToolTipFrameText, FRAMEPOINT_TOPRIGHT, this.Parent, FRAMEPOINT_TOPLEFT, -0.006, -0.052)
end
this.ButtonList.UpdateAction = this.ActionSpellListDraw
this.ButtonList.ButtonAction = ActionSpellListPress
this.ButtonList.SearchAction = this.ActionSpellListSearch
this.ButtonList.FilterAction = ActionSpellListFilter
BlzFrameSetPoint(frame, FRAMEPOINT_TOPRIGHT, this.Bars.Master.Frame, FRAMEPOINT_BOTTOMRIGHT, 0, 0)
BlzFrameSetSize(this.ButtonList.Head, BlzFrameGetWidth(this.ButtonList.Head), BlzFrameGetHeight(this.ButtonList.Head) + 0.0135 + categoryButtonRowCount*categoryButtonSize)
for key, spellCode in ipairs(this.Spells) do TasButtonListAddData(this.ButtonList, spellCode) end
UpdateTasButtonList(this.ButtonList)
this.CreateTextTooltip(this.ButtonList.InputFrame, this.DoLocalize(this.SearchBarTooltip))
this.Category.Frames.Parent = BlzCreateFrame("TasSkillSetPickerBox", this.ButtonList.Parent, 0, 0)
BlzFrameSetPoint(this.Category.Frames.Parent, FRAMEPOINT_TOPRIGHT, this.ButtonList.InputFrame, FRAMEPOINT_BOTTOMRIGHT, 0, 0)
BlzFrameSetSize(this.Category.Frames.Parent, BlzFrameGetWidth(frame), 0.0135 + categoryButtonRowCount*categoryButtonSize)
for i, cat in ipairs(this.Category) do this.CreateCatButton(cat) end
if #this.Category > 10 then BlzFrameSetPoint(this.Category.Frames[11].Button, FRAMEPOINT_TOPLEFT, this.Category.Frames[1].Button, FRAMEPOINT_BOTTOMLEFT, 0, -0.001)end
if #this.Category > 20 then BlzFrameSetPoint(this.Category.Frames[21].Button, FRAMEPOINT_TOPLEFT, this.Category.Frames[11].Button, FRAMEPOINT_BOTTOMLEFT, 0, -0.001)end
BlzFrameClick(this.Bars.Master[this.CurrentTargetIndex[GetLocalPlayer()]].Button)
--this.UpdateCatButtons(GetLocalPlayer())
--TasButtonListSearch(this.ButtonList)
this.ShowOtherPlayerBars()
BlzFrameSetVisible(this.Window.WindowHead, this.Show)
end
function this.CreateTextTooltip(frame, text)
-- this FRAME is important when the Box is outside of 4:3 it can be limited to 4:3.
local toolTipParent = BlzCreateFrameByType("FRAME", "", frame, "", 0)
local toolTipBox = BlzCreateFrame("TasSkillSetPickerBox", toolTipParent, 0, 0)
local toolTip = BlzCreateFrame("TasSkillSetPickerText", toolTipBox, 0, 0)
BlzFrameSetPoint(toolTip, FRAMEPOINT_BOTTOM, frame, FRAMEPOINT_TOP, 0, 0.008)
BlzFrameSetPoint(toolTipBox, FRAMEPOINT_TOPLEFT, toolTip, FRAMEPOINT_TOPLEFT, -0.008, 0.008)
BlzFrameSetPoint(toolTipBox, FRAMEPOINT_BOTTOMRIGHT, toolTip, FRAMEPOINT_BOTTOMRIGHT, 0.008, -0.008)
BlzFrameSetText(toolTip, text)
BlzFrameSetTooltip(frame, toolTipParent)
return toolTip
end
function this.Init()
--this.Group = CreateGroup()
--this.Timer = CreateTimer()
--TimerStart(this.Timer, this.UpdateTime, true, this.Update)
for i =0, bj_MAX_PLAYERS -1 do
this.Category[Player(i)] = 0
this.Spells[Player(i)] = {}
this.CurrentTargetIndex[Player(i)] = 1
this.EnforcedFilter[Player(i)] = 0
this.NotAllowed[Player(i)] = 0
end
if TasButtonList.FirstInit then TasButtonList.FirstInit() end
InitFrames()
if FrameLoaderAdd then FrameLoaderAdd(InitFrames) end
end
end
do
local AutoRun = true--(true) will create Itself at 0s, (false) you need to TasSkillSetPickerConfig
local catUlti
local function AddChoice(spellCode, wantedCat)
if type(spellCode) == "string" then spellCode = FourCC(spellCode) end
if type(spellCode) == "number" then
if TasAbilityData.GetField(spellCode, "reqLevel", S2I) > 1 then
TasSkillSetPicker.Add(spellCode, wantedCat + catUlti)
else
TasSkillSetPicker.Add(spellCode, wantedCat)
end
else
TasSkillSetPicker.Add(spellCode, wantedCat)
end
end
function TasSkillSetPickerConfig()
xpcall(function()
ClearSelection() -- In V1.31.1 this performs bad when an unit is selected
--BlzHideOriginFrames(true)
local catPassive = TasSkillSetPicker.DefineCategory("ReplaceableTextures/PassiveButtons/PASBTNStatUp.tga", "Passive")
local catNoTarget = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNPatrol", "Cast: No Target")
local catSingleTarget = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/btnloadpeon", "Cast: Target")
local catPointTarget = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/btnload", "Cast: Point")
local catChannel = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNBlizzard", "Cast: Channel")
catUlti = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNAvatar", "Ultimate")
local catWeaken = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNCripple", "Weaken")
local catEmpower = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNInnerFire", "Empower")
local catDisable = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNStun", "Disable")
local catSpeed = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNBootsOfSpeed", "Speed")
local catMorph = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNMetamorphosis", "Morph")
local catSummon = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNSummonWaterElemental", "Summon")
local catHeal = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNHeal", "Heal")
local catDamage = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNWallOfFire", "Damage")
local catMana = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNBrilliance", "Mana")
local catAura = catPassive + catEmpower -- no real cate but shortens
oldTime = os.clock()
TasSkillSetPicker.BanCategory(1, catUlti) -- ultimateSkill not allowed here
TasSkillSetPicker.BanCategory(2, catUlti)
TasSkillSetPicker.BanCategory(3, catUlti)
TasSkillSetPicker.BanCategory(4, catUlti)
TasSkillSetPicker.LockCategory(5, catUlti) -- only ultimateSkill allowed here
TasSkillSetPicker.LockCategory(6, catUlti)
AddChoice('AHhb', catHeal + catDamage)
AddChoice('AHab', catAura + catMana)
AddChoice('AHmt', catChannel + catPointTarget + catSingleTarget + catSpeed )
AddChoice('AHwe', catSummon + catNoTarget)
AddChoice('AHbz', catChannel + catPointTarget + catDamage)
AddChoice('ANst', catPointTarget + catChannel + catDamage )
AddChoice('ANsg', catSummon + catNoTarget)
AddChoice('ANsq', catSummon + catNoTarget)
AddChoice('ANsw', catSummon + catNoTarget)
AddChoice('AOww', catNoTarget + catDamage )
AddChoice('AOcr', catPassive + catDamage)
AddChoice('AOmi', catNoTarget)
AddChoice('AOwk', catNoTarget + catDamage)
AddChoice('AHbn', catSingleTarget + catDisable + catWeaken)
AddChoice('AHfs', catPointTarget + catDamage)
AddChoice('AHdr', catSingleTarget + catChannel + catMana)
AddChoice('AHpx', catSummon + catNoTarget )
AddChoice('AUcb', catSummon + catNoTarget + catSingleTarget)
AddChoice('AUim', catPointTarget + catDamage + catDisable)
AddChoice('AUls', catNoTarget + catDamage)
AddChoice('AUts', catPassive)
AddChoice('ANba', catSingleTarget + catDamage + catSummon)
AddChoice('ANch', catSingleTarget + catSummon )
AddChoice('ANdr', catSingleTarget + catDamage + catChannel + catHeal)
AddChoice('ANsi', catPointTarget + catDisable)
AddChoice('AUan', catNoTarget + catSummon )
AddChoice('AUdc', catSingleTarget + catDamage + catHeal)
AddChoice('AUdp', catSingleTarget + catHeal)
AddChoice('AUau', catAura + catSpeed)
AddChoice('AEev', catPassive)
AddChoice('AEim', catNoTarget + catDamage)
AddChoice('AEmb', catSingleTarget + catDamage + catMana)
AddChoice('AEme', catNoTarget + catMorph )
AddChoice('AUsl', catSingleTarget + catDisable)
AddChoice('AUav', catAura + catHeal)
AddChoice('AUcs', catPointTarget + catDamage)
AddChoice('AUin', catPointTarget + catDamage + catSummon + catDisable )
AddChoice('AOcl', catDamage + catSingleTarget)
AddChoice('AOeq', catDamage + catWeaken + catChannel +catPointTarget )
AddChoice('AOfs', catPointTarget)
AddChoice('AOsf', catNoTarget + catSummon)
AddChoice('AEer', catSingleTarget + catDamage + catDisable)
AddChoice('AEfn', catSummon, catPointTarget)
AddChoice('AEah', catAura)
AddChoice('AEtq', catHeal + catChannel + catNoTarget)
AddChoice('AUdr', catMana, catSingleTarget)
AddChoice('AUdd', catChannel + catPointTarget + catDamage)
AddChoice('AUfa', catSingleTarget + catEmpower)
AddChoice('AUfu', catSingleTarget + catEmpower)
AddChoice('AUfn', catSingleTarget + catDamage + catWeaken)
AddChoice('AHav', catNoTarget )
AddChoice('AHbh', catPassive + catDamage)
AddChoice('AHtb', catDamage + catSingleTarget + catDisable)
AddChoice('AHtc', catDamage + catNoTarget + catWeaken)
AddChoice('ANfl', catDamage + catSingleTarget)
AddChoice('ANfa', catDamage + catSingleTarget + catWeaken)
AddChoice('ANto', catSummon + catChannel + catPointTarget +catDamage +catDisable)
AddChoice('ANms', catNoTarget + catMana)
AddChoice('AHad', catAura)
AddChoice('AHds', catNoTarget)
AddChoice('AHhb', catDamage +catHeal + catSingleTarget)
AddChoice('AHre', catSummon + catNoTarget )
AddChoice('ANbf', catDamage + catPointTarget)
AddChoice('ANdb', catPassive + catDamage)
AddChoice('ANdh', catWeaken + catSingleTarget)
AddChoice('ANef', catSummon + catNoTarget)
AddChoice('ANdo', catSingleTarget +catSummon +catDamage +catDisable)
AddChoice('ANht', catNoTarget + catWeaken)
AddChoice('ANca', catPassive + catDamage)
AddChoice('ANrf', catDamage + catPointTarget +catChannel)
AddChoice('AHfa', catDamage + catSingleTarget)
AddChoice('AEst', catSummon + catNoTarget)
AddChoice('AEsf', catDamage + catChannel +catNoTarget)
AddChoice('AEar', catAura + catDamage)
AddChoice('AOae', catAura + catSpeed)
AddChoice('AOre', catPassive)
AddChoice('AOsh', catDamage + catPointTarget)
AddChoice('AOws', catNoTarget + catDamage + catDisable)
AddChoice('AOhw', catHeal +catSingleTarget)
AddChoice('AOhx', catSingleTarget + catDisable)
AddChoice('AOsw', catPointTarget + catSummon)
AddChoice('AOvd', catChannel + catNoTarget )
AddChoice('AEbl', catPointTarget + catSpeed)
AddChoice('AEfk', catDamage + catNoTarget)
AddChoice('AEsh', catDamage + catWeaken +catSingleTarget)
AddChoice('AEsv', catNoTarget + catSummon)
AddChoice('ANab', catDamage +catWeaken +catSingleTarget)
AddChoice('ANcr', catMorph )
AddChoice('ANhs', catChannel + catHeal + catPointTarget)
AddChoice('ANtm', catSingleTarget )
AddChoice('ANeg', catPassive)
AddChoice('ANcs', catPointTarget +catDamage + catChannel +catDisable)
AddChoice('ANrg', catMorph )
AddChoice('ANsy', catPointTarget + catSummon)
AddChoice('ANde', catPassive +catDamage)
AddChoice('ANia', catDamage +catPassive)
AddChoice('ANso', catDamage + catWeaken +catDisable +catSingleTarget)
AddChoice('ANlm', catSummon +catNoTarget)
AddChoice('ANvc', catPointTarget +catChannel +catDamage +catDisable)
AddChoice({Icon = "ReplaceableTextures/CommandButtons/BTNClawsOfAttack.tga", Name = "Table1", Text="Table1Text"}, 0)
AddChoice({Icon = "ReplaceableTextures/CommandButtons/BTNHelmOfValor.tga", Name = "Table2", Text="Table2Text"}, 0)
print("AddedItems in",os.clock()-oldTime)
TasSkillSetPicker.Init()
local counter = 120
TimerStart(CreateTimer(), 1, true, function()
counter = counter - 1
BlzFrameSetText(TasSkillSetPicker.Window.WindowHead, "SkillPicker "..counter)
if counter <= 0 then
TasSkillSetPicker.ForcePickNow()
BlzFrameSetVisible(TasSkillSetPicker.Window.WindowHead, false)
PauseTimer(GetExpiredTimer())
DestroyTimer(GetExpiredTimer())
end
end)
end, print)
end
if AutoRun then
if OnInit then -- Total Initialization v5.2.0.1 by Bribe
OnInit.final(TasSkillSetPickerConfig)
else -- without
local real = MarkGameStarted
function MarkGameStarted()
real()
TasSkillSetPickerConfig()
end
end
end
end
do
local AutoRun = false --(true) will create Itself at 0s, (false) you need to TasSkillSetPickerConfig() , be
function TasSkillSetPickerConfig()
xpcall(function()
ClearSelection() -- In V1.31.1 this performs bad when an unit is selected
--BlzHideOriginFrames(true)
local catPassive = TasSkillSetPicker.DefineCategory("ReplaceableTextures/PassiveButtons/PASBTNStatUp.tga", "Passive")
local catNoTarget = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNPatrol", "Cast: No Target")
local catSingleTarget = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/btnloadpeon", "Cast: Target")
local catPointTarget = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/btnload", "Cast: Point")
local catChannel = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNBlizzard", "Cast: Channel")
local catUlti = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNAvatar", "Ultimate")
local catWeaken = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNCripple", "Weaken")
local catEmpower = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNInnerFire", "Empower")
local catDisable = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNStun", "Disable")
local catSpeed = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNBootsOfSpeed", "Speed")
local catMorph = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNMetamorphosis", "Morph")
local catSummon = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNSummonWaterElemental", "Summon")
local catHeal = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNHeal", "Heal")
local catDamage = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNWallOfFire", "Damage")
local catMana = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNBrilliance", "Mana")
local catAura = catPassive + catEmpower -- no real cate but shortens
oldTime = os.clock()
TasSkillSetPicker.BanCategory(1, catUlti) -- ultimateSkill not allowed here
TasSkillSetPicker.BanCategory(2, catUlti)
TasSkillSetPicker.BanCategory(3, catUlti)
TasSkillSetPicker.BanCategory(4, catUlti)
TasSkillSetPicker.LockCategory(5, catUlti) -- only ultimateSkill allowed here
TasSkillSetPicker.LockCategory(6, catUlti)
TasSkillSetPicker.Add('AHhb', catHeal + catDamage)
TasSkillSetPicker.Add('AHab', catAura + catMana)
TasSkillSetPicker.Add('AHmt', catChannel + catPointTarget + catSingleTarget + catSpeed + catUlti)
TasSkillSetPicker.Add('AHwe', catSummon + catNoTarget)
TasSkillSetPicker.Add('ANst', catPointTarget + catChannel + catDamage + catUlti)
TasSkillSetPicker.Add('ANsg', catSummon + catNoTarget)
TasSkillSetPicker.Add('ANsq', catSummon + catNoTarget)
TasSkillSetPicker.Add('ANsw', catSummon + catNoTarget)
TasSkillSetPicker.Add('AOww', catNoTarget + catDamage + catUlti)
TasSkillSetPicker.Add('AOcr', catPassive + catDamage)
TasSkillSetPicker.Add('AOmi', catNoTarget)
TasSkillSetPicker.Add('AOwk', catNoTarget + catDamage)
TasSkillSetPicker.Add('AHbn', catSingleTarget + catDisable + catWeaken)
TasSkillSetPicker.Add('AHfs', catPointTarget + catDamage)
TasSkillSetPicker.Add('AHdr', catSingleTarget + catChannel + catMana)
TasSkillSetPicker.Add('AHpx', catSummon + catNoTarget + catUlti)
TasSkillSetPicker.Add('AUcb', catSummon + catNoTarget + catSingleTarget)
TasSkillSetPicker.Add('AUim', catPointTarget + catDamage + catDisable)
TasSkillSetPicker.Add('AUls', catNoTarget + catUlti + catDamage)
TasSkillSetPicker.Add('AUts', catPassive)
TasSkillSetPicker.Add('ANba', catSingleTarget + catDamage + catSummon)
TasSkillSetPicker.Add('ANch', catSingleTarget + catSummon + catUlti)
TasSkillSetPicker.Add('ANdr', catSingleTarget + catDamage + catChannel + catHeal)
TasSkillSetPicker.Add('ANsi', catPointTarget + catDisable)
TasSkillSetPicker.Add('AUan', catNoTarget + catSummon + catUlti)
TasSkillSetPicker.Add('AUdc', catSingleTarget + catDamage + catHeal)
TasSkillSetPicker.Add('AUdp', catSingleTarget + catHeal)
TasSkillSetPicker.Add('AUau', catAura + catSpeed)
TasSkillSetPicker.Add('AEev', catPassive)
TasSkillSetPicker.Add('AEim', catNoTarget + catDamage)
TasSkillSetPicker.Add('AEmb', catSingleTarget + catDamage + catMana)
TasSkillSetPicker.Add('AEme', catNoTarget + catMorph + catUlti)
TasSkillSetPicker.Add('AUsl', catSingleTarget + catDisable)
TasSkillSetPicker.Add('AUav', catAura + catHeal)
TasSkillSetPicker.Add('AUcs', catPointTarget + catDamage)
TasSkillSetPicker.Add('AUin', catPointTarget + catDamage + catSummon + catDisable + catUlti)
TasSkillSetPicker.Add('AOcl', catDamage + catSingleTarget)
TasSkillSetPicker.Add('AOeq', catDamage + catWeaken + catChannel +catPointTarget + catUlti)
TasSkillSetPicker.Add('AOfs', catPointTarget)
TasSkillSetPicker.Add('AOsf', catNoTarget + catSummon)
TasSkillSetPicker.Add('AEer', catSingleTarget + catDamage + catDisable)
TasSkillSetPicker.Add('AEfn', catSummon, catPointTarget)
TasSkillSetPicker.Add('AEah', catAura)
TasSkillSetPicker.Add('AEtq', catHeal + catChannel + catUlti + catNoTarget)
TasSkillSetPicker.Add('AUdr', catMana, catSingleTarget)
TasSkillSetPicker.Add('AUdd', catUlti + catChannel + catPointTarget + catDamage)
TasSkillSetPicker.Add('AUfa', catSingleTarget + catEmpower)
TasSkillSetPicker.Add('AUfu', catSingleTarget + catEmpower)
TasSkillSetPicker.Add('AUfn', catSingleTarget + catDamage + catWeaken)
TasSkillSetPicker.Add('AHav', catNoTarget + catUlti)
TasSkillSetPicker.Add('AHbh', catPassive + catDamage)
TasSkillSetPicker.Add('AHtb', catDamage + catSingleTarget + catDisable)
TasSkillSetPicker.Add('AHtc', catDamage + catNoTarget + catWeaken)
TasSkillSetPicker.Add('ANfl', catDamage + catSingleTarget)
TasSkillSetPicker.Add('ANfa', catDamage + catSingleTarget + catWeaken)
TasSkillSetPicker.Add('ANto', catSummon + catChannel + catPointTarget + catUlti +catDamage +catDisable)
TasSkillSetPicker.Add('ANms', catNoTarget + catMana)
TasSkillSetPicker.Add('AHad', catAura)
TasSkillSetPicker.Add('AHds', catNoTarget)
TasSkillSetPicker.Add('AHhb', catDamage +catHeal + catSingleTarget)
TasSkillSetPicker.Add('AHre', catSummon + catNoTarget + catUlti)
TasSkillSetPicker.Add('ANbf', catDamage + catPointTarget)
TasSkillSetPicker.Add('ANdb', catPassive + catDamage)
TasSkillSetPicker.Add('ANdh', catWeaken + catSingleTarget)
TasSkillSetPicker.Add('ANef', catSummon + catUlti + catNoTarget)
TasSkillSetPicker.Add('ANdo', catSingleTarget +catUlti +catSummon +catDamage +catDisable)
TasSkillSetPicker.Add('ANht', catNoTarget + catWeaken)
TasSkillSetPicker.Add('ANca', catPassive + catDamage)
TasSkillSetPicker.Add('ANrf', catDamage + catPointTarget +catChannel)
TasSkillSetPicker.Add('AHfa', catDamage + catSingleTarget)
TasSkillSetPicker.Add('AEst', catSummon + catNoTarget)
TasSkillSetPicker.Add('AEsf', catDamage + catChannel + catUlti +catNoTarget)
TasSkillSetPicker.Add('AEar', catAura + catDamage)
TasSkillSetPicker.Add('AOae', catAura + catSpeed)
TasSkillSetPicker.Add('AOre', catUlti + catPassive)
TasSkillSetPicker.Add('AOsh', catDamage + catPointTarget)
TasSkillSetPicker.Add('AOws', catNoTarget + catDamage + catDisable)
TasSkillSetPicker.Add('AOhw', catHeal +catSingleTarget)
TasSkillSetPicker.Add('AOhx', catSingleTarget + catDisable)
TasSkillSetPicker.Add('AOsw', catPointTarget + catSummon)
TasSkillSetPicker.Add('AOvd', catChannel + catNoTarget + catUlti)
TasSkillSetPicker.Add('AEbl', catPointTarget + catSpeed)
TasSkillSetPicker.Add('AEfk', catDamage + catNoTarget)
TasSkillSetPicker.Add('AEsh', catDamage + catWeaken +catSingleTarget)
TasSkillSetPicker.Add('AEsv', catNoTarget +catUlti + catSummon)
TasSkillSetPicker.Add('ANab', catDamage +catWeaken +catSingleTarget)
TasSkillSetPicker.Add('ANcr', catMorph + catUlti)
TasSkillSetPicker.Add('ANhs', catChannel + catHeal + catPointTarget)
TasSkillSetPicker.Add('ANtm', catSingleTarget + catUlti)
TasSkillSetPicker.Add('ANeg', catPassive)
TasSkillSetPicker.Add('ANcs', catPointTarget +catDamage + catChannel +catDisable)
TasSkillSetPicker.Add('ANrg', catMorph +catUlti)
TasSkillSetPicker.Add('ANsy', catPointTarget + catSummon)
TasSkillSetPicker.Add('ANde', catPassive +catDamage)
TasSkillSetPicker.Add('ANia', catDamage +catPassive)
TasSkillSetPicker.Add('ANso', catDamage + catWeaken +catDisable +catSingleTarget)
TasSkillSetPicker.Add('ANlm', catSummon +catNoTarget)
TasSkillSetPicker.Add('ANvc', catPointTarget +catChannel +catUlti +catDamage +catDisable)
TasSkillSetPicker.Add({Icon = "ReplaceableTextures/CommandButtons/BTNClawsOfAttack.tga", Name = "Table1", Text="Table1Text"}, 0)
TasSkillSetPicker.Add({Icon = "ReplaceableTextures/CommandButtons/BTNHelmOfValor.tga", Name = "Table2", Text="Table2Text"}, 0)
print("AddedItems in",os.clock()-oldTime)
TasSkillSetPicker.Init()
local counter = 120
TimerStart(CreateTimer(), 1, true, function()
counter = counter - 1
BlzFrameSetText(TasSkillSetPicker.Window.WindowHead, "SkillPicker "..counter)
if counter <= 0 then
TasSkillSetPicker.ForcePickNow()
BlzFrameSetVisible(TasSkillSetPicker.Window.WindowHead, false)
PauseTimer(GetExpiredTimer())
DestroyTimer(GetExpiredTimer())
end
end)
end, print)
end
if AutoRun then
if OnInit then -- Total Initialization v5.2.0.1 by Bribe
OnInit.final(TasSkillSetPickerConfig)
else -- without
local real = MarkGameStarted
function MarkGameStarted()
real()
TasSkillSetPickerConfig()
end
end
end
end
do
local AutoRun = false --(true) will create Itself at 0s, (false) you need to TasSkillSetPickerConfig
function TasSkillSetPickerConfig()
xpcall(function()
ClearSelection() -- In V1.31.1 this performs bad when an unit is selected
local catPassive = TasSkillSetPicker.DefineCategory("ReplaceableTextures/PassiveButtons/PASBTNStatUp.tga", "Passive")
local catDamage = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNSteelMelee", "Offensive")
local catUlti = TasSkillSetPicker.DefineCategory("ReplaceableTextures/CommandButtons/BTNAvatar", "Ultimate")
TasSkillSetPicker.BanCategory(1, catUlti) -- ultimateSkill not allowed here
TasSkillSetPicker.BanCategory(2, catUlti)
TasSkillSetPicker.BanCategory(3, catUlti)
TasSkillSetPicker.BanCategory(4, catUlti)
TasSkillSetPicker.LockCategory(5, catUlti) -- only ultimateSkill allowed here
TasSkillSetPicker.LockCategory(6, catUlti)
TasSkillSetPicker.Add('AHhb', catHeal + catDamage)
TasSkillSetPicker.Add('AHab', catAura + catMana)
TasSkillSetPicker.Init()
local counter = 120
TimerStart(CreateTimer(), 1, true, function()
counter = counter - 1
BlzFrameSetText(TasSkillSetPicker.Window.WindowHead, "SkillPicker "..counter)
if counter <= 0 then
TasSkillSetPicker.ForcePickNow()
BlzFrameSetVisible(TasSkillSetPicker.Window.WindowHead, false)
PauseTimer(GetExpiredTimer())
DestroyTimer(GetExpiredTimer())
end
end)
end, print)
end
if AutoRun then
if OnInit then -- Total Initialization v5.2.0.1 by Bribe
OnInit.final(TasSkillSetPickerConfig)
else -- without
local real = MarkGameStarted
function MarkGameStarted()
real()
TasSkillSetPickerConfig()
end
end
end
end
function LuaInputAction()
load(BlzFrameGetText(BlzGetFrameByName("EscMenuEditBoxTemplate",0)))()
end
function CreateLuaInput()
BlzLoadTOCFile("war3mapImported\\Templates.toc")
BlzCreateFrame("EscMenuEditBoxTemplate", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0, 0)
BlzFrameSetAbsPoint(BlzGetFrameByName("EscMenuEditBoxTemplate", 0), FRAMEPOINT_TOPLEFT, 0.12, 0.05)
BlzFrameSetSize(BlzGetFrameByName("EscMenuEditBoxTemplate", 0), 0.20, 0.04)
TasEditBoxAction(BlzGetFrameByName("EscMenuEditBoxTemplate", 0), function()
xpcall(LuaInputAction, print)
end)
end