- Joined
- Jul 18, 2010
- Messages
- 2,377
This will probably get a vjass port in some days.
call TasToolTipBox_AddDataBatch(null , 'htow' , "hpea,Rhpm,hkee")
// townhall trains/researches this 3 rawCodes in its default view.
call TasToolTipBox_SetObjectSlot('hpea' , -2 , "120" , "ReplaceableTextures/CommandButtons/BTNBrilliance.tga")
--[[ 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
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
// ==========