From e5a60da1ed08846d00c0c63044b848d230bd6a48 Mon Sep 17 00:00:00 2001 From: Hendrik Leppkes Date: Tue, 20 Oct 2020 00:12:26 +0200 Subject: [PATCH] Properly handle vehicle button show/hide Early hooking changes prevented the default Blizzard logic from hiding it in some cases. Fixes #40 --- VehicleBar.lua | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/VehicleBar.lua b/VehicleBar.lua index 1e28ffd..d61255a 100644 --- a/VehicleBar.lua +++ b/VehicleBar.lua @@ -50,17 +50,24 @@ function VehicleBarMod:ApplyConfig() self.bar:ApplyConfig(self.db.profile) end -function VehicleBarMod:MainMenuBarVehicleLeaveButton_Update() +local function ShouldVehicleButtonBeShown() if WoWClassic then - if UnitOnTaxi("player") then - MainMenuBarVehicleLeaveButton:Show() - end + return UnitOnTaxi("player") + else + return CanExitVehicle() + end +end + +function VehicleBarMod:MainMenuBarVehicleLeaveButton_Update() + if ShouldVehicleButtonBeShown() then + self.bar:PerformLayout() + MainMenuBarVehicleLeaveButton:Show() + MainMenuBarVehicleLeaveButton:Enable() else - if CanExitVehicle() then - MainMenuBarVehicleLeaveButton:Show() - end + MainMenuBarVehicleLeaveButton:SetHighlightTexture([[Interface\Buttons\ButtonHilight-Square]], "ADD") + MainMenuBarVehicleLeaveButton:UnlockHighlight() + MainMenuBarVehicleLeaveButton:Hide() end - self.bar:PerformLayout() end function VehicleBar:ApplyConfig(config)