View Single Post
03-12-24, 11:15 PM   #13
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 115
In addon Events tracker, this function is implemented. When event B is in progress, event A has not started and its start time is increased (see picture)



The code below shows the entire code of addon Events tracker (the code shows the time of different regions, Europe, America, etc. but I only need 1 region - Europe)
Where - Trial of Elements is event A
Where - Storm's fury is event B
The timer only needs to display event A


As I understand it, this is done through the datablock function
Lua Code:
  1. datablock = {
  2.                 [0] = {name = "Trial of the Elements", enable = false, coor = {2085, 27.91, 25.86},},
  3.                 [1] = {name = "Trial of the Elements", enable = false, coor = {2085, 27.91, 25.86},},
  4.                 [2] = {name = "Trial of the Elements", enable = true, coor = {2085, 27.91, 25.86},},
  5.                 [3] = {name = "Trial of the Elements", enable = true, coor = {2085, 27.91, 25.86},},
  6.                 [4] = {name = "Trial of the Elements", enable = true, coor = {2085, 27.91, 25.86},},
  7.             },



Lua Code:
  1. local _, L = ...
  2. local LMB, RMB = CreateAtlasMarkup("NPE_LeftClick", 18, 18), CreateAtlasMarkup("NPE_RightClick", 18,18);
  3. --EVENTS_TRACKER_MODULE = ObjectiveTracker_GetModuleInfoTable("EVENTS_TRACKER_MODULE");
  4. --EVENTS_TRACKER_MODULE.updateReasonModule = OBJECTIVE_TRACKER_UPDATE_MODULE_EVENTS;
  5. --EVENTS_TRACKER_MODULE:SetHeader(ObjectiveTrackerFrame.BlocksFrame.ProfessionHeader, PROFESSIONS_TRACKER_HEADER_PROFESSION);
  6.  
  7. EventsTrackerMixin = {}
  8. local eventFrame = {}
  9. local selfName
  10.  
  11. ---------------------------------------------
  12. -- Default config
  13. local DefaultConfig = {
  14.     collapsed = false,
  15.     iconSize = 26,
  16.     iconSpace = 8,
  17.     iconsInRow = 8,
  18.     fontSize = 10,
  19.     speakVolume = 70,
  20.     timeBefore = 300,
  21.     extendedTooltip = true,
  22.     events = {
  23.         [1] = { name = "Community feast",
  24.             texture = "MajorFactions_MapIcons_Tuskarr64",
  25.             eventRegionOffset = {
  26.                 [1] = 52,   -- us
  27.                 [2] = 52,   -- kr
  28.                 [3] = 52,   -- eu
  29.                 [4] = 52,   -- tw
  30.                 [5] = 52,}, -- ch              
  31.             eventDuration = 900,
  32.             eventInterval = 5400,
  33.             enable = true,
  34.             sound = false,
  35.             voice_before = false,
  36.             voice_active = false,
  37.             anim = true,
  38.             questIDs = {70893},
  39.             findEventOnMap = {},
  40.             coor = {2024, 13.4, 48.4},
  41.             datablock = {},
  42.         },
  43.         [2] = { name = "Researchers under fire",
  44.             texture = "MajorFactions_MapIcons_Niffen64",
  45.             eventRegionOffset = {
  46.                 [1] = 1800,
  47.                 [2] = 1800,
  48.                 [3] = 1800,
  49.                 [4] = 1800,
  50.                 [5] = 1800,},
  51.             eventDuration = 1500,
  52.             eventInterval = 3600,
  53.             enable = true,
  54.             sound = false,
  55.             voice_before = false,
  56.             voice_active = false,
  57.             anim = true,
  58.             questIDs = {75627, 75628, 75629, 75630}, -- Epic 75630, Rare 75629, Uncommon, 75628, Common 75627
  59.             findEventOnMap = {},
  60.             coor = {2133, 47.6, 56.7},
  61.             datablock = {},
  62.         },
  63.         [3] = { name = "Dragonbane Keep",
  64.             texture = "MajorFactions_MapIcons_Expedition64",
  65.             eventRegionOffset = {
  66.                 [1] = 100,
  67.                 [2] = 100,
  68.                 [3] = 100,
  69.                 [4] = 100
  70.                 [5] = 100,},
  71.             eventDuration = 3600,
  72.             eventInterval = 7200,
  73.             enable = true,
  74.             sound = false,
  75.             voice_before = false,
  76.             voice_active = false,
  77.             anim = true,
  78.             questIDs = {70866},
  79.             findEventOnMap = {},
  80.             coor = {2022, 30.48, 78.20},
  81.             datablock = {},
  82.         },
  83.         [4] = { name = "Time rift",
  84.             texture = "interface/targetingframe/unitframeicons.blp", --ChromieTime-32x32
  85.             eventRegionOffset = {
  86.                 [1] = 20,
  87.                 [2] = 20,
  88.                 [3] = 20,
  89.                 [4] = 20,  
  90.                 [5] = 20,},
  91.             eventDuration = 900,
  92.             eventInterval = 3600,
  93.             enable = true,
  94.             sound = false,
  95.             voice_before = false,
  96.             voice_active = false,
  97.             anim = true,
  98.             questIDs = {77836},
  99.             findEventOnMap = {},
  100.             coor = {2025, 51, 57},
  101.             datablock = {},
  102.         },
  103.         [5] = { name = "Rares spawn",
  104.             texture = "VignetteKillElite",
  105.             eventRegionOffset = {
  106.                 [1] = 0,
  107.                 [2] = 0,
  108.                 [3] = 14400,
  109.                 [4] = 0,
  110.                 [5] = 0,},
  111.             eventDuration = 60,
  112.             eventInterval = 1800,
  113.             enable = true,
  114.             sound = false,
  115.             voice_before = false,
  116.             voice_active = false,
  117.             anim = true,
  118.             questIDs = {},
  119.             findEventOnMap = {},
  120.             coor = {},
  121.             datablock = {
  122.                 [0] = {name = "Amethyzar the Glittering", enable = true, coor = {2022, 63.6, 55.0},},
  123.                 [1] = {name = "Eldoren the Reborn", enable = true, coor = {2025, 47.8, 51.2},},
  124.                 [2] = {name = "Pheran", enable = true, coor = {2025, 60.6, 61.6},},
  125.                 [3] = {name = "Skag the Thrower", enable = true, coor = {2024, 26.8, 49.6},},
  126.                 [4] = {name = "Mikrin of the Raging Winds", enable = true, coor = {2023, 63.0, 80.0},},
  127.                 [5] = {name = "Rokmur", enable = true, coor = {2025, 50.0, 51.6},},
  128.                 [6] = {name = "Smogswog the Firebreather", enable = true, coor = {2022, 69.6, 64.6},},
  129.                 [7] = {name = "Matriarch Remalla", enable = true, coor = {2025, 52.8, 59.0},},
  130.                 [8] = {name = "O'nank Shorescour", enable = true, coor = {2022, 79.19, 52.92},},
  131.                 [9] = {name = "Researcher Sneakwing", enable = true, coor = {2023, 37.0, 53.8},},
  132.                 [10] = {name = "Treasure-Mad Trambladd", enable = true, coor = {2025, 35.0, 70.0},},
  133.                 [11] = {name = "Harkyn Grymstone", enable = true, coor = {2022, 42.2, 39.6},},
  134.                 [12] = {name = "Fulgurb", enable = true, coor = {2023, 75.2, 46.8},},
  135.                 [13] = {name = "Sandana the Tempest", enable = true, coor = {2025, 37.6, 78.0},},
  136.                 [14] = {name = "Gorjo the Crab Shackler", enable = true, coor = {2022, 78.6, 49.8},},
  137.                 [15] = {name = "Steamgill", enable = true, coor = {2023, 53.6, 72.8},},
  138.                 [16] = {name = "Tempestrian", enable = true, coor = {2025, 50.0, 79.0},},
  139.                 [17] = {name = "Massive Magmashell", enable = true, coor = {2022, 21.8, 76.6},},
  140.                 [18] = {name = "Grumbletrunk", enable = true, coor = {2024, 19.6, 43.2},},
  141.                 [19] = {name = "Oshigol", enable = true, coor = {2023, 61.6, 30.0},},
  142.                 [20] = {name = "Broodweaver Araznae", enable = true, coor = {2025, 61.51, 73.74},},
  143.                 [21] = {name = "Azra's Prized Peony", enable = true, coor = {2022, 54.6, 71.6},},
  144.                 [22] = {name = "Malsegan", enable = true, coor = {2023, 72.0, 46.6},},
  145.                 [23] = {name = "Phleep", enable = true, coor = {2025, 58.6, 85.6},},
  146.                 [24] = {name = "Magmaton", enable = true, coor = {2022, 40.0, 64.0},},
  147.                 [25] = {name = "Gruffy", enable = true, coor = {2024, 32.6, 29.2},},
  148.                 [26] = {name = "Ronsak the Decimator", enable = true, coor = {2023, 43.6, 55.4},},
  149.                 [27] = {name = "Riverwalker Tamopo", enable = true, coor = {2025, 39.8, 70.0},},
  150.             },
  151.         },
  152.         [6] = { name = "Dreamsurge",
  153.             texture = "dreamsurge_hub-icon",
  154.             eventRegionOffset = {
  155.                 [1] = 19,
  156.                 [2] = 19,
  157.                 [3] = 19,
  158.                 [4] = 19,  
  159.                 [5] = 19,},
  160.             eventDuration = 1800,
  161.             eventInterval = 1800,
  162.             enable = true,
  163.             sound = false,
  164.             voice_before = false,
  165.             voice_active = false,
  166.             anim = true,
  167.             questIDs = {77251},
  168.             findEventOnMap = {2022, 2023, 2024, 2025},
  169.             coor = {},
  170.             datablock = {},
  171.         },
  172.         [7] = { name = "Storm's Fury",
  173.             texture = "ElementalStorm-Boss-Water",
  174.             eventRegionOffset = {
  175.                 [1] = 1670338860 + 3600,
  176.                 [2] = 1670698860,
  177.                 [3] = 1674763260,
  178.                 [4] = 1670698860,
  179.                 [5] = 1670677260,},
  180.             eventDuration = 7200,
  181.             eventInterval = 18000,
  182.             enable = true,
  183.             sound = false,
  184.             voice_before = false,
  185.             voice_active = false,
  186.             anim = true,
  187.             questIDs = {74378}, --73162
  188.             findEventOnMap = {},
  189.             coor = {2025, 59.84, 82.29},
  190.             datablock = {},
  191.         },
  192.         [8] = { name = "Trial of Elements",         -- ENCOUNTER_LOOT_RECEIVED: encounterID, itemID, itemLink, quantity, playerName, classFileName
  193.             texture = "VignetteLootElite",          -- AREA_POIS_UPDATE
  194.             eventRegionOffset = {
  195.                 [1] = 1670342460,
  196.                 [2] = 1670698860,
  197.                 [3] = 1674763260,
  198.                 [4] = 1670698860,
  199.                 [5] = 1670677260,},
  200.             eventDuration = 600,
  201.             eventInterval = 3600,
  202.             enable = true,
  203.             sound = false,
  204.             voice_before = false,
  205.             voice_active = false,
  206.             anim = true,
  207.             questIDs = {71995}, --71033 Flood
  208.             findEventOnMap = {},
  209.             coor = {},
  210.             datablock = {
  211.                 [0] = {name = "Trial of the Elements", enable = false, coor = {2085, 27.91, 25.86},},
  212.                 [1] = {name = "Trial of the Elements", enable = false, coor = {2085, 27.91, 25.86},},
  213.                 [2] = {name = "Trial of the Elements", enable = true, coor = {2085, 27.91, 25.86},},
  214.                 [3] = {name = "Trial of the Elements", enable = true, coor = {2085, 27.91, 25.86},},
  215.                 [4] = {name = "Trial of the Elements", enable = true, coor = {2085, 27.91, 25.86},},
  216.             },
  217.         },
  218.         [9] = { name = "Elemental Storm",
  219.             texture = "ElementalStorm-Lesser-Earth",
  220.             eventRegionOffset = {
  221.                 [1] = 60,
  222.                 [2] = 60,
  223.                 [3] = 60,
  224.                 [4] = 60,  
  225.                 [5] = 60,},
  226.             eventDuration = 7200,
  227.             eventInterval = 10800,
  228.             enable = true,
  229.             sound = false,
  230.             voice_before = false,
  231.             voice_active = false,
  232.             anim = true,
  233.             questIDs = {70752, 70753, 70754, 70723, 72686}, -- Water 70752, Air 70753, Fire 70754, Earth 70723, Surge 72686
  234.             findEventOnMap = {2022, 2023, 2024, 2025},
  235.             coor = {},
  236.             datablock = {},
  237.         },
  238.         [10] = {    name = "Superbloom",
  239.             texture = "MajorFactions_MapIcons_Dream64",
  240.             eventRegionOffset = {
  241.                 [1] = 11,
  242.                 [2] = 11,
  243.                 [3] = 11,
  244.                 [4] = 11,  
  245.                 [5] = 11,},
  246.             eventDuration = 1040,
  247.             eventInterval = 3600,
  248.             enable = true,
  249.             sound = false,
  250.             voice_before = false,
  251.             voice_active = false,
  252.             anim = true,
  253.             questIDs = {78319},
  254.             findEventOnMap = {},
  255.             coor = {2200, 51.39, 59.71},
  256.             datablock = {},
  257.         },
  258.         [11] = {    name = "The Big Dig",
  259.             texture = "interface/archeology/arch-icon-marker.blp",
  260.             eventRegionOffset = {
  261.                 [1] = 1836,
  262.                 [2] = 1836,
  263.                 [3] = 1836,
  264.                 [4] = 1836,
  265.                 [5] = 1836,},
  266.             eventDuration = 552,
  267.             eventInterval = 3600,
  268.             enable = true,
  269.             sound = false,
  270.             voice_before = false,
  271.             voice_active = false,
  272.             anim = true,
  273.             questIDs = {79226},
  274.             findEventOnMap = {},
  275.             coor = {2024, 26.96, 46.46},
  276.             datablock = {},
  277.         },
  278.         [12] = {    name = "Hearthstone",
  279.             texture = "WarlockPortal-Yellow-32x32",
  280.             eventRegionOffset = {
  281.                 [1] = 48,
  282.                 [2] = 48,
  283.                 [3] = 48,
  284.                 [4] = 48,  
  285.                 [5] = 48,},
  286.             eventDuration = 300,
  287.             eventInterval = 3600,
  288.             enable = true,
  289.             sound = false,
  290.             voice_before = false,
  291.             voice_active = false,
  292.             anim = true,
  293.             questIDs = {},
  294.             findEventOnMap = {},
  295.             coor = {},
  296.             datablock = {
  297.                 [0] = {name = "Hearthstone in Valdraken", enable = true, coor = {2112, 62.38, 67.40},},
  298.                 [1] = {name = "Hearthstone in Stormwind", enable = true, coor = {84, 33.8, 19.6},}, --UnitFactionGroup("player") == 'Alliance' and {84, 33.8, 19.6} or {1, 52.8, 15.8},},
  299.                 [2] = {name = "Hearthstone in Durotar", enable = true, coor = {1, 52.8, 15.8},},
  300.             },
  301.         },
  302.     },
  303. }
  304.  
  305. ---------------------------------------------
  306. -- Setup functions
  307. SetupEventsTrackerMixin = {};
  308. function SetupEventsTrackerMixin:OnShow()
  309.     self.IconSizeSlider:SetEnabled(true);
  310.     self.IconSizeSlider:SetupSlider(L.cfg.iconSize);
  311.     self.IconSpaceSlider:SetEnabled(true);
  312.     self.IconSpaceSlider:SetupSlider(L.cfg.iconSpace);
  313.     self.IconsInRowSlider:SetEnabled(true);
  314.     self.IconsInRowSlider:SetupSlider(L.cfg.iconsInRow);
  315.     self.FontSizeSlider:SetEnabled(true);
  316.     self.FontSizeSlider:SetupSlider(L.cfg.fontSize);
  317.     self.SpeakVolumeSlider:SetEnabled(true);
  318.     self.SpeakVolumeSlider:SetupSlider(L.cfg.speakVolume);
  319.     self.TimeBeforeSlider:SetEnabled(true);
  320.     self.TimeBeforeSlider:SetupSlider(L.cfg.timeBefore);
  321.     self.ExtendedTooltipCheckButton:SetControlChecked(L.cfg.extendedTooltip);
  322.    
  323.     local function onExtendedTooltipChecked(isChecked, isUserInput)
  324.         L.cfg.extendedTooltip = isChecked
  325.     end
  326.     self.ExtendedTooltipCheckButton:SetCallback(onExtendedTooltipChecked);
  327.    
  328.     self.animIn:Play();
  329. end
  330.  
  331. IconSizeSliderMixin = {};
  332. function IconSizeSliderMixin:SetupSlider(value)
  333.     self.Slider:Init(value, 12, 40, 40 - 12, self.formatters);
  334. end
  335. function IconSizeSliderMixin:SetEnabled(enabled)
  336.     self.Slider:SetEnabled_(enabled);
  337. end
  338. function IconSizeSliderMixin:OnSliderValueChanged(value)
  339.     L.cfg.iconSize = value;
  340.     EventsTrackerMixin:ReloadAllEvents();
  341. end
  342.  
  343. IconSpaceSliderMixin = {};
  344. function IconSpaceSliderMixin:SetupSlider(value)
  345.     self.Slider:Init(value, 0, 16, 16, self.formatters);
  346. end
  347. function IconSpaceSliderMixin:SetEnabled(enabled)
  348.     self.Slider:SetEnabled_(enabled);
  349. end
  350. function IconSpaceSliderMixin:OnSliderValueChanged(value)
  351.     L.cfg.iconSpace = value;
  352.     EventsTrackerMixin:ReloadAllEvents();
  353. end
  354.  
  355. IconsInRowSliderMixin = {};
  356. function IconsInRowSliderMixin:SetupSlider(value)
  357.     self.Slider:Init(value, 1, 40, 40 - 1, self.formatters);
  358. end
  359. function IconsInRowSliderMixin:SetEnabled(enabled)
  360.     self.Slider:SetEnabled_(enabled);
  361. end
  362. function IconsInRowSliderMixin:OnSliderValueChanged(value)
  363.     L.cfg.iconsInRow = value;
  364.     EventsTrackerMixin:ReloadAllEvents();
  365. end
  366.  
  367. FontSizeSliderMixin = {};
  368. function FontSizeSliderMixin:SetupSlider(value)
  369.     self.Slider:Init(value, 7, 20, 20 - 7, self.formatters);
  370. end
  371. function FontSizeSliderMixin:SetEnabled(enabled)
  372.     self.Slider:SetEnabled_(enabled);
  373. end
  374. function FontSizeSliderMixin:OnSliderValueChanged(value)
  375.     L.cfg.fontSize = value;
  376.     EventsTrackerMixin:ReloadAllEvents();
  377. end
  378.  
  379. SpeakVolumeSliderMixin = {};
  380. function SpeakVolumeSliderMixin:SetupSlider(value)
  381.     self.Slider:Init(value, 1, 100, 99, self.formatters);
  382. end
  383. function SpeakVolumeSliderMixin:SetEnabled(enabled)
  384.     self.Slider:SetEnabled_(enabled);
  385. end
  386. function SpeakVolumeSliderMixin:OnSliderValueChanged(value)
  387.     L.cfg.speakVolume = value;
  388. end
  389.  
  390. TimeBeforeSliderMixin = {};
  391. function TimeBeforeSliderMixin:SetupSlider(value)
  392.     self.Slider:Init(value, 60, 600, 600-60, self.formatters);
  393. end
  394. function TimeBeforeSliderMixin:SetEnabled(enabled)
  395.     self.Slider:SetEnabled_(enabled);
  396. end
  397. function TimeBeforeSliderMixin:OnSliderValueChanged(value)
  398.     L.cfg.timeBefore = value;
  399. end
  400.  
  401. ---------------------------------------------
  402. -- Pomocne funkcie
  403. EventsTrackerMixin.FUNC_QUEUE_TABLE = {}
  404. function EventsTrackerMixin:CallFunctionOutOfCombat(funcName, ...)
  405.     if type(funcName) == 'function' then
  406.         if InCombatLockdown() then
  407.             table_insert(self.FUNC_QUEUE_TABLE,{funcName,{...}})
  408.         else
  409.             funcName(...)
  410.         end
  411.     end
  412. end
  413.  
  414. -- 2022 The Walking Shore, 2023 Ohn'Ahran plains, 2024 The Azure Span, 2025 Taldraszus, 2112 Valdrakken
  415. --/dump EventsTrackerMixin:FindEventOnMaps("all", {84})
  416. function EventsTrackerMixin:FindEventOnMaps(eventName, maps)
  417.     for _, mapID in next, maps do
  418.         local areaPoiIDs = C_AreaPoiInfo.GetAreaPOIForMap(mapID);
  419.         for _, ids in pairs(areaPoiIDs) do
  420.             --areaPoiID,position,name,description,textureIndex,widgetSetID,atlasName,uiTextureKit,shouldGlow,factionID,isPrimaryMapForPOI,isAlwaysOnFlightmap,addPaddingAboveWidgets,highlightWorldQuestsOnHover,highlightVignettesOnHover
  421.             local poiInfo = C_AreaPoiInfo.GetAreaPOIInfo(mapID, ids);
  422.             if eventName == "all" then
  423.                 print("--------------------------------------");
  424.                 print(C_Map.GetMapInfo(mapID).name .. "("..mapID..") - "..poiInfo.name)
  425.                 print(poiInfo.atlasName, poiInfo.isPrimaryMapForPOI)
  426.                                
  427.             elseif ((poiInfo.atlasName == "dreamsurge_hub-icon" and eventName == "Dreamsurge") or poiInfo.name == eventName) and poiInfo.isPrimaryMapForPOI then
  428.                 local elementType = poiInfo.atlasName and strmatch(poiInfo.atlasName, "ElementalStorm%-Lesser%-(.+)") or "";
  429.                 local x, y = poiInfo.position:GetXY();
  430.                
  431.                 return mapID, x*100, y*100, poiInfo.areaPoiID, poiInfo.atlasName, elementType
  432.             end
  433.         end
  434.     end
  435. end
  436.  
  437. local function SetTextureForEventFrame(frame, texture)
  438.     if tonumber(texture) then
  439.         frame.icon:SetTexture(texture);
  440.         frame.icon:SetTexCoord(.08, .92, 0.08, 0.92);
  441.     else
  442.         local info = C_Texture.GetAtlasInfo(texture);
  443.         if info then
  444.             frame.icon:SetAtlas(texture);
  445.         else
  446.             frame.icon:SetTexture(texture);
  447.         end
  448.     end
  449. end
  450.  
  451. local function isQuestCompleted(questIDTable)
  452.     local completed = 0;
  453.     if questIDTable and (type(questIDTable) == "table") then
  454.         for _, questID in pairs(questIDTable) do
  455.             if (C_QuestLog.IsOnQuest(questID)) then
  456.                 isCompleted = C_QuestLog.IsComplete(questID);
  457.             else
  458.                 isCompleted = C_QuestLog.IsQuestFlaggedCompleted(questID);
  459.             end
  460.            
  461.             if isCompleted then
  462.                 completed = completed + 1;
  463.             end
  464.         end
  465.     end
  466.     return (completed > 0)
  467. end
  468.  
  469. local function InstanceCheck()
  470.     if IsInInstance() then
  471.         if EventsTrackerHeader:IsShown() then
  472.             EventsTrackerMixin:ReloadAllEvents(true)
  473.             EventsTrackerHeader:Hide()
  474.         end
  475.     elseif not EventsTrackerHeader:IsShown() then
  476.         EventsTrackerMixin:ReloadAllEvents(false)
  477.         EventsTrackerHeader:Show()
  478.     end
  479. end
  480.  
  481. local function SetupReset()
  482.     for key, value in pairs(DefaultConfig.events) do
  483.         L.cfg.events[key].enable = value.enable;
  484.         L.cfg.events[key].sound = value.sound;
  485.         L.cfg.events[key].voice_before = value.voice_before;
  486.         L.cfg.events[key].voice_active = value.voice_active;
  487.         L.cfg.events[key].anim = value.anim;
  488.     end
  489.    
  490.     L.cfg.collapsed = DefaultConfig.collapsed;
  491.     L.cfg.iconSize = DefaultConfig.iconSize;
  492.     L.cfg.iconSpace = DefaultConfig.iconSpace;
  493.     L.cfg.iconsInRow = DefaultConfig.iconsInRow;
  494.     L.cfg.fontSize = DefaultConfig.fontSize;
  495.     L.cfg.speakVolume = DefaultConfig.speakVolume;
  496.     L.cfg.timeBefore = DefaultConfig.timeBefore;
  497.     L.cfg.savedposition = {"CENTER", nil, "CENTER", 0, 0};
  498.    
  499.     EventsTrackerHeader:ClearAllPoints();
  500.     EventsTrackerHeader:SetPoint(unpack(L.cfg.savedposition));
  501.     EventsTrackerMixin:ReloadAllEvents();
  502. end
  503.  
  504. function EventsTrackerMixin:GetLinkToEvent(index)
  505.     return L.cfg.events[index];
  506. end
  507.  
  508. function EventsTrackerMixin:GetLinkToFullEvent(index)
  509.     return DefaultConfig.events[index];
  510. end
  511.  
  512. function EventsTrackerMixin:GetTimeBefore()
  513.     return L.cfg.timeBefore;
  514. end
  515.  
  516. function EventsTrackerMixin:GetCollapsed()
  517.     return L.cfg.collapsed;
  518. end
  519.  
  520. function EventsTrackerMixin:SetCollapsed(value)
  521.     L.cfg.collapsed = value;
  522. end
  523.  
  524. function EventsTrackerMixin:SavePosition(point, relativeTo, relativePoint, xOfs, yOfs)
  525.     L.cfg.savedposition = {point, relativeTo, relativePoint, xOfs, yOfs};
  526. end
  527.  
  528. local function UpdateAllQuestCompleted()
  529.     for i, v in ipairs(L.cfg.events) do
  530.         if next(DefaultConfig.events[i].questIDs) then
  531.             local isComplete = isQuestCompleted(DefaultConfig.events[i].questIDs);
  532.             if v.enable and eventFrame[i] then
  533.                 eventFrame[i].icon:SetDesaturated(isComplete);
  534.             end
  535.             L.cfg.events[i].isComplete = isComplete;
  536.             _G["EventsTrackerDB"][selfName].events[i].isComplete = isComplete;
  537.         end
  538.     end
  539. end
  540.  
  541. function EventsTrackerMixin:GetToolTipComplete(index)
  542.     if not next(DefaultConfig.events[index].questIDs) then
  543.         return "", ""
  544.     end
  545.    
  546.     local completeOnCurrentChar;
  547.     local completeOnAccout = "";
  548.            
  549.     if _G["EventsTrackerDB"][selfName].events[index].isComplete then
  550.         completeOnCurrentChar = "|cFF00FF00Complete on this character|r"
  551.     else
  552.         completeOnCurrentChar = "|cFFFF0000Not complete on this character|r";
  553.     end
  554.    
  555.     if L.cfg.extendedTooltip then
  556.         for name in pairs(_G["EventsTrackerDB"]) do
  557.             if name ~= selfName and _G["EventsTrackerDB"][name].enable then
  558.                 if not _G["EventsTrackerDB"][name].events[index] or  _G["EventsTrackerDB"][name].events[index].isComplete == nil or not _G["EventsTrackerDB"][name].events[index].isComplete then
  559.                     local classColorStr = _G["EventsTrackerDB"][name].class and RAID_CLASS_COLORS[_G["EventsTrackerDB"][name].class].colorStr or "FFFFFFFF"
  560.                     completeOnAccout = completeOnAccout .. "|c"..classColorStr .. name .. "|r\n"
  561.                 end
  562.             end
  563.         end
  564.     end
  565.     return completeOnCurrentChar, completeOnAccout
  566. end
  567.  
  568. function EventsTrackerMixin:WeeklyUpdate(reset)
  569.     local weeklyResetTime = C_DateAndTime.GetSecondsUntilWeeklyReset()
  570.     if reset or (_G["EventsTrackerSetup"].savedResetTime and _G["EventsTrackerSetup"].savedResetTime < weeklyResetTime) then
  571.         print("|cFFFF0000Events tracker weekly reset.|r")
  572.         for name in pairs(_G["EventsTrackerDB"]) do
  573.             for i in pairs(_G["EventsTrackerDB"][name].events) do
  574.                 if i > #DefaultConfig.events then
  575.                     _G["EventsTrackerDB"][name].events[i] = nil
  576.                 elseif next(DefaultConfig.events[i].questIDs) then
  577.                     _G["EventsTrackerDB"][name].events[i].isComplete = false;
  578.                 end
  579.             end
  580.         end
  581.     end
  582.     _G["EventsTrackerSetup"].savedResetTime = weeklyResetTime;
  583. end
  584.  
  585. local function FindNextEventInDataBlock(self, index)
  586.     for i = 0, #DefaultConfig.events[self.index].datablock do
  587.         if not DefaultConfig.events[self.index].datablock[index].enable then
  588.             self.timeTmp = (self.timeTmp or 0) + DefaultConfig.events[self.index].eventInterval;
  589.         else
  590.             return index
  591.         end
  592.         index = index == #DefaultConfig.events[self.index].datablock and 0 or (index + 1);
  593.     end
  594.     return index
  595. end
  596.                
  597. local function CreateEventFrame(v, index)
  598.     local eFrame = CreateFrame("Button", nil, EventsTrackerHeader, "EventsTrackerButton");
  599.     local serverResetTime = GetServerTime() - (604800 - C_DateAndTime.GetSecondsUntilWeeklyReset());
  600.     local region = GetCurrentRegion();
  601.     -- ptr
  602.     if not region or region > 5 then
  603.         region = 1;
  604.     end
  605.    
  606.     eFrame.index = index;
  607.     eFrame.initComplete = false;
  608.     eFrame.notification = false;
  609.     eFrame.isEventActive = nil;
  610.     eFrame.timeTmp = nil;
  611.        
  612.     eFrame.enable = v.enable;
  613.     eFrame.sound = v.sound;
  614.     eFrame.voice_before = v.voice_before;
  615.     eFrame.voice_active = v.voice_active;
  616.     eFrame.anim = v.anim;
  617.    
  618.     eFrame.tooltipTitle = DefaultConfig.events[index].name;
  619.     eFrame.coor = DefaultConfig.events[index].coor;
  620.     eFrame.eventNewRegionOffset = DefaultConfig.events[index].eventRegionOffset[region] > 1600000000 and DefaultConfig.events[index].eventRegionOffset[region] or (serverResetTime + DefaultConfig.events[index].eventRegionOffset[region]);
  621.    
  622.     SetTextureForEventFrame(eFrame, DefaultConfig.events[index].texture);
  623.     eFrame.icon:SetDesaturated(v.isComplete);
  624.    
  625.     eFrame:SetScript("OnUpdate", function(self, elapsed)
  626.         self.elapsed = (self.elapsed or 1) + elapsed;
  627.         if self.elapsed < 1 then return end
  628.         self.elapsed = 0;
  629.         if not self:IsShown() then return end
  630.  
  631.         local timeFromFirstStart = GetServerTime() - self.eventNewRegionOffset;
  632.         local timeToNextEvent = (DefaultConfig.events[self.index].eventInterval - timeFromFirstStart % DefaultConfig.events[self.index].eventInterval) + (self.timeTmp and self.timeTmp or 0);
  633.         local timeActiveEvent = self.timeTmp and timeToNextEvent or DefaultConfig.events[self.index].eventDuration - (DefaultConfig.events[self.index].eventInterval - timeToNextEvent);
  634.         local isEventActive = (DefaultConfig.events[self.index].eventInterval + (self.timeTmp and self.timeTmp or 0)) - timeToNextEvent <= DefaultConfig.events[self.index].eventDuration;
  635.         local showedTime = isEventActive and timeActiveEvent or timeToNextEvent;
  636.            
  637.         if not self.initComplete or (self.isEventActive and not isEventActive) then
  638.             if (self.isEventActive and not isEventActive) then self.isEventActive = false end
  639.             self.timer:SetTextColor(.9, .9, .9);
  640.             self.timeTmp = nil;
  641.                        
  642.             -- hladam dalsi event v databloku ak je neaky disabled preskocim ho a pripocitam cas
  643.             if next(DefaultConfig.events[self.index].datablock) then --not isEventActive and
  644.                 local index = math.floor(((timeFromFirstStart + (not self.isEventActive and DefaultConfig.events[self.index].eventInterval or 0)) / DefaultConfig.events[self.index].eventInterval) % (#DefaultConfig.events[self.index].datablock + 1));
  645.                                
  646.                 -- ak su nasledujuce eventy v databloku vypnute najdem prvy aktivny a upravim cas
  647.                 index = FindNextEventInDataBlock(self, index)
  648.                
  649.                 local tmp = self.timeTmp
  650.                 local nextIndex = index + 1
  651.                 nextIndex = nextIndex > #DefaultConfig.events[self.index].datablock and 0 or nextIndex;
  652.                 nextIndex = FindNextEventInDataBlock(self, nextIndex)
  653.                 self.timeTmp = tmp
  654.                                
  655.                 if DefaultConfig.events[self.index].datablock[index].name ~= DefaultConfig.events[self.index].datablock[nextIndex].name then
  656.                     self.tooltipTitle = DefaultConfig.events[self.index].datablock[index].name .. "\n|cFF808080" .. DefaultConfig.events[self.index].datablock[nextIndex].name .."|r";
  657.                 else
  658.                     self.tooltipTitle = DefaultConfig.events[self.index].datablock[index].name
  659.                 end
  660.                
  661.                 self.coor = DefaultConfig.events[self.index].datablock[index].coor;
  662.                
  663.             elseif next(DefaultConfig.events[self.index].findEventOnMap) then
  664.                 -- po ukonceni eventu (elemental storm) zmen na zakladnu iconu a popis
  665.                 self.tooltipTitle = DefaultConfig.events[self.index].name;
  666.                 SetTextureForEventFrame(self, DefaultConfig.events[self.index].texture);
  667.                 self.icon:SetDesaturated(true);
  668.                 wipe(self.coor);
  669.                
  670.             end
  671.         end
  672.        
  673.         if showedTime < 3600 then
  674.             self.timer:SetText(date("%M:%S", showedTime));
  675.         else
  676.             self.timer:SetText(date("%H", showedTime)-1 .. date("h%M", showedTime));
  677.         end
  678.        
  679.         if not self.isEventActive and isEventActive then
  680.             if self.timeTmp and self.timeTmp > 0 then
  681.                 self.timeTmp = self.timeTmp - DefaultConfig.events[self.index].eventInterval;
  682.                            
  683.             elseif DefaultConfig.events[self.index].eventDuration > 0 then
  684.                 if next(DefaultConfig.events[self.index].findEventOnMap) then
  685.                     local mapID, x, y, areaPoiID, atlasName, elementType = EventsTrackerMixin:FindEventOnMaps(DefaultConfig.events[self.index].name, DefaultConfig.events[self.index].findEventOnMap);
  686.                     if mapID then
  687.                         local mapName = C_Map.GetMapInfo(mapID).name;
  688.                         self.tooltipTitle = DefaultConfig.events[self.index].name .. " in " ..mapName;
  689.                         self.coor = {mapID, x, y};
  690.                         if atlasName then
  691.                             self.icon:SetAtlas(atlasName);
  692.                         end
  693.                         self.icon:SetDesaturated(false);
  694.                     else
  695.                         self.tooltipTitle = DefaultConfig.events[self.index].name;
  696.                         SetTextureForEventFrame(self, DefaultConfig.events[self.index].texture);
  697.                         self.icon:SetDesaturated(true);
  698.                         wipe(self.coor);
  699.                         return;
  700.                     end
  701.                 end
  702.                
  703.                 self.timer:SetTextColor(0, 1, 0);
  704.                 if self.anim and not self.icon.Anim:IsPlaying() then
  705.                     self.icon.Anim:Play();
  706.                 end
  707.                 if self.voice_active and self.initComplete then
  708.                     C_VoiceChat.SpeakText(0, DefaultConfig.events[self.index].name.." is active.", 1, 0, L.cfg.speakVolume);
  709.                 end
  710.             end
  711.             self.isEventActive = true;
  712.            
  713.         elseif not isEventActive then
  714.             if showedTime < L.cfg.timeBefore and not self.timeTmp then
  715.                 if not self.notification then
  716.                     if self.sound and self.initComplete then
  717.                         PlaySound(32585, "Master");
  718.                     end
  719.                     if self.voice_before and self.initComplete then
  720.                         C_VoiceChat.SpeakText(0, DefaultConfig.events[self.index].name.." event will start in a moment.", 1, 0, L.cfg.speakVolume);
  721.                     end
  722.                     if self.anim and not self.icon.Anim:IsPlaying() then
  723.                         self.icon.Anim:Play();
  724.                     end
  725.                     self.timer:SetTextColor(1, 1, 0);
  726.                     self.notification = true;
  727.                 end
  728.             elseif self.notification then
  729.                 self.notification = false;
  730.             end
  731.         end
  732.    
  733.         self.initComplete = true    ;
  734.     end)
  735.  
  736.     return eFrame;
  737. end
  738.  
  739. function EventsTrackerMixin:ReloadAllEvents(hideAll)
  740.     local firstEventFrame, lastEventFrame;
  741.     local iconsInRow = 0;
  742.    
  743.     for i, v in ipairs(L.cfg.events) do
  744.         if not hideAll and v.enable and not L.cfg.collapsed then
  745.             if not eventFrame[i] then
  746.                 eventFrame[i] = CreateEventFrame(v, i);
  747.             end
  748.             eventFrame[i]:SetSize(L.cfg.iconSize, L.cfg.iconSize)
  749.             eventFrame[i].icon:SetSize(L.cfg.iconSize + 6, L.cfg.iconSize + 6)
  750.             eventFrame[i]:ClearAllPoints();
  751.             eventFrame[i].timer:SetFont("Fonts\\FRIZQT__.TTF", L.cfg.fontSize, "OUTLINE")
  752.            
  753.             iconsInRow = (iconsInRow or 0) + 1;
  754.             if not lastEventFrame then
  755.                 eventFrame[i]:SetPoint("TOPLEFT", EventsTrackerHeader, "TOPRIGHT", 4, -5);
  756.                 firstEventFrame = eventFrame[i];
  757.             elseif iconsInRow > L.cfg.iconsInRow then
  758.                 eventFrame[i]:SetPoint("TOP", firstEventFrame, "BOTTOM", 0, -12);
  759.                 firstEventFrame = eventFrame[i];
  760.                 iconsInRow = 1;
  761.             else
  762.                 eventFrame[i]:SetPoint("LEFT", lastEventFrame, "RIGHT", L.cfg.iconSpace, 0);
  763.             end
  764.            
  765.             eventFrame[i].enable = true;
  766.             eventFrame[i]:Show();
  767.             lastEventFrame = eventFrame[i];
  768.            
  769.         elseif eventFrame[i] then
  770.             eventFrame[i]:Hide();
  771.             eventFrame[i]:SetScript("OnUpdate", nil);
  772.             eventFrame[i] = nil;
  773.         end
  774.     end
  775.    
  776.     EventsTrackerHeader.CollapsedButton:SetButtonState(L.cfg.collapsed and "PUSHED" or "NORMAL", L.cfg.collapsed and true or false);
  777. end
  778.  
  779. function EventsTrackerMixin:OnEvent(event, ...)
  780.     local arg1 = ...
  781.     if ( event == "ADDON_LOADED" ) then
  782.         if arg1 == _ then
  783.             selfName = UnitName("player") .. " - " .. GetRealmName();
  784.            
  785.             if _G["EventsTrackerDB"] == nil then _G["EventsTrackerDB"] = {}; end
  786.             if _G["EventsTrackerDB"][selfName] == nil then
  787.                 _G["EventsTrackerDB"][selfName] = {};
  788.                 _G["EventsTrackerDB"][selfName].class = select(2, UnitClass("player"));
  789.                 _G["EventsTrackerDB"][selfName].enable = true;
  790.                 _G["EventsTrackerDB"][selfName].events = {};
  791.             end
  792.            
  793.             -- prekopiruj nove eventy
  794.             for i, v in pairs(DefaultConfig.events) do
  795.                 if _G["EventsTrackerDB"][selfName].events[i] == nil then
  796.                     _G["EventsTrackerDB"][selfName].events[i] = {};
  797.                     _G["EventsTrackerDB"][selfName].events[i].enable = v.enable;
  798.                     _G["EventsTrackerDB"][selfName].events[i].sound = v.sound;
  799.                     _G["EventsTrackerDB"][selfName].events[i].voice_before = v.voice_before;
  800.                     _G["EventsTrackerDB"][selfName].events[i].voice_active = v.voice_active;
  801.                     _G["EventsTrackerDB"][selfName].events[i].anim = v.anim;
  802.                 end
  803.             end
  804.             -- zmaz zvysne eventy pod char save
  805.             if #DefaultConfig.events <  #_G["EventsTrackerDB"][selfName].events then
  806.                 for i = #DefaultConfig.events+1, #_G["EventsTrackerDB"][selfName].events do
  807.                     _G["EventsTrackerDB"][selfName].events[i] = nil
  808.                 end
  809.             end
  810.             -- pridaj nove hodnoty
  811.             for key, value in pairs(DefaultConfig) do
  812.                 if _G["EventsTrackerDB"][selfName][key] == nil and type(value) ~= "table" then
  813.                     _G["EventsTrackerDB"][selfName][key] = value;
  814.                 end
  815.             end
  816.            
  817.             L.cfg = _G["EventsTrackerDB"][selfName];
  818.            
  819.             -- ak nebol nastaveny savedposition pre ETH nastav ho z predchadzajucej pozicie uzivatela
  820.             if not L.cfg.savedposition or (type(L.cfg.savedposition) ~= "table") then
  821.                 local point, relativeTo, relativePoint, xOfs, yOfs = EventsTrackerHeader:GetPoint(1)
  822.                 if point then
  823.                     L.cfg.savedposition = {point, relativeTo, relativePoint, xOfs, yOfs};
  824.                 else
  825.                     L.cfg.savedposition = {"CENTER", nil, "CENTER", 0, 0}
  826.                 end
  827.             end
  828.            
  829.             if _G["EventsTrackerSetup"] == nil then _G["EventsTrackerSetup"] = {}; end
  830.                        
  831.             EventsTrackerHeader.SetupButton:SetScript("OnClick", function(self, button)
  832.                 if button == "LeftButton" then
  833.                     if SetupEventsTrackerFrame:IsShown() then
  834.                         SetupEventsTrackerFrame:Hide()
  835.                         EventsTrackerHeader.SetupButton:SetButtonState("NORMAL", false);
  836.                     else
  837.                         SetupEventsTrackerFrame:Show()
  838.                         EventsTrackerHeader.SetupButton:SetButtonState("PUSHED", true);
  839.                     end
  840.                                
  841.                 elseif button == "RightButton"then
  842.                     local menuFrame = CreateFrame("Frame", "EventsMenuFrame", UIParent, "UIDropDownMenuTemplate");
  843.                     local menu = {};
  844.                     local eventListMenu = {};
  845.                     local copySetupMenu = {};
  846.                     local charactersEnableMenu = {};
  847.                     local selfName = UnitName("player") .. " - " .. GetRealmName();
  848.                    
  849.                     -- vytvor Events list menu
  850.                     for i, v in ipairs(L.cfg.events) do
  851.                         tinsert(eventListMenu,
  852.                             { text = DefaultConfig.events[i].name,
  853.                                 checked = function() return v.enable; end,
  854.                                 keepShownOnClick = 1,
  855.                                 tooltipOnButton = 1,
  856.                                 tooltipTitle = v.name,
  857.                                 tooltipText = "Enable or diasable this event.",
  858.                                 func = function() v.enable = not v.enable; EventsTrackerMixin:ReloadAllEvents(); end
  859.                             }
  860.                         )
  861.                     end
  862.                    
  863.                     -- vytvor Reset menu
  864.                     tinsert(copySetupMenu,
  865.                         { text = "Reset to default",
  866.                             notCheckable = 1,
  867.                             tooltipOnButton = 1,
  868.                             tooltipTitle = "Reset",
  869.                             tooltipText = "Reset setup for active character to default.",
  870.                             colorCode = "|cFFFF0000",
  871.                             func = function()
  872.                                 SetupReset()
  873.                                 CloseDropDownMenus();
  874.                                 if SetupEventsTrackerFrame:IsShown() then
  875.                                     SetupEventsTrackerFrame:Hide()
  876.                                 end
  877.                             end
  878.                         })
  879.                    
  880.                     -- vytvor Copy to all
  881.                     tinsert(copySetupMenu,
  882.                         { text = "Copy to all",
  883.                             notCheckable = 1,
  884.                             tooltipOnButton = 1,
  885.                             tooltipTitle = "Copy",
  886.                             tooltipText = "Copy this active setup to all your characters.",
  887.                             colorCode = "|cFFFF0000",
  888.                             func = function()
  889.                                 for name in pairs(_G["EventsTrackerDB"]) do
  890.                                     if name ~= selfName then
  891.                                         for key, value in pairs(L.cfg) do
  892.                                             if ( key == "events" ) then
  893.                                                 for i, event in pairs(value) do
  894.                                                     for x, y in pairs(event) do
  895.                                                         if x ~= "isComplete" then
  896.                                                             if _G["EventsTrackerDB"][name].events[i] == nil then
  897.                                                                 _G["EventsTrackerDB"][name].events[i] = {}
  898.                                                             end
  899.                                                             _G["EventsTrackerDB"][name].events[i][x] = y;
  900.                                                         end
  901.                                                     end
  902.                                                 end
  903.                                                
  904.                                             elseif key ~= "class" then
  905.                                                 _G["EventsTrackerDB"][name][key] = value;
  906.                                             end
  907.                                         end
  908.                                     end
  909.                                 end
  910.                                 CloseDropDownMenus();
  911.                             end
  912.                         })
  913.                    
  914.                     -- pridaj separator
  915.                     tinsert(copySetupMenu,
  916.                         {   text = "", hasArrow = false;    dist = 0; isTitle = true; isUninteractable = true; notCheckable = true; iconOnly = true;
  917.                             icon = "Interface\\Common\\UI-TooltipDivider-Transparent"; tCoordLeft = 0; tCoordRight = 1; tCoordTop = 0; tCoordBottom = 1; tSizeX = 0; tSizeY = 8;    tFitDropDownSizeX = true;
  918.                             iconInfo = {    tCoordLeft = 0, tCoordRight = 1,    tCoordTop = 0, tCoordBottom = 1, tSizeX = 0, tSizeY = 8, tFitDropDownSizeX = true},
  919.                         })
  920.                                            
  921.                     -- vytvor copy form selected char
  922.                     for name in pairs(_G["EventsTrackerDB"]) do
  923.                         local classColorStr = _G["EventsTrackerDB"][name].class and RAID_CLASS_COLORS[_G["EventsTrackerDB"][name].class].colorStr or "FFFFFFFF"
  924.                         if name ~= selfName then
  925.                             tinsert(copySetupMenu,
  926.                                 { text = name,
  927.                                     notCheckable = 1,
  928.                                     tooltipOnButton = 1,
  929.                                     tooltipTitle = name,
  930.                                     tooltipText = "Copy setup from this character",
  931.                                     colorCode = "|c" .. classColorStr,
  932.                                     func = function()
  933.                                         for key, value in pairs(_G["EventsTrackerDB"][name]) do
  934.                                             if ( key == "events" ) then
  935.                                                 for i, event in pairs(value) do
  936.                                                     for x, y in pairs(event) do
  937.                                                         if x ~= "isComplete" then
  938.                                                             _G["EventsTrackerDB"][selfName].events[i][x] = y;
  939.                                                             L.cfg.events[i][x] = y;
  940.                                                         end
  941.                                                     end
  942.                                                 end
  943.                                                
  944.                                             elseif key ~= "class" then
  945.                                                 _G["EventsTrackerDB"][selfName][key] = value;
  946.                                                 L.cfg[key] = value;
  947.                                             end
  948.                                         end
  949.                                                                                
  950.                                         if SetupEventsTrackerFrame:IsShown() then
  951.                                             SetupEventsTrackerFrame:Hide()
  952.                                         end
  953.                                         EventsTrackerMixin:ReloadAllEvents();
  954.                                         CloseDropDownMenus();
  955.                                     end
  956.                                 }
  957.                             )
  958.                         end
  959.                     end
  960.                    
  961.                     -- vytvor character enable
  962.                     for name in pairs(_G["EventsTrackerDB"]) do
  963.                         local classColorStr = _G["EventsTrackerDB"][name].class and RAID_CLASS_COLORS[_G["EventsTrackerDB"][name].class].colorStr or "FFFFFFFF"
  964.                         tinsert(charactersEnableMenu,
  965.                             { text = name,
  966.                                 checked = function() return _G["EventsTrackerDB"][name].enable; end,
  967.                                 keepShownOnClick = 1,
  968.                                 tooltipOnButton = 1,
  969.                                 tooltipTitle = name,
  970.                                 tooltipText = "Enable this character for toolTip information.",
  971.                                 colorCode = "|c" .. classColorStr,
  972.                                 func = function() _G["EventsTrackerDB"][name].enable = not _G["EventsTrackerDB"][name].enable; end
  973.                             }
  974.                         )
  975.                     end
  976.                    
  977.                     tinsert(menu, { text = "Enable events", hasArrow = true, notCheckable = 1, menuList = eventListMenu});
  978.                     tinsert(menu, { text = "Characters in toolTip", hasArrow = true, notCheckable = 1, menuList = charactersEnableMenu});
  979.                     if copySetupMenu and #copySetupMenu > 0 then
  980.                         tinsert(menu, { text = "Copy setup", hasArrow = true, notCheckable = 1, menuList = copySetupMenu});
  981.                     end
  982.                     EasyMenu(menu, menuFrame, "cursor", 0 , 0, "MENU");
  983.                 end        
  984.             end)
  985.                        
  986.             function EventsTrackerAlertFrame_SetUp(self, str, sound)
  987.                 if str ~= nil then
  988.                     self.Text:SetText(str);
  989.                 end
  990.                 --https://github.com/Gethe/wow-ui-source/blob/live/Interface/SharedXML/SoundKitConstants.lua
  991.                 if sound then
  992.                     PlaySound(sound);
  993.                 end
  994.             end
  995.  
  996.             EventsTrackerAlertSystem = AlertFrame:AddQueuedAlertFrameSubSystem("EventsTrackerWarningTemplate", EventsTrackerAlertFrame_SetUp, 6, math.huge);
  997.  
  998.             SLASH_ETRACKER1 = "/etracker"
  999.             SlashCmdList["ETRACKER"] = function(msg)
  1000.                 if ( msg == "reset" ) then
  1001.                     SetupReset()
  1002.                 end
  1003.             end
  1004.            
  1005.             if IsAddOnLoaded(_) then
  1006.                 self:UnregisterEvent('ADDON_LOADED');
  1007.             end
  1008.         end
  1009.            
  1010.     elseif ( event == "SCENARIO_UPDATE" ) then
  1011.         if arg1 == false then
  1012.             local bestMap = C_Map.GetBestMapForUnit("player");
  1013.             if bestMap == 2085 then
  1014.                 EventsTrackerAlertSystem:AddAlert("You dont have active scenario, fly out and back to cave.", SOUNDKIT.UI_RAID_BOSS_WHISPER_WARNING);
  1015.             end
  1016.         elseif arg1 == nil then
  1017.             UpdateAllQuestCompleted()
  1018.         end
  1019.    
  1020.     elseif ( event == "ZONE_CHANGED_NEW_AREA" ) then
  1021.         EventsTrackerMixin:CallFunctionOutOfCombat(InstanceCheck())
  1022.        
  1023.     elseif ( event == "PLAYER_ENTERING_WORLD" or ( event == "UNIT_QUEST_LOG_CHANGED" and arg1 == "player")) or event == "QUEST_TURNED_IN" or event == "ENCOUNTER_LOOT_RECEIVED" then
  1024.         if event == "PLAYER_ENTERING_WORLD" then
  1025.             self:CallFunctionOutOfCombat(InstanceCheck())
  1026.             self:ReloadAllEvents();
  1027.             EventsTrackerHeader:ClearAllPoints();
  1028.             EventsTrackerHeader:SetPoint(unpack(L.cfg.savedposition));
  1029.         end
  1030.         UpdateAllQuestCompleted()
  1031.            
  1032.     elseif ( event == "PLAYER_REGEN_ENABLED" ) then
  1033.         for _, function_tbl in ipairs(self.FUNC_QUEUE_TABLE) do
  1034.             if type(function_tbl[1]) == 'function' then
  1035.                 function_tbl[1](unpack(function_tbl[2]))
  1036.             end
  1037.         end
  1038.         wipe(self.FUNC_QUEUE_TABLE)
  1039.        
  1040.     elseif ( event == "COVENANT_CHOSEN" or event == "COVENANT_CALLINGS_UPDATED" ) then
  1041.         self:WeeklyUpdate()
  1042.        
  1043.     end
  1044. end
  1045.  
  1046. function EventsTrackerMixin:OnLoad()
  1047.     for _, event in pairs({
  1048.         "ADDON_LOADED",
  1049.         "PLAYER_ENTERING_WORLD",
  1050.         "ZONE_CHANGED_NEW_AREA",
  1051.         "UNIT_QUEST_LOG_CHANGED",   -- QUEST_WATCH_UPDATE. QUEST_LOG_UPDATE, UI_INFO_MESSAGE 303,"Objective complete"
  1052.         "QUEST_TURNED_IN",
  1053.         "SCENARIO_UPDATE",
  1054.         "PLAYER_REGEN_ENABLED",     -- pre spustenie funkcii outOfCombat
  1055.         "COVENANT_CHOSEN",          -- COVENANT_CALLINGS_UPDATED, GUILDBANK_UPDATE_WITHDRAWMONEY, TREASURE_PICKER_CACHE_FLUSH pre weekly update ak je player online pocas weekly resetu
  1056.         "COVENANT_CALLINGS_UPDATED",
  1057.         "ENCOUNTER_LOOT_RECEIVED"-- pre Trial of the element
  1058.     }) do self:RegisterEvent(event) end
  1059. end

Last edited by Hubb777 : 03-12-24 at 11:23 PM.
  Reply With Quote