-
Notifications
You must be signed in to change notification settings - Fork 64
/
Copy patheditor-pottus.pwn
1132 lines (1036 loc) · 40.8 KB
/
editor-pottus.pwn
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
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#define FILTERSCRIPT
#include <a_samp>
#include <sscanf2>
#include <YSI\y_iterate>
#include <YSI\y_inline>
#include <YSI\y_dialog>
#include <YSI\y_commands>
#include <progress2>
#include <filemanager>
#define STEALTH_GREEN 0x33DD1100
#define STEALTH_ORANGE 0xFF880000
#define STEALTH_YELLOW 0xFFFF00AA
#define MAX_PB_EDIT (10)
#define EDIT_STATE_NONE (0)
#define EDIT_STATE_OPEN (1)
#define EDIT_MODE_NONE (0)
#define EDIT_MODE_MOVEBAR (1)
#define DB_SAVE_TYPE_POS (0)
#define DB_SAVE_TYPE_WIDTH (1)
#define DB_SAVE_TYPE_HEIGHT (2)
#define DB_SAVE_TYPE_COLOR (3)
#define DB_SAVE_TYPE_MAX (4)
#define DB_SAVE_TYPE_BARVALUE (5)
#define DB_SAVE_TYPE_DIRECTION (6)
#define RGBA(%0,%1,%2,%3) ((((%0) & 0xFF) << 24) | (((%1) & 0xFF) << 16) | (((%2) & 0xFF) << 8) | (((%3) & 0xFF) << 0))
static PlayerBar:EditBars[MAX_PLAYERS][MAX_PB_EDIT];
static EditState[MAX_PLAYERS];
static EditMode[MAX_PLAYERS];
static CurrEditIndex[MAX_PLAYERS];
static DB:ProjectDB[MAX_PLAYERS];
static msgline[144];
static Float:SavedXY[MAX_PLAYERS][2];
static const DirectionNames[4][] = {
"Right",
"Left",
"Up",
"Down"
};
static const DirectionEnumNames[4][] = {
"BAR_DIRECTION_RIGHT",
"BAR_DIRECTION_LEFT",
"BAR_DIRECTION_UP",
"BAR_DIRECTION_DOWN"
};
static webcolors[4096];
static WebColorsRGBA[216] = {
0x000000FF,0x000033FF,0x000066FF,0x000099FF,0x0000CCFF,0x0000FFFF,
0x003300FF,0x003333FF,0x003366FF,0x003399FF,0x0033CCFF,0x0033FFFF,
0x006600FF,0x006633FF,0x006666FF,0x006699FF,0x0066CCFF,0x0066FFFF,
0x009900FF,0x009933FF,0x009966FF,0x009999FF,0x0099CCFF,0x0099FFFF,
0x00CC00FF,0x00CC33FF,0x00CC66FF,0x00CC99FF,0x00CCCCFF,0x00CCFFFF,
0x00FF00FF,0x00FF33FF,0x00FF66FF,0x00FF99FF,0x00FFCCFF,0x00FFFFFF,
0x330000FF,0x330033FF,0x330066FF,0x330099FF,0x3300CCFF,0x3300FFFF,
0x333300FF,0x333333FF,0x333366FF,0x333399FF,0x3333CCFF,0x3333FFFF,
0x336600FF,0x336633FF,0x336666FF,0x336699FF,0x3366CCFF,0x3366FFFF,
0x339900FF,0x339933FF,0x339966FF,0x339999FF,0x3399CCFF,0x3399FFFF,
0x33CC00FF,0x33CC33FF,0x33CC66FF,0x33CC99FF,0x33CCCCFF,0x33CCFFFF,
0x33FF00FF,0x33FF33FF,0x33FF66FF,0x33FF99FF,0x33FFCCFF,0x33FFFFFF,
0x660000FF,0x660033FF,0x660066FF,0x660099FF,0x6600CCFF,0x6600FFFF,
0x663300FF,0x663333FF,0x663366FF,0x663399FF,0x6633CCFF,0x6633FFFF,
0x666600FF,0x666633FF,0x666666FF,0x666699FF,0x6666CCFF,0x6666FFFF,
0x669900FF,0x669933FF,0x669966FF,0x669999FF,0x6699CCFF,0x6699FFFF,
0x66CC00FF,0x66CC33FF,0x66CC66FF,0x66CC99FF,0x66CCCCFF,0x66CCFFFF,
0x66FF00FF,0x66FF33FF,0x66FF66FF,0x66FF99FF,0x66FFCCFF,0x66FFFFFF,
0x990000FF,0x990033FF,0x990066FF,0x990099FF,0x9900CCFF,0x9900FFFF,
0x993300FF,0x993333FF,0x993366FF,0x993399FF,0x9933CCFF,0x9933FFFF,
0x996600FF,0x996633FF,0x996666FF,0x996699FF,0x9966CCFF,0x9966FFFF,
0x999900FF,0x999933FF,0x999966FF,0x999999FF,0x9999CCFF,0x9999FFFF,
0x99CC00FF,0x99CC33FF,0x99CC66FF,0x99CC99FF,0x99CCCCFF,0x99CCFFFF,
0x99FF00FF,0x99FF33FF,0x99FF66FF,0x99FF99FF,0x99FFCCFF,0x99FFFFFF,
0xCC0000FF,0xCC0033FF,0xCC0066FF,0xCC0099FF,0xCC00CCFF,0xCC00FFFF,
0xCC3300FF,0xCC3333FF,0xCC3366FF,0xCC3399FF,0xCC33CCFF,0xCC33FFFF,
0xCC6600FF,0xCC6633FF,0xCC6666FF,0xCC6699FF,0xCC66CCFF,0xCC66FFFF,
0xCC9900FF,0xCC9933FF,0xCC9966FF,0xCC9999FF,0xCC99CCFF,0xCC99FFFF,
0xCCCC00FF,0xCCCC33FF,0xCCCC66FF,0xCCCC99FF,0xCCCCCCFF,0xCCCCFFFF,
0xCCFF00FF,0xCCFF33FF,0xCCFF66FF,0xCCFF99FF,0xCCFFCCFF,0xCCFFFFFF,
0xFF0000FF,0xFF0033FF,0xFF0066FF,0xFF0099FF,0xFF00CCFF,0xFF00FFFF,
0xFF3300FF,0xFF3333FF,0xFF3366FF,0xFF3399FF,0xFF33CCFF,0xFF33FFFF,
0xFF6600FF,0xFF6633FF,0xFF6666FF,0xFF6699FF,0xFF66CCFF,0xFF66FFFF,
0xFF9900FF,0xFF9933FF,0xFF9966FF,0xFF9999FF,0xFF99CCFF,0xFF99FFFF,
0xFFCC00FF,0xFFCC33FF,0xFFCC66FF,0xFFCC99FF,0xFFCCCCFF,0xFFCCFFFF,
0xFFFF00FF,0xFFFF33FF,0xFFFF66FF,0xFFFF99FF,0xFFFFCCFF,0xFFFFFFFF
};
public OnFilterScriptInit()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
CurrEditIndex[i] = -1;
for(new j = 0; j < MAX_PB_EDIT; j++) EditBars[i][j] = INVALID_PLAYER_BAR_ID;
}
for(new i = 0; i < 216; i++) format(webcolors, sizeof(webcolors), "%s{%06x}00000000\n", webcolors, WebColorsRGBA[i] >>> 8);
return 1;
}
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid, STEALTH_ORANGE, "Type /pbedit to start editing progress bars!");
return 1;
}
public OnFilterScriptExit()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
CleanupPlayer(i);
}
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
CleanupPlayer(playerid);
return 1;
}
CMD:pbedit(playerid, arg[])
{
if(EditMode[playerid] == EDIT_MODE_MOVEBAR) return SendClientMessage(playerid, STEALTH_YELLOW, "Please finish editing before using any commands");
ProgressProjectEdit(playerid);
return 1;
}
static ProgressProjectEdit(playerid)
{
switch(EditState[playerid])
{
// No progject is open
case EDIT_STATE_NONE:
{
inline PBNewLoadMenu(pid, dialogid, response, listitem, string:text[])
{
#pragma unused listitem, dialogid, pid, text
if(response)
{
if(listitem == 0) CreateNewProject(playerid);
// Open Existing project
else if(listitem == 1)
{
new dir:dHandle = dir_open("./scriptfiles/pbedit/");
new item[40], type;
new line[1024];
new extension[3];
new fcount;
// Create a load list
while(dir_list(dHandle, item, type))
{
if(type != FM_DIR)
{
// We need to check extension
if(strlen(item) > 3)
{
format(extension, sizeof(extension), "%s%s", item[strlen(item) - 2],item[strlen(item) - 1]);
// File is apparently a db
if(!strcmp(extension, "db"))
{
format(line, sizeof(line), "%s\n%s", item, line);
fcount++;
}
}
}
}
// Files were found
if(fcount > 0)
{
inline Select(spid, sdialogid, sresponse, slistitem, string:stext[])
{
#pragma unused slistitem, sdialogid, spid, stext
// Player selected project to load
if(sresponse)
{
if(LoadProject(playerid, stext))
{
EditState[playerid] = EDIT_STATE_OPEN;
EditMode[playerid] = EDIT_MODE_NONE;
SendClientMessage(playerid, STEALTH_GREEN, "Project has been loaded");
for(new i = 0; i < MAX_PB_EDIT; i++)
{
if(EditBars[playerid][i] != INVALID_PLAYER_BAR_ID)
{
CurrEditIndex[playerid] = i;
break;
}
}
ProgressProjectEdit(playerid);
}
}
}
Dialog_ShowCallback(playerid, using inline Select, DIALOG_STYLE_LIST, "Progress Bar Editor", line, "Ok", "Cancel");
}
// No files found
else
{
inline CreateProject(cpid, cdialogid, cresponse, clistitem, string:ctext[])
{
#pragma unused clistitem, cdialogid, cpid, ctext
if(cresponse) CreateNewProject(playerid);
else ProgressProjectEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline CreateProject, DIALOG_STYLE_MSGBOX, "Progress Bar Editor", "There are no projects to load create a new project?", "Ok", "Cancel");
}
return 1;
}
}
}
Dialog_ShowCallback(playerid, using inline PBNewLoadMenu, DIALOG_STYLE_LIST, "Progress Bar Editor", "New\nLoad", "Ok", "Cancel");
}
// Project is open
case EDIT_STATE_OPEN:
{
inline PBEditMenu(pid, dialogid, response, listitem, string:text[])
{
#pragma unused listitem, dialogid, pid, text
if(response)
{
switch(listitem)
{
// Create a new progress bar edit
case 0:
{
new index = CreateProgressBarEdit(playerid);
if(index > -1)
{
CurrEditIndex[playerid] = index;
format(msgline, sizeof(msgline), "A new progress bar has been created Index: %i", index);
SendClientMessage(playerid, STEALTH_GREEN, msgline);
ProgressProjectEdit(playerid);
}
else
{
SendClientMessage(playerid, STEALTH_YELLOW, "Too many progress bars created!");
ProgressProjectEdit(playerid);
}
}
// Select a progress bar
case 1:
{
inline PBSelect(spid, sdialogid, sresponse, slistitem, string:stext[])
{
#pragma unused slistitem, sdialogid, spid, stext
if(sresponse)
{
sscanf(stext, "s[144]i", msgline, CurrEditIndex[playerid]);
format(msgline, sizeof(msgline), "You have selected progress bar index %i for editing", CurrEditIndex[playerid]);
SendClientMessage(playerid, STEALTH_GREEN, msgline);
}
ProgressProjectEdit(playerid);
}
new line[256];
for(new i = 0; i < MAX_PB_EDIT; i++)
{
if(EditBars[playerid][i] != INVALID_PLAYER_BAR_ID) format(line, sizeof(line), "%sIndex: %i\n", line, i);
}
Dialog_ShowCallback(playerid, using inline PBSelect, DIALOG_STYLE_LIST, "Progress Bar Editor", line, "Ok", "Cancel");
}
// Edit progress bar
case 2:
{
if(CurrEditIndex[playerid] == -1)
{
SendClientMessage(playerid, STEALTH_YELLOW, "You must have a bar selected to use this feature!");
ProgressProjectEdit(playerid);
}
else ProgressProjectPropEdit(playerid);
}
// Delete a progress bar
case 3:
{
inline PBDelete(spid, sdialogid, sresponse, slistitem, string:stext[])
{
#pragma unused slistitem, sdialogid, spid, stext
if(sresponse)
{
sscanf(stext, "s[144]i", msgline, CurrEditIndex[playerid]);
format(msgline, sizeof(msgline), "You have deleted progress bar index %i for editing", CurrEditIndex[playerid]);
SendClientMessage(playerid, STEALTH_GREEN, msgline);
new q[128];
format(q, sizeof(q), "DELETE FROM `ProgressBars` WHERE `IndexID` = %i", CurrEditIndex[playerid]);
db_query(ProjectDB[playerid], q);
DestroyPlayerProgressBar(playerid, EditBars[playerid][CurrEditIndex[playerid]]);
EditBars[playerid][CurrEditIndex[playerid]] = INVALID_PLAYER_BAR_ID;
CurrEditIndex[playerid] = -1;
ProgressProjectEdit(playerid);
}
else ProgressProjectEdit(playerid);
}
new line[256];
for(new i = 0; i < MAX_PB_EDIT; i++)
{
if(EditBars[playerid][i] != INVALID_PLAYER_BAR_ID) format(line, sizeof(line), "%sIndex: %i\n", line, i);
}
Dialog_ShowCallback(playerid, using inline PBDelete, DIALOG_STYLE_LIST, "Progress Bar Editor", line, "Ok", "Cancel");
}
// Export project
case 4:
{
new exportproj[64];
// Ask for a map name
inline ExportProject(epid, edialogid, eresponse, elistitem, string:etext[])
{
#pragma unused elistitem, edialogid, epid
if(eresponse)
{
// Was a project name supplied ?
if(!isnull(etext))
{
// Check map name length
if(strlen(etext) >= 20)
{
SendClientMessage(playerid, STEALTH_YELLOW, "Choose a shorter project name to export to...");
return 1;
}
// Format the output name
format(exportproj, sizeof(exportproj), "pbedit/%s.txt", etext);
// Project exists ask to remove
if(fexist(exportproj))
{
inline RemoveProject(rpid, rdialogid, rresponse, rlistitem, string:rtext[])
{
#pragma unused rlistitem, rdialogid, rpid, rtext
// Remove map and export
if(rresponse)
{
fremove(exportproj);
ProjectExport(playerid, exportproj);
}
else ProgressProjectEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline RemoveProject, DIALOG_STYLE_MSGBOX, "Progress Bar Editor", "A export exists with this name replace?", "Ok", "Cancel");
}
// We can start the export
else ProjectExport(playerid, exportproj);
}
else
{
SendClientMessage(playerid, STEALTH_YELLOW, "You can't export a project with no name");
Dialog_ShowCallback(playerid, using inline ExportProject, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a export project name", "Ok", "Cancel");
}
}
else ProgressProjectEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline ExportProject, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a export project name", "Ok", "Cancel");
}
// Close project
case 5:
{
CleanupPlayer(playerid);
SendClientMessage(playerid, STEALTH_GREEN, "Your project has been closed!");
}
}
}
}
Dialog_ShowCallback(playerid, using inline PBEditMenu, DIALOG_STYLE_LIST, "Progress Bar Editor", "Create Progress Bar\nSelect Progress Bar\nEdit Progress Bar\nDelete Progress Bar\nExport Progress Bar\nClose Project", "Ok", "Cancel");
}
}
return 1;
}
static ProjectExport(playerid, filename[])
{
new File:f = fopen(filename, io_write);
new templine[256], Float:x, Float:y, count;
for(new i = 0; i < MAX_PB_EDIT; i++)
{
if(EditBars[playerid][i] != INVALID_PLAYER_BAR_ID)
{
GetPlayerProgressBarPos(playerid, EditBars[playerid][i], x, y);
format(templine, sizeof(templine), "PlayerBar_%i[playerid] = CreatePlayerProgressBar(playerid, %f, %f, %f, %f, %i, %f, %s);\r\n",
count,
x,
y,
GetPlayerProgressBarWidth(playerid, EditBars[playerid][i]),
GetPlayerProgressBarHeight(playerid, EditBars[playerid][i]),
GetPlayerProgressBarColour(playerid, EditBars[playerid][i]),
GetPlayerProgressBarMaxValue(playerid, EditBars[playerid][i]),
DirectionEnumNames[GetPlayerProgressBarDirection(playerid, EditBars[playerid][CurrEditIndex[playerid]])]
);
fwrite(f, templine);
if(GetPlayerProgressBarValue(playerid, EditBars[playerid][i]) > 0.0)
{
format(templine, sizeof(templine), "PlayerBar_%i[playerid] = SetPlayerProgressBarValue(playerid, %f);\r\n",
GetPlayerProgressBarValue(playerid, EditBars[playerid][i]));
fwrite(f, templine);
}
count++;
}
}
fclose(f);
if(count) SendClientMessage(playerid, STEALTH_GREEN, "Project exported!");
return 1;
}
static LoadProject(playerid, filename[])
{
new file[64];
format(file, sizeof(file), "pbedit/%s", filename);
ProjectDB[playerid] = db_open(file);
new DBResult:r = db_query(ProjectDB[playerid], "SELECT * FROM `ProgressBars`");
if(db_num_rows(r))
{
new Field[32], index, Float:x, Float:y, Float:w, Float:h, color, Float:bmax, Float:pbv, direction;
for(new i = 0; i < db_num_rows(r); i++)
{
db_get_field_assoc(r, "IndexID", Field, 32);
index = strval(Field);
db_get_field_assoc(r, "BarX", Field, 32);
x = floatstr(Field);
db_get_field_assoc(r, "BarY", Field, 32);
y = floatstr(Field);
db_get_field_assoc(r, "BarWidth", Field, 32);
w = floatstr(Field);
db_get_field_assoc(r, "BarHeight", Field, 32);
h = floatstr(Field);
db_get_field_assoc(r, "BarColor", Field, 32);
color = strval(Field);
db_get_field_assoc(r, "BarMaxValue", Field, 32);
bmax = floatstr(Field);
db_get_field_assoc(r, "BarProgressValue", Field, 32);
pbv = floatstr(Field);
db_get_field_assoc(r, "BarDirection", Field, 32);
direction = strval(Field);
EditBars[playerid][index] = CreatePlayerProgressBar(playerid, x, y, w, h, color, bmax, direction);
ShowPlayerProgressBar(playerid, EditBars[playerid][index]);
SetPlayerProgressBarValue(playerid, EditBars[playerid][index], pbv);
db_next_row(r);
}
db_free_result(r);
}
else
{
SendClientMessage(playerid, STEALTH_YELLOW, "There was no progress bars to load please make a new project");
db_free_result(r);
db_close(ProjectDB[playerid]);
return 0;
}
return 1;
}
static CreateNewProject(playerid)
{
inline PBNewProject(npid, ndialogid, nresponse, nlistitem, string:ntext[])
{
#pragma unused nlistitem, ndialogid, npid, ntext
if(nresponse)
{
if(!isnull(ntext))
{
new fname[64];
format(fname, sizeof(fname), "pbedit/%s.db", ntext);
if(fexist(fname))
{
inline PBOverWrite(opid, odialogid, oresponse, olistitem, string:otext[])
{
#pragma unused olistitem, odialogid, opid, otext
if(oresponse)
{
fremove(fname);
CreateProgressBarProject(playerid, fname);
SendClientMessage(playerid, STEALTH_GREEN, "You have created a new project!");
ProgressProjectEdit(playerid);
}
else ProgressProjectEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline PBOverWrite, DIALOG_STYLE_MSGBOX, "Progress Bar Editor", "Overwrite?", "Ok", "Cancel");
}
else
{
printf("New project");
CreateProgressBarProject(playerid, fname);
ProgressProjectEdit(playerid);
SendClientMessage(playerid, STEALTH_GREEN, "You have created a new project!");
}
}
else
{
SendClientMessage(playerid, STEALTH_YELLOW, "You need to supply a filename to save to!");
Dialog_ShowCallback(playerid, using inline PBNewProject, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a filename for your project", "Ok", "Cancel");
}
}
else ProgressProjectEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline PBNewProject, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a filename for your project", "Ok", "Cancel");
return 1;
}
static ProgressProjectPropEdit(playerid)
{
new Float:x, Float:y;
inline PBPropEditMenu(pid, dialogid, response, listitem, string:text[])
{
#pragma unused listitem, dialogid, pid, text
if(response)
{
switch(listitem)
{
// Set X-Position
case 0:
{
inline SetXPos(spid, sdialogid, sresponse, slistitem, string:stext[])
{
#pragma unused slistitem, sdialogid, spid, stext
if(sresponse)
{
if(!isnull(stext))
{
new Float:pos;
if(sscanf(stext, "f", pos))
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must be a float!");
Dialog_ShowCallback(playerid, using inline SetXPos, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new X Value", "Ok", "Back");
}
else if(pos < 0.0)
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must not be negative!");
Dialog_ShowCallback(playerid, using inline SetXPos, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new X Value", "Ok", "Back");
}
else if(pos > 640.0)
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must be less than 640.0!");
Dialog_ShowCallback(playerid, using inline SetXPos, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new X Value", "Ok", "Back");
}
else
{
GetPlayerProgressBarPos(playerid, EditBars[playerid][CurrEditIndex[playerid]], x, y);
SetPlayerProgressBarPos(playerid, EditBars[playerid][CurrEditIndex[playerid]], pos, y);
SendClientMessage(playerid, STEALTH_GREEN, "X Position has been updated");
UpdateDB(playerid, CurrEditIndex[playerid], DB_SAVE_TYPE_POS);
ProgressProjectPropEdit(playerid);
}
}
else ProgressProjectPropEdit(playerid);
}
else ProgressProjectPropEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline SetXPos, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new X Value", "Ok", "Back");
}
// Set Y Pos
case 1:
{
inline SetYPos(spid, sdialogid, sresponse, slistitem, string:stext[])
{
#pragma unused slistitem, sdialogid, spid, stext
if(sresponse)
{
if(!isnull(stext))
{
new Float:pos;
if(sscanf(stext, "f", pos))
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must be a float!");
Dialog_ShowCallback(playerid, using inline SetYPos, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new Y Value", "Ok", "Back");
}
else if(pos < 0.0)
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must not be negative!");
Dialog_ShowCallback(playerid, using inline SetYPos, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new Y Value", "Ok", "Back");
}
else if(pos > 480.0)
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must be less than 480.0!");
Dialog_ShowCallback(playerid, using inline SetYPos, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new Y Value", "Ok", "Back");
}
else
{
GetPlayerProgressBarPos(playerid, EditBars[playerid][CurrEditIndex[playerid]], x, y);
SetPlayerProgressBarPos(playerid, EditBars[playerid][CurrEditIndex[playerid]], x, pos);
SendClientMessage(playerid, STEALTH_GREEN, "Y Position has been updated");
UpdateDB(playerid, CurrEditIndex[playerid], DB_SAVE_TYPE_POS);
ProgressProjectPropEdit(playerid);
}
}
else ProgressProjectPropEdit(playerid);
}
else ProgressProjectPropEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline SetYPos, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new Y Value", "Ok", "Back");
}
// Set width
case 2:
{
inline SetWidth(spid, sdialogid, sresponse, slistitem, string:stext[])
{
#pragma unused slistitem, sdialogid, spid, stext
if(sresponse)
{
if(!isnull(stext))
{
new Float:width;
if(sscanf(stext, "f", width))
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must be a float!");
Dialog_ShowCallback(playerid, using inline SetWidth, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new width Value", "Ok", "Back");
}
else if(width < 0.0)
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must not be negative!");
Dialog_ShowCallback(playerid, using inline SetWidth, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new width Value", "Ok", "Back");
}
else if(width > 640.0)
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must be less than 640.0!");
Dialog_ShowCallback(playerid, using inline SetWidth, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new width Value", "Ok", "Back");
}
else
{
SetPlayerProgressBarWidth(playerid, EditBars[playerid][CurrEditIndex[playerid]], width);
SendClientMessage(playerid, STEALTH_GREEN, "Width has been updated");
UpdateDB(playerid, CurrEditIndex[playerid], DB_SAVE_TYPE_WIDTH);
ProgressProjectPropEdit(playerid);
}
}
else ProgressProjectPropEdit(playerid);
}
else ProgressProjectPropEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline SetWidth, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new width Value", "Ok", "Back");
}
// Set height
case 3:
{
inline SetHeight(spid, sdialogid, sresponse, slistitem, string:stext[])
{
#pragma unused slistitem, sdialogid, spid, stext
if(sresponse)
{
if(!isnull(stext))
{
new Float:height;
if(sscanf(stext, "f", height))
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must be a float!");
Dialog_ShowCallback(playerid, using inline SetHeight, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new height Value", "Ok", "Back");
}
else if(height < 0.0)
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must not be negative!");
Dialog_ShowCallback(playerid, using inline SetHeight, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new height Value", "Ok", "Back");
}
else if(height > 640.0)
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must be less than 640.0!");
Dialog_ShowCallback(playerid, using inline SetHeight, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new height Value", "Ok", "Back");
}
else
{
SetPlayerProgressBarHeight(playerid, EditBars[playerid][CurrEditIndex[playerid]], height);
SendClientMessage(playerid, STEALTH_GREEN, "Height has been updated");
UpdateDB(playerid, CurrEditIndex[playerid], DB_SAVE_TYPE_HEIGHT);
ProgressProjectPropEdit(playerid);
}
}
else ProgressProjectPropEdit(playerid);
}
else ProgressProjectPropEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline SetHeight, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new height Value", "Ok", "Back");
}
// Set Color
case 4:
{
inline SelectColorMet(spid, sdialogid, sresponse, slistitem, string:stext[])
{
#pragma unused slistitem, sdialogid, spid, stext
if(sresponse)
{
switch(slistitem)
{
case 0:
{
inline SelectHexColor(hpid, hdialogid, hresponse, hlistitem, string:htext[])
{
#pragma unused hlistitem, hdialogid, hpid, htext
if(hresponse)
{
new hex;
if(sscanf(htext, "x", hex))
{
SendClientMessage(playerid, STEALTH_YELLOW, "Invalid hex value!");
ProgressProjectPropEdit(playerid);
}
else
{
SetPlayerProgressBarColour(playerid, EditBars[playerid][CurrEditIndex[playerid]], hex);
SendClientMessage(playerid, STEALTH_GREEN, "Color has been updated");
UpdateDB(playerid, CurrEditIndex[playerid], DB_SAVE_TYPE_COLOR);
ProgressProjectPropEdit(playerid);
}
}
else ProgressProjectPropEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline SelectHexColor, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Hex color ( 0x00000000 ) ARGB", "Ok", "Cancel");
}
case 1:
{
new red, green, blue, alpha;
inline SelectRed(redpid, reddialogid, redresponse, redlistitem, string:redtext[])
{
#pragma unused redlistitem, reddialogid, redpid, redtext
if(redresponse)
{
red = strval(redtext);
if(red < 0 || red > 255) Dialog_ShowCallback(playerid, using inline SelectRed, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter Red Value <0 - 255>", "Ok", "Cancel");
else
{
inline SelectGreen(greenpid, greendialogid, greenresponse, greenlistitem, string:greentext[])
{
#pragma unused greenlistitem, greendialogid, greenpid, greentext
if(greenresponse)
{
green = strval(greentext);
if(green < 0 || green > 255) Dialog_ShowCallback(playerid, using inline SelectGreen, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter Green Value <0 - 255>", "Ok", "Cancel");
else
{
inline SelectBlue(bluepid, bluedialogid, blueresponse, bluelistitem, string:bluetext[])
{
#pragma unused bluelistitem, bluedialogid, bluepid, bluetext
if(blueresponse)
{
blue = strval(bluetext);
if(blue < 0 || blue > 255) Dialog_ShowCallback(playerid, using inline SelectBlue, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter Blue Value <0 - 255>", "Ok", "Cancel");
else
{
inline SelectAlpha(alphapid, alphadialogid, alpharesponse, alphalistitem, string:alphatext[])
{
#pragma unused alphalistitem, alphadialogid, alphapid, alphatext
if(alpharesponse)
{
if(isnull(alphatext)) alpha = 255;
else alpha = strval(alphatext);
if(alpha < 0 || alpha > 255) Dialog_ShowCallback(playerid, using inline SelectAlpha, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter Alpha Value <0 - 255>\nNote: Leaving this empty is full alpha 255", "Ok", "Cancel");
else
{
ProgressProjectPropEdit(playerid);
SetPlayerProgressBarColour(playerid, EditBars[playerid][CurrEditIndex[playerid]], RGBA(red, green, blue, alpha));
SendClientMessage(playerid, STEALTH_GREEN, "Color has been updated");
UpdateDB(playerid, CurrEditIndex[playerid], DB_SAVE_TYPE_COLOR);
ProgressProjectPropEdit(playerid);
}
}
else ProgressProjectPropEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline SelectAlpha, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter Alpha Value <0 - 255>\nNote: Leaving this empty is full alpha 255", "Ok", "Cancel");
}
}
else ProgressProjectPropEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline SelectBlue, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter Blue Value <0 - 255>", "Ok", "Cancel");
}
}
else ProgressProjectPropEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline SelectGreen, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter Green Value <0 - 255>", "Ok", "Cancel");
}
}
else ProgressProjectPropEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline SelectRed, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter Red Value <0 - 255>", "Ok", "Cancel");
}
case 2:
{
inline SelectWebColor(wpid, wdialogid, wresponse, wlistitem, string:wtext[])
{
#pragma unused wlistitem, wdialogid, wpid, wtext
if(wresponse)
{
SetPlayerProgressBarColour(playerid, EditBars[playerid][CurrEditIndex[playerid]], WebColorsRGBA[wlistitem]);
SendClientMessage(playerid, STEALTH_GREEN, "Color has been updated");
UpdateDB(playerid, CurrEditIndex[playerid], DB_SAVE_TYPE_COLOR);
ProgressProjectPropEdit(playerid);
}
else ProgressProjectPropEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline SelectWebColor, DIALOG_STYLE_LIST, "Progress Bar Editor", webcolors, "Ok", "Cancel");
}
}
}
}
Dialog_ShowCallback(playerid, using inline SelectColorMet, DIALOG_STYLE_LIST, "Progress Bar Editor", "Hex Value\nCombinator\nWeb Colors", "Ok", "Cancel");
}
// Set Max value
case 5:
{
inline SetMax(spid, sdialogid, sresponse, slistitem, string:stext[])
{
#pragma unused slistitem, sdialogid, spid, stext
if(sresponse)
{
if(!isnull(stext))
{
new Float:maxv;
if(sscanf(stext, "f", maxv))
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must be a float!");
Dialog_ShowCallback(playerid, using inline SetMax, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new max Value", "Ok", "Back");
}
else if(maxv < 0.0)
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must not be negative!");
Dialog_ShowCallback(playerid, using inline SetMax, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new max Value", "Ok", "Back");
}
else if(maxv > 640.0)
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must be less than 640.0!");
Dialog_ShowCallback(playerid, using inline SetMax, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new max Value", "Ok", "Back");
}
else
{
SetPlayerProgressBarMaxValue(playerid, EditBars[playerid][CurrEditIndex[playerid]], maxv);
SendClientMessage(playerid, STEALTH_GREEN, "Max has been updated");
UpdateDB(playerid, CurrEditIndex[playerid], DB_SAVE_TYPE_MAX);
ProgressProjectPropEdit(playerid);
}
}
else ProgressProjectPropEdit(playerid);
}
else ProgressProjectPropEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline SetMax, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new max Value", "Ok", "Back");
}
// Set bar value
case 6:
{
inline SetBarValue(spid, sdialogid, sresponse, slistitem, string:stext[])
{
#pragma unused slistitem, sdialogid, spid, stext
if(sresponse)
{
if(!isnull(stext))
{
new Float:barv;
if(sscanf(stext, "f", barv))
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must be a float!");
Dialog_ShowCallback(playerid, using inline SetBarValue, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new bar Value", "Ok", "Back");
}
else if(barv < 0.0)
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must not be negative!");
Dialog_ShowCallback(playerid, using inline SetBarValue, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new bar Value", "Ok", "Back");
}
else if(barv > 640.0)
{
SendClientMessage(playerid, STEALTH_YELLOW, "Value must be less than 640.0!");
Dialog_ShowCallback(playerid, using inline SetBarValue, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new bar Value", "Ok", "Back");
}
else
{
SetPlayerProgressBarValue(playerid, EditBars[playerid][CurrEditIndex[playerid]], barv);
SendClientMessage(playerid, STEALTH_GREEN, "Bar value has been updated");
UpdateDB(playerid, CurrEditIndex[playerid], DB_SAVE_TYPE_BARVALUE);
ProgressProjectPropEdit(playerid);
}
}
else ProgressProjectPropEdit(playerid);
}
else ProgressProjectPropEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline SetBarValue, DIALOG_STYLE_INPUT, "Progress Bar Editor", "Enter a new bar Value", "Ok", "Back");
}
// Set progress bar direction
case 7:
{
inline SetBarDirection(spid, sdialogid, sresponse, slistitem, string:stext[])
{
#pragma unused slistitem, sdialogid, spid, stext
if(sresponse)
{
switch(slistitem)
{
case 0: SetPlayerProgressBarDirection(playerid, EditBars[playerid][CurrEditIndex[playerid]], BAR_DIRECTION_RIGHT);
case 1: SetPlayerProgressBarDirection(playerid, EditBars[playerid][CurrEditIndex[playerid]], BAR_DIRECTION_LEFT);
case 2: SetPlayerProgressBarDirection(playerid, EditBars[playerid][CurrEditIndex[playerid]], BAR_DIRECTION_UP);
case 3: SetPlayerProgressBarDirection(playerid, EditBars[playerid][CurrEditIndex[playerid]], BAR_DIRECTION_DOWN);
}
SendClientMessage(playerid, STEALTH_GREEN, "Bar direction has been updated");
UpdateDB(playerid, CurrEditIndex[playerid], DB_SAVE_TYPE_DIRECTION);
ProgressProjectPropEdit(playerid);
}
else ProgressProjectPropEdit(playerid);
}
Dialog_ShowCallback(playerid, using inline SetBarDirection, DIALOG_STYLE_LIST, "Progress Bar Editor", "Right\nLeft\nUp\nDown", "Ok", "Back");
}
// Set XY with keys
case 8:
{
EditMode[playerid] = EDIT_MODE_MOVEBAR;
GetPlayerProgressBarPos(playerid, EditBars[playerid][CurrEditIndex[playerid]], SavedXY[playerid][0], SavedXY[playerid][1]);
// TogglePlayerControllable(playerid, false);
SendClientMessage(playerid, STEALTH_GREEN, "Use the arrow keys to set the position press 'WALK KEY' when finished!");
}
}
}
else ProgressProjectEdit(playerid);
}
new line[256];
GetPlayerProgressBarPos(playerid, EditBars[playerid][CurrEditIndex[playerid]], x, y);
format(line, sizeof(line), "XPos: %f\nYPos: %f\nWidth: %f\nHeight: %f\nColor: {%06x}XXXXXXXX{FFFFFF}\nMax Value:%f\nBar Value: %f\nDirection: %s\nSet XY with keys",
x,
y,
GetPlayerProgressBarWidth(playerid, EditBars[playerid][CurrEditIndex[playerid]]),
GetPlayerProgressBarHeight(playerid, EditBars[playerid][CurrEditIndex[playerid]]),
GetPlayerProgressBarColour(playerid, EditBars[playerid][CurrEditIndex[playerid]]) >>> 8,
GetPlayerProgressBarMaxValue(playerid, EditBars[playerid][CurrEditIndex[playerid]]),
GetPlayerProgressBarValue(playerid, EditBars[playerid][CurrEditIndex[playerid]]),
DirectionNames[GetPlayerProgressBarDirection(playerid, EditBars[playerid][CurrEditIndex[playerid]])]
);
Dialog_ShowCallback(playerid, using inline PBPropEditMenu, DIALOG_STYLE_LIST, "Progress Bar Editor", line, "Ok", "Back");
return 1;
}
public OnPlayerUpdate(playerid)
{
if(EditMode[playerid] == EDIT_MODE_MOVEBAR)
{
new Keys,ud,lr, Float:x, Float:y;
GetPlayerKeys(playerid,Keys,ud,lr);
if(Keys & KEY_WALK)
{
inline SavePosition(spid, sdialogid, sresponse, slistitem, string:stext[])
{
#pragma unused slistitem, sdialogid, spid, stext
if(sresponse)
{
SendClientMessage(playerid, STEALTH_GREEN, "Position Updated");
UpdateDB(playerid, CurrEditIndex[playerid], DB_SAVE_TYPE_POS);
}
else
{
SetPlayerProgressBarPos(playerid, EditBars[playerid][CurrEditIndex[playerid]], SavedXY[playerid][0], SavedXY[playerid][1]);
SendClientMessage(playerid, STEALTH_YELLOW, "Position update cancelled");
}
ProgressProjectPropEdit(playerid);