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

TurnInUI.lua 7.4KB

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