From 420fbe65e6310585be2f80c11d54e476fb03b011 Mon Sep 17 00:00:00 2001 From: urnati Date: Sun, 18 Oct 2020 13:37:05 -0400 Subject: [PATCH 1/2] - Fix for #1282 : An empty bag slot now counts correctly rather than an 'error' --- TitanBag/TitanBag.lua | 330 +++++++++++++------------------------------------ 1 file changed, 88 insertions(+), 242 deletions(-) diff --git a/TitanBag/TitanBag.lua b/TitanBag/TitanBag.lua index 9c892ea..6b40140 100644 --- a/TitanBag/TitanBag.lua +++ b/TitanBag/TitanBag.lua @@ -159,118 +159,131 @@ function TitanPanelBagButton_OnClick(self, button) end -- ************************************************************************** --- NAME : isProfBag(id) --- DESC : Determine if this is a profession bag by getting its id and checking +-- NAME : isBag(id) +-- DESC : Determine if this is a bag. Then check for a profession bag using its id -- against the table of known ids. -- If it is a profession bag then grab its 'color' in case the user requested it. -- VARS : name = text (localized) of the bag to check +-- VARS : pos = position of the bag to check -- ************************************************************************** ---[==[ - local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, - itemStackCount, itemEquipLoc, itemIcon, itemSellPrice, itemClassID, itemSubClassID, - bindType, expacID, itemSetID, isCraftingReagent = - GetItemInfo(bag_name) - local bag_type = false + -- using GetItemInfo caused a 'script ran too long' error on Shadowlands ptr (9.x) although it worked in retail (8.x) + -- GetItemInfoInstant returns the needed id and uses client files - no server call. +local function isBag(bag_name, pos) +--[[ +print("isBag:" +.." '"..tostring(pos).."'" +.." '"..tostring(bag_name).."'" +) +--]] + -- set defaults for no bag found + local is_bag = false + local bag_type = "none" local color = {r=0,g=0,b=0} -- black (should never be used...) - if itemName == nil or itemName == false then - -- For some inexplicable reason the Backpack does not return as an item... - --TitanDebug("Bag name not found: '"..tostring(name).."'") + if bag_name == nil then + -- no bag found, return defaults else - local _, _, icolor, ltype, id, enchant, gem1, gem2, gem3, gem4, - suffix, unique, linkLvl, specID, - upgradeID, instance_diff_id, num_bonus_ids, bonus1, bonus2, name = string.find(itemLink, - "|?c?f?f?(%x*)|?H?([^:]*):?(%d+):?(%d*):?(%d*):?(%d*):?(%d*):?(%d*):?(%-?%d*):?(%-?%d*):?(%d*):?(%d*):?(%-?%d*):?(%d*):?(%d*):?(%d*):?(%d*):|h%[(.-)%]|h?|?r?") - - local string_id = tonumber(id) - if bags[string_id] then - bag_type = bags[string_id].style - color = bag_info[bag_type].color - else - -- not a profession bag - end + local itemID, itemType, itemSubType, itemEquipLoc, icon, itemClassID, itemSubClassID = GetItemInfoInstant(bag_name) --[[ -TitanDebug("Bag id: "..tostring(string_id).." '"..tostring(bag_type).."'" -.." ["..tostring(icolor).."]:" -.." '"..tostring(string.format("%1.2f",color.r)).."' '"..tostring(string.format("%1.2f",color.g)).."' '"..tostring(string.format("%1.2f",color.b)).."'") +print("isBag:" +.." ID:'"..tostring(itemID).."'" +.." ty:'"..tostring(itemType).."'" +.." sty:'"..tostring(itemSubType).."'" +.." EL:'"..tostring(itemEquipLoc).."'" +.." ic:'"..tostring(icon).."'" +.." CI:'"..tostring(itemClassID).."'" +.." SCI:'"..tostring(itemSubClassID).."'" +) --]] - end ---]==] -local function isProfBag(bag_name) - -- using straight GetItemInfo caused a 'script ran too long' error on Shadowlands ptr although it worked in retail - -- GetItemInfoInstant returns the needed id and uses client files - no server call. - local itemID, itemType, itemSubType, itemEquipLoc, icon, itemClassID, itemSubClassID = GetItemInfoInstant(bag_name) - local bag_type = false - local color = {r=0,g=0,b=0} -- black (should never be used...) - - if itemID == nil or itemId == false then -- For some inexplicable reason the Backpack does not return as an item... - --TitanDebug("Bag name not found: '"..tostring(name).."'") - else + -- so create a default so routine is successful + itemID = itemID or 0 + is_bag = true -- assume non nil is a valid bag name + if bags[itemID] then bag_type = bags[itemID].style color = bag_info[bag_type].color + bag_type = "profession" else - -- not a profession bag + bag_type = "normal" end end --[[ -TitanDebug("isProfBag: "..tostring(itemID).." '"..tostring(bag_type) +TitanDebug("isBag: "..tostring(itemID) +.." '"..tostring(bag_name).."'" +.." '"..tostring(is_bag).."'" +.." '"..tostring(bag_type).."'" .." '"..tostring(string.format("%1.2f",color.r)).."' '"..tostring(string.format("%1.2f",color.g)).."' '"..tostring(string.format("%1.2f",color.b)).."'") --]] - return bag_type, color + return is_bag, bag_type, color end -local function TextTest(id) +local function GetButtonText(id) local button, id = TitanUtils_GetButton(id, true); - local totalBagSlots, usedBagSlots, availableBagSlots, bag, bagText, bagRichText, bagType, color; + local totalBagSlots, usedBagSlots, availableBagSlots, bag, bagText, bagRichText, bag_type, color; local totalProfBagSlots = {0,0,0,0,0}; local usedProfBagSlots = {0,0,0,0,0}; local availableProfBagSlots = {0,0,0,0,0}; local bagRichTextProf = {"","","","",""}; +--[[ +TitanDebug("GetButtonText: >>>") +--]] totalBagSlots = 0; usedBagSlots = 0; for bag = 0, 4 do -- assuming 0 (Backpack) will not be a profession bag - local bagType, color = isProfBag(GetBagName(bag)) + local is_bag, bag_type, color = isBag(GetBagName(bag), bag) + + if is_bag then + if bag_type == "profession" then -- found a profession bag + -- when user wants profession bags counted, they are listed separately in the plugin + if TitanGetVar(TITAN_BAG_ID, "CountProfBagSlots") then + local size = GetContainerNumSlots(bag); + if (size and size > 0) then + totalProfBagSlots[bag] = size; + for slot = 1, size do + if (GetContainerItemInfo(bag, slot)) then + usedProfBagSlots[bag] = usedProfBagSlots[bag] + 1; + end + end + availableProfBagSlots[bag] = totalProfBagSlots[bag] - usedProfBagSlots[bag]; + end - if bagType then -- found a profession bag - -- when user wants profession bags counted, they are listed separately in the plugin - if TitanGetVar(TITAN_BAG_ID, "CountProfBagSlots") then + if (TitanGetVar(TITAN_BAG_ID, "ShowUsedSlots")) then + bagText = " [" .. format(L["TITAN_BAG_FORMAT"], usedProfBagSlots[bag], totalProfBagSlots[bag]) .. "]"; + else + bagText = " [" .. format(L["TITAN_BAG_FORMAT"], availableProfBagSlots[bag], totalProfBagSlots[bag]) .. "]"; + end + if ( TitanGetVar(TITAN_BAG_ID, "ShowColoredText") ) then + bagRichTextProf[bag] = TitanUtils_GetColoredText(bagText, color); + else + bagRichTextProf[bag] = TitanUtils_GetHighlightText(bagText); + end + end + elseif bag_type == "normal" then -- not a profession bag so get used & available counts local size = GetContainerNumSlots(bag); if (size and size > 0) then - totalProfBagSlots[bag] = size; + totalBagSlots = totalBagSlots + size; for slot = 1, size do if (GetContainerItemInfo(bag, slot)) then - usedProfBagSlots[bag] = usedProfBagSlots[bag] + 1; + usedBagSlots = usedBagSlots + 1; end end - availableProfBagSlots[bag] = totalProfBagSlots[bag] - usedProfBagSlots[bag]; - end - - if (TitanGetVar(TITAN_BAG_ID, "ShowUsedSlots")) then - bagText = " [" .. format(L["TITAN_BAG_FORMAT"], usedProfBagSlots[bag], totalProfBagSlots[bag]) .. "]"; - else - bagText = " [" .. format(L["TITAN_BAG_FORMAT"], availableProfBagSlots[bag], totalProfBagSlots[bag]) .. "]"; - end - if ( TitanGetVar(TITAN_BAG_ID, "ShowColoredText") ) then - bagRichTextProf[bag] = TitanUtils_GetColoredText(bagText, color); - else - bagRichTextProf[bag] = TitanUtils_GetHighlightText(bagText); - end - end - else -- not a profession bag so get used & available counts - local size = GetContainerNumSlots(bag); - if (size and size > 0) then - totalBagSlots = totalBagSlots + size; - for slot = 1, size do - if (GetContainerItemInfo(bag, slot)) then - usedBagSlots = usedBagSlots + 1; - end end + else -- catch all... end + else -- no bag in slot end +--[[ +TitanDebug("GetButtonText:" +.." "..tostring(bag) +.." total '"..tostring(totalBagSlots).."'" +.." used '"..tostring(usedBagSlots).."'" +.." '"..tostring(is_bag).."'" +.." '"..tostring(bag_type).."'" +) +--]] end availableBagSlots = totalBagSlots - usedBagSlots; @@ -289,104 +302,14 @@ local function TextTest(id) bagRichText = bagRichText..bagRichTextProf[1]..bagRichTextProf[2]..bagRichTextProf[3]..bagRichTextProf[4]..bagRichTextProf[5]; - return L["TITAN_BAG_BUTTON_LABEL"], bagRichText; -end - -local function UpdateButton(id) - local button, id = TitanUtils_GetButton(id, true); - local totalBagSlots, usedBagSlots, availableBagSlots, bag, bagText, bagRichText, color; - local totalProfBagSlots = {0,0,0,0,0}; - local usedProfBagSlots = {0,0,0,0,0}; - local availableProfBagSlots = {0,0,0,0,0}; - local bagRichTextProf = {"","","","",""}; - - totalBagSlots = 0; - usedBagSlots = 0; - for bag = 0, 4 do - - local bagType, color = TitanBag_IsProfBag(GetBagName(bag)) - - if not TitanBag_IsProfBag(GetBagName(bag)) then - local size = GetContainerNumSlots(bag); - if (size and size > 0) then - totalBagSlots = totalBagSlots + size; - for slot = 1, size do - if (GetContainerItemInfo(bag, slot)) then - usedBagSlots = usedBagSlots + 1; - end - end - end - end - if TitanGetVar(TITAN_BAG_ID, "CountProfBagSlots") and TitanBag_IsProfBag(GetBagName(bag)) then - local size = GetContainerNumSlots(bag); - if (size and size > 0) then - totalProfBagSlots[bag+1] = size; - for slot = 1, size do - if (GetContainerItemInfo(bag, slot)) then - usedProfBagSlots[bag+1] = usedProfBagSlots[bag+1] + 1; - end - end - availableProfBagSlots[bag+1] = totalProfBagSlots[bag+1] - usedProfBagSlots[bag+1]; - end - end - end - availableBagSlots = totalBagSlots - usedBagSlots; - - if (TitanGetVar(TITAN_BAG_ID, "ShowUsedSlots")) then - bagText = format(L["TITAN_BAG_FORMAT"], usedBagSlots, totalBagSlots); - else - bagText = format(L["TITAN_BAG_FORMAT"], availableBagSlots, totalBagSlots); - end - - if ( TitanGetVar(TITAN_BAG_ID, "ShowColoredText") ) then - color = TitanUtils_GetThresholdColor(TITAN_BAG_THRESHOLD_TABLE, usedBagSlots / totalBagSlots); - bagRichText = TitanUtils_GetColoredText(bagText, color); - else - bagRichText = TitanUtils_GetHighlightText(bagText); - end - - for bag = 1, 5 do - if totalProfBagSlots[bag] > 0 then - if (TitanGetVar(TITAN_BAG_ID, "ShowUsedSlots")) then - bagText = " [" .. format(L["TITAN_BAG_FORMAT"], usedProfBagSlots[bag], totalProfBagSlots[bag]) .. "]"; - else - bagText = " [" .. format(L["TITAN_BAG_FORMAT"], availableProfBagSlots[bag], totalProfBagSlots[bag]) .. "]"; - end - if ( TitanGetVar(TITAN_BAG_ID, "ShowColoredText") ) then - bagType, color = TitanBag_IsProfBag(GetBagName(bag-1)); - bagRichTextProf[bag] = TitanUtils_GetColoredText(bagText, color); - else - bagRichTextProf[bag] = TitanUtils_GetHighlightText(bagText); - end - end - end - bagRichText = bagRichText..bagRichTextProf[1]..bagRichTextProf[2]..bagRichTextProf[3]..bagRichTextProf[4]..bagRichTextProf[5]; - +--[[ +TitanDebug("GetButtonText: <<<") +--]] return L["TITAN_BAG_BUTTON_LABEL"], bagRichText; end function TitanPanelBagButton_GetButtonText(id) - ---TitanDebug("Bags ...") --- local str1, str2 = UpdateButton(id) ---TitanDebug("> '"..tostring(str1).."' '"..tostring(str2).."'") ---TitanDebug("Bags new ...") - local strA, strB = TextTest(id) ---TitanDebug("> '"..tostring(strA).."' '"..tostring(strB).."'") ---[[ - local cmp = "" - - if str1 == strA and str2 == strB then - -- old & new are the same - cmp = " == " - else - cmp = " ~= " - end ---]] --- TitanDebug("BagText "..cmp.." '"..tostring(str1).."' '"..tostring(strA).."'") --- TitanDebug(" >>>>>> ".." '"..tostring(str2).."' '"..tostring(strB).."'") - - + local strA, strB = GetButtonText(id) return strA, strB end @@ -537,80 +460,3 @@ end function TitanPanelBagButton_ShowDetailedInfo() TitanToggleVar(TITAN_BAG_ID, "ShowDetailedInfo"); end - --- ************************************************************************** --- NAME : TitanBag_IsProfBag(name) --- DESC : est to see if bag is a profession bag --- VARS : name = item name --- OUT : bagType = type of profession matching bag name --- color = the color associated with the profession --- ************************************************************************** -function TitanBag_IsProfBag(name) - local bagType, color; - if (name) then - for index, value in pairs(L["TITAN_BAG_PROF_BAG_ENCHANTING"]) do - if (string.find(name, value, 1, true)) then - bagType = "ENCHANTING"; - color = {r=0,g=0,b=1}; -- BLUE - return bagType, color; - end - end - for index, value in pairs(L["TITAN_BAG_PROF_BAG_ENGINEERING"]) do - if (string.find(name, value, 1, true)) then - bagType = "ENGINEERING"; - color = {r=1,g=0.49,b=0.04}; -- ORANGE - return bagType, color; - end - end - for index, value in pairs(L["TITAN_BAG_PROF_BAG_HERBALISM"]) do - if (string.find(name, value, 1, true)) then - bagType = "HERBALISM"; - color = {r=0,g=1,b=0}; -- GREEN - return bagType, color; - end - end - for index, value in pairs(L["TITAN_BAG_PROF_BAG_INSCRIPTION"]) do - if (string.find(name, value, 1, true)) then - bagType = "INSCRIPTION"; - color = {r=0.58,g=0.51,b=0.79}; -- PURPLE - return bagType, color; - end - end - for index, value in pairs(L["TITAN_BAG_PROF_BAG_JEWELCRAFTING"]) do - if (string.find(name, value, 1, true)) then - bagType = "JEWELCRAFTING"; - color = {r=1,g=0,b=0}; -- RED - return bagType, color; - end - end - for index, value in pairs(L["TITAN_BAG_PROF_BAG_LEATHERWORKING"]) do - if (string.find(name, value, 1, true)) then - bagType = "LEATHERWORKING"; - color = {r=0.78,g=0.61,b=0.43}; -- TAN - return bagType, color; - end - end - for index, value in pairs(L["TITAN_BAG_PROF_BAG_MINING"]) do - if (string.find(name, value, 1, true)) then - bagType = "MINING"; - color = {r=1,g=1,b=1}; -- WHITE - return bagType, color; - end - end - for index, value in pairs(L["TITAN_BAG_PROF_BAG_FISHING"]) do - if (string.find(name, value, 1, true)) then - bagType = "FISHING"; - color = {r=0.41,g=0.8,b=0.94}; -- LIGHT_BLUE - return bagType, color; - end - end - for index, value in pairs(L["TITAN_BAG_PROF_BAG_COOKING"]) do - if (string.find(name, value, 1, true)) then - bagType = "COOKING"; - color = {r=0.96,g=0.55,b=0.73}; -- PINK - return bagType, color; - end - end - end - return false; -end \ No newline at end of file -- 1.7.9.5 From 2cd9efe7548522c9fc748d820b1891d1d0b55de1 Mon Sep 17 00:00:00 2001 From: urnati Date: Mon, 26 Oct 2020 14:30:29 -0400 Subject: [PATCH 2/2] - Attempted fix for 'bouncing' extra action button - #1285 : Adjust default for buff icon list - Config : per user requests on Curse -- Add ability to adjust the Buff icon list offset, vertical only -- Add flags to output or not, on startup, Titan verion and registration process info --- Titan/TitanConfig.lua | 117 +++++++++++++++----- Titan/TitanMovable.lua | 265 ++++++++++++++++++++++++++++++++++++++-------- Titan/TitanPanel.lua | 16 +-- Titan/TitanUtils.lua | 4 +- Titan/TitanVariables.lua | 17 ++- 5 files changed, 330 insertions(+), 89 deletions(-) diff --git a/Titan/TitanConfig.lua b/Titan/TitanConfig.lua index 6fd02f4..e7ef19d 100644 --- a/Titan/TitanConfig.lua +++ b/Titan/TitanConfig.lua @@ -49,7 +49,7 @@ end --[[ local NAME: TitanAdjustPanelScale -DESC: Set the Tian bars and plugins to the selected scale then adjust other frames as needed. +DESC: Set the Titan bars and plugins to the selected scale then adjust other frames as needed. VAR: scale - the scale the user has selected for Titan OUT: None --]] @@ -57,7 +57,7 @@ local function TitanAdjustPanelScale(scale) Titan_AdjustScale() -- Adjust frame positions - TitanPanel_AdjustFrames(TITAN_PANEL_PLACE_BOTH, true) + TitanPanel_AdjustFrames(true, "AdjustPanelScale") end -- helper functions @@ -922,7 +922,7 @@ local optionsAuxBars = { set = function(_, a) TitanPanelSetVar("MainMenuBarXAdj", a); -- Adjust frame positions - TitanPanel_AdjustFrames(TITAN_PANEL_PLACE_BOTH, true) + TitanPanel_AdjustFrames(true, "Config: Adjust X (right / left)") end, }, } @@ -1705,33 +1705,96 @@ local optionsAdvanced = { name = L["TITAN_PANEL_MENU_ADV"], type = "group", args = { - confdesc = { + conftimerdesc = { + name = "Timers", + type = "group", inline = true, order = 1, - type = "description", - name = L["TITAN_PANEL_MENU_ADV_DESC"], - cmdHidden = true + args = { + confdesc = { + order = 10, + type = "description", + name = L["TITAN_PANEL_MENU_ADV_DESC"], + cmdHidden = true + }, + advtimerpew = { + name = L["TITAN_PANEL_MENU_ADV_PEW"], + desc = L["TITAN_PANEL_MENU_ADV_PEW_DESC"], + order = 20, type = "range", width = "full", + min = 1, max = 10, step = 0.5, + get = function() return TitanAllGetVar("TimerPEW") end, + set = function(_, a) + TitanAllSetVar("TimerPEW", a); + TitanTimers["EnterWorld"].delay = a + end, + }, + advtimervehicle = { + name = L["TITAN_PANEL_MENU_ADV_VEHICLE"], + desc = L["TITAN_PANEL_MENU_ADV_VEHICLE_DESC"], + order = 50, type = "range", width = "full", + min = 1, max = 10, step = 0.5, + get = function() return TitanAllGetVar("TimerVehicle") end, + set = function(_, a) + TitanAllSetVar("TimerVehicle", a); + TitanTimers["Vehicle"].delay = a + end, + }, }, - advtimerpew = { - name = L["TITAN_PANEL_MENU_ADV_PEW"], - desc = L["TITAN_PANEL_MENU_ADV_PEW_DESC"], - order = 10, type = "range", width = "full", - min = 1, max = 10, step = 0.5, - get = function() return TitanAllGetVar("TimerPEW") end, - set = function(_, a) - TitanAllSetVar("TimerPEW", a); - TitanTimers["EnterWorld"].delay = a - end, }, - advtimervehicle = { - name = L["TITAN_PANEL_MENU_ADV_VEHICLE"], - desc = L["TITAN_PANEL_MENU_ADV_VEHICLE_DESC"], - order = 50, type = "range", width = "full", - min = 1, max = 10, step = 0.5, - get = function() return TitanAllGetVar("TimerVehicle") end, - set = function(_, a) - TitanAllSetVar("TimerVehicle", a); - TitanTimers["Vehicle"].delay = a - end, + confbuffdesc = { + name = "Buff Icon Vertical Adjustment", + type = "group", inline = true, + order = 2, + args = { + confbuffdesc = { + order = 110, + type = "description", + name = "Adjust Buff icons only as needed. This will override the Titan default adjustment.", --L["TITAN_PANEL_MENU_ADV_DESC"], + cmdHidden = true + }, + advbuffadj = { + name = "Buff", --L["TITAN_PANEL_MENU_ADV_PEW"], + desc = "", -- L["TITAN_PANEL_MENU_ADV_PEW_DESC"], + order = 120, type = "range", width = "full", + min = -100, max = 100, step = 1, + get = function() return TitanPanelGetVar("BuffIconVerticalAdj") end, + set = function(_, a) + TitanPanelSetVar("BuffIconVerticalAdj", a); + -- Adjust frame positions + TitanPanel_AdjustFrames(true, "BuffIconVerticalAdj") + end, + }, + }, + }, + confoutputdesc = { + name = "Output", + type = "group", inline = true, + order = 3, + args = { + confdesc = { + order = 110, + type = "description", + name = "Output Various Titan Info At Startup.", --L["TITAN_PANEL_MENU_ADV_DESC"], + cmdHidden = true + }, + advname = { + name = "Name and Version", --L["TITAN_PANEL_MENU_ADV_PEW"], + desc = "", -- L["TITAN_PANEL_MENU_ADV_PEW_DESC"], + order = 120, type = "toggle", width = "full", + get = function() return not TitanAllGetVar("Silenced") end, -- yes, we did it to ourselves... + set = function(_, a) + TitanAllSetVar("Silenced", not a); + end, + }, + advplugins = { + name = "Registration process", --L["TITAN_PANEL_MENU_ADV_PEW"], + desc = "Registration and number of registered", -- L["TITAN_PANEL_MENU_ADV_PEW_DESC"], + order = 120, type = "toggle", width = "full", + get = function() return TitanAllGetVar("Registered") end, + set = function(_, a) + TitanAllSetVar("Registered", a); + end, + }, + }, }, }, } diff --git a/Titan/TitanMovable.lua b/Titan/TitanMovable.lua index c1c20bf..26e5bfd 100755 --- a/Titan/TitanMovable.lua +++ b/Titan/TitanMovable.lua @@ -61,8 +61,8 @@ local function DoAdjust(place, force) local res = false -- assume we will not adjust -- force is passed to cover cases where the user has just deselected both top or bottom bars -- When that happens we need to adjust - - -- We did it to ourselves - if (Aux)ScreenAdjust is true it means the user wants Titan to NOT adjust... + + -- We did it to ourselves - if (Aux)ScreenAdjust is true / 1 it means the user wants Titan to NOT adjust... if place == TITAN_PANEL_PLACE_TOP then if TitanPanelGetVar("ScreenAdjust") == 1 then -- do not adjust @@ -87,6 +87,25 @@ local function DoAdjust(place, force) return res end +--[[ local +NAME: VisibleBars +DESC: Get the x axis offset if XP or another bar are shown +VAR: None +OUT: int - X axis offset, in pixels +--]] +local function VisibleBars() + -- A valid frame and point is required + -- Determine a proper X offset using the given point (position) + local ret = 0 -- In case player at max level (no XP gain) and nothing else shown + if ( StatusTrackingBarManager:GetNumberVisibleBars() == 2 ) then + ret = 17; + elseif ( StatusTrackingBarManager:GetNumberVisibleBars() == 1 ) then + ret = 14; + end + + return ret +end + --[[ Titan NAME: TitanMovable_MenuBar_Disable DESC: Handle the main menu bar so Blizzard does not get upset. @@ -187,8 +206,8 @@ function TitanMovable_GetPanelYOffset(framePosition) -- used by other addons if framePosition == TITAN_PANEL_PLACE_TOP then return (-TITAN_PANEL_BAR_HEIGHT * scale)*(barnum_top); elseif framePosition == TITAN_PANEL_PLACE_BOTTOM then - return (TITAN_PANEL_BAR_HEIGHT * scale)*(barnum_bot)-1; - -- no idea why -1 is needed... seems anchoring to bottom is off a pixel + return (TITAN_PANEL_BAR_HEIGHT * scale)*(barnum_bot) + -1 -- no idea why -1 is needed... seems anchoring to bottom is off a pixel end end return 0 @@ -342,8 +361,17 @@ local function MoveFrame(frame_ptr, start_y, top_bottom, force) then -- skip this frame else +--[[ +TitanDebug ("MoveFrame :" + .." "..tostring(frame_ptr) + .." y:"..tostring(start_y) + ) +--]] if DoAdjust(top_bottom, force) and frame:IsShown() then - local y = TitanMovable_GetPanelYOffset(top_bottom) + (start_y or 0) -- includes scale adjustment + local scale = TitanPanelGetVar("Scale") + local y = 0 + y = TitanMovable_GetPanelYOffset(top_bottom) + + (start_y or 0) local point, relativeTo, relativePoint, xOfs, yOfs = frame:GetPoint() -- check for nil which will cause an error if point and relativeTo and relativePoint and xOfs then -- do not care about yOfs @@ -351,7 +379,9 @@ local function MoveFrame(frame_ptr, start_y, top_bottom, force) -- frame:ClearAllPoints(); -- frame:SetPoint(point, relativeTo:GetName(), relativePoint, xOfs, y) --[[ - if frame == ExtraActionBarFrame then +-- if tostring(relativeTo:GetName()) == "UIParent" then + if tostring(frame:GetName()) == "ExtraAbilityContainer" then +-- else TitanDebug ("MoveFrame :" .." "..tostring(frame:GetName()) .." point:"..tostring(point) @@ -359,6 +389,9 @@ local function MoveFrame(frame_ptr, start_y, top_bottom, force) .." relativePoint:"..tostring(relativePoint) .." xOfs:"..tostring(xOfs) .." y:"..tostring(y) + .." adj:"..tostring(DoAdjust(top_bottom, force)) + .." tb:"..tostring(top_bottom) + .." f:"..tostring(force) ) end --]] @@ -408,12 +441,7 @@ local function MoveMenuFrame(frame_ptr, start_y, top_bottom, force) and DoAdjust(top_bottom, force) then local yOffset = TitanMovable_GetPanelYOffset(top_bottom) -- includes scale adjustment --- xOffset = TitanMovableFrame_GetXOffset(frame, top_bottom); - if ( StatusTrackingBarManager:GetNumberVisibleBars() == 2 ) then - yOffset = yOffset + 17; - elseif ( StatusTrackingBarManager:GetNumberVisibleBars() == 1 ) then - yOffset = yOffset + 14; - end + + VisibleBars() local xOfs = TitanPanelGetVar("MainMenuBarXAdj") SetPosition(frame, "BOTTOM", "UIParent", "BOTTOM", xOfs, yOffset) @@ -540,6 +568,66 @@ local function has_pet_bar() return hasPetBar end +local function calc_bars() -- extra action button + local res = 0 + local out = "" + local main = 0 + local left = 0 + local pet = 0 + local stance = 0 + local cast = 0 + local poss = 0 + local vehicle = 0 + -- This covers the basic UI where there is no pet or extras + if MainMenuBar and MainMenuBar:IsShown() then + main = MainMenuBar:GetHeight() + out = MainMenuBar + end + -- Add the left bottom; the right bottom does not change Y + if MultiBarBottomLeft and MultiBarBottomLeft:IsShown() then + left = MultiBarBottomLeft:GetHeight() + out = MainMenuBar + end + -- These should be mutually exclusive... + if PetActionBarFrame and PetActionBarFrame:IsShown() then + pet = PetActionBarFrame:GetHeight(); + out = PetActionBarFrame + end + if StanceBarFrame and StanceBarFrame:IsShown() then + stance = StanceBarFrame:GetHeight(); + out = StanceBarFrame + end + if MultiCastActionBarFrame and MultiCastActionBarFrame:IsShown() then + cast = MultiCastActionBarFrame:GetHeight(); + out = MultiCastActionBarFrame + end + if PossessBarFrame and PossessBarFrame:IsShown() then + poss = PossessBarFrame:GetHeight(); + out = PossessBarFrame + end + if MainMenuBarVehicleLeaveButton and MainMenuBarVehicleLeaveButton:IsShown() then + vehicle = MainMenuBarVehicleLeaveButton:GetHeight(); + out = MainMenuBarVehicleLeaveButton + end + + res = main + left + pet + stance + cast + poss + vehicle +--[[ +TitanDebug ("calc_bars :" + .." "..tostring(out:GetName()) + .." y: "..tostring(res) + .." m: "..tostring(main) + .." l: "..tostring(left) + .." p: "..tostring(pet) + .." s: "..tostring(stance) + .." c: "..tostring(cast) + .." p: "..tostring(poss) + .." v: "..tostring(vehicle) + ) +--]] + return res +end +XXZZ_calc_bars = calc_bars + --[[ local NAME: MData table DESC: MData is a local table that holds each frame Titan may need to adjust. It controls the offsets needed to make room for the Titan bar(s). @@ -549,9 +637,14 @@ frameName - frame name (string) to adjust addonAdj - true if another addon is taking responsibility of adjusting this frame, if false Titan will use the user settings to adjust or not :DESC NOTE: +- MoveFrame calculates and offsets for the Titan bars, if shown +- When calculating the initial Y offset, consider the points and relative points of the frame being adjusted. +Titan only adjusts Y while leaving the rest of the SetPoint values as is. +An example is the extra action button - It is set against center of UIParent; it is not relative to the action bars... - Of course Blizzard had to make the MainMenuBar act differently . :GetPoint() does not work on it so a special helper routine was needed. :NOTE --]] +local save_y = 0 local MData = { [1] = {frameName = "PlayerFrame", move = function (force) MoveFrame("PlayerFrame", 0, TITAN_PANEL_PLACE_TOP, force) end, @@ -577,9 +670,10 @@ local MData = { then yOffset = (-TicketStatusFrame:GetHeight()) else - yOffset = -13 + yOffset = TitanPanelGetVar("BuffIconVerticalAdj") -- -13 (8.x) end - MoveFrame("BuffFrame", yOffset, TITAN_PANEL_PLACE_TOP, force) end, + MoveFrame("BuffFrame", yOffset, TITAN_PANEL_PLACE_TOP, force) + end, addonAdj = false, }, [6] = {frameName = "MinimapCluster", move = function (force) @@ -610,6 +704,7 @@ local MData = { if ExtraActionBarFrame and ExtraActionBarFrame:IsShown() then -- Need to calc Y because Y depends on what else is shown + -- The extra action button is calculated from the center of the screen so this needs more effort than the other buttons --[=[ UIParent Look at UIParent.lua for logic (UIParent_ManageFramePosition) --]=] @@ -618,31 +713,43 @@ local MData = { local overrideActionBarTop = 40; local petBattleTop = 60; - local yOfs = 18 -- FramePositionDelegate:UIParentManageFramePositions + local start_y = ExtraAbilityContainer:GetHeight() -- 18 -- FramePositionDelegate:UIParentManageFramePositions + local rel_start = UIParent:GetHeight() / 2 -- CENTER of UIParent + local yOfs = 0 + local yOfs1 = 0 +--[[ if MainMenuBar and MainMenuBar:IsShown() then - yOfs = yOfs + menuBarTop + yOfs2 = MainMenuBar:GetTop() -- menuBarTop end if (MultiBarBottomLeft and MultiBarBottomLeft:IsShown()) or (MultiBarBottomRight and MultiBarBottomRight:IsShown()) then - yOfs = yOfs + actionBarOffset + yOfs2 = MultiBarBottomRight:GetTop() -- actionBarOffset end if (has_pet_bar()) and (MultiBarBottomRight and MultiBarBottomRight:IsShown()) then - yOfs = yOfs + petBattleTop + yOfs2 = petBattleTop end + --(yOfs + start_y) * -1 +--]] + yOfs = (rel_start * -1) -- bottom of screen + + calc_bars() -- offset of WoW bars shown + + start_y -- center of extra action button --[[ -TitanDebug ("MData ExtraActionBarFrame :" - .." yOfs:"..tostring(yOfs) +TitanDebug ("move y :" + .." "..tostring(ExtraActionBarFrame:GetName()) + .." y: "..tostring(yOfs) + .." b/2: "..tostring(start_y) + .." b+: "..tostring(calc_bars()) + .." rs: "..tostring(rel_start) ) --]] - MoveFrame("ExtraActionBarFrame", yOfs, TITAN_PANEL_PLACE_BOTTOM, force) + --MoveFrame("ExtraActionBarFrame", yOfs, TITAN_PANEL_PLACE_BOTTOM, force) + MoveFrame("ExtraAbilityContainer", yOfs, TITAN_PANEL_PLACE_BOTTOM, force) end end, addonAdj = false, }, ---[=[ ---]=] --[[ [12] = {frameName = "OrderHallCommandBar", move = function (force) @@ -695,6 +802,7 @@ OUT: None local function TitanMovableFrame_MoveFrames(force) local move_count = 0 -- debug local str = "" -- debug + local force = force or false --[[ Setting the MainMenuBar as user placed is needed because in 8.0.0 Blizzard changed something in the way they controlled the frame. With Titan panel and bottom bars enabled the MainMenuBar @@ -730,8 +838,7 @@ local function TitanMovableFrame_MoveFrames(force) end end end ---[ ---]] + Titan_FCF_UpdateDockPosition(); -- chat UpdateContainerFrameAnchors(); -- Move bags as needed else @@ -753,14 +860,24 @@ end NAME: TitanPanel_AdjustFrames DESC: Adjust the frames for the Titan visible bars. This is a shell for the actual Movable routine used by other Titan routines and secure hooks +VAR: force - Force an adjust such as when the user changes bars shown OUT: None NOTE: :NOTE --]] -function TitanPanel_AdjustFrames(force) - -- force is passed to cover cases where Titan should always adjust - -- such as when the user has just de/selected top or bottom bars - local f = force or false -- do not require the parameter +function TitanPanel_AdjustFrames(force, reason) +--[[ +TitanDebug ("_AdjustFrames :" + .." "..tostring(force) + .." reason: '"..tostring(reason).."'" + ) +--]] + local f = false -- do not require the parameter + if force == true then -- but force it to be boolean + f = true + else + f = false + end -- Adjust frame positions top and bottom based on user choices if hooks_done then @@ -790,12 +907,76 @@ function Titan_AdjustScale() , TITAN_PANEL_PLACE_TOP); end - TitanMovableFrame_MoveFrames() + TitanPanel_AdjustFrames(false, "_AdjustScale ") -- TitanPanelBarButton_DisplayBarsWanted() TitanPanel_RefreshPanelButtons(); end end +--[[ ============= +NAME: Titan_Hook_* +DESC: Set of routines to front the adjust the frames routine. +VAR: None +OUT: None +NOTE: +This group of Titan_Hook_* is : +- to debug moving of frames when TitanPanel_AdjustFrames hooks trigger +- just in case there is specific processing needed per hook +- used when hooks and callbacks are needed + +These may be called from any Titan Panel code +:NOTE +--]] +function Titan_Hook_Frames() + TitanPanel_AdjustFrames(false, "Hook UIParent_ManageFramePositions ") +end + +function Titan_Hook_Ticket_Show() + TitanPanel_AdjustFrames(false, "Hook TicketStatusFrame Show ") +end + +function Titan_Hook_Ticket_Hide() + TitanPanel_AdjustFrames(false, "Hook TicketStatusFrame Hide ") +end + +function Titan_Hook_Target() + TitanPanel_AdjustFrames(false, "Hook TargetFrame_Update ") +end + +function Titan_Hook_Override_Show() + TitanPanel_AdjustFrames(false, "Hook OverrideActionBar Show") +end + +function Titan_Hook_Override_Hide() + TitanPanel_AdjustFrames(false, "Hook OverrideActionBar Hide") +end + +function Titan_Hook_Map() + TitanPanel_AdjustFrames(false, "Hook WorldMapFrame.BorderFrame.MaximizeMinimizeFrame.MinimizeButton ") +end + +function Titan_Hook_OrderHall() + TitanPanel_AdjustFrames(false, "Hook OrderHall_CheckCommandBar ") +end + +function Titan_Hook_PEW() + TitanPanel_AdjustFrames(false, "Hook PEW Config timer") +end + +function Titan_Hook_SpecSwitch() + TitanPanel_AdjustFrames(false, "Hook SpecSwitch Config timer ") +end + +function Titan_Hook_MoveAdj() + TitanPanel_AdjustFrames(false, "Hook MoveAdj Config timer ") +end + +function Titan_Hook_Vehicle() + TitanPanel_AdjustFrames(false, "Hook Vehicle Config timer ") +end + +-- ============= + --[[ Titan NAME: TitanMovable_SecureFrames DESC: Once Titan is initialized create the post hooks we need to help adjust frames properly. @@ -810,23 +991,21 @@ function TitanMovable_SecureFrames() if not TitanPanelAce:IsHooked("FCF_UpdateDockPosition", Titan_FCF_UpdateDockPosition) then TitanPanelAce:SecureHook("FCF_UpdateDockPosition", Titan_FCF_UpdateDockPosition) -- FloatingChatFrame end - if not TitanPanelAce:IsHooked("UIParent_ManageFramePositions", TitanPanel_AdjustFrames) then - TitanPanelAce:SecureHook("UIParent_ManageFramePositions", TitanPanel_AdjustFrames) -- UIParent.lua - TitanPanel_AdjustFrames() + if not TitanPanelAce:IsHooked("UIParent_ManageFramePositions", Titan_Hook_Frames) then + TitanPanelAce:SecureHook("UIParent_ManageFramePositions", Titan_Hook_Frames) -- UIParent.lua + TitanPanel_AdjustFrames(true, "Hook First UIParent_ManageFramePositions") end - if not TitanPanelAce:IsHooked(TicketStatusFrame, "Show", TitanPanel_AdjustFrames) then - TitanPanelAce:SecureHook(TicketStatusFrame, "Show", TitanPanel_AdjustFrames) -- HelpFrame.xml - TitanPanelAce:SecureHook(TicketStatusFrame, "Hide", TitanPanel_AdjustFrames) -- HelpFrame.xml - TitanPanelAce:SecureHook("TargetFrame_Update", TitanPanel_AdjustFrames) -- TargetFrame.lua --- TitanPanelAce:SecureHook(MainMenuBar, "Show", TitanPanel_AdjustFrames) -- HelpFrame.xml --- TitanPanelAce:SecureHook(MainMenuBar, "Hide", TitanPanel_AdjustFrames) -- HelpFrame.xml - TitanPanelAce:SecureHook(OverrideActionBar, "Show", TitanPanel_AdjustFrames) -- HelpFrame.xml - TitanPanelAce:SecureHook(OverrideActionBar, "Hide", TitanPanel_AdjustFrames) -- HelpFrame.xml + if not TitanPanelAce:IsHooked(TicketStatusFrame, "Show", Titan_Hook_Ticket_Show) then + TitanPanelAce:SecureHook(TicketStatusFrame, "Show", Titan_Hook_Ticket_Show) -- HelpFrame.xml + TitanPanelAce:SecureHook(TicketStatusFrame, "Hide", Titan_Hook_Ticket_Hide) -- HelpFrame.xml + TitanPanelAce:SecureHook("TargetFrame_Update", Titan_Hook_Target) -- TargetFrame.lua + TitanPanelAce:SecureHook(OverrideActionBar, "Show", Titan_Hook_Override_Show) -- HelpFrame.xml + TitanPanelAce:SecureHook(OverrideActionBar, "Hide", Titan_Hook_Override_Hide) -- HelpFrame.xml TitanPanelAce:SecureHook("UpdateContainerFrameAnchors", Titan_ContainerFrames_Relocate) -- ContainerFrame.lua - TitanPanelAce:SecureHook(WorldMapFrame.BorderFrame.MaximizeMinimizeFrame.MinimizeButton, "Show", TitanPanel_AdjustFrames) -- WorldMapFrame.lua + TitanPanelAce:SecureHook(WorldMapFrame.BorderFrame.MaximizeMinimizeFrame.MinimizeButton, "Show", Titan_Hook_Map) -- WorldMapFrame.lua - TitanPanelAce:SecureHook("OrderHall_CheckCommandBar", TitanPanel_AdjustFrames) + TitanPanelAce:SecureHook("OrderHall_CheckCommandBar", Titan_Hook_OrderHall) end if not TitanPanelAce:IsHooked("VideoOptionsFrameOkay_OnClick", Titan_AdjustUIScale) then diff --git a/Titan/TitanPanel.lua b/Titan/TitanPanel.lua index 5df466d..8e20428 100644 --- a/Titan/TitanPanel.lua +++ b/Titan/TitanPanel.lua @@ -422,7 +422,7 @@ function TitanPanel_PlayerEnteringWorld() -- Move frames TitanMovable_SecureFrames() - TitanPanel_AdjustFrames() + TitanPanel_AdjustFrames(true, "Init: PEW (Player Entering World)") -- Secondary failsafe check for bottom frame adjustment -- @@ -499,7 +499,7 @@ function TitanPanelBarButton:CVAR_UPDATE(cvarname, cvarvalue) if TitanPlayerSettings and TitanPanelGetVar("Scale") then Titan_AdjustScale() -- Adjust frame positions - TitanPanel_AdjustFrames() + TitanPanel_AdjustFrames(true, "CVar update "..tostring(cvarname)) end end end @@ -525,7 +525,7 @@ end function TitanPanelBarButton:PLAYER_REGEN_ENABLED() -- Outside combat check to see if frames need correction - TitanPanel_AdjustFrames() + TitanPanel_AdjustFrames(true, "Regen enabled") end --[ function TitanPanelBarButton:ACTIVE_TALENT_GROUP_CHANGED() @@ -541,7 +541,7 @@ function TitanPanelBarButton:UNIT_ENTERED_VEHICLE(self, ...) end function TitanPanelBarButton:UNIT_EXITED_VEHICLE(self, ...) -- A combat check will be done inside the adjust - TitanPanel_AdjustFrames(true) + TitanPanel_AdjustFrames(true, "Exit vehicle") end --]] -- @@ -697,7 +697,7 @@ local function handle_reset_cmds(cmd_list) -- Adjust panel scale Titan_AdjustScale() -- Adjust frame positions - TitanPanel_AdjustFrames() + TitanPanel_AdjustFrames(true, "Config: adj scale") TitanPrint(L["TITAN_PANEL_SLASH_RESP3"], "info") else TitanPrint(L["TITAN_PANEL_MENU_IN_COMBAT_LOCKDOWN"], "warning") @@ -1133,7 +1133,7 @@ NOTE: function TitanPanelBarButton_ToggleScreenAdjust() -- Turn on / off adjusting of other frames around Titan TitanPanelToggleVar("ScreenAdjust"); - TitanPanel_AdjustFrames(true) + TitanPanel_AdjustFrames(true, "Config: on/off adj top frames") end --[[ Titan @@ -1148,7 +1148,7 @@ NOTE: function TitanPanelBarButton_ToggleAuxScreenAdjust() -- turn on / off adjusting of frames at the bottom of the screen TitanPanelToggleVar("AuxScreenAdjust"); - TitanPanel_AdjustFrames(true) + TitanPanel_AdjustFrames(true, "Config: on/off adj bottom frames") end --[[ Titan @@ -1239,7 +1239,7 @@ function TitanPanelBarButton_DisplayBarsWanted() TitanAnchors() -- Adjust other frames because the bars shown / hidden may have changed - TitanPanel_AdjustFrames(true) + TitanPanel_AdjustFrames(true, "_DisplayBarsWanted") end --[[ Titan diff --git a/Titan/TitanUtils.lua b/Titan/TitanUtils.lua index ba95597..9eba364 100644 --- a/Titan/TitanUtils.lua +++ b/Titan/TitanUtils.lua @@ -1437,7 +1437,7 @@ function TitanUtils_RegisterPluginList() local id local cnt = 0 if TitanPluginToBeRegisteredNum > 0 then - if not Titan__InitializedPEW and not TitanAllGetVar("Silenced") then + if not Titan__InitializedPEW and TitanAllGetVar("Registered") then TitanDebug(L["TITAN_PANEL_REGISTER_START"], "normal") end for index, value in ipairs(TitanPluginToBeRegistered) do @@ -1446,7 +1446,7 @@ function TitanUtils_RegisterPluginList() end cnt = cnt + 1 end - if not Titan__InitializedPEW and not TitanAllGetVar("Silenced") then + if not Titan__InitializedPEW and TitanAllGetVar("Registered") then TitanDebug((L["TITAN_PANEL_REGISTER_END"].." "..cnt), "normal") end end diff --git a/Titan/TitanVariables.lua b/Titan/TitanVariables.lua index d277877..909a79d 100644 --- a/Titan/TitanVariables.lua +++ b/Titan/TitanVariables.lua @@ -277,6 +277,7 @@ TITAN_PANEL_SAVED_VARIABLES = { AuxBar2_Transparency = 0.7, AuxBar2_Align = TITAN_PANEL_BUTTONS_ALIGN_LEFT, MainMenuBarXAdj = 0, + BuffIconVerticalAdj = 10, }; --[[ Titan @@ -292,8 +293,8 @@ TITAN_ALL_SAVED_VARIABLES = { -- Global profile GlobalProfileUse = false, GlobalProfileName = TITAN_PROFILE_NONE, - -- Silent Load - Silenced = false, + Silenced = false,-- Silent Load : name and version + Registered = false, -- for debug -- OrderHallCommandBar Status OrderHall = true, }; @@ -518,9 +519,7 @@ OUT: None --]] local function Sync_panel_settings(settings) -- Synchronize registered and saved variables ---TitanDebug("Sync_1: "..(settings.FontName or "?")) TitanVariables_SyncRegisterSavedVariables(settings, TitanPanelSettings) ---TitanDebug("Sync_2: "..(TitanPanelSettings.FontName or "?")) end --[[ local @@ -532,11 +531,11 @@ OUT: None local function Set_Timers(reset) -- Titan is loaded so set the timers we want to use TitanTimers = { - ["EnterWorld"] = {obj = "PEW", callback = TitanPanel_AdjustFrames, delay = 4,}, - ["DualSpec"] = {obj = "SpecSwitch", callback = TitanPanel_AdjustFrames, delay = 2,}, + ["EnterWorld"] = {obj = "PEW", callback = Titan_Hook_PEW, delay = 4,}, + ["DualSpec"] = {obj = "SpecSwitch", callback = Titan_Hook_SpecSwitch, delay = 2,}, ["LDBRefresh"] = {obj = "LDB", callback = TitanLDBRefreshButton, delay = 2,}, - ["Adjust"] = {obj = "MoveAdj", callback = TitanPanel_AdjustFrames, delay = 1,}, - ["Vehicle"] = {obj = "Vehicle", callback = TitanPanel_AdjustFrames, delay = 1,}, + ["Adjust"] = {obj = "MoveAdj", callback = Titan_Hook_MoveAdj, delay = 1,}, + ["Vehicle"] = {obj = "Vehicle", callback = Titan_Hook_Vehicle, delay = 1,}, } if reset then @@ -626,7 +625,7 @@ function TitanVariables_InitTitanSettings() --[[ TitanDumpPlayerList() --]] - Sync_panel_settings(TITAN_PANEL_SAVED_VARIABLES) +-- Sync_panel_settings(TITAN_PANEL_SAVED_VARIABLES) if (TitanAll) then else -- 1.7.9.5