📄 glimquestion.lua
字号:
local gLimQuestion_QuestData = nil;
local SortedTable = nil;
local sizeSortedTable = nil;
local orgQuestHistory_Detail_Update;
local orgQuestHistory_SortComparison;
local gLimQuestion_Inited = false;
function gLimQuestion_OnLoad()
orgQuestHistory_Detail_Update = QuestHistory_Detail_Update;
this:RegisterEvent("VARIABLES_LOADED");
this:RegisterEvent("UNIT_NAME_UPDATE");
Sea.util.hook("QuestHistory_BuildSortedTable","gLimQuestion_QH_BuildSortedTable","replace");
-- Sea.util.hook("QuestHistory_SortComparison","gLimQuestion_QH_SortComparison","replace");
orgQuestHistory_SortComparison = QuestHistory_SortComparison;
QuestHistory_SortComparison = gLimQuestion_QH_SortComparison;
Sea.util.hook("QuestHistory_Update","gLimQuestion_QH_Update","replace");
Sea.util.hook("QuestHistoryListFrame_OnClick","gLimQuestion_QH_ListFrame_OnClick","replace");--button="LeftButton"继续,否则不动作
Sea.util.hook("QuestHistoryListFrame_OnEnter","gLimQuestion_QH_ListFrame_OnEnter","replace");
Sea.util.hook("QuestHistory_Detail_Update","gLimQuestion_QH_Detail_Update","replace");
Sea.util.hook("QuestLog_UpdateQuestDetails","gLimQuestion_QL_Detail_Update","after");
Sea.util.hook("QuestLog_Update","gLimQuestion_QL_Update","after");
end
function gLimQuestion_OnEvent()
if( event == "VARIABLES_LOADED" ) then
if ( MapNotes_Data and MapNotes_ZoneNames ) then
gLimQuestionWorldMapDeleteButton:Show();
end
end
end
local function gLimQuestion_DoNothing()
end
local function gLimQuestion_GetQuestByIndex(index)
local questData = nil;
if ( not index ) then
index = 1;
end
local _,_,qc,qt,qla,ql,qf,qo = string.find(BaseQuestDB[index].q,"([^`]*)`([^`]*)`(%d*)`(%d*)`(%d*)`(.*)");
qla = tonumber(qla);
ql = tonumber(ql);
qf = tonumber(qf);
questData = {};
questData.c = qc;
questData.t = qt;
questData.la = qla;
questData.l = ql;
questData.o = qo;
if (BaseQuestDB[index].pa) then
_,_,questData.g,questData.az,questData.pas = string.find(BaseQuestDB[index].pa,"([^`]*)`([^`]*)`(.*)");
questData.pa = {};
for x,y in string.gfind(questData.pas,"(%d+),(%d+)") do
x,y = tonumber(x),tonumber(y);
local haspos=false;
local insertpos=table.getn(questData.pa)+1;
for k,v in questData.pa do
if (v.x==x and v.y==y) then
haspos = true;
break;
elseif (v.x>x or (v.x==x and v.y>y)) then
insertpos = k;
break;
end
end
if (not haspos) then
table.insert(questData.pa,insertpos,{x=x,y=y});
end
end
questData.pas = nil;
end
if (BaseQuestDB[index].pc) then
_,_,questData.w,questData.cz,questData.pcs = string.find(BaseQuestDB[index].pc,"([^`]*)`([^`]*)`(.*)");
questData.pc = {};
for x,y in string.gfind(questData.pcs,"(%d+),(%d+)") do
x,y = tonumber(x),tonumber(y);
local haspos=false;
local insertpos=table.getn(questData.pc)+1;
for k,v in questData.pc do
if (v.x==x and v.y==y) then
haspos = true;
break;
elseif (v.x>x or (v.x==x and v.y>y)) then
insertpos = k;
break;
end
end
if (not haspos) then
table.insert(questData.pc,insertpos,{x=x,y=y});
end
end
questData.pcs = nil;
end
if BaseQuestDB[index].os then
questData.os = {};
for j,o in BaseQuestDB[index].os do
local osd = {};
osd.t = o.t;
if (o.n) then
osd.npc = {};
for npccode in string.gfind(o.n,"(%d+)") do
npccode = tonumber(npccode);
if (BaseNpcDB[npccode]) then
local _,_,n,c,ll,lm = string.find(BaseNpcDB[npccode].n,"([^`]*)`([^`]*)`(%d*)`(%d*)");
ll,lm = tonumber(ll),tonumber(lm);
for xi in BaseNpcDB[npccode].x do
local _,_,a,pos = string.find(BaseNpcDB[npccode].x[xi],"([^`]*)`(.*)");
if (not osd.npc[a]) then
osd.npc[a] = {};
end
local npcindex=nil;
for k,v in osd.npc[a] do
if (v.n==n and v.c==c) then
npcindex=k;
break;
end
end
if (not npcindex) then
table.insert(osd.npc[a],{n=n,c=c});
npcindex = table.getn(osd.npc[a]);
else
npcindex = nil;
end
if (npcindex) then
osd.npc[a][npcindex].ll = ll;
osd.npc[a][npcindex].lm = lm;
if (not osd.npc[a][npcindex].pos) then
osd.npc[a][npcindex].pos = {};
end
for x,y in string.gfind(pos,"(%d+),(%d+)") do
x,y = tonumber(x),tonumber(y);
table.insert(osd.npc[a][npcindex].pos,{x=x,y=y});
end
end
end
end
end
for area,npclist in osd.npc do
table.sort(osd.npc[area],function(n1,n2) return (n1.ll or -1)<(n2.ll or -1) or (n1.ll==n2.ll and (n1.lm or -1)<(n2.lm or -1)); end);
end
end
table.insert(questData.os,osd);
end
end
return questData;
end
local function gLimQuestion_GetQuest(title,level,objective)
if ( not title ) then
title = "";
end
if ( not level ) then
level = "";
else
level = tonumber(level);
end
if ( not objective ) then
objective = "";
end
for i,q in BaseQuestDB do
local _,_,qt,ql,qo = string.find(q.q,"[^`]*`([^`]*)`%d*`(%d*)`%d*`(.*)");
ql = tonumber(ql);
if (qt==title and ql==level and qo==objective) then
return gLimQuestion_GetQuestByIndex(i);
end
end
return nil;
end
-- Converts the zone into the continent/zone numbers used by MapNotes
local function gLimQuestion_MapNotes_GetZone(zone)
for i = 1, 2, 1 do
for j, value in MapNotes_ZoneNames[i] do
if ( value == zone ) then
return i, j;
end
end
end
return 0, 0;
end
local function gLimQuestion_Make_MapNote(zonename,title,tcolor,info1,i1color,info2,i2color,icon,x,y)
local rl = 0;
if ( MapNotes_Data and MapNotes_ZoneNames ) then
local old_WorldMapButton_OnUpdate = MapNotes_WorldMapButton_OnUpdate;
MapNotes_WorldMapButton_OnUpdate = gLimQuestion_DoNothing;
local continent, zone = gLimQuestion_MapNotes_GetZone(zonename);
local xpos,ypos=(x+0)/100,(y+0)/100;
local c, hasnear = 1, false;
for l, value in MapNotes_Data[continent][zone] do
if (abs(value.xPos - xpos) <= 0.0009765625 * MapNotes_MinDiff and abs(value.yPos - ypos) <= 0.0013020833 * MapNotes_MinDiff) then
hasnear=true;
break;
end
c = l+1;
end
if ( not hasnear and c < MapNotes_NotesPerZone) then
MapNotes_Data[continent][zone][c] = {};
MapNotes_Data[continent][zone][c].name = title;
MapNotes_Data[continent][zone][c].ncol = tcolor;
MapNotes_Data[continent][zone][c].inf1 = info1;
MapNotes_Data[continent][zone][c].in1c = i1color;
MapNotes_Data[continent][zone][c].inf2 = info2;
MapNotes_Data[continent][zone][c].in2c = i2color;
MapNotes_Data[continent][zone][c].creator = "gLim";
MapNotes_Data[continent][zone][c].icon = icon;
MapNotes_Data[continent][zone][c].xPos = xpos;
MapNotes_Data[continent][zone][c].yPos = ypos;
elseif (hasnear) then
rl = 1;
else
rl = 2;
end
MapNotes_WorldMapButton_OnUpdate = old_WorldMapButton_OnUpdate;
old_WorldMapButton_OnUpdate = nil;
end
return rl;
end
local function gLimQuestion_DeleteMapNotes(continent,zone)
if ( MapNotes_Data and MapNotes_ZoneNames ) then
local i = 1;
local old_WorldMapButton_OnUpdate = MapNotes_WorldMapButton_OnUpdate;
MapNotes_WorldMapButton_OnUpdate = gLimQuestion_DoNothing;
local orgCont,orgZone = GetCurrentMapContinent(),GetCurrentMapZone();
SetMapZoom(continent, zone);
while (MapNotes_Data[continent][zone][i]) do
if (MapNotes_Data[continent][zone][i].creator=="gLim") then
MapNotes_DeleteNote(i);
else
i = i + 1;
end
end
SetMapZoom(orgCont, orgZone);
MapNotes_WorldMapButton_OnUpdate = old_WorldMapButton_OnUpdate;
old_WorldMapButton_OnUpdate = nil;
end
end
function gLimQuestion_QL_Update()
gLimQuestionQLNPCFrame:Hide();
QuestLogFrameAbandonButton:Show();
QuestFramePushQuestButton:Show();
end
function gLimQuestion_QL_Detail_Update()
gLimQuestionQLNPCFrame:Hide();
QuestLogDetailScrollFrame:Show();
QuestLogFrameAbandonButton:Show();
QuestFramePushQuestButton:Show();
local questID = GetQuestLogSelection();
local questTitle,level = GetQuestLogTitle(questID);
local _, questObjectives = GetQuestLogQuestText();
gLimQuestion_QuestData = gLimQuestion_GetQuest(questTitle,level,questObjectives);
if (gLimQuestion_QuestData and (gLimQuestion_QuestData.az or gLimQuestion_QuestData.cz))
then
gLimQuestionQLACQueryButton:Show();
else
gLimQuestionQLACQueryButton:Hide();
end
local i;
for i = 1, 10 do
local button = getglobal("gLimQuestionQLObjectButton"..i);
local qlstring = getglobal("QuestLogObjective"..i);
button:Hide();
if (qlstring:IsVisible() and gLimQuestion_QuestData and gLimQuestion_QuestData.os) then
local text = qlstring:GetText();
text = string.gsub(text,"已杀死","");
text = string.gsub(text,":.*","");
for k,v in gLimQuestion_QuestData.os do
local objtext = v.t;
objtext = string.gsub(objtext,"已杀死","");
objtext = string.gsub(objtext,":.*","");
if (objtext==text and v.npc) then
button:ClearAllPoints();
button:SetPoint("TOPLEFT","QuestLogObjective"..i,"TOPLEFT", 0, 0);
button:SetPoint("BOTTOMRIGHT","QuestLogObjective"..i,"BOTTOMRIGHT", 0, 0);
button:SetID(k);
button:Show();
break;
end
end
end
end
end
local function gLimQuestion_QuestNPCTree_OnClick(postable)
if (not postable or not gLimQuestion_QuestData) then
return;
end
local MapNoteError = 0;
local text = "["..gLimQuestion_QuestData.t.."]任务目标["..postable.t.."]获得: "..postable.n.." 位于 "..postable.a;
if ( MapNotes_Data and MapNotes_ZoneNames and postable.pos and postable.pos[1] and not IsShiftKeyDown()) then
local continent, zone = gLimQuestion_MapNotes_GetZone(postable.a);
gLimQuestion_DeleteMapNotes(continent, zone);
end
for k,pos in postable.pos do
text = text.." <"..pos.x..","..pos.y..">";
if (not (IsShiftKeyDown() and ChatFrameEditBox:IsVisible()) and MapNoteError<2) then
MapNoteError = gLimQuestion_Make_MapNote(postable.a,postable.n,0,"任务: "..gLimQuestion_QuestData.t,4,postable.t,8,1,pos.x,pos.y);
if (MapNoteError==2) then
Sea.io.print("|cff00ffff区域 "..postable.a.." 中的地图标记过多,请删除部分。|r");
end
end
end
if ( IsShiftKeyDown() ) then
if ( ChatFrameEditBox:IsVisible() ) then
ChatFrameEditBox:Insert(text);
end
elseif ( MapNotes_Data and MapNotes_ZoneNames and postable.pos and postable.pos[1]) then
local continent, zone = gLimQuestion_MapNotes_GetZone(postable.a);
ToggleWorldMap();
SetMapZoom(continent, zone);
end
end
local function gLimQuestion_GenEarthTreeTable(id)
if (gLimQuestion_QuestData and gLimQuestion_QuestData.os and gLimQuestion_QuestData.os[id] and gLimQuestion_QuestData.os[id].npc) then
local eTree={};
local objtext = gLimQuestion_QuestData.os[id].t;
objtext = string.gsub(objtext,"已杀死","");
objtext = string.gsub(objtext,":.*","");
for z,zn in gLimQuestion_QuestData.os[id].npc do
local areaentry={};
areaentry.title = z;
areaentry.children = {};
for i,nd in zn do
local npcentry = {};
npcentry.title = nd.n;
npcentry.titleColor={r=1,g=1,b=0};
npcentry.right = "";
if (nd.c) then
npcentry.right = npcentry.right..nd.c;
end
if (nd.ll and nd.lm) then
if (nd.ll==nd.lm) then
npcentry.right = npcentry.right.." lv "..nd.ll;
else
npcentry.right = npcentry.right.." lv "..nd.ll.."-"..nd.lm;
end
npcentry.rightColor=GetDifficultyColor(nd.ll);
else
npcentry.right = npcentry.right.." 等级未知";
end
npcentry.onClick = gLimQuestion_QuestNPCTree_OnClick;
local tltip="|cFFFFFF00月光任务查询(任务物品获得)|r\n|cFF00FF00"..objtext.."|r\n|cFFFF0000"..nd.n.."|r\n"..z.."\n";
local poscount = 0;
for k,v in nd.pos do
if (poscount==5) then
poscount = 0;
tltip = tltip.."\n";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -