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 8.7KB

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