Antares
Spell Reviewer
- Joined
- Dec 13, 2009
- Messages
- 982
Moved resource.
Approved
Approved
-- GetDisabledIcon by Tasyen
-- a function to get the disabled version when providing the enabled version
do
local data = {}
function GetDisabledIcon(icon)
if not type(icon) == "string" then return icon end
if icon == "" or icon == " " then return icon end
--ReplaceableTextures\CommandButtons\BTNHeroPaladin.tga -> ReplaceableTextures\CommandButtonsDisabled\DISBTNHeroPaladin.tga
if not data[icon] and string.sub(icon,35,35) ~= "\\" then return icon end --this string has not enough chars return it
if not data[icon] then
local old = icon
-- make it lower to reduce the amount of cases and for warcraft 3 FilePath case does not matter
icon = string.lower(icon)
if string.find(icon, "commandbuttons\\btn") then data[old] = string.gsub(icon, "commandbuttons\\btn", "commandbuttonsdisabled\\disbtn" )
-- default wacraft 3 style
elseif string.find(icon, "passivebuttons\\pasbtn") then data[old] = string.gsub(icon, "passivebuttons\\pasbtn", "commandbuttonsdisabled\\dispasbtn" )
--recommented by hiveworkshop
elseif string.find(icon, "passivebuttons\\pas") then data[old] = string.gsub(icon, "passivebuttons\\pas", "commandbuttonsdisabled\\dispas" )
elseif string.find(icon, "commandbuttons\\atc") then data[old] = string.gsub(icon, "commandbuttons\\atc", "commandbuttonsdisabled\\disbtn" )
elseif string.find(icon, "commandbuttons\\pasbtn") then data[old] = string.gsub(icon, "commandbuttons\\pasbtn", "commandbuttonsdisabled\\dispasbtn" )
end
icon = old
end
return data[icon] or ""
end
end
-- GetDisabledIcon by Tasyen
-- a function to get the disabled version when providing the enabled version
--no cache version
function GetDisabledIcon(icon)
if not type(icon) == "string" then return icon end
if icon == "" or icon == " " then return icon end
--ReplaceableTextures\CommandButtons\BTNHeroPaladin.tga -> ReplaceableTextures\CommandButtonsDisabled\DISBTNHeroPaladin.tga
if string.sub(icon,35,35) ~= "\\" then return icon end --this string has not enough chars return it
-- make it lower to reduce the amount of cases and for warcraft 3 FilePath case does not matter
icon = string.lower(icon)
if string.find(icon, "commandbuttons\\btn") then return string.gsub(icon, "commandbuttons\\btn", "commandbuttonsdisabled\\disbtn" )
-- default wacraft 3 style
elseif string.find(icon, "passivebuttons\\pasbtn") then return string.gsub(icon, "passivebuttons\\pasbtn", "commandbuttonsdisabled\\dispasbtn" )
--recommented by hiveworkshop
elseif string.find(icon, "passivebuttons\\pas") then return string.gsub(icon, "passivebuttons\\pas", "commandbuttonsdisabled\\dispas" )
elseif string.find(icon, "commandbuttons\\atc") then return string.gsub(icon, "commandbuttons\\atc", "commandbuttonsdisabled\\disbtn" )
--ANeg
elseif string.find(icon, "commandbuttons\\pasbtn") then return string.gsub(icon, "commandbuttons\\pasbtn", "commandbuttonsdisabled\\dispasbtn" )
end
return icon
end
// GetDisabledIcon by Tasyen
// a function to get the disabled version when providing the enabled version
function GetDisabledIcon takes string icon returns string
if icon == null or icon == "" or icon == " " then
return icon
endif
//ReplaceableTextures\CommandButtons\BTNHeroPaladin.tga -> ReplaceableTextures\CommandButtonsDisabled\DISBTNHeroPaladin.tga
if SubString(icon, 34, 35) != "\\" then
return icon
endif //this string has not enough chars return it
//string.len(icon) < 34 then return icon end //this string has not enough chars return it
set icon = StringCase(icon, false)
if SubString(icon, 20, 38) == "commandbuttons\\btn" then
return SubString(icon, 0, 20) + "CommandButtonsDisabled\\DIS" + SubString(icon, 35, StringLength(icon))
endif
if SubString(icon, 20, 41) == "passivebuttons\\pasbtn" then
return SubString(icon, 0, 20) + "CommandButtonsDisabled\\DIS" + SubString(icon, 35, StringLength(icon))
endif
if SubString(icon, 20, 38) == "passivebuttons\\pas" then
return SubString(icon, 0, 20) + "CommandButtonsDisabled\\DIS" + SubString(icon, 35, StringLength(icon))
endif
if SubString(icon, 20, 38) == "commandbuttons\\atc" then
return SubString(icon, 0, 20) + "CommandButtonsDisabled\\DIS" + SubString(icon, 35, StringLength(icon))
endif
if SubString(icon, 20, 41) == "commandbuttons\\pasbtn" then
return SubString(icon, 0, 20) + "CommandButtonsDisabled\\DIS" + SubString(icon, 35, StringLength(icon))
endif
return icon
endfunction
//demo
call BJDebugMsg(BlzGetAbilityIcon('Hpal') + "->" + GetDisabledIcon(BlzGetAbilityIcon('Hpal') ))
call BJDebugMsg(BlzGetAbilityIcon('AHbz') + "->" + GetDisabledIcon(BlzGetAbilityIcon('AHbz') ))
call BJDebugMsg(BlzGetAbilityIcon('ANeg') + "->" + GetDisabledIcon(BlzGetAbilityIcon('ANeg') ))
call BJDebugMsg(BlzGetAbilityIcon('AHab') + "->" + GetDisabledIcon(BlzGetAbilityIcon('AHab') ))
function Test takes string icon returns nothing
local framehandle blademaster = BlzCreateFrameByType("BACKDROP", "Blademaster", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
local framehandle blademaster2 = BlzCreateFrameByType("BACKDROP", "Blademaster", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
set udg_Counter = udg_Counter + 1
call BlzFrameSetSize(blademaster, 0.03, 0.03)
call BlzFrameSetAbsPoint(blademaster, FRAMEPOINT_CENTER, 0.4, 0.25 + udg_Counter*0.04)
call BlzFrameSetTexture(blademaster, icon,0, true)
call BlzFrameSetSize(blademaster2, 0.03, 0.03)
call BlzFrameSetAbsPoint(blademaster2, FRAMEPOINT_CENTER, 0.35, 0.25 + udg_Counter*0.04)
call BlzFrameSetTexture(blademaster2, GetDisabledIcon(icon),0, true)
endfunction
--demo
print(BlzGetAbilityIcon(FourCC('Hpal')), "->", GetDisabledIcon(BlzGetAbilityIcon(FourCC('Hpal')) ))
print(BlzGetAbilityIcon(GetUnitTypeId(udg_Unit)), "->", GetDisabledIcon(BlzGetAbilityIcon(GetUnitTypeId(udg_Unit))))
print(BlzGetAbilityIcon(FourCC('AHbz')), "->", GetDisabledIcon(BlzGetAbilityIcon(FourCC('AHbz')) ))
print(BlzGetAbilityIcon(FourCC('ANeg')), "->", GetDisabledIcon(BlzGetAbilityIcon(FourCC('ANeg')) ))
function Test(icon)
if not udg_Counter then udg_Counter = 0 end
local blademaster = BlzCreateFrameByType("BACKDROP", "Blademaster", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
local blademaster2 = BlzCreateFrameByType("BACKDROP", "Blademaster", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
udg_Counter = udg_Counter + 1
BlzFrameSetSize(blademaster, 0.03, 0.03)
BlzFrameSetAbsPoint(blademaster, FRAMEPOINT_CENTER, 0.4, 0.25 + udg_Counter*0.04)
BlzFrameSetTexture(blademaster, icon,0, true)
BlzFrameSetSize(blademaster2, 0.03, 0.03)
BlzFrameSetAbsPoint(blademaster2, FRAMEPOINT_CENTER, 0.35, 0.25 + udg_Counter*0.04)
BlzFrameSetTexture(blademaster2, GetDisabledIcon(icon),0, true)
end
Test(BlzGetAbilityIcon(FourCC('Hpal')))
Test(BlzGetAbilityIcon(FourCC('AHbz')))
Test(BlzGetAbilityIcon(FourCC('ANeg')))
Test(BlzGetAbilityIcon(FourCC('AHab')))