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
--[[
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
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 Rows, frame is the parent and define the action when clicking the Button
local object = CreateTasButtonTextListBig(2, 2, 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")
TasButtonListAddData(object, "orai")
TasButtonListAddData(object, "Ulic")
TasButtonListAddData(object, "Udea")
-- force an update
-- UpdateTasButtonList(object)
BlzFrameSetValue(object.Slider, 999999)
TimerStart(CreateTimer(), 2, false, function()
print("Add Rows")
TasButtonListAddRow(object)
TasButtonListAddRow(object)
TasButtonListAddRow(object)
-- BlzFrameSetValue(object.Slider, 999999)
end)
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)
print("click")
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
local function CreateButton(frameObject, parent, index)
local buttonFrame = BlzCreateFrameByType("GLUEBUTTON", "FaceButton", parent, "", 0)
local buttonIconFrame = BlzCreateFrameByType("BACKDROP", "FaceButtonIcon", buttonFrame, "", 0)
BlzFrameSetAllPoints(buttonIconFrame, buttonFrame)
BlzFrameSetSize(buttonFrame, 0.05, 0.05)
frameObject.Icon = buttonIconFrame
return buttonFrame
end
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 = CreateTasButtonListEx2(CreateButton, 3, 2, 0.003, 0.003, frame)
object.ButtonAction = function(data, buttonListObject, dataIndex, player)
CreateUnit(player, data, GetPlayerStartLocationX(player), GetPlayerStartLocationY(player), 0)
end
--[[ possible 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
--]]
--[[ object.UpdateAction = function(frameObject, data)
print("my update",data, frameObject.Index)
print(GetHandleId(frameObject.Icon))
BlzFrameSetTexture(frameObject.Icon, BlzGetAbilityIcon(data), 0, false)
BlzFrameSetTexture(frameObject.ToolTipFrameIcon, BlzGetAbilityIcon(data), 0, false)
BlzFrameSetText(frameObject.ToolTipFrameName, GetObjectName(data))
-- frameObject.ToolTipFrameSeperator
BlzFrameSetText(frameObject.ToolTipFrameText, BlzGetAbilityExtendedTooltip(data, 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)
TimerStart(CreateTimer(), 5, false, function()
print("Add Row")
TasButtonListAddRow(object)
end)
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