Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846
  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. x.args = i;
  442. x.type = v.type;
  443. x.icon = v.icon;
  444. x.state = false;
  445. table.insert(ListEntry, x);
  446. end
  447. ListEntry.state = false;
  448. local TotalOptions = #AvailableQuests+#ActiveQuests+#GossipOptions;
  449. if(TotalOptions < 1) then
  450. return;
  451. end
  452. local npcname = UnitName("npc");
  453. TI_AddNPCToTempList(npcname, ListEntry);
  454. if(TI_status.autoadd and (not TI_NPCDB[npcname])) then
  455. TI_debug("autoadd on, adding this NPC", TI_status.autoadd, TI_NPCDB[npcname]);
  456. TI_AddNPCToList(ListEntry, npcname);
  457. end
  458. -- If a NPC is in the Database but a new dialog option has appeared (new daily/completed quest) then add it to the DB
  459. if (TI_NPCDB[npcname]) then
  460. for k1, v1 in ipairs(ListEntry) do
  461. local found = false;
  462. for k2, v2 in ipairs(TI_NPCDB[npcname]) do
  463. if (v2.type == v1.type and v2.name == v1.name) then
  464. found = true;
  465. end
  466. end
  467. if (not found) then
  468. table.insert(TI_NPCDB[npcname], v1)
  469. TI_PopulateOptions("npclist updated");
  470. end
  471. end
  472. end
  473. if(TI_availnumber > TotalOptions or TI_activenumber > TotalOptions) then
  474. TI_ResetPointers();
  475. return;
  476. end
  477. TI_debug(npcname);
  478. if(TI_NPCDB[npcname]) then
  479. local thisnpc = TI_NPCDB[npcname];
  480. if(thisnpc.state) then
  481. TI_debug("npc is active, using his options");
  482. for i1,current in ipairs(thisnpc) do
  483. if (current.state == true) then
  484. TI_debug("Current Quest: "..current.name);
  485. if (TI_specnum == 0 or i1 > TI_specnum) then
  486. TI_specnum = i1;
  487. if (current.type == "availquest") then
  488. for i2,v2 in ipairs(AvailableQuests) do
  489. if (v2.name == current.name) then
  490. TI_debug(i1.."-Available Match Found: "..current.name);
  491. SAvQ(v2.questID);
  492. return;
  493. end
  494. end
  495. elseif (current.type == "activequest") then
  496. for i2,v2 in ipairs(ActiveQuests) do
  497. if (v2.name == current.name) then
  498. TI_debug(i1.."-Active Match Found: "..current.name..", "..current.type);
  499. SAcQ(v2.questID);
  500. return;
  501. end
  502. end
  503. else
  504. for i2,v2 in ipairs(GossipOptions) do
  505. if (v2.name == current.name) then
  506. TI_debug(i1.."-Gossip Match Found: "..current.name..", "..current.type);
  507. TI_FunctionList.g.gossip(i2);
  508. return;
  509. end
  510. end
  511. end
  512. end
  513. end
  514. end
  515. return;
  516. else
  517. TI_debug("npc in list, but not active");
  518. end
  519. else
  520. TI_debug("npc not in list");
  521. end
  522. if(TI_status.usedefault == false) then
  523. TI_debug("npc not in list, default set to off, returning.");
  524. return;
  525. end;
  526. TI_debug("using default config");
  527. for i,current in ipairs(TI_status.options) do
  528. if(current.state) then
  529. if(current.type == "availquest" and #AvailableQuests > 0 and TI_availnumber <= #AvailableQuests) then
  530. SAvQ(AvailableQuests[TI_availnumber].questID);
  531. TI_debug("Selecting Available Quest ".. TI_availnumber);
  532. TI_ResetPointers();
  533. return;
  534. elseif(current.type == "activequest" and #ActiveQuests > 0 and TI_activenumber <= #ActiveQuests) then
  535. while TI_activenumber <= #ActiveQuests do
  536. if ActiveQuests[TI_activenumber].isComplete then
  537. TI_debug("Selecting Active Quest ".. TI_activenumber .. " " .. ActiveQuests[TI_activenumber].name );
  538. SAcQ(ActiveQuests[TI_activenumber].questID);
  539. TI_ResetPointers();
  540. return;
  541. else
  542. TI_debug("Active Quest ".. TI_activenumber .. " " .. ActiveQuests[TI_activenumber].name .. " is not complete")
  543. TI_activenumber = TI_activenumber + 1;
  544. end
  545. end
  546. elseif(#GossipOptions > 0) then
  547. for j,val in ipairs(GossipOptions) do
  548. if(val.type == current.type) then
  549. TI_ResetPointers();
  550. TI_FunctionList.g.gossip(j);
  551. return;
  552. end
  553. end
  554. end
  555. end
  556. end
  557. end
  558. function TI_AddNPCToList(OptList, npcname, confirminquestion)
  559. if (npcname == nil) then
  560. npcname = UnitName("npc");
  561. end
  562. if(#OptList > 0) then
  563. if(TI_NPCDB[npcname] == nil) then
  564. TI_NPCDB[npcname] = TI_copyTable(OptList);
  565. table.insert(TI_NPCIndex, npcname);
  566. table.sort(TI_NPCIndex);
  567. TI_PopulateOptions("npclist updated");
  568. elseif(confirminquestion == true) then
  569. TI_NPCDB[npcname] = TI_copyTable(OptList);
  570. TI_PopulateOptions("npclist updated");
  571. else
  572. TI_NPCInQuestion = {name=npcname, list=OptList};
  573. StaticPopup_Show("TI_NPCINQUESTION", npcname);
  574. end
  575. end
  576. end
  577. function TI_AddNPCToTempList(name, list)
  578. local temp = {};
  579. temp.name = name;
  580. temp.list = list;
  581. local subZone = GetSubZoneText();
  582. local realZone = GetRealZoneText();
  583. if(subZone == "") then
  584. temp.location = realZone;
  585. else
  586. temp.location = subZone .. ", " .. realZone;
  587. end
  588. table.insert(TI_TempNPCList, 1, temp);
  589. if(#TI_TempNPCList > TI_TempNPCListMaxSize) then
  590. table.remove(TI_TempNPCList, TI_TempNPCListMaxSize);
  591. end
  592. TI_TempNPCListUpdate();
  593. end
  594. function TI_DeleteTempNPCIndex(index)
  595. table.remove(TI_TempNPCList, index);
  596. TI_TempNPCListUpdate();
  597. end
  598. function TI_AddTempNPCIndex(index)
  599. TI_AddNPCToList(TI_TempNPCList[index].list, TI_TempNPCList[index].name);
  600. end
  601. function TI_DeleteNPC(index)
  602. local name = TI_NPCIndex[index];
  603. table.remove(TI_NPCIndex, index);
  604. TI_NPCDB[name] = nil;
  605. end
  606. function TI_StripDescriptors(...)
  607. local x = {};
  608. local arg = {...};
  609. for i=1, #arg, 2 do
  610. table.insert(x,arg[i]);
  611. end
  612. return x;
  613. end
  614. function TI_TabulateGossipOptions_Classic(...)
  615. local x = {};
  616. local arg = {...};
  617. for i=1, #arg, 2 do
  618. local temp = {};
  619. temp.name = arg[i];
  620. temp.type = arg[i+1];
  621. table.insert(x, temp);
  622. end
  623. return x;
  624. end
  625. function TI_TabulateGossipQuestUIInfo_Retail(gquis)
  626. local x = {};
  627. for i,gqui in ipairs(gquis) do
  628. local temp = {};
  629. temp.name = gqui.title;
  630. temp.icon = QuestUtil.GetQuestIconOffer(
  631. gqui.isLegendary,
  632. gqui.frequency,
  633. gqui.isRepeatable,
  634. false,
  635. false
  636. );
  637. temp.questID = gqui.questID;
  638. temp.isComplete = gqui.isComplete;
  639. table.insert(x, temp);
  640. end
  641. return x;
  642. end
  643. function TI_TabulateGossipUIInfo_Retail(guis)
  644. local x = {};
  645. for i,gui in ipairs(guis) do
  646. local temp = {};
  647. temp.name = gui.name;
  648. local gossipType = TI_TranslateIconToType(gui.icon)
  649. if gossipType == "chatbubble" then
  650. gossipType = "gossip"
  651. end
  652. temp.type = gossipType;
  653. temp.icon = gui.icon;
  654. temp.gossipOptionID = gui.gossipOptionID
  655. temp.orderIndex = gui.orderIndex
  656. table.insert(x, temp);
  657. end
  658. return x;
  659. end
  660. function TI_TabulateGossipAvailableQuests_Classic(...)
  661. local x = {};
  662. local idx = 1;
  663. for i=1, select("#", ...), 7 do
  664. local temp = {};
  665. temp.name = select(i, ...);
  666. local isTrivial = select(i+2, ...);
  667. local isDaily = select(i+3, ...);
  668. local isRepeatable = select(i+4, ...);
  669. local isLegendary = select(i+5, ...);
  670. local isIgnored = select(i+6, ...);
  671. if ( isDaily ) then
  672. temp.icon = "Interface\\GossipFrame\\DailyQuestIcon";
  673. elseif ( isRepeatable ) then
  674. temp.icon = "Interface\\GossipFrame\\DailyActiveQuestIcon";
  675. elseif ( isLegendary ) then
  676. temp.icon = "Interface\\GossipFrame\\AvailableLegendaryQuestIcon";
  677. else
  678. temp.icon = "Interface\\GossipFrame\\AvailableQuestIcon";
  679. end
  680. temp.questID = idx;
  681. table.insert(x, temp);
  682. idx = idx + 1;
  683. end
  684. return x;
  685. end
  686. function TI_TabulateGossipActiveQuests_Classic(...)
  687. local x = {};
  688. local idx = 1;
  689. for i=1, select("#", ...), 6 do
  690. local temp = {};
  691. temp.name = select(i, ...);
  692. local isComplete = select(i+3, ...);
  693. temp.isComplete = isComplete;
  694. local isLegendary = select(i+4, ...);
  695. if(isComplete) then
  696. if(isLegendary) then
  697. temp.icon = "Interface\\GossipFrame\\ActiveLegendaryQuestIcon";
  698. else
  699. temp.icon = "Interface\\GossipFrame\\ActiveQuestIcon";
  700. end
  701. else
  702. temp.icon = "Interface\\GossipFrame\\IncompleteQuestIcon";
  703. end
  704. temp.questID = idx;
  705. table.insert(x, temp);
  706. idx = idx + 1;
  707. end
  708. return x;
  709. end
  710. -- set up functions by release type
  711. if (TI_IsRetail()) then
  712. TI_FunctionList = {
  713. g = {
  714. availquest = C_GossipInfo.SelectAvailableQuest,
  715. activequest = C_GossipInfo.SelectActiveQuest,
  716. gossip = SelectGossipOption,
  717. getavailquests = C_GossipInfo.GetAvailableQuests,
  718. getactivequests = C_GossipInfo.GetActiveQuests,
  719. getoptions = C_GossipInfo.GetOptions,
  720. tabulateAvailable = TI_TabulateGossipQuestUIInfo_Retail,
  721. tabulateActive = TI_TabulateGossipQuestUIInfo_Retail,
  722. tabulateOptions = TI_TabulateGossipUIInfo_Retail,
  723. },
  724. q = {
  725. activequest = SelectActiveQuest,
  726. availquest = SelectAvailableQuest,
  727. }
  728. };
  729. else
  730. TI_FunctionList = {
  731. g = {
  732. availquest = SelectGossipAvailableQuest,
  733. activequest = SelectGossipActiveQuest,
  734. gossip = SelectGossipOption,
  735. getavailquests = GetGossipAvailableQuests,
  736. getactivequests = GetGossipActiveQuests,
  737. getoptions = GetGossipOptions,
  738. tabulateAvailable = TI_TabulateGossipAvailableQuests_Classic,
  739. tabulateActive = TI_TabulateGossipActiveQuests_Classic,
  740. tabulateOptions = TI_TabulateGossipOptions_Classic,
  741. },
  742. q = {
  743. activequest = SelectActiveQuest,
  744. availquest = SelectAvailableQuest,
  745. }
  746. };
  747. end
  748. --[[this function stolen from WhisperCast by Sarris, whom I love dearly for his contribution to Paladins everywhere.
  749. ]]
  750. function TI_copyTable( src )
  751. local copy = {}
  752. for k1,v1 in pairs(src) do
  753. if ( type(v1) == "table" ) then
  754. copy[k1]=TI_copyTable(v1)
  755. else
  756. copy[k1]=v1
  757. end
  758. end
  759. return copy
  760. end
  761. function toggle(arg)
  762. if(arg) then
  763. return false;
  764. else
  765. return true;
  766. end
  767. end