Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

TurnInUI.lua 7.6KB

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