/Tukui/modules/blizzard/vehicle.lua

http://github.com/Asphyxia/Tukui · Lua · 70 lines · 55 code · 9 blank · 6 comment · 13 complexity · e2b040cc683e0fca212e892c4f2b98ee MD5 · raw file

  1. local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
  2. --------------------------------------------------------------------------
  3. -- move vehicle indicator
  4. --------------------------------------------------------------------------
  5. local anchor = CreateFrame("Frame", "TukuiVehicleAnchor", UIParent)
  6. anchor:Point("BOTTOM", UIParent, "BOTTOM", 0, 168)
  7. anchor:Size(120, 20)
  8. anchor:SetMovable(true)
  9. anchor:SetClampedToScreen(true)
  10. anchor:SetTemplate("Default")
  11. anchor:SetBackdropBorderColor(1,0,0)
  12. anchor:SetAlpha(0)
  13. anchor.text = T.SetFontString(anchor, C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  14. anchor.text:SetPoint("CENTER")
  15. anchor.text:SetText(L.move_vehicle)
  16. hooksecurefunc(VehicleSeatIndicator,"SetPoint",function(_,_,parent) -- vehicle seat indicator
  17. if (parent == "MinimapCluster") or (parent == _G["MinimapCluster"]) then
  18. VehicleSeatIndicator:ClearAllPoints()
  19. VehicleSeatIndicator:Point("BOTTOM", anchor, "BOTTOM", 0, 24)
  20. end
  21. end)
  22. --------------------------------------------------------------------------
  23. -- vehicule on mouseover because this shit take too much space on screen
  24. --------------------------------------------------------------------------
  25. local function VehicleNumSeatIndicator()
  26. if VehicleSeatIndicatorButton6 then
  27. T.numSeat = 6
  28. elseif VehicleSeatIndicatorButton5 then
  29. T.numSeat = 5
  30. elseif VehicleSeatIndicatorButton4 then
  31. T.numSeat = 4
  32. elseif VehicleSeatIndicatorButton3 then
  33. T.numSeat = 3
  34. elseif VehicleSeatIndicatorButton2 then
  35. T.numSeat = 2
  36. elseif VehicleSeatIndicatorButton1 then
  37. T.numSeat = 1
  38. end
  39. end
  40. local function vehmousebutton(alpha)
  41. for i=1, T.numSeat do
  42. local pb = _G["VehicleSeatIndicatorButton"..i]
  43. pb:SetAlpha(alpha)
  44. end
  45. end
  46. local function vehmouse()
  47. if VehicleSeatIndicator:IsShown() then
  48. VehicleSeatIndicator:SetAlpha(0)
  49. VehicleSeatIndicator:EnableMouse(true)
  50. VehicleNumSeatIndicator()
  51. VehicleSeatIndicator:HookScript("OnEnter", function() VehicleSeatIndicator:SetAlpha(1) vehmousebutton(1) end)
  52. VehicleSeatIndicator:HookScript("OnLeave", function() VehicleSeatIndicator:SetAlpha(0) vehmousebutton(0) end)
  53. for i=1, T.numSeat do
  54. local pb = _G["VehicleSeatIndicatorButton"..i]
  55. pb:SetAlpha(0)
  56. pb:HookScript("OnEnter", function(self) VehicleSeatIndicator:SetAlpha(1) vehmousebutton(1) end)
  57. pb:HookScript("OnLeave", function(self) VehicleSeatIndicator:SetAlpha(0) vehmousebutton(0) end)
  58. end
  59. end
  60. end
  61. hooksecurefunc("VehicleSeatIndicator_Update", vehmouse)