Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

TurnIn.lua 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  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. TI_TempNPCList = {};
  59. function TI_message(...)
  60. local x = {...};
  61. for k,v in pairs(x) do
  62. DEFAULT_CHAT_FRAME:AddMessage(tostring(v));
  63. end
  64. end
  65. function TI_debug(...)
  66. if(TI_status.debugstate) then
  67. TI_message(...)
  68. end
  69. end
  70. function TI_OnLoad()
  71. SlashCmdList["TI"]=TI_SlashCmdHandler;
  72. SLASH_TI1="/turnin";
  73. SLASH_TI2="/ti";
  74. tinsert(UISpecialFrames,"TI_OptionsFrame");
  75. TI_message("Turn In loaded");
  76. TI_slashtable = {};
  77. TI_gossipopts = {};
  78. TI_gossipclosed = false;
  79. TurnIn:RegisterEvent("VARIABLES_LOADED");
  80. TI_activenumber = 1;
  81. TI_availnumber = 1;
  82. TI_specnum = 0;
  83. StaticPopupDialogs["TI_NPCINQUESTION"] = {
  84. 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.)",
  85. button1 = "Yes",
  86. button2 = "No",
  87. OnAccept = function()
  88. TI_AddNPCToList(TI_NPCInQuestion.list, TI_NPCInQuestion.name, true);
  89. end,
  90. timeout=0,
  91. whileDead = 1,
  92. hideOnEscape = 1
  93. };
  94. end
  95. function TI_VarInit()
  96. if(not TI_status or TI_status.version ~= TI_VersionString) then
  97. TI_status = TI_copyTable(TI_DefaultStatus);
  98. TI_OptionsInit();
  99. end
  100. if(not TI_status.options or #TI_status.options == 0) then
  101. TI_OptionsInit();
  102. end
  103. if(not TI_NPCDB) then
  104. TI_NPCDB = {};
  105. end
  106. if(not TI_NPCIndex) then
  107. TI_NPCIndexGenerate();
  108. end
  109. TI_PopulateOptions("vars loaded");
  110. end
  111. function TI_OptionsInit()
  112. TI_status.options = {};
  113. for k,v in pairs(TI_GossipDefaults) do
  114. local temp = {};
  115. temp.name = v;
  116. temp.type = k;
  117. temp.state = false;
  118. table.insert(TI_status.options, temp);
  119. end
  120. end
  121. function TI_NPCIndexGenerate()
  122. TI_NPCIndex = {};
  123. for k,v in pairs(TI_NPCDB) do
  124. table.insert(TI_NPCIndex, k);
  125. end
  126. table.sort(TI_NPCIndex);
  127. end
  128. function TI_LoadEvents()
  129. for k,v in pairs(TI_events) do
  130. TurnIn:RegisterEvent(v);
  131. end
  132. end
  133. function TI_ResetPointers()
  134. TI_activenumber = 1;
  135. TI_availnumber = 1;
  136. TI_specnum = 0;
  137. end
  138. function TI_UnloadEvents()
  139. for k,v in pairs(TI_events) do
  140. TurnIn:UnregisterEvent(v);
  141. end
  142. end
  143. function TI_Switch(state)
  144. if(state=="on") then
  145. TI_status.state = true;
  146. TI_LoadEvents();
  147. TI_message("Turn In On");
  148. elseif(state=="off") then
  149. TI_ResetPointers();
  150. TI_status.state = false;
  151. TI_UnloadEvents();
  152. TI_message("Turn In Off");
  153. elseif(state=="toggle") then
  154. if(TI_status.state) then
  155. TI_Switch("off");
  156. else
  157. TI_Switch("on");
  158. end
  159. end
  160. TI_StatusIndicatorUpdate();
  161. end
  162. function TI_SlashCmdHandler(cmd)
  163. cmdlist = {strsplit(" ", cmd)};
  164. local commands = {
  165. on = function ()
  166. TI_Switch("on");
  167. end,
  168. off = function ()
  169. TI_Switch("off");
  170. end,
  171. toggle = function ()
  172. TI_Switch("toggle");
  173. end,
  174. status = function ()
  175. if(TI_status.state) then
  176. TI_message("Turn In On");
  177. else
  178. TI_message("Turn In Off");
  179. end
  180. end,
  181. window = function ()
  182. TI_OptionsFrame:Show();
  183. end,
  184. config = function ()
  185. TI_OptionsFrame:Show();
  186. end,
  187. recent = function ()
  188. TI_TempNPCListWindow:Show();
  189. end,
  190. debug = function ()
  191. if(TI_status.debugstate) then
  192. TI_status.debugstate = false;
  193. TI_message("debug mode off");
  194. else
  195. TI_status.debugstate = true;
  196. TI_message("debug mode on");
  197. end
  198. end
  199. };
  200. if(commands[cmdlist[1]]) then
  201. commands[cmdlist[1]](cmdlist[2], cmdlist[3], cmdlist[4]);
  202. else
  203. 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");
  204. end
  205. end
  206. function TI_IsNPCOn(npcname, type)
  207. local opton = false;
  208. if(type ~= nil) then
  209. for k,v in pairs(TI_status.options) do
  210. if(v.type == type and v.state == true) then
  211. opton = true;
  212. end
  213. end
  214. else
  215. opton = true;
  216. end
  217. if(TI_NPCDB[npcname] == nil and TI_status.usedefault == true and opton == true) then
  218. TI_debug("case 1");
  219. return true;
  220. elseif(TI_NPCDB[npcname] ~= nil and TI_NPCDB[npcname].state) then
  221. TI_debug("case 2");
  222. return true;
  223. elseif(TI_NPCDB[npcname] ~= nil and TI_status.usedefault == true and not TI_NPCDB[npcname].state and opton == true) then
  224. TI_debug("case 4");
  225. return true;
  226. else
  227. TI_debug("case 3");
  228. return false;
  229. end
  230. end
  231. function TI_OnEvent(self, event, ...)
  232. if(event == "VARIABLES_LOADED") then
  233. TI_VarInit();
  234. if(TI_status.state) then
  235. TI_LoadEvents();
  236. end
  237. end
  238. if(TI_status.state and not IsShiftKeyDown()) then
  239. if(event == "QUEST_GREETING") then
  240. TI_debug("Quest Greeting");
  241. TI_lastquestframe = "greeting";
  242. if(QuestFrame:IsVisible()) then
  243. if(TI_gossipclosed) then
  244. TI_debug("resetting pointers");
  245. TI_gossipclosed = false;
  246. TI_ResetPointers();
  247. end
  248. TI_HandleGossipWindow("q");
  249. end
  250. end
  251. if(event == "GOSSIP_SHOW") then
  252. TI_debug("Gossip Show");
  253. if(GossipFrame:IsVisible()) then
  254. if(TI_gossipclosed) then
  255. TI_debug("resetting pointers");
  256. TI_gossipclosed = false;
  257. TI_ResetPointers();
  258. end
  259. TI_HandleGossipWindow("g");
  260. end
  261. end
  262. if(event == "GOSSIP_CLOSED") then
  263. TI_debug("Gossip Closed");
  264. if(not GossipFrame:IsVisible()) then
  265. TI_gossipclosed = true;
  266. end;
  267. end
  268. if(event == "QUEST_COMPLETE") then
  269. TI_debug("Quest Complete");
  270. if(TI_IsNPCOn(UnitName("npc"), "activequest")) then
  271. if(not (GetNumQuestChoices() > 1)) then
  272. GetQuestReward(1);
  273. end
  274. end
  275. TI_ResetPointers();
  276. end
  277. if(event == "QUEST_PROGRESS") then
  278. TI_debug("Quest Progress");
  279. TI_gossipclosed = false;
  280. TI_lastquestframe = "progress";
  281. TI_HandleQuestProgress();
  282. end
  283. if(event == "QUEST_DETAIL") then
  284. TI_debug("Quest Detail");
  285. TI_gossipclosed = false;
  286. if(TI_IsNPCOn(UnitName("npc"), "availquest")) then
  287. TI_HandleAcceptQuest();
  288. end
  289. TI_ResetPointers();
  290. end
  291. if(event == "QUEST_FINISHED") then
  292. TI_debug("Quest Finished");
  293. if(not QuestFrame:IsVisible() and TI_lastquestframe == "greeting") then
  294. TI_debug("looks like the quest frame closed, resetting pointers on next open");
  295. TI_gossipclosed = true;
  296. end
  297. end
  298. end
  299. end
  300. function TI_HandleAcceptQuest()
  301. --QuestInfoFadingFrame_OnUpdate(QuestInfoFadingFrame, 1); -- does not exist anymore in 6.0
  302. QuestDetailAcceptButton_OnClick();
  303. end
  304. function TI_HandleQuestProgress()
  305. local questname = GetTitleText();
  306. local npcname = UnitName("npc");
  307. if(QuestFrame:IsVisible()) then
  308. if(TI_NPCDB[npcname]) then
  309. local thisnpc = TI_NPCDB[npcname];
  310. if(thisnpc.state) then
  311. for i,current in ipairs(thisnpc) do
  312. if(current.name == questname and current.state) then
  313. TI_CompleteQuest();
  314. end
  315. end
  316. else
  317. if(TI_IsNPCOn(UnitName("npc"), "activequest")) then
  318. TI_CompleteQuest();
  319. end
  320. end
  321. else
  322. if(TI_IsNPCOn(UnitName("npc"), "activequest")) then
  323. TI_CompleteQuest();
  324. end
  325. end
  326. end
  327. end
  328. function TI_CompleteQuest()
  329. if(IsQuestCompletable()) then
  330. TI_debug("quest is completable, completeing");
  331. CompleteQuest();
  332. TI_ResetPointers();
  333. else
  334. TI_debug("quest is not completable, declining");
  335. QuestDetailDeclineButton_OnClick();
  336. end
  337. end
  338. function TI_GetQuests(type)
  339. local numQuests = (getglobal("GetNum"..type.."Quests"))();
  340. local qfn = getglobal("Get"..type.."Title");
  341. local ret = {};
  342. local qname;
  343. local i=1;
  344. for i=1,numQuests do
  345. qname = qfn(i);
  346. ret[i] = {name=qname};
  347. end
  348. return ret;
  349. end
  350. function TI_HandleGossipWindow(gorq)
  351. local SAcQ;
  352. local SAvQ;
  353. local AvailableQuests;
  354. local ActiveQuests;
  355. local GossipOptions;
  356. if(gorq == "g") then
  357. AvailableQuests = TI_FunctionList.g.tabulateAvailable(TI_FunctionList.g.getavailquests());
  358. ActiveQuests = TI_FunctionList.g.tabulateActive(TI_FunctionList.g.getactivequests());
  359. GossipOptions = TI_FunctionList.g.tabulateOptions(TI_FunctionList.g.getoptions());
  360. SAcQ = TI_FunctionList.g.activequest;
  361. SAvQ = TI_FunctionList.g.availquest;
  362. elseif(gorq == "q") then
  363. AvailableQuests = TI_GetQuests("Available");
  364. ActiveQuests = TI_GetQuests("Active");
  365. GossipOptions = {};
  366. SAcQ=TI_FunctionList.q.activequest;
  367. SAvQ=TI_FunctionList.q.availquest;
  368. end
  369. local ListEntry = {};
  370. for i,v in ipairs(AvailableQuests) do
  371. local x={};
  372. x.name = v.name;
  373. x.gorq = gorq;
  374. x.args = i;
  375. x.type = "availquest";
  376. x.icon = v.icon;
  377. x.state = false;
  378. table.insert(ListEntry, x);
  379. end
  380. for i,v in ipairs(ActiveQuests) do
  381. local x={};
  382. x.name = v.name;
  383. x.gorq = gorq;
  384. x.args = i;
  385. x.type = "activequest";
  386. x.icon = v.icon;
  387. x.state = false;
  388. table.insert(ListEntry, x);
  389. end
  390. for i,v in ipairs(GossipOptions) do
  391. local x={};
  392. x.name = v.name;
  393. x.gorq = gorq;
  394. x.args = i;
  395. x.type = v.type;
  396. x.state = false;
  397. table.insert(ListEntry, x);
  398. end
  399. ListEntry.state = false;
  400. local TotalOptions = #AvailableQuests+#ActiveQuests+#GossipOptions;
  401. --if(TI_activenumber > ActiveQuests.getn()) TI_activenumber = 1;
  402. if(TotalOptions < 1) then
  403. return;
  404. end
  405. local npcname = UnitName("npc");
  406. TI_AddNPCToTempList(npcname, ListEntry);
  407. if(TI_status.autoadd and (not TI_NPCDB[npcname])) then
  408. TI_debug("autoadd on, adding this NPC", TI_status.autoadd, TI_NPCDB[npcname]);
  409. TI_AddNPCToList(ListEntry, npcname);
  410. end
  411. -- If a NPC is in the Database but a new dialog option has appeared (new daily/completed quest) then add it to the DB
  412. if (TI_NPCDB[npcname]) then
  413. for k1, v1 in ipairs(ListEntry) do
  414. local found = false;
  415. for k2, v2 in ipairs(TI_NPCDB[npcname]) do
  416. if (v2.type == v1.type and v2.name == v1.name) then
  417. found = true;
  418. end
  419. end
  420. if (not found) then
  421. table.insert(TI_NPCDB[npcname], v1)
  422. TI_PopulateOptions("npclist updated");
  423. end
  424. end
  425. end
  426. if(TI_availnumber > TotalOptions or TI_activenumber > TotalOptions) then
  427. TI_ResetPointers();
  428. return;
  429. end
  430. TI_debug(npcname);
  431. if(TI_NPCDB[npcname]) then
  432. local thisnpc = TI_NPCDB[npcname];
  433. if(thisnpc.state) then
  434. TI_debug("npc is active, using his options");
  435. for i1,current in ipairs(thisnpc) do
  436. if (current.state == true) then
  437. TI_debug("Current Quest: "..current.name);
  438. if (TI_specnum == 0 or i1 > TI_specnum) then
  439. TI_specnum = i1;
  440. if (current.type == "availquest") then
  441. for i2,v2 in ipairs(AvailableQuests) do
  442. if (v2.name == current.name) then
  443. TI_debug(i1.."-Available Match Found: "..current.name);
  444. TI_FunctionList[current.gorq]["availquest"](i2);
  445. return;
  446. end
  447. end
  448. elseif (current.type == "activequest") then
  449. for i2,v2 in ipairs(ActiveQuests) do
  450. if (v2.name == current.name) then
  451. TI_debug(i1.."-Active Match Found: "..current.name..", "..current.type);
  452. TI_FunctionList[current.gorq]["activequest"](i2);
  453. return;
  454. end
  455. end
  456. else
  457. for i2,v2 in ipairs(GossipOptions) do
  458. if (v2.name == current.name) then
  459. TI_debug(i1.."-Gossip Match Found: "..current.name..", "..current.type);
  460. TI_FunctionList.g.default(i2);
  461. return;
  462. end
  463. end
  464. end
  465. end
  466. end
  467. end
  468. return;
  469. else
  470. TI_debug("npc in list, but not active");
  471. end
  472. else
  473. TI_debug("npc not in list");
  474. end
  475. if(TI_status.usedefault == false) then
  476. TI_debug("npc not in list, default set to off, returning.");
  477. return;
  478. end;
  479. TI_debug("using default config");
  480. for i,current in ipairs(TI_status.options) do
  481. if(current.state) then
  482. if(current.type == "availquest" and #AvailableQuests > 0 and TI_availnumber <= #AvailableQuests) then
  483. TI_availnumber = TI_availnumber + 1;
  484. SAvQ(TI_availnumber-1);
  485. TI_debug("Selecting Available Quest ".. TI_availnumber-1);
  486. TI_ResetPointers();
  487. return;
  488. elseif(current.type == "activequest" and #ActiveQuests > 0 and TI_activenumber <= #ActiveQuests) then
  489. while TI_activenumber <= #ActiveQuests do
  490. TI_activenumber = TI_activenumber + 1;
  491. if ActiveQuests[TI_activenumber-1].isComplete then
  492. TI_debug("Selecting Active Quest ".. TI_activenumber-1 .. " " .. ActiveQuests[TI_activenumber-1].name );
  493. SAcQ(TI_activenumber-1);
  494. TI_ResetPointers();
  495. return;
  496. else
  497. TI_debug("Active Quest ".. TI_activenumber-1 .. " " .. ActiveQuests[TI_activenumber-1].name .. " is not complete")
  498. end
  499. end
  500. elseif(#GossipOptions > 0) then
  501. for j,val in ipairs(GossipOptions) do
  502. if(val.type == current.type) then
  503. TI_ResetPointers();
  504. TI_FunctionList.g.default(j);
  505. return;
  506. end
  507. end
  508. end
  509. end
  510. end
  511. end
  512. function TI_AddNPCToList(OptList, npcname, confirminquestion)
  513. if (npcname == nil) then
  514. npcname = UnitName("npc");
  515. end
  516. if(#OptList > 0) then
  517. if(TI_NPCDB[npcname] == nil) then
  518. TI_NPCDB[npcname] = TI_copyTable(OptList);
  519. table.insert(TI_NPCIndex, npcname);
  520. table.sort(TI_NPCIndex);
  521. TI_PopulateOptions("npclist updated");
  522. elseif(confirminquestion == true) then
  523. TI_NPCDB[npcname] = TI_copyTable(OptList);
  524. TI_PopulateOptions("npclist updated");
  525. else
  526. TI_NPCInQuestion = {name=npcname, list=OptList};
  527. StaticPopup_Show("TI_NPCINQUESTION", npcname);
  528. end
  529. end
  530. end
  531. function TI_AddNPCToTempList(name, list)
  532. local temp = {};
  533. temp.name = name;
  534. temp.list = list;
  535. local subZone = GetSubZoneText();
  536. local realZone = GetRealZoneText();
  537. if(subZone == "") then
  538. temp.location = realZone;
  539. else
  540. temp.location = subZone .. ", " .. realZone;
  541. end
  542. table.insert(TI_TempNPCList, 1, temp);
  543. if(#TI_TempNPCList > TI_TempNPCListMaxSize) then
  544. table.remove(TI_TempNPCList, TI_TempNPCListMaxSize);
  545. end
  546. TI_TempNPCListUpdate();
  547. end
  548. function TI_DeleteTempNPCIndex(index)
  549. table.remove(TI_TempNPCList, index);
  550. TI_TempNPCListUpdate();
  551. end
  552. function TI_AddTempNPCIndex(index)
  553. TI_AddNPCToList(TI_TempNPCList[index].list, TI_TempNPCList[index].name);
  554. end
  555. function TI_DeleteNPC(index)
  556. local name = TI_NPCIndex[index];
  557. table.remove(TI_NPCIndex, index);
  558. TI_NPCDB[name] = nil;
  559. end
  560. function TI_StripDescriptors(...)
  561. local x = {};
  562. local arg = {...};
  563. for i=1, #arg, 2 do
  564. table.insert(x,arg[i]);
  565. end
  566. return x;
  567. end
  568. function TI_TabulateGossipOptions_Classic(...)
  569. local x = {};
  570. local arg = {...};
  571. for i=1, #arg, 2 do
  572. local temp = {};
  573. temp.name = arg[i];
  574. temp.type = arg[i+1];
  575. table.insert(x, temp);
  576. end
  577. return x;
  578. end
  579. function TI_TabulateGossipQuestUIInfo_Retail(gquis)
  580. local x = {};
  581. for i,gqui in ipairs(gquis) do
  582. local temp = {};
  583. temp.name = gqui.title;
  584. temp.icon = QuestUtil.GetQuestIconActive(gqui.isComplete, gqui.isLegendary,
  585. gqui.frequency, gqui.isRepeatable, gqui.isCampaign, gqui.isCovenantCalling);
  586. temp.isComplete = gqui.isComplete;
  587. table.insert(x, temp);
  588. end
  589. return x;
  590. end
  591. function TI_TabulateGossipUIInfo_Retail(guis)
  592. local x = {};
  593. for i,gui in ipairs(guis) do
  594. local temp = {};
  595. temp.name = gui.name;
  596. if gui.type == "chatbubble" then
  597. gui.type = "gossip"
  598. end
  599. temp.type = gui.type;
  600. table.insert(x, temp);
  601. end
  602. return x;
  603. end
  604. function TI_TabulateGossipAvailableQuests_Classic(...)
  605. local x = {};
  606. for i=1, select("#", ...), 7 do
  607. local temp = {};
  608. temp.name = select(i, ...);
  609. local isTrivial = select(i+2, ...);
  610. local isDaily = select(i+3, ...);
  611. local isRepeatable = select(i+4, ...);
  612. local isLegendary = select(i+5, ...);
  613. local isIgnored = select(i+6, ...);
  614. if ( isDaily ) then
  615. temp.icon = "Interface\\GossipFrame\\DailyQuestIcon";
  616. elseif ( isRepeatable ) then
  617. temp.icon = "Interface\\GossipFrame\\DailyActiveQuestIcon";
  618. elseif ( isLegendary ) then
  619. temp.icon = "Interface\\GossipFrame\\AvailableLegendaryQuestIcon";
  620. else
  621. temp.icon = "Interface\\GossipFrame\\AvailableQuestIcon";
  622. end
  623. table.insert(x, temp);
  624. end
  625. return x;
  626. end
  627. function TI_TabulateGossipActiveQuests_Classic(...)
  628. local x = {};
  629. for i=1, select("#", ...), 6 do
  630. local temp = {};
  631. temp.name = select(i, ...);
  632. local isComplete = select(i+3, ...);
  633. temp.isComplete = isComplete;
  634. local isLegendary = select(i+4, ...);
  635. if(isComplete) then
  636. if(isLegendary) then
  637. temp.icon = "Interface\\GossipFrame\\ActiveLegendaryQuestIcon";
  638. else
  639. temp.icon = "Interface\\GossipFrame\\ActiveQuestIcon";
  640. end
  641. else
  642. temp.icon = "Interface\\GossipFrame\\IncompleteQuestIcon";
  643. end
  644. table.insert(x, temp);
  645. end
  646. return x;
  647. end
  648. -- set up functions by release type
  649. if (TI_IsRetail()) then
  650. TI_FunctionList = {
  651. g = {
  652. availquest = C_GossipInfo.SelectAvailableQuest,
  653. activequest = C_GossipInfo.SelectActiveQuest,
  654. default = C_GossipInfo.SelectOption,
  655. getavailquests = C_GossipInfo.GetAvailableQuests,
  656. getactivequests = C_GossipInfo.GetActiveQuests,
  657. getoptions = C_GossipInfo.GetOptions,
  658. tabulateAvailable = TI_TabulateGossipQuestUIInfo_Retail,
  659. tabulateActive = TI_TabulateGossipQuestUIInfo_Retail,
  660. tabulateOptions = TI_TabulateGossipUIInfo_Retail,
  661. },
  662. q = {
  663. activequest = C_GossipInfo.SelectActiveQuest,
  664. availquest = C_GossipInfo.SelectAvailableQuest,
  665. }
  666. };
  667. else
  668. TI_FunctionList = {
  669. g = {
  670. availquest = SelectGossipAvailableQuest,
  671. activequest = SelectGossipActiveQuest,
  672. default = SelectGossipOption,
  673. getavailquests = GetGossipAvailableQuests,
  674. getactivequests = GetGossipActiveQuests,
  675. getoptions = GetGossipOptions,
  676. tabulateAvailable = TI_TabulateGossipAvailableQuests_Classic,
  677. tabulateActive = TI_TabulateGossipActiveQuests_Classic,
  678. tabulateOptions = TI_TabulateGossipOptions_Classic,
  679. },
  680. q = {
  681. activequest = SelectActiveQuest,
  682. availquest = SelectAvailableQuest,
  683. }
  684. };
  685. end
  686. --[[this function stolen from WhisperCast by Sarris, whom I love dearly for his contribution to Paladins everywhere.
  687. ]]
  688. function TI_copyTable( src )
  689. local copy = {}
  690. for k1,v1 in pairs(src) do
  691. if ( type(v1) == "table" ) then
  692. copy[k1]=TI_copyTable(v1)
  693. else
  694. copy[k1]=v1
  695. end
  696. end
  697. return copy
  698. end
  699. function toggle(arg)
  700. if(arg) then
  701. return false;
  702. else
  703. return true;
  704. end
  705. end