Name | Type | is_array | initial_value |
--[[ TasSpellView 1.1c by Tasyen
displays with custom UI the abilites of not controled units in the command card
can use Total Initialization by Bribe
]]
do
TasSpellView = {
AutoRun = true --(true) will create Itself at 0s, (false) you need to InitSpellView()
,TocPath = "war3mapImported\\TasSpellView.toc"
,ParentFuncSimple = function()
if GetHandleId(BlzGetFrameByName("CommandBarFrame", 0)) > 0 then return BlzGetFrameByName("CommandBarFrame", 0) end
return BlzGetFrameByName("ConsoleUI", 0)
end
,ParentFunc = function()
-- if GetHandleId(BlzGetFrameByName("ConsoleUIBackdrop", 0)) > 0 then return BlzGetFrameByName("ConsoleUIBackdrop", 0) end
return BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0)
end
,UpdateTime = 0.1 -- lower number is faster
,ShowCooldown = true -- can be set async, needs BlzGetAbilityId for ability by index
,ToolTipSizeX = 0.26
,ToolTipPosX = 0.79
,ToolTipPosY = 0.165
,ToolTipPos = FRAMEPOINT_BOTTOMRIGHT
,Data = {}
,UnitSkills = {
-- you can store the abilities shown for that unitCode
--, otherwise the system will show the abilites found by index which pass the filter
[FourCC'Ulic'] = {[1]= FourCC'AUfn',[2]= FourCC'AUfu',[3]= FourCC'AUdr',[4]= FourCC'AUdd'}
}
,MOD_ABI = 1
,MOD_ABI_CODE = 0
,AbilityCache = {} -- makes performance better in V1.31 cause it lacks ParseTags and needs to do tooltip nonsense which with a cachce needs to be done only once.
}
local this = TasSpellView
if TasHeroLearnEx then
this.AbilityCache = TasHeroLearnEx.AbilityCache
this.GetAbilityData = TasHeroLearnEx.GetAbilityData
else
function this.GetAbilityData(abiCode, tag, convertFunc)
-- was this ability already parsed?
if not this.AbilityCache[abiCode..tag] then
-- calc it and store it
-- have ParseTags native?
if ParseTags then
local abiString = string.pack(">I4", abiCode)
this.AbilityCache[abiCode..tag] = ParseTags("<"..abiString..","..tag..">")
else
local backup = BlzGetAbilityExtendedTooltip(abiCode, 0)
local abiString = string.pack(">I4", abiCode)
BlzSetAbilityExtendedTooltip(abiCode, "<"..abiString..","..tag..">", 0)
this.AbilityCache[abiCode..tag] = BlzGetAbilityExtendedTooltip(abiCode, 0)
BlzSetAbilityExtendedTooltip(abiCode, backup, 0)
end
if convertFunc then this.AbilityCache[abiCode..tag] = convertFunc(this.AbilityCache[abiCode..tag]) end
end
return this.AbilityCache[abiCode..tag]
end
end
function this.AbiFilter(abi, text)
if BlzGetAbilityBooleanField(abi, ABILITY_BF_ITEM_ABILITY) then
return false
end
if BlzGetAbilityIntegerField(abi, ABILITY_IF_BUTTON_POSITION_NORMAL_X) == 0 and BlzGetAbilityIntegerField(abi, ABILITY_IF_BUTTON_POSITION_NORMAL_Y) == -11 then
return false
end
if text == "Tool tip missing!" or text == "" or text == " " then
return false
end
return true
end
this.GetUnitData = function(unit)
while table.remove(this.Data) do end
-- have presaved Data
if this.UnitSkills[GetUnitTypeId(unit)] then
for i, v in ipairs(this.UnitSkills[GetUnitTypeId(unit)]) do this.Data[i - 1] = v end
this.Data.Mod = this.MOD_ABI_CODE
else
this.Data.Mod = this.MOD_ABI
if BlzGetAbilityId then
-- store abiCode treat it like this.MOD_ABI_CODE
this.Data.Mod = this.MOD_ABI_CODE
end
local i = 0
local addCount = 0
local abi
while true do
abi = BlzGetUnitAbilityByIndex(unit, i)
if not abi then break end
if this.AbiFilter(abi, BlzGetAbilityStringLevelField(abi, ABILITY_SLF_TOOLTIP_NORMAL, 0)) then
if BlzGetAbilityId then
-- store abiCode treat it like this.MOD_ABI_CODE
abi = BlzGetAbilityId(abi)
this.Data[addCount] = abi
else
-- store the data
this.Data[addCount] = {
Icon = BlzGetAbilityStringLevelField(abi, ABILITY_SLF_ICON_NORMAL, 0)
,Name = BlzGetAbilityStringLevelField(abi, ABILITY_SLF_TOOLTIP_NORMAL, 0)
,Text = BlzGetAbilityStringLevelField(abi, ABILITY_SLF_TOOLTIP_NORMAL_EXTENDED, 0)
,Mana = BlzGetAbilityIntegerLevelField(abi, ABILITY_ILF_MANA_COST, 0)
,Cool = BlzGetAbilityRealLevelField(abi, ABILITY_RLF_COOLDOWN, 0)
,Range = R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_CAST_RANGE, 0))
,Area = R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_AREA_OF_EFFECT, 0))
}
if this.Data[addCount].Mana > 9999 then
this.Data[addCount].Mana = string.format( "\x25.0f", this.Data[addCount].Mana/1000).."k"
end
if this.Data[addCount].Range > 9999 then
this.Data[addCount].Range = string.format( "\x25.0f", this.Data[addCount].Range/1000).."k"
end
if this.Data[addCount].Area > 9999 then
this.Data[addCount].Area = string.format( "\x25.0f", this.Data[addCount].Area/1000).."k"
end
end
addCount = addCount + 1
end
i = i + 1
end
abi = nil
end
end
local LastAbiCode, LastAbiLevel, LastUnit
function this.Update()
local foundTooltip = false
local unit
if not UnitInfoGetUnit then
GroupEnumUnitsSelected(this.Group, GetLocalPlayer(), nil)
unit = FirstOfGroup(this.Group)
GroupClear(this.Group)
else
unit = UnitInfoPanelUnit
end
if unit ~= LastUnit then
LastUnit = unit
this.GetUnitData(unit)
end
local hasControl = IsUnitOwnedByPlayer(unit, GetLocalPlayer()) or GetPlayerAlliance(GetOwningPlayer(unit), GetLocalPlayer(), ALLIANCE_SHARED_CONTROL)
-- check for visible buttons, if any is visible then do not show TasSpellView
if not hasControl then
for i= 0, 11 do
if BlzFrameIsVisible(BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, i)) then
hasControl = true
break
end
end
end
local showSpellView = not hasControl
BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewSimpleFrame", 0), showSpellView)
BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewFrame", 0), showSpellView)
if showSpellView then
local data = this.Data
for i = 0, 11 do
BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButton", i), data[i])
if data[i] then
if this.Data.Mod == this.MOD_ABI then
BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButtonCooldown", i), false)
BlzFrameSetTexture(BlzGetFrameByName("TasSpellViewButtonBackdrop", i), data[i].Icon, 0, false)
BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButtonOverLayFrame", i), false)
elseif this.Data.Mod == this.MOD_ABI_CODE then
local level = GetUnitAbilityLevel(unit, data[i])
if this.ShowCooldown then
local cdRemain = BlzGetUnitAbilityCooldownRemaining(unit, data[i])
if cdRemain > 0 then
-- this be inaccurate when the map has systems to change cooldowns only during the casting.
local cdTotal = BlzGetUnitAbilityCooldown(unit, data[i], level - 1)
--print(GetObjectName(data[i]),cdRemain,cdTotal, cdRemain/cdTotal)
BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButtonCooldown", i), true)
BlzFrameSetValue(BlzGetFrameByName("TasSpellViewButtonCooldown", i), 100-(cdRemain/cdTotal)*100)
--print(BlzFrameIsVisible(BlzGetFrameByName("TasSpellViewButtonCooldown", i)), BlzFrameGetValue(BlzGetFrameByName("TasSpellViewButtonCooldown", i)))
else
BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButtonCooldown", i), false)
end
else
BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButtonCooldown", i), false)
end
BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButtonOverLayFrame", i), true)
BlzFrameSetText(BlzGetFrameByName("TasSpellViewButtonChargeText", i), level)
BlzFrameSetTexture(BlzGetFrameByName("TasSpellViewButtonBackdrop", i), BlzGetAbilityIcon(data[i]), 0, false)
end
else
BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButtonCooldown", i), false)
end
-- hovered?
if BlzFrameIsVisible(BlzGetFrameByName("TasSpellViewButtonToolTip", i)) then
foundTooltip = true
-- only update Tooltip when needed
if data[i] ~= LastAbiCode then
LastAbiCode = data[i]
-- LastAbiLevel = level
if this.Data.Mod == this.MOD_ABI then
BlzFrameSetTexture(BlzGetFrameByName("TasSpellViewTooltipIcon", 0), data[i].Icon, 0, false)
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipName", 0), data[i].Name)
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipText", 0), data[i].Text)
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipManaText", 0), data[i].Mana)
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipCooldownText", 0), data[i].Cool)
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipRangeText", 0), data[i].Range)
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipAreaText", 0), data[i].Area)
elseif this.Data.Mod == this.MOD_ABI_CODE then
local level = GetUnitAbilityLevel(unit, data[i])
local abi = BlzGetUnitAbility(unit, data[i])
BlzFrameSetTexture(BlzGetFrameByName("TasSpellViewTooltipIcon", 0), BlzGetAbilityIcon(data[i]), 0, false)
if level > 0 then
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipManaText", 0), BlzGetUnitAbilityManaCost(unit, data[i], level - 1))
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipCooldownText", 0), BlzGetUnitAbilityCooldown(unit, data[i], level - 1))
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipRangeText", 0), R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_CAST_RANGE, level - 1)))
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipAreaText", 0), R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_AREA_OF_EFFECT, level - 1)))
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipName", 0), BlzGetAbilityTooltip(data[i], level - 1))
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipText", 0), BlzGetAbilityExtendedTooltip(data[i], level - 1))
else
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipName", 0), BlzGetAbilityResearchTooltip(data[i], 0))
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipText", 0), BlzGetAbilityResearchExtendedTooltip(data[i], 0))
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipManaText", 0), BlzGetAbilityManaCost(data[i], 0))
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipCooldownText", 0), BlzGetAbilityCooldown(data[i], 0))
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipRangeText", 0), R2I(this.GetAbilityData(data[i], "Rng1")))
BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipAreaText", 0), R2I(this.GetAbilityData(data[i], "Area1")))
end
abi = nil
end
end
end
end
BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewTooltipFrame", 0), foundTooltip)
end
unit = nil
end
local InitFrames = function()
if not BlzLoadTOCFile(this.TocPath) then
print("|cffff0000TasSpellView - Error Reading Toc File at", this.TocPath)
end
this.ParentSimple = BlzCreateFrameByType("SIMPLEFRAME", "TasSpellViewSimpleFrame", this.ParentFuncSimple(), "", 0)
this.Parent = BlzCreateFrameByType("FRAME", "TasSpellViewFrame", this.ParentFunc(), "", 0)
for i = 0, 11 do
local frame = BlzCreateSimpleFrame("TasSpellViewButton", this.ParentSimple, i)
BlzFrameSetPoint(frame, FRAMEPOINT_CENTER, BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, i), FRAMEPOINT_CENTER, 0, 0.0)
local tooltipFrame = BlzCreateFrameByType("SIMPLEFRAME", "TasSpellViewButtonToolTip", frame, "", i)
BlzFrameSetLevel(frame, 6) -- reforged stuff
BlzFrameSetLevel(BlzGetFrameByName("TasSpellViewButtonOverLayFrame", i), 7) -- reforged stuff
BlzFrameSetTooltip(frame, tooltipFrame)
BlzFrameSetVisible(tooltipFrame, false)
BlzFrameSetVisible(BlzCreateFrame("TasSpellViewButtonCooldown", this.Parent, 0, i), false)
-- reserve HandleIds
BlzGetFrameByName("TasSpellViewButtonBackdrop", i)
BlzGetFrameByName("TasSpellViewButtonTextOverLay", i)
BlzGetFrameByName("TasSpellViewButtonOverLayFrame", i)
BlzGetFrameByName("TasSpellViewButtonChargeBox", i)
BlzGetFrameByName("TasSpellViewButtonChargeText", i)
end
if GetHandleId(BlzGetFrameByName("TasSpellViewButtonBackdrop", 1)) == 0 then
print("|cffff0000TasSpellView - Error Create TasSpellViewButton|r")
print(" Check Imported toc & fdf & TocPath in Map script")
print(" Imported toc needs to have empty ending line")
print(" fdf path in toc needs to match map imported path")
print(" TocPath in Map script needs to match map imported path")
end
-- create one ToolTip which shows data for current hovered inside a timer.
-- also reserve handleIds to allow async usage
BlzCreateFrame("TasSpellViewTooltipFrame", this.Parent, 0, 0)
BlzGetFrameByName("TasSpellViewTooltipBox", 0)
BlzGetFrameByName("TasSpellViewTooltipIcon", 0)
BlzGetFrameByName("TasSpellViewTooltipName", 0)
BlzGetFrameByName("TasSpellViewTooltipSeperator", 0)
BlzGetFrameByName("TasSpellViewTooltipText", 0)
BlzGetFrameByName("TasSpellViewTooltipManaText", 0)
BlzGetFrameByName("TasSpellViewTooltipCooldownText", 0)
BlzGetFrameByName("TasSpellViewTooltipRangeText", 0)
BlzGetFrameByName("TasSpellViewTooltipAreaText", 0)
BlzFrameSetSize(BlzGetFrameByName("TasSpellViewTooltipText", 0), this.ToolTipSizeX, 0)
BlzFrameSetAbsPoint(BlzGetFrameByName("TasSpellViewTooltipText", 0), this.ToolTipPos, this.ToolTipPosX, this.ToolTipPosY)
BlzFrameSetPoint(BlzGetFrameByName("TasSpellViewTooltipBox", 0), FRAMEPOINT_TOPLEFT, BlzGetFrameByName("TasSpellViewTooltipIcon", 0), FRAMEPOINT_TOPLEFT, -0.005, 0.005)
BlzFrameSetPoint(BlzGetFrameByName("TasSpellViewTooltipBox", 0), FRAMEPOINT_BOTTOMRIGHT, BlzGetFrameByName("TasSpellViewTooltipText", 0), FRAMEPOINT_BOTTOMRIGHT, 0.005, -0.005)
BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewTooltipFrame", 0), false)
BlzFrameSetVisible(this.ParentSimple, false)
BlzFrameSetVisible(this.Parent, false)
if GetHandleId(BlzGetFrameByName("TasSpellViewTooltipFrame", 0)) == 0 then
print("TasSpellView - Error", "Create TasSpellViewTooltipFrame")
print("Check Imported toc & fdf & TocPath")
end
end
function InitSpellView()
this.Group = CreateGroup()
this.Timer = CreateTimer()
TimerStart(this.Timer, this.UpdateTime, true, this.Update)
InitFrames()
if FrameLoaderAdd then FrameLoaderAdd(InitFrames) end
end
if this.AutoRun then
if OnInit then -- Total Initialization v5.2.0.1 by Bribe
OnInit.final(InitSpellView)
else -- without
local real = MarkGameStarted
function MarkGameStarted()
real()
InitSpellView()
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 TasSpellView initializer init_function requires optional Ascii, optional FrameLoader
// TasSpellView 1.1c by Tasyen
//displays with custom UI the abilites of not controled units in the command card
// when REFORGED = false you need to tell the abilityCodes used by units to have cooldown display
// the unit does not need to have the skills they are displayed when added that way.
// call TasSpellView_AddUnitCodeData('Ulic', "AUfn,AUfu,AUdr,AUdd")
globals
constant boolean REFORGED = true // have BlzGetAbilityId? otherwise false
public boolean AutoRun = true //(true) will create Itself at 0s, (false) you need to InitSpellView()
public string TocPath = "war3mapImported\\TasSpellView.toc"
public real UpdateTime = 0.1
public boolean ShowCooldown = true // can be set async, needs BlzGetAbilityId for ability by index
//ToolTip
public real ToolTipSizeX = 0.26
public real ToolTipPosX = 0.79
public real ToolTipPosY = 0.165
public framepointtype ToolTipPos = FRAMEPOINT_BOTTOMRIGHT
// currentSelected
public integer DataCount = 0
public integer DataMod = 0
public integer array DataAbiCode
public integer array DataMana
public real array DataRange
public real array DataAoe
public real array DataCool
public string array DataName
public string array DataText
public string array DataIcon
public framehandle ParentSimple
public framehandle Parent
public group Group
public timer Timer
public unit LastUnit = null
public integer MOD_ABI = 1
public integer MOD_ABI_CODE = 0
public string array UnitCodeText
public integer array UnitCodeType
public integer UnitCodeCount = 0
endglobals
public function ParentFuncSimple takes nothing returns framehandle
if GetHandleId(BlzGetFrameByName("CommandBarFrame", 0)) > 0 then
return BlzGetFrameByName("CommandBarFrame", 0)
endif
return BlzGetFrameByName("ConsoleUI", 0)
endfunction
public function ParentFunc takes nothing returns framehandle
// if GetHandleId(BlzGetFrameByName("ConsoleUIBackdrop", 0)) > 0 then
// return BlzGetFrameByName("ConsoleUIBackdrop", 0)
// endif
return BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0)
endfunction
public function AbiFilter takes ability abi, string text returns boolean
if BlzGetAbilityBooleanField(abi, ABILITY_BF_ITEM_ABILITY) then
return false
endif
if BlzGetAbilityIntegerField(abi, ABILITY_IF_BUTTON_POSITION_NORMAL_X) == 0 and BlzGetAbilityIntegerField(abi, ABILITY_IF_BUTTON_POSITION_NORMAL_Y) == -11 then
return false
endif
if text == "Tool tip missing!" or text == "" or text == " " then
return false
endif
return true
endfunction
public function AddUnitCodeData takes integer unitCode, string abiCodeString returns nothing
set UnitCodeCount = UnitCodeCount + 1
set UnitCodeType[UnitCodeCount] = unitCode
set UnitCodeText[UnitCodeCount] = abiCodeString
endfunction
public function GetUnitCodeData takes integer unitCode returns string
local integer i = UnitCodeCount
loop
exitwhen i <= 0
if unitCode == UnitCodeType[i] then
return UnitCodeText[i]
endif
set i = i - 1
endloop
return ""
endfunction
static if LIBRARY_Ascii then
public function AddSpellString takes string abiString returns nothing
local integer startIndex = 0
local integer skillCode
local integer addCount = 0
loop
exitwhen startIndex + 3 >= StringLength(abiString)
set skillCode = S2A(SubString(abiString, startIndex, startIndex + 4))
set startIndex = startIndex + 5
set DataAbiCode[addCount] = skillCode
set addCount = addCount + 1
endloop
set DataCount = addCount - 1
endfunction
endif
public function GetUnitData takes unit u returns nothing
local integer i = 0
local integer addCount = 0
local ability abi
local string abiString
set DataCount = 0
// have presaved Data
set abiString = GetUnitCodeData(GetUnitTypeId(u))
if abiString != "" then
static if LIBRARY_Ascii then
call AddSpellString(abiString)
endif
set DataMod = MOD_ABI_CODE
else
set DataMod = MOD_ABI
static if REFORGED then
// store abiCode treat it like MOD_ABI_CODE
set DataMod = MOD_ABI_CODE
endif
set i = 0
set addCount = 0
loop
set abi = BlzGetUnitAbilityByIndex(u, i)
exitwhen abi == null
if AbiFilter(abi, BlzGetAbilityStringLevelField(abi, ABILITY_SLF_TOOLTIP_NORMAL, 0)) then
static if REFORGED then
// store abiCode treat it like MOD_ABI_CODE
set DataAbiCode[addCount] = BlzGetAbilityId(abi)
else
// store the data
set DataIcon[addCount] = BlzGetAbilityStringLevelField(abi, ABILITY_SLF_ICON_NORMAL, 0)
set DataName[addCount] = BlzGetAbilityStringLevelField(abi, ABILITY_SLF_TOOLTIP_NORMAL, 0)
set DataText[addCount] = BlzGetAbilityStringLevelField(abi, ABILITY_SLF_TOOLTIP_NORMAL_EXTENDED, 0)
set DataMana[addCount] = BlzGetAbilityIntegerLevelField(abi, ABILITY_ILF_MANA_COST, 0)
set DataCool[addCount] = BlzGetAbilityRealLevelField(abi, ABILITY_RLF_COOLDOWN, 0)
set DataRange[addCount] = BlzGetAbilityRealLevelField(abi, ABILITY_RLF_CAST_RANGE, 0)
set DataAoe[addCount] = BlzGetAbilityRealLevelField(abi, ABILITY_RLF_AREA_OF_EFFECT, 0)
//if DataMana[addCount] > 9999 then
// set DataMana[addCount] = string.format( "\x25.0f", DataMana[addCount]/1000).."k"
//endif
//if DataRange[addCount] > 9999 then
//set DataRange[addCount] = string.format( "\x25.0f", DataRange[addCount]/1000).."k"
//endif
//if DataArea[addCount] > 9999 then
//set DataArea[addCount] = string.format( "\x25.0f", DataArea[addCount]/1000).."k"
//endif
endif
set addCount = addCount + 1
endif
set i = i + 1
endloop
set DataCount = addCount - 1
set abi = null
endif
endfunction
public function Update takes nothing returns nothing
local boolean foundTooltip = false
local unit u
local boolean hasControl
local boolean showSpellView
local integer i
local integer level
local real cdRemain
local real cdTotal
local integer abiCode
local ability abi
call GroupEnumUnitsSelected(Group, GetLocalPlayer(), null)
set u = FirstOfGroup(Group)
call GroupClear(Group)
if u != LastUnit then
set LastUnit = u
call GetUnitData(u)
endif
set hasControl = IsUnitOwnedByPlayer(u, GetLocalPlayer()) or GetPlayerAlliance(GetOwningPlayer(u), GetLocalPlayer(), ALLIANCE_SHARED_CONTROL)
// check for visible buttons, if any is visible then do not show TasSpellView
if not hasControl then
set i = 0
loop
if BlzFrameIsVisible(BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, 0)) then
set hasControl = true
exitwhen true
endif
exitwhen i == 11
set i = i + 1
endloop
endif
set showSpellView = not hasControl
call BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewSimpleFrame", 0), showSpellView)
call BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewFrame", 0), showSpellView)
if showSpellView then
set i = 0
loop
if i <= DataCount then
call BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButton", i), true)
if DataMod == MOD_ABI then
call BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButtonCooldown", i), false)
call BlzFrameSetTexture(BlzGetFrameByName("TasSpellViewButtonBackdrop", i), DataIcon[i], 0, false)
call BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButtonOverLayFrame", i), false)
elseif DataMod == MOD_ABI_CODE then
set abiCode = DataAbiCode[i]
set level = GetUnitAbilityLevel(u, abiCode)
if ShowCooldown then
set cdRemain = BlzGetUnitAbilityCooldownRemaining(u, abiCode)
if cdRemain > 0 then
// this be inaccurate when the map has systems to change cooldowns only during the casting.
set cdTotal = BlzGetUnitAbilityCooldown(u, abiCode, level - 1)
//print(GetObjectName(data[i]),cdRemain,cdTotal, cdRemain/cdTotal)
call BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButtonCooldown", i), true)
call BlzFrameSetValue(BlzGetFrameByName("TasSpellViewButtonCooldown", i), 100-(cdRemain/cdTotal)*100)
//print(BlzFrameIsVisible(BlzGetFrameByName("TasSpellViewButtonCooldown", i)), BlzFrameGetValue(BlzGetFrameByName("TasSpellViewButtonCooldown", i)))
else
call BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButtonCooldown", i), false)
endif
else
call BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButtonCooldown", i), false)
endif
call BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButtonOverLayFrame", i), true)
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewButtonChargeText", i), I2S(level))
call BlzFrameSetTexture(BlzGetFrameByName("TasSpellViewButtonBackdrop", i), BlzGetAbilityIcon(abiCode), 0, false)
endif
else
call BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButtonCooldown", i), false)
call BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewButton", i), false)
endif
// hovered?
if BlzFrameIsVisible(BlzGetFrameByName("TasSpellViewButtonToolTip", i)) then
set foundTooltip = true
if DataMod == MOD_ABI then
call BlzFrameSetTexture(BlzGetFrameByName("TasSpellViewTooltipIcon", 0), DataIcon[i], 0, false)
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipName", 0), DataName[i])
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipText", 0), DataText[i])
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipManaText", 0), I2S(DataMana[i]))
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipCooldownText", 0), R2SW(DataCool[i],1,1))
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipRangeText", 0), I2S(R2I(DataRange[i])))
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipAreaText", 0), I2S(R2I(DataAoe[i])))
elseif DataMod == MOD_ABI_CODE then
set abiCode = DataAbiCode[i]
set level = GetUnitAbilityLevel(u, DataAbiCode[i])
set abi = BlzGetUnitAbility(u, abiCode)
call BlzFrameSetTexture(BlzGetFrameByName("TasSpellViewTooltipIcon", 0), BlzGetAbilityIcon(abiCode), 0, false)
if level > 0 then
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipManaText", 0), I2S(BlzGetUnitAbilityManaCost(u, abiCode, level - 1)))
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipCooldownText", 0), R2SW(BlzGetUnitAbilityCooldown(u, abiCode, level - 1),1,1))
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipRangeText", 0), I2S(R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_CAST_RANGE, level - 1))))
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipAreaText", 0), I2S(R2I(BlzGetAbilityRealLevelField(abi, ABILITY_RLF_AREA_OF_EFFECT, level - 1))))
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipName", 0), BlzGetAbilityTooltip(abiCode, level - 1))
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipText", 0), BlzGetAbilityExtendedTooltip(abiCode, level - 1))
else
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipName", 0), BlzGetAbilityResearchTooltip(abiCode, 0))
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipText", 0), BlzGetAbilityResearchExtendedTooltip(abiCode, 0))
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipManaText", 0), I2S(BlzGetAbilityManaCost(abiCode, 0)))
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipCooldownText", 0), R2SW(BlzGetAbilityCooldown(abiCode, 0),1,1))
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipRangeText", 0), "0")
call BlzFrameSetText(BlzGetFrameByName("TasSpellViewTooltipAreaText", 0), "0")
endif
endif
endif
exitwhen i == 11
set i = i + 1
endloop
call BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewTooltipFrame", 0), foundTooltip)
endif
set u = null
set abi = null
endfunction
public function InitFrames takes nothing returns nothing
local integer i
local framehandle frame
local framehandle tooltipFrame
if not BlzLoadTOCFile(TocPath) then
call BJDebugMsg("|cffff0000TasSpellView - Error Reading Toc File at: " + TocPath)
endif
set ParentSimple = BlzCreateFrameByType("SIMPLEFRAME", "TasSpellViewSimpleFrame", ParentFuncSimple(), "", 0)
set Parent = BlzCreateFrameByType("FRAME", "TasSpellViewFrame", ParentFunc(), "", 0)
set i = 0
loop
set frame = BlzCreateSimpleFrame("TasSpellViewButton", ParentSimple, i)
call BlzFrameSetPoint(frame, FRAMEPOINT_CENTER, BlzGetOriginFrame(ORIGIN_FRAME_COMMAND_BUTTON, i), FRAMEPOINT_CENTER, 0, 0.0)
call BlzFrameSetLevel(frame, 6) // reforged stuff
call BlzFrameSetLevel(BlzGetFrameByName("TasSpellViewButtonOverLayFrame", i), 7) // reforged stuff
set tooltipFrame = BlzCreateFrameByType("SIMPLEFRAME", "TasSpellViewButtonToolTip", frame, "", i)
call BlzFrameSetTooltip(frame, tooltipFrame)
call BlzFrameSetVisible(tooltipFrame, false)
call BlzFrameSetVisible(BlzCreateFrame("TasSpellViewButtonCooldown", Parent, 0, i), false)
// reserve HandleIds
call BlzGetFrameByName("TasSpellViewButtonBackdrop", i)
call BlzGetFrameByName("TasSpellViewButtonTextOverLay", i)
call BlzGetFrameByName("TasSpellViewButtonOverLayFrame", i)
call BlzGetFrameByName("TasSpellViewButtonChargeBox", i)
call BlzGetFrameByName("TasSpellViewButtonChargeText", i)
set i = i + 1
exitwhen i > 11
endloop
if GetHandleId(BlzGetFrameByName("TasSpellViewButtonBackdrop", 1)) == 0 then
call BJDebugMsg("|cffff0000TasSpellView - Error Create TasSpellViewButton|r")
call BJDebugMsg(" Check Imported toc & fdf & TocPath in Map script")
call BJDebugMsg(" Imported toc needs to have empty ending line")
call BJDebugMsg(" fdf path in toc needs to match map imported path")
call BJDebugMsg(" TocPath in Map script needs to match map imported path")
endif
// create one ToolTip which shows data for current hovered inside a timer.
// also reserve handleIds to allow async usage
call BlzCreateFrame("TasSpellViewTooltipFrame", Parent, 0, 0)
call BlzGetFrameByName("TasSpellViewTooltipBox", 0)
call BlzGetFrameByName("TasSpellViewTooltipIcon", 0)
call BlzGetFrameByName("TasSpellViewTooltipName", 0)
call BlzGetFrameByName("TasSpellViewTooltipSeperator", 0)
call BlzGetFrameByName("TasSpellViewTooltipText", 0)
call BlzGetFrameByName("TasSpellViewTooltipManaText", 0)
call BlzGetFrameByName("TasSpellViewTooltipCooldownText", 0)
call BlzGetFrameByName("TasSpellViewTooltipRangeText", 0)
call BlzGetFrameByName("TasSpellViewTooltipAreaText", 0)
call BlzFrameSetSize(BlzGetFrameByName("TasSpellViewTooltipText", 0), ToolTipSizeX, 0)
call BlzFrameSetAbsPoint(BlzGetFrameByName("TasSpellViewTooltipText", 0), ToolTipPos, ToolTipPosX, ToolTipPosY)
call BlzFrameSetPoint(BlzGetFrameByName("TasSpellViewTooltipBox", 0), FRAMEPOINT_TOPLEFT, BlzGetFrameByName("TasSpellViewTooltipIcon", 0), FRAMEPOINT_TOPLEFT, -0.005, 0.005)
call BlzFrameSetPoint(BlzGetFrameByName("TasSpellViewTooltipBox", 0), FRAMEPOINT_BOTTOMRIGHT, BlzGetFrameByName("TasSpellViewTooltipText", 0), FRAMEPOINT_BOTTOMRIGHT, 0.005, -0.005)
call BlzFrameSetVisible(BlzGetFrameByName("TasSpellViewTooltipFrame", 0), false)
call BlzFrameSetVisible(ParentSimple, false)
call BlzFrameSetVisible(Parent, false)
if GetHandleId(BlzGetFrameByName("TasSpellViewTooltipFrame", 0)) == 0 then
call BJDebugMsg("TasSpellView - Error - Create TasSpellViewTooltipFrame")
call BJDebugMsg("Check Imported toc & fdf & TocPath")
endif
endfunction
function InitSpellView takes nothing returns nothing
set Group = CreateGroup()
set Timer = CreateTimer()
call TimerStart(Timer, UpdateTime, true, function Update)
call InitFrames()
static if LIBRARY_FrameLoader then
call FrameLoaderAdd(function InitFrames)
endif
endfunction
private function init_function takes nothing returns nothing
if AutoRun then
call InitSpellView()
endif
endfunction
endlibrary