Name | Type | is_array | initial_value |
HeroScoreFrame_Event | real | No | |
HeroScoreFrame_Icon | imagefile | Yes | |
HeroScoreFrame_PlayerA | player | No | |
HeroScoreFrame_PlayerB | player | No | |
HeroScoreFrame_Text | string | Yes | |
HeroScoreFrame_Unit | unit | No |
TasButtonAction = {
Set = function(frame, action)
-- first call?
if not TasButtonAction.Trigger then
-- yes, Create the Trigger and the click handler
TasButtonAction.Trigger = CreateTrigger()
TriggerAddAction(TasButtonAction.Trigger, function()
local frame = BlzGetTriggerFrame()
-- remove Focus for the local clicking player
if GetTriggerPlayer() == GetLocalPlayer() then
BlzFrameSetEnable(frame, false)
BlzFrameSetEnable(frame, true)
end
-- call the action set for that frame
TasButtonAction[frame](frame, GetTriggerPlayer())
frame = nil
end)
end
-- create the click event only when it does not exist yet.
if not TasButtonAction[frame] then
BlzTriggerRegisterFrameEvent(TasButtonAction.Trigger, frame, FRAMEEVENT_CONTROL_CLICK)
end
TasButtonAction[frame] = action
end
}
NumberDialog = {
Value = __jarray(0)
,Action = {}
,IconType = {"NumberDialogTitelIcon", "NumberDialogTitelIconGold", "NumberDialogTitelIconLumber"}
}
function NumberDialog.Add(player, value)
NumberDialog.Value[player] = NumberDialog.Value[player]*10 + value
if NumberDialog.Value[player] > 999999999 then NumberDialog.Value[player] = 999999999
elseif NumberDialog.Value[player] < 0 then NumberDialog.Value[player] = 999999999
end
if GetLocalPlayer() == player then
BlzFrameSetText(BlzGetFrameByName("NumberDisplayText", 0), NumberDialog.Value[player])
end
end
function ShowNumberDialog(player, iconType, action)
if GetLocalPlayer() == player then
BlzFrameSetVisible(BlzGetFrameByName("NumberDialog", 0), true)
BlzFrameSetVisible(BlzGetFrameByName(NumberDialog.IconType[1], 0), false)
BlzFrameSetVisible(BlzGetFrameByName(NumberDialog.IconType[2], 0), false)
BlzFrameSetVisible(BlzGetFrameByName(NumberDialog.IconType[3], 0), false)
BlzFrameSetVisible(BlzGetFrameByName(NumberDialog.IconType[iconType], 0), true)
end
NumberDialog.Action[player] = action
end
function CreateNumberDialog(parent)
if not parent then parent = BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0) end
BlzLoadTOCFile("war3mapImported\\NumberDialog.toc")
BlzCreateFrame("NumberDialog", parent, 0, 0)
if GetHandleId(BlzGetFrameByName("NumberDialog", 0)) == 0 then print("Error - Creating NumberDialog") end
BlzFrameSetAbsPoint(BlzGetFrameByName("NumberDialog", 0), FRAMEPOINT_CENTER, 0.4, 0.3)
BlzFrameSetVisible(BlzGetFrameByName("NumberDialog", 0), false)
BlzGetFrameByName("NumberDisplayText", 0)
BlzGetFrameByName("NumberDialogTitelIcon", 0)
BlzGetFrameByName("NumberDialogTitelIconGold", 0)
BlzGetFrameByName("NumberDialogTitelIconLumber", 0)
TasButtonAction.Set(BlzGetFrameByName("NumberButton0", 0), function()
NumberDialog.Add(GetTriggerPlayer(), 0)
end)
TasButtonAction.Set(BlzGetFrameByName("NumberButton1", 0), function()
NumberDialog.Add(GetTriggerPlayer(), 1)
end)
TasButtonAction.Set(BlzGetFrameByName("NumberButton2", 0), function()
NumberDialog.Add(GetTriggerPlayer(), 2)
end)
TasButtonAction.Set(BlzGetFrameByName("NumberButton3", 0), function()
NumberDialog.Add(GetTriggerPlayer(), 3)
end)
TasButtonAction.Set(BlzGetFrameByName("NumberButton4", 0), function()
NumberDialog.Add(GetTriggerPlayer(), 4)
end)
TasButtonAction.Set(BlzGetFrameByName("NumberButton5", 0), function()
NumberDialog.Add(GetTriggerPlayer(), 5)
end)
TasButtonAction.Set(BlzGetFrameByName("NumberButton6", 0), function()
NumberDialog.Add(GetTriggerPlayer(), 6)
end)
TasButtonAction.Set(BlzGetFrameByName("NumberButton7", 0), function()
NumberDialog.Add(GetTriggerPlayer(), 7)
end)
TasButtonAction.Set(BlzGetFrameByName("NumberButton8", 0), function()
NumberDialog.Add(GetTriggerPlayer(), 8)
end)
TasButtonAction.Set(BlzGetFrameByName("NumberButton9", 0), function()
NumberDialog.Add(GetTriggerPlayer(), 9)
end)
TasButtonAction.Set(BlzGetFrameByName("AcceptButton", 0), function()
BlzFrameSetVisible(BlzFrameGetParent(BlzGetTriggerFrame()), false)
NumberDialog.Action[GetTriggerPlayer()](NumberDialog.Value[GetTriggerPlayer()])
end)
TasButtonAction.Set(BlzGetFrameByName("CancelButton", 0), function()
if NumberDialog.Value[GetTriggerPlayer()] == 0 then
BlzFrameSetVisible(BlzFrameGetParent(BlzGetTriggerFrame()), false)
else
NumberDialog.Value[GetTriggerPlayer()] = 0
NumberDialog.Add(GetTriggerPlayer(), 0)
end
end)
end
--[[
HeroScoreFrame 1.5e
by Tasyen
HeroScoreFrame is a Frame-UI System for a Hero-Centric map.
The UI is only shown while the player holds a key (default Tab) and shows some Infos about the Player's Heroes.
Throws realVariable events when the GUI variable udg_HeroScoreFrame_Text exists, expects all of them in such a case.
udg_HeroScoreFrame_PlayerA, udg_HeroScoreFrame_PlayerB, udg_HeroScoreFrame_Event, udg_HeroScoreFrame_Unit, udg_HeroScoreFrame_Icon[], udg_HeroScoreFrame_Text[]
udg_HeroScoreFrame_Event 1.0 = Before Swaping players
udg_HeroScoreFrame_Event 2.0 = After Swaping players
udg_HeroScoreFrame_Event 3.0 = Before Switch Teams
udg_HeroScoreFrame_Event 4.0 = After Switch Teams
udg_HeroScoreFrame_Event 5.0 = Update ScoreFrameInfo
udg_HeroScoreFrame_Event -1.0 = Request Swap
udg_HeroScoreFrame_Event -2.0 = Share
udg_HeroScoreFrame_Event -3.0 = ShareAdv
function HeroScoreFrameGetPlayerContext(player)
find the first used HeroScoreFrame used by Player and return the createContext
returns -1, when the player does not use any
function HeroScoreFrameSetTargetUnit(createContext, unit)
When AutoSearchTarget is active the unit should be owned by the player using that card
function HeroScoreFrameSetTargetPlayer(createContext, player)
Makes the HeroScoreFrame with CreateContext target player
A HeroSccoreFrame with player null will hide itself
function HeroScoreFrameSetTargetTimer(createContext, timer)
Read timer to display AutoReviveTime.
function HeroScoreFrameSetFaceOverlayText(createContext, text)
Set Current Text of the OverlayText, is overwritten every Timeout when a timer is set
function HeroScoreFrameGetTargetPlayer(createContext)
function HeroScoreFrameGetTargetUnit(createContext)
function HeroScoreFrameSetScale(scale)
function HeroScoreFrameSetAllyScale(scale)
function HeroScoreFrameSetTooltipScale(scale)
]]
do
HeroScoreFrame = {
AutoRun = true --(true) will create Itself at 0s, (false) you need to HeroScoreFrameInit()
,TocPath = "war3mapImported\\HeroScoreFrame.toc"
,ParentFunc = function() return BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0) end
,CreateOptions = true
,CreateOptionsInMenu = true
, OptionX = 0.1
, OptionY = 0.55
-- HideText(true) hides the score Icons and Texts between Face and Items
,HideText = false
-- HideTextPack(true) only works with HideText(true), Then it makes the Frames take less space.
,HideTextPack = true
-- FACE_COLOR_BACKGROUND(true) moves the playercolor below the Face. (false) To the top of a HeroScoreFrame
, FACE_COLOR_BACKGROUND = true
-- AutoSearchTarget, when there is no valid Unit of the UIPlayer of a HeroScoreFrame search one
, AutoSearchTarget = true
, Scale = 0.7
--SizeX Y should match fdf values
,SizeX = 0.22
,SizeXPacked = 0.22 - 0.054
,SizeY = 0.075
-- how many HeroCards are created in InitFrames
, AutoCreateCount = GetBJMaxPlayers()
-- how many HeroCards are in one Col
, Rows = 6
-- X space between 2 Cols
, ColOffsetX = 0
-- Inital TooltipScale
, TooltipScale = 1.0
, TooltipWidth = 0.2
, TooltipFixedPosition = true
, TooltipFixedPositionX = 0.79
, TooltipFixedPositionY = 0.16
, TooltipFixedPositionPoint = FRAMEPOINT_BOTTOMRIGHT
-- can be used to prevent players from taking an UI
-- return false when no UI shall be used by that player
-- only affects auto filling
, AllowedPlayer = function (player)
if GetPlayerSlotState(player) ~= PLAYER_SLOT_STATE_PLAYING then
-- return false
end
if (GetPlayerController(player) ~= MAP_CONTROL_USER and GetPlayerController(player) ~= MAP_CONTROL_COMPUTER) then
return false
end
if player == Player(6) or player == Player(0) then
-- return false
end
return true
end
-- FillByTeam(false) fill the UI based on PlayerNumber
-- FillByTeam(true) start with PlayerTeam than PlayerNumber
-- FillByTeam = false is recommented when there are no fixed Teams
, FillByTeam = false
, FillByTeamSkipCols = true
-- postion of the first HeroScoreFrame,
, X = 0.4
, Y = 0.55
, Point = FRAMEPOINT_TOPRIGHT
-- Key has to be hold to show the UI
, TriggerKey = OSKEY_TAB
, AllyScale = 1.0
-- shown next to Share/Swap Buttons (current State)
, Texture = {
[false] = "ui\\widgets\\glues\\thumbsdown-up"
,[true] = "ui\\widgets\\glues\\thumbsup-up"
}
-- Read item specific text/icon, instead of itemCode text/icon.
, DynamicItems = false
-- Fixed postion of the PlayerControl-PopUp,
-- disable fixed position with AllyPoint = false or commenting it out
--, AllyPoint = FRAMEPOINT_TOPRIGHT
, AllyX = 0.79
, AllyY = 0.55
, AutoSwapBot = true
, AllowSwapEnemies = true
, SwitchAllianceType = bj_ALLIANCE_ALLIED_VISION -- choose a bj_ALLIANCE_xxxx
, SwitchAddStates = {ALLIANCE_SHARED_ADVANCED_CONTROL} -- add additional AllianceStates
-- Interpret Swap onto Enemy Players as Team Switch
-- SwapEnemyIsSwitch(true) change Teams, no unit owner change
-- SwapEnemyIsSwitch(false) change unit owner, not Team
, SwapEnemyIsSwitch = true
, AllowSwapAllies = true
, AllowShareAdv = true
, AllowShare = true
, AllowSendGoldAlly = true
, AllowSendLumberAlly = true
, AllowSendGoldEnemy = false
, AllowSendLumberEnemy = false
------------------
-- Created contains the CreateContexts created.
, Created = {}
-- UiTargetTimer is saved under the indexes saved in Created (CreateContext)
, UiTargetTimer = {}
-- UiTargetUnit is saved under the indexes saved in Created (CreateContext)
, UiTargetUnit = {}
-- UiTargetPlayer stores the Player under the indexes saved in Created (CreateContext)
, UiTargetPlayer = {}
-- SelectedPlayer is the current Target for UI interaction (share, swap) stored based on Player
, SelectedPlayer = {}
, Swap = __jarray(false)
, ColStarts = 0
------------------
------------------
}
local this = HeroScoreFrame
function HeroScoreFrameGetPlayerContext(player)
for _, index in ipairs(this.Created) do
if player == this.UiTargetPlayer[index] then
return index
end
end
return -1
end
function HeroScoreFrameSetFaceOverlayText(createContext, text)
BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameFaceTextOverLay", createContext), text)
end
function HeroScoreFrameSetTargetTimer(createContext, timer)
this.UiTargetTimer[createContext] = timer
end
function HeroScoreFrameSetTargetUnit(createContext, unit)
this.UiTargetUnit[createContext] = unit
end
function HeroScoreFrameSetTargetPlayer(createContext, player)
this.UiTargetPlayer[createContext] = player
end
function HeroScoreFrameGetTargetUnit(createContext)
return this.UiTargetUnit[createContext]
end
function HeroScoreFrameGetTargetPlayer(createContext)
return this.UiTargetPlayer[createContext]
end
function HeroScoreFrameSetTooltipScale(scale)
this.TooltipScale = scale
BlzFrameSetScale(BlzGetFrameByName("HeroScoreFrameTooltipParent", 0), scale)
end
function HeroScoreFrameSetAllyScale(scale)
this.AllyScale = scale
BlzFrameSetScale(BlzGetFrameByName("HeroScoreFrameAlly", 0), scale)
end
function HeroScoreFrameSetScale(scale)
this.Scale = scale
BlzFrameSetScale(BlzGetFrameByName("HeroScoreFrameParent", 0), scale)
-- Scale Tooltips/Ally, to undo the overall Scaling for them
HeroScoreFrameSetTooltipScale(this.TooltipScale)
HeroScoreFrameSetAllyScale(this.AllyScale)
BlzFrameSetScale(BlzGetFrameByName("NumberDialog", 0), 1)
if GetHandleId(BlzGetFrameByName("HeroScoreFrameOptions", 0)) > 0 then BlzFrameSetScale(BlzGetFrameByName("HeroScoreFrameOptions", 0), 1) end
end
local DisabledData = {}
function GetDisabledIcon(icon)
if not DisabledData[icon] then
--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
--string.len(icon) < 35 then return icon end --this string has not enough chars return it
local prefix = string.sub(icon, 1, 34)
local sufix = string.sub(icon, 36)
DisabledData[icon] = prefix .."Disabled\\DIS"..sufix
return prefix .."Disabled\\DIS"..sufix
else
return DisabledData[icon]
end
end
function CreateSimpleTooltipHSF(frame, wantedframeName, wantedCreateContext, text)
-- this FRAME is important when the Box is outside of 4:3 it can be limited to 4:3.
local toolTipParent = BlzCreateFrameByType("FRAME", "", BlzGetFrameByName("HeroScoreFrameTooltipParent", 0), "", 0)
local toolTipBox = BlzCreateFrame("TasToolTipBox", toolTipParent, 0, 0)
local toolTip = BlzCreateFrameByType("TEXT", wantedframeName, toolTipBox, "TasTooltipText", wantedCreateContext)
--print(GetHandleId(toolTip))
--local toolTip = BlzCreateFrame("TasButtonTextTemplate", toolTipBox, 0, 0)
if this.TooltipFixedPosition then
BlzFrameSetAbsPoint(toolTip, this.TooltipFixedPositionPoint, this.TooltipFixedPositionX, this.TooltipFixedPositionY)
else
BlzFrameSetPoint(toolTip, FRAMEPOINT_TOP, frame, FRAMEPOINT_BOTTOM, 0, -0.008)
end
BlzFrameSetPoint(toolTipBox, FRAMEPOINT_TOPLEFT, toolTip, FRAMEPOINT_TOPLEFT, -0.008, 0.008)
BlzFrameSetPoint(toolTipBox, FRAMEPOINT_BOTTOMRIGHT, toolTip, FRAMEPOINT_BOTTOMRIGHT, 0.008, -0.008)
BlzFrameSetText(toolTip, text)
BlzFrameSetTooltip(frame, toolTipParent)
BlzFrameSetSize(toolTip, this.TooltipWidth, 0)
return toolTip
end
local function Update(unit, frameIndex)
local item, itemTypeId, player
player = this.UiTargetPlayer[frameIndex]
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrame", frameIndex), true)
-- update Face Display
if IsUnitType(unit, UNIT_TYPE_DEAD) then
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameFaceBackdrop", frameIndex), GetDisabledIcon(BlzGetAbilityIcon(GetUnitTypeId(unit))), 0, false)
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameFaceBackdropDisabled", frameIndex), GetDisabledIcon(BlzGetAbilityIcon(GetUnitTypeId(unit))), 0, false)
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameFaceBackdropPushed", frameIndex), GetDisabledIcon(BlzGetAbilityIcon(GetUnitTypeId(unit))), 0, false)
if this.UiTargetTimer[frameIndex] then BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameFaceTextOverLay", frameIndex), string.format( "%%0.f", TimerGetRemaining(this.UiTargetTimer[frameIndex]))) end
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameFaceTextOverLay", frameIndex), true)
else
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameFaceBackdrop", frameIndex), BlzGetAbilityIcon(GetUnitTypeId(unit)), 0, false)
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameFaceBackdropDisabled", frameIndex), BlzGetAbilityIcon(GetUnitTypeId(unit)), 0, false)
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameFaceBackdropPushed", frameIndex), BlzGetAbilityIcon(GetUnitTypeId(unit)), 0, false)
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameFaceTextOverLay", frameIndex), false)
end
if GetPlayerColorTexture then
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFramePlayerColor", frameIndex), GetPlayerColorTexture(player), 0, false)
else
-- PlayerColor
if GetHandleId(GetPlayerColor(player)) < 10 then
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFramePlayerColor", frameIndex), "ReplaceableTextures\\TeamColor\\TeamColor0"..GetHandleId(GetPlayerColor(player)), 0, false)
else
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFramePlayerColor", frameIndex), "ReplaceableTextures\\TeamColor\\TeamColor"..GetHandleId(GetPlayerColor(player)), 0, false)
end
end
-- LevelBox
BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameFaceChargeText", frameIndex), GetUnitLevel(unit))
-- Face Tooltip
--BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameFaceTooltipText", frameIndex), GetPlayerName(player).." ("..GetUnitName(unit).." - "..GetHeroProperName(unit).. ")")
local text = ""
if GetPlayerId(player) < bj_MAX_PLAYERS then
text = text .. GetPlayerName(player)
end
if IsUnitType(unit, UNIT_TYPE_HERO) then
text = text .." ("..GetUnitName(unit).." - "..GetHeroProperName(unit).. ")"
else
text = text .. GetUnitName(unit)
end
BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameFaceTooltipText", frameIndex), text)
-- Score Text
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameTextParent", frameIndex), not this.HideText)
if this.HideText and this.HideTextPack then
BlzFrameSetSize(BlzGetFrameByName("HeroScoreFrame", frameIndex), this.SizeXPacked , this.SizeY)
else
BlzFrameSetSize(BlzGetFrameByName("HeroScoreFrame", frameIndex), this.SizeX, this.SizeY)
end
-- Throw the event independent from HideText to avoid desync, but support async changes to HideText.
if this.HaveVariableEvent then
udg_HeroScoreFrame_PlayerA = player
udg_HeroScoreFrame_Unit = unit
globals.udg_HeroScoreFrame_Event = 5
globals.udg_HeroScoreFrame_Event = 0
end
if not this.HideText then
if this.HaveVariableEvent then
BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameText1", frameIndex), udg_HeroScoreFrame_Text[1])
BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameText2", frameIndex), udg_HeroScoreFrame_Text[2])
BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameText3", frameIndex), udg_HeroScoreFrame_Text[3])
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameTextIcon1", frameIndex), udg_HeroScoreFrame_Icon[1], 0, false)
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameTextIcon2", frameIndex), udg_HeroScoreFrame_Icon[2], 0, false)
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameTextIcon3", frameIndex), udg_HeroScoreFrame_Icon[3], 0, false)
BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameTextTooltip1", frameIndex), udg_HeroScoreFrame_Text[11])
BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameTextTooltip2", frameIndex), udg_HeroScoreFrame_Text[12])
BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameTextTooltip3", frameIndex), udg_HeroScoreFrame_Text[13])
else
BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameText1", frameIndex), GetPlayerScore(player, PLAYER_SCORE_UNITS_KILLED) - GetPlayerScore(player, PLAYER_SCORE_HEROES_KILLED))
BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameText2", frameIndex), GetPlayerScore(player, PLAYER_SCORE_HEROES_KILLED))
BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameText3", frameIndex), GetPlayerScore(player, PLAYER_SCORE_STRUCT_RAZED))
end
end
-- update Item Display
for i = 0, 5 do
item = UnitItemInSlot(unit, i)
itemTypeId = GetItemTypeId(item)
if itemTypeId > 0 then
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameItemSlotButton_"..i, frameIndex), true)
if this.DynamicItems then
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameItemSlotButton_"..i.."Backdrop", frameIndex), BlzGetItemIconPath(item), 0, false)
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameItemSlotButton_"..i.."BackdropDisabled", frameIndex), BlzGetItemIconPath(item), 0, false)
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameItemSlotButton_"..i.."BackdropPushed", frameIndex), BlzGetItemIconPath(item), 0, false)
BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameItemSlotButtonTooltipText_"..i, frameIndex), GetItemName(item).."\n"..BlzGetItemExtendedTooltip(item))
else
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameItemSlotButton_"..i.."Backdrop", frameIndex), BlzGetAbilityIcon(itemTypeId), 0, false)
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameItemSlotButton_"..i.."BackdropDisabled", frameIndex), BlzGetAbilityIcon(itemTypeId), 0, false)
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameItemSlotButton_"..i.."BackdropPushed", frameIndex), BlzGetAbilityIcon(itemTypeId), 0, false)
BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameItemSlotButtonTooltipText_"..i, frameIndex), GetObjectName(itemTypeId).."\n"..BlzGetAbilityExtendedTooltip(itemTypeId, 0))
end
if GetItemCharges(item) > 0 then
BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameItemSlotButtonChargeText_"..i, frameIndex), GetItemCharges(item))
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameItemSlotButtonChargeBox_"..i, frameIndex), true)
else
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameItemSlotButtonChargeBox_"..i, frameIndex), false)
end
else
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameItemSlotButton_"..i, frameIndex), false)
end
end
item = nil
end
local function UpdateFrameAllyIcons(player)
if GetLocalPlayer() == player then
-- PlayerColor
if GetHandleId(GetPlayerColor(this.SelectedPlayer[player])) < 10 then
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameAllyTargetPlayerColor", 0), "ReplaceableTextures\\TeamColor\\TeamColor0"..GetHandleId(GetPlayerColor(this.SelectedPlayer[player])), 0, false)
else
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameAllyTargetPlayerColor", 0), "ReplaceableTextures\\TeamColor\\TeamColor"..GetHandleId(GetPlayerColor(this.SelectedPlayer[player])), 0, false)
end
-- revert Player in ALLIANCE_SHARED_ADVANCED_CONTROL because we want to see the target players face
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameAllyButtonShareAdvIcon", 0), this.Texture[GetPlayerAlliance(this.SelectedPlayer[player], player, ALLIANCE_SHARED_ADVANCED_CONTROL)], 0, true)
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameAllyButtonShareIcon", 0), this.Texture[GetPlayerAlliance(player, this.SelectedPlayer[player], ALLIANCE_SHARED_CONTROL)], 0, true)
BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameAllyButtonSwapIcon", 0), this.Texture[this.Swap[GetPlayerId(player)*bj_MAX_PLAYER_SLOTS + GetPlayerId(this.SelectedPlayer[player])]], 0, true)
BlzFrameSetVisible(BlzGetFrameByName("NumberDialog", 0), false)
if not this.AllowSendGoldAlly and not this.AllowSendLumberAlly and not this.AllowSendGoldEnemy and not this.AllowSendLumberEnemy then
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendGold", 0), false)
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendLumber", 0), false)
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAllyButtonSend", 0), false)
else
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendGold", 0), true)
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendLumber", 0), true)
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAllyButtonSend", 0), true)
end
if IsPlayerAlly(player, this.SelectedPlayer[player]) then
BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendGold", 0), this.AllowSendGoldAlly)
BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendLumber", 0), this.AllowSendLumberAlly)
BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyButtonSwap", 0), this.AllowSwapAllies)
BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyButtonShare", 0), this.AllowShare)
BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyButtonShareAdv", 0), this.AllowShareAdv)
else
BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendGold", 0), this.AllowSendGoldEnemy)
BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendLumber", 0), this.AllowSendLumberEnemy)
BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyButtonSwap", 0), this.AllowSwapEnemies)
BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyButtonShare", 0), false)
BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyButtonShareAdv", 0), false)
end
end
end
local function ShowFrameAlly(player, frame)
if GetLocalPlayer() == player then
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAlly", 0), this.AllowSwapEnemies or this.AllowSwapAllies or this.AllowShareAdv or this.AllowShare or this.AllowSendGoldAlly or this.AllowSendLumberAlly or this.AllowSendGoldEnemy or this.AllowSendLumberEnemy)
if not this.AllyPoint then
BlzFrameClearAllPoints(BlzGetFrameByName("HeroScoreFrameAlly", 0))
BlzFrameSetPoint(BlzGetFrameByName("HeroScoreFrameAlly", 0), FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPRIGHT, 0, 0)
end
UpdateFrameAllyIcons(player)
end
end
function CreateGeneratedFrameHeroScoreFrame(index)
local frame = BlzCreateFrame("HeroScoreFrame", BlzGetFrameByName("HeroScoreFrameParent", 0), 0, index)
if GetHandleId(frame) == 0 then
print("Error - Create HeroScoreFrame")
end
if this.HideText then
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameTextParent", index), false)
BlzFrameSetSize(frame, BlzFrameGetWidth(frame) - 0.055, BlzFrameGetHeight(frame))
end
if this.FACE_COLOR_BACKGROUND then
BlzFrameClearAllPoints(BlzGetFrameByName("HeroScoreFramePlayerColor", index))
BlzFrameSetPoint(BlzGetFrameByName("HeroScoreFramePlayerColor", index), FRAMEPOINT_TOPLEFT, BlzGetFrameByName("HeroScoreFrameFace", index), FRAMEPOINT_TOPLEFT, -0.002, 0.002)
BlzFrameSetPoint(BlzGetFrameByName("HeroScoreFramePlayerColor", index), FRAMEPOINT_BOTTOMRIGHT, BlzGetFrameByName("HeroScoreFrameFace", index), FRAMEPOINT_BOTTOMRIGHT, 0.002, -0.002)
end
if #this.Created == 0 then
this.ColStarts = index
BlzFrameSetAbsPoint(frame, this.Point, this.X, this.Y)
elseif this.Rows > 0 and ModuloInteger(#this.Created, this.Rows) == 0 then
BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, BlzGetFrameByName("HeroScoreFrame", this.ColStarts), FRAMEPOINT_TOPRIGHT, this.ColOffsetX, 0.0)
this.ColStarts = index
else
BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, BlzGetFrameByName("HeroScoreFrame", this.Created[#this.Created]), FRAMEPOINT_BOTTOMLEFT, 0.0, 0.0)
end
table.insert(this.Created, index)
CreateSimpleTooltipHSF(BlzGetFrameByName("HeroScoreFrameFace", index), "HeroScoreFrameFaceTooltipText", index, "test")
BlzFrameSetSize(BlzGetFrameByName("HeroScoreFrameFaceTooltipText", index), 0, 0)
TasButtonAction.Set(BlzGetFrameByName("HeroScoreFrameFace", index), function()
this.SelectedPlayer[GetTriggerPlayer()] = this.UiTargetPlayer[index]
ShowFrameAlly(GetTriggerPlayer(), frame)
end)
TasButtonAction.Set(frame, function()
this.SelectedPlayer[GetTriggerPlayer()] = this.UiTargetPlayer[index]
ShowFrameAlly(GetTriggerPlayer(), frame)
end)
CreateSimpleTooltipHSF(BlzGetFrameByName("HeroScoreFrameText1", index), "HeroScoreFrameTextTooltip1", index, GetLocalizedString("UNIT_COLUMN1"))
CreateSimpleTooltipHSF(BlzGetFrameByName("HeroScoreFrameText2", index), "HeroScoreFrameTextTooltip2", index, GetLocalizedString("HEROES_COLUMN1"))
CreateSimpleTooltipHSF(BlzGetFrameByName("HeroScoreFrameText3", index), "HeroScoreFrameTextTooltip3", index, GetLocalizedString("UNIT_COLUMN3"))
if not this.HaveVariableEvent then
BlzFrameSetSize(BlzGetFrameByName("HeroScoreFrameTextTooltip1", index), 0, 0)
BlzFrameSetSize(BlzGetFrameByName("HeroScoreFrameTextTooltip2", index), 0, 0)
BlzFrameSetSize(BlzGetFrameByName("HeroScoreFrameTextTooltip3", index), 0, 0)
end
BlzGetFrameByName("HeroScoreFrameTextTooltip1", index)
BlzGetFrameByName("HeroScoreFrameTextTooltip2", index)
BlzGetFrameByName("HeroScoreFrameTextTooltip3", index)
BlzGetFrameByName("HeroScoreFrameTextIcon1", index)
BlzGetFrameByName("HeroScoreFrameTextIcon2", index)
BlzGetFrameByName("HeroScoreFrameTextIcon3", index)
for i = 0, 5 do
CreateSimpleTooltipHSF(BlzGetFrameByName("HeroScoreFrameItemSlotButton_"..i, index), "HeroScoreFrameItemSlotButtonTooltipText_"..i, index, "test")
-- Reserve HandleId
BlzGetFrameByName("HeroScoreFrameItemSlotButton_"..i.."Backdrop", index)
BlzGetFrameByName("HeroScoreFrameItemSlotButton_"..i.."BackdropDisabled", index)
BlzGetFrameByName("HeroScoreFrameItemSlotButton_"..i.."BackdropPushed", index)
BlzGetFrameByName("HeroScoreFrameItemSlotButtonTooltipText_"..i, index)
BlzGetFrameByName("HeroScoreFrameItemSlotButtonChargeText_"..i, index)
BlzGetFrameByName("HeroScoreFrameItemSlotButtonChargeBox_"..i, index)
end
BlzGetFrameByName("HeroScoreFrameFaceTextOverLay", index)
end
local function SwitchTeams(playerA, playerB)
-- Enemy Swap - Fixed Team Game -> swap Team
if IsPlayerEnemy(playerA, playerB) and this.SwapEnemyIsSwitch then
if this.HaveVariableEvent then
udg_HeroScoreFrame_PlayerA = playerA
udg_HeroScoreFrame_PlayerB = playerB
globals.udg_HeroScoreFrame_Event = 3
globals.udg_HeroScoreFrame_Event = 0
end
local teamA = GetPlayerTeam(playerA)
local teamB = GetPlayerTeam(playerB)
SetPlayerTeam(playerA, teamB)
SetPlayerTeam(playerB, teamA)
-- swap used StartLocation
local indexTemp = GetPlayerStartLocation(playerB)
SetPlayerStartLocation(playerB, GetPlayerStartLocation(playerA))
SetPlayerStartLocation(playerA, indexTemp)
-- swap Alliance with others
for i = 0, bj_MAX_PLAYER_SLOTS - 1 do
if Player(i) ~= playerA and Player(i) ~= playerB and IsPlayerAlly(playerA, Player(i)) ~= IsPlayerAlly(playerB, Player(i)) then
if IsPlayerAlly(playerA, Player(i)) then
SetPlayerAllianceStateBJ(Player(i), playerB, this.SwitchAllianceType)
SetPlayerAllianceStateBJ(playerB, Player(i), this.SwitchAllianceType)
if this.SwitchAddStates then
for _, allyAdd in ipairs(this.SwitchAddStates) do
SetPlayerAlliance(Player(i), playerB, allyAdd, true)
SetPlayerAlliance(playerB, Player(i), allyAdd, true)
end
end
SetPlayerAllianceStateBJ(Player(i), playerA, bj_ALLIANCE_UNALLIED)
SetPlayerAllianceStateBJ(playerA, Player(i), bj_ALLIANCE_UNALLIED)
else
SetPlayerAllianceStateBJ(Player(i), playerA, this.SwitchAllianceType)
SetPlayerAllianceStateBJ(playerA, Player(i), this.SwitchAllianceType)
if this.SwitchAddStates then
for _, allyAdd in ipairs(this.SwitchAddStates) do
SetPlayerAlliance(Player(i), playerA, allyAdd, true)
SetPlayerAlliance(playerA, Player(i), allyAdd, true)
end
end
SetPlayerAllianceStateBJ(Player(i), playerB, bj_ALLIANCE_UNALLIED)
SetPlayerAllianceStateBJ(playerB, Player(i), bj_ALLIANCE_UNALLIED)
end
end
end
-- find used UI-Indexes
local heroCardIndexA, heroCardIndexB
for _, index in ipairs(this.Created) do
if playerA == this.UiTargetPlayer[index] then
heroCardIndexA = index
end
if playerB == this.UiTargetPlayer[index] then
heroCardIndexB = index
end
end
-- swap used ones
HeroScoreFrameSetTargetPlayer(heroCardIndexA, playerB)
HeroScoreFrameSetTargetPlayer(heroCardIndexB, playerA)
local tempUnit = HeroScoreFrameGetTargetUnit(heroCardIndexA)
HeroScoreFrameSetTargetUnit(heroCardIndexA, HeroScoreFrameGetTargetUnit(heroCardIndexB))
HeroScoreFrameSetTargetUnit(heroCardIndexB, tempUnit)
tempUnit = nil
if this.HaveVariableEvent then
udg_HeroScoreFrame_PlayerA = playerA
udg_HeroScoreFrame_PlayerB = playerB
globals.udg_HeroScoreFrame_Event = 4
globals.udg_HeroScoreFrame_Event = 0
else
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 30, "Switch Team: " .. GetPlayerName(playerA) .. " - " .. GetPlayerName(playerB))
end
end
end
function HeroScoreSendLumberAction(amount)
if GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_LUMBER) < amount then amount = GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_LUMBER) end
AdjustPlayerStateBJ(-amount, GetTriggerPlayer(), PLAYER_STATE_RESOURCE_LUMBER)
AdjustPlayerStateBJ(amount, this.SelectedPlayer[GetTriggerPlayer()], PLAYER_STATE_RESOURCE_LUMBER)
print("Send Lumber:", amount, GetPlayerName(GetTriggerPlayer()), " ->",GetPlayerName(this.SelectedPlayer[GetTriggerPlayer()]))
end
function HeroScoreSendGoldAction(amount)
if GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) < amount then amount = GetPlayerState(GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD) end
AdjustPlayerStateBJ(-amount, GetTriggerPlayer(), PLAYER_STATE_RESOURCE_GOLD)
AdjustPlayerStateBJ(amount, this.SelectedPlayer[GetTriggerPlayer()], PLAYER_STATE_RESOURCE_GOLD)
print("Send Gold:", amount, GetPlayerName(GetTriggerPlayer()), " ->",GetPlayerName(this.SelectedPlayer[GetTriggerPlayer()]))
end
function CreateGeneratedFrameHeroScoreFrameAlly(index)
local frame = BlzCreateFrame("HeroScoreFrameAlly", BlzGetFrameByName("HeroScoreFrameParent", 0), 0, index)
if GetHandleId(frame) == 0 then print("HeroScoreFrame - Error Creating HeroScoreFrameAlly") end
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAlly", 0), false)
if this.AllyPoint then
BlzFrameSetAbsPoint(BlzGetFrameByName("HeroScoreFrameAlly", 0), this.AllyPoint, this.AllyX,this.AllyY)
end
local groupA = CreateGroup()
local groupB = CreateGroup()
TasButtonAction.Set(BlzGetFrameByName("HeroScoreFrameAllyButtonSwap", index), function()
if GetTriggerPlayer() ~= this.SelectedPlayer[GetTriggerPlayer()] then
local playerA = GetTriggerPlayer()
local playerB = this.SelectedPlayer[GetTriggerPlayer()]
local indexA = GetPlayerId(playerA)*bj_MAX_PLAYER_SLOTS + GetPlayerId(playerB)
local indexB = GetPlayerId(playerB)*bj_MAX_PLAYER_SLOTS + GetPlayerId(playerA)
this.Swap[indexA] = not this.Swap[indexA]
if this.HaveVariableEvent then
udg_HeroScoreFrame_PlayerA = playerA
udg_HeroScoreFrame_PlayerB = playerB
globals.udg_HeroScoreFrame_Event = -1
globals.udg_HeroScoreFrame_Event = 0
else
DisplayTimedTextToPlayer(this.SelectedPlayer[GetTriggerPlayer()], 0, 0, 30, GetPlayerName(GetTriggerPlayer()).. "requests swapping with you")
end
if this.Swap[indexA] and (this.Swap[indexB] or
(this.AutoSwapBot and (GetPlayerController(playerB) == MAP_CONTROL_COMPUTER) or GetPlayerSlotState(playerB) ~= PLAYER_SLOT_STATE_PLAYING )) then
if not IsPlayerEnemy(playerA, playerB) or not this.SwapEnemyIsSwitch then
if this.HaveVariableEvent then
udg_HeroScoreFrame_PlayerA = playerA
udg_HeroScoreFrame_PlayerB = playerB
globals.udg_HeroScoreFrame_Event = 1
globals.udg_HeroScoreFrame_Event = 0
end
GroupEnumUnitsOfPlayer(groupA, playerA, nil)
GroupEnumUnitsOfPlayer(groupB, playerB, nil)
ForGroup(groupA, function()
SetUnitOwner(GetEnumUnit(), playerB, true)
end)
ForGroup(groupB, function()
SetUnitOwner(GetEnumUnit(), playerA, true)
end)
GroupClear(groupA)
GroupClear(groupB)
if this.HaveVariableEvent then
udg_HeroScoreFrame_PlayerA = playerA
udg_HeroScoreFrame_PlayerB = playerB
globals.udg_HeroScoreFrame_Event = 2
globals.udg_HeroScoreFrame_Event = 0
else
DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 30, "Swap Players: " .. GetPlayerName(playerA) .. " - " .. GetPlayerName(playerB))
end
end
SwitchTeams(playerA, playerB)
this.Swap[indexA] = false
this.Swap[indexB] = false
end
UpdateFrameAllyIcons(GetTriggerPlayer())
end
end)
TasButtonAction.Set(BlzGetFrameByName("HeroScoreFrameAllyButtonShare", index), function()
if GetTriggerPlayer() ~= this.SelectedPlayer[GetTriggerPlayer()] then
SetPlayerAlliance(GetTriggerPlayer(), this.SelectedPlayer[GetTriggerPlayer()], ALLIANCE_SHARED_CONTROL, not GetPlayerAlliance(GetTriggerPlayer(), this.SelectedPlayer[GetTriggerPlayer()], ALLIANCE_SHARED_CONTROL))
--SetPlayerAlliance(this.SelectedPlayer[GetTriggerPlayer()], GetTriggerPlayer(), ALLIANCE_SHARED_CONTROL, not GetPlayerAlliance(this.SelectedPlayer[GetTriggerPlayer()], GetTriggerPlayer(), ALLIANCE_SHARED_CONTROL))
if this.HaveVariableEvent then
udg_HeroScoreFrame_PlayerA = GetTriggerPlayer()
udg_HeroScoreFrame_PlayerB = this.SelectedPlayer[GetTriggerPlayer()]
globals.udg_HeroScoreFrame_Event = -2
globals.udg_HeroScoreFrame_Event = 0
else
--DisplayTimedTextToPlayer(this.SelectedPlayer[GetTriggerPlayer()], 0, 0, 30, GetPlayerName(GetTriggerPlayer()).. "requests swapping with you")
end
UpdateFrameAllyIcons(GetTriggerPlayer())
end
end)
TasButtonAction.Set(BlzGetFrameByName("HeroScoreFrameAllyButtonShareAdv", index), function()
if GetTriggerPlayer() ~= this.SelectedPlayer[GetTriggerPlayer()] then
--SetPlayerAlliance(GetTriggerPlayer(), this.SelectedPlayer[GetTriggerPlayer()], ALLIANCE_SHARED_ADVANCED_CONTROL, not GetPlayerAlliance(GetTriggerPlayer(), this.SelectedPlayer[GetTriggerPlayer()], ALLIANCE_SHARED_ADVANCED_CONTROL))
-- The clicking Player wants to see the face of the target Player
SetPlayerAlliance(this.SelectedPlayer[GetTriggerPlayer()], GetTriggerPlayer(), ALLIANCE_SHARED_ADVANCED_CONTROL, not GetPlayerAlliance(this.SelectedPlayer[GetTriggerPlayer()], GetTriggerPlayer(), ALLIANCE_SHARED_ADVANCED_CONTROL))
if this.HaveVariableEvent then
udg_HeroScoreFrame_PlayerA = GetTriggerPlayer()
udg_HeroScoreFrame_PlayerB = this.SelectedPlayer[GetTriggerPlayer()]
globals.udg_HeroScoreFrame_Event = -3
globals.udg_HeroScoreFrame_Event = 0
else
--DisplayTimedTextToPlayer(this.SelectedPlayer[GetTriggerPlayer()], 0, 0, 30, GetPlayerName(GetTriggerPlayer()).. "requests swapping with you")
end
UpdateFrameAllyIcons(GetTriggerPlayer())
end
end)
TasButtonAction.Set(BlzGetFrameByName("HeroScoreFrameAllyButtonClose", index), function()
if GetLocalPlayer() == GetTriggerPlayer() then
BlzFrameSetVisible(BlzFrameGetParent(BlzGetTriggerFrame()), false)
BlzFrameSetVisible(BlzGetFrameByName("NumberDialog", 0), false)
end
end)
TasButtonAction.Set(BlzGetFrameByName("HeroScoreFrameAllyButtonSend", index), function()
if GetLocalPlayer() == GetTriggerPlayer() then
BlzFrameSetVisible(BlzFrameGetParent(BlzGetTriggerFrame()), false)
end
end)
BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyButtonSend", index), false)
TasButtonAction.Set(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendGold", index), function()
if ShowNumberDialog then
ShowNumberDialog(GetTriggerPlayer(), 2, HeroScoreSendGoldAction)
end
end)
TasButtonAction.Set(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendLumber", index), function()
if ShowNumberDialog then
ShowNumberDialog(GetTriggerPlayer(), 3, HeroScoreSendLumberAction)
end
end)
-- Reserve HandleIds
BlzGetFrameByName("HeroScoreFrameAllyButtonShareAdvIcon", 0)
BlzGetFrameByName("HeroScoreFrameAllyButtonShareIcon", 0)
BlzGetFrameByName("HeroScoreFrameAllyButtonSwapIcon", 0)
BlzGetFrameByName("HeroScoreFrameAllyTargetPlayerColor", 0)
end
local function CreateGeneratedFrameHeroScoreOptions(index)
if this.CreateOptions then
if this.CreateOptionsInMenu then
BlzCreateFrame("HeroScoreFrameOptions", BlzGetFrameByName("InsideMainPanel", 0), 0, 0)
else
BlzCreateFrame("HeroScoreFrameOptions", BlzGetFrameByName("HeroScoreFrameParent", 0), 0, 0)
end
if GetHandleId(BlzGetFrameByName("HeroScoreFrameOptions", 0)) == 0 then print("HeroScoreFrame - Error Creating HeroScoreFrameOptions") end
BlzFrameSetAbsPoint(BlzGetFrameByName("HeroScoreFrameOptions", 0), FRAMEPOINT_TOPLEFT, this.OptionX, this.OptionY)
BlzFrameSetValue(BlzGetFrameByName("HeroScoreFrameOptionsSlider1", index), this.TooltipScale)
BlzFrameSetValue(BlzGetFrameByName("HeroScoreFrameOptionsSlider2", index), this.AllyScale)
BlzFrameSetValue(BlzGetFrameByName("HeroScoreFrameOptionsSlider3", index), this.Scale)
local trigger
trigger = CreateTrigger()
BlzTriggerRegisterFrameEvent(trigger, BlzGetFrameByName("HeroScoreFrameOptionsSlider1", index), FRAMEEVENT_SLIDER_VALUE_CHANGED)
TriggerAddAction(trigger, function()
if GetLocalPlayer() == GetTriggerPlayer() then
HeroScoreFrameSetTooltipScale(BlzGetTriggerFrameValue())
end
end)
trigger = CreateTrigger()
BlzTriggerRegisterFrameEvent(trigger, BlzGetFrameByName("HeroScoreFrameOptionsSlider1", index), FRAMEEVENT_MOUSE_WHEEL)
TriggerAddAction(trigger, function()
if GetLocalPlayer() == GetTriggerPlayer() then
if BlzGetTriggerFrameValue() > 0 then
BlzFrameSetValue(BlzGetTriggerFrame(), BlzFrameGetValue(BlzGetTriggerFrame()) + .05)
else
BlzFrameSetValue(BlzGetTriggerFrame(), BlzFrameGetValue(BlzGetTriggerFrame()) - .05)
end
end
end)
trigger = CreateTrigger()
BlzTriggerRegisterFrameEvent(trigger, BlzGetFrameByName("HeroScoreFrameOptionsSlider2", index), FRAMEEVENT_SLIDER_VALUE_CHANGED)
TriggerAddAction(trigger, function()
if GetLocalPlayer() == GetTriggerPlayer() then
HeroScoreFrameSetAllyScale(BlzGetTriggerFrameValue())
end
end)
trigger = CreateTrigger()
BlzTriggerRegisterFrameEvent(trigger, BlzGetFrameByName("HeroScoreFrameOptionsSlider2", index), FRAMEEVENT_MOUSE_WHEEL)
TriggerAddAction(trigger, function()
if GetLocalPlayer() == GetTriggerPlayer() then
if BlzGetTriggerFrameValue() > 0 then
BlzFrameSetValue(BlzGetTriggerFrame(), BlzFrameGetValue(BlzGetTriggerFrame()) + .05)
else
BlzFrameSetValue(BlzGetTriggerFrame(), BlzFrameGetValue(BlzGetTriggerFrame()) - .05)
end
end
end)
trigger = CreateTrigger()
BlzTriggerRegisterFrameEvent(trigger, BlzGetFrameByName("HeroScoreFrameOptionsSlider3", index), FRAMEEVENT_SLIDER_VALUE_CHANGED)
TriggerAddAction(trigger, function()
if GetLocalPlayer() == GetTriggerPlayer() then
HeroScoreFrameSetScale(BlzGetTriggerFrameValue())
end
end)
trigger = CreateTrigger()
BlzTriggerRegisterFrameEvent(trigger, BlzGetFrameByName("HeroScoreFrameOptionsSlider3", index), FRAMEEVENT_MOUSE_WHEEL)
TriggerAddAction(trigger, function()
if GetLocalPlayer() == GetTriggerPlayer() then
if BlzGetTriggerFrameValue() > 0 then
BlzFrameSetValue(BlzGetTriggerFrame(), BlzFrameGetValue(BlzGetTriggerFrame()) + .05)
else
BlzFrameSetValue(BlzGetTriggerFrame(), BlzFrameGetValue(BlzGetTriggerFrame()) - .05)
end
end
end)
trigger = CreateTrigger()
BlzTriggerRegisterFrameEvent(trigger, BlzGetFrameByName("HeroScoreFrameOptionsCheckBox4", index), FRAMEEVENT_CHECKBOX_CHECKED)
BlzTriggerRegisterFrameEvent(trigger, BlzGetFrameByName("HeroScoreFrameOptionsCheckBox4", index), FRAMEEVENT_CHECKBOX_UNCHECKED)
TriggerAddAction(trigger, function()
local checked = BlzGetTriggerFrameEvent() == FRAMEEVENT_CHECKBOX_CHECKED
if GetLocalPlayer() == GetTriggerPlayer() then
this.HideText = checked
end
end)
trigger = CreateTrigger()
BlzTriggerRegisterFrameEvent(trigger, BlzGetFrameByName("HeroScoreFrameOptionsCheckBox5", index), FRAMEEVENT_CHECKBOX_CHECKED)
BlzTriggerRegisterFrameEvent(trigger, BlzGetFrameByName("HeroScoreFrameOptionsCheckBox5", index), FRAMEEVENT_CHECKBOX_UNCHECKED)
TriggerAddAction(trigger, function()
local checked = BlzGetTriggerFrameEvent() == FRAMEEVENT_CHECKBOX_CHECKED
if GetLocalPlayer() == GetTriggerPlayer() then
this.HideTextPack = checked
end
end)
print("creation done")
end
end
local InitFrames = function()
BlzLoadTOCFile(this.TocPath)
this.Created = {}
BlzCreateFrameByType("FRAME", "HeroScoreFrameParent", this.ParentFunc(), "", 0)
-- has to be something acceptimg BlzFrameSetLevel in V1.31.1
BlzCreateFrameByType("BUTTON", "HeroScoreFrameTooltipParent", BlzGetFrameByName("HeroScoreFrameParent", 0), "", 0)
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameParent", 0), false)
for i = 0, this.AutoCreateCount - 1 do
CreateGeneratedFrameHeroScoreFrame(i)
end
local usedCounter = 0
if this.FillByTeam then
for team = 0, GetTeams() - 1 do
for i = 0, bj_MAX_PLAYERS - 1 do
if GetPlayerTeam(Player(i)) == team and this.AllowedPlayer(Player(i)) then
HeroScoreFrameSetTargetPlayer(usedCounter, Player(i))
usedCounter = usedCounter + 1
end
end
-- Team finished jump to next col, if there are remaining spaces.
if this.FillByTeamSkipCols then
local remain = ModuloInteger(usedCounter, this.Rows)
if remain > 0 and remain < this.Rows then
usedCounter = usedCounter + (this.Rows - remain)
end
else
usedCounter = usedCounter + 1
end
end
else
for i = 0, bj_MAX_PLAYERS - 1 do
if this.AllowedPlayer(Player(i)) then
HeroScoreFrameSetTargetPlayer(usedCounter, Player(i))
usedCounter = usedCounter + 1
end
end
end
CreateGeneratedFrameHeroScoreFrameAlly(0)
if CreateNumberDialog then
CreateNumberDialog(BlzGetFrameByName("HeroScoreFrameParent", 0))
end
CreateGeneratedFrameHeroScoreOptions(0)
-- make the tooltipParent take the highest Layer of all silberlings, for some reasons this has to be done after all silberlings were created
BlzFrameSetLevel(BlzGetFrameByName("HeroScoreFrameTooltipParent", 0), 99)
HeroScoreFrameSetScale(this.Scale)
HeroScoreFrameSetTooltipScale(this.TooltipScale)
end
function HeroScoreFrameInit()
InitFrames()
this.HaveVariableEvent = udg_HeroScoreFrame_Text ~= nil
local trigger = CreateTrigger()
for i = 0, bj_MAX_PLAYER_SLOTS - 1 do
BlzTriggerRegisterPlayerKeyEvent(trigger, Player(i), this.TriggerKey, 0, true)
BlzTriggerRegisterPlayerKeyEvent(trigger, Player(i), this.TriggerKey, 0, false)
end
TriggerAddAction(trigger, function()
if GetLocalPlayer() == GetTriggerPlayer() then
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameParent", 0), BlzGetTriggerPlayerIsKeyDown())
if not BlzGetTriggerPlayerIsKeyDown() then
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAlly", 0), false)
BlzFrameSetVisible(BlzGetFrameByName("NumberDialog", 0), false)
end
end
end)
local group = CreateGroup()
local player
TimerStart(CreateTimer(), 0.25, true, function()
for _, index in ipairs(this.Created) do
player = this.UiTargetPlayer[index]
if player then
if this.AutoSearchTarget and (not this.UiTargetUnit[index] or GetUnitTypeId(this.UiTargetUnit[index]) == 0 or GetOwningPlayer(this.UiTargetUnit[index]) ~= player or not IsUnitType(this.UiTargetUnit[index], UNIT_TYPE_HERO)) then
GroupEnumUnitsOfPlayer(group, player, nil)
if IsUnitType(FirstOfGroup(group), UNIT_TYPE_HERO) then
HeroScoreFrameSetTargetUnit(index, FirstOfGroup(group))
Update(FirstOfGroup(group), index)
else
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrame", index), false)
end
else
Update(this.UiTargetUnit[index], index)
end
else
BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrame", index), false)
end
end
GroupClear(group)
end)
if FrameLoaderAdd then FrameLoaderAdd(InitFrames) end
end
if this.AutoRun then
if OnInit then -- Total Initialization v5.2.0.1 by Bribe
OnInit.final(HeroScoreFrameInit)
else -- without
local real = MarkGameStarted
function MarkGameStarted()
real()
HeroScoreFrameInit()
end
end
end
end
library FrameNumberDialog
globals
public integer array Value
public real array Action
private string array IconType
player NumberDialogPlayer
integer NumberDialogResult
real NumberDialogEvent
endglobals
private function Add takes player p, integer value returns nothing
local integer playerId = GetPlayerId(p)
set Value[playerId] = Value[playerId]*10 + value
if GetLocalPlayer() == p then
call BlzFrameSetText(BlzGetFrameByName("NumberDisplayText", 0), I2S(Value[playerId]))
endif
endfunction
function ShowNumberDialog takes player p, integer iconType, real actionNumber returns nothing
if GetLocalPlayer() == p then
call BlzFrameSetVisible(BlzGetFrameByName(IconType[1], 0), false)
call BlzFrameSetVisible(BlzGetFrameByName(IconType[2], 0), false)
call BlzFrameSetVisible(BlzGetFrameByName(IconType[3], 0), false)
call BlzFrameSetVisible(BlzGetFrameByName(IconType[iconType], 0), true)
call BlzFrameSetVisible(BlzGetFrameByName("NumberDialog", 0), true)
endif
set Action[GetPlayerId(p)] = actionNumber
endfunction
private function ActionNumberButton0 takes nothing returns nothing
call Add(GetTriggerPlayer(), 0)
endfunction
private function ActionNumberButton1 takes nothing returns nothing
call Add(GetTriggerPlayer(), 1)
endfunction
private function ActionNumberButton2 takes nothing returns nothing
call Add(GetTriggerPlayer(), 2)
endfunction
private function ActionNumberButton3 takes nothing returns nothing
call Add(GetTriggerPlayer(), 3)
endfunction
private function ActionNumberButton4 takes nothing returns nothing
call Add(GetTriggerPlayer(), 4)
endfunction
private function ActionNumberButton5 takes nothing returns nothing
call Add(GetTriggerPlayer(), 5)
endfunction
private function ActionNumberButton6 takes nothing returns nothing
call Add(GetTriggerPlayer(), 6)
endfunction
private function ActionNumberButton7 takes nothing returns nothing
call Add(GetTriggerPlayer(), 7)
endfunction
private function ActionNumberButton8 takes nothing returns nothing
call Add(GetTriggerPlayer(), 8)
endfunction
private function ActionNumberButton9 takes nothing returns nothing
call Add(GetTriggerPlayer(), 9)
endfunction
private function ActionAcceptButton takes nothing returns nothing
set NumberDialogPlayer = GetTriggerPlayer()
set NumberDialogResult = Value[GetPlayerId(NumberDialogPlayer)]
set NumberDialogEvent = Action[GetPlayerId(NumberDialogPlayer)]
call BlzFrameSetVisible(BlzFrameGetParent(BlzGetTriggerFrame()), false)
endfunction
private function ActionCancelButton takes nothing returns nothing
if Value[GetPlayerId(GetTriggerPlayer())] == 0 then
call BlzFrameSetVisible(BlzFrameGetParent(BlzGetTriggerFrame()), false)
else
set Value[GetPlayerId(GetTriggerPlayer())] = 0
call Add(GetTriggerPlayer(), 0)
endif
endfunction
public function create takes integer index, framehandle parent returns nothing
local trigger trig
local boolean loaded = BlzLoadTOCFile("war3mapImported\\NumberDialog.toc")
local framehandle frame = BlzCreateFrame("NumberDialog", parent, 0, index)
call BlzFrameSetAbsPoint(BlzGetFrameByName("NumberDialog", 0), FRAMEPOINT_CENTER, 0.4, 0.3)
if GetHandleId(frame) == 0 then
call BJDebugMsg("Error - Creating NumberDialog")
endif
set IconType[1] = "NumberDialogTitelIcon"
set IconType[2] = "NumberDialogTitelIconGold"
set IconType[3] = "NumberDialogTitelIconLumber"
call BlzGetFrameByName("NumberDisplayText", 0)
call BlzGetFrameByName(IconType[1], 0)
call BlzGetFrameByName(IconType[2], 0)
call BlzGetFrameByName(IconType[3], 0)
call BlzFrameSetVisible(frame, false)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("NumberButton0", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function ActionNumberButton0)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("NumberButton1", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function ActionNumberButton1)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("NumberButton2", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function ActionNumberButton2)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("NumberButton3", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function ActionNumberButton3)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("NumberButton4", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function ActionNumberButton4)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("NumberButton5", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function ActionNumberButton5)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("NumberButton6", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function ActionNumberButton6)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("NumberButton7", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function ActionNumberButton7)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("NumberButton8", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function ActionNumberButton8)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("NumberButton9", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function ActionNumberButton9)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("AcceptButton", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function ActionAcceptButton)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("CancelButton", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function ActionCancelButton)
endfunction
endlibrary
library FrameHeroScoreFrameOptions
globals
private boolean CreateOptionsInMenu = true
private real OptionX = 0.1
private real OptionY = 0.55
endglobals
private function ValueActionHeroScoreFrameOptionsSlider1 takes nothing returns nothing
if GetLocalPlayer() == GetTriggerPlayer() then
set HeroScoreFrame_TooltipScale = BlzGetTriggerFrameValue()
endif
call ExecuteFunc("HeroScoreFrameUpdateScale")
endfunction
private function WheelActionHeroScoreFrameOptionsSlider1 takes nothing returns nothing
if GetLocalPlayer() == GetTriggerPlayer() then
if BlzGetTriggerFrameValue() > 0 then
call BlzFrameSetValue(BlzGetTriggerFrame(), BlzFrameGetValue(BlzGetTriggerFrame()) + .05)
else
call BlzFrameSetValue(BlzGetTriggerFrame(), BlzFrameGetValue(BlzGetTriggerFrame()) - .05)
endif
endif
endfunction
private function ValueActionHeroScoreFrameOptionsSlider2 takes nothing returns nothing
if GetLocalPlayer() == GetTriggerPlayer() then
set HeroScoreFrame_AllyScale = BlzGetTriggerFrameValue()
endif
call ExecuteFunc("HeroScoreFrameUpdateScale")
endfunction
private function WheelActionHeroScoreFrameOptionsSlider2 takes nothing returns nothing
if GetLocalPlayer() == GetTriggerPlayer() then
if BlzGetTriggerFrameValue() > 0 then
call BlzFrameSetValue(BlzGetTriggerFrame(), BlzFrameGetValue(BlzGetTriggerFrame()) + .05)
else
call BlzFrameSetValue(BlzGetTriggerFrame(), BlzFrameGetValue(BlzGetTriggerFrame()) - .05)
endif
endif
endfunction
private function ValueActionHeroScoreFrameOptionsSlider3 takes nothing returns nothing
if GetLocalPlayer() == GetTriggerPlayer() then
set HeroScoreFrame_Scale = BlzGetTriggerFrameValue()
endif
call ExecuteFunc("HeroScoreFrameUpdateScale")
endfunction
private function WheelActionHeroScoreFrameOptionsSlider3 takes nothing returns nothing
if GetLocalPlayer() == GetTriggerPlayer() then
if BlzGetTriggerFrameValue() > 0 then
call BlzFrameSetValue(BlzGetTriggerFrame(), BlzFrameGetValue(BlzGetTriggerFrame()) + .05)
else
call BlzFrameSetValue(BlzGetTriggerFrame(), BlzFrameGetValue(BlzGetTriggerFrame()) - .05)
endif
endif
endfunction
private function ActionHeroScoreFrameOptionsCheckBox4 takes nothing returns nothing
local boolean checked = BlzGetTriggerFrameEvent() == FRAMEEVENT_CHECKBOX_CHECKED
if GetLocalPlayer() == GetTriggerPlayer() then
set HeroScoreFrame_HideText = checked
endif
endfunction
private function ActionHeroScoreFrameOptionsCheckBox5 takes nothing returns nothing
local boolean checked = BlzGetTriggerFrameEvent() == FRAMEEVENT_CHECKBOX_CHECKED
if GetLocalPlayer() == GetTriggerPlayer() then
set HeroScoreFrame_HideTextPack = checked
endif
endfunction
public function Create takes integer index returns nothing
local trigger trig
if CreateOptionsInMenu then
call BlzCreateFrame("HeroScoreFrameOptions", BlzGetFrameByName("InsideMainPanel", 0), 0, 0)
else
call BlzCreateFrame("HeroScoreFrameOptions", BlzGetFrameByName("HeroScoreFrameParent", 0), 0, 0)
endif
call BlzFrameSetAbsPoint(BlzGetFrameByName("HeroScoreFrameOptions", 0), FRAMEPOINT_TOPLEFT, OptionX, OptionY)
call BlzFrameSetValue(BlzGetFrameByName("HeroScoreFrameOptionsSlider1", index), HeroScoreFrame_TooltipScale)
call BlzFrameSetValue(BlzGetFrameByName("HeroScoreFrameOptionsSlider2", index), HeroScoreFrame_AllyScale)
call BlzFrameSetValue(BlzGetFrameByName("HeroScoreFrameOptionsSlider3", index), HeroScoreFrame_Scale)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameOptionsSlider1", index), FRAMEEVENT_SLIDER_VALUE_CHANGED)
call TriggerAddAction(trig, function ValueActionHeroScoreFrameOptionsSlider1)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameOptionsSlider1", index), FRAMEEVENT_MOUSE_WHEEL)
call TriggerAddAction(trig, function WheelActionHeroScoreFrameOptionsSlider1)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameOptionsSlider2", index), FRAMEEVENT_SLIDER_VALUE_CHANGED)
call TriggerAddAction(trig, function ValueActionHeroScoreFrameOptionsSlider2)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameOptionsSlider2", index), FRAMEEVENT_MOUSE_WHEEL)
call TriggerAddAction(trig, function WheelActionHeroScoreFrameOptionsSlider2)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameOptionsSlider3", index), FRAMEEVENT_SLIDER_VALUE_CHANGED)
call TriggerAddAction(trig, function ValueActionHeroScoreFrameOptionsSlider3)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameOptionsSlider3", index), FRAMEEVENT_MOUSE_WHEEL)
call TriggerAddAction(trig, function WheelActionHeroScoreFrameOptionsSlider3)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameOptionsCheckBox4", index), FRAMEEVENT_CHECKBOX_CHECKED)
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameOptionsCheckBox4", index), FRAMEEVENT_CHECKBOX_UNCHECKED)
call TriggerAddAction(trig, function ActionHeroScoreFrameOptionsCheckBox4)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameOptionsCheckBox5", index), FRAMEEVENT_CHECKBOX_CHECKED)
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameOptionsCheckBox5", index), FRAMEEVENT_CHECKBOX_UNCHECKED)
call TriggerAddAction(trig, function ActionHeroScoreFrameOptionsCheckBox5)
endfunction
endlibrary
library HeroScoreFrame initializer init_function requires optional FrameLoader, optional FrameHeroScoreFrameOptions, optional FrameNumberDialog
// HeroScoreFrame 1.5f
// by Tasyen
// HeroScoreFrame is a Frame-UI System for a Hero-Centric map.
// The UI is only shown while the player holds a key (default Tab) and shows some Infos about the Player's Heroes.
// Throws realVariable events when the library HeroScoreFrameEventGUI is found.
// udg_HeroScoreFrame_PlayerA, udg_HeroScoreFrame_PlayerB, udg_HeroScoreFrame_Event, udg_HeroScoreFrame_Unit, udg_HeroScoreFrame_Icon[], udg_HeroScoreFrame_Text[]
// udg_HeroScoreFrame_Event 1.0 = Before Swaping players
// udg_HeroScoreFrame_Event 2.0 = After Swaping players
// udg_HeroScoreFrame_Event 3.0 = Before Switch Teams
// udg_HeroScoreFrame_Event 4.0 = After Switch Teams
// udg_HeroScoreFrame_Event 5.0 = Update ScoreFrameInfo
// udg_HeroScoreFrame_Event -1.0 = Request Swap
// udg_HeroScoreFrame_Event -2.0 = Share
// udg_HeroScoreFrame_Event -3.0 = ShareAdv
// function HeroScoreFrameGetPlayerContext takes player p returns integer
// find the first used HeroScoreFrame used by Player and return the createContext
// returns -1, when the player does not use any
// function HeroScoreFrameSetTargetUnit takes integer createContext, unit u returns nothing
// When AutoSearchTarget is active the unit should be owned by the player using that card
// function HeroScoreFrameSetTargetPlayer takes integer createContext, player p returns nothing
// Makes the HeroScoreFrame with CreateContext target player
// A HeroSccoreFrame with player null will hide itself
// function HeroScoreFrameSetTargetTimer takes integer createContext, timer t returns nothing
// Read timer to display AutoReviveTime
// function HeroScoreFrameSetFaceOverlayText takes integer createContext, string text returns nothing
// Set Current Text of the OverlayText, is overwritten every Timeout when a timer is set
// function HeroScoreFrameGetTargetPlayer takes integer createContext returns player
// function HeroScoreFrameGetTargetUnit takes integer createContext returns unit
// function HeroScoreFrameSetScale takes real scale returns nothing
// function HeroScoreFrameSetAllyScale takes real scale returns nothing
// function HeroScoreFrameSetTooltipScale takes real scale returns nothing
globals
// AutoRun(true) will create Itself at 0s, (false) you need to HeroScoreFrameInit()
private boolean AutoRun = true
public string TocPath = "war3mapImported\\HeroScoreFrame.toc"
private constant integer eventNumberGold = 1
private constant integer eventNumberLumber = 2
// HideText(true) hides the score Icons and Texts between Face and Items
public boolean HideText = false
// HideTextPack(true) only works with HideText(true), Then it makes the Frames take less space.
public boolean HideTextPack = true
public real Scale = 0.8
// SizeX Y should match fdf values
public real SizeX = 0.22
public real SizeXPacked = 0.22 - 0.054
public real SizeY = 0.075
// how many HeroCards are created in InitFrames
private integer AutoCreateCount = GetBJMaxPlayers()
// how many HeroCards are in one Col
private integer Rows = 6
// X space between 2 Cols
private real ColOffsetX = 0
public real TooltipScale = 1.0
private real TooltipWidth = 0.2
private boolean TooltipFixedPosition = true
private real TooltipFixedPositionX = 0.79
private real TooltipFixedPositionY = 0.16
private framepointtype TooltipFixedPositionPoint = FRAMEPOINT_BOTTOMRIGHT
// AutoSearchTarget, when there is no valid Unit of the UIPlayer of a HeroScoreFrame search one
private boolean AutoSearchTarget = true
// FillByTeam(false) fill the UI based on PlayerNumber
// FillByTeam(true) start with PlayerTeam than PlayerNumber
// FillByTeam = false is recommented when there are no fixed Teams
private boolean FillByTeam = true
private boolean FillByTeamSkipCols = true
// postion of the first HeroScoreFrame,
private real X = 0.4
private real Y = 0.55
private framepointtype Point = FRAMEPOINT_TOPRIGHT
// Key has to be hold to show the UI
private oskeytype TriggerKey = OSKEY_TAB
public real AllyScale = 0.80
// Fixed postion of the PlayerControl-PopUp,
// disable fixed position with AllyPoint = null
public framepointtype AllyPoint = FRAMEPOINT_TOPRIGHT
public real AllyX = 0.79
public real AllyY = 0.55
// Read item specific text/icon, instead of itemCode text/icon.
public boolean DynamicItems = false
public boolean AutoSwapBot = true
public boolean AllowSwapEnemies = true
public integer SwitchAllianceType = bj_ALLIANCE_ALLIED_VISION // choose a bj_ALLIANCE_xxxx
public boolean SwitchAllianceAdv = true // give adv shared Control, shows hero icons and other stuff. Ordering still requires bj_ALLIANCE_ALLIED_UNITS or bj_ALLIANCE_ALLIED_ADVUNITS
// Interpret Swap onto Enemy Players as Team Switch
// SwapEnemyIsSwitch(true) does not change units but Teams
// SwapEnemyIsSwitch(false) does change units but no Teams
public boolean SwapEnemyIsSwitch = true
public boolean AllowSwapAllies = true
public boolean AllowShareAdv = true
public boolean AllowShare = true
public boolean AllowSendGoldAlly = true
public boolean AllowSendLumberAlly = true
public boolean AllowSendGoldEnemy = false
public boolean AllowSendLumberEnemy = false
//===========
// system globals
// Created contains the CreateContexts created.
private integer array Created
private integer CreatedCount = 0
private integer ColStarts = 0
// UiTargets are stored under CreateContext
public unit array UiTargetUnit
public player array UiTargetPlayer
public timer array UiTargetTimer
private group g = CreateGroup()
private group swapGroupA = CreateGroup()
private group swapGroupB = CreateGroup()
private player array SelectedPlayer
private boolean array Swap
endglobals
// can be used to prevent players from taking an UI
// return false when no UI shall be used by that player
private function AllowedPlayer takes player p returns boolean
if GetPlayerSlotState(p) != PLAYER_SLOT_STATE_PLAYING then
return false
endif
if (GetPlayerController(p) != MAP_CONTROL_USER and GetPlayerController(p) != MAP_CONTROL_COMPUTER) then
return false
endif
if p == Player(6) or p == Player(0) then
//return false
endif
return true
endfunction
// shown next to Share/Swap Buttons (current State)
private function GetTexture takes boolean enabled returns string
if enabled then
return "ui\\widgets\\glues\\thumbsup-up"
else
return "ui\\widgets\\glues\\thumbsdown-up"
endif
endfunction
public function ParentFunc takes nothing returns framehandle
return BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0)
endfunction
// FACE_COLOR_BACKGROUND(true) moves the playercolor below the Face. (false) To the top of a HeroScoreFrame
private function FACE_COLOR_BACKGROUND takes nothing returns boolean
return true
endfunction
//===========
//===========
function HeroScoreFrameGetPlayerContext takes player p returns integer
local integer loopIndex = 0
loop
if UiTargetPlayer[Created[loopIndex]] == p then
return Created[loopIndex]
endif
set loopIndex = loopIndex + 1
exitwhen loopIndex >= CreatedCount
endloop
return -1
endfunction
function HeroScoreFrameSetFaceOverlayText takes integer createContext, string text returns nothing
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameFaceTextOverLay", createContext), text)
endfunction
function HeroScoreFrameSetTargetTimer takes integer createContext, timer t returns nothing
if createContext < 0 then
return
endif
set UiTargetTimer[createContext] = t
endfunction
function HeroScoreFrameSetTargetUnit takes integer createContext, unit u returns nothing
if createContext < 0 then
return
endif
set UiTargetUnit[createContext] = u
endfunction
function HeroScoreFrameSetTargetPlayer takes integer createContext, player p returns nothing
if createContext < 0 then
return
endif
set UiTargetPlayer[createContext] = p
endfunction
function HeroScoreFrameGetTargetUnit takes integer createContext returns unit
return UiTargetUnit[createContext]
endfunction
function HeroScoreFrameGetTargetPlayer takes integer createContext returns player
return UiTargetPlayer[createContext]
endfunction
function HeroScoreFrameSetTooltipScale takes real scale returns nothing
set TooltipScale = scale
call BlzFrameSetScale(BlzGetFrameByName("HeroScoreFrameTooltipParent", 0), scale)
endfunction
function HeroScoreFrameSetAllyScale takes real scale returns nothing
set AllyScale = scale
call BlzFrameSetScale(BlzGetFrameByName("HeroScoreFrameAlly", 0), scale)
endfunction
function HeroScoreFrameSetScale takes real scale returns nothing
set Scale = scale
call BlzFrameSetScale(BlzGetFrameByName("HeroScoreFrameParent", 0), scale)
// Scale Tooltips/Ally, to undo the overall Scaling for them
call HeroScoreFrameSetTooltipScale(TooltipScale)
call HeroScoreFrameSetAllyScale(AllyScale)
static if LIBRARY_FrameNumberDialog then
call BlzFrameSetScale(BlzGetFrameByName("NumberDialog", 0), 1)
endif
static if LIBRARY_FrameHeroScoreFrameOptions then
call BlzFrameSetScale(BlzGetFrameByName("HeroScoreFrameOptions", 0), 1)
endif
endfunction
function HeroScoreFrameUpdateScale takes nothing returns nothing
call HeroScoreFrameSetScale(Scale)
endfunction
private function GetDisabledIcon takes string icon returns string
//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
return SubString(icon, 0, 34) + "Disabled\\DIS" + SubString(icon, 35, StringLength(icon))
endfunction
public function CreateSimpleTooltipHSF takes framehandle frame, string wantedframeName, integer wantedCreateContext, string text returns framehandle
// this FRAME is important when the Box is outside of 4:3 it can be limited to 4:3.
local framehandle toolTipParent = BlzCreateFrameByType("FRAME", "", BlzGetFrameByName("HeroScoreFrameTooltipParent", 0), "", 0)
local framehandle toolTipBox = BlzCreateFrame("TasToolTipBox", toolTipParent, 0, 0)
local framehandle toolTip = BlzCreateFrameByType("TEXT", wantedframeName, toolTipBox, "TasTooltipText", wantedCreateContext)
//local toolTip = BlzCreateFrame("TasButtonTextTemplate", toolTipBox, 0, 0)
if TooltipFixedPosition then
call BlzFrameSetAbsPoint(toolTip, TooltipFixedPositionPoint, TooltipFixedPositionX, TooltipFixedPositionY)
else
call BlzFrameSetPoint(toolTip, FRAMEPOINT_TOP, frame, FRAMEPOINT_BOTTOM, 0, -0.008)
endif
call BlzFrameSetPoint(toolTipBox, FRAMEPOINT_TOPLEFT, toolTip, FRAMEPOINT_TOPLEFT, -0.008, 0.008)
call BlzFrameSetPoint(toolTipBox, FRAMEPOINT_BOTTOMRIGHT, toolTip, FRAMEPOINT_BOTTOMRIGHT, 0.008, -0.008)
call BlzFrameSetText(toolTip, text)
call BlzFrameSetTooltip(frame, toolTipParent)
call BlzFrameSetSize(toolTip, TooltipWidth, 0)
return toolTip
endfunction
private function Update takes unit u, integer frameIndex returns nothing
local item i
local integer itemTypeId
local player p = UiTargetPlayer[frameIndex]
local integer loopIndex = 0
// show this HeroScoreFrame
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrame", frameIndex), true)
// update Face Display
if IsUnitType(u, UNIT_TYPE_DEAD) then
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameFaceBackdrop", frameIndex), GetDisabledIcon(BlzGetAbilityIcon(GetUnitTypeId(u))), 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameFaceBackdropDisabled", frameIndex), GetDisabledIcon(BlzGetAbilityIcon(GetUnitTypeId(u))), 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameFaceBackdropPushed", frameIndex), GetDisabledIcon(BlzGetAbilityIcon(GetUnitTypeId(u))), 0, false)
if UiTargetTimer[frameIndex] != null then
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameFaceTextOverLay", frameIndex), I2S(R2I(TimerGetRemaining(UiTargetTimer[frameIndex]))))
endif
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameFaceTextOverLay", frameIndex), true)
else
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameFaceBackdrop", frameIndex), BlzGetAbilityIcon(GetUnitTypeId(u)), 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameFaceBackdropDisabled", frameIndex), BlzGetAbilityIcon(GetUnitTypeId(u)), 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameFaceBackdropPushed", frameIndex), BlzGetAbilityIcon(GetUnitTypeId(u)), 0, false)
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameFaceTextOverLay", frameIndex), false)
endif
// PlayerColor
if GetHandleId(GetPlayerColor(p)) < 10 then
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFramePlayerColor", frameIndex), "ReplaceableTextures\\TeamColor\\TeamColor0" + I2S(GetHandleId(GetPlayerColor(p))), 0, false)
else
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFramePlayerColor", frameIndex), "ReplaceableTextures\\TeamColor\\TeamColor" + I2S(GetHandleId(GetPlayerColor(p))), 0, false)
endif
// LevelBox
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameFaceChargeText", frameIndex), I2S(GetUnitLevel(u)))
// Face Tooltip
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameFaceTooltipText", frameIndex), GetPlayerName(p) + " (" + GetUnitName(u) + " - " + GetHeroProperName(u) + ")")
// Score Text
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameTextParent", frameIndex), not HideText)
if HideText and HideTextPack then
call BlzFrameSetSize(BlzGetFrameByName("HeroScoreFrame", frameIndex), SizeXPacked, SizeY)
else
call BlzFrameSetSize(BlzGetFrameByName("HeroScoreFrame", frameIndex), SizeX , SizeY)
endif
// Throw the event independent from HideText to avoid desync, but support async changes to HideText.
static if LIBRARY_HeroScoreFrameEventGUI then
set udg_HeroScoreFrame_PlayerA = p
set udg_HeroScoreFrame_Unit = u
set udg_HeroScoreFrame_Event = 5
set udg_HeroScoreFrame_Event = 0
endif
if not HideText then
static if LIBRARY_HeroScoreFrameEventGUI then
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameText1", frameIndex), udg_HeroScoreFrame_Text[1])
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameText2", frameIndex), udg_HeroScoreFrame_Text[2])
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameText3", frameIndex), udg_HeroScoreFrame_Text[3])
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameTextIcon1", frameIndex), udg_HeroScoreFrame_Icon[1], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameTextIcon2", frameIndex), udg_HeroScoreFrame_Icon[2], 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameTextIcon3", frameIndex), udg_HeroScoreFrame_Icon[3], 0, false)
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameTextTooltip1", frameIndex), udg_HeroScoreFrame_Text[11])
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameTextTooltip2", frameIndex), udg_HeroScoreFrame_Text[12])
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameTextTooltip3", frameIndex), udg_HeroScoreFrame_Text[13])
else
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameText1", frameIndex), I2S(GetPlayerScore(p, PLAYER_SCORE_UNITS_KILLED) - GetPlayerScore(p, PLAYER_SCORE_HEROES_KILLED)))
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameText2", frameIndex), I2S(GetPlayerScore(p, PLAYER_SCORE_HEROES_KILLED)))
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameText3", frameIndex), I2S(GetPlayerScore(p, PLAYER_SCORE_STRUCT_RAZED)))
endif
endif
// update Item Display
loop
set i = UnitItemInSlot(u, loopIndex)
set itemTypeId = GetItemTypeId(i)
if itemTypeId > 0 then
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameItemSlotButton_" + I2S(loopIndex), frameIndex), true)
if DynamicItems then
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameItemSlotButton_"+I2S(loopIndex)+"Backdrop", frameIndex), BlzGetItemIconPath(i), 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameItemSlotButton_"+I2S(loopIndex)+"BackdropDisabled", frameIndex), BlzGetItemIconPath(i), 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameItemSlotButton_"+I2S(loopIndex)+"BackdropPushed", frameIndex), BlzGetItemIconPath(i), 0, false)
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameItemSlotButtonTooltipText_"+I2S(loopIndex), frameIndex), GetItemName(i)+"\n"+BlzGetItemExtendedTooltip(i))
else
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameItemSlotButton_" + I2S(loopIndex) + "Backdrop", frameIndex), BlzGetAbilityIcon(itemTypeId), 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameItemSlotButton_" + I2S(loopIndex) + "BackdropDisabled", frameIndex), BlzGetAbilityIcon(itemTypeId), 0, false)
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameItemSlotButton_" + I2S(loopIndex) + "BackdropPushed", frameIndex), BlzGetAbilityIcon(itemTypeId), 0, false)
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameItemSlotButtonTooltipText_" + I2S(loopIndex), frameIndex), GetObjectName(itemTypeId) + "\n" + BlzGetAbilityExtendedTooltip(itemTypeId, 0))
endif
if GetItemCharges(i) > 0 then
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameItemSlotButtonChargeText_" + I2S(loopIndex), frameIndex), I2S(GetItemCharges(i)))
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameItemSlotButtonChargeBox_" + I2S(loopIndex), frameIndex), true)
else
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameItemSlotButtonChargeBox_" + I2S(loopIndex), frameIndex), false)
endif
else
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameItemSlotButton_" + I2S(loopIndex), frameIndex), false)
endif
set loopIndex = loopIndex + 1
exitwhen loopIndex >= 6
endloop
set i = null
set p = null
endfunction
private function UpdateFrameAllyIcons takes player p returns nothing
if GetLocalPlayer() == p then
// PlayerColor
if GetHandleId(GetPlayerColor(SelectedPlayer[GetPlayerId(p)])) < 10 then
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameAllyTargetPlayerColor", 0), "ReplaceableTextures\\TeamColor\\TeamColor0" + I2S(GetHandleId(GetPlayerColor(SelectedPlayer[GetPlayerId(p)]))), 0, false)
else
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameAllyTargetPlayerColor", 0), "ReplaceableTextures\\TeamColor\\TeamColor" + I2S(GetHandleId(GetPlayerColor(SelectedPlayer[GetPlayerId(p)]))), 0, false)
endif
// revert Player in ALLIANCE_SHARED_ADVANCED_CONTROL because we want to see the target players face
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameAllyButtonShareAdvIcon", 0), GetTexture(GetPlayerAlliance(SelectedPlayer[GetPlayerId(p)], p, ALLIANCE_SHARED_ADVANCED_CONTROL)), 0, true)
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameAllyButtonShareIcon", 0), GetTexture(GetPlayerAlliance(p, SelectedPlayer[GetPlayerId(p)], ALLIANCE_SHARED_CONTROL)), 0, true)
call BlzFrameSetTexture(BlzGetFrameByName("HeroScoreFrameAllyButtonSwapIcon", 0), GetTexture(Swap[GetPlayerId(p)*bj_MAX_PLAYER_SLOTS + GetPlayerId(SelectedPlayer[GetPlayerId(p)])]), 0, true)
if not AllowSendGoldAlly and not AllowSendLumberAlly and not AllowSendGoldEnemy and not AllowSendLumberEnemy then
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendGold", 0), false)
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendLumber", 0), false)
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAllyButtonSend", 0), false)
else
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendGold", 0), true)
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendLumber", 0), true)
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAllyButtonSend", 0), true)
endif
if IsPlayerAlly(p, SelectedPlayer[GetPlayerId(p)]) then
call BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendGold", 0), AllowSendGoldAlly)
call BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendLumber", 0), AllowSendLumberAlly)
call BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyButtonSwap", 0), AllowSwapAllies)
call BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyButtonShare", 0), AllowShare)
call BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyButtonShareAdv", 0), AllowShareAdv)
else
call BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendGold", 0), AllowSendGoldEnemy)
call BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendLumber", 0), AllowSendLumberEnemy)
call BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyButtonSwap", 0), AllowSwapEnemies)
call BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyButtonShare", 0), false)
call BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyButtonShareAdv", 0), false)
endif
endif
endfunction
private function ShowFrameAlly takes player p, framehandle frame returns nothing
if GetLocalPlayer() == p then
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAlly", 0), AllowSwapEnemies or AllowSwapAllies or AllowShareAdv or AllowShare or AllowSendGoldAlly or AllowSendLumberAlly or AllowSendGoldEnemy or AllowSendLumberEnemy)
if AllyPoint == null then
call BlzFrameClearAllPoints(BlzGetFrameByName("HeroScoreFrameAlly", 0))
call BlzFrameSetPoint(BlzGetFrameByName("HeroScoreFrameAlly", 0), FRAMEPOINT_TOPLEFT, frame, FRAMEPOINT_TOPRIGHT, 0, 0)
endif
call UpdateFrameAllyIcons(p)
endif
endfunction
private function HeroScoreFrameAction takes nothing returns nothing
set SelectedPlayer[GetPlayerId(GetTriggerPlayer())] = UiTargetPlayer[(S2I(BlzFrameGetText(BlzGetTriggerFrame())))]
call ShowFrameAlly(GetTriggerPlayer(), BlzGetTriggerFrame())
endfunction
private function HeroScoreFrameFaceAction takes nothing returns nothing
set SelectedPlayer[GetPlayerId(GetTriggerPlayer())] = UiTargetPlayer[(S2I(BlzFrameGetText(BlzGetTriggerFrame())))]
call ShowFrameAlly(GetTriggerPlayer(), BlzFrameGetParent(BlzGetTriggerFrame()))
endfunction
private function CreateHeroScoreFrame takes integer index returns nothing
local trigger trig
local framehandle frame = BlzCreateFrame("HeroScoreFrame", BlzGetFrameByName("HeroScoreFrameParent", 0), 0, index)
local integer loopIndex = 0
if GetHandleId(frame) == 0 then
call BJDebugMsg("Error - Create HeroScoreFrame")
endif
if HideText then
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameTextParent", index), false)
call BlzFrameSetSize(frame, BlzFrameGetWidth(frame) - 0.055, BlzFrameGetHeight(frame))
endif
if FACE_COLOR_BACKGROUND() then
call BlzFrameClearAllPoints(BlzGetFrameByName("HeroScoreFramePlayerColor", index))
call BlzFrameSetPoint(BlzGetFrameByName("HeroScoreFramePlayerColor", index), FRAMEPOINT_TOPLEFT, BlzGetFrameByName("HeroScoreFrameFace", index), FRAMEPOINT_TOPLEFT, -0.002, 0.002)
call BlzFrameSetPoint(BlzGetFrameByName("HeroScoreFramePlayerColor", index), FRAMEPOINT_BOTTOMRIGHT, BlzGetFrameByName("HeroScoreFrameFace", index), FRAMEPOINT_BOTTOMRIGHT, 0.002, -0.002)
endif
if CreatedCount == 0 then
call BlzFrameSetAbsPoint(frame, Point, X, Y)
set ColStarts = index
elseif Rows > 0 and ModuloInteger(CreatedCount, Rows) == 0 then
call BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, BlzGetFrameByName("HeroScoreFrame", ColStarts), FRAMEPOINT_TOPRIGHT, ColOffsetX, 0.0)
set ColStarts = index
else
call BlzFrameSetPoint(frame, FRAMEPOINT_TOPLEFT, BlzGetFrameByName("HeroScoreFrame", Created[CreatedCount]), FRAMEPOINT_BOTTOMLEFT, 0.0, 0.0)
endif
set CreatedCount = CreatedCount + 1
set Created[CreatedCount] = index
call CreateSimpleTooltipHSF(BlzGetFrameByName("HeroScoreFrameFace", index), "HeroScoreFrameFaceTooltipText", index, "test")
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, frame, FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function HeroScoreFrameAction)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameFace", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function HeroScoreFrameFaceAction)
call BlzFrameSetText(frame, I2S(index))
call BlzFrameSetText(BlzGetFrameByName("HeroScoreFrameFace", index), I2S(index))
call BlzFrameSetSize(BlzGetFrameByName("HeroScoreFrameFaceTooltipText", index), 0, 0)
call CreateSimpleTooltipHSF(BlzGetFrameByName("HeroScoreFrameText1", index), "HeroScoreFrameTextTooltip1", index, GetLocalizedString("UNIT_COLUMN1"))
call CreateSimpleTooltipHSF(BlzGetFrameByName("HeroScoreFrameText2", index), "HeroScoreFrameTextTooltip2", index, GetLocalizedString("HEROES_COLUMN1"))
call CreateSimpleTooltipHSF(BlzGetFrameByName("HeroScoreFrameText3", index), "HeroScoreFrameTextTooltip3", index, GetLocalizedString("UNIT_COLUMN3"))
static if not LIBRARY_HeroScoreFrameEventGUI then
call BlzFrameSetSize(BlzGetFrameByName("HeroScoreFrameTextTooltip1", index), 0, 0)
call BlzFrameSetSize(BlzGetFrameByName("HeroScoreFrameTextTooltip2", index), 0, 0)
call BlzFrameSetSize(BlzGetFrameByName("HeroScoreFrameTextTooltip3", index), 0, 0)
endif
call BlzGetFrameByName("HeroScoreFrameTextTooltip1", index)
call BlzGetFrameByName("HeroScoreFrameTextTooltip2", index)
call BlzGetFrameByName("HeroScoreFrameTextTooltip3", index)
call BlzGetFrameByName("HeroScoreFrameTextIcon1", index)
call BlzGetFrameByName("HeroScoreFrameTextIcon2", index)
call BlzGetFrameByName("HeroScoreFrameTextIcon3", index)
loop
call CreateSimpleTooltipHSF(BlzGetFrameByName("HeroScoreFrameItemSlotButton_" + I2S(loopIndex), index), "HeroScoreFrameItemSlotButtonTooltipText_" + I2S(loopIndex), index, "test")
// Reserve HandleId
call BlzGetFrameByName("HeroScoreFrameItemSlotButton_"+ I2S(loopIndex) + "Backdrop", index)
call BlzGetFrameByName("HeroScoreFrameItemSlotButton_"+ I2S(loopIndex) + "BackdropDisabled", index)
call BlzGetFrameByName("HeroScoreFrameItemSlotButton_"+ I2S(loopIndex) + "BackdropPushed", index)
call BlzGetFrameByName("HeroScoreFrameItemSlotButtonTooltipText_"+ I2S(loopIndex), index)
call BlzGetFrameByName("HeroScoreFrameItemSlotButtonChargeText_"+ I2S(loopIndex), index)
call BlzGetFrameByName("HeroScoreFrameItemSlotButtonChargeBox_"+ I2S(loopIndex), index)
set loopIndex = loopIndex + 1
exitwhen loopIndex >= 6
endloop
call BlzGetFrameByName("HeroScoreFrameFaceTextOverLay", index)
endfunction
private function SwapActionGroupA takes nothing returns nothing
call SetUnitOwner(GetEnumUnit(), SelectedPlayer[GetPlayerId(GetTriggerPlayer())], true)
endfunction
private function SwapActionGroupB takes nothing returns nothing
call SetUnitOwner(GetEnumUnit(), GetTriggerPlayer(), true)
endfunction
private function SwitchTeams takes player playerA, player playerB returns nothing
local integer teamA = GetPlayerTeam(playerA)
local integer teamB = GetPlayerTeam(playerB)
local integer indexTemp = GetPlayerStartLocation(playerB)
local integer i = 0
local integer index
local integer heroCardIndexA
local integer heroCardIndexB
local playercolor tempColor = GetPlayerColor(playerB)
// Enemy Swap - Fixed Team Game -> swap Team
if IsPlayerEnemy(playerA, playerB) and SwapEnemyIsSwitch then
static if LIBRARY_HeroScoreFrameEventGUI then
set udg_HeroScoreFrame_PlayerA = playerA
set udg_HeroScoreFrame_PlayerB = playerB
set udg_HeroScoreFrame_Event = 3
set udg_HeroScoreFrame_Event = 0
else
endif
call SetPlayerTeam(playerA, teamB)
call SetPlayerTeam(playerB, teamA)
// swap used StartLocation
call SetPlayerStartLocation(playerB, GetPlayerStartLocation(playerA))
call SetPlayerStartLocation(playerA, indexTemp)
// swap Alliance with others
loop
if Player(i) != playerA and Player(i) != playerB and IsPlayerAlly(playerA, Player(i)) != IsPlayerAlly(playerB, Player(i)) then
if IsPlayerAlly(playerA, Player(i)) then
call SetPlayerAllianceStateBJ(Player(i), playerB, SwitchAllianceType)
call SetPlayerAllianceStateBJ(playerB, Player(i), SwitchAllianceType)
if SwitchAllianceAdv then
call SetPlayerAlliance(Player(i), playerA, ALLIANCE_SHARED_ADVANCED_CONTROL, true)
call SetPlayerAlliance(playerA, Player(i), ALLIANCE_SHARED_ADVANCED_CONTROL, true)
endif
call SetPlayerAllianceStateBJ(Player(i), playerA, bj_ALLIANCE_UNALLIED)
call SetPlayerAllianceStateBJ(playerA, Player(i), bj_ALLIANCE_UNALLIED)
else
call SetPlayerAllianceStateBJ(Player(i), playerA, SwitchAllianceType)
call SetPlayerAllianceStateBJ(playerA, Player(i), SwitchAllianceType)
if SwitchAllianceAdv then
call SetPlayerAlliance(Player(i), playerB, ALLIANCE_SHARED_ADVANCED_CONTROL, true)
call SetPlayerAlliance(playerB, Player(i), ALLIANCE_SHARED_ADVANCED_CONTROL, true)
endif
call SetPlayerAllianceStateBJ(Player(i), playerB, bj_ALLIANCE_UNALLIED)
call SetPlayerAllianceStateBJ(playerB, Player(i), bj_ALLIANCE_UNALLIED)
endif
endif
set i = i + 1
exitwhen i == bj_MAX_PLAYER_SLOTS
endloop
// find used UI
set i = CreatedCount
loop
set index = Created[i]
if playerA == UiTargetPlayer[index] then
set heroCardIndexA = index
endif
if playerB == UiTargetPlayer[index] then
set heroCardIndexB = index
endif
set i = i - 1
exitwhen i <= 0
endloop
// swap UI
call HeroScoreFrameSetTargetPlayer(heroCardIndexA, playerB)
call HeroScoreFrameSetTargetPlayer(heroCardIndexB, playerA)
static if LIBRARY_HeroScoreFrameEventGUI then
set udg_HeroScoreFrame_PlayerA = playerA
set udg_HeroScoreFrame_PlayerB = playerB
set udg_HeroScoreFrame_Event = 4
set udg_HeroScoreFrame_Event = 0
else
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 30, "Switch Team: "+ GetPlayerName(playerA)+ " - " + GetPlayerName(playerB))
endif
endif
endfunction
private function HeroScoreFrameAllyButtonSwapAction takes nothing returns nothing
local integer indexA
local integer indexB
local player playerA = GetTriggerPlayer()
local player playerB = SelectedPlayer[GetPlayerId(GetTriggerPlayer())]
if playerA != playerB then
set indexA = GetPlayerId(playerA)*bj_MAX_PLAYER_SLOTS + GetPlayerId(playerB)
set indexB = GetPlayerId(playerB)*bj_MAX_PLAYER_SLOTS + GetPlayerId(playerA)
set Swap[indexA] = not Swap[indexA]
static if LIBRARY_HeroScoreFrameEventGUI then
set udg_HeroScoreFrame_PlayerA = playerA
set udg_HeroScoreFrame_PlayerB = playerB
set udg_HeroScoreFrame_Event = -1
set udg_HeroScoreFrame_Event = 0
else
call DisplayTimedTextToPlayer(playerB, 0, 0, 30, GetPlayerName(playerA) + "requests swapping with you")
endif
if Swap[indexA] and (Swap[indexB] or (AutoSwapBot and (GetPlayerController(playerB) == MAP_CONTROL_COMPUTER) or GetPlayerSlotState(playerB) != PLAYER_SLOT_STATE_PLAYING)) then
if not IsPlayerEnemy(playerA, playerB) or not SwapEnemyIsSwitch then
static if LIBRARY_HeroScoreFrameEventGUI then
set udg_HeroScoreFrame_PlayerA = playerA
set udg_HeroScoreFrame_PlayerB = playerB
set udg_HeroScoreFrame_Event = 1
set udg_HeroScoreFrame_Event = 0
endif
call GroupEnumUnitsOfPlayer(swapGroupA, playerA, null)
call GroupEnumUnitsOfPlayer(swapGroupB, playerB, null)
call ForGroup(swapGroupA, function SwapActionGroupA)
call ForGroup(swapGroupB, function SwapActionGroupB)
call GroupClear(swapGroupA)
call GroupClear(swapGroupB)
static if LIBRARY_HeroScoreFrameEventGUI then
set udg_HeroScoreFrame_PlayerA = playerA
set udg_HeroScoreFrame_PlayerB = playerB
set udg_HeroScoreFrame_Event = 2
set udg_HeroScoreFrame_Event = 0
else
call DisplayTimedTextToPlayer(GetLocalPlayer(), 0, 0, 30, "Swap Players: "+ GetPlayerName(playerA)+ " - " + GetPlayerName(playerB))
endif
endif
call SwitchTeams(playerA, playerB)
set Swap[indexA] = false
set Swap[indexB] = false
endif
call UpdateFrameAllyIcons(playerA)
endif
set playerA = null
set playerB = null
endfunction
private function HeroScoreFrameAllyButtonShareAction takes nothing returns nothing
if GetTriggerPlayer() != SelectedPlayer[GetPlayerId(GetTriggerPlayer())] then
call SetPlayerAlliance(GetTriggerPlayer(), SelectedPlayer[GetPlayerId(GetTriggerPlayer())], ALLIANCE_SHARED_CONTROL, not GetPlayerAlliance(GetTriggerPlayer(), SelectedPlayer[GetPlayerId(GetTriggerPlayer())], ALLIANCE_SHARED_CONTROL))
// call SetPlayerAlliance(SelectedPlayer[GetPlayerId(GetTriggerPlayer())], GetTriggerPlayer(), ALLIANCE_SHARED_CONTROL, not GetPlayerAlliance(SelectedPlayer[GetPlayerId(GetTriggerPlayer())], GetTriggerPlayer(), ALLIANCE_SHARED_CONTROL))
static if LIBRARY_HeroScoreFrameEventGUI then
set udg_HeroScoreFrame_PlayerA = GetTriggerPlayer()
set udg_HeroScoreFrame_PlayerB = SelectedPlayer[GetPlayerId(GetTriggerPlayer())]
set udg_HeroScoreFrame_Event = -2
set udg_HeroScoreFrame_Event = 0
else
endif
call UpdateFrameAllyIcons(GetTriggerPlayer())
endif
endfunction
private function HeroScoreFrameAllyButtonShareAdvAction takes nothing returns nothing
if GetTriggerPlayer() != SelectedPlayer[GetPlayerId(GetTriggerPlayer())] then
//SetPlayerAlliance(GetTriggerPlayer(), SelectedPlayer[GetPlayerId(GetTriggerPlayer())], ALLIANCE_SHARED_ADVANCED_CONTROL, not GetPlayerAlliance(GetTriggerPlayer(), SelectedPlayer[GetPlayerId(GetTriggerPlayer())], ALLIANCE_SHARED_ADVANCED_CONTROL))
// The clicking Player wants to see the face of the target Player
call SetPlayerAlliance(SelectedPlayer[GetPlayerId(GetTriggerPlayer())], GetTriggerPlayer(), ALLIANCE_SHARED_ADVANCED_CONTROL, not GetPlayerAlliance(SelectedPlayer[GetPlayerId(GetTriggerPlayer())], GetTriggerPlayer(), ALLIANCE_SHARED_ADVANCED_CONTROL))
static if LIBRARY_HeroScoreFrameEventGUI then
set udg_HeroScoreFrame_PlayerA = GetTriggerPlayer()
set udg_HeroScoreFrame_PlayerB = SelectedPlayer[GetPlayerId(GetTriggerPlayer())]
set udg_HeroScoreFrame_Event = -3
set udg_HeroScoreFrame_Event = 0
else
endif
call UpdateFrameAllyIcons(GetTriggerPlayer())
endif
endfunction
private function ButtonCloseAction takes nothing returns nothing
if GetLocalPlayer() == GetTriggerPlayer() then
call BlzFrameSetVisible(BlzFrameGetParent(BlzGetTriggerFrame()), false)
endif
endfunction
static if LIBRARY_FrameNumberDialog then
private function ButtonSendGoldAction takes nothing returns nothing
call ShowNumberDialog(GetTriggerPlayer(), 2, eventNumberGold)
endfunction
private function ButtonSendLumberAction takes nothing returns nothing
call ShowNumberDialog(GetTriggerPlayer(), 3, eventNumberLumber)
endfunction
private function SendGoldAction takes nothing returns nothing
local integer amount = NumberDialogResult
if GetPlayerState(NumberDialogPlayer, PLAYER_STATE_RESOURCE_GOLD) < amount then
set amount = GetPlayerState(NumberDialogPlayer, PLAYER_STATE_RESOURCE_GOLD)
endif
call AdjustPlayerStateBJ(-amount,NumberDialogPlayer, PLAYER_STATE_RESOURCE_GOLD)
call AdjustPlayerStateBJ(amount, SelectedPlayer[GetPlayerId(NumberDialogPlayer)], PLAYER_STATE_RESOURCE_GOLD)
call BJDebugMsg("Send Gold: " + I2S(amount) + " " + GetPlayerName(GetTriggerPlayer()) + " -> " +GetPlayerName(SelectedPlayer[GetPlayerId(NumberDialogPlayer)]))
endfunction
private function SendLumberAction takes nothing returns nothing
local integer amount = NumberDialogResult
if GetPlayerState(NumberDialogPlayer, PLAYER_STATE_RESOURCE_LUMBER) < amount then
set amount = GetPlayerState(NumberDialogPlayer, PLAYER_STATE_RESOURCE_LUMBER)
endif
call AdjustPlayerStateBJ(-amount,NumberDialogPlayer, PLAYER_STATE_RESOURCE_LUMBER)
call AdjustPlayerStateBJ(amount, SelectedPlayer[GetPlayerId(NumberDialogPlayer)], PLAYER_STATE_RESOURCE_LUMBER)
call BJDebugMsg("Send Lumber: " + I2S(amount) + " " + GetPlayerName(GetTriggerPlayer()) + " -> " +GetPlayerName(SelectedPlayer[GetPlayerId(NumberDialogPlayer)]))
endfunction
endif
function CreateGeneratedFrameHeroScoreFrameAlly takes integer index returns nothing
local trigger trig
local framehandle frame = BlzCreateFrame("HeroScoreFrameAlly", BlzGetFrameByName("HeroScoreFrameParent", 0), 0, index)
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAlly", 0), false)
if AllyPoint != null then
call BlzFrameSetAbsPoint(BlzGetFrameByName("HeroScoreFrameAlly", 0), AllyPoint, AllyX, AllyY)
endif
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameAllyButtonSwap", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function HeroScoreFrameAllyButtonSwapAction)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameAllyButtonShare", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function HeroScoreFrameAllyButtonShareAction)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameAllyButtonShareAdv", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function HeroScoreFrameAllyButtonShareAdvAction)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameAllyButtonClose", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function ButtonCloseAction)
static if LIBRARY_FrameNumberDialog then
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendGold", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function ButtonSendGoldAction)
set trig = CreateTrigger()
call BlzTriggerRegisterFrameEvent(trig, BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendLumber", index), FRAMEEVENT_CONTROL_CLICK)
call TriggerAddAction(trig, function ButtonSendLumberAction)
set trig = CreateTrigger()
call TriggerRegisterVariableEvent(trig, "NumberDialogEvent", EQUAL, eventNumberGold )
call TriggerAddAction(trig, function SendGoldAction)
set trig = CreateTrigger()
call TriggerRegisterVariableEvent(trig, "NumberDialogEvent", EQUAL, eventNumberLumber)
call TriggerAddAction(trig, function SendLumberAction)
endif
call BlzFrameSetEnable(BlzGetFrameByName("HeroScoreFrameAllyButtonSend", index), false)
// Reserve HandleIds
call BlzGetFrameByName("HeroScoreFrameAllyButtonShareAdvIcon", index)
call BlzGetFrameByName("HeroScoreFrameAllyButtonShareIcon", index)
call BlzGetFrameByName("HeroScoreFrameAllyButtonSwapIcon", index)
call BlzGetFrameByName("HeroScoreFrameAllyTargetPlayerColor", index)
call BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendGold", index)
call BlzGetFrameByName("HeroScoreFrameAllyIconButtonSendLumber", index)
// call BlzFrameSetScale(frame, 1)
endfunction
private function InitFrames takes nothing returns nothing
local integer i = 0
local integer team = 0
local integer remain
local integer usedCounter = 0
call BlzLoadTOCFile(TocPath)
call BlzCreateFrameByType("FRAME", "HeroScoreFrameParent", ParentFunc(), "", 0)
// has to be something acceptimg BlzFrameSetLevel in V1.31.1
call BlzCreateFrameByType("BUTTON", "HeroScoreFrameTooltipParent", BlzGetFrameByName("HeroScoreFrameParent", 0), "", 0)
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameParent", 0), false)
set CreatedCount = 0
loop
call CreateHeroScoreFrame(i)
set i = i + 1
exitwhen i >= AutoCreateCount
endloop
if FillByTeam then
loop
set i = 0
loop
if GetPlayerTeam(Player(i)) == team and AllowedPlayer(Player(i)) then
call HeroScoreFrameSetTargetPlayer(usedCounter, Player(i))
set usedCounter = usedCounter + 1
endif
set i = i + 1
exitwhen i >= bj_MAX_PLAYERS
endloop
// Team finished jump to next col, if there are remaining spaces.
if FillByTeamSkipCols then
set remain = ModuloInteger(usedCounter, Rows)
if remain > 0 and remain < Rows then
set usedCounter = usedCounter + (Rows - remain)
endif
else
set usedCounter = usedCounter + 1
endif
set team = team + 1
exitwhen team >= GetTeams()
endloop
else
set i = 0
loop
if AllowedPlayer(Player(i)) then
call HeroScoreFrameSetTargetPlayer(usedCounter, Player(i))
set usedCounter = usedCounter + 1
endif
set i = i + 1
exitwhen i >= bj_MAX_PLAYERS
endloop
endif
call CreateGeneratedFrameHeroScoreFrameAlly(0)
static if LIBRARY_FrameNumberDialog then
call FrameNumberDialog_create(0, BlzGetFrameByName("HeroScoreFrameParent", 0))
endif
static if LIBRARY_FrameHeroScoreFrameOptions then
call FrameHeroScoreFrameOptions_Create(0)
endif
// make the tooltipParent take the highest Layer of all silberlings, for some reasons this has to be done after all silberlings were created
call BlzFrameSetLevel(BlzGetFrameByName("HeroScoreFrameTooltipParent", 0), 99)
call HeroScoreFrameSetScale(Scale)
endfunction
private function TimerAction takes nothing returns nothing
local integer loopIndex = CreatedCount
local integer index
loop
set index = Created[loopIndex]
if UiTargetPlayer[index] != null then
if AutoSearchTarget and (UiTargetUnit[index] == null or GetUnitTypeId(UiTargetUnit[index]) == 0 or GetOwningPlayer(UiTargetUnit[index]) != UiTargetPlayer[index] or not IsUnitType(UiTargetUnit[index], UNIT_TYPE_HERO)) then
call GroupEnumUnitsOfPlayer(g, UiTargetPlayer[index], null)
if IsUnitType(FirstOfGroup(g), UNIT_TYPE_HERO) then
set UiTargetUnit[index] = FirstOfGroup(g)
call Update(UiTargetUnit[index], index)
else
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrame", index), false)
endif
else
call Update(UiTargetUnit[index], index)
endif
else
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrame", index), false)
endif
set loopIndex = loopIndex - 1
exitwhen loopIndex <= 0
endloop
call GroupClear(g)
endfunction
private function KeyAction takes nothing returns nothing
if GetLocalPlayer() == GetTriggerPlayer() then
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameParent", 0), BlzGetTriggerPlayerIsKeyDown())
if not BlzGetTriggerPlayerIsKeyDown() then
call BlzFrameSetVisible(BlzGetFrameByName("HeroScoreFrameAlly", 0), false)
endif
endif
endfunction
function HeroScoreFrameInit takes nothing returns nothing
local trigger t = CreateTrigger()
local integer loopIndex = 0
call InitFrames()
loop
call BlzTriggerRegisterPlayerKeyEvent(t, Player(loopIndex), TriggerKey, 0, true)
call BlzTriggerRegisterPlayerKeyEvent(t, Player(loopIndex), TriggerKey, 0, false)
set loopIndex = loopIndex + 1
exitwhen loopIndex >= bj_MAX_PLAYER_SLOTS
endloop
call TriggerAddAction(t, function KeyAction)
if AutoRun then
call TimerStart(GetExpiredTimer(), 0.25, true, function TimerAction)
else
call TimerStart(CreateTimer(), 0.25, true, function TimerAction)
endif
static if LIBRARY_FrameLoader then
call FrameLoaderAdd(function InitFrames)
endif
endfunction
private function init_function takes nothing returns nothing
if AutoRun then
call TimerStart(CreateTimer(), 0, false, function HeroScoreFrameInit)
endif
endfunction
endlibrary
// only when this is enabled the vjass will try to generate the event code.
library HeroScoreFrameEventGUI
endlibrary