Name | Type | is_array | initial_value |
-- function IsRightClick(player)
-- is that currently a right click. Was created for the useage in Frames MOUSE_UP
-- not mp safe
do
local real = InitBlizzard
local isRightClick = __jarray(false)
function IsRightClick(player)
return isRightClick[player]
end
function InitBlizzard()
real()
local trigger = CreateTrigger()
for i = 0, bj_MAX_PLAYERS - 1 do
local player = Player(i)
TriggerRegisterPlayerEvent(trigger, player, EVENT_PLAYER_MOUSE_UP)
end
TriggerAddAction(trigger, function()
isRightClick[GetTriggerPlayer()] = BlzGetTriggerPlayerMouseButton() == MOUSE_BUTTON_TYPE_RIGHT
end)
end
end
--[[
TasButtonList11 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.
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 = {
-- TasButtonListAddData will FourCC given 4 digit strings?
Interpret4DigitString = true
}
do
local function reload()
BlzLoadTOCFile("war3mapimported\\TasButtonList.toc")
end
local realFunc = InitBlizzard
function InitBlizzard()
realFunc()
reload()
-- 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(reload) end
TasButtonList.SyncTrigger = CreateTrigger()
TasButtonList.SyncTriggerAction = TriggerAddAction(TasButtonList.SyncTrigger, function()
xpcall(function()
local buttonListObject = TasButtonList[BlzGetTriggerFrame()]
local dataIndex = math.tointeger(BlzGetTriggerFrameValue())
if buttonListObject.ButtonAction then
-- call the wanted action, 1 the current Data
buttonListObject.ButtonAction(buttonListObject.Data[GetTriggerPlayer()][dataIndex], buttonListObject, dataIndex)
end
UpdateTasButtonList(buttonListObject)
end,print)
end)
-- do this only if the function IsRightClick exists
if IsRightClick then
TasButtonList.SyncTriggerRightClick = CreateTrigger()
TasButtonList.SyncTriggerRightClickAction = TriggerAddAction(TasButtonList.SyncTriggerRightClick, function()
xpcall(function()
local buttonListObject = TasButtonList[BlzGetTriggerFrame()]
local dataIndex = math.tointeger(BlzGetTriggerFrameValue())
if buttonListObject.RightClickAction then
-- call the wanted action, 1 the current Data
buttonListObject.RightClickAction(buttonListObject.Data[GetTriggerPlayer()][dataIndex], buttonListObject, dataIndex)
end
UpdateTasButtonList(buttonListObject)
end,print)
end)
end
TasButtonList.RightClickSound = CreateSound("Sound\\Interface\\MouseClick1.wav", false, false, false, 10, 10, "")
SetSoundParamsFromLabel(TasButtonList.RightClickSound, "InterfaceClick")
SetSoundDuration(TasButtonList.RightClickSound, 239)
-- handles the clicking
TasButtonList.ButtonTrigger = CreateTrigger()
TasButtonList.ButtonTriggerAction = TriggerAddAction(TasButtonList.ButtonTrigger, function()
local frame = BlzGetTriggerFrame()
local buttonIndex = TasButtonList[frame].Index
local buttonListObject = TasButtonList[TasButtonList[frame]]
local dataIndex = buttonListObject.DataFiltered[buttonListObject.ViewPoint + buttonIndex]
BlzFrameSetEnable(frame, false)
BlzFrameSetEnable(frame, true)
if GetLocalPlayer() == GetTriggerPlayer() then
if buttonListObject.AsyncButtonAction then
buttonListObject.AsyncButtonAction(buttonListObject, buttonListObject.Data[GetLocalPlayer()][R2I(dataIndex)], frame)
end
BlzFrameSetValue(buttonListObject.SyncFrame, dataIndex)
end
end)
-- do this only if the function IsRightClick exists
if IsRightClick then
-- handles the clicking
TasButtonList.ButtonTriggerRightClick = CreateTrigger()
TasButtonList.ButtonTriggerRightClickAction = TriggerAddAction(TasButtonList.ButtonTriggerRightClick, function()
local frame = BlzGetTriggerFrame()
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 IsRightClick(GetTriggerPlayer()) and GetLocalPlayer() == GetTriggerPlayer() then
if buttonListObject.AsyncRightClickAction then
buttonListObject.AsyncRightClickAction(buttonListObject, buttonListObject.Data[GetLocalPlayer()][R2I(dataIndex)], frame)
end
StartSound(TasButtonList.RightClickSound)
BlzFrameSetValue(buttonListObject.SyncFrameRightClick, dataIndex)
end
end)
end
TasButtonList.SearchTrigger = CreateTrigger()
TasButtonList.SearchTriggerAction = TriggerAddAction(TasButtonList.SearchTrigger, function()
TasButtonListSearch(TasButtonList[BlzGetTriggerFrame()], BlzFrameGetText(BlzGetTriggerFrame()))
end)
-- scrolling while pointing on Buttons
TasButtonList.ButtonScrollTrigger = CreateTrigger()
TasButtonList.ButtonScrollTriggerAction = TriggerAddAction(TasButtonList.ButtonScrollTrigger, function()
local buttonListObject = TasButtonList[TasButtonList[BlzGetTriggerFrame()]]
local frame = buttonListObject.Slider
if GetLocalPlayer() == GetTriggerPlayer() then
if BlzGetTriggerFrameValue() > 0 then
BlzFrameSetValue(frame, BlzFrameGetValue(frame) + buttonListObject.SliderStep)
else
BlzFrameSetValue(frame, BlzFrameGetValue(frame) - buttonListObject.SliderStep)
end
end
end)
-- scrolling while pointing on slider aswell as calling
TasButtonList.SliderTrigger = CreateTrigger()
TasButtonList.SliderTriggerAction = TriggerAddAction(TasButtonList.SliderTrigger, function()
local buttonListObject = TasButtonList[BlzGetTriggerFrame()]
local frame = BlzGetTriggerFrame()
if GetLocalPlayer() == GetTriggerPlayer() then
if BlzGetTriggerFrameEvent() == FRAMEEVENT_MOUSE_WHEEL then
if BlzGetTriggerFrameValue() > 0 then
BlzFrameSetValue(frame, BlzFrameGetValue(frame) + buttonListObject.SliderStep)
else
BlzFrameSetValue(frame, BlzFrameGetValue(frame) - buttonListObject.SliderStep)
end
else
-- 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 - math.tointeger(BlzGetTriggerFrameValue())
else
buttonListObject.ViewPoint = 0
end
UpdateTasButtonList(buttonListObject)
end
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)
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)
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.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)
BlzTriggerRegisterFrameEvent(TasButtonList.SyncTrigger, object.SyncFrame, FRAMEEVENT_SLIDER_VALUE_CHANGED)
BlzFrameSetVisible(object.SyncFrame, false)
TasButtonList[object.SyncFrame] = object
-- do this only if the function IsRightClick exists
if IsRightClick then
object.SyncFrameRightClick = BlzCreateFrameByType("SLIDER", "", parent, "", 0)
BlzFrameSetMinMaxValue(object.SyncFrameRightClick, 0, 9999999)
BlzFrameSetStepSize(object.SyncFrameRightClick, 1.0)
BlzTriggerRegisterFrameEvent(TasButtonList.SyncTriggerRightClick, object.SyncFrameRightClick, FRAMEEVENT_SLIDER_VALUE_CHANGED)
BlzFrameSetVisible(object.SyncFrameRightClick, false)
TasButtonList[object.SyncFrameRightClick] = object
end
object.InputFrame = BlzCreateFrame("TasEditBox", parent, 0, 0)
BlzTriggerRegisterFrameEvent(TasButtonList.SearchTrigger, object.InputFrame, FRAMEEVENT_EDITBOX_TEXT_CHANGED)
BlzFrameSetPoint(object.InputFrame, FRAMEPOINT_TOPRIGHT, parent, FRAMEPOINT_TOPRIGHT, 0, 0)
TasButtonList[object.InputFrame] = object
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)
BlzFrameSetSize(object.Slider, 0.012, BlzFrameGetHeight(object.Frames[1].Button) * rowCount + rowGap * (rowCount - 1))
BlzTriggerRegisterFrameEvent(TasButtonList.SliderTrigger, object.Slider , FRAMEEVENT_SLIDER_VALUE_CHANGED)
BlzTriggerRegisterFrameEvent(TasButtonList.SliderTrigger, object.Slider , FRAMEEVENT_MOUSE_WHEEL)
-- 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)
-- 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", frameObject.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(frameObject.Button, frameObject.ToolTipFrameFrame)
end
function CreateTasButtonListEx(buttonName, cols, rows, parent, buttonAction, rightClickAction, updateAction, searchAction, filterAction, asyncButtonAction, asyncRightClickAction, colGap, rowGap)
if not rowGap then rowGap = 0.0 end
if not colGap then colGap = 0.0 end
local buttonCount = rows*cols
local object = InitTasButtonListObject(parent, buttonAction, updateAction, searchAction, filterAction, rightClickAction, asyncButtonAction, asyncRightClickAction)
object.Frames.Count = buttonCount
local rowRemain = cols
for int = 1, buttonCount do
local frameObject = {}
frameObject.Index = int
frameObject.Button = BlzCreateFrame(buttonName, parent, 0, 0)
if GetHandleId(frameObject.Button) == 0 then print("TasButtonList - Error - can't create:", buttonName) end
CreateTasButtonTooltip(frameObject, parent)
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)
TasButtonList[frameObject.Button] = frameObject
TasButtonList[frameObject] = object
object.Frames[int] = frameObject
BlzTriggerRegisterFrameEvent(TasButtonList.ButtonTrigger, frameObject.Button, FRAMEEVENT_CONTROL_CLICK)
-- do this only if the function IsRightClick exists
if IsRightClick then
BlzTriggerRegisterFrameEvent(TasButtonList.ButtonTriggerRightClick, frameObject.Button, FRAMEEVENT_MOUSE_UP)
end
BlzTriggerRegisterFrameEvent(TasButtonList.ButtonScrollTrigger, frameObject.Button, FRAMEEVENT_MOUSE_WHEEL)
if int > 1 then
if rowRemain == 0 then
BlzFrameSetPoint(frameObject.Button, FRAMEPOINT_TOP, object.Frames[int - cols].Button, FRAMEPOINT_BOTTOM, 0, -rowGap)
rowRemain = cols
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))
if cols > 1 then
BlzFrameSetPoint(frameObject.Button, FRAMEPOINT_TOPRIGHT, object.InputFrame, FRAMEPOINT_BOTTOMRIGHT, -BlzFrameGetWidth(frameObject.Button)*(cols-1) - colGap*(cols-1), 0)
else
BlzFrameSetPoint(frameObject.Button, FRAMEPOINT_TOPRIGHT, object.InputFrame, FRAMEPOINT_BOTTOMRIGHT, 0, 0)
end
end
rowRemain = rowRemain - 1
end
InitTasButtonListSlider(object, cols, rows, colGap, rowGap)
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
do
local realFunc = MarkGameStarted
function MarkGameStarted()
realFunc()
SoundNoLumber = {}
SoundNoGold = {}
SoundNoGold[RACE_HUMAN] = CreateSound("Sound\\Interface\\Warning\\Human\\KnightNoGold1.wav", false, false, false, 10, 10, "")
SetSoundParamsFromLabel(SoundNoGold[RACE_HUMAN], "NoGoldHuman")
SetSoundDuration(SoundNoGold[RACE_HUMAN], 1618)
SoundNoLumber[RACE_HUMAN] = CreateSound("Sound\\Interface\\Warning\\Human\\KnightNoLumber1.wav", false, false, false, 10, 10, "")
SetSoundParamsFromLabel(SoundNoLumber[RACE_HUMAN], "NoLumberHuman")
SetSoundDuration(SoundNoLumber[RACE_HUMAN], 1903)
local raceNaga = ConvertRace(11)
SoundNoGold[raceNaga] = CreateSound("Sound\\Interface\\Warning\\Naga\\NagaNoGold1.wav", false, false, false, 10, 10, "")
SetSoundParamsFromLabel(SoundNoGold[raceNaga], "NoGoldNaga")
SetSoundDuration(SoundNoGold[raceNaga], 2690)
SoundNoLumber[raceNaga] = CreateSound("Sound\\Interface\\Warning\\Naga\\NagaNoLumber1.wav", false, false, false, 10, 10, "")
SetSoundParamsFromLabel(SoundNoLumber[raceNaga], "NoLumberNaga")
SetSoundDuration(SoundNoLumber[raceNaga], 2011)
SoundNoGold[RACE_ORC] = CreateSound("Sound\\Interface\\Warning\\Orc\\GruntNoGold1.wav", false, false, false, 10, 10, "")
SetSoundParamsFromLabel(SoundNoGold[RACE_ORC], "NoGoldOrc")
SetSoundDuration(SoundNoGold[RACE_ORC], 1450)
SoundNoLumber[RACE_ORC] = CreateSound("Sound\\Interface\\Warning\\Orc\\GruntNoLumber1.wav", false, false, false, 10, 10, "")
SetSoundParamsFromLabel(SoundNoLumber[RACE_ORC], "NoLumberOrc")
SetSoundDuration(SoundNoLumber[RACE_ORC], 1219)
SoundNoGold[RACE_NIGHTELF] = CreateSound("Sound\\Interface\\Warning\\NightElf\\SentinelNoGold1.wav", false, false, false, 10, 10, "")
SetSoundParamsFromLabel(SoundNoGold[RACE_NIGHTELF], "NoGoldNightElf")
SetSoundDuration(SoundNoGold[RACE_NIGHTELF], 1229)
SoundNoLumber[RACE_NIGHTELF] = CreateSound("Sound\\Interface\\Warning\\NightElf\\SentinelNoLumber1.wav", false, false, false, 10, 10, "")
SetSoundParamsFromLabel(SoundNoLumber[RACE_NIGHTELF], "NoLumberNightElf")
SetSoundDuration(SoundNoLumber[RACE_NIGHTELF], 1454)
SoundNoGold[RACE_UNDEAD] = CreateSound("Sound\\Interface\\Warning\\Undead\\NecromancerNoGold1.wav", false, false, false, 10, 10, "")
SetSoundParamsFromLabel(SoundNoGold[RACE_UNDEAD], "NoGoldUndead")
SetSoundDuration(SoundNoGold[RACE_UNDEAD], 2005)
SoundNoLumber[RACE_UNDEAD] = CreateSound("Sound\\Interface\\Warning\\Undead\\NecromancerNoLumber1.wav", false, false, false, 10, 10, "")
SetSoundParamsFromLabel(SoundNoLumber[RACE_UNDEAD], "NoLumberUndead")
SetSoundDuration(SoundNoLumber[RACE_UNDEAD], 2005)
end
end
do
local realFunc = MarkGameStarted
function MarkGameStarted()
realFunc()
xpcall(function()
-- create an empty Frame that will be the ButtonLists parent. if you want to hide/move the ButtonList hide/move the parent.
local frame = BlzCreateFrameByType("FRAME", "", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "",0)
BlzFrameSetSize(frame, 0.23, 0.001)
BlzFrameSetAbsPoint(frame, FRAMEPOINT_TOP, 0.6, 0.5)
-- create a new ButtonList with 8 Rows, frame is the parent and define the action when clicking the Button
local object = CreateTasButtonList(8, frame, function(data, buttonListObject, dataIndex)
-- create an unit for the clicking player at 0/0 with facing 0
CreateUnit(GetTriggerPlayer(), data, 0, 0, 0)
end)
-- add various data
TasButtonListAddData(object, "Hpal")
TasButtonListAddData(object, "Hblm")
TasButtonListAddData(object, "hfoo")
TasButtonListAddData(object, "hkni")
TasButtonListAddData(object, "hdhw")
TasButtonListAddData(object, "hmpr")
TasButtonListAddData(object, "hsor")
TasButtonListAddData(object, "hrif")
TasButtonListAddData(object, "Ofar")
TasButtonListAddData(object, "ogru")
TasButtonListAddData(object, "orai")
-- force an update
-- UpdateTasButtonList(object)
BlzFrameSetValue(object.Slider, 999999)
print("done")
end, print)
end
end
do
local realFunc = MarkGameStarted
function MarkGameStarted()
realFunc()
xpcall(function()
-- create an empty Frame that will be the ButtonLists parent. if you want to hide/move the ButtonList hide/move the parent.
local frame = BlzCreateFrameByType("FRAME", "", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "",0)
BlzFrameSetSize(frame, 0.23, 0.001)
BlzFrameSetAbsPoint(frame, FRAMEPOINT_TOP, 0.6, 0.5)
-- this adds an checkbox, when the checkbox is checked only heroes are valid search targets
local isChecked = false
local checkBox = BlzCreateFrame("QuestCheckBox", frame, 0, 0)
BlzFrameSetPoint(checkBox, FRAMEPOINT_TOPRIGHT, frame, FRAMEPOINT_TOPLEFT, 0, 0)
-- create trigger with Checkbox-Events
local trigger = CreateTrigger()
BlzTriggerRegisterFrameEvent(trigger, checkBox, FRAMEEVENT_CHECKBOX_CHECKED)
BlzTriggerRegisterFrameEvent(trigger, checkBox, FRAMEEVENT_CHECKBOX_UNCHECKED)
local label = BlzCreateFrameByType("TEXT", "", frame, "", 0)
BlzFrameSetPoint(label, FRAMEPOINT_LEFT, checkBox, FRAMEPOINT_RIGHT, 0, 0)
BlzFrameSetText(label, "Heroes")
-- create a new ButtonList with 3 Rows, frame is the parent and define the action when clicking the Button
local object = CreateTasButtonList(3, frame, function(data, buttonListObject, dataIndex)
-- create an unit for the clicking player at 0/0 with facing 0
CreateUnit(GetTriggerPlayer(), data, 0, 0, 0)
end,
nil,
nil,
function(data, buttonListObject, isTextSearching)
if isChecked then
return IsUnitIdType(data, UNIT_TYPE_HERO)
else
return true
end
end
)
-- this is the checkbox toogling, it has to be written below object because one uses content of object; object.InputFrame
TriggerAddAction(trigger, function()
if GetLocalPlayer() == GetTriggerPlayer() then
isChecked = (BlzGetTriggerFrameEvent() == FRAMEEVENT_CHECKBOX_CHECKED)
BlzFrameSetText(object.InputFrame, "")
end
end)
-- add various data
TasButtonListAddData(object, "Hpal")
TasButtonListAddData(object, "Hblm")
TasButtonListAddData(object, "hfoo")
TasButtonListAddData(object, "hkni")
TasButtonListAddData(object, "hdhw")
TasButtonListAddData(object, "hmpr")
TasButtonListAddData(object, "hsor")
TasButtonListAddData(object, "hrif")
TasButtonListAddData(object, "Ofar")
TasButtonListAddData(object, "ogru")
TasButtonListAddData(object, "orai")
TasButtonListAddData(object, "Edem")
TasButtonListAddData(object, "Emoo")
TasButtonListAddData(object, "emtg")
TasButtonListAddData(object, "earc")
TasButtonListAddData(object, "ehpr")
TasButtonListAddData(object, "ehpr")
-- force an update
-- UpdateTasButtonList(object)
BlzFrameSetValue(object.Slider, 999999)
print("done")
end, print)
end
end
do
local realFunc = MarkGameStarted
function MarkGameStarted()
realFunc()
xpcall(function()
-- create an empty Frame that will be the ButtonLists parent. if you want to hide/move the ButtonList hide/move the parent.
local frame = BlzCreateFrameByType("FRAME", "", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "",0)
BlzFrameSetSize(frame, 0.23, 0.001)
BlzFrameSetAbsPoint(frame, FRAMEPOINT_TOP, 0.6, 0.5)
-- create a new ButtonList with 4 Rows, frame is the parent and define the action when clicking the Button
local object = CreateTasButtonList(4, frame, function(data, buttonListObject, dataIndex)
print(data.Icon, data.Text)
end,
function(frameObject, data)
BlzFrameSetTexture(frameObject.Icon, data.Icon, 0, false)
BlzFrameSetText(frameObject.Text, data.Text)
BlzFrameSetTexture(frameObject.ToolTipFrameIcon, data.Icon, 0, false)
BlzFrameSetText(frameObject.ToolTipFrameName, data.Text)
end)
-- add various data
TasButtonListAddData(object, {Icon = "ReplaceableTextures\\CommandButtons\\BTNPriest", Text = "Custom A"})
TasButtonListAddData(object, {Icon = "ReplaceableTextures\\CommandButtons\\BTNSlow", Text = "Custom B"})
TasButtonListAddData(object, {Icon = "ReplaceableTextures\\CommandButtons\\BTNInvisibility", Text = "Custom C"})
TasButtonListAddData(object, {Icon = "ReplaceableTextures\\CommandButtons\\BTNBanish", Text = "Custom D"})
TasButtonListAddData(object, {Icon = "ReplaceableTextures\\CommandButtons\\BTNCrystalBall", Text = "Custom E"})
TasButtonListAddData(object, {Icon = "ReplaceableTextures\\CommandButtons\\BTNBoots", Text = "Custom F"})
TasButtonListAddData(object, {Icon = "ReplaceableTextures\\CommandButtons\\BTNTalisman", Text = "Custom G"})
-- force an update
-- UpdateTasButtonList(object)
BlzFrameSetValue(object.Slider, 999999)
print("done")
end, print)
end
end
do
local realFunc = MarkGameStarted
function MarkGameStarted()
realFunc()
xpcall(function()
-- create an empty Frame that will be the ButtonLists parent. if you want to hide/move the ButtonList hide/move the parent.
local frame = BlzCreateFrameByType("FRAME", "", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "",0)
BlzFrameSetSize(frame, 0.23, 0.001)
BlzFrameSetAbsPoint(frame, FRAMEPOINT_TOP, 0.6, 0.5)
-- create a new ButtonList with 8 Rows, frame is the parent and define the action when clicking the Button
local object = CreateTasButtonTextListBig(5, 1, frame, function(data, buttonListObject, dataIndex)
-- create an unit for the clicking player at 0/0 with facing 0
CreateUnit(GetTriggerPlayer(), data, 0, 0, 0)
end
--,--runs once for each button shown
--function (frameObject, data)
--BlzFrameSetTexture(frameObject.Icon, "UI/Widgets/EscMenu/Human/blank-background", 0, true)
--BlzFrameSetText(frameObject.Text, data)
--BlzFrameSetTexture(frameObject.ToolTipFrameIcon, "UI/Widgets/EscMenu/Human/blank-background", 0, false)
--BlzFrameSetText(frameObject.ToolTipFrameName, data)
-- frameObject.ToolTipFrameSeperator
-- BlzFrameSetText(frameObject.ToolTipFrameText, data)
--end
)
-- add various data
TasButtonListAddData(object, "Paladin")
--TasButtonListAddData(object, "Hpal")
TasButtonListAddData(object, "hfoo")
TasButtonListAddData(object, "hkni")
TasButtonListAddData(object, "hdhw")
TasButtonListAddData(object, "hmpr")
TasButtonListAddData(object, "hsor")
TasButtonListAddData(object, "hrif")
TasButtonListAddData(object, "Ofar")
TasButtonListAddData(object, "ogru")
TasButtonListAddData(object, "orai")
-- force an update
-- UpdateTasButtonList(object)
BlzFrameSetValue(object.Slider, 999999)
print("done")
end, print)
end
end
do
local realFunc = MarkGameStarted
function MarkGameStarted()
realFunc()
xpcall(function()
-- create an empty Frame that will be the ButtonLists parent. if you want to hide/move the ButtonList hide/move the parent.
local frame = BlzCreateFrameByType("FRAME", "", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "",0)
BlzFrameSetSize(frame, 0.23, 0.001)
BlzFrameSetAbsPoint(frame, FRAMEPOINT_TOP, 0.6, 0.5)
-- create a new ButtonList with 8 Buttons, frame is the parent and define the action when clicking the Button
local object = CreateTasButtonList(8, frame, function(data, buttonListObject, dataIndex)
-- create an unit for the clicking player at 0/0 with facing 0
print(GetObjectName(data))
end)
--In this example Costs do not matter hence we hide the gold/lumber display
-- the Buttons now also can be smaller
for int = 1, 8 do
BlzFrameSetVisible(object.Frames[int].TextLumber, false)
BlzFrameSetVisible(object.Frames[int].TextGold, false)
BlzFrameSetVisible(object.Frames[int].IconGold, false)
BlzFrameSetVisible(object.Frames[int].IconLumber, false)
BlzFrameSetSize(object.Frames[int].Button, 0.15, 0.0265)
end
-- add various data
TasButtonListAddDataBatchEx(object, "AHbz", "AHhb", "AHtc", "AHtb", "AOcl", "AOsw", "AOww", "AOws", "AChx", "AUfn"
, "AUdc", "AUdp", "AUan", "AUau")
-- force an update
-- UpdateTasButtonList(object)
BlzFrameSetValue(object.Slider, 999999)
print("done")
end, print)
end
end
do
local realFunc = MarkGameStarted
function MarkGameStarted()
realFunc()
xpcall(function()
-- create the Background Box
local box = BlzCreateFrame("EscMenuBackdrop", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), 0, 0)
BlzFrameSetSize(box, 0.255, 0.29)
BlzFrameSetAbsPoint(box, FRAMEPOINT_TOPRIGHT, 0.80, 0.56)
--Create a Button to rotate the current viewed TasButtonList
local button = BlzCreateFrameByType("GLUETEXTBUTTON", "", box, "ScriptDialogButton",0)
BlzFrameSetAbsPoint(button, FRAMEPOINT_TOPRIGHT, 0.78, 0.58)
BlzFrameSetSize(button, 0.1, 0.03)
BlzFrameSetText(button, "Units")
-- define a Clickaction, this is done here because all 3 ButtonLists use the same
local clickAction = function(data, buttonListObject, dataIndex)
local gold, lumber
if not IsUnitIdType(data, UNIT_TYPE_HERO) then
gold = GetUnitGoldCost(data)
lumber = GetUnitWoodCost(data)
else
gold = 0
lumber = 0
end
local player = GetTriggerPlayer()
if GetPlayerState(player, PLAYER_STATE_RESOURCE_GOLD) >= gold then
if GetPlayerState(player, PLAYER_STATE_RESOURCE_LUMBER) >= lumber then
AdjustPlayerStateSimpleBJ(player, PLAYER_STATE_RESOURCE_GOLD, -gold)
AdjustPlayerStateSimpleBJ(player, PLAYER_STATE_RESOURCE_LUMBER, -lumber)
CreateUnit(player, data, GetPlayerStartLocationX(player), GetPlayerStartLocationY(player), 0)
elseif not GetSoundIsPlaying(SoundNoLumber[GetPlayerRace(player)]) then
StartSoundForPlayerBJ(player, SoundNoLumber[GetPlayerRace(player)])
end
elseif not GetSoundIsPlaying(SoundNoGold[GetPlayerRace(player)]) then
StartSoundForPlayerBJ(player, SoundNoGold[GetPlayerRace(player)])
end
end
-- create and place the container of the TasButtonList
local frameA = BlzCreateFrameByType("FRAME", "", box, "",0)
BlzFrameSetSize(frameA, 0.23, 0.001)
--BlzFrameSetAbsPoint(frameA, FRAMEPOINT_TOPRIGHT, 0.78, 0.54)
BlzFrameSetPoint(frameA, FRAMEPOINT_TOPLEFT, box, FRAMEPOINT_TOPLEFT, 0, -0.02)
-- create a TasButtonList of Type 2 with 7 Rows, Type 2 is 2 Buttons in each Row, using frameA as parent/container doing clickAction on click
local object = CreateTasButtonListV2(7, frameA, clickAction)
object.RightClickAction = function(data, buttonListObject, dataIndex) print(GetPlayerName(GetTriggerPlayer()),"RightClick", GetObjectName(data)) end
-- add various data
local data = {"Hamg"
, "Hblm", "Hmkg", "Hpal", "hbot", "hbsh", "hdes", "hdhw", "hfoo", "hgry", "hgyr", "hkni", "hmil"
, "hmpr", "hmtm", "hmtt", "hpea", "hphx", "hpxe", "hrif", "hrtt", "hsor", "hspt", "hwat", "hwt2"
, "hwt3", "nlv1", "nlv2", "nlv3", "halt", "harm", "hars", "hatw", "hbar", "hbla", "hcas", "hctw"
, "hgra", "hgtw", "hhou", "hkee", "hlum", "hshy", "htow", "hvlt", "hwtw", "Obla", "Ofar", "Oshd"
, "Otch", "ncat", "nsw1", "nsw2", "nsw3", "nwad", "obot", "ocat", "odes", "odoc", "oeye", "ogru"
, "ohun", "ohwd", "okod", "opeo", "orai", "oshm", "osp1", "osp2", "osp3", "osp4", "ospm", "ospw"
, "osw1", "osw2", "osw3", "otau", "otbk", "otbr", "otot", "owyv", "oalt", "obar", "obea", "ofor"
, "ofrt", "ogre", "oshy", "osld", "ostr", "otrb", "otto", "ovln", "owtw", "Edem", "Edmm", "Ekee"
, "Emoo", "Ewar", "earc", "ebal", "ebsh", "echm", "edcm", "edes", "edoc", "edot", "edry", "edtm"
, "efdr", "efon", "ehip", "ehpr", "emtg", "esen", "espv", "even", "ewsp", "eaoe", "eaom", "eaow"
, "eate", "eden", "edob", "edos", "egol", "emow", "eshy", "etoa", "etoe", "etol", "etrp", "Ucrl"
, "Udea", "Udre", "Ulic", "uabo", "uaco", "uban", "ubsp", "ucrm", "ucry", "ucs1", "ucs2", "ucs3"
, "ucsB", "ucsC", "ufro", "ugar", "ugho", "ugrm", "uloc", "umtw", "unec", "uobs", "uplg", "ushd"
, "uske", "uskm", "uubs", "uaod", "ubon", "ugol", "ugrv", "unp1", "unp2", "unpl", "usap", "usep"
, "ushp", "uslh", "utod", "utom", "uzg1", "uzg2", "uzig", "Nal2", "Nal3", "Nalc", "Nalm", "Nbrn"
, "Nbst", "Nfir", "Nngs", "Npbm", "Nplh", "Nrob", "Ntin", "ncg1", "ncg2", "ncg3", "ncgb", "ndr1"
, "ndr2", "ndr3", "nfa1", "nfa2", "nfac", "ngz1", "ngz2", "ngz3", "ngz4", "ngzc", "ngzd", "npn1"
, "npn2", "npn3", "npn4", "npn5", "npn6", "nqb1", "nqb2", "nqb3", "nqb4", "nwe1", "nwe2", "nwe3"
, "nadk", "nadr", "nadw", "nahy", "nanb", "nanc", "nane", "nanm", "nano", "nanw", "narg", "nass"
, "nba2", "nbal", "nban", "nbda", "nbdk", "nbdm", "nbdo", "nbdr", "nbds", "nbdw", "nbld", "nbnb"
, "nbot", "nbrg", "nbwm", "nbzd", "nbzk", "nbzw", "ncea", "ncen", "ncer", "ncfs", "nchp", "ncim"
, "ncks", "ncnk", "ndqn", "ndqp", "ndqs", "ndqt", "ndqv", "ndrv", "ndtb", "ndth", "ndtp", "ndtr"
, "ndtt", "ndtw", "nehy", "nelb", "nele", "nenc", "nenf", "nenp", "nepl", "nerd", "ners", "nerw"
, "nfel", "nfgb", "nfgo", "nfgt", "nfgu", "nfod", "nfor", "nfot", "nfov", "nfpc", "nfpe", "nfpl"
, "nfps", "nfpt", "nfpu", "nfra", "nfrb", "nfre", "nfrg", "nfrl", "nfrp", "nfrs", "nfsh", "nfsp"
, "nftb", "nftk", "nftr", "nftt", "ngdk", "nggr", "ngh1", "ngh2", "ngir", "nglm", "ngna", "ngnb"
, "ngno", "ngns", "ngnv", "ngnw", "ngrd", "ngrk", "ngrw", "ngsp", "ngst", "ngza", "nhar", "nhdc"
, "nhfp", "nhhr", "nhrh", "nhrq", "nhrr", "nhrw", "nhyc", "nhyd", "nhyh", "nhym", "nina", "ninc"
, "ninf", "ninm", "nith", "nitp", "nitr", "nits", "nitt", "nitw", "njg1", "njga", "njgb", "nkob"
, "nkog", "nkol", "nkot", "nlds", "nlkl", "nlpd", "nlpr", "nlps", "nlrv", "nlsn", "nltc", "nltl"
, "nlur", "nmam", "nmbg", "nmcf", "nmdr", "nmfs", "nmgd", "nmgr", "nmgw", "nmit", "nmmu", "nmpg"
, "nmrl", "nmrm", "nmrr", "nmrv", "nmsc", "nmsn", "nmtw", "nmyr", "nmys", "nndk", "nndr", "nnht"
, "nnmg", "nnrg", "nnrs", "nnsu", "nnsw", "nnwa", "nnwl", "nnwq", "nnwr", "nnws", "noga", "nogl"
, "nogm", "nogn", "nogo", "nogr", "nomg", "nowb", "nowe", "nowk", "npfl", "npfm", "nplb", "nplg"
, "nqbh", "nrdk", "nrdr", "nrel", "nrog", "nrvd", "nrvf", "nrvi", "nrvl", "nrvs", "nrwm", "nrzb"
, "nrzg", "nrzm", "nrzs", "nrzt", "nsat", "nsbm", "nsbs", "nsc2", "nsc3", "nsca", "nscb", "nsce"
, "nsel", "nsgb", "nsgg", "nsgh", "nsgn", "nsgt", "nska", "nske", "nskf", "nskg", "nskm", "nsko"
, "nslf", "nslh", "nsll", "nslm", "nsln", "nslr", "nslv", "nsnp", "nsns", "nsoc", "nsog", "nspb"
, "nspd", "nspg", "nspp", "nspr", "nsqa", "nsqe", "nsqo", "nsqt", "nsra", "nsrh", "nsrn", "nsrv"
, "nsrw", "nssp", "nsth", "nstl", "nsts", "nstw", "nsty", "nthl", "ntka", "ntkc", "ntkf", "ntkh"
, "ntks", "ntkt", "ntkw", "ntor", "ntrd", "ntrg", "ntrh", "ntrs", "ntrt", "ntrv", "ntws", "nubk"
, "nubr", "nubw", "nvde", "nvdg", "nvdl", "nvdw", "nwen", "nwgs", "nwiz", "nwld", "nwlg", "nwlt"
, "nwna", "nwnr", "nwns", "nwrg", "nws1", "nwwd", "nwwf", "nwwg", "nwzd", "nwzg", "nwzr", "nzep"
, "nzom", "nzof", "nalb", "ncrb", "nder", "ndog", "ndwm", "nech", "necr", "nfbr", "nfro", "nhmc"
, "now2", "now3", "nowl", "npig", "npng", "npnw", "nrac", "nrat", "nsea", "nsha", "nshe", "nshf"
, "nshw", "nskk", "nsno", "nvil", "nvk2", "nvl2", "nvlk", "nvlw", "nvul", "ncb0", "ncb1", "ncb2"
, "ncb3", "ncb4", "ncb5", "ncb6", "ncb7", "ncb8", "ncb9", "ncba", "ncbb", "ncbc", "ncbd", "ncbe"
, "ncbf", "ncnt", "ncop", "ncp2", "ncp3", "nct1", "nct2", "ndch", "ndh0", "ndh1", "ndh2", "ndh3"
, "ndh4", "ndrg", "ndrk", "ndro", "ndrr", "ndru", "ndrz", "nfh0", "nfh1", "nfoh", "nfr1", "nfr2"
, "ngad", "ngme", "ngnh", "ngni", "ngol", "ngt2", "ngwr", "nhns", "nmer", "nmg0", "nmg1", "nmh0"
, "nmh1", "nmoo", "nmr0", "nmr2", "nmr3", "nmr4", "nmr5", "nmr6", "nmr7", "nmr8", "nmr9", "nmra"
, "nmrb", "nmrc", "nmrd", "nmre", "nmrf", "nmrk", "nnzg", "nshp", "ntav", "nten", "nth0", "nth1"
, "ntn2", "ntnt", "ntt2", "nwgt", "Ecen", "Eevi", "Eevm", "Efur", "Eidm", "Eill", "Eilm", "Ekgg"
, "Emfr", "Emns", "Etyr", "Ewrd", "Hant", "Hapm", "Harf", "Hart", "Hdgo", "Hgam", "Hhkl", "Hjai"
, "Hkal", "Hlgr", "Hmbr", "Hmgd", "Hpb1", "Hpb2", "Huth", "Hvsh", "Hvwd", "Naka", "Nbbc", "Nkjx"
, "Nklj", "Nmag", "Nman", "Npld", "Nsjs", "Ocb2", "Ocbh", "Odrt", "Ogld", "Ogrh", "Opgh", "Orex"
, "Orkn", "Osam", "Otcc", "Othr", "Oths", "Uanb", "Ubal", "Uclc", "Udth", "Uear", "Uktl", "Umal"
, "Usyl", "Utic", "Uvar", "Uvng", "Uwar", "eilw", "enec", "ensh", "eshd", "etrs", "hbew", "hcth"
, "hhdl", "hhes", "hprt", "hrdh", "nbee", "nbel", "nbsp", "nchg", "nchr", "nchw", "nckb", "ncpn"
, "ndmu", "ndrd", "ndrf", "ndrh", "ndrj", "ndrl", "ndrm", "ndrn", "ndrp", "ndrs", "ndrt", "ndrw"
, "ndsa", "negz", "nemi", "nfgl", "ngbl", "nhea", "nhef", "nhem", "nhew", "njks", "nmdm", "nmed"
, "nmpe", "nmsh", "nser", "nspc", "nssn", "nthr", "nw2w", "nwat", "nzlc", "odkt", "ogrk", "ojgn"
, "omtg", "onzg", "oosc", "oswy", "ovlj", "owar", "ownr", "uabc", "uarb", "ubdd", "ubdr", "ubot"
, "udes", "uktg", "uktn", "uswb", "haro", "nbfl", "nbse", "nbsm", "nbsw", "nbt1", "nbt2", "nbwd"
, "ncap", "ncaw", "ncmw", "ncta", "ncte", "nctl", "ndfl", "ndgt", "ndke", "ndkw", "ndmg", "ndrb"
, "ndt1", "ndt2", "nef0", "nef1", "nef2", "nef3", "nef4", "nef5", "nef6", "nef7", "nefm", "negf"
, "negm", "negt", "net1", "net2", "nfnp", "nfrm", "nfrt", "nft1", "nft2", "nfv0", "nfv1", "nfv2"
, "nfv3", "nfv4", "ngob", "nhcn", "nheb", "nico", "nitb", "nmgv", "nnad", "nnfm", "nnsa", "nnsg"
, "nntg", "nntt", "npgf", "npgr", "nshr", "ntt1", "ntx2", "nvr0", "nvr1", "nvr2", "nwc1", "nwc2"
, "nwc3", "nwc4", "nzin", "ocbw", "zcso", "zhyd", "zjug", "zmar", "zshv", "zsmc", "zzrg", "Nmsr"
, "Nswt", "ntn3", "nggm", "nggg", "nggd", "ngow", "nwzw", "ngos", "ngog", "nwar", "nccd", "ncco"
, "nccu", "nccr", "Hjnd", "nmg2", "nhn2", "obai", "hrrh", "Haah", "Hssa", "Hddt", "owad"
}
local i = 0
for _, k in ipairs(data) do
i= i + 1
TasButtonListAddData(object, k)
end
--force an update to the TasButtonList after removing/adding this should be done
BlzFrameSetValue(object.Slider, 999999)
--remember this ButtonList in another variable, because object is a reused temp reference
local objectListA = object
-- create another TasButtonList
-- container/Parent
local frameB = BlzCreateFrameByType("FRAME", "", box, "",0)
BlzFrameSetSize(frameB, 0.23, 0.001)
--BlzFrameSetAbsPoint(frameB, FRAMEPOINT_TOPRIGHT, 0.78, 0.54)
BlzFrameSetPoint(frameB, FRAMEPOINT_TOPLEFT, box, FRAMEPOINT_TOPLEFT, 0, -0.02)
-- starts hidden
BlzFrameSetVisible(frameB, false)
--create a TasButtonList with 8 rows
object = CreateTasButtonList(8, frameB, clickAction)
--the new TasButtonList will use the same data-Array as the first created one.
TasButtonListCopyData(object, objectListA)
-- BlzFrameSetValue(object.Slider, 999999)
local objectListB = object
--create a 3.
local frameC = BlzCreateFrameByType("FRAME", "", box, "",0)
BlzFrameSetSize(frameC, 0.23, 0.001)
--BlzFrameSetAbsPoint(frameA, FRAMEPOINT_TOPRIGHT, 0.78, 0.54)
BlzFrameSetPoint(frameC, FRAMEPOINT_TOPLEFT, box, FRAMEPOINT_TOPLEFT, 0, -0.02)
BlzFrameSetVisible(frameC, false)
object = CreateTasButtonListV3(8, frameC, clickAction)
TasButtonListCopyData(object, objectListA)
-- BlzFrameSetValue(object.Slider, 999999)
local objectListC = object
-- create the logic for the rotation
local trigger = CreateTrigger()
TriggerAddAction(trigger, function()
BlzFrameSetEnable(BlzGetTriggerFrame(), false)
BlzFrameSetEnable(BlzGetTriggerFrame(), true)
if GetLocalPlayer() == GetTriggerPlayer() then
if BlzFrameIsVisible(frameA) then
BlzFrameSetVisible(frameA, false)
BlzFrameSetVisible(frameB, true)
UpdateTasButtonList(objectListB)
BlzFrameSetText(button, "B")
elseif BlzFrameIsVisible(frameB) then
BlzFrameSetVisible(frameC, true)
BlzFrameSetVisible(frameB, false)
UpdateTasButtonList(objectListB)
BlzFrameSetText(button, "C")
elseif BlzFrameIsVisible(frameC) then
BlzFrameSetVisible(frameC, false)
BlzFrameSetVisible(frameA, true)
UpdateTasButtonList(objectListC)
BlzFrameSetText(button, "A")
end
end
end)
BlzTriggerRegisterFrameEvent(trigger, button, FRAMEEVENT_CONTROL_CLICK)
--some Safety check
print("done")
end, print)
end
end
do
local realFunc = MarkGameStarted
function MarkGameStarted()
realFunc()
xpcall(function()
-- create an empty Frame that will be the ButtonLists parent. if you want to hide/move the ButtonList hide/move the parent.
local frame = BlzCreateFrameByType("FRAME", "", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "",0)
BlzFrameSetSize(frame, 0.23, 0.001)
BlzFrameSetAbsPoint(frame, FRAMEPOINT_TOP, 0.6, 0.5)
-- create a new ButtonList with 8 Rows, frame is the parent and define the action when clicking the Button
local object = CreateTasButtonList(8, frame, function(data, buttonListObject, dataIndex)
local gold, lumber
if not IsUnitIdType(data, UNIT_TYPE_HERO) then
gold = GetUnitGoldCost(data)
lumber = GetUnitWoodCost(data)
else
gold = 0
lumber = 0
end
local player = GetTriggerPlayer()
if GetPlayerState(player, PLAYER_STATE_RESOURCE_GOLD) >= gold then
if GetPlayerState(player, PLAYER_STATE_RESOURCE_LUMBER) >= lumber then
AdjustPlayerStateSimpleBJ(player, PLAYER_STATE_RESOURCE_GOLD, -gold)
AdjustPlayerStateSimpleBJ(player, PLAYER_STATE_RESOURCE_LUMBER, -lumber)
CreateUnit(player, data, GetPlayerStartLocationX(player), GetPlayerStartLocationY(player), 0)
elseif not GetSoundIsPlaying(SoundNoLumber[GetPlayerRace(player)]) then
StartSoundForPlayerBJ(player, SoundNoLumber[GetPlayerRace(player)])
end
elseif not GetSoundIsPlaying(SoundNoGold[GetPlayerRace(player)]) then
StartSoundForPlayerBJ(player, SoundNoGold[GetPlayerRace(player)])
end
end)
local function Human(player)
TasButtonListAddDataBatch(object, player
, "Hamg", "Hblm", "Hmkg", "Hpal", "hbot", "hbsh","hdes"
, "hdhw", "hfoo", "hgry", "hgyr", "hkni", "hmil","hmpr"
, "hmtm", "hmtt", "hpea", "hphx", "hpxe", "hrif"
, "hrtt", "hsor", "hspt", "hwat", "hwt2", "hwt3"
)
end
local function Orc(player)
TasButtonListAddDataBatch(object, player
,"Obla" ,"Ofar" ,"Oshd" ,"Otch"
,"ncat" ,"nsw1" ,"nsw2" ,"nsw3"
,"nwad" ,"obot" ,"ocat" ,"odes"
,"odoc" ,"oeye" ,"ogru" ,"ohun"
,"ohwd" ,"okod" ,"opeo" ,"orai"
,"oshm" ,"osp1" ,"osp2" ,"osp3"
,"osp4" ,"ospm" ,"ospw" ,"osw1"
,"osw2" ,"osw3" ,"otau" ,"otbk"
,"otbr" ,"otot" ,"owyv"
)
end
local function NightElf(player)
TasButtonListAddDataBatch(object, player
,"Edem","Edmm","Ekee","Emoo","Ewar","earc","even","ewsp"
,"ebal","ebsh","echm","edcm","edes","edoc","edot","edry"
,"edtm","efdr","efon","ehip","ehpr","emtg","esen","espv"
)
end
local function Undead(player)
TasButtonListAddDataBatch(object, player
,"Ucrl","Udea","Udre","Ulic","uabo"
,"uaco","uban","ubsp","ucrm","ucry"
,"ucs1","ucs2","ucs3","ucsB","ucsC"
,"ufro","ugar","ugho","ugrm","uloc"
,"umtw","unec","uobs","uplg","ushd"
,"uske" ,"uskm" ,"uubs"
)
end
for i = 0, bj_MAX_PLAYER_SLOTS - 1 do
local player = Player(i)
if GetPlayerRace(player) == RACE_HUMAN then Human(player)
elseif GetPlayerRace(player) == RACE_ORC then Orc(player)
elseif GetPlayerRace(player) == RACE_UNDEAD then Undead(player)
elseif GetPlayerRace(player) == RACE_NIGHTELF then NightElf(player)
end
end
-- force an update
-- UpdateTasButtonList(object)
BlzFrameSetValue(object.Slider, 999999)
print("done")
end, print)
end
end