better hooks into Atlas functions

This commit is contained in:
Spit
2025-11-28 18:30:42 +03:00
parent 9a2d7b0a47
commit 521b0ec1dc
2 changed files with 66 additions and 230 deletions
+66 -192
View File
@@ -55,9 +55,9 @@ local Anchor_AlphaMap = { "TOPLEFT", "AlphaMapAlphaMapFrame", "TOPLEFT", 0, 0 }
local Anchor_Default = { "TOPLEFT", "AtlasLootDefaultFrame", "TOPLEFT", 45, -85 }
-- Variables to hold hooked Atlas functions
Hooked_Atlas_Refresh = nil;
Hooked_Atlas_OnShow = nil;
Hooked_AtlasScrollBar_Update = nil;
local Original_Atlas_Refresh;
local Original_Atlas_OnShow;
local Original_AtlasScrollBar_Update;
AtlasLootCharDB = {};
@@ -933,12 +933,12 @@ function AtlasLoot_OnVariablesLoaded()
AtlasButton_LoadAtlas();
end
-- Hook the necessary Atlas functions
Hooked_Atlas_Refresh = Atlas_Refresh;
Original_Atlas_Refresh = Atlas_Refresh;
Atlas_Refresh = AtlasLoot_Refresh;
Hooked_Atlas_OnShow = Atlas_OnShow;
Original_Atlas_OnShow = Atlas_OnShow;
Atlas_OnShow = AtlasLoot_Atlas_OnShow;
-- Instead of hooking, replace the scrollbar driver function
Hooked_AtlasScrollBar_Update = AtlasScrollBar_Update;
Original_AtlasScrollBar_Update = AtlasScrollBar_Update;
AtlasScrollBar_Update = AtlasLoot_AtlasScrollBar_Update;
-- Disable options that don't have the supporting mods
if ( not LootLink_SetTooltip and (AtlasLootCharDB.LootlinkTT == true ) ) then
@@ -959,7 +959,7 @@ function AtlasLoot_OnVariablesLoaded()
AtlasLootItemsFrame_Back:SetTexture(0, 0, 0, 0.65);
end
-- If Atlas is installed, set up for Atlas
if ( Hooked_Atlas_Refresh ) then
if ( Original_Atlas_Refresh ) then
AtlasLoot_SetupForAtlas();
-- If a first time user, set up options
if ( AtlasLootCharDB.FirstTime == nil or AtlasLootCharDB.FirstTime == true ) then
@@ -973,7 +973,7 @@ function AtlasLoot_OnVariablesLoaded()
StaticPopup_Show ("ATLASLOOT_SETUP");
AtlasLootCharDB.FirstTime = false;
end
Hooked_Atlas_Refresh();
Original_Atlas_Refresh();
else
-- If we are not using Atlas, keep the items frame out of the way
AtlasLootItemsFrame:Hide();
@@ -1189,47 +1189,33 @@ Hooks the Atlas scroll frame.
Required as the Atlas function cannot deal with the AtlasLoot button template or the added Atlasloot entries
]]
function AtlasLoot_AtlasScrollBar_Update()
local lineplusoffset;
if ( not AtlasBossLine1_Text ) then
return
end
Original_AtlasScrollBar_Update()
local zoneID = ATLAS_DROPDOWNS[AtlasOptions.AtlasType][AtlasOptions.AtlasZone];
-- Update the contents of the Atlas scroll frame
FauxScrollFrame_Update(AtlasScrollBar, ATLAS_CUR_LINES, ATLAS_LOOT_BOSS_LINES, 15);
-- Make note of how far in the scroll frame we are
for line = 1, ATLAS_NUM_LINES do
lineplusoffset = line + FauxScrollFrame_GetOffset(AtlasScrollBar);
local bossLine = _G["AtlasBossLine" .. line]
if ( lineplusoffset <= ATLAS_CUR_LINES ) then
local loot = _G["AtlasBossLine" .. line .. "_Loot"]
local selected = _G["AtlasBossLine" .. line .. "_Selected"]
_G["AtlasBossLine" .. line .. "_Text"]:SetText(ATLAS_SCROLL_LIST[lineplusoffset]);
local lineplusoffset = line + FauxScrollFrame_GetOffset(AtlasScrollBar);
local entry = _G["AtlasEntry" .. line]
local loot = _G["AtlasEntry" .. line .. "_Loot"]
local selected = _G["AtlasEntry" .. line .. "_Selected"]
if ( loot and lineplusoffset <= ATLAS_CUR_LINES ) then
_G["AtlasEntry" .. line .. "_Text"]:SetText(ATLAS_SCROLL_LIST[lineplusoffset]);
local showIcon = (AtlasLootBossButtons[zoneID] and AtlasLootBossButtons[zoneID][lineplusoffset] and AtlasLootBossButtons[zoneID][lineplusoffset] ~= "") or
(AtlasLootWBBossButtons[zoneID] and AtlasLootWBBossButtons[zoneID][lineplusoffset] and AtlasLootWBBossButtons[zoneID][lineplusoffset] ~= "") or
(AtlasLootBattlegrounds[zoneID] and AtlasLootBattlegrounds[zoneID][lineplusoffset] and AtlasLootBattlegrounds[zoneID][lineplusoffset] ~= "")
if ( AtlasLootItemsFrame.activeBoss == lineplusoffset ) then
bossLine:Enable();
entry:Enable();
loot:Hide();
selected:Show();
elseif ( (AtlasLootBossButtons[zoneID] and AtlasLootBossButtons[zoneID][lineplusoffset] and AtlasLootBossButtons[zoneID][lineplusoffset] ~= "") ) then
bossLine:Enable();
loot:Show();
selected:Hide();
elseif ( (AtlasLootWBBossButtons[zoneID] and AtlasLootWBBossButtons[zoneID][lineplusoffset] and AtlasLootWBBossButtons[zoneID][lineplusoffset] ~= "") ) then
bossLine:Enable();
loot:Show();
selected:Hide();
elseif ( (AtlasLootBattlegrounds[zoneID] and AtlasLootBattlegrounds[zoneID][lineplusoffset] and AtlasLootBattlegrounds[zoneID][lineplusoffset] ~= "") ) then
bossLine:Enable();
elseif ( showIcon ) then
entry:Enable();
loot:Show();
selected:Hide();
else
bossLine:Disable();
entry:Disable();
loot:Hide();
selected:Hide();
end
bossLine.idnum = lineplusoffset;
bossLine:Show();
elseif ( bossLine ) then
-- Hide lines that are not needed
bossLine:Hide();
entry.idnum = lineplusoffset;
end
end
end
@@ -1239,148 +1225,41 @@ AtlasLoot_Refresh:
Replacement for Atlas_Refresh, required as the template for the boss buttons in Atlas is insufficient
Called whenever the state of Atlas changes
]]
function AtlasLoot_Refresh()
function AtlasLoot_Refresh(keepSelection)
-- Reset which loot page is 'current'
AtlasLootItemsFrame.activeBoss = nil;
-- Get map selection info from Atlas
local zoneID = ATLAS_DROPDOWNS[AtlasOptions.AtlasType][AtlasOptions.AtlasZone];
local data = AtlasMaps;
local base = {};
-- Get boss name information
for k,v in pairs(data[zoneID]) do
base[k] = v;
if ( not keepSelection ) then
AtlasLootItemsFrame.activeBoss = nil
end
-- Display the newly selected texture
AtlasMap:ClearAllPoints();
AtlasMap:SetWidth(512);
AtlasMap:SetHeight(512);
AtlasMap:SetPoint("TOPLEFT", "AtlasFrame", "TOPLEFT", 18, -84);
local builtIn = AtlasMap:SetTexture("Interface\\AddOns\\Atlas\\Images\\Maps\\"..zoneID);
-- If texture was not found in the core Atlas mod, check plugins
if ( not builtIn ) then
for k,v in pairs(ATLAS_PLUGINS) do
if ( AtlasMap:SetTexture("Interface\\AddOns\\"..v.."\\Images\\"..zoneID) ) then
break;
end
end
end
-- Setup info panel above boss listing
local tName = base.ZoneName[1];
if ( AtlasOptions.AtlasAcronyms and base.Acronym ) then
local _RED = "|cffcc6666";
tName = tName.._RED.." ["..base.Acronym.."]";
end
AtlasText_ZoneName_Text:SetText(tName);
local tLoc = "";
local tLR = "";
local tML = "";
local tPL = "";
if ( base.Location[1] ) then
tLoc = ATLAS_STRING_LOCATION..": "..base.Location[1];
end
if ( base.LevelRange ) then
tLR = ATLAS_STRING_LEVELRANGE..": "..base.LevelRange;
end
if ( base.MinLevel ) then
tML = ATLAS_STRING_MINLEVEL..": "..base.MinLevel;
end
if ( base.PlayerLimit ) then
tPL = ATLAS_STRING_PLAYERLIMIT..": "..base.PlayerLimit;
end
AtlasText_Location_Text:SetText(tLoc);
AtlasText_LevelRange_Text:SetText(tLR);
AtlasText_MinLevel_Text:SetText(tML);
AtlasText_PlayerLimit_Text:SetText(tPL);
Atlastextbase = base;
-- Get the size of the Atlas text to append stuff to the bottom. Looks for empty lines
local i = 1;
local j = 2;
while ( (Atlastextbase[i] and Atlastextbase[i] ~= "") or (Atlastextbase[j] and Atlastextbase[j] ~= "")) do
i = i + 1;
j = i + 1;
end
-- Hide any Atlas objects lurking around that have now been replaced
for i = 1,ATLAS_CUR_LINES do
if ( _G["AtlasEntry"..i] ) then
_G["AtlasEntry"..i]:Hide();
end
end
ATLAS_DATA = Atlastextbase;
ATLAS_SEARCH_METHOD = data.Search;
-- Deal with Atlas's search function
if ( data.Search == nil ) then
ATLAS_SEARCH_METHOD = AtlasSimpleSearch;
end
if ( data.Search ~= false ) then
AtlasSearchEditBox:Show();
AtlasNoSearch:Hide();
if ( AtlasLootItemsFrame.activeBoss ) then
AtlasLootItemsFrame:Show()
else
AtlasSearchEditBox:Hide();
AtlasNoSearch:Show();
ATLAS_SEARCH_METHOD = nil;
AtlasLootItemsFrame:Hide()
end
-- populate the scroll frame entries list, the update func will do the rest
Atlas_Search("");
AtlasSearchEditBox:SetText("");
AtlasSearchEditBox:ClearFocus();
-- create and align any new entry buttons that we need
for i = 1,ATLAS_CUR_LINES do
local f;
if ( not _G["AtlasBossLine"..i] ) then
f = CreateFrame("Button", "AtlasBossLine"..i, AtlasFrame, "AtlasLootNewBossLineTemplate");
f:SetFrameStrata("HIGH");
if ( i == 1 ) then
f:SetPoint("TOPLEFT", "AtlasScrollBar", "TOPLEFT", 16, -3);
else
f:SetPoint("TOPLEFT", "AtlasBossLine"..(i-1), "BOTTOMLEFT");
end
else
_G["AtlasBossLine"..i.."_Loot"]:Hide();
_G["AtlasBossLine"..i.."_Selected"]:Hide();
-- Call original function
Original_Atlas_Refresh()
for i = 1, ATLAS_NUM_LINES do
local entry = _G["AtlasEntry" .. i]
if ( entry and not _G["AtlasEntry"..i.."_Loot"] ) then
-- Add deselected icon
local loot = entry:CreateTexture("$parent_Loot", "OVERLAY");
loot:SetWidth(16)
loot:SetHeight(16)
loot:SetPoint("RIGHT", entry, 0, 0)
loot:SetTexture("Interface\\AddOns\\AtlasLoot\\Images\\looticon")
loot:Show()
-- Add selected icon
local selected = entry:CreateTexture("$parent_Selected", "OVERLAY")
selected:SetWidth(16)
selected:SetHeight(16)
selected:SetPoint("RIGHT", entry, 0, 0)
selected:SetTexture("Interface\\AddOns\\AtlasLoot\\Images\\gold")
selected:Hide()
-- Add OnClick function
entry:SetScript("OnClick", AtlasLootBoss_OnClick)
entry:SetHighlightTexture("Interface\\QuestFrame\\UI-QuestTitleHighlight")
end
end
-- Hide the loot frame now that a pristine Atlas instance is created
AtlasLootItemsFrame:Hide();
Atlas_Search("");
-- Make sure the scroll bar is correctly offset
AtlasLoot_AtlasScrollBar_Update();
-- see if we should display the entrance/instance button or not, and decide what it should say
local matchFound = {nil};
local sayEntrance = nil;
for k,v in pairs(Atlas_EntToInstMatches) do
if ( k == zoneID ) then
matchFound = v;
sayEntrance = false;
end
end
if ( not matchFound[1] ) then
for k,v in pairs(Atlas_InstToEntMatches) do
if ( k == zoneID ) then
matchFound = v;
sayEntrance = true;
end
end
end
-- set the button's text, populate the dropdown menu, and show or hide the button
if ( matchFound[1] ) then
ATLAS_INST_ENT_DROPDOWN = {};
for k,v in pairs(matchFound) do
table.insert(ATLAS_INST_ENT_DROPDOWN, v);
end
table.sort(ATLAS_INST_ENT_DROPDOWN, AtlasSwitchDD_Sort);
if ( sayEntrance ) then
AtlasSwitchButton:SetText(ATLAS_ENTRANCE_BUTTON);
else
AtlasSwitchButton:SetText(ATLAS_INSTANCE_BUTTON);
end
AtlasSwitchButton:Show();
UIDropDownMenu_Initialize(AtlasSwitchDD, AtlasSwitchDD_OnLoad);
else
AtlasSwitchButton:Hide();
end
if ( TitanPanelButton_UpdateButton ) then
TitanPanelButton_UpdateButton("Atlas");
end
end
--[[
@@ -1389,26 +1268,20 @@ Hooks Atlas_OnShow() to add extra setup routines that AtlasLoot needs for
integration purposes.
]]
function AtlasLoot_Atlas_OnShow()
Atlas_Refresh();
AtlasLoot_Refresh(true);
-- We don't want Atlas and the Loot Browser open at the same time, so the Loot Browser is close
if ( AtlasLootDefaultFrame ) then
AtlasLootDefaultFrame:Hide();
AtlasLoot_SetupForAtlas();
end
-- Call the Atlas function
Hooked_Atlas_OnShow();
Original_Atlas_OnShow();
-- If we were looking at a loot table earlier in the session, it is still
-- saved on the item frame, so restore it in Atlas
if ( AtlasLootItemsFrame.activeBoss ) then
AtlasLootItemsFrame:Show();
AtlasLootItemsFrame:Show()
else
-- If no loot table is selected, set up icons next to boss names
for i = 1,ATLAS_CUR_LINES do
if ( _G["AtlasEntry"..i.."_Selected"] and _G["AtlasEntry"..i.."_Selected"]:IsVisible() ) then
_G["AtlasEntry"..i.."_Loot"]:Show();
_G["AtlasEntry"..i.."_Selected"]:Hide();
end
end
AtlasLootItemsFrame:Hide()
end
-- Consult the saved variable table to see whether to show the bottom panel
if ( AtlasLootCharDB.HidePanel == true ) then
@@ -1416,6 +1289,7 @@ function AtlasLoot_Atlas_OnShow()
else
AtlasLootPanel:Show();
end
AtlasLoot_AtlasScrollBar_Update()
end
--[[
@@ -1435,7 +1309,8 @@ AtlasLootBoss_OnClick:
Invoked whenever a boss line in Atlas is clicked
Shows a loot page if one is associated with the button
]]
function AtlasLootBoss_OnClick(name)
function AtlasLootBoss_OnClick()
local name = this:GetName()
local zoneID = ATLAS_DROPDOWNS[AtlasOptions.AtlasType][AtlasOptions.AtlasZone];
local id = this.idnum;
-- If the loot table was already shown and boss clicked again, hide the loot table and fix boss list icons
@@ -2060,7 +1935,6 @@ function AtlasLoot_ShowItemsFrame(dataID, dataSource, boss)
if ( AtlasLoot_ButtonRegistry[tablebase.Back_Page] ) then
AtlasLootItemsFrame_BACK.title = AtlasLoot_ButtonRegistry[tablebase.Back_Page].Title;
end
-- Hide navigation buttons if we click Quicklooks in Atlas
if ( AtlasFrame and AtlasFrame:IsVisible() ) then
local sourceKey
for k, v in pairs(AtlasLoot_Data) do
@@ -2068,11 +1942,13 @@ function AtlasLoot_ShowItemsFrame(dataID, dataSource, boss)
sourceKey = k
end
end
if ( sourceKey == "AtlasLootItems" ) then
-- Hide navigation buttons if we click on boss loot in Atlas
if ( sourceKey == "AtlasLootItems" or sourceKey == "AtlasLootWBItems" ) then
AtlasLootItemsFrame_BACK:Hide()
AtlasLootItemsFrame_NEXT:Hide()
AtlasLootItemsFrame_PREV:Hide()
end
-- Hide navigation buttons if we click Quicklooks in Atlas
for i = 1, 4 do
if ( AtlasLootCharDB["QuickLooks"][i] and dataID == AtlasLootCharDB["QuickLooks"][i][1] ) then
AtlasLootItemsFrame_BACK:Hide();
@@ -2399,12 +2275,10 @@ function AtlasLootItemsFrame_OnCloseButton()
AtlasLootItemsFrame.activeBoss = nil;
-- Fix the boss buttons so the correct icons are displayed
if ( AtlasFrame and AtlasFrame:IsVisible() ) then
if ( ATLAS_CUR_LINES ) then
for i = 1,ATLAS_CUR_LINES do
if ( _G["AtlasBossLine"..i.."_Selected"]:IsVisible() ) then
_G["AtlasBossLine"..i.."_Selected"]:Hide();
_G["AtlasBossLine"..i.."_Loot"]:Show();
end
for i = 1, ATLAS_NUM_LINES do
if ( _G["AtlasEntry"..i.."_Selected"] and _G["AtlasEntry"..i.."_Selected"]:IsShown() ) then
_G["AtlasEntry"..i.."_Selected"]:Hide();
_G["AtlasEntry"..i.."_Loot"]:Show();
end
end
end
-38
View File
@@ -438,44 +438,6 @@
</OnLoad>
</Scripts>
</GameTooltip>
<Button name="AtlasLootNewBossLineTemplate" virtual="true" hidden="true">
<Size x="336" y="15"/>
<HighlightTexture file="Interface\QuestFrame\UI-QuestTitleHighlight" alphaMode="ADD"/>
<Layers>
<Layer level="ARTWORK">
<FontString name="$parent_Text" inherits="GameFontNormal" justifyH="LEFT">
<Size x="320" y="15"/>
<Anchors>
<Anchor point="LEFT" relativeTo="$parent" relativePoint="LEFT"/>
</Anchors>
</FontString>
<Texture name="$parent_Loot" file="Interface\AddOns\AtlasLoot\Images\looticon" hidden="true">
<Size x="16" y="16"/>
<Anchors>
<Anchor point="RIGHT" relativeTo="$parent" relativePoint="RIGHT"/>
</Anchors>
</Texture>
<Texture name="$parent_Selected" file="Interface\AddOns\AtlasLoot\Images\gold" hidden="true">
<Size x="16" y="16"/>
<Anchors>
<Anchor point="RIGHT" relativeTo="$parent" relativePoint="RIGHT"/>
</Anchors>
</Texture>
</Layer>
</Layers>
<Scripts>
<OnLeave>
GameTooltip:Hide();
</OnLeave>
<OnClick>
AtlasLootBoss_OnClick(this:GetName());
</OnClick>
<OnShow>
this:SetFrameLevel((this:GetParent()):GetFrameLevel() + 1);
</OnShow>
</Scripts>
</Button>
<Button name="AtlasLootPanelButtonTemplate" inherits="OptionsButtonTemplate" virtual="true">
<Size x="120" y="20"/>