Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

TurnInUI.lua 7.6KB

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