PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 5ms RepoModel.GetById 35ms app.codeStats 1ms

/Tukui/modules/blizzard/vehicle.lua

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