forked from jzy-chitong56/AMAI-CN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBlizzard_UIFrame.eai
239 lines (226 loc) · 8.06 KB
/
Blizzard_UIFrame.eai
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#IFDEF GLOBAL
#DEFINE VER $VER$
#IFDEF REFORGED
boolean W3CIcons = true
minimapicon array miniicons
//framehandle array iconFrame
integer miniicons_length = 0
boolean W3CClock = true
framehandle clock = null
integer GameTimeSec = 0
timer ClockTimer = null
#ELSE
boolean W3CClock = true
real GameTimeSec = 0
timer ClockTimer = null
timer ClockTimerTemp = null
timerdialog W3CTimerDialog = null
#ENDIF
#UNDEF VER
#ELSE
#DEFINE VER $VER$
#IFDEF REFORGED
//===========================================================================
// W3C UI Frame (Some ICON is custom)
// use Frame need adapter 1.36 new Observer mode minimap changing position , here no adapter
// use miniicon always have some slight deviation , like lua have innate advantage
//===========================================================================
function SetW3CMiniMapIcons takes nothing returns nothing
local integer i = 0
if GetTriggerPlayer() != null then
if W3CIcons == false then
set W3CIcons = true
call DisplayTimedTextToForce(GetPlayersAll(), 7.00, "MiniMapIcon |cff00ff00[on]|r")
else
set W3CIcons = false
call DisplayTimedTextToForce(GetPlayersAll(), 7.00, "MiniMapIcon |cfffd0000[off]|r")
endif
endif
loop
exitwhen i >= miniicons_length
//call BlzFrameSetEnable(iconFrame[i], not BlzFrameGetEnable(iconFrame[i]))
//call BlzDestroyFrame(iconFrame[i])
//set iconFrame[i] = null
call SetMinimapIconVisible(miniicons[i], W3CIcons)
//call DestroyMinimapIcon(miniicons[i])
//set miniicons[i] = null
set i = i + 1
endloop
endfunction
function W3CMiniMapIcons takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
loop
exitwhen i >= GetBJMaxPlayers()
if GetPlayerController(Player(i)) != MAP_CONTROL_COMPUTER then
call TriggerRegisterPlayerChatEvent(t, Player(i), "-minimap", false)
endif
set i = i + 1
endloop
call TriggerAddAction(t, function SetW3CMiniMapIcons)
endfunction
function CreateW3CMiniMapIcons takes nothing returns nothing
local unit u = null
local group g = null
local string t = null
local integer i = 0
local integer id = 0
local real x = 0
local real y = 0
local real xR
local real yR
local real maxMinimapDist = RMaxBJ(GetCameraBoundMaxX() - GetCameraBoundMinX() + 768 , GetCameraBoundMaxY() - GetCameraBoundMinY() + 512) / 2
local real xCenter = (GetCameraBoundMaxX() + GetCameraBoundMinX()) / 2
local real yCenter = (GetCameraBoundMaxY() + GetCameraBoundMinY()) / 2
if W3CIcons == false or IsMapFlagSet(MAP_FOG_HIDE_TERRAIN) then
return
endif
set g = CreateGroup()
call GroupEnumUnitsOfPlayer(g, Player(PLAYER_NEUTRAL_PASSIVE), null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
set t = null
set id = GetUnitTypeId(u)
if false then
#INCLUDETABLE <NeutralIcon.txt> #EFR
elseif id == '%1' then
set t = "%2"
#ENDINCLUDE
endif
if t != null and GetUnitState(u, UNIT_STATE_LIFE) > 0 then
// try fix deviation
set xR = R2I((GetUnitX(u) - xCenter) / maxMinimapDist)
set yR = R2I((GetUnitY(u) - yCenter) / maxMinimapDist)
// set iconFrame[i] = BlzCreateFrameByType("BACKDROP", "Icon", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
// call BlzFrameSetSize(iconFrame[i], 0.0166, 0.0166)
// call BlzFrameSetAbsPoint(iconFrame[i], FRAMEPOINT_CENTER, 0.077 + 0.069 * xR, 0.074 + 0.069 * yR)
// call BlzFrameSetTexture(iconFrame[i], t, 0, true)
// call BlzFrameSetVisible(iconFrame[i], true)
// call BlzFrameSetEnable(iconFrame[i], false)
set x = GetUnitX(u) + 69 * xR - 74
set y = GetUnitY(u) + 69 * yR - 74
set miniicons[i] = CreateMinimapIcon(x, y, 255, 255, 255, t, FOG_OF_WAR_FOGGED)
set i = i + 1
endif
call GroupRemoveUnit(g, u)
endloop
set miniicons_length = i
call DestroyGroup(g)
set g = null
call W3CMiniMapIcons()
endfunction
function UpdateW3CClock takes nothing returns nothing
local string s = "Time: "
local integer timeHour = 0
local integer timeMin = 0
local integer timeSec = 0
set GameTimeSec = GameTimeSec + 1
if GameTimeSec >= 360000 then // 5999 minutes in seconds
set GameTimeSec = 359999 // Cap at 999:59:59
endif
set timeHour = GameTimeSec / 3600
set timeMin = (GameTimeSec - (timeHour * 3600)) / 60
set timeSec = GameTimeSec - (timeHour * 3600) - (timeMin * 60)
// set timeMin = GameTimeSec / 60
// set timeSec = GameTimeSec - (timeMin * 60)
if timeHour < 10 then
set s = s + "0"
endif
set s = s + I2S(timeHour) + " : "
if timeMin < 10 then
set s = s + "0"
endif
set s = s + I2S(timeMin) + " : "
if timeSec < 10 then
set s = s + "0"
endif
set s = s + I2S(timeSec)
call BlzFrameSetText(clock, s)
set s = null
endfunction
function SetW3CClock takes nothing returns nothing
if GetTriggerPlayer() != null then
if W3CClock == false then
set W3CClock = true
call DisplayTimedTextToForce(GetPlayersAll(), 7.00, "Game time clock |cff00ff00[on]|r")
else
set W3CClock = false
call DisplayTimedTextToForce(GetPlayersAll(), 7.00, "Game time clock |cfffd0000[off]|r")
endif
call BlzFrameSetVisible(clock, W3CClock)
endif
endfunction
function CreateW3CClock takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
if clock == null then
set clock = BlzCreateFrameByType("TEXT", "GameTime", BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0), "", 0)
call BlzFrameSetAbsPoint(clock, FRAMEPOINT_CENTER, 0.490, 0.561) //0.465, 0.563
call BlzFrameSetScale(clock, 1.2)
call BlzFrameSetText(clock, "Time: 00 : 00 : 00")
call BlzFrameSetTextColor(clock, BlzConvertColor(255, 205, 205, 50))
set ClockTimer = CreateTimer()
call TimerStart(ClockTimer, 1, true, function UpdateW3CClock)
endif
loop
exitwhen i >= GetBJMaxPlayers()
if GetPlayerController(Player(i)) != MAP_CONTROL_COMPUTER then
call BlzFrameSetVisible(clock, W3CClock)
call TriggerRegisterPlayerChatEvent(t, Player(i), "-clock", true)
endif
set i = i + 1
endloop
call TriggerAddAction(t, function SetW3CClock)
endfunction
#ELSE
function CreateW3CMiniMapIcons takes nothing returns nothing
// old war3 cannot use
endfunction
function UpdateW3CClock takes nothing returns nothing
set GameTimeSec = GameTimeSec + 0.5
call TimerDialogSetRealTimeRemaining(W3CTimerDialog,I2R(R2I(GameTimeSec)))
endfunction
function SetW3CClock takes nothing returns nothing
local player p = GetTriggerPlayer()
if p != null then
if W3CClock == false then
set W3CClock = true
call DisplayTimedTextToPlayer(p, 0, 0, 7.00, "Game time clock |cff00ff00[on]|r")
else
set W3CClock = false
call DisplayTimedTextToPlayer(p, 0, 0, 7.00, "Game time clock |cfffd0000[off]|r")
endif
call TimerDialogDisplayForPlayerBJ(W3CClock, W3CTimerDialog, p)
endif
set p = null
endfunction
function CreateW3CClockDialog takes nothing returns nothing
if W3CTimerDialog == null then
set W3CTimerDialog = CreateTimerDialogBJ( null, "Time: " )
call TimerDialogDisplayBJ(W3CClock, W3CTimerDialog)
call DestroyTimer(ClockTimerTemp)
set ClockTimerTemp = null
endif
endfunction
function CreateW3CClock takes nothing returns nothing
local trigger t = CreateTrigger()
local integer i = 0
if ClockTimer == null then
set ClockTimer = CreateTimer()
call TimerStart(ClockTimer, 0.5, true, function UpdateW3CClock)
set ClockTimerTemp = CreateTimer()
call TimerStart(ClockTimerTemp, 0.01, false, function CreateW3CClockDialog)
endif
loop
exitwhen i >= GetBJMaxPlayers()
if GetPlayerController(Player(i)) != MAP_CONTROL_COMPUTER then
call TriggerRegisterPlayerChatEvent(t, Player(i), "-clock", true)
endif
set i = i + 1
endloop
call TriggerAddAction(t, function SetW3CClock)
endfunction
#ENDIF
#UNDEF VER
#ENDIF