📄 mapnotes.lua
字号:
old_ToggleWorldMap(); MapNotes_OnToggleWorldMap(); end old_WorldMapZoomOutButton_OnClick = WorldMapZoomOutButton_OnClick; WorldMapZoomOutButton_OnClick = function() old_WorldMapZoomOutButton_OnClick(); MapNotes_ZoomOutButton_OnClick(); end end elseif (event == "WORLD_MAP_UPDATE") then MapNotes_HideFrames(); endendfunction MapNotes_MiniNote_OnUpdate(arg1) if ( MapNotes_MiniNote_Data.xPos ~= nil ) then MiniNotePOI.TimeSinceLastUpdate = MiniNotePOI.TimeSinceLastUpdate + arg1; if( MiniNotePOI.TimeSinceLastUpdate > MapNotes_Mininote_UpdateRate ) then local x, y = GetPlayerMapPosition("player"); local currentZone; local continent = GetCurrentMapContinent(); local zone; local zoneText; if( continent == -1 ) then zoneText = GetZoneText(); zone = -1; else zone = MapNotes_ZoneShift[continent][GetCurrentMapZone()]; end if ((x == 0 and y == 0 and (zone > 0 or continent ~= MapNotes_MiniNote_Data.continent)) or continent == 0) then SetMapToCurrentZone(); continent = GetCurrentMapContinent(); if( continent > 0 ) then zone = MapNotes_ZoneShift[continent][GetCurrentMapZone()]; end x, y = GetPlayerMapPosition("player"); end local currentConst; if( continent == -1 ) then currentConst = MapNotes_Const[zoneText]; elseif( continent > 0 ) then currentConst = MapNotes_Const[MapNotes_MiniNote_Data.continent][MapNotes_MiniNote_Data.zone]; end local currentZoom = Minimap:GetZoom(); if (currentConst and x ~= 0 and y ~= 0 and currentConst.scale ~= 0) then local xscale; local yscale; if (zone > 0) then xscale = MapNotes_Const[MapNotes_MiniNote_Data.continent][currentZoom].xscale; yscale = MapNotes_Const[MapNotes_MiniNote_Data.continent][currentZoom].yscale; else xscale = MapNotes_Const[2][currentZoom].xscale; yscale = MapNotes_Const[2][currentZoom].yscale; end if (MapNotes_MiniNote_IsInCity) then xscale = xscale * MapNotes_Const[2][currentZoom].cityscale; yscale = yscale * MapNotes_Const[2][currentZoom].cityscale; end local xpos = MapNotes_MiniNote_Data.xPos * currentConst.scale + currentConst.xoffset; local ypos = MapNotes_MiniNote_Data.yPos * currentConst.scale + currentConst.yoffset; if (zone > 0) then x = x * MapNotes_Const[continent][zone].scale + MapNotes_Const[continent][zone].xoffset; y = y * MapNotes_Const[continent][zone].scale + MapNotes_Const[continent][zone].yoffset; elseif( zone == -1 ) then x = x * MapNotes_Const[zoneText].scale + MapNotes_Const[zoneText].xoffset; y = y * MapNotes_Const[zoneText].scale + MapNotes_Const[zoneText].yoffset; end local deltax = (xpos - x) * xscale; local deltay = (ypos - y) * yscale; if (sqrt( (deltax * deltax) + (deltay * deltay) ) > 56.5) then local adjust = 1; if (deltax == 0) then deltax = deltax + 0.0000000001; elseif (deltax < 0) then adjust = -1; end local m = math.atan(deltay / deltax); deltax = math.cos(m) * 57 * adjust; deltay = math.sin(m) * 57 * adjust; end MiniNotePOI:SetPoint("CENTER", "MinimapCluster", "TOPLEFT", 105 + deltax, -93 - deltay); MiniNotePOI:Show(); else MiniNotePOI:Hide(); end end MiniNotePOI.TimeSinceLastUpdate = 0; else MiniNotePOI:Hide(); endendfunction MapNotes_ShowNewFrame(ax, ay) if (MapNotes_BlockingFrame()) then MapNotes_TempData_xPos = ax; MapNotes_TempData_yPos = ay; MapNotes_TempData_Id = nil; if (ax*1002 >= (1002 - 195)) then xOffset = -176; else xOffset = 0; end if (ay*668 <= (668 - 156)) then yOffset = -75; else yOffset = 87; end MapNotesNewMenuFrame:SetPoint("TOPLEFT", "WorldMapFrame", "TOPLEFT", ax * WorldMapButton:GetWidth() + xOffset, -(ay * WorldMapButton:GetHeight()) + yOffset); if (MapNotes_MiniNote_Data.xPos == nil) then MapNotesButtonMiniNoteOff:Disable(); else MapNotesButtonMiniNoteOff:Enable(); end if (MapNotes_NewNoteSlot() >= MapNotes_NotesPerZone + 1) then MapNotesButtonNewNote:Disable(); end MapNotesPOIMenuFrame:Hide(); MapNotesSpecialActionMenuFrame:Hide(); MapNotesNewMenuFrame:Show(); endendfunction MapNotes_ShowSpecialActionsFrame() local ax; local ay; if (MapNotes_TempData_Id == 0) then ax = MapNotes_tloc_xPos; ay = MapNotes_tloc_yPos; elseif (MapNotes_TempData_Id == -1) then ax = MapNotes_PartyNoteData.xPos; ay = MapNotes_PartyNoteData.yPos; else local zone = MapNotes_ZoneShift[GetCurrentMapContinent()][GetCurrentMapZone()]; local continent = GetCurrentMapContinent(); ax = MapNotes_Data[continent][zone][MapNotes_TempData_Id].xPos; ay = MapNotes_Data[continent][zone][MapNotes_TempData_Id].yPos; end MapNotesPOIMenuFrame:Hide(); if (ax*1002 >= (1002 - 195)) then xOffset = -176; else xOffset = 0; end if (ay*668 <= (668 - 156)) then yOffset = -75; else yOffset = 61; end MapNotesSpecialActionMenuFrame:SetPoint("TOPLEFT", "WorldMapFrame", "TOPLEFT", ax * WorldMapButton:GetWidth() + xOffset, -(ay * WorldMapButton:GetHeight()) + yOffset); if ( MapNotes_TempData_Id <= 0 ) then MapNotesButtonToggleLine:Disable(); else MapNotesButtonToggleLine:Enable(); end MapNotesSpecialActionMenuFrame:Show();endfunction MapNotes_Edit_SetIcon(icon) MapNotes_TempData_Icon = icon; IconOverlay:SetPoint("TOPLEFT", "EditIcon"..icon, "TOPLEFT", -3, 3);endfunction MapNotes_Edit_SetTextColor(color) MapNotes_TempData_TextColor = color; TextColorOverlay:SetPoint("TOPLEFT", "TextColor"..color, "TOPLEFT", -3, 3);endfunction MapNotes_Edit_SetInfo1Color(color) MapNotes_TempData_Info1Color = color; Info1ColorOverlay:SetPoint("TOPLEFT", "Info1Color"..color, "TOPLEFT", -3, 3);endfunction MapNotes_Edit_SetInfo2Color(color) MapNotes_TempData_Info2Color = color; Info2ColorOverlay:SetPoint("TOPLEFT", "Info2Color"..color, "TOPLEFT", -3, 3);endfunction MapNotes_OpenEditForExistingNote(id) MapNotes_HideFrames(); local currentZone; local continent = GetCurrentMapContinent(); if( continent == -1 ) then currentZone = MapNotes_Data[GetZoneText()]; else local zone = MapNotes_ZoneShift[continent][GetCurrentMapZone()]; currentZone = MapNotes_Data[continent][zone]; end MapNotes_TempData_Id = id; MapNotes_TempData_Creator = currentZone[MapNotes_TempData_Id].creator; MapNotes_TempData_xPos = currentZone[MapNotes_TempData_Id].xPos; MapNotes_TempData_yPos = currentZone[MapNotes_TempData_Id].yPos; MapNotes_Edit_SetIcon(currentZone[MapNotes_TempData_Id].icon); MapNotes_Edit_SetTextColor(currentZone[MapNotes_TempData_Id].ncol); MapNotes_Edit_SetInfo1Color(currentZone[MapNotes_TempData_Id].in1c); MapNotes_Edit_SetInfo2Color(currentZone[MapNotes_TempData_Id].in2c); TitleWideEditBox:SetText(currentZone[MapNotes_TempData_Id].name); Info1WideEditBox:SetText(currentZone[MapNotes_TempData_Id].inf1); Info2WideEditBox:SetText(currentZone[MapNotes_TempData_Id].inf2); MapNotesEditMenuFrame:Show();endfunction MapNotes_ShowSendFrame(number) if (number == 1) then MapNotesSendPlayer:Enable(); if (Sky) then MapNotesSendParty:Enable(); else MapNotesSendParty:Disable(); end MapNotesChangeSendMenu:SetText(MAPNOTES_SLASHCOMMAND); SendWideEditBox:SetText(""); if ( UnitCanCooperate("player", "target") ) then SendWideEditBox:SetText(UnitName("target")); end MapNotes_SendFrame_Title:SetText(MAPNOTES_SEND_COSMOSTITLE); MapNotes_SendFrame_Tip:SetText(MAPNOTES_SEND_COSMOSTIP); MapNotes_SendFrame_Player:SetText(MAPNOTES_SEND_PLAYER); MapNotes_ToggleSendValue = 2; elseif (number == 2) then MapNotesSendPlayer:Disable(); MapNotesSendParty:Disable(); MapNotesChangeSendMenu:SetText(MAPNOTES_SHOWSEND); SendWideEditBox:SetText("/mapnote"..MapNotes_GenerateSendString(2)); MapNotes_SendFrame_Title:SetText(MAPNOTES_SEND_SLASHTITLE); MapNotes_SendFrame_Tip:SetText(MAPNOTES_SEND_SLASHTIP); MapNotes_SendFrame_Player:SetText(MAPNOTES_SEND_SLASHCOMMAND); MapNotes_ToggleSendValue = 1; end if (not MapNotesSendFrame:IsVisible()) then MapNotes_HideFrames(); MapNotesSendFrame:Show(); endendfunction MapNotes_GenerateSendString(version)-- <MapN> c<1> z<1> x<0.123123> y<0.123123> t<> i1<> i2<> cr<> i<8> tc<3> i1c<5> i2c<6> local text = ""; if (version == 1) then text = "<MapN>"; end local currentZone; local continent = GetCurrentMapContinent(); local zone; if( continent == -1 ) then currentZone = MapNotes_Data[GetZoneText()]; zone = -1; else zone = MapNotes_ZoneShift[continent][GetCurrentMapZone()]; currentZone = MapNotes_Data[continent][zone]; end if( not currentZone) then return; end text = text.." c<"..continent.."> z<"..zone..">"; local xPos = floor(currentZone[MapNotes_TempData_Id].xPos * 1000000)/1000000; --cut to six digits behind the 0 local yPos = floor(currentZone[MapNotes_TempData_Id].yPos * 1000000)/1000000; text = text.." x<"..xPos.."> y<"..yPos..">"; text = text.." t<"..MapNotes_EliminateUsedChars(currentZone[MapNotes_TempData_Id].name)..">"; text = text.." i1<"..MapNotes_EliminateUsedChars(currentZone[MapNotes_TempData_Id].inf1)..">"; text = text.." i2<"..MapNotes_EliminateUsedChars(currentZone[MapNotes_TempData_Id].inf2)..">"; if ( not currentZone[MapNotes_TempData_Id].creator ) then currentZone[MapNotes_TempData_Id].creator = UnitName("player"); end text = text.." cr<"..currentZone[MapNotes_TempData_Id].creator..">"; text = text.." i<"..currentZone[MapNotes_TempData_Id].icon..">"; text = text.." tf<"..currentZone[MapNotes_TempData_Id].ncol..">"; text = text.." i1f<"..currentZone[MapNotes_TempData_Id].in1c..">"; text = text.." i2f<"..currentZone[MapNotes_TempData_Id].in2c..">"; if( continent == -1 and currentZone[MapNotes_TempData_Id].zname) then text = text.." zn<"..currentZone[MapNotes_TempData_Id].zname..">"; end return text;endfunction MapNotes_EliminateUsedChars(text) --ok, this has to be reworked with a simple replace or something like this while ( strfind(text, "<", 1) ~= nil ) do if (strfind(text, "<", 1) == 1) then text = strsub(text, 2); else text = strsub(text, 1, strfind(text, "<", 1) - 1)..strsub(text, strfind(text, "<", 1) + 1); end end while ( strfind(text, ">", 1) ~= nil ) do if (strfind(text, ">", 1) == 1) then text = strsub(text, 2); else text = strsub(text, 1, strfind(text, ">", 1) - 1)..strsub(text, strfind(text, ">", 1) + 1); end end return text;endfunction MapNotes_SendNote(type) if( Sky ) then if (type == 1) then -- Marsman 3/27/05 changed Player to Player notes to use Sky [added sending to non sky users, - Sinaloit] if (Sky.isSkyUser(SendWideEditBox:GetText())) then Sky.sendAlert(MapNotes_GenerateSendString(1), SKY_PLAYER, "MN", SendWideEditBox:GetText()); else SendChatMessage(MapNotes_GenerateSendString(1), "WHISPER", this.language, SendWideEditBox:GetText()); end MapNotes_HideFrames(); elseif (type == 2) then Sky.sendAlert(MapNotes_GenerateSendString(1), SKY_PARTY, "MN"); MapNotes_HideFrames(); end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -