Name | Type | is_array | initial_value |
Icons | imagefile | Yes | |
Item | item | No | |
Texts | string | Yes | |
Unit | unit | No |
--[[ HoverOriginButton V1.4 by Tasyen
This System gives a easy way setup callbacks when a originframe Button is hovered. It uses Tooltips hence the executed callbacks are async.
I created this because one can do this Tooltip approach to know hovering only once per map so that systems don't have to fight over that feature but use it.
function HoverOriginButton.Add(originframeType, function(buttonIndex) end[, everyTime])
originframeType ORIGIN_FRAME_COMMAND_BUTTON or ORIGIN_FRAME_HERO_BUTTON ...
everyTime (false) only happens when the current Frame was not hovered lastTime.
action the callback
function(buttonIndex)
yourCode
yourCode
end
returns the new objects can be used for HoverOriginButton.Remove
function HoverOriginButton.AddClose(function() end)
add a callback that happens when the user stops hoveringer a Command/Item Button, async.
function()
yourCode
yourCode
end
function HoverOriginButton.Remove(object)
removes the table from the callback List
--]]
do
HoverOriginButton = {}
local SystemSpeed = 1/32.0 -- How Fast is the System
local this = HoverOriginButton
local function CreateTooltipForOrigin(originframeType, firstIndex, lastIndex)
for int = firstIndex, lastIndex do
local button = BlzGetOriginFrame(originframeType, int)
local frame = BlzCreateFrameByType("SIMPLEFRAME", "", button, "", 0)
BlzFrameSetTooltip(button, frame)
BlzFrameSetVisible(frame, false)
this[frame] = {originframeType, int}
table.insert(this.Frames, frame)
end
end
local function CreateTooltipForBuffs(firstIndex, lastIndex)
if ORIGIN_FRAME_UNIT_PANEL_BUFF_BAR then
local parent = BlzGetOriginFrame(ORIGIN_FRAME_UNIT_PANEL_BUFF_BAR, 0)
for int = firstIndex, lastIndex do
local button = BlzFrameGetChild(parent, int)
local frame = BlzCreateFrameByType("SIMPLEFRAME", "", button, "", 0)
BlzFrameSetTooltip(button, frame)
BlzFrameSetVisible(frame, false)
this[frame] = {ORIGIN_FRAME_UNIT_PANEL_BUFF_BAR, int}
table.insert(this.Frames, frame)
end
end
end
local function InitFrames()
this.Frames = {}
local frame, button, CurrentSelectedButtonIndex, selectedAnything
CreateTooltipForOrigin(ORIGIN_FRAME_COMMAND_BUTTON, 0, 11)
CreateTooltipForOrigin(ORIGIN_FRAME_ITEM_BUTTON, 0, 5)
CreateTooltipForOrigin(ORIGIN_FRAME_HERO_BUTTON, 0, 6)
CreateTooltipForOrigin(ORIGIN_FRAME_SYSTEM_BUTTON, 0, 3)
CreateTooltipForOrigin(ORIGIN_FRAME_MINIMAP_BUTTON, 0, 4)
CreateTooltipForBuffs(0, 7)
button = nil
frame = nil
-- saves the last selected Button, async
CurrentSelectedButtonIndex = nil
TimerStart(this.Timer, SystemSpeed, true, function()
selectedAnything = false
-- loop all tooltips and check for the visible one
for tooltipIndex, tooltip in ipairs(this.Frames) do
if BlzFrameIsVisible(tooltip) then
selectedAnything = true
local actionType = this[tooltip][1]
local buttonIndex = this[tooltip][2]
-- the new selected is not the same as the current one?
if this.Actions[actionType] then
for _, v in ipairs(this.Actions[actionType]) do
if CurrentSelectedButtonIndex ~= tooltipIndex or v[2] then
v[1](buttonIndex)
end
end
end
CurrentSelectedButtonIndex = tooltipIndex
end
end
-- now selects nothing?
if not selectedAnything and CurrentSelectedButtonIndex then
for _, v in ipairs(this.ActionsClose) do v[1]() end
CurrentSelectedButtonIndex = nil
end
end)
end
local function Init()
this.Timer = CreateTimer()
InitFrames()
if FrameLoaderAdd then FrameLoaderAdd(InitFrames) end
this.Actions = {}
this.ActionsClose = {}
end
function HoverOriginButton.Add(originframeType, action, everyTime)
if not this.Timer then Init() end
if not everyTime then everyTime = false end
local object = {action, everyTime}
if not originframeType then originframeType = ORIGIN_FRAME_COMMAND_BUTTON end
if not this.Actions[originframeType] then this.Actions[originframeType] = {} end
table.insert(this.Actions[originframeType], object)
return object
end
function HoverOriginButton.AddClose(action)
if not this.Timer then Init() end
local object = {action}
table.insert(this.ActionsClose, object)
return object
end
function HoverOriginButton.Remove(object)
for _, actions in pairs(this.Actions) do
for i, v in ipairs(actions) do
if v == object then
table.remove(actions, i)
return
end
end
end
for i, v in ipairs(this.ActionsClose) do
if v == object then
table.remove(this.ActionsClose, i)
return
end
end
end
end
--[[ TasToolTipBox V8c by Tasyen
An additional TooltipBox for buttons in the command card/inventory which displays MissileSpeed, Cooldown, Range & Area values
changes position of ORIGIN_FRAME_UBERTOOLTIP
function TasToolTipBox.AddData(array, unitCode, objectCode)
Tell the TasToolTipBox that units of unitTypeId UnitCode have objectCode inside array. This is needed for BuiltMenu, LearnMenu & Selling/Training.
array should be one of the TasTooltipBox dataSets:
TasToolTipBox.DataBuilt
TasToolTipBox.DataLearn
TasToolTipBox.DataDefault
unitCode is the unitTypeId of the unit using this data.
objectCode is one RawCode in a string or a number 'Hpal'.
uses x/y coords of objectCode, therefore with colisions you get unwanted results
function TasToolTipBox.AddDataBatch(array, unitCode, objectCodeString)
uses TasToolTipBox.AddData with many rawCodes at once.
TasToolTipBox.AddDataBatch(TasToolTipBox.DataBuilt, 'hpea', "htow,hhou,hbar,hbla,hwtw,halt,harm,hars,hlum,hgra,hvlt")
TasToolTipBox.AddDataBatch(TasToolTipBox.DataDefault, 'htow', "hpea,Rhpm,hkee")
to get this string open the unit in object editor navigate to the field hold shift press enter which opens the field in text input, copy paste it.
function TasToolTipBox.SetObjectSlot(objectCode, slotIndex, text, icon)
objectCode can be an item
SlotIndex shows Text & Icon when ObjectCode is hovered.
SlotIndex is -InTooltipInfoCount to InfoCount, 0 is not used.
0 to InfoCount - 1 are in the custom UI
-SlotIndex are next to the normal resource costs.
ObjectCode is the rawCode of an ObjectEditor object.
This only works for data added with TasToolTipBox.AddData/TasToolTipBox.AddDataBatch.
This should be called outside of the action call backs like at map init or 0s.
example: TasToolTipBox.SetObjectSlot('hpea', 3, "120", "ReplaceableTextures/CommandButtons/BTNBrilliance.tga")
When a command button is hovered that holds Human worker in DataBuilt DataLearn or DataDefault. Then it slot 3 will diplsay 120 and the Aura Icon
text & icon can be string or table. As table it reads either table[item] or table[GetItemUserData(item)], depends on the setup ArrayUseUserData
function TasToolTipBox.ClearObjectSlot(objectCode)
clear data stored at objectCode placed over TasToolTipBox.SetObjectSlot
you could do this when an item is destroyed/removed
function TasToolTipBox.SetUnitData(unit, buttonIndex, slotIndex, text, icon)
sets custom wanted data for an unit for that buttonIndex.
buttonIndex is 0 to 11 for command buttonIndexes.
buttonIndex can be a spellCode like 'AHbz' then the buttonIndex is calced from the data.
slotIndex like TasToolTipBox.SetObjectSlot
text & icon can be string or table. As table it reads table[unit] or table[GetUnitUserData(unit)], depends on the setup ArrayUseUserData
function TasToolTipBox.ClearUnitData(unit[, buttonIndex])
removes data of unit without buttonIndex all is removed
This is automaticly used for not heroes when they die.
works incorrect when multiple skills use 1 slot in the command card
works incorrect in group selection
works incorrect with spellbooks
requires BlzGetAbilityId for skills with more than 1 level (not Warcraft V1.31.1)
requires HoverOriginButton
]]
do
TasToolTipBox = {
--config start
TocPath = "war3mapImported\\TasToolTipBox.toc"
,AutoRun = true --(true) will create Itself at 0s, (false) you need to TasToolTipBox.Init()
,ArrayUseUserData = true -- when an array/table is provided as text/icon (true) it reads text[GetUnitUserData(unit)] (false ) read text[unit]
,ParentFunc = function() return BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0) end -- should not be simple, called when TasToolTipBox is created the returned frame is used as parent
,Hide0Text = true -- hide a Slot when the displayed Text would be 0/0s/0.0s
,InfoCount = 5 -- how many Infos you want, every 4 are one row
,InTooltipInfoCount = 3 -- how many additional slots next to the default ResourceCost slots
,FixedPos = false -- true default tooltip pos does not change when TasToolTipBox is not shown
,ExcludSlots = {[7] = true} -- the buttonIndexes set, are not used in the auto ability detection -> this.ActionSpell; [7] = true -> ignore command button 7, 0 is the Top Left button 11 the bottom right
,Icon = { -- filePaths used for the icons, Indexes should fit the data used in this.ActionXxxx functions
"replaceabletextures/passivebuttons/pasbtntrueshot"
,"ui/widgets/battlenet/bnet-tournament-clock"
,"replaceabletextures/commandbuttons/btnload"
,"replaceabletextures/selection/spellareaofeffect_undead"
,"replaceabletextures/commandbuttons/btnreplay-speedup"
,"UI/Widgets/ToolTips/Human/ToolTipManaIcon"
}
,FilterItemSkills = true -- true items are never in the command card in your map
,EnableSubMenu = true -- true creates events/timer; changing it after the Init run is not supported/recommented.
,YPos = 0.17
,NoFDF = false -- only affects InTooltipInfoCount, true dont need the fdf. should also change InfoCount to 0.
--
-- manual stored data Display Actions
--
---@param buttonIndex integer active commandButton Index
---@param data type manual stored Data at buttonIndex for Learning
---@param unit unit active unit
---@param unitCode integer of unit
---@return boolean use/show the custom UI
,ActionSubMenuHero = function(buttonIndex, data, unit, unitCode)
-- requires EnableSubMenu
-- inside hero skill menu
--BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 1), GetObjectName(data))
TasToolTipBox.ShowObjectSlot(data) -- Show Content for TasToolTipBox.SetObjectSlot
return true
end
,ActionSubMenuBuilt = function(buttonIndex, data, unit, unitCode)
-- requires EnableSubMenu
-- inside built menu
--BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 1), GetObjectName(data))
TasToolTipBox.ShowObjectSlot(data) -- Show Content for TasToolTipBox.SetObjectSlot
return true
end
,ActionDefaultData = function(buttonIndex, data, unit, unitCode)
-- mostly meant for shops/trainers
--BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 1), GetObjectName(data))
TasToolTipBox.ShowObjectSlot(data) -- Show Content for TasToolTipBox.SetObjectSlot
TasToolTipBox.ShowUnitData(unit, buttonIndex)
return true
end
--
-- autoDetect Actions
--
---@param buttonIndex integer active commandButton Index
---@param abi ability ability that uses the button
---@param abiCode integer rawCode of abi requires BlzGetAbilityId
---@param unit unit active unit
---@param unitCode integer of unit
---@param level integer abi index for abilityInstance api requires BlzGetAbilityId
---@return boolean use/show the custom UI
,ActionSpell = function(buttonIndex, abi, unit, abiCode, level, unitCode)
-- displayed data in autoDetect ability
BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 1), BlzGetAbilityIntegerField(abi, ABILITY_IF_MISSILE_SPEED))
BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 2), R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_COOLDOWN, level)).."s")
BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 3), R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_CAST_RANGE, level)))
BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 4), R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_AREA_OF_EFFECT, level)))
BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 5), BlzGetAbilityRealLevelField(abi, ABILITY_RLF_CASTING_TIME, level).."s")
TasToolTipBox.ShowObjectSlot(abiCode) -- Show Content for TasToolTipBox.SetObjectSlot
TasToolTipBox.ShowUnitData(unit, buttonIndex)
--BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 6), BlzGetAbilityIntegerLevelField(abi, ABILITY_ILF_MANA_COST, level))
return true
end
,ActionItemSpell = function(buttonIndex, abi, unit, abiCode, level, unitCode, item)
-- displayed data autoDetect inventoryButton-ability
BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 1), BlzGetAbilityIntegerField(abi, ABILITY_IF_MISSILE_SPEED))
BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 2), R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_COOLDOWN, level)).."s")
BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 3), R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_CAST_RANGE, level)))
BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 4), R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_AREA_OF_EFFECT, level)))
BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 5), BlzGetAbilityRealLevelField(abi, ABILITY_RLF_CASTING_TIME, level).."s")
TasToolTipBox.ShowObjectSlot(abiCode) -- Show Content for TasToolTipBox.SetObjectSlot
TasToolTipBox.ShowObjectSlot(item)
--BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 6), BlzGetAbilityIntegerLevelField(abi, ABILITY_ILF_MANA_COST, level))
return true
end
-- config ende
-- System Stuff
,DataBuilt = {} -- Manual insert data in worker built submenu; expects TasToolTipBox.DataBuilt[unitCode][0 to 10] Use TasToolTipBox.AddDataBatch to fill it
,DataLearn = {} -- ^^ for submenu Hero Learn
,DataDefault = {} -- ^^ manual data outside of sub menues like train unit research sell items
,DataObject = {} -- What to displays in the slots for objects when they are hovered
,DataUnit = {} -- displays in slots for living units DataUnit[unit][buttonIndex][slotIndex] = {text, icon}
,EventCount = -1
,TimerUnit = -1
,LastAction = -1
,TimerCount = -1
}
local this = TasToolTipBox
this.CountCommandButtons = function()
local count = 0
for i = 0,11 do
if BlzFrameIsVisible(BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, i)) then
count = count + 1
end
end
return count
end
this.ResetDisplay = function()
if not this.FixedPos and this.SizeX then BlzFrameSetSize(BlzGetFrameByName("TasTooltipBox", 0), this.SizeX, 0.0001) end
BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBox", 0), false)
BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBoxInsideParent", 0), false)
local scale = BlzFrameGetWidth(BlzGetFrameByName("ConsoleUIBackdrop", 0))/0.8
if scale > 0.1 then
BlzFrameSetScale(BlzGetFrameByName("TasTooltipBox", 0), scale)
BlzFrameSetScale(BlzGetFrameByName("TasTooltipBoxInsideParent", 0), scale)
end
for i = -this.InTooltipInfoCount, this.InfoCount do
BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", i), "0")
if this.Icon[i] then BlzFrameSetTexture(BlzGetFrameByName("TasTooltipBoxInfoIcon", i), this.Icon[i], 0, true) end
end
end
this.AddData = function(array, unitCode, objectCode)
if not array[unitCode] then array[unitCode] = {} end
if type(unitCode) == "string" then unitCode = FourCC(unitCode) end
if type(objectCode) == "string" then objectCode = FourCC(objectCode) end
local coord = BlzGetAbilityPosX(objectCode)+4*BlzGetAbilityPosY(objectCode)
if array == this.DataLearn then
-- learning Get Learn x/YPos is not a thing so just put it at first found slot
for i=0, 11 do
if not array[unitCode][i] then array[unitCode][i] = objectCode break end
end
elseif coord >= 0 then
array[unitCode][coord] = objectCode
end
end
this.AddDataBatch = function(array, unitCode, objectCodeString)
if not array[unitCode] then array[unitCode] = {} end
if type(unitCode) == "string" then unitCode = FourCC(unitCode) end
local startIndex = 1
local skillCode
while startIndex + 3 <= string.len(objectCodeString) do
skillCode = string.sub(objectCodeString, startIndex, startIndex + 3)
startIndex = startIndex + 5
skillCode = FourCC(skillCode)
this.AddData(array, unitCode, skillCode)
end
end
this.ClearUnitData = function(unit, buttonIndex)
if not buttonIndex then this.DataUnit[unit] = nil return end
this.DataUnit[unit][buttonIndex] = nil
end
this.SetUnitData = function(unit, buttonIndex, slotIndex, text, icon)
if not unit then BJDebugMsg("TasToolTipBox - Error - SetUnitData arg #1 nil") print(unit, buttonIndex, slotIndex, text, icon) return end
if not this.DataUnit[unit] then this.DataUnit[unit] = {} end
-- convert RawCode from a spell into a coord
if type(buttonIndex) == "string" then buttonIndex = FourCC(buttonIndex) end
if buttonIndex >= 12 then buttonIndex = BlzGetAbilityPosX(buttonIndex)+4*BlzGetAbilityPosY(buttonIndex) end
if not this.DataUnit[unit][buttonIndex] then this.DataUnit[unit][buttonIndex] = {} end
if not this.DataUnit[unit][buttonIndex][slotIndex] then this.DataUnit[unit][buttonIndex][slotIndex] = {} end
this.DataUnit[unit][buttonIndex][slotIndex][1] = text
this.DataUnit[unit][buttonIndex][slotIndex][2] = icon
end
this.ShowUnitData = function(unit, buttonIndex)
if not this.DataUnit[unit] then return end
if not this.DataUnit[unit][buttonIndex] then return end
BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBoxInsideParent", 0), true)
local text, icon
for i = -this.InTooltipInfoCount, this.InfoCount do
if this.DataUnit[unit][buttonIndex][i] then
text = this.DataUnit[unit][buttonIndex][i][1]
icon = this.DataUnit[unit][buttonIndex][i][2]
if type(text) == "table" then
if this.ArrayUseUserData then text = text[GetUnitUserData(unit)]
else text = text[unit] end
end
if type(icon) == "table" then
if this.ArrayUseUserData then icon = icon[GetUnitUserData(unit)]
else icon = icon[unit] end
end
BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", i), text)
BlzFrameSetTexture(BlzGetFrameByName("TasTooltipBoxInfoIcon", i), icon, 0, true)
end
end
end
this.ClearObjectSlot = function(item)
this.DataObject[item] = nil
end
this.ShowObjectSlot = function(objectCode)
if not objectCode then return end
if type(objectCode) == "number" and objectCode <= 0 then return end
if not this.DataObject[objectCode] then return end
BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBoxInsideParent", 0), true)
local text, icon
for i = -this.InTooltipInfoCount, this.InfoCount do
if this.DataObject[objectCode][i] then
text = this.DataObject[objectCode][i][1]
icon = this.DataObject[objectCode][i][2]
if type(text) == "table" then
if this.ArrayUseUserData then text = text[GetItemUserData(objectCode)]
else text = text[objectCode] end
end
if type(icon) == "table" then
if this.ArrayUseUserData then icon = icon[GetItemUserData(objectCode)]
else icon = icon[objectCode] end
end
BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", i), text)
BlzFrameSetTexture(BlzGetFrameByName("TasTooltipBoxInfoIcon", i), icon, 0, true)
end
end
end
this.SetObjectSlot = function(objectCode, slotIndex, text, icon)
if not objectCode then BJDebugMsg("TasToolTipBox - Error - SetObjectSlot arg #1 nil") print(objectCode, slotIndex, text, icon) return end
if type(objectCode) == "string" then objectCode = FourCC(objectCode) end
if not this.DataObject[objectCode] then this.DataObject[objectCode] = {} end
if not this.DataObject[objectCode][slotIndex] then this.DataObject[objectCode][slotIndex] = {} end
this.DataObject[objectCode][slotIndex][1] = text
this.DataObject[objectCode][slotIndex][2] = icon
end
this.UpdateShowInfos = function(found)
--local slotInUseCount = 0
local showBox = false
local showBoxInside = false
local endIndex = 0
if found then endIndex = this.InfoCount end
if this.Hide0Text then
for i = -this.InTooltipInfoCount, endIndex do
local text = BlzFrameGetText(BlzGetFrameByName("TasTooltipBoxInfoText", i))
local show = not (text == "0" or text == "0s" or text == "0.0s")
BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBoxInfo", i) , show)
if show then
if found and not showBox and i > 0 then showBox = true end
if i < 0 then showBoxInside = true end
--slotInUseCount = slotInUseCount + 1
end
end
end
if found and showBox and not this.FixedPos then BlzFrameSetSize(BlzGetFrameByName("TasTooltipBox", 0), this.SizeX, this.SizeY) end
BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBoxInsideParent", 0), showBoxInside)
BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBox", 0), found and showBox)
end
local currentAction
this.StartUI = function(buttonIndex)
local unit = this[GetLocalPlayer()]
local unitCode = GetUnitTypeId(unit)
local level
local i = 0
local abi, abiCode
local found = false
-- reset currentAction?
if currentAction and this.EventCount ~= this.CountCommandButtons() then
currentAction = nil
end
this.ResetDisplay()
if currentAction == EVENT_GAME_BUILD_SUBMENU then
if this.DataBuilt[unitCode] then
if this.DataBuilt[unitCode][buttonIndex] then
found = this.ActionSubMenuBuilt(buttonIndex, this.DataBuilt[unitCode][buttonIndex], unit, unitCode)
end
end
elseif currentAction == EVENT_GAME_SHOW_SKILL then
if this.DataLearn[unitCode] then
if this.DataLearn[unitCode][buttonIndex] then
found = this.ActionSubMenuHero(buttonIndex, this.DataLearn[unitCode][buttonIndex], unit, unitCode)
end
end
end
if not currentAction and not found then
-- have manual data for default menu and this unitCode?
if this.DataDefault[unitCode] then
if this.DataDefault[unitCode][buttonIndex] then
found = this.ActionDefaultData(buttonIndex, this.DataDefault[unitCode][buttonIndex], unit, unitCode)
end
end
if not found then
-- dont use the first 5 buttons and ignore wanted slots
if buttonIndex < 5 or this.ExcludSlots[buttonIndex] then unit = nil return end
while true do
abi = BlzGetUnitAbilityByIndex(unit, i)
if not abi then break end
if (not this.FilterItemSkills or not BlzGetAbilityBooleanField(abi, ABILITY_BF_ITEM_ABILITY)) and BlzGetAbilityIntegerField(abi, ABILITY_IF_BUTTON_POSITION_NORMAL_X)+BlzGetAbilityIntegerField(abi, ABILITY_IF_BUTTON_POSITION_NORMAL_Y)*4 == buttonIndex then
level = 0
if BlzGetAbilityId then
abiCode = BlzGetAbilityId(abi)
level = GetUnitAbilityLevel(unit, abiCode) - 1
end
found = this.ActionSpell(buttonIndex, abi, unit, abiCode, level, unitCode)
break
end
i = i + 1
end
end
end
this.UpdateShowInfos(found)
abi = nil
unit = nil
end
this.StartUIItem = function(buttonIndex)
local unit = this[GetLocalPlayer()]
local level
local abi, abiCode
local found = false
local item = UnitItemInSlot(unit, buttonIndex)
this.ResetDisplay()
if GetItemTypeId(item) > 0 then
-- index 0 is the active skill in a correct setuped item
abi = BlzGetItemAbilityByIndex(item, 0)
if GetHandleId(abi) > 0 then
level = 0
if BlzGetAbilityId then
abiCode = BlzGetAbilityId(abi)
level = GetUnitAbilityLevel(unit, abiCode) - 1
end
found = this.ActionItemSpell(buttonIndex, abi, unit, abiCode, level, unitCode, item)
end
end
this.UpdateShowInfos(found)
abi = nil
unit = nil
item = nil
end
this.endUI = function()
this.ResetDisplay()
end
this.InitDo = function()
BlzLoadTOCFile(this.TocPath)
-- reserve HandleId to allow async access later
BlzGetFrameByName("ConsoleUIBackdrop", 0)
local orgTooltip = BlzGetOriginFrame(ORIGIN_FRAME_UBERTOOLTIP, 0)
local superParent = BlzCreateFrameByType("FRAME", "TasTooltipBoxParent", this.ParentFunc(), "", 0)
local parent = BlzCreateFrame("TasTooltipBox", superParent, 0, 0)
local parent2 = BlzCreateFrameByType("FRAME", "TasTooltipBoxInsideParent", superParent, "", 0)
local frame, prev
local colRemain = 5
local rows = 1
for i = 1, this.InfoCount do
frame = BlzCreateFrame("TasTooltipBoxInfo", parent, 0, i)
if GetHandleId(frame) == 0 then BJDebugMsg("TasToolTipBox - Error - Can not Create Frame\nCheck for Imported Toc & fdf File") end
BlzGetFrameByName("TasTooltipBoxInfo", i)
BlzGetFrameByName("TasTooltipBoxInfoIcon", i)
BlzGetFrameByName("TasTooltipBoxInfoText", i)
colRemain = colRemain - 1
if i == 1 then BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, parent, FRAMEPOINT_TOPLEFT, 0.006, -0.006)
elseif colRemain <= 0 then
rows = rows + 1
colRemain = 4
BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, BlzGetFrameByName("TasTooltipBoxInfo", i - 4), FRAMEPOINT_BOTTOMLEFT, 0, -0.006)
else BlzFrameSetPoint(frame, FRAMEPOINT_LEFT, prev, FRAMEPOINT_RIGHT, 0.006, 0) end
prev = frame
end
prev = nil
for i = -1, -this.InTooltipInfoCount,-1 do
if this.NoFDF then
frame = BlzCreateFrameByType("FRAME", "TasTooltipBoxInfo", parent2, "", i)
BlzFrameSetSize(frame, 0.06, 0.015)
local icon = BlzCreateFrameByType("BACKDROP", "TasTooltipBoxInfoIcon", frame, "", i)
local text = BlzCreateFrameByType("TEXT", "TasTooltipBoxInfoText", frame, "", i)
BlzFrameSetSize(icon, 0.015, 0.015)
BlzFrameSetPoint(icon, FRAMEPOINT_LEFT, frame, FRAMEPOINT_LEFT, 0, 0)
BlzFrameSetPoint(text, FRAMEPOINT_LEFT, icon, FRAMEPOINT_RIGHT, 0.001, 0)
BlzFrameSetPoint(text, FRAMEPOINT_RIGHT, frame, FRAMEPOINT_RIGHT, -0.005, 0)
else
frame = BlzCreateFrame("TasTooltipBoxInfo", parent2, 0, i)
BlzGetFrameByName("TasTooltipBoxInfo", i)
BlzGetFrameByName("TasTooltipBoxInfoIcon", i)
BlzGetFrameByName("TasTooltipBoxInfoText", i)
end
if prev then
BlzFrameSetPoint(frame, FRAMEPOINT_RIGHT, prev, FRAMEPOINT_LEFT, -0.00, 0)
else
BlzFrameSetPoint(frame, FRAMEPOINT_TOPRIGHT, orgTooltip, FRAMEPOINT_TOPRIGHT, -0.00, -0.017)
end
prev = frame
end
BlzGetFrameByName("TasTooltipBoxInfo", 0)
BlzGetFrameByName("TasTooltipBoxInfoIcon", 0)
BlzGetFrameByName("TasTooltipBoxInfoText", 0)
this.ResetDisplay()
this.SizeY = BlzFrameGetHeight(frame)*rows+ (rows-1)*0.006 + 0.011
this.SizeX = BlzFrameGetWidth(orgTooltip)
local ySize = this.SizeY
if not this.FixedPos then ySize = 0.0001 end
BlzFrameSetSize(parent, this.SizeX, ySize)
BlzFrameSetPoint(orgTooltip, FRAMEPOINT_BOTTOMRIGHT, parent, FRAMEPOINT_TOPRIGHT, 0, 0.002)
BlzFrameSetAbsPoint(parent, FRAMEPOINT_BOTTOMRIGHT, 0.795, this.YPos)
--BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBoxInfo", 1), false)
BlzFrameSetVisible(parent, false)
BlzFrameSetVisible(parent2, false)
end
this.Init = function()
this.InitDo()
if FrameLoaderAdd then FrameLoaderAdd(this.InitDo) end
if not HoverOriginButton then BJDebugMsg("TasToolTipBox - Error - HoverOriginButton is missing") return end
HoverOriginButton.Add(ORIGIN_FRAME_COMMAND_BUTTON, this.StartUI)
HoverOriginButton.Add(ORIGIN_FRAME_ITEM_BUTTON, this.StartUIItem)
HoverOriginButton.AddClose(this.endUI)
local trig = CreateTrigger()
TriggerAddAction(trig, function()
this[GetTriggerPlayer()] = GetTriggerUnit()
end)
TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SELECTED)
trig = CreateTrigger()
TriggerAddAction(trig, function()
if not IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) then
this.ClearUnitData(GetTriggerUnit())
end
end)
TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_DEATH)
if this.EnableSubMenu then
trig = CreateTrigger()
TriggerAddAction(trig, function()
-- when the buttons changed since the last timeOut but is still the same unit then the local player has most likely opened a submenu
-- filter the case with 1 only button that is most likely targeting/placing
--print("Skill")
--print("Hero", GetTriggerPlayer(), GetPlayerId(GetTriggerPlayer()), GetTriggerUnit(), GetUnitName(GetTriggerUnit()))
local count = this.CountCommandButtons()
if (this.TimerCountChanged or count ~= this.TimerCount) and count > 1 and GetHandleId(this[GetLocalPlayer()]) == this.TimerUnit then
--print("Skill Accept")
currentAction = EVENT_GAME_SHOW_SKILL
this.EventCount = count
this.TimerCount = count
end
end)
TriggerRegisterShowSkillEventBJ(trig)
trig = CreateTrigger()
TriggerAddAction(trig, function()
-- when the buttons changed since the last timeOut but is still the same unit then the local player has most likely opened a submenu
-- filter the case with 1 only button that is most likely targeting/placing
--print("Build", GetTriggerPlayer(), GetPlayerId(GetTriggerPlayer()), GetTriggerUnit(), GetUnitName(GetTriggerUnit()))
local count = this.CountCommandButtons()
--print("LastCount",this.TimerCount, "Count", count, "Units", GetHandleId(this[GetLocalPlayer()]),this.TimerUnit)
if (this.TimerCountChanged or count ~= this.TimerCount) and count > 1 and GetHandleId(this[GetLocalPlayer()]) == this.TimerUnit then
--print("Built Accept")
currentAction = EVENT_GAME_BUILD_SUBMENU
this.EventCount = count
this.TimerCount = count
end
end)
TriggerRegisterBuildSubmenuEventBJ(trig)
TimerStart(CreateTimer(), 0.2, true, function()
-- remember the last unitHandle buttonCount and remember if it changed
-- dont be to fast
local count = this.CountCommandButtons()
this.TimerCountChanged = count ~= this.TimerCount
this.TimerCount = this.CountCommandButtons()
this.TimerUnit = GetHandleId(this[GetLocalPlayer()])
--print(this.TimerCount)
end)
end
this.CountCommandButtons()
end
if this.AutoRun then
if OnInit then -- Total Initialization v5.2.0.1 by Bribe
OnInit.final(this.Init)
else -- without
local real = MarkGameStarted
function MarkGameStarted()
real()
this.Init()
end
end
end
end
library Ascii /* v1.1.0.0 TheDamian/Nestharus
************************************************************************************
*
* function Char2Ascii takes string s returns integer
* integer ascii = Char2Ascii("F")
*
* function Ascii2Char takes integer a returns string
* string char = Ascii2Char('F')
*
* function A2S takes integer a returns string
* string rawcode = A2S('CODE')
*
* function S2A takes string s returns integer
* integer rawcode = S2A("CODE")
*
************************************************************************************/
globals
private integer array i //hash
private integer array h //hash2
private integer array y //hash3
private string array c //char
endglobals
function Char2Ascii takes string p returns integer
local integer z = i[StringHash(p)/0x1F0748+0x40D]
if (c[z] != p) then
if (c[z - 32] != p) then
if (c[h[z]] != p) then
if (c[y[z]] != p) then
if (c[83] != p) then
debug call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"ASCII ERROR: INVALID CHARACTER: " + p)
return 0
endif
return 83
endif
return y[z]
endif
return h[z]
endif
return z - 32
endif
return z
endfunction
function Ascii2Char takes integer a returns string
return c[a]
endfunction
function A2S takes integer a returns string
local string s=""
loop
set s=c[a-a/256*256]+s
set a=a/256
exitwhen 0==a
endloop
return s
endfunction
function S2A takes string s returns integer
local integer a=0
local integer l=StringLength(s)
local integer j=0
local string m
local integer h
loop
exitwhen j==l
set a = a*256 + Char2Ascii(SubString(s,j,j+1))
set j=j+1
endloop
return a
endfunction
private module Init
private static method onInit takes nothing returns nothing
set i[966] = 8
set i[1110] = 9
set i[1621] = 10
set i[1375] = 12
set i[447] = 13
set i[233] = 32
set i[2014] = 33
set i[1348] = 34
set i[1038] = 35
set i[1299] = 36
set i[1018] = 37
set i[1312] = 38
set i[341] = 39
set i[939] = 40
set i[969] = 41
set i[952] = 42
set i[2007] = 43
set i[1415] = 44
set i[2020] = 45
set i[904] = 46
set i[1941] = 47
set i[918] = 48
set i[1593] = 49
set i[719] = 50
set i[617] = 51
set i[703] = 52
set i[573] = 53
set i[707] = 54
set i[1208] = 55
set i[106] = 56
set i[312] = 57
set i[124] = 58
set i[1176] = 59
set i[74] = 60
set i[1206] = 61
set i[86] = 62
set i[340] = 63
set i[35] = 64
set i[257] = 65
set i[213] = 66
set i[271] = 67
set i[219] = 68
set i[1330] = 69
set i[1425] = 70
set i[1311] = 71
set i[238] = 72
set i[1349] = 73
set i[244] = 74
set i[1350] = 75
set i[205] = 76
set i[1392] = 77
set i[1378] = 78
set i[1432] = 79
set i[1455] = 80
set i[1454] = 81
set i[1431] = 82
set i[1409] = 83
set i[1442] = 84
set i[534] = 85
set i[1500] = 86
set i[771] = 87
set i[324] = 88
set i[1021] = 89
set i[73] = 90
set i[1265] = 91
set i[1941] = 92
set i[1671] = 93
set i[1451] = 94
set i[1952] = 95
set i[252] = 96
set i[257] = 97
set i[213] = 98
set i[271] = 99
set i[219] = 100
set i[1330] = 101
set i[1425] = 102
set i[1311] = 103
set i[238] = 104
set i[1349] = 105
set i[244] = 106
set i[1350] = 107
set i[205] = 108
set i[1392] = 109
set i[1378] = 110
set i[1432] = 111
set i[1455] = 112
set i[1454] = 113
set i[1431] = 114
set i[1409] = 115
set i[1442] = 116
set i[534] = 117
set i[1500] = 118
set i[771] = 119
set i[324] = 120
set i[1021] = 121
set i[73] = 122
set i[868] = 123
set i[1254] = 124
set i[588] = 125
set i[93] = 126
set i[316] = 161
set i[779] = 162
set i[725] = 163
set i[287] = 164
set i[212] = 165
set i[7] = 166
set i[29] = 167
set i[1958] = 168
set i[1009] = 169
set i[1580] = 170
set i[1778] = 171
set i[103] = 172
set i[400] = 174
set i[1904] = 175
set i[135] = 176
set i[1283] = 177
set i[469] = 178
set i[363] = 179
set i[550] = 180
set i[1831] = 181
set i[1308] = 182
set i[1234] = 183
set i[1017] = 184
set i[1093] = 185
set i[1577] = 186
set i[606] = 187
set i[1585] = 188
set i[1318] = 189
set i[980] = 190
set i[1699] = 191
set i[1292] = 192
set i[477] = 193
set i[709] = 194
set i[1600] = 195
set i[2092] = 196
set i[50] = 197
set i[546] = 198
set i[408] = 199
set i[853] = 200
set i[205] = 201
set i[411] = 202
set i[1311] = 203
set i[1422] = 204
set i[1808] = 205
set i[457] = 206
set i[1280] = 207
set i[614] = 208
set i[1037] = 209
set i[237] = 210
set i[1409] = 211
set i[1023] = 212
set i[1361] = 213
set i[695] = 214
set i[161] = 215
set i[1645] = 216
set i[1822] = 217
set i[644] = 218
set i[1395] = 219
set i[677] = 220
set i[1677] = 221
set i[881] = 222
set i[861] = 223
set i[1408] = 224
set i[1864] = 225
set i[1467] = 226
set i[1819] = 227
set i[1971] = 228
set i[949] = 229
set i[774] = 230
set i[1828] = 231
set i[865] = 232
set i[699] = 233
set i[786] = 234
set i[1806] = 235
set i[1286] = 236
set i[1128] = 237
set i[1490] = 238
set i[1720] = 239
set i[1817] = 240
set i[729] = 241
set i[1191] = 242
set i[1164] = 243
set i[413] = 244
set i[349] = 245
set i[1409] = 246
set i[660] = 247
set i[2016] = 248
set i[1087] = 249
set i[1497] = 250
set i[753] = 251
set i[1579] = 252
set i[1456] = 253
set i[606] = 254
set i[1625] = 255
set h[92] = 47
set h[201] = 108
set h[201] = 76
set h[203] = 103
set h[203] = 71
set h[246] = 115
set h[246] = 83
set h[246] = 211
set h[254] = 187
set y[201] = 108
set y[203] = 103
set y[246] = 115
set c[8]="\b"
set c[9]="\t"
set c[10]="\n"
set c[12]="\f"
set c[13]="\r"
set c[32]=" "
set c[33]="!"
set c[34]="\""
set c[35]="#"
set c[36]="$"
set c[37]="%"
set c[38]="&"
set c[39]="'"
set c[40]="("
set c[41]=")"
set c[42]="*"
set c[43]="+"
set c[44]=","
set c[45]="-"
set c[46]="."
set c[47]="/"
set c[48]="0"
set c[49]="1"
set c[50]="2"
set c[51]="3"
set c[52]="4"
set c[53]="5"
set c[54]="6"
set c[55]="7"
set c[56]="8"
set c[57]="9"
set c[58]=":"
set c[59]=";"
set c[60]="<"
set c[61]="="
set c[62]=">"
set c[63]="?"
set c[64]="@"
set c[65]="A"
set c[66]="B"
set c[67]="C"
set c[68]="D"
set c[69]="E"
set c[70]="F"
set c[71]="G"
set c[72]="H"
set c[73]="I"
set c[74]="J"
set c[75]="K"
set c[76]="L"
set c[77]="M"
set c[78]="N"
set c[79]="O"
set c[80]="P"
set c[81]="Q"
set c[82]="R"
set c[83]="S"
set c[84]="T"
set c[85]="U"
set c[86]="V"
set c[87]="W"
set c[88]="X"
set c[89]="Y"
set c[90]="Z"
set c[91]="["
set c[92]="\\"
set c[93]="]"
set c[94]="^"
set c[95]="_"
set c[96]="`"
set c[97]="a"
set c[98]="b"
set c[99]="c"
set c[100]="d"
set c[101]="e"
set c[102]="f"
set c[103]="g"
set c[104]="h"
set c[105]="i"
set c[106]="j"
set c[107]="k"
set c[108]="l"
set c[109]="m"
set c[110]="n"
set c[111]="o"
set c[112]="p"
set c[113]="q"
set c[114]="r"
set c[115]="s"
set c[116]="t"
set c[117]="u"
set c[118]="v"
set c[119]="w"
set c[120]="x"
set c[121]="y"
set c[122]="z"
set c[123]="{"
set c[124]="|"
set c[125]="}"
set c[126]="~"
set c[128] = "€"
set c[130] = "‚"
set c[131] = "ƒ"
set c[132] = "„"
set c[133] = "…"
set c[134] = "†"
set c[135] = "‡"
set c[136] = "ˆ"
set c[137] = "‰"
set c[138] = "Š"
set c[139] = "‹"
set c[140] = "Œ"
set c[142] = "Ž"
set c[145] = "‘"
set c[146] = "’"
set c[147] = "“"
set c[148] = "”"
set c[149] = "•"
set c[150] = "–"
set c[151] = "—"
set c[152] = "˜"
set c[153] = "™"
set c[154] = "š"
set c[155] = "›"
set c[156] = "œ"
set c[158] = "ž"
set c[159] = "Ÿ"
set c[160] = " "
set c[161] = "¡"
set c[162] = "¢"
set c[163] = "£"
set c[164] = "¤"
set c[165] = "¥"
set c[166] = "¦"
set c[167] = "§"
set c[168] = "¨"
set c[169] = "©"
set c[170] = "ª"
set c[171] = "«"
set c[172] = "¬"
set c[174] = "®"
set c[175] = "¯"
set c[176] = "°"
set c[177] = "±"
set c[178] = "²"
set c[179] = "³"
set c[180] = "´"
set c[181] = "µ"
set c[182] = "¶"
set c[183] = "·"
set c[184] = "¸"
set c[185] = "¹"
set c[186] = "º"
set c[187] = "»"
set c[188] = "¼"
set c[189] = "½"
set c[190] = "¾"
set c[191] = "¿"
set c[192] = "À"
set c[193] = "Á"
set c[194] = "Â"
set c[195] = "Ã"
set c[196] = "Ä"
set c[197] = "Å"
set c[198] = "Æ"
set c[199] = "Ç"
set c[200] = "È"
set c[201] = "É"
set c[202] = "Ê"
set c[203] = "Ë"
set c[204] = "Ì"
set c[205] = "Í"
set c[206] = "Î"
set c[207] = "Ï"
set c[208] = "Ð"
set c[209] = "Ñ"
set c[210] = "Ò"
set c[211] = "Ó"
set c[212] = "Ô"
set c[213] = "Õ"
set c[214] = "Ö"
set c[215] = "×"
set c[216] = "Ø"
set c[217] = "Ù"
set c[218] = "Ú"
set c[219] = "Û"
set c[220] = "Ü"
set c[221] = "Ý"
set c[222] = "Þ"
set c[223] = "ß"
set c[224] = "à"
set c[225] = "á"
set c[226] = "â"
set c[227] = "ã"
set c[228] = "ä"
set c[229] = "å"
set c[230] = "æ"
set c[231] = "ç"
set c[232] = "è"
set c[233] = "é"
set c[234] = "ê"
set c[235] = "ë"
set c[236] = "ì"
set c[237] = "í"
set c[238] = "î"
set c[239] = "ï"
set c[240] = "ð"
set c[241] = "ñ"
set c[242] = "ò"
set c[243] = "ó"
set c[244] = "ô"
set c[245] = "õ"
set c[246] = "ö"
set c[247] = "÷"
set c[248] = "ø"
set c[249] = "ù"
set c[250] = "ú"
set c[251] = "û"
set c[252] = "ü"
set c[253] = "ý"
set c[254] = "þ"
set c[255] = "ÿ"
endmethod
endmodule
private struct Inits extends array
implement Init
endstruct
endlibrary
library HoverOriginButton initializer Init requires optional FrameLoader
/* HoverOriginButtonV1.3 by Tasyen
This System gives a easy way to setup callbacks when a Origin-SimpleButton is hovered. It uses Tooltips hence the executed callbacks are async.
I created this because one can do this Tooltip approach only once per map so that systems don't have to fight over that feature but use it.
function HoverOriginButtonAdd takes code action returns triggercondition
the action happens when the user starts hovering a button
action the callback
use HoverOriginButton_ActionButtonIndex, HoverOriginButton_ActionOFrameType & HoverOriginButton_ActionNewHovered to know the current hovered Button
function()
yourCode
yourCode
end
returns the new objects can be used for HoverOriginButtonRemove
function HoverOriginButtonAddClose takes code action returns triggercondition
add a callback that happens when the user stops hoveringer a Command/Item Button, async.
function()
yourCode
yourCode
end
function HoverOriginButtonRemove takes triggercondition action returns nothing
removes the table from the callback List
*/
globals
//System Globals
public framehandle array Frames
public timer Timer
public integer SectionSize = 30 //Size Given to each originFrameType
public integer LastFrameIndex = 0
public integer LastSelectedIndex = -1
public real timeOut = 1/32.0 // How Fast is the Syste,m
// Custom ActionIntegerFace
public integer ActionButtonIndex = -1
public originframetype ActionOFrameType
public boolean ActionNewHovered
public trigger Actions
public trigger ActionsClose
endglobals
// ===========
// Custom Action Interface
// ===========
// default is setuped to push functions Actions & ActionsClose
private function HoverAction takes originframetype oFrameType, integer buttonIndex, boolean newHovered returns nothing
set ActionOFrameType = oFrameType
set ActionButtonIndex = buttonIndex
set ActionNewHovered = newHovered
call TriggerEvaluate(Actions)
endfunction
private function HoverActionClose takes originframetype oFrameType returns nothing
set ActionOFrameType = oFrameType
call TriggerEvaluate(ActionsClose)
endfunction
function HoverOriginButtonAdd takes code action returns triggercondition
return TriggerAddCondition(Actions, Condition(action) )
endfunction
function HoverOriginButtonAddClose takes code action returns triggercondition
return TriggerAddCondition(ActionsClose, Condition(action) )
endfunction
function HoverOriginButtonRemove takes triggercondition action returns nothing
call TriggerRemoveCondition(Actions, action)
call TriggerRemoveCondition(ActionsClose, action)
endfunction
// ===========
// System Code
// ===========
private function CreateTooltipForOrigin takes originframetype oFrameType, integer first, integer last returns nothing
local integer i = first
local integer baseIndex = GetHandleId(oFrameType)*SectionSize
local framehandle oFrame
local framehandle newFrame
loop
exitwhen i > last
set oFrame = BlzGetOriginFrame(oFrameType, i)
set newFrame = BlzCreateFrameByType("SIMPLEFRAME", "", oFrame, "", 0)
call BlzFrameSetTooltip(oFrame, newFrame)
call BlzFrameSetVisible(newFrame, false)
set Frames[baseIndex + i] = newFrame
set i = i + 1
endloop
if LastFrameIndex < baseIndex + i then
set LastFrameIndex = baseIndex + i
endif
endfunction
private function TimerAction takes nothing returns nothing
local boolean selectedAnything = false
local integer int
local integer originFrameIndex
local integer buttonIndex
local boolean newOneHovered
set int = 0
loop
exitwhen int > LastFrameIndex
if BlzFrameIsVisible(Frames[int]) then
set selectedAnything = true
// the new selected is not the same as the current one?
set newOneHovered = LastSelectedIndex != int
set LastSelectedIndex = int
set originFrameIndex = int/SectionSize
set buttonIndex = int - originFrameIndex*SectionSize
//if newOneHovered then
//call BJDebugMsg("TotalIndex"+I2S(int)+ " Origin"+I2S(originFrameIndex) + " button"+I2S(buttonIndex))
//endif
call HoverAction(ConvertOriginFrameType(originFrameIndex), buttonIndex, newOneHovered)
exitwhen true
endif
set int = int + 1
endloop
// now selects nothing?
if not selectedAnything and LastSelectedIndex != - 1 then
set originFrameIndex = LastSelectedIndex/SectionSize
call HoverActionClose(ConvertOriginFrameType(originFrameIndex))
set LastSelectedIndex = -1
endif
endfunction
private function InitFrames takes nothing returns nothing
call CreateTooltipForOrigin(ORIGIN_FRAME_COMMAND_BUTTON, 0, 11)
call CreateTooltipForOrigin(ORIGIN_FRAME_ITEM_BUTTON, 0, 5)
call CreateTooltipForOrigin(ORIGIN_FRAME_HERO_BUTTON, 0, 6)
call CreateTooltipForOrigin(ORIGIN_FRAME_SYSTEM_BUTTON, 0, 3)
call CreateTooltipForOrigin(ORIGIN_FRAME_MINIMAP_BUTTON, 0, 4)
call TimerStart(Timer, timeOut, true, function TimerAction)
endfunction
private function At0s takes nothing returns nothing
call InitFrames()
endfunction
private function Init takes nothing returns nothing
set Timer = CreateTimer()
set Actions = CreateTrigger()
set ActionsClose = CreateTrigger()
call TimerStart(Timer,0 ,false, function At0s)
// Frame related code actions are not saved/Loaded, probably repeat them after Loading the game
static if LIBRARY_FrameLoader then
call FrameLoaderAdd(function InitFrames)
endif
endfunction
endlibrary
library TasToolTipBox initializer init_function requires HoverOriginButton, optional Ascii, optional FrameLoader
/* TasToolTipBox V8c by Tasyen
An additional Box for a spell in the command card/inventory which displays MissileSpeed, Cooldown, Range & Area values
changes position of ORIGIN_FRAME_UBERTOOLTIP
function TasToolTipBox_GetUnitCodeData takes integer unitCode, boolean insert returns integer
makes unitCode use an index and return it
returns 0 when the unitcode was not used and insert == false
only 32k/12 ~2666 unitCodes can have data in this system
GetObjectSlotCode
function TasToolTipBox_AddData takes gameevent dataType, integer unitCode, integer objectCode returns nothing
Tell the TasToolTipBox that units of unitTypeId UnitCode have objectCode inside dataType. This is needed for BuiltMenu, LearnMenu & Selling/Training.
supproted dataType are:
EVENT_GAME_BUILD_SUBMENU
EVENT_GAME_SHOW_SKILL
null
unitCode is the unitTypeId of the unit using this data.
objectCode is one RawCode in a string or a number 'Hpal'.
uses x/y coords of objectCode, therefore with colisions you get unwanted results
function TasToolTipBox_AddDataBatch takes gameevent dataType, integer unitCode, string objectCodeString returns nothing
uses AddData with many rawCodes at once.
requires Ascii
call TasToolTipBox_AddDataBatch(EVENT_GAME_BUILD_SUBMENU, 'hpea', "htow,hhou,hbar,hbla,hwtw,halt,harm,hars,hlum,hgra,hvlt")
call TasToolTipBox_AddDataBatch(EVENT_GAME_SHOW_SKILL, 'Hpal', "AHhb,AHds,AHre,AHad")
call TasToolTipBox_AddDataBatch(null, 'ngme', "stwp,bspd,dust,tret,prvt,cnob,stel,pnvl,shea,spro,pinv")
function TasToolTipBox_GetObjectSlotCode takes integer objectCode, boolean insert returns integer
makes objectCode use an index and return it
returns 0 when the objectCode was not used and insert == false
only 32k/InfoCount objectCode can have data in this system.
function TasToolTipBox_SetObjectSlot takes integer objectCode, integer slotIndex, string text, string icon returns nothing
SlotIndex shows Text & Icon when ObjectCode is hovered.
SlotIndex is -InTooltipInfoCount to InfoCount
0 to InfoCount - 1 are in the custom UI
-SlotIndex are next to the normal resource costs.
ObjectCode is the rawCode of an ObjectEditor object.
This only works for data added with TasToolTipBox_AddData/TasToolTipBox_AddDataBatch.
This should be called outside of the action call backs like at map init or 0s.
example: TasToolTipBox_SetObjectSlot('hpea', 3, "120", "ReplaceableTextures/CommandButtons/BTNBrilliance.tga")
When a command button is hovered that holds Human worker in DataBuilt DataLearn or DataDefault. Then it slot 3 will diplsay 120 and the Aura Icon
function TasToolTipBox_SetWidgetSlot takes widget u, integer buttonIndex, integer slotIndex, string text, string icon returns nothing
sets custom wanted data for an unit or item for that buttonIndex.
buttonIndex is 0 to 11 for command buttonIndexes.
buttonIndex can be a spellCode like 'AHbz' then the buttonIndex is calced from the data.
slotIndex like TasToolTipBox_SetObjectSlot
for items always use buttonIndex 0
the first use of this will use a hashtable
function TasToolTipBox_RemoveSlot takes widget u returns nothing
removes all SetWidgetSlot of u, u should be an item or unit
function TasToolTipBox_RemoveWidgetSlot takes widget u, integer buttonIndex, integer slotIndex returns nothing
removes one data entry SetWidgetSlot of u, u should be an item or unit
works incorrect when multiple skills use 1 slot in the command card
works incorrect in group selection
works incorrect with spellbooks
requires BlzGetAbilityId for skills with more than 1 level (not Warcraft V1.31.1)
*/
globals
constant boolean REFORGED = false // have BlzGetAbilityId? otherwise false
public string TocPath = "war3mapImported\\TasToolTipBox.toc"
public boolean AutoRun = true //(true) will create Itself at 0s, (false) you need to TasToolTipBox_Init()
public boolean FixedPos = false // true default tooltip pos is the same even no TasToolTipBox is shown
public boolean Hide0Text = true // hide a Slot when the displayed Text would be 0/0s/0.0s
public boolean FilterItemSkills = true // true itemspells are never in the command card in your map
public boolean EnableSubMenu = true // creates events/timer; changing it after the Init run is not supported/recommented.
public integer InfoCount = 5 // how many Infos you want, every 4 are one row
public integer InTooltipInfoCount = 3 // how many additional slots next to the default ResourceCost slots
public real YPos = 0.17
public boolean NoFDF = false // only affects InTooltipInfoCount, true dont need the fdf. should also change InfoCount to 0
public constant boolean SpeedUpHash = true // true makes it faster hopeful, stores hashes for TasToolTipBox_SetWidgetSlot
// system variables
public real SizeX
public real SizeY
public boolean array ExcludSlots // the buttonIndexes set, are not used in the auto ability detection
public string array Icon // filePaths used, indexes should fit the data used in ActionXxxx functions
public unit array SelectedUnit // current Selected
public integer array DataUnitCode // the unitcodes with Data
public integer array DataBuilt // DataUnitCode*12
public integer array DataLearn // DataUnitCode*12
public integer array DataDefault // DataUnitCode*12
public integer array ObjectSlotCode // the unitcodes with ObjectSlotData
public string array ObjectSlotIcon // ObjectSlotCode*InfoCount+InfoCount
public string array ObjectSlotText // ObjectSlotCode*InfoCount+InfoCount
public string array ObjectSlotIcon2 // ObjectSlotCode*InTooltipInfoCount+InTooltipInfoCount
public string array ObjectSlotText2 // ObjectSlotCode*InTooltipInfoCount+InTooltipInfoCount
public hashtable Hash = null
public integer array StringHashWidgetText
public integer array StringHashWidgetIcon
public integer EventCount = -1
public integer TimerUnit = -1
public integer LastAction = -1
public integer TimerCount = -1
public boolean TimerCountChanged = false
public gameevent currentAction = null
endglobals
// ==========
// Config functions
// ==========
public function ParentFunc takes nothing returns framehandle // should not be simple, called when TasToolTipBox is created the returned frame is used as parent
return BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0)
endfunction
public function InitUserData takes nothing returns nothing
// filePaths used for the icons, Indexes should fit the data used in ActionXxxx functions
set Icon[1] = "replaceabletextures/passivebuttons/pasbtntrueshot"
set Icon[2] = "ui/widgets/battlenet/bnet-tournament-clock"
set Icon[3] = "replaceabletextures/commandbuttons/btnload"
set Icon[4] = "replaceabletextures/selection/spellareaofeffect_undead"
set Icon[5] = "replaceabletextures/commandbuttons/btnreplay-speedup"
set Icon[6] = "UI/Widgets/ToolTips/Human/ToolTipManaIcon"
set ExcludSlots[7] = true // the buttonIndexes set, are not used in the auto ability detection -> ActionSpell; [7] = true -> ignore command button 7, 0 is the Top Left button 11 the bottom right
endfunction
public function ActionSubMenuHero takes integer buttonIndex, integer data, unit u, integer unitCode returns boolean
// requires EnableSubMenu
// what to display inside hero skill menu
//call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 1), GetObjectName(data))
return true
endfunction
public function ActionSubMenuBuilt takes integer buttonIndex, integer data, unit u, integer unitCode returns boolean
// what to display inside built menu
//call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 1), GetObjectName(data))
return true
endfunction
public function ActionDefaultData takes integer buttonIndex, integer data, unit u, integer unitCode returns boolean
// what to display with manual written data
//call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 1), GetObjectName(data))
return true
endfunction
public function ActionSpell takes integer buttonIndex, ability abi, unit u, integer abiCode, integer level, integer unitCode returns boolean
// this is the place you can change the displayed data
call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 1), I2S(BlzGetAbilityIntegerField(abi, ABILITY_IF_MISSILE_SPEED)))
call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 2), I2S(R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_COOLDOWN, level)))+"s")
call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 3), I2S(R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_CAST_RANGE, level))))
call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 4), I2S(R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_AREA_OF_EFFECT, level))))
call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 5), R2SW(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_CASTING_TIME, level),1,1)+"s")
//call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 6), I2S(BlzGetAbilityIntegerLevelField(abi, ABILITY_ILF_MANA_COST, level)))
return true
endfunction
public function ActionItemSpell takes integer buttonIndex, ability abi, unit u, integer abiCode, integer level, integer unitCode, item it returns boolean
// Update displayed Text
// this is the place you can change the displayed data
call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 1), I2S(BlzGetAbilityIntegerField(abi, ABILITY_IF_MISSILE_SPEED)))
call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 2), I2S(R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_COOLDOWN, level)))+"s")
call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 3), I2S(R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_CAST_RANGE, level))))
call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 4), I2S(R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_AREA_OF_EFFECT, level))))
call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 5), R2SW(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_CASTING_TIME, level),1,1)+"s")
//call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", 6), I2S(BlzGetAbilityIntegerLevelField(abi, ABILITY_ILF_MANA_COST, level)))
return true
endfunction
// ==========
// Confg Ende
// ==========
public function CountCommandButtons takes nothing returns integer
local integer count = 0
local integer i = 11
loop
exitwhen i < 0
if BlzFrameIsVisible(BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, i)) then
set count = count + 1
endif
set i = i - 1
endloop
return count
endfunction
public function ResetDisplay takes nothing returns nothing
local integer i = -InTooltipInfoCount
local real scale
if not FixedPos then
call BlzFrameSetSize(BlzGetFrameByName("TasTooltipBox", 0), SizeX, 0.0001)
endif
call BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBox", 0), false)
call BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBoxInsideParent", 0), false)
set scale = BlzFrameGetWidth(BlzGetFrameByName("ConsoleUIBackdrop", 0))/0.8
if scale > 0.1 then
call BlzFrameSetScale(BlzGetFrameByName("TasTooltipBox", 0), scale)
call BlzFrameSetScale(BlzGetFrameByName("TasTooltipBoxInsideParent", 0), scale)
endif
loop
exitwhen i > InfoCount
call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", i), "0")
if Icon[i] != "" then
call BlzFrameSetTexture(BlzGetFrameByName("TasTooltipBoxInfoIcon", i), Icon[i], 0, true)
endif
set i = i + 1
endloop
endfunction
public function GetHashSlot takes integer buttonIndex, integer slotIndex, boolean icon returns integer
local integer usedIndex
static if not SpeedUpHash then
if icon then
return StringHash(I2S(buttonIndex) +","+I2S(slotIndex) + "Icon")
else
return StringHash(I2S(buttonIndex) +","+I2S(slotIndex) + "Text")
endif
else
if slotIndex < 0 then
set slotIndex = InfoCount - slotIndex
endif
set usedIndex = buttonIndex*(InTooltipInfoCount+InfoCount) + slotIndex
if icon then
// First call preload all of it
if StringHashWidgetIcon[usedIndex] == 0 then
set StringHashWidgetIcon[usedIndex] = StringHash(I2S(buttonIndex) +","+I2S(slotIndex) + "Icon")
endif
return StringHashWidgetIcon[usedIndex]
else
if StringHashWidgetText[usedIndex] == 0 then
set StringHashWidgetText[usedIndex] = StringHash(I2S(buttonIndex) +","+I2S(slotIndex) + "Text")
endif
return StringHashWidgetText[usedIndex]
endif
endif
endfunction
public function ShowWidgetSlot takes widget u, integer buttonIndex returns nothing
local integer slotIndex
local integer uId
local string icon
local string text
if Hash == null then
return
endif
set uId = GetHandleId(u)
if not HaveSavedBoolean(Hash, uId, 0) then
return
endif
set slotIndex = -InTooltipInfoCount
call BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBoxInsideParent", 0), true)
loop
set icon = LoadStr(Hash, uId, GetHashSlot(buttonIndex,slotIndex, true))
set text = LoadStr(Hash, uId, GetHashSlot(buttonIndex,slotIndex, false))
if icon != null and icon != "" then
call BlzFrameSetTexture(BlzGetFrameByName("TasTooltipBoxInfoIcon", slotIndex), icon, 0, true)
endif
if text != null and text != "" then
call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", slotIndex), text)
endif
set slotIndex = slotIndex + 1
exitwhen slotIndex > InfoCount
endloop
endfunction
public function RemoveSlot takes widget u returns nothing
call FlushChildHashtable(Hash, GetHandleId(u))
call RemoveSavedBoolean(Hash, GetHandleId(u), 0)
endfunction
public function RemoveWidgetSlot takes widget u, integer buttonIndex, integer slotIndex returns nothing
call RemoveSavedString(Hash, GetHandleId(u), GetHashSlot(buttonIndex,slotIndex, true))
call RemoveSavedString(Hash, GetHandleId(u), GetHashSlot(buttonIndex,slotIndex, false))
endfunction
public function SetWidgetSlot takes widget u, integer buttonIndex, integer slotIndex, string text, string icon returns nothing
if slotIndex >= InfoCount then
call BJDebugMsg("TasToolTipBox_SetWidgetSlot Error - slotIndex to big for " + I2S(buttonIndex) + " "+I2S(slotIndex) + " " + text +" "+ icon)
return
endif
if buttonIndex >= 12 then
set buttonIndex = BlzGetAbilityPosX(buttonIndex)+4*BlzGetAbilityPosY(buttonIndex)
endif
if Hash == null then
set Hash = InitHashtable()
endif
call SaveBoolean(Hash, GetHandleId(u), 0, true)
call SaveStr(Hash, GetHandleId(u), GetHashSlot(buttonIndex,slotIndex, true), icon)
call SaveStr(Hash, GetHandleId(u), GetHashSlot(buttonIndex,slotIndex, false), text)
endfunction
public function GetObjectSlotCode takes integer objectCode, boolean insert returns integer
local integer i = 1
loop
if ObjectSlotCode[i] == objectCode then
return i
elseif ObjectSlotCode[i] == 0 then
if not insert then
exitwhen true
endif
set ObjectSlotCode[i] = objectCode
return i
endif
set i = i + 1
endloop
return 0
endfunction
public function ShowObjectSlot takes integer objectCode returns nothing
local integer index
local integer i
local integer usedSlot
if objectCode <= 0 then
return
endif
set index = GetObjectSlotCode(objectCode, false)
if index == 0 then
return
endif
set i = -InTooltipInfoCount
call BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBoxInsideParent", 0), true)
loop
if i >= 0 then
set usedSlot = index*InfoCount + i - 1
if ObjectSlotIcon[usedSlot] != null then
call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", i), ObjectSlotText[usedSlot])
call BlzFrameSetTexture(BlzGetFrameByName("TasTooltipBoxInfoIcon", i), ObjectSlotIcon[usedSlot], 0, true)
endif
else //-i
set usedSlot = index*InTooltipInfoCount - i
if ObjectSlotIcon2[usedSlot] != null then
call BlzFrameSetText(BlzGetFrameByName("TasTooltipBoxInfoText", i), ObjectSlotText2[usedSlot])
call BlzFrameSetTexture(BlzGetFrameByName("TasTooltipBoxInfoIcon", i), ObjectSlotIcon2[usedSlot], 0, true)
endif
endif
set i = i + 1
exitwhen i > InfoCount
endloop
endfunction
public function SetObjectSlot takes integer objectCode, integer slotIndex, string text, string icon returns nothing
local integer index = GetObjectSlotCode(objectCode, true)
local integer usedSlot
if slotIndex >= InfoCount then
call BJDebugMsg("TasToolTipBox_SetObjectSlot Error - slotIndex to big for " + GetObjectName(objectCode) + " "+I2S(objectCode))
return
endif
if slotIndex >= 0 then
set usedSlot = index*InfoCount + slotIndex
set ObjectSlotIcon[usedSlot] = icon
set ObjectSlotText[usedSlot] = text
else
set usedSlot = index*InTooltipInfoCount - slotIndex
set ObjectSlotIcon2[usedSlot] = icon
set ObjectSlotText2[usedSlot] = text
endif
endfunction
public function GetUnitCodeData takes integer unitCode, boolean insert returns integer
local integer i = 1
loop
if DataUnitCode[i] == unitCode then
return i
elseif DataUnitCode[i] == 0 then
if not insert then
exitwhen true
endif
set DataUnitCode[i] = unitCode
return i
endif
set i = i + 1
endloop
return 0
endfunction
public function AddData takes gameevent dataType, integer unitCode, integer objectCode returns nothing
local integer index = GetUnitCodeData(unitCode, true)
local integer coord = BlzGetAbilityPosX(objectCode)+4* BlzGetAbilityPosY(objectCode)
if coord >= 0 then
if dataType == null then
set DataDefault[index*12 + coord] = objectCode
elseif dataType == EVENT_GAME_BUILD_SUBMENU then
set DataBuilt[index*12 + coord] = objectCode
elseif dataType == EVENT_GAME_SHOW_SKILL then
// find first free slot in the unitCodeData
// learning Get Learn x/YPos is not a thing so just put it at first found slot
set coord = 0
loop
exitwhen coord > 11
if DataLearn[index*12 + coord] == 0 then
set DataLearn[index*12 + coord] = objectCode
exitwhen true
endif
set coord = coord + 1
endloop
endif
endif
endfunction
static if LIBRARY_Ascii then
public function AddDataBatch takes gameevent dataType, integer unitCode, string objectCodeString returns nothing
local integer startIndex = 0
// "Hamg,Hmkg,Hpal,Hblm"
loop
exitwhen startIndex + 3 > StringLength(objectCodeString)
call AddData(dataType, unitCode, S2A(SubString(objectCodeString, startIndex, startIndex + 4)))
set startIndex = startIndex + 5
endloop
endfunction
endif
public function StartUI takes nothing returns nothing
local integer buttonIndex = HoverOriginButton_ActionButtonIndex
local unit u
local integer unitCode
local integer level
local integer i
local integer abiCode = 0
local ability abi
local string text
local boolean found = false
local integer highestNo0 = -1
local boolean showThis
local boolean showBox = false
local boolean showBoxInside = false
local item it
local integer unitCodeDataValue
if not HoverOriginButton_ActionNewHovered then
return
endif
if HoverOriginButton_ActionOFrameType != ORIGIN_FRAME_COMMAND_BUTTON and HoverOriginButton_ActionOFrameType != ORIGIN_FRAME_ITEM_BUTTON then
return
endif
set u = SelectedUnit[GetPlayerId(GetLocalPlayer())]
set unitCode = GetUnitTypeId(u)
call ResetDisplay()
if HoverOriginButton_ActionOFrameType == ORIGIN_FRAME_COMMAND_BUTTON then
set unitCodeDataValue = GetUnitCodeData(unitCode, false)*12
// reset currentAction?
if currentAction != null and EventCount != CountCommandButtons() then
set currentAction = null
endif
if currentAction == EVENT_GAME_BUILD_SUBMENU then
if DataBuilt[unitCodeDataValue + buttonIndex] > 0 then
call ShowObjectSlot(DataBuilt[unitCodeDataValue + buttonIndex])
set found = ActionSubMenuBuilt(buttonIndex, DataBuilt[unitCodeDataValue + buttonIndex], u, unitCode)
endif
elseif currentAction == EVENT_GAME_SHOW_SKILL then
if DataLearn[unitCodeDataValue + buttonIndex] > 0 then
call ShowObjectSlot(DataLearn[unitCodeDataValue + buttonIndex])
set found = ActionSubMenuHero(buttonIndex, DataLearn[unitCodeDataValue + buttonIndex], u, unitCode)
endif
endif
if currentAction == null then
//- have manual data for default menu and this unitCode?
if DataDefault[unitCodeDataValue + buttonIndex] > 0 then
call ShowObjectSlot(DataDefault[unitCodeDataValue + buttonIndex])
set found = ActionDefaultData(buttonIndex, DataDefault[unitCodeDataValue + buttonIndex], u, unitCode)
endif
if not found then
// dont use the first 5 buttons and ignore wanted slots
if buttonIndex < 5 or ExcludSlots[buttonIndex] then
return
endif
set i = 0
loop
set abi = BlzGetUnitAbilityByIndex(u, i)
exitwhen abi == null
if (not FilterItemSkills or not BlzGetAbilityBooleanField(abi, ABILITY_BF_ITEM_ABILITY)) and BlzGetAbilityIntegerField(abi, ABILITY_IF_BUTTON_POSITION_NORMAL_X)+BlzGetAbilityIntegerField(abi, ABILITY_IF_BUTTON_POSITION_NORMAL_Y)*4 == buttonIndex then
set level = 0
static if REFORGED then
set abiCode = BlzGetAbilityId(abi)
set level = GetUnitAbilityLevel(u, abiCode) - 1
call ShowObjectSlot(abiCode)
endif
set found = ActionSpell(buttonIndex, abi, u, abiCode, level, unitCode)
exitwhen true
endif
set i = i + 1
endloop
endif
call ShowWidgetSlot(u, buttonIndex)
endif
elseif HoverOriginButton_ActionOFrameType == ORIGIN_FRAME_ITEM_BUTTON then
set it = UnitItemInSlot(u, buttonIndex)
if GetItemTypeId(it) > 0 then
// index 0 is the active skill in a correct setuped item
set abi = BlzGetItemAbilityByIndex(it, 0)
if GetHandleId(abi) > 0 then
set level = 0
static if REFORGED then
set abiCode = BlzGetAbilityId(abi)
set level = GetUnitAbilityLevel(u, abiCode) - 1
call ShowObjectSlot(abiCode)
endif
set found = ActionItemSpell(buttonIndex, abi, u, abiCode, level, unitCode, it)
call ShowWidgetSlot(it, 0)
endif
endif
endif
if Hide0Text then
set i = -InTooltipInfoCount
loop
exitwhen i > InfoCount
if i != 0 then
set text = BlzFrameGetText(BlzGetFrameByName("TasTooltipBoxInfoText", i))
set showThis = not (text == "0" or text == "0s" or text == "0.0s")
call BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBoxInfo", i) , showThis)
if showThis then
if i >= 0 then
set showBox = true
endif
if i < 0 then
set showBoxInside = true
endif
endif
endif
set i = i + 1
endloop
call BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBoxInsideParent", 0), showBoxInside)
call BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBox", 0), found and showBox)
else
call BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBox", 0), found)
endif
if BlzFrameIsVisible(BlzGetFrameByName("TasTooltipBox", 0)) and not FixedPos then
call BlzFrameSetSize(BlzGetFrameByName("TasTooltipBox", 0), SizeX, SizeY)
endif
set abi = null
set u = null
set it = null
endfunction
public function EndUI takes nothing returns nothing
call ResetDisplay()
endfunction
public function InitFrames takes nothing returns nothing
local framehandle orgTooltip = null
local framehandle parent = null
local framehandle parent2 = null
local framehandle superParent = null
local framehandle prev = null
local framehandle frame = null
local framehandle text = null
local framehandle icon = null
local integer colRemain = 5
local integer rows = 1
local integer i = 1
local real ySize
call BlzLoadTOCFile(TocPath)
// reserve HandleId to allow async access later
call BlzGetFrameByName("ConsoleUIBackdrop", 0)
set orgTooltip = BlzGetOriginFrame(ORIGIN_FRAME_UBERTOOLTIP, 0)
set superParent = BlzCreateFrameByType("FRAME", "TasTooltipBoxParent", ParentFunc(), "", 0)
set parent = BlzCreateFrame("TasTooltipBox", superParent, 0, 0)
set parent2 = BlzCreateFrameByType("FRAME", "TasTooltipBoxInsideParent", superParent, "", 0)
set i = 1
loop
exitwhen i > InfoCount
set frame = BlzCreateFrame("TasTooltipBoxInfo", parent, 0, i)
if GetHandleId(frame) == 0 then
call BJDebugMsg("TasToolTipBox - Error - Can not Create Frame\nCheck for Imported Toc & fdf File")
endif
call BlzGetFrameByName("TasTooltipBoxInfo", i)
call BlzGetFrameByName("TasTooltipBoxInfoIcon", i)
call BlzGetFrameByName("TasTooltipBoxInfoText", i)
set colRemain = colRemain - 1
if i == 1 then
call BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, parent, FRAMEPOINT_TOPLEFT, 0.006, -0.006)
elseif colRemain <= 0 then
set rows = rows + 1
set colRemain = 4
call BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, BlzGetFrameByName("TasTooltipBoxInfo", i - 4), FRAMEPOINT_BOTTOMLEFT, 0, -0.006)
else
call BlzFrameSetPoint(frame, FRAMEPOINT_LEFT, prev, FRAMEPOINT_RIGHT, 0.006, 0)
endif
set prev = frame
set i = i + 1
endloop
set i = -1
set prev = null
loop
exitwhen i < -InTooltipInfoCount
if NoFDF then
set frame = BlzCreateFrameByType("FRAME", "TasTooltipBoxInfo", parent2, "", i)
call BlzFrameSetSize(frame, 0.06, 0.015)
set icon = BlzCreateFrameByType("BACKDROP", "TasTooltipBoxInfoIcon", frame, "", i)
set text = BlzCreateFrameByType("TEXT", "TasTooltipBoxInfoText", frame, "", i)
call BlzFrameSetSize(icon, 0.015, 0.015)
call BlzFrameSetPoint(icon, FRAMEPOINT_LEFT, frame, FRAMEPOINT_LEFT, 0, 0)
call BlzFrameSetPoint(text, FRAMEPOINT_LEFT, icon, FRAMEPOINT_RIGHT, 0.001, 0)
call BlzFrameSetPoint(text, FRAMEPOINT_RIGHT, frame, FRAMEPOINT_RIGHT, -0.005, 0)
else
set frame = BlzCreateFrame("TasTooltipBoxInfo", parent2, 0, i)
call BlzGetFrameByName("TasTooltipBoxInfo", i)
call BlzGetFrameByName("TasTooltipBoxInfoIcon", i)
call BlzGetFrameByName("TasTooltipBoxInfoText", i)
endif
if prev != null then
call BlzFrameSetPoint(frame, FRAMEPOINT_RIGHT, prev, FRAMEPOINT_LEFT, -0.00, 0)
else
call BlzFrameSetPoint(frame, FRAMEPOINT_TOPRIGHT, orgTooltip, FRAMEPOINT_TOPRIGHT, -0.00, -0.017)
endif
set prev = frame
set i = i - 1
endloop
call BlzGetFrameByName("TasTooltipBoxInfo", 0)
call BlzGetFrameByName("TasTooltipBoxInfoIcon", 0)
call BlzGetFrameByName("TasTooltipBoxInfoText", 0)
set SizeY = BlzFrameGetHeight(frame)*rows+ (rows-1)*0.006 + 0.011
set SizeX = BlzFrameGetWidth(orgTooltip)
set ySize = SizeY
if not FixedPos then
set ySize = 0.0001
endif
call BlzFrameSetSize(parent, SizeX, ySize)
call BlzFrameSetPoint(orgTooltip, FRAMEPOINT_BOTTOMRIGHT, parent, FRAMEPOINT_TOPRIGHT, 0, 0.002)
call BlzFrameSetAbsPoint(parent, FRAMEPOINT_BOTTOMRIGHT, 0.795, YPos)
//call BlzFrameSetVisible(BlzGetFrameByName("TasTooltipBoxInfo", 1), false)
call BlzFrameSetVisible(parent, false)
call BlzFrameSetVisible(parent2, false)
call ResetDisplay()
endfunction
public function SelectAction takes nothing returns nothing
set SelectedUnit[GetPlayerId(GetTriggerPlayer())] = GetTriggerUnit()
endfunction
public function DeathAction takes nothing returns nothing
if not IsUnitType(GetTriggerUnit(), UNIT_TYPE_HERO) then
call RemoveSlot(GetTriggerUnit())
endif
endfunction
public function TimerAction takes nothing returns nothing
// remember the last unitHandle buttonCount and remember if it changed
// dont be to fast
local integer count = CountCommandButtons()
set TimerCountChanged = count != TimerCount
set TimerCount = count
set TimerUnit = GetHandleId(SelectedUnit[GetPlayerId(GetLocalPlayer())])
endfunction
public function TriggerActionBuilt takes nothing returns nothing
// when the buttons changed since the last timeOut but is still the same unit then the local player has most likely opened a submenu
// filter the case with 1 only button that is most likely targeting/placing
local integer count = CountCommandButtons()
if (TimerCountChanged or count != TimerCount) and count > 1 and GetHandleId(SelectedUnit[GetPlayerId(GetLocalPlayer())]) == TimerUnit then
set currentAction = EVENT_GAME_BUILD_SUBMENU
set EventCount = count
set TimerCount = count
endif
endfunction
public function TriggerActionLearn takes nothing returns nothing
// when the buttons changed since the last timeOut but is still the same unit then the local player has most likely opened a submenu
// filter the case with 1 only button that is most likely targeting/placing
local integer count = CountCommandButtons()
if (TimerCountChanged or count != TimerCount) and count > 1 and GetHandleId(SelectedUnit[GetPlayerId(GetLocalPlayer())]) == TimerUnit then
set currentAction = EVENT_GAME_SHOW_SKILL
set EventCount = count
set TimerCount = count
endif
endfunction
public function Init takes nothing returns nothing
local trigger trig
call InitFrames()
static if LIBRARY_FrameLoader then
call FrameLoaderAdd(function InitFrames)
endif
call HoverOriginButtonAdd(function StartUI)
call HoverOriginButtonAddClose(function EndUI)
set trig = CreateTrigger()
call TriggerAddAction(trig, function SelectAction)
call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_SELECTED)
set trig = CreateTrigger()
call TriggerAddAction(trig, function DeathAction)
call TriggerRegisterAnyUnitEventBJ(trig, EVENT_PLAYER_UNIT_DEATH)
if EnableSubMenu then
set trig = CreateTrigger()
call TriggerAddAction(trig, function TriggerActionLearn)
call TriggerRegisterShowSkillEventBJ(trig)
set trig = CreateTrigger()
call TriggerAddAction(trig, function TriggerActionBuilt)
call TriggerRegisterBuildSubmenuEventBJ(trig)
call TimerStart(CreateTimer(), 0.2, true, function TimerAction)
endif
call CountCommandButtons()
endfunction
public function At0s takes nothing returns nothing
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
call Init()
endfunction
public function init_function takes nothing returns nothing
call InitUserData()
if AutoRun then
call TimerStart(CreateTimer(), 1, false, function At0s)
endif
endfunction
endlibrary
TasToolTipBox.AddDataBatch(TasToolTipBox.DataBuilt, 'hpea', "htow,hhou,hbar,hbla,hwtw,halt,harm,hars,hlum,hgra,hvlt")
TasToolTipBox.AddDataBatch(TasToolTipBox.DataBuilt, 'opeo', "ogre,otrb,orbr,obar,ofor,oalt,obea,osld,otto,owtw,ovln")
TasToolTipBox.AddDataBatch(TasToolTipBox.DataBuilt, 'ewsp', "etol,emow,edos,eaom,eate,eaow,eaoe,edob,etrp,eden")
TasToolTipBox.AddDataBatch(TasToolTipBox.DataBuilt, 'uaco', "unpl,uzig,usep,ugrv,uaod,utod,uslh,ubon,usap,ugol,utom")
TasToolTipBox.AddDataBatch(TasToolTipBox.DataDefault, 'ngme', "stwp,bspd,dust,tret,prvt,cnob,stel,pnvl,shea,spro,pinv")
TasToolTipBox.AddDataBatch(TasToolTipBox.DataDefault, 'htow', "hpea,Rhpm,hkee")
TasToolTipBox.AddDataBatch(TasToolTipBox.DataLearn, 'Hpal', "AHhb,AHds,AHre,AHad")
TasToolTipBox.SetObjectSlot('hwtw', -1, "200", "ReplaceableTextures/CommandButtons/BTNBlizzard.tga")
TasToolTipBox.SetObjectSlot('hhou', -2, "2200", "ReplaceableTextures/CommandButtons/BTNBlizzard.tga")
TasToolTipBox.SetObjectSlot('hpea', 3, "120", "ReplaceableTextures/CommandButtons/BTNBrilliance.tga")
TasToolTipBox.SetObjectSlot('hpea', -3, "12", "ReplaceableTextures/CommandButtons/BTNBrilliance.tga")
library TasToolTipBoxUserInit initializer init_function requires TasToolTipBox, Ascii
public function init_function takes nothing returns nothing
call TasToolTipBox_AddDataBatch(EVENT_GAME_BUILD_SUBMENU, 'hpea', "htow,hhou,hbar,hbla,hwtw,halt,harm,hars,hlum,hgra,hvlt")
call TasToolTipBox_AddDataBatch(EVENT_GAME_BUILD_SUBMENU, 'opeo', "ogre,otrb,orbr,obar,ofor,oalt,obea,osld,otto,owtw,ovln")
call TasToolTipBox_AddDataBatch(EVENT_GAME_BUILD_SUBMENU, 'ewsp', "etol,emow,edos,eaom,eate,eaow,eaoe,edob,etrp,eden")
call TasToolTipBox_AddDataBatch(EVENT_GAME_BUILD_SUBMENU, 'uaco', "unpl,uzig,usep,ugrv,uaod,utod,uslh,ubon,usap,ugol,utom")
call TasToolTipBox_AddDataBatch(null, 'ngme', "stwp,bspd,dust,tret,prvt,cnob,stel,pnvl,shea,spro,pinv")
call TasToolTipBox_AddDataBatch(null, 'htow', "hpea,Rhpm,hkee")
call TasToolTipBox_AddDataBatch(EVENT_GAME_SHOW_SKILL, 'Hpal', "AHhb,AHds,AHre,AHad")
call TasToolTipBox_SetObjectSlot('hwtw', -3, "200", "ReplaceableTextures/CommandButtons/BTNBlizzard.tga")
call TasToolTipBox_SetObjectSlot('hhou', -1, "2200", "ReplaceableTextures/CommandButtons/BTNBlizzard.tga")
call TasToolTipBox_SetObjectSlot('hpea', -2, "120", "ReplaceableTextures/CommandButtons/BTNBrilliance.tga")
call TasToolTipBox_SetObjectSlot('AIps', -2, "11", "ReplaceableTextures/CommandButtons/BTNEntrapmentWard.tga")
endfunction
endlibrary