Name | Type | is_array | initial_value |
Copy TasCheatBox
For the unit item placement you need to import export
war3mapImported\TasButtonList.fdf
war3mapImported\TasButtonList.toc
For the lua input you need
war3mapImported\Templates.toc
function CreateSimpleTooltip(frame, text)
-- this FRAME is important when the Box is outside of 4:3 it can be limited to 4:3.
local toolTipParent = BlzCreateFrameByType("FRAME", "", frame, "", 0)
local toolTipBox = BlzCreateFrame("EscMenuControlBackdropTemplate", toolTipParent, 0, 0)
local toolTip = BlzCreateFrame("TasButtonTextTemplate", toolTipBox, 0, 0)
BlzFrameSetPoint(toolTip, FRAMEPOINT_BOTTOM, frame, FRAMEPOINT_TOP, 0, 0.008)
BlzFrameSetPoint(toolTipBox, FRAMEPOINT_TOPLEFT, toolTip, FRAMEPOINT_TOPLEFT, -0.008, 0.008)
BlzFrameSetPoint(toolTipBox, FRAMEPOINT_BOTTOMRIGHT, toolTip, FRAMEPOINT_BOTTOMRIGHT, 0.008, -0.008)
BlzFrameSetText(toolTip, text)
BlzFrameSetTooltip(frame, toolTipParent)
return toolTip
end
--[[
TasButtonList11a 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)
BlzFrameSetPoint(object.Slider, FRAMEPOINT_TOPLEFT, object.InputFrame, FRAMEPOINT_BOTTOMRIGHT, 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
--[[ TasCheatBox V0.8 by Tasyen
A UI addition that gives the user various powers. Good to have fun or test your map.
Works out of the box, for singleplayer only.
TasCheatBox becomes more powerful when your map has installed TasButtonList and Load in the default Templates.
]]
do
TasCheatBox = {
AutoRun = true --(true) will create Itself at 0s, (false) you need to TasCheatBox.Init()
,TemplatesToc = "war3mapImported\\Templates.toc" -- optional for the Lua input box
,ParentFunc = function() return BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0) end
,OpenX = 0.2
,OpenY = 0.15
,OpenPos = FRAMEPOINT_BOTTOMLEFT
,X = 0.79
,Y = 0.16
,Pos = FRAMEPOINT_BOTTOMRIGHT
-- Units/Item only work when TasButtonList is installed
,ListX = 0.77
,ListY = 0.57
,ListPos = FRAMEPOINT_TOPRIGHT
,ListCols = 4
,LisRows = 6
,Scale = 0.8
,IncludeDefaultItems = true --add default Items to the List?
,IncludeDefaultUnits = true
,IncludeCustomItems = false --Try to find Custom Items and add them to the List?
,IncludeCustomUnits = false
,CheckCustomObject = true -- slows the process but excludes objects without name
,CustomItemEnd = FourCC'I09Z' -- LastItem Custom Id
,CustomUnitCodes = {
{FourCC'h000',FourCC'h0A0'} -- startIndex , endIndex
,{FourCC'H000',FourCC'H09Z'}
,{FourCC'o000',FourCC'o09Z'}
,{FourCC'O000',FourCC'O09Z'}
,{FourCC'u000',FourCC'u09Z'}
,{FourCC'U000',FourCC'U09Z'}
,{FourCC'e000',FourCC'e09Z'}
,{FourCC'E000',FourCC'E09Z'}
,{FourCC'n000',FourCC'n09Z'}
,{FourCC'N000',FourCC'N09Z'}
}
,ButtonCount = __jarray(0)
,ButtonAction = {}
,ButtonActionGroup = {}
,ParentPage = {}
,CurrentUnitOwner = 0
,PageName = {
"Unit","Player Game", "Place Unit","Place Item","Lua"
}
}
local this = TasCheatBox
--this.SelectAction = function()
--this.Selected = GetTriggerUnit()
--end
function this.ActionClone()
local u = GetEnumUnit()
local u2 = CreateUnit(GetOwningPlayer(u), GetUnitTypeId(u), GetUnitX(u), GetUnitY(u), GetUnitFacing(u))
if IsUnitType(u, UNIT_TYPE_HERO) then
SetHeroLevel(u2, GetHeroLevel(u))
SetHeroAgi(u2, GetHeroAgi(u), true)
SetHeroInt(u2, GetHeroInt(u), true)
SetHeroStr(u2, GetHeroStr(u), true)
for i = 0, bj_MAX_INVENTORY-1 do
UnitAddItemToSlotById(u2, GetItemTypeId(UnitItemInSlot(u, i)), i)
end
end
PauseUnit(u2, IsUnitPaused(u))
end
function this.ActionInvul()
local u = GetEnumUnit()
SetUnitInvulnerable(u, not BlzIsUnitInvulnerable(u))
end
function this.ActionControl()
SetUnitOwner(GetEnumUnit(), GetTriggerPlayer(), true)
end
function this.ActionHeal()
local u = GetEnumUnit()
SetUnitState(u, UNIT_STATE_LIFE, GetUnitState(u, UNIT_STATE_MAX_LIFE))
SetUnitState(u, UNIT_STATE_MANA, GetUnitState(u, UNIT_STATE_MAX_MANA))
UnitResetCooldown(u)
end
function this.ActionMaxLevel() SetHeroLevel(GetEnumUnit(), 99999, true) end
function this.ActionKill() KillUnit(GetEnumUnit()) end
function this.ActionDispel() UnitRemoveBuffs(GetEnumUnit(), true, true) end
function this.ActionTeleport() SetUnitPosition(GetEnumUnit(), GetCameraTargetPositionX(), GetCameraTargetPositionY()) end
function this.ActionPause() PauseUnit(GetEnumUnit(), not IsUnitPaused(GetEnumUnit())) end
function this.ActionPauseAll() PauseAllUnitsBJ(true) end
function this.ActionUnPauseAll() PauseAllUnitsBJ(false) end
function this.ActionFood0(player)
SetPlayerState(player, PLAYER_STATE_RESOURCE_FOOD_USED, 0)
SetPlayerState(player, PLAYER_STATE_RESOURCE_FOOD_CAP, 999)
end
function this.ActionDefeatPlayer(player)
GroupEnumUnitsSelected(this.Group, player, nil)
local u = FirstOfGroup(this.Group)
GroupClear(this.Group)
if u then CustomDefeatBJ(GetOwningPlayer(u), GetLocalizedString("GAMEOVER_DEFEAT_MSG")) end
end
function this.ActionVictory(player)
CustomVictoryBJ(player, true, true)
end
function this.ActionRevive(player)
GroupEnumUnitsOfPlayer(this.Group, player, nil)
for i = 0, BlzGroupGetSize(this.Group) - 1 do
local u = BlzGroupUnitAt(this.Group, i)
if IsUnitType(u, UNIT_TYPE_HERO) then
SetUnitUseFood(u, false)
ReviveHero(u, GetCameraTargetPositionX(), GetCameraTargetPositionY(), true)
else
return
end
end
end
function this.ActionFastBuilt(player)
Cheat("warpten")
Cheat("WHOISJOHNGALT")
end
function this.AddIds(id, idEnd, tasButList)
local rest = ModuloInteger(id, 256)
local digit00XX
-- easy to use variables for later
local bj_256power2 = 256 * 256
local bj_ZZ = 256 * 90 + 90
local bj_00 = 47 + 48 * 256
local bj_9Z = 256 * 57 + 90
local bj_A0 = 256 * 65 + 47
while id <= idEnd do
--Number 0 to 9 A to Z
if (rest >= 48 and rest <= 57 ) or (rest >= 65 and rest <= 90) then
--Instead of Debug you would have to add remove ability or create Items/Units.
--print(id..": "..GetObjectName(id))
if not this.CheckCustomObject or GetObjectName(id) ~= "" then
TasButtonListAddData(tasButList, id)
end
id = id + 1
rest = rest +1
--move 1 expo up and jump to 0
elseif rest > 90 then
digit00XX = ModuloInteger(id, bj_256power2)
-- 'ZZ', push 1 digit up.?
if digit00XX > bj_ZZ then
id = id + bj_256power2 - bj_ZZ + bj_00 --'00' has to be added.
--skip value between 'A09Z' and 'A0A0'?
elseif digit00XX > bj_9Z then
id = id + (bj_A0 - bj_9Z)
else
id = id + (256 - rest + 48)
end
rest = 48
--skip values between 9 and A
elseif rest > 57 then
id = id + (65 - rest)
rest = 65
end
end
return id
end
this.AnyAction = function()
local frame = BlzGetTriggerFrame()
local player = GetTriggerPlayer()
BlzFrameSetEnable(frame, false)
BlzFrameSetEnable(frame, true)
StopCamera()
print("Cheat",BlzFrameGetText(frame), GetPlayerName(player))
if this.ButtonAction[frame] then
if type(this.ButtonAction[frame]) == "function" then
this.ButtonAction[frame](player)
elseif type(this.ButtonAction[frame]) == "string" then
Cheat(this.ButtonAction[frame])
end
end
if this.ButtonActionGroup[frame] then
GroupEnumUnitsSelected(this.Group, player, nil)
ForGroup(this.Group, this.ButtonActionGroup[frame])
end
end
this.OpenAction = function()
BlzFrameSetVisible(BlzGetFrameByName("CheatFrame", 0), BlzGetTriggerFrameEvent() == FRAMEEVENT_CHECKBOX_CHECKED)
end
this.ShowPage = function(page)
for i, v in ipairs(this.ParentPage) do BlzFrameSetVisible(v, false) end
BlzFrameSetVisible(this.ParentPage[page], true)
if page == 5 then
print "Insert Lua code into the EditBox & press Enter/Return\nUdg_Unit is single selected Unit\nSupports CTRL V/C Pos1 end marking with shift"
end
end
local function TryCreateTooltp(frame, text)
if CreateSimpleTooltip and text then
CreateSimpleTooltip(frame, text)
end
end
this.AddButton = function(page, text, action, actionSelectedUnits, toolTipText)
local frame
local trig = CreateTrigger()
TriggerAddAction(trig, this.AnyAction)
this.ButtonCount[0] = this.ButtonCount[0] + 1
frame = BlzCreateFrameByType("GLUETEXTBUTTON", "CheatButton", this.ParentPage[page], "ScriptDialogButton", this.ButtonCount[0])
TryCreateTooltp(frame, toolTipText)
if this.ButtonCount[page] == 0 then
BlzFrameSetAbsPoint(frame, this.Pos, this.X, this.Y + 0.025)
else
BlzFrameSetPoint(frame, FRAMEPOINT_BOTTOM, BlzGetFrameByName("CheatButton", this.ButtonCount[page]), FRAMEPOINT_TOP, 0,0)
end
this.ButtonCount[page] = this.ButtonCount[0]
BlzTriggerRegisterFrameEvent(trig, frame, FRAMEEVENT_CONTROL_CLICK)
BlzFrameSetText(frame, text)
this.ButtonAction[frame] = action
this.ButtonActionGroup[frame] = actionSelectedUnits
end
this.InitFrames = function()
BlzLoadTOCFile(this.TemplatesToc)
this.Parent = BlzCreateFrameByType("FRAME", "CheatFrame", this.ParentFunc(), "", 0)
BlzFrameSetScale(this.Parent, this.Scale)
this.ParentPage[1] = BlzCreateFrameByType("FRAME", "CheatFramePageA", this.Parent, "", 0)
this.ParentPage[2] = BlzCreateFrameByType("FRAME", "CheatFramePageB", this.Parent, "", 0)
this.ParentPage[3] = BlzCreateFrameByType("FRAME", "CheatFramePageC", this.Parent, "", 0)
this.ParentPage[4] = BlzCreateFrameByType("FRAME", "CheatFramePageD", this.Parent, "", 0)
this.ParentPage[5] = BlzCreateFrameByType("FRAME", "CheatFramePageE", this.Parent, "", 0)
for i = 1, #this.ParentPage do
frame = BlzCreateFrameByType("GLUETEXTBUTTON", "CheatFramePageButton", this.Parent, "ScriptDialogButton", i)
BlzFrameSetSize(frame, 0.03, 0.03)
BlzFrameSetText(frame, i)
BlzFrameSetAbsPoint(frame, this.Pos, this.X - 0.035*i +0.035, this.Y)
local trig = CreateTrigger()
TriggerAddAction(trig, function()
this.ShowPage(i)
BlzFrameSetEnable(BlzGetTriggerFrame(), false)
BlzFrameSetEnable(BlzGetTriggerFrame(), true)
end)
BlzTriggerRegisterFrameEvent(trig, frame, FRAMEEVENT_CONTROL_CLICK)
TryCreateTooltp(frame, this.PageName[i])
end
BlzCreateFrame("EscMenuEditBoxTemplate", this.ParentPage[5], 0, 0)
TryCreateTooltp(BlzGetFrameByName("EscMenuEditBoxTemplate", 0), "executes Lua code|nudg_Unit is the current Selected Unit|n ctrl + v")
BlzFrameSetAbsPoint(BlzGetFrameByName("EscMenuEditBoxTemplate", 0), this.Pos, this.X, this.Y + 0.025)
BlzFrameSetSize(BlzGetFrameByName("EscMenuEditBoxTemplate", 0), 0.16, 0.032)
local trig = CreateTrigger()
TriggerAddAction(trig, function() xpcall(function() load(BlzFrameGetText(BlzGetTriggerFrame()))() end, print) end)
BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("EscMenuEditBoxTemplate", 0), FRAMEEVENT_EDITBOX_ENTER)
BlzFrameSetScale(BlzGetFrameByName("EscMenuEditBoxTemplate", 0), 1.1)
local frame = BlzCreateFrameByType("GLUECHECKBOX", "CheatCheckBox", this.ParentFunc(), "QuestCheckBox", 0)
BlzFrameSetAbsPoint(frame, this.OpenPos, this.OpenX, this.OpenY)
local trig = CreateTrigger()
TriggerAddAction(trig, this.OpenAction)
BlzTriggerRegisterFrameEvent(trig, frame, FRAMEEVENT_CHECKBOX_CHECKED)
BlzTriggerRegisterFrameEvent(trig, frame, FRAMEEVENT_CHECKBOX_UNCHECKED)
TryCreateTooltp(frame, "Show CheatBox?")
this.AddButton(1,"Kill", nil, this.ActionKill, "Kill Selected")
this.AddButton(2,"Victory", this.ActionVictory, "You win")
this.AddButton(1,"Teleport", nil, this.ActionTeleport, "Selected Units -> center of Screen")
this.AddButton(1,"Dispel", nil, this.ActionDispel, "Remove All Buffs Selected")
this.AddButton(1,"Clone", nil, this.ActionClone, "Create Copies of Selected")
this.AddButton(1,"MaxLevel", nil, this.ActionMaxLevel, "Max Hero Level")
this.AddButton(2,"Resources", "greedisgood 999999", nil, "Much Lumber & Golld")
this.AddButton(2,"Food", this.ActionFood0, nil, "Food used 0; Food cap Max")
this.AddButton(1,"Heal & Cooldown", nil, this.ActionHeal, "HP & MP & Cooldowns Selected")
this.AddButton(1,"(In)vul", nil, this.ActionInvul, "Toggle Invul Selected")
this.AddButton(2,"Vision", "ISEEDEADPEOPLE", nil, "Reveal all Map On/off")
this.AddButton(2,"Fast Built & Research", this.ActionFastBuilt)
this.AddButton(2,"Morning", "RISEANDSHINE", nil, "6h")
this.AddButton(2,"Evening", "LIGHTSOUT", nil, "18h")
this.AddButton(1,"Control", nil, this.ActionControl, "Selected is yours")
this.AddButton(2,"Revive", this.ActionRevive, nil, "Revive your Heroes, might need to repeat")
this.AddButton(1,"(Un)Pause", nil, this.ActionPause, "Toggle Pause state of Selected")
this.AddButton(2,"Pause All", this.ActionPauseAll, nil, "Pause all Units currently on the map")
this.AddButton(2,"UnPause All", this.ActionUnPauseAll, nil, "UnPause all Units currently on the map")
this.AddButton(2,"Defeat", this.ActionDefeatPlayer, nil, "Defeats the player owning the selected Unit")
if TasButtonList then
for pInt = 0, bj_MAX_PLAYER_SLOTS - 1 do
local colorButton = BlzCreateFrameByType("GLUEBUTTON", "UnitListPlayerColorButton", this.ParentPage[3], "IconicButtonTemplate", pInt)
BlzFrameSetSize(colorButton, 0.018, 0.018)
if pInt == 0 then
BlzFrameSetAbsPoint(colorButton, this.ListPos, this.ListX, this.ListY)
elseif pInt == 12 then
BlzFrameSetAbsPoint(colorButton, this.ListPos, this.ListX, this.ListY - 0.0182)
elseif pInt == 24 then
BlzFrameSetAbsPoint(colorButton, this.ListPos, this.ListX, this.ListY - 0.0364)
else
BlzFrameSetPoint(colorButton, FRAMEPOINT_RIGHT, BlzGetFrameByName("UnitListPlayerColorButton", pInt - 1), FRAMEPOINT_LEFT, -0.002, 0)
end
local icon = BlzCreateFrameByType("BACKDROP", "UnitListPlayerColorIcon", colorButton, "", pInt)
BlzFrameSetAllPoints(icon, colorButton)
local colorIndex = GetHandleId(GetPlayerColor(Player(pInt)))
if colorIndex < 10 then
BlzFrameSetTexture(icon, "ReplaceableTextures\\TeamColor\\TeamColor0"..colorIndex, 0, false)
else
BlzFrameSetTexture(icon, "ReplaceableTextures\\TeamColor\\TeamColor"..colorIndex, 0, false)
end
local trig = CreateTrigger()
TriggerAddAction(trig, function()
this.CurrentUnitOwner = pInt
BlzFrameSetPoint(this.SpriteFrame, FRAMEPOINT_BOTTOMLEFT, BlzGetTriggerFrame(), FRAMEPOINT_BOTTOMLEFT, -0.003, -0.003)
BlzFrameSetEnable(BlzGetTriggerFrame(), false)
BlzFrameSetEnable(BlzGetTriggerFrame(), true)
end)
BlzTriggerRegisterFrameEvent(trig, colorButton, FRAMEEVENT_CONTROL_CLICK)
end
local sprite = BlzCreateFrameByType("SPRITE", "UnitListPlayerColorSprite", this.ParentPage[3], "", 0)
BlzFrameSetModel(sprite, "ui\\feedback\\autocast\\ui-modalbuttonon.mdx", 0)
BlzFrameSetScale(sprite, 0.018/0.039)
BlzFrameSetSize(sprite, 0.001, 0.001)
BlzFrameSetPoint(sprite, FRAMEPOINT_BOTTOMLEFT, BlzGetFrameByName("UnitListPlayerColorButton", this.CurrentUnitOwner), FRAMEPOINT_BOTTOMLEFT, -0.003, -0.003)
this.SpriteFrame = sprite
this.UnitListFrame = BlzCreateFrameByType("FRAME", "", this.ParentPage[3], "",0)
BlzFrameSetSize(this.UnitListFrame, 0.23, 0.001)
BlzFrameSetScale(this.UnitListFrame, 1)
--BlzFrameSetAbsPoint(frameA, FRAMEPOINT_TOPRIGHT, 0.78, 0.54)
BlzFrameSetAbsPoint(this.UnitListFrame, this.ListPos, this.ListX, this.ListY - 0.06)
this.UnitList = CreateTasButtonListEx("TasButtonGrid", this.ListCols, this.LisRows, this.UnitListFrame, function(data, buttonListObject, dataIndex)
this.CurrentUnitCode = data
BlzSetSpecialEffectScale(this.PreviewItem, 0.00001)
BlzSetSpecialEffectScale(this.PreviewUnit, 1)
print "Left Click -> create\nother mouse clicks end it"
end)
for int = 1, this.ListCols*this.LisRows do
BlzFrameSetVisible(this.UnitList.Frames[int].TextLumber, false)
BlzFrameSetVisible(this.UnitList.Frames[int].TextGold, false)
BlzFrameSetVisible(this.UnitList.Frames[int].IconGold, false)
BlzFrameSetVisible(this.UnitList.Frames[int].IconLumber, false)
BlzFrameSetSize(this.UnitList.Frames[int].Button, 0.03, 0.0265)
BlzFrameSetScale(this.UnitList.Frames[int].Button, 1.5)
BlzFrameSetScale(this.UnitList.Frames[int].ToolTipFrame, 1.0)
end
BlzFrameSetPoint(this.UnitList.Frames[1].Button, FRAMEPOINT_TOPRIGHT, this.UnitList.InputFrame, FRAMEPOINT_BOTTOMRIGHT, -BlzFrameGetWidth(this.UnitList.Frames[1].Button)*(5-1)*0.5, 0)
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"
}
if this.IncludeDefaultUnits then
for _, k in ipairs(data) do
TasButtonListAddData(this.UnitList, k)
end
end
-- load in the custom Units
if this.IncludeCustomUnits then
for i, v in ipairs(this.CustomUnitCodes) do
this.AddIds(v[1], v[2],this.UnitList)
end
end
--force an update to the TasButtonList after removing/adding this should be done
BlzFrameSetValue(this.UnitList.Slider, 999999)
this.ItemListFrame = BlzCreateFrameByType("FRAME", "", this.ParentPage[4], "",0)
BlzFrameSetSize(this.ItemListFrame, 0.23, 0.001)
BlzFrameSetScale(this.ItemListFrame, 1)
--BlzFrameSetAbsPoint(frameA, FRAMEPOINT_TOPRIGHT, 0.78, 0.54)
BlzFrameSetAbsPoint(this.ItemListFrame, this.ListPos, this.ListX, this.ListY)
this.ItemList = CreateTasButtonListEx("TasButtonGrid", this.ListCols, this.LisRows, this.ItemListFrame, function(data, buttonListObject, dataIndex)
this.CurrentItemCode = data
BlzSetSpecialEffectScale(this.PreviewItem, 1)
BlzSetSpecialEffectScale(this.PreviewUnit, 0.0001)
print "Left Click -> create\nother mouse clicks end it"
end)
local data = {"ckng","modt","tkno","ratf","ofro","desc","fgdg","infs","shar","sand"
,"wild","srrc","odef","rde4","pmna","rhth","ssil","spsh","sres","pdiv","pres","totw"
,"fgfh","fgrd","fgrg","hcun","hval","mcou","ajen","clfm","ratc","war2","kpin","lgdh"
,"ankh","whwd","fgsk","wcyc","hlst","mnst","belv","bgst","ciri","lhst","afac","sbch"
,"brac","rwiz","pghe","pgma","pnvu","sror","woms","crys","evtl","penr","prvt","rat9"
,"rde3","rlif","bspd","rej3","will","wlsd","wswd","cnob","gcel","rat6","rde2","tdx2"
,"tin2","tpow","tst2","pnvl","clsd","rag1","rin1","rst1","manh","tdex","tint","tstr"
,"pomn","wshs","rej6","rej5","rej4","ram4","dsum","ofir","ocor","oli2","oven","ram3"
,"tret","tgrh","rej2","gemt","ram2","stel","stwp","wneg","sneg","wneu","shea","sman"
,"rej1","pspd","dust","ram1","pinv","phea","pman","spro","hslv","moon","shas","skul"
,"mcri","rnec","ritd","tsct","azhr","bzbe","bzbf","ches","cnhn","glsk","gopr","k3m1"
,"k3m2","k3m3","ktrm","kybl","kygh","kymn","kysn","ledg","phlt","sehr","engs","sorf"
,"gmfr","jpnt","shwd","skrt","thle","sclp","wtlg","wolg","mgtk","mort","dphe","dkfw"
,"dthb","fgun","lure","olig","amrc","ccmd","flag","gobm","gsou","nflg","nspi","oflg"
,"pams","pgin","rat3","rde0","rde1","rnsp","soul","tels","tgxp","uflg","anfg","brag"
,"drph","iwbr","jdrn","lnrn","mlst","oslo","sbok","sksh","sprn","tmmt","vddl","spre"
,"sfog","sor1","sor2","sor3","sor4","sor5","sor6","sor7","sor8","sor9","sora","fwss"
,"shtm","esaz","btst","tbsm","tfar","tlum","tbar","tbak","gldo","stre","horl","hbth"
,"blba","rugt","frhg","gvsm","crdt","arsc","scul","tmsc","dtsb","grsl","arsh","shdt"
,"shhn","shen","thdm","stpg","shrs","bfhr","cosl","shcw","srbd","frgd","envl","rump"
,"srtl","stwa","klmm","rots","axas","mnsf","schl","asbl","kgal","ward","gold","lmbr"
,"gfor","guvi","rspl","rre1","rre2","gomn","rsps","rspd","rman","rma2","rres","rreb"
,"rhe1","rhe2","rhe3","rdis","texp","rwat","pclr","plcl","silk","vamp","sreg","ssan","tcas","ofr2"
}
if this.IncludeDefaultItems then
for _, k in ipairs(data) do
TasButtonListAddData(this.ItemList, k)
end
end
for int = 1, this.ListCols*this.LisRows do
BlzFrameSetVisible(this.ItemList.Frames[int].TextLumber, false)
BlzFrameSetVisible(this.ItemList.Frames[int].TextGold, false)
BlzFrameSetVisible(this.ItemList.Frames[int].IconGold, false)
BlzFrameSetVisible(this.ItemList.Frames[int].IconLumber, false)
BlzFrameSetSize(this.ItemList.Frames[int].Button, 0.03, 0.0265)
BlzFrameSetScale(this.ItemList.Frames[int].Button, 1.5)
BlzFrameSetScale(this.ItemList.Frames[int].ToolTipFrame, 1.0)
end
BlzFrameSetPoint(this.ItemList.Frames[1].Button, FRAMEPOINT_TOPRIGHT, this.ItemList.InputFrame, FRAMEPOINT_BOTTOMRIGHT, -BlzFrameGetWidth(this.ItemList.Frames[1].Button)*(5-1)*0.5, 0)
if this.IncludeCustomItems then
this.AddIds(FourCC'I000', this.CustomItemEnd,this.ItemList)
end
BlzFrameSetValue(this.ItemList.Slider, 999999)
local trig = CreateTrigger()
TriggerAddAction(trig, function()
if BlzGetTriggerPlayerMouseButton() == MOUSE_BUTTON_TYPE_LEFT then
if this.CurrentUnitCode then
CreateUnit(Player(this.CurrentUnitOwner), this.CurrentUnitCode, BlzGetTriggerPlayerMouseX(), BlzGetTriggerPlayerMouseY(), 270)
elseif this.CurrentItemCode then
CreateItem(this.CurrentItemCode, BlzGetTriggerPlayerMouseX(), BlzGetTriggerPlayerMouseY())
end
else
BlzSetSpecialEffectScale(this.PreviewItem, 0.0001)
BlzSetSpecialEffectScale(this.PreviewUnit, 0.0001)
this.CurrentUnitCode = nil
this.CurrentItemCode = nil
end
end)
TriggerRegisterPlayerEvent(trig, GetLocalPlayer(), EVENT_PLAYER_MOUSE_DOWN)
else
BlzFrameSetVisible(BlzGetFrameByName("CheatFramePageButton", 3), false)
BlzFrameSetVisible(BlzGetFrameByName("CheatFramePageButton", 4), false)
end
this.ShowPage(1)
BlzFrameSetVisible(this.Parent, false)
print("init frames done")
end
this.Init = function()
this.Group = CreateGroup()
--local trig = CreateTrigger()
--TriggerAddAction(trig, this.SelectAction)
--TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SELECTED)
this.PreviewUnit = AddSpecialEffect("Objects\\InvalidObject\\InvalidObject.mdx", 0, 0)
this.PreviewItem = AddSpecialEffect("Objects\\InventoryItems\\TreasureChest\\treasurechest.mdx", 0, 0)
BlzSetSpecialEffectScale(this.PreviewItem, 0.0001)
BlzSetSpecialEffectScale(this.PreviewUnit, 0.0001)
local loc = Location(0, 0)
local trig = CreateTrigger()
TriggerAddAction(trig, function()
MoveLocation(loc, BlzGetTriggerPlayerMouseX(), BlzGetTriggerPlayerMouseY())
if this.CurrentUnitCode then
BlzSetSpecialEffectPosition(this.PreviewUnit, BlzGetTriggerPlayerMouseX(), BlzGetTriggerPlayerMouseY(), GetLocationZ(loc) + 56)
--BlzSetSpecialEffectHeight(this.PreviewUnit, GetLocationZ(loc) + 56)
elseif this.CurrentItemCode then
BlzSetSpecialEffectPosition(this.PreviewItem, BlzGetTriggerPlayerMouseX(), BlzGetTriggerPlayerMouseY(), GetLocationZ(loc) + 65)
--BlzSetSpecialEffectHeight(this.PreviewItem, GetLocationZ(loc) + 56)
end
end)
TriggerRegisterPlayerEvent(trig, GetLocalPlayer(), EVENT_PLAYER_MOUSE_MOVE)
local trig = CreateTrigger()
TriggerAddAction(trig, function()
udg_Unit = GetTriggerUnit()
end)
TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SELECTED)
xpcall(function() this.InitFrames() end, print)
if FrameLoaderAdd then FrameLoaderAdd(this.InitFrames) end
end
if this.AutoRun then
if OnInit then -- Total Initialization v5.2.0.1 by Bribe
OnInit.final(TasCheatBox.Init)
else -- without
local real = MarkGameStarted
function MarkGameStarted()
real()
TasCheatBox.Init()
end
end
end
end
--TasCheatBox.Init()