Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function BattlefieldMinimap_OnUpdate(self, elapsed)
- -- Throttle updates
- if ( BattlefieldMinimap.updateTimer < 0 ) then
- BattlefieldMinimap.updateTimer = BATTLEFIELD_MINIMAP_UPDATE_RATE;
- else
- BattlefieldMinimap.updateTimer = BattlefieldMinimap.updateTimer - elapsed;
- end
- --Position player
- UpdateWorldMapArrowFrames();
- local playerX, playerY = GetPlayerMapPosition("player");
- if ( playerX == 0 and playerY == 0 and not WorldMapFrame:IsShown() ) then
- SetMapToCurrentZone();
- playerX, playerY = GetPlayerMapPosition("player");
- end
- if ( playerX == 0 and playerY == 0 ) then
- ShowMiniWorldMapArrowFrame(nil);
- else
- playerX = playerX * BattlefieldMinimap:GetWidth();
- playerY = -playerY * BattlefieldMinimap:GetHeight();
- PositionMiniWorldMapArrowFrame("CENTER", "BattlefieldMinimap", "TOPLEFT", playerX, playerY);
- ShowMiniWorldMapArrowFrame(1);
- end
- -- If resizing the frame then scale everything accordingly
- if ( BattlefieldMinimap.resizing ) then
- local sizeUnit = BattlefieldMinimap:GetWidth()/4;
- local mapPiece;
- for i=1, NUM_WORLDMAP_DETAIL_TILES do
- mapPiece = _G["BattlefieldMinimap"..i];
- mapPiece:SetWidth(sizeUnit);
- mapPiece:SetHeight(sizeUnit);
- end
- local numPOIs = GetNumMapLandmarks();
- for i=1, NUM_BATTLEFIELDMAP_POIS, 1 do
- local battlefieldPOIName = "BattlefieldMinimapPOI"..i;
- local battlefieldPOI = _G[battlefieldPOIName];
- if ( i <= numPOIs ) then
- local name, description, textureIndex, x, y, maplinkID,showInBattleMap = GetMapLandmarkInfo(i);
- if ( showInBattleMap ) then
- local x1, x2, y1, y2 = WorldMap_GetPOITextureCoords(textureIndex);
- _G[battlefieldPOIName.."Texture"]:SetTexCoord(x1, x2, y1, y2);
- x = x * BattlefieldMinimap:GetWidth();
- y = -y * BattlefieldMinimap:GetHeight();
- battlefieldPOI:SetPoint("CENTER", "BattlefieldMinimap", "TOPLEFT", x, y );
- battlefieldPOI:Show();
- else
- battlefieldPOI:Hide();
- end
- else
- battlefieldPOI:Hide();
- end
- end
- end
- if ( not BattlefieldMinimapOptions.showPlayers ) then
- for i=1, MAX_PARTY_MEMBERS do
- _G["BattlefieldMinimapParty"..i]:Hide();
- end
- for i=1, MAX_RAID_MEMBERS do
- _G["BattlefieldMinimapRaid"..i]:Hide();
- end
- wipe(BG_VEHICLES);
- else
- --Position groupmates
- local playerCount = 0;
- if ( GetNumRaidMembers() > 0 ) then
- for i=1, MAX_PARTY_MEMBERS do
- local partyMemberFrame = _G["BattlefieldMinimapParty"..i];
- partyMemberFrame:Hide();
- end
- for i=1, MAX_RAID_MEMBERS do
- local unit = "raid"..i;
- local partyX, partyY = GetPlayerMapPosition(unit);
- local partyMemberFrame = _G["BattlefieldMinimapRaid"..(playerCount + 1)];
- if ( (partyX ~= 0 or partyY ~= 0) and not UnitIsUnit("raid"..i, "player") ) then
- partyX = partyX * BattlefieldMinimap:GetWidth();
- partyY = -partyY * BattlefieldMinimap:GetHeight();
- partyMemberFrame:SetPoint("CENTER", "BattlefieldMinimap", "TOPLEFT", partyX, partyY);
- partyMemberFrame.name = nil;
- partyMemberFrame.unit = unit;
- partyMemberFrame:Show();
- playerCount = playerCount + 1;
- end
- end
- else
- for i=1, MAX_PARTY_MEMBERS do
- local partyX, partyY = GetPlayerMapPosition("party"..i);
- local partyMemberFrame = _G["BattlefieldMinimapParty"..i];
- if ( partyX == 0 and partyY == 0 ) then
- partyMemberFrame:Hide();
- else
- partyX = partyX * BattlefieldMinimap:GetWidth();
- partyY = -partyY * BattlefieldMinimap:GetHeight();
- partyMemberFrame:SetPoint("CENTER", "BattlefieldMinimap", "TOPLEFT", partyX, partyY);
- partyMemberFrame:Show();
- end
- end
- end
- -- Position Team Members
- local numTeamMembers = GetNumBattlefieldPositions();
- for i=playerCount+1, MAX_RAID_MEMBERS do
- local partyX, partyY, name = GetBattlefieldPosition(i - playerCount);
- local partyMemberFrame = _G["BattlefieldMinimapRaid"..i];
- if ( partyX == 0 and partyY == 0 ) then
- partyMemberFrame:Hide();
- else
- partyX = partyX * BattlefieldMinimap:GetWidth();
- partyY = -partyY * BattlefieldMinimap:GetHeight();
- partyMemberFrame:SetPoint("CENTER", "BattlefieldMinimap", "TOPLEFT", partyX, partyY);
- partyMemberFrame.name = name;
- partyMemberFrame.unit = nil;
- partyMemberFrame:Show();
- end
- end
- -- Position flags
- local numFlags = GetNumBattlefieldFlagPositions();
- for i=1, NUM_WORLDMAP_FLAGS do
- local flagFrameName = "BattlefieldMinimapFlag"..i;
- local flagFrame = _G[flagFrameName];
- if ( i <= numFlags ) then
- local flagX, flagY, flagToken = GetBattlefieldFlagPosition(i);
- local flagTexture = _G[flagFrameName.."Texture"];
- if ( flagX == 0 and flagY == 0 ) then
- flagFrame:Hide();
- else
- flagX = flagX * BattlefieldMinimap:GetWidth();
- flagY = -flagY * BattlefieldMinimap:GetHeight();
- flagFrame:SetPoint("CENTER", "BattlefieldMinimap", "TOPLEFT", flagX, flagY);
- local flagTexture = _G[flagFrameName.."Texture"];
- flagTexture:SetTexture("Interface\\WorldStateFrame\\"..flagToken);
- flagFrame:Show();
- end
- else
- flagFrame:Hide();
- end
- end
- -- position vehicles
- local numVehicles = GetNumBattlefieldVehicles();
- local totalVehicles = #BG_VEHICLES;
- local index = 0;
- for i=1, numVehicles do
- if (i > totalVehicles) then
- local vehicleName = "BattlefieldMinimap"..i;
- BG_VEHICLES[i] = CreateFrame("FRAME", vehicleName, BattlefieldMinimap, "WorldMapVehicleTemplate");
- BG_VEHICLES[i].texture = _G[vehicleName.."Texture"];
- BG_VEHICLES[i]:SetWidth(30 * GetBattlefieldMapIconScale());
- BG_VEHICLES[i]:SetHeight(30 * GetBattlefieldMapIconScale());
- end
- local vehicleX, vehicleY, unitName, isPossessed, vehicleType, orientation, isPlayer = GetBattlefieldVehicleInfo(i);
- -- If vehicle has position and isn't the player
- if ( vehicleX and not isPlayer) then
- vehicleX = vehicleX * BattlefieldMinimap:GetWidth();
- vehicleY = -vehicleY * BattlefieldMinimap:GetHeight();
- BG_VEHICLES[i].texture:SetTexture(WorldMap_GetVehicleTexture(vehicleType, isPossessed));
- BG_VEHICLES[i].texture:SetRotation( orientation );
- BG_VEHICLES[i]:SetPoint("CENTER", "BattlefieldMinimap", "TOPLEFT", vehicleX, vehicleY);
- BG_VEHICLES[i]:Show();
- index = i; -- save for later
- else
- BG_VEHICLES[i]:Hide();
- end
- end
- if (index < totalVehicles) then
- for i=index+1, totalVehicles do
- BG_VEHICLES[i]:Hide();
- end
- end
- end
- -- Fadein tab if mouse is over
- if ( BattlefieldMinimap:IsMouseOver(45, -10, -5, 5) ) then
- local xPos, yPos = GetCursorPosition();
- -- If mouse is hovering don't show the tab until the elapsed time reaches the tab show delay
- if ( BattlefieldMinimap.hover ) then
- if ( (BattlefieldMinimap.oldX == xPos and BattlefieldMinimap.oldy == yPos) ) then
- BattlefieldMinimap.hoverTime = BattlefieldMinimap.hoverTime + elapsed;
- else
- BattlefieldMinimap.hoverTime = 0;
- BattlefieldMinimap.oldX = xPos;
- BattlefieldMinimap.oldy = yPos;
- end
- if ( BattlefieldMinimap.hoverTime > BATTLEFIELD_TAB_SHOW_DELAY ) then
- -- If the battlefieldtab's alpha is less than the current default, then fade it in
- if ( not BattlefieldMinimap.hasBeenFaded and (BattlefieldMinimap.oldAlpha and BattlefieldMinimap.oldAlpha < DEFAULT_BATTLEFIELD_TAB_ALPHA) ) then
- UIFrameFadeIn(BattlefieldMinimapTab, BATTLEFIELD_TAB_FADE_TIME, BattlefieldMinimap.oldAlpha, DEFAULT_BATTLEFIELD_TAB_ALPHA);
- -- Set the fact that the chatFrame has been faded so we don't try to fade it again
- BattlefieldMinimap.hasBeenFaded = 1;
- end
- end
- else
- -- Start hovering counter
- BattlefieldMinimap.hover = 1;
- BattlefieldMinimap.hoverTime = 0;
- BattlefieldMinimap.hasBeenFaded = nil;
- CURSOR_OLD_X, CURSOR_OLD_Y = GetCursorPosition();
- -- Remember the oldAlpha so we can return to it later
- if ( not BattlefieldMinimap.oldAlpha ) then
- BattlefieldMinimap.oldAlpha = BattlefieldMinimapTab:GetAlpha();
- end
- end
- else
- -- If the tab's alpha was less than the current default, then fade it back out to the oldAlpha
- if ( BattlefieldMinimap.hasBeenFaded and BattlefieldMinimap.oldAlpha and BattlefieldMinimap.oldAlpha < DEFAULT_BATTLEFIELD_TAB_ALPHA ) then
- UIFrameFadeOut(BattlefieldMinimapTab, BATTLEFIELD_TAB_FADE_TIME, DEFAULT_BATTLEFIELD_TAB_ALPHA, BattlefieldMinimap.oldAlpha);
- BattlefieldMinimap.hover = nil;
- BattlefieldMinimap.hasBeenFaded = nil;
- end
- BattlefieldMinimap.hoverTime = 0;
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement