режим предателя + UI референсы и DragonUI

This commit is contained in:
2026-04-09 02:05:29 +04:00
parent 1109d19bb5
commit e8f1ae4ab9
397 changed files with 202750 additions and 37 deletions
@@ -939,10 +939,14 @@ local function ApplyMicromenuSystem()
end
local icon = button.DragonUIPVPIcon
if englishFaction == 'Alliance' then
-- MoonWell: traitors display opposite faction icon
local displayFaction = (MoonWell_IsTraitor and englishFaction == 'Alliance') and 'Horde'
or (MoonWell_IsTraitor and englishFaction == 'Horde') and 'Alliance'
or englishFaction
if displayFaction == 'Alliance' then
icon:SetTexture(microTexture)
icon:SetTexCoord(0, 118 / 256, 0, 151 / 256)
elseif englishFaction == 'Horde' then
elseif displayFaction == 'Horde' then
icon:SetTexture(microTexture)
icon:SetTexCoord(118 / 256, 236 / 256, 0, 151 / 256)
else
@@ -959,10 +963,10 @@ local function ApplyMicromenuSystem()
-- WoW shows/hides this automatically on mouse enter/leave.
local highlightTexture = button:GetHighlightTexture()
if highlightTexture then
if englishFaction == 'Alliance' then
if displayFaction == 'Alliance' then
highlightTexture:SetTexture(microTexture)
highlightTexture:SetTexCoord(0, 118 / 256, 0, 151 / 256)
elseif englishFaction == 'Horde' then
elseif displayFaction == 'Horde' then
highlightTexture:SetTexture(microTexture)
highlightTexture:SetTexCoord(118 / 256, 236 / 256, 0, 151 / 256)
else
@@ -1462,14 +1462,18 @@ local function StylePVPBattlefieldFrame()
MiniMapBattlefieldFrame:SetPushedTexture('')
-- Detect player faction and apply appropriate textures
local faction = string.lower(UnitFactionGroup('player'))
-- MoonWell: traitors display opposite faction icon
local realFaction = UnitFactionGroup('player')
local displayFaction = (MoonWell_IsTraitor and realFaction == 'Alliance') and 'horde'
or (MoonWell_IsTraitor and realFaction == 'Horde') and 'alliance'
or string.lower(realFaction)
-- Apply textures using SetAtlasTexture
if MiniMapBattlefieldFrame:GetNormalTexture() then
SetAtlasTexture(MiniMapBattlefieldFrame:GetNormalTexture(), 'Minimap-PVP-' .. faction .. '-Normal')
SetAtlasTexture(MiniMapBattlefieldFrame:GetNormalTexture(), 'Minimap-PVP-' .. displayFaction .. '-Normal')
end
if MiniMapBattlefieldFrame:GetPushedTexture() then
SetAtlasTexture(MiniMapBattlefieldFrame:GetPushedTexture(), 'Minimap-PVP-' .. faction .. '-Pushed')
SetAtlasTexture(MiniMapBattlefieldFrame:GetPushedTexture(), 'Minimap-PVP-' .. displayFaction .. '-Pushed')
end
-- Configure click script like in minimapa_old.lua
@@ -0,0 +1,62 @@
-- ============================================================================
-- MoonWell Client
-- Server integration: game modes, traitor faction display
-- ============================================================================
-- Global flag read by FrameXML files to decide which faction icon to show.
-- true = show opposite faction icon (traitor)
-- false = show real faction icon (normal)
MoonWell_IsTraitor = false
-- ============================================================================
-- AIO handler — called by server on login
-- Server: AIO:Handle(player, "MoonWellClient", "Init", gameMode)
-- gameMode: 0 = normal, 1 = traitor
-- ============================================================================
if not AIO then
return
end
local Handler = AIO.AddHandlers("MoonWellClient", {})
local function MoonWell_RefreshFactionIcons()
-- Portrait PvP icon
if PlayerFrame_UpdatePvPStatus then
PlayerFrame_UpdatePvPStatus()
end
-- DragonUI PvP micro button: SetupPVPButton() runs on load before AIO responds,
-- so we refresh its DragonUIPVPIcon texture directly after Init.
if PVPMicroButton and PVPMicroButton.DragonUIPVPIcon then
local factionGroup = UnitFactionGroup("player")
if factionGroup then
local displayFaction = MoonWell_IsTraitor
and (factionGroup == "Alliance" and "Horde" or "Alliance")
or factionGroup
local microTexture = "Interface\\AddOns\\DragonUI\\Textures\\Micromenu\\micropvp"
local icon = PVPMicroButton.DragonUIPVPIcon
if displayFaction == "Alliance" then
icon:SetTexture(microTexture)
icon:SetTexCoord(0, 118/256, 0, 151/256)
elseif displayFaction == "Horde" then
icon:SetTexture(microTexture)
icon:SetTexCoord(118/256, 236/256, 0, 151/256)
end
local hl = PVPMicroButton:GetHighlightTexture()
if hl then
if displayFaction == "Alliance" then
hl:SetTexture(microTexture)
hl:SetTexCoord(0, 118/256, 0, 151/256)
elseif displayFaction == "Horde" then
hl:SetTexture(microTexture)
hl:SetTexCoord(118/256, 236/256, 0, 151/256)
end
end
end
end
end
function Handler.Init(_, mode)
MoonWell_IsTraitor = (tonumber(mode) == 1)
MoonWell_RefreshFactionIcons()
end
@@ -0,0 +1,11 @@
## Interface: 30300
## Title: MoonWell Client
## Notes: MoonWell server integration — game modes, traitor faction display
## Version: 1.0.0
## Author: MoonWell
## SavedVariables: MoonWellClientDB
## Dependencies: AIO_Client
## DefaultState: Enabled
## X-Hidden: 1
MoonWellClient.lua
@@ -0,0 +1,807 @@
-- MoonWell: returns display faction (opposite for traitors)
local function MoonWell_GetDisplayFaction()
local f = UnitFactionGroup("player");
if MoonWell_IsTraitor and f then
return f == "Alliance" and "Horde" or "Alliance";
end
return f;
end
BATTLEFIELD_ZONES_DISPLAYED = 5;
BATTLEFIELD_ZONES_HEIGHT = 20;
BATTLEFIELD_SHUTDOWN_TIMER = 0;
BATTLEFIELD_TIMER_THRESHOLDS = {600, 300, 60, 15};
BATTLEFIELD_TIMER_THRESHOLD_INDEX = 1;
PREVIOUS_BATTLEFIELD_MOD = 0;
BATTLEFIELD_TIMER_DELAY = 3;
BATTLEFIELD_MAP_WIDTH = 320;
BATTLEFIELD_MAP_HEIGHT = 213;
MAX_BATTLEFIELD_QUEUES = 2;
MAX_WORLD_PVP_QUEUES = 1;
CURRENT_BATTLEFIELD_QUEUES = {};
PREVIOUS_BATTLEFIELD_QUEUES = {};
local BATTLEFIELD_FRAME_FADE_TIME = 0.15
function BattlefieldFrame_OnLoad (self)
self:RegisterEvent("PLAYER_ENTERING_WORLD");
self:RegisterEvent("BATTLEFIELDS_SHOW");
self:RegisterEvent("BATTLEFIELDS_CLOSED");
self:RegisterEvent("UPDATE_BATTLEFIELD_STATUS");
self:RegisterEvent("PARTY_LEADER_CHANGED");
self:RegisterEvent("ZONE_CHANGED");
self:RegisterEvent("ZONE_CHANGED_NEW_AREA");
self:RegisterEvent("BATTLEFIELD_MGR_QUEUE_REQUEST_RESPONSE");
self:RegisterEvent("BATTLEFIELD_MGR_QUEUE_INVITE");
self:RegisterEvent("BATTLEFIELD_MGR_ENTRY_INVITE");
self:RegisterEvent("BATTLEFIELD_MGR_EJECT_PENDING");
self:RegisterEvent("BATTLEFIELD_MGR_EJECTED");
self:RegisterEvent("BATTLEFIELD_MGR_ENTERED");
BattlefieldFrame.timerDelay = 0;
end
function BattlefieldFrame_OnEvent (self, event, ...)
if ( event == "PLAYER_ENTERING_WORLD" ) then
MiniMapBattlefieldDropDown_OnLoad();
BattlefieldFrame_UpdateStatus(false, nil);
elseif ( event == "BATTLEFIELDS_SHOW" ) then
if ( not IsBattlefieldArena() ) then
ShowUIPanel(BattlefieldFrame);
-- Default to first available
SetSelectedBattlefield(0);
if ( not BattlefieldFrame:IsShown() ) then
CloseBattlefield();
return;
end
UpdateMicroButtons();
BattlefieldFrame_Update();
end
elseif ( event == "BATTLEFIELDS_CLOSED" ) then
HideUIPanel(BattlefieldFrame);
elseif ( event == "UPDATE_BATTLEFIELD_STATUS" or event == "ZONE_CHANGED_NEW_AREA" or event == "ZONE_CHANGED") then
local arg1 = ...
BattlefieldFrame_UpdateStatus(false, arg1);
BattlefieldFrame_Update();
elseif ( event == "BATTLEFIELD_MGR_QUEUE_REQUEST_RESPONSE" ) then
local battleID, accepted, warmup, inArea, loggingIn = ...;
if(not loggingIn) then
if(accepted) then
if(warmup) then
StaticPopup_Show("BFMGR_CONFIRM_WORLD_PVP_QUEUED_WARMUP", "Wintergrasp", nil, arg1);
elseif (inArea) then
StaticPopup_Show("BFMGR_EJECT_PENDING", "Wintergrasp", nil, arg1);
else
StaticPopup_Show("BFMGR_CONFIRM_WORLD_PVP_QUEUED", "Wintergrasp", nil, arg1);
end
else
StaticPopup_Show("BFMGR_DENY_WORLD_PVP_QUEUED", "Wintergrasp", nil, arg1);
end
end
BattlefieldFrame_UpdateStatus(false);
BattlefieldFrame_Update();
elseif ( event == "BATTLEFIELD_MGR_EJECT_PENDING" ) then
local battleID, remote = ...;
if(remote) then
local dialog = StaticPopup_Show("BFMGR_EJECT_PENDING_REMOTE", "Wintergrasp", nil, arg1);
else
local dialog = StaticPopup_Show("BFMGR_EJECT_PENDING", "Wintergrasp", nil, arg1);
end
BattlefieldFrame_UpdateStatus(false);
BattlefieldFrame_Update();
elseif ( event == "BATTLEFIELD_MGR_EJECTED" ) then
local battleID, playerExited, relocated, battleActive, lowLevel = ...;
StaticPopup_Hide("BFMGR_INVITED_TO_QUEUE");
StaticPopup_Hide("BFMGR_INVITED_TO_QUEUE_WARMUP");
StaticPopup_Hide("BFMGR_INVITED_TO_ENTER");
StaticPopup_Hide("BFMGR_EJECT_PENDING");
if(lowLevel) then
local dialog = StaticPopup_Show("BFMGR_PLAYER_LOW_LEVEL", "Wintergrasp", nil, arg1);
elseif (playerExited and battleActive and not relocated) then
local dialog = StaticPopup_Show("BFMGR_PLAYER_EXITED_BATTLE", "Wintergrasp", nil, arg1);
end
BattlefieldFrame_UpdateStatus(false);
BattlefieldFrame_Update();
elseif ( event == "BATTLEFIELD_MGR_QUEUE_INVITE" ) then
local battleID, warmup = ...;
if(warmup) then
local dialog = StaticPopup_Show("BFMGR_INVITED_TO_QUEUE_WARMUP", "Wintergrasp", nil, arg1);
else
local dialog = StaticPopup_Show("BFMGR_INVITED_TO_QUEUE", "Wintergrasp", nil, arg1);
end
StaticPopup_Hide("BFMGR_EJECT_PENDING");
BattlefieldFrame_UpdateStatus(false);
BattlefieldFrame_Update();
elseif ( event == "BATTLEFIELD_MGR_ENTRY_INVITE" ) then
local battleID = ...;
local dialog = StaticPopup_Show("BFMGR_INVITED_TO_ENTER", "Wintergrasp", nil, arg1);
StaticPopup_Hide("BFMGR_EJECT_PENDING");
BattlefieldFrame_UpdateStatus(false);
BattlefieldFrame_Update();
elseif ( event == "BATTLEFIELD_MGR_ENTERED" ) then
StaticPopup_Hide("BFMGR_INVITED_TO_QUEUE");
StaticPopup_Hide("BFMGR_INVITED_TO_QUEUE_WARMUP");
StaticPopup_Hide("BFMGR_INVITED_TO_ENTER");
StaticPopup_Hide("BFMGR_EJECT_PENDING");
BattlefieldFrame_UpdateStatus(false);
BattlefieldFrame_Update();
end
if ( event == "PARTY_LEADER_CHANGED" ) then
BattlefieldFrame_Update();
end
end
function BattlefieldTimerFrame_OnUpdate(self, elapsed)
local keepUpdating = false;
if ( BATTLEFIELD_SHUTDOWN_TIMER > 0 ) then
keepUpdating = true;
BattlefieldIconText:Hide();
else
local lowestExpiration = 0;
for i = 1, MAX_BATTLEFIELD_QUEUES do
local expiration = GetBattlefieldPortExpiration(i);
if ( expiration > 0 ) then
if( expiration < lowestExpiration or lowestExpiration == 0 ) then
lowestExpiration = expiration;
end
keepUpdating = true;
end
end
if( lowestExpiration > 0 and lowestExpiration <= 10 ) then
BattlefieldIconText:SetText(lowestExpiration);
BattlefieldIconText:Show();
else
BattlefieldIconText:Hide();
end
end
if ( not keepUpdating ) then
BattlefieldTimerFrame:SetScript("OnUpdate", nil);
return;
end
local frame = BattlefieldFrame
BATTLEFIELD_SHUTDOWN_TIMER = BATTLEFIELD_SHUTDOWN_TIMER - elapsed;
-- Set the time for the score frame
WorldStateScoreFrameTimer:SetFormattedText(SecondsToTimeAbbrev(BATTLEFIELD_SHUTDOWN_TIMER));
-- Check if I should send a message only once every 3 seconds (BATTLEFIELD_TIMER_DELAY)
frame.timerDelay = frame.timerDelay + elapsed;
if ( frame.timerDelay < BATTLEFIELD_TIMER_DELAY ) then
return;
else
frame.timerDelay = 0
end
local threshold = BATTLEFIELD_TIMER_THRESHOLDS[BATTLEFIELD_TIMER_THRESHOLD_INDEX];
if ( BATTLEFIELD_SHUTDOWN_TIMER > 0 ) then
if ( BATTLEFIELD_SHUTDOWN_TIMER < threshold and BATTLEFIELD_TIMER_THRESHOLD_INDEX ~= #BATTLEFIELD_TIMER_THRESHOLDS ) then
-- If timer past current threshold advance to the next one
BATTLEFIELD_TIMER_THRESHOLD_INDEX = BATTLEFIELD_TIMER_THRESHOLD_INDEX + 1;
else
-- See if time should be posted
local currentMod = floor(BATTLEFIELD_SHUTDOWN_TIMER/threshold);
if ( PREVIOUS_BATTLEFIELD_MOD ~= currentMod ) then
-- Print message
local info = ChatTypeInfo["SYSTEM"];
local string;
if ( GetBattlefieldWinner() ) then
local isArena = IsActiveBattlefieldArena();
if ( isArena ) then
string = format(ARENA_COMPLETE_MESSAGE, SecondsToTime(ceil(BATTLEFIELD_SHUTDOWN_TIMER/threshold) * threshold));
else
string = format(BATTLEGROUND_COMPLETE_MESSAGE, SecondsToTime(ceil(BATTLEFIELD_SHUTDOWN_TIMER/threshold) * threshold));
end
else
string = format(INSTANCE_SHUTDOWN_MESSAGE, SecondsToTime(ceil(BATTLEFIELD_SHUTDOWN_TIMER/threshold) * threshold));
end
DEFAULT_CHAT_FRAME:AddMessage(string, info.r, info.g, info.b, info.id);
PREVIOUS_BATTLEFIELD_MOD = currentMod;
end
end
else
BATTLEFIELD_SHUTDOWN_TIMER = 0;
end
end
function BattlefieldFrame_UpdateStatus(tooltipOnly, mapIndex)
local status, mapName, instanceID, queueID, levelRangeMin, levelRangeMax, teamSize, registeredMatch;
local numberQueues = 0;
local waitTime, timeInQueue;
local tooltip;
local showRightClickText;
BATTLEFIELD_SHUTDOWN_TIMER = 0;
-- Reset tooltip
MiniMapBattlefieldFrame.tooltip = nil;
MiniMapBattlefieldFrame.waitTime = {};
MiniMapBattlefieldFrame.status = nil;
-- Copy current queues into previous queues
if ( not tooltipOnly ) then
PREVIOUS_BATTLEFIELD_QUEUES = {};
for index, value in pairs(CURRENT_BATTLEFIELD_QUEUES) do
tinsert(PREVIOUS_BATTLEFIELD_QUEUES, value);
end
CURRENT_BATTLEFIELD_QUEUES = {};
end
if ( CanHearthAndResurrectFromArea() ) then
if ( not MiniMapBattlefieldFrame.inWorldPVPArea ) then
MiniMapBattlefieldFrame.inWorldPVPArea = true;
UIFrameFadeIn(MiniMapBattlefieldFrame, BATTLEFIELD_FRAME_FADE_TIME);
BattlegroundShineFadeIn();
end
else
MiniMapBattlefieldFrame.inWorldPVPArea = false;
end
for i=1, MAX_BATTLEFIELD_QUEUES do
status, mapName, instanceID, levelRangeMin, levelRangeMax, teamSize, registeredMatch = GetBattlefieldStatus(i);
if ( mapName ) then
if ( instanceID ~= 0 ) then
mapName = mapName.." "..instanceID;
end
if ( teamSize ~= 0 ) then
if ( registeredMatch ) then
mapName = ARENA_RATED_MATCH.." "..format(PVP_TEAMSIZE, teamSize, teamSize);
else
mapName = ARENA_CASUAL.." "..format(PVP_TEAMSIZE, teamSize, teamSize);
end
end
end
tooltip = nil;
MiniMapBattlefieldFrame_isArena();
if ( not tooltipOnly and (status ~= "confirm") ) then
StaticPopup_Hide("CONFIRM_BATTLEFIELD_ENTRY", i);
end
if ( status ~= "none" ) then
numberQueues = numberQueues+1;
if ( status == "queued" ) then
-- Update queue info show button on minimap
waitTime = GetBattlefieldEstimatedWaitTime(i);
timeInQueue = GetBattlefieldTimeWaited(i)/1000;
if ( waitTime == 0 ) then
waitTime = QUEUE_TIME_UNAVAILABLE;
elseif ( waitTime < 60000 ) then
waitTime = LESS_THAN_ONE_MINUTE;
else
waitTime = SecondsToTime(waitTime/1000, 1);
end
MiniMapBattlefieldFrame.waitTime[i] = waitTime;
tooltip = format(BATTLEFIELD_IN_QUEUE, mapName, waitTime, SecondsToTime(timeInQueue));
if ( not tooltipOnly ) then
if ( not IsAlreadyInQueue(mapName) ) then
UIFrameFadeIn(MiniMapBattlefieldFrame, BATTLEFIELD_FRAME_FADE_TIME);
BattlegroundShineFadeIn();
PlaySound("PVPENTERQUEUE");
end
tinsert(CURRENT_BATTLEFIELD_QUEUES, mapName);
end
showRightClickText = 1;
elseif ( status == "confirm" ) then
-- Have been accepted show enter battleground dialog
local seconds = SecondsToTime(GetBattlefieldPortExpiration(i));
if ( seconds ~= "" ) then
tooltip = format(BATTLEFIELD_QUEUE_CONFIRM, mapName, seconds);
else
tooltip = format(BATTLEFIELD_QUEUE_PENDING_REMOVAL, mapName);
end
if ( (i==mapIndex) and (not tooltipOnly) ) then
local dialog = StaticPopup_Show("CONFIRM_BATTLEFIELD_ENTRY", mapName, nil, i);
PlaySound("PVPTHROUGHQUEUE");
MiniMapBattlefieldFrame:Show();
end
showRightClickText = 1;
BattlefieldTimerFrame:SetScript("OnUpdate", BattlefieldTimerFrame_OnUpdate);
elseif ( status == "active" ) then
-- In the battleground
if ( teamSize ~= 0 ) then
tooltip = mapName;
else
tooltip = format(BATTLEFIELD_IN_BATTLEFIELD, mapName);
end
BATTLEFIELD_SHUTDOWN_TIMER = GetBattlefieldInstanceExpiration()/1000;
if ( BATTLEFIELD_SHUTDOWN_TIMER > 0 ) then
BattlefieldTimerFrame:SetScript("OnUpdate", BattlefieldTimerFrame_OnUpdate);
end
BATTLEFIELD_TIMER_THRESHOLD_INDEX = 1;
PREVIOUS_BATTLEFIELD_MOD = 0;
MiniMapBattlefieldFrame.status = status;
elseif ( status == "error" ) then
-- Should never happen haha
end
if ( tooltip ) then
if ( MiniMapBattlefieldFrame.tooltip ) then
MiniMapBattlefieldFrame.tooltip = MiniMapBattlefieldFrame.tooltip.."\n\n"..tooltip;
else
MiniMapBattlefieldFrame.tooltip = tooltip;
end
end
end
end
for i=1, MAX_WORLD_PVP_QUEUES do
status, mapName, queueID = GetWorldPVPQueueStatus(i);
if ( status ~= "none" ) then
numberQueues = numberQueues + 1;
end
if ( status == "queued" or status == "confirm" ) then
if ( status == "queued" ) then
tooltip = format(BATTLEFIELD_IN_QUEUE_SIMPLE, mapName);
elseif ( status == "confirm" ) then
tooltip = format(BATTLEFIELD_QUEUE_CONFIRM_SIMPLE, mapName);
end
if ( MiniMapBattlefieldFrame.tooltip ) then
MiniMapBattlefieldFrame.tooltip = MiniMapBattlefieldFrame.tooltip.."\n\n"..tooltip;
else
MiniMapBattlefieldFrame.tooltip = tooltip;
end
end
end
-- See if should add right click message
if ( MiniMapBattlefieldFrame.tooltip and showRightClickText ) then
MiniMapBattlefieldFrame.tooltip = MiniMapBattlefieldFrame.tooltip.."\n"..RIGHT_CLICK_MESSAGE;
elseif ( MiniMapBattlefieldFrame_isArena() ) then
MiniMapBattlefieldFrame.tooltip = MiniMapBattlefieldFrame.tooltip;
end
if ( not tooltipOnly ) then
MiniMapBattlefieldFrame_isArena();
if ( numberQueues == 0 and (not CanHearthAndResurrectFromArea()) ) then
-- Clear everything out
MiniMapBattlefieldFrame:Hide();
else
MiniMapBattlefieldFrame:Show();
end
end
BattlefieldFrame.numQueues = numberQueues;
end
function MiniMapBattlefieldFrame_isArena()
-- Set minimap icon here since it bugs out on login
local status, mapName, instanceID, levelRangeMin, levelRangeMax, teamSize, registeredMatch = GetBattlefieldStatus(1);
local isArena, isRegistered = IsActiveBattlefieldArena();
if ( registeredMatch or isRegistered ) then
MiniMapBattlefieldIcon:SetTexture("Interface\\PVPFrame\\PVP-ArenaPoints-Icon");
MiniMapBattlefieldIcon:SetWidth(19);
MiniMapBattlefieldIcon:SetHeight(19);
MiniMapBattlefieldIcon:SetPoint("CENTER", "MiniMapBattlefieldFrame", "CENTER", -1, 2);
elseif ( UnitFactionGroup("player") ) then
MiniMapBattlefieldIcon:SetTexture("Interface\\BattlefieldFrame\\Battleground-"..MoonWell_GetDisplayFaction());
MiniMapBattlefieldIcon:SetTexCoord(0, 1, 0, 1);
MiniMapBattlefieldIcon:SetWidth(32);
MiniMapBattlefieldIcon:SetHeight(32);
MiniMapBattlefieldIcon:SetPoint("CENTER", "MiniMapBattlefieldFrame", "CENTER", -1, 0);
end
end
function BattlefieldFrame_Update()
local zoneIndex;
local zoneOffset = FauxScrollFrame_GetOffset(BattlefieldListScrollFrame);
local playerLevel = UnitLevel("player");
local button, buttonStatus;
local instanceID;
local mapName, mapDescription, maxGroup = GetBattlefieldInfo();
local factionTexture = "Interface\\PVPFrame\\PVP-Currency-"..MoonWell_GetDisplayFaction();
if ( not mapName ) then
return;
end
-- Set title text
BattlefieldFrameFrameLabel:SetText(mapName);
-- Set the Join as Group text based on the limits of which instances can join as group.
if ( maxGroup and maxGroup == 5 ) then
BattlefieldFrameGroupJoinButton:SetText(JOIN_AS_PARTY);
else
BattlefieldFrameGroupJoinButton:SetText(JOIN_AS_GROUP);
end
-- Setup instance buttons
-- add one to battlefields because of the fake "first available" button
local numBattlefields = GetNumBattlefields() + 1;
for i=1, BATTLEFIELD_ZONES_DISPLAYED, 1 do
zoneIndex = zoneOffset + i;
button = _G["BattlefieldZone"..i];
if ( zoneIndex == 1 ) then
-- The first entry in the list is always "first available"
button:SetText(FIRST_AVAILABLE);
-- Set tooltip
button.title = FIRST_AVAILABLE;
button.tooltip = NEWBIE_TOOLTIP_FIRST_AVAILABLE;
button:Show();
elseif ( zoneIndex > numBattlefields ) then
button:Hide();
else
instanceID = GetBattlefieldInstanceInfo(zoneIndex - 1);
button:SetText(mapName.." "..instanceID);
-- Set tooltip
button.title = mapName.." "..instanceID;
button.tooltip = NEWBIE_TOOLTIP_ENTER_BATTLEGROUND;
button:Show();
end
-- Set queued status
button.status:Hide();
local queueStatus, queueMapName, queueInstanceID;
for i=1, MAX_BATTLEFIELD_QUEUES do
queueStatus, queueMapName, queueInstanceID = GetBattlefieldStatus(i);
if ( queueStatus ~= "none" and queueMapName.." "..queueInstanceID == button.title ) then
if ( queueStatus == "queued" ) then
button.status.texture:SetTexture(factionTexture);
button.status.texture:SetTexCoord(0.0, 1.0, 0.0, 1.0);
button.status.tooltip = BATTLEFIELD_QUEUE_STATUS;
button.status:Show();
elseif ( queueStatus == "confirm" ) then
button.status.texture:SetTexture("Interface\\CharacterFrame\\UI-StateIcon");
button.status.texture:SetTexCoord(0.45, 0.95, 0.0, 0.5);
button.status.tooltip = BATTLEFIELD_CONFIRM_STATUS;
button.status:Show();
end
elseif ( button.title == FIRST_AVAILABLE and queueMapName == mapName and queueInstanceID == 0 ) then
if ( queueStatus == "queued" ) then
button.status.texture:SetTexture(factionTexture);
button.status.texture:SetTexCoord(0.0, 1.0, 0.0, 1.0);
button.status.tooltip = BATTLEFIELD_QUEUE_STATUS;
button.status:Show();
end
end
end
-- Set selected instance
if ( zoneIndex == 1 and GetSelectedBattlefield() == 0 ) then
button:LockHighlight();
elseif ( zoneIndex - 1 == GetSelectedBattlefield() ) then
button:LockHighlight();
else
button:UnlockHighlight();
end
end
local mapName, mapDescription, maxGroup, canEnter, isHoliday, isRandom = GetBattlefieldInfo();
if ( isRandom or isHoliday ) then
BattlefieldFrame_UpdateRandomInfo();
BattlefieldFrameInfoScrollFrameChildFrameRewardsInfo:Show();
BattlefieldFrameInfoScrollFrameChildFrameDescription:Hide();
else
if ( mapDescription ~= BattlefieldFrameInfoScrollFrameChildFrameDescription:GetText() ) then
BattlefieldFrameInfoScrollFrameChildFrameDescription:SetText(mapDescription);
BattlefieldFrameInfoScrollFrame:SetVerticalScroll(0);
end
BattlefieldFrameInfoScrollFrameChildFrameRewardsInfo:Hide();
BattlefieldFrameInfoScrollFrameChildFrameDescription:Show();
end
-- Enable or disable the group join button
if ( CanJoinBattlefieldAsGroup() ) then
if ( ((GetNumPartyMembers() > 0) or (GetNumRaidMembers() > 0)) and IsPartyLeader() ) then
-- If this is true then can join as a group
BattlefieldFrameGroupJoinButton:Enable();
else
BattlefieldFrameGroupJoinButton:Disable();
end
BattlefieldFrameGroupJoinButton:Show();
else
BattlefieldFrameGroupJoinButton:Hide();
end
if ( BattlefieldFrame.numQueues ) then
if ( BattlefieldFrame.numQueues <= 3 ) then
BattlefieldFrameJoinButton:Enable();
else
BattlefieldFrameJoinButton:Disable();
end
end
FauxScrollFrame_Update(BattlefieldListScrollFrame, numBattlefields, BATTLEFIELD_ZONES_DISPLAYED, BATTLEFIELD_ZONES_HEIGHT, "BattlefieldZone", 293, 315);
end
function PVPQueue_UpdateRandomInfo(base, infoFunc)
local BGname, canEnter, isHoliday, isRandom = infoFunc();
local hasWin, lossHonor, winHonor, winArena, lossArena;
if ( isRandom ) then
hasWin, winHonor, winArena, lossHonor, lossArena = GetRandomBGHonorCurrencyBonuses();
base.title:SetText(RANDOM_BATTLEGROUND);
base.description:SetText(RANDOM_BATTLEGROUND_EXPLANATION);
else
base.title:SetText(BATTLEGROUND_HOLIDAY);
base.description:SetText(BATTLEGROUND_HOLIDAY_EXPLANATION);
hasWin, winHonor, winArena, lossHonor, lossArena = GetHolidayBGHonorCurrencyBonuses();
end
if (winHonor ~= 0) then
base.winReward.honorSymbol:Show();
base.winReward.honorAmount:Show();
base.winReward.honorAmount:SetText(winHonor);
else
base.winReward.honorSymbol:Hide();
base.winReward.honorAmount:Hide();
end
if (winArena ~= 0) then
base.winReward.arenaSymbol:Show();
base.winReward.arenaAmount:Show();
base.winReward.arenaAmount:SetText(winArena);
else
base.winReward.arenaSymbol:Hide();
base.winReward.arenaAmount:Hide();
end
if (lossHonor ~= 0) then
base.lossReward.honorSymbol:Show();
base.lossReward.honorAmount:Show();
base.lossReward.honorAmount:SetText(lossHonor);
else
base.lossReward.honorSymbol:Hide();
base.lossReward.honorAmount:Hide();
end
if (lossArena ~= 0) then
base.lossReward.arenaSymbol:Show();
base.lossReward.arenaAmount:Show();
base.lossReward.arenaAmount:SetText(lossArena);
else
base.lossReward.arenaSymbol:Hide();
base.lossReward.arenaAmount:Hide();
end
local englishFaction = MoonWell_GetDisplayFaction();
base.winReward.honorSymbol:SetTexture("Interface\\PVPFrame\\PVP-Currency-"..englishFaction);
base.lossReward.honorSymbol:SetTexture("Interface\\PVPFrame\\PVP-Currency-"..englishFaction);
end
function BattlefieldFrame_GetSelectedBattlegroundInfo()
local BGname, description, groupSize, canEnter, isHoliday, isRandom = GetBattlefieldInfo();
return BGname, canEnter, isHoliday, isRandom;
end
function BattlefieldFrame_UpdateRandomInfo()
PVPQueue_UpdateRandomInfo(BattlefieldFrameInfoScrollFrameChildFrameRewardsInfo, BattlefieldFrame_GetSelectedBattlegroundInfo);
end
function BattlefieldButton_OnClick(self)
local id = self:GetID();
SetSelectedBattlefield(FauxScrollFrame_GetOffset(BattlefieldListScrollFrame) + id - 1);
BattlefieldFrame_Update();
end
function BattlefieldFrameJoinButton_OnClick(self)
local GROUPJOIN_BUTTONID = 2;
local id = self:GetID();
if ( id == GROUPJOIN_BUTTONID ) then
JoinBattlefield(GetSelectedBattlefield(), 1);
else
JoinBattlefield(GetSelectedBattlefield());
end
HideUIPanel(BattlefieldFrame);
end
function MiniMapBattlefieldDropDown_OnLoad()
UIDropDownMenu_Initialize(MiniMapBattlefieldDropDown, MiniMapBattlefieldDropDown_Initialize, "MENU");
end
function MiniMapBattlefieldDropDown_Initialize()
local info;
local status, mapName, instanceID, queueID, levelRangeMin, levelRangeMax, teamSize, registeredMatch;
local numQueued = 0;
local numShown = 0;
local shownHearthAndRes;
for i=1, MAX_BATTLEFIELD_QUEUES do
status, mapName, instanceID, levelRangeMin, levelRangeMax, teamSize, registeredMatch = GetBattlefieldStatus(i);
-- Inserts a spacer if it's not the first option... to make it look nice.
if ( status ~= "none" ) then
numShown = numShown + 1;
if ( numShown > 1 ) then
info = UIDropDownMenu_CreateInfo();
info.isTitle = 1;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
end
end
if ( status == "queued" or status == "confirm" ) then
numQueued = numQueued + 1;
-- Add a spacer if there were dropdown items before this
info = UIDropDownMenu_CreateInfo();
if ( teamSize ~= 0 ) then
if ( registeredMatch ) then
info.text = ARENA_RATED_MATCH.." "..format(PVP_TEAMSIZE, teamSize, teamSize);
else
info.text = ARENA_CASUAL.." "..format(PVP_TEAMSIZE, teamSize, teamSize);
end
else
info.text = mapName;
end
info.isTitle = 1;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
if ( CanHearthAndResurrectFromArea() and not shownHearthAndRes and GetRealZoneText() == mapName ) then
info = UIDropDownMenu_CreateInfo();
info.text = format(LEAVE_ZONE, GetRealZoneText());
info.func = HearthAndResurrectFromArea;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
shownHearthAndRes = true;
end
if ( status == "queued" ) then
info = UIDropDownMenu_CreateInfo();
info.text = LEAVE_QUEUE;
info.func = function (self, ...) AcceptBattlefieldPort(...) end;
info.arg1 = i;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
elseif ( status == "confirm" ) then
info = UIDropDownMenu_CreateInfo();
info.text = ENTER_BATTLE;
info.func = function (self, ...) AcceptBattlefieldPort(...) end;
info.arg1 = i;
info.arg2 = 1;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
if ( teamSize == 0 ) then
info = UIDropDownMenu_CreateInfo();
info.text = LEAVE_QUEUE;
info.func = function (self, ...) AcceptBattlefieldPort(...) end;
info.arg1 = i;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
end
end
elseif ( status == "active" ) then
info = UIDropDownMenu_CreateInfo();
if ( teamSize ~= 0 ) then
info.text = mapName.." "..format(PVP_TEAMSIZE, teamSize, teamSize);
else
info.text = mapName;
end
info.isTitle = 1;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
info = UIDropDownMenu_CreateInfo();
if ( IsActiveBattlefieldArena() ) then
info.text = LEAVE_ARENA;
else
info.text = LEAVE_BATTLEGROUND;
end
info.func = function (self, ...) LeaveBattlefield(...) end;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
end
end
for i=1, MAX_WORLD_PVP_QUEUES do
status, mapName, queueID = GetWorldPVPQueueStatus(i);
-- Inserts a spacer if it's not the first option... to make it look nice.
if ( status ~= "none" ) then
numShown = numShown + 1;
if ( numShown > 1 ) then
info = UIDropDownMenu_CreateInfo();
info.isTitle = 1;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
end
end
if ( status == "queued" or status == "confirm" ) then
numQueued = numQueued + 1;
-- Add a spacer if there were dropdown items before this
info = UIDropDownMenu_CreateInfo();
info.text = mapName;
info.isTitle = 1;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
if ( CanHearthAndResurrectFromArea() and not shownHearthAndRes and GetRealZoneText() == mapName ) then
info = UIDropDownMenu_CreateInfo();
info.text = format(LEAVE_ZONE, GetRealZoneText());
info.func = HearthAndResurrectFromArea;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
shownHearthAndRes = true;
end
if ( status == "queued" ) then
info = UIDropDownMenu_CreateInfo();
info.text = LEAVE_QUEUE;
info.func = function (self, ...) BattlefieldMgrExitRequest(...) end;
info.arg1 = queueID;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
elseif ( status == "confirm" ) then
info = UIDropDownMenu_CreateInfo();
info.text = ENTER_BATTLE;
info.func = function (self, ...) BattlefieldMgrEntryInviteResponse(...) end;
info.arg1 = queueID;
info.arg2 = 1;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
info = UIDropDownMenu_CreateInfo();
info.text = LEAVE_QUEUE;
info.func = function (self, ...) BattlefieldMgrEntryInviteResponse(...) end;
info.arg1 = i;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
end
end
end
if ( CanHearthAndResurrectFromArea() and not shownHearthAndRes ) then
numShown = numShown + 1;
info = UIDropDownMenu_CreateInfo();
info.text = GetRealZoneText();
info.isTitle = 1;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
info = UIDropDownMenu_CreateInfo();
info.text = format(LEAVE_ZONE, GetRealZoneText());
info.func = HearthAndResurrectFromArea;
info.notCheckable = 1;
UIDropDownMenu_AddButton(info);
end
end
function BattlegroundShineFadeIn()
-- Fade in the shine and then fade it out with the ComboPointShineFadeOut function
local fadeInfo = {};
fadeInfo.mode = "IN";
fadeInfo.timeToFade = 0.5;
fadeInfo.finishedFunc = BattlegroundShineFadeOut;
UIFrameFade(BattlegroundShine, fadeInfo);
end
--hack since a frame can't have a reference to itself in it
function BattlegroundShineFadeOut()
UIFrameFadeOut(BattlegroundShine, 0.5);
end
function IsAlreadyInQueue(mapName)
local inQueue = nil;
for index,value in pairs(PREVIOUS_BATTLEFIELD_QUEUES) do
if ( value == mapName ) then
inQueue = 1;
end
end
return inQueue;
end
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,316 @@
-- MoonWell: returns display faction (opposite for traitors)
local function MoonWell_GetDisplayFaction()
local f = UnitFactionGroup("player");
if MoonWell_IsTraitor and f then
return f == "Alliance" and "Horde" or "Alliance";
end
return f;
end
NUM_DISPLAYED_BATTLEGROUNDS = 5;
local PVPBATTLEGROUND_TEXTURELIST = {};
PVPBATTLEGROUND_TEXTURELIST[1] = "Interface\\PVPFrame\\PvpBg-AlteracValley";
PVPBATTLEGROUND_TEXTURELIST[2] = "Interface\\PVPFrame\\PvpBg-WarsongGulch";
PVPBATTLEGROUND_TEXTURELIST[3] = "Interface\\PVPFrame\\PvpBg-ArathiBasin";
PVPBATTLEGROUND_TEXTURELIST[7] = "Interface\\PVPFrame\\PvpBg-EyeOfTheStorm";
PVPBATTLEGROUND_TEXTURELIST[9] = "Interface\\PVPFrame\\PvpBg-StrandOfTheAncients";
PVPBATTLEGROUND_TEXTURELIST[30] = "Interface\\PVPFrame\\PvpBg-IsleOfConquest";
PVPBATTLEGROUND_TEXTURELIST[32] = "Interface\\PVPFrame\\PvpRandomBg";
function PVPBattleground_UpdateBattlegrounds()
local frame;
local localizedName, canEnter, isHoliday;
local tempString, BGindex, isBig;
local offset = FauxScrollFrame_GetOffset(PVPBattlegroundFrameTypeScrollFrame);
local currentFrameNum = -offset + 1;
local numBGs = 0;
for i=1,GetNumBattlegroundTypes() do
frame = _G["BattlegroundType"..currentFrameNum];
localizedName, canEnter, isHoliday = GetBattlegroundInfo(i);
tempString = localizedName;
if ( localizedName and canEnter ) then
if ( frame ) then
frame.BGindex = i;
frame.localizedName = localizedName;
if ( not PVPBattlegroundFrame.selectedBG ) then
PVPBattlegroundFrame.selectedBG = i;
end
frame:Enable();
if ( isHoliday ) then
tempString = tempString.." ("..BATTLEGROUND_HOLIDAY..")";
end
frame.title:SetText(tempString);
frame:Show();
if ( i == PVPBattlegroundFrame.selectedBG ) then
frame:LockHighlight();
else
frame:UnlockHighlight();
end
end
currentFrameNum = currentFrameNum + 1;
numBGs = numBGs + 1;
end
end
if ( currentFrameNum <= NUM_DISPLAYED_BATTLEGROUNDS ) then
isBig = true; --Espand the highlight to cover where the scroll bar usually is.
end
for i=1,NUM_DISPLAYED_BATTLEGROUNDS do
frame = _G["BattlegroundType"..i];
if ( isBig ) then
frame:SetWidth(315);
else
frame:SetWidth(295);
end
end
for i=currentFrameNum,NUM_DISPLAYED_BATTLEGROUNDS do
frame = _G["BattlegroundType"..i];
frame:Hide();
end
PVPBattleground_UpdateQueueStatus();
PVPBattlegroundFrame_UpdateGroupAvailable();
FauxScrollFrame_Update(PVPBattlegroundFrameTypeScrollFrame, numBGs, NUM_DISPLAYED_BATTLEGROUNDS, 16);
end
function PVPBattleground_UpdateInfo(BGindex)
if ( type(BGindex) ~= "number" ) then
BGindex = PVPBattlegroundFrame.selectedBG;
end
local BGname, canEnter, isHoliday, isRandom, BattleGroundID = GetBattlegroundInfo(BGindex);
if(PVPBATTLEGROUND_TEXTURELIST[BattleGroundID]) then
PVPBattlegroundFrameBGTex:SetTexture(PVPBATTLEGROUND_TEXTURELIST[BattleGroundID]);
end
if ( isRandom or isHoliday ) then
PVPBattleground_UpdateRandomInfo();
PVPBattlegroundFrameInfoScrollFrameChildFrameRewardsInfo:Show();
PVPBattlegroundFrameInfoScrollFrameChildFrameDescription:Hide();
else
local mapName, mapDescription, maxGroup = GetBattlefieldInfo();
if ( mapDescription ~= PVPBattlegroundFrameInfoScrollFrameChildFrameDescription:GetText() ) then
PVPBattlegroundFrameInfoScrollFrameChildFrameDescription:SetText(mapDescription);
PVPBattlegroundFrameInfoScrollFrame:SetVerticalScroll(0);
end
PVPBattlegroundFrameInfoScrollFrameChildFrameRewardsInfo:Hide();
PVPBattlegroundFrameInfoScrollFrameChildFrameDescription:Show();
end
end
function PVPBattleground_GetSelectedBattlegroundInfo()
return GetBattlegroundInfo(PVPBattlegroundFrame.selectedBG);
end
function PVPBattleground_UpdateRandomInfo()
PVPQueue_UpdateRandomInfo(PVPBattlegroundFrameInfoScrollFrameChildFrameRewardsInfo, PVPBattleground_GetSelectedBattlegroundInfo);
end
function PVPBattleground_UpdateQueueStatus()
local queueStatus, queueMapName, queueInstanceID, frame;
for i=1, NUM_DISPLAYED_BATTLEGROUNDS do
frame = _G["BattlegroundType"..i];
frame.status:Hide();
end
local factionTexture = "Interface\\PVPFrame\\PVP-Currency-"..MoonWell_GetDisplayFaction();
for i=1, MAX_BATTLEFIELD_QUEUES do
queueStatus, queueMapName, queueInstanceID = GetBattlefieldStatus(i);
if ( queueStatus ~= "none" ) then
for j=1, NUM_DISPLAYED_BATTLEGROUNDS do
local frame = _G["BattlegroundType"..j];
if ( frame.localizedName == queueMapName ) then
if ( queueStatus == "queued" ) then
frame.status.texture:SetTexture(factionTexture);
frame.status.texture:SetTexCoord(0.0, 1.0, 0.0, 1.0);
frame.status.tooltip = BATTLEFIELD_QUEUE_STATUS;
frame.status:Show();
elseif ( queueStatus == "confirm" ) then
frame.status.texture:SetTexture("Interface\\CharacterFrame\\UI-StateIcon");
frame.status.texture:SetTexCoord(0.45, 0.95, 0.0, 0.5);
frame.status.tooltip = BATTLEFIELD_CONFIRM_STATUS;
frame.status:Show();
end
end
end
end
end
end
function PVPBattleground_ResetInfo()
RequestBattlegroundInstanceInfo(PVPBattlegroundFrame.selectedBG);
PVPBattleground_UpdateInfo();
end
function PVPBattlegroundButton_OnClick(self)
local offset = FauxScrollFrame_GetOffset(PVPBattlegroundFrameTypeScrollFrame);
local id = self:GetID() + offset;
for i=1,NUM_DISPLAYED_BATTLEGROUNDS do
if ( id == i + offset ) then
_G["BattlegroundType"..i]:LockHighlight();
else
_G["BattlegroundType"..i]:UnlockHighlight();
end
end
if ( self.BGindex == PVPBattlegroundFrame.selectedBG ) then
return;
end
PVPBattlegroundFrame.selectedBG = self.BGindex;
PVPBattleground_ResetInfo();
PVPBattleground_UpdateJoinButton();
end
function PVPBattleground_UpdateJoinButton()
local mapName, mapDescription, maxGroup = GetBattlefieldInfo();
if ( maxGroup and maxGroup == 5 ) then
PVPBattlegroundFrameGroupJoinButton:SetText(JOIN_AS_PARTY);
else
PVPBattlegroundFrameGroupJoinButton:SetText(JOIN_AS_GROUP);
end
end
function PVPBattlegroundFrameJoinButton_OnClick(self)
local joinAsGroup;
if ( self == PVPBattlegroundFrameGroupJoinButton ) then
joinAsGroup = true;
end
JoinBattlefield(0, joinAsGroup);
end
function PVPBattlegroundFrame_OnLoad(self)
self:RegisterEvent("PVPQUEUE_ANYWHERE_SHOW");
self:RegisterEvent("NPC_PVPQUEUE_ANYWHERE");
self:RegisterEvent("UPDATE_BATTLEFIELD_STATUS");
self:RegisterEvent("PVPQUEUE_ANYWHERE_UPDATE_AVAILABLE");
self:RegisterEvent("PLAYER_ENTERING_WORLD");
self:RegisterEvent("PARTY_MEMBERS_CHANGED");
PanelTemplates_SetTab(PVPParentFrame, 1);
PVPBattlegroundFrame_UpdateVisible();
BattlegroundType1:Click();
end
function PVPBattlegroundFrame_OnEvent(self, event, ...)
if ( event == "PVPQUEUE_ANYWHERE_SHOW" or event == "NPC_PVPQUEUE_ANYWHERE") then
self.currentData = true;
PVPBattleground_UpdateBattlegrounds();
if ( self.selectedBG ) then
PVPBattleground_UpdateInfo();
end
if ( event == "NPC_PVPQUEUE_ANYWHERE" ) then
ShowUIPanel(PVPParentFrame);
PVPFrame_SetJustBG(true);
end
elseif ( event == "UPDATE_BATTLEFIELD_STATUS" ) then
PVPBattleground_UpdateQueueStatus();
elseif ( event == "PVPQUEUE_ANYWHERE_UPDATE_AVAILABLE" or event == "PLAYER_ENTERING_WORLD" ) then
self:UnregisterEvent("PLAYER_ENTERING_WORLD");
FauxScrollFrame_SetOffset(PVPBattlegroundFrameTypeScrollFrame, 0);
FauxScrollFrame_OnVerticalScroll(PVPBattlegroundFrameTypeScrollFrame, 0, 16, PVPBattleground_UpdateBattlegrounds); --We may be changing brackets, so we don't want someone to see an outdated version of the data.
if ( self.selectedBG ) then
PVPBattleground_ResetInfo();
PVPBattleground_UpdateJoinButton();
end
PVPBattlegroundFrame_UpdateVisible();
elseif ( event == "PARTY_MEMBERS_CHANGED" ) then
PVPBattlegroundFrame_UpdateGroupAvailable();
end
end
function PVPBattlegroundFrame_OnShow(self)
if ( IsInInstance() ) then
WintergraspTimer:Hide();
else
WintergraspTimer:Show();
end
SortBGList();
PVPBattleground_UpdateBattlegrounds();
RequestBattlegroundInstanceInfo(self.selectedBG or 1);
end
function PVPBattlegroundFrame_OnHide(self)
CloseBattlefield();
end
function PVPBattlegroundFrame_UpdateVisible()
for i=1, GetNumBattlegroundTypes() do
local _, canEnter = GetBattlegroundInfo(i);
if ( canEnter ) then
if ( not PVPFrame_IsJustBG() ) then
PVPParentFrameTab1:Show();
PVPParentFrameTab2:Show();
end
return;
end
end
PVPParentFrameTab1:Click();
PVPParentFrameTab1:Hide();
PVPParentFrameTab2:Hide();
end
function PVPBattlegroundFrame_UpdateGroupAvailable()
if ( ((GetNumPartyMembers() > 0) or (GetNumRaidMembers() > 0)) and IsPartyLeader() ) then
-- If this is true then can join as a group
PVPBattlegroundFrameGroupJoinButton:Enable();
else
PVPBattlegroundFrameGroupJoinButton:Disable();
end
end
function WintergraspTimer_OnLoad(self)
self.canQueue = false;
self.tooltip = PVPBATTLEGROUND_WINTERGRASPTIMER_CANNOT_QUEUE;
self.texture:SetTexCoord(0.0, 1.0, 0.0, 0.5);
end
function WintergraspTimer_OnUpdate(self, elapsed)
local nextBattleTime = GetWintergraspWaitTime();
if ( nextBattleTime and nextBattleTime > 60 ) then
self.text:SetFormattedText(PVPBATTLEGROUND_WINTERGRASPTIMER, SecondsToTime(nextBattleTime, true));
elseif ( nextBattleTime and nextBattleTime > 0 ) then
self.text:SetFormattedText(PVPBATTLEGROUND_WINTERGRASPTIMER, SecondsToTime(nextBattleTime, false));
else
self.text:SetFormattedText(PVPBATTLEGROUND_WINTERGRASPTIMER, WINTERGRASP_IN_PROGRESS);
end
local canQueue = CanQueueForWintergrasp();
if ( self.canQueue ~= canQueue ) then
-- simple safeguard so we're not doing a bunch of unnecessary work for each OnUpdate
if ( canQueue ) then
self.tooltip = PVPBATTLEGROUND_WINTERGRASPTIMER_CAN_QUEUE;
self.texture:SetTexCoord(0.0, 1.0, 0.5, 1.0);
else
self.tooltip = PVPBATTLEGROUND_WINTERGRASPTIMER_CANNOT_QUEUE;
self.texture:SetTexCoord(0.0, 1.0, 0.0, 0.5);
end
self.canQueue = canQueue;
end
end
@@ -0,0 +1,601 @@
MAX_ARENA_TEAMS = 3;
MAX_ARENA_TEAM_MEMBERS = 10;
MAX_ARENA_TEAM_NAME_WIDTH = 310;
function PVPFrame_OnLoad(self)
PVPFrameLine1:SetAlpha(0.3);
PVPHonorKillsLabel:SetVertexColor(0.6, 0.6, 0.6);
PVPHonorHonorLabel:SetVertexColor(0.6, 0.6, 0.6);
PVPHonorTodayLabel:SetVertexColor(0.6, 0.6, 0.6);
PVPHonorYesterdayLabel:SetVertexColor(0.6, 0.6, 0.6);
PVPHonorLifetimeLabel:SetVertexColor(0.6, 0.6, 0.6);
self:RegisterEvent("PLAYER_ENTERING_WORLD");
self:RegisterEvent("ARENA_TEAM_UPDATE");
self:RegisterEvent("ARENA_TEAM_ROSTER_UPDATE");
self:RegisterEvent("PLAYER_PVP_KILLS_CHANGED");
self:RegisterEvent("PLAYER_PVP_RANK_CHANGED");
self:RegisterEvent("HONOR_CURRENCY_UPDATE");
--self:RegisterEvent("ARENA_SEASON_WORLD_STATE");
end
function PVPFrame_OnEvent(self, event, ...)
local arg1 = ...;
if ( event == "PLAYER_ENTERING_WORLD" ) then
-- PVPFrame.season = GetCurrentArenaSeason();
PVPFrame_Update();
PVPHonor_Update();
elseif ( event == "PLAYER_PVP_KILLS_CHANGED" or event == "PLAYER_PVP_RANK_CHANGED") then
PVPHonor_Update();
elseif ( event == "ARENA_TEAM_UPDATE" ) then
PVPFrame_Update();
if ( PVPTeamDetails:IsShown() ) then
local team = GetArenaTeam(PVPTeamDetails.team);
if ( not team ) then
PVPTeamDetails:Hide();
else
PVPTeamDetails_Update(PVPTeamDetails.team); -- team games played/won are shown in the detail frame
end
end
--[[ elseif ( event == "ARENA_SEASON_WORLD_STATE" ) then
PVPFrame.season = GetCurrentArenaSeason();
PVPFrame_Update(); ]]
elseif ( event == "HONOR_CURRENCY_UPDATE" ) then
PVPHonor_Update();
elseif ( event == "ARENA_TEAM_ROSTER_UPDATE" ) then
if ( arg1 ) then
if ( PVPTeamDetails:IsShown() ) then
ArenaTeamRoster(PVPTeamDetails.team);
end
elseif ( PVPTeamDetails.team ) then
PVPTeamDetails_Update(PVPTeamDetails.team);
PVPFrame_Update();
end
end
end
function PVPFrame_OnShow()
PVPFrame_SetFaction();
PVPFrame_Update();
PVPMicroButton_SetPushed();
UpdateMicroButtons();
SetPortraitTexture(PVPFramePortrait, "player");
PlaySound("igCharacterInfoOpen");
end
function PVPFrame_OnHide()
PVPTeamDetails:Hide();
PVPFrame_SetJustBG(false);
PVPMicroButton_SetNormal();
UpdateMicroButtons();
PlaySound("igCharacterInfoClose");
end
function PVPFrame_SetFaction()
local factionGroup = UnitFactionGroup("player");
if ( factionGroup ) then
-- MoonWell: traitors display opposite faction icon
local displayFaction = MoonWell_IsTraitor
and (factionGroup == "Alliance" and "Horde" or "Alliance")
or factionGroup;
PVPFrameHonorIcon:SetTexture("Interface\\TargetingFrame\\UI-PVP-"..displayFaction);
PVPFrameHonorIcon:Show();
end
end
function PVPFrame_Update()
for i=1, MAX_ARENA_TEAMS do
GetArenaTeam(i);
end
PVPHonor_Update();
PVPTeam_Update();
if ( GetCurrentArenaSeason() == 0 ) then --We're in an off-season.
PVPFrame_SetToOffSeason();
elseif ( PVPFrameOffSeason:IsShown() ) then
PVPFrame_SetToInSeason();
end
end
function PVPTeam_Update()
-- Display Elements
local button, buttonName, highlight, data, standard, emblem, border;
-- Data Elements
local teamName, teamSize, teamRating, teamPlayed, teamWins, teamLoss, seasonTeamPlayed, seasonTeamWins, playerPlayed, seasonPlayerPlayed, playerPlayedPct, teamRank, playerRating;
local played, wins, loss;
local background = {};
local borderColor = {};
local emblemColor = {};
local ARENA_TEAMS = {};
ARENA_TEAMS[1] = {size = 2};
ARENA_TEAMS[2] = {size = 3};
ARENA_TEAMS[3] = {size = 5};
-- Sort teams by size
local count = 0;
local buttonIndex = 0;
for index, value in pairs(ARENA_TEAMS) do
for i=1, MAX_ARENA_TEAMS do
teamName, teamSize = GetArenaTeam(i);
if ( value.size == teamSize ) then
value.index = i;
end
end
end
-- fill out data
for index, value in pairs(ARENA_TEAMS) do
buttonIndex = buttonIndex + 1;
button = _G["PVPTeam"..buttonIndex];
if ( value.index ) then
-- Pull Values
teamName, teamSize, teamRating, teamPlayed, teamWins, seasonTeamPlayed, seasonTeamWins, playerPlayed, seasonPlayerPlayed, teamRank, playerRating, background.r, background.g, background.b, emblem, emblemColor.r, emblemColor.g, emblemColor.b, border, borderColor.r, borderColor.g, borderColor.b = GetArenaTeam(value.index);
-- Set button elements to variables
buttonName = "PVPTeam"..buttonIndex;
data = buttonName.."Data";
standard = buttonName.."Standard";
button:SetID(value.index);
if ( PVPFrame.seasonStats ) then
_G[data.."TypeLabel"]:SetText(ARENA_THIS_SEASON);
PVPFrameToggleButton:SetText(ARENA_THIS_WEEK_TOGGLE);
played = seasonTeamPlayed;
wins = seasonTeamWins;
playerPlayed = seasonPlayerPlayed;
else
_G[data.."TypeLabel"]:SetText(ARENA_THIS_WEEK);
PVPFrameToggleButton:SetText(ARENA_THIS_SEASON_TOGGLE);
played = teamPlayed;
wins = teamWins;
playerPlayed = playerPlayed;
end
loss = played - wins;
if ( played ~= 0 ) then
playerPlayedPct = floor( ( playerPlayed / played ) * 100 );
else
playerPlayedPct = floor( ( playerPlayed / 1 ) * 100 );
end
-- Populate Data
_G[data.."Name"]:SetText(teamName);
_G[data.."Rating"]:SetText(teamRating);
_G[data.."Games"]:SetText(played);
_G[data.."Wins"]:SetText(wins);
_G[data.."Loss"]:SetText(loss);
if ( PVPFrame.seasonStats ) then
_G[data.."Played"]:SetText(playerRating);
_G[data.."Played"]:SetVertexColor(1.0, 1.0, 1.0);
_G[data.."PlayedLabel"]:SetText(PVP_YOUR_RATING);
else
-- played %
if ( playerPlayedPct < 10 ) then
_G[data.."Played"]:SetVertexColor(1.0, 0, 0);
else
_G[data.."Played"]:SetVertexColor(1.0, 1.0, 1.0);
end
-- FIXME: Turn this into a localized format string
playerPlayedPct = format("%d", playerPlayedPct);
_G[data.."Played"]:SetText(playerPlayed.." ("..playerPlayedPct.."%)");
_G[data.."PlayedLabel"]:SetText(PLAYED);
end
-- Set TeamSize Banner
_G[standard.."Banner"]:SetTexture("Interface\\PVPFrame\\PVP-Banner-"..teamSize);
_G[standard.."Banner"]:SetVertexColor(background.r, background.g, background.b);
_G[standard.."Border"]:SetVertexColor(borderColor.r, borderColor.g, borderColor.b);
_G[standard.."Emblem"]:SetVertexColor(emblemColor.r, emblemColor.g, emblemColor.b);
if ( border ~= -1 ) then
_G[standard.."Border"]:SetTexture("Interface\\PVPFrame\\PVP-Banner-"..teamSize.."-Border-"..border);
end
if ( emblem ~= -1 ) then
_G[standard.."Emblem"]:SetTexture("Interface\\PVPFrame\\Icons\\PVP-Banner-Emblem-"..emblem);
end
-- Set visual elements
_G[data]:Show();
button:SetAlpha(1);
_G[buttonName.."Highlight"]:SetAlpha(1);
_G[buttonName.."Highlight"]:SetBackdropBorderColor(1.0, 0.82, 0);
_G[standard]:SetAlpha(1);
_G[standard.."Border"]:Show();
_G[standard.."Emblem"]:Show();
_G[buttonName.."Background"]:SetVertexColor(0, 0, 0);
_G[buttonName.."Background"]:SetAlpha(1);
_G[buttonName.."TeamType"]:Hide();
else
-- Set button elements to variables
buttonName = "PVPTeam"..buttonIndex;
data = buttonName.."Data";
button:SetID(0);
-- Set standard type
local standardBanner = _G[buttonName.."StandardBanner"];
standardBanner:SetTexture("Interface\\PVPFrame\\PVP-Banner-"..value.size);
standardBanner:SetVertexColor(1, 1, 1);
-- Hide or Show items
button:SetAlpha(0.4);
_G[data]:Hide();
_G[buttonName.."Background"]:SetVertexColor(0, 0, 0);
_G[buttonName.."Standard"]:SetAlpha(0.1);
_G[buttonName.."StandardBorder"]:Hide();
_G[buttonName.."StandardEmblem"]:Hide();
_G[buttonName.."TeamType"]:SetFormattedText(PVP_TEAMSIZE, value.size, value.size);
_G[buttonName.."TeamType"]:Show(); end
count = count +1;
end
if ( count == 3 ) then
PVPFrameToggleButton:Hide();
else
PVPFrameToggleButton:Show();
end
end
function PVPTeam_OnEnter(self)
if ( GetArenaTeam(self:GetID() ) ) then
_G[self:GetName().."Highlight"]:Show();
GameTooltip_AddNewbieTip(self, ARENA_TEAM, 1.0, 1.0, 1.0, CLICK_FOR_DETAILS, 1);
else
GameTooltip_AddNewbieTip(self, ARENA_TEAM, 1.0, 1.0, 1.0, ARENA_TEAM_LEAD_IN, 1);
end
end
function PVPTeam_OnLeave(self)
_G[self:GetName().."Highlight"]:Hide();
GameTooltip:Hide();
end
function PVPTeamDetails_OnShow()
PlaySound("igSpellBookOpen");
end
function PVPTeamDetails_OnHide()
CloseArenaTeamRoster();
PlaySound("igSpellBookClose");
end
function PVPTeamDetails_Update(id)
local numMembers = GetNumArenaTeamMembers(id, 1);
local name, rank, level, class, online, played, win, loss, seasonPlayed, seasonWin, seasonLoss, rating;
local teamName, teamSize, teamRating, teamPlayed, teamWins, seasonTeamPlayed, seasonTeamWins, playerPlayed, seasonPlayerPlayed, teamRank, personalRating = GetArenaTeam(id);
local button;
local teamIndex;
-- Display General Team Stats
PVPTeamDetailsName:SetText(teamName);
PVPTeamDetailsSize:SetFormattedText(PVP_TEAMSIZE, teamSize, teamSize);
PVPTeamDetailsRank:SetText(teamRank);
PVPTeamDetailsRating:SetText(teamRating);
-- Tidy up team name display if it's too long - mostly for CN
PVPTeamDetailsName:SetWidth(0);
if ( PVPTeamDetailsName:GetWidth() > MAX_ARENA_TEAM_NAME_WIDTH ) then
PVPTeamDetailsName:SetWidth(MAX_ARENA_TEAM_NAME_WIDTH);
end
-- Display General Team Data
if ( PVPTeamDetails.season ) then
PVPTeamDetailsFrameColumnHeader3.sortType = "seasonplayed";
PVPTeamDetailsFrameColumnHeader4.sortType = "seasonwon";
PVPTeamDetailsGames:SetText(seasonTeamPlayed);
PVPTeamDetailsWins:SetText(seasonTeamWins);
PVPTeamDetailsLoss:SetText(seasonTeamPlayed - seasonTeamWins);
PVPTeamDetailsStatsType:SetText(strupper(ARENA_THIS_SEASON));
PVPTeamDetailsToggleButton:SetText(ARENA_THIS_WEEK_TOGGLE);
else
PVPTeamDetailsFrameColumnHeader3.sortType = "played";
PVPTeamDetailsFrameColumnHeader4.sortType = "won";
PVPTeamDetailsGames:SetText(teamPlayed);
PVPTeamDetailsWins:SetText(teamWins);
PVPTeamDetailsLoss:SetText(teamPlayed - teamWins);
PVPTeamDetailsStatsType:SetText(strupper(ARENA_THIS_WEEK));
PVPTeamDetailsToggleButton:SetText(ARENA_THIS_SEASON_TOGGLE);
end
local nameText, classText, playedText, winLossWin, winLossLoss, ratingText;
local nameButton, classButton, playedButton, winLossButton;
-- Display Team Member Specific Info
local playedValue, winValue, lossValue, playedPct;
for i=1, MAX_ARENA_TEAM_MEMBERS, 1 do
button = _G["PVPTeamDetailsButton"..i];
if ( i > numMembers ) then
button:Hide();
else
button.teamIndex = i;
-- Get Data
name, rank, level, class, online, played, win, seasonPlayed, seasonWin, rating = GetArenaTeamRosterInfo(id, i);
loss = played - win;
seasonLoss = seasonPlayed - seasonWin;
if ( class ) then
button.tooltip = LEVEL.." "..level.." "..class;
else
button.tooltip = LEVEL.." "..level;
end
-- Populate Data into the display, season or this week
if ( PVPTeamDetails.season ) then
playedValue = seasonPlayed;
winValue = seasonWin;
lossValue = seasonLoss;
teamPlayed = seasonTeamPlayed;
else
playedValue = played;
winValue = win;
lossValue = loss;
teamPlayed = teamPlayed;
end
if ( teamPlayed ~= 0 ) then
playedPct = floor( ( playedValue / teamPlayed ) * 100 );
else
playedPct = floor( (playedValue / 1 ) * 100 );
end
if ( playedPct < 10 ) then
_G["PVPTeamDetailsButton"..i.."PlayedText"]:SetVertexColor(1.0, 0, 0);
else
_G["PVPTeamDetailsButton"..i.."PlayedText"]:SetVertexColor(1.0, 1.0, 1.0);
end
playedPct = format("%d", playedPct);
_G["PVPTeamDetailsButton"..i.."Played"].tooltip = playedPct.."%";
nameText = _G["PVPTeamDetailsButton"..i.."NameText"];
classText = _G["PVPTeamDetailsButton"..i.."ClassText"];
playedText = _G["PVPTeamDetailsButton"..i.."PlayedText"]
winLossWin = _G["PVPTeamDetailsButton"..i.."WinLossWin"];
winLossLoss = _G["PVPTeamDetailsButton"..i.."WinLossLoss"];
ratingText = _G["PVPTeamDetailsButton"..i.."RatingText"];
--- Not needed after Arena Season 3 change.
nameButton = _G["PVPTeamDetailsButton"..i.."Name"];
classButton = _G["PVPTeamDetailsButton"..i.."Class"];
playedButton = _G["PVPTeamDetailsButton"..i.."Played"]
winLossButton = _G["PVPTeamDetailsButton"..i.."WinLoss"];
nameText:SetText(name);
classText:SetText(class);
playedText:SetText(playedValue);
winLossWin:SetText(winValue)
winLossLoss:SetText(lossValue);
ratingText:SetText(rating);
-- Color Entries based on Online status
local r, g, b;
if ( online ) then
if ( rank > 0 ) then
r = 1.0;
g = 1.0;
b = 1.0;
else
r = 1.0;
g = 0.82;
b = 0.0;
end
else
r = 0.5;
g = 0.5;
b = 0.5;
end
nameText:SetTextColor(r, g, b);
classText:SetTextColor(r, g, b);
playedText:SetTextColor(r, g, b);
winLossWin:SetTextColor(r, g, b);
_G["PVPTeamDetailsButton"..i.."WinLoss-"]:SetTextColor(r, g, b);
winLossLoss:SetTextColor(r, g, b);
ratingText:SetTextColor(r, g, b);
button:Show();
-- Highlight the correct who
if ( GetArenaTeamRosterSelection(id) == i ) then
button:LockHighlight();
else
button:UnlockHighlight();
end
end
end
end
function PVPTeamDetailsToggleButton_OnClick()
if ( PVPTeamDetails.season ) then
PVPTeamDetails.season = nil;
else
PVPTeamDetails.season = 1;
end
PVPTeamDetails_Update(PVPTeamDetails.team);
end
function PVPFrameToggleButton_OnClick()
if ( PVPFrame.seasonStats ) then
PVPFrame.seasonStats = nil;
else
PVPFrame.seasonStats = 1;
end
PVPTeam_Update();
end
function PVPTeamDetailsButton_OnClick(self, button)
if ( button == "LeftButton" ) then
PVPTeamDetails.previousSelectedTeamMember = PVPTeamDetails.selectedTeamMember;
PVPTeamDetails.selectedTeamMember = self.teamIndex;
SetArenaTeamRosterSelection(PVPTeamDetails.team, PVPTeamDetails.selectedTeamMember);
PVPTeamDetails_Update(PVPTeamDetails.team);
else
local name, rank, level, class, online = GetArenaTeamRosterInfo(PVPTeamDetails.team, self.teamIndex);
PVPFrame_ShowDropdown(name, online);
end
end
function PVPDropDown_Initialize()
UnitPopup_ShowMenu(UIDROPDOWNMENU_OPEN_MENU, "TEAM", nil, PVPDropDown.name);
end
function PVPFrame_ShowDropdown(name, online)
HideDropDownMenu(1);
if ( not IsArenaTeamCaptain(PVPTeamDetails.team) ) then
if ( online ) then
PVPDropDown.initialize = PVPDropDown_Initialize;
PVPDropDown.displayMode = "MENU";
PVPDropDown.name = name;
PVPDropDown.online = online;
ToggleDropDownMenu(1, nil, PVPDropDown, "cursor");
end
else
PVPDropDown.initialize = PVPDropDown_Initialize;
PVPDropDown.displayMode = "MENU";
PVPDropDown.name = name;
PVPDropDown.online = online;
ToggleDropDownMenu(1, nil, PVPDropDown, "cursor");
end
end
function PVPStandard_OnLoad(self)
self:SetAlpha(0.1);
end
function PVPTeam_OnClick(self)
local id = self:GetID();
local teamName, teamSize = GetArenaTeam(id);
if ( not teamName ) then
return;
else
if ( PVPTeamDetails:IsShown() and id == PVPTeamDetails.team ) then
PVPTeamDetails:Hide();
else
PVPTeamDetails.team = id;
ArenaTeamRoster(id);
PVPTeamDetails_Update(id);
PVPTeamDetails:Show();
end
end
end
function PVPTeam_OnMouseDown(self)
if ( GetArenaTeam(self:GetID()) and (not self.isDown) ) then
self.isDown = true;
local point, relativeTo, relativePoint, offsetX, offsetY = self:GetPoint();
self:SetPoint(point, relativeTo, relativePoint, offsetX-2, offsetY-2);
end
end
function PVPTeam_OnMouseUp(self)
--Note that this function is also called OnShow. Make sure it always checks if it was previously down.
if ( GetArenaTeam(self:GetID()) and (self.isDown) ) then
self.isDown = false;
local point, relativeTo, relativePoint, offsetX, offsetY = self:GetPoint();
self:SetPoint(point, relativeTo, relativePoint, offsetX+2, offsetY+2);
end
end
-- PVP Honor Data
function PVPHonor_Update()
local hk, cp, dk, contribution, rank, highestRank, rankName, rankNumber;
-- Yesterday's values
hk, contribution = GetPVPYesterdayStats();
PVPHonorYesterdayKills:SetText(hk);
PVPHonorYesterdayHonor:SetText(contribution);
-- Lifetime values
hk, contribution = GetPVPLifetimeStats();
PVPHonorLifetimeKills:SetText(hk);
PVPFrameHonorPoints:SetText(GetHonorCurrency());
PVPFrameArenaPoints:SetText(GetArenaCurrency())
-- Today's values
hk, cp = GetPVPSessionStats();
PVPHonorTodayKills:SetText(hk);
PVPHonorTodayHonor:SetText(cp);
PVPHonorTodayHonor:SetHeight(14);
end
function PVPMicroButton_SetPushed()
PVPMicroButtonTexture:SetPoint("TOP", PVPMicroButton, "TOP", 5, -31);
PVPMicroButtonTexture:SetAlpha(0.5);
end
function PVPMicroButton_SetNormal()
PVPMicroButtonTexture:SetPoint("TOP", PVPMicroButton, "TOP", 6, -30);
PVPMicroButtonTexture:SetAlpha(1.0);
end
function PVPFrame_SetToOffSeason()
PVPTeam1:Hide();
PVPTeam1Standard:Hide();
PVPTeam2:Hide();
PVPTeam2Standard:Hide();
PVPTeam3:Hide();
PVPTeam3Standard:Hide();
PVPFrameBlackFilter:Show();
PVPFrameOffSeason:Show();
local previousArenaSeason = GetPreviousArenaSeason();
PVPFrameOffSeasonText:SetText(format(ARENA_OFF_SEASON_TEXT, previousArenaSeason, previousArenaSeason+1));
end
function PVPFrame_SetToInSeason()
PVPTeam1:Show();
PVPTeam1Standard:Show();
PVPTeam2:Show();
PVPTeam2Standard:Show();
PVPTeam3:Show();
PVPTeam3Standard:Show();
PVPFrameBlackFilter:Hide();
PVPFrameOffSeason:Hide();
end
function TogglePVPFrame()
if ( PVPFrame_IsJustBG() ) then
PVPFrame_SetJustBG(false);
else
if ( UnitLevel("player") >= SHOW_PVP_LEVEL ) then
ToggleFrame(PVPParentFrame);
end
end
end
function PVPFrame_IsJustBG()
return PVPParentFrame.justBG;
end
function PVPFrame_SetJustBG(justBG)
local pvpParentFrame = PVPParentFrame;
if ( justBG ) then
pvpParentFrame.justBG = true;
pvpParentFrame.savedSelectedTab = PanelTemplates_GetSelectedTab(pvpParentFrame);
PVPParentFrameTab2:Click();
PVPParentFrameTab1:Hide();
PVPParentFrameTab2:Hide();
UpdateMicroButtons();
else
pvpParentFrame.justBG = false;
if ( pvpParentFrame.savedSelectedTab ) then
_G["PVPParentFrameTab"..pvpParentFrame.savedSelectedTab]:Click();
pvpParentFrame.savedSelectedTab = nil;
end
CloseBattlefield();
PVPBattlegroundFrame_UpdateVisible();
UpdateMicroButtons();
end
end
@@ -0,0 +1,688 @@
REQUIRED_REST_HOURS = 5;
function PlayerFrame_OnLoad(self)
UnitFrame_Initialize(self, "player", PlayerName, PlayerPortrait,
PlayerFrameHealthBar, PlayerFrameHealthBarText,
PlayerFrameManaBar, PlayerFrameManaBarText,
PlayerFrameFlash);
self.statusCounter = 0;
self.statusSign = -1;
CombatFeedback_Initialize(self, PlayerHitIndicator, 30);
PlayerFrame_Update();
self:RegisterEvent("UNIT_LEVEL");
self:RegisterEvent("UNIT_COMBAT");
self:RegisterEvent("UNIT_FACTION");
self:RegisterEvent("UNIT_MAXMANA");
self:RegisterEvent("PLAYER_ENTERING_WORLD");
self:RegisterEvent("PLAYER_ENTER_COMBAT");
self:RegisterEvent("PLAYER_LEAVE_COMBAT");
self:RegisterEvent("PLAYER_REGEN_DISABLED");
self:RegisterEvent("PLAYER_REGEN_ENABLED");
self:RegisterEvent("PLAYER_UPDATE_RESTING");
self:RegisterEvent("PARTY_MEMBERS_CHANGED");
self:RegisterEvent("PARTY_LEADER_CHANGED");
self:RegisterEvent("PARTY_LOOT_METHOD_CHANGED");
self:RegisterEvent("VOICE_START");
self:RegisterEvent("VOICE_STOP");
self:RegisterEvent("RAID_ROSTER_UPDATE");
self:RegisterEvent("READY_CHECK");
self:RegisterEvent("READY_CHECK_CONFIRM");
self:RegisterEvent("READY_CHECK_FINISHED");
self:RegisterEvent("UNIT_ENTERED_VEHICLE");
self:RegisterEvent("UNIT_ENTERING_VEHICLE");
self:RegisterEvent("UNIT_EXITING_VEHICLE");
self:RegisterEvent("UNIT_EXITED_VEHICLE");
self:RegisterEvent("PLAYER_FLAGS_CHANGED");
self:RegisterEvent("PLAYER_ROLES_ASSIGNED");
-- Chinese playtime stuff
self:RegisterEvent("PLAYTIME_CHANGED");
PlayerAttackBackground:SetVertexColor(0.8, 0.1, 0.1);
PlayerAttackBackground:SetAlpha(0.4);
local showmenu = function()
ToggleDropDownMenu(1, nil, PlayerFrameDropDown, "PlayerFrame", 106, 27);
end
SecureUnitButton_OnLoad(self, "player", showmenu);
end
function PlayerFrame_Update ()
if ( UnitExists("player") ) then
PlayerLevelText:SetText(UnitLevel(PlayerFrame.unit));
PlayerFrame_UpdatePartyLeader();
PlayerFrame_UpdatePvPStatus();
PlayerFrame_UpdateStatus();
PlayerFrame_UpdatePlaytime();
PlayerFrame_UpdateLayout();
end
end
function PlayerFrame_UpdatePartyLeader()
if ( IsPartyLeader() ) then
if ( HasLFGRestrictions() ) then
PlayerGuideIcon:Show();
PlayerLeaderIcon:Hide();
else
PlayerLeaderIcon:Show()
PlayerGuideIcon:Hide();
end
else
PlayerLeaderIcon:Hide();
PlayerGuideIcon:Hide();
end
local lootMethod;
local lootMaster;
lootMethod, lootMaster = GetLootMethod();
if ( lootMaster == 0 and ((GetNumPartyMembers() > 0) or (GetNumRaidMembers() > 0)) ) then
PlayerMasterIcon:Show();
else
PlayerMasterIcon:Hide();
end
end
function PlayerFrame_UpdatePvPStatus()
local factionGroup, factionName = UnitFactionGroup("player");
if ( UnitIsPVPFreeForAll("player") ) then
if ( not PlayerPVPIcon:IsShown() ) then
PlaySound("igPVPUpdate");
end
PlayerPVPIcon:SetTexture("Interface\\TargetingFrame\\UI-PVP-FFA");
PlayerPVPIcon:Show();
-- Setup newbie tooltip
PlayerPVPIconHitArea.tooltipTitle = PVPFFA;
PlayerPVPIconHitArea.tooltipText = NEWBIE_TOOLTIP_PVPFFA;
PlayerPVPIconHitArea:Show();
PlayerPVPTimerText:Hide();
PlayerPVPTimerText.timeLeft = nil;
elseif ( factionGroup and UnitIsPVP("player") ) then
if ( not PlayerPVPIcon:IsShown() ) then
PlaySound("igPVPUpdate");
end
-- MoonWell: traitors display the opposite faction icon
local displayFaction = factionGroup;
if ( MoonWell_IsTraitor ) then
displayFaction = (factionGroup == "Alliance") and "Horde" or "Alliance";
end
PlayerPVPIcon:SetTexture("Interface\\TargetingFrame\\UI-PVP-"..displayFaction);
PlayerPVPIcon:Show();
-- Setup newbie tooltip
PlayerPVPIconHitArea.tooltipTitle = factionName;
PlayerPVPIconHitArea.tooltipText = _G["NEWBIE_TOOLTIP_"..strupper(factionGroup)];
PlayerPVPIconHitArea:Show();
else
PlayerPVPIcon:Hide();
PlayerPVPIconHitArea:Hide();
PlayerPVPTimerText:Hide();
PlayerPVPTimerText.timeLeft = nil;
end
end
function PlayerFrame_OnEvent(self, event, ...)
UnitFrame_OnEvent(self, event, ...);
local arg1, arg2, arg3, arg4, arg5 = ...;
if ( event == "UNIT_LEVEL" ) then
if ( arg1 == "player" ) then
PlayerLevelText:SetText(UnitLevel(self.unit));
end
elseif ( event == "UNIT_COMBAT" ) then
if ( arg1 == self.unit ) then
CombatFeedback_OnCombatEvent(self, arg2, arg3, arg4, arg5);
end
elseif ( event == "UNIT_FACTION" ) then
if ( arg1 == "player" ) then
PlayerFrame_UpdatePvPStatus();
end
elseif ( event == "PLAYER_ENTERING_WORLD" ) then
PlayerFrame_ToPlayerArt(self);
-- if ( UnitHasVehicleUI("player") ) then
-- UnitFrame_SetUnit(self, "vehicle", PlayerFrameHealthBar, PlayerFrameManaBar);
-- else
-- UnitFrame_SetUnit(self, "player", PlayerFrameHealthBar, PlayerFrameManaBar);
-- end
self.inCombat = nil;
self.onHateList = nil;
PlayerFrame_Update();
PlayerFrame_UpdateStatus();
PlayerFrame_UpdateRolesAssigned();
PlayerSpeakerFrame:Show();
PlayerFrame_UpdateVoiceStatus(UnitIsTalking(UnitName("player")));
if ( IsPVPTimerRunning() ) then
PlayerPVPTimerText:Show();
PlayerPVPTimerText.timeLeft = GetPVPTimer();
else
PlayerPVPTimerText:Hide();
PlayerPVPTimerText.timeLeft = nil;
end
elseif ( event == "PLAYER_ENTER_COMBAT" ) then
self.inCombat = 1;
PlayerFrame_UpdateStatus();
elseif ( event == "PLAYER_LEAVE_COMBAT" ) then
self.inCombat = nil;
PlayerFrame_UpdateStatus();
elseif ( event == "PLAYER_REGEN_DISABLED" ) then
self.onHateList = 1;
PlayerFrame_UpdateStatus();
if ( GetCVarBool("screenEdgeFlash") ) then
CombatFeedback_StartFullscreenStatus();
end
elseif ( event == "PLAYER_REGEN_ENABLED" ) then
self.onHateList = nil;
PlayerFrame_UpdateStatus();
CombatFeedback_StopFullscreenStatus();
elseif ( event == "PLAYER_UPDATE_RESTING" ) then
PlayerFrame_UpdateStatus();
elseif ( event == "PARTY_MEMBERS_CHANGED" or event == "PARTY_LEADER_CHANGED" or event == "RAID_ROSTER_UPDATE" ) then
PlayerFrame_UpdateGroupIndicator();
PlayerFrame_UpdatePartyLeader();
PlayerFrame_UpdateReadyCheck();
elseif ( event == "PARTY_LOOT_METHOD_CHANGED" ) then
local lootMethod;
local lootMaster;
lootMethod, lootMaster = GetLootMethod();
if ( lootMaster == 0 and ((GetNumPartyMembers() > 0) or (GetNumRaidMembers() > 0)) ) then
PlayerMasterIcon:Show();
else
PlayerMasterIcon:Hide();
end
elseif ( event == "VOICE_START") then
if ( arg1 == "player" ) then
PlayerFrame_UpdateVoiceStatus(true);
end
elseif ( event == "VOICE_STOP" ) then
if ( arg1 == "player" ) then
PlayerFrame_UpdateVoiceStatus(false);
end
elseif ( event == "PLAYTIME_CHANGED" ) then
PlayerFrame_UpdatePlaytime();
elseif ( event == "READY_CHECK" or event == "READY_CHECK_CONFIRM" ) then
PlayerFrame_UpdateReadyCheck();
elseif ( event == "READY_CHECK_FINISHED" ) then
ReadyCheck_Finish(PlayerFrameReadyCheck);
elseif ( event == "UNIT_RUNIC_POWER" and arg1 == "player" ) then
PlayerFrame_SetRunicPower(UnitPower("player"));
elseif ( event == "UNIT_ENTERING_VEHICLE" ) then
if ( arg1 == "player" ) then
if ( arg2 ) then
PlayerFrame_AnimateOut(self);
else
if ( PlayerFrame.state == "vehicle" ) then
PlayerFrame_AnimateOut(self);
end
end
end
elseif ( event == "UNIT_ENTERED_VEHICLE" ) then
if ( arg1 == "player" ) then
self.inSeat = true;
PlayerFrame_UpdateArt(self);
end
elseif ( event == "UNIT_EXITING_VEHICLE" ) then
if ( arg1 == "player" ) then
if ( self.state == "vehicle" ) then
PlayerFrame_AnimateOut(self);
end
end
elseif ( event == "UNIT_EXITED_VEHICLE" ) then
if ( arg1 == "player" ) then
self.inSeat = true;
PlayerFrame_UpdateArt(self);
end
elseif ( event == "PLAYER_FLAGS_CHANGED" ) then
if ( IsPVPTimerRunning() ) then
PlayerPVPTimerText:Show();
PlayerPVPTimerText.timeLeft = GetPVPTimer();
else
PlayerPVPTimerText:Hide();
PlayerPVPTimerText.timeLeft = nil;
end
elseif ( event == "PLAYER_ROLES_ASSIGNED" ) then
PlayerFrame_UpdateRolesAssigned();
end
end
function PlayerFrame_UpdateRolesAssigned()
local frame = PlayerFrame;
local icon = _G[frame:GetName().."RoleIcon"];
local isTank, isHealer, isDamage = UnitGroupRolesAssigned("player");
if ( isTank ) then
icon:SetTexCoord(0, 19/64, 22/64, 41/64);
icon:Show();
elseif ( isHealer ) then
icon:SetTexCoord(20/64, 39/64, 1/64, 20/64);
icon:Show();
elseif ( isDamage ) then
icon:SetTexCoord(20/64, 39/64, 22/64, 41/64);
icon:Show();
else
icon:Hide();
end
end
local function PlayerFrame_AnimPos(self, fraction)
return "TOPLEFT", UIParent, "TOPLEFT", -19, fraction*140-4;
end
local PlayerFrameAnimTable = {
totalTime = 0.3,
updateFunc = "SetPoint",
getPosFunc = PlayerFrame_AnimPos,
}
function PlayerFrame_AnimateOut(self)
self.inSeat = false;
self.animFinished = false;
self.inSequence = true;
SetUpAnimation(PlayerFrame, PlayerFrameAnimTable, PlayerFrame_AnimFinished, false)
end
function PlayerFrame_AnimFinished(self)
self.animFinished = true;
PlayerFrame_UpdateArt(self);
end
function PlayerFrame_UpdateArt(self)
if ( self.animFinished and self.inSeat and self.inSequence) then
SetUpAnimation(PlayerFrame, PlayerFrameAnimTable, PlayerFrame_SequenceFinished, true)
if ( UnitHasVehicleUI("player") ) then
PlayerFrame_ToVehicleArt(self, UnitVehicleSkin("player"));
else
PlayerFrame_ToPlayerArt(self);
end
end
end
function PlayerFrame_SequenceFinished(self)
self.inSequence = false;
PetFrame_Update(PetFrame);
end
function PlayerFrame_ToVehicleArt(self, vehicleType)
--Swap frame
PlayerFrame.state = "vehicle";
UnitFrame_SetUnit(self, "vehicle", PlayerFrameHealthBar, PlayerFrameManaBar);
UnitFrame_SetUnit(PetFrame, "player", PetFrameHealthBar, PetFrameManaBar);
PetFrame_Update(PetFrame);
PlayerFrame_Update();
BuffFrame_Update();
ComboFrame_Update();
PlayerFrameTexture:Hide();
if ( vehicleType == "Natural" ) then
PlayerFrameVehicleTexture:SetTexture("Interface\\Vehicles\\UI-Vehicle-Frame-Organic");
PlayerFrameHealthBar:SetWidth(103);
PlayerFrameHealthBar:SetPoint("TOPLEFT",116,-41);
PlayerFrameManaBar:SetWidth(103);
PlayerFrameManaBar:SetPoint("TOPLEFT",116,-52);
else
PlayerFrameVehicleTexture:SetTexture("Interface\\Vehicles\\UI-Vehicle-Frame");
PlayerFrameHealthBar:SetWidth(100);
PlayerFrameHealthBar:SetPoint("TOPLEFT",119,-41);
PlayerFrameManaBar:SetWidth(100);
PlayerFrameManaBar:SetPoint("TOPLEFT",119,-52);
end
PlayerFrameVehicleTexture:Show();
PlayerName:SetPoint("CENTER",50,23);
PlayerLeaderIcon:SetPoint("TOPLEFT",40,-12);
PlayerMasterIcon:SetPoint("TOPLEFT",86,0);
PlayerFrameGroupIndicator:SetPoint("BOTTOMLEFT", PlayerFrame, "TOPLEFT", 97, -13);
PlayerFrameBackground:SetWidth(114);
PlayerLevelText:Hide();
end
function PlayerFrame_ToPlayerArt(self)
--Unswap frame
PlayerFrame.state = "player";
UnitFrame_SetUnit(self, "player", PlayerFrameHealthBar, PlayerFrameManaBar);
UnitFrame_SetUnit(PetFrame, "pet", PetFrameHealthBar, PetFrameManaBar);
PetFrame_Update(PetFrame);
PlayerFrame_Update();
BuffFrame_Update();
ComboFrame_Update();
PlayerFrameTexture:Show();
PlayerFrameVehicleTexture:Hide();
PlayerName:SetPoint("CENTER",50,19);
PlayerLeaderIcon:SetPoint("TOPLEFT",40,-12);
PlayerMasterIcon:SetPoint("TOPLEFT",80,-10);
PlayerFrameGroupIndicator:SetPoint("BOTTOMLEFT", PlayerFrame, "TOPLEFT", 97, -20);
PlayerFrameHealthBar:SetWidth(119);
PlayerFrameHealthBar:SetPoint("TOPLEFT",106,-41);
PlayerFrameManaBar:SetWidth(119);
PlayerFrameManaBar:SetPoint("TOPLEFT",106,-52);
PlayerFrameBackground:SetWidth(119);
PlayerLevelText:Show();
end
function PlayerFrame_UpdateVoiceStatus (status)
if ( status ) then
UIFrameFadeIn(PlayerSpeakerFrame, 0.2, PlayerSpeakerFrame:GetAlpha(), 1);
VoiceChat_Animate(PlayerSpeakerFrame, 1);
else
UIFrameFadeOut(PlayerSpeakerFrame, 0.2, PlayerSpeakerFrame:GetAlpha(), 0);
VoiceChat_Animate(PlayerSpeakerFrame, nil);
end
end
function PlayerFrame_UpdateReadyCheck ()
local readyCheckStatus = GetReadyCheckStatus("player");
if ( readyCheckStatus ) then
if ( readyCheckStatus == "ready" ) then
ReadyCheck_Confirm(PlayerFrameReadyCheck, 1);
elseif ( readyCheckStatus == "notready" ) then
ReadyCheck_Confirm(PlayerFrameReadyCheck, 0);
else -- "waiting"
ReadyCheck_Start(PlayerFrameReadyCheck);
end
else
PlayerFrameReadyCheck:Hide();
end
end
function PlayerFrame_OnUpdate (self, elapsed)
if ( PlayerStatusTexture:IsShown() ) then
local alpha = 255;
local counter = self.statusCounter + elapsed;
local sign = self.statusSign;
if ( counter > 0.5 ) then
sign = -sign;
self.statusSign = sign;
end
counter = mod(counter, 0.5);
self.statusCounter = counter;
if ( sign == 1 ) then
alpha = (55 + (counter * 400)) / 255;
else
alpha = (255 - (counter * 400)) / 255;
end
PlayerStatusTexture:SetAlpha(alpha);
PlayerStatusGlow:SetAlpha(alpha);
end
if ( PlayerPVPTimerText.timeLeft ) then
PlayerPVPTimerText.timeLeft = PlayerPVPTimerText.timeLeft - elapsed*1000;
local timeLeft = PlayerPVPTimerText.timeLeft;
if ( timeLeft < 0 ) then
PlayerPVPTimerText:Hide()
end
PlayerPVPTimerText:SetFormattedText(SecondsToTimeAbbrev(floor(timeLeft/1000)));
else
PlayerPVPTimerText:Hide();
end
CombatFeedback_OnUpdate(self, elapsed);
end
function PlayerFrame_OnReceiveDrag ()
if ( CursorHasItem() ) then
AutoEquipCursorItem();
end
end
function PlayerFrame_UpdateStatus()
if ( UnitHasVehicleUI("player") ) then
PlayerStatusTexture:Hide()
PlayerRestIcon:Hide()
PlayerAttackIcon:Hide()
PlayerRestGlow:Hide()
PlayerAttackGlow:Hide()
PlayerStatusGlow:Hide()
PlayerAttackBackground:Hide()
elseif ( IsResting() ) then
PlayerStatusTexture:SetVertexColor(1.0, 0.88, 0.25, 1.0);
PlayerStatusTexture:Show();
PlayerRestIcon:Show();
PlayerAttackIcon:Hide();
PlayerRestGlow:Show();
PlayerAttackGlow:Hide();
PlayerStatusGlow:Show();
PlayerAttackBackground:Hide();
elseif ( PlayerFrame.inCombat ) then
PlayerStatusTexture:SetVertexColor(1.0, 0.0, 0.0, 1.0);
PlayerStatusTexture:Show();
PlayerAttackIcon:Show();
PlayerRestIcon:Hide();
PlayerAttackGlow:Show();
PlayerRestGlow:Hide();
PlayerStatusGlow:Show();
PlayerAttackBackground:Show();
elseif ( PlayerFrame.onHateList ) then
PlayerAttackIcon:Show();
PlayerRestIcon:Hide();
PlayerStatusGlow:Hide();
PlayerAttackBackground:Hide();
else
PlayerStatusTexture:Hide();
PlayerRestIcon:Hide();
PlayerAttackIcon:Hide();
PlayerStatusGlow:Hide();
PlayerAttackBackground:Hide();
end
end
function PlayerFrame_UpdateGroupIndicator()
PlayerFrameGroupIndicator:Hide();
local name, rank, subgroup;
if ( GetNumRaidMembers() == 0 ) then
PlayerFrameGroupIndicator:Hide();
return;
end
local numRaidMembers = GetNumRaidMembers();
for i=1, MAX_RAID_MEMBERS do
if ( i <= numRaidMembers ) then
name, rank, subgroup = GetRaidRosterInfo(i);
-- Set the player's group number indicator
if ( name == UnitName("player") ) then
PlayerFrameGroupIndicatorText:SetText(GROUP.." "..subgroup);
PlayerFrameGroupIndicator:SetWidth(PlayerFrameGroupIndicatorText:GetWidth()+40);
PlayerFrameGroupIndicator:Show();
end
end
end
end
function PlayerFrameDropDown_OnLoad (self)
UIDropDownMenu_Initialize(self, PlayerFrameDropDown_Initialize, "MENU");
end
function PlayerFrameDropDown_Initialize ()
if ( PlayerFrame.unit == "vehicle" ) then
UnitPopup_ShowMenu(PlayerFrameDropDown, "VEHICLE", "vehicle");
else
UnitPopup_ShowMenu(PlayerFrameDropDown, "SELF", "player");
end
end
function PlayerFrame_UpdatePlaytime()
if ( PartialPlayTime() ) then
PlayerPlayTimeIcon:SetTexture("Interface\\CharacterFrame\\UI-Player-PlayTimeTired");
PlayerPlayTime.tooltip = format(PLAYTIME_TIRED, REQUIRED_REST_HOURS - floor(GetBillingTimeRested()/60));
PlayerPlayTime:Show();
elseif ( NoPlayTime() ) then
PlayerPlayTimeIcon:SetTexture("Interface\\CharacterFrame\\UI-Player-PlayTimeUnhealthy");
PlayerPlayTime.tooltip = format(PLAYTIME_UNHEALTHY, REQUIRED_REST_HOURS - floor(GetBillingTimeRested()/60));
PlayerPlayTime:Show();
else
PlayerPlayTime:Hide();
end
end
function PlayerFrame_SetupDeathKnniggetLayout ()
PlayerFrame:SetHitRectInsets(0,0,0,35);
--[[ PlayerFrame:SetPoint("TOPLEFT", -11, -8);
PlayerFrame:RegisterEvent("UNIT_RUNIC_POWER");
PlayerPortrait:SetDrawLayer("BACKGROUND");
PlayerFrameTexture:ClearAllPoints();
PlayerFrameTexture:SetTexture("Interface\\PlayerFrame\\UI-PlayerFrame-Deathknight");
PlayerFrameTexture:SetPoint("TOPLEFT", 15, 15);
PlayerFrameTexture:SetTexCoord(0, 1, 0, 1)
PlayerFrameTexture:SetHeight(128);
PlayerFrameTexture:SetWidth(256)
PlayerFrame:CreateTexture("PlayerFrameBackgroundTexture", "BACKGROUND");
PlayerFrameBackgroundTexture:SetTexture("Interface\\PlayerFrame\\UI-PlayerFrame-DeathKnight-Background");
PlayerFrameBackgroundTexture:SetPoint("TOPLEFT", 15, 15);
PlayerFrameBackgroundTexture:SetWidth(256);
PlayerFrameBackgroundTexture:SetHeight(128);
PlayerFrameBackgroundTexture:SetDrawLayer("BORDER");
PlayerFrameBackground:SetDrawLayer("ARTWORK");
PlayerFrameBackground:SetHeight(4);
PlayerFrameBackground:SetWidth(4);
PlayerFrameBackground:SetPoint("TOPLEFT", 108, -24);
PlayerName:SetPoint("CENTER", 50, 18);
PlayerFrameHealthBar:SetPoint("TOPLEFT", PlayerFrame, "TOPLEFT", 113, -41);
PlayerFrameHealthBar:SetWidth(112);
PlayerFrameHealthBarText:SetPoint("CENTER", 53, 3);
-- Death Knight Specific Border Frame
PlayerFrame:CreateTexture("PlayerFrameRunicPowerOverlay", "OVERLAY");
PlayerFrameRunicPowerOverlay:SetPoint("TOPLEFT", 15, 15);
PlayerFrameRunicPowerOverlay:SetWidth(256);
PlayerFrameRunicPowerOverlay:SetHeight(128);
PlayerFrameRunicPowerOverlay:SetTexture("Interface\\PlayerFrame\\UI-PlayerFrame-DeathKnight-GoldBorder");
-- Death Knight Runic Power Glow
local frame = CreateFrame("Frame");
frame:SetPoint("TOPLEFT", PlayerFrame);
frame:SetPoint("BOTTOMRIGHT", PlayerFrame);
frame:CreateTexture("PlayerFrameRunicPowerGlow", "BORDER");
PlayerFrameRunicPowerGlow:SetPoint("TOPLEFT", 15, 15);
PlayerFrameRunicPowerGlow:SetPoint("BOTTOMRIGHT", PlayerFrameBackgroundTexture);
PlayerFrameRunicPowerGlow:SetAlpha(0.050);
PlayerFrameRunicPowerGlow:SetWidth(256);
PlayerFrameRunicPowerGlow:SetHeight(128);
PlayerFrameRunicPowerGlow:Hide();
PlayerFrameRunicPowerGlow:SetTexture("Interface\\PlayerFrame\\UI-PlayerFrame-DeathKnight-Sword-Glow");
--Hoorah for hacks!
PlayerFrameManaBar:UnregisterAllEvents();
PlayerFrameManaBar:Hide();
PlayerFrameManaBar:ClearAllPoints();
PlayerFrameManaBar:SetPoint("TOPLEFT", UIParent, "BOTTOMRIGHT");
PlayerFrameManaBarText:SetParent(PlayerFrameManaBar);
local runicPowerBar = PlayerFrame:CreateTexture("$parentRunicPowerBar", "ARTWORK");
-- Mmmm, runic Power Bars, my favorite kind. Tastes like Death Knnigget.
runicPowerBar:SetTexture("Interface\\PlayerFrame\\UI-PlayerFrame-DeathKnight-RunicPower");
runicPowerBar:SetPoint("BOTTOMLEFT", "$parent", "BOTTOMLEFT", 70, 24);
runicPowerBar:SetWidth(64);
runicPowerBar:SetHeight(63);
PlayerFrame_SetRunicPower(UnitPower("player"));--]]
end
CustomClassLayouts = {
["DEATHKNIGHT"] = PlayerFrame_SetupDeathKnniggetLayout,
}
local layoutUpdated = false;
function PlayerFrame_UpdateLayout ()
if ( layoutUpdated ) then
return;
end
layoutUpdated = true;
local _, class = UnitClass("player");
if ( CustomClassLayouts[class] ) then
CustomClassLayouts[class]();
end
end
local RUNICPOWERBARHEIGHT = 63;
local RUNICPOWERBARWIDTH = 64;
local RUNICGLOW_FADEALPHA = .050
local RUNICGLOW_MINALPHA = .40
local RUNICGLOW_MAXALPHA = .80
local RUNICGLOW_THROBINTERVAL = .8;
RUNICGLOW_FINISHTHROBANDHIDE = false;
local RUNICGLOW_THROBSTART = 0;
function PlayerFrame_SetRunicPower (runicPower)
PlayerFrameRunicPowerBar:SetHeight(RUNICPOWERBARHEIGHT * (runicPower / 100));
PlayerFrameRunicPowerBar:SetTexCoord(0, 1, (1 - (runicPower / 100)), 1);
if ( runicPower >= 90 ) then
-- Oh, God help us for these function and variable names.
RUNICGLOW_FINISHTHROBANDHIDE = false;
if ( not PlayerFrameRunicPowerGlow:IsShown() ) then
PlayerFrameRunicPowerGlow:Show();
end
PlayerFrameRunicPowerGlow:GetParent():SetScript("OnUpdate", DeathKnniggetThrobFunction);
elseif ( PlayerFrameRunicPowerGlow:GetParent():GetScript("OnUpdate") ) then
RUNICGLOW_FINISHTHROBANDHIDE = true;
else
PlayerFrameRunicPowerGlow:Hide();
end
end
local firstFadeIn = true;
function DeathKnniggetThrobFunction (self, elapsed)
if ( RUNICGLOW_THROBSTART == 0 ) then
RUNICGLOW_THROBSTART = GetTime();
elseif ( not RUNICGLOW_FINISHTHROBANDHIDE ) then
local interval = RUNICGLOW_THROBINTERVAL - math.abs( .9 - (UnitPower("player") / 100));
local animTime = GetTime() - RUNICGLOW_THROBSTART;
if ( animTime >= interval ) then
-- Fading out
PlayerFrameRunicPowerGlow:SetAlpha(math.max(RUNICGLOW_MINALPHA, math.min(RUNICGLOW_MAXALPHA, RUNICGLOW_MAXALPHA * interval/animTime)));
if ( animTime >= interval * 2 ) then
self.timeSinceThrob = 0;
RUNICGLOW_THROBSTART = GetTime();
end
firstFadeIn = false;
else
-- Fading in
if ( firstFadeIn ) then
PlayerFrameRunicPowerGlow:SetAlpha(math.max(RUNICGLOW_FADEALPHA, math.min(RUNICGLOW_MAXALPHA, RUNICGLOW_MAXALPHA * animTime/interval)));
else
PlayerFrameRunicPowerGlow:SetAlpha(math.max(RUNICGLOW_MINALPHA, math.min(RUNICGLOW_MAXALPHA, RUNICGLOW_MAXALPHA * animTime/interval)));
end
end
elseif ( RUNICGLOW_FINISHTHROBANDHIDE ) then
local currentAlpha = PlayerFrameRunicPowerGlow:GetAlpha();
local animTime = GetTime() - RUNICGLOW_THROBSTART;
local interval = RUNICGLOW_THROBINTERVAL;
firstFadeIn = true;
if ( animTime >= interval ) then
-- Already fading out, just keep fading out.
local alpha = math.min(PlayerFrameRunicPowerGlow:GetAlpha(), RUNICGLOW_MAXALPHA * (interval/(animTime*(animTime/2))));
PlayerFrameRunicPowerGlow:SetAlpha(alpha);
if ( alpha <= RUNICGLOW_FADEALPHA ) then
self.timeSinceThrob = 0;
RUNICGLOW_THROBSTART = 0;
PlayerFrameRunicPowerGlow:Hide();
self:SetScript("OnUpdate", nil);
RUNICGLOW_FINISHTHROBANDHIDE = false;
return;
end
else
-- Was fading in, start fading out
animTime = interval;
end
end
end
@@ -7,6 +7,9 @@ MAX_ADDONS_DISPLAYED = 19;
-- Addons hidden from the list (players cannot see or disable them)
local MOONWELL_HIDDEN_ADDONS = {
["AIO"] = true,
["DragonUI"] = true,
["DragonUI_Options"] = true,
["MoonWellClient"] = true,
};
local function AddonList_IsHidden(name)