Advertisement
Guest User

Untitled

a guest
Sep 6th, 2015
574
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 137.86 KB | None | 0 0
  1. -------------------------------------------------------------------------------
  2. -- ESO Master Recipe List v1.36c
  3. -------------------------------------------------------------------------------
  4. --
  5. -- Copyright (c) 2015 James A. Keene (Phinix) All rights reserved.
  6. --
  7. -- Permission is hereby granted, free of charge, to any person obtaining
  8. -- a copy of this software and associated documentation (the "Software"),
  9. -- to operate the Software for personal use only. Permission is NOT granted
  10. -- to modify, merge, publish, distribute, sublicense, re-upload, and/or sell
  11. -- copies of the Software.
  12. --
  13. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  14. -- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  15. -- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  16. -- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  17. -- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  18. -- WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. -- OTHER DEALINGS IN THE SOFTWARE.
  21. --
  22. -------------------------------------------------------------------------------
  23. --
  24. -- DISCLAIMER:
  25. --
  26. -- This Add-on is not created by, affiliated with or sponsored by ZeniMax
  27. -- Media Inc. or its affiliates. The Elder Scrolls® and related logos are
  28. -- registered trademarks or trademarks of ZeniMax Media Inc. in the United
  29. -- States and/or other countries. All rights reserved.
  30. --
  31. -- You can read the full terms at:
  32. -- https://account.elderscrollsonline.com/add-on-terms
  33. --
  34. -------------------------------------------------------------------------------
  35. local ESOMRL = _G['ESOMRL']
  36. local L = ESOMRL:GetLanguage()
  37. ESOMRL.Name = 'MasterRecipeList'
  38. ESOMRL.Author = '|c66ccffPhinix|r'
  39. ESOMRL.Version = '1.36c'
  40.  
  41. local setPage = 1
  42. local editText = 0
  43. local searchSize = 0
  44. local recountTracked = 0
  45. local PlayerLoaded = 0
  46. local stationNode = 0
  47. local stationItem = 0
  48. local stationNav = 0
  49. local textInput = ""
  50. local searchTable = {}
  51. local qualityCap = {}
  52. local nameList = {}
  53. local openTab
  54. local currentChar
  55. local charnameDropdown
  56. local stationControl
  57. local stationSelection
  58. local RecipeItemTooltipControl
  59. local IngredientItemTooltipControl
  60.  
  61. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  62. -- Used for third-party addon support.
  63. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  64. local FCOItemSaverActive
  65.  
  66. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  67. -- Database setup.
  68. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  69. local IconStrings = {[1]='|t16:16:/MasterRecipeList/textures/known.dds|t ',[2]='|t16:16:/MasterRecipeList/textures/knownt.dds|t ',[3]='|t16:16:/MasterRecipeList/textures/unknown.dds|t ',[4]='|t16:16:/MasterRecipeList/textures/unknownt.dds|t ',[5]='|t16:16:/MasterRecipeList/textures/writ.dds|t ',[6]='|t16:16:/MasterRecipeList/textures/writt.dds|t '}
  70. local StationIcons = {[1] = '  |t16:16:/MasterRecipeList/textures/stat_hstar.dds|t',[2] = '  |t16:16:/MasterRecipeList/textures/stat_mstar.dds|t',[3] = '  |t16:16:/MasterRecipeList/textures/stat_sstar.dds|t',[4] = '  |t16:16:/MasterRecipeList/textures/stat_hstar.dds|t |t16:16:/MasterRecipeList/textures/stat_mstar.dds|t',[5] = '  |t16:16:/MasterRecipeList/textures/stat_hstar.dds|t |t16:16:/MasterRecipeList/textures/stat_sstar.dds|t',[6] = '  |t16:16:/MasterRecipeList/textures/stat_mstar.dds|t |t16:16:/MasterRecipeList/textures/stat_sstar.dds|t',[7] = '  |t16:16:/MasterRecipeList/textures/stat_hstar.dds|t |t16:16:/MasterRecipeList/textures/stat_mstar.dds|t |t16:16:/MasterRecipeList/textures/stat_sstar.dds|t',[8] = ' |t16:16:/MasterRecipeList/textures/tracking.dds|t',[9] = ' |t16:16:/MasterRecipeList/textures/trackings.dds|t'}
  71. local StatIcons = {[1] = '  |t16:16:/MasterRecipeList/textures/stat_hstar.dds|t',[2] = '  |t16:16:/MasterRecipeList/textures/stat_mstar.dds|t',[3] = '  |t16:16:/MasterRecipeList/textures/stat_sstar.dds|t',[4] = '  |t16:16:/MasterRecipeList/textures/stat_hstar.dds|t |t16:16:/MasterRecipeList/textures/stat_mstar.dds|t',[5] = '  |t16:16:/MasterRecipeList/textures/stat_hstar.dds|t |t16:16:/MasterRecipeList/textures/stat_sstar.dds|t',[6] = '  |t16:16:/MasterRecipeList/textures/stat_mstar.dds|t |t16:16:/MasterRecipeList/textures/stat_sstar.dds|t',[7] = '  |t16:16:/MasterRecipeList/textures/stat_hstar.dds|t |t16:16:/MasterRecipeList/textures/stat_mstar.dds|t |t16:16:/MasterRecipeList/textures/stat_sstar.dds|t',[8] = '  |t16:16:/MasterRecipeList/textures/stat_h.dds|t',[9] = '  |t16:16:/MasterRecipeList/textures/stat_m.dds|t',[10] = '  |t16:16:/MasterRecipeList/textures/stat_s.dds|t',[11] = '  |t16:16:/MasterRecipeList/textures/stat_h.dds|t |t16:16:/MasterRecipeList/textures/stat_m.dds|t',[12] = '  |t16:16:/MasterRecipeList/textures/stat_h.dds|t |t16:16:/MasterRecipeList/textures/stat_s.dds|t',[13] = '  |t16:16:/MasterRecipeList/textures/stat_m.dds|t |t16:16:/MasterRecipeList/textures/stat_s.dds|t',[14] = '  |t16:16:/MasterRecipeList/textures/stat_h.dds|t |t16:16:/MasterRecipeList/textures/stat_m.dds|t |t16:16:/MasterRecipeList/textures/stat_s.dds|t'}
  72. local StatOptions = {[1] = '/MasterRecipeList/textures/opt_stars.dds',[2] = '/MasterRecipeList/textures/opt_circles.dds'}
  73. local StatOptionTooltips = {[1] = L.ESOMRL_ICONTT1,[2] = L.ESOMRL_ICONTT2}
  74. local WritQuest = {reqId1 = 0, reqId2 = 0}
  75. local StationChecking = {[1] = {tr = ESOMRL.ProvisioningLinksFood1, cv = 1},[2] = {tr = ESOMRL.ProvisioningLinksFood2, cv = 1},[3] = {tr = ESOMRL.ProvisioningLinksFood3, cv = 1},[4] = {tr = ESOMRL.ProvisioningLinksFood4, cv = 2},[5] = {tr = ESOMRL.ProvisioningLinksFood5, cv = 2},[6] = {tr = ESOMRL.ProvisioningLinksFood6, cv = 2},[7] = {tr = ESOMRL.ProvisioningLinksFood7, cv = 3},[8] = {tr = ESOMRL.ProvisioningLinksDrinks1, cv = 1},[9] = {tr = ESOMRL.ProvisioningLinksDrinks2, cv = 1},[10] = {tr = ESOMRL.ProvisioningLinksDrinks3, cv = 1},[11] = {tr = ESOMRL.ProvisioningLinksDrinks4, cv = 2},[12] = {tr = ESOMRL.ProvisioningLinksDrinks5, cv = 2},[13] = {tr = ESOMRL.ProvisioningLinksDrinks6, cv = 2},[14] = {tr = ESOMRL.ProvisioningLinksDrinks7, cv = 3},[15] = {tr = ESOMRL.ProvisioningLinksPsijic, cv = 4}}
  76. local StationControls = {[1] = {c = nil, w = 0, t = 0},[2] = {c = nil, w = 0, t = 0},[3] = {c = nil, w = 0, t = 0},[4] = {c = nil, w = 0, t = 0},[5] = {c = nil, w = 0, t = 0},[6] = {c = nil, w = 0, t = 0},[7] = {c = nil, w = 0, t = 0},[8] = {c = nil, w = 0, t = 0},[9] = {c = nil, w = 0, t = 0},[10] = {c = nil, w = 0, t = 0},[11] = {c = nil, w = 0, t = 0},[12] = {c = nil, w = 0, t = 0},[13] = {c = nil, w = 0, t = 0},[14] = {c = nil, w = 0, t = 0},[14] = {c = nil, w = 0, t = 0},[15] = {c = nil, w = 0, t = 0}}
  77. local CharacterDefaults = {[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,[50]=0,[51]=0,[52]=0,[53]=0,[54]=0,[55]=0,[56]=0,[57]=0,[58]=0,[59]=0,[60]=0,[61]=0,[62]=0,[63]=0,[64]=0,[65]=0,[66]=0,[67]=0,[68]=0,[69]=0,[70]=0,[71]=0,[72]=0,[73]=0,[74]=0,[75]=0,[76]=0,[77]=0,[78]=0,[79]=0,[80]=0,[81]=0,[82]=0,[83]=0,[84]=0,[85]=0,[86]=0,[87]=0,[88]=0,[89]=0,[90]=0,[91]=0,[92]=0,[93]=0,[94]=0,[95]=0,[96]=0,[97]=0,[98]=0,[99]=0,[100]=0,[101]=0,[102]=0,[103]=0,[104]=0,[105]=0,[106]=0,[107]=0,[108]=0,[109]=0,[110]=0,[111]=0,[112]=0,[113]=0,[114]=0,[115]=0,[116]=0,[117]=0,[118]=0,[119]=0,[120]=0,[121]=0,[122]=0,[123]=0,[124]=0,[125]=0,[126]=0,[127]=0,[128]=0,[129]=0,[130]=0,[131]=0,[132]=0,[133]=0,[134]=0,[135]=0,[136]=0,[137]=0,[138]=0,[139]=0,[140]=0,[141]=0,[142]=0,[143]=0,[144]=0,[145]=0,[146]=0,[147]=0,[148]=0,[149]=0,[150]=0,[151]=0,[152]=0,[153]=0,[154]=0,[155]=0,[156]=0,[157]=0,[158]=0,[159]=0,[160]=0,[161]=0,[162]=0,[163]=0,[164]=0,[165]=0,[166]=0,[167]=0,[168]=0,[169]=0,[170]=0,[171]=0,[172]=0,[173]=0,[174]=0,[175]=0,[176]=0,[177]=0,[178]=0,[179]=0,[180]=0,[181]=0,[182]=0,[183]=0,[184]=0,[185]=0,[186]=0,[187]=0,[188]=0,[189]=0,[190]=0,[191]=0,[192]=0,[193]=0,[194]=0,[195]=0,[196]=0,[197]=0,[198]=0,[199]=0,[200]=0,[201]=0,[202]=0,[203]=0,[204]=0,[205]=0,[206]=0,[207]=0,[208]=0,[209]=0,[210]=0,[211]=0,[212]=0,[213]=0,[214]=0,[215]=0,[216]=0,[217]=0,[218]=0,[219]=0,[220]=0,[221]=0,[222]=0,[223]=0,[224]=0,[225]=0,[226]=0,[227]=0,[228]=0,[229]=0,[230]=0,[231]=0,[232]=0,[233]=0,[234]=0,[235]=0,[236]=0,[237]=0,[238]=0,[239]=0,[240]=0,[241]=0,[242]=0,[243]=0,[244]=0,[245]=0,[246]=0,[247]=0,[248]=0,[249]=0,[250]=0,[251]=0,[252]=0,[253]=0,[254]=0,[255]=0,[256]=0,[257]=0,[258]=0,[259]=0,[260]=0,[261]=0,[262]=0,[263]=0,[264]=0,[265]=0,[266]=0,[267]=0,[268]=0,[269]=0,[270]=0,[271]=0,[272]=0,[273]=0,[274]=0,[275]=0,[276]=0,[277]=0,[278]=0,[279]=0,[280]=0,[281]=0,[282]=0,[283]=0,[284]=0,[285]=0,[286]=0,[287]=0,[288]=0,[289]=0,[290]=0,[291]=0,[292]=0,[293]=0,[294]=0,[295]=0,[296]=0,[297]=0,[298]=0,[299]=0,[300]=0,[301]=0,[302]=0,[303]=0,[304]=0,[305]=0,[306]=0,[307]=0,[308]=0,[309]=0,[310]=0,[311]=0,[312]=0,[313]=0,[314]=0,[315]=0,[316]=0,[317]=0,[318]=0,[319]=0,[320]=0,[321]=0,[322]=0,[323]=0,[324]=0,[325]=0,[326]=0,[327]=0,[328]=0,[329]=0,[330]=0,[331]=0,[332]=0,[333]=0,[334]=0,[335]=0,[336]=0,[337]=0,[338]=0,[339]=0,[340]=0,[341]=0,[342]=0,[343]=0,[344]=0,[345]=0,[346]=0,[347]=0,[348]=0,[349]=0,[350]=0,[351]=0,[352]=0,[353]=0,[354]=0,[355]=0,[356]=0,[357]=0,[358]=0,[359]=0,[360]=0,[361]=0,[362]=0,[363]=0,[364]=0,[365]=0,[366]=0,[367]=0,[368]=0,[369]=0,[370]=0,[371]=0,[372]=0,[373]=0,[374]=0,[375]=0,[376]=0,[377]=0,[378]=0,[379]=0,[380]=0,[381]=0,[382]=0,[383]=0,[384]=0,[385]=0,[386]=0,[387]=0,[388]=0,[389]=0,[390]=0,[391]=0,[392]=0,[393]=0,[394]=0,[395]=0,[396]=0,[397]=0,[398]=0,[399]=0,[400]=0,[401]=0,[402]=0,[403]=0,[404]=0,[405]=0,[406]=0,[407]=0,[408]=0,[409]=0,[410]=0,[411]=0,[412]=0,[413]=0,[414]=0,[415]=0,[416]=0,[417]=0,[418]=0,[419]=0,[420]=0,[421]=0,[422]=0,[423]=0,[424]=0,[425]=0,[426]=0,[427]=0,[428]=0,[429]=0,[430]=0,[431]=0,[432]=0,[433]=0,[434]=0,[435]=0,[436]=0,[437]=0,[438]=0,[439]=0,[440]=0,[441]=0,[442]=0,[443]=0,[444]=0,[445]=0,[446]=0,[447]=0,[448]=0,[449]=0,[450]=0,[451]=0,[452]=0,[453]=0,[454]=0,[455]=0,[456]=0,[457]=0,[458]=0,[459]=0,[460]=0,[461]=0,[462]=0,[463]=0,[464]=0,[465]=0,[466]=0,[467]=0,[468]=0,[469]=0,[470]=0,[471]=0,[472]=0,[473]=0,[474]=0,[475]=0,[476]=0,[477]=0,[478]=0,[479]=0,[480]=0,[481]=0,[482]=0,[483]=0,[484]=0,[485]=0,[486]=0,[487]=0,[601]=0,[602]=0,[603]=0,[604]=0,[605]=0,[606]=0,[607]=0,[608]=0,[609]=0,[610]=0,[611]=0,[612]=0,[613]=0,[614]=0,[615]=0,[616]=0,[617]=0,[618]=0,[619]=0,[620]=0,[621]=0,[622]=0,[623]=0,[624]=0,[625]=0,[626]=0,[627]=0,[628]=0,[629]=0,[630]=0,[631]=0,[632]=0,[633]=0,[634]=0,[635]=0,[636]=0,[637]=0,[638]=0,[639]=0,[640]=0,[641]=0,[642]=0,[643]=0,[644]=0,[645]=0,[646]=0,[647]=0,[648]=0,[649]=0,[650]=0,[800]={xpos=0,ypos=0,recipetracklist=0,ingtracklist=0,trackChar=true,destroyjunkrecipes=false,destroyjunkingredients=false,debugmode=true,ignorestolen=true,fcoitemsaver=false,altknown=false,altknownself=false,trackingchar=1,lttshow=1,sttshow=1,stmarked=1,tooltipstyle=0,recipeconfigpanel=0,junkunmarkedrecipes=0,junkunmarkedingredients=0,destroyunmarkedrecipes=0,destroyunmarkedingredients=0,maxjunkstack=10,maxjunkquality=2}}
  78. local AccountDefaults = {[1]={names={}},[2]={names={}},[3]={names={}},[4]={names={}},[5]={names={}},[6]={names={}},[7]={names={}},[8]={names={}},[9]={names={}},[10]={names={}},[11]={names={}},[12]={names={}},[13]={names={}},[14]={names={}},[15]={names={}},[16]={names={}},[17]={names={}},[18]={names={}},[19]={names={}},[20]={names={}},[21]={names={}},[22]={names={}},[23]={names={}},[24]={names={}},[25]={names={}},[26]={names={}},[27]={names={}},[28]={names={}},[29]={names={}},[30]={names={}},[31]={names={}},[32]={names={}},[33]={names={}},[34]={names={}},[35]={names={}},[36]={names={}},[37]={names={}},[38]={names={}},[39]={names={}},[40]={names={}},[41]={names={}},[42]={names={}},[43]={names={}},[44]={names={}},[45]={names={}},[46]={names={}},[47]={names={}},[48]={names={}},[49]={names={}},[50]={names={}},[51]={names={}},[52]={names={}},[53]={names={}},[54]={names={}},[55]={names={}},[56]={names={}},[57]={names={}},[58]={names={}},[59]={names={}},[60]={names={}},[61]={names={}},[62]={names={}},[63]={names={}},[64]={names={}},[65]={names={}},[66]={names={}},[67]={names={}},[68]={names={}},[69]={names={}},[70]={names={}},[71]={names={}},[72]={names={}},[73]={names={}},[74]={names={}},[75]={names={}},[76]={names={}},[77]={names={}},[78]={names={}},[79]={names={}},[80]={names={}},[81]={names={}},[82]={names={}},[83]={names={}},[84]={names={}},[85]={names={}},[86]={names={}},[87]={names={}},[88]={names={}},[89]={names={}},[90]={names={}},[91]={names={}},[92]={names={}},[93]={names={}},[94]={names={}},[95]={names={}},[96]={names={}},[97]={names={}},[98]={names={}},[99]={names={}},[100]={names={}},[101]={names={}},[102]={names={}},[103]={names={}},[104]={names={}},[105]={names={}},[106]={names={}},[107]={names={}},[108]={names={}},[109]={names={}},[110]={names={}},[111]={names={}},[112]={names={}},[113]={names={}},[114]={names={}},[115]={names={}},[116]={names={}},[117]={names={}},[118]={names={}},[119]={names={}},[120]={names={}},[121]={names={}},[122]={names={}},[123]={names={}},[124]={names={}},[125]={names={}},[126]={names={}},[127]={names={}},[128]={names={}},[129]={names={}},[130]={names={}},[131]={names={}},[132]={names={}},[133]={names={}},[134]={names={}},[135]={names={}},[136]={names={}},[137]={names={}},[138]={names={}},[139]={names={}},[140]={names={}},[141]={names={}},[142]={names={}},[143]={names={}},[144]={names={}},[145]={names={}},[146]={names={}},[147]={names={}},[148]={names={}},[149]={names={}},[150]={names={}},[151]={names={}},[152]={names={}},[153]={names={}},[154]={names={}},[155]={names={}},[156]={names={}},[157]={names={}},[158]={names={}},[159]={names={}},[160]={names={}},[161]={names={}},[162]={names={}},[163]={names={}},[164]={names={}},[165]={names={}},[166]={names={}},[167]={names={}},[168]={names={}},[169]={names={}},[170]={names={}},[171]={names={}},[172]={names={}},[173]={names={}},[174]={names={}},[175]={names={}},[176]={names={}},[177]={names={}},[178]={names={}},[179]={names={}},[180]={names={}},[181]={names={}},[182]={names={}},[183]={names={}},[184]={names={}},[185]={names={}},[186]={names={}},[187]={names={}},[188]={names={}},[189]={names={}},[190]={names={}},[191]={names={}},[192]={names={}},[193]={names={}},[194]={names={}},[195]={names={}},[196]={names={}},[197]={names={}},[198]={names={}},[199]={names={}},[200]={names={}},[201]={names={}},[202]={names={}},[203]={names={}},[204]={names={}},[205]={names={}},[206]={names={}},[207]={names={}},[208]={names={}},[209]={names={}},[210]={names={}},[211]={names={}},[212]={names={}},[213]={names={}},[214]={names={}},[215]={names={}},[216]={names={}},[217]={names={}},[218]={names={}},[219]={names={}},[220]={names={}},[221]={names={}},[222]={names={}},[223]={names={}},[224]={names={}},[225]={names={}},[226]={names={}},[227]={names={}},[228]={names={}},[229]={names={}},[230]={names={}},[231]={names={}},[232]={names={}},[233]={names={}},[234]={names={}},[235]={names={}},[236]={names={}},[237]={names={}},[238]={names={}},[239]={names={}},[240]={names={}},[241]={names={}},[242]={names={}},[243]={names={}},[244]={names={}},[245]={names={}},[246]={names={}},[247]={names={}},[248]={names={}},[249]={names={}},[250]={names={}},[251]={names={}},[252]={names={}},[253]={names={}},[254]={names={}},[255]={names={}},[256]={names={}},[257]={names={}},[258]={names={}},[259]={names={}},[260]={names={}},[261]={names={}},[262]={names={}},[263]={names={}},[264]={names={}},[265]={names={}},[266]={names={}},[267]={names={}},[268]={names={}},[269]={names={}},[270]={names={}},[271]={names={}},[272]={names={}},[273]={names={}},[274]={names={}},[275]={names={}},[276]={names={}},[277]={names={}},[278]={names={}},[279]={names={}},[280]={names={}},[281]={names={}},[282]={names={}},[283]={names={}},[284]={names={}},[285]={names={}},[286]={names={}},[287]={names={}},[288]={names={}},[289]={names={}},[290]={names={}},[291]={names={}},[292]={names={}},[293]={names={}},[294]={names={}},[295]={names={}},[296]={names={}},[297]={names={}},[298]={names={}},[299]={names={}},[300]={names={}},[301]={names={}},[302]={names={}},[303]={names={}},[304]={names={}},[305]={names={}},[306]={names={}},[307]={names={}},[308]={names={}},[309]={names={}},[310]={names={}},[311]={names={}},[312]={names={}},[313]={names={}},[314]={names={}},[315]={names={}},[316]={names={}},[317]={names={}},[318]={names={}},[319]={names={}},[320]={names={}},[321]={names={}},[322]={names={}},[323]={names={}},[324]={names={}},[325]={names={}},[326]={names={}},[327]={names={}},[328]={names={}},[329]={names={}},[330]={names={}},[331]={names={}},[332]={names={}},[333]={names={}},[334]={names={}},[335]={names={}},[336]={names={}},[337]={names={}},[338]={names={}},[339]={names={}},[340]={names={}},[341]={names={}},[342]={names={}},[343]={names={}},[344]={names={}},[345]={names={}},[346]={names={}},[347]={names={}},[348]={names={}},[349]={names={}},[350]={names={}},[351]={names={}},[352]={names={}},[353]={names={}},[354]={names={}},[355]={names={}},[356]={names={}},[357]={names={}},[358]={names={}},[359]={names={}},[360]={names={}},[361]={names={}},[362]={names={}},[363]={names={}},[364]={names={}},[365]={names={}},[366]={names={}},[367]={names={}},[368]={names={}},[369]={names={}},[370]={names={}},[371]={names={}},[372]={names={}},[373]={names={}},[374]={names={}},[375]={names={}},[376]={names={}},[377]={names={}},[378]={names={}},[379]={names={}},[380]={names={}},[381]={names={}},[382]={names={}},[383]={names={}},[384]={names={}},[385]={names={}},[386]={names={}},[387]={names={}},[388]={names={}},[389]={names={}},[390]={names={}},[391]={names={}},[392]={names={}},[393]={names={}},[394]={names={}},[395]={names={}},[396]={names={}},[397]={names={}},[398]={names={}},[399]={names={}},[400]={names={}},[401]={names={}},[402]={names={}},[403]={names={}},[404]={names={}},[405]={names={}},[406]={names={}},[407]={names={}},[408]={names={}},[409]={names={}},[410]={names={}},[411]={names={}},[412]={names={}},[413]={names={}},[414]={names={}},[415]={names={}},[416]={names={}},[417]={names={}},[418]={names={}},[419]={names={}},[420]={names={}},[421]={names={}},[422]={names={}},[423]={names={}},[424]={names={}},[425]={names={}},[426]={names={}},[427]={names={}},[428]={names={}},[429]={names={}},[430]={names={}},[431]={names={}},[432]={names={}},[433]={names={}},[434]={names={}},[435]={names={}},[436]={names={}},[437]={names={}},[438]={names={}},[439]={names={}},[440]={names={}},[441]={names={}},[442]={names={}},[443]={names={}},[444]={names={}},[445]={names={}},[446]={names={}},[447]={names={}},[448]={names={}},[449]={names={}},[450]={names={}},[451]={names={}},[452]={names={}},[453]={names={}},[454]={names={}},[455]={names={}},[456]={names={}},[457]={names={}},[458]={names={}},[459]={names={}},[460]={names={}},[461]={names={}},[462]={names={}},[463]={names={}},[464]={names={}},[465]={names={}},[466]={names={}},[467]={names={}},[468]={names={}},[469]={names={}},[470]={names={}},[471]={names={}},[472]={names={}},[473]={names={}},[474]={names={}},[475]={names={}},[476]={names={}},[477]={names={}},[478]={names={}},[479]={names={}},[480]={names={}},[481]={names={}},[482]={names={}},[483]={names={}},[484]={names={}},[485]={names={}},[486]={names={}},[487]={names={}},[800]={known=true,ingfood=true,inventoryicons=true,stationstats=true,stationicons=1,bagiconoffset=25,gstoreiconoffset=-30,glistingiconoffset=-30},[801]={globalingprofile={[1]=0,[2]=0,[3]=0,[4]=0,[5]=0,[6]=0,[7]=0,[8]=0,[9]=0,[10]=0,[11]=0,[12]=0,[13]=0,[14]=0,[15]=0,[16]=0,[17]=0,[18]=0,[19]=0,[20]=0,[21]=0,[22]=0,[23]=0,[24]=0,[25]=0,[26]=0,[27]=0,[28]=0,[29]=0,[30]=0,[31]=0,[32]=0,[33]=0,[34]=0,[35]=0,[36]=0,[37]=0,[38]=0,[39]=0,[40]=0,[41]=0,[42]=0,[43]=0,[44]=0,[45]=0,[46]=0,[47]=0,[48]=0,[49]=0,[50]=0}}}
  79.  
  80. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  81. -- Get and set saved variables.
  82. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  83. local function TierIndex(index, tier)
  84.     if tier == 2 then
  85.         index = index + 39
  86.     elseif tier == 3 then
  87.         index = index + 78
  88.     elseif tier == 4 then
  89.         index = index + 117
  90.     elseif tier == 5 then
  91.         index = index + 150
  92.     elseif tier == 6 then
  93.         index = index + 183
  94.     elseif tier == 7 then
  95.         index = index + 216
  96.     elseif tier == 8 then
  97.         index = index + 243
  98.     elseif tier == 9 then
  99.         index = index + 282
  100.     elseif tier == 10 then
  101.         index = index + 321
  102.     elseif tier == 11 then
  103.         index = index + 360
  104.     elseif tier == 12 then
  105.         index = index + 393
  106.     elseif tier == 13 then
  107.         index = index + 426
  108.     elseif tier == 14 then
  109.         index = index + 459
  110.     elseif tier == 15 then
  111.         index = 487
  112.     end
  113.     return index
  114. end
  115.  
  116. local function GetRecipeSavedVar(index, tier)
  117.     index = TierIndex(index, tier)
  118.     return ESOMRL.SV[index]
  119. end
  120.  
  121. local function SetRecipeSavedVar(index, tier, val)
  122.     index = TierIndex(index, tier)
  123.     ESOMRL.SV[index] = val
  124. end
  125.  
  126. local function GetIngredientSavedVar(index)
  127.     index = index + 600
  128.     return ESOMRL.SV[index]
  129. end
  130.  
  131. local function SetIngredientSavedVar(index, val)
  132.     index = index + 600
  133.     ESOMRL.SV[index] = val
  134. end
  135.  
  136. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  137. -- Various utility functions used in other areas.
  138. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  139. local function SetTrackedRecipeCountText() -- Updates the current tracked recipe display text.
  140.     ESOMRL_MainFrameSelectionFrameClearSearchLabel:SetText(L.ESOMRL_CLEAR .. ' |cff9900(' .. L.ESOMRL_TRACKING .. '|r |cffffff' .. ESOMRL.SV[800].recipetracklist .. '|r |cff9900' .. L.ESOMRL_RECIPES .. ')|r')
  141.     if stationControl ~= nil then stationControl:RefreshRecipeList() end
  142. end
  143.  
  144. local function SetTrackedIngredientCountText() -- Updates the current tracked ingredient display text.
  145.     ESOMRL_MainFrameIngredientsFrameClearIngTrackLabel:SetText(L.ESOMRL_ICLEAR .. ' |cff9900(' .. L.ESOMRL_TRACKING .. '|r |cffffff' .. ESOMRL.SV[800].ingtracklist .. '|r |cff9900' .. L.ESOMRL_INGREDIENTS .. ')|r')
  146. end
  147.  
  148. local function GetItemIdFromLink(itemLink) -- Parse the link data for base itemId.
  149.     local itemId = select(4, ZO_LinkHandler_ParseLink(itemLink))
  150.     return tonumber(itemId)
  151. end
  152.  
  153. local function RefreshViews() -- Refresh current views when tracking status updates so icons re-populate in real-time.
  154.     ZO_ScrollList_RefreshVisible(ZO_PlayerInventoryBackpack)
  155.     ZO_ScrollList_RefreshVisible(ZO_PlayerBankBackpack)
  156.     ZO_ScrollList_RefreshVisible(ZO_GuildBankBackpack)
  157.     ZO_ScrollList_RefreshVisible(ZO_TradingHouseItemPaneSearchResults)
  158.     ZO_ScrollList_RefreshVisible(ZO_TradingHousePostedItemsList)
  159. end
  160.  
  161. local function LinkNameLanguageFormat(langtext)
  162.     local langString = GetCVar('Language.2')
  163.     if langString == 'en' then
  164.         return langtext
  165.     else
  166.         return zo_strformat("<<t:1>>",langtext)
  167.     end
  168. end
  169.  
  170. local function LowerSpaceSpecial(text) -- Remove spaces and change to lower case.
  171.     if GetCVar('Language.2') == 'en' then
  172.         return tostring(text):gsub("%s",''):gsub(":.*",''):gsub("%W",''):lower()
  173.     else
  174.         return zo_strlower(zo_strformat("<<t:1>>",text)):gsub("%s",''):gsub(":.*",''):gsub("%W",'')
  175.     end
  176. end
  177.  
  178. local function Contains(table, element) -- Determined if a given element exists in a given table.
  179.     for k,v in pairs(table) do
  180.         if v == element then
  181.             return true
  182.         end
  183.     end
  184.     return false
  185. end
  186.  
  187. local function FindName(table, element) -- Returns the table key that contains a given element value.
  188.     for k,v in pairs(table) do  -- Used for determining which key has the name to remove with table.remove.
  189.         if v == element then
  190.             return k
  191.         end
  192.     end
  193.     return 0
  194. end
  195.  
  196. local function LookupPosition(htable, tval) -- Lookup the itemId's position from a given resource table (fast).
  197.     if htable[tval] ~= nil then
  198.         return tonumber(htable[tval].position)
  199.     end
  200.     return 0
  201. end
  202.  
  203. local function FindMatch(htable, tval) -- Search for an itemId and get the position if found (slower).
  204.     for k, v in pairs(htable) do
  205.         if htable[k].id == tostring(tval) then
  206.             return tonumber(htable[k].position)
  207.         end
  208.     end
  209.     return 0
  210. end
  211.  
  212. local function GetTextureId(texturePath)
  213.     for k, v in pairs(StatOptions) do
  214.         if  v == texturePath then
  215.             return k
  216.         end
  217.     end
  218.     return 0
  219. end
  220.  
  221. local function SwitchStationIcons(textureId)
  222.     if textureId == 1 then
  223.         for i = 1, 7 do StationIcons[i] = StatIcons[i] end
  224.     elseif textureId == 2 then
  225.         for i = 1, 7 do local b = i + 7 StationIcons[i] = StatIcons[b] end
  226.     end
  227. end
  228.  
  229. local function RecountTracked() -- Recount tracked recipes/ingredients once when you log in.
  230.     if ShowMotifs then -- Offset default position if ShowMotifs enabled to match new columns.
  231.         if ESOMRL.ASV[800].bagiconoffset == 25 then
  232.             ESOMRL.ASV[800].bagiconoffset = 82
  233.         end
  234.         if ESOMRL.ASV[800].gstoreiconoffset == -30 then
  235.             ESOMRL.ASV[800].gstoreiconoffset = 27
  236.         end
  237.         if ESOMRL.ASV[800].glistingiconoffset == -30 then
  238.             ESOMRL.ASV[800].glistingiconoffset = 27
  239.         end
  240.         RefreshViews()
  241.     elseif not ShowMotifs then
  242.         if ESOMRL.ASV[800].bagiconoffset == 82 then
  243.             ESOMRL.ASV[800].bagiconoffset = 25
  244.         end
  245.         if ESOMRL.ASV[800].gstoreiconoffset == 27 then
  246.             ESOMRL.ASV[800].gstoreiconoffset = -30
  247.         end
  248.         if ESOMRL.ASV[800].glistingiconoffset == 27 then
  249.             ESOMRL.ASV[800].glistingiconoffset = -30
  250.         end
  251.         RefreshViews()
  252.     end
  253.     ESOMRL.SV[800].recipetracklist = 0
  254.     ESOMRL.SV[800].ingtracklist = 0
  255.     local trackedrecipes = 0
  256.     local trackedingredients = 0
  257.     local playername = GetUnitName("player")
  258.     for r = 1, 487 do
  259.         local savedvar = GetRecipeSavedVar(r, 1)
  260.         if savedvar == 2 or savedvar == 1 then
  261.             trackedrecipes = trackedrecipes + 1
  262.         end
  263.     end
  264.     for i = 1, 50 do
  265.         local savedvar = GetIngredientSavedVar(i)
  266.         if savedvar == 1 then
  267.             trackedingredients = trackedingredients + 1
  268.         end
  269.     end
  270.     ESOMRL.SV[800].recipetracklist = trackedrecipes
  271.     ESOMRL.SV[800].ingtracklist = trackedingredients
  272.     SetTrackedRecipeCountText()
  273.     SetTrackedIngredientCountText()
  274.     recountTracked = 1
  275. end
  276.  
  277. local function InitKnown() -- Re-scans for known recipes any time you learn a recipe or open the recipe book.
  278.     local playername = GetUnitName("player")
  279.     for i = 1, 487 do
  280.         local savedvar = GetRecipeSavedVar(i, 1)
  281.         if IsItemLinkRecipeKnown(ESOMRL.ProvisioningLinks[i].link) == true then
  282.             if (savedvar == 2) or (savedvar == 1) then
  283.                 SetRecipeSavedVar(i, 1, 2)
  284.             else
  285.                 SetRecipeSavedVar(i, 1, 3)
  286.             end
  287.             if ESOMRL.SV[800].trackChar == true then
  288.                 if not Contains(ESOMRL.ASV[i].names, playername) then
  289.                     table.insert(ESOMRL.ASV[i].names, #ESOMRL.ASV[i].names + 1, playername)
  290.                 end
  291.             else
  292.                 if Contains(ESOMRL.ASV[i].names, playername) then
  293.                     table.remove(ESOMRL.ASV[i].names, FindName(ESOMRL.ASV[i].names, playername))
  294.                 end
  295.             end
  296.         else
  297.             if savedvar == 2 then
  298.                 SetRecipeSavedVar(i, 1, 1)
  299.             elseif savedvar == 3 then
  300.                 SetRecipeSavedVar(i, 1, 0)
  301.             end
  302.         end
  303.     end
  304.     RefreshViews()
  305.     if recountTracked == 0 then
  306.         RecountTracked()
  307.     end
  308. end
  309.  
  310. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  311. -- Functions to show and hide the recipe list, adjust for laguage settings, and remember position.
  312. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  313. local function RestorePosition() -- Restores previous window position when opened.
  314.     local left = ESOMRL.SV[800].xpos
  315.     local top = ESOMRL.SV[800].ypos
  316.     ESOMRL_MainFrame:ClearAnchors()
  317.     ESOMRL_MainFrame:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, left, top)
  318. end
  319.  
  320. local function FormatTooltipText(text) -- Formats tooltip data by language.
  321.     if GetCVar('Language.2') == 'en' then
  322.         return text
  323.     else
  324.         text = text:gsub('Makes',L.ESOMRL_MAKE)
  325.         text = text:gsub('Level',L.ESOMRL_LEVEL)
  326.         text = text:gsub('Veteran',L.ESOMRL_VETERAN)
  327.         text = text:gsub('Food',L.ESOMRL_FOOD)
  328.         text = text:gsub('Drink',L.ESOMRL_DRINK)
  329.         text = text:gsub('Psijic Ambrosia',zo_strformat("<<t:1>>",GetItemLinkName(GetItemLinkRecipeResultItemLink("|H1:item:64223:3:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h"))))
  330.         return text
  331.     end
  332. end
  333.  
  334. local function CloseMain(control, option)
  335.     if option == 1 then
  336.         InitializeTooltip(InformationTooltip, control, TOPLEFT, 8, -44, BOTTOMRIGHT)
  337.         SetTooltipText(InformationTooltip, L.ESOMRL_CLOSE)
  338.     elseif option == 2 then
  339.         ClearTooltip(InformationTooltip)
  340.     elseif option == 3 then
  341.         local control = GetControl('ESOMRL_MainFrame')
  342.         control:SetHidden(true)
  343.     end
  344. end
  345.  
  346. local function StationButtonTooltip(control, option)
  347.     if option == 1 then
  348.         InitializeTooltip(InformationTooltip, control, BOTTOMLEFT, 0, -11, TOPRIGHT)
  349.         SetTooltipText(InformationTooltip, "Master Recipe List")
  350.     elseif option == 2 then
  351.         ClearTooltip(InformationTooltip)
  352.     end
  353. end
  354.  
  355. local function InfoTooltip(option) -- Show the legend.
  356.     if setPage == 1 then
  357.         if option == 1 then
  358.             ESOMRL_MainFrameInfoBox:SetHidden(false)
  359.         elseif option == 2 then
  360.             ESOMRL_MainFrameInfoBox:SetHidden(true)
  361.         end
  362.     elseif setPage == 0 then
  363.         if option == 1 then
  364.             ESOMRL_MainFrameInfoBoxIng:SetHidden(false)
  365.         elseif option == 2 then
  366.             ESOMRL_MainFrameInfoBoxIng:SetHidden(true)
  367.         end
  368.     end
  369. end
  370.        
  371. local function ToggleTooltips(control, option) -- Handles turning list item tooltips on and off.
  372.     if option == 1 then
  373.         InitializeTooltip(InformationTooltip, control, TOPLEFT, 34, -39, BOTTOMRIGHT)
  374.         if ESOMRL.SV[800].lttshow == 1 then
  375.             SetTooltipText(InformationTooltip, L.ESOMRL_LTTHIDE)
  376.         else
  377.             SetTooltipText(InformationTooltip, L.ESOMRL_LTTSHOW)
  378.         end
  379.     elseif option == 2 then
  380.         ClearTooltip(InformationTooltip)
  381.     elseif option == 3 then
  382.         if ESOMRL.SV[800].lttshow == 1 then
  383.             ESOMRL.SV[800].lttshow = 0
  384.             ClearTooltip(InformationTooltip)
  385.             InitializeTooltip(InformationTooltip, control, TOPLEFT, 34, -39, BOTTOMRIGHT)
  386.             SetTooltipText(InformationTooltip, L.ESOMRL_LTTSHOW)
  387.         else
  388.             ESOMRL.SV[800].lttshow = 1
  389.             ClearTooltip(InformationTooltip)
  390.             InitializeTooltip(InformationTooltip, control, TOPLEFT, 34, -39, BOTTOMRIGHT)
  391.             SetTooltipText(InformationTooltip, L.ESOMRL_LTTHIDE)
  392.         end
  393.     end
  394. end
  395.  
  396. local function IngredientPanelSetup() -- Configure the ingredients display when the panel is shown.
  397.     for i = 111, 160 do
  398.         local control = ESOMRL_MainFrameIngredientsFrame:GetChild(i)
  399.         local index = i - 110
  400.         if GetIngredientSavedVar(index) == 1 then
  401.             control:SetText(LinkNameLanguageFormat(GetItemLinkName(ESOMRL.IngredientLinks[index].link)))
  402.             control:SetColor(1,1,0,1)
  403.             control:SetAlpha(1)
  404.         elseif GetIngredientSavedVar(index) == 0 then
  405.             control:SetText(LinkNameLanguageFormat(GetItemLinkName(ESOMRL.IngredientLinks[index].link)))
  406.             control:SetColor(0.7647,0.7647,0.7647,1)
  407.             control:SetAlpha(1)
  408.         end
  409.     end
  410.     if ESOMRL.SV[800].destroyjunkingredients == true then
  411.         if ESOMRL.SV[800].destroyunmarkedingredients == 0 then
  412.             ESOMRL_MainFrameIngredientsFrameTrashUncheckedButton1:SetHidden(false)
  413.             ESOMRL_MainFrameIngredientsFrameTrashUncheckedButton2:SetHidden(true)
  414.         elseif ESOMRL.SV[800].destroyunmarkedingredients == 1 then
  415.             ESOMRL_MainFrameIngredientsFrameTrashUncheckedButton1:SetHidden(true)
  416.             ESOMRL_MainFrameIngredientsFrameTrashUncheckedButton2:SetHidden(false)
  417.         end
  418.     elseif ESOMRL.SV[800].destroyjunkingredients == false then
  419.         if ESOMRL.SV[800].junkunmarkedingredients == 0 then
  420.             ESOMRL_MainFrameIngredientsFrameTrashUncheckedButton1:SetHidden(false)
  421.             ESOMRL_MainFrameIngredientsFrameTrashUncheckedButton2:SetHidden(true)
  422.         elseif ESOMRL.SV[800].junkunmarkedingredients == 1 then
  423.             ESOMRL_MainFrameIngredientsFrameTrashUncheckedButton1:SetHidden(true)
  424.             ESOMRL_MainFrameIngredientsFrameTrashUncheckedButton2:SetHidden(false)
  425.         end
  426.     end
  427. end
  428.  
  429. local function RecipePanelSetup() -- Configure the recipe display when the panel is shown.
  430.     if ESOMRL.SV[800].destroyjunkrecipes == true then
  431.         if ESOMRL.SV[800].destroyunmarkedrecipes == 0 then
  432.             ESOMRL_MainFrameListFrameBatchTrackingTrashUncheckedButton1:SetHidden(false)
  433.             ESOMRL_MainFrameListFrameBatchTrackingTrashUncheckedButton2:SetHidden(true)
  434.         elseif ESOMRL.SV[800].destroyunmarkedrecipes == 1 then
  435.             ESOMRL_MainFrameListFrameBatchTrackingTrashUncheckedButton1:SetHidden(true)
  436.             ESOMRL_MainFrameListFrameBatchTrackingTrashUncheckedButton2:SetHidden(false)
  437.         end
  438.     elseif ESOMRL.SV[800].destroyjunkrecipes == false then
  439.         if ESOMRL.SV[800].junkunmarkedrecipes == 0 then
  440.             ESOMRL_MainFrameListFrameBatchTrackingTrashUncheckedButton1:SetHidden(false)
  441.             ESOMRL_MainFrameListFrameBatchTrackingTrashUncheckedButton2:SetHidden(true)
  442.         elseif ESOMRL.SV[800].junkunmarkedrecipes == 1 then
  443.             ESOMRL_MainFrameListFrameBatchTrackingTrashUncheckedButton1:SetHidden(true)
  444.             ESOMRL_MainFrameListFrameBatchTrackingTrashUncheckedButton2:SetHidden(false)
  445.         end
  446.     end
  447. end
  448.  
  449. local function RecipeOptionPanel(option) -- Handles turning recipe config panel on and off.
  450.     if option == 1 then
  451.         InitializeTooltip(InformationTooltip, ESOMRL_MainFrameListFrame, BOTTOMLEFT, 26, 28, BOTTOMRIGHT)
  452.         if ESOMRL.SV[800].recipeconfigpanel == 0 then
  453.             SetTooltipText(InformationTooltip, L.ESOMRL_SRCONFIGPANEL)
  454.         elseif ESOMRL.SV[800].recipeconfigpanel == 1 then
  455.             SetTooltipText(InformationTooltip, L.ESOMRL_HRCONFIGPANEL)
  456.         end
  457.     elseif option == 2 then
  458.         ClearTooltip(InformationTooltip)
  459.     elseif option == 3 then
  460.         if ESOMRL.SV[800].recipeconfigpanel == 0 then
  461.             ESOMRL.SV[800].recipeconfigpanel = 1
  462.             ESOMRL_MainFrameListFrameBatchTracking:SetHidden(false)
  463.             ClearTooltip(InformationTooltip)
  464.             InitializeTooltip(InformationTooltip, ESOMRL_MainFrameListFrame, BOTTOMLEFT, 26, 28, BOTTOMRIGHT)
  465.             SetTooltipText(InformationTooltip, L.ESOMRL_HRCONFIGPANEL)
  466.         elseif ESOMRL.SV[800].recipeconfigpanel == 1 then
  467.             ESOMRL.SV[800].recipeconfigpanel = 0
  468.             ESOMRL_MainFrameListFrameBatchTracking:SetHidden(true)
  469.             ClearTooltip(InformationTooltip)
  470.             InitializeTooltip(InformationTooltip, ESOMRL_MainFrameListFrame, BOTTOMLEFT, 26, 28, BOTTOMRIGHT)
  471.             SetTooltipText(InformationTooltip, L.ESOMRL_SRCONFIGPANEL)
  472.         end
  473.         RecipePanelSetup()
  474.     end
  475. end
  476.  
  477. local function RecipePanelRestore() -- Restore previous status of recipe config panel on load.
  478.     if ESOMRL.SV[800].recipeconfigpanel == 0 then
  479.         ESOMRL_MainFrameListFrameBatchTracking:SetHidden(true)
  480.     elseif ESOMRL.SV[800].recipeconfigpanel == 1 then
  481.         ESOMRL_MainFrameListFrameBatchTracking:SetHidden(false)
  482.     end
  483.     RecipePanelSetup()
  484. end
  485.  
  486. local function OnCharacterSelected(_, charName, choice) -- Dropbox callback.
  487.     currentChar = charName
  488. end
  489.  
  490. local function SetupCharacterDropbox() -- Initialize dropbox selection of all tracked characters who know any recipes.
  491.     currentChar = GetUnitName("player")
  492.     table.insert(nameList, 1, currentChar)
  493.     for i = 1, 487 do
  494.         if next(ESOMRL.ASV[i].names) ~= nil then
  495.             for n = 1, #ESOMRL.ASV[i].names do
  496.                 local name = ESOMRL.ASV[i].names[n]
  497.                 if not Contains(nameList, name) then
  498.                     table.insert(nameList, #nameList + 1, name)
  499.                 end
  500.             end
  501.         end
  502.     end
  503.     charnameDropdown = WINDOW_MANAGER:CreateControlFromVirtual('CharacterDropdownList', ESOMRL_MainFrameListFrameBatchTracking, 'ZO_StatsDropdownRow')
  504.     charnameDropdown:SetWidth(300)
  505.     charnameDropdown:SetAnchor(TOPLEFT, ESOMRL_MainFrameListFrameBatchTracking, TOPLEFT, -4, 2)
  506.     charnameDropdown:GetNamedChild('Dropdown'):SetWidth(295)
  507.     charnameDropdown.dropdown:SetSelectedItem(currentChar)
  508.     for k,v in pairs(nameList) do
  509.         local entry = charnameDropdown.dropdown:CreateItemEntry(v, OnCharacterSelected)
  510.         charnameDropdown.dropdown:AddItem(entry)
  511.     end
  512. end
  513.  
  514. local function RemoveCharacter(option) -- Handles removing selected character from the tracking database.
  515.     if option == 1 then
  516.         InitializeTooltip(InformationTooltip, ESOMRL_MainFrameCloseButton, TOPLEFT, 8, -44, BOTTOMRIGHT)
  517.         SetTooltipText(InformationTooltip, L.ESOMRL_REMOVECHAR)
  518.     elseif option == 2 then
  519.         ClearTooltip(InformationTooltip)
  520.     elseif option == 3 then
  521.         if currentChar ~= GetUnitName("player") then
  522.             table.remove(nameList, FindName(nameList, currentChar)) -- Remove the selected character from the current name table.
  523.             for i = 1, 487 do -- Remove the selected character from the global tracking database.
  524.                 if Contains(ESOMRL.ASV[i].names, currentChar) then
  525.                     table.remove(ESOMRL.ASV[i].names, FindName(ESOMRL.ASV[i].names, currentChar))
  526.                 end
  527.             end
  528.             currentChar = GetUnitName("player") -- Set the addon-global active name to the current character.
  529.             charnameDropdown.dropdown:ClearItems() -- Clear the list of names in the dropdown menu so we can rebuild.
  530.             for k,v in pairs(nameList) do -- Rebuild using the names table we just removed a character from.
  531.                 local entry = charnameDropdown.dropdown:CreateItemEntry(v, OnCharacterSelected)
  532.                 charnameDropdown.dropdown:AddItem(entry)
  533.             end
  534.             charnameDropdown.dropdown:SetSelectedItem(currentChar) -- Set the dropdown selected item to the current character.
  535.         end
  536.     end
  537. end
  538.  
  539. local function SwitchPage(control, option) -- Handles switching between recipe and ingredient pages.
  540.     if option == 1 then
  541.         if setPage == 1 then
  542.             InitializeTooltip(InformationTooltip, control, BOTTOMLEFT, -53, -4, TOPRIGHT)
  543.             SetTooltipText(InformationTooltip, L.ESOMRL_SHOWING)
  544.         elseif setPage == 0 then
  545.             InitializeTooltip(InformationTooltip, control, BOTTOMLEFT, -53, -4, TOPRIGHT)
  546.             SetTooltipText(InformationTooltip, L.ESOMRL_SHOWRECIPE)
  547.         end
  548.     elseif option == 2 then
  549.         ClearTooltip(InformationTooltip)
  550.     elseif option == 3 then
  551.         if setPage == 1 then
  552.             ClearTooltip(InformationTooltip)
  553.             InitializeTooltip(InformationTooltip, control, BOTTOMLEFT, -53, -4, TOPRIGHT)
  554.             SetTooltipText(InformationTooltip, L.ESOMRL_SHOWRECIPE)
  555.             ESOMRL_MainFrameSelectionFrame:SetHidden(true)
  556.             ESOMRL_MainFrameListFrame:SetHidden(true)
  557.             ESOMRL_MainFrameIngredientsFrame:SetHidden(false)
  558.             SetTrackedIngredientCountText()
  559.             IngredientPanelSetup()
  560.             setPage = 0
  561.         elseif setPage == 0 then
  562.             ClearTooltip(InformationTooltip)
  563.             InitializeTooltip(InformationTooltip, control, BOTTOMLEFT, -53, -4, TOPRIGHT)
  564.             SetTooltipText(InformationTooltip, L.ESOMRL_SHOWING)
  565.             ESOMRL_MainFrameSelectionFrame:SetHidden(false)
  566.             ESOMRL_MainFrameListFrame:SetHidden(false)
  567.             ESOMRL_MainFrameIngredientsFrame:SetHidden(true)
  568.             setPage = 1
  569.         end
  570.     end
  571. end
  572.  
  573. local function WritButton(control, option) -- Button tooltip for writ lookups.
  574.     if option == 1 then
  575.         InitializeTooltip(InformationTooltip, control, TOPLEFT, 0, 0, BOTTOMRIGHT)
  576.         SetTooltipText(InformationTooltip, L.ESOMRL_FINDWRIT)
  577.     elseif option == 2 then
  578.         ClearTooltip(InformationTooltip)
  579.     end
  580. end
  581.  
  582. local function OnMoveStop() -- Saves the current window position when closed.
  583.     ESOMRL.SV[800].xpos = ESOMRL_MainFrame:GetLeft()
  584.     ESOMRL.SV[800].ypos = ESOMRL_MainFrame:GetTop()
  585. end
  586.  
  587. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  588. -- Functions related to the quest-event-based tracking of writ requirements.
  589. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  590. local function CheckForWritMatch(conditionText)
  591.     local mTable = {}
  592.     local wWords = {}
  593.     for w in conditionText:gmatch("%S+") do table.insert(wWords, #wWords + 1, LowerSpaceSpecial(w)) end
  594.     local text = LowerSpaceSpecial(conditionText)
  595.     local mCount = 0
  596.     for i = 1, 487 do
  597.         local search = LowerSpaceSpecial(GetItemLinkName(ESOMRL.ProvisioningLinks[i].item))
  598.         local name = zo_strlower(zo_strformat("<<t:1>>",GetItemLinkName(ESOMRL.ProvisioningLinks[i].item)))
  599.         if (string.find(text,search) ~= nil) then
  600.             table.insert(mTable, #mTable + 1, {search=name, pos=i}) mCount = mCount + 1
  601.         end
  602.     end
  603.     if mCount > 0 then
  604.         if mCount > 1 then
  605.             local smCount = 0
  606.             local sm = 0
  607.             for i = 1, mCount do
  608.                 local tsmCount = 0
  609.                 local sWords = {}
  610.                 local sString = mTable[i].search
  611.                 for w in sString:gmatch("%S+") do table.insert(sWords, #sWords + 1, LowerSpaceSpecial(w)) end
  612.                 for m = 1, #sWords do
  613.                     for w = 1, #wWords do
  614.                         if sWords[m] == wWords[w] then tsmCount = tsmCount + 1 end
  615.                     end
  616.                     if tsmCount > smCount then
  617.                         smCount = tsmCount
  618.                         sm = mTable[i].pos
  619.                     end
  620.                 end
  621.             end
  622.             return GetItemIdFromLink(ESOMRL.ProvisioningLinks[sm].item)
  623.         elseif mCount == 1 then
  624.             return GetItemIdFromLink(ESOMRL.ProvisioningLinks[mTable[1].pos].item)
  625.         end
  626.     else
  627.         return 0
  628.     end
  629. end
  630.  
  631. local function GetWritID()
  632.     for i = 1, MAX_JOURNAL_QUESTS do
  633.         if IsValidQuestIndex(i) then
  634.             local questType = GetJournalQuestType(i)
  635.             if questType == 4 then
  636.                 local QuestName = GetJournalQuestName(i)
  637.                 if QuestName == L.ESOMRL_WRITQUEST then
  638.                     return i
  639.                 end
  640.             end
  641.         end
  642.     end
  643.     return 0
  644. end
  645.  
  646. function StationWritCheck()
  647.     local writIndex = GetWritID()
  648.     local questTable = {}
  649.     WritQuest.reqId1 = 0
  650.     WritQuest.reqId2 = 0
  651.     local function CheckInfo(q,r)
  652.         local a, b, _, _, _, _ = GetJournalQuestConditionInfo(q,1,r)
  653.         return a, b
  654.     end
  655.     if writIndex == 0 then
  656.         WritQuest.reqId1 = 0
  657.         WritQuest.reqId2 = 0
  658.         return
  659.     end
  660.     for i = 1, GetJournalQuestNumConditions(writIndex) do
  661.         local conditionText, current = CheckInfo(writIndex,i)
  662.         table.insert(questTable, #questTable + 1, {conditionText=conditionText, current=current})
  663.     end
  664.     for r = 1, #questTable do
  665.         if string.find(questTable[r].conditionText, L.ESOMRL_WRITFINISH) then
  666.             WritQuest.reqId1 = 0
  667.             WritQuest.reqId2 = 0
  668.             return
  669.         end
  670.         if questTable[r].conditionText ~= "" and questTable[r].current == 0 then
  671.             if WritQuest.reqId1 == 0 then
  672.                 WritQuest.reqId1 = CheckForWritMatch(questTable[r].conditionText)
  673.             elseif WritQuest.reqId2 == 0 then
  674.                 WritQuest.reqId2 = CheckForWritMatch(questTable[r].conditionText)
  675.             end
  676.         end
  677.     end
  678. end
  679.  
  680. local function OnQuestAdded(eventCode, journalIndex, questName, objectiveName)
  681.     if questName == L.ESOMRL_WRITQUEST then
  682.         StationWritCheck()
  683.     end
  684. end
  685.  
  686. local function OnQuestConditionCounterChanged(eventCode, journalIndex, questName, conditionText, conditionType, currConditionVal, newConditionVal, conditionMax, isFailCondition, stepOverrideText, isPushed, isComplete, isConditionComplete, isStepHidden)
  687.     if questName == L.ESOMRL_WRITQUEST then
  688.         local a, b, _, _, _, _ = GetJournalQuestConditionInfo(journalIndex,1,1)
  689.         local c, d, _, _, _, _ = GetJournalQuestConditionInfo(journalIndex,1,2)
  690.         local e, f, _, _, _, _ = GetJournalQuestConditionInfo(journalIndex,1,2)
  691.         if string.find(a, "L.ESOMRL_WRITFINISH") or string.find(c, "L.ESOMRL_WRITFINISH") or string.find(e, "L.ESOMRL_WRITFINISH") then
  692.             WritQuest.reqId1 = 0
  693.             WritQuest.reqId2 = 0
  694.             return
  695.         elseif a == "" and c == "" then
  696.             WritQuest.reqId1 = 0
  697.             WritQuest.reqId2 = 0
  698.             return
  699.         else
  700.             StationWritCheck()
  701.         end
  702.     end
  703. end
  704.  
  705. local function OnQuestComplete(eventCode, questName, level, previousExperience, currentExperience, rank, previousPoints, currentPoints)
  706.     if questName == L.ESOMRL_WRITQUEST then
  707.         WritQuest.reqId1 = 0 WritQuest.reqId2 = 0 return
  708.     end
  709. end
  710.  
  711. local function OnQuestRemoved(eventCode, isCompleted, journalIndex, questName, zoneIndex, poiIndex)
  712.     if questName == L.ESOMRL_WRITQUEST then
  713.         WritQuest.reqId1 = 0 WritQuest.reqId2 = 0 return
  714.     end
  715. end
  716.  
  717. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  718. -- Set up hooks into various tooltips and add appropriate text.
  719. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  720. local function AddRecipeTooltipLine(control, tooltipLine, itemId, itemLink, option) -- Modifies tooltip based on various options.
  721.     local pos = 0
  722.     if option == 1 then
  723.         pos = LookupPosition(ESOMRL.RecipeMaterials, itemId)
  724.     elseif option == 0 then
  725.         pos = LookupPosition(ESOMRL.ResultMaterials, itemId)
  726.     end
  727.     if option == 1 then
  728.         control:AddVerticalPadding(20)
  729.         control:AddLine(FormatTooltipText(tooltipLine), 'ZoFontGame', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, LEFT, false)
  730.     end
  731.     if pos ~= 0 then
  732.  
  733.         if ESOMRL.ASV[800].ingfood == true then -- Show ingredients in food item tooltips (if enabled in global options).
  734.             if option == 0 then
  735.                 local inglink = ESOMRL.ProvisioningLinks[tonumber(ESOMRL.ResultMaterials[itemId].position)].link
  736.                 local ingnumber = GetItemLinkRecipeNumIngredients(inglink)
  737.                 local ingstring = ''
  738.                 for i = 1, ingnumber do
  739.                     local ing, num = GetItemLinkRecipeIngredientInfo(inglink, i)
  740.                     if i == ingnumber then
  741.                         if num > 0 then
  742.                             ingstring = ingstring .. '|cffffff' .. tostring(LinkNameLanguageFormat(ing)) .. '|r'
  743.                         else
  744.                             ingstring = ingstring .. '|c656565' .. tostring(LinkNameLanguageFormat(ing)) .. '|r'
  745.                         end
  746.                     else
  747.                         if num > 0 then
  748.                             ingstring = ingstring .. '|cffffff' .. tostring(LinkNameLanguageFormat(ing)) .. '|r' .. ', '
  749.                         else
  750.                             ingstring = ingstring .. '|c656565' .. tostring(LinkNameLanguageFormat(ing)) .. '|r' .. ', '
  751.                         end
  752.                     end
  753.                 end
  754.                 control:AddVerticalPadding(20)
  755.                 control:AddLine(L.ESOMRL_INGFOOD, 'ZoFontHeader', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, LEFT, false)
  756.                 control:AddVerticalPadding(-10)
  757.                 control:AddLine(ingstring, 'ZoFontGame', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, LEFT, false)
  758.             end
  759.         end
  760.  
  761.         if ESOMRL.ASV[800].known == true then -- Show list of characters who know/are able to craft the given recipe or food item in tooltips.
  762.             local namestring
  763.             local cstring
  764.             if next(ESOMRL.ASV[pos].names) ~= nil then
  765.                 control:AddVerticalPadding(10)
  766.                 ZO_Tooltip_AddDivider(control)
  767.                 control:AddVerticalPadding(10)
  768.                 if option == 1 then
  769.                     control:AddLine(L.ESOMRL_KNOWN, 'ZoFontHeader', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, LEFT, false)
  770.                 elseif option == 0 then
  771.                     control:AddLine(L.ESOMRL_CRAFTABLE, 'ZoFontHeader', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, LEFT, false)
  772.                 end
  773.                 local count = #ESOMRL.ASV[pos].names
  774.                 for i = 1, count do
  775.                     local name = ESOMRL.ASV[pos].names[i]
  776.                     if i == 1 then
  777.                         if count == i then
  778.                             control:AddVerticalPadding(-10)
  779.                             control:AddLine('|c66ccff' .. name .. '|r', 'ZoFontGame', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, LEFT, false)
  780.                         else
  781.                             if #name > 35 then
  782.                                 control:AddVerticalPadding(-10)
  783.                                 control:AddLine('|c66ccff' .. name .. '|r' .. ', ', 'ZoFontGame', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, LEFT, false)
  784.                             else
  785.                                 namestring = '|c66ccff' .. name .. '|r' .. ', '
  786.                                 cstring = name .. ', '
  787.                             end
  788.                         end
  789.                     else
  790.                         if count == i then
  791.                             local tempa = namestring .. '|c66ccff' .. name .. '|r'
  792.                             local tempb = cstring .. name
  793.                             if #tempb > 45 then
  794.                                 control:AddVerticalPadding(-10)
  795.                                 control:AddLine(namestring, 'ZoFontGame', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, LEFT, false)
  796.                                 control:AddVerticalPadding(-10)
  797.                                 control:AddLine('|c66ccff' .. name .. '|r', 'ZoFontGame', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, LEFT, false)
  798.                             else
  799.                                 control:AddVerticalPadding(-10)
  800.                                 control:AddLine(tempa, 'ZoFontGame', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, LEFT, false)
  801.                             end
  802.                         else
  803.                             if #name > 35 then
  804.                                 control:AddVerticalPadding(-10)
  805.                                 control:AddLine('|c66ccff' .. name .. '|r' .. ', ', 'ZoFontGame', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, LEFT, false)
  806.                             else
  807.                                 local tempa = namestring .. '|c66ccff' .. name .. '|r' .. ', '
  808.                                 local tempb = cstring .. name .. ','
  809.                                 if #tempb > 45 then
  810.                                     control:AddVerticalPadding(-10)
  811.                                     control:AddLine(namestring, 'ZoFontGame', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, LEFT, false)
  812.                                     namestring = '|c66ccff' .. name .. '|r' .. ', '
  813.                                     cstring = name .. ', '
  814.                                 else
  815.                                     namestring = tempa
  816.                                     cstring = tempb
  817.                                 end
  818.                             end
  819.                         end
  820.                     end
  821.                 end
  822.             end
  823.         end
  824.     end
  825.  
  826.     if option == 1 then -- Show if selected recipe/food item is needed for current writ (if any).
  827.         if IsItemLinkRecipeKnown(itemLink) == false then
  828.             local saved = GetRecipeSavedVar(pos, 0)
  829.             if saved == 1 then
  830.                 control:AddVerticalPadding(20)
  831.                 control:AddLine('|cfee854' .. L.ESOMRL_RTRACK .. '|r', 'ZoFontHeader2', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, CENTER, false)
  832.                 local resLink = ESOMRL.RecipeMaterials[itemId].item
  833.                 if GetItemIdFromLink(resLink) == WritQuest.reqId1 or GetItemIdFromLink(resLink) == WritQuest.reqId2 then
  834.                     control:AddLine('|cffff00' .. L.ESOMRL_NWRITU .. '|r', 'ZoFontGame', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, CENTER, false)
  835.                 end
  836.             elseif saved == 0 then
  837.                 local resLink = ESOMRL.RecipeMaterials[itemId].item
  838.                 if GetItemIdFromLink(resLink) == WritQuest.reqId1 or GetItemIdFromLink(resLink) == WritQuest.reqId2 then
  839.                     control:AddVerticalPadding(20)
  840.                     control:AddLine('|cffff00' .. L.ESOMRL_NWRITU .. '|r', 'ZoFontGame', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, CENTER, false)
  841.                 end
  842.             end
  843.         elseif IsItemLinkRecipeKnown(itemLink) == true then
  844.             local pos = tonumber(ESOMRL.RecipeMaterials[itemId].position)
  845.             local saved = GetRecipeSavedVar(pos, 0)
  846.             if saved == 2 then
  847.                 control:AddVerticalPadding(20)
  848.                 control:AddLine('|cfee854' .. L.ESOMRL_RTRACK .. '|r', 'ZoFontHeader2', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, CENTER, false)
  849.                 local resLink = ESOMRL.RecipeMaterials[itemId].item
  850.                 if GetItemIdFromLink(resLink) == WritQuest.reqId1 or GetItemIdFromLink(resLink) == WritQuest.reqId2 then
  851.                     control:AddLine('|cffff00' .. L.ESOMRL_NWRITK .. '|r', 'ZoFontGame', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, CENTER, false)
  852.                 end
  853.             elseif saved == 3 then
  854.                 local resLink = ESOMRL.RecipeMaterials[itemId].item
  855.                 if GetItemIdFromLink(resLink) == WritQuest.reqId1 or GetItemIdFromLink(resLink) == WritQuest.reqId2 then
  856.                     control:AddVerticalPadding(20)
  857.                     control:AddLine('|cffff00' .. L.ESOMRL_NWRITK .. '|r', 'ZoFontGame', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, CENTER, false)
  858.                 end
  859.             end
  860.         end
  861.     elseif option == 0 then
  862.         if pos ~= 0 then
  863.             local saved = GetRecipeSavedVar(pos, 0)
  864.             if saved == 1 or saved == 2 then
  865.                 local resLink = ESOMRL.ProvisioningLinks[tonumber(ESOMRL.ResultMaterials[itemId].position)].item
  866.                 if GetItemIdFromLink(resLink) == WritQuest.reqId1 or GetItemIdFromLink(resLink) == WritQuest.reqId2 then
  867.                     control:AddVerticalPadding(20)
  868.                     control:AddLine('|cffff00' .. L.ESOMRL_NWRIT .. '|r', 'ZoFontHeader2', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, CENTER, false)
  869.                 end
  870.             elseif saved == 0 or saved == 3 then
  871.                 local resLink = ESOMRL.ProvisioningLinks[tonumber(ESOMRL.ResultMaterials[itemId].position)].item
  872.                 if GetItemIdFromLink(resLink) == WritQuest.reqId1 or GetItemIdFromLink(resLink) == WritQuest.reqId2 then
  873.                     control:AddVerticalPadding(20)
  874.                     control:AddLine('|cffff00' .. L.ESOMRL_NWRIT .. '|r', 'ZoFontHeader2', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, CENTER, false)
  875.                 end
  876.             end
  877.         end
  878.     end
  879. end
  880.  
  881. local function AddIngredientTooltipLine(control, itemId) -- Modifies ingredient tooltip with tracked status.
  882.     local pos = LookupPosition(ESOMRL.IngredientMaterials, itemId)
  883.     if pos ~= 0 then
  884.         if GetIngredientSavedVar(pos) == 1 then
  885.             control:AddVerticalPadding(30)
  886.             control:AddLine('|cfee854' .. L.ESOMRL_ITRACK .. '|r', 'ZoFontHeader2', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, CENTER, false)
  887.         end
  888.     end
  889. end
  890.  
  891. local function HookTooltips()
  892.     local ESOMRLSetBagItemTooltip = ItemTooltip.SetBagItem
  893.     ItemTooltip.SetBagItem = function(control, bagId, slotIndex)
  894.         local itemLink = GetItemLink(bagId, slotIndex)
  895.         local itemId = GetItemIdFromLink(itemLink)
  896.         ESOMRLSetBagItemTooltip(control, bagId, slotIndex)
  897.         if ESOMRL.RecipeMaterials[itemId] ~= nil then
  898.             AddRecipeTooltipLine(control, ESOMRL.RecipeMaterials[itemId].tooltip, itemId, itemLink, 1)
  899.         elseif ESOMRL.IngredientMaterials[itemId] ~= nil then
  900.             AddIngredientTooltipLine(control, itemId)
  901.         elseif ESOMRL.ResultMaterials[itemId] ~= nil then
  902.             AddRecipeTooltipLine(control, nil, itemId, itemLink, 0)
  903.         end
  904.     end
  905.     local ESOMRLSetLootItemTooltip = ItemTooltip.SetLootItem
  906.     ItemTooltip.SetLootItem = function(control, lootId)
  907.         local itemLink = GetLootItemLink(lootId)
  908.         local itemId = GetItemIdFromLink(itemLink)
  909.         ESOMRLSetLootItemTooltip(control, lootId)
  910.         if ESOMRL.RecipeMaterials[itemId] ~= nil then
  911.             AddRecipeTooltipLine(control, ESOMRL.RecipeMaterials[itemId].tooltip, itemId, itemLink, 1)
  912.         elseif ESOMRL.IngredientMaterials[itemId] ~= nil then
  913.             AddIngredientTooltipLine(control, itemId)
  914.         elseif ESOMRL.ResultMaterials[itemId] ~= nil then
  915.             AddRecipeTooltipLine(control, nil, itemId, itemLink, 0)
  916.         end
  917.     end
  918.     local ESOMRLSetTradingHouseItemTooltip = ItemTooltip.SetTradingHouseItem
  919.     ItemTooltip.SetTradingHouseItem = function(control, tradingHouseIndex)
  920.         local itemLink = GetTradingHouseSearchResultItemLink(tradingHouseIndex)
  921.         local itemId = GetItemIdFromLink(itemLink)
  922.         ESOMRLSetTradingHouseItemTooltip(control, tradingHouseIndex)
  923.         if ESOMRL.RecipeMaterials[itemId] ~= nil then
  924.             AddRecipeTooltipLine(control, ESOMRL.RecipeMaterials[itemId].tooltip, itemId, itemLink, 1)
  925.         elseif ESOMRL.IngredientMaterials[itemId] ~= nil then
  926.             AddIngredientTooltipLine(control, itemId)
  927.         elseif ESOMRL.ResultMaterials[itemId] ~= nil then
  928.             AddRecipeTooltipLine(control, nil, itemId, itemLink, 0)
  929.         end
  930.     end
  931.     local ESOMRLSetTradingHouseListingTooltip = ItemTooltip.SetTradingHouseListing
  932.     ItemTooltip.SetTradingHouseListing = function(control, tradingHouseListingIndex)
  933.         local itemLink = GetTradingHouseListingItemLink(tradingHouseListingIndex)
  934.         local itemId = GetItemIdFromLink(itemLink)
  935.         ESOMRLSetTradingHouseListingTooltip(control, tradingHouseListingIndex)
  936.         if ESOMRL.RecipeMaterials[itemId] ~= nil then
  937.             AddRecipeTooltipLine(control, ESOMRL.RecipeMaterials[itemId].tooltip, itemId, itemLink, 1)
  938.         elseif ESOMRL.IngredientMaterials[itemId] ~= nil then
  939.             AddIngredientTooltipLine(control, itemId)
  940.         elseif ESOMRL.ResultMaterials[itemId] ~= nil then
  941.             AddRecipeTooltipLine(control, nil, itemId, itemLink, 0)
  942.         end
  943.     end
  944.     local ESOMRLSetAttachedMailItemTooltip = ItemTooltip.SetAttachedMailItem
  945.     ItemTooltip.SetAttachedMailItem = function(control, mailId, attachmentIndex)
  946.         local itemLink = GetAttachedItemLink(mailId, attachmentIndex)
  947.         local itemId = GetItemIdFromLink(itemLink)
  948.         ESOMRLSetAttachedMailItemTooltip(control, mailId, attachmentIndex)
  949.         if ESOMRL.RecipeMaterials[itemId] ~= nil then
  950.             AddRecipeTooltipLine(control, ESOMRL.RecipeMaterials[itemId].tooltip, itemId, itemLink, 1)
  951.         elseif ESOMRL.IngredientMaterials[itemId] ~= nil then
  952.             AddIngredientTooltipLine(control, itemId)
  953.         elseif ESOMRL.ResultMaterials[itemId] ~= nil then
  954.             AddRecipeTooltipLine(control, nil, itemId, itemLink, 0)
  955.         end
  956.     end
  957.     local ESOMRLSetBuybackTooltip = ItemTooltip.SetBuybackItem
  958.     ItemTooltip.SetBuybackItem = function(control, slotIndex)
  959.         local itemLink = GetBuybackItemLink(slotIndex)
  960.         local itemId = GetItemIdFromLink(itemLink)
  961.         ESOMRLSetBuybackTooltip(control, slotIndex)
  962.         if ESOMRL.RecipeMaterials[itemId] ~= nil then
  963.             AddRecipeTooltipLine(control, ESOMRL.RecipeMaterials[itemId].tooltip, itemId, itemLink, 1)
  964.         elseif ESOMRL.IngredientMaterials[itemId] ~= nil then
  965.             AddIngredientTooltipLine(control, itemId)
  966.         elseif ESOMRL.ResultMaterials[itemId] ~= nil then
  967.             AddRecipeTooltipLine(control, nil, itemId, itemLink, 0)
  968.         end
  969.     end
  970.     local ESOMRLSetTradeItemTooltip = ItemTooltip.SetTradeItem
  971.     ItemTooltip.SetTradeItem = function(control, tradeId, slotIndex)
  972.         local itemLink = GetTradeItemLink(slotIndex)
  973.         local itemId = GetItemIdFromLink(itemLink)
  974.         ESOMRLSetTradeItemTooltip(control, tradeId, slotIndex)
  975.         if ESOMRL.RecipeMaterials[itemId] ~= nil then
  976.             AddRecipeTooltipLine(control, ESOMRL.RecipeMaterials[itemId].tooltip, itemId, itemLink, 1)
  977.         elseif ESOMRL.IngredientMaterials[itemId] ~= nil then
  978.             AddIngredientTooltipLine(control, itemId)
  979.         elseif ESOMRL.ResultMaterials[itemId] ~= nil then
  980.             AddRecipeTooltipLine(control, nil, itemId, itemLink, 0)
  981.         end
  982.     end
  983.     local ESOMRLSetStoreItemTooltip = ItemTooltip.SetStoreItem
  984.     ItemTooltip.SetStoreItem = function(control, slotIndex)
  985.         local itemLink = GetStoreItemLink(slotIndex)
  986.         local itemId = GetItemIdFromLink(itemLink)
  987.         ESOMRLSetStoreItemTooltip(control, slotIndex)
  988.         if ESOMRL.RecipeMaterials[itemId] ~= nil then
  989.             AddRecipeTooltipLine(control, ESOMRL.RecipeMaterials[itemId].tooltip, itemId, itemLink, 1)
  990.         elseif ESOMRL.IngredientMaterials[itemId] ~= nil then
  991.             AddIngredientTooltipLine(control, itemId)
  992.         elseif ESOMRL.ResultMaterials[itemId] ~= nil then
  993.             AddRecipeTooltipLine(control, nil, itemId, itemLink, 0)
  994.         end
  995.     end
  996.     local ESOMRLSetLinkTooltip = PopupTooltip.SetLink
  997.     PopupTooltip.SetLink = function(control, itemLink)
  998.         local itemId = GetItemIdFromLink(itemLink)
  999.         ESOMRLSetLinkTooltip(control, itemLink)
  1000.         if ESOMRL.RecipeMaterials[itemId] ~= nil then
  1001.             AddRecipeTooltipLine(control, ESOMRL.RecipeMaterials[itemId].tooltip, itemId, itemLink, 1)
  1002.         elseif ESOMRL.IngredientMaterials[itemId] ~= nil then
  1003.             AddIngredientTooltipLine(control, itemId)
  1004.         elseif ESOMRL.ResultMaterials[itemId] ~= nil then
  1005.             AddRecipeTooltipLine(control, nil, itemId, itemLink, 0)
  1006.         end
  1007.     end
  1008. end
  1009.  
  1010. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1011. -- Set up hooks into various inventories and apply the tracking icon if enabled.
  1012. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1013. local function CreateInventoryTrackingControl(parent)
  1014.     local control = WINDOW_MANAGER:CreateControl(parent:GetName() .. 'InventoryTrackingControl', parent, CT_TEXTURE)
  1015.     control:SetDrawTier(DT_HIGH)
  1016.     control:SetHidden(true)
  1017.     return control
  1018. end
  1019.  
  1020. local function CreateInventoryKnownControl(parent)
  1021.     local control = WINDOW_MANAGER:CreateControl(parent:GetName() .. 'InventoryKnownControl', parent, CT_TEXTURE)
  1022.     control:SetDrawTier(DT_HIGH)
  1023.     control:SetHidden(true)
  1024.     return control
  1025. end
  1026.  
  1027. local function AddTrackingIndicator(control, bagID, slotIndex, itemLink, relativePoint, opt)
  1028.     local TrackingControl = control:GetNamedChild('InventoryTrackingControl')
  1029.     local KnownControl = control:GetNamedChild('InventoryKnownControl')
  1030.     local itemType = GetItemLinkItemType(itemLink)
  1031.     local itemId = GetItemIdFromLink(itemLink)
  1032.     local playerChar = GetUnitName("player")
  1033.     local IsGridViewEnabled
  1034.    
  1035.     if not ESOMRL.ASV[800].inventoryicons then
  1036.         if TrackingControl then TrackingControl:SetHidden(true) end
  1037.         if KnownControl then KnownControl:SetHidden(true) end
  1038.         return
  1039.     end
  1040.    
  1041.     if not TrackingControl then TrackingControl = CreateInventoryTrackingControl(control) else TrackingControl:SetHidden(true) end
  1042.     if not KnownControl then KnownControl = CreateInventoryKnownControl(control) else KnownControl:SetHidden(true) end
  1043.    
  1044.     if itemType ~= ITEMTYPE_INGREDIENT and itemType ~= ITEMTYPE_RECIPE then
  1045.         TrackingControl:SetHidden(true)
  1046.         KnownControl:SetHidden(true)
  1047.         return
  1048.     end
  1049.     if itemType == ITEMTYPE_INGREDIENT and ESOMRL.IngredientMaterials[itemId] == nil then
  1050.         TrackingControl:SetHidden(true)
  1051.         KnownControl:SetHidden(true)
  1052.         return
  1053.     end
  1054.     if itemType == ITEMTYPE_RECIPE and ESOMRL.RecipeMaterials[itemId] == nil then
  1055.         TrackingControl:SetHidden(true)
  1056.         KnownControl:SetHidden(true)
  1057.         return
  1058.     end
  1059.    
  1060.     if ( control.isGrid or ( control:GetWidth() - control:GetHeight() < 5 ) ) then
  1061.         IsGridViewEnabled = true else IsGridViewEnabled = false
  1062.     end
  1063.    
  1064.     local controlName = WINDOW_MANAGER:GetControlByName(control:GetName() .. 'Name')
  1065.     TrackingControl:ClearAnchors()
  1066.    
  1067.     if opt == 2 then
  1068.         TrackingControl:SetAnchor(LEFT, controlName, relativePoint, ESOMRL.ASV[800].gstoreiconoffset, 9)
  1069.         KnownControl:SetAnchor(LEFT, controlName, relativePoint, ESOMRL.ASV[800].gstoreiconoffset, 9)
  1070.     elseif opt == 3 then
  1071.         TrackingControl:SetAnchor(LEFT, controlName, relativePoint, ESOMRL.ASV[800].glistingiconoffset, 0)
  1072.         KnownControl:SetAnchor(LEFT, controlName, relativePoint, ESOMRL.ASV[800].glistingiconoffset, 0)
  1073.    
  1074.    
  1075.    
  1076.     elseif opt == 1 then
  1077.         if IsGridViewEnabled then
  1078.             TrackingControl:SetAnchor(LEFT, parent, BOTTOMLEFT, 4, -12)
  1079.             KnownControl:SetAnchor(LEFT, parent, BOTTOMLEFT, 4, -12)
  1080.         else
  1081.             TrackingControl:SetAnchor(LEFT, controlName, relativePoint, ESOMRL.ASV[800].bagiconoffset)
  1082.             KnownControl:SetAnchor(LEFT, controlName, relativePoint, ESOMRL.ASV[800].bagiconoffset)
  1083.         end
  1084.     end
  1085.  
  1086.     if itemType == ITEMTYPE_INGREDIENT then
  1087.         local saved = GetIngredientSavedVar(tonumber(ESOMRL.IngredientMaterials[itemId].position))
  1088.         if KnownControl then KnownControl:SetHidden(true) end
  1089.         if saved == 0 then
  1090.             if TrackingControl then TrackingControl:SetHidden(true) end
  1091.         else
  1092.             if IsGridViewEnabled then
  1093.                 TrackingControl:SetDimensions(14, 14)
  1094.                 TrackingControl:SetTexture('/MasterRecipeList/textures/tracking_igv.dds')
  1095.                 TrackingControl:SetHidden(false)
  1096.                 KnownControl:SetHidden(true)
  1097.             else
  1098.                 TrackingControl:SetDimensions(20, 20)
  1099.                 TrackingControl:SetTexture('/MasterRecipeList/textures/tracking.dds')
  1100.                 TrackingControl:SetHidden(false)
  1101.                 KnownControl:SetHidden(true)
  1102.             end
  1103.         end
  1104.     elseif itemType == ITEMTYPE_RECIPE then
  1105.         local saved = GetRecipeSavedVar(tonumber(ESOMRL.RecipeMaterials[itemId].position), 1)
  1106.         if (saved ~= 1) and (saved ~= 2) then
  1107.             if TrackingControl then TrackingControl:SetHidden(true) end
  1108.             local pos = tonumber(ESOMRL.RecipeMaterials[itemId].position)
  1109.             if not Contains(ESOMRL.ASV[pos].names, nameList[ESOMRL.SV[800].trackingchar]) then
  1110.                 if IsGridViewEnabled then
  1111.                     KnownControl:SetDimensions(14, 14)
  1112.                     KnownControl:SetTexture('/MasterRecipeList/textures/trackcknown_igv.dds')
  1113.                     KnownControl:SetHidden(false)
  1114.                 else
  1115.                     KnownControl:SetDimensions(20, 20)
  1116.                     KnownControl:SetTexture('/MasterRecipeList/textures/trackcknown.dds')
  1117.                     KnownControl:SetHidden(false)
  1118.                 end
  1119.             elseif ESOMRL.SV[800].altknown then
  1120.                 if ESOMRL.SV[800].altknownself then
  1121.                     if Contains(ESOMRL.ASV[pos].names, playerChar) then
  1122.                         if IsGridViewEnabled then
  1123.                             KnownControl:SetDimensions(14, 14)
  1124.                             KnownControl:SetTexture('/MasterRecipeList/textures/trackaknown_igv.dds')
  1125.                             KnownControl:SetHidden(false)
  1126.                         else
  1127.                             KnownControl:SetDimensions(20, 20)
  1128.                             KnownControl:SetTexture('/MasterRecipeList/textures/trackaknown.dds')
  1129.                             KnownControl:SetHidden(false)
  1130.                         end
  1131.                     end
  1132.                 elseif not ESOMRL.SV[800].altknownself then
  1133.                     if Contains(ESOMRL.ASV[pos].names, nameList[ESOMRL.SV[800].trackingchar]) then
  1134.                         if IsGridViewEnabled then
  1135.                             KnownControl:SetDimensions(14, 14)
  1136.                             KnownControl:SetTexture('/MasterRecipeList/textures/trackaknown_igv.dds')
  1137.                             KnownControl:SetHidden(false)
  1138.                         else
  1139.                             KnownControl:SetDimensions(20, 20)
  1140.                             KnownControl:SetTexture('/MasterRecipeList/textures/trackaknown.dds')
  1141.                             KnownControl:SetHidden(false)
  1142.                         end
  1143.                     end
  1144.                 end
  1145.             end
  1146.         else
  1147.             if IsGridViewEnabled then
  1148.                 if KnownControl then KnownControl:SetHidden(true) end
  1149.                 TrackingControl:SetDimensions(14, 14)
  1150.                 TrackingControl:SetTexture('/MasterRecipeList/textures/tracking_igv.dds')
  1151.                 TrackingControl:SetHidden(false)
  1152.             else
  1153.                 if KnownControl then KnownControl:SetHidden(true) end
  1154.                 TrackingControl:SetDimensions(20, 20)
  1155.                 TrackingControl:SetTexture('/MasterRecipeList/textures/tracking.dds')
  1156.                 TrackingControl:SetHidden(false)
  1157.             end
  1158.         end
  1159.     else
  1160.         if TrackingControl then TrackingControl:SetHidden(true) end
  1161.         if KnownControl then KnownControl:SetHidden(true) end
  1162.     end
  1163.  
  1164.     if FCOIsMarked and ESOMRL.SV[800].fcoitemsaver == true then -- Compatibility for FCO ItemSaver
  1165.         if opt == 1 then
  1166.             if itemType == ITEMTYPE_INGREDIENT and ESOMRL.IngredientMaterials[itemId] ~= nil then
  1167.                 local saved = GetIngredientSavedVar(tonumber(ESOMRL.IngredientMaterials[itemId].position))
  1168.                 if saved == 0 then
  1169.                     FCOMarkItem(bagID, slotIndex, 1, false, true)
  1170.                 else
  1171.                     if TrackingControl then TrackingControl:SetHidden(true) end
  1172.                     FCOMarkItem(bagID, slotIndex, 1, true, true)
  1173.                 end
  1174.             elseif itemType == ITEMTYPE_RECIPE and ESOMRL.RecipeMaterials[itemId] ~= nil then
  1175.                 local saved = GetRecipeSavedVar(tonumber(ESOMRL.RecipeMaterials[itemId].position), 1)
  1176.                 if (saved ~= 1) and (saved ~= 2) then
  1177.                     FCOMarkItem(bagID, slotIndex, 1, false, true)
  1178.                 else
  1179.                     if TrackingControl then TrackingControl:SetHidden(true) end
  1180.                     FCOMarkItem(bagID, slotIndex, 1, true, true)
  1181.                 end
  1182.             end
  1183.         end
  1184.     elseif FCOIsMarked and ESOMRL.SV[800].fcoitemsaver == false then
  1185.         if opt == 1 then
  1186.             if itemType == ITEMTYPE_INGREDIENT and ESOMRL.IngredientMaterials[itemId] ~= nil then
  1187.                 FCOMarkItem(bagID, slotIndex, 1, false, true)
  1188.             elseif itemType == ITEMTYPE_RECIPE and ESOMRL.RecipeMaterials[itemId] ~= nil then
  1189.                 FCOMarkItem(bagID, slotIndex, 1, false, true)
  1190.             end
  1191.         end
  1192.     end
  1193. end
  1194.  
  1195. local function HookBags( ... )
  1196.     for k,v in pairs(PLAYER_INVENTORY.inventories) do
  1197.         local listView = v.listView
  1198.         if ( listView and listView.dataTypes and listView.dataTypes[1] ) then
  1199.             local ESOMRLHookBags = listView.dataTypes[1].setupCallback
  1200.             listView.dataTypes[1].setupCallback = function(control, slot)
  1201.             ESOMRLHookBags(control, slot)
  1202.                 local itemLink = GetItemLink(control.dataEntry.data.bagId, control.dataEntry.data.slotIndex, LINK_STYLE_BRACKETS)
  1203.                 AddTrackingIndicator(control, control.dataEntry.data.bagId, control.dataEntry.data.slotIndex, itemLink, RIGHT, 1)
  1204.             end            
  1205.         end
  1206.     end
  1207. end
  1208.  
  1209. local function HookTradeHouse( ... )
  1210.     local ESOMRLHookTradeHouseSearch = TRADING_HOUSE.m_searchResultsList.dataTypes[1].setupCallback
  1211.     TRADING_HOUSE.m_searchResultsList.dataTypes[1].setupCallback = function( ... )
  1212.     local control, data = ...
  1213.     ESOMRLHookTradeHouseSearch( ... )
  1214.         if ( control.slotControlType and control.slotControlType == 'listSlot' and control.dataEntry.data.slotIndex ) then
  1215.             local itemLink = GetTradingHouseSearchResultItemLink(control.dataEntry.data.slotIndex, LINK_STYLE_BRACKETS)
  1216.             AddTrackingIndicator(control, nil, nil, itemLink, RIGHT, 2)
  1217.         end
  1218.     end
  1219.     local ESOMRLHookTradeHouseListing = TRADING_HOUSE.m_postedItemsList.dataTypes[2].setupCallback
  1220.     TRADING_HOUSE.m_postedItemsList.dataTypes[2].setupCallback = function( ... )
  1221.     local control, data = ...
  1222.     ESOMRLHookTradeHouseListing( ... )
  1223.         if ( control.slotControlType and control.slotControlType == 'listSlot' and control.dataEntry.data.slotIndex ) then
  1224.             local itemLink = GetTradingHouseListingItemLink(control.dataEntry.data.slotIndex, LINK_STYLE_BRACKETS)
  1225.             AddTrackingIndicator(control, nil, nil, itemLink, RIGHT, 3)
  1226.         end
  1227.     end
  1228. end
  1229.  
  1230. local function HookBuyback( ... )
  1231.     local ESOMRLHookBuybackList = ZO_BuyBackList.dataTypes[1].setupCallback
  1232.     ZO_BuyBackList.dataTypes[1].setupCallback = function( ... )
  1233.     local control, data = ...
  1234.     ESOMRLHookBuybackList( ... )
  1235.         if ( control.slotControlType and control.slotControlType == 'listSlot' and control.dataEntry.data.slotIndex ) then
  1236.             local itemLink = GetBuybackItemLink(control.dataEntry.data.slotIndex, LINK_STYLE_BRACKETS)
  1237.             AddTrackingIndicator(control, control.dataEntry.data.bagId, control.dataEntry.data.slotIndex, itemLink, RIGHT, 1)
  1238.         end
  1239.     end
  1240. end
  1241.  
  1242. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1243. --Handle coloring the cooking station categories and adding optional stat and writ tracking icons.
  1244. --------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1245. local function ClearStationSelection()
  1246.     local selectedNode = stationControl.recipeTree.selectedNode
  1247.     if selectedNode then selectedNode.selected = false selectedNode = nil stationControl:RefreshRecipeList() end
  1248.     stationControl.resultTooltip:SetHidden(true)
  1249.     for ingredientIndex, ingredientSlot in ipairs(stationControl.ingredientRows) do
  1250.         ingredientSlot:ClearItem()
  1251.     end
  1252. end
  1253.  
  1254. local function ToggleStationTooltips(control, option) -- Handles turning cooking station item tooltips on and off.
  1255.     if option == 1 then
  1256.         InitializeTooltip(InformationTooltip, control, BOTTOMLEFT, 0, -11, TOPRIGHT)
  1257.         if ESOMRL.SV[800].sttshow == 1 then
  1258.             SetTooltipText(InformationTooltip, L.ESOMRL_LTTHIDE)
  1259.         else
  1260.             SetTooltipText(InformationTooltip, L.ESOMRL_LTTSHOW)
  1261.         end
  1262.     elseif option == 2 then
  1263.         ClearTooltip(InformationTooltip)
  1264.     elseif option == 3 then
  1265.         if ESOMRL.SV[800].sttshow == 1 then
  1266.             stationControl.resultTooltip:SetHidden(true)
  1267.             ESOMRL.SV[800].sttshow = 0
  1268.             ClearTooltip(InformationTooltip)
  1269.             InitializeTooltip(InformationTooltip, control, BOTTOMLEFT, 0, -11, TOPRIGHT)
  1270.             SetTooltipText(InformationTooltip, L.ESOMRL_LTTSHOW)
  1271.         else
  1272.             local selectedNode = stationControl.recipeTree.selectedNode
  1273.             if selectedNode and selectedNode.selected then
  1274.                 stationControl.resultTooltip:SetHidden(false)
  1275.             end
  1276.             ESOMRL.SV[800].sttshow = 1
  1277.             ClearTooltip(InformationTooltip)
  1278.             InitializeTooltip(InformationTooltip, control, BOTTOMLEFT, 0, -11, TOPRIGHT)
  1279.             SetTooltipText(InformationTooltip, L.ESOMRL_LTTHIDE)
  1280.         end
  1281.     end
  1282. end
  1283.  
  1284. local function HighlightTracked(control, option) -- Toggle highlighting tracked items at the cooking station.
  1285.     if option == 1 then
  1286.         InitializeTooltip(InformationTooltip, control, BOTTOMLEFT, 0, -11, TOPRIGHT)
  1287.         if ESOMRL.SV[800].stmarked == 1 then
  1288.             SetTooltipText(InformationTooltip, L.ESOMRL_STRACKN)
  1289.         else
  1290.             SetTooltipText(InformationTooltip, L.ESOMRL_STRACKY)
  1291.         end
  1292.     elseif option == 2 then
  1293.         ClearTooltip(InformationTooltip)
  1294.     elseif option == 3 then
  1295.         if ESOMRL.SV[800].stmarked == 1 then
  1296.             ESOMRL.SV[800].stmarked = 0
  1297.             stationControl:RefreshRecipeList()
  1298.             ClearTooltip(InformationTooltip)
  1299.             InitializeTooltip(InformationTooltip, control, BOTTOMLEFT, 0, -11, TOPRIGHT)
  1300.             SetTooltipText(InformationTooltip, L.ESOMRL_STRACKY)
  1301.         else
  1302.             ESOMRL.SV[800].stmarked = 1
  1303.             stationControl:RefreshRecipeList()
  1304.             ClearTooltip(InformationTooltip)
  1305.             InitializeTooltip(InformationTooltip, control, BOTTOMLEFT, 0, -11, TOPRIGHT)
  1306.             SetTooltipText(InformationTooltip, L.ESOMRL_STRACKN)
  1307.         end
  1308.     end
  1309. end
  1310.  
  1311. local function SetStationIcons(control, list, headerText, hasWrit, hasTrack) -- Add stat indicator if enabled.
  1312.     local recipeListName, numRecipes, upIcon, downIcon, overIcon, disabledIcon, createSound = GetRecipeListInfo(list)
  1313.     local recipeListName = string.upper(recipeListName)
  1314.     local function markTrack() control.text:SetText(control.text:GetText() .. StationIcons[9]) end
  1315.     local function markWrit() control.text:SetText(control.text:GetText() .. StationIcons[8]) end
  1316.     if list == 1 or list == 8 then
  1317.         if recipeListName == headerText then
  1318.             if ESOMRL.ASV[800].stationstats then control.text:SetText(headerText .. StationIcons[1]) else control.text:SetText(headerText) end
  1319.             if hasTrack then markTrack() end
  1320.             if hasWrit then markWrit() end
  1321.         end
  1322.     elseif list== 2 or list == 9 then
  1323.         if recipeListName == headerText then
  1324.             if ESOMRL.ASV[800].stationstats then control.text:SetText(headerText .. StationIcons[2]) else control.text:SetText(headerText) end
  1325.             if hasTrack then markTrack() end
  1326.             if hasWrit then markWrit() end
  1327.         end
  1328.     elseif list == 3 or list == 10 then
  1329.         if recipeListName == headerText then
  1330.             if ESOMRL.ASV[800].stationstats then control.text:SetText(headerText .. StationIcons[3]) else control.text:SetText(headerText) end
  1331.             if hasTrack then markTrack() end
  1332.             if hasWrit then markWrit() end
  1333.         end
  1334.     elseif list == 4 or list == 11 then
  1335.         if recipeListName == headerText then
  1336.             if ESOMRL.ASV[800].stationstats then control.text:SetText(headerText .. StationIcons[4]) else control.text:SetText(headerText) end
  1337.             if hasTrack then markTrack() end
  1338.             if hasWrit then markWrit() end
  1339.         end
  1340.     elseif list == 5 or list == 12 then
  1341.         if recipeListName == headerText then
  1342.             if ESOMRL.ASV[800].stationstats then control.text:SetText(headerText .. StationIcons[5]) else control.text:SetText(headerText) end
  1343.             if hasTrack then markTrack() end
  1344.             if hasWrit then markWrit() end
  1345.         end
  1346.     elseif list == 6 or list == 13 then
  1347.         if recipeListName == headerText then
  1348.             if ESOMRL.ASV[800].stationstats then control.text:SetText(headerText .. StationIcons[6]) else control.text:SetText(headerText) end
  1349.             if hasTrack then markTrack() end
  1350.             if hasWrit then markWrit() end
  1351.         end
  1352.     elseif list == 7 or list == 14 then
  1353.         if recipeListName == headerText then
  1354.             if ESOMRL.ASV[800].stationstats then control.text:SetText(headerText .. StationIcons[7]) else control.text:SetText(headerText) end
  1355.             if hasTrack then markTrack() end
  1356.             if hasWrit then markWrit() end
  1357.         end
  1358.     elseif list == 15 then
  1359.         if recipeListName == headerText then
  1360.             control.text:SetText(headerText)
  1361.             if hasTrack then markTrack() end
  1362.         end
  1363.     end
  1364. end
  1365.  
  1366. local function SetStationColors(control, opt, recipeListIndex) -- Colorize cooking station recipe headers by quality.
  1367.     local headerText = control.text:GetText():gsub("  |.*",''):gsub(" |.*",'')
  1368.     local function setWritColor(recipeListName, header, cv, hasWrit, hasTrack)
  1369.         local r, g, b
  1370.         if cv == 1 then
  1371.             if recipeListName == headerText then
  1372.                 if StationControls[header].c == nil then StationControls[header].c = control end
  1373.                 if opt == 1 then r, g, b = 0.176, 0.773, 0.055 else r, g, b = 0.314, 0.91, 0.192 end
  1374.                 control.text:SetColor(r,g,b)
  1375.                 SetStationIcons(control, header, headerText, hasWrit, hasTrack)
  1376.             end
  1377.         elseif cv == 2 then
  1378.             if recipeListName == headerText then
  1379.                 if StationControls[header].c == nil then StationControls[header].c = control end
  1380.                 if opt == 1 then r, g, b = 0.227, 0.573, 1 else r, g, b = 0.365, 0.71, 1 end
  1381.                 control.text:SetColor(r,g,b)
  1382.                 SetStationIcons(control, header, headerText, hasWrit, hasTrack)
  1383.             end
  1384.         elseif cv == 3 then
  1385.             if recipeListName == headerText then
  1386.                 if StationControls[header].c == nil then StationControls[header].c = control end
  1387.                 if opt == 1 then r, g, b = 0.627, 0.18, 0.969 else r, g, b = 0.765, 0.318, 1 end
  1388.                 control.text:SetColor(r,g,b)
  1389.                 SetStationIcons(control, header, headerText, hasWrit, hasTrack)
  1390.             end
  1391.         elseif cv == 4 then
  1392.             if recipeListName == headerText then
  1393.                 if StationControls[header].c == nil then StationControls[header].c = control end
  1394.                 if opt == 1 then r, g, b = 0.933, 0.792, 0.165 else r, g, b = 1, 0.929, 0.302 end
  1395.                 control.text:SetColor(r,g,b)
  1396.                 SetStationIcons(control, header, headerText, hasWrit, hasTrack)
  1397.             end
  1398.         end
  1399.     end
  1400.     if recipeListIndex ~= nil then
  1401.         local countWrit = false
  1402.         local countTrack = false
  1403.         local recipeListName, numRecipes, upIcon, downIcon, overIcon, disabledIcon, createSound = GetRecipeListInfo(recipeListIndex)
  1404.         recipeListName = string.upper(recipeListName)
  1405.         local cv = StationChecking[recipeListIndex].cv
  1406.         for i = 1, #StationChecking[recipeListIndex].tr do
  1407.             if StationChecking[recipeListIndex].tr[i].writ == 1 then countWrit = true break end
  1408.         end
  1409.         for i = 1, #StationChecking[recipeListIndex].tr do
  1410.             if StationChecking[recipeListIndex].tr[i].track == 1 then countTrack = true break end
  1411.         end
  1412.         setWritColor(recipeListName, recipeListIndex, cv, countWrit, countTrack)
  1413.     else
  1414.         for c = 1, GetNumRecipeLists() do
  1415.             local countWrit = false
  1416.             local countTrack = false
  1417.             local recipeListName, numRecipes, upIcon, downIcon, overIcon, disabledIcon, createSound = GetRecipeListInfo(c)
  1418.             recipeListName = string.upper(recipeListName)
  1419.             if( StationChecking[c] ~= nil ) then
  1420.                 local cv = StationChecking[c].cv
  1421.                 for i = 1, #StationChecking[c].tr do
  1422.                     if StationChecking[c].tr[i].writ == 1 then countWrit = true break end
  1423.                 end
  1424.                 for i = 1, #StationChecking[c].tr do
  1425.                     if StationChecking[c].tr[i].track == 1 then countTrack = true break end
  1426.                 end
  1427.                 setWritColor(recipeListName, c, cv, countWrit, countTrack)
  1428.             end
  1429.         end
  1430.     end
  1431. end
  1432.  
  1433. local function SetWritColor(self)
  1434.     local recipeListIndex = self.data.recipeListIndex
  1435.     local recipeIndex = self.data.recipeIndex
  1436.     local itemLink = GetRecipeResultItemLink(recipeListIndex, recipeIndex)
  1437.     local itemId = GetItemIdFromLink(itemLink)
  1438.     local control = StationControls[recipeListIndex].c
  1439.     local saved = GetRecipeSavedVar(LookupPosition(ESOMRL.ResultMaterials, itemId), 1)
  1440.     local sub = ESOMRL.ResultMaterials[itemId].sub
  1441.     StationChecking[recipeListIndex].tr[sub].writ = 0
  1442.     StationChecking[recipeListIndex].tr[sub].track = 0
  1443.     if itemId == WritQuest.reqId1 or itemId == WritQuest.reqId2 then
  1444.         StationChecking[recipeListIndex].tr[sub].writ = 1
  1445.         SetStationColors(control, 1, recipeListIndex)
  1446.         if not self.enabled then
  1447.             return 0.878,0.878,0.298
  1448.         elseif self.mouseover then
  1449.             return 1,1,0.394
  1450.         else
  1451.             return 1,1,0
  1452.         end
  1453.     elseif ( ( (saved == 1) or (saved == 2) ) and ( ESOMRL.SV[800].stmarked == 1 ) ) then
  1454.         StationChecking[recipeListIndex].tr[sub].track = 1
  1455.         SetStationColors(control, 1, recipeListIndex)
  1456.         if not self.enabled then
  1457.             return 0,0.82,0.91
  1458.         elseif self.selected or self.mouseover then
  1459.             return 0.2,1,1
  1460.         else
  1461.             return 0,0.91,1
  1462.         end
  1463.     elseif not self.enabled then
  1464.         SetStationColors(control, 1, recipeListIndex)
  1465.         return GetInterfaceColor(INTERFACE_COLOR_TYPE_TEXT_COLORS, INTERFACE_TEXT_COLOR_DISABLED)
  1466.     elseif self.selected then
  1467.         SetStationColors(control, 1, recipeListIndex)
  1468.         return GetInterfaceColor(INTERFACE_COLOR_TYPE_TEXT_COLORS, INTERFACE_TEXT_COLOR_SELECTED)
  1469.     elseif self.mouseover then
  1470.         SetStationColors(control, 1, recipeListIndex)
  1471.         return GetInterfaceColor(INTERFACE_COLOR_TYPE_TEXT_COLORS, INTERFACE_TEXT_COLOR_HIGHLIGHT)
  1472.     elseif self.meetsLevelReq and self.meetsQualityReq then
  1473.         SetStationColors(control, 1, recipeListIndex)
  1474.         return GetInterfaceColor(INTERFACE_COLOR_TYPE_TEXT_COLORS, INTERFACE_TEXT_COLOR_NORMAL)
  1475.     end
  1476.     return ZO_ERROR_COLOR:UnpackRGBA()
  1477. end
  1478.  
  1479. local function HookStation()
  1480.     local ESOMRL_ZO_IconHeader_Setup = ZO_IconHeader_Setup
  1481.     ZO_IconHeader_Setup = function(control,...)
  1482.         ESOMRL_ZO_IconHeader_Setup(control,...)
  1483.         if GetCraftingInteractionType() == 5 then SetStationColors(control, 1) end
  1484.     end
  1485.     local ESOMRL_ZO_IconHeader_OnMouseEnter = ZO_IconHeader_OnMouseEnter
  1486.     ZO_IconHeader_OnMouseEnter = function(control)
  1487.         ESOMRL_ZO_IconHeader_OnMouseEnter(control)
  1488.         if GetCraftingInteractionType() == 5 then SetStationColors(control, 2) end
  1489.     end
  1490.     local ESOMRL_ZO_IconHeader_OnMouseExit = ZO_IconHeader_OnMouseExit
  1491.     ZO_IconHeader_OnMouseExit = function(control)
  1492.         ESOMRL_ZO_IconHeader_OnMouseExit(control)
  1493.         if GetCraftingInteractionType() == 5 then SetStationColors(control, 1) end
  1494.     end
  1495.     local ESOMRL_ZO_ProvisionerRow_GetTextColor = ZO_ProvisionerRow_GetTextColor
  1496.     ZO_ProvisionerRow_GetTextColor = function(self)
  1497.         return SetWritColor(self)
  1498.     end
  1499.  
  1500.     local ESOMRL_ZO_ProvisionerRefreshRecipeDetails = ZO_Provisioner.RefreshRecipeDetails
  1501.     ZO_Provisioner.RefreshRecipeDetails = function(self,...)
  1502.         local recipeListIndex, recipeIndex = self:GetSelectedRecipeListIndex(), self:GetSelectedRecipeIndex()
  1503.         local itemLink = GetRecipeResultItemLink(recipeListIndex, recipeIndex)
  1504.         local itemId = GetItemIdFromLink(itemLink)
  1505.         local name, icon = GetRecipeResultItemInfo(recipeListIndex, recipeIndex)
  1506.         stationSelection = LinkNameLanguageFormat(name) -- Store the selected item name for interactive use elsewhere.
  1507.         ESOMRL_ZO_ProvisionerRefreshRecipeDetails(self,...)
  1508.         if ESOMRL.SV[800].sttshow == 0 then self.resultTooltip:SetHidden(true) else self.resultTooltip:SetHidden(false) end
  1509.         if itemId == WritQuest.reqId1 or itemId == WritQuest.reqId2 then
  1510.             self.resultTooltip:AddVerticalPadding(20)
  1511.             self.resultTooltip:AddLine('|cffff00' .. L.ESOMRL_NWRIT .. '|r', 'ZoFontHeader2', 1, 1, 1, CENTER, MODIFY_TEXT_TYPE_NONE, CENTER, false)
  1512.         end
  1513.     end
  1514.  
  1515.     local ESOMRL_ZO_ProvisionerStartInteract = ZO_Provisioner.StartInteract
  1516.     ZO_Provisioner.StartInteract = function(self,...)
  1517.         ESOMRL_ZO_ProvisionerStartInteract(self,...)
  1518.         stationControl = self -- Store the station control for interactive use elsewhere.
  1519.         stationControl:RefreshRecipeList()
  1520.     end
  1521.     local ESOMRL_ZO_ProvisionerOnSceneShowing = ZO_Provisioner.OnSceneShowing
  1522.     ZO_Provisioner.OnSceneShowing = function(self)
  1523.         ESOMRL_ZO_ProvisionerOnSceneShowing(self)
  1524.         if stationItem == 0 then
  1525.             stationControl.resultTooltip:SetHidden(true)
  1526.             for ingredientIndex, ingredientSlot in ipairs(stationControl.ingredientRows) do ingredientSlot:ClearItem() end
  1527.             stationItem = 1
  1528.         end
  1529.     end
  1530.     local ESOMRL_ZO_ProvisionerOnTabFilterChanged = ZO_Provisioner.OnTabFilterChanged
  1531.     ZO_Provisioner.OnTabFilterChanged = function(self, filterData)
  1532.         ESOMRL_ZO_ProvisionerOnTabFilterChanged(self, filterData)
  1533.         ClearStationSelection()
  1534.     end
  1535.  
  1536.     local ESOMRL_ZO_CheckButton_OnClicked = ZO_CheckButton_OnClicked
  1537.     ZO_CheckButton_OnClicked = function(buttonControl, mouseButton)
  1538.     ESOMRL_ZO_CheckButton_OnClicked(buttonControl, mouseButton)
  1539.         if GetCraftingInteractionType() == 5 then
  1540.             ClearStationSelection()
  1541.         end
  1542.     end
  1543.  
  1544.     local ESOMRL_ZO_IconHeader_UpdateSize = ZO_IconHeader_UpdateSize
  1545.     ZO_IconHeader_UpdateSize = function(control)
  1546.         ESOMRL_ZO_IconHeader_UpdateSize(control)
  1547.         if GetCraftingInteractionType() == 5 then
  1548.             local _, textHeight = control.text:GetTextDimensions()
  1549.             control.text:SetDimensionConstraints(0, 0, 580, 0)
  1550.             control.text:SetDimensions(580, textHeight)
  1551.         end
  1552.     end
  1553.  
  1554.     local ESOMRL_ZO_TreeHeader_OnMouseUp = ZO_TreeHeader_OnMouseUp
  1555.     ZO_TreeHeader_OnMouseUp = function(self,...)
  1556.         if GetCraftingInteractionType() == 5 then
  1557.             local treeNode = self.node.tree
  1558.             if treeNode.exclusive or treeNode.open then
  1559.                 treeNode.exclusive = false
  1560.                 treeNode.open = false
  1561.             end
  1562.             stationNav = 1
  1563.             stationItem = 1
  1564.             ClearStationSelection()
  1565.         end
  1566.         ESOMRL_ZO_TreeHeader_OnMouseUp(self,...)
  1567.     end
  1568.  
  1569.     local ESOMRL_ZO_TreeSetNodeOpen = ZO_Tree.SetNodeOpen
  1570.     ZO_Tree.SetNodeOpen = function(self, treeNode, open,...)
  1571.         if GetCraftingInteractionType() == 5 then
  1572.             if stationNode == 0 then open = false stationNode = 1 end
  1573.             if stationItem == 0 or stationNav == 0 then open = false end
  1574.         end
  1575.         ESOMRL_ZO_TreeSetNodeOpen(self, treeNode, open,...)
  1576.     end
  1577. end
  1578.  
  1579. local function OnEndCraftingStationInteract(eventCode)
  1580.     ESOMRL:SetHidden(true)
  1581.     stationControl = nil
  1582.     EVENT_MANAGER:UnregisterForEvent(ESOMRL.Name, EVENT_END_CRAFTING_STATION_INTERACT)
  1583. end
  1584.  
  1585. local function OnCraftingStationInteract(eventCode, craftSkill)
  1586.     if craftSkill == CRAFTING_TYPE_PROVISIONING then
  1587.         local controlName = ZO_ProvisionerTopLevelNavigationContainer
  1588.         if ESOMRL:IsHidden() then
  1589.             if KhrillMasterCook_settings then
  1590.                 ESOMRL:ClearAnchors() ESOMRL:SetAnchor(TOPLEFT, controlName, TOPLEFT, 58, -89) ESOMRL:SetHidden(false)
  1591.             else
  1592.                 ESOMRL:ClearAnchors() ESOMRL:SetAnchor(TOPLEFT, controlName, TOPLEFT, 0, -86) ESOMRL:SetHidden(false)
  1593.             end
  1594.         end
  1595.         EVENT_MANAGER:RegisterForEvent(ESOMRL.Name, EVENT_END_CRAFTING_STATION_INTERACT, OnEndCraftingStationInteract)
  1596.     end
  1597. end
  1598.  
  1599. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1600. -- Initialize the scrollable list of recipes and handle various category and search functions.
  1601. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1602. local function SetListItem(control,data) -- Hook the ScrollList data table.
  1603.     local listitemtext = control:GetNamedChild( 'Name' )
  1604.     listitemtext:SetText( data.RecipeName )
  1605. end
  1606.  
  1607. local function TextSearch(refresh) -- Populate recipe list based on text search.
  1608.     local datalist = ZO_ScrollList_GetDataList(ESOMRL_MainFrameListFrameList)
  1609.     local searchtext
  1610.     local known
  1611.     local color
  1612.     local row = 0
  1613.     if editText ~= 2 then
  1614.         openTab = 50
  1615.         if editText == 1 or refresh == 1 then
  1616.             ZO_ScrollList_Clear(ESOMRL_MainFrameListFrameList)
  1617.             if refresh == 1 then searchtext = LowerSpaceSpecial(LinkNameLanguageFormat(textInput)) else searchtext = ESOMRL_MainFrameSelectionFrameSearchBox:GetText() end
  1618.             if searchtext == "" then
  1619.                 for k,v in pairs(datalist) do datalist[k] = nil end
  1620.                 ZO_ScrollList_Commit(ESOMRL_MainFrameListFrameList, datalist)
  1621.             else
  1622.                 for k,v in pairs(searchTable) do searchTable[k] = nil end
  1623.                 if refresh ~= 1 then searchtext = searchtext:gsub("%W",''):lower() end
  1624.                 for i = 1, 487 do
  1625.                     local name = LowerSpaceSpecial(LinkNameLanguageFormat(GetItemLinkName(ESOMRL.ProvisioningLinks[i].item)))
  1626.                     local flevel = ESOMRL.ProvisioningLabels[i].level
  1627.                     local searchn = searchtext:gsub("%D",'')
  1628.                     flevel = flevel:gsub("%(Veteran",''):gsub("%(Level",''):gsub("Food%)",''):gsub("Drink%)",''):gsub("%s",'')
  1629.                     flevel = tonumber(flevel)
  1630.                     if string.find(ESOMRL.ProvisioningLabels[i].level,"Veteran") ~= nil then
  1631.                         if flevel == 1 then flevel = 50 else flevel = flevel + 50 end
  1632.                     end
  1633.                     searchn = tonumber(searchn)
  1634.                     if (string.find(name,searchtext) ~= nil) or (flevel == searchn and flevel ~= nil) then
  1635.                         local ln = tonumber(ESOMRL.ProvisioningLabels[i].position)
  1636.                         if ln > 0 and ln < 118 then
  1637.                             color = '|c00ff00'
  1638.                         elseif ln > 117 and ln < 217 then
  1639.                             color = '|c3a92ff'
  1640.                         elseif ln > 216 and ln < 244 then
  1641.                             color = '|ca02ef7'
  1642.                         elseif ln > 243 and ln < 361 then
  1643.                             color = '|c00ff00'
  1644.                         elseif ln > 360 and ln < 460 then
  1645.                             color = '|c3a92ff'
  1646.                         elseif ln > 459 and ln < 487 then
  1647.                             color = '|ca02ef7'
  1648.                         elseif ln == 487 then
  1649.                             color = '|ceeca2a'
  1650.                         end
  1651.                         local level = FormatTooltipText(ESOMRL.ProvisioningLabels[ln].level)
  1652.                         local saved = GetRecipeSavedVar(ln, 0)
  1653.                         if IsItemLinkRecipeKnown(ESOMRL.ProvisioningLinks[ln].link) == false then
  1654.                             local resLink = ESOMRL.ProvisioningLinks[ln].item
  1655.                             if GetItemIdFromLink(resLink) == WritQuest.reqId1 or GetItemIdFromLink(resLink) == WritQuest.reqId2 then
  1656.                                 if saved == 1 then known = IconStrings[6] elseif saved == 0 then known = IconStrings[5] end
  1657.                             else
  1658.                                 if saved == 1 then known = IconStrings[4] elseif saved == 0 then known = IconStrings[3] end
  1659.                             end
  1660.                         else
  1661.                             if saved == 2 then known = IconStrings[2] elseif saved == 3 then known = IconStrings[1] end
  1662.                         end
  1663.                         row = row + 1
  1664.                         searchSize = row
  1665.                         local namestring = LinkNameLanguageFormat(GetItemLinkName(ESOMRL.ProvisioningLinks[ln].item))
  1666.                         searchTable[row] = { pos = ln, text = known .. color .. namestring .. '|r' .. '|cffffff ' .. level .. '|r' }
  1667.                         datalist[row] = ZO_ScrollList_CreateDataEntry( 1,
  1668.                         {
  1669.                             RecipeName = known .. color .. namestring .. '|r' .. '|cffffff ' .. level .. '|r',
  1670.                         }
  1671.                         )
  1672.                     end
  1673.                 end
  1674.                 ZO_ScrollList_Commit(ESOMRL_MainFrameListFrameList, datalist)
  1675.             end
  1676.         end
  1677.     end
  1678. end
  1679.  
  1680. local function StationSearch(control, option) -- Search MRL for the selected cooking station item.
  1681.     if option == 1 then
  1682.         InitializeTooltip(InformationTooltip, control, BOTTOMLEFT, 0, -11, TOPRIGHT)
  1683.         SetTooltipText(InformationTooltip, L.ESOMRL_SEARCHS)
  1684.     elseif option == 2 then
  1685.         ClearTooltip(InformationTooltip)
  1686.     elseif option == 3 then
  1687.         local control = GetControl('ESOMRL_MainFrame')
  1688.         if control:IsHidden() then
  1689.             ESOMRL:SetLanguageFormat()
  1690.             control:SetHidden(false)
  1691.             RestorePosition()
  1692.             openTab = 1
  1693.             SetTrackedRecipeCountText()
  1694.             RecipePanelRestore()
  1695.             textInput = stationSelection
  1696.             TextSearch(1)
  1697.         else
  1698.             textInput = stationSelection
  1699.             TextSearch(1)
  1700.         end
  1701.     end
  1702. end
  1703.  
  1704. local function GetWrits() -- Populate recipe list based on current active writ requirements.
  1705.     if GetWritID() ~= 0 then
  1706.         local datalist = ZO_ScrollList_GetDataList(ESOMRL_MainFrameListFrameList)
  1707.         local searchtext
  1708.         local known
  1709.         local color
  1710.         local row = 0
  1711.         openTab = 51
  1712.         textInput = ''
  1713.         ZO_ScrollList_Clear(ESOMRL_MainFrameListFrameList)
  1714.         for k,v in pairs(datalist) do datalist[k] = nil end
  1715.         for k,v in pairs(searchTable) do searchTable[k] = nil end
  1716.         for i = 1, 487 do
  1717.             local lookup = GetItemIdFromLink(ESOMRL.ProvisioningLinks[i].item)
  1718.             if lookup == WritQuest.reqId1 or lookup == WritQuest.reqId2 then
  1719.                 local ln = tonumber(ESOMRL.ProvisioningLabels[i].position)
  1720.                 if ln > 0 and ln < 118 then
  1721.                     color = '|c00ff00'
  1722.                 elseif ln > 117 and ln < 217 then
  1723.                     color = '|c3a92ff'
  1724.                 elseif ln > 216 and ln < 244 then
  1725.                     color = '|ca02ef7'
  1726.                 elseif ln > 243 and ln < 361 then
  1727.                     color = '|c00ff00'
  1728.                 elseif ln > 360 and ln < 460 then
  1729.                     color = '|c3a92ff'
  1730.                 elseif ln > 459 and ln < 487 then
  1731.                     color = '|ca02ef7'
  1732.                 elseif ln == 487 then
  1733.                     color = '|ceeca2a'
  1734.                 end
  1735.                 local level = FormatTooltipText(ESOMRL.ProvisioningLabels[ln].level)
  1736.                 local saved = GetRecipeSavedVar(ln, 0)
  1737.                 if IsItemLinkRecipeKnown(ESOMRL.ProvisioningLinks[ln].link) == false then
  1738.                     local resLink = ESOMRL.ProvisioningLinks[ln].item
  1739.                     if GetItemIdFromLink(resLink) == WritQuest.reqId1 or GetItemIdFromLink(resLink) == WritQuest.reqId2 then
  1740.                         if saved == 1 then known = IconStrings[6] elseif saved == 0 then known = IconStrings[5] end
  1741.                     else
  1742.                         if saved == 1 then known = IconStrings[4] elseif saved == 0 then known = IconStrings[3] end
  1743.                     end
  1744.                 else
  1745.                     if saved == 2 then known = IconStrings[2] elseif saved == 3 then known = IconStrings[1] end
  1746.                 end
  1747.                 row = row + 1
  1748.                 searchSize = row
  1749.                 local namestring = LinkNameLanguageFormat(GetItemLinkName(ESOMRL.ProvisioningLinks[ln].item))
  1750.                 searchTable[row] = { pos = ln, text = known .. color .. namestring .. '|r' .. '|cffffff ' .. level .. '|r' }
  1751.                 datalist[row] = ZO_ScrollList_CreateDataEntry( 1,
  1752.                 {
  1753.                     RecipeName = known .. color .. namestring .. '|r' .. '|cffffff ' .. level .. '|r',
  1754.                 }
  1755.                 )
  1756.             end
  1757.         end
  1758.         ZO_ScrollList_Commit(ESOMRL_MainFrameListFrameList, datalist)
  1759.         editText = 2
  1760.     end
  1761. end
  1762.  
  1763. local function TrackNavigationTier(list) -- Marks the entire tier as tracked if holding shift when clicking the button.
  1764.     local lower
  1765.     local upper
  1766.     if list == 1 then
  1767.         lower = 1
  1768.         upper = 39
  1769.     elseif list == 2 then
  1770.         lower = 40
  1771.         upper = 78
  1772.     elseif list == 3 then
  1773.         lower = 79
  1774.         upper = 117
  1775.     elseif list == 4 then
  1776.         lower = 118
  1777.         upper = 150
  1778.     elseif list == 5 then
  1779.         lower = 151
  1780.         upper = 183
  1781.     elseif list == 6 then
  1782.         lower = 184
  1783.         upper = 216
  1784.     elseif list == 7 then
  1785.         lower = 217
  1786.         upper = 243
  1787.     elseif list == 8 then
  1788.         lower = 244
  1789.         upper = 282
  1790.     elseif list == 9 then
  1791.         lower = 283
  1792.         upper = 321
  1793.     elseif list == 10 then
  1794.         lower = 322
  1795.         upper = 360
  1796.     elseif list == 11 then
  1797.         lower = 361
  1798.         upper = 393
  1799.     elseif list == 12 then
  1800.         lower = 394
  1801.         upper = 426
  1802.     elseif list == 13 then
  1803.         lower = 427
  1804.         upper = 459
  1805.     elseif list == 14 then
  1806.         lower = 460
  1807.         upper = 486
  1808.     elseif list == 15 then
  1809.         lower = 487
  1810.         upper = 487
  1811.     end
  1812.     for i = lower, upper do
  1813.         local savedvar = GetRecipeSavedVar(i, 1)
  1814.         if savedvar == 3 then
  1815.             SetRecipeSavedVar(i, 1, 2)
  1816.             ESOMRL.SV[800].recipetracklist = ESOMRL.SV[800].recipetracklist + 1
  1817.         elseif savedvar == 0 then
  1818.             SetRecipeSavedVar(i, 1, 1)
  1819.             ESOMRL.SV[800].recipetracklist = ESOMRL.SV[800].recipetracklist + 1
  1820.         end
  1821.     end
  1822.     SetTrackedRecipeCountText()
  1823.     RefreshViews()
  1824. end
  1825.  
  1826. local function NavigateScrollList(list) -- Populate recipe list based on navigation item clicked.
  1827.     ZO_ScrollList_Clear(ESOMRL_MainFrameListFrameList)
  1828.     local datalist = ZO_ScrollList_GetDataList(ESOMRL_MainFrameListFrameList)
  1829.     for k,v in pairs(datalist) do datalist[k] = nil end
  1830.     for k,v in pairs(searchTable) do searchTable[k] = nil end  
  1831.     local known
  1832.     local color
  1833.     local row = 0
  1834.     local linktable
  1835.     textInput = ''
  1836.     if list == 1 then
  1837.         linktable = ESOMRL.ProvisioningLinksFood1
  1838.         color = '|c00ff00'
  1839.         openTab = 1
  1840.     elseif list == 2 then
  1841.         linktable = ESOMRL.ProvisioningLinksFood2
  1842.         color = '|c00ff00'
  1843.         openTab = 2
  1844.     elseif list == 3 then
  1845.         linktable = ESOMRL.ProvisioningLinksFood3
  1846.         color = '|c00ff00'
  1847.         openTab = 3
  1848.     elseif list == 4 then
  1849.         linktable = ESOMRL.ProvisioningLinksFood4
  1850.         color = '|c3a92ff'
  1851.         openTab = 4
  1852.     elseif list == 5 then
  1853.         linktable = ESOMRL.ProvisioningLinksFood5
  1854.         color = '|c3a92ff'
  1855.         openTab = 5
  1856.     elseif list == 6 then
  1857.         linktable = ESOMRL.ProvisioningLinksFood6
  1858.         color = '|c3a92ff'
  1859.         openTab = 6
  1860.     elseif list == 7 then
  1861.         linktable = ESOMRL.ProvisioningLinksFood7
  1862.         color = '|ca02ef7'
  1863.         openTab = 7
  1864.     elseif list == 8 then
  1865.         linktable = ESOMRL.ProvisioningLinksDrinks1
  1866.         color = '|c00ff00'
  1867.         openTab = 8
  1868.     elseif list == 9 then
  1869.         linktable = ESOMRL.ProvisioningLinksDrinks2
  1870.         color = '|c00ff00'
  1871.         openTab = 9
  1872.     elseif list == 10 then
  1873.         linktable = ESOMRL.ProvisioningLinksDrinks3
  1874.         color = '|c00ff00'
  1875.         openTab = 10
  1876.     elseif list == 11 then
  1877.         linktable = ESOMRL.ProvisioningLinksDrinks4
  1878.         color = '|c3a92ff'
  1879.         openTab = 11
  1880.     elseif list == 12 then
  1881.         linktable = ESOMRL.ProvisioningLinksDrinks5
  1882.         color = '|c3a92ff'
  1883.         openTab = 12
  1884.     elseif list == 13 then
  1885.         linktable = ESOMRL.ProvisioningLinksDrinks6
  1886.         color = '|c3a92ff'
  1887.         openTab = 13
  1888.     elseif list == 14 then
  1889.         linktable = ESOMRL.ProvisioningLinksDrinks7
  1890.         color = '|ca02ef7'
  1891.         openTab = 14
  1892.     elseif list == 15 then
  1893.         linktable = ESOMRL.ProvisioningLinksPsijic
  1894.         color = '|ceeca2a'
  1895.         openTab = 15
  1896.     end
  1897.     for i = 1, #linktable do
  1898.         local ln = tonumber(linktable[i].position)
  1899.         local level = FormatTooltipText(linktable[i].level)
  1900.         local saved = GetRecipeSavedVar(i, list)
  1901.         if IsItemLinkRecipeKnown(linktable[i].link) == false then
  1902.             local resLink = linktable[i].item
  1903.             if GetItemIdFromLink(resLink) == WritQuest.reqId1 or GetItemIdFromLink(resLink) == WritQuest.reqId2 then
  1904.                 if saved == 1 then known = IconStrings[6] elseif saved == 0 then known = IconStrings[5] end
  1905.             else
  1906.                 if saved == 1 then known = IconStrings[4] elseif saved == 0 then known = IconStrings[3] end
  1907.             end
  1908.         else
  1909.             if saved == 2 then known = IconStrings[2] elseif saved == 3 then known = IconStrings[1] end
  1910.         end
  1911.         row = row + 1
  1912.         searchSize = row
  1913.         local namestring = LinkNameLanguageFormat(GetItemLinkName(linktable[i].item))
  1914.         searchTable[row] = { pos = ln, text = known .. color .. namestring .. '|r' .. '|cffffff ' .. level .. '|r' }
  1915.         datalist[i] = ZO_ScrollList_CreateDataEntry( 1,
  1916.         {
  1917.             RecipeName = known .. color .. namestring .. '|r' .. '|cffffff ' .. level .. '|r',
  1918.         }
  1919.         )
  1920.     end
  1921.     ZO_ScrollList_Commit(ESOMRL_MainFrameListFrameList, datalist)
  1922. end
  1923.  
  1924. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1925. -- Handle the clicking of items in the active recipe list, setting and clearing tracked items.
  1926. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  1927. local function CountRecipeTrackingList(option, tier) -- Counts the current number of recipes you are tracking.
  1928.     if option == 0 then
  1929.         ESOMRL.SV[800].recipetracklist = ESOMRL.SV[800].recipetracklist - 1
  1930.         SetTrackedRecipeCountText()
  1931.     elseif option == 1 then
  1932.         ESOMRL.SV[800].recipetracklist = ESOMRL.SV[800].recipetracklist + 1
  1933.         SetTrackedRecipeCountText()
  1934.     end
  1935.     if tier == 51 then
  1936.         GetWrits()
  1937.     elseif tier == 50 then
  1938.         TextSearch(1)
  1939.     else
  1940.         NavigateScrollList(tier)
  1941.     end
  1942.     RefreshViews()
  1943. end
  1944.  
  1945. local function TrackAllRecipes(option) -- Set all recipes to tracked.
  1946.     if option == 1 then
  1947.         InitializeTooltip(InformationTooltip, ESOMRL_MainFrameCloseButton, TOPLEFT, 8, -44, BOTTOMRIGHT)
  1948.         SetTooltipText(InformationTooltip, L.ESOMRL_TRACKALL)
  1949.     elseif option == 2 then
  1950.         ClearTooltip(InformationTooltip)
  1951.     elseif option == 3 then
  1952.         for i = 1, 487 do
  1953.             local savedvar = GetRecipeSavedVar(i, 1)
  1954.             if savedvar == 3 then
  1955.                 SetRecipeSavedVar(i, 1, 2)
  1956.                 ESOMRL.SV[800].recipetracklist = ESOMRL.SV[800].recipetracklist + 1
  1957.             elseif savedvar == 0 then
  1958.                 SetRecipeSavedVar(i, 1, 1)
  1959.                 ESOMRL.SV[800].recipetracklist = ESOMRL.SV[800].recipetracklist + 1
  1960.             end
  1961.         end
  1962.         if (openTab ~= 50) and (openTab ~= 51) then
  1963.             NavigateScrollList(openTab)
  1964.         else
  1965.             openTab = 1
  1966.             NavigateScrollList(openTab)
  1967.             textInput = ''
  1968.         end
  1969.         SetTrackedRecipeCountText()
  1970.         RefreshViews()
  1971.     end
  1972. end
  1973.  
  1974. local function TrackUnknownRecipes(option) -- Track recipes the current selected character does not know.
  1975.     if option == 1 then
  1976.         InitializeTooltip(InformationTooltip, ESOMRL_MainFrameCloseButton, TOPLEFT, 8, -44, BOTTOMRIGHT)
  1977.         SetTooltipText(InformationTooltip, L.ESOMRL_TRACKUNKNOWN)
  1978.     elseif option == 2 then
  1979.         ClearTooltip(InformationTooltip)
  1980.     elseif option == 3 then
  1981.         for i = 1, 487 do
  1982.             local savedvar = GetRecipeSavedVar(i, 1)
  1983.             if not Contains(ESOMRL.ASV[i].names, currentChar) then
  1984.                 if savedvar == 3 then
  1985.                     SetRecipeSavedVar(i, 1, 2)
  1986.                     ESOMRL.SV[800].recipetracklist = ESOMRL.SV[800].recipetracklist + 1
  1987.                 elseif savedvar == 0 then
  1988.                     SetRecipeSavedVar(i, 1, 1)
  1989.                     ESOMRL.SV[800].recipetracklist = ESOMRL.SV[800].recipetracklist + 1
  1990.                 end
  1991.             end
  1992.         end
  1993.         if (openTab ~= 50) and (openTab ~= 51) then
  1994.             NavigateScrollList(openTab)
  1995.         else
  1996.             openTab = 1
  1997.             NavigateScrollList(openTab)
  1998.             textInput = ''
  1999.         end
  2000.         SetTrackedRecipeCountText()
  2001.         RefreshViews()
  2002.     end
  2003. end
  2004.  
  2005. local function ClearTrackedRecipes() -- Clears all tracked recipes, removing tooltip line.
  2006.     ESOMRL.SV[800].recipetracklist = 0
  2007.     for i = 1, 487 do
  2008.         if IsItemLinkRecipeKnown(ESOMRL.ProvisioningLinks[i].link) == false then
  2009.             SetRecipeSavedVar(i, 1, 0)
  2010.         else
  2011.             if GetRecipeSavedVar(i, 1) == 2 then
  2012.                 SetRecipeSavedVar(i, 1, 3)
  2013.             end
  2014.         end
  2015.     end
  2016.     if (openTab ~= 50) and (openTab ~= 51) then
  2017.         NavigateScrollList(openTab)
  2018.     else
  2019.         openTab = 1
  2020.         NavigateScrollList(openTab)
  2021.         textInput = ''
  2022.     end
  2023.     ESOMRL.SV[800].junkunmarkedrecipes = 0
  2024.     ESOMRL.SV[800].destroyunmarkedrecipes = 0
  2025.     SetTrackedRecipeCountText()
  2026.     RecipePanelRestore()
  2027.     RefreshViews()
  2028. end
  2029.  
  2030. local function RecipeListClick(clicktext) -- Handles clicking and shift-clicking of list items.
  2031.     if openTab < 50 then
  2032.         for i = 1, searchSize do
  2033.             local name = searchTable[i].text
  2034.             if clicktext == name then
  2035.                 if IsShiftKeyDown() == false then
  2036.                     local savedval = GetRecipeSavedVar(i, openTab)
  2037.                     if savedval == 0 then
  2038.                         SetRecipeSavedVar(i, openTab, 1)
  2039.                         CountRecipeTrackingList(1, openTab)
  2040.                     elseif savedval == 1 then
  2041.                         SetRecipeSavedVar(i, openTab, 0)
  2042.                         CountRecipeTrackingList(0, openTab)
  2043.                     elseif savedval == 2 then
  2044.                         SetRecipeSavedVar(i, openTab, 3)
  2045.                         CountRecipeTrackingList(0, openTab)
  2046.                     elseif savedval == 3 then
  2047.                         SetRecipeSavedVar(i, openTab, 2)
  2048.                         CountRecipeTrackingList(1, openTab)
  2049.                     end
  2050.                 elseif IsShiftKeyDown() == true then
  2051.                     local index = 0
  2052.                     if openTab == 1 then
  2053.                         index = i
  2054.                     elseif openTab == 2 then
  2055.                         index = i + 39
  2056.                     elseif openTab == 3 then
  2057.                         index = i + 78
  2058.                     elseif openTab == 4 then
  2059.                         index = i + 117
  2060.                     elseif openTab == 5 then
  2061.                         index = i + 150
  2062.                     elseif openTab == 6 then
  2063.                         index = i + 183
  2064.                     elseif openTab == 7 then
  2065.                         index = i + 216
  2066.                     elseif openTab == 8 then
  2067.                         index = i + 243
  2068.                     elseif openTab == 9 then
  2069.                         index = i + 282
  2070.                     elseif openTab == 10 then
  2071.                         index = i + 321
  2072.                     elseif openTab == 11 then
  2073.                         index = i + 360
  2074.                     elseif openTab == 12 then
  2075.                         index = i + 393
  2076.                     elseif openTab == 13 then
  2077.                         index = i + 426
  2078.                     elseif openTab == 14 then
  2079.                         index = i + 459
  2080.                     elseif openTab == 15 then
  2081.                         index = 487
  2082.                     end
  2083.                     local ChatEditControl = CHAT_SYSTEM.textEntry.editControl
  2084.                     if not ChatEditControl:HasFocus() then
  2085.                         StartChatInput()
  2086.                     end
  2087.                     if ESOMRL.SV[800].tooltipstyle == 0 then
  2088.                         ChatEditControl:InsertText(ESOMRL.ProvisioningLinks[index].link)
  2089.                     elseif ESOMRL.SV[800].tooltipstyle == 1 then
  2090.                         ChatEditControl:InsertText(ESOMRL.ProvisioningLinks[index].item)
  2091.                     end
  2092.                 end
  2093.             end
  2094.         end
  2095.     else
  2096.         for i = 1, searchSize do
  2097.             local row = searchTable[i].pos
  2098.             local name = searchTable[i].text
  2099.             if clicktext == name then
  2100.                 if IsShiftKeyDown() == false then
  2101.                     local savedval = GetRecipeSavedVar(row, openTab)
  2102.                     if savedval == 0 then
  2103.                         SetRecipeSavedVar(row, openTab, 1)
  2104.                         CountRecipeTrackingList(1, openTab)
  2105.                     elseif savedval == 1 then
  2106.                         SetRecipeSavedVar(row, openTab, 0)
  2107.                         CountRecipeTrackingList(0, openTab)
  2108.                     elseif savedval == 2 then
  2109.                         SetRecipeSavedVar(row, openTab, 3)
  2110.                         CountRecipeTrackingList(0, openTab)
  2111.                     elseif savedval == 3 then
  2112.                         SetRecipeSavedVar(row, openTab, 2)
  2113.                         CountRecipeTrackingList(1, openTab)
  2114.                     end
  2115.                 elseif IsShiftKeyDown() == true then
  2116.                     local ChatEditControl = CHAT_SYSTEM.textEntry.editControl
  2117.                     if not ChatEditControl:HasFocus() then
  2118.                         StartChatInput()
  2119.                     end
  2120.                     if ESOMRL.SV[800].tooltipstyle == 0 then
  2121.                         ChatEditControl:InsertText(ESOMRL.ProvisioningLinks[row].link)
  2122.                     elseif ESOMRL.SV[800].tooltipstyle == 1 then
  2123.                         ChatEditControl:InsertText(ESOMRL.ProvisioningLinks[row].item)
  2124.                     end
  2125.                 end
  2126.             end
  2127.         end
  2128.     end
  2129. end
  2130.  
  2131. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2132. -- Handle the clicking of items in the ingredients panel.
  2133. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2134. local function CountIngredientTrackingList(option) -- Counts the current number of ingredients you are tracking.
  2135.     if option == 0 then
  2136.         ESOMRL.SV[800].ingtracklist = ESOMRL.SV[800].ingtracklist - 1
  2137.         SetTrackedIngredientCountText()
  2138.     elseif option == 1 then
  2139.         ESOMRL.SV[800].ingtracklist = ESOMRL.SV[800].ingtracklist + 1
  2140.         SetTrackedIngredientCountText()
  2141.     end
  2142.     RefreshViews()
  2143. end
  2144.  
  2145. local function ClearTrackedIngredients() -- Clears all tracked ingredients, removing tooltip line.
  2146.     ESOMRL.SV[800].ingtracklist = 0
  2147.     for i = 1, 50 do
  2148.         SetIngredientSavedVar(i, 0)
  2149.         SetTrackedIngredientCountText()
  2150.     end
  2151.     ESOMRL.SV[800].junkunmarkedingredients = 0
  2152.     ESOMRL.SV[800].destroyunmarkedingredients = 0
  2153.     IngredientPanelSetup()
  2154.     RefreshViews()
  2155. end
  2156.  
  2157. local function SelectAllIngredients(control, option) -- Button function to mark all ingredients.
  2158.     if option == 1 then
  2159.         InitializeTooltip(InformationTooltip, ESOMRL_MainFrameIngredientsFrameListTooltipButton, TOPLEFT, 10, -42, BOTTOMRIGHT)
  2160.         SetTooltipText(InformationTooltip, L.ESOMRL_TRACKALLING)
  2161.     elseif option == 2 then
  2162.         ClearTooltip(InformationTooltip)
  2163.     elseif option == 3 then
  2164.         for i = 1, 50 do
  2165.             if GetIngredientSavedVar(i) == 0 then
  2166.                 SetIngredientSavedVar(i, 1)
  2167.                 CountIngredientTrackingList(1)
  2168.             end
  2169.         end
  2170.         IngredientPanelSetup()
  2171.         RefreshViews()
  2172.     end
  2173. end
  2174.  
  2175. local function SaveGlobalIngredientProfile(option) -- Clear the global ingredient tracking profile.
  2176.     if option == 1 then
  2177.         InitializeTooltip(InformationTooltip, ESOMRL_MainFrameIngredientsFrameListTooltipButton, TOPLEFT, 10, -63, BOTTOMRIGHT)
  2178.         SetTooltipText(InformationTooltip, L.ESOMRL_SAVEINGTP)
  2179.     elseif option == 2 then
  2180.         ClearTooltip(InformationTooltip)
  2181.     elseif option == 3 then
  2182.         for i = 1, 50 do
  2183.             ESOMRL.ASV[801].globalingprofile[i] = GetIngredientSavedVar(i)
  2184.         end
  2185.     end
  2186. end
  2187.  
  2188. local function LoadGlobalIngredientProfile(option) -- Load the global ingredient tracking profile.
  2189.     if option == 1 then
  2190.         if GetCVar('Language.2') == 'fr' then
  2191.             InitializeTooltip(InformationTooltip, ESOMRL_MainFrameIngredientsFrameListTooltipButton, TOPLEFT, 10, -63, BOTTOMRIGHT)
  2192.         elseif GetCVar('Language.2') == 'de' then
  2193.             InitializeTooltip(InformationTooltip, ESOMRL_MainFrameIngredientsFrameListTooltipButton, TOPLEFT, 10, -63, BOTTOMRIGHT)
  2194.         else
  2195.             InitializeTooltip(InformationTooltip, ESOMRL_MainFrameIngredientsFrameListTooltipButton, TOPLEFT, 10, -42, BOTTOMRIGHT)
  2196.         end
  2197.         SetTooltipText(InformationTooltip, L.ESOMRL_LOADINGTP)
  2198.     elseif option == 2 then
  2199.         ClearTooltip(InformationTooltip)
  2200.     elseif option == 3 then
  2201.         ESOMRL.SV[800].ingtracklist = 0
  2202.         for i = 1, 50 do
  2203.             local global = ESOMRL.ASV[801].globalingprofile[i]
  2204.             if global == 1 then ESOMRL.SV[800].ingtracklist = ESOMRL.SV[800].ingtracklist + 1 end
  2205.             SetIngredientSavedVar(i, global)
  2206.         end
  2207.         SetTrackedIngredientCountText()
  2208.         IngredientPanelSetup()
  2209.         RefreshViews()
  2210.     end
  2211. end
  2212.  
  2213. local function IngredientListClick(control, option, index) -- Handles clicking and shift-clicking of ingredients.
  2214.     if option == 1 then
  2215.         if ESOMRL.SV[800].lttshow == 1 then
  2216.             local IngredientItemTooltip = IngredientItemTooltipControl
  2217.             local itemLink = ESOMRL.IngredientLinks[index].link
  2218.             InitializeTooltip(IngredientItemTooltip, ESOMRL_MainFrame, TOPLEFT, 10, -8, TOPRIGHT)
  2219.             PopupTooltip.SetLink(IngredientItemTooltip, itemLink)
  2220.         end
  2221.         if GetIngredientSavedVar(index) == 1 then
  2222.             control:SetColor(1,1,0,1)
  2223.             control:SetAlpha(.5)
  2224.         elseif GetIngredientSavedVar(index) == 0 then
  2225.             control:SetColor(1,1,1,1)
  2226.             control:SetAlpha(1)
  2227.         end
  2228.     elseif option == 2 then
  2229.         local IngredientItemTooltip = IngredientItemTooltipControl
  2230.         ClearTooltip(IngredientItemTooltip)
  2231.         if GetIngredientSavedVar(index) == 1 then
  2232.             control:SetColor(1,1,0,1)
  2233.             control:SetAlpha(1)
  2234.         elseif GetIngredientSavedVar(index) == 0 then
  2235.             control:SetColor(0.7647,0.7647,0.7647,1)
  2236.             control:SetAlpha(1)
  2237.         end
  2238.     elseif option == 3 then
  2239.         if IsShiftKeyDown() == false then
  2240.             if GetIngredientSavedVar(index) == 1 then
  2241.                 control:SetColor(0.7647,0.7647,0.7647,1)
  2242.                 control:SetAlpha(1)
  2243.                 SetIngredientSavedVar(index, 0)
  2244.                 CountIngredientTrackingList(0)
  2245.             elseif GetIngredientSavedVar(index) == 0 then
  2246.                 control:SetColor(1,1,0,1)
  2247.                 control:SetAlpha(1)
  2248.                 SetIngredientSavedVar(index, 1)
  2249.                 CountIngredientTrackingList(1)
  2250.             end
  2251.         elseif IsShiftKeyDown() == true then
  2252.             local ChatEditControl = CHAT_SYSTEM.textEntry.editControl
  2253.             if not ChatEditControl:HasFocus() then
  2254.                 StartChatInput()
  2255.             end
  2256.             ChatEditControl:InsertText(ESOMRL.IngredientLinks[index].link)
  2257.         end
  2258.     end
  2259. end
  2260.  
  2261. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2262. -- Generate the popup list tooltips.
  2263. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2264. local function ListTooltips(control, text, option)
  2265.     if option == 1 then
  2266.         if ESOMRL.SV[800].lttshow == 1 then
  2267.             local RecipeItemTooltip = RecipeItemTooltipControl
  2268.             for i = 1, searchSize do
  2269.                 local row = searchTable[i].pos
  2270.                 local name = searchTable[i].text
  2271.                 if text == name then
  2272.                     local itemlink
  2273.                     if ESOMRL.SV[800].tooltipstyle == 0 then
  2274.                         itemLink = ESOMRL.ProvisioningLinks[row].link
  2275.                     elseif ESOMRL.SV[800].tooltipstyle == 1 then
  2276.                         itemLink = ESOMRL.ProvisioningLinks[row].item
  2277.                     end
  2278.                     InitializeTooltip(RecipeItemTooltip, ESOMRL_MainFrame, TOPLEFT, 10, -8, TOPRIGHT)
  2279.                     PopupTooltip.SetLink(RecipeItemTooltip, itemLink)
  2280.                 end
  2281.             end
  2282.         end
  2283.         control:SetAlpha(.5)
  2284.     elseif option == 2 then
  2285.         local RecipeItemTooltip = RecipeItemTooltipControl
  2286.         ClearTooltip(RecipeItemTooltip)
  2287.         control:SetAlpha(1)
  2288.     end
  2289. end
  2290.  
  2291. local function SelectTooltipStyle(option)
  2292.     if option == 1 then
  2293.         InitializeTooltip(InformationTooltip, ESOMRL_MainFrameListFrame, BOTTOMLEFT, 26, 28, BOTTOMRIGHT)
  2294.         if ESOMRL.SV[800].tooltipstyle == 0 then
  2295.             SetTooltipText(InformationTooltip, L.ESOMRL_TTFOOD)
  2296.         elseif ESOMRL.SV[800].tooltipstyle == 1 then
  2297.             SetTooltipText(InformationTooltip, L.ESOMRL_TTRECIPE)
  2298.         end
  2299.     elseif option == 2 then
  2300.         ClearTooltip(InformationTooltip)
  2301.     elseif option == 3 then
  2302.         if ESOMRL.SV[800].tooltipstyle == 0 then
  2303.             ESOMRL.SV[800].tooltipstyle = 1
  2304.             ClearTooltip(InformationTooltip)
  2305.             InitializeTooltip(InformationTooltip, ESOMRL_MainFrameListFrame, BOTTOMLEFT, 26, 28, BOTTOMRIGHT)
  2306.             SetTooltipText(InformationTooltip, L.ESOMRL_TTRECIPE)
  2307.         elseif ESOMRL.SV[800].tooltipstyle == 1 then
  2308.             ESOMRL.SV[800].tooltipstyle = 0
  2309.             ClearTooltip(InformationTooltip)
  2310.             InitializeTooltip(InformationTooltip, ESOMRL_MainFrameListFrame, BOTTOMLEFT, 26, 28, BOTTOMRIGHT)
  2311.             SetTooltipText(InformationTooltip, L.ESOMRL_TTFOOD)
  2312.         end
  2313.     end
  2314. end
  2315.  
  2316. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2317. -- Text search mouse events.
  2318. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2319. local function TextBoxEvents(option)
  2320.     local control = ESOMRL_MainFrameSelectionFrameSearchBox
  2321.     local controlBG = ESOMRL_MainFrameSelectionFrameSearchBG
  2322.     if option == 1 then -- On Mouse Enter
  2323.         if editText == 0 or editText == 2 then
  2324.             controlBG:SetAlpha(0.5)
  2325.             if textInput == '' then
  2326.                 control:SetText(L.ESOMRL_SEARCHBOX)
  2327.             else
  2328.                 control:SetText(textInput)
  2329.             end
  2330.         end
  2331.     elseif option == 2 then -- On Mouse Exit
  2332.         if editText == 0 or editText == 2 then
  2333.             controlBG:SetAlpha(0)
  2334.             if control:GetText() == L.ESOMRL_SEARCHBOX then
  2335.                 textInput = L.ESOMRL_SEARCHBOX
  2336.             end
  2337.             control:SetText('')
  2338.         end
  2339.     elseif option == 3 then -- On Focus Gained
  2340.         control:SetText('')
  2341.         textInput = ''
  2342.         editText = 1
  2343.         openTab = 50
  2344.         TextSearch()
  2345.     elseif option == 4 then -- On Focus Lost
  2346.         editText = 0
  2347.         textInput = control:GetText()
  2348.         control:SetText('')
  2349.         controlBG:SetAlpha(0)
  2350.         TextSearch(1)
  2351.     elseif option == 5 then -- On Text Changed
  2352.         if textInput ~= L.ESOMRL_SEARCHBOX and control:GetText() ~= L.ESOMRL_SEARCHBOX then
  2353.             TextSearch()
  2354.         end
  2355.     end
  2356. end
  2357.  
  2358. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2359. -- Handles populating the list of tracked ingredients based on those needed by currently tracked recipes.
  2360. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2361. local function TrackedRecipeCheck()
  2362.     local ingredients = {}
  2363.     for r = 1, 487 do
  2364.         local savedvar = GetRecipeSavedVar(r, 1)
  2365.         if (savedvar == 1) or (savedvar == 2) then
  2366.             local linkcheck = ESOMRL.ProvisioningLinks[r].link
  2367.             local numIngredients = GetItemLinkRecipeNumIngredients(linkcheck)
  2368.             for i = 1, numIngredients do
  2369.                 local ingredientName,_ = GetItemLinkRecipeIngredientInfo(linkcheck, i)
  2370.                 ingredientName = LowerSpaceSpecial(ingredientName)
  2371.                 if not Contains(ingredients, ingredientName) then
  2372.                     table.insert(ingredients, #ingredients + 1, ingredientName)
  2373.                 end
  2374.             end
  2375.         end
  2376.     end
  2377.     for a = 1, #ingredients do
  2378.         for b = 1, 50 do
  2379.             local namelookup = LowerSpaceSpecial(GetItemLinkName(ESOMRL.IngredientLinks[b].link))
  2380.             if namelookup == ingredients[a] then
  2381.                 if GetIngredientSavedVar(b) == 0 then
  2382.                     SetIngredientSavedVar(b, 1)
  2383.                     CountIngredientTrackingList(1)
  2384.                 end
  2385.             end
  2386.         end
  2387.     end
  2388.     IngredientPanelSetup()
  2389. end
  2390.  
  2391. local function TrackedRecipeIngredients(control, option)
  2392.     if option == 1 then
  2393.         if GetCVar('Language.2') == 'fr' then
  2394.             InitializeTooltip(InformationTooltip, control, TOPLEFT, 10, -63, BOTTOMRIGHT)
  2395.         elseif GetCVar('Language.2') == 'de' then
  2396.             InitializeTooltip(InformationTooltip, control, TOPLEFT, 10, -63, BOTTOMRIGHT)
  2397.         else
  2398.             InitializeTooltip(InformationTooltip, control, TOPLEFT, 10, -42, BOTTOMRIGHT)
  2399.         end
  2400.         SetTooltipText(InformationTooltip, L.ESOMRL_TRACKRING)
  2401.     elseif option == 2 then
  2402.         ClearTooltip(InformationTooltip)
  2403.     elseif option == 3 then
  2404.         TrackedRecipeCheck()
  2405.     end
  2406. end
  2407.  
  2408. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2409. -- Setup button functions and handle the junking and deleting of unmarked items as per options.
  2410. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2411. local function JunkUnmarkedRecipeFunction(option)
  2412.     if option == 1 then
  2413.         InitializeTooltip(InformationTooltip, ESOMRL_MainFrameCloseButton, TOPLEFT, 8, -44, BOTTOMRIGHT)
  2414.         if ESOMRL.SV[800].destroyjunkrecipes == true then
  2415.             if ESOMRL.SV[800].destroyunmarkedrecipes == 0 then
  2416.                 SetTooltipText(InformationTooltip, L.ESOMRL_DESTROYURECIPE)
  2417.             elseif ESOMRL.SV[800].destroyunmarkedrecipes == 1 then
  2418.                 SetTooltipText(InformationTooltip, L.ESOMRL_DDESTROYURECIPE)
  2419.             end
  2420.         elseif ESOMRL.SV[800].destroyjunkrecipes == false then
  2421.             if ESOMRL.SV[800].junkunmarkedrecipes == 0 then
  2422.                 SetTooltipText(InformationTooltip, L.ESOMRL_JUNKURECIPE)
  2423.             elseif ESOMRL.SV[800].junkunmarkedrecipes == 1 then
  2424.                 SetTooltipText(InformationTooltip, L.ESOMRL_DJUNKURECIPE)
  2425.             end
  2426.         end
  2427.     elseif option == 2 then
  2428.         ClearTooltip(InformationTooltip)
  2429.     elseif option == 3 then
  2430.         if ESOMRL.SV[800].destroyjunkrecipes == true then
  2431.             if ESOMRL.SV[800].destroyunmarkedrecipes == 0 then
  2432.                 ESOMRL.SV[800].destroyunmarkedrecipes = 1
  2433.                 ESOMRL_MainFrameListFrameBatchTrackingTrashUncheckedButton1:SetHidden(true)
  2434.                 ESOMRL_MainFrameListFrameBatchTrackingTrashUncheckedButton2:SetHidden(false)
  2435.                 ClearTooltip(InformationTooltip)
  2436.                 InitializeTooltip(InformationTooltip, ESOMRL_MainFrameCloseButton, TOPLEFT, 8, -44, BOTTOMRIGHT)
  2437.                 SetTooltipText(InformationTooltip, L.ESOMRL_DDESTROYURECIPE)
  2438.             elseif ESOMRL.SV[800].destroyunmarkedrecipes == 1 then
  2439.                 ESOMRL.SV[800].destroyunmarkedrecipes = 0
  2440.                 ESOMRL_MainFrameListFrameBatchTrackingTrashUncheckedButton1:SetHidden(false)
  2441.                 ESOMRL_MainFrameListFrameBatchTrackingTrashUncheckedButton2:SetHidden(true)
  2442.                 ClearTooltip(InformationTooltip)
  2443.                 InitializeTooltip(InformationTooltip, ESOMRL_MainFrameCloseButton, TOPLEFT, 8, -44, BOTTOMRIGHT)
  2444.                 SetTooltipText(InformationTooltip, L.ESOMRL_DESTROYURECIPE)
  2445.             end
  2446.         elseif ESOMRL.SV[800].destroyjunkrecipes == false then
  2447.             if ESOMRL.SV[800].junkunmarkedrecipes == 0 then
  2448.                 ESOMRL.SV[800].junkunmarkedrecipes = 1
  2449.                 ESOMRL_MainFrameListFrameBatchTrackingTrashUncheckedButton1:SetHidden(true)
  2450.                 ESOMRL_MainFrameListFrameBatchTrackingTrashUncheckedButton2:SetHidden(false)
  2451.                 ClearTooltip(InformationTooltip)
  2452.                 InitializeTooltip(InformationTooltip, ESOMRL_MainFrameCloseButton, TOPLEFT, 8, -44, BOTTOMRIGHT)
  2453.                 SetTooltipText(InformationTooltip, L.ESOMRL_DJUNKURECIPE)
  2454.             elseif ESOMRL.SV[800].junkunmarkedrecipes == 1 then
  2455.                 ESOMRL.SV[800].junkunmarkedrecipes = 0
  2456.                 ESOMRL_MainFrameListFrameBatchTrackingTrashUncheckedButton1:SetHidden(false)
  2457.                 ESOMRL_MainFrameListFrameBatchTrackingTrashUncheckedButton2:SetHidden(true)
  2458.                 ClearTooltip(InformationTooltip)
  2459.                 InitializeTooltip(InformationTooltip, ESOMRL_MainFrameCloseButton, TOPLEFT, 8, -44, BOTTOMRIGHT)
  2460.                 SetTooltipText(InformationTooltip, L.ESOMRL_JUNKURECIPE)
  2461.             end
  2462.         end
  2463.     end
  2464. end
  2465.  
  2466. local function JunkUnmarkedIngredientFunction(option)
  2467.     if option == 1 then
  2468.         if GetCVar('Language.2') == 'fr' then
  2469.             InitializeTooltip(InformationTooltip, ESOMRL_MainFrameIngredientsFrameListTooltipButton, TOPLEFT, 10, -85, BOTTOMRIGHT)
  2470.         else
  2471.             InitializeTooltip(InformationTooltip, ESOMRL_MainFrameIngredientsFrameListTooltipButton, TOPLEFT, 10, -63, BOTTOMRIGHT)
  2472.         end
  2473.         if ESOMRL.SV[800].destroyjunkingredients == true then
  2474.             if ESOMRL.SV[800].destroyunmarkedingredients == 0 then
  2475.                 SetTooltipText(InformationTooltip, L.ESOMRL_DESTROYUING)
  2476.             elseif ESOMRL.SV[800].destroyunmarkedingredients == 1 then
  2477.                 SetTooltipText(InformationTooltip, L.ESOMRL_DDESTROYUING)
  2478.             end
  2479.         elseif ESOMRL.SV[800].destroyjunkingredients == false then
  2480.             if ESOMRL.SV[800].junkunmarkedingredients == 0 then
  2481.                 SetTooltipText(InformationTooltip, L.ESOMRL_JUNKUING)
  2482.             elseif ESOMRL.SV[800].junkunmarkedingredients == 1 then
  2483.                 SetTooltipText(InformationTooltip, L.ESOMRL_DJUNKUING)
  2484.             end
  2485.         end
  2486.     elseif option == 2 then
  2487.         ClearTooltip(InformationTooltip)
  2488.     elseif option == 3 then
  2489.         if ESOMRL.SV[800].destroyjunkingredients == true then
  2490.             if ESOMRL.SV[800].destroyunmarkedingredients == 0 then
  2491.                 ESOMRL.SV[800].destroyunmarkedingredients = 1
  2492.                 ESOMRL_MainFrameIngredientsFrameTrashUncheckedButton1:SetHidden(true)
  2493.                 ESOMRL_MainFrameIngredientsFrameTrashUncheckedButton2:SetHidden(false)
  2494.                 ClearTooltip(InformationTooltip)
  2495.                 if GetCVar('Language.2') == 'fr' then
  2496.                     InitializeTooltip(InformationTooltip, ESOMRL_MainFrameIngredientsFrameListTooltipButton, TOPLEFT, 10, -85, BOTTOMRIGHT)
  2497.                 else
  2498.                     InitializeTooltip(InformationTooltip, ESOMRL_MainFrameIngredientsFrameListTooltipButton, TOPLEFT, 10, -63, BOTTOMRIGHT)
  2499.                 end
  2500.                 SetTooltipText(InformationTooltip, L.ESOMRL_DDESTROYUING)
  2501.             elseif ESOMRL.SV[800].destroyunmarkedingredients == 1 then
  2502.                 ESOMRL.SV[800].destroyunmarkedingredients = 0
  2503.                 ESOMRL_MainFrameIngredientsFrameTrashUncheckedButton1:SetHidden(false)
  2504.                 ESOMRL_MainFrameIngredientsFrameTrashUncheckedButton2:SetHidden(true)
  2505.                 ClearTooltip(InformationTooltip)
  2506.                 if GetCVar('Language.2') == 'fr' then
  2507.                     InitializeTooltip(InformationTooltip, ESOMRL_MainFrameIngredientsFrameListTooltipButton, TOPLEFT, 10, -85, BOTTOMRIGHT)
  2508.                 else
  2509.                     InitializeTooltip(InformationTooltip, ESOMRL_MainFrameIngredientsFrameListTooltipButton, TOPLEFT, 10, -63, BOTTOMRIGHT)
  2510.                 end
  2511.                 SetTooltipText(InformationTooltip, L.ESOMRL_DESTROYUING)
  2512.             end
  2513.         elseif ESOMRL.SV[800].destroyjunkingredients == false then
  2514.             if ESOMRL.SV[800].junkunmarkedingredients == 0 then
  2515.                 ESOMRL.SV[800].junkunmarkedingredients = 1
  2516.                 ESOMRL_MainFrameIngredientsFrameTrashUncheckedButton1:SetHidden(true)
  2517.                 ESOMRL_MainFrameIngredientsFrameTrashUncheckedButton2:SetHidden(false)
  2518.                 ClearTooltip(InformationTooltip)
  2519.                 if GetCVar('Language.2') == 'fr' then
  2520.                     InitializeTooltip(InformationTooltip, ESOMRL_MainFrameIngredientsFrameListTooltipButton, TOPLEFT, 10, -85, BOTTOMRIGHT)
  2521.                 else
  2522.                     InitializeTooltip(InformationTooltip, ESOMRL_MainFrameIngredientsFrameListTooltipButton, TOPLEFT, 10, -63, BOTTOMRIGHT)
  2523.                 end
  2524.                 SetTooltipText(InformationTooltip, L.ESOMRL_DJUNKUING)
  2525.             elseif ESOMRL.SV[800].junkunmarkedingredients == 1 then
  2526.                 ESOMRL.SV[800].junkunmarkedingredients = 0
  2527.                 ESOMRL_MainFrameIngredientsFrameTrashUncheckedButton1:SetHidden(false)
  2528.                 ESOMRL_MainFrameIngredientsFrameTrashUncheckedButton2:SetHidden(true)
  2529.                 ClearTooltip(InformationTooltip)
  2530.                 if GetCVar('Language.2') == 'fr' then
  2531.                     InitializeTooltip(InformationTooltip, ESOMRL_MainFrameIngredientsFrameListTooltipButton, TOPLEFT, 10, -85, BOTTOMRIGHT)
  2532.                 else
  2533.                     InitializeTooltip(InformationTooltip, ESOMRL_MainFrameIngredientsFrameListTooltipButton, TOPLEFT, 10, -63, BOTTOMRIGHT)
  2534.                 end
  2535.                 SetTooltipText(InformationTooltip, L.ESOMRL_JUNKUING)
  2536.             end
  2537.         end
  2538.     end
  2539. end
  2540.  
  2541. local function OnInventorySlotUpdate(eventCode, bagId, slotId, isNewItem, itemSoundCategory, updateReason)
  2542.     if PlayerLoaded == 0 then return end
  2543.     if isNewItem ~= true then return end
  2544.     if bagId ~= BAG_BACKPACK then return end
  2545.     if updateReason ~= INVENTORY_UPDATE_REASON_DEFAULT then return end
  2546.     if IsUnderArrest() then return end
  2547.     if Roomba and Roomba.WorkInProgress and Roomba.WorkInProgress() then return end
  2548.     if IsItemJunk(bagId, slotId) then return end
  2549.     local icon, stackCount, sellPrice, meetsUsageRequirements, locked, equipType, itemStyle, quality = GetItemInfo(bagId, slotId)
  2550.     if stackCount < 1 then return end
  2551.     local itemLink = GetItemLink(bagId, slotId)
  2552.     local itemType = GetItemLinkItemType(itemLink)
  2553.     local itemId = select(4, ZO_LinkHandler_ParseLink(itemLink))
  2554.     if ESOMRL.SV[800].ignorestolen and IsItemLinkStolen(itemLink) then
  2555.         if ESOMRL.SV[800].debugmode == true then
  2556.             if itemType == ITEMTYPE_INGREDIENT then
  2557.                 d('\'' .. stackCount .. 'x ' .. GetItemLinkName(itemLink) .. '\' ' .. L.ESOMRL_ISTOLENM)
  2558.             elseif itemType == ITEMTYPE_RECIPE then
  2559.                 d('\'' .. GetItemLinkName(itemLink) .. '\' ' .. L.ESOMRL_ISTOLENM)
  2560.             end
  2561.         end
  2562.     return end
  2563.     if itemType == ITEMTYPE_INGREDIENT then
  2564.         local key = FindMatch(ESOMRL.IngredientMaterials, itemId)
  2565.         if key ~= 0 then
  2566.             if itemId == ESOMRL.IngredientLinks[key].id then
  2567.                 if GetIngredientSavedVar(key) == 0 then
  2568.                     if ESOMRL.SV[800].destroyjunkingredients == true then
  2569.                         if ESOMRL.SV[800].destroyunmarkedingredients == 1 then
  2570.                             if stackCount <= ESOMRL.SV[800].maxjunkstack then
  2571.                                 DestroyItem(bagId, slotId)
  2572.                                 if ESOMRL.SV[800].debugmode == true then
  2573.                                     d('\'' .. stackCount .. 'x ' .. GetItemLinkName(itemLink) .. '\' ' .. L.ESOMRL_IDESTROYM)
  2574.                                 end
  2575.                             end
  2576.                         end
  2577.                     elseif ESOMRL.SV[800].destroyjunkingredients == false then
  2578.                         if ESOMRL.SV[800].junkunmarkedingredients == 1 then
  2579.                             if not IsItemJunk(bagId, slotId) then
  2580.                                 if stackCount <= ESOMRL.SV[800].maxjunkstack then  
  2581.                                     SetItemIsJunk(bagId, slotId, true)
  2582.                                     if ESOMRL.SV[800].debugmode == true then
  2583.                                         d('\'' .. stackCount .. 'x ' .. GetItemLinkName(itemLink) .. '\' ' .. L.ESOMRL_IJUNKM)
  2584.                                     end
  2585.                                 end
  2586.                             end
  2587.                         end
  2588.                     end
  2589.                 end
  2590.             end
  2591.         end
  2592.     elseif itemType == ITEMTYPE_RECIPE then
  2593.         local key = FindMatch(ESOMRL.RecipeMaterials, itemId)
  2594.         if key ~= 0 then
  2595.             local quality = GetItemLinkQuality(itemLink)
  2596.             local checktracking = GetRecipeSavedVar(key, 1)
  2597.             if itemId == ESOMRL.ProvisioningLinks[key].id then
  2598.                 if checktracking == 0 or checktracking == 3 then
  2599.                     if ESOMRL.SV[800].destroyjunkrecipes == true then
  2600.                         if ESOMRL.SV[800].destroyunmarkedrecipes == 1 then
  2601.                             if quality < ESOMRL.SV[800].maxjunkquality then
  2602.                                 DestroyItem(bagId, slotId)
  2603.                                 if ESOMRL.SV[800].debugmode == true then
  2604.                                     d('\'' .. GetItemLinkName(itemLink) .. '\' ' .. L.ESOMRL_IDESTROYM)
  2605.                                 end
  2606.                             end
  2607.                         end
  2608.                     elseif ESOMRL.SV[800].destroyjunkrecipes == false then
  2609.                         if ESOMRL.SV[800].junkunmarkedrecipes == 1 then
  2610.                             if not IsItemJunk(bagId, slotId) then
  2611.                                 if quality < ESOMRL.SV[800].maxjunkquality then
  2612.                                     SetItemIsJunk(bagId, slotId, true)
  2613.                                     if ESOMRL.SV[800].debugmode == true then
  2614.                                         d('\'' .. GetItemLinkName(itemLink) .. '\' ' .. L.ESOMRL_IJUNKM)
  2615.                                     end
  2616.                                 end
  2617.                             end
  2618.                         end
  2619.                     end
  2620.                 end
  2621.             end
  2622.         end
  2623.     end
  2624. end
  2625.  
  2626. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2627. -- Set up the Addon Settings options panel.
  2628. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2629. local function CreateSettingsWindow(addonName)
  2630.     local panelData = {
  2631.         type                    = 'panel',
  2632.         name                    = 'ESO Master Recipe List',
  2633.         displayName             = '|cFEE854ESO|r |cFF9900Master Recipe List|r',
  2634.         author                  = ESOMRL.Author,
  2635.         version                 = ESOMRL.Version,
  2636.         registerForRefresh      = true,
  2637.         registerForDefaults     = true,
  2638.     }
  2639.  
  2640.     local optionsData = {
  2641.     {
  2642.         type = 'header',
  2643.         name = ZO_HIGHLIGHT_TEXT:Colorize(L.ESOMRL_CHAROPT),
  2644.     },
  2645.     {
  2646.         type            = 'checkbox',
  2647.         name            = L.ESOMRL_ETRACKING,
  2648.         tooltip         = L.ESOMRL_TRACKDESC,
  2649.         getFunc         = function() return ESOMRL.SV[800].trackChar end,
  2650.         setFunc         = function(value)
  2651.                             ESOMRL.SV[800].trackChar = value
  2652.                             InitKnown()
  2653.                         end,
  2654.         warning         = L.ESOMRL_TRACKWARN,
  2655.         default         = CharacterDefaults[800].trackChar,
  2656.     },
  2657.     {
  2658.         type            = 'checkbox',
  2659.         name            = '|cff0000' .. L.ESOMRL_RDESTROY .. '|r',
  2660.         tooltip         = L.ESOMRL_RDESTDESC,
  2661.         getFunc         = function() return ESOMRL.SV[800].destroyjunkrecipes end,
  2662.         setFunc         = function(value)
  2663.                             ESOMRL.SV[800].junkunmarkedrecipes = 0
  2664.                             ESOMRL.SV[800].destroyunmarkedrecipes = 0
  2665.                             ESOMRL.SV[800].destroyjunkrecipes = value
  2666.                             RecipePanelSetup()
  2667.                         end,
  2668.         warning         = L.ESOMRL_RDESTROYWARN,
  2669.         default         = CharacterDefaults[800].destroyjunkrecipes,
  2670.     },
  2671.     {
  2672.         type            = 'checkbox',
  2673.         name            = '|cff0000' .. L.ESOMRL_IDESTROY .. '|r',
  2674.         tooltip         = L.ESOMRL_IDESTDESC,
  2675.         getFunc         = function() return ESOMRL.SV[800].destroyjunkingredients end,
  2676.         setFunc         = function(value)
  2677.                             ESOMRL.SV[800].junkunmarkedingredients = 0
  2678.                             ESOMRL.SV[800].destroyunmarkedingredients = 0
  2679.                             ESOMRL.SV[800].destroyjunkingredients = value
  2680.                             IngredientPanelSetup()
  2681.                         end,
  2682.         warning         = L.ESOMRL_IDESTROYWARN,
  2683.         default         = CharacterDefaults[800].destroyjunkingredients,
  2684.     },
  2685.     {
  2686.         type            = 'checkbox',
  2687.         name            = '|c00ff00' .. L.ESOMRL_ISTOLEN .. '|r',
  2688.         tooltip         = L.ESOMRL_ISTOLEND,
  2689.         getFunc         = function() return ESOMRL.SV[800].ignorestolen end,
  2690.         setFunc         = function(value) ESOMRL.SV[800].ignorestolen = value end,
  2691.         default         = CharacterDefaults[800].ignorestolen,
  2692.     },
  2693.     {
  2694.         type            = 'checkbox',
  2695.         name            = '|cffff00' .. L.ESOMRL_DEBUGMODE .. '|r',
  2696.         tooltip         = L.ESOMRL_DEBUGDESC,
  2697.         getFunc         = function() return ESOMRL.SV[800].debugmode end,
  2698.         setFunc         = function(value) ESOMRL.SV[800].debugmode = value end,
  2699.         default         = CharacterDefaults[800].debugmode,
  2700.     },
  2701.     {
  2702.         type            = 'dropdown',
  2703.         name            = L.ESOMRL_DQUALITY,
  2704.         tooltip         = L.ESOMRL_DQUALITYDESC,
  2705.         choices         = qualityCap,
  2706.         getFunc         = function() return qualityCap[ESOMRL.SV[800].maxjunkquality - 1] end,
  2707.         setFunc         = function(selected)
  2708.                             for k,v in ipairs(qualityCap) do
  2709.                                 if v == selected then
  2710.                                     ESOMRL.SV[800].maxjunkquality = k + 1
  2711.                                     break
  2712.                                 end
  2713.                             end
  2714.                         end,
  2715.         default         = qualityCap[CharacterDefaults[800].maxjunkquality],
  2716.     },
  2717.     {
  2718.         type            = 'slider',
  2719.         name            = L.ESOMRL_STACKSIZE,
  2720.         tooltip         = L.ESOMRL_STACKDESC,
  2721.         min             = 1,
  2722.         max             = 100,
  2723.         step            = 1,
  2724.         getFunc         = function() return ESOMRL.SV[800].maxjunkstack end,
  2725.         setFunc         = function(value) ESOMRL.SV[800].maxjunkstack = value end,
  2726.         default         = CharacterDefaults[800].maxjunkstack,
  2727.     },
  2728.     {
  2729.         type            = 'dropdown',
  2730.         name            = L.ESOMRL_TCHAR,
  2731.         tooltip         = L.ESOMRL_TCHARD,
  2732.         choices         = nameList,
  2733.         getFunc         = function() return nameList[ESOMRL.SV[800].trackingchar] end,
  2734.         setFunc         = function(selected)
  2735.                             for k,v in ipairs(nameList) do
  2736.                                 if v == selected then
  2737.                                     ESOMRL.SV[800].trackingchar = k
  2738.                                     break
  2739.                                 end
  2740.                             end
  2741.                             RefreshViews()
  2742.                         end,
  2743.         default         = CharacterDefaults[800].trackingchar,
  2744.     },
  2745.     {
  2746.         type            = 'checkbox',
  2747.         name            = L.ESOMRL_ALTIU,
  2748.         tooltip         = L.ESOMRL_ALTIUD,
  2749.         getFunc         = function() return ESOMRL.SV[800].altknown end,
  2750.         setFunc         = function(value)
  2751.                             ESOMRL.SV[800].altknown = value
  2752.                             RefreshViews()
  2753.                         end,
  2754.         default         = CharacterDefaults[800].altknown,
  2755.     },
  2756.     {
  2757.         type            = 'checkbox',
  2758.         name            = L.ESOMRL_ALTIS,
  2759.         tooltip         = L.ESOMRL_ALTISD,
  2760.         getFunc         = function() return ESOMRL.SV[800].altknownself end,
  2761.         setFunc         = function(value)
  2762.                             ESOMRL.SV[800].altknownself = value
  2763.                             RefreshViews()
  2764.                         end,
  2765.         default         = CharacterDefaults[800].altknownself,
  2766.         disabled        = function() return not ESOMRL.SV[800].altknown end,
  2767.     },
  2768.     {
  2769.         type            = 'submenu',
  2770.         name            = L.ESOMRL_GLOBALOPT,
  2771.         tooltip         = L.ESOMRL_GLOBALOPT,
  2772.         controls        = {
  2773.                         [1] = {
  2774.                             type = 'checkbox',
  2775.                             name = L.ESOMRL_SHOWKNOWN,
  2776.                             tooltip = L.ESOMRL_SHOWKNOWND,
  2777.                             getFunc = function() return ESOMRL.ASV[800].known end,
  2778.                             setFunc = function(value) ESOMRL.ASV[800].known = value end,
  2779.                             width = 'full',
  2780.                             default = AccountDefaults[800].known,
  2781.                         },
  2782.                         [2] = {
  2783.                             type = 'checkbox',
  2784.                             name = L.ESOMRL_SHOWINGFOOD,
  2785.                             tooltip = L.ESOMRL_SHOWINGFOODD,
  2786.                             getFunc = function() return ESOMRL.ASV[800].ingfood end,
  2787.                             setFunc = function(value) ESOMRL.ASV[800].ingfood = value end,
  2788.                             width = 'full',
  2789.                             default = AccountDefaults[800].ingfood,
  2790.                         },
  2791.                         [3] = {
  2792.                             type            = 'checkbox',
  2793.                             name            = L.ESOMRL_INVENTORYI,
  2794.                             tooltip         = L.ESOMRL_INVENTORYD,
  2795.                             getFunc         = function() return ESOMRL.ASV[800].inventoryicons end,
  2796.                             setFunc         = function(value)
  2797.                                                 ESOMRL.ASV[800].inventoryicons = value
  2798.                                                 RefreshViews()
  2799.                                             end,
  2800.                             default         = AccountDefaults[800].inventoryicons,
  2801.                         },
  2802.                         [4] = {
  2803.                             type            = 'slider',
  2804.                             name            = L.ESOMRL_ICONPOSI,
  2805.                             tooltip         = L.ESOMRL_ICONPOSID,
  2806.                             min             = -380,
  2807.                             max             = 100,
  2808.                             step            = 1,
  2809.                             getFunc         = function() return ESOMRL.ASV[800].bagiconoffset end,
  2810.                             setFunc         = function(value)
  2811.                                                 ESOMRL.ASV[800].bagiconoffset = value
  2812.                                                 RefreshViews()
  2813.                                             end,
  2814.                             default         = AccountDefaults[800].bagiconoffset,
  2815.                             disabled        = function() return ESOMRL.SV[800].fcoitemsaver end,
  2816.                         },
  2817.                         [5] =  {
  2818.                             type            = 'slider',
  2819.                             name            = L.ESOMRL_ICONPOSB,
  2820.                             tooltip         = L.ESOMRL_ICONPOSBD,
  2821.                             min             = -30,
  2822.                             max             = 145,
  2823.                             step            = 1,
  2824.                             getFunc         = function() return ESOMRL.ASV[800].gstoreiconoffset end,
  2825.                             setFunc         = function(value)
  2826.                                                 ESOMRL.ASV[800].gstoreiconoffset = value
  2827.                                                 RefreshViews()
  2828.                                             end,
  2829.                             default         = AccountDefaults[800].gstoreiconoffset,
  2830.                         },
  2831.                         [6] =  {
  2832.                             type            = 'slider',
  2833.                             name            = L.ESOMRL_ICONPOSL,
  2834.                             tooltip         = L.ESOMRL_ICONPOSLD,
  2835.                             min             = -30,
  2836.                             max             = 145,
  2837.                             step            = 1,
  2838.                             getFunc         = function() return ESOMRL.ASV[800].glistingiconoffset end,
  2839.                             setFunc         = function(value)
  2840.                                                 ESOMRL.ASV[800].glistingiconoffset = value
  2841.                                                 RefreshViews()
  2842.                                             end,
  2843.                             default         = AccountDefaults[800].glistingiconoffset,
  2844.                         },
  2845.                         [7] = {
  2846.                             type            = 'checkbox',
  2847.                             name            = L.ESOMRL_SSTATS,
  2848.                             tooltip         = L.ESOMRL_SSTATSD,
  2849.                             getFunc         = function() return ESOMRL.ASV[800].stationstats end,
  2850.                             setFunc         = function(value)
  2851.                                                 ESOMRL.ASV[800].stationstats = value
  2852.                                             end,
  2853.                             default         = AccountDefaults[800].stationstats,
  2854.                         },
  2855.                         [8] = {
  2856.                             type            = 'iconpicker',
  2857.                             name            = L.ESOMRL_SSTATICONS,
  2858.                             tooltip         = L.ESOMRL_SSTATICONSD,
  2859.                             choices         = StatOptions,
  2860.                             choicesTooltips = StatOptionTooltips,
  2861.                             getFunc         = function() return StatOptions[ESOMRL.ASV[800].stationicons] end,
  2862.                             setFunc         = function(texturePath)
  2863.                                                 local textureId = GetTextureId(texturePath)
  2864.                                                 if textureId ~= 0 then
  2865.                                                     ESOMRL.ASV[800].stationicons = textureId
  2866.                                                     SwitchStationIcons(textureId)
  2867.                                                 end
  2868.                                             end,
  2869.                             maxColumns      = 2,
  2870.                             visibleRows     = 1,
  2871.                             iconSize        = 64,
  2872.                             default         = StatOptions[AccountDefaults[800].stationicons],
  2873.                             disabled        = function() return not ESOMRL.ASV[800].stationstats end,
  2874.                         },
  2875.                         },
  2876.     },
  2877.     {
  2878.         type            = 'submenu',
  2879.         name            = L.ESOMRL_ADDONS,
  2880.         tooltip         = L.ESOMRL_ADDONSD,
  2881.         controls        = {
  2882.                         [1] = {
  2883.                             type            = 'checkbox',
  2884.                             name            = L.ESOMRL_FCOITEM,
  2885.                             tooltip         = L.ESOMRL_FCOITEMD,
  2886.                             getFunc         = function() return ESOMRL.SV[800].fcoitemsaver end,
  2887.                             setFunc         = function(value)
  2888.                                                 ESOMRL.SV[800].fcoitemsaver = value
  2889.                                                 RefreshViews()
  2890.                                             end,
  2891.                             default         = CharacterDefaults[800].fcoitemsaver,
  2892.                             disabled        = function() return not FCOItemSaverActive end,
  2893.                         },
  2894.                         }
  2895.     }
  2896.     }
  2897.  
  2898.     local LAM = LibStub('LibAddonMenu-2.0')
  2899.     LAM:RegisterAddonPanel('ESOMRL_Panel', panelData)
  2900.     LAM:RegisterOptionControls('ESOMRL_Panel', optionsData)
  2901. end
  2902.  
  2903. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2904. -- Initialize the addon and the interactive recipe scroll list, and set up language strings and formatting.
  2905. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2906. local function InitMain()
  2907.     local control = GetControl('ESOMRL_MainFrameListFrameList')
  2908.     ZO_ScrollList_AddDataType(control, 1 , 'ESOMRL_ListItemTemplate', 20,  SetListItem)
  2909. end
  2910.  
  2911. local function InitRecipeTooltip(control)
  2912.     if not control then return end
  2913.     RecipeItemTooltipControl = control
  2914.     control:SetParent(PopupTooltipTopLevel)
  2915. end
  2916.  
  2917. local function InitIngredientTooltip(control)
  2918.     if not control then return end
  2919.     IngredientItemTooltipControl = control
  2920.     control:SetParent(PopupTooltipTopLevel)
  2921. end
  2922.  
  2923. local function InitQualityDatabase()
  2924.     qualityCap[1] = '|c00ff00' .. L.ESOMRL_QUALITY1 .. '|r'
  2925.     qualityCap[2] = '|c3a92ff' .. L.ESOMRL_QUALITY2 .. '|r'
  2926.     qualityCap[3] = '|ca02ef7' .. L.ESOMRL_QUALITY3 .. '|r'
  2927. end
  2928.  
  2929. local function ShowMain()
  2930.     ESOMRL:SetLanguageFormat()
  2931.     local control = GetControl('ESOMRL_MainFrame')
  2932.     if ( control:IsHidden() ) then
  2933.         control:SetHidden(false)
  2934.         RestorePosition()
  2935.         openTab = 1
  2936.         NavigateScrollList(1)
  2937.     else
  2938.         control:SetHidden(true)
  2939.     end
  2940.     SetTrackedRecipeCountText()
  2941.     RecipePanelRestore()
  2942. end
  2943.  
  2944. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2945. -- Global function to check if MRL is tracking a recipe or ingredient.
  2946. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2947. function ESOMRL.ISMRLTracking(itemLink)
  2948.     if itemLink ~= nil then
  2949.         local itemIdT = {select(4, ZO_LinkHandler_ParseLink(itemLink))}
  2950.         local itemId = tonumber(itemIdT[1])
  2951.         if ESOMRL.IngredientMaterials[itemId] ~= nil then
  2952.             local key = ESOMRL.IngredientMaterials[itemId].position
  2953.             if GetIngredientSavedVar(key) == 1 then
  2954.                 return true
  2955.             end
  2956.         elseif ESOMRL.RecipeMaterials[itemId] ~= nil then
  2957.             local key = ESOMRL.RecipeMaterials[itemId].position
  2958.             local checktracking = GetRecipeSavedVar(key, 1)
  2959.             if checktracking == 1 or checktracking == 2 then
  2960.                 return true
  2961.             end
  2962.         end
  2963.     end
  2964.     return false
  2965. end
  2966.  
  2967. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2968. -- Handle function calls from XML.
  2969. -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  2970. function ESOMRL.XMLNavigation(option, control, text, n1, n2)
  2971. -- List click and tooltips.
  2972.     if option == 001 then
  2973.         ListTooltips(control, text, n1)
  2974.     elseif option == 002 then
  2975.         RecipeListClick(text)
  2976. -- Main Frame functions.
  2977.     elseif option == 101 then
  2978.         OnMoveStop()
  2979.     elseif option == 102 then
  2980.         InitMain()
  2981.     elseif option == 103 then
  2982.         InitRecipeTooltip(control)
  2983.     elseif option == 104 then
  2984.         InitIngredientTooltip(control)
  2985.     elseif option == 105 then
  2986.         CloseMain(control, n1)
  2987.     elseif option == 106 then
  2988.         ToggleTooltips(control, n1)
  2989.     elseif option == 107 then
  2990.         InfoTooltip(n1)
  2991.     elseif option == 108 then
  2992.         SwitchPage(control, n1)
  2993. -- Ingredient Frame functions.
  2994.     elseif option == 201 then
  2995.         IngredientListClick(control, n1, n2)
  2996.     elseif option == 202 then
  2997.         ClearTrackedIngredients()
  2998.     elseif option == 203 then
  2999.         TrackedRecipeIngredients(control, n1)
  3000.     elseif option == 204 then
  3001.         SelectAllIngredients(control, n1)
  3002.     elseif option == 205 then
  3003.         JunkUnmarkedIngredientFunction(n1)
  3004.     elseif option == 206 then
  3005.         SaveGlobalIngredientProfile(n1)
  3006.     elseif option == 207 then
  3007.         LoadGlobalIngredientProfile(n1)
  3008. -- Left side navigation.
  3009.     elseif option == 301 then
  3010.         ClearTrackedRecipes()
  3011.     elseif option == 302 then
  3012.         WritButton(control, n1)
  3013.     elseif option == 303 then
  3014.         GetWrits()
  3015.     elseif option == 304 then
  3016.         if IsShiftKeyDown() == true then
  3017.             TrackNavigationTier(n1)
  3018.         end
  3019.         NavigateScrollList(n1)
  3020.     elseif option == 305 then
  3021.         SelectTooltipStyle(n1)
  3022.     elseif option == 306 then
  3023.         RecipeOptionPanel(n1)
  3024. -- Text search options
  3025.     elseif option == 401 then
  3026.         TextBoxEvents(n1)
  3027. -- Open Main Window
  3028.     elseif option == 501 then
  3029.         ShowMain()
  3030. -- Recipe config menu functions.
  3031.     elseif option == 601 then
  3032.         TrackUnknownRecipes(n1)
  3033.     elseif option == 602 then
  3034.         TrackAllRecipes(n1)
  3035.     elseif option == 603 then
  3036.         JunkUnmarkedRecipeFunction(n1)
  3037.     elseif option == 604 then
  3038.         RemoveCharacter(n1)
  3039. -- Cooking station controls.
  3040.     elseif option == 701 then
  3041.         StationButtonTooltip(control, n1)
  3042.     elseif option == 702 then
  3043.         HighlightTracked(control, n1)
  3044.     elseif option == 703 then
  3045.         ToggleStationTooltips(control, n1)
  3046.     elseif option == 704 then
  3047.         StationSearch(control, n1)
  3048.     end
  3049. end
  3050.  
  3051. local function Init(eventCode) PlayerLoaded = 1 end
  3052. local function OnAddonLoaded(event, addonName)
  3053.     if addonName ~= ESOMRL.Name then return end
  3054.     EVENT_MANAGER:UnregisterForEvent(ESOMRL.Name, EVENT_ADD_ON_LOADED)
  3055.     ESOMRL.SV = ZO_SavedVars:New(ESOMRL.Name, 1.29, 'CharacterSettings', CharacterDefaults)
  3056.     ESOMRL.ASV = ZO_SavedVars:NewAccountWide(ESOMRL.Name, 1.29, 'AccountSettings', AccountDefaults)
  3057.     ZO_CreateStringId('SI_BINDING_NAME_TOGGLE_RECIPE_WINDOW', 'Toggle Recipe Window')
  3058.     FCOItemSaverActive = (FCOIsMarked ~= nil)
  3059.     if not FCOItemSaverActive then ESOMRL.SV[800].fcoitemsaver = false end
  3060.     SetupCharacterDropbox()
  3061.     InitQualityDatabase()
  3062.     HookBags()
  3063.     HookTooltips()
  3064.     HookStation()
  3065.     InitKnown()
  3066.     StationWritCheck()
  3067.     CreateSettingsWindow(addonName)
  3068. end
  3069.  
  3070. SLASH_COMMANDS['/mrl'] = ShowMain
  3071. SLASH_COMMANDS['/recipes'] = ShowMain
  3072. EVENT_MANAGER:RegisterForEvent(ESOMRL.Name, EVENT_PLAYER_ACTIVATED, Init)
  3073. EVENT_MANAGER:RegisterForEvent(ESOMRL.Name, EVENT_ADD_ON_LOADED, OnAddonLoaded)
  3074. EVENT_MANAGER:RegisterForEvent(ESOMRL.Name, EVENT_RECIPE_LEARNED, InitKnown)
  3075. EVENT_MANAGER:RegisterForEvent(ESOMRL.Name, EVENT_INVENTORY_SINGLE_SLOT_UPDATE, OnInventorySlotUpdate)
  3076. EVENT_MANAGER:RegisterForEvent(ESOMRL.Name, EVENT_TRADING_HOUSE_RESPONSE_RECEIVED, HookTradeHouse)
  3077. EVENT_MANAGER:RegisterForEvent(ESOMRL.Name, EVENT_OPEN_STORE, HookBuyback)
  3078. EVENT_MANAGER:RegisterForEvent(ESOMRL.Name, EVENT_QUEST_ADDED, OnQuestAdded)
  3079. EVENT_MANAGER:RegisterForEvent(ESOMRL.Name, EVENT_QUEST_REMOVED, OnQuestRemoved)
  3080. EVENT_MANAGER:RegisterForEvent(ESOMRL.Name, EVENT_QUEST_COMPLETE, OnQuestComplete)
  3081. EVENT_MANAGER:RegisterForEvent(ESOMRL.Name, EVENT_QUEST_CONDITION_COUNTER_CHANGED, OnQuestConditionCounterChanged)
  3082. EVENT_MANAGER:RegisterForEvent(ESOMRL.Name, EVENT_CRAFTING_STATION_INTERACT, OnCraftingStationInteract)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement