-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMMBlinker.lua
193 lines (177 loc) · 5.73 KB
/
MMBlinker.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
MMBlinker = {}
function MMBlinker.initialize()
MMBlinker.blink = {
{true, false, .25},
{false, true, .25},
{true, true, .16}
}
MMBlinker.filtersShowing = false
MMBlinker.pinList = {}
MMBlinker.defaultItem = 0
MMBlinker.maps = {}
MMBlinker.maps[1] = {}
MMBlinker.maps[1].window = "EA_Window_OverheadMapMapDisplay"
MMBlinker.maps[1].filters = EA_Window_OverheadMap.Settings.mapPinFilters
MMBlinker.maps[2] = {}
MMBlinker.maps[2].window = "EA_Window_WorldMapZoneViewMapDisplay"
MMBlinker.maps[2].filters = EA_Window_WorldMap.Settings.mapPinFilters
MMBlinker.availableFilters = EA_Window_OverheadMap.mapPinFilters
CreateWindow("MMBlinker", true)
WindowSetShowing("MMBlinker", true)
CreateWindow("MMBlinker_filters", true)
WindowSetShowing("MMBlinker_filters", false)
local n = 1
LabelSetText("MMBlinker_filtersLabel"..n, L"group");
MMBlinker.pinList[n] = {}
MMBlinker.pinList[n].pins = {}
MMBlinker.pinList[n].pins[1] = SystemData.MapPips.GROUP_MEMBER
n = n + 1
LabelSetText("MMBlinker_filtersLabel"..n, L"warband");
MMBlinker.pinList[n] = {}
MMBlinker.pinList[n].pins = {}
MMBlinker.pinList[n].pins[1] = SystemData.MapPips.WARBAND_MEMBER
n = n + 1
for i, o in pairs(MMBlinker.availableFilters) do
if ( n <= 20 ) then
LabelSetText("MMBlinker_filtersLabel"..n, GetStringFromTable("MapPointFilterNames", o.label))
MMBlinker.pinList[n] = o
for i = 1, #o.pins do
if ( o.pins[i] == SystemData.MapPips.HEALER_NPC ) then
MMBlinker.defaultItem = n
end
end
n = n + 1
end
end
local x, y = WindowGetDimensions("MMBlinker_filters")
y = 15 + 30 * n
WindowSetDimensions("MMBlinker_filters", x, y)
LayoutEditor.RegisterWindow( "MMBlinker" , L"MMBlinker" , L"MMBlinker Windows",
false , false , true , nil )
end
function MMBlinker.pinState(type, state)
for map = 1, #MMBlinker.maps do
local newState = state
if ( newState == nil ) then
newState = MMBlinker.maps[map].filters[type]
end
MapSetPinFilter(MMBlinker.maps[map].window, type, newState)
end
end
function MMBlinker.findAddonMaps()
local i = 3
if ( MinmapSettings ~= nil ) then
MMBlinker.maps[i] = {}
MMBlinker.maps[i].window = "MinmapMapDisplay"
MMBlinker.maps[i].filters = MinmapSettings.mapPinFilters
i = i + 1
end
end
function MMBlinker.leftDownMain()
MMBlinker.findAddonMaps()
if ( MMBlinker.filtersShowing == true or MMBlinker.running == true ) then
WindowSetShowing("MMBlinker_filters", false)
MMBlinker.filtersShowing = false
MMBlinker.running = false
MMBlinker.blinkState(0)
else
MMBlinker.start(MMBlinker.defaultItem)
end
end
function MMBlinker.rightDownMain()
MMBlinker.findAddonMaps()
if ( MMBlinker.filtersShowing == true ) then
WindowSetShowing("MMBlinker_filters", false)
MMBlinker.filtersShowing = false
else
WindowSetShowing("MMBlinker_filters", true)
MMBlinker.filtersShowing = true
end
end
function MMBlinker.leftDownFilters(flags,x,y)
local scale = WindowGetScale("MMBlinker_filters")
if ( scale ~= 0 ) then
x = x / scale
y = y / scale
end
local n = math.floor((y-15)/30)+1
MMBlinker.start(n)
end
function MMBlinker.rightDownFilters()
MMBlinker.rightDownMain()
end
function MMBlinker.start(n)
if ( MMBlinker.running ) then
MMBlinker.blinkState(0)
if ( MMBlinker.currentPins == n ) then
return
end
end
for index, type in pairs( SystemData.MapPips )
do
MMBlinker.pinState(type, false)
end
MMBlinker.pins = {SystemData.MapPips.HEALER_NPC}
if ( n > 0 ) then
MMBlinker.pins = MMBlinker.pinList[n].pins
end
MMBlinker.currentPins = n
MMBlinker.autoStop = 30
MMBlinker.blinkState(1)
end
function MMBlinker.repentHarlequin(elapsed)
if ( MMBlinker.running == true )
then
MMBlinker.autoStop = MMBlinker.autoStop - elapsed
if ( MMBlinker.autoStop <= 0 ) then
MMBlinker.blinkState(0)
else
MMBlinker.flipTime = MMBlinker.flipTime - elapsed
if ( MMBlinker.flipTime <= 0 )
then
MMBlinker.currentState = MMBlinker.currentState + 1
if ( MMBlinker.currentState > #MMBlinker.blink ) then
MMBlinker.currentState = 1
end
MMBlinker.blinkState( MMBlinker.currentState )
end
end
end
end
function MMBlinker.blinkState(n)
if ( n == 0 ) then
MMBlinker.running = false
for index, type in pairs( SystemData.MapPips )
do
MMBlinker.pinState(type, nil)
end
else
MMBlinker.pinState(SystemData.MapPips.PLAYER, MMBlinker.blink[n][2])
for i, f in pairs(MMBlinker.pins) do
MMBlinker.pinState(f, MMBlinker.blink[n][1])
end
MMBlinker.flipTime = MMBlinker.blink[n][3]
MMBlinker.currentState = n
MMBlinker.running = true
end
end
function MMBlinker.dp(...)
local out = L""
for i, part in ipairs(arg) do
if ( type(part) == "wstring" ) then
out = out .. part
elseif ( type(part) == "boolean" ) then
if ( part == true ) then out = out .. L"true"
else out = out .. L"false" end
else
out = out .. towstring(""..part)
end
end
d(out)
end
function MMBlinker.allon()
for index, type in pairs( SystemData.MapPips )
do
MMBlinker.pinState(type, true)
end
end