-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmenu-floating.inc
More file actions
388 lines (331 loc) · 13.2 KB
/
Copy pathmenu-floating.inc
File metadata and controls
388 lines (331 loc) · 13.2 KB
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
#if defined _INC_menu_floating
#endinput
#endif
#define _INC_menu_floating
#include <a_samp>
#if !defined MENU_FLOATING_MAX_LISTITEM
#define MENU_FLOATING_MAX_LISTITEM (10)
#endif
#if !defined _INC_open_mp
#if !defined TextDrawColour
#define TextDrawColour TextDrawColor
#endif
#if !defined TextDrawBackgroundColour
#define TextDrawBackgroundColour TextDrawBackgroundColor
#endif
#if !defined PlayerTextDrawColour
#define PlayerTextDrawColour PlayerTextDrawColor
#endif
#if !defined PlayerTextDrawBackgroundColour
#define PlayerTextDrawBackgroundColour PlayerTextDrawBackgroundColor
#endif
#if !defined TEXT_DRAW_ALIGN_CENTER
#define TEXT_DRAW_ALIGN_CENTER (2)
#endif
#if !defined TEXT_DRAW_FONT_SPRITE_DRAW
#define TEXT_DRAW_FONT_SPRITE_DRAW (4)
#endif
#endif
static
PlayerText:g_tdPlayerMenuFloatingHeader[MAX_PLAYERS][2],
PlayerText:g_tdPlayerMenuFloatingListItem[MAX_PLAYERS][MENU_FLOATING_MAX_LISTITEM][2];
new PlayerText:g_tdArrowRight[MAX_PLAYERS];
new PlayerText:g_tdArrowLeft[MAX_PLAYERS];
static
g_PlayerMenuFloatingID[MAX_PLAYERS] = { -1, ... },
g_PlayerMenuFloatingLength[MAX_PLAYERS];
forward OnPlayerMenuFloatingResponse(playerid, extraid, bool:response, listitem);
stock bool:IsPlayerViewingMenuFloating(playerid)
return (g_PlayerMenuFloatingID[playerid] != -1);
stock bool:ShowMenuFloatingForPlayer(playerid, extraid, const header[], header_colour, const list_items[][], list_length = sizeof list_items)
{
if (!IsPlayerConnected(playerid))
return false;
if (extraid < 0)
return false;
if (!list_length)
return false;
if (IsPlayerViewingMenuFloating(playerid))
_destroy_menufloating(playerid, true);
PlayerTextDrawShow(playerid, g_tdArrowRight[playerid]);
PlayerTextDrawShow(playerid, g_tdArrowLeft[playerid]);
PlayerTextDrawColour(playerid, g_tdPlayerMenuFloatingHeader[playerid][0], header_colour);
PlayerTextDrawShow(playerid, g_tdPlayerMenuFloatingHeader[playerid][0]);
PlayerTextDrawSetString(playerid, g_tdPlayerMenuFloatingHeader[playerid][1], _fix_text(header));
PlayerTextDrawShow(playerid, g_tdPlayerMenuFloatingHeader[playerid][1]);
if (list_length > MENU_FLOATING_MAX_LISTITEM)
list_length = MENU_FLOATING_MAX_LISTITEM;
g_PlayerMenuFloatingID[playerid] = extraid;
g_PlayerMenuFloatingLength[playerid] = list_length;
for (new i = 0; i < list_length; i++)
{
g_tdPlayerMenuFloatingListItem[playerid][i][0] = CreatePlayerTextDraw(playerid, 380.0, 175.0 + 26.0 * i, !"LD_SPAC:white");
PlayerTextDrawTextSize(playerid, g_tdPlayerMenuFloatingListItem[playerid][i][0], 100.0, 25.0);
PlayerTextDrawColour(playerid, g_tdPlayerMenuFloatingListItem[playerid][i][0], 255);
PlayerTextDrawFont(playerid, g_tdPlayerMenuFloatingListItem[playerid][i][0], TEXT_DRAW_FONT_SPRITE_DRAW);
PlayerTextDrawSetSelectable(playerid, g_tdPlayerMenuFloatingListItem[playerid][i][0], true);
PlayerTextDrawShow(playerid, g_tdPlayerMenuFloatingListItem[playerid][i][0]);
g_tdPlayerMenuFloatingListItem[playerid][i][1] = CreatePlayerTextDraw(playerid, 386.0, 182.0 + 26.0 * i, _fix_text(list_items[i]));
PlayerTextDrawLetterSize(playerid, g_tdPlayerMenuFloatingListItem[playerid][i][1], 0.22, 1.15);
PlayerTextDrawTextSize(playerid, g_tdPlayerMenuFloatingListItem[playerid][i][1], 473.0, 98.0);
PlayerTextDrawColour(playerid, g_tdPlayerMenuFloatingListItem[playerid][i][1], 0xE1E1E1FF);
PlayerTextDrawSetShadow(playerid, g_tdPlayerMenuFloatingListItem[playerid][i][1], 0);
PlayerTextDrawSetOutline(playerid, g_tdPlayerMenuFloatingListItem[playerid][i][1], 1);
PlayerTextDrawBackgroundColour(playerid, g_tdPlayerMenuFloatingListItem[playerid][i][1], 0);
PlayerTextDrawShow(playerid, g_tdPlayerMenuFloatingListItem[playerid][i][1]);
}
SelectTextDraw(playerid, 0x080808FF);
return true;
}
stock bool:HideMenuFloatingForPlayer(playerid)
{
if (_destroy_menufloating(playerid))
{
CancelSelectTextDraw(playerid);
return true;
}
return false;
}
static stock _destroy_menufloating(playerid, bool:call = false)
{
if (!IsPlayerViewingMenuFloating(playerid))
return 0;
PlayerTextDrawHide(playerid, g_tdArrowRight[playerid]);
PlayerTextDrawHide(playerid, g_tdArrowLeft[playerid]);
PlayerTextDrawHide(playerid, g_tdPlayerMenuFloatingHeader[playerid][0]);
PlayerTextDrawHide(playerid, g_tdPlayerMenuFloatingHeader[playerid][1]);
for (new j = 0; j < g_PlayerMenuFloatingLength[playerid]; j++)
{
PlayerTextDrawDestroy(playerid, g_tdPlayerMenuFloatingListItem[playerid][j][0]);
PlayerTextDrawDestroy(playerid, g_tdPlayerMenuFloatingListItem[playerid][j][1]);
}
if (call)
{
CallLocalFunction("OnPlayerMenuFloatingResponse", "iiii", playerid, g_PlayerMenuFloatingID[playerid], false, -1);
}
g_PlayerMenuFloatingID[playerid] = -1;
g_PlayerMenuFloatingLength[playerid] = 0;
return 1;
}
static stock _fix_text(const string[])
{
new
text[128];
for (new i = 0; i < strlen(string); i++)
{
text[i] = string[i];
switch (text[i])
{
case 0xC0 .. 0xC3: text[i] -= 0x40;
case 0xC7 .. 0xC9: text[i] -= 0x42;
case 0xD2 .. 0xD5: text[i] -= 0x44;
case 0xD9 .. 0xDC: text[i] -= 0x47;
case 0xE0 .. 0xE3: text[i] -= 0x49;
case 0xE7 .. 0xEF: text[i] -= 0x4B;
case 0xF2 .. 0xF5: text[i] -= 0x4D;
case 0xF9 .. 0xFC: text[i] -= 0x50;
case 0xC4, 0xE4: text[i] = 0x83;
case 0xC6, 0xE6: text[i] = 0x84;
case 0xD6, 0xF6: text[i] = 0x91;
case 0xD1, 0xF1: text[i] = 0xEC;
case 0xDF: text[i] = 0x96;
case 0xBF: text[i] = 0xAF;
}
}
return text;
}
static _MenuFloating_OnPlayerConnect(playerid)
{
g_PlayerMenuFloatingID[playerid] = -1;
g_PlayerMenuFloatingLength[playerid] = 0;
g_tdPlayerMenuFloatingHeader[playerid][0] = CreatePlayerTextDraw(playerid, 380.0, 148.0, !"LD_SPAC:white");
PlayerTextDrawTextSize(playerid, g_tdPlayerMenuFloatingHeader[playerid][0], 100.0, 26.0);
PlayerTextDrawFont(playerid, g_tdPlayerMenuFloatingHeader[playerid][0], TEXT_DRAW_FONT_SPRITE_DRAW);
g_tdPlayerMenuFloatingHeader[playerid][1] = CreatePlayerTextDraw(playerid, 430.0, 156.0, #);
PlayerTextDrawLetterSize(playerid, g_tdPlayerMenuFloatingHeader[playerid][1], 0.22, 1.15);
PlayerTextDrawTextSize(playerid, g_tdPlayerMenuFloatingHeader[playerid][1], 24.0, 98.0);
PlayerTextDrawAlignment(playerid, g_tdPlayerMenuFloatingHeader[playerid][1], TEXT_DRAW_ALIGN_CENTER);
PlayerTextDrawColour(playerid, g_tdPlayerMenuFloatingHeader[playerid][1], 0xE1E1E1FF);
PlayerTextDrawSetShadow(playerid, g_tdPlayerMenuFloatingHeader[playerid][1], 0);
PlayerTextDrawSetOutline(playerid, g_tdPlayerMenuFloatingHeader[playerid][1], 1);
PlayerTextDrawBackgroundColour(playerid, g_tdPlayerMenuFloatingHeader[playerid][1], 0);
// Flecha derecha '>'
g_tdArrowRight[playerid] = CreatePlayerTextDraw(playerid, 467.0, 155.0, ">");
PlayerTextDrawLetterSize(playerid, g_tdArrowRight[playerid], 0.23, 1.4);
PlayerTextDrawColour(playerid, g_tdArrowRight[playerid], 0xE1E1E1FF);
PlayerTextDrawSetShadow(playerid, g_tdArrowRight[playerid], 0);
PlayerTextDrawSetOutline(playerid, g_tdArrowRight[playerid], 1);
PlayerTextDrawBackgroundColour(playerid, g_tdArrowRight[playerid], 0);
// Flecha izquierda '<'
g_tdArrowLeft[playerid] = CreatePlayerTextDraw(playerid, 387.0, 155.0, "<");
PlayerTextDrawLetterSize(playerid, g_tdArrowLeft[playerid], 0.23, 1.4);
PlayerTextDrawColour(playerid, g_tdArrowLeft[playerid], 0xE1E1E1FF);
PlayerTextDrawSetShadow(playerid, g_tdArrowLeft[playerid], 0);
PlayerTextDrawSetOutline(playerid, g_tdArrowLeft[playerid], 1);
PlayerTextDrawBackgroundColour(playerid, g_tdArrowLeft[playerid], 0);
return 1;
}
public OnPlayerClickTextDraw(playerid, Text:clickedid)
{
if (IsPlayerViewingMenuFloating(playerid))
{
if (clickedid == Text:INVALID_TEXT_DRAW)
{
CallLocalFunction("OnPlayerMenuFloatingResponse", "iiii", playerid, g_PlayerMenuFloatingID[playerid], false, -1);
HideMenuFloatingForPlayer(playerid);
}
}
#if defined mf_OnPlayerClickTextDraw
return mf_OnPlayerClickTextDraw(playerid, Text:clickedid);
#else
return 1;
#endif
}
#if defined _ALS_OnPlayerClickTextDraw
#undef OnPlayerClickTextDraw
#else
#define _ALS_OnPlayerClickTextDraw
#endif
#define OnPlayerClickTextDraw mf_OnPlayerClickTextDraw
#if defined mf_OnPlayerClickTextDraw
forward mf_OnPlayerClickTextDraw(playerid, Text:clickedid);
#endif
public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid)
{
if (IsPlayerViewingMenuFloating(playerid))
{
for (new i = 0; i < g_PlayerMenuFloatingLength[playerid]; i++)
{
if (playertextid == g_tdPlayerMenuFloatingListItem[playerid][i][0])
{
CallLocalFunction("OnPlayerMenuFloatingResponse", "iiii", playerid, g_PlayerMenuFloatingID[playerid], true, i);
break;
}
}
}
#if defined mf_OnPlayerClickPlayerTextDraw
return mf_OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid);
#else
return 1;
#endif
}
#if defined _ALS_OnClickPTD
#undef OnPlayerClickPlayerTextDraw
#else
#define _ALS_OnClickPTD
#endif
#define OnPlayerClickPlayerTextDraw mf_OnPlayerClickPlayerTextDraw
#if defined mf_OnPlayerClickPlayerTextDraw
forward mf_OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid);
#endif
public OnPlayerConnect(playerid)
{
_MenuFloating_OnPlayerConnect(playerid);
#if defined mf_OnPlayerConnect
return mf_OnPlayerConnect(playerid);
#else
return 1;
#endif
}
#if defined _ALS_OnPlayerConnect
#undef OnPlayerConnect
#else
#define _ALS_OnPlayerConnect
#endif
#define OnPlayerConnect mf_OnPlayerConnect
#if defined mf_OnPlayerConnect
forward mf_OnPlayerConnect(playerid);
#endif
public OnPlayerDeath(playerid, killerid)
{
if (_destroy_menufloating(playerid, true))
{
CancelSelectTextDraw(playerid);
}
#if defined mf_OnPlayerDeath
return mf_OnPlayerDeath(playerid, killerid);
#else
return 1;
#endif
}
#if defined _ALS_OnPlayerDeath
#undef OnPlayerDeath
#else
#define _ALS_OnPlayerDeath
#endif
#define OnPlayerDeath mf_OnPlayerDeath
#if defined mf_OnPlayerDeath
forward mf_OnPlayerDeath(playerid, killerid);
#endif
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
for (new playerid; playerid < MAX_PLAYERS; playerid++)
{
if (IsPlayerConnected(playerid))
_MenuFloating_OnPlayerConnect(playerid);
}
#if defined mf_OnFilterScriptInit
return mf_OnFilterScriptInit();
#else
return 1;
#endif
}
#if defined _ALS_OnFilterScriptInit
#undef OnFilterScriptInit
#else
#define _ALS_OnFilterScriptInit
#endif
#define OnFilterScriptInit mf_OnFilterScriptInit
#if defined mf_OnFilterScriptInit
forward mf_OnFilterScriptInit();
#endif
public OnFilterScriptExit()
{
for (new playerid, j = 0; playerid < MAX_PLAYERS; playerid++)
{
if (IsPlayerConnected(playerid))
{
PlayerTextDrawDestroy(playerid, g_tdPlayerMenuFloatingHeader[playerid][0]);
PlayerTextDrawDestroy(playerid, g_tdPlayerMenuFloatingHeader[playerid][1]);
for (j = 0; j < g_PlayerMenuFloatingLength[playerid]; j++)
{
PlayerTextDrawDestroy(playerid, g_tdPlayerMenuFloatingListItem[playerid][j][0]);
PlayerTextDrawDestroy(playerid, g_tdPlayerMenuFloatingListItem[playerid][j][1]);
}
}
}
#if defined mf_OnFilterScriptExit
return mf_OnFilterScriptExit();
#else
return 1;
#endif
}
#if defined _ALS_OnFilterScriptExit
#undef OnFilterScriptExit
#else
#define _ALS_OnFilterScriptExit
#endif
#define OnFilterScriptExit mf_OnFilterScriptExit
#if defined mf_OnFilterScriptExit
forward mf_OnFilterScriptExit();
#endif
#else
public OnGameModeInit()
{
#if defined mf_OnGameModeInit
return mf_OnGameModeInit();
#else
return 1;
#endif
}
#if defined _ALS_OnGameModeInit
#undef OnGameModeInit
#else
#define _ALS_OnGameModeInit
#endif
#define OnGameModeInit mf_OnGameModeInit
#if defined mf_OnGameModeInit
forward mf_OnGameModeInit();
#endif
#endif