--[[ TasSkillSetPicker V1.2 by Tasyen
TasSkillSetPicker.DefineCategory(icon, text) -> number categoryValue
make a new category
categories need to be made before the UI is created.
TasSkillSetPicker.Add(spellCode, category)
add an new Spell as option with category.
i Suggest to store categories in variables and add them
TasSkillSetPicker.Add('AHhb', 1 + 2)
spellCode can be a Table expects some Keys {Icon = img, Text = bigText, Name = smallText}
you can add after the ui was created or before.
this can be used to set the category of already added choices
TasSkillSetPicker.LockCategory(buttonIndex, category)
the skill selected at buttonIndex needs to have this category, it can have other categories aswell.
buttonIndex starts with 1
TasSkillSetPicker.BanCategory(buttonIndex, category)
the skill selected at buttonIndex can not have this category.
TasSkillSetPicker.PlayerAccept(player)
finish player, fills unset slots with randoms
TasSkillSetPicker.ForcePickNow()
all players PLAYER_SLOT_STATE_PLAYING are forced to accept now, if they did not already.
TasSkillSetPicker.ResetPlayer([player])
players choosen data is removed and can use ui again
no player = all players
TasSkillSetPicker.ShowOtherPlayerBars([show, player])
TasSkillSetPicker.ClearData()
remove all choseable options.
requires
GetPlayerColorTexture
TasButtonList V14 or higher
TasWindow
TasFrameList
TasFrameAction
optional
TasAbilityData (ToolTipGenInfo = true)
]]
do
local this = {}
this.Show = true -- Show on Creation
this.TocPath = "war3mapImported\\TasSkillSetPicker.toc"
this.BarSlotCount = 6 -- The amount of Skills a Player picks & Buttons in one Bar. Expects 1 to 12. 6 are one Row, 12 are 2 Rows. You could choose more but more rows was not coded and therefore will look bad. Dont change this value after creation
this.ParentFunc = function() return BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0) end
this.PosX = 0.77
this.PosY = 0.55
this.SizeX = 0.51 -- total Size with Bars & editor
this.SizeY = 0.37
this.Pos = FRAMEPOINT_TOPRIGHT
this.ToolTipGenInfo = true -- (true) Add generic spell Fields to the displayed tooltip text (only for number choices). requires GetGenericSpellData
this.ShowBars = true -- preview other player builts (false) makes the UI smaller
this.ShowEnemy = true -- can look into enemy builts false/true?
this.Localize = true -- try to throw texts in to GetLocalizedString
-- These are images displayed over a category button that mets the conditions. Only one of them is displayed at once, or none of them.
-- They are displayed with reduced Alpha
this.FilterNotAllowed = "ui/widgets/battlenet/chaticons/bnet-squelch" -- TasSkillSetPicker.BanCategory
this.FilterNotUsed = "textures/black32" -- user does not search by this category
this.FilterEnforced = "ui/widgets/glues/gluescreen-checkbox-check" -- TasSkillSetPicker.LockCategory
-- accept/random/show Button
-- a button that allows the user to show a hidden TasSkillSetPicker
this.ShowButtonShow = true
this.ShowButtonParentFunc = function() return BlzGetFrameByName("InsideMainPanel", 0) end
this.ShowButtonText = "Skill Picker" --tries Localizing
this.ShowButtonPosX = 0.1
this.ShowButtonPosY = 0.55
-- Inside a SkillBar what to display for no/0 skill?
-- not used in table mode
this.NoSkillIcon = "replaceabletextures/commandbuttons/btntemp"
this.NoSkillTooltip = "No Skill"
-- accept/random Button
this.ControlButtonSizeX = 0.085
this.ControlButtonSizeY = 0.03
this.RandomButtonText = "RANDOM" --tries Localizing
this.AcceptButtonText = "ACCEPT" --tries Localizing
this.RandomButtonTooltip = "Randomize the current Slot" --tries Localizing
this.AcceptButtonTooltip = "Finish selection & Fills unused slots" --tries Localizing
this.FreeButtonText = "" --tries Localizing
this.FreeButtonTooltip = "" --tries Localizing
this.FreeButtonShow = false --show the free button which function you need to code function this.ActionButtonFree(frame, player)
this.EditorBarTitle = "SkillSet Editor"
this.EditorBarIcon = "replaceabletextures/commandbuttons/btnengineeringupgrade"
this.SearchBarTooltip = "Search in Ability Name & Text, Ignores Case"
this.AllowPlayer = function(player)
-- this should be edited for your maps need.
-- used by ForcePickNow & to consider if this player is added to the other players view
-- return false to reject a player
if GetPlayerSlotState(player) ~= PLAYER_SLOT_STATE_PLAYING then return false end
return true
end
this.DoLocalize = function(text) if this.Localize then return GetLocalizedString(text) else return text end end
this.PlayerDone = function(player, spellArray)
-- this function happens when a player finished the picking
this.PlayerHasDone[player] = true -- remember this player finished
this.EnableControl(player, false)
-- what to do with the choice
TasHeroLearnEx.HeroData[player] = spellArray
end
function this.ActionButtonFree(frame, player)
-- What happens when the Free button is pressed
print("Free Button")
end
-- how to display a choice in the list and its tooltip?
function this.ActionSpellListDraw(frameObject, data)
if not data then data = 0 end
if type(data) == "number" then
if data == 0 then
BlzFrameSetTexture(frameObject.Icon, this.NoSkillIcon, 0, false)
BlzFrameSetTexture(frameObject.IconPush, this.NoSkillIcon, 0, false)
BlzFrameSetTexture(frameObject.IconOff, this.NoSkillIcon, 0, false)
BlzFrameSetText(frameObject.Text, this.NoSkillTooltip)
BlzFrameSetTexture(frameObject.ToolTipFrameIcon, this.NoSkillIcon, 0, false)
BlzFrameSetText(frameObject.ToolTipFrameName, this.NoSkillTooltip)
BlzFrameSetText(frameObject.ToolTipFrameText, "")
else
BlzFrameSetTexture(frameObject.Icon, BlzGetAbilityIcon(data), 0, false)
BlzFrameSetTexture(frameObject.IconPush, BlzGetAbilityIcon(data), 0, false)
BlzFrameSetTexture(frameObject.IconOff, BlzGetAbilityIcon(data), 0, false)
BlzFrameSetText(frameObject.Text, GetObjectName(data))
BlzFrameSetTexture(frameObject.ToolTipFrameIcon, BlzGetAbilityIcon(data), 0, false)
BlzFrameSetText(frameObject.ToolTipFrameName, GetObjectName(data))
--BlzFrameSetText(frameObject.ToolTipFrameText, BlzGetAbilityResearchExtendedTooltip(data, 0))
if this.ToolTipGenInfo and data > 0 then
BlzFrameSetText(frameObject.ToolTipFrameText, BlzGetAbilityResearchExtendedTooltip(data, 0).. TasAbilityData.GetGenericFields(data))
else
BlzFrameSetText(frameObject.ToolTipFrameText, BlzGetAbilityResearchExtendedTooltip(data, 0))
end
end
elseif type(data) == "table" then
BlzFrameSetTexture(frameObject.Icon, data.Icon, 0, false)
BlzFrameSetTexture(frameObject.IconPush, data.Icon, 0, false)
BlzFrameSetTexture(frameObject.IconOff, data.Icon, 0, false)
BlzFrameSetText(frameObject.Text, data.Text)
BlzFrameSetTexture(frameObject.ToolTipFrameIcon, data.Icon, 0, false)
BlzFrameSetText(frameObject.ToolTipFrameName, data.Name)
BlzFrameSetText(frameObject.ToolTipFrameText, data.Text)
end
end
-- how to search
function this.ActionSpellListSearch(data, text, buttonListObject)
if not text or text == "" then return true end
text = string.lower(text)
if type(data) == "number" then
if string.find(string.lower(GetObjectName(data)), text, 1, true) then return true end
if string.find(string.lower(BlzGetAbilityTooltip(data, 0)), text, 1, true) then return true end
if string.find(string.lower(BlzGetAbilityResearchTooltip(data, 0)), text, 1, true) then return true end
if string.find(string.lower(BlzGetAbilityExtendedTooltip(data, 0)), text, 1, true) then return true end
if string.find(string.lower(BlzGetAbilityResearchExtendedTooltip(data, 0)), text, 1, true) then return true end
elseif type(data) == "table" then
if string.find(string.lower(data.Name), text, 1, true) then return true end
if string.find(string.lower(data.Text), text, 1, true) then return true end
end
return false
end