-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1578 lines (1500 loc) · 65.1 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FPS X</title>
<link rel="preload" href="/fonts/Thunderbolt.otf" as="font" type="font/otf" crossorigin>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="icon" type="image/x-icon" href="/images/logos/0.ico">
<style>
@import url("/fonts/WorkSans/WorkSans.css");
@font-face {
font-family: "Thunderbolt";
src: url(/fonts/Thunderbolt.otf);
font-display: swap
}
html {
background: #000;
}
html, body {
overflow: hidden !important;
user-select: none !important;
-moz-user-select: none !important;
-webkit-user-select: none !important;
}
.wrapper {
width: 1440px;
height: 900px;
position: fixed;
top: 50%;
left: 50%;
margin-top: -450px;
margin-left: -720px;
background-image: url(/images/other/menu/0.png);
background-size: cover;
background-position: center center;
}
.tabs {
position: relative;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
top: 30px;
}
.tab {
width: 260px;
border: 3px solid #fff;
margin-right: 20px;
margin-left: 20px;
padding: 5px;
text-align: center;
color: #fff;
font-family: "Work Sans", Arial;
font-weight: 300;
font-size: 20px;
cursor: pointer;
}
.tab.selected {
background: #fff;
color: black;
mix-blend-mode: screen;
}
.tab:hover:not(.selected), .tab.hover:not(.selected) {
background: rgba(255, 255, 255, 0.3);
}
.sub-menu {
position: absolute;
left: 150px;
bottom: 200px;
}
.sub-menu .item {
width: 500px;
font-family: "Work Sans", Arial;
font-size: 34px;
font-weight: 250;
color: #fff;
border-bottom: 2.5px solid #fff;
margin-top: 20px;
}
.sub-menu .item:hover, .sub-menu .item.hover {
border-width: 4px;
margin-bottom: -1.5px;
font-weight: 400;
cursor: pointer;
}
.info {
position: absolute;
right: 10px;
bottom: 35px;
text-align: right;
}
.info .version {
font-size: 40px;
color: #fff;
font-family: "Work Sans", Arial;
font-weight: 300;
margin-bottom: 5px;
}
.info .copyright {
font-size: 20px;
color: #fff;
font-family: "Work Sans", Arial;
font-weight: 200;
}
.swal-modal {
background: rgba(0, 0, 0, 0.6);
border-radius: 0;
box-shadow: 0 10px 10px rgba(0, 0, 0, 0.1), 0 1px 8px rgba(0, 0, 0, 0.3);
backdrop-filter: blur(3px);
overflow: hidden;
animation: none !important;
}
.swal-text, .swal-title {
color: #fff !important;
font-family: "Thunderbolt", Arial;
}
.swal-footer {
display: flex;
align-items: center;
justify-content: center;
}
.swal-button-container {
width: 40%;
white-space: nowrap;
}
.swal-button {
width: 100%;
white-space: nowrap;
border: 2px solid #fff;
background: transparent;
border-radius: 0;
color: #fff;
box-shadow: 0 5px 10px rgba(255, 255, 255, 0.1), 0 5px 10px rgba(255, 255, 255, 0.3) !important;
}
.swal-button:hover, .swal-button.hover {
background: rgba(255, 255, 255, 0.3) !important;
}
.gamepad-cursor {
position: absolute;
z-index: 99999999999;
width: 20px;
height: 20px;
background: transparent;
border-radius: 100%;
border: 3px solid #eee;
outline: 1px solid #000;
margin-left: -10px;
margin-top: -10px;
visibility: hidden;
}
.swal-content.scrollable {
position: relative;
height: 200px;
overflow-y: scroll;
background: #fff;
text-align: left;
border: 2px solid #ddd;
border-radius: 10px;
width: 75%;
left: 50%;
margin-left: -42%;
font-family: Arial, Helvetica, sans-serif;
}
.swal-content.scrollable a {
color: #416dea !important;
text-decoration: none;
}
.swal-content.scrollable a:hover {
text-decoration: underline;
}
.weapon-select {
display: inline-flex;
align-items: center;
justify-content: center;
text-align: center;
border: 2.4px solid #fff;
border-radius: 8px;
padding: 8px;
width: 96px;
height: 96px;
margin-right: 8px;
}
.weapon-select.selected {
outline: 4.8px solid #fff;
}
.weapon-select:hover, .weapon-select.hover {
background: rgba(255, 255, 255, 0.25);
cursor: pointer;
}
.weapon-select-image {
width: 56px;
height: 56px;
filter: invert(1) drop-shadow(1px 1px 1px rgba(0, 0, 0, 0.5));
}
.weapon-select-title {
color: #fff;
margin-left: 4px;
font-family: "Thunderbolt", Arial;
font-size: 16px;
}
.options-wrapper {
position: absolute;
left: 100px;
bottom: 10px;
}
.primary-weapon-selection {
margin-bottom: 10px;
}
.weapon-selection-header {
color: #fff;
font-family: "Work Sans", Arial;
font-size: 30px;
}
.options-header-main {
font-size: 20px;
color: #fff;
font-family: "Work Sans", Arial;
margin-top: 30px;
}
.options-header-main::before {
content: "";
display: inline-block;
width: 30px;
height: 30px;
background-image: url(/images/icons/arrowhead_right.png);
background-size: contain;
background-repeat: no-repeat;
filter: invert(1);
margin-top: -5px;
vertical-align: middle;
line-height: 10px;
}
.look-sensitivity-header {
font-family: "Work Sans", Arial;
font-size: 14px;
font-weight: 500;
color: #fff;
}
.look-sensitivity-wrapper {
float: left;
}
#pointer-speed-value-text {
position: relative;
color: #fff;
margin-left: 10px;
font-family: "Thunderbolt", Arial;
font-size: 26px;
border: 1px solid #fff;
padding: 5px;
padding-top: 0;
width: 30px;
text-align: center;
display: inline-block;
}
.custom-slider {
position: relative;
width: 200px;
height: 20px;
display: inline-block;
}
.slider-track {
position: absolute;
top: 50%;
transform: translateY(-50%);
width: 100%;
height: 2px;
border: 1px solid #ccc;
background: transparent;
}
.slider-thumb {
position: absolute;
top: 50%;
transform: translate(-50%, -50%);
width: 20px;
height: 20px;
background-color: #fff;
border: 1px solid #ccc;
cursor: default;
}
.slider-thumb:active {
background: #ccc;
}
.account-wrapper {
position: absolute;
left: 100px;
bottom: 100px;
}
.input {
background: transparent;
border: 3px solid #fff;
width: 300px;
padding: 3px;
font-family: "Thunderbolt", Arial;
color: #fff;
font-size: 30px;
}
.input.login-input.password {
width: 250px;
}
.input.login-input.readonly-username.edit {
width: 250px;
}
.input.login-input.readonly-username.edit + button.login-input.submit {
display: inline-block;
margin-left: 0 !important;
}
.input.login-input.readonly-username + button.login-input.submit {
display: none;
}
button.login-input.submit {
background: #fff;
border: none;
width: 39px;
padding: 6px;
font-size: 30px;
margin-left: 5px;
color: #222;
float: right;
text-align: center;
cursor: pointer;
}
button.login-input.submit:active {
background: #ccc;
}
.account-header {
font-family: "Work Sans", Arial;
font-size: 20px;
font-weight: 500;
color: #fff;
}
.account-subheader {
font-family: "Work Sans", Arial;
font-size: 14px;
font-weight: 300;
color: #fff;
margin: 0;
}
.select {
background: #fff;
width: 200px;
padding: 3px;
font-family: "Thunderbolt", Arial;
font-size: 20px;
border: none;
color: #000 !important;
}
button.logout {
color: #dc3545;
border: 3px solid #dc3545;
background: transparent;
font-family: "Thunderbolt", Arial;
font-size: 30px;
padding: 3px;
padding-top: 0;
cursor: pointer;
margin-bottom: 10px;
}
button.logout:hover, button.logout.hover {
background: rgba(255, 255, 255, 0.3);
}
.account-link {
display: inline-block;
font-family: "Thunderbolt", Arial;
font-size: 30px;
color: #fff;
height: 30px;
border-bottom: 1px solid currentColor;
cursor: pointer;
}
.account-link:hover, .account-link.hover {
color: #ccc;
}
.account-link:active {
color: #aaa;
}
.swal-content__input {
background: transparent;
font-family: "Work Sans", Arial;
font-size: 20px;
font-weight: 100;
color: #fff;
border: 3px solid #fff !important;
border-radius: none;
box-shadow: none;
outline: none;
}
.game-preset-wrapper .option-header {
display: block;
color: #fff;
font-family: "Work Sans", Arial;
font-size: 18px;
margin-bottom: 5px !important;
}
.game-preset-description {
display: block;
color: #fff;
font-family: "Thunderbolt", Arial;
font-size: 16px;
}
.controls-binding-wrapper {
position: relative;
float: right;
margin: 0 !important;
left: -200px;
}
.button.controls-binding-button {
background: #fff;
border: none;
width: 250px;
padding: 10px;
font-family: Arial;
font-size: 20px;
display: block;
margin-top: 30px;
cursor: default;
color: #000;
}
.button.controls-binding-button:hover, .button.controls-binding-button.hover {
background: #ddd;
}
.controls-binding-header {
text-align: left;
color: #fff;
font-size: 12px;
font-family: Arial;
}
.controls-binding-box {
text-align: left;
color: #fff;
font-size: 12px;
float: right;
margin-top: -32px;
background: rgba(0, 0, 0, 0.6);
border: 1px solid #888;
padding: 3px;
width: 50px;
font-family: Arial;
}
.controls-binding-box:hover, .controls-binding-box.hover {
background: rgba(80, 80, 80, 0.6);
}
.error-message {
color: #ff0000;
font-family: monospace, Arial;
}
.stats-points-counter {
font-family: "Work Sans", Arial;
font-size: 20px;
font-weight: 300;
color: #fff;
}
.stats-points-counter .points {
font-family: "Work Sans", Arial;
font-size: 40px;
font-weight: 300;
color: #fff;
}
.stats-header {
font-family: "Work Sans", Arial;
font-size: 20px;
font-weight: 500;
color: #fff;
}
.medal {
color: #ddd;
margin-bottom: 10px;
font-family: Arial;
font-weight: 100;
text-shadow: 0 0 2px black;
display: inline-block;
}
.medal .medal-icon {
width: 50px;
vertical-align: middle;
line-height: 25px;
filter: invert(1);
}
.stats-games-counter {
font-family: "Work Sans", Arial;
font-size: 20px;
font-weight: 300;
color: #fff;
}
.stats-games-counter .games-played {
font-family: "Work Sans", Arial;
font-size: 40px;
font-weight: 300;
color: #fff;
}
.stats-wrapper {
position: absolute;
left: 100px;
bottom: 100px;
}
.nothing {
font-family: "Work Sans", Arial;
font-size: 30px;
font-weight: 500;
color: #aaa;
}
.character-select {
display: inline-flex;
align-items: center;
justify-content: center;
text-align: center;
border: 2.4px solid #fff;
border-radius: 8px;
padding: 8px;
width: 96px;
height: 192px;
margin-right: 8px;
}
.character-select.selected {
outline: 4.8px solid #fff;
}
.character-select:hover, .weapon-select.hover {
background: rgba(255, 255, 255, 0.25);
cursor: pointer;
}
.character-select-image {
width: 56px;
height: 112px;
filter: drop-shadow(1px 1px 1px rgba(255, 255, 255, 0.5));
}
.character-select-title {
color: #fff;
margin-left: 4px;
font-family: "Thunderbolt", Arial;
font-size: 16px;
}
.character-selection-wrapper {
position: relative;
margin: 0 !important;
left: 370px;
}
.character-selection {
position: relative;
display: flex;
}
code {
background: #ddd;
padding: 3px;
font-size: 13px;
border-radius: 3px;
}
.character-selection-wrapper * {
pointer-events: auto !important;
}
.character-selection-wrapper {
pointer-events: none;
}
</style>
<script src="https://unpkg.com/sweetalert@2.1.2/dist/sweetalert.min.js"></script>
</head>
<body>
<div class="gamepad-cursor"></div>
<div class="wrapper">
<div class="tabs">
<div class="tab selected" onclick="selectTab(this)" data-tab="play">PLAY</div>
<div class="tab" onclick="selectTab(this)" data-tab="options">OPTIONS</div>
<div class="tab" onclick="selectTab(this)" data-tab="stats">STATS</div>
<div class="tab" onclick="selectTab(this)" data-tab="account">LOG IN</div>
</div>
<div class="content">
<div class="sub-menu">
<div class="item" onclick="subMenuAction(this)" data-action="search-game">SEARCH FOR GAME</div>
<div class="item" onclick="subMenuAction(this)" data-action="game-presets">GAME PRESETS</div>
<div class="game-preset-wrapper"></div>
<div class="item" onclick="subMenuAction(this)" data-action="custom-lan-server">CUSTOM LAN SERVER</div>
<div class="item" onclick="subMenuAction(this)" data-action="help">HELP</div>
</div>
</div>
<div class="info">
<div class="version">v1.0.0</div>
<div class="copyright">© 2025 Parking Master</div>
</div>
</div>
<script src="/lib/user.js"></script>
<script src="/lib/plugins.js"></script>
<script src="/lib/MenuControls.js"></script>
<script src="/lib/HtmlRange.js"></script>
<script src="https://x.gametime.js.org/gametime.js"></script>
<script>
(async () => {
// We'll try to connect to a Gametime.js-X socket server, but will use PubNub instead if not available
await gametime.setCustomServer(["http://weatherstationpi.local:4444", "https://caribou-needed-implicitly.ngrok-free.app", "https://new-suitably-gnu.ngrok-free.app", "https://gratefully-engaged-bluebird.ngrok-free.app"]);
await gametime.set("channel", "example-channel123");
await gametime.set("key", "pub-c-99b84afd-1fa3-4452-a727-4b46d06a11e2", "sub-c-ed7e8e7f-1c0a-40ec-bc97-7da421c062a0");
await gametime.sustain();
gametime.on("decideLobbyName", function(lobbyOptions) {
if (lobbyOptions.name === global.lobbyName) {
matchFound(lobbyOptions);
}
})
})();
global = {
server: "https://hardy-beetle-free.ngrok-free.app",
stopSearch: false,
lobbyName: null,
matchFound: false,
wrapperScale: 1,
lobbyOptions: {
mode: "default",
map: "random",
teams: "1v1"
}
};
if (user.loggedIn) {
document.querySelector(".tab[data-tab='account']").textContent = "ACCOUNT";
}
function onWindowResize() {
let averageScale = window.innerHeight / 900;
let minWidth = 1440 * averageScale;
if (window.innerWidth < minWidth) {
// Scale the UI based on the width of window
let wrapperScale = (window.innerWidth / 1440);
global.wrapperScale = wrapperScale;
document.querySelector(".wrapper").style.transform = `scale(${wrapperScale})`;
if (document.querySelector(".swal-modal")) {
document.querySelector(".swal-modal").style.scale = wrapperScale * 1.5;
}
} else {
// Scale the UI based on the height of window
let wrapperScale = (window.innerHeight / 900);
global.wrapperScale = wrapperScale;
document.querySelector(".wrapper").style.transform = `scale(${wrapperScale})`;
if (document.querySelector(".swal-modal")) {
document.querySelector(".swal-modal").style.scale = wrapperScale * 1.5;
}
}
}
window.addEventListener("resize", onWindowResize);
onWindowResize();
user.logInCallback = function() {
document.querySelector(".wrapper").style.backgroundImage = `url(/images/other/menu/${user.preferences.menuBackground}.png)`;
document.querySelector("link[rel=icon]").href = `/images/logos/${user.preferences.menuBackground}.ico`;
};
if (localStorage["game-over-earnings"]) {
let earnings = JSON.parse(localStorage["game-over-earnings"]);
if (user.loggedIn) {
plugins.waitUntil(() => user.email).then(async () => {
let medals = user.preferences.medals;
let points = user.preferences.points;
let gamesPlayed = user.preferences.gamesPlayed;
user.set("medals", medals.concat(earnings.medals));
await plugins.delay(200);
user.set("points", points + earnings.points);
await plugins.delay(200);
user.set("gamesPlayed", gamesPlayed + 1);
localStorage.removeItem("game-over-earnings");
});
}
}
function menuDialog() {
let output = swal.apply(null, arguments);
document.querySelector(".swal-modal").style.scale = global.wrapperScale * 1.5;
return output;
};
function startSearchForGame(onSuccessCallback, onLobbyFoundCallback) {
let lobbyOptions = global.lobbyOptions;
function next() {
global.lobbyName = lobbyOptions.name;
onSuccessCallback();
let search = setInterval(() => {
fetch(`${global.server}/lobby/search?options=${btoa(JSON.stringify(lobbyOptions))}`, {
headers: {
"ngrok-skip-browser-warning": "69420"
}
}).then(async response => {
if (response.status === 200) {
let matchingLobbyOptions = await response.json();
onLobbyFoundCallback(matchingLobbyOptions);
clearInterval(search);
lobbyName = null;
lobbyOptions = null;
search = null;
}
});
}, 10000);
let checkSearch = setInterval(function() {
if (global.stopSearch) return clearInterval(checkSearch), clearInterval(search), global.stopSearch = false;
});
}
let existingLobby = JSON.parse(localStorage["lobby"] || "{}");
if (!existingLobby.name || Date.now() - existingLobby.creationDate > (15 * 60 * 1000)) {
fetch(`${global.server}/lobby/create?options=${btoa(JSON.stringify(lobbyOptions))}`, {
headers: {
"ngrok-skip-browser-warning": "69420"
}
}).then(async response => {
if (response.status === 200) {
let lobbyName = await response.text();
let savedLobby = {
name: lobbyName,
creationDate: Date.now()
};
lobbyOptions.name = lobbyName;
localStorage.setItem("lobby", JSON.stringify(savedLobby));
next();
}
});
} else {
lobbyOptions.name = existingLobby.name;
next();
}
}
function matchFound(lobbyOptions) {
if (global.matchFound) return;
global.matchFound = true;
menuDialog({
title: "Match found",
text: "Connecting all players.",
button: false,
closeOnEsc: false,
closeOnClickOutside: false
});
// We'll start the game at a fixed real-world time, so both players are synced
let time = Date.now().toString().slice(-4) - 0;
let timeUntilStart = time >= 5000 ? 10000 - time : 5000 - time;
setTimeout(() => {
location.replace(`/src.html?lobby=${lobbyOptions.name}&map=${lobbyOptions.map}&character=${user.preferences.game.character}`);
}, timeUntilStart);
}
function subMenuAction(button) {
let action = button.dataset.action;
if (action === "search-game") {
startSearchForGame(function() {
menuDialog({
title: "Searching for game",
text: "Please wait. We will search for a matching game and connect you to it automatically if we find one.",
button: "Cancel",
closeOnEsc: false,
closeOnClickOutside: false
}).then(function() {
global.stopSearch = true;
});
}, function(lobbyOptions) {
matchFound(lobbyOptions);
gametime.run("decideLobbyName", [lobbyOptions]);
});
} if (action === "game-presets") {
if (document.querySelector(".game-preset-wrapper").classList.contains("dropdown")) {
document.querySelector(".game-preset-wrapper").classList.remove("dropdown");
document.querySelector(".game-preset-wrapper").innerHTML = "";
} else {
document.querySelector(".game-preset-wrapper").classList.add("dropdown");
document.querySelector(".game-preset-wrapper").innerHTML = `
<p class="option-header">Game mode:</p>
<select class="select select-game-mode" value="default" onchange="global.lobbyOptions.mode = this.value, externalAction('menu:generatedescription')">
<option value="default" selected>Default</option>
<option value="fiesta">Fiesta</option>
<option value="snipers">Snipers</option>
</select>
<p class="option-header">Map:</p>
<select class="select select-game-map" value="random" onchange="global.lobbyOptions.map = this.value, externalAction('menu:generatedescription')">
<option value="random" selected>random</option>
<option value="Cargo_Port">Cargo Port</option>
<option value="Breakthrough">Breakthrough</option>
<option value="Lihid">Lihid</option>
<option value="Ghost_Town">Ghost Town</option>
<option value="Abandoned_City">Abandoned City</option>
</select>
<p class="option-header">Team size:</p>
<select class="select select-game-teams" value="1v1" onchange="global.lobbyOptions.teams = this.value, externalAction('menu:generatedescription')">
<option value="1v1" selected>1v1</option>
<option value="2v2">2v2</option>
</select>
<p class="game-preset-description">A basic 1v1 game with chosen loadouts + map weapons, and a random map.</p>
`;
document.querySelector(".select.select-game-mode").value = global.lobbyOptions.mode;
document.querySelector(`.select.select-game-mode option[selected]`).selected = "";
document.querySelector(`.select.select-game-mode option[value="${global.lobbyOptions.mode}"]`).selected = "selected";
document.querySelector(".select.select-game-map").value = global.lobbyOptions.map;
document.querySelector(`.select.select-game-map option[selected]`).selected = "";
document.querySelector(`.select.select-game-map option[value="${global.lobbyOptions.map}"]`).selected = "selected";
document.querySelector(".select.select-game-teams").value = global.lobbyOptions.teams;
document.querySelector(`.select.select-game-teams option[selected]`).selected = "";
document.querySelector(`.select.select-game-teams option[value="${global.lobbyOptions.teams}"]`).selected = "selected";
externalAction("menu:generatedescription");
}
} else if (action === "custom-lan-server") {
let content = document.createElement("div");
content.innerHTML = `
<h3>Running a LAN sever</h3>
<p>Running a LAN (Local Area Network) server is beneficial for lower-latency games, especially if you're playing with friends and are already on the same network. By default, you are using a Gametime.js X Public Socket Server for multiplayer. But we are going to cover how you can easily host your own local Socket Server.</p>
<h4>Prerequisites</h4>
<p>Make sure you already have these installed:</p>
<ul>
<li>Node.js</li>
<li>NPM</li>
<li>Socket.io</li>
<li>Git</li>
</ul>
<ol>
<li>Download the <a href="https://github.com/Parking-Master/FPS-X/blob/main/socket.js" target="_blank">Socket Server File</a> for FPS X</li>
<li>Find the path to the file you downloaded, then run:</li>
<li><code>$ node /path/to/file.js</code></li>
<li>This will start the socket server on your machine.</li>
<li>In order to connect your socket server to FPS X, you need to find either your machine's IP address or Hostname. How you find it will vary between Mac, Windows, and Linux. You can also just use <a href="http://localhost:4444" target="_blank">localhost:4444</a>.</li>
<li>Download FPS X onto your system using either git, or by downloading from the source:</li>
<li><code>$ git clone https://github.com/Parking-Master/FPS-X</code></li>
<li>Or download manually from <a href="https://github.com/Parking-Master/FPS-X/archive/refs/heads/main.zip" target="_blank">here</a></li>
<li>With FPS X now installed, go to the downloaded folder, and edit the files <code>index.html</code> and <code>src.html</code>.
<li>Find the lines that start with <code>gametime.setCustomServer</code>. Then, as one of the server URLs, add the hostname or IP address of your socket server into the server list.</li>
<li>Save the file, then run <code>$ node server.js</code> in the FPS X directory.</li>
<li>Go to <a href="http://localhost:8080" target="_blank">localhost:8080</a>, and you will see the FPS X main menu. <a href="https://github.com/Parking-Master/FPS-X#starting-a-game" target="_blank">Start a game</a> and it will attempt to find a game through your local network.</li>
</ol>
<p>Also feel free to edit the code yourself after your download FPS X. You can add custom mods, cheats, or even change the graphics!</p>
`;
menuDialog({
title: "Run your own FPS X server",
content: content,
button: "Close",
closeOnEsc: false,
closeOnClickOutside: false
});
document.querySelector(".swal-content").classList.add("scrollable");
}
}
function selectTab(button) {
let tab = button.dataset.tab;
document.querySelector(".tab.selected").classList.remove("selected");
button.classList.add("selected");
if (tab === "play") {
let content = `
<div class="sub-menu">
<div class="item" onclick="subMenuAction(this)" data-action="search-game">SEARCH FOR GAME</div>
<div class="item" onclick="subMenuAction(this)" data-action="game-presets">GAME PRESETS</div>
<div class="game-preset-wrapper"></div>
<div class="item" onclick="subMenuAction(this)" data-action="custom-lan-server">CUSTOM LAN SERVER</div>
<div class="item" onclick="subMenuAction(this)" data-action="help">HELP</div>
</div>
`;
document.querySelector(".content").innerHTML = content;
}
if (tab === "options") {
let primaryWeapons = ["AK-74", "M16", "AR-15", "SCAR-H", "MK-14", "SKS"];
let secondaryWeapons = ["FN-502", "Glock-19", "XD-Mod-2", "Desert-Eagle"];
let characters = ["SWAT", "Marine", "GasMask"];
let content = document.createElement("div");
content.innerHTML = `
<div class="options-wrapper">
<div class="weapon-selection-wrapper">
<p class="options-header-main">Loadout</p>
<p class="weapon-selection-header">Primary weapon</p>
<div class="primary-weapon-selection"></div>
<p class="weapon-selection-header">Secondary weapon</p>
<div class="secondary-weapon-selection"></div>
</div>
<div class="look-sensitivity-wrapper">
<p class="options-header-main">Look sensitivity</p>
<p class="look-sensitivity-header">Mouse pointer speed</p>
<div class="custom-slider look-sensitivity-slider" data-type="pointer">
<div class="slider-track"></div>
<div class="slider-thumb"></div>
</div>
<span id="pointer-speed-value-text" data-type="pointer">2.0</span>
<br>
<p class="look-sensitivity-header">Gamepad joystick speed</p>
<div class="custom-slider look-sensitivity-slider" data-type="gamepad">
<div class="slider-track"></div>
<div class="slider-thumb"></div>
</div>
<span id="pointer-speed-value-text" data-type="gamepad">1.0</span>
<br>
<p class="look-sensitivity-header">Touch screen speed</p>
<div class="custom-slider look-sensitivity-slider" data-type="touch">
<div class="slider-track"></div>
<div class="slider-thumb"></div>
</div>
<span id="pointer-speed-value-text" data-type="touch">2.0</span>
</div>
<div class="controls-binding-wrapper">
<p class="options-header-main">Controller bindings</p>
<button class="button controls-binding-button" onclick="externalAction('menu:controlsbinding_key')">Key bindings</button>
<button class="button controls-binding-button" onclick="externalAction('menu:controlsbinding_gamepad')">Gamepad bindings</button>
</div>
<div class="character-selection-wrapper">
<p class="options-header-main">Character</p>
<div class="character-selection"></div>
</div>
</div>
`;
primaryWeapons.forEach(weapon => {
content.querySelector(".primary-weapon-selection").innerHTML += `
<div class="weapon-select" data-weapon="${weapon}" onclick="externalAction('setprimaryweapon:${weapon}')">
<img class="weapon-select-image" src="/images/other/weapons/${weapon}.png">
<p class="weapon-select-title">${weapon}</p>
</div>
`;
});
secondaryWeapons.forEach(weapon => {
content.querySelector(".secondary-weapon-selection").innerHTML += `
<div class="weapon-select" data-weapon="${weapon}" onclick="externalAction('setsecondaryweapon:${weapon}')">
<img class="weapon-select-image" src="/images/other/weapons/${weapon}.png">
<p class="weapon-select-title">${weapon}</p>
</div>
`;
});
content.querySelector(`.primary-weapon-selection .weapon-select[data-weapon="${user.preferences.game.loadout[0]}"]`).classList.add("selected");
content.querySelector(`.secondary-weapon-selection .weapon-select[data-weapon="${user.preferences.game.loadout[1]}"]`).classList.add("selected");
characters.forEach(character => {
content.querySelector(".character-selection").innerHTML += `
<div class="character-select" data-character="${character}" onclick="externalAction('setcharacter:${character}')">
<img class="character-select-image" src="/images/other/characters/${character}.png">
<p class="character-select-title">${character}</p>
</div>
`;
});
content.querySelector(`.character-selection .character-select[data-character="${user.preferences.game.character}"]`).classList.add("selected");
document.querySelector(".content").innerHTML = content.innerHTML;
let lookSensitivity = {
"pointer": user.preferences.game.mouseSpeed,
"gamepad": user.preferences.game.gamepadSpeed,
"touch": user.preferences.game.touchSpeed
};
document.querySelectorAll(".look-sensitivity-slider").forEach(sliderElement => {
let value = lookSensitivity[sliderElement.dataset.type];
let slider = new CustomSlider(sliderElement, {
min: 1,
max: 20,
value: value * 2,
onchange: async (value) => {
let sensitivity = (Math.round(value) / 2).toFixed(1);
let sensitivityValue = sensitivity - 0;
document.querySelector(`#pointer-speed-value-text[data-type="${sliderElement.dataset.type}"]`).textContent = sensitivity;
},
onfinish: async (value) => {
let sensitivity = (Math.round(value) / 2).toFixed(1);
let sensitivityValue = sensitivity - 0;
if (sliderElement.dataset.type === "pointer") {
user.set("game.mouseSpeed", sensitivityValue);
} else if (sliderElement.dataset.type === "gamepad") {
user.set("game.gamepadSpeed", sensitivityValue);
} else if (sliderElement.dataset.type === "touch") {
user.set("game.touchSpeed", sensitivityValue);
}
}
});
slider.onchange(lookSensitivity[sliderElement.dataset.type] * 2);
});
}
if (tab === "stats") {
if (!localStorage["loginToken"]) {
externalAction("redirect:login");
//notification("Please log in to view your stats.")
} else {
let content = document.createElement("div");
let medalWrapper = document.createElement("div");
let medals = user.preferences.medals;
if (medals.length === 0) {
medalWrapper.innerHTML = `
<p class="nothing">No medals earned yet.</p>
`;
}
medals.forEach(medal => {
if (medalWrapper.querySelector(`.medal[data-medal="${medal}"]`)) {
let medalElement = medalWrapper.querySelector(`.medal[data-medal="${medal}"]`);