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.

TurnInUI.lua 7.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. function TI_PopulateOptions(arg)
  2. TI_debug(arg);
  3. local CurrOpts;
  4. local last=1;
  5. if(TI_status and TI_status.options) then
  6. if(TI_LoadedNPCIndex > 0) then
  7. CurrOpts = TI_NPCDB[TI_NPCIndex[TI_LoadedNPCIndex]];
  8. else
  9. CurrOpts = TI_status.options;
  10. end
  11. for i,v in ipairs(CurrOpts) do
  12. local entry = "TI_OptionsPriority" .. i;
  13. local entrybutton = getglobal(entry);
  14. local entrytext = getglobal("TI_OptionsPriority"..i.."_Text");
  15. local iconpath;
  16. if(v.name == nil) then TI_debug("oh noes") end;
  17. entrytext:SetText(v.name);
  18. if(v.type == "activequest") then
  19. iconpath = "Interface\\GossipFrame\\ActiveQuestIcon";
  20. elseif(v.type == "availquest") then
  21. iconpath = "Interface\\GossipFrame\\AvailableQuestIcon";
  22. else
  23. iconpath = "Interface\\GossipFrame\\" .. v.type .. "GossipIcon";
  24. end
  25. getglobal(entry .. "_Icon"):SetTexture(iconpath);
  26. getglobal(entry .. "_Check"):SetChecked(v.state);
  27. entrytext:SetWidth(156); --make sure to change this if you change the anchors in the XML
  28. entrybutton:SetHeight( entrytext:GetHeight() + 6);
  29. entrybutton:Show();
  30. last = last+1;
  31. end
  32. for j=last, 16, 1 do
  33. getglobal("TI_OptionsPriority" .. j):Hide();
  34. end
  35. TI_OptionsPriorityScrollFrame:SetVerticalScroll(0);
  36. TI_OptionsPriorityScrollFrame:UpdateScrollChildRect();
  37. TI_StatusIndicatorUpdate();
  38. end
  39. TI_NPCListScrollBarUpdate();
  40. TI_SettingCheckboxUpdate();
  41. end
  42. --[[
  43. function TI_PopulateOptions(arg)
  44. TI_debug(arg);
  45. if(TI_status and TI_status.options) then
  46. for i,v in ipairs(TI_status.options) do
  47. local entry = "TI_OptionsPriority" .. i;
  48. local iconpath;
  49. if(v.name == nil) then TI_debug("oh noes") end;
  50. if(getglobal(entry .. "_Text") == nil) then TI_debug("wtf "..entry .. "_Text") end;
  51. getglobal(entry .. "_Text"):SetText(v.name);
  52. if(v.type == "activequest") then
  53. iconpath = "Interface\\GossipFrame\\ActiveQuestIcon";
  54. elseif(v.type == "availquest") then
  55. iconpath = "Interface\\GossipFrame\\AvailableQuestIcon";
  56. else
  57. iconpath = "Interface\\GossipFrame\\" .. v.type .. "GossipIcon";
  58. end
  59. getglobal(entry .. "_Icon"):SetTexture(iconpath);
  60. getglobal(entry .. "_Check"):SetChecked(v.state);
  61. getglobal(entry):Show();
  62. end
  63. end
  64. TI_NPCListScrollBarUpdate();
  65. end
  66. ]]--
  67. function TI_NPCListScrollBarUpdate()
  68. if(TI_NPCIndex) then
  69. FauxScrollFrame_Update(TI_NPCListScrollFrame,table.getn(TI_NPCIndex),8,20);
  70. -- arg2 is max entries, arg3 is number of lines, arg4 is pixel height of each line
  71. local line; -- 1 through 8 of our window to scroll
  72. local lineplusoffset; -- an index into our data calculated from the scroll offset
  73. local offset = FauxScrollFrame_GetOffset(TI_NPCListScrollFrame);
  74. local i=1;
  75. local j=1;
  76. --~ for k, v in pairs(TI_NPCDB) do
  77. --~ if(offset <= i and i < offset+8) then
  78. --~ if(i <= table.getn(TI_NPCDB)) then
  79. --~ getglobal("TI_OptionsNPCContainer"..j.."_Text"):SetText(k);
  80. --~ getglobal("TI_OptionsNPCContainer"..j.."_Check"):SetChecked(v.state);
  81. --~ getglobal("TI_OptionsNPCContainer"..j):Show();
  82. --~ else
  83. --~ getglobal("TI_OptionsNPCContainer"..j):Hide();
  84. --~ end
  85. --~ j = j + 1;
  86. --~ end
  87. --~ i = i + 1;
  88. --~ end
  89. for line=1,8 do
  90. lineplusoffset = line + FauxScrollFrame_GetOffset(TI_NPCListScrollFrame);
  91. if(lineplusoffset <= table.getn(TI_NPCIndex)) then
  92. getglobal("TI_OptionsNPCContainer"..line):SetID(lineplusoffset);
  93. getglobal("TI_OptionsNPCContainer"..line.."_Text"):SetText(TI_NPCIndex[lineplusoffset]);
  94. getglobal("TI_OptionsNPCContainer"..line.."_Check"):SetChecked(TI_NPCDB[TI_NPCIndex[lineplusoffset]].state);
  95. if(lineplusoffset == TI_LoadedNPCIndex) then
  96. getglobal("TI_OptionsNPCContainer"..line):LockHighlight();
  97. else
  98. getglobal("TI_OptionsNPCContainer"..line):UnlockHighlight();
  99. end
  100. getglobal("TI_OptionsNPCContainer"..line):Show();
  101. else
  102. getglobal("TI_OptionsNPCContainer"..line):Hide();
  103. end
  104. end
  105. end
  106. end
  107. function TI_SelectNPCIndex()
  108. local index = this:GetID();
  109. if(TI_LoadedNPCIndex == index) then
  110. TI_LoadedNPCIndex = 0;
  111. else
  112. TI_LoadedNPCIndex = index;
  113. end
  114. TI_PopulateOptions("select npc");
  115. end
  116. function TI_DeleteNPCIndex()
  117. local index = this:GetParent():GetID();
  118. TI_DeleteNPC(index);
  119. if(TI_LoadedNPCIndex == index) then
  120. TI_LoadedNPCIndex = 0;
  121. end
  122. TI_PopulateOptions("npclist update");
  123. end
  124. function TI_NPCToggle()
  125. local index = this:GetParent():GetID();
  126. TI_NPCDB[TI_NPCIndex[index]].state = this:GetChecked();
  127. if(TI_NPCDB[TI_NPCIndex[index]].state) then
  128. TI_LoadedNPCIndex = index;
  129. else
  130. if(TI_LoadedNPCIndex == index) then
  131. TI_LoadedNPCIndex = 0;
  132. end
  133. end
  134. TI_PopulateOptions("select npc");
  135. end
  136. function TI_OptionMove(offset)
  137. local CurrOpts;
  138. if(TI_LoadedNPCIndex > 0) then
  139. CurrOpts = TI_NPCDB[TI_NPCIndex[TI_LoadedNPCIndex]];
  140. else
  141. CurrOpts = TI_status.options;
  142. end
  143. local id = this:GetParent():GetID();
  144. local newid = id + offset;
  145. if(newid < 1 or newid > table.getn(CurrOpts)) then
  146. return;
  147. end
  148. local temp = CurrOpts[newid];
  149. CurrOpts[newid] = CurrOpts[id];
  150. CurrOpts[id] = temp;
  151. TI_PopulateOptions("move");
  152. end
  153. function TI_OptionToggle()
  154. local CurrOpts;
  155. if(TI_LoadedNPCIndex > 0) then
  156. CurrOpts = TI_NPCDB[TI_NPCIndex[TI_LoadedNPCIndex]];
  157. else
  158. CurrOpts = TI_status.options;
  159. end
  160. local id = this:GetParent():GetID();
  161. if(this:GetChecked()) then
  162. CurrOpts[id].state=true;
  163. else
  164. CurrOpts[id].state=false;
  165. end
  166. end
  167. function TI_StatusIndicatorUpdate()
  168. if(TI_status) then
  169. if(TI_status.state) then
  170. TI_StatusIndicator_Status:SetText("On");
  171. TI_StatusIndicator_Status:SetTextColor(0,1,0);
  172. else
  173. TI_StatusIndicator_Status:SetText("Off");
  174. TI_StatusIndicator_Status:SetTextColor(1,0,0);
  175. end
  176. TI_StatusIndicator_Checkbox:SetChecked(TI_status.state);
  177. end
  178. end
  179. function TI_StatusIndicator_CheckFn()
  180. if(this:GetChecked()) then
  181. TI_Switch("on");
  182. else
  183. TI_Switch("off");
  184. end
  185. end
  186. function TI_TempNPCListTooltipShow()
  187. TI_Tooltip:SetOwner(this, ANCHOR_PRESERVE);
  188. TI_Tooltip:ClearLines();
  189. local id = this:GetID();
  190. TI_Tooltip:AddLine(TI_TempNPCList[id].location);
  191. for i,v in ipairs(TI_TempNPCList[id].list) do
  192. TI_Tooltip:AddLine("- " .. v.name);
  193. end
  194. --TI_Tooltip:SetText(text);
  195. TI_Tooltip:Show();
  196. end
  197. function TI_TooltipHide()
  198. TI_Tooltip:Hide();
  199. end
  200. function TI_TooltipMessage(msg)
  201. TI_Tooltip:SetOwner(this, ANCHOR_PRESERVE);
  202. TI_Tooltip:ClearLines();
  203. TI_Tooltip:SetText(msg);
  204. TI_Tooltip:Show();
  205. end
  206. function TI_TempNPCListUpdate()
  207. local last = 1;
  208. for i,v in ipairs(TI_TempNPCList) do
  209. local tempbuttontext = getglobal("TI_TempNPCListWindow"..i.."_Text");
  210. tempbuttontext:SetText(v.name);
  211. tempbuttontext:GetParent():Show();
  212. last = last+1;
  213. end
  214. for j=last, TI_TempNPCListMaxSize, 1 do
  215. getglobal("TI_TempNPCListWindow" .. j):Hide();
  216. end
  217. end
  218. function TI_NPCListCheckboxTooltip()
  219. if(this:GetChecked()) then
  220. TI_TooltipMessage("NPC is using specific settings.");
  221. else
  222. TI_TooltipMessage("NPC is using default settings.");
  223. end
  224. end
  225. function TI_OptionListCheckboxTooltip()
  226. if(this:GetChecked()) then
  227. TI_TooltipMessage("This option is enabled.");
  228. else
  229. TI_TooltipMessage("This option is disabled.");
  230. end
  231. end
  232. function TI_SettingCheckboxFn(var)
  233. if(this:GetChecked()) then
  234. TI_status[var] = true;
  235. else
  236. TI_status[var] = false;
  237. end
  238. end
  239. function TI_SettingCheckboxUpdate()
  240. if(TI_status) then
  241. TI_SettingCheckboxes_UseDefault:SetChecked(TI_status.usedefault);
  242. TI_SettingCheckboxes_AddAutomatically:SetChecked(TI_status.autoadd);
  243. end
  244. end