📄 alphamap.lua
字号:
AlphaMap_LoadCount = AlphaMap_LoadCount + 1;
-- DEFAULT_CHAT_FRAME:AddMessage( "AlphaMap: Variables Loaded!" );
if( AlphaMapConfig.enabled==nil ) then
AlphaMapConfig.enabled = false;
end
if( not AlphaMapConfig.alpha ) then
AlphaMapConfig.alpha = 0.5;
end
if( not AlphaMapConfig.scale ) then
AlphaMapConfig.scale = 0.8;
end
if( AlphaMapConfig.lock == nil ) then
AlphaMapConfig.lock = false;
end
if( AlphaMapConfig.combat == nil ) then
AlphaMapConfig.combat = true;
end
if( AlphaMapConfig.ptips == nil ) then
AlphaMapConfig.ptips = true;
end
if( AlphaMapConfig.gtips == nil ) then
AlphaMapConfig.gtips = false;
end
if( AlphaMapConfig.mntips == nil ) then
AlphaMapConfig.mntips = false;
end
if( AlphaMapConfig.mngtips == nil ) then
AlphaMapConfig.mngtips = false;
end
if( AlphaMapConfig.wmclose == nil ) then
AlphaMapConfig.wmclose = true;
end
if( AlphaMapConfig.gathering == nil ) then
AlphaMapConfig.gathering = false;
end
if( AlphaMapConfig.gatherer == nil ) then
AlphaMapConfig.gatherer = false;
end
if( AlphaMapConfig.mapnotes == nil ) then
AlphaMapConfig.mapnotes = false;
end
if( AlphaMapConfig.raid == nil ) then
AlphaMapConfig.raid = true;
end
if( AlphaMapConfig.sliderlock == nil ) then
AlphaMapConfig.sliderlock = true;
end
if( AlphaMapConfig.slider == nil ) then
AlphaMapConfig.slider = true;
end
if( AlphaMapConfig.slider == false ) then
HideUIPanel( AlphaMapSliderFrame );
end
AlphaMapDetailFrame:SetAlpha( AlphaMapConfig.alpha );
AlphaMapSliderFrame:SetValue( 1 - AlphaMapConfig.alpha );
-- If there is 1 alpha, then hide the markers
if( AlphaMapConfig.alpha == 0.0 ) then
AlphaMapUnits:Hide();
else
AlphaMapUnits:Show();
end
AlphaMap_Register();
--AlphaMap_RegisterCosmos();
end
end
-- Helper function to compute UV coords to draw pins
function AlphaMap_GetPOITextureCoords( index )
local alphaMapIconDimension = AlphaMapPOI1Texture:GetWidth();
local xCoord1, xCoord2, yCoord1, yCoord2;
local coordIncrement = alphaMapIconDimension / ALPHAMAP_POI_TEXTURE_WIDTH;
xCoord1 = mod(index , NUM_ALPHAMAP_POI_COLUMNS) * coordIncrement;
xCoord2 = xCoord1 + coordIncrement;
yCoord1 = floor(index / NUM_ALPHAMAP_POI_COLUMNS) * coordIncrement;
yCoord2 = yCoord1 + coordIncrement;
return xCoord1, xCoord2, yCoord1, yCoord2;
end
-- Called every frame to update the AlphaMap
function AlphaMapFrame_Update()
local mapFileName, textureHeight = GetMapInfo();
if ( not mapFileName ) then
mapFileName = "World";
end
for i=1, NUM_ALPHAMAP_DETAIL_TILES, 1 do
getglobal("AlphaMapDetailTile"..i):SetTexture("Interface\\WorldMap\\"..mapFileName.."\\"..mapFileName..i);
end
-- Setup the POI's
-- This should be moved out of here
local numPOIs = GetNumMapLandmarks();
local name, textureIndex, x, y;
local alphaMapPOI;
local x1, x2, y1, y2;
-- Iterate through each of the Points of interest
for i=1, NUM_ALPHAMAP_POIS, 1 do
-- Get the current point of interest
alphaMapPOI = getglobal( "AlphaMapPOI"..i );
-- Check if the current POI is a valid POI
if ( i <= numPOIs ) then
name, description, textureIndex, x, y = GetMapLandmarkInfo( i );
x1, x2, y1, y2 = AlphaMap_GetPOITextureCoords( textureIndex );
-- Set the texture coordinates
getglobal( alphaMapPOI:GetName().."Texture" ):SetTexCoord( x1, x2, y1, y2 );
x = x * AlphaMapUnits:GetWidth();
y = -y * AlphaMapUnits:GetHeight();
alphaMapPOI:SetPoint( "CENTER", "AlphaMapUnits", "TOPLEFT", x, y );
alphaMapPOI.name = name;
alphaMapPOI:Show();
else
alphaMapPOI:Hide();
end
end
-- Overlay stuff
local numOverlays = GetNumMapOverlays();
local textureName, textureWidth, textureHeight, offsetX, offsetY, mapPointX, mapPointY;
local textureCount = 1;
local texture;
local texturePixelWidth, textureFileWidth, texturePixelHeight, textureFileHeight;
local numTexturesWide, numTexturesTall;
for i=1, numOverlays do
textureName, textureWidth, textureHeight, offsetX, offsetY, mapPointX, mapPointY = GetMapOverlayInfo(i);
numTexturesWide = ceil(textureWidth/256);
numTexturesTall = ceil(textureHeight/256);
for j=1, numTexturesTall do
if ( j < numTexturesTall ) then
texturePixelHeight = 256;
textureFileHeight = 256;
else
texturePixelHeight = mod(textureHeight, 256);
if ( texturePixelHeight == 0 ) then
texturePixelHeight = 256;
end
textureFileHeight = 16;
while(textureFileHeight < texturePixelHeight) do
textureFileHeight = textureFileHeight * 2;
end
end
for k=1, numTexturesWide do
if ( textureCount > NUM_ALPHAMAP_OVERLAYS ) then
message(ALPHAMAP_TOOMANYMAPOVERLAY);
return;
end
texture = getglobal("AlphaMapOverlay"..textureCount);
if ( k < numTexturesWide ) then
texturePixelWidth = 256;
textureFileWidth = 256;
else
texturePixelWidth = mod(textureWidth, 256);
if ( texturePixelWidth == 0 ) then
texturePixelWidth = 256;
end
textureFileWidth = 16;
while(textureFileWidth < texturePixelWidth) do
textureFileWidth = textureFileWidth * 2;
end
end
texture:SetWidth(texturePixelWidth);
texture:SetHeight(texturePixelHeight);
texture:SetTexCoord(0, texturePixelWidth/textureFileWidth, 0, texturePixelHeight/textureFileHeight);
texture:ClearAllPoints();
texture:SetPoint("TOPLEFT", "AlphaMapDetailFrame", "TOPLEFT", offsetX + (256 * (k-1)), -(offsetY + (256 * (j - 1))));
texture:SetTexture(textureName..(((j - 1) * numTexturesWide) + k));
texture:Show();
textureCount = textureCount +1;
end
end
end
for i=textureCount, NUM_ALPHAMAP_OVERLAYS do
getglobal("AlphaMapOverlay"..i):Hide();
end
if( AlphaMapConfig.scale ) then
AlphaMapFrame:SetScale( AlphaMapConfig.scale );
end
end
-- Called to toggle visibility of the AlphaMap
function ToggleAlphaMap(toggle)
if (not toggle) then
AlphaMapConfig.enabled = not AlphaMapFrame:IsVisible();
if (AlphaMapConfig.enabled) then
toggle = 1;
else
toggle = 0;
end
else
AlphaMapConfig.enabled = ( toggle==1 );
end
if ( not AlphaMapConfig.enabled ) then
AlphaMapFrame.UserHidden = true;
AlphaMapFrame:Hide();
else
--SetupWorldMapScale(WorldMapFrame);
AlphaMapFrame:Show();
end
if (Khaos) then
--Khaos.setSetKeyParameter("AlphaMap", "AlphaMapEnabled", "checked", AlphaMapConfig.enabled);
end
if ( Cosmos_RegisterConfiguration ) then
Cosmos_UpdateValue("COS_ALPHAMAP_ENABLED",CSM_CHECKONOFF,toggle);
end
if ( Cosmos_SetCVar ) then
Cosmos_SetCVar("COS_ALPHAMAP_ENABLED_X", toggle);
end
end
function ToggleSlider()
if ( AlphaMapSliderFrame:IsVisible() ) then
AlphaMapSliderFrame:Hide();
AlphaMapConfig.slider = false;
else
AlphaMapSliderFrame:Show();
AlphaMapConfig.slider = true;
end
end
-- Helper function to increment the opacity by .10
function IncrementAlphaMap()
-- Determine the transparency from the alpha slider
local alpha = 1.0 - AlphaMapSliderFrame:GetValue();
-- Increment the opacity
alpha = alpha + ALPHAMAP_INCREMENT;
local slider = 0;
if (AlphaMapConfig.slider) then
slider = 1;
end
AlphaMap_Alpha_Set(slider,alpha);
end
-- Helper function to decrement the opacity by .10
function DecrementAlphaMap()
-- Determine the transparency from the alpha slider
local alpha = 1.0 - AlphaMapSliderFrame:GetValue();
-- Increment the opacity
alpha = alpha - ALPHAMAP_INCREMENT;
local slider = 0;
if (AlphaMapConfig.slider) then
slider = 1;
end
AlphaMap_Alpha_Set(slider,alpha);
end
-- Called every frame to update the pin overlays on the AlphaMap
function AlphaMapUnits_OnUpdate()
-- Get Zone/Continent Info
local zone = GetCurrentMapZone();
local continent = GetCurrentMapContinent();
--Position player
local playerX, playerY = GetPlayerMapPosition("player");
if ( playerX == 0 and playerY == 0 ) then
AlphaMapMinimap:Hide();
else
playerX = playerX * AlphaMapDetailFrame:GetWidth();
playerY = -playerY * AlphaMapDetailFrame:GetHeight();
AlphaMapMinimap:SetPoint("CENTER", "AlphaMapDetailFrame", "TOPLEFT", playerX, playerY);
AlphaMapMinimap:Show();
end
-- Update Position info
playerX, playerY = GetPlayerMapPosition("player");
AlphaMapLocationText:SetText( format( "%d, %d", playerX * 100.0, playerY * 100.0) );
--Position groupmates
local partyX, partyY, partyMemberFrame;
if( GetNumRaidMembers() > 0 and AlphaMapConfig.raid == true ) then
for i=1, MAX_PARTY_MEMBERS do
partyMemberFrame = getglobal("AlphaMapParty"..i);
partyMemberFrame:Hide();
end
for i=1, MAX_RAID_MEMBERS do
partyX, partyY = GetPlayerMapPosition( "raid"..i );
partyMemberFrame = getglobal( "AlphaMapRaid"..i );
if ( partyX == 0 and partyY == 0 or UnitIsUnit( "raid"..i, "player" ) ) then
partyMemberFrame:Hide();
else
partyX = partyX * AlphaMapDetailFrame:GetWidth();
partyY = -partyY * AlphaMapDetailFrame:GetHeight();
partyMemberFrame:SetPoint( "CENTER", "AlphaMapDetailFrame", "TOPLEFT", partyX, partyY);
partyMemberFrame:Show();
end
end
else
for i=1, MAX_PARTY_MEMBERS do
partyX, partyY = GetPlayerMapPosition("party"..i);
partyMemberFrame = getglobal("AlphaMapParty"..i);
if ( partyX == 0 and partyY == 0 ) then
partyMemberFrame:Hide();
else
partyX = partyX * AlphaMapDetailFrame:GetWidth();
partyY = -partyY * AlphaMapDetailFrame:GetHeight();
partyMemberFrame:SetPoint("CENTER", "AlphaMapDetailFrame", "TOPLEFT", partyX, partyY);
partyMemberFrame:Show();
end
end
for i=1, MAX_RAID_MEMBERS do
partyMemberFrame = getglobal("AlphaMapRaid"..i);
partyMemberFrame:Hide();
end
end
--Position corpse
local corpseX, corpseY = GetCorpseMapPosition();
if ( corpseX == 0 and corpseY == 0 ) then
AlphaMapCorpse:Hide();
else
corpseX = corpseX * AlphaMapDetailFrame:GetWidth();
corpseY = -corpseY * AlphaMapDetailFrame:GetHeight();
AlphaMapCorpse:SetPoint("CENTER", "AlphaMapDetailFrame", "TOPLEFT", corpseX, corpseY);
AlphaMapCorpse:Show();
end
-- /////////////////////////////////////////////////////////////////
-- MapNotes 0.5.3 Pins
-- ////////////////////////////////////////////////////////////////
-- Check if we're in a valid zone and MapNotes is active
if( zone ~= 0 and MapNotes_Options and AlphaMapConfig.mapnotes == true ) then
local n = 1;
-- Iterate through the saved MapNotes
for i, value in MapNotes_Data[continent][zone] do
local temp = getglobal( "AlphaMapNotesPOI"..i );
temp:SetPoint("CENTER", "AlphaMapDetailFrame", "TOPLEFT", ( MapNotes_Data[continent][zone][i].xPos)*AlphaMapDetailFrame:GetWidth(), -(MapNotes_Data[continent][zone][i].yPos)*AlphaMapDetailFrame:GetHeight() );
local myTexture = getglobal( "AlphaMapNotesPOI"..i.."Texture" );
myTexture:SetTexture( "Interface\\AddOns\\MapNotes\\POIIcons\\Icon"..MapNotes_Data[continent][zone][i].icon );
if( MapNotes_Options[ MapNotes_Data[continent][zone][i].icon ] ~= "off" and ((MapNotes_Options[10] ~= "off" and MapNotes_Data[continent][zone][i].creator == UnitName("player")) or (MapNotes_Options[11] ~= "off" and MapNotes_Data[continent][zone][i].creator ~= UnitName("player")))) then
temp:Show();
else
temp:Hide();
end
n = n + 1;
end
-- Hide all the others
for i=n, NUM_ALPHAMAP_MAPNOTE_POIS, 1 do
getglobal( "AlphaMapNotesPOI"..i ):Hide();
end
else
for i=1, NUM_ALPHAMAP_MAPNOTE_POIS, 1 do
getglobal("AlphaMapNotesPOI"..i):Hide();
end
end
-- ////////////////////////////////////////////////////////////////
-- MapNotes Gathering 0.5.6 Pins
-- ////////////////////////////////////////////////////////////////
if( zone ~= 0 and MapNotesGathering_Data and AlphaMapConfig.gathering == true ) then
for i=1, getn( MapNotesGathering_Data[continent][zone] ), 1 do
local temp = getglobal( "AlphaMapGatheringPOI"..i );
local icon = MapNotesGathering_Data[continent][zone][i].icon;
if (icon ~= nil and icon ~= 0) then --workaround for the bug in the first version...
if ((MapNotes_Options.showherbs and icon > 9 and icon <= 38 and
MapNotes_Options["Gathering"][icon] ~= "off") or
(MapNotes_Options.showveins and icon <= 9 and
MapNotes_Options["Gathering"][icon] ~= "off") or
(MapNotes_Options.showchests and icon >= 39)) then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -