您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850
  1. --[[
  2. Turn-In Mod
  3. version 2.1
  4. Authored by Ian Friedman
  5. Sabindeus of Smolderthorn (Alliance)
  6. The repeatable quest turn in automating machine.
  7. Thanks to Arcanemagus of Hyjal for extra bug fixes and coding input
  8. ]]
  9. -- WOW Version detection
  10. local function TI_IsRetail()
  11. if WOW_PROJECT_ID == WOW_PROJECT_MAINLINE then
  12. return true;
  13. else
  14. return false;
  15. end
  16. end
  17. TI_VersionString = "2.0";
  18. local TI_slashtable;
  19. TI_gossipclosed = false;
  20. TI_LoadedNPCIndex = 0;
  21. TI_activenumber = 1;
  22. TI_availnumber = 1;
  23. TI_specnum = 0;
  24. TI_gossipopts = {};
  25. TI_TempNPCList = {};
  26. TI_TempNPCListMaxSize = 5;
  27. TI_NPCInQuestion = nil;
  28. local TI_GossipDefaults = {
  29. availquest ="Available Quests",
  30. activequest = "Active Quests",
  31. gossip = "Gossip",
  32. vendor = "Vendor",
  33. taxi = "Taxi",
  34. trainer = "Trainer",
  35. battlemaster = "Battlemaster",
  36. binder = "Hearthstone Binder",
  37. healer = "Spirit Healer",
  38. banker = "Bank"
  39. };
  40. TI_FunctionList = {};
  41. local TI_DefaultStatus = {
  42. state = false,
  43. version = TI_VersionString,
  44. options = {},
  45. debugstate = false,
  46. usedefault=true,
  47. autoadd=false
  48. };
  49. local TI_events = {
  50. "GOSSIP_SHOW",
  51. "GOSSIP_CLOSED",
  52. "QUEST_DETAIL",
  53. "QUEST_COMPLETE",
  54. "QUEST_PROGRESS",
  55. "QUEST_GREETING",
  56. "QUEST_FINISHED"
  57. };
  58. local TI_GossipIconNameToId = {
  59. ["activequesticon"] = 132048,
  60. ["availablequesticon"] = 132049,
  61. ["banker"] = 132050,
  62. ["battlemaster"] = 132051,
  63. ["binder"] = 132052,
  64. ["gossip"] = 132053,
  65. ["healer"] = 132054,
  66. ["petition"] = 132055,
  67. ["tabard"] = 132056,
  68. ["taxi"] = 132057,
  69. ["trainer"] = 132058,
  70. ["unlearn"] = 132059,
  71. ["vendor"] = 132060,
  72. ["incompletequest"] = 365195,
  73. ["dailyquest"] = 368364,
  74. ["dailyactivequest"] = 368577,
  75. ["auctioneer"] = 528409,
  76. ["activelegendaryquest"] = 646979,
  77. ["availablelegendaryquest"] = 646980,
  78. ["chatbubble"] = 1019848,
  79. ["workorder"] = 1130518,
  80. ["transmogrify"] = 1673939,
  81. ["campaignactivequest"] = 3532316,
  82. ["campaignavailablequest"] = 3532317,
  83. ["campaignincompletequest"] = 3532318,
  84. ["campaigngossipicons"] = 3595324,
  85. }
  86. local function TI_InvertDictionary(input)
  87. local s={}
  88. for k,v in pairs(input) do
  89. s[v]=k
  90. end
  91. return s
  92. end
  93. local TI_GossipIconIdToName = TI_InvertDictionary(TI_GossipIconNameToId)
  94. local function TI_TranslateIconToType(iconId)
  95. return TI_GossipIconIdToName[iconId]
  96. end
  97. TI_TempNPCList = {};
  98. function TI_message(...)
  99. local x = {...};
  100. for k,v in pairs(x) do
  101. DEFAULT_CHAT_FRAME:AddMessage(tostring(v));
  102. end
  103. end
  104. function TI_debug(...)
  105. if(TI_status.debugstate) then
  106. LoadAddOn("Blizzard_DebugTools")
  107. local x = {...};
  108. for k,v in pairs(x) do
  109. if type(v) == "table" and DevTools_Dump then
  110. DevTools_Dump(v)
  111. else
  112. DEFAULT_CHAT_FRAME:AddMessage(tostring(v));
  113. end
  114. end
  115. end
  116. end
  117. function TI_OnLoad()
  118. SlashCmdList["TI"]=TI_SlashCmdHandler;
  119. SLASH_TI1="/turnin";
  120. SLASH_TI2="/ti";
  121. tinsert(UISpecialFrames,"TI_OptionsFrame");
  122. TI_message("Turn In loaded");
  123. TI_slashtable = {};
  124. TI_gossipopts = {};
  125. TI_gossipclosed = false;
  126. TurnIn:RegisterEvent("VARIABLES_LOADED");
  127. TI_activenumber = 1;
  128. TI_availnumber = 1;
  129. TI_specnum = 0;
  130. StaticPopupDialogs["TI_NPCINQUESTION"] = {
  131. text = "The NPC %s is already in your NPC Database. Do you wish to replace his gossip options with the current ones? (Note: This will overwrite your settings for this NPC.)",
  132. button1 = "Yes",
  133. button2 = "No",
  134. OnAccept = function()
  135. TI_AddNPCToList(TI_NPCInQuestion.list, TI_NPCInQuestion.name, true);
  136. end,
  137. timeout=0,
  138. whileDead = 1,
  139. hideOnEscape = 1
  140. };
  141. end
  142. function TI_VarInit()
  143. if(not TI_status or TI_status.version ~= TI_VersionString) then
  144. TI_status = TI_copyTable(TI_DefaultStatus);
  145. TI_OptionsInit();
  146. end
  147. if(not TI_status.options or #TI_status.options == 0) then
  148. TI_OptionsInit();
  149. end
  150. if(not TI_NPCDB) then
  151. TI_NPCDB = {};
  152. end
  153. if(not TI_NPCIndex) then
  154. TI_NPCIndexGenerate();
  155. end
  156. TI_PopulateOptions("vars loaded");
  157. end
  158. function TI_OptionsInit()
  159. TI_status.options = {};
  160. for k,v in pairs(TI_GossipDefaults) do
  161. local temp = {};
  162. temp.name = v;
  163. temp.type = k;
  164. temp.state = false;
  165. table.insert(TI_status.options, temp);
  166. end
  167. end
  168. function TI_NPCIndexGenerate()
  169. TI_NPCIndex = {};
  170. for k,v in pairs(TI_NPCDB) do
  171. table.insert(TI_NPCIndex, k);
  172. end
  173. table.sort(TI_NPCIndex);
  174. end
  175. function TI_LoadEvents()
  176. for k,v in pairs(TI_events) do
  177. TurnIn:RegisterEvent(v);
  178. end
  179. end
  180. function TI_ResetPointers()
  181. TI_activenumber = 1;
  182. TI_availnumber = 1;
  183. TI_specnum = 0;
  184. end
  185. function TI_UnloadEvents()
  186. for k,v in pairs(TI_events) do
  187. TurnIn:UnregisterEvent(v);
  188. end
  189. end
  190. function TI_Switch(state)
  191. if(state=="on") then
  192. TI_status.state = true;
  193. TI_LoadEvents();
  194. TI_message("Turn In On");
  195. elseif(state=="off") then
  196. TI_ResetPointers();
  197. TI_status.state = false;
  198. TI_UnloadEvents();
  199. TI_message("Turn In Off");
  200. elseif(state=="toggle") then
  201. if(TI_status.state) then
  202. TI_Switch("off");
  203. else
  204. TI_Switch("on");
  205. end
  206. end
  207. TI_StatusIndicatorUpdate();
  208. end
  209. function TI_SlashCmdHandler(cmd)
  210. cmdlist = {strsplit(" ", cmd)};
  211. local commands = {
  212. on = function ()
  213. TI_Switch("on");
  214. end,
  215. off = function ()
  216. TI_Switch("off");
  217. end,
  218. toggle = function ()
  219. TI_Switch("toggle");
  220. end,
  221. status = function ()
  222. if(TI_status.state) then
  223. TI_message("Turn In On");
  224. else
  225. TI_message("Turn In Off");
  226. end
  227. end,
  228. window = function ()
  229. TI_OptionsFrame:Show();
  230. end,
  231. config = function ()
  232. TI_OptionsFrame:Show();
  233. end,
  234. recent = function ()
  235. TI_TempNPCListWindow:Show();
  236. end,
  237. debug = function ()
  238. if(TI_status.debugstate) then
  239. TI_status.debugstate = false;
  240. TI_message("debug mode off");
  241. else
  242. TI_status.debugstate = true;
  243. TI_message("debug mode on");
  244. end
  245. end
  246. };
  247. if(commands[cmdlist[1]]) then
  248. commands[cmdlist[1]](cmdlist[2], cmdlist[3], cmdlist[4]);
  249. else
  250. TI_message("Turn In 2.1 Help", "--------------", "/ti on - turns Turn In on", "/ti off - turns Turn In off", "/ti toggle - toggles Turn In on or off", "/ti window - shows the options window", "/ti recent - shows the recently visited NPCs");
  251. end
  252. end
  253. function TI_IsNPCOn(npcname, type)
  254. local opton = false;
  255. if(type ~= nil) then
  256. for k,v in pairs(TI_status.options) do
  257. if(v.type == type and v.state == true) then
  258. opton = true;
  259. end
  260. end
  261. else
  262. opton = true;
  263. end
  264. if(TI_NPCDB[npcname] == nil and TI_status.usedefault == true and opton == true) then
  265. TI_debug("case 1");
  266. return true;
  267. elseif(TI_NPCDB[npcname] ~= nil and TI_NPCDB[npcname].state) then
  268. TI_debug("case 2");
  269. return true;
  270. elseif(TI_NPCDB[npcname] ~= nil and TI_status.usedefault == true and not TI_NPCDB[npcname].state and opton == true) then
  271. TI_debug("case 4");
  272. return true;
  273. else
  274. TI_debug("case 3");
  275. return false;
  276. end
  277. end
  278. function TI_OnEvent(self, event, ...)
  279. if(event == "VARIABLES_LOADED") then
  280. TI_VarInit();
  281. if(TI_status.state) then
  282. TI_LoadEvents();
  283. end
  284. end
  285. if(TI_status.state and not IsShiftKeyDown()) then
  286. if(event == "QUEST_GREETING") then
  287. TI_debug("Quest Greeting");
  288. TI_lastquestframe = "greeting";
  289. if(QuestFrame:IsVisible()) then
  290. if(TI_gossipclosed) then
  291. TI_debug("resetting pointers");
  292. TI_gossipclosed = false;
  293. TI_ResetPointers();
  294. end
  295. TI_HandleGossipWindow("q");
  296. end
  297. end
  298. if(event == "GOSSIP_SHOW") then
  299. TI_debug("Gossip Show");
  300. if(GossipFrame:IsVisible()) then
  301. if(TI_gossipclosed) then
  302. TI_debug("resetting pointers");
  303. TI_gossipclosed = false;
  304. TI_ResetPointers();
  305. end
  306. TI_HandleGossipWindow("g");
  307. end
  308. end
  309. if(event == "GOSSIP_CLOSED") then
  310. TI_debug("Gossip Closed");
  311. if(not GossipFrame:IsVisible()) then
  312. TI_gossipclosed = true;
  313. end;
  314. end
  315. if(event == "QUEST_COMPLETE") then
  316. TI_debug("Quest Complete");
  317. if(TI_IsNPCOn(UnitName("npc"), "activequest")) then
  318. if(not (GetNumQuestChoices() > 1)) then
  319. GetQuestReward(1);
  320. end
  321. end
  322. TI_ResetPointers();
  323. end
  324. if(event == "QUEST_PROGRESS") then
  325. TI_debug("Quest Progress");
  326. TI_gossipclosed = false;
  327. TI_lastquestframe = "progress";
  328. TI_HandleQuestProgress();
  329. end
  330. if(event == "QUEST_DETAIL") then
  331. TI_debug("Quest Detail");
  332. TI_gossipclosed = false;
  333. if(TI_IsNPCOn(UnitName("npc"), "availquest")) then
  334. TI_HandleAcceptQuest();
  335. end
  336. TI_ResetPointers();
  337. end
  338. if(event == "QUEST_FINISHED") then
  339. TI_debug("Quest Finished");
  340. if(not QuestFrame:IsVisible() and TI_lastquestframe == "greeting") then
  341. TI_debug("looks like the quest frame closed, resetting pointers on next open");
  342. TI_gossipclosed = true;
  343. end
  344. end
  345. end
  346. end
  347. function TI_HandleAcceptQuest()
  348. --QuestInfoFadingFrame_OnUpdate(QuestInfoFadingFrame, 1); -- does not exist anymore in 6.0
  349. QuestDetailAcceptButton_OnClick();
  350. end
  351. function TI_HandleQuestProgress()
  352. local questname = GetTitleText();
  353. local npcname = UnitName("npc");
  354. if(QuestFrame:IsVisible()) then
  355. if(TI_NPCDB[npcname]) then
  356. local thisnpc = TI_NPCDB[npcname];
  357. if(thisnpc.state) then
  358. for i,current in ipairs(thisnpc) do
  359. if(current.name == questname and current.state) then
  360. TI_CompleteQuest();
  361. end
  362. end
  363. else
  364. if(TI_IsNPCOn(UnitName("npc"), "activequest")) then
  365. TI_CompleteQuest();
  366. end
  367. end
  368. else
  369. if(TI_IsNPCOn(UnitName("npc"), "activequest")) then
  370. TI_CompleteQuest();
  371. end
  372. end
  373. end
  374. end
  375. function TI_CompleteQuest()
  376. if(IsQuestCompletable()) then
  377. TI_debug("quest is completable, completeing");
  378. CompleteQuest();
  379. TI_ResetPointers();
  380. else
  381. TI_debug("quest is not completable, declining");
  382. QuestDetailDeclineButton_OnClick();
  383. end
  384. end
  385. function TI_GetQuests(type)
  386. local numQuests = (getglobal("GetNum"..type.."Quests"))();
  387. local qfn = getglobal("Get"..type.."Title");
  388. local ret = {};
  389. local i=1;
  390. for i=1,numQuests do
  391. local qname, isComplete = qfn(i);
  392. ret[i] = {name=qname, questID=i, isComplete=isComplete};
  393. end
  394. return ret;
  395. end
  396. function TI_HandleGossipWindow(gorq)
  397. local SAcQ;
  398. local SAvQ;
  399. local AvailableQuests;
  400. local ActiveQuests;
  401. local GossipOptions;
  402. TI_debug(gorq);
  403. if(gorq == "g") then
  404. AvailableQuests = TI_FunctionList.g.tabulateAvailable(TI_FunctionList.g.getavailquests());
  405. ActiveQuests = TI_FunctionList.g.tabulateActive(TI_FunctionList.g.getactivequests());
  406. GossipOptions = TI_FunctionList.g.tabulateOptions(TI_FunctionList.g.getoptions());
  407. SAcQ = TI_FunctionList.g.activequest;
  408. SAvQ = TI_FunctionList.g.availquest;
  409. elseif(gorq == "q") then
  410. AvailableQuests = TI_GetQuests("Available");
  411. ActiveQuests = TI_GetQuests("Active");
  412. GossipOptions = {};
  413. SAcQ=TI_FunctionList.q.activequest;
  414. SAvQ=TI_FunctionList.q.availquest;
  415. end
  416. local ListEntry = {};
  417. for i,v in ipairs(AvailableQuests) do
  418. local x={};
  419. x.name = v.name;
  420. x.gorq = gorq;
  421. x.args = i;
  422. x.type = "availquest";
  423. x.icon = v.icon;
  424. x.state = false;
  425. table.insert(ListEntry, x);
  426. end
  427. for i,v in ipairs(ActiveQuests) do
  428. local x={};
  429. x.name = v.name;
  430. x.gorq = gorq;
  431. x.args = i;
  432. x.type = "activequest";
  433. x.icon = v.icon;
  434. x.state = false;
  435. table.insert(ListEntry, x);
  436. end
  437. for i,v in ipairs(GossipOptions) do
  438. local x={};
  439. x.name = v.name;
  440. x.gorq = gorq;
  441. if x.orderIndex then
  442. x.args = v.orderIndex;
  443. else
  444. x.args = i;
  445. end
  446. x.type = v.type;
  447. x.icon = v.icon;
  448. x.state = false;
  449. table.insert(ListEntry, x);
  450. end
  451. ListEntry.state = false;
  452. local TotalOptions = #AvailableQuests+#ActiveQuests+#GossipOptions;
  453. if(TotalOptions < 1) then
  454. return;
  455. end
  456. local npcname = UnitName("npc");
  457. TI_AddNPCToTempList(npcname, ListEntry);
  458. if(TI_status.autoadd and (not TI_NPCDB[npcname])) then
  459. TI_debug("autoadd on, adding this NPC", TI_status.autoadd, TI_NPCDB[npcname]);
  460. TI_AddNPCToList(ListEntry, npcname);
  461. end
  462. -- If a NPC is in the Database but a new dialog option has appeared (new daily/completed quest) then add it to the DB
  463. if (TI_NPCDB[npcname]) then
  464. for k1, v1 in ipairs(ListEntry) do
  465. local found = false;
  466. for k2, v2 in ipairs(TI_NPCDB[npcname]) do
  467. if (v2.type == v1.type and v2.name == v1.name) then
  468. found = true;
  469. end
  470. end
  471. if (not found) then
  472. table.insert(TI_NPCDB[npcname], v1)
  473. TI_PopulateOptions("npclist updated");
  474. end
  475. end
  476. end
  477. if(TI_availnumber > TotalOptions or TI_activenumber > TotalOptions) then
  478. TI_ResetPointers();
  479. return;
  480. end
  481. TI_debug(npcname);
  482. if(TI_NPCDB[npcname]) then
  483. local thisnpc = TI_NPCDB[npcname];
  484. if(thisnpc.state) then
  485. TI_debug("npc is active, using his options");
  486. for i1,current in ipairs(thisnpc) do
  487. if (current.state == true) then
  488. TI_debug("Current Quest: "..current.name);
  489. if (TI_specnum == 0 or i1 > TI_specnum) then
  490. TI_specnum = i1;
  491. if (current.type == "availquest") then
  492. for i2,v2 in ipairs(AvailableQuests) do
  493. if (v2.name == current.name) then
  494. TI_debug(i1.."-Available Match Found: "..current.name);
  495. SAvQ(v2.questID);
  496. return;
  497. end
  498. end
  499. elseif (current.type == "activequest") then
  500. for i2,v2 in ipairs(ActiveQuests) do
  501. if (v2.name == current.name) then
  502. TI_debug(i1.."-Active Match Found: "..current.name..", "..current.type);
  503. SAcQ(v2.questID);
  504. return;
  505. end
  506. end
  507. else
  508. for i2,v2 in ipairs(GossipOptions) do
  509. if (v2.name == current.name) then
  510. TI_debug(i1.."-Gossip Match Found: "..current.name..", "..current.type);
  511. TI_FunctionList.g.gossip(i2);
  512. return;
  513. end
  514. end
  515. end
  516. end
  517. end
  518. end
  519. return;
  520. else
  521. TI_debug("npc in list, but not active");
  522. end
  523. else
  524. TI_debug("npc not in list");
  525. end
  526. if(TI_status.usedefault == false) then
  527. TI_debug("npc not in list, default set to off, returning.");
  528. return;
  529. end;
  530. TI_debug("using default config");
  531. for i,current in ipairs(TI_status.options) do
  532. if(current.state) then
  533. if(current.type == "availquest" and #AvailableQuests > 0 and TI_availnumber <= #AvailableQuests) then
  534. SAvQ(AvailableQuests[TI_availnumber].questID);
  535. TI_debug("Selecting Available Quest ".. TI_availnumber);
  536. TI_ResetPointers();
  537. return;
  538. elseif(current.type == "activequest" and #ActiveQuests > 0 and TI_activenumber <= #ActiveQuests) then
  539. while TI_activenumber <= #ActiveQuests do
  540. if ActiveQuests[TI_activenumber].isComplete then
  541. TI_debug("Selecting Active Quest ".. TI_activenumber .. " " .. ActiveQuests[TI_activenumber].name );
  542. SAcQ(ActiveQuests[TI_activenumber].questID);
  543. TI_ResetPointers();
  544. return;
  545. else
  546. TI_debug("Active Quest ".. TI_activenumber .. " " .. ActiveQuests[TI_activenumber].name .. " is not complete")
  547. TI_activenumber = TI_activenumber + 1;
  548. end
  549. end
  550. elseif(#GossipOptions > 0) then
  551. for j,val in ipairs(GossipOptions) do
  552. if(val.type == current.type) then
  553. TI_ResetPointers();
  554. TI_FunctionList.g.gossip(j);
  555. return;
  556. end
  557. end
  558. end
  559. end
  560. end
  561. end
  562. function TI_AddNPCToList(OptList, npcname, confirminquestion)
  563. if (npcname == nil) then
  564. npcname = UnitName("npc");
  565. end
  566. if(#OptList > 0) then
  567. if(TI_NPCDB[npcname] == nil) then
  568. TI_NPCDB[npcname] = TI_copyTable(OptList);
  569. table.insert(TI_NPCIndex, npcname);
  570. table.sort(TI_NPCIndex);
  571. TI_PopulateOptions("npclist updated");
  572. elseif(confirminquestion == true) then
  573. TI_NPCDB[npcname] = TI_copyTable(OptList);
  574. TI_PopulateOptions("npclist updated");
  575. else
  576. TI_NPCInQuestion = {name=npcname, list=OptList};
  577. StaticPopup_Show("TI_NPCINQUESTION", npcname);
  578. end
  579. end
  580. end
  581. function TI_AddNPCToTempList(name, list)
  582. local temp = {};
  583. temp.name = name;
  584. temp.list = list;
  585. local subZone = GetSubZoneText();
  586. local realZone = GetRealZoneText();
  587. if(subZone == "") then
  588. temp.location = realZone;
  589. else
  590. temp.location = subZone .. ", " .. realZone;
  591. end
  592. table.insert(TI_TempNPCList, 1, temp);
  593. if(#TI_TempNPCList > TI_TempNPCListMaxSize) then
  594. table.remove(TI_TempNPCList, TI_TempNPCListMaxSize);
  595. end
  596. TI_TempNPCListUpdate();
  597. end
  598. function TI_DeleteTempNPCIndex(index)
  599. table.remove(TI_TempNPCList, index);
  600. TI_TempNPCListUpdate();
  601. end
  602. function TI_AddTempNPCIndex(index)
  603. TI_AddNPCToList(TI_TempNPCList[index].list, TI_TempNPCList[index].name);
  604. end
  605. function TI_DeleteNPC(index)
  606. local name = TI_NPCIndex[index];
  607. table.remove(TI_NPCIndex, index);
  608. TI_NPCDB[name] = nil;
  609. end
  610. function TI_StripDescriptors(...)
  611. local x = {};
  612. local arg = {...};
  613. for i=1, #arg, 2 do
  614. table.insert(x,arg[i]);
  615. end
  616. return x;
  617. end
  618. function TI_TabulateGossipOptions_Classic(...)
  619. local x = {};
  620. local arg = {...};
  621. for i=1, #arg, 2 do
  622. local temp = {};
  623. temp.name = arg[i];
  624. temp.type = arg[i+1];
  625. table.insert(x, temp);
  626. end
  627. return x;
  628. end
  629. function TI_TabulateGossipQuestUIInfo_Retail(gquis)
  630. local x = {};
  631. for i,gqui in ipairs(gquis) do
  632. local temp = {};
  633. temp.name = gqui.title;
  634. temp.icon = QuestUtil.GetQuestIconOffer(
  635. gqui.isLegendary,
  636. gqui.frequency,
  637. gqui.isRepeatable,
  638. false,
  639. false
  640. );
  641. temp.questID = gqui.questID;
  642. temp.isComplete = gqui.isComplete;
  643. table.insert(x, temp);
  644. end
  645. return x;
  646. end
  647. function TI_TabulateGossipUIInfo_Retail(guis)
  648. local x = {};
  649. table.sort(guis, GossipOptionSort);
  650. for i,gui in ipairs(guis) do
  651. local temp = {};
  652. temp.name = gui.name;
  653. local gossipType = TI_TranslateIconToType(gui.icon)
  654. if gossipType == "chatbubble" then
  655. gossipType = "gossip"
  656. end
  657. temp.type = gossipType;
  658. temp.icon = gui.icon;
  659. temp.gossipOptionID = gui.gossipOptionID
  660. temp.orderIndex = gui.orderIndex
  661. table.insert(x, temp);
  662. end
  663. return x;
  664. end
  665. function TI_TabulateGossipAvailableQuests_Classic(...)
  666. local x = {};
  667. local idx = 1;
  668. for i=1, select("#", ...), 7 do
  669. local temp = {};
  670. temp.name = select(i, ...);
  671. local isTrivial = select(i+2, ...);
  672. local isDaily = select(i+3, ...);
  673. local isRepeatable = select(i+4, ...);
  674. local isLegendary = select(i+5, ...);
  675. local isIgnored = select(i+6, ...);
  676. if ( isDaily ) then
  677. temp.icon = "Interface\\GossipFrame\\DailyQuestIcon";
  678. elseif ( isRepeatable ) then
  679. temp.icon = "Interface\\GossipFrame\\DailyActiveQuestIcon";
  680. elseif ( isLegendary ) then
  681. temp.icon = "Interface\\GossipFrame\\AvailableLegendaryQuestIcon";
  682. else
  683. temp.icon = "Interface\\GossipFrame\\AvailableQuestIcon";
  684. end
  685. temp.questID = idx;
  686. table.insert(x, temp);
  687. idx = idx + 1;
  688. end
  689. return x;
  690. end
  691. function TI_TabulateGossipActiveQuests_Classic(...)
  692. local x = {};
  693. local idx = 1;
  694. for i=1, select("#", ...), 6 do
  695. local temp = {};
  696. temp.name = select(i, ...);
  697. local isComplete = select(i+3, ...);
  698. temp.isComplete = isComplete;
  699. local isLegendary = select(i+4, ...);
  700. if(isComplete) then
  701. if(isLegendary) then
  702. temp.icon = "Interface\\GossipFrame\\ActiveLegendaryQuestIcon";
  703. else
  704. temp.icon = "Interface\\GossipFrame\\ActiveQuestIcon";
  705. end
  706. else
  707. temp.icon = "Interface\\GossipFrame\\IncompleteQuestIcon";
  708. end
  709. temp.questID = idx;
  710. table.insert(x, temp);
  711. idx = idx + 1;
  712. end
  713. return x;
  714. end
  715. -- set up functions by release type
  716. if (TI_IsRetail()) then
  717. TI_FunctionList = {
  718. g = {
  719. availquest = C_GossipInfo.SelectAvailableQuest,
  720. activequest = C_GossipInfo.SelectActiveQuest,
  721. gossip = SelectGossipOption,
  722. getavailquests = C_GossipInfo.GetAvailableQuests,
  723. getactivequests = C_GossipInfo.GetActiveQuests,
  724. getoptions = C_GossipInfo.GetOptions,
  725. tabulateAvailable = TI_TabulateGossipQuestUIInfo_Retail,
  726. tabulateActive = TI_TabulateGossipQuestUIInfo_Retail,
  727. tabulateOptions = TI_TabulateGossipUIInfo_Retail,
  728. },
  729. q = {
  730. activequest = SelectActiveQuest,
  731. availquest = SelectAvailableQuest,
  732. }
  733. };
  734. else
  735. TI_FunctionList = {
  736. g = {
  737. availquest = C_GossipInfo.SelectAvailableQuest,
  738. activequest = C_GossipInfo.SelectActiveQuest,
  739. gossip = SelectGossipOption,
  740. getavailquests = C_GossipInfo.GetAvailableQuests,
  741. getactivequests = C_GossipInfo.GetActiveQuests,
  742. getoptions = C_GossipInfo.GetOptions,
  743. tabulateAvailable = TI_TabulateGossipQuestUIInfo_Retail,
  744. tabulateActive = TI_TabulateGossipQuestUIInfo_Retail,
  745. tabulateOptions = TI_TabulateGossipUIInfo_Retail,
  746. },
  747. q = {
  748. activequest = SelectActiveQuest,
  749. availquest = SelectAvailableQuest,
  750. }
  751. };
  752. end
  753. --[[this function stolen from WhisperCast by Sarris, whom I love dearly for his contribution to Paladins everywhere.
  754. ]]
  755. function TI_copyTable( src )
  756. local copy = {}
  757. for k1,v1 in pairs(src) do
  758. if ( type(v1) == "table" ) then
  759. copy[k1]=TI_copyTable(v1)
  760. else
  761. copy[k1]=v1
  762. end
  763. end
  764. return copy
  765. end
  766. function toggle(arg)
  767. if(arg) then
  768. return false;
  769. else
  770. return true;
  771. end
  772. end