From 21f30af11fd59edd75a85d4c9dbab636f8752a7f Mon Sep 17 00:00:00 2001 From: Tercio Jose Date: Sun, 29 Oct 2023 23:49:40 -0300 Subject: [PATCH] Fixed Death tooltip not clamping to screen --- Libs/DF/cooltip.lua | 25 ++++++++++++++++++++----- boot.lua | 4 ++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/Libs/DF/cooltip.lua b/Libs/DF/cooltip.lua index 72db42ef9..c38007f08 100644 --- a/Libs/DF/cooltip.lua +++ b/Libs/DF/cooltip.lua @@ -15,7 +15,7 @@ local max = math.max --api locals local PixelUtil = PixelUtil or DFPixelUtil -local version = 17 +local version = 18 local CONST_MENU_TYPE_MAINMENU = "main" local CONST_MENU_TYPE_SUBMENU = "sub" @@ -2204,6 +2204,9 @@ function DF:CreateCoolTip() frame1:ClearAllPoints() PixelUtil.SetPoint(frame1, gameCooltip.OptionsTable.MyAnchor, anchor, gameCooltip.OptionsTable.RelativeAnchor, 0 + moveX + gameCooltip.OptionsTable.WidthAnchorMod, 10 + gameCooltip.OptionsTable.HeightAnchorMod + moveY) + local bHadXPositionOutOfScreen = false + local bHadYPositionOutOfScreen = false + if (not xOffset) then --check if cooltip is out of screen bounds local centerX = frame1:GetCenter() @@ -2216,13 +2219,17 @@ function DF:CreateCoolTip() --out of right side local moveLeftOffset = (centerX + halfScreenWidth) - screenWidth gameCooltip.internal_x_mod = -moveLeftOffset - return gameCooltip:SetMyPoint(host, -moveLeftOffset, 0) + xOffset = -moveLeftOffset + bHadXPositionOutOfScreen = true + --return gameCooltip:SetMyPoint(host, -moveLeftOffset, 0) elseif (centerX - halfScreenWidth < 0) then --out of left side local moveRightOffset = centerX - halfScreenWidth gameCooltip.internal_x_mod = moveRightOffset * -1 - return gameCooltip:SetMyPoint(host, moveRightOffset * -1, 0) + xOffset = moveRightOffset * -1 + bHadXPositionOutOfScreen = true + --return gameCooltip:SetMyPoint(host, moveRightOffset * -1, 0) end end end @@ -2238,17 +2245,25 @@ function DF:CreateCoolTip() --out of top side local moveDownOffset = (centerY + helpScreenHeight) - screenHeight gameCooltip.internal_y_mod = -moveDownOffset - return gameCooltip:SetMyPoint(host, 0, -moveDownOffset) + yOffset = -moveDownOffset + bHadYPositionOutOfScreen = true + --return gameCooltip:SetMyPoint(host, 0, -moveDownOffset) elseif (centerY - helpScreenHeight < 0) then --out of bottom side local moveUpOffset = centerY - helpScreenHeight gameCooltip.internal_y_mod = moveUpOffset * -1 - return gameCooltip:SetMyPoint(host, 0, moveUpOffset * -1) + yOffset = moveUpOffset * -1 + bHadYPositionOutOfScreen = true + --return gameCooltip:SetMyPoint(host, 0, moveUpOffset * -1) end end end + if (bHadXPositionOutOfScreen or bHadYPositionOutOfScreen) then + return gameCooltip:SetMyPoint(host, bHadXPositionOutOfScreen and xOffset or 0, bHadYPositionOutOfScreen and yOffset or 0) + end + if (frame2:IsShown() and not gameCooltip.overlap_checked) then local frame2CenterX = frame2:GetCenter() if (frame2CenterX) then diff --git a/boot.lua b/boot.lua index a134c1350..213b9aad6 100644 --- a/boot.lua +++ b/boot.lua @@ -13,8 +13,8 @@ local addonName, Details222 = ... local version, build, date, tocversion = GetBuildInfo() - Details.build_counter = 12018 - Details.alpha_build_counter = 12018 --if this is higher than the regular counter, use it instead + Details.build_counter = 12019 + Details.alpha_build_counter = 12019 --if this is higher than the regular counter, use it instead Details.dont_open_news = true Details.game_version = version Details.userversion = version .. " " .. Details.build_counter