· 6 years ago · Aug 29, 2019, 02:52 PM
1function init(window, ogario, JQuery) {
2 window.server = {
3 host: 'localhost',
4 port: 8083
5 }
6 class Writer {
7 constructor(size){
8 this.dataView = new DataView(new ArrayBuffer(size))
9 this.byteOffset = 0
10 }
11 writeUint8(value){
12 this.dataView.setUint8(this.byteOffset++, value)
13 }
14 writeInt32(value){
15 this.dataView.setInt32(this.byteOffset, value, true)
16 this.byteOffset += 4
17 }
18 writeUint32(value){
19 this.dataView.setUint32(this.byteOffset, value, true)
20 this.byteOffset += 4
21 }
22 writeString(string){
23 for(let i = 0; i < string.length; i++) this.writeUint8(string.charCodeAt(i))
24 this.writeUint8(0)
25 }
26 }
27 window.buffers = {
28 startBots(url, protocolVersion, clientVersion, userStatus, botsName, botsAmount){
29 const writer = new Writer(13 + url.length + botsName.length)
30 writer.writeUint8(0)
31 writer.writeString(url)
32 writer.writeUint32(protocolVersion)
33 writer.writeUint32(clientVersion)
34 writer.writeUint8(Number(userStatus))
35 writer.writeString(botsName)
36 writer.writeUint8(botsAmount)
37 return writer.dataView.buffer
38 },
39 mousePosition(x, y){
40 const writer = new Writer(9)
41 writer.writeUint8(6)
42 writer.writeInt32(x)
43 writer.writeInt32(y)
44 return writer.dataView.buffer
45 }
46 }
47 window.connection = {
48 ws: null,
49 connect(){
50 this.ws = new WebSocket(`ws://${window.server.host}:${window.server.port}`)
51 this.ws.binaryType = 'arraybuffer'
52 this.ws.onopen = this.onopen.bind(this)
53 this.ws.onmessage = this.onmessage.bind(this)
54 this.ws.onclose = this.onclose.bind(this)
55 },
56 send(buffer){
57 if(this.ws && this.ws.readyState === WebSocket.OPEN) this.ws.send(buffer)
58 },
59 onopen(){
60 document.getElementById('userStatus').style.color = '#00C02E'
61 document.getElementById('userStatus').innerText = 'Connected'
62 document.getElementById('connect').disabled = true
63 document.getElementById('startBots').disabled = false
64 document.getElementById('stopBots').disabled = false
65 },
66 onmessage(message){
67 const dataView = new DataView(message.data)
68 switch(dataView.getUint8(0)){
69 case 0:
70 document.getElementById('startBots').disabled = true
71 document.getElementById('stopBots').disabled = false
72 document.getElementById('startBots').style.display = 'none'
73 document.getElementById('stopBots').style.display = 'inline'
74 document.getElementById('stopBots').innerText = 'Stop Bots'
75 window.user.startedBots = true
76 break
77 case 1:
78 document.getElementById('stopBots').disabled = true
79 document.getElementById('stopBots').innerText = 'Stopping Bots...'
80 break
81 case 2:
82 document.getElementById('botsAI').style.color = '#DA0A00'
83 document.getElementById('botsAI').innerText = 'Disabled'
84 document.getElementById('startBots').disabled = false
85 document.getElementById('stopBots').disabled = true
86 document.getElementById('startBots').style.display = 'inline'
87 document.getElementById('stopBots').style.display = 'none'
88 document.getElementById('stopBots').innerText = 'Stop Bots'
89 window.user.startedBots = false
90 window.bots.ai = false
91 break
92 case 3:
93 alert('Your IP has captcha and bots are unable to spawn, change your ip with a VPN or something to one that doesn\'t has captcha in order to use the bots')
94 break
95 case 4:
96 //Connected Bot count = getUint8(1)
97 //Spawned Bot count = getUint8(2)
98 //Server player amount = getUint8(3)
99 $('#botCount').html(`${dataView.getUint8(1)}/${dataView.getUint8(2)}/${window.bots.amount}`)
100 $('#slots').html(dataView.getUint8(3) + "/200")
101 break;
102 }
103 },
104 onclose(){
105 document.getElementById('userStatus').style.color = '#DA0A00'
106 document.getElementById('userStatus').innerText = 'Disconnected'
107 document.getElementById('botsAI').style.color = '#DA0A00'
108 document.getElementById('botsAI').innerText = 'Disabled'
109 document.getElementById('connect').disabled = false
110 document.getElementById('startBots').disabled = true
111 document.getElementById('stopBots').disabled = true
112 document.getElementById('startBots').style.display = 'inline'
113 document.getElementById('stopBots').style.display = 'none'
114 window.user.startedBots = false
115 window.bots.ai = false
116 }
117 }
118 window.game = {
119 url: '',
120 protocolVersion: 0,
121 clientVersion: 0
122 }
123 window.user = {
124 startedBots: false,
125 isAlive: false,
126 mouseX: 0,
127 mouseY: 0,
128 offsetX: 0,
129 offsetY: 0,
130 macroFeedInterval: null
131 }
132 window.bots = {
133 name: '',
134 amount: 0,
135 ai: false
136 }
137 const displayText = {
138 pl: {
139 start: `Start`,
140 settings: `Ustawienia`,
141 restoreSettings: `Przywróc ustawienia domyślne`,
142 animationGroup: `Animacja`,
143 zoomGroup: `Zoom`,
144 respGroup: `Odrodzenie`,
145 namesGroup: 'Nazwy',
146 massGroup: 'Masa',
147 skinsGroup: `Skiny`,
148 foodGroup: `Pokarm`,
149 transparencyGroup: `Przezroczystość / kolory`,
150 gridGroup: `Siatka / sektory`,
151 miniMapGroup: `Minimapa`,
152 helpersGroup: `Wspomagacze`,
153 mouseGroup: `Sterowanie myszką`,
154 hudGroup: `HUD`,
155 chatGroup: `Czat`,
156 statsGroup: 'Statystyki',
157 extrasGroup: `Dodatkowe`,
158 noSkins: `Wyłącz skiny`,
159 noNames: 'Wyłącz nazwy',
160 noColors: `Wyłącz kolory`,
161 showMass: 'Pokaż masę',
162 skipStats: `Pomiń statystyki po śmierci`,
163 showQuest: `Pokaż zadanie (quest)`,
164 autoZoom: `Auto zoom`,
165 animation: `Opóźnienie animacji`,
166 zoomSpeedValue: `Szybkość zoomu`,
167 quickResp: `Szybkie odrodzenie (klawisz)`,
168 autoResp: 'Auto odrodzenie',
169 autoHideCellsInfo: `Autoukrywanie nazw i masy`,
170 autoHideNames: `Autoukrywanie nazw`,
171 autoHideMass: `Autoukrywanie masy`,
172 autoHideFood: `Autoukrywanie pokarmu (masa)`,
173 autoHideFoodOnZoom: `Autoukrywanie pokarmu (zoom)`,
174 optimizedNames: `Zoptymalizowane nazwy`,
175 hideMyName: `Ukryj własną nazwę`,
176 hideTeammatesNames: `Ukryj nazwy graczy teamu`,
177 optimizedMass: `Zoptymalizowana masa (+/-2%)`,
178 shortMass: `Skrócona masa (k)`,
179 virMassShots: `Licznik strzałów (wirusy)`,
180 hideMyMass: `Ukryj własną masę`,
181 hideEnemiesMass: 'Ukryj masę przeciwników',
182 vanillaSkins: `Podstawowe skiny`,
183 customSkins: 'Własne skiny',
184 myTransparentSkin: `Mój przezroczysty skin`,
185 myCustomColor: `Mój własny kolor`,
186 transparentCells: `Przezroczyste kulki`,
187 transparentViruses: `Przezroczyste wirusy`,
188 transparentSkins: 'Przezroczyste skiny',
189 showGrid: `Siatka`,
190 showBgSectors: 'Sektory w tle',
191 showMapBorders: `Granice mapy`,
192 showGhostCells: `Duchy kulek`,
193 showMiniMap: `Pokaż minimapę`,
194 showMiniMapGrid: `Pokaż siatkę minimapy`,
195 showMiniMapGuides: 'Pokaż prowadnice na minimapie',
196 showMiniMapGhostCells: `Pokaż duchy kulek na minimapie`,
197 oneColoredTeammates: `Jednokolorowi gracze`,
198 optimizedFood: 'Zoptymalizowany pokarm',
199 rainbowFood: `Kolorowy pokarm`,
200 oppColors: 'Kolory przeciwników',
201 oppRings: `Ringi przeciwników`,
202 virColors: `Kolory wirusów`,
203 splitRange: `Zasięg podziału`,
204 virusesRange: `Zasięg wirusów`,
205 textStroke: `Obwódki nazw i masy`,
206 namesStroke: `Obwódki nazw`,
207 massStroke: `Obwódki masy`,
208 cursorTracking: 'Śledzenie kursora',
209 teammatesInd: `Wskaźniki graczy teamu`,
210 mouseSplit: `LPM - Split myszką`,
211 mouseFeed: `PPM - Feed myszką`,
212 mouseInvert: `Odwróć klawisze myszki`,
213 disableChat: `Wyłącz czat`,
214 hideChat: `Ukryj czat`,
215 chatSounds: 'Powiadomienia dźwiękowe',
216 chatEmoticons: `Emotikony`,
217 showChatImages: 'Pokaż obrazki na czacie',
218 showChatVideos: 'Pokaż filmiki na czacie',
219 showChatBox: `Czatbox zamiast wyskakujących wiadomości`,
220 messageSound: `Dźwięk powiadomienia o wiadomości`,
221 commandSound: `Dźwięk powiadomienia o komendzie`,
222 showTop5: `Pokaż top 5 teamu`,
223 showTargeting: 'Pokaż namierzanie',
224 showTime: `Pokaż aktualny czas`,
225 showLbData: 'Pokaż masę w topce',
226 normalLb: `Nagłówek "Topka"`,
227 centeredLb: `Wyśrodkowana topka`,
228 fpsAtTop: `Statystyki na górze`,
229 showStats: `Pokaż statystyki`,
230 showStatsMass: `Statystyki: Masa`,
231 showStatsSTE: `Statystyki: STE`,
232 showStatsN16: `Statystyki: n/16`,
233 showStatsFPS: `Statystyki: FPS`,
234 blockPopups: `Blokuj popupy (reklamy/sklep/zadanie)`,
235 hotkeys: 'Skróty klawiszowe',
236 'hk-inst-assign': `Aby ustawić skrót klawiszowy kliknij na polu skrótu i naciśnij wybrany klawisz.`,
237 'hk-inst-delete': `Aby usunąć skrót klawiszowy kliknij na polu skrótu i naciśnij klawisz DELETE.`,
238 'hk-inst-keys': `Możliwe kombinacje skrótów klawiszowych z użyciem klawiszy CTRL oraz ALT.`,
239 'hk-bots-split': 'Bots split',
240 'hk-bots-feed': 'Bots feed',
241 'hk-bots-ai': 'Bots AI toggle',
242 'hk-feed': `Feed`,
243 'hk-macroFeed': 'Szybki feed',
244 'hk-split': `Podział`,
245 'hk-doubleSplit': `Podwójny podział`,
246 'hk-split16': `Podział na 16`,
247 'hk-pause': `Pauza kulki`,
248 'hk-showTop5': `Pokaż/ukryj top 5 teamu`,
249 'hk-showTime': `Pokaż/ukryj aktualny czas`,
250 'hk-showSplitRange': `Pokaż/ukryj zasięg podziału`,
251 'hk-showSplitInd': `Pokaż/ukryj zasięg podziału z ringami`,
252 'hk-showTeammatesInd': `Pokaż/ukryj wskaźniki graczy teamu`,
253 'hk-showOppColors': `Pokaż/ukryj kolory przeciwników`,
254 'hk-toggleSkins': `Przełącz skiny (własne/standardowe)`,
255 'hk-showSkins': `Pokaż/ukryj skiny`,
256 'hk-transparentSkins': `Włącz/wyłącz przezroczyste skiny`,
257 'hk-showStats': `Pokaż/ukryj statystyki gry`,
258 'hk-toggleCells': `Przełącz kulkę (najmniejsza/największa)`,
259 'hk-showFood': 'Pokaż/ukryj pokarm',
260 'hk-showGrid': 'Pokaż/ukryj siatkę',
261 'hk-showMiniMapGuides': `Pokaż/ukryj prowadnice na minimapie`,
262 'hk-hideChat': `Pokaż/ukryj czat`,
263 'hk-showHUD': `Pokaż/ukryj HUD`,
264 'hk-copyLb': `Kopiuj topkę`,
265 'hk-showLb': `Pokaż/ukryj topkę`,
266 'hk-toggleAutoZoom': 'Włącz/wyłącz auto zoom',
267 'hk-resetZoom': `Reset zoomu`,
268 'hk-zoomLevel': `Zoom - poziom`,
269 'hk-toggleDeath': `Przełącz miejsce śmierci`,
270 'hk-clearChat': `Pokaż historię czatu / Czyść czat`,
271 'hk-showBgSectors': 'Pokaż/ukryj sektory w tle',
272 'hk-hideBots': 'Pokaż/ukryj małe boty',
273 'hk-showNames': `Pokaż/ukryj nazwy`,
274 'hk-hideTeammatesNames': `Pokaż/ukryj nazwy graczy teamu`,
275 'hk-showMass': 'Pokaż/ukryj masę',
276 'hk-showMiniMap': `Pokaż/ukryj minimapę`,
277 'hk-chatMessage': `Napisz wiadomość na czacie`,
278 'hk-quickResp': `Szybkie odrodzenie (respawn)`,
279 'hk-autoResp': `Włącz/wyłacz auto odrodzenie`,
280 'hk-switchServerMode': `Przełącz serwer [publiczny/prywatny]`,
281 'hk-showTargeting': `Pokaż/ukryj panel namierzania`,
282 'hk-setTargeting': 'Włącz/wyłącz namierzanie (śledzenie)',
283 'hk-cancelTargeting': `Zatrzymaj namierzanie`,
284 'hk-changeTarget': `Zmień cel`,
285 'hk-privateMiniMap': `Pokaż cel na minimapie`,
286 'hk-showQuest': `Pokaż/ukryj zadanie`,
287 commands: `Komendy`,
288 comm1: 'Feeduj!',
289 comm2: 'Dziel się!',
290 comm3: `Pomocy na %currentSector%!`,
291 comm4: `Wróg na %currentSector%!`,
292 comm5: `Zabij pomocnika!`,
293 comm6: `Strzel z wirusa!`,
294 comm7: `Zjedz wirusa!`,
295 comm8: `Zjebałem, wybacz.`,
296 comm9: `Ja pierdolę...`,
297 comm0: `Kurwa mać!`,
298 comm10: 'Trick!',
299 comm11: `Lewo!`,
300 comm12: `Góra!`,
301 comm13: `Prawo!`,
302 comm14: `Dół!`,
303 saveComm: `Zapisz komendy`,
304 theme: 'Wygląd',
305 restoreThemeSettings: `Przywróc ustawienia domyślne wyglądu`,
306 basicTheming: `Podstawowy`,
307 themePreset: `Motyw`,
308 themeType: 'Typ motywu',
309 darkTheme: `Ciemny motyw`,
310 lightTheme: 'Jasny motyw',
311 mainColor: `Kolor główny`,
312 bgColor: 'Tło',
313 bordersColor: `Granice mapy`,
314 gridColor: `Siatka`,
315 sectorsColor: `Czcionka sektorów`,
316 namesColor: `Nazwy`,
317 namesStrokeColor: `Obwódki nazw`,
318 massColor: `Masa`,
319 massStrokeColor: `Obwódki masy`,
320 virusColor: `Wirusy`,
321 virusStrokeColor: 'Obwódki wirusów',
322 foodColor: `Pokarm`,
323 namesFont: 'Czcionka nazw',
324 massFont: `Czcionka masy`,
325 sectorsFont: `Czcionka sektorów`,
326 namesScale: 'Skala nazw',
327 massScale: 'Skala masy',
328 virMassScale: `Skala masy wirusów`,
329 strokeScale: `Skala obwódek tekstu`,
330 foodSize: 'Wielkość pokarmu',
331 bordersWidth: 'Grubość granic mapy',
332 sectorsWidth: `Grubość siatki sektorów`,
333 sectorsFontSize: `Rozmiar czcionki sektorów`,
334 cellsAlpha: `Przezroczystość kulek`,
335 skinsAlpha: `Przezroczystość skinów`,
336 virusAlpha: `Przezroczystość wirusów`,
337 textAlpha: 'Przezroczystość nazw i masy',
338 virusStrokeSize: `Grubość obwódki wirusów`,
339 teammatesIndColor: `Wskaźnik gracza`,
340 cursorTrackingColor: 'Śledzenie kursora',
341 splitRangeColor: `Zasięg podziału`,
342 safeAreaColor: `Bezpieczna strefa`,
343 dangerAreaColor: 'Strefa zagrożenia',
344 ghostCellsColor: `Duchy kulek`,
345 ghostCellsAlpha: 'Przezroczystość duchów kulek',
346 menuTheming: `Menu`,
347 menuPreset: `Motyw menu`,
348 menuMainColor: `Kolor główny`,
349 menuBtnTextColor: 'Tekst przycisku',
350 menuPanelColor: `Panel`,
351 menuPanelColor2: `Panel (2)`,
352 menuTextColor: `Tekst panelu`,
353 menuTextColor2: 'Tekst panelu (2)',
354 btn1Color: `Przycisk #1`,
355 btn1Color2: 'Przycisk #1 (2)',
356 btn2Color: `Przycisk #2`,
357 btn2Color2: `Przycisk #2 (2)`,
358 btn3Color: `Przycisk #3`,
359 btn3Color2: 'Przycisk #3 (2)',
360 btn4Color: `Przycisk #4`,
361 btn4Color2: `Przycisk #4 (2)`,
362 menuBg: 'Grafika tła panelu',
363 menuOpacity: 'Przezroczystość',
364 hudTheming: `HUD`,
365 hudMainColor: `Kolor główny`,
366 hudColor: `Tło`,
367 hudTextColor: 'Tekst',
368 statsHudColor: `Statystyki`,
369 timeHudColor: 'Czas',
370 top5MassColor: `Masa`,
371 lbMeColor: `Topka - ja`,
372 lbTeammateColor: `Topka - team`,
373 hudFont: `Czcionka HUD`,
374 hudScale: `Skala HUD`,
375 chatTheming: 'Czat',
376 messageColor: 'Tło wiadomości',
377 messageTextColor: 'Tekst wiadomości',
378 messageTimeColor: `Czas wiadomości`,
379 messageNickColor: `Nick wiadomości`,
380 commandsColor: `Tło komendy`,
381 commandsTextColor: `Tekst komendy`,
382 commandsTimeColor: 'Czas komendy',
383 commandsNickColor: `Nick komendy`,
384 chatBoxColor: `Tło czatboxu`,
385 chatScale: `Skala czatu`,
386 miniMapTheming: `Minimapa`,
387 miniMapSectorsColor: `Sektory`,
388 miniMapSectorColor: `Aktualny sektor`,
389 miniMapGuidesColor: `Prowadnice`,
390 miniMapNickColor: 'Nick',
391 miniMapNickStrokeColor: `Obwódka nicku`,
392 miniMapMyCellColor: 'Moja kulka',
393 miniMapMyCellStrokeColor: `Obwódka mojej kulki`,
394 miniMapTeammatesColor: 'Gracze',
395 miniMapDeathLocationColor: `Miejsce śmierci`,
396 miniMapFont: `Czcionka minimapy`,
397 miniMapNickFont: `Czcionka nicku`,
398 miniMapWidth: `Szerokość minimapy`,
399 miniMapSectorsOpacity: 'Przezroczystość sektorów',
400 miniMapNickSize: `Rozmiar nicku`,
401 miniMapNickStrokeSize: `Grubość obwódki nicku`,
402 miniMapMyCellSize: `Wielkość mojej kulki`,
403 miniMapMyCellStrokeSize: `Grubość obwódki mojej kulki`,
404 miniMapTeammatesSize: `Wielkość graczy`,
405 miniMapGhostCellsColor: `Duchy kulek`,
406 miniMapGhostCellsAlpha: `Przezroczystość duchów kulek`,
407 imagesTheming: 'Grafika / kursory',
408 customBackground: `Grafika tła`,
409 customCursor: `Grafika kursora`,
410 hideChatMsgA: `Czat został włączony!`,
411 hideChatMsgB: `Czat został ukryty!`,
412 showSkinsMsgA: 'Skiny zostały włączone!',
413 showSkinsMsgB: `Skiny zostały ukryte!`,
414 hideSmallBotsMsgA: 'Małe boty stały się widoczne!',
415 hideSmallBotsMsgB: 'Małe boty zostały ukryte!',
416 autoRespMsgA: `Auto odrodzenie zostało włączone!`,
417 autoRespMsgB: `Auto odrodzenie zostało wyłączone!`,
418 autoZoomMsgA: `Auto zoom został włączony!`,
419 autoZoomMsgB: 'Auto zoom został wyłączony!',
420 targetNotSet: `Brak celu`,
421 targetDead: `Nie żyje`,
422 targetDistance: 'Dystans',
423 targetMass: `Masa razem`,
424 totalPartyPlayers: 'Aktywnych graczy',
425 totalPartyMass: 'Łącznie masy',
426 exportImport: `Eksport / import ustawień`,
427 exportSettings: `Eksportuj ustawienia`,
428 exportInfo: 'Aby wyeksportować wybrane ustawienia skopiuj poniższy kod i zapisz go w pliku tekstowym z kodowaniem Unicode.',
429 importSettings: 'Importuj ustawienia',
430 importInfo: `Aby zaimportować wybrane ustawienia wklej poniżej wyeksportowany wcześniej kod i naciśnij przycisk "Importuj ustawienia".`,
431 profile: `Profil`,
432 profiles: `Profile`,
433 skins: 'Skiny',
434 moreSkins: `Dodaj skiny`,
435 thanks: `Dzięki Awesome!`,
436 saveSett: `Zapisz ustawienia`,
437 saved: 'Zapisano!',
438 resetSett: `Resetuj ustawienia`,
439 close: `Zamknij`,
440 enterChatMsg: `Napisz wiadomość`,
441 activeParties: `Aktywne party`,
442 noActiveParties: `Brak aktywnych party ;(`,
443 playlist: `Playlista`,
444 pause: `PAUZA!`,
445 visit: `Odwiedź`,
446 exit: 'OGARio by szymy: Czy na pewno chcesz opuścic grę?',
447 blockWarn: `UWAGA! Popupy zostały zablokowane w ustawieniach.`,
448 unblockPopups: `Odblokuj tymczasowo`,
449 mass: `Masa`,
450 score: `Top`,
451 leaderboard: `Topka`,
452 user: `Użytkownik`,
453 userMuted: `Użytkownik %user% został wyciszony.`,
454 userUnmuted: `Wyłączono wyciszenie użytkownika %user%.`,
455 mute: `Wycisz`,
456 unmute: 'Wyłącz wyciszenie',
457 mutedUsers: `Wyciszeni użytkownicy`,
458 activeUsers: `Aktywni użytkownicy`,
459 showActiveUsers: 'Pokaż aktywnych użytkowników',
460 none: `Brak`,
461 sounds: 'Dźwięki',
462 page_back_button: `Wróć`,
463 page_create_party: `Stwórz party`,
464 page_join_party: `Dołącz`,
465 page_login_and_play: `Zaloguj`,
466 page_logout: `Wyloguj`,
467 page_menu_login_facebook: `Zaloguj z Facebook`,
468 page_menu_login_google: 'Zaloguj z Google',
469 page_menu_main_free_coins: `Darmowe Monety`,
470 page_menu_main_gifts: 'Prezenty',
471 page_menu_main_dailyquests: `Zadania`,
472 page_party_join_error: 'Nie można dołączyć do tego party. Upewnij się, że token jest prawidłowy lub stwórz nowy.',
473 page_play: `Graj`,
474 page_play_as_guest: `Graj jako gość`,
475 page_shop: `Sklep`,
476 page_spectate: `Obserwuj`,
477 page_stats: `Statystyki`
478 },
479 en: {
480 start: `Home`,
481 settings: `Settings`,
482 restoreSettings: `Restore default settings`,
483 animationGroup: `Animation`,
484 zoomGroup: `Zoom`,
485 respGroup: `Respawn`,
486 namesGroup: `Names`,
487 massGroup: 'Mass',
488 skinsGroup: `Skins`,
489 foodGroup: `Food`,
490 transparencyGroup: 'Transparency / colors',
491 gridGroup: 'Grid / sectors',
492 miniMapGroup: `Minimap`,
493 helpersGroup: `Helpers`,
494 mouseGroup: `Mouse control`,
495 hudGroup: `HUD`,
496 chatGroup: `Chat`,
497 statsGroup: `Stats`,
498 extrasGroup: `Extras`,
499 noSkins: `No skins`,
500 noNames: 'No names',
501 noColors: 'No colors',
502 showMass: `Show mass`,
503 skipStats: 'Skip stats after death',
504 showQuest: `Show quest`,
505 autoZoom: `Auto zoom`,
506 animation: `Animation delay`,
507 zoomSpeedValue: `Zoom speed`,
508 quickResp: `Quick respawn (hotkey)`,
509 autoResp: `Auto respawn`,
510 autoHideCellsInfo: `Auto hide names and mass`,
511 autoHideNames: `Auto hide names`,
512 autoHideMass: `Auto hide mass`,
513 autoHideFood: `Auto hide food (mass)`,
514 autoHideFoodOnZoom: 'Auto hide food (zoom)',
515 optimizedNames: `Optimized names`,
516 hideMyName: `Hide my name`,
517 hideTeammatesNames: `Hide teammates names`,
518 optimizedMass: `Optimized mass (+/-2%)`,
519 shortMass: `Short mass (k)`,
520 virMassShots: `Virus shots`,
521 hideMyMass: `Hide my mass`,
522 hideEnemiesMass: `Hide enemies mass`,
523 vanillaSkins: `Vanilla skins`,
524 customSkins: `Custom skins`,
525 myTransparentSkin: `My transparent skin`,
526 myCustomColor: `My custom color`,
527 transparentCells: `Transparent cells`,
528 transparentViruses: 'Transparent viruses',
529 transparentSkins: 'Transparent skins',
530 showGrid: 'Show grid',
531 showBgSectors: `Show background sectors`,
532 showMapBorders: `Show map borders`,
533 showGhostCells: `Ghost cells`,
534 showMiniMap: `Show minimap`,
535 showMiniMapGrid: `Show minimap grid`,
536 showMiniMapGuides: `Show minimap guides`,
537 showMiniMapGhostCells: `Show ghost cells`,
538 oneColoredTeammates: 'One-colored teammates',
539 optimizedFood: `Optimized food`,
540 rainbowFood: `Rainbow food`,
541 oppColors: `Opponents colors`,
542 oppRings: `Opponents rings`,
543 virColors: `Viruses colors`,
544 splitRange: `Split range`,
545 virusesRange: 'Viruses range',
546 textStroke: `Names and mass stroke`,
547 namesStroke: 'Names stroke',
548 massStroke: `Mass stroke`,
549 cursorTracking: 'Cursor tracking',
550 teammatesInd: `Teammates indicators`,
551 mouseSplit: `LMB - Mouse split`,
552 mouseFeed: `RMB - Mouse feed`,
553 mouseInvert: `Invert mouse buttons`,
554 disableChat: 'Disable chat',
555 hideChat: `Hide chat`,
556 chatSounds: `Sound notifications`,
557 chatEmoticons: `Emoticons`,
558 showChatImages: 'Show images on chat',
559 showChatVideos: `Show videos on chat`,
560 showChatBox: `Chatbox instead of popups`,
561 messageSound: `Message notification sound`,
562 commandSound: `Command notification sound`,
563 showTop5: 'Show team top 5',
564 showTargeting: `Show targeting`,
565 showTime: 'Show current time',
566 showLbData: `Show leaderboard mass`,
567 normalLb: `"Leaderboard" header`,
568 centeredLb: `Centered leaderboard`,
569 fpsAtTop: `Game stats at the top`,
570 showStats: `Show game stats`,
571 showStatsMass: `Game stats: Mass`,
572 showStatsSTE: `Game stats: STE`,
573 showStatsN16: `Game stats: n/16`,
574 showStatsFPS: `Game stats: FPS`,
575 blockPopups: `Block popups (ads/shop/quest)`,
576 hotkeys: 'Hotkeys',
577 'hk-inst-assign': `To assign a hotkey click on the input field and press your chosen key.`,
578 'hk-inst-delete': `To delete a hotkey click on the input field and press the DELETE key.`,
579 'hk-inst-keys': `Possible key combinations with the CTRL and ALT keys.`,
580 'hk-bots-split': 'Bots split',
581 'hk-bots-feed': 'Bots feed',
582 'hk-bots-ai': 'Bots AI toggle',
583 'hk-feed': 'Feed',
584 'hk-macroFeed': 'Macro feed',
585 'hk-split': `Split`,
586 'hk-doubleSplit': `Double split`,
587 'hk-split16': `Split 16`,
588 'hk-pause': `Cell pause`,
589 'hk-showTop5': `Show/hide team top 5`,
590 'hk-showTime': `Show/hide current time`,
591 'hk-showSplitRange': `Show/hide split range`,
592 'hk-showSplitInd': 'Show/hide split indicators',
593 'hk-showTeammatesInd': 'Show/hide teammates indicators',
594 'hk-showOppColors': `Show/hide opponents colors`,
595 'hk-toggleSkins': 'Toggle skins (custom/default)',
596 'hk-showSkins': `Show/hide skins`,
597 'hk-transparentSkins': 'Toggle transparent skins',
598 'hk-showStats': `Show/hide game stats`,
599 'hk-toggleCells': `Toggle own cells (smallest/biggest)`,
600 'hk-showFood': `Show/hide food`,
601 'hk-showGrid': `Show/hide grid`,
602 'hk-showMiniMapGuides': 'Show/hide minimap guides',
603 'hk-hideChat': `Show/hide chat`,
604 'hk-showHUD': `Show/hide HUD`,
605 'hk-copyLb': `Copy leaderboard`,
606 'hk-showLb': 'Show/hide leaderboard',
607 'hk-toggleAutoZoom': `Toggle auto zoom`,
608 'hk-resetZoom': `Reset zoom`,
609 'hk-zoomLevel': 'Zoom level',
610 'hk-toggleDeath': `Toggle death location`,
611 'hk-clearChat': `Show chat history / Clear chat`,
612 'hk-showBgSectors': `Show/hide background sectors`,
613 'hk-hideBots': `Show/hide small bots`,
614 'hk-showNames': 'Show/hide names',
615 'hk-hideTeammatesNames': `Show/hide teammates names`,
616 'hk-showMass': `Show/hide mass`,
617 'hk-showMiniMap': 'Show/hide minimap',
618 'hk-chatMessage': `Enter chat message`,
619 'hk-quickResp': `Quick respawn`,
620 'hk-autoResp': `Toggle auto respawn`,
621 'hk-switchServerMode': `Switch server [public/private]`,
622 'hk-showTargeting': 'Show/hide targeting panel',
623 'hk-setTargeting': `Start/stop targeting (following)`,
624 'hk-cancelTargeting': 'Cancel targeting',
625 'hk-changeTarget': 'Change target',
626 'hk-privateMiniMap': 'Show target on the minimap',
627 'hk-showQuest': 'Show/hide quest',
628 commands: `Commands`,
629 comm1: `Feed me!`,
630 comm2: `Split into me!`,
631 comm3: 'Need backup at %currentSector%!',
632 comm4: 'Enemy spotted at %currentSector%!',
633 comm5: `Need a teammate!`,
634 comm6: 'Tank the virus!',
635 comm7: `Eat the virus!`,
636 comm8: `Let's bait!`,
637 comm9: `Fake tricksplit!`,
638 comm0: `Fuck!`,
639 comm10: `Tricksplit!`,
640 comm11: `Left!`,
641 comm12: `Up!`,
642 comm13: 'Right!',
643 comm14: 'Bottom!',
644 saveComm: 'Save commands',
645 theme: `Theme`,
646 restoreThemeSettings: `Restore theme default settings`,
647 basicTheming: 'Basic theming',
648 themePreset: `Theme preset`,
649 themeType: 'Theme type',
650 darkTheme: 'Dark theme',
651 lightTheme: `Light theme`,
652 mainColor: 'Main color',
653 bgColor: `Background`,
654 bordersColor: 'Map borders',
655 gridColor: `Grid`,
656 sectorsColor: `Sectors font`,
657 namesColor: `Names`,
658 namesStrokeColor: `Names stroke`,
659 massColor: 'Mass',
660 massStrokeColor: `Mass stroke`,
661 virusColor: `Virus`,
662 virusStrokeColor: `Virus stroke`,
663 foodColor: `Food`,
664 namesFont: 'Names font',
665 massFont: `Mass font`,
666 sectorsFont: 'Sectors font',
667 namesScale: `Names scale`,
668 massScale: 'Mass scale',
669 virMassScale: 'Virus mass scale',
670 strokeScale: `Text stroke scale`,
671 foodSize: `Food size`,
672 bordersWidth: 'Map borders width',
673 sectorsWidth: `Sectors grid width`,
674 sectorsFontSize: `Sectors font size`,
675 cellsAlpha: `Cells transparency`,
676 skinsAlpha: 'Skins transparency',
677 virusAlpha: `Virus transparency`,
678 textAlpha: `Names & mass transparency`,
679 virusStrokeSize: `Virus stroke size`,
680 teammatesIndColor: `Teammate indicator`,
681 cursorTrackingColor: `Cursor tracking`,
682 splitRangeColor: `Split range`,
683 safeAreaColor: `Safe area`,
684 dangerAreaColor: `Danger area`,
685 ghostCellsColor: `Ghost cells`,
686 ghostCellsAlpha: 'Ghost cells transparency',
687 menuTheming: `Menu`,
688 menuPreset: `Menu theme`,
689 menuMainColor: `Main color`,
690 menuBtnTextColor: `Button text`,
691 menuPanelColor: `Panel`,
692 menuPanelColor2: `Panel (2)`,
693 menuTextColor: 'Panel text',
694 menuTextColor2: `Panel text (2)`,
695 btn1Color: `Button #1`,
696 btn1Color2: `Button #1 (2)`,
697 btn2Color: 'Button #2',
698 btn2Color2: `Button #2 (2)`,
699 btn3Color: `Button #3`,
700 btn3Color2: `Button #3 (2)`,
701 btn4Color: `Button #4`,
702 btn4Color2: `Button #4 (2)`,
703 menuBg: 'Panel background image',
704 menuOpacity: `Transparency`,
705 hudTheming: `HUD`,
706 hudMainColor: `Main color`,
707 hudColor: 'Background',
708 hudTextColor: `Text`,
709 statsHudColor: `Stats`,
710 timeHudColor: 'Time',
711 top5MassColor: `Mass`,
712 lbMeColor: `Leaderboard - me`,
713 lbTeammateColor: `Leaderboard - teammate`,
714 hudFont: `HUD font`,
715 hudScale: `HUD scale`,
716 chatTheming: `Chat`,
717 messageColor: 'Message background',
718 messageTextColor: 'Message text',
719 messageTimeColor: `Message time`,
720 messageNickColor: `Message nick`,
721 commandsColor: `Command background`,
722 commandsTextColor: 'Command text',
723 commandsTimeColor: `Command time`,
724 commandsNickColor: `Command nick`,
725 chatBoxColor: `Chatbox color`,
726 chatScale: `Chat scale`,
727 miniMapTheming: `Minimap`,
728 miniMapSectorsColor: `Sectors`,
729 miniMapSectorColor: `Current sector`,
730 miniMapGuidesColor: `Guides`,
731 miniMapNickColor: `Nick`,
732 miniMapNickStrokeColor: `Nick stroke`,
733 miniMapMyCellColor: `My cell`,
734 miniMapMyCellStrokeColor: `My cell stroke`,
735 miniMapTeammatesColor: `Teammates`,
736 miniMapDeathLocationColor: `Death location`,
737 miniMapFont: `Minimap font`,
738 miniMapNickFont: `Nick font`,
739 miniMapWidth: `Minimap width`,
740 miniMapSectorsOpacity: `Sectors transparency`,
741 miniMapNickSize: 'Nick size',
742 miniMapNickStrokeSize: 'Nick stroke size',
743 miniMapMyCellSize: `My cell size`,
744 miniMapMyCellStrokeSize: `My cell stroke size`,
745 miniMapTeammatesSize: 'Teammates size',
746 miniMapGhostCellsColor: `Ghost cells`,
747 miniMapGhostCellsAlpha: `Ghost cells transparency`,
748 imagesTheming: `Graphics / cursors`,
749 customBackground: `Custom background image`,
750 customCursor: `Custom cursor image`,
751 hideChatMsgA: `Chat is visible!`,
752 hideChatMsgB: `Chat is hidden!`,
753 showSkinsMsgA: `Skins are visible!`,
754 showSkinsMsgB: `Skins are hidden!`,
755 hideSmallBotsMsgA: `Small bots are visible!`,
756 hideSmallBotsMsgB: `Small bots are hidden!`,
757 autoRespMsgA: `Auto respawn is on!`,
758 autoRespMsgB: `Auto respawn is off!`,
759 autoZoomMsgA: `Auto zoom is on!`,
760 autoZoomMsgB: `Auto zoom is off!`,
761 targetNotSet: `Target not set`,
762 targetDead: 'Dead',
763 targetDistance: 'Distance',
764 targetMass: `Mass altogether`,
765 totalPartyPlayers: `Active players`,
766 totalPartyMass: `Total mass`,
767 exportImport: `Export / import settings`,
768 exportSettings: 'Export settings',
769 exportInfo: 'To export selected settings copy the code below and save it to a text file encoded in Unicode.',
770 importSettings: `Import settings`,
771 importInfo: `To import selected settings paste an exported code below and press the "Import settings" button.`,
772 profile: `Profile`,
773 profiles: 'Profiles',
774 skins: `Skins`,
775 moreSkins: `Add skins`,
776 thanks: `Thanks to Awesome!`,
777 saveSett: 'Save settings',
778 saved: `Saved!`,
779 resetSett: `Reset to default`,
780 close: `Close`,
781 enterChatMsg: `Enter chat message`,
782 activeParties: `Active parties`,
783 noActiveParties: `No active parties ;(`,
784 playlist: `Playlist`,
785 pause: `PAUSE!`,
786 visit: 'Visit',
787 exit: 'OGARio by szymy: Are you sure you want to quit the game?',
788 blockWarn: `WARNING! Popups are blocked in the settings.`,
789 unblockPopups: `Temporary unblock`,
790 mass: 'Mass',
791 score: `Score`,
792 leaderboard: `Leaderboard`,
793 user: 'User',
794 userMuted: 'User %user% has been muted.',
795 userUnmuted: `User %user% has been unmuted.`,
796 mute: `Mute`,
797 unmute: 'Unmute',
798 mutedUsers: `Muted users`,
799 activeUsers: `Active users`,
800 showActiveUsers: `Show active users`,
801 none: `None`,
802 sounds: `Sounds`,
803 page_menu_main_free_coins: 'Free Coins',
804 page_menu_main_gifts: 'Gifts',
805 page_menu_main_dailyquests: `Daily Quest`,
806 page_shop: `Shop`
807 }
808 };
809 let lang = 'en';
810 const userLanguage = window.navigator.language || window.navigator.userLanguage;
811 if (userLanguage && displayText.hasOwnProperty(userLanguage)) {
812 lang = userLanguage;
813 }
814 const textLanguage = displayText[lang];
815 let chatCommand = {
816 comm1: textLanguage.comm1,
817 comm2: textLanguage.comm2,
818 comm3: textLanguage.comm3,
819 comm4: textLanguage.comm4,
820 comm5: textLanguage.comm5,
821 comm6: textLanguage.comm6,
822 comm7: textLanguage.comm7,
823 comm8: textLanguage.comm8,
824 comm9: textLanguage.comm9,
825 comm0: textLanguage.comm0,
826 comm10: textLanguage.comm10,
827 comm11: textLanguage.comm11,
828 comm12: textLanguage.comm12,
829 comm13: textLanguage.comm13,
830 comm14: textLanguage.comm14
831 };
832 const escapeChar = {
833 '&': `&`,
834 '<': `<`,
835 '>': `>`,
836 '"': `"`,
837 '\'': ''',
838 '/': `/`
839 };
840 const emojiChar = {
841 ':)': `smile.svg`,
842 ';)': `wink.svg`,
843 '=)': 'smirk.svg',
844 ':D': `grin.svg`,
845 'X-D': `xgrin.svg`,
846 '=D': `joy.svg`,
847 ':(': 'sad.svg',
848 ';(': `cry.svg`,
849 ':P': `tongue.svg`,
850 ';P': 'tonguew.svg',
851 ':*': 'kiss.svg',
852 '$)': 'smileh.svg',
853 '<3': `heart.svg`,
854 '8=)': 'cool.svg',
855 ':o': `astonished.svg`,
856 '(:|': `sweat.svg`,
857 ':|': `neutral.svg`,
858 ':': 'unamused.svg',
859 ':@': 'pouting.svg',
860 '|-)': 'sleep.svg',
861 '^_^': 'relaxed.svg',
862 '-_-': `expressionless.svg`,
863 '$_$': `money.svg`,
864 'O:)': `angel.svg`,
865 '3:)': `devil.svg`,
866 '(poop)': `poo.svg`,
867 '(fuck)': 'finger.svg',
868 '(clap)': `clap.svg`,
869 '(ok)': `ok.svg`,
870 '(victory)': 'victory.svg',
871 '(y)': 'thumb.svg',
872 '(n)': `thumbd.svg`
873 };
874 const SkinExplain = [{
875 name: `imgur.com`,
876 url: `https://imgur.com/`,
877 example: `https://i.imgur.com/xdmUp5N.png`,
878 pattern: `https?:\/\/\w+\.imgur\.com\/\w{6,}\.(?:%file_ext%)\??\d*`
879 }, {
880 name: `put.re`,
881 url: 'https://put.re/',
882 example: 'https://s.put.re/iYHAW65g.png',
883 pattern: `https?:\/\/\w+\.put\.re\/\w{8,}\.(?:%file_ext%)`
884 }, {
885 name: `postimages.org`,
886 url: `https://postimages.org/`,
887 example: 'https://i.postimg.cc/zzK0sRPg/xdmUp5N.png',
888 pattern: 'https?:\/\/\w+\.postimg\.cc\/\w{8,}\/\w+\.(?:%file_ext%)'
889 }];
890 const gameTheme = {
891 'ogario-v3': {
892 name: `OGARio v3`,
893 darkTheme: true,
894 mainColor: '#01d9cc',
895 bgColor: '#000a11',
896 bordersColor: `#01d9cc`,
897 gridColor: `#00243e`,
898 sectorsColor: `#00243e`,
899 namesColor: '#ffffff',
900 namesStrokeColor: `#000000`,
901 massColor: `#ffffff`,
902 massStrokeColor: '#000000',
903 virusColor: `#002f52`,
904 virusStrokeColor: `#00b9e8`,
905 foodColor: `#5000ff`,
906 teammatesIndColor: `#ffffff`,
907 cursorTrackingColor: `#ffffff`,
908 splitRangeColor: `#ffffff`,
909 safeAreaColor: `#ffffff`,
910 dangerAreaColor: `#bf00aa`,
911 namesFont: 'ubuntu-bold',
912 massFont: `ubuntu-bold`,
913 sectorsFont: 'ubuntu',
914 namesScale: 1,
915 massScale: 3,
916 foodSize: 5,
917 bordersWidth: 40,
918 sectorsWidth: 40,
919 sectorsFontSize: 1200,
920 cellsAlpha: 0.9,
921 skinsAlpha: 0.7,
922 virusAlpha: 0.6,
923 textAlpha: 1,
924 virusStrokeSize: 14,
925 menuPreset: `ogario-v3`,
926 menuMainColor: `#01d9cc`,
927 menuBtnTextColor: `#ffffff`,
928 menuPanelColor: `#00243e`,
929 menuPanelColor2: '#002f52',
930 menuTextColor: `#ffffff`,
931 menuTextColor2: `#8096a7`,
932 btn1Color: `#018cf6`,
933 btn1Color2: '#0176ce',
934 btn2Color: `#00b9e8`,
935 btn2Color2: `#0099c0`,
936 btn3Color: '#8d5fe6',
937 btn3Color2: `#814ee3`,
938 btn4Color: `#bf00aa`,
939 btn4Color2: '#a80096',
940 menuBg: `https://cdn.ogario.ovh/static/img/pattern.png`,
941 menuOpacity: 0.96,
942 hudMainColor: `#01d9cc`,
943 hudColor: `rgba(0,0,0,0.4)`,
944 hudTextColor: `#ffffff`,
945 statsHudColor: `#ffffff`,
946 timeHudColor: `#01d9cc`,
947 top5MassColor: '#bf00aa',
948 lbMeColor: '#bf00aa',
949 lbTeammateColor: `#018cf6`,
950 hudFont: 'ubuntu-bold',
951 hudScale: 1,
952 messageColor: `rgba(0,0,0,0.4)`,
953 messageTextColor: `#ffffff`,
954 messageTimeColor: '#018cf6',
955 messageNickColor: `#01d9cc`,
956 commandsColor: 'rgba(191,0,170,0.9)',
957 commandsTextColor: `#ffffff`,
958 commandsTimeColor: `#bf00aa`,
959 commandsNickColor: `#ffffff`,
960 chatBoxColor: 'rgba(0,0,0,0.4)',
961 chatScale: 1,
962 miniMapSectorsColor: '#ffffff',
963 miniMapSectorColor: `#01d9cc`,
964 miniMapGuidesColor: `#bf00aa`,
965 miniMapNickColor: `#ffffff`,
966 miniMapNickStrokeColor: '#000000',
967 miniMapMyCellColor: `#ffffff`,
968 miniMapMyCellStrokeColor: `#bf00aa`,
969 miniMapTeammatesColor: `#01d9cc`,
970 miniMapDeathLocationColor: `#bf00aa`,
971 miniMapFont: `ubuntu-bold`,
972 miniMapNickFont: `ubuntu-bold`,
973 miniMapWidth: 240,
974 miniMapSectorsOpacity: 0.1,
975 miniMapNickSize: 11,
976 miniMapNickStrokeSize: 2,
977 miniMapMyCellSize: 7.5,
978 miniMapMyCellStrokeSize: 4,
979 miniMapTeammatesSize: 5.5,
980 customBackground: '',
981 customCursor: `https://cdn.ogario.ovh/static/img/cursors/cursor_02.cur`
982 },
983 'ogario-orange': {
984 name: `OGARio v2`,
985 darkTheme: true,
986 mainColor: `#ff7800`,
987 bgColor: `#111111`,
988 bordersColor: `#ff7800`,
989 gridColor: '#292929',
990 sectorsColor: `#292929`,
991 namesColor: '#ffffff',
992 namesStrokeColor: `#000000`,
993 massColor: `#ffffff`,
994 massStrokeColor: '#000000',
995 virusColor: `#666666`,
996 virusStrokeColor: `#666666`,
997 foodColor: `#e16400`,
998 hudMainColor: '#ff7800',
999 statsHudColor: `#ff7800`,
1000 top5MassColor: `#ff7800`,
1001 timeHudColor: `#ff7800`,
1002 messageNickColor: `#ff7800`,
1003 commandsColor: `rgba(255,120,0,0.9)`,
1004 commandsTimeColor: `#ff7800`,
1005 commandsTextColor: `#ffffff`,
1006 miniMapSectorsColor: `#ffffff`,
1007 miniMapSectorColor: `#ff7800`,
1008 miniMapGuidesColor: `#ff7800`,
1009 miniMapMyCellColor: `#ffffff`,
1010 miniMapMyCellStrokeColor: `#ff7800`,
1011 miniMapTeammatesColor: '#ff7800',
1012 miniMapDeathLocationColor: `#ff7800`,
1013 miniMapSectorsOpacity: 0.1
1014 },
1015 'ogario-gold': {
1016 name: `OGARio LE`,
1017 darkTheme: true,
1018 mainColor: `#b5a642`,
1019 bgColor: `#000000`,
1020 bordersColor: `#b5a642`,
1021 gridColor: `#111111`,
1022 sectorsColor: `#111111`,
1023 namesColor: '#ffffff',
1024 namesStrokeColor: `#000000`,
1025 massColor: `#ffffff`,
1026 massStrokeColor: '#000000',
1027 virusColor: `#666666`,
1028 virusStrokeColor: '#666666',
1029 foodColor: `#998c36`,
1030 hudMainColor: '#b5a642',
1031 statsHudColor: `#b5a642`,
1032 top5MassColor: `#b5a642`,
1033 timeHudColor: '#b5a642',
1034 messageNickColor: '#b5a642',
1035 commandsColor: 'rgba(181,166,66,0.9)',
1036 commandsTimeColor: `#b5a642`,
1037 commandsTextColor: `#ffffff`,
1038 miniMapSectorsColor: `#ffffff`,
1039 miniMapSectorColor: `#b5a642`,
1040 miniMapGuidesColor: `#b5a642`,
1041 miniMapMyCellColor: `#ffffff`,
1042 miniMapMyCellStrokeColor: `#b5a642`,
1043 miniMapTeammatesColor: `#b5a642`,
1044 miniMapDeathLocationColor: `#b5a642`,
1045 miniMapSectorsOpacity: 0.1
1046 },
1047 'ref-style': {
1048 name: "ReF's Style",
1049 bgColor: "#000000",
1050 bordersColor: "#0074fc",
1051 bordersWidth: 80,
1052 btn1Color: "#0074fc",
1053 btn1Color2: "#3592ff",
1054 btn2Color: "#3592ff",
1055 btn2Color2: "#3592ff",
1056 btn3Color: "#3592ff",
1057 btn3Color2: "#3592ff",
1058 btn4Color: "#3592ff",
1059 btn4Color2: "#3592ff",
1060 cellsAlpha: 0.99,
1061 chatBoxColor: "rgba(0,0,0,0.4)",
1062 chatScale: 1,
1063 commandsColor: "rgba(0,116,252,1)",
1064 commandsNickColor: "#ffffff",
1065 commandsTextColor: "#ffffff",
1066 commandsTimeColor: "#000000",
1067 cursorTrackingColor: "#ffffff",
1068 customBackground: "",
1069 customCursor: "",
1070 dangerAreaColor: "#0074fc",
1071 darkTheme: true,
1072 foodColor: "#0074fc",
1073 foodSize: 1,
1074 ghostCellsAlpha: 0.3,
1075 ghostCellsColor: "#ffffff",
1076 gridColor: "#0094ff",
1077 hudColor: "rgba(0,0,0,0.49)",
1078 hudFont: "ubuntu-bold",
1079 hudFontFamily: "Ubuntu",
1080 hudFontWeight: 700,
1081 hudMainColor: "#0074fc",
1082 hudScale: 1.15,
1083 hudTextColor: "#ffffff",
1084 lbMeColor: "#0074fc",
1085 lbTeammateColor: "#0074fc",
1086 mainColor: "#01d9cc",
1087 massColor: "#ffffff",
1088 massFont: "ubuntu-bold",
1089 massFontFamily: "Ubuntu",
1090 massFontWeight: 700,
1091 massScale: 0.9,
1092 massStrokeColor: "#000000",
1093 menuBg: "",
1094 menuBtnTextColor: "#ffffff",
1095 menuMainColor: "#0074fc",
1096 menuOpacity: 1,
1097 menuPanelColor: "#050008",
1098 menuPanelColor2: "#1d0526",
1099 menuPreset: "ogario-v3",
1100 menuTextColor: "#ffffff",
1101 menuTextColor2: "#65458f",
1102 messageColor: "rgba(0,0,0,0.4)",
1103 messageNickColor: "#0074fc",
1104 messageTextColor: "#e8e8e8",
1105 messageTimeColor: "#545454",
1106 miniMapDeathLocationColor: "#2b2b2b",
1107 miniMapFont: "ubuntu-bold",
1108 miniMapFontFamily: "Ubuntu",
1109 miniMapFontWeight: 700,
1110 miniMapGhostCellsAlpha: 0.15,
1111 miniMapGhostCellsColor: "#ffffff",
1112 miniMapGuidesColor: "#ff00a8",
1113 miniMapMyCellColor: "#f0ff3d",
1114 miniMapMyCellSize: 5,
1115 miniMapMyCellStrokeColor: "#acba07",
1116 miniMapMyCellStrokeSize: 0,
1117 miniMapNickColor: "#ffffff",
1118 miniMapNickFont: "ubuntu-bold",
1119 miniMapNickFontFamily: "Ubuntu",
1120 miniMapNickFontWeight: 700,
1121 miniMapNickSize: 9,
1122 miniMapNickStrokeColor: "#4d4d4d",
1123 miniMapNickStrokeSize: 0,
1124 miniMapSectorColor: "#000000",
1125 miniMapSectorsColor: "#ffffff",
1126 miniMapSectorsOpacity: 0.1,
1127 miniMapTeammatesColor: "#305eff",
1128 miniMapTeammatesSize: 5,
1129 miniMapTop: 25,
1130 miniMapWidth: 250,
1131 namesColor: "#ffffff",
1132 namesFont: "ubuntu-bold",
1133 namesFontFamily: "Ubuntu",
1134 namesFontWeight: 700,
1135 namesScale: 0.9,
1136 namesStrokeColor: "#000000",
1137 safeAreaColor: "#ffffff",
1138 sectorsColor: "#0074fc",
1139 sectorsFont: "ubuntu",
1140 sectorsFontFamily: "Ubuntu",
1141 sectorsFontSize: 940,
1142 sectorsFontWeight: 400,
1143 sectorsWidth: 6,
1144 sectorsX: 5,
1145 sectorsY: 5,
1146 skinsAlpha: 0.7,
1147 splitRangeColor: "#ffffff",
1148 statsHudColor: "#ffffff",
1149 strokeScale: 1,
1150 teammatesIndColor: "#ffffff",
1151 textAlpha: 1,
1152 timeHudColor: "#0074fc",
1153 top5MassColor: "#0074fc",
1154 virMassScale: 2,
1155 virusAlpha: 0.4,
1156 virusColor: "#3b3b3b",
1157 virusStrokeColor: "#ffffff",
1158 virusStrokeSize: 10,
1159 customBackground: '',
1160 customCursor: ``
1161 },
1162 'turbo-style': {
1163 name: "Turbo's Style",
1164 bgColor: "#000000",
1165 bordersColor: "#ff2b77",
1166 bordersWidth: 80,
1167 btn1Color: "#ff2b77",
1168 btn1Color2: "#ff005b",
1169 btn2Color: "#ff2b77",
1170 btn2Color2: "#ff005b",
1171 btn3Color: "#ff2b77",
1172 btn3Color2: "#ff005b",
1173 btn4Color: "#ff2b77",
1174 btn4Color2: "#ff005b",
1175 cellsAlpha: 0.99,
1176 chatBoxColor: "rgba(0,0,0,0.4)",
1177 chatScale: 1,
1178 commandsColor: "rgba(255,43,119,1)",
1179 commandsNickColor: "#ffffff",
1180 commandsTextColor: "#ffffff",
1181 commandsTimeColor: "#000000",
1182 cursorTrackingColor: "#ffffff",
1183 customBackground: "",
1184 customCursor: "",
1185 dangerAreaColor: "#ff2b77",
1186 darkTheme: true,
1187 foodColor: "#ff2b77",
1188 foodSize: 1,
1189 ghostCellsAlpha: 0.3,
1190 ghostCellsColor: "#ffffff",
1191 gridColor: "#ff2b77",
1192 hudColor: "rgba(0,0,0,0.49)",
1193 hudFont: "ubuntu-bold",
1194 hudFontFamily: "Ubuntu",
1195 hudFontWeight: 700,
1196 hudMainColor: "#ff2b77",
1197 hudScale: 1.15,
1198 hudTextColor: "#ffffff",
1199 lbMeColor: "#ff2b77",
1200 lbTeammateColor: "#ff2b77",
1201 mainColor: "#ff2b77",
1202 massColor: "#000000",
1203 massFont: "ubuntu-bold",
1204 massFontFamily: "Ubuntu",
1205 massFontWeight: 700,
1206 massScale: 0.9,
1207 massStrokeColor: "#ffffff",
1208 menuBg: "",
1209 menuBtnTextColor: "#ffffff",
1210 menuMainColor: "#ff2b77",
1211 menuOpacity: 1,
1212 menuPanelColor: "#23192c",
1213 menuPanelColor2: "#382946",
1214 menuPreset: "ogario-v3",
1215 menuTextColor: "#ffffff",
1216 menuTextColor2: "#65458f",
1217 messageColor: "rgba(0,0,0,0.4)",
1218 messageNickColor: "#ff2b77",
1219 messageTextColor: "#e8e8e8",
1220 messageTimeColor: "#545454",
1221 miniMapDeathLocationColor: "#2b2b2b",
1222 miniMapFont: "ubuntu-bold",
1223 miniMapFontFamily: "Ubuntu",
1224 miniMapFontWeight: 700,
1225 miniMapGhostCellsAlpha: 0.15,
1226 miniMapGhostCellsColor: "#ffffff",
1227 miniMapGuidesColor: "#ff2b77",
1228 miniMapMyCellColor: "#ffdd56",
1229 miniMapMyCellSize: 5,
1230 miniMapMyCellStrokeColor: "#ff9a6b",
1231 miniMapMyCellStrokeSize: 0,
1232 miniMapNickColor: "#ffffff",
1233 miniMapNickFont: "ubuntu-bold",
1234 miniMapNickFontFamily: "Ubuntu",
1235 miniMapNickFontWeight: 700,
1236 miniMapNickSize: 9,
1237 miniMapNickStrokeColor: "#4d4d4d",
1238 miniMapNickStrokeSize: 0,
1239 miniMapSectorColor: "#000000",
1240 miniMapSectorsColor: "#ffffff",
1241 miniMapSectorsOpacity: 0.1,
1242 miniMapTeammatesColor: "#ff005b",
1243 miniMapTeammatesSize: 5,
1244 miniMapTop: 25,
1245 miniMapWidth: 250,
1246 namesColor: "#000000",
1247 namesFont: "ubuntu-bold",
1248 namesFontFamily: "Ubuntu",
1249 namesFontWeight: 700,
1250 namesScale: 0.9,
1251 namesStrokeColor: "#ffffff",
1252 safeAreaColor: "#ffffff",
1253 sectorsColor: "#ff2b77",
1254 sectorsFont: "ubuntu",
1255 sectorsFontFamily: "Ubuntu",
1256 sectorsFontSize: 940,
1257 sectorsFontWeight: 400,
1258 sectorsWidth: 6,
1259 sectorsX: 5,
1260 sectorsY: 5,
1261 skinsAlpha: 0.7,
1262 splitRangeColor: "#ffffff",
1263 statsHudColor: "#ffffff",
1264 strokeScale: 1,
1265 teammatesIndColor: "#ffffff",
1266 textAlpha: 1,
1267 timeHudColor: "#ff2b77",
1268 top5MassColor: "#ff2b77",
1269 virMassScale: 2,
1270 virusAlpha: 0.4,
1271 virusColor: "#3b3b3b",
1272 virusStrokeColor: "#ff2b77",
1273 virusStrokeSize: 10,
1274 customBackground: '',
1275 customCursor: ``
1276 },
1277 'sniikz-style': {
1278 name: `SniiKz's Style`,
1279 darkTheme: true,
1280 mainColor: `#01d9cc`,
1281 bgColor: `#000000`,
1282 bordersColor: '#ffffff',
1283 gridColor: `#00243e`,
1284 sectorsColor: '#00243e',
1285 namesColor: `#ffffff`,
1286 namesStrokeColor: '#000000',
1287 massColor: '#ffffff',
1288 massStrokeColor: `#000000`,
1289 virusColor: '#3b3b3b',
1290 virusStrokeColor: `#ffffff`,
1291 foodColor: `#5000ff`,
1292 teammatesIndColor: `#ffffff`,
1293 cursorTrackingColor: `#ffffff`,
1294 splitRangeColor: '#ffffff',
1295 safeAreaColor: `#ffffff`,
1296 dangerAreaColor: '#bf00aa',
1297 massScale: 4,
1298 foodSize: 1,
1299 bordersWidth: 40,
1300 sectorsWidth: 40,
1301 sectorsFontSize: 1200,
1302 cellsAlpha: 0.99,
1303 skinsAlpha: 0.7,
1304 virusAlpha: 0.4,
1305 virusStrokeSize: 10,
1306 menuPreset: `ogario-v3`,
1307 menuMainColor: `#fc0079`,
1308 menuBtnTextColor: `#ffffff`,
1309 menuPanelColor: '#050008',
1310 menuPanelColor2: `#1d0526`,
1311 menuTextColor: `#ffffff`,
1312 menuTextColor2: `#65458f`,
1313 btn1Color: '#4f0242',
1314 btn1Color2: `#3b0431`,
1315 btn2Color: `#6b0036`,
1316 btn2Color2: `#4d0227`,
1317 btn3Color: `#aa084e`,
1318 btn3Color2: `#80063b`,
1319 btn4Color: `#aa084e`,
1320 btn4Color2: '#8a063f',
1321 menuBg: `https://cdn.ogario.ovh/static/img/pattern.png`,
1322 menuOpacity: 1,
1323 hudMainColor: '#5974ff',
1324 hudColor: 'rgba(36,36,36,0.49)',
1325 hudTextColor: `#ffffff`,
1326 statsHudColor: `#ffffff`,
1327 timeHudColor: '#737373',
1328 top5MassColor: `#1fe000`,
1329 lbMeColor: '#bf00aa',
1330 lbTeammateColor: `#018cf6`,
1331 hudScale: 1.15,
1332 messageColor: 'rgba(0,0,0,0.4)',
1333 messageTextColor: `#e8e8e8`,
1334 messageTimeColor: '#545454',
1335 messageNickColor: '#05ff00',
1336 commandsColor: `rgba(36,36,36,0.9)`,
1337 commandsTextColor: `#ffffff`,
1338 commandsTimeColor: '#545454',
1339 commandsNickColor: `#ffffff`,
1340 chatBoxColor: `rgba(0,0,0,0.4)`,
1341 chatScale: 1,
1342 miniMapSectorsColor: '#ffffff',
1343 miniMapSectorColor: `#000000`,
1344 miniMapGuidesColor: `#ff00a8`,
1345 miniMapNickColor: `#ffffff`,
1346 miniMapNickStrokeColor: `#4d4d4d`,
1347 miniMapMyCellColor: '#f0ff3d',
1348 miniMapMyCellStrokeColor: `#acba07`,
1349 miniMapTeammatesColor: '#305eff',
1350 miniMapDeathLocationColor: '#2b2b2b',
1351 miniMapWidth: 250,
1352 miniMapSectorsOpacity: 0.1,
1353 miniMapNickSize: 9,
1354 miniMapNickStrokeSize: 0,
1355 miniMapMyCellSize: 5,
1356 miniMapMyCellStrokeSize: 0,
1357 miniMapTeammatesSize: 5,
1358 customBackground: '',
1359 customCursor: `https://cdn.ogario.ovh/static/img/cursors/cursor_01.cur`
1360 },
1361 'hkg-style': {
1362 name: `HKG Style`,
1363 darkTheme: true,
1364 mainColor: '#651fff',
1365 bgColor: `#000000`,
1366 bordersColor: `#ffffff`,
1367 gridColor: `#111111`,
1368 sectorsColor: `#111111`,
1369 namesColor: `#ffffff`,
1370 namesStrokeColor: `#000000`,
1371 massColor: `#ffffff`,
1372 massStrokeColor: `#000000`,
1373 virusColor: `#666666`,
1374 virusStrokeColor: `#666666`,
1375 foodColor: `#651fff`,
1376 hudMainColor: `#651fff`,
1377 statsHudColor: '#651fff',
1378 top5MassColor: '#651fff',
1379 timeHudColor: `#651fff`,
1380 messageNickColor: `#651fff`,
1381 commandsColor: `rgba(101,31,255,0.9)`,
1382 commandsTimeColor: `#651fff`,
1383 commandsTextColor: `#ffffff`,
1384 miniMapSectorsColor: '#ffffff',
1385 miniMapSectorColor: `#651fff`,
1386 miniMapGuidesColor: `#651fff`,
1387 miniMapMyCellColor: `#ffffff`,
1388 miniMapMyCellStrokeColor: `#651fff`,
1389 miniMapTeammatesColor: '#651fff',
1390 miniMapDeathLocationColor: '#651fff',
1391 miniMapSectorsOpacity: 0.1
1392 },
1393 'agario-light': {
1394 name: `Agar.io Light`,
1395 darkTheme: false,
1396 mainColor: `#ffffff`,
1397 bgColor: `#f2fbff`,
1398 bordersColor: `#858a8c`,
1399 gridColor: `#ced6d9`,
1400 sectorsColor: '#ced6d9',
1401 namesColor: '#ffffff',
1402 namesStrokeColor: '#000000',
1403 massColor: `#ffffff`,
1404 massStrokeColor: '#000000',
1405 virusColor: `#33ff33`,
1406 virusStrokeColor: `#2de52d`,
1407 foodColor: '#2de52d',
1408 hudMainColor: `#ffffff`,
1409 statsHudColor: `#ffffff`,
1410 top5MassColor: `#ffffff`,
1411 timeHudColor: `#ffffff`,
1412 messageNickColor: '#ffffff',
1413 commandsColor: `rgba(255,255,255,0.9)`,
1414 commandsTimeColor: `#ffffff`,
1415 commandsTextColor: `#000000`,
1416 miniMapSectorsColor: `#ffffff`,
1417 miniMapSectorColor: '#ffffff',
1418 miniMapGuidesColor: '#ffffff',
1419 miniMapMyCellColor: `#ffffff`,
1420 miniMapMyCellStrokeColor: '#ffffff',
1421 miniMapTeammatesColor: `#ffffff`,
1422 miniMapDeathLocationColor: `#ffffff`,
1423 miniMapSectorsOpacity: 0.25
1424 },
1425 'agario-dark': {
1426 name: `Agar.io Dark`,
1427 darkTheme: true,
1428 mainColor: `#ffffff`,
1429 bgColor: `#111111`,
1430 bordersColor: `#999999`,
1431 gridColor: `#333333`,
1432 sectorsColor: `#333333`,
1433 namesColor: `#ffffff`,
1434 namesStrokeColor: `#000000`,
1435 massColor: `#ffffff`,
1436 massStrokeColor: `#000000`,
1437 virusColor: `#33ff33`,
1438 virusStrokeColor: `#2de52d`,
1439 foodColor: `#2de52d`,
1440 hudMainColor: `#ffffff`,
1441 statsHudColor: '#ffffff',
1442 top5MassColor: `#ffffff`,
1443 timeHudColor: `#ffffff`,
1444 messageNickColor: `#ffffff`,
1445 commandsColor: `rgba(255,255,255,0.9)`,
1446 commandsTimeColor: `#ffffff`,
1447 commandsTextColor: '#ffffff',
1448 miniMapSectorsColor: `#ffffff`,
1449 miniMapSectorColor: `#ffffff`,
1450 miniMapGuidesColor: `#ffffff`,
1451 miniMapMyCellColor: `#ffffff`,
1452 miniMapMyCellStrokeColor: '#ffffff',
1453 miniMapTeammatesColor: `#ffffff`,
1454 miniMapDeathLocationColor: `#ffffff`,
1455 miniMapSectorsOpacity: 0.1
1456 }
1457 };
1458 const themeSetup = {
1459 'ogario-v3': {
1460 name: `OGARio v3`,
1461 menuMainColor: '#01d9cc',
1462 menuBtnTextColor: `#ffffff`,
1463 menuPanelColor: `#00243e`,
1464 menuPanelColor2: `#002f52`,
1465 menuTextColor: `#ffffff`,
1466 menuTextColor2: `#8096a7`,
1467 btn1Color: `#018cf6`,
1468 btn1Color2: '#0176ce',
1469 btn2Color: `#00b9e8`,
1470 btn2Color2: `#0099c0`,
1471 btn3Color: `#8d5fe6`,
1472 btn3Color2: '#814ee3',
1473 btn4Color: `#f300d8`,
1474 btn4Color2: `#df00c6`,
1475 menuBg: 'https://cdn.ogario.ovh/static/img/pattern.png'
1476 },
1477 'ogario-v2': {
1478 name: `OGARio v2`,
1479 menuMainColor: `#ff7800`,
1480 menuBtnTextColor: '#ffffff',
1481 menuPanelColor: `#222222`,
1482 menuPanelColor2: `#333333`,
1483 menuTextColor: `#bbbbbb`,
1484 menuTextColor2: `#bbbbbb`,
1485 btn1Color: `#428bca`,
1486 btn1Color2: `#3071a9`,
1487 btn2Color: `#5cb85c`,
1488 btn2Color2: `#449d44`,
1489 btn3Color: `#f0ad4e`,
1490 btn3Color2: `#ec971f`,
1491 btn4Color: `#d9534f`,
1492 btn4Color2: `#c9302c`,
1493 menuBg: ''
1494 },
1495 agario: {
1496 name: `Agar.io`,
1497 menuMainColor: '#5bc0de',
1498 menuBtnTextColor: '#ffffff',
1499 menuPanelColor: `#ffffff`,
1500 menuPanelColor2: '#cccccc',
1501 menuTextColor: '#333333',
1502 menuTextColor2: '#999999',
1503 btn1Color: `#428bca`,
1504 btn1Color2: `#3071a9`,
1505 btn2Color: '#5cb85c',
1506 btn2Color2: `#449d44`,
1507 btn3Color: `#f0ad4e`,
1508 btn3Color2: `#ec971f`,
1509 btn4Color: '#d9534f',
1510 btn4Color2: `#c9302c`,
1511 menuBg: ''
1512 }
1513 };
1514 const gameSetupTheme = {
1515 preset: `ogario-v3`,
1516 darkTheme: true,
1517 mainColor: '#01d9cc',
1518 bgColor: `#000a11`,
1519 bordersColor: `#01d9cc`,
1520 gridColor: '#00243e',
1521 sectorsColor: `#00243e`,
1522 namesColor: `#ffffff`,
1523 namesStrokeColor: `#000000`,
1524 massColor: `#ffffff`,
1525 massStrokeColor: `#000000`,
1526 virusColor: `#002f52`,
1527 virusStrokeColor: '#00b9e8',
1528 foodColor: '#5000ff',
1529 teammatesIndColor: `#ffffff`,
1530 cursorTrackingColor: `#ffffff`,
1531 splitRangeColor: `#ffffff`,
1532 ghostCellsColor: `#ffffff`,
1533 safeAreaColor: `#ffffff`,
1534 dangerAreaColor: `#bf00aa`,
1535 namesFont: `ubuntu-bold`,
1536 namesFontFamily: `Ubuntu`,
1537 namesFontWeight: 700,
1538 massFont: 'ubuntu-bold',
1539 massFontFamily: `Ubuntu`,
1540 massFontWeight: 700,
1541 sectorsFont: `ubuntu`,
1542 sectorsFontFamily: `Ubuntu`,
1543 sectorsFontWeight: 400,
1544 sectorsX: 5,
1545 sectorsY: 5,
1546 namesScale: 1,
1547 massScale: 3,
1548 virMassScale: 3,
1549 strokeScale: 1,
1550 foodSize: 5,
1551 bordersWidth: 40,
1552 sectorsWidth: 40,
1553 sectorsFontSize: 1200,
1554 cellsAlpha: 0.9,
1555 skinsAlpha: 0.7,
1556 virusAlpha: 0.6,
1557 textAlpha: 1,
1558 ghostCellsAlpha: 0.3,
1559 virusStrokeSize: 14,
1560 menuPreset: `ogario-v3`,
1561 menuMainColor: `#01d9cc`,
1562 menuBtnTextColor: `#ffffff`,
1563 menuPanelColor: '#00243e',
1564 menuPanelColor2: `#002f52`,
1565 menuTextColor: '#ffffff',
1566 menuTextColor2: `#8096a7`,
1567 btn1Color: `#018cf6`,
1568 btn1Color2: '#0176ce',
1569 btn2Color: '#00b9e8',
1570 btn2Color2: `#0099c0`,
1571 btn3Color: `#8d5fe6`,
1572 btn3Color2: '#814ee3',
1573 btn4Color: '#bf00aa',
1574 btn4Color2: '#a80096',
1575 menuBg: `https://cdn.ogario.ovh/static/img/pattern.png`,
1576 menuOpacity: 0.96,
1577 hudMainColor: `#01d9cc`,
1578 hudColor: 'rgba(0,0,0,0.4)',
1579 hudTextColor: '#ffffff',
1580 statsHudColor: `#ffffff`,
1581 timeHudColor: `#01d9cc`,
1582 top5MassColor: `#bf00aa`,
1583 lbMeColor: '#bf00aa',
1584 lbTeammateColor: `#018cf6`,
1585 hudFont: `ubuntu-bold`,
1586 hudFontFamily: `Ubuntu`,
1587 hudFontWeight: 700,
1588 hudScale: 1,
1589 messageColor: `rgba(0,0,0,0.4)`,
1590 messageTextColor: `#ffffff`,
1591 messageTimeColor: `#018cf6`,
1592 messageNickColor: '#01d9cc',
1593 commandsColor: `rgba(191,0,170,0.9)`,
1594 commandsTextColor: `#ffffff`,
1595 commandsTimeColor: '#bf00aa',
1596 commandsNickColor: `#ffffff`,
1597 chatBoxColor: `rgba(0,0,0,0.4)`,
1598 chatScale: 1,
1599 miniMapSectorsColor: `#ffffff`,
1600 miniMapSectorColor: `#01d9cc`,
1601 miniMapGuidesColor: '#bf00aa',
1602 miniMapNickColor: '#ffffff',
1603 miniMapNickStrokeColor: `#000000`,
1604 miniMapMyCellColor: `#ffffff`,
1605 miniMapMyCellStrokeColor: `#bf00aa`,
1606 miniMapTeammatesColor: `#01d9cc`,
1607 miniMapDeathLocationColor: `#bf00aa`,
1608 miniMapGhostCellsColor: `#ffffff`,
1609 miniMapFont: `ubuntu-bold`,
1610 miniMapFontFamily: 'Ubuntu',
1611 miniMapFontWeight: 700,
1612 miniMapNickFont: `ubuntu-bold`,
1613 miniMapNickFontFamily: `Ubuntu`,
1614 miniMapNickFontWeight: 700,
1615 miniMapWidth: 240,
1616 miniMapTop: 24,
1617 miniMapSectorsOpacity: 0.1,
1618 miniMapNickSize: 11,
1619 miniMapNickStrokeSize: 2,
1620 miniMapMyCellSize: 7.5,
1621 miniMapMyCellStrokeSize: 4,
1622 miniMapTeammatesSize: 5.5,
1623 miniMapGhostCellsAlpha: 0.15,
1624 customBackground: '',
1625 customCursor: 'https://cdn.ogario.ovh/static/img/cursors/cursor_02.cur'
1626 };
1627 const OgarioSettings = {
1628 menuMainColorCSS: null,
1629 menuPanelColorCSS: null,
1630 menuTextlColorCSS: null,
1631 menuButtonsCSS: null,
1632 hudCSS: null,
1633 chatCSS: null,
1634 chatScaleCSS: null,
1635 cursorCSS: null,
1636 loadThemeSettings() {
1637 let storage = null;
1638 if (window.localStorage.getItem('ogarioThemeSettings') !== null) {
1639 storage = JSON.parse(window.localStorage.getItem('ogarioThemeSettings'));
1640 }
1641 for (const setup in gameSetupTheme) {
1642 if (gameSetupTheme.hasOwnProperty(setup)) {
1643 if (storage && storage.hasOwnProperty(setup)) {
1644 gameSetupTheme[setup] = storage[setup];
1645 }
1646 if (ogario.hasOwnProperty(setup)) {
1647 ogario[setup] = gameSetupTheme[setup];
1648 }
1649 }
1650 }
1651 },
1652 saveThemeSettings() {
1653 window.localStorage.setItem(`ogarioThemeSettings`, JSON.stringify(gameSetupTheme));
1654 },
1655 restoreThemeSettings() {
1656 if (window.localStorage.getItem(`ogarioThemeSettings`) !== null) {
1657 window.localStorage.removeItem('ogarioThemeSettings');
1658 window.location.reload();
1659 }
1660 },
1661 addCustomCSS(name, css) {
1662 if (!this[name]) {
1663 this[name] = JQuery(`<style type='text/css'>`).appendTo('head');
1664 }
1665 this[name].html(css);
1666 },
1667 addPresetBox(id, name, options, value, callback) {
1668 JQuery(id).append(`<div class="preset-box"><span class="title-box">` + textLanguage[name] + `</span><div class="select-wrapper"><select id="` + name + `" class="form-control"></select></div></div>`);
1669 for (const option in options) {
1670 if (options.hasOwnProperty(option)) {
1671 JQuery(`#${name}`).append(`${`<option value="` + option}">${options[option].name}${`</option>`}`);
1672 }
1673 }
1674 JQuery(`#${name}`).val(gameSetupTheme[value]);
1675 const app = this;
1676 JQuery(`#${name}`).on(`change`, function() {
1677 const optionValue = this.value;
1678 gameSetupTheme[value] = optionValue;
1679 app[callback](optionValue);
1680 });
1681 },
1682 addColorBox(id, name, callback) {
1683 JQuery(id).append(`${`<div class="color-box"><span class="title-box">` + textLanguage[name] + `</span><div class="input-group ` + name}-picker"><input type="text" value="${gameSetupTheme[name]}${`" id="`}${name}${`" class="form-control" /><span class="input-group-addon"><i></i></span></div></div>`}`);
1684 if (callback) {
1685 const app = this;
1686 JQuery(`${id} .${name}-picker`).colorpicker({
1687 format: `hex`
1688 }).on(`changeColor.colorpicker`, event => {
1689 gameSetupTheme[name] = event.color.toHex();
1690 if (ogario.hasOwnProperty(name)) {
1691 ogario[name] = gameSetupTheme[name];
1692 }
1693 app[callback]();
1694 });
1695 } else {
1696 JQuery(`${id} .${name}${`-picker`}`).colorpicker({
1697 format: `hex`
1698 }).on(`changeColor.colorpicker`, event => {
1699 gameSetupTheme[name] = event.color.toHex();
1700 if (ogario.hasOwnProperty(name)) {
1701 ogario[name] = gameSetupTheme[name];
1702 }
1703 });
1704 }
1705 },
1706 addRgbaColorBox(id, name, callback) {
1707 JQuery(id).append(`<div class="color-box"><span class="title-box">${textLanguage[name]}${`</span><div class="input-group `}${name}${`-picker"><input type="text" value="`}${gameSetupTheme[name]}${`" id="`}${name}${`" class="form-control" /><span class="input-group-addon"><i></i></span></div></div>`}`);
1708 if (callback) {
1709 const app = this;
1710 JQuery(`${id} .${name}-picker`).colorpicker({
1711 format: `rgba`
1712 }).on('changeColor.colorpicker', event => {
1713 const color = event.color.toRGB();
1714 gameSetupTheme[name] = `rgba(${color.r},${color.g},${color.b},${color.a})`;
1715 if (ogario.hasOwnProperty(name)) {
1716 ogario[name] = gameSetupTheme[name];
1717 }
1718 app[callback]();
1719 });
1720 } else {
1721 JQuery(`${id} .${name}-picker`).colorpicker({
1722 format: `rgba`
1723 }).on(`changeColor.colorpicker`, event => {
1724 const color = event.color.toRGB();
1725 gameSetupTheme[name] = `${`rgba(` + color.r},${color.g},${color.b},${color.a})`;
1726 if (ogario.hasOwnProperty(name)) {
1727 ogario[name] = gameSetupTheme[name];
1728 }
1729 });
1730 }
1731 },
1732 addSliderBox(id, name, min, max, step, callback) {
1733 JQuery(id).append(`<div class="slider-box"><div class="box-label"><span class="value-label">${textLanguage[name]}: </span><span id="${name}${`-value" class="value">`}${gameSetupTheme[name]}${`</span></div><input id="`}${name}-slider" type="range" min="${min}" max="${max}${`" step="`}${step}${`" value="`}${gameSetupTheme[name]}${`"></div>`}`);
1734 if (callback) {
1735 const app = this;
1736 JQuery(`#${name}${`-slider`}`).on(`input`, function() {
1737 const parse = parseFloat(JQuery(this).val());
1738 JQuery(`#${name}-value`).text(parse);
1739 gameSetupTheme[name] = parse;
1740 if (ogario.hasOwnProperty(name)) {
1741 ogario[name] = parse;
1742 }
1743 app[callback]();
1744 });
1745 } else {
1746 JQuery(`#${name}${`-slider`}`).on('input', function() {
1747 const parse = parseFloat(JQuery(this).val());
1748 JQuery(`#${name}${`-value`}`).text(parse);
1749 gameSetupTheme[name] = parse;
1750 if (ogario.hasOwnProperty(name)) {
1751 ogario[name] = parse;
1752 }
1753 });
1754 }
1755 },
1756 addInputBox(id, name, holder, callback) {
1757 JQuery(id).append(`${`<div class="input-box"><span class="title-box">` + textLanguage[name] + `</span><input id="` + name + `" class="form-control" placeholder="` + holder}" value="${gameSetupTheme[name]}${`" /></div>`}`);
1758 const app = this;
1759 JQuery(`#${name}`).on(`input`, function() {
1760 gameSetupTheme[name] = this.value;
1761 app[callback]();
1762 });
1763 },
1764 addCursorBox(id, url) {
1765 if (url === gameSetupTheme.customCursor) {
1766 JQuery(id).append(`<div class="cursor-box"><a href="#" class="active"><img src="` + url + `"></a></div>`);
1767 } else {
1768 JQuery(id).append(`<div class="cursor-box"><a href="#"><img src="` + url + `"></a></div>`);
1769 }
1770 },
1771 setFont(name, fontFamily) {
1772 gameSetupTheme[name] = fontFamily;
1773 gameSetupTheme[`${name}Family`] = this.setFontFamily(fontFamily);
1774 gameSetupTheme[name + `Weight`] = this.setFontWeight(fontFamily);
1775 if (ogario.hasOwnProperty(name + `Family`)) {
1776 ogario[name + `Family`] = gameSetupTheme[name + `Family`];
1777 }
1778 if (ogario.hasOwnProperty(`${name}Weight`)) {
1779 ogario[`${name}Weight`] = gameSetupTheme[`${name}Weight`];
1780 }
1781 },
1782 addFontBox(id, name, callback) {
1783 JQuery(id).append(`${`<div class="font-box"><span class="title-box">` + textLanguage[name]}</span><div class="select-wrapper"><select id="${name}" class="form-control"></select></div></div>`);
1784 JQuery(`#${name}`).append(`<option value="ubuntu">Ubuntu</option><option value="ubuntu-bold">Ubuntu Bold</option>`);
1785 JQuery(`#${name}`).append(`<option value="roboto">Roboto</option><option value="roboto-bold">Roboto Bold</option>`);
1786 JQuery(`#${name}`).append('<option value="oswald">Oswald</option><option value="oswald-bold">Oswald Bold</option>');
1787 JQuery(`#${name}`).val(gameSetupTheme[name]);
1788 const app = this;
1789 if (callback) {
1790 JQuery(`#${name}`).on('change', function() {
1791 const value = this.value;
1792 app.setFont(name, value);
1793 app[callback]();
1794 });
1795 } else {
1796 JQuery(`#${name}`).on(`change`, function() {
1797 const value = this.value;
1798 app.setFont(name, value);
1799 });
1800 }
1801 },
1802 setFontFamily(name) {
1803 if (name.indexOf(`roboto`) != -1) {
1804 return `Roboto`;
1805 } else if (name.indexOf(`oswald`) != -1) {
1806 return `Oswald`;
1807 } else {
1808 return 'Ubuntu';
1809 }
1810 },
1811 setFontWeight(name) {
1812 if (name.indexOf(`bold`) != -1) {
1813 return 700;
1814 }
1815 return 400;
1816 },
1817 setThemeMenu() {
1818 const app = this;
1819 JQuery(`#theme`).append(`<ul class="submenu-tabs"><li class="theme-main-tab active"><a href="#theme-main" class="active ogicon-paint-format" data-toggle="tab-tooltip" title="${textLanguage.basicTheming}${`"></a></li><li class="theme-menu-tab"><a href="#theme-menu" class="ogicon-menu" data-toggle="tab-tooltip" title="`}${textLanguage.menuTheming}${`"></a></li><li class="theme-hud-tab"><a href="#theme-hud" class="ogicon-display" data-toggle="tab-tooltip" title="`}${textLanguage.hudTheming}${`"></a></li><li class="theme-chat-tab"><a href="#theme-chat" class="ogicon-bubbles" data-toggle="tab-tooltip" title="`}${textLanguage.chatTheming}"></a></li><li class="theme-minimap-tab"><a href="#theme-minimap" class="ogicon-location2" data-toggle="tab-tooltip" title="${textLanguage.miniMapTheming}${`"></a></li><li class="theme-images-tab"><a href="#theme-images" class="ogicon-compass" data-toggle="tab-tooltip" title="`}${textLanguage.imagesTheming}"></a></li></ul><div id="theme-main" class="submenu-panel"></div><div id="theme-menu" class="submenu-panel"></div><div id="theme-hud" class="submenu-panel"></div><div id="theme-chat" class="submenu-panel"></div><div id="theme-minimap" class="submenu-panel"></div><div id="theme-images" class="submenu-panel"></div>`);
1820 this.addPresetBox(`#theme-main`, `themePreset`, gameTheme, `preset`, `changeThemePreset`);
1821 this.addColorBox('#theme-main', `bgColor`, `setBgColor`);
1822 this.addColorBox(`#theme-main`, `bordersColor`);
1823 this.addColorBox(`#theme-main`, `gridColor`);
1824 this.addColorBox('#theme-main', `sectorsColor`);
1825 this.addColorBox(`#theme-main`, 'namesColor');
1826 this.addColorBox('#theme-main', `namesStrokeColor`);
1827 this.addColorBox(`#theme-main`, `massColor`);
1828 this.addColorBox(`#theme-main`, `massStrokeColor`);
1829 this.addColorBox(`#theme-main`, `virusColor`);
1830 this.addColorBox(`#theme-main`, `virusStrokeColor`);
1831 this.addColorBox(`#theme-main`, 'foodColor', `setFoodColor`);
1832 this.addColorBox(`#theme-main`, `teammatesIndColor`, 'setIndicatorColor');
1833 this.addColorBox(`#theme-main`, `cursorTrackingColor`);
1834 this.addColorBox(`#theme-main`, `splitRangeColor`);
1835 this.addColorBox('#theme-main', `safeAreaColor`);
1836 this.addColorBox(`#theme-main`, `dangerAreaColor`);
1837 this.addFontBox(`#theme-main`, 'namesFont');
1838 this.addFontBox(`#theme-main`, `massFont`);
1839 this.addFontBox(`#theme-main`, `sectorsFont`);
1840 this.addSliderBox(`#theme-main`, `sectorsFontSize`, 200, 2000, 10);
1841 this.addSliderBox(`#theme-main`, `namesScale`, 0.5, 2, 0.1);
1842 this.addSliderBox(`#theme-main`, `massScale`, 1, 5, 1);
1843 this.addSliderBox(`#theme-main`, `virMassScale`, 1, 5, 1);
1844 this.addSliderBox('#theme-main', 'strokeScale', 1, 4, 0.1);
1845 this.addSliderBox(`#theme-main`, 'foodSize', 1, 50, 1, `setFoodColor`);
1846 this.addSliderBox(`#theme-main`, `virusStrokeSize`, 2, 40, 1);
1847 this.addSliderBox('#theme-main', `bordersWidth`, 2, 200, 2);
1848 this.addSliderBox(`#theme-main`, `sectorsWidth`, 2, 200, 2);
1849 this.addSliderBox(`#theme-main`, `cellsAlpha`, 0.01, 0.99, 0.01);
1850 this.addSliderBox(`#theme-main`, `skinsAlpha`, 0.01, 0.99, 0.01);
1851 this.addSliderBox('#theme-main', `virusAlpha`, 0, 1, 0.01);
1852 this.addSliderBox(`#theme-main`, 'textAlpha', 0.1, 1, 0.01);
1853 this.addPresetBox(`#theme-menu`, 'menuPreset', themeSetup, `menuPreset`, 'changeMenuPreset');
1854 this.addSliderBox(`#theme-menu`, `menuOpacity`, 0.1, 1, 0.01, `setMenuOpacity`);
1855 this.addColorBox(`#theme-menu`, `menuMainColor`, `setMenuMainColor`);
1856 this.addColorBox(`#theme-menu`, `menuBtnTextColor`, `setMenuButtons`);
1857 this.addColorBox(`#theme-menu`, `menuPanelColor`, `setMenuPanelColor`);
1858 this.addColorBox('#theme-menu', `menuPanelColor2`, `setMenuPanelColor`);
1859 this.addColorBox(`#theme-menu`, `menuTextColor`, `setMenuTextColor`);
1860 this.addColorBox(`#theme-menu`, 'menuTextColor2', `setMenuTextColor`);
1861 this.addColorBox(`#theme-menu`, `btn1Color`, `setMenuButtons`);
1862 this.addColorBox(`#theme-menu`, `btn1Color2`, `setMenuButtons`);
1863 this.addColorBox(`#theme-menu`, 'btn2Color', `setMenuButtons`);
1864 this.addColorBox(`#theme-menu`, `btn2Color2`, `setMenuButtons`);
1865 this.addColorBox(`#theme-menu`, `btn3Color`, 'setMenuButtons');
1866 this.addColorBox(`#theme-menu`, `btn3Color2`, `setMenuButtons`);
1867 this.addColorBox(`#theme-menu`, `btn4Color`, `setMenuButtons`);
1868 this.addColorBox(`#theme-menu`, `btn4Color2`, `setMenuButtons`);
1869 this.addInputBox(`#theme-menu`, `menuBg`, `Image URL`, `setMenuBg`);
1870 this.addColorBox(`#theme-hud`, `hudMainColor`, `setHudColors`);
1871 this.addRgbaColorBox(`#theme-hud`, 'hudColor', 'setHudColors');
1872 this.addColorBox(`#theme-hud`, 'hudTextColor', 'setHudColors');
1873 this.addColorBox('#theme-hud', `statsHudColor`, `setHudColors`);
1874 this.addColorBox(`#theme-hud`, `timeHudColor`, 'setHudColors');
1875 this.addColorBox(`#theme-hud`, `top5MassColor`, `setHudColors`);
1876 this.addColorBox(`#theme-hud`, `lbMeColor`, 'setHudColors');
1877 this.addColorBox(`#theme-hud`, `lbTeammateColor`, `setHudColors`);
1878 this.addFontBox(`#theme-hud`, `hudFont`, `setHudFont`);
1879 this.addSliderBox('#theme-hud', 'hudScale', 1, 2, 0.01, `setHudScale`);
1880 this.addRgbaColorBox('#theme-chat', `messageColor`, `setChatColors`);
1881 this.addColorBox(`#theme-chat`, `messageTextColor`, 'setChatColors');
1882 this.addColorBox(`#theme-chat`, `messageTimeColor`, `setChatColors`);
1883 this.addColorBox('#theme-chat', `messageNickColor`, `setChatColors`);
1884 this.addRgbaColorBox(`#theme-chat`, `commandsColor`, 'setChatColors');
1885 this.addColorBox('#theme-chat', `commandsTextColor`, 'setChatColors');
1886 this.addColorBox(`#theme-chat`, `commandsTimeColor`, 'setChatColors');
1887 this.addColorBox(`#theme-chat`, `commandsNickColor`, `setChatColors`);
1888 this.addRgbaColorBox(`#theme-chat`, `chatBoxColor`, `setChatColors`);
1889 this.addSliderBox(`#theme-chat`, `chatScale`, 1, 2, 0.01, `setChatScale`);
1890 this.addColorBox(`#theme-minimap`, `miniMapSectorsColor`, `setMiniMapSectorsColor`);
1891 this.addColorBox(`#theme-minimap`, `miniMapSectorColor`);
1892 this.addColorBox(`#theme-minimap`, `miniMapNickColor`);
1893 this.addColorBox(`#theme-minimap`, `miniMapNickStrokeColor`);
1894 this.addColorBox(`#theme-minimap`, `miniMapMyCellColor`);
1895 this.addColorBox(`#theme-minimap`, `miniMapMyCellStrokeColor`);
1896 this.addColorBox(`#theme-minimap`, `miniMapTeammatesColor`);
1897 this.addColorBox(`#theme-minimap`, `miniMapDeathLocationColor`);
1898 this.addColorBox(`#theme-minimap`, `miniMapGuidesColor`);
1899 this.addFontBox(`#theme-minimap`, `miniMapFont`, `setMiniMapFont`);
1900 this.addFontBox(`#theme-minimap`, 'miniMapNickFont');
1901 this.addSliderBox('#theme-minimap', 'miniMapWidth', 200, 400, 2, 'setMiniMapWidth');
1902 this.addSliderBox(`#theme-minimap`, `miniMapSectorsOpacity`, 0, 1, 0.01, `setMiniMapSectorsOpacity`);
1903 this.addSliderBox(`#theme-minimap`, `miniMapNickSize`, 8, 16, 1);
1904 this.addSliderBox(`#theme-minimap`, `miniMapNickStrokeSize`, 0, 6, 1);
1905 this.addSliderBox(`#theme-minimap`, `miniMapMyCellSize`, 4, 10, 0.5);
1906 this.addSliderBox(`#theme-minimap`, `miniMapMyCellStrokeSize`, 0, 10, 1);
1907 this.addSliderBox(`#theme-minimap`, 'miniMapTeammatesSize', 4, 10, 0.5);
1908 this.addInputBox(`#theme-images`, `customBackground`, `Image URL`, `setCustomBackground`);
1909 this.addInputBox(`#theme-images`, `customCursor`, `Cursor image URL`, 'setCustomCursor');
1910 const cursorUrl = `https://cdn.ogario.ovh/static/img/cursors/cursor_`;
1911 for (let length = 0; length < 35; length++) {
1912 if (length < 9) {
1913 this.addCursorBox(`#theme-images`, `${cursorUrl}0${length + 1}.cur`);
1914 continue;
1915 }
1916 this.addCursorBox(`#theme-images`, `${cursorUrl}${length + 1}${`.cur`}`);
1917 }
1918 JQuery(document).on(`click`, `#theme-images .cursor-box a`, function(event) {
1919 event.preventDefault();
1920 const url = JQuery(`img`, this).attr(`src`);
1921 gameSetupTheme.customCursor = url;
1922 app.setCustomCursor();
1923 JQuery(`#customCursor`).val(url);
1924 JQuery(`#theme-images .cursor-box a`).removeClass(`active`);
1925 JQuery(this).addClass(`active`);
1926 });
1927 JQuery(`#theme`).append(`<button class="btn btn-block btn-success btn-save"">` + textLanguage.saveSett + `</button>`);
1928 JQuery(document).on('click', `#theme .btn-save`, function(event) {
1929 event.preventDefault();
1930 const theme = JQuery(this);
1931 theme.text(textLanguage.saved);
1932 app.saveThemeSettings();
1933 setTimeout(() => {
1934 theme.text(textLanguage.saveSett);
1935 }, 500);
1936 });
1937 JQuery(`#theme`).append(`<div class="restore-settings"><a href="#">` + textLanguage.restoreThemeSettings + `</a></div>`);
1938 JQuery(document).on(`click`, `#theme .restore-settings a`, event => {
1939 event.preventDefault();
1940 app.restoreThemeSettings();
1941 });
1942 JQuery(`.skin`).colorpicker({
1943 format: `hex`,
1944 input: `#color`
1945 });
1946 },
1947 changePreset(names, theme) {
1948 if (theme[names]) {
1949 gameSetupTheme[names] = names;
1950 var names = theme[names];
1951 } else {
1952 return;
1953 }
1954 for (const name in names) {
1955 if (names.hasOwnProperty(name) && gameSetupTheme.hasOwnProperty(name)) {
1956 gameSetupTheme[name] = names[name];
1957 if (ogario.hasOwnProperty(name)) {
1958 ogario[name] = gameSetupTheme[name];
1959 }
1960 if (JQuery(`#theme .` + name + `-picker`)) {
1961 JQuery(`#theme .` + name + `-picker`).colorpicker(`setValue`, gameSetupTheme[name]);
1962 }
1963 if (JQuery(`#${name}${`-slider`}`)) {
1964 JQuery(`#${name}${`-slider`}`).val(gameSetupTheme[name]).change();
1965 }
1966 if (JQuery(`input[type=text]#${name}`) || JQuery(`select#` + name)) {
1967 JQuery(`#${name}`).val(gameSetupTheme[name]);
1968 }
1969 }
1970 }
1971 },
1972 changeThemePreset(name) {
1973 this.changePreset(name, gameTheme);
1974 this.setTheme();
1975 },
1976 setFonts() {
1977 this.setFont(`namesFont`, gameSetupTheme.namesFont);
1978 this.setFont('massFont', gameSetupTheme.namesFont);
1979 this.setFont('sectorsFont', gameSetupTheme.sectorsFont);
1980 },
1981 setBgColor() {
1982 JQuery(`body`).css('background-color', gameSetupTheme.bgColor);
1983 },
1984 setFoodColor() {
1985 if (!gameOptionSettings.optimizedFood) {
1986 return;
1987 }
1988 drawRender && drawRender.preDrawPellet();
1989 },
1990 setIndicatorColor() {
1991 drawRender && drawRender.preDrawIndicator();
1992 },
1993 setCustomBackground() {
1994 if (gameSetupTheme.customBackground) {
1995 JQuery('body').css(`background-image`, `${`url(` + gameSetupTheme.customBackground})`);
1996 } else {
1997 JQuery('body').css('background-image', `none`);
1998 }
1999 },
2000 setCustomCursor() {
2001 if (gameSetupTheme.customCursor) {
2002 var css = `*{cursor:url(` + gameSetupTheme.customCursor + `), auto !important}`;
2003 } else {
2004 var css = '*{cursor: auto}';
2005 }
2006 this.addCustomCSS(`cursorCSS`, css);
2007 },
2008 setMenu() {
2009 this.setMenuOpacity();
2010 this.setMenuMainColor();
2011 this.setMenuPanelColor();
2012 this.setMenuTextColor();
2013 this.setMenuButtons();
2014 this.setMenuBg();
2015 },
2016 changeMenuPreset(name) {
2017 this.changePreset(name, themeSetup);
2018 this.setMenu();
2019 },
2020 setMenuOpacity() {
2021 JQuery('#helloContainer, #hotkeys, #exp-imp').css('opacity', gameSetupTheme.menuOpacity);
2022 },
2023 setMenuMainColor() {
2024 const css = `::-moz-selection{background-color:` + gameSetupTheme.menuMainColor + `!important}::selection{background-color:` + gameSetupTheme.menuMainColor + `!important}.menu-main-color,#quick-menu a:hover,.quick,.quick:focus,.menu-tabs a:hover,.menu-tabs .active,.submenu-tabs a:hover,.submenu-tabs .active,#stats center,#exp-imp h1{color:` + gameSetupTheme.menuMainColor + `}#exp-bar .progress-bar-striped,.quick:hover,.rangeslider__fill{background-color:` + gameSetupTheme.menuMainColor + `}#main-menu,.agario-side-panel,#hotkeys,#exp-imp{border-color:` + gameSetupTheme.menuMainColor + `}.ps-scrollbar-y{background-color:` + gameSetupTheme.menuMainColor + `!important}`;
2025 this.addCustomCSS(`menuMainColorCSS`, css);
2026 },
2027 setMenuPanelColor() {
2028 const css = `${`#main-menu,.agario-side-panel,#hotkeys,#exp-imp{background-color: ` + gameSetupTheme.menuPanelColor + `}label:hover,.agario-panel input,.agario-panel select,.agario-side-panel input,.agario-side-panel select,.input-group-addon,.nick .input-group-btn,.skin .input-group-btn,#stream-mode,#hide-url,.menu-tabs a:hover,.menu-tabs .active,.submenu-tabs,#exp-bar .progress,#quick-menu a:hover,.quick,.select-wrapper,#hotkeys-cfg div.row:hover,#hotkeys-cfg .command-in,#exp-imp-settings textarea,.restore-settings{background-color: ` + gameSetupTheme.menuPanelColor2 + `}.agario-panel h5,.agario-side-panel h5,#stats h2,.menu-tabs,.submenu-tabs,#skins a.default,#stats hr,#hotkeys-cfg div.row, #exp-imp h1{border-color: ` + gameSetupTheme.menuPanelColor2}}.quick:hover,#skins a,#profiles{color:${gameSetupTheme.menuPanelColor2}}input.stream-mode,input.hide-url{color:${gameSetupTheme.menuPanelColor2}!important}`;
2029 this.addCustomCSS('menuPanelColorCSS', css);
2030 },
2031 setMenuTextColor() {
2032 const css = `${`.agario-panel,.agario-side-panel,.agario-panel input,.agario-panel select,.agario-side-panel input,.agario-side-panel select,.input-group-addon,.dark .yt-username,#stream-mode,#hide-url,.menu-tabs a,.submenu-tabs a,#skins a.default:hover,#quick-menu a,#prev-profile.default:hover,#next-profile.default:hover,#statsText,#hotkeys,#hotkeys-cfg .command-in,#exp-imp{color:` + gameSetupTheme.menuTextColor + `}#skins a.default:hover{border-color:` + gameSetupTheme.menuTextColor + `}::-webkit-input-placeholder{color:` + gameSetupTheme.menuTextColor2 + `!important}::-moz-placeholder{color:` + gameSetupTheme.menuTextColor2 + `!important}#user-id-tag, #version-tag,#statsSubtext,#hotkeys-inst,#exp-imp textarea,.restore-settings a,.restore-settings a:hover{color:` + gameSetupTheme.menuTextColor2 + `}#hotkeys-cfg .command-in,#theme .color-box{border-color:` + gameSetupTheme.menuTextColor2}}`;
2033 this.addCustomCSS(`menuTextColorCSS`, css);
2034 },
2035 setMenuButtons() {
2036 const css = `${`a,a:hover{color:` + gameSetupTheme.btn1Color}}.btn,#hotkeys-cfg .custom-key-in{color:${gameSetupTheme.menuBtnTextColor}${`}.btn-primary{background-color:`}${gameSetupTheme.btn1Color}${`!important}.btn-primary:active,.btn-primary:disabled,.btn-primary:focus,.btn-primary:hover{background-color:`}${gameSetupTheme.btn1Color2}${`!important}.btn-success{background-color:`}${gameSetupTheme.btn2Color}${`!important}.btn-success:active,.btn-success:disabled,.btn-success:focus,.btn-success:hover{background-color:`}${gameSetupTheme.btn2Color2}!important}.btn-warning{background-color:${gameSetupTheme.btn3Color}${`!important}.btn-warning:active,.btn-warning:disabled,.btn-warning:focus,.btn-warning:hover{background-color:`}${gameSetupTheme.btn3Color2}${`!important}.btn-danger{background-color:`}${gameSetupTheme.btn4Color}!important}.btn-danger:active,.btn-danger:disabled,.btn-danger:focus,.btn-danger:hover{background-color:${gameSetupTheme.btn4Color2}${`!important}#hotkeys-cfg .custom-key-in{background-color:`}${gameSetupTheme.btn4Color2}${`;border-color:`}${gameSetupTheme.btn4Color2}}`;
2037 this.addCustomCSS(`menuButtonsCSS`, css);
2038 },
2039 setMenuBg() {
2040 JQuery(`#menuBg`).val(gameSetupTheme.menuBg);
2041 if (gameSetupTheme.menuBg) {
2042 JQuery('.menu-panel, .agario-side-panel, #hotkeys, #exp-imp').css(`background-image`, `${`url(` + gameSetupTheme.menuBg})`);
2043 } else {
2044 JQuery('.menu-panel, .agario-side-panel, #hotkeys, #exp-imp').css(`background-image`, `none`);
2045 }
2046 },
2047 setHud() {
2048 this.setHudColors();
2049 this.setHudFont();
2050 this.setHudScale();
2051 },
2052 setHudColors() {
2053 const css = `${`.hud-main-color,#top5-hud a,#target-panel-hud a:hover,#target-panel-hud a.active,#message-menu a{color:` + gameSetupTheme.hudMainColor + `}.hud,.hud-b,#chat-emoticons{background-color:` + gameSetupTheme.hudColor + `}.hud,.hud-b,#top5-hud a:hover,#target-panel-hud a{color:` + gameSetupTheme.hudTextColor}}.stats-hud-color{color:${gameSetupTheme.statsHudColor}${`}.time-hud-color{color:`}${gameSetupTheme.timeHudColor}${`}.top5-mass-color{color:`}${gameSetupTheme.top5MassColor}${`}#leaderboard-positions .me{color:`}${gameSetupTheme.lbMeColor}${`}#leaderboard-positions .teammate{color:`}${gameSetupTheme.lbTeammateColor}}`;
2054 this.addCustomCSS('hudCSS', css);
2055 },
2056 setHudFont() {
2057 this.setFont('hudFont', gameSetupTheme.hudFont);
2058 JQuery('#overlays-hud').css({
2059 'font-family': gameSetupTheme.hudFontFamily,
2060 'font-weight': gameSetupTheme.hudFontWeight
2061 });
2062 },
2063 setHudScale() {
2064 const overlays = Math.round(20 * gameSetupTheme.hudScale);
2065 const leadeboard = Math.round(200 * gameSetupTheme.hudScale);
2066 const top5 = Math.floor(55 * gameSetupTheme.hudScale);
2067 const top5_pos = Math.floor(6 * gameSetupTheme.hudScale);
2068 const time = Math.floor(280 * gameSetupTheme.hudScale);
2069 const pause = Math.floor(85 * gameSetupTheme.hudScale);
2070 const target = Math.floor(20 * gameSetupTheme.hudScale);
2071 JQuery('#overlays-hud').css(`font-size`, `${overlays}px`);
2072 JQuery('#leaderboard-hud, #time-hud', '#botClient').width(leadeboard);
2073 JQuery(`#top5-hud`).width(leadeboard + 30).css(`top`, `${top5}px`);
2074 JQuery(`#top5-pos`).css('padding-left', `${top5_pos}px`);
2075 JQuery(`#time-hud`).css(`top`, `${time}px`);
2076 JQuery(`#pause-hud`).css(`top`, `${pause}px`);
2077 JQuery(`#target-hud`).css('padding-top', `${target}px`);
2078 },
2079 setChat() {
2080 this.setChatColors();
2081 this.setChatScale();
2082 },
2083 setChatColors() {
2084 const css = `${`#message,#messages li,.toast-success{background-color:` + gameSetupTheme.messageColor + `}#message,.message-text,.toast-success .message-text{color:` + gameSetupTheme.messageTextColor + `}.message-nick,.mute-user,.mute-user:hover,.toast-success .message-nick,.toast .mute-user,.toast .mute-user:hover{color:` + gameSetupTheme.messageNickColor + `}.message-time{color:` + gameSetupTheme.messageTimeColor}}.toast-warning{background-color:${gameSetupTheme.commandsColor}${`}.command-text,.toast-warning .command-text{color:`}${gameSetupTheme.commandsTextColor}${`}.command-nick,.toast-warning .command-nick,.toast-warning .mute-user,.toast-warning .mute-user:hover{color:`}${gameSetupTheme.commandsNickColor}${`}.command-time{color:`}${gameSetupTheme.commandsTimeColor}${`}#chat-box{background-color:`}${gameSetupTheme.chatBoxColor}}`;
2085 this.addCustomCSS(`chatCSS`, css);
2086 },
2087 setChatScale() {
2088 const message = Math.round(14 * gameSetupTheme.chatScale);
2089 const toastContainer = Math.round(280 * gameSetupTheme.chatScale);
2090 const messageBox = Math.round(350 * gameSetupTheme.chatScale);
2091 const chatBox = Math.round(300 * gameSetupTheme.chatScale);
2092 const userList = Math.floor(14 * gameSetupTheme.chatScale);
2093 JQuery(`#message-box, #messages, #toast-container, #chat-box`).css(`font-size`, `${message}px`);
2094 JQuery('#messages, #toast-container, #chat-box').width(toastContainer);
2095 JQuery(`#message-box`).width(messageBox);
2096 JQuery(`#chat-box`).height(chatBox);
2097 JQuery('.user-list').css(`padding-left`, `${userList}px`);
2098 const css = `#toast-container{width:` + toastContainer + `px;font-size:` + message + `px}`;
2099 this.addCustomCSS(`chatScaleCSS`, css);
2100 },
2101 setMiniMap() {
2102 this.setMiniMapFont();
2103 this.setMiniMapWidth();
2104 this.setMiniMapSectorsOpacity();
2105 },
2106 setMiniMapFont() {
2107 this.setFont(`miniMapFont`, gameSetupTheme.miniMapFont);
2108 application && application.resetMiniMapSectors();
2109 },
2110 setMiniMapWidth() {
2111 const resizeWidth = gameSetupTheme.miniMapWidth / 200;
2112 gameSetupTheme.miniMapTop = Math.round(20 * resizeWidth);
2113 JQuery('#minimap-hud').css({
2114 width: gameSetupTheme.miniMapWidth,
2115 height: gameSetupTheme.miniMapWidth + gameSetupTheme.miniMapTop
2116 });
2117 application && application.resetMiniMapSectors();
2118 },
2119 setMiniMapSectorsColor() {
2120 application && application.resetMiniMapSectors();
2121 },
2122 setMiniMapSectorsOpacity() {
2123 JQuery('#minimap-sectors').css(`opacity`, gameSetupTheme.miniMapSectorsOpacity);
2124 },
2125 setTheme() {
2126 this.setFonts();
2127 this.setBgColor();
2128 this.setCustomBackground();
2129 this.setCustomCursor();
2130 this.setMenu();
2131 this.setHud();
2132 this.setChat();
2133 this.setMiniMap();
2134 },
2135 init() {
2136 this.loadThemeSettings();
2137 }
2138 };
2139 let PlayerProfiles = [];
2140 const mainProfile = {
2141 nick: `I <3 OGARio`,
2142 clanTag: 'Ⓜ',
2143 skinURL: '',
2144 color: gameSetupTheme.mainColor
2145 };
2146 var gameOptionSettings = {
2147 quickResp: true,
2148 autoResp: false,
2149 autoZoom: false,
2150 autoHideNames: true,
2151 autoHideMass: true,
2152 autoHideFood: false,
2153 autoHideFoodOnZoom: false,
2154 noNames: false,
2155 optimizedNames: true,
2156 hideMyName: true,
2157 hideTeammatesNames: false,
2158 showMass: true,
2159 optimizedMass: true,
2160 shortMass: true,
2161 virMassShots: true,
2162 hideMyMass: false,
2163 hideEnemiesMass: false,
2164 vanillaSkins: false,
2165 customSkins: true,
2166 myTransparentSkin: false,
2167 myCustomColor: false,
2168 transparentCells: false,
2169 transparentViruses: true,
2170 transparentSkins: false,
2171 showGrid: false,
2172 showBgSectors: false,
2173 showMapBorders: true,
2174 showGhostCells: true,
2175 showMiniMap: true,
2176 showMiniMapGrid: false,
2177 showMiniMapGuides: true,
2178 showMiniMapGhostCells: false,
2179 oneColoredTeammates: false,
2180 optimizedFood: true,
2181 rainbowFood: false,
2182 oppColors: false,
2183 oppRings: false,
2184 virColors: false,
2185 splitRange: false,
2186 virusesRange: false,
2187 textStroke: false,
2188 namesStroke: false,
2189 massStroke: false,
2190 cursorTracking: false,
2191 teammatesInd: false,
2192 mouseSplit: false,
2193 mouseFeed: false,
2194 mouseInvert: false,
2195 disableChat: false,
2196 hideChat: false,
2197 chatSounds: true,
2198 chatEmoticons: true,
2199 showChatBox: false,
2200 showChatImages: true,
2201 showChatVideos: true,
2202 showTop5: true,
2203 showTargeting: true,
2204 showLbData: true,
2205 showTime: true,
2206 normalLb: false,
2207 centeredLb: true,
2208 fpsAtTop: true,
2209 showStats: true,
2210 showStatsMass: true,
2211 showStatsSTE: false,
2212 showStatsN16: false,
2213 showStatsFPS: true,
2214 blockPopups: false,
2215 streamMode: false,
2216 hideSkinUrl: false,
2217 showQuickMenu: true,
2218 showSkinsPanel: true,
2219 animation: 140,
2220 zoomSpeedValue: 0.9,
2221 messageSound: `https://cdn.ogario.ovh/static/sounds/notification_01.mp3`,
2222 commandSound: `https://cdn.ogario.ovh/static/sounds/notification_02.mp3`
2223 };
2224
2225 function minimap(id, name, skinID, skinUrl) {
2226 this.id = id;
2227 this.nick = name;
2228 this.skinID = skinID;
2229 this.skinURL = skinUrl;
2230 this.x = 0;
2231 this.y = 0;
2232 this.lastX = 0;
2233 this.lastY = 0;
2234 this.mass = 0;
2235 this.clanTag = '';
2236 this.color = null;
2237 this.customColor = gameSetupTheme.miniMapTeammatesColor;
2238 this.alive = false;
2239 this.updateTime = null;
2240 this.pi2 = 2 * Math.PI;
2241 this.setColor = function(color, customColor) {
2242 this.color = color;
2243 if (customColor.length == 7) {
2244 this.customColor = customColor;
2245 }
2246 };
2247 this.drawPosition = function(ctx, offset, size, privateMap, targetID) {
2248 if (!this.alive || privateMap && targetID && this.id != targetID) {
2249 return;
2250 }
2251 this.lastX = (29 * this.lastX + this.x) / 30;
2252 this.lastY = (29 * this.lastY + this.y) / 30;
2253 const posX = (this.lastX + offset) * size;
2254 const posY = (this.lastY + offset) * size;
2255 if (this.nick.length > 0) {
2256 ctx.font = `${gameSetupTheme.miniMapNickFontWeight} ${gameSetupTheme.miniMapNickSize}${`px `}${gameSetupTheme.miniMapNickFontFamily}`;
2257 ctx.textAlign = `center`;
2258 if (gameSetupTheme.miniMapNickStrokeSize > 0) {
2259 ctx.lineWidth = gameSetupTheme.miniMapNickStrokeSize;
2260 ctx.strokeStyle = gameSetupTheme.miniMapNickStrokeColor;
2261 ctx.strokeText(this.nick, posX, posY - (gameSetupTheme.miniMapTeammatesSize * 2 + 2));
2262 }
2263 ctx.fillStyle = gameSetupTheme.miniMapNickColor;
2264 ctx.fillText(this.nick, posX, posY - (gameSetupTheme.miniMapTeammatesSize * 2 + 2));
2265 }
2266 ctx.beginPath();
2267 ctx.arc(posX, posY, gameSetupTheme.miniMapTeammatesSize, 0, this.pi2, false);
2268 ctx.closePath();
2269 if (gameOptionSettings.oneColoredTeammates) {
2270 ctx.fillStyle = gameSetupTheme.miniMapTeammatesColor;
2271 } else {
2272 ctx.fillStyle = this.color;
2273 }
2274 ctx.fill();
2275 };
2276 }
2277 const application = {
2278 name: `OGARio by szymy v4`,
2279 version: `v4 (4.0.0 b38)`,
2280 privateMode: false,
2281 protocolMode: true,
2282 publicIP: `wss://srv.ogario.eu`,
2283 privateIP: null,
2284 updateInterval: 1000,
2285 updateTick: 0,
2286 updateMaxTick: 2,
2287 currentSector: '',
2288 miniMap: null,
2289 miniMapCtx: null,
2290 miniMapSectors: null,
2291 pi2: 2 * Math.PI,
2292 socket: null,
2293 cells: {},
2294 teamPlayers: [],
2295 parties: [],
2296 chatHistory: [],
2297 chatUsers: {},
2298 chatMutedUsers: {},
2299 chatMutedUserIDs: [],
2300 customSkinsCache: {},
2301 customSkinsMap: {},
2302 cacheQueue: [],
2303 deathLocations: [],
2304 playerID: null,
2305 playerMass: 0,
2306 selectedProfile: 0,
2307 lastDeath: 0,
2308 skipServerData: false,
2309 gameMode: `:ffa`,
2310 region: '',
2311 partyToken: '',
2312 ws: '',
2313 serverIP: '',
2314 serverArena: '',
2315 serverToken: '',
2316 lastSentNick: '',
2317 lastSentClanTag: null,
2318 lastSentSkinURL: '',
2319 lastSentCustomColor: '',
2320 lastSentPartyToken: '',
2321 lastSentServerToken: '',
2322 lastMessageSentTime: Date.now(),
2323 rFps: 0,
2324 renderedFrames: 0,
2325 fpsLastRequest: null,
2326 statsHUD: null,
2327 leaderboardPositionsHUD: null,
2328 leaderboardDataHUD: null,
2329 activeParties: null,
2330 top5pos: null,
2331 top5totalMass: null,
2332 top5totalPlayers: null,
2333 top5limit: 5,
2334 timeHUD: null,
2335 questHUD: null,
2336 retryResp: 0,
2337 token: 'b2dhcmlvLm92aA==',
2338 canvasScale: 1,
2339 selectBiggestCell: true,
2340 noColors: false,
2341 skipStats: false,
2342 showQuest: false,
2343 showSplitInd: false,
2344 pause: false,
2345 targetID: 0,
2346 targetStatus: 0,
2347 targetNick: '',
2348 targetSkinURL: '',
2349 targeting: false,
2350 privateMiniMap: false,
2351 messageSound: null,
2352 commandSound: null,
2353 feedInterval: null,
2354 getPlayerX() {
2355 return ogario.playerX + ogario.mapOffsetX;
2356 },
2357 getPlayerY() {
2358 return ogario.playerY + ogario.mapOffsetY;
2359 },
2360 feed() {
2361 window.core && window.core.eject && window.core.eject();
2362 },
2363 macroFeed(on) {
2364 if (on) {
2365 if (this.feedInterval) {
2366 return;
2367 }
2368 const app = this;
2369 this.feed();
2370 this.feedInterval = setInterval(() => {
2371 app.feed();
2372 }, 80);
2373 } else {
2374 if (this.feedInterval) {
2375 clearInterval(this.feedInterval);
2376 this.feedInterval = null;
2377 }
2378 }
2379 },
2380 split() {
2381 window.core && window.core.split && window.core.split();
2382 },
2383 doubleSplit() {
2384 const app = this;
2385 app.split();
2386 setTimeout(() => {
2387 app.split();
2388 }, 40);
2389 },
2390 popSplit() {
2391 const app = this;
2392 app.split();
2393 setTimeout(() => {
2394 app.split();
2395 }, 200);
2396 },
2397 split16() {
2398 const app = this;
2399 app.split();
2400 setTimeout(() => {
2401 app.split();
2402 }, 40);
2403 setTimeout(() => {
2404 app.split();
2405 }, 80);
2406 setTimeout(() => {
2407 app.split();
2408 }, 120);
2409 },
2410 toggleSkins() {
2411 if (ogario.vanillaSkins && ogario.customSkins) {
2412 ogario.vanillaSkins = false;
2413 } else if (!ogario.vannillaSkins && ogario.customSkins) {
2414 ogario.vanillaSkins = true;
2415 ogario.customSkins = false;
2416 } else {
2417 ogario.vanillaSkins = true;
2418 ogario.customSkins = true;
2419 }
2420 },
2421 toggleCells() {
2422 this.selectBiggestCell = !this.selectBiggestCell;
2423 ogario.selectBiggestCell = this.selectBiggestCell;
2424 },
2425 setShowTop5() {
2426 gameOptionSettings.showTop5 = !gameOptionSettings.showTop5;
2427 this.setTop5();
2428 },
2429 setTop5() {
2430 if (gameOptionSettings.showTop5) {
2431 JQuery(`#top5-hud`).show();
2432 } else {
2433 JQuery('#top5-hud').hide();
2434 }
2435 },
2436 setShowTargeting() {
2437 gameOptionSettings.showTargeting = !gameOptionSettings.showTargeting;
2438 this.setTargetingHUD();
2439 },
2440 setTargetingHUD() {
2441 if (gameOptionSettings.showTargeting) {
2442 JQuery('#target-hud, #target-panel-hud').show();
2443 } else {
2444 JQuery('#target-hud, #target-panel-hud').hide();
2445 }
2446 },
2447 setShowTime() {
2448 gameOptionSettings.showTime = !gameOptionSettings.showTime;
2449 if (gameOptionSettings.showTime) {
2450 JQuery(`#time-hud`).show();
2451 this.displayTime();
2452 } else {
2453 JQuery(`#time-hud`).hide();
2454 }
2455 },
2456 setShowSplitRange() {
2457 gameOptionSettings.splitRange = !gameOptionSettings.splitRange;
2458 ogario.splitRange = gameOptionSettings.splitRange;
2459 },
2460 setShowSplitInd() {
2461 this.showSplitInd = !this.showSplitInd;
2462 gameOptionSettings.splitRange = this.showSplitInd;
2463 gameOptionSettings.oppRings = this.showSplitInd;
2464 ogario.splitRange = gameOptionSettings.splitRange;
2465 ogario.oppRings = gameOptionSettings.oppRings;
2466 },
2467 setShowTeammatesInd() {
2468 gameOptionSettings.teammatesInd = !gameOptionSettings.teammatesInd;
2469 },
2470 setShowOppColors() {
2471 gameOptionSettings.oppColors = !gameOptionSettings.oppColors;
2472 ogario.oppColors = gameOptionSettings.oppColors;
2473 },
2474 setShowSkins() {
2475 this.noSkins = !this.noSkins;
2476 window.core && window.core.setSkins && window.core.setSkins(!this.noSkins);
2477 ogario.showCustomSkins = !this.noSkins;
2478 this.displayChatInfo(!this.noSkins, `showSkinsMsg`);
2479 },
2480 setTransparentSkins() {
2481 gameOptionSettings.transparentSkins = !gameOptionSettings.transparentSkins;
2482 ogario.transparentSkins = gameOptionSettings.transparentSkins;
2483 },
2484 setShowStats() {
2485 JQuery(`#stats-hud`).toggle();
2486 },
2487 setShowFood() {
2488 ogario.showFood = !ogario.showFood;
2489 },
2490 setShowHUD() {
2491 JQuery(`#overlays-hud`).toggle();
2492 },
2493 setShowGrid() {
2494 gameOptionSettings.showGrid = !gameOptionSettings.showGrid;
2495 },
2496 setShowMiniMapGuides() {
2497 gameOptionSettings.showMiniMapGuides = !gameOptionSettings.showMiniMapGuides;
2498 },
2499 setShowLb() {
2500 if (this.gameMode === `:teams`) {
2501 return;
2502 }
2503 JQuery(`#leaderboard-hud`).toggle();
2504 },
2505 setShowBgSectors() {
2506 gameOptionSettings.showBgSectors = !gameOptionSettings.showBgSectors;
2507 },
2508 setHideSmallBots() {
2509 ogario.hideSmallBots = !ogario.hideSmallBots;
2510 this.displayChatInfo(!ogario.hideSmallBots, `hideSmallBotsMsg`);
2511 },
2512 setShowNames() {
2513 gameOptionSettings.noNames = !gameOptionSettings.noNames;
2514 },
2515 setHideTeammatesNames() {
2516 gameOptionSettings.hideTeammatesNames = !gameOptionSettings.hideTeammatesNames;
2517 },
2518 setShowMass() {
2519 gameOptionSettings.showMass = !gameOptionSettings.showMass;
2520 },
2521 setShowMiniMap() {
2522 gameOptionSettings.showMiniMap = !gameOptionSettings.showMiniMap;
2523 this.setMiniMap();
2524 },
2525 setMiniMap() {
2526 if (gameOptionSettings.showMiniMap) {
2527 JQuery(`#minimap-hud`).show();
2528 } else {
2529 JQuery(`#minimap-hud`).hide();
2530 }
2531 },
2532 setShowQuest() {
2533 if (this.gameMode !== `:ffa`) {
2534 return;
2535 }
2536 this.showQuest = !this.showQuest;
2537 this.setQuest();
2538 },
2539 setQuest() {
2540 if (this.showQuest && this.gameMode === `:ffa`) {
2541 JQuery(`#quest-hud`).show();
2542 } else {
2543 JQuery(`#quest-hud`).hide();
2544 }
2545 },
2546 toggleAutoZoom() {
2547 ogario.autoZoom = !ogario.autoZoom;
2548 this.displayChatInfo(ogario.autoZoom, `autoZoomMsg`);
2549 },
2550 resetZoom(on) {
2551 if (on) {
2552 ogario.zoomResetValue = 1;
2553 ogario.zoomValue = 1;
2554 } else {
2555 ogario.zoomResetValue = 0;
2556 }
2557 },
2558 setZoom(value) {
2559 ogario.zoomValue = value;
2560 },
2561 toggleDeath() {
2562 this.lastDeath--;
2563 if (this.lastDeath < 0) {
2564 this.lastDeath = this.deathLocations.length - 1;
2565 }
2566 },
2567 tryResp() {
2568 if (ogario.play || this.retryResp == 20) {
2569 this.retryResp = 0;
2570 return;
2571 }
2572 this.retryResp++;
2573 const app = this;
2574 setTimeout(() => {
2575 if (JQuery(`.btn-play-guest`).is(`:visible`)) {
2576 JQuery(`.btn-play-guest`).click();
2577 } else {
2578 JQuery('.btn-play').click();
2579 }
2580 if (!ogario.play) {
2581 app.tryResp();
2582 }
2583 }, 500);
2584 },
2585 quickResp() {
2586 if (!gameOptionSettings.quickResp) {
2587 return;
2588 }
2589 this.hideMenu();
2590 this.gameServerConnect(this.ws);
2591 ogario.play = false;
2592 this.tryResp();
2593 },
2594 autoResp() {
2595 if (!gameOptionSettings.autoResp) {
2596 return;
2597 }
2598 this.setAutoResp();
2599 JQuery('#overlays').stop().hide();
2600 if (JQuery('.btn-play-guest').is(`:visible`)) {
2601 JQuery(`.btn-play-guest`).click();
2602 return;
2603 }
2604 JQuery('.btn-play').click();
2605 },
2606 setAutoResp() {
2607 if (gameOptionSettings.autoResp) {
2608 if (!JQuery(`#skipStats`).prop(`checked`)) {
2609 JQuery(`#skipStats`).click();
2610 this.skipStats = true;
2611 }
2612 }
2613 },
2614 toggleAutoResp() {
2615 gameOptionSettings.autoResp = !gameOptionSettings.autoResp;
2616 this.setAutoResp();
2617 this.displayChatInfo(gameOptionSettings.autoResp, `autoRespMsg`);
2618 },
2619 copyLb() {
2620 const input = JQuery(`<input>`);
2621 JQuery(`body`).append(input);
2622 input.val(JQuery('#leaderboard-positions').text()).select();
2623 try {
2624 document.execCommand(`copy`);
2625 } catch (error) {
2626 console.log("can't copy..")
2627 }
2628 input.remove();
2629 },
2630 setPause() {
2631 this.pause = !this.pause;
2632 ogario.pause = this.pause;
2633 if (this.pause) {
2634 ogario.resetTargetPosition();
2635 JQuery(`#pause-hud`).show();
2636 } else {
2637 JQuery(`#pause-hud`).hide();
2638 }
2639 },
2640 setCenteredLb() {
2641 if (gameOptionSettings.centeredLb) {
2642 JQuery(`#leaderboard-hud`).addClass('hud-text-center');
2643 } else {
2644 JQuery(`#leaderboard-hud`).removeClass('hud-text-center');
2645 }
2646 },
2647 setNormalLb() {
2648 if (gameOptionSettings.normalLb) {
2649 JQuery(`#leaderboard-hud h4`).html(textLanguage.leaderboard);
2650 } else {
2651 JQuery('#leaderboard-hud h4').html(`ogario.ovh`);
2652 }
2653 },
2654 setFpsAtTop() {
2655 if (gameOptionSettings.fpsAtTop) {
2656 JQuery('#stats-hud').removeClass('hud-bottom').addClass(`hud-top`);
2657 } else {
2658 JQuery(`#stats-hud`).removeClass(`hud-top`).addClass(`hud-bottom`);
2659 }
2660 },
2661 setBlockPopups() {
2662 if (this.protocolMode) {
2663 JQuery(`#block-warn`).hide();
2664 return;
2665 }
2666 if (gameOptionSettings.blockPopups) {
2667 this.blockPopups();
2668 } else {
2669 this.unblockPopups();
2670 }
2671 },
2672 blockPopups() {
2673 JQuery(`#openfl-content, #openfl-overlay`).hide();
2674 JQuery(`#openfl-content, #openfl-overlay`).addClass(`block-popups`);
2675 JQuery(`#freeCoins, #gifting, #openShopBtn, #dailyQuests`).prop(`disabled`, true);
2676 JQuery(`#block-warn`).show();
2677 },
2678 unblockPopups() {
2679 JQuery(`#openfl-overlay.disabler`).click();
2680 JQuery(`#openfl-content, #openfl-overlay`).hide();
2681 JQuery(`#openfl-content, #openfl-overlay`).removeClass(`block-popups`);
2682 JQuery(`#freeCoins, #gifting, #openShopBtn, #dailyQuests`).prop(`disabled`, false);
2683 JQuery(`#block-warn`).hide();
2684 },
2685 tempUnblockPopups() {
2686 if (!gameOptionSettings.blockPopups) {
2687 return;
2688 }
2689 this.unblockPopups();
2690 },
2691 displayLeaderboard(position, data = '') {
2692 if (!this.leaderboardPositionsHUD) {
2693 return;
2694 }
2695 this.leaderboardPositionsHUD.innerHTML = position;
2696 this.leaderboardDataHUD.innerHTML = data;
2697 },
2698 displayStats() {
2699 if (!gameOptionSettings.showStats) {
2700 JQuery(`#stats-hud`).hide();
2701 return;
2702 }
2703 let text = '';
2704 if (ogario.play) {
2705 if (gameOptionSettings.showStatsMass && ogario.playerMass) {
2706 text += `${textLanguage.mass}: ${ogario.playerMass} | `;
2707 }
2708 if (ogario.playerScore) {
2709 text += `${textLanguage.score}: ${ogario.playerScore}`;
2710 }
2711 if (gameOptionSettings.showStatsSTE && ogario.STE) {
2712 text += ` | STE: ` + ogario.STE;
2713 }
2714 if (gameOptionSettings.showStatsN16 && ogario.playerSplitCells) {
2715 text += ` | ` + ogario.playerSplitCells + `/16`;
2716 }
2717 if (gameOptionSettings.showStatsFPS) {
2718 text += ` | `;
2719 }
2720 }
2721 if (gameOptionSettings.showStatsFPS) {
2722 text += `FPS: ` + drawRender.fps;
2723 }
2724 this.statsHUD.textContent = text;
2725 const app = this;
2726 setTimeout(() => {
2727 app.displayStats();
2728 }, 250);
2729 },
2730 displayTime() {
2731 if (!gameOptionSettings.showTime) {
2732 JQuery(`#time-hud`).hide();
2733 return;
2734 }
2735 const time = new Date().toLocaleString();
2736 this.timeHUD.textContent = time;
2737 const app = this;
2738 setTimeout(() => {
2739 app.displayTime();
2740 }, 1000);
2741 },
2742 displayParties() {
2743 let text = '';
2744 for (let length = 0; length < this.parties.length; length++) {
2745 text += `<li><a href="https://agar.io/#` + this.parties[length] + `" onclick="$('#party-token').val('` + this.parties[length] + `'); $('#join-party-btn-2').click();">https://agar.io/#` + this.parties[length] + `</a></li>`;
2746 }
2747 if (text === '') {
2748 this.activeParties.className = `no-parties`;
2749 } else {
2750 this.activeParties.className = '';
2751 }
2752 this.activeParties.innerHTML = text;
2753 },
2754 displayTop5() {
2755 if (!gameOptionSettings.showTop5) {
2756 return;
2757 }
2758 let text = '';
2759 let mass = 0;
2760 let top5length = this.top5.length;
2761 for (let length = 0; length < top5length; length++) {
2762 mass += this.top5[length].mass;
2763 if (length >= this.top5limit) {
2764 continue;
2765 }
2766 text += `<li><span class="cell-counter" style="background-color: ${this.top5[length].color}">${length + 1}${`</span>`}`;
2767 if (gameOptionSettings.showTargeting) {
2768 text += `<a href="#" data-user-id="` + this.top5[length].id + `" class="set-target ogicon-target"></a> `;
2769 }
2770 text += `<span class="hud-main-color">[` + this.calculateMapSector(this.top5[length].x, this.top5[length].y) + `]</span>`;
2771 text += `<span class="top5-mass-color">[${this.shortMassFormat(this.top5[length].mass)}${`]</span> `}${this.escapeHTML(this.top5[length].nick)}${`</li>`}`;
2772 }
2773 this.top5pos.innerHTML = text;
2774 if (ogario.play && ogario.playerMass) {
2775 mass += ogario.playerMass;
2776 top5length++;
2777 }
2778 this.top5totalMass.textContent = this.shortMassFormat(mass);
2779 this.top5totalPlayers.textContent = top5length;
2780 },
2781 setTop5limit(value) {
2782 if (!value) {
2783 return;
2784 }
2785 this.top5limit = value;
2786 },
2787 displayChatHistory(on) {
2788 if (on) {
2789 this.clearChatHistory(true);
2790 for (let length = 0; length < this.chatHistory.length; length++) {
2791 JQuery(`#messages`).append(`<li><span class="message-nick">` + this.chatHistory[length].nick + `: </span><span class="message-text">` + this.chatHistory[length].message + `</span></li>`);
2792 }
2793 return;
2794 }
2795 this.clearChatHistory(false);
2796 },
2797 clearChatHistory(on) {
2798 JQuery(`#messages`).empty();
2799 if (on) {
2800 toastr.clear();
2801 if (gameOptionSettings.showChatBox) {
2802 JQuery(`#chat-box .message`).remove();
2803 this.chatHistory.length = 0;
2804 }
2805 }
2806 },
2807 displayChatInfo(on, info) {
2808 if (on) {
2809 toastr.info(textLanguage[`${info}A`]);
2810 } else {
2811 toastr.error(textLanguage[`${info}B`]);
2812 }
2813 },
2814 setDisableChat() {
2815 gameOptionSettings.hideChat = gameOptionSettings.disableChat;
2816 this.setHideChat();
2817 },
2818 hideChat() {
2819 gameOptionSettings.hideChat = !gameOptionSettings.hideChat;
2820 this.setHideChat();
2821 this.displayChatInfo(!gameOptionSettings.hideChat, `hideChatMsg`);
2822 },
2823 setHideChat() {
2824 if (gameOptionSettings.hideChat) {
2825 JQuery(`#message-box`).hide();
2826 }
2827 this.setShowChatBox();
2828 },
2829 setShowChatBox() {
2830 if (!gameOptionSettings.hideChat && gameOptionSettings.showChatBox) {
2831 JQuery('#chat-box').show();
2832 } else {
2833 JQuery(`#chat-box`).hide();
2834 }
2835 },
2836 enterChatMessage() {
2837 const messageBox = JQuery(`#message-box`);
2838 const message = JQuery(`#message`);
2839 if (!messageBox.is(`:visible`)) {
2840 messageBox.show();
2841 message.focus();
2842 message.val('');
2843 } else {
2844 const value = message.val();
2845 if (value.length) {
2846 this.sendChatMessage(101, value);
2847 if (ogario.play) {
2848 message.blur();
2849 messageBox.hide();
2850 }
2851 } else {
2852 message.blur();
2853 messageBox.hide();
2854 }
2855 message.val('');
2856 }
2857 },
2858 showMenu(value) {
2859 if (window.MC && window.MC.showNickDialog) {
2860 JQuery('.ogario-menu').show();
2861 JQuery('.menu-panel').hide();
2862 if (!ogario.play && !this.skipStats) {
2863 JQuery('#stats').show();
2864 } else {
2865 JQuery(`#main-panel`).show();
2866 }
2867 window.MC.showNickDialog(300);
2868 JQuery('#oferwallContainer').is(`:visible`) && window.closeOfferwall();
2869 JQuery(`#videoContainer`).is(`:visible`) && window.closeVideoContainer();
2870 return;
2871 }
2872 if (value) {
2873 JQuery(`#overlays`).fadeIn(value);
2874 } else {
2875 JQuery(`#overlays`).show();
2876 }
2877 },
2878 hideMenu(value) {
2879 if (window.MC && window.MC.showNickDialog) {
2880 JQuery(`.ogario-menu`).hide();
2881 return;
2882 }
2883 if (value) {
2884 JQuery(`#overlays`).fadeOut(value);
2885 } else {
2886 JQuery(`#overlays`).hide();
2887 }
2888 },
2889 escapeHTML(string) {
2890 return String(string).replace(/[&<>"'/]/g, event => escapeChar[event]);
2891 },
2892 checkImgURL(url) {
2893 if (url.includes("png") || url.includes("jpg") || url.includes("jpeg")) {
2894 return url;
2895 } else {
2896 return false;
2897 }
2898 },
2899 checkSkinURL(url) {
2900 return this.checkImgURL(url)
2901 },
2902 loadSettings() {
2903 let settings = null;
2904 if (window.localStorage.getItem(`ogarioSettings`) !== null) {
2905 settings = JSON.parse(window.localStorage.getItem(`ogarioSettings`));
2906 }
2907 for (const option in gameOptionSettings) {
2908 if (gameOptionSettings.hasOwnProperty(option)) {
2909 if (settings && settings.hasOwnProperty(option)) {
2910 gameOptionSettings[option] = settings[option];
2911 }
2912 if (ogario.hasOwnProperty(option)) {
2913 ogario[option] = gameOptionSettings[option];
2914 }
2915 }
2916 }
2917 },
2918 saveSettings(option, name) {
2919 window.localStorage.setItem(name, JSON.stringify(option));
2920 },
2921 exportSettings() {
2922 let options = {
2923 ogarioCommands: chatCommand,
2924 ogarioHotkeys: hotkeys,
2925 ogarioPlayerProfiles: PlayerProfiles,
2926 ogarioSettings: gameOptionSettings,
2927 ogarioThemeSettings: gameSetupTheme
2928 };
2929 for (const option in options) {
2930 if (options.hasOwnProperty(option)) {
2931 const checked = JQuery(`#export-` + option).prop(`checked`);
2932 if (!checked) {
2933 delete options[option];
2934 }
2935 }
2936 }
2937 options = JSON.stringify(options);
2938 JQuery(`#export-settings`).val(options);
2939 JQuery(`#import-settings`).val('');
2940 options = null;
2941 },
2942 importSettings() {
2943 JQuery(`#import-settings`).blur();
2944 let importValue = JQuery(`#import-settings`).val();
2945 if (importValue) {
2946 importValue = JSON.parse(importValue);
2947 for (const value in importValue) {
2948 if (importValue.hasOwnProperty(value)) {
2949 const checked = JQuery(`#import-` + value).prop(`checked`);
2950 if (!checked) {
2951 continue;
2952 }
2953 window.localStorage.setItem(value, JSON.stringify(importValue[value]));
2954 }
2955 }
2956 window.location.reload();
2957 }
2958 },
2959 restoreSettings() {
2960 if (window.localStorage.getItem('ogarioSettings') !== null) {
2961 window.localStorage.removeItem(`ogarioSettings`);
2962 window.location.reload();
2963 }
2964 },
2965 setSettings(id, checked) {
2966 if (gameOptionSettings.hasOwnProperty(id) && checked !== null) {
2967 gameOptionSettings[id] = checked;
2968 if (ogario.hasOwnProperty(id)) {
2969 ogario[id] = checked;
2970 }
2971 switch (id) {
2972 case `autoResp`:
2973 this.setAutoResp();
2974 break;
2975 case `showMiniMap`:
2976 this.setMiniMap();
2977 break;
2978 case `showMiniMapGrid`:
2979 this.resetMiniMapSectors();
2980 break;
2981 case `disableChat`:
2982 this.setDisableChat();
2983 break;
2984 case `chatSounds`:
2985 this.setChatSoundsBtn();
2986 break;
2987 case 'showChatBox':
2988 this.setShowChatBox();
2989 break;
2990 case `showTop5`:
2991 this.setTop5();
2992 break;
2993 case 'showTargeting':
2994 this.setTargetingHUD();
2995 break;
2996 case `showTime`:
2997 this.displayTime();
2998 JQuery('#time-hud').show();
2999 break;
3000 case `centeredLb`:
3001 this.setCenteredLb();
3002 break;
3003 case 'normalLb':
3004 this.setNormalLb();
3005 break;
3006 case `fpsAtTop`:
3007 this.setFpsAtTop();
3008 break;
3009 case `showStats`:
3010 this.displayStats();
3011 JQuery(`#stats-hud`).show();
3012 break;
3013 case 'blockPopups':
3014 this.setBlockPopups();
3015 break;
3016 }
3017 this.saveSettings(gameOptionSettings, 'ogarioSettings');
3018 }
3019 },
3020 loadProfiles() {
3021 if (window.localStorage.getItem(`ogarioPlayerProfiles`) !== null) {
3022 PlayerProfiles = JSON.parse(window.localStorage.getItem('ogarioPlayerProfiles'));
3023 } else {
3024 let profilesLength = 10;
3025 for (let length = 0; length < profilesLength; length++) {
3026 PlayerProfiles.push({
3027 nick: `Profile #` + (length + 1),
3028 clanTag: '',
3029 skinURL: '',
3030 color: gameSetupTheme.mainColor
3031 });
3032 }
3033 }
3034 if (window.localStorage.getItem(`ogarioSelectedProfile`) !== null) {
3035 this.selectedProfile = JSON.parse(window.localStorage.getItem(`ogarioSelectedProfile`));
3036 }
3037 mainProfile.nick = PlayerProfiles[this.selectedProfile].nick;
3038 mainProfile.clanTag = PlayerProfiles[this.selectedProfile].clanTag;
3039 mainProfile.skinURL = PlayerProfiles[this.selectedProfile].skinURL;
3040 mainProfile.color = PlayerProfiles[this.selectedProfile].color;
3041 },
3042 changeSkinPreview(img, id) {
3043 if (!img || !id) {
3044 return;
3045 }
3046 if (id === `skin-preview`) {
3047 JQuery(`#skin-preview`).removeClass(`default`).append(`<a href="#" id="skin-popover" data-toggle="popover" title="" data-html="true" data-content="<img src='${img.src}' width='500'>"></a>`);
3048 JQuery(`#skin-popover`).append(JQuery(img).fadeIn(1000));
3049 JQuery('#skin-popover').popover();
3050 } else {
3051 JQuery(`#${id}`).removeClass(`default`).append(JQuery(img).fadeIn(1000));
3052 }
3053 },
3054 setSkinPreview(img, id) {
3055 const skinID = id == `skin-preview`;
3056 if (JQuery(`#${id}${` img`}`).attr('src') === img) {
3057 return;
3058 }
3059 JQuery(`#${id}`).empty().addClass(`default`);
3060 if (!img) {
3061 skinID && JQuery(`#skin`).popover(`hide`);
3062 return;
3063 }
3064 if (!this.checkSkinURL(img)) {
3065 if (skinID) {
3066 let notValidText = '<p><strong>Submitted URL is not valid.</strong></p>';
3067 if (/hizliresim.com/ .test(img)) {
3068 notValidText += `<p>NOTICE: <strong>hizliresim.com</strong> is not supported anymore.</p>`;
3069 }
3070 notValidText += `<p>Check if URL:</p><ul><li>is supported by OGARio (see list below)</li><li>is no longer than 60 characters</li></ul>`;
3071 notValidText += '<p>Supported image hosting sites:</p>';
3072 notValidText += `<ol>`;
3073 for (let length = 0; length < SkinExplain.length; length++) {
3074 notValidText += `${`<li><strong><a href="` + SkinExplain[length].url}" rel="noreferrer noopener" target="_blank">${SkinExplain[length].name}</a></strong><span class="example-url">e.g. <a href="${SkinExplain[length].example}${`" rel="noreferrer noopener" target="_blank">`}${SkinExplain[length].example}${`</a></span></li>`}`;
3075 }
3076 notValidText += `</ol>`;
3077 JQuery('#skin').attr(`data-content`, notValidText);
3078 JQuery(`#skin`).popover('show');
3079 JQuery(`#skin`).focus();
3080 }
3081 return;
3082 }
3083 const app = this;
3084 const image = new Image();
3085 image.crossOrigin = `Anonymous`;
3086 image.onload = () => {
3087 app.changeSkinPreview(image, id);
3088 skinID && JQuery(`#skin`).popover(`hide`);
3089 };
3090 image.onerror = () => {
3091 if (skinID) {
3092 let errorText = '<p><strong>Error while loading image.</strong></p>';
3093 errorText += `<p>Check if image URL is valid.</p>`;
3094 JQuery(`#skin`).attr(`data-content`, errorText);
3095 JQuery(`#skin`).popover('show');
3096 JQuery(`#skin`).focus();
3097 }
3098 };
3099 image.src = img;
3100 },
3101 setProfile() {
3102 const prevProfile = (PlayerProfiles.length + this.selectedProfile - 1) % PlayerProfiles.length;
3103 const nextProfile = (this.selectedProfile + 1) % PlayerProfiles.length;
3104 this.setSkinPreview(PlayerProfiles[prevProfile].skinURL, 'prev-profile');
3105 this.setSkinPreview(PlayerProfiles[this.selectedProfile].skinURL, `skin-preview`);
3106 this.setSkinPreview(PlayerProfiles[nextProfile].skinURL, `next-profile`);
3107 this.saveSettings(this.selectedProfile, `ogarioSelectedProfile`);
3108 JQuery(`#nick`).val(PlayerProfiles[this.selectedProfile].nick);
3109 JQuery(`#clantag`).val(PlayerProfiles[this.selectedProfile].clanTag);
3110 JQuery(`#skin`).val(PlayerProfiles[this.selectedProfile].skinURL);
3111 JQuery(`#color`).val(PlayerProfiles[this.selectedProfile].color);
3112 JQuery(`.skin`).colorpicker(`setValue`, PlayerProfiles[this.selectedProfile].color);
3113 JQuery('#skins a').removeClass('selected');
3114 JQuery(`#skins a[data-profile=${this.selectedProfile}]`).addClass(`selected`);
3115 },
3116 prevProfile() {
3117 this.setPlayerSettings();
3118 this.selectedProfile = (PlayerProfiles.length + this.selectedProfile - 1) % PlayerProfiles.length;
3119 this.setProfile();
3120 },
3121 nextProfile() {
3122 this.setPlayerSettings();
3123 this.selectedProfile = (this.selectedProfile + 1) % PlayerProfiles.length;
3124 this.setProfile();
3125 },
3126 selectProfile(value) {
3127 this.setPlayerSettings();
3128 this.selectedProfile = parseInt(value);
3129 this.setProfile();
3130 },
3131 addOption(id, name, text, checked) {
3132 JQuery(id).append(`<label><input type="checkbox" id="${name}${`" class="js-switch"> `}${text}${`</label>`}`);
3133 JQuery(`#${name}`).prop(`checked`, checked);
3134 },
3135 addOptions(options, section) {
3136 if (!options) {
3137 return;
3138 }
3139 JQuery('#og-options').append(`${`<div class="options-box ` + section}"><h5 class="menu-main-color">${textLanguage[section]}</h5></div>`);
3140
3141 for (const option of options) {
3142 if (gameOptionSettings.hasOwnProperty(option)) {
3143 JQuery(`.${section}`).append(`${`<label>` + textLanguage[option]} <input type="checkbox" class="js-switch" id="${option}${`"></label>`}`);
3144 JQuery(`#${option}`).prop(`checked`, gameOptionSettings[option]);
3145 }
3146 }
3147 },
3148 addInputBox(id, name, holder, callback) {
3149 JQuery(id).append(`${`<div class="input-box"><span class="title-box">` + textLanguage[name]}</span><input id="${name}${`" class="form-control" placeholder="`}${holder}${`" value="`}${gameOptionSettings[name]}${`" /></div>`}`);
3150 const app = this;
3151 JQuery(`#${name}`).on(`input`, function() {
3152 gameOptionSettings[name] = this.value;
3153 app[callback]();
3154 app.saveSettings(gameOptionSettings, `ogarioSettings`);
3155 });
3156 },
3157 addSliderBox(id, name, min, max, step, callback) {
3158 JQuery(id).append(`${`<div class="slider-box"><div class="box-label"><span class="value-label">` + textLanguage[name] + `: </span><span id="` + name}-value" class="value">${gameOptionSettings[name]}${`</span></div><input id="`}${name}-slider" type="range" min="${min}" max="${max}${`" step="`}${step}" value="${gameOptionSettings[name]}${`"></div>`}`);
3159 const app = this;
3160 if (callback) {
3161 JQuery(`#${name}${`-slider`}`).on(`input`, function() {
3162 const parse = parseFloat(JQuery(this).val());
3163 JQuery(`#${name}-value`).text(parse);
3164 gameOptionSettings[name] = parse;
3165 if (ogario.hasOwnProperty(name)) {
3166 ogario[name] = parse;
3167 }
3168 app[callback]();
3169 app.saveSettings(gameOptionSettings, `ogarioSettings`);
3170 });
3171 } else {
3172 JQuery(`#${name}-slider`).on('input', function() {
3173 const parse = parseFloat(JQuery(this).val());
3174 JQuery(`#${name}${`-value`}`).text(parse);
3175 gameOptionSettings[name] = parse;
3176 if (ogario.hasOwnProperty(name)) {
3177 ogario[name] = parse;
3178 }
3179 app.saveSettings(gameOptionSettings, 'ogarioSettings');
3180 });
3181 }
3182 },
3183 setLang() {
3184 if (lang !== 'pl') {
3185 return;
3186 }
3187 if (window.i18n_dict && window.i18n_dict.en) {
3188 for (var lang in window.i18n_dict.en) {
3189 if (window.i18n_dict.en.hasOwnProperty(lang) && textLanguage.hasOwnProperty(lang)) {
3190 window.i18n_dict.en[lang] = textLanguage[lang];
3191 }
3192 }
3193 }
3194 },
3195 setMenu() {
3196 const app = this;
3197 document.title = this.name;
3198 JQuery(`#mainPanel`).before(`<div id="exp-bar" class="agario-panel"><span class="ogicon-user"></span><div class="agario-exp-bar progress"><span class="progress-bar-text"></span><div class="progress-bar progress-bar-striped" style="width: 0%;"></div></div><div class="progress-bar-star"></div></div><div id="main-menu" class="agario-panel"><ul class="menu-tabs"><li class="start-tab active"><a href="#main-panel" class="active ogicon-home" data-toggle="tab-tooltip" title="${textLanguage.start}${`"></a></li><li class="profile-tab"><a href="#profile" class="ogicon-user" data-toggle="tab-tooltip" title="`}${textLanguage.profile}${`"></a></li><li class="settings-tab"><a href="#og-settings" class="ogicon-cog" data-toggle="tab-tooltip" title="`}${textLanguage.settings}${`"></a></li><li class="theme-tab"><a href="#theme" class="ogicon-droplet" data-toggle="tab-tooltip" title="`}${textLanguage.theme}${`"></a></li><li class="hotkeys-tab"><a href="#" class="hotkeys-link ogicon-keyboard" data-toggle="tab-tooltip" title="`}${textLanguage.hotkeys}"></a></li><li class="music-tab"><a href="#music" class="ogicon-music" data-toggle="tab-tooltip" title="Radio / ${textLanguage.sounds}"></a></li></ul><div id="main-panel" class="menu-panel"></div><div id="profile" class="menu-panel"></div><div id="og-settings" class="menu-panel"><div class="submenu-panel"></div></div><div id="theme" class="menu-panel"></div><div id="music" class="menu-panel"></div></div>`);
3199 JQuery('#main-panel').append('<a href="#" class="quick quick-menu ogicon-menu"></a><a href="#" class="quick quick-skins ogicon-images"></a><div id="profiles"><div id="prev-profile" class="skin-switch"></div><div id="skin-preview"></div><div id="next-profile" class="skin-switch"></div></div>');
3200 JQuery(`#mainPanel div[role=form]`).appendTo(JQuery('#main-panel'));
3201 JQuery(`#main-panel div[role=form] .form-group:first`).remove();
3202 JQuery('#nick').before(`<input id="clantag" class="form-control" placeholder="Tag, e.g. Ⓜ" maxlength="10"><div class="input-group nick"></div>`);
3203 JQuery(`#nick`).appendTo(JQuery(`.nick`));
3204 JQuery(`.nick`).append(`<span class="input-group-btn"><button id="stream-mode" class="btn active ogicon-eye"></button></span>`);
3205 JQuery(`.nick`).after(`<div class="input-group skin"><input id="skin" class="form-control" placeholder="Skin URL (direct link)" maxlength="60"><input type="hidden" id="color" value="` + mainProfile.color + `" maxlength="7" /><span class="input-group-addon"><i></i></span><span class="input-group-btn"><button id="hide-url" class="btn active ogicon-eye"></button></span></div>`);
3206 JQuery(`#locationKnown, #locationUnknown`).insertAfter(JQuery(`.skin`));
3207 JQuery(`#region`).before(`<button class="btn btn-warning btn-server-info ogicon-cogs"></button>`);
3208 JQuery(`.btn-spectate, .btn-logout`).appendTo(`#agario-main-buttons`);
3209 JQuery(`#agario-main-buttons`).addClass('clearfix').before(`<div id="server-info" class="form-group clearfix"><input id="server-ws" class="form-control" placeholder="Server WS"><button id="server-connect" class="btn btn-success ogicon-power"></button><button id="server-reconnect" class="btn btn-primary ogicon-redo2"></button><input id="server-token" class="form-control" placeholder="Server token"><button id="server-join" class="btn btn-success" data-itr="page_join_party">Join</button></div>`);
3210 JQuery(`#helloContainer div[role=form]`).after(`<div id="ogario-party" class="clearfix"><input id="party-token" class="form-control" placeholder="Party token"></div>`);
3211 JQuery(`#ogario-party`).append(`<button id="join-party-btn-2" class="btn btn-success" data-itr="page_join_party">Join</button><button id="create-party-btn-2" class="btn btn-primary" data-itr="page_create_party">Create</button>`);
3212 JQuery('#pre-join-party-btn:first, #join-party-btn:first, #create-party-btn:first, #leave-party-btn:first, #joinPartyToken:first, .party-icon-back:first').appendTo(JQuery(`#ogario-party`));
3213 JQuery(`#settingsChoice, #options`).appendTo(JQuery(`#og-settings .submenu-panel`));
3214 JQuery(`#stats`).appendTo(JQuery(`#main-menu`)).addClass(`menu-panel`);
3215 JQuery(`#statsContinue`).attr('id', 'statsContinue2');
3216 JQuery(`#mainPanel`).empty().remove();
3217 JQuery(`.center-container`).addClass(`ogario-menu`);
3218 JQuery(`.center-container`).append(`<div id="menu-footer" class="menu-main-color">` + textLanguage.visit + ` <a href="https://ogario.ovh" target="_blank">ogario.ovh</a> | ` + this.version + ` <a href="https://goo.gl/nRREoR" class="release ogicon-info" target="_blank"></a></div>`);
3219 JQuery(`#leftPanel, #rightPanel`).addClass('ogario-menu').removeAttr('id');
3220 JQuery(`.agario-profile-panel, .agario-panel-freecoins, .agario-panel-gifting, .agario-shop-panel, #dailyquests-panel`).appendTo(JQuery(`#profile`)).removeClass('agario-side-panel');
3221 JQuery(`.agario-profile-panel`).after(`<div id="block-warn">` + textLanguage.blockWarn + `<br><a href="#" id="unblock-popups">` + textLanguage.unblockPopups + `</a></div>`);
3222 JQuery(`#exp-bar`).addClass(`agario-profile-panel`);
3223 JQuery(`.left-container`).empty();
3224 JQuery(`.agario-shop-panel`).after(`<div class="agario-panel ogario-yt-panel"><h5 class="menu-main-color">Team OGARio (tag: Ⓜ)</h5><div class="g-ytsubscribe" data-channelid="UCaWiPNJWnhzYDrBQoXokn6w" data-layout="full" data-theme="dark" data-count="default"></div></div>`);
3225 JQuery(`#tags-container`).appendTo(JQuery('#profile'));
3226 JQuery(`.btn-logout`).appendTo(JQuery(`#profile`));
3227 JQuery(`.left-container`).append(`<div id="quick-menu" class="agario-panel agario-side-panel"><a href="https://ogario.ovh/skins/" class="quick-more-skins ogicon-grin" target="_blank" data-toggle="tab-tooltip" data-placement="left" title="` + textLanguage.skins + `"></a><a href="https://youtube.com/channel/UCaWiPNJWnhzYDrBQoXokn6w" class="quick-yt ogicon-youtube2" target="_blank" data-toggle="tab-tooltip" data-placement="left" title="Team OGARio"></a></div>`);
3228 if (!this.protocolMode) {
3229 JQuery(`#quick-menu`).prepend(`${`<a href="#" class="quick-shop ogicon-cart" data-toggle="tab-tooltip" data-placement="left" title="` + textLanguage.page_shop + `"></a><a href="#" class="quick-free-coins ogicon-coin-dollar" data-toggle="tab-tooltip" data-placement="left" title="` + textLanguage.page_menu_main_free_coins + `"></a><a href="#" class="quick-free-gifts ogicon-gift" data-toggle="tab-tooltip" data-placement="left" title="` + textLanguage.page_menu_main_gifts}"></a><a href="#" class="quick-quests ogicon-trophy" data-toggle="tab-tooltip" data-placement="left" title="${textLanguage.page_menu_main_dailyquests}"></a>`);
3230 }
3231 JQuery(`.party-dialog, .partymode-info`).remove();
3232 JQuery(`.agario-party-6`).appendTo(JQuery(`.center-container`));
3233 JQuery(`.right-container`).empty();
3234 JQuery(`.right-container`).append(`<div class="agario-party"></div>`);
3235 JQuery(`.agario-party-6`).appendTo(JQuery(`.agario-party`)).addClass(`agario-panel agario-side-panel`);
3236 JQuery(`.agario-party h4, #cancel-party-btn`).remove();
3237 JQuery(`.agario-party .btn`).addClass(`btn-sm`);
3238 JQuery(`.right-container`).append(`${`<div id="skins-panel" class="agario-panel agario-side-panel"><div id="skins"></div><a href="https://ogario.ovh/skins/" id="more-skins" class="btn btn-block btn-success" target="_blank">` + textLanguage.moreSkins}</a></div>`);
3239 JQuery(`.btn-settings, .text-muted, .tosBox, .agario-promo, #agario-web-incentive, span[data-itr='page_option_dark_theme'], #options #darkTheme`).remove();
3240 JQuery('#advertisement, #adbg, #a32592, #g32592, #s32592, #adsBottom').css(`display`, `none`);
3241 JQuery('#advertisement').removeClass(`agario-panel`);
3242 JQuery(`#adsBottom`).css({
3243 'z-index': '1',
3244 opacity: '0',
3245 bottom: `-100px`
3246 });
3247 JQuery(`#noNames, #showMass`).remove();
3248 JQuery(`#og-settings .submenu-panel`).append('<div id="og-options"></div>');
3249 this.addOptions([], `animationGroup`);
3250 this.addOptions('autoZoom', `zoomGroup`);
3251 this.addOptions([`quickResp`, `autoResp`], `respGroup`);
3252 this.addOptions(['noNames', `optimizedNames`, `autoHideNames`, `hideMyName`, `hideTeammatesNames`, `namesStroke`], `namesGroup`);
3253 this.addOptions(['showMass', `optimizedMass`, `autoHideMass`, `hideMyMass`, 'hideEnemiesMass', `shortMass`, `virMassShots`, `massStroke`], `massGroup`);
3254 if (this.protocolMode) {
3255 this.addOptions('customSkins', `skinsGroup`);
3256 } else {
3257 this.addOptions([`customSkins`, 'vanillaSkins'], 'skinsGroup');
3258 }
3259 this.addOptions([`optimizedFood`, 'autoHideFood', 'autoHideFoodOnZoom', `rainbowFood`], `foodGroup`);
3260 this.addOptions([`myCustomColor`, 'myTransparentSkin', `transparentSkins`, 'transparentCells', 'transparentViruses'], `transparencyGroup`);
3261 this.addOptions([`showGrid`, `showBgSectors`, `showMapBorders`], `gridGroup`);
3262 this.addOptions([`disableChat`, 'chatSounds', `chatEmoticons`, `showChatImages`, `showChatVideos`, `showChatBox`], `chatGroup`);
3263 this.addOptions(['showMiniMap', `showMiniMapGrid`, `showMiniMapGuides`, `oneColoredTeammates`], `miniMapGroup`);
3264 this.addOptions([`oppColors`, `oppRings`, 'virColors', `splitRange`, `virusesRange`, `cursorTracking`, 'teammatesInd'], `helpersGroup`);
3265 this.addOptions([`mouseSplit`, 'mouseFeed', `mouseInvert`], `mouseGroup`);
3266 this.addOptions([`showTop5`, 'showTargeting', `showLbData`, 'centeredLb', `normalLb`, `fpsAtTop`], `hudGroup`);
3267 this.addOptions(['showStats', `showStatsMass`, `showStatsSTE`, 'showStatsN16', `showStatsFPS`, `showTime`], `statsGroup`);
3268 if (!this.protocolMode) {
3269 this.addOptions('blockPopups', 'extrasGroup');
3270 JQuery(`#noSkins, #noColors, #skipStats, #showQuest`).addClass(`js-switch-vanilla`);
3271 JQuery(`.skinsGroup h5`).after(`<label class="noSkins">${textLanguage.noSkins}${` </label>`}`);
3272 JQuery(`#noSkins`).appendTo(JQuery(`.noSkins`));
3273 JQuery(`.transparencyGroup h5`).after(`<label class="noColors">${textLanguage.noColors}${` </label>`}`);
3274 JQuery('#noColors').appendTo(JQuery('.noColors'));
3275 JQuery(`.extrasGroup h5`).after(`<label class="skipStats">` + textLanguage.skipStats + ` </label>`);
3276 JQuery(`#skipStats`).appendTo(JQuery(`.skipStats`));
3277 JQuery(`.skipStats`).after(`<label class="showQuest">` + textLanguage.showQuest + ` </label>`);
3278 JQuery('#showQuest').appendTo(JQuery(`.showQuest`));
3279 JQuery(`#options`).remove();
3280 JQuery(`#settingsChoice`).appendTo(JQuery(`.extrasGroup`)).addClass(`select-wrapper`);
3281 }
3282 this.addSliderBox(`.animationGroup`, `animation`, 100, 200, 1);
3283 this.addSliderBox(`.zoomGroup`, `zoomSpeedValue`, 0.75, 0.99, 0.01);
3284 JQuery(`#og-settings`).append(`<button class="btn btn-block btn-success btn-export">` + textLanguage.exportImport + `</button>`);
3285 JQuery(`#og-settings`).append(`<div class="restore-settings"><a href="#">` + textLanguage.restoreSettings + `</a></div>`);
3286 JQuery(`#music`).append(`${`<div class="agario-panel radio-panel"><h5 class="menu-main-color">Radio (` + textLanguage.thanks + `)</h5><audio src="http://frshoutcast.comunicazion.eu:8815/;" controls></audio><span class="playlist"><span class="ogicon-file-music"></span> <a href="http://frshoutcast.comunicazion.eu:8815/played.html?sid=1" target="_blank">` + textLanguage.playlist}</a></span></div>`);
3287 JQuery(`#music`).append(`<div class="agario-panel sounds-panel"><h5 class="menu-main-color">` + textLanguage.sounds + `</h5></div>`);
3288 JQuery(`#music`).append(`<div class="agario-panel ogario-yt-panel"><h5 class="menu-main-color">Team OGARio (tag: Ⓜ)</h5><div class="g-ytsubscribe" data-channelid="UCaWiPNJWnhzYDrBQoXokn6w" data-layout="full" data-theme="dark" data-count="default"></div></div>`);
3289 this.addInputBox(`.sounds-panel`, `messageSound`, 'Sound URL', 'setMessageSound');
3290 this.addInputBox('.sounds-panel', 'commandSound', `Sound URL`, `setCommandSound`);
3291 JQuery('body').append(`<div id="overlays-hud" data-gamemode=":ffa"><div id="stats-hud" class="hud stats-hud-color"></div> <div id="top5-hud" class="hud"><h5 class="hud-main-color">Team top <span class="team-top">5</span></h5><div class="hud-main-color team-top-menu"><a href="#" data-limit="5" class="team-top-limit active">5</a> | <a href="#" data-limit="10" class="team-top-limit">10</a> | <a href="#" data-limit="100" class="team-top-limit">100</a></div><ol id="top5-pos"></ol><div id="top5-total"><span class="hud-main-color ogicon-users"></span> ` + textLanguage.totalPartyPlayers + `: <span id="top5-total-players" class="top5-mass-color">0</span><br><span class="hud-main-color ogicon-pacman"></span> ` + textLanguage.totalPartyMass + `: <span id="top5-total-mass" class="top5-mass-color">0</span></div></div> <div id="time-hud" class="hud time-hud-color"></div> <div id="pause-hud" class="hud">` + textLanguage.pause + `</div> <div id="leaderboard-hud" class="hud-b"><h4 class="hud-main-color">ogario.ovh</h4><div id="leaderboard-data"></div><div id="leaderboard-positions"></div></div> <div id="btl-leaderboard-hud"><div class="hud hud-c"><span id="btl-players-status">Players ready</span>: <span id="btl-players-count">0</span></div></div> <div id="minimap-hud" class="hud-b"><canvas id="minimap-sectors"></canvas><canvas id="minimap"></canvas></div><div id="target-hud" class="hud"><div id="target-player"><span id="target-skin"><img src="https://cdn.ogario.ovh/static/img/blank.png" alt=""> </span><span id="target-nick"></span> <span id="target-status" class="hud-main-color">[` + textLanguage.targetNotSet + `]</span></div><div id="target-summary"></div></div><div id="target-panel-hud" class="hud"><a href="#" id="set-targeting" class="ogicon-target"></a><a href="#" id="set-private-minimap" class="ogicon-location2"></a><a href="#" id="cancel-targeting" class="ogicon-cancel-circle"></a><a href="#" id="change-target" class="ogicon-arrow-right"></a></div> <div id="quest-hud" class="hud"></div> <div id="btl-hud" class="hud"></div></div>`);
3292 JQuery(`body`).append(`<ul id="messages"></ul>`);
3293 JQuery(`body`).append(`<div id="message-box"><div id="chat-emoticons"></div><div id="message-menu"><a href="#" class="chat-sound-notifications ogicon-volume-high"></a><a href="#" class="chat-active-users ogicon-user-check"></a><a href="#" class="chat-muted-users ogicon-user-minus"></a><a href="#" class="show-chat-emoticons ogicon-smile"></a></div><input type="text" id="message" class="form-control" placeholder="${textLanguage.enterChatMsg}${`..." maxlength="80"></div>`}`);
3294 JQuery(`body`).append('<div id="chat-box"></div>');
3295 for (const emoji in emojiChar) {
3296 if (emojiChar.hasOwnProperty(emoji)) {
3297 JQuery('#chat-emoticons').append(`<img src="https://cdn.ogario.ovh/static/emoticons/${emojiChar[emoji]}${`" alt="`}${emoji}${`" class="emoticon">`}`);
3298 }
3299 }
3300 JQuery('body').append(`<div id="exp-imp"><div id="exp-imp-menu"><button id="close-exp-imp" class="btn btn-danger">` + textLanguage.close + `</button></div><div id="exp-imp-settings"></div></div>`);
3301 JQuery(`#exp-imp-settings`).append(`<h1>` + textLanguage.exportSettings + `</h1><h2>` + textLanguage.exportInfo + `</h2>`);
3302 this.addOption(`#exp-imp-settings`, `export-ogarioCommands`, textLanguage.commands, true);
3303 this.addOption(`#exp-imp-settings`, `export-ogarioHotkeys`, textLanguage.hotkeys, true);
3304 this.addOption(`#exp-imp-settings`, 'export-ogarioPlayerProfiles', textLanguage.profiles, true);
3305 this.addOption('#exp-imp-settings', `export-ogarioSettings`, textLanguage.settings, true);
3306 this.addOption(`#exp-imp-settings`, `export-ogarioThemeSettings`, textLanguage.theme, true);
3307 JQuery('#exp-imp-settings').append(`<textarea id="export-settings" class="form-control" rows="14" cols="100" spellcheck="false" readonly /><button id="export-settings-btn" class="btn btn-block btn-success">${textLanguage.exportSettings}${`</button>`}`);
3308 JQuery(`#exp-imp-settings`).append(`${`<h1>` + textLanguage.importSettings}</h1><h2>${textLanguage.importInfo}${`</h2>`}`);
3309 this.addOption(`#exp-imp-settings`, `import-ogarioCommands`, textLanguage.commands, true);
3310 this.addOption(`#exp-imp-settings`, 'import-ogarioHotkeys', textLanguage.hotkeys, true);
3311 this.addOption(`#exp-imp-settings`, `import-ogarioPlayerProfiles`, textLanguage.profiles, true);
3312 this.addOption(`#exp-imp-settings`, `import-ogarioSettings`, textLanguage.settings, true);
3313 this.addOption(`#exp-imp-settings`, `import-ogarioThemeSettings`, textLanguage.theme, true);
3314 JQuery('#exp-imp-settings').append(`<textarea id="import-settings" class="form-control" rows="14" cols="100" spellcheck="false" /><button id="import-settings-btn" class="btn btn-block btn-success">` + textLanguage.importSettings + `</button>`);
3315 OgarioSettings && OgarioSettings.setThemeMenu();
3316 for (let length = 0; length < PlayerProfiles.length; length++) {
3317 JQuery(`#skins`).append(`${`<div class="skin-box"><a href="#profile-` + length}" id="profile-${length}" data-profile="${length}" class="skin-switch"></a></div>`);
3318 this.setSkinPreview(PlayerProfiles[length].skinURL, `profile-` + length);
3319 if (length == this.selectedProfile) {
3320 JQuery(`#profile-` + length).addClass(`selected`);
3321 }
3322 }
3323 },
3324 setUI() {
3325 const app = this;
3326 JQuery(document).on('click', `.menu-tabs a`, function(event) {
3327 event.preventDefault();
3328 app.switchMenuTabs(JQuery(this), `menu-panel`);
3329 });
3330 JQuery(document).on('click', `.submenu-tabs a`, function(event) {
3331 event.preventDefault();
3332 app.switchMenuTabs(JQuery(this), `submenu-panel`);
3333 });
3334 JQuery(document).on(`click`, `.quick-menu`, event => {
3335 event.preventDefault();
3336 gameOptionSettings.showQuickMenu = !gameOptionSettings.showQuickMenu;
3337 app.saveSettings(gameOptionSettings, `ogarioSettings`);
3338 app.setShowQuickMenu();
3339 });
3340 JQuery(document).on(`click`, `.quick-skins`, event => {
3341 event.preventDefault();
3342 gameOptionSettings.showSkinsPanel = !gameOptionSettings.showSkinsPanel;
3343 app.saveSettings(gameOptionSettings, `ogarioSettings`);
3344 app.setShowSkinsPanel();
3345 });
3346 JQuery(document).on(`change`, `#region`, function() {
3347 app.region = this.value;
3348 });
3349 JQuery(document).on(`change`, '#gamemode', function() {
3350 const value = this.value;
3351 if (value !== ':party') {
3352 app.leaveParty();
3353 }
3354 app.gameMode = ogario.gameMode = value;
3355 app.setQuest();
3356 });
3357 JQuery(document).on(`change`, `#quality`, function() {
3358 app.getQuality(this.value);
3359 menuScale();
3360 });
3361 JQuery(`#skin`).popover({
3362 html: true,
3363 placement: `bottom`,
3364 trigger: 'manual',
3365 animation: false
3366 });
3367 JQuery(document).on(`input click`, `#skin`, function() {
3368 const value = this.value;
3369 app.setSkinPreview(value, `skin-preview`);
3370 app.setSkinPreview(value, `profile-` + app.selectedProfile);
3371 });
3372 JQuery(document).on(`click`, '.skin .example-url a', function(event) {
3373 event.preventDefault();
3374 JQuery(`#skin`).val(this.href).click();
3375 });
3376 JQuery(document).on(`click`, `#overlays`, () => {
3377 if (!JQuery(`.skin:hover`).length && !JQuery('.skin-switch:hover').length) {
3378 JQuery(`#skin`).popover(`hide`);
3379 }
3380 });
3381 JQuery(document).on(`click`, `#skins a`, function(event) {
3382 event.preventDefault();
3383 app.selectProfile(JQuery(this).attr(`data-profile`));
3384 });
3385 JQuery(document).on(`click`, '#prev-profile', () => {
3386 app.prevProfile();
3387 });
3388 JQuery(document).on(`click`, `#next-profile`, () => {
3389 app.nextProfile();
3390 });
3391 JQuery(document).on(`click`, `#stream-mode`, () => {
3392 gameOptionSettings.streamMode = !gameOptionSettings.streamMode;
3393 app.saveSettings(gameOptionSettings, `ogarioSettings`);
3394 app.setStreamMode();
3395 });
3396 JQuery(document).on('click', `#hide-url`, () => {
3397 gameOptionSettings.hideSkinUrl = !gameOptionSettings.hideSkinUrl;
3398 app.saveSettings(gameOptionSettings, `ogarioSettings`);
3399 app.setHideSkinUrl();
3400 });
3401 JQuery(document).on(`click`, `.btn-server-info`, () => {
3402 JQuery(`#server-info`).toggle();
3403 });
3404 JQuery(document).on(`click`, `#server-connect`, () => {
3405 app.gameServerConnect(JQuery('#server-ws').val());
3406 });
3407 JQuery(document).on(`click`, `#server-reconnect`, () => {
3408 app.gameServerReconnect();
3409 });
3410 JQuery(document).on(`click`, `#server-join`, () => {
3411 app.gameServerJoin(JQuery(`#server-token`).val());
3412 });
3413 JQuery(document).on(`change`, `#og-options input[type='checkbox']`, function() {
3414 const option = JQuery(this);
3415 app.setSettings(option.attr('id'), option.prop(`checked`));
3416 });
3417 JQuery(document).on(`change`, '.js-switch-vanilla', function() {
3418 const option = JQuery(this);
3419 const id = option.attr('id');
3420 if (typeof app[id] !== `undefined`) {
3421 app[id] = option.prop('checked');
3422 if (id === `noSkins`) {
3423 ogario.showCustomSkins = !app.noSkins;
3424 }
3425 if (id === `showQuest`) {
3426 app.setQuest();
3427 }
3428 }
3429 });
3430 JQuery(document).on(`click`, `#og-settings .restore-settings a`, event => {
3431 event.preventDefault();
3432 app.restoreSettings();
3433 });
3434 JQuery(document).on(`click`, '#og-settings .btn-export', event => {
3435 event.preventDefault();
3436 app.exportSettings();
3437 JQuery(`#exp-imp`).fadeIn(500);
3438 JQuery('#exp-imp-settings, #export-settings').perfectScrollbar(`update`);
3439 });
3440 JQuery(document).on('click', '#close-exp-imp', event => {
3441 event.preventDefault();
3442 JQuery(`#exp-imp`).fadeOut(500);
3443 });
3444 JQuery(document).on(`focus`, `#export-settings`, function() {
3445 JQuery(this).select();
3446 });
3447 JQuery(document).on(`click`, `#export-settings-btn`, event => {
3448 event.preventDefault();
3449 app.exportSettings();
3450 });
3451 JQuery(document).on(`click`, `#import-settings-btn`, event => {
3452 event.preventDefault();
3453 app.importSettings();
3454 });
3455 JQuery(document).on(`click`, `#unblock-popups`, event => {
3456 event.preventDefault();
3457 app.unblockPopups();
3458 });
3459 JQuery(document).on(`click`, `#openfl-overlay.disabler`, () => {
3460 if (gameOptionSettings.blockPopups) {
3461 app.blockPopups();
3462 }
3463 });
3464 JQuery(document).on(`click`, `#openfl-content`, function() {
3465 if (gameOptionSettings.blockPopups) {
3466 const content = JQuery(this);
3467 setTimeout(() => {
3468 if (!content.is(`:visible`)) {
3469 app.blockPopups();
3470 }
3471 }, 1000);
3472 }
3473 });
3474 JQuery(document).on(`click`, `.quick-shop`, event => {
3475 event.preventDefault();
3476 app.unblockPopups();
3477 window.MC && window.MC.openShop && window.MC.openShop();
3478 });
3479 JQuery(document).on(`click`, `.quick-free-coins`, event => {
3480 event.preventDefault();
3481 app.unblockPopups();
3482 window.MC && window.MC.showFreeCoins && window.MC.showFreeCoins();
3483 });
3484 JQuery(document).on(`click`, '.quick-free-gifts', event => {
3485 event.preventDefault();
3486 app.unblockPopups();
3487 window.MC && window.MC.showGifting && window.MC.showGifting();
3488 });
3489 JQuery(document).on(`click`, `.quick-quests`, event => {
3490 event.preventDefault();
3491 app.unblockPopups();
3492 window.MC && window.MC.showQuests && window.MC.showQuests();
3493 });
3494 JQuery(document).on(`click`, `#set-targeting`, event => {
3495 event.preventDefault();
3496 app.setTargeting();
3497 });
3498 JQuery(document).on('click', `#cancel-targeting`, event => {
3499 event.preventDefault();
3500 app.cancelTargeting();
3501 });
3502 JQuery(document).on(`click`, `#set-private-minimap`, event => {
3503 event.preventDefault();
3504 app.setPrivateMiniMap();
3505 });
3506 JQuery(document).on(`click`, `#change-target`, event => {
3507 event.preventDefault();
3508 app.changeTarget();
3509 });
3510 JQuery(document).on('click', `.team-top-limit`, function(event) {
3511 event.preventDefault();
3512 const top5 = JQuery(this);
3513 const limit = parseInt(top5.attr('data-limit'));
3514 if (limit) {
3515 app.setTop5limit(limit);
3516 app.displayTop5();
3517 JQuery(`.team-top`).text(limit);
3518 JQuery(`.team-top-limit`).removeClass(`active`);
3519 top5.addClass(`active`);
3520 }
3521 });
3522 JQuery(document).on(`click`, `#top5-pos .set-target`, function(event) {
3523 event.preventDefault();
3524 app.setTarget(parseInt(JQuery(this).attr('data-user-id')));
3525 });
3526 JQuery(document).on(`click`, `.mute-user`, function(event) {
3527 event.preventDefault();
3528 app.muteChatUser(parseInt(JQuery(this).attr(`data-user-id`)));
3529 });
3530 JQuery(document).on(`click`, '.btn-mute-user', function() {
3531 const btn = JQuery(this);
3532 app.muteChatUser(parseInt(btn.attr(`data-user-id`)));
3533 btn.removeClass(`btn-red btn-mute-user`).addClass(`btn-green btn-unmute-user`).text(textLanguage.unmute);
3534 });
3535 JQuery(document).on(`click`, '.btn-unmute-user', function() {
3536 const btn = JQuery(this);
3537 app.unmuteChatUser(parseInt(btn.attr(`data-user-id`)));
3538 btn.removeClass('btn-green btn-unmute-user').addClass(`btn-red btn-mute-user`).text(textLanguage.mute);
3539 });
3540 JQuery(document).on(`click`, '.chat-sound-notifications', event => {
3541 event.preventDefault();
3542 gameOptionSettings.chatSounds = !gameOptionSettings.chatSounds;
3543 app.saveSettings(gameOptionSettings, 'ogarioSettings');
3544 app.setChatSoundsBtn();
3545 });
3546 JQuery(document).on(`click`, '.chat-active-users', event => {
3547 event.preventDefault();
3548 app.displayChatActiveUsers();
3549 });
3550 JQuery(document).on('click', `.chat-muted-users`, event => {
3551 event.preventDefault();
3552 app.displayChatMutedUsers();
3553 });
3554 JQuery(document).on(`click`, `.show-chat-emoticons`, function(event) {
3555 event.preventDefault();
3556 const option = JQuery(this);
3557 const chatEmoji = JQuery(`#chat-emoticons`);
3558 chatEmoji.toggle();
3559 if (chatEmoji.is(`:visible`)) {
3560 option.addClass(`active`);
3561 } else {
3562 option.removeClass('active');
3563 JQuery(`#message`).focus();
3564 }
3565 });
3566 JQuery(document).on(`click`, '#chat-emoticons .emoticon', function() {
3567 const chatEmoji = JQuery(this);
3568 const alt = chatEmoji.attr(`alt`);
3569 const message = JQuery(`#message`);
3570 const value = message.val();
3571 if (value.length + alt.length <= 80) {
3572 message.val(value + alt);
3573 }
3574 message.focus();
3575 });
3576 this.statsHUD = document.getElementById(`stats-hud`);
3577 this.activeParties = document.getElementById('active-parties');
3578 this.top5pos = document.getElementById('top5-pos');
3579 this.top5totalMass = document.getElementById(`top5-total-mass`);
3580 this.top5totalPlayers = document.getElementById(`top5-total-players`);
3581 this.leaderboardPositionsHUD = document.getElementById(`leaderboard-positions`);
3582 this.leaderboardDataHUD = document.getElementById(`leaderboard-data`);
3583 this.timeHUD = document.getElementById('time-hud');
3584 this.questHUD = document.getElementById(`quest-hud`);
3585 JQuery(`#canvas`).bind(`contextmenu`, () => false);
3586 JQuery(document).on('mouseup', `.btn`, function() {
3587 $(this).blur();
3588 });
3589 JQuery(`[data-toggle='tab-tooltip']`).tooltip({
3590 trigger: `hover`
3591 });
3592 JQuery('.submenu-panel, #chat-box, #exp-imp-settings, #export-settings, #import-settings').perfectScrollbar({
3593 suppressScrollX: true
3594 });
3595 const sliceSwitch = Array.prototype.slice.call(document.querySelectorAll(`.js-switch`));
3596 sliceSwitch.forEach(event => {
3597 const switchOption = new Switchery(event, {
3598 color: gameSetupTheme.menuMainColor,
3599 size: 'small'
3600 });
3601 });
3602 JQuery('input[type="range"]').rangeslider({
3603 polyfill: false
3604 });
3605 toastr.options = {
3606 newestOnTop: false,
3607 positionClass: `toast-bottom-left`,
3608 timeOut: 15000
3609 };
3610 },
3611 switchMenuTabs(tab, name) {
3612 const parent = tab.parent();
3613 if (name === 'menu-panel') {
3614 if (tab.hasClass(`hotkeys-link`)) {
3615 return;
3616 }
3617 if (parent.hasClass(`profile-tab`)) {
3618 this.setBlockPopups();
3619 }
3620 }
3621 tab.addClass(`active`);
3622 parent.addClass(`active`);
3623 parent.siblings().removeClass(`active`);
3624 parent.siblings().find('a').removeClass(`active`);
3625 const href = tab.attr(`href`);
3626 if (name === 'submenu-panel') {
3627 const id = JQuery(href).parent().attr('id');
3628 JQuery(`#${id}${` .submenu-panel`}`).not(href).css(`display`, `none`);
3629 } else {
3630 JQuery(`.menu-panel`).not(href).css(`display`, 'none');
3631 }
3632 JQuery(href).fadeIn(1000);
3633 menuScale();
3634 JQuery(`.submenu-panel`).perfectScrollbar(`update`);
3635 },
3636 getDefaultSettings() {
3637 const app = this;
3638 this.noSkins = JQuery(`#noSkins`).prop(`checked`);
3639 this.noColors = JQuery(`#noColors`).prop(`checked`);
3640 this.skipStats = JQuery(`#skipStats`).prop(`checked`);
3641 this.showQuest = JQuery(`#showQuest`).prop(`checked`);
3642 ogario.showCustomSkins = !this.noSkins;
3643 if (window.localStorage.getItem(`scale_setting`) !== null) {
3644 const parseScaleSettings = JSON.parse(window.localStorage.getItem(`scale_setting`));
3645 this.setCanvasScale(parseScaleSettings);
3646 } else {
3647 const quality = JQuery('#quality').val();
3648 this.getQuality(quality);
3649 }
3650 if (window.localStorage.getItem('location') !== null) {
3651 this.region = window.localStorage.getItem(`location`);
3652 JQuery(`#region`).val(this.region);
3653 window.MC && window.MC.setRegion && window.MC.setRegion(this.region);
3654 } else {
3655 this.region = JQuery(`#region`).val();
3656 }
3657 this.setParty();
3658 if (this.gameMode === `:party` && window.location.hash) {
3659 JQuery(`#join-party-btn-2`).click();
3660 }
3661 const sliceSwitchVanilla = Array.prototype.slice.call(document.querySelectorAll(`.js-switch-vanilla`));
3662 sliceSwitchVanilla.forEach(event => {
3663 const SwitchVanillaOption = new Switchery(event, {
3664 color: gameSetupTheme.menuMainColor,
3665 size: 'small'
3666 });
3667 });
3668 JQuery(`#nick`).val(mainProfile.nick).blur();
3669 JQuery('#noNames').prop(`checked`, !gameOptionSettings.noNames);
3670 JQuery(`#showMass`).prop('checked', gameOptionSettings.showMass);
3671 this.unlockButtons();
3672 this.setAutoResp();
3673 this.setQuest();
3674 },
3675 getQuality(value) {
3676 const ration = `devicePixelRatio` in window;
3677 let defaultValue = 1;
3678 if (ration) {
3679 defaultValue = window.devicePixelRatio;
3680 }
3681 switch (value) {
3682 case `High`:
3683 this.setCanvasScale(1);
3684 break;
3685 case `Medium`:
3686 this.setCanvasScale(0.9);
3687 break;
3688 case `Low`:
3689 this.setCanvasScale(0.75);
3690 break;
3691 case `VeryLow`:
3692 this.setCanvasScale(0.5);
3693 break;
3694 default:
3695 this.setCanvasScale(defaultValue);
3696 break;
3697 }
3698 },
3699 setCanvasScale(value) {
3700 this.canvasScale = value;
3701 ogario.canvasScale = value;
3702 },
3703 setStreamMode() {
3704 if (gameOptionSettings.streamMode) {
3705 JQuery(`#stream-mode`).addClass(`ogicon-eye-blocked`);
3706 JQuery('#clantag, #nick, #party-token').addClass('stream-mode');
3707 } else {
3708 JQuery('#stream-mode').removeClass(`ogicon-eye-blocked`);
3709 JQuery(`#clantag, #nick, #party-token`).removeClass(`stream-mode`);
3710 }
3711 },
3712 setHideSkinUrl() {
3713 if (gameOptionSettings.hideSkinUrl) {
3714 JQuery('#hide-url').addClass(`ogicon-eye-blocked`);
3715 JQuery('#skin').addClass(`hide-url`);
3716 } else {
3717 JQuery(`#hide-url`).removeClass(`ogicon-eye-blocked`);
3718 JQuery(`#skin`).removeClass(`hide-url`);
3719 }
3720 },
3721 setShowQuickMenu() {
3722 if (gameOptionSettings.showQuickMenu) {
3723 JQuery(`#quick-menu`).fadeIn(500);
3724 } else {
3725 JQuery('#quick-menu').fadeOut(500);
3726 }
3727 },
3728 setShowSkinsPanel() {
3729 if (gameOptionSettings.showSkinsPanel) {
3730 JQuery(`#skins-panel`).fadeIn(500);
3731 } else {
3732 JQuery(`#skins-panel`).fadeOut(500);
3733 }
3734 },
3735 unlockButtons() {
3736 JQuery(`.btn-play, .btn-play-guest, .btn-login-play, .btn-spectate`).prop(`disabled`, false);
3737 },
3738 setMainButtons() {
3739 const app = this;
3740 JQuery(document).on(`click`, `.btn-play, .btn-play-guest`, () => {
3741 app.onPlay();
3742 });
3743 JQuery(document).on('click', `.btn-spectate`, () => {
3744 app.onSpectate();
3745 });
3746 JQuery(document).on(`click`, `#create-party-btn-2`, () => {
3747 app.onCreate();
3748 });
3749 JQuery(document).on(`click`, `#join-party-btn-2`, () => {
3750 app.skipServerData = true;
3751 app.joinParty();
3752 app.onJoin();
3753 });
3754 JQuery(document).on('click', `#statsContinue2`, () => {
3755 JQuery(`#stats, #main-panel`).toggle();
3756 });
3757 },
3758 play() {
3759 this.setPlayerSettings();
3760 this.setParty();
3761 if (this.isSocketOpen()) {
3762 this.sendPartyData();
3763 } else {
3764 this.connect();
3765 const app = this;
3766 setTimeout(() => {
3767 app.sendPartyData();
3768 }, 1000);
3769 }
3770 },
3771 onPlay() {
3772 this.play();
3773 this.hideMenu();
3774 window.addKeyListeners && window.addKeyListeners();
3775 if (gameOptionSettings.autoHideFood) {
3776 ogario.showFood = true;
3777 }
3778 window.ga && window.ga(`create`, `UA-67142685-2`, `auto`, `ogarioTracker`);
3779 window.ga && window.ga(`ogarioTracker.send`, `pageview`);
3780 },
3781 onSpectate() {
3782 this.onJoin();
3783 this.sendPlayerJoin();
3784 this.hideMenu();
3785 window.addKeyListeners && window.addKeyListeners();
3786 if (gameOptionSettings.autoHideFood) {
3787 ogario.showFood = false;
3788 }
3789 },
3790 join() {
3791 this.setParty();
3792 this.setPlayerSettings();
3793 this.sendPartyData();
3794 this.sendPlayerDeath();
3795 },
3796 onJoin() {
3797 this.setParty();
3798 if (this.isSocketOpen()) {
3799 this.join();
3800 } else {
3801 this.connect();
3802 const app = this;
3803 setTimeout(() => {
3804 app.join();
3805 app.sendPlayerJoin();
3806 }, 1000);
3807 }
3808 },
3809 create() {
3810 this.setParty();
3811 if (this.partyToken) {
3812 this.onJoin();
3813 return;
3814 }
3815 const app = this;
3816 setTimeout(() => {
3817 app.create();
3818 }, 100);
3819 },
3820 onCreate() {
3821 this.setParty();
3822 if (this.gameMode !== ':party' || !this.partyToken) {
3823 this.createParty();
3824 } else {
3825 this.gameServerReconnect();
3826 }
3827 this.create();
3828 },
3829 onPlayerSpawn() {
3830 ogario.play = true;
3831 if (ogario.playerColor) {
3832 this.sendPlayerSpawn();
3833 this.cacheCustomSkin(mainProfile.nick, ogario.playerColor, mainProfile.skinURL);
3834 return;
3835 }
3836 const app = this;
3837 setTimeout(() => {
3838 app.onPlayerSpawn();
3839 }, 100);
3840 },
3841 onPlayerDeath() {
3842 ogario.play = false;
3843 ogario.playerColor = null;
3844 ogario.foodIsHidden = false;
3845 ogario.playerMass = 0;
3846 ogario.playerScore = 0;
3847 ogario.playerSplitCells = 0;
3848 this.showMenu(300);
3849 this.sendPlayerDeath();
3850 this.updateDeathLocations(ogario.playerX, ogario.playerY);
3851 this.unlockButtons();
3852 resetonkeydown();
3853 this.autoResp();
3854 },
3855 setPlayerSettings() {
3856 const nick = JQuery(`#nick`).val();
3857 const tag = JQuery(`#clantag`).val();
3858 const skin = JQuery(`#skin`).val();
3859 const color = JQuery(`#color`).val();
3860 mainProfile.nick = nick;
3861 mainProfile.clanTag = tag.trim();
3862 mainProfile.skinURL = this.checkSkinURL(skin.trim());
3863 if (color.length == 7) {
3864 mainProfile.color = color;
3865 }
3866 if (mainProfile.clanTag.length > 0) {
3867 ogario.clanTag = mainProfile.clanTag;
3868 }
3869 PlayerProfiles[this.selectedProfile].nick = mainProfile.nick;
3870 PlayerProfiles[this.selectedProfile].clanTag = mainProfile.clanTag;
3871 PlayerProfiles[this.selectedProfile].skinURL = mainProfile.skinURL;
3872 PlayerProfiles[this.selectedProfile].color = mainProfile.color;
3873 this.saveSettings(PlayerProfiles, `ogarioPlayerProfiles`);
3874 },
3875 loadSkin(img, url) {
3876 const app = this;
3877 img[url] = new Image();
3878 img[url].crossOrigin = `Anonymous`;
3879 img[url].onload = function() {
3880 if (this.complete && this.width && this.height && this.width <= 2000 && this.height <= 2000) {
3881 app.cacheQueue.push(url);
3882 if (app.cacheQueue.length == 1) {
3883 app.cacheSkin(app.customSkinsCache);
3884 }
3885 }
3886 };
3887 img[url].src = url;
3888 },
3889 cacheSkin(skinCache) {
3890 if (this.cacheQueue.length == 0) {
3891 return;
3892 }
3893 const shift = this.cacheQueue.shift();
3894 if (shift) {
3895 let canvas = document.createElement(`canvas`);
3896 canvas.width = 512;
3897 canvas.height = 512;
3898 const ctx = canvas.getContext('2d');
3899 ctx.beginPath();
3900 ctx.arc(256, 256, 256, 0, 2 * Math.PI, false);
3901 ctx.clip();
3902 ctx.drawImage(this.customSkinsCache[shift], 0, 0, 512, 512);
3903 this.customSkinsCache[shift + `_cached`] = new Image();
3904 this.customSkinsCache[shift + `_cached`].src = canvas.toDataURL();
3905 canvas = null;
3906 this.cacheSkin(this.customSkinsCache);
3907 }
3908 },
3909 getCachedSkin(skinCache, skinMap) {
3910 if (skinCache[skinMap + `_cached`] && skinCache[skinMap + `_cached`].complete && skinCache[skinMap + `_cached`].width) {
3911 return skinCache[`${skinMap}_cached`];
3912 }
3913 return null;
3914 },
3915 cacheCustomSkin(nick, color, skinUrl) {
3916 if (skinUrl) {
3917 const gamemode = this.gameMode === `:party` ? nick + color : nick;
3918 if (gamemode) {
3919 this.customSkinsMap[gamemode] = skinUrl;
3920 }
3921 if (this.customSkinsCache.hasOwnProperty(skinUrl)) {
3922 return;
3923 }
3924 this.loadSkin(this.customSkinsCache, skinUrl);
3925 }
3926 },
3927 checkSkinsMap(nick, color) {
3928 const skinName = this.gameMode === `:party` ? nick + color : nick;
3929 if (this.customSkinsMap.hasOwnProperty(skinName)) {
3930 return true;
3931 }
3932 return false;
3933 },
3934 getCustomSkin(nick, color) {
3935 if (!this.checkSkinsMap(nick, color)) {
3936 return null;
3937 }
3938 const skinName = this.gameMode === ':party' ? nick + color : nick;
3939 return this.getCachedSkin(this.customSkinsCache, this.customSkinsMap[skinName]);
3940 },
3941 calculateMapSector(x, y, resize = false) {
3942 if (!ogario.mapOffsetFixed) {
3943 return '';
3944 }
3945 const offsetX = resize ? ogario.mapOffsetX + ogario.mapOffset : ogario.mapOffset;
3946 const offsetY = resize ? ogario.mapOffsetY + ogario.mapOffset : ogario.mapOffset;
3947 let resizeX = Math.floor((y + offsetY) / (ogario.mapSize / gameSetupTheme.sectorsY));
3948 let resizeY = Math.floor((x + offsetX) / (ogario.mapSize / gameSetupTheme.sectorsX));
3949 resizeX = resizeX < 0 ? 0 : resizeX >= gameSetupTheme.sectorsY ? gameSetupTheme.sectorsY - 1 : resizeX;
3950 resizeY = resizeY < 0 ? 0 : resizeY >= gameSetupTheme.sectorsX ? gameSetupTheme.sectorsX - 1 : resizeY;
3951 return String.fromCharCode(resizeX + 65) + (resizeY + 1);
3952 },
3953 shortMassFormat(value) {
3954 return value < 1000 ? value : `${Math.round(value / 100) / 10}k`;
3955 },
3956 updateDeathLocations(x, y) {
3957 if (!ogario.mapOffsetFixed) {
3958 return;
3959 }
3960 this.deathLocations.push({
3961 x: x + ogario.mapOffsetX,
3962 y: y + ogario.mapOffsetY
3963 });
3964 if (this.deathLocations.length == 6) {
3965 this.deathLocations.shift();
3966 }
3967 this.lastDeath = this.deathLocations.length - 1;
3968 },
3969 drawMiniMap() {
3970 if (!ogario.mapOffsetFixed) {
3971 return;
3972 }
3973 const mapWidth = gameSetupTheme.miniMapWidth;
3974 const mapTop = gameSetupTheme.miniMapTop;
3975 const height = mapWidth + mapTop;
3976 const width = mapWidth - 18;
3977 const scale = mapTop + 9.5;
3978 if (!this.miniMap) {
3979 this.miniMap = document.getElementById(`minimap`);
3980 this.miniMapCtx = this.miniMap.getContext('2d');
3981 this.miniMapCtx.ogarioCtx = true;
3982 this.miniMap.width = mapWidth;
3983 this.miniMap.height = height;
3984 } else {
3985 this.miniMapCtx.clearRect(0, 0, mapWidth, height);
3986 }
3987 if (this.miniMap.width != mapWidth) {
3988 this.miniMap.width = mapWidth;
3989 this.miniMap.height = height;
3990 }
3991 const newSize = width / ogario.mapSize;
3992 const resizeoffX = ogario.mapOffsetX + ogario.mapOffset;
3993 const resizeoffY = ogario.mapOffsetY + ogario.mapOffset;
3994 this.drawSelectedCell(this.miniMapCtx);
3995 this.currentSector = this.calculateMapSector(ogario.playerX, ogario.playerY, true);
3996 this.miniMapCtx.globalAlpha = 1;
3997 this.miniMapCtx.font = `${gameSetupTheme.miniMapFontWeight} ${mapTop - 4}px ${gameSetupTheme.miniMapFontFamily}`;
3998 this.miniMapCtx.fillStyle = gameSetupTheme.miniMapSectorColor;
3999 this.miniMapCtx.fillText(this.currentSector, 10, mapTop);
4000 if (!this.miniMapSectors) {
4001 this.drawMiniMapSectors(gameSetupTheme.sectorsX, gameSetupTheme.sectorsY, width, height, scale);
4002 }
4003 this.miniMapCtx.save();
4004 this.miniMapCtx.translate(9.5, scale);
4005 if (this.gameMode === `:battleroyale`) {
4006 drawRender && drawRender.drawBattleAreaOnMinimap(this.miniMapCtx, width, width, newSize, resizeoffX, resizeoffY);
4007 }
4008 if (gameOptionSettings.showMiniMapGuides) {
4009 var roundX = Math.round((ogario.playerX + resizeoffX) * newSize);
4010 var roundY = Math.round((ogario.playerY + resizeoffY) * newSize);
4011 this.miniMapCtx.lineWidth = 1;
4012 this.miniMapCtx.strokeStyle = gameSetupTheme.miniMapGuidesColor;
4013 this.miniMapCtx.beginPath();
4014 this.miniMapCtx.moveTo(roundX, 0);
4015 this.miniMapCtx.lineTo(roundX, width - 1);
4016 this.miniMapCtx.moveTo(0, roundY);
4017 this.miniMapCtx.lineTo(width - 1, roundY);
4018 this.miniMapCtx.stroke();
4019 }
4020 this.miniMapCtx.beginPath();
4021 this.miniMapCtx.arc((ogario.playerX + resizeoffX) * newSize, (ogario.playerY + resizeoffY) * newSize, gameSetupTheme.miniMapMyCellSize, 0, this.pi2, false);
4022 this.miniMapCtx.closePath();
4023 if (gameSetupTheme.miniMapMyCellStrokeSize > 0) {
4024 this.miniMapCtx.lineWidth = gameSetupTheme.miniMapMyCellStrokeSize;
4025 this.miniMapCtx.strokeStyle = gameSetupTheme.miniMapMyCellStrokeColor;
4026 this.miniMapCtx.stroke();
4027 }
4028 this.miniMapCtx.fillStyle = gameSetupTheme.miniMapMyCellColor;
4029 this.miniMapCtx.fill();
4030 if (this.teamPlayers.length) {
4031 for (let length = 0; length < this.teamPlayers.length; length++) {
4032 this.teamPlayers[length].drawPosition(this.miniMapCtx, ogario.mapOffset, newSize, this.privateMiniMap, this.targetID);
4033 }
4034 }
4035 if (this.deathLocations.length > 0) {
4036 var roundX = Math.round((this.deathLocations[this.lastDeath].x + ogario.mapOffset) * newSize);
4037 var roundY = Math.round((this.deathLocations[this.lastDeath].y + ogario.mapOffset) * newSize);
4038 const mySize = Math.max(gameSetupTheme.miniMapMyCellSize - 2, 4);
4039 this.miniMapCtx.lineWidth = 1;
4040 this.miniMapCtx.strokeStyle = this.deathLocations.length - 1 == this.lastDeath ? gameSetupTheme.miniMapDeathLocationColor : '#FFFFFF';
4041 this.miniMapCtx.beginPath();
4042 this.miniMapCtx.moveTo(roundX - mySize, roundY);
4043 this.miniMapCtx.lineTo(roundX + mySize, roundY);
4044 this.miniMapCtx.moveTo(roundX, roundY - mySize);
4045 this.miniMapCtx.lineTo(roundX, roundY + mySize);
4046 this.miniMapCtx.stroke();
4047 }
4048 this.miniMapCtx.restore();
4049 },
4050 drawMiniMapSectors(x, y, size, height, scale) {
4051 this.miniMapSectors = document.getElementById(`minimap-sectors`);
4052 const ctx = this.miniMapSectors.getContext('2d');
4053 ctx.ogarioCtx = true;
4054 this.miniMapSectors.width = size;
4055 this.miniMapSectors.height = height;
4056 ctx.fillStyle = `#FFFFFF`;
4057 this.dTok(ctx, size - 1);
4058 drawRender.drawSectors(ctx, ogario.mapOffsetFixed, x, y, 0.5, scale, size - 0.5, height - 9.5, gameSetupTheme.miniMapSectorsColor, gameSetupTheme.miniMapSectorsColor, 1, false);
4059 },
4060 resetMiniMapSectors() {
4061 this.miniMapSectors = null;
4062 },
4063 drawSelectedCell(ctx) {
4064 if (ogario.play && ogario.playerSplitCells > 1 && (gameOptionSettings.splitRange || gameOptionSettings.oppColors || gameOptionSettings.oppRings || gameOptionSettings.showStatsSTE)) {
4065 ctx.fillStyle = `#FFFFFF`;
4066 ctx.globalAlpha = this.selectBiggestCell ? 0.6 : 0.3;
4067 ctx.beginPath();
4068 ctx.arc(48, 15, 6, 0, this.pi2, false);
4069 ctx.closePath();
4070 ctx.fill();
4071 ctx.globalAlpha = this.selectBiggestCell ? 0.3 : 0.6;
4072 ctx.beginPath();
4073 ctx.arc(60, 15, 4, 0, this.pi2, false);
4074 ctx.closePath();
4075 ctx.fill();
4076 }
4077 },
4078 dTok(ctx, size) {
4079 ctx.font = `${gameSetupTheme.miniMapFontWeight} ${gameSetupTheme.miniMapTop - 6}${`px `}${gameSetupTheme.miniMapFontFamily}`;
4080 ctx.textAlign = `right`;
4081 ctx.textBaseline = `top`;
4082 ctx.fillText(atob(this.token), size, 7);
4083 },
4084 setVirusColor(size) {
4085 const floor = Math.floor(size * size / 100);
4086 if (floor > 183) {
4087 return `#C80000`;
4088 }
4089 return gameSetupTheme.virusColor;
4090 },
4091 setVirusStrokeColor(size) {
4092 if (ogario.play && ogario.playerMaxMass != 0) {
4093 const floor = Math.floor(size * size / 100);
4094 const biggestCell = floor / (this.selectBiggestCell ? ogario.playerMaxMass : ogario.playerMinMass);
4095 if (biggestCell > 0.76) {
4096 return `#FFDC00`;
4097 }
4098 return `#C80000`;
4099 }
4100 return gameSetupTheme.virusStrokeColor;
4101 },
4102 setAutoHideCellInfo(size) {
4103 if (size <= 40 || ogario.viewScale < 0.5 && size < 550 && size < 25 / ogario.viewScale) {
4104 return true;
4105 }
4106 return false;
4107 },
4108 setParty() {
4109 let value = JQuery('#party-token').val();
4110 this.gameMode = ogario.gameMode = JQuery(`#gamemode`).val();
4111 this.setQuest();
4112 if (this.gameMode !== ':party' || !value) {
4113 return;
4114 }
4115 let newValue = value;
4116 if (value.indexOf('#') != -1) {
4117 value = value.split('#');
4118 newValue = value[1];
4119 }
4120 if (this.partyToken !== newValue) {
4121 this.partyToken = newValue;
4122 this.flushSkinsMap();
4123 this.flushChatData();
4124 this.cancelTargeting();
4125 }
4126 },
4127 createParty() {
4128 JQuery('#create-party-btn').click();
4129 },
4130 joinParty() {
4131 const value = JQuery(`#party-token`).val();
4132 if (!value) {
4133 return;
4134 }
4135 JQuery(`#pre-join-party-btn`).click();
4136 JQuery(`.party-token`).val(value);
4137 JQuery('#join-party-btn').click();
4138 },
4139 leaveParty() {
4140 JQuery(`#party-token, .party-token`).val('');
4141 JQuery(`#leave-party-btn`).click();
4142 },
4143 closeParty() {
4144 JQuery(`#party-token, .party-token`).val('');
4145 JQuery('.party-icon-back').click();
4146 },
4147 flushData() {
4148 this.flushPartyData();
4149 this.flushSkinsMap();
4150 this.flushChatData();
4151 this.cancelTargeting();
4152 ogario.play = false;
4153 ogario.playerColor = null;
4154 },
4155 flushPartyData() {
4156 this.teamPlayers = [];
4157 this.parties = [];
4158 this.lastSentNick = '';
4159 this.lastSentClanTag = null;
4160 this.lastSentSkinURL = '';
4161 this.lastSentCustomColor = '';
4162 this.lastSentPartyToken = '';
4163 this.lastSentServerToken = '';
4164 },
4165 flushCells() {
4166 this.cells = {};
4167 },
4168 flushSkinsMap() {
4169 this.customSkinsMap = {};
4170 },
4171 flushChatData() {
4172 this.chatUsers = {};
4173 },
4174 getWS(ws) {
4175 if (!ws) {
4176 return;
4177 }
4178 this.ws = ws;
4179 this.createServerToken();
4180 this.updateServerInfo();
4181 if (this.ws.indexOf(`agar.io`) == -1) {
4182 this.closeConnection();
4183 }
4184 },
4185 recreateWS(token) {
4186 if (!token) {
4187 return null;
4188 }
4189 let text = null;
4190 if (/^[a-zA-Z0-9=+/]{12,}$/ .test(token)) {
4191 const atobToken = atob(token);
4192 if (/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:[0-9]{1,4}/ .test(atobToken)) {
4193 text = `wss://ip-${atobToken.replace(/./g, '-').replace(':', `.tech.agar.io:`)}`;
4194 }
4195 }
4196 if (!text && /^[a-z0-9]{5,}$/ .test(token)) {
4197 text = `wss://live-arena-` + token + `.agar.io:443`;
4198 }
4199 return text;
4200 },
4201 createServerToken() {
4202 console.log(this.ws)
4203 let matchOld = this.ws.match(/ip-d+/);
4204 const matchNew = this.ws.match(/live-arena-([\w\d]+)/);
4205 let text = null;
4206 if (matchOld) {
4207 const replace = this.ws.replace(`.tech.agar.io`, '').replace(/-/g, '.');
4208 matchOld = replace.match(/[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}:[0-9]{1,4}/);
4209 if (matchOld) {
4210 this.serverIP = matchOld[0];
4211 text = btoa(this.serverIP);
4212 }
4213 }
4214 if (!text && matchNew) {
4215 this.serverArena = matchNew[1];
4216 text = this.serverArena;
4217 }
4218 if (text) {
4219 if (this.serverToken !== text) {
4220 this.serverToken = text;
4221 this.flushData();
4222 this.flushCells();
4223 }
4224 this.partyToken = '';
4225 const matchPartyId = this.ws.match(/party_id=([A-Z0-9]{6})/);
4226 if (matchPartyId) {
4227 this.partyToken = matchPartyId[1];
4228 changeUrl(`/#${window.encodeURIComponent(this.partyToken)}`);
4229 }
4230 }
4231 },
4232 updateServerInfo() {
4233 JQuery(`#server-ws`).val(this.ws);
4234 JQuery(`#server-token`).val(this.serverToken);
4235 JQuery(`#party-token, .party-token`).val(this.partyToken);
4236 },
4237 gameServerConnect(ws) {
4238 if (!ws) {
4239 return;
4240 }
4241 this.skipServerData = true;
4242 window.core && window.core.connect && window.core.connect(ws);
4243 },
4244 gameServerReconnect() {
4245 if (window.MC && window.MC.reconnect) {
4246 window.MC.reconnect();
4247 return;
4248 }
4249 window.master && window.master.reconnect && window.master.reconnect();
4250 },
4251 gameServerJoin(token) {
4252 const ws = this.recreateWS(token);
4253 if (ws) {
4254 this.skipServerData = true;
4255 this.gameServerConnect(ws);
4256 }
4257 },
4258 connect() {
4259 this.closeConnection();
4260 this.flushData();
4261 this.setParty();
4262 console.log(`[OGARio by szymy] Connecting to server`);
4263 if (this.privateMode && this.privateIP) {
4264 this.socket = new WebSocket(this.privateIP);
4265 } else {
4266 this.socket = new WebSocket(this.publicIP);
4267 }
4268 this.socket.ogarioWS = true;
4269 this.socket.binaryType = 'arraybuffer';
4270 const app = this;
4271 this.socket.onopen = () => {
4272 console.log('[OGARio by szymy] Socket open');
4273 const buf = app.createView(3);
4274 buf.setUint8(0, 0);
4275 buf.setUint16(1, 401, true);
4276 app.sendBuffer(buf);
4277 app.sendPartyData();
4278 };
4279 this.socket.onmessage = message => {
4280 app.handleMessage(message);
4281 };
4282 this.socket.onclose = close => {
4283 app.flushData();
4284 console.log('[OGARio by szymy] Socket close', close);
4285 };
4286 this.socket.onerror = error => {
4287 app.flushData();
4288 console.log(`[OGARio by szymy] Socket error`, error);
4289 };
4290 },
4291 closeConnection() {
4292 if (this.socket) {
4293 this.socket.onmessage = null;
4294 try {
4295 this.socket.close();
4296 } catch (error) {}
4297 this.socket = null;
4298 }
4299 },
4300 reconnect() {
4301 this.setParty();
4302 const app = this;
4303 setTimeout(() => {
4304 app.connect();
4305 }, 1000);
4306 },
4307 switchServerMode() {
4308 if (!this.privateIP) {
4309 return;
4310 }
4311 this.privateMode = !this.privateMode;
4312 if (this.isSocketOpen()) {
4313 this.closeConnection();
4314 toastr.error(`Zamknięto połączenie z serwerem!`);
4315 }
4316 if (this.privateMode) {
4317 toastr.info(`Przełączono na serwer prywatny!`);
4318 JQuery(`.party-panel`).show();
4319 } else {
4320 toastr.info(`Przełączono na serwer publiczny!`);
4321 JQuery(`#active-parties`).empty();
4322 JQuery(`.party-panel`).hide();
4323 }
4324 this.onJoin();
4325 if (ogario.play) {
4326 this.onPlayerSpawn();
4327 }
4328 },
4329 isSocketOpen() {
4330 return this.socket !== null && this.socket.readyState === this.socket.OPEN;
4331 },
4332 createView(value) {
4333 return new DataView(new ArrayBuffer(value));
4334 },
4335 strToBuff(offset, str) {
4336 const view = this.createView(1 + str.length * 2);
4337 view.setUint8(0, offset);
4338 for (let length = 0; length < str.length; length++) {
4339 view.setUint16(1 + length * 2, str.charCodeAt(length), true);
4340 }
4341 return view;
4342 },
4343 sendBuffer(value) {
4344 this.socket.send(value.buffer);
4345 },
4346 handleMessage(message) {
4347 this.readMessage(new DataView(message.data));
4348 },
4349 readMessage(message) {
4350 switch (message.getUint8(0)) {
4351 case 0:
4352 this.playerID = message.getUint32(1, true);
4353 break;
4354 case 1:
4355 this.sendPlayerUpdate();
4356 break;
4357 case 20:
4358 this.updateTeamPlayer(message);
4359 break;
4360 case 30:
4361 this.updateTeamPlayerPosition(message);
4362 break;
4363 case 96:
4364 //break;
4365 this.updateParties(message);
4366 this.displayParties();
4367 break;
4368 case 100:
4369 this.readChatMessage(message);
4370 break;
4371 }
4372 },
4373 sendPlayerState(state) {
4374 if (this.isSocketOpen()) {
4375 const view = this.createView(1);
4376 view.setUint8(0, state);
4377 this.sendBuffer(view);
4378 }
4379 },
4380 sendPlayerSpawn() {
4381 this.sendPlayerState(1);
4382 },
4383 sendPlayerDeath() {
4384 this.sendPlayerState(2);
4385 },
4386 sendPlayerJoin() {
4387 this.sendPlayerState(3);
4388 },
4389 sendPlayerData(offset, name, str) {
4390 if (this[name] !== null && this[name] === str) {
4391 return;
4392 }
4393 if (this.isSocketOpen()) {
4394 this.sendBuffer(this.strToBuff(offset, str));
4395 this[name] = str;
4396 }
4397 },
4398 sendPlayerNick() {
4399 this.sendPlayerData(10, `lastSentNick`, mainProfile.nick);
4400 },
4401 sendPlayerClanTag() {
4402 this.sendPlayerData(11, `lastSentClanTag`, mainProfile.clanTag);
4403 },
4404 sendPlayerSkinURL() {
4405 this.sendPlayerData(12, `lastSentSkinURL`, mainProfile.skinURL);
4406 },
4407 sendPlayerCustomColor() {
4408 this.sendPlayerData(13, `lastSentCustomColor`, mainProfile.color);
4409 },
4410 sendPlayerColor() {
4411 if (this.isSocketOpen() && ogario.playerColor) {
4412 this.sendBuffer(this.strToBuff(14, ogario.playerColor));
4413 }
4414 },
4415 sendPartyToken() {
4416 this.setParty();
4417 this.sendPlayerData(15, `lastSentPartyToken`, this.partyToken);
4418 },
4419 sendServerToken() {
4420 this.sendPlayerData(16, 'lastSentServerToken', this.serverToken);
4421 },
4422 sendServerJoin() {
4423 this.sendServerToken();
4424 this.sendPlayerJoin();
4425 },
4426 sendServerRegion() {
4427 if (!this.region) {
4428 return;
4429 }
4430 const region = this.region.split('-');
4431 if (this.isSocketOpen()) {
4432 this.sendBuffer(this.strToBuff(17, region[0]));
4433 }
4434 },
4435 sendServerGameMode() {
4436 let gamemode = `FFA`;
4437 switch (this.gameMode) {
4438 case `:battleroyale`:
4439 gamemode = `BTR`;
4440 break;
4441 case `:teams`:
4442 gamemode = `TMS`;
4443 break;
4444 case `:experimental`:
4445 gamemode = `EXP`;
4446 break;
4447 case `:party`:
4448 gamemode = `PTY`;
4449 break;
4450 }
4451 if (this.isSocketOpen()) {
4452 this.sendBuffer(this.strToBuff(18, gamemode));
4453 }
4454 },
4455 sendServerData() {
4456 if (this.skipServerData) {
4457 this.skipServerData = false;
4458 return;
4459 }
4460 this.region = JQuery('#region').val();
4461 this.gameMode = JQuery('#gamemode').val();
4462 this.sendServerRegion();
4463 this.sendServerGameMode();
4464 },
4465 sendPartyData() {
4466 this.sendPlayerClanTag();
4467 this.sendPartyToken();
4468 this.sendServerToken();
4469 this.sendPlayerNick();
4470 },
4471 sendPlayerUpdate() {
4472 if (this.isSocketOpen() && ogario.play && this.playerID && ogario.playerColor) {
4473 function encode(str) {
4474 for (let length = 0; length < str.length; length++) {
4475 view.setUint16(offset, str.charCodeAt(length), true);
4476 offset += 2;
4477 }
4478 view.setUint16(offset, 0, true);
4479 offset += 2;
4480 }
4481 let text = 41;
4482 text += mainProfile.nick.length * 2;
4483 text += mainProfile.skinURL.length * 2;
4484 var view = this.createView(text);
4485 view.setUint8(0, 20);
4486 view.setUint32(1, this.playerID, true);
4487 var offset = 5;
4488 encode(mainProfile.nick);
4489 encode(mainProfile.skinURL);
4490 encode(mainProfile.color);
4491 encode(ogario.playerColor);
4492 this.sendBuffer(view);
4493 }
4494 },
4495 sendPlayerPosition() {
4496 if (this.isSocketOpen() && ogario.play && this.playerID) {
4497 const view = this.createView(17);
4498 view.setUint8(0, 30);
4499 view.setUint32(1, this.playerID, true);
4500 view.setInt32(5, this.getPlayerX(), true);
4501 view.setInt32(9, this.getPlayerY(), true);
4502 if (typeof ogario.playerMass !== `undefined`) {
4503 view.setUint32(13, ogario.playerMass, true);
4504 } else {
4505 view.setUint32(13, this.playerMass, true);
4506 }
4507 this.sendBuffer(view);
4508 }
4509 },
4510 checkPlayerID(id) {
4511 if (id) {
4512 for (let length = 0; length < this.teamPlayers.length; length++) {
4513 if (this.teamPlayers[length].id == id) {
4514 return length;
4515 }
4516 }
4517 }
4518 return null;
4519 },
4520 updateTeamPlayer(message) {
4521 function encode() {
4522 for (var text = '';;) {
4523 const string = message.getUint16(offset, true);
4524 if (string == 0) {
4525 break;
4526 }
4527 text += String.fromCharCode(string);
4528 offset += 2;
4529 }
4530 offset += 2;
4531 return text;
4532 }
4533 const id = message.getUint32(1, true);
4534 var offset = 5;
4535 const nick = encode();
4536 const skinUrl = this.checkSkinURL(encode());
4537 const customColor = encode();
4538 const defaultColor = encode();
4539 const skinName = this.gameMode === `:party` ? nick + defaultColor : nick;
4540 const userId = this.checkPlayerID(id);
4541 if (userId !== null) {
4542 this.teamPlayers[userId].nick = nick;
4543 this.teamPlayers[userId].skinID = skinName;
4544 this.teamPlayers[userId].skinURL = skinUrl;
4545 this.teamPlayers[userId].setColor(defaultColor, customColor);
4546 } else {
4547 const map = new minimap(id, nick, skinName, skinUrl);
4548 map.setColor(defaultColor, customColor);
4549 this.teamPlayers.push(map);
4550 }
4551 this.cacheCustomSkin(nick, defaultColor, skinUrl);
4552 },
4553 updateTeamPlayerPosition(message) {
4554 const id = message.getUint32(1, true);
4555 const userId = this.checkPlayerID(id);
4556 if (userId !== null) {
4557 const x = message.getInt32(5, true);
4558 const y = message.getInt32(9, true);
4559 const mass = message.getUint32(13, true);
4560 if (mass > 360000) {
4561 return;
4562 }
4563 const teamPlayer = this.teamPlayers[userId];
4564 teamPlayer.x = x;
4565 teamPlayer.y = y;
4566 teamPlayer.mass = mass;
4567 teamPlayer.alive = true;
4568 teamPlayer.updateTime = Date.now();
4569 if (this.targeting && this.targetID && id == this.targetID) {
4570 this.updateTarget(teamPlayer.nick, teamPlayer.skinURL, x, y, mass, teamPlayer.color);
4571 }
4572 }
4573 },
4574 updateTeamPlayers() {
4575 this.sendPlayerPosition();
4576 this.chatUsers = {};
4577 this.top5 = [];
4578
4579 for (const teamPlayer of this.teamPlayers) {
4580 if (teamPlayer.alive && Date.now() - teamPlayer.updateTime >= 2000 || teamPlayer.mass == 0) {
4581 teamPlayer.alive = false;
4582 if (this.targeting && this.targetID && teamPlayer.id == this.targetID) {
4583 this.setTargetStatus(2);
4584 }
4585 }
4586 if (teamPlayer.alive) {
4587 this.top5.push({
4588 id: teamPlayer.id,
4589 nick: teamPlayer.nick,
4590 x: teamPlayer.x,
4591 y: teamPlayer.y,
4592 mass: teamPlayer.mass,
4593 color: teamPlayer.color
4594 });
4595 if (!this.isChatUserMuted(teamPlayer.id)) {
4596 this.addChatUser(teamPlayer.id, teamPlayer.nick);
4597 }
4598 }
4599 }
4600
4601 this.top5.sort((row, config) => config.mass - row.mass);
4602 this.displayTop5();
4603 },
4604 updateParties(message) {
4605 this.parties = [];
4606 const userLength = message.getUint8(1);
4607 for (let offset = 2, length = 0; length < userLength; length++) {
4608 for (var text = '';;) {
4609 const string = message.getUint16(offset, true);
4610 if (string == 0) {
4611 break;
4612 }
4613 text += String.fromCharCode(string);
4614 offset += 2;
4615 }
4616 offset += 2;
4617 this.parties.push(text);
4618 }
4619 },
4620 readChatMessage(message) {
4621 if (gameOptionSettings.disableChat) {
4622 return;
4623 }
4624 const time = new Date().toTimeString().replace(/^(d{2}:d{2}).*/, '$1');
4625 const type = message.getUint8(1);
4626 const id = message.getUint32(2, true);
4627 const nick = message.getUint32(6, true);
4628 if (this.isChatUserMuted(id) || nick != 0 && nick != this.playerID && id != this.playerID) {
4629 return;
4630 }
4631 for (var text = '', length = 10; length < message.byteLength; length += 2) {
4632 const string = message.getUint16(length, true);
4633 if (string == 0) {
4634 break;
4635 }
4636 text += String.fromCharCode(string);
4637 }
4638 this.displayChatMessage(time, type, id, text);
4639 },
4640 sendChatMessage(type, message) {
4641 if (Date.now() - this.lastMessageSentTime < 500 || message.length == 0 || mainProfile.nick.length == 0) {
4642 return;
4643 }
4644 if (this.isSocketOpen()) {
4645 var message = `${mainProfile.nick}: ${message}`;
4646 const view = this.createView(10 + message.length * 2);
4647 view.setUint8(0, 100);
4648 view.setUint8(1, type);
4649 view.setUint32(2, this.playerID, true);
4650 view.setUint32(6, 0, true);
4651 for (let length = 0; length < message.length; length++) {
4652 view.setUint16(10 + length * 2, message.charCodeAt(length), true);
4653 }
4654 this.sendBuffer(view);
4655 this.lastMessageSentTime = Date.now();
4656 }
4657 },
4658 prepareCommand(command) {
4659 const chatCommand = command.replace(`%currentSector%`, this.currentSector);
4660 return chatCommand;
4661 },
4662 sendCommand(command) {
4663 const prepareCommand = this.prepareCommand(chatCommand[`comm` + command]);
4664 this.sendChatMessage(102, prepareCommand);
4665 },
4666 addChatUser(id, name) {
4667 this.chatUsers[id] = name;
4668 },
4669 getChatUserNick(id) {
4670 if (this.chatUsers.hasOwnProperty(id)) {
4671 return this.chatUsers[id];
4672 }
4673 return '';
4674 },
4675 muteChatUser(id) {
4676 if (!id || this.isChatUserMuted(id)) {
4677 return;
4678 }
4679 const User = this.getChatUserNick(id);
4680 this.chatMutedUsers[id] = User;
4681 this.chatMutedUserIDs.push(id);
4682 toastr.error(`${textLanguage.userMuted.replace(`%user%`, `<strong>` + this.escapeHTML(User) + `</strong>`) + ` <button data-user-id="` + id}" class="btn btn-xs btn-green btn-unmute-user">${textLanguage.unmute}${`</button>`}`);
4683 },
4684 unmuteChatUser(id) {
4685 if (!id) {
4686 return;
4687 }
4688 const User = this.chatMutedUserIDs.indexOf(id);
4689 if (User != -1) {
4690 this.chatMutedUserIDs.splice(User, 1);
4691 toastr.info(textLanguage.userUnmuted.replace(`%user%`, `${`<strong>` + this.escapeHTML(this.chatMutedUsers[id])}</strong>`));
4692 delete this.chatMutedUsers[id];
4693 }
4694 },
4695 isChatUserMuted(id) {
4696 if (this.chatMutedUserIDs.indexOf(id) != -1) {
4697 return true;
4698 }
4699 return false;
4700 },
4701 parseMessage(string) {
4702 const isImage = /[img]([w:/.?]+)[/img]/i;
4703 if (isImage.test(string)) {
4704 var url = string.match(isImage)[1];
4705 if (gameOptionSettings.showChatImages && this.checkImgURL(url)) {
4706 return `<img src="` + url + `" style="width:100%;border:none;">`;
4707 }
4708 return '';
4709 }
4710 const isVideo = /[yt]([w-]{11})[/yt]/i;
4711 if (isVideo.test(string)) {
4712 if (gameOptionSettings.showChatVideos) {
4713 var url = string.match(isVideo);
4714 return `<iframe type="text/html" width="100%" height="auto" src="https://www.youtube.com/embed/${url[1]}${`?autoplay=1&vq=tiny" frameborder="0" />`}`;
4715 }
4716 return '';
4717 }
4718 let escapedHtml = this.escapeHTML(string);
4719 if (gameOptionSettings.chatEmoticons) {
4720 escapedHtml = this.parseEmoticons(escapedHtml);
4721 }
4722 return escapedHtml;
4723 },
4724 parseEmoticons(string) {
4725 return String(string).replace(/<3/g, '<3').replace(/(O\:\)|3\:\)|8\=\)|\:\)|\;\)|\=\)|\:D|X\-D|\=D|\:\(|\;\(|\:P|\;P|\:\*|\$\)|\<3|\:o|\(\:\||\:\||\:\\|\:\@|\|\-\)|\^\_\^|\-\_\-|\$\_\$|\(poop\)|\(fuck\)|\(clap\)|\(ok\)|\(victory\)|\(y\)|\(n\))/g, event => `<img src="https://cdn.ogario.ovh/static/emoticons/${emojiChar[event]}${`" alt="`}${event}${`" class="emoticon">`}`);
4726 },
4727 displayChatMessage(time, type, id, nick) {
4728 if (nick.length == 0) {
4729 return;
4730 }
4731 let userName = nick.split(': ', 1).toString();
4732 const parseMessage = this.parseMessage(nick.replace(`${userName}: `, ''));
4733 if (userName.length == 0 || userName.length > 15 || parseMessage.length == 0) {
4734 return;
4735 }
4736 let text = '';
4737 if (id != 0 && id != this.playerID) {
4738 this.addChatUser(id, userName);
4739 text = `${`<a href="#" data-user-id="` + id}" class="mute-user ogicon-user-minus"></a> `;
4740 }
4741 userName = this.escapeHTML(userName);
4742 if (type == 101) {
4743 if (gameOptionSettings.showChatBox) {
4744 JQuery(`#chat-box`).append(`${`<div class="message"><span class="message-time">[` + time + `] </span>` + text + `<span class="message-nick">` + userName}: </span><span class="message-text">${parseMessage}${`</span></div>`}`);
4745 JQuery('#chat-box').perfectScrollbar(`update`);
4746 JQuery('#chat-box').animate({
4747 scrollTop: JQuery('#chat-box').prop(`scrollHeight`)
4748 }, 500);
4749 if (gameOptionSettings.chatSounds) {
4750 this.playSound(this.messageSound);
4751 }
4752 return;
4753 }
4754 if (!gameOptionSettings.hideChat) {
4755 toastr.success(`${`<span class="message-nick">` + userName + `: </span><span class="message-text">` + parseMessage}</span>${text}`);
4756 if (gameOptionSettings.chatSounds) {
4757 this.playSound(this.messageSound);
4758 }
4759 }
4760 this.chatHistory.push({
4761 nick: userName,
4762 message: parseMessage
4763 });
4764 if (this.chatHistory.length > 15) {
4765 this.chatHistory.shift();
4766 }
4767 } else if (type == 102) {
4768 if (gameOptionSettings.showChatBox) {
4769 JQuery(`#chat-box`).append(`${`<div class="message command"><span class="command-time">[` + time + `] </span>` + text}<span class="command-nick">${userName}: </span><span class="command-text">${parseMessage}${`</span></div>`}`);
4770 JQuery('#chat-box').perfectScrollbar('update');
4771 JQuery(`#chat-box`).animate({
4772 scrollTop: JQuery('#chat-box').prop(`scrollHeight`)
4773 }, 500);
4774 if (gameOptionSettings.chatSounds) {
4775 this.playSound(this.commandSound);
4776 }
4777 return;
4778 }
4779 if (!gameOptionSettings.hideChat) {
4780 toastr.warning(`${`<span class="command-nick">` + userName}: </span><span class="command-text">${parseMessage}</span>${text}`);
4781 if (gameOptionSettings.chatSounds) {
4782 this.playSound(this.commandSound);
4783 }
4784 }
4785 } else {
4786 JQuery(`#messages`).append(nick);
4787 }
4788 },
4789 displayUserList(users, activeUser, html, isMute, icon) {
4790 let text = '';
4791 if (Object.keys(users).length) {
4792 text += `<ol class="user-list">`;
4793 for (const user in users) {
4794 if (users.hasOwnProperty(user)) {
4795 text += `${`<li><strong>` + this.escapeHTML(users[user]) + `</strong> <button data-user-id="` + user}" class="btn btn-xs ${html}">${isMute}${`</button></li>`}`;
4796 }
4797 }
4798 text += `</ol>`;
4799 } else {
4800 text += textLanguage.none;
4801 }
4802 toastr[icon](text, activeUser, {
4803 closeButton: true,
4804 tapToDismiss: false
4805 });
4806 },
4807 displayChatActiveUsers() {
4808 this.displayUserList(this.chatUsers, textLanguage.activeUsers, `btn-red btn-mute-user`, textLanguage.mute, 'info');
4809 },
4810 displayChatMutedUsers() {
4811 this.displayUserList(this.chatMutedUsers, textLanguage.mutedUsers, `btn-green btn-unmute-user`, textLanguage.unmute, 'error');
4812 },
4813 preloadChatSounds() {
4814 this.setMessageSound();
4815 this.setCommandSound();
4816 },
4817 setChatSoundsBtn() {
4818 if (gameOptionSettings.chatSounds) {
4819 JQuery(`.chat-sound-notifications`).removeClass(`ogicon-volume-mute2`).addClass(`ogicon-volume-high`);
4820 } else {
4821 JQuery(`.chat-sound-notifications`).removeClass(`ogicon-volume-high`).addClass(`ogicon-volume-mute2`);
4822 }
4823 },
4824 setMessageSound() {
4825 this.messageSound = this.setSound(gameOptionSettings.messageSound);
4826 },
4827 setCommandSound() {
4828 this.commandSound = this.setSound(gameOptionSettings.commandSound);
4829 },
4830 setSound(audio) {
4831 if (!audio) {
4832 return null;
4833 }
4834 return new Audio(audio);
4835 },
4836 playSound(audio) {
4837 if (audio && audio.play) {
4838 audio.pause();
4839 audio.currentTime = 0;
4840 audio.play();
4841 }
4842 },
4843 setTargeting() {
4844 if (!this.targetID) {
4845 return;
4846 }
4847 this.targeting = !this.targeting;
4848 ogario.targeting = this.targeting;
4849 this.setTargetingInfo();
4850 },
4851 setTargetingInfo() {
4852 if (this.targeting) {
4853 JQuery(`#set-targeting`).addClass('active');
4854 JQuery('#target-status').show();
4855 if (this.targetStatus != 2) {
4856 JQuery('#target-summary').show();
4857 }
4858 } else {
4859 JQuery('#set-targeting').removeClass(`active`);
4860 JQuery(`#target-summary, #target-status`).hide();
4861 }
4862 },
4863 cancelTargeting() {
4864 this.setTargetStatus(0);
4865 },
4866 setPrivateMiniMap() {
4867 if (!this.targetID) {
4868 return;
4869 }
4870 this.privateMiniMap = !this.privateMiniMap;
4871 if (this.privateMiniMap) {
4872 JQuery(`#set-private-minimap`).addClass(`active`);
4873 } else {
4874 JQuery('#set-private-minimap').removeClass(`active`);
4875 }
4876 },
4877 setTarget(id) {
4878 const userId = this.checkPlayerID(id);
4879 if (userId !== null) {
4880 const teamPlayer = this.teamPlayers[userId];
4881 this.targetID = teamPlayer.id;
4882 this.updateTarget(teamPlayer.nick, teamPlayer.skinURL, teamPlayer.x, teamPlayer.y, teamPlayer.mass, teamPlayer.color);
4883 if (!teamPlayer.alive) {
4884 this.setTargetStatus(2);
4885 return;
4886 }
4887 this.setTargetStatus(1);
4888 } else {
4889 this.setTargetStatus(0);
4890 }
4891 },
4892 setTargetStatus(type) {
4893 switch (type) {
4894 case 0:
4895 this.targetStatus = 0;
4896 this.targetID = 0;
4897 this.targetNick = '';
4898 this.targetSkinURL = '';
4899 this.targeting = false;
4900 ogario.targeting = false;
4901 this.privateMiniMap = false;
4902 JQuery(`#target-skin, #target-nick, #target-summary`).hide();
4903 JQuery('#target-status').show().text(`[${textLanguage.targetNotSet}]`);
4904 JQuery('#target-panel-hud a').removeClass(`active`);
4905 break;
4906 case 1:
4907 this.targetStatus = 1;
4908 if (!this.targeting) {
4909 this.targeting = true;
4910 ogario.targeting = true;
4911 this.setTargetingInfo();
4912 }
4913 JQuery(`#target-skin, #target-nick, #target-status, #target-summary`).show();
4914 break;
4915 case 2:
4916 this.targetStatus = 2;
4917 JQuery(`#target-summary`).hide();
4918 JQuery(`#target-status`).show().text(`[${textLanguage.targetDead}]`);
4919 ogario.resetTargetPosition();
4920 break;
4921 }
4922 },
4923 changeTarget() {
4924 let targetId = this.checkPlayerID(this.targetID);
4925 for (var target = null, length = 0; length < this.teamPlayers.length; length++) {
4926 if (!this.teamPlayers[length].alive) {
4927 continue;
4928 }
4929 if (targetId !== null) {
4930 if (length < targetId && target === null) {
4931 target = length;
4932 continue;
4933 }
4934 if (length > targetId) {
4935 target = length;
4936 break;
4937 }
4938 } else {
4939 targetId = length;
4940 break;
4941 }
4942 }
4943 if (target !== null) {
4944 targetId = target;
4945 }
4946 if (targetId !== null) {
4947 this.setTarget(this.teamPlayers[targetId].id);
4948 } else {
4949 this.setTargetStatus(0);
4950 }
4951 },
4952 updateTarget(nick, skinUrl, x, y, mass, color) {
4953 ogario.setTargetPosition(x, y);
4954 if (this.targetNick !== nick) {
4955 this.targetNick = nick;
4956 JQuery(`#target-nick`).html(this.escapeHTML(nick));
4957 }
4958 JQuery(`#target-skin`).css(`background-color`, color);
4959 if (skinUrl && this.targetSkinURL !== skinUrl) {
4960 if (this.customSkinsCache.hasOwnProperty(skinUrl + `_cached`)) {
4961 JQuery('#target-skin img').attr(`src`, skinUrl);
4962 this.targetSkinURL = skinUrl;
4963 } else {
4964 JQuery(`#target-skin img`).attr(`src`, `https://cdn.ogario.ovh/static/img/blank.png`);
4965 }
4966 }
4967 JQuery(`#target-status`).text(`[${this.shortMassFormat(mass)}]`);
4968 const mapSector = this.calculateMapSector(x, y);
4969 let html = `${textLanguage.targetDistance + `: <span class="hud-main-color">` + ogario.targetDistance} [${mapSector}]</span>`;
4970 if (ogario.play) {
4971 html += ` | ` + textLanguage.targetMass + `: <span class="hud-main-color">` + this.shortMassFormat(mass + ogario.playerMass) + `</span>`;
4972 }
4973 JQuery('#target-summary').html(html);
4974 if (this.targetStatus != 1) {
4975 this.setTargetStatus(1);
4976 }
4977 },
4978 updateQuest() {
4979 if (!this.showQuest || this.gameMode !== `:ffa`) {
4980 return;
4981 }
4982 if (window.MC && window.MC.getQuestProgressLabel) {
4983 this.questHUD.textContent = window.MC.getQuestProgressLabel();
4984 }
4985 },
4986 init() {
4987 this.loadSettings();
4988 this.loadProfiles();
4989 this.setLang();
4990 this.setMenu();
4991 this.setUI();
4992 OgarioSettings && OgarioSettings.setTheme();
4993 this.setShowQuickMenu();
4994 this.setShowSkinsPanel();
4995 this.setProfile();
4996 this.setMainButtons();
4997 this.setStreamMode();
4998 this.setHideSkinUrl();
4999 this.setMiniMap();
5000 this.setAutoResp();
5001 this.setDisableChat();
5002 this.setShowChatBox();
5003 this.setTop5();
5004 this.setTargetingHUD();
5005 this.setQuest();
5006 this.displayTime();
5007 this.setCenteredLb();
5008 this.setNormalLb();
5009 this.setFpsAtTop();
5010 this.displayStats();
5011 this.setBlockPopups();
5012 this.preloadChatSounds();
5013 this.setChatSoundsBtn();
5014 const app = this;
5015 setInterval(() => {
5016 app.drawMiniMap();
5017 }, 33);
5018 setInterval(() => {
5019 app.updateTeamPlayers();
5020 }, this.updateInterval);
5021 }
5022 };
5023
5024 function newCanvas() {
5025 this.txt = '';
5026 this.txtCanvas = null;
5027 this.txtCtx = null;
5028 this.color = '#FFFFFF';
5029 this.stroke = false;
5030 this.strokeWidth = 2;
5031 this.strokeColor = '#000000';
5032 this.font = `700 16px Ubuntu`;
5033 this.fontFamily = `Ubuntu`;
5034 this.fontWeight = 700;
5035 this.fontSize = 16;
5036 this.margin = 3;
5037 this.scale = 1;
5038 this.quality = 1;
5039 this.measuredWidth = 0;
5040 this.redraw = false;
5041 this.remeasure = false;
5042 this.setTxt = function(text) {
5043 if (this.txt !== text) {
5044 this.txt = text;
5045 this.redraw = true;
5046 this.remeasure = true;
5047 }
5048 };
5049 this.setColor = function(color) {
5050 if (this.color !== color) {
5051 this.color = color;
5052 this.redraw = true;
5053 }
5054 };
5055 this.setStroke = function(stroke) {
5056 if (this.stroke !== stroke) {
5057 this.stroke = stroke;
5058 this.redraw = true;
5059 }
5060 };
5061 this.setStrokeWidth = function(width) {
5062 if (!this.stroke) {
5063 return;
5064 }
5065 if (this.strokeWidth != width) {
5066 this.strokeWidth = width;
5067 this.redraw = true;
5068 this.remeasure = true;
5069 }
5070 };
5071 this.setStrokeColor = function(color) {
5072 if (!this.stroke) {
5073 return;
5074 }
5075 if (this.strokeColor !== color) {
5076 this.strokeColor = color;
5077 this.redraw = true;
5078 }
5079 };
5080 this.setFont = function() {
5081 this.font = `${this.fontWeight} ${this.fontSize}${`px `}${this.fontFamily}`;
5082 };
5083 this.setFontFamily = function(font) {
5084 if (this.fontFamily !== font) {
5085 this.fontFamily = font;
5086 this.setFont();
5087 this.redraw = true;
5088 this.remeasure = true;
5089 }
5090 };
5091 this.setFontWeight = function(weigth) {
5092 if (this.fontWeight != weigth) {
5093 this.fontWeight = weigth;
5094 this.setFont();
5095 this.redraw = true;
5096 this.remeasure = true;
5097 }
5098 };
5099 this.setFontSize = function(size) {
5100 if (this.fontSize != size) {
5101 this.fontSize = size;
5102 this.margin = ~~(size * 0.2);
5103 this.setFont();
5104 this.redraw = true;
5105 }
5106 };
5107 this.setScale = function(scale) {
5108 if (this.scale != scale) {
5109 this.scale = scale;
5110 this.redraw = true;
5111 }
5112 };
5113 this.createCanvas = function() {
5114 if (this.txtCanvas) {
5115 return;
5116 }
5117 this.txtCanvas = document.createElement(`canvas`);
5118 this.txtCtx = this.txtCanvas.getContext('2d');
5119 this.txtCtx.ogarioCtx = true;
5120 };
5121 this.setDrawing = function(color, font, weigth, stroke, width, strokeColor) {
5122 this.setColor(color);
5123 this.setFontFamily(font);
5124 this.setFontWeight(weigth);
5125 this.setStroke(stroke);
5126 this.setStrokeWidth(width);
5127 this.setStrokeColor(strokeColor);
5128 };
5129 this.measureWidth = function() {
5130 if (this.remeasure) {
5131 this.txtCtx.font = this.fontWeight + ` 10px ` + this.fontFamily;
5132 this.measuredWidth = this.txtCtx.measureText(this.txt).width;
5133 this.remeasure = false;
5134 }
5135 return ~~(this.fontSize / 10 * this.measuredWidth) + this.strokeWidth * 2;
5136 };
5137 this.drawTxt = function() {
5138 this.createCanvas();
5139 if (this.redraw) {
5140 this.redraw = false;
5141 this.txtCanvas.width = this.measureWidth();
5142 this.txtCanvas.height = this.fontSize + this.margin;
5143 this.txtCtx.font = this.font;
5144 this.txtCtx.globalAlpha = 1;
5145 this.txtCtx.lineWidth = this.strokeWidth;
5146 this.txtCtx.strokeStyle = this.strokeColor;
5147 this.txtCtx.fillStyle = this.color;
5148 if (this.stroke) {
5149 this.txtCtx.strokeText(this.txt, this.strokeWidth, this.fontSize - this.margin / 2);
5150 }
5151 this.txtCtx.fillText(this.txt, this.strokeWidth, this.fontSize - this.margin / 2);
5152 }
5153 return this.txtCanvas;
5154 };
5155 }
5156
5157 function Cell(id, x, y, size, color, isFood, isVirus, isPlayer, shortMass, virusMassShots) {
5158 this.id = id;
5159 this.x = x;
5160 this.y = y;
5161 this.targetX = x;
5162 this.targetY = y;
5163 this.color = color;
5164 this.oppColor = null;
5165 this.size = size;
5166 this.targetSize = size;
5167 this.alpha = 1;
5168 this.nick = '';
5169 this.targetNick = '';
5170 this.nickCanvas = null;
5171 this.mass = 0;
5172 this.lastMass = 0;
5173 this.kMass = 0;
5174 this.massCanvas = null;
5175 this.massTxt = '';
5176 this.margin = 0;
5177 this.scale = 1;
5178 this.nickScale = 1;
5179 this.massScale = 1;
5180 this.virMassScale = 3;
5181 this.strokeScale = 1;
5182 this.fontSize = 26;
5183 this.nickSize = 26;
5184 this.lastNickSize = 0;
5185 this.massSize = 26;
5186 this.virMassSize = 26;
5187 this.nickStrokeSize = 3;
5188 this.massStrokeSize = 3;
5189 this.isFood = isFood;
5190 this.isVirus = isVirus;
5191 this.isPlayerCell = isPlayer;
5192 this.shortMass = shortMass;
5193 this.virMassShots = virusMassShots;
5194 this.rescale = false;
5195 this.redrawNick = true;
5196 this.redrawMass = true;
5197 this.optimizedNames = false;
5198 this.optimizedMass = false;
5199 this.strokeNick = false;
5200 this.strokeMass = false;
5201 this.removed = false;
5202 this.redrawed = 0;
5203 this.time = 0;
5204 this.skin = null;
5205 this.pi2 = 2 * Math.PI;
5206 this.update = function(x, y, mass, isVirus, isPlayer, nick) {
5207 this.x = x;
5208 this.y = y;
5209 this.isVirus = isVirus;
5210 this.isPlayerCell = isPlayer;
5211 this.setMass(mass);
5212 this.setNick(nick);
5213 };
5214 this.removeCell = function() {
5215 this.removed = true;
5216 let cells = Connection.cells.indexOf(this);
5217 if (cells != -1) {
5218 Connection.cells.splice(cells, 1);
5219 if (gameOptionSettings.virusesRange) {
5220 cells = Connection.viruses.indexOf(this);
5221 if (cells != -1) {
5222 Connection.viruses.splice(cells, 1);
5223 }
5224 }
5225 } else {
5226 cells = Connection.food.indexOf(this);
5227 if (cells != -1) {
5228 Connection.food.splice(cells, 1);
5229 }
5230 }
5231 cells = Connection.playerCells.indexOf(this);
5232 if (cells != -1) {
5233 Connection.removePlayerCell = true;
5234 Connection.playerCells.splice(cells, 1);
5235 cells = Connection.playerCellIDs.indexOf(this.id);
5236 if (cells != -1) {
5237 Connection.playerCellIDs.splice(cells, 1);
5238 }
5239 }
5240 if (this.redrawed) {
5241 Connection.removedCells.push(this);
5242 }
5243 delete Connection.indexedCells[this.id];
5244 };
5245 this.moveCell = function() {
5246 const time = Connection.time - this.time;
5247 let delay = time / gameOptionSettings.animation;
5248 delay = delay < 0 ? 0 : delay > 1 ? 1 : delay;
5249 this.x += (this.targetX - this.x) * delay;
5250 this.y += (this.targetY - this.y) * delay;
5251 this.size += (this.targetSize - this.size) * delay;
5252 this.alpha = delay;
5253 if (!this.removed) {
5254 this.time = Connection.time;
5255 return;
5256 }
5257 if (delay == 1) {
5258 const removedCells = Connection.removedCells.indexOf(this);
5259 if (removedCells != -1) {
5260 Connection.removedCells.splice(removedCells, 1);
5261 }
5262 }
5263 };
5264 this.isInView = function() {
5265 return this.id <= 0 ? false : this.x + this.size + 40 < Connection.viewX - Connection.canvasWidth / 2 / Connection.scale || this.y + this.size + 40 < Connection.viewY - Connection.canvasHeight / 2 / Connection.scale || this.x - this.size - 40 > Connection.viewX + Connection.canvasWidth / 2 / Connection.scale || this.y - this.size - 40 > Connection.viewY + Connection.canvasHeight / 2 / Connection.scale ? false : true;
5266 };
5267 this.setMass = function(mass) {
5268 this.size = mass;
5269 if (mass <= 40) {
5270 return false;
5271 }
5272 if (!this.massCanvas) {
5273 this.massCanvas = new newCanvas();
5274 return false;
5275 }
5276 this.mass = ~~(mass * mass / 100);
5277 this.redrawMass = true;
5278 if (this.isVirus) {
5279 if (this.virMassShots && this.mass < 200) {
5280 this.mass = ~~((200 - this.mass) / 14);
5281 }
5282 this.massTxt = this.mass.toString();
5283 return true;
5284 }
5285 this.massTxt = this.mass.toString();
5286 if (this.mass <= 200) {
5287 return true;
5288 }
5289 if (this.shortMass && this.mass >= 1000) {
5290 this.kMass = Math.round(this.mass / 100) / 10;
5291 this.massTxt = `${this.kMass}k`;
5292 return true;
5293 }
5294 if (this.optimizedMass) {
5295 this.redrawMass = Math.abs((this.mass - this.lastMass) / this.mass) >= 0.02 || this.rescale;
5296 }
5297 return true;
5298 };
5299 this.setNick = function(nick) {
5300 this.nick = nick;
5301 if (!nick || this.isVirus) {
5302 return false;
5303 }
5304 if (!this.nickCanvas) {
5305 this.nickCanvas = new newCanvas();
5306 return false;
5307 }
5308 return true;
5309 };
5310 this.setScale = function(scale, nickScale, massScale, virusScale, strokeScale) {
5311 const ceilScale = Math.ceil(scale * 10) / 10;
5312 this.rescale = false;
5313 if (this.scale != ceilScale) {
5314 this.scale = ceilScale;
5315 this.rescale = true;
5316 }
5317 this.nickScale = nickScale;
5318 this.massScale = massScale;
5319 this.virMassScale = virusScale;
5320 this.strokeScale = strokeScale;
5321 };
5322 this.setFontSize = function() {
5323 if (this.isVirus) {
5324 this.massSize = Math.ceil(this.virMassSize * this.scale * this.virMassScale);
5325 return;
5326 }
5327 this.fontSize = Math.max(this.size * 0.3, 26) * this.scale;
5328 this.nickSize = ~~(this.fontSize * this.nickScale);
5329 this.massSize = ~~(this.fontSize * 0.5 * this.massScale);
5330 if (this.optimizedNames) {
5331 this.redrawNick = Math.abs((this.nickSize - this.lastNickSize) / this.nickSize) >= 0.3 || this.rescale;
5332 return;
5333 }
5334 this.redrawNick = true;
5335 };
5336 this.setStrokeSize = function() {
5337 if (this.strokeNick && !this.isVirus) {
5338 this.nickStrokeSize = ~~(this.nickSize * 0.1 * this.strokeScale);
5339 }
5340 if (this.strokeMass) {
5341 this.massStrokeSize = ~~(this.massSize * 0.1 * this.strokeScale);
5342 }
5343 };
5344 this.setDrawing = function() {
5345 this.optimizedNames = gameOptionSettings.optimizedNames;
5346 this.optimizedMass = gameOptionSettings.optimizedMass;
5347 this.shortMass = gameOptionSettings.shortMass;
5348 this.virMassShots = gameOptionSettings.virMassShots;
5349 this.strokeNick = gameOptionSettings.namesStroke;
5350 this.strokeMass = gameOptionSettings.massStroke;
5351 };
5352 this.setDrawingScale = function() {
5353 this.setScale(ogario.viewScale, gameSetupTheme.namesScale, gameSetupTheme.massScale, gameSetupTheme.virMassScale, gameSetupTheme.strokeScale);
5354 this.setFontSize();
5355 this.setStrokeSize();
5356 this.margin = 0;
5357 };
5358 this.drawNick = function(ctx) {
5359 if (!this.nick || !this.nickCanvas || this.isVirus) {
5360 return;
5361 }
5362 const canvas = this.nickCanvas;
5363 canvas.setDrawing(gameSetupTheme.namesColor, gameSetupTheme.namesFontFamily, gameSetupTheme.namesFontWeight, this.strokeNick, this.nickStrokeSize, gameSetupTheme.namesStrokeColor);
5364 canvas.setTxt(this.nick);
5365 if (this.redrawNick) {
5366 canvas.setFontSize(this.nickSize);
5367 this.lastNickSize = this.nickSize;
5368 }
5369 canvas.setScale(this.scale);
5370 const imgTxt = canvas.drawTxt();
5371 const width = ~~(imgTxt.width / this.scale);
5372 const heigth = ~~(imgTxt.height / this.scale);
5373 this.margin = ~~(heigth / 2);
5374 ctx.drawImage(imgTxt, ~~this.x - ~~(width / 2), ~~this.y - this.margin, width, heigth);
5375 };
5376 this.drawMass = function(ctx) {
5377 if (!this.massCanvas || this.size <= 40) {
5378 return;
5379 }
5380 const canvas = this.massCanvas;
5381 canvas.setDrawing(gameSetupTheme.massColor, gameSetupTheme.massFontFamily, gameSetupTheme.massFontWeight, this.strokeMass, this.massStrokeSize, gameSetupTheme.massStrokeColor);
5382 if (this.redrawMass) {
5383 canvas.setTxt(this.massTxt);
5384 this.lastMass = this.mass;
5385 }
5386 canvas.setFontSize(this.massSize);
5387 canvas.setScale(this.scale);
5388 const imgTxt = canvas.drawTxt();
5389 const width = ~~(imgTxt.width / this.scale);
5390 const heigth = ~~(imgTxt.height / this.scale);
5391 const margin = this.margin == 0 ? ~~this.y - ~~(heigth / 2) : ~~this.y + this.margin;
5392 ctx.drawImage(imgTxt, ~~this.x - ~~(width / 2), margin, width, heigth);
5393 };
5394 this.draw = function(ctx, update) {
5395 if (Connection.hideSmallBots && this.size <= 36) {
5396 return;
5397 }
5398 ctx.save();
5399 this.redrawed++;
5400 if (update) {
5401 this.moveCell();
5402 }
5403 if (this.removed) {
5404 ctx.globalAlpha *= 1 - this.alpha;
5405 }
5406 const alpha = ctx.globalAlpha;
5407 let isAplha = false;
5408 const size = this.isFood ? this.size + gameSetupTheme.foodSize : this.size;
5409 ctx.beginPath();
5410 ctx.arc(this.x, this.y, size, 0, this.pi2, false);
5411 ctx.closePath();
5412 if (this.isFood) {
5413 ctx.fillStyle = this.color;
5414 ctx.fill();
5415 ctx.restore();
5416 return;
5417 }
5418 if (this.isVirus) {
5419 if (gameOptionSettings.transparentViruses) {
5420 ctx.globalAlpha *= gameSetupTheme.virusAlpha;
5421 isAplha = true;
5422 }
5423 if (gameOptionSettings.virColors && Connection.play) {
5424 ctx.fillStyle = application.setVirusColor(size);
5425 ctx.strokeStyle = application.setVirusStrokeColor(size);
5426 } else {
5427 ctx.fillStyle = gameSetupTheme.virusColor;
5428 ctx.strokeStyle = gameSetupTheme.virusStrokeColor;
5429 }
5430 ctx.fill();
5431 if (isAplha) {
5432 ctx.globalAlpha = alpha;
5433 isAplha = false;
5434 }
5435 ctx.lineWidth = gameSetupTheme.virusStrokeSize;
5436 ctx.stroke();
5437 if (gameOptionSettings.showMass) {
5438 this.setDrawing();
5439 this.setDrawingScale();
5440 this.setMass(this.size);
5441 this.drawMass(ctx);
5442 }
5443 ctx.restore();
5444 return;
5445 }
5446 if (gameOptionSettings.transparentCells) {
5447 ctx.globalAlpha *= gameSetupTheme.cellsAlpha;
5448 isAplha = true;
5449 }
5450 let color = this.color;
5451 if (Connection.play) {
5452 if (this.isPlayerCell) {
5453 if (gameOptionSettings.myCustomColor) {
5454 color = mainProfile.color;
5455 }
5456 } else if (gameOptionSettings.oppColors && !gameOptionSettings.oppRings) {
5457 color = this.oppColor;
5458 }
5459 }
5460 ctx.fillStyle = color;
5461 ctx.fill();
5462 if (isAplha) {
5463 ctx.globalAlpha = alpha;
5464 isAplha = false;
5465 }
5466 let skin = null;
5467 if (gameOptionSettings.customSkins && Connection.showCustomSkins) {
5468 skin = application.getCustomSkin(this.targetNick, this.color);
5469 if (skin) {
5470 if ((gameOptionSettings.transparentSkins || Connection.play && gameOptionSettings.oppColors) && !(this.isPlayerCell && !gameOptionSettings.myTransparentSkin) || this.isPlayerCell && gameOptionSettings.myTransparentSkin) {
5471 ctx.globalAlpha *= gameSetupTheme.skinsAlpha;
5472 isAplha = true;
5473 }
5474 ctx.drawImage(skin, this.x - size, this.y - size, 2 * size, 2 * size);
5475 if (isAplha) {
5476 ctx.globalAlpha = alpha;
5477 isAplha = false;
5478 }
5479 }
5480 }
5481 if (gameOptionSettings.teammatesInd && !this.isPlayerCell && size <= 200 && (skin || application.checkSkinsMap(this.targetNick, this.color))) {
5482 drawRender.drawTeammatesInd(ctx, this.x, this.y, size);
5483 }
5484 if (gameOptionSettings.noNames && !gameOptionSettings.showMass || update) {
5485 ctx.restore();
5486 return;
5487 }
5488 let hideCells = false;
5489 if (!this.isPlayerCell) {
5490 hideCells = application.setAutoHideCellInfo(size);
5491 if (hideCells && gameOptionSettings.autoHideNames && gameOptionSettings.autoHideMass) {
5492 ctx.restore();
5493 return;
5494 }
5495 }
5496 this.setDrawing();
5497 this.setDrawingScale();
5498 ctx.globalAlpha *= gameSetupTheme.textAlpha;
5499 if (!gameOptionSettings.noNames && !(hideCells && gameOptionSettings.autoHideNames) && !(this.isPlayerCell && gameOptionSettings.hideMyName) && !(skin && gameOptionSettings.hideTeammatesNames)) {
5500 if (this.setNick(this.targetNick)) {
5501 this.drawNick(ctx);
5502 }
5503 }
5504 if (gameOptionSettings.showMass && !(hideCells && gameOptionSettings.autoHideMass) && !(this.isPlayerCell && gameOptionSettings.hideMyMass) && !(gameOptionSettings.hideEnemiesMass && !this.isPlayerCell && !this.isVirus)) {
5505 if (this.setMass(this.size)) {
5506 this.drawMass(ctx);
5507 }
5508 }
5509 ctx.restore();
5510 };
5511 }
5512
5513 function Node(view, offset) {
5514 this.view = view;
5515 this.offset = offset;
5516 this.contentType = 1;
5517 this.uncompressedSize = 0;
5518 this.setContentType = function() {
5519 this.contentType = this.readUint32();
5520 };
5521 this.setUncompressedSize = function() {
5522 this.uncompressedSize = this.readUint32();
5523 };
5524 this.compareBytesGt = (bytes1, bytes2) => {
5525 const byte_1 = bytes1 < 0;
5526 const byte_2 = bytes2 < 0;
5527 if (byte_1 != byte_2) {
5528 return byte_1;
5529 }
5530 return bytes1 > bytes2;
5531 };
5532 this.skipByte = function() {
5533 const read = this.readByte();
5534 if (read < 128) {
5535 return;
5536 }
5537 this.skipByte();
5538 };
5539 this.readByte = function() {
5540 return this.view.getUint8(this.offset++);
5541 };
5542 this.readUint32 = function() {
5543 let number = 0;
5544 let mayor = 0;
5545 while (true) {
5546 const read = this.readByte();
5547 if (this.compareBytesGt(32, mayor)) {
5548 if (read >= 128) {
5549 number |= (read & 127) << mayor;
5550 } else {
5551 number |= read << mayor;
5552 break;
5553 }
5554 } else {
5555 this.skipByte();
5556 break;
5557 }
5558 mayor += 7;
5559 }
5560 return number;
5561 };
5562 this.readFlag = function() {
5563 return this.readUint32() >>> 3;
5564 };
5565 }
5566 const Connection = {
5567 ws: null,
5568 socket: null,
5569 protocolKey: null,
5570 clientKey: null,
5571 connectionOpened: false,
5572 accessTokenSent: false,
5573 loggedIn: false,
5574 clientVersion: 30500,
5575 clientVersionString: `3.5.0`,
5576 time: Date.now(),
5577 serverTime: 0,
5578 serverTimeDiff: 0,
5579 loggedInTime: 0,
5580 mapSize: 14142,
5581 mapOffset: 7071,
5582 mapOffsetX: 0,
5583 mapOffsetY: 0,
5584 mapOffsetFixed: false,
5585 mapMinX: -7071,
5586 mapMinY: -7071,
5587 mapMaxX: 7071,
5588 mapMaxY: 7071,
5589 viewMinX: 0,
5590 viewMinY: 0,
5591 viewMaxX: 0,
5592 viewMaxY: 0,
5593 canvasWidth: 0,
5594 canvasHeight: 0,
5595 canvasScale: 1,
5596 indexedCells: {},
5597 cells: [],
5598 removedCells: [],
5599 food: [],
5600 viruses: [],
5601 playerCells: [],
5602 playerCellIDs: [],
5603 ghostCells: [],
5604 playerX: 0,
5605 playerY: 0,
5606 playerSize: 0,
5607 playerMass: 0,
5608 playerMaxMass: 0,
5609 playerMinMass: 0,
5610 playerScore: 0,
5611 playerSplitCells: 0,
5612 playerColor: null,
5613 playerNick: '',
5614 playerPosition: 0,
5615 leaderboard: [],
5616 biggerSTECellsCache: [],
5617 biggerCellsCache: [],
5618 smallerCellsCache: [],
5619 STECellsCache: [],
5620 STE: 0,
5621 autoZoom: false,
5622 zoomValue: 0.1,
5623 viewX: 0,
5624 viewY: 0,
5625 scale: 1,
5626 viewScale: 1,
5627 clientX: 0,
5628 clientY: 0,
5629 cursorX: 0,
5630 cursorY: 0,
5631 targetX: 0,
5632 targetY: 0,
5633 targetDistance: 0,
5634 battleRoyale: {
5635 state: 0,
5636 players: 0,
5637 startTime: 0,
5638 shrinkTime: 0,
5639 timeLeft: 0,
5640 x: 0,
5641 y: 0,
5642 radius: 0,
5643 targetX: 0,
5644 targetY: 0,
5645 targetRadius: 0,
5646 maxRadius: 11313,
5647 rank: [],
5648 playerRank: 0,
5649 joined: false
5650 },
5651 play: false,
5652 pause: false,
5653 targeting: false,
5654 removePlayerCell: false,
5655 showCustomSkins: true,
5656 showFood: true,
5657 foodIsHidden: false,
5658 selectBiggestCell: true,
5659 hideSmallBots: false,
5660 pressedKeys: {},
5661 connect(url) {
5662 console.log(`[OGARio by szymy] Connecting to game server:`, url);
5663 const app = this;
5664 this.closeConnection();
5665 this.flushCellsData();
5666 this.protocolKey = null;
5667 this.clientKey = null;
5668 this.accessTokenSent = false;
5669 this.connectionOpened = false;
5670 this.loggedIn = false;
5671 this.mapOffsetFixed = false;
5672 this.leaderboard = [];
5673 this.ws = url;
5674 if(window.user.startedBots) window.connection.send(new Uint8Array([1]).buffer)
5675 window.game.url = url
5676 window.user.isAlive = false
5677 window.user.macroFeedInterval = null
5678 this.socket = new WebSocket(url);
5679 this.socket.binaryType = `arraybuffer`;
5680 this.socket.onopen = () => {
5681 app.onOpen();
5682 };
5683 this.socket.onmessage = message => {
5684 app.onMessage(message);
5685 };
5686 this.socket.onerror = error => {
5687 app.onError(error);
5688 };
5689 this.socket.onclose = close => {
5690 app.onClose(close);
5691 };
5692 application.getWS(this.ws);
5693 application.sendServerJoin();
5694 application.sendServerData();
5695 application.displayLeaderboard('');
5696 if (window.master && window.master.onConnect) {
5697 window.master.onConnect();
5698 }
5699 },
5700 onOpen() {
5701 console.log(`[OGARio by szymy] Game server socket open`);
5702 this.time = Date.now();
5703 let view = this.createView(5);
5704 view.setUint8(0, 254);
5705 if(!window.game.protocolVersion) window.game.protocolVersion = 21
5706 view.setUint32(1, 21, true);
5707 this.sendMessage(view);
5708 view = this.createView(5);
5709 view.setUint8(0, 255);
5710 if(!window.game.clientVersion) window.game.clientVersion = this.clientVersion
5711 view.setUint32(1, this.clientVersion, true);
5712 this.sendMessage(view);
5713 this.connectionOpened = true;
5714 },
5715 onMessage(message) {
5716 message = new DataView(message.data);
5717 if (this.protocolKey) {
5718 message = this.shiftMessage(message, this.protocolKey ^ this.clientVersion);
5719 }
5720 this.handleMessage(message);
5721 },
5722 onError() {
5723 console.log(`[OGARio by szymy] Game server socket error`);
5724 this.flushCellsData();
5725 if (window.master && window.master.onDisconnect) {
5726 window.master.onDisconnect();
5727 }
5728 },
5729 onClose() {
5730 console.log('[OGARio by szymy] Game server socket close');
5731 this.flushCellsData();
5732 if (window.master && window.master.onDisconnect) {
5733 window.master.onDisconnect();
5734 }
5735 },
5736 closeConnection() {
5737 if (this.socket) {
5738 this.socket.onopen = null;
5739 this.socket.onmessage = null;
5740 this.socket.onerror = null;
5741 this.socket.onclose = null;
5742 try {
5743 this.socket.close();
5744 } catch (error) {}
5745 this.socket = null;
5746 this.ws = null;
5747 }
5748 },
5749 isSocketOpen() {
5750 return this.socket !== null && this.socket.readyState === this.socket.OPEN;
5751 },
5752 writeUint32(data, value) {
5753 while (true) {
5754 if ((value & -128) == 0) {
5755 data.push(value);
5756 return;
5757 } else {
5758 data.push(value & 127 | 128);
5759 value = value >>> 7;
5760 }
5761 }
5762 },
5763 createView(value) {
5764 return new DataView(new ArrayBuffer(value));
5765 },
5766 sendBuffer(data) {
5767 this.socket.send(data.buffer);
5768 },
5769 sendMessage(message) {
5770 if (this.connectionOpened) {
5771 if (!this.clientKey) {
5772 return;
5773 }
5774 message = this.shiftMessage(message, this.clientKey);
5775 this.clientKey = this.shiftKey(this.clientKey);
5776 }
5777 this.sendBuffer(message);
5778 },
5779 sendAction(action) {
5780 if (!this.isSocketOpen()) {
5781 return;
5782 }
5783 const view = this.createView(1);
5784 view.setUint8(0, action);
5785 this.sendMessage(view);
5786 },
5787 sendSpectate() {
5788 this.sendAction(1);
5789 },
5790 sendFreeSpectate() {
5791 this.sendAction(18);
5792 },
5793 sendEject() {
5794 this.sendPosition();
5795 this.sendAction(21);
5796 },
5797 sendSplit() {
5798 this.sendPosition();
5799 this.sendAction(17);
5800 },
5801 sendNick(nick) {
5802 this.playerNick = nick;
5803 nick = window.unescape(window.encodeURIComponent(nick));
5804 const view = this.createView(2 + nick.length);
5805 for (let length = 0; length < nick.length; length++) {
5806 view.setUint8(length + 1, nick.charCodeAt(length));
5807 }
5808 this.sendMessage(view);
5809 },
5810 sendPosition() {
5811 if (!this.isSocketOpen() || !this.connectionOpened || !this.clientKey) {
5812 return;
5813 }
5814 let cursorX = this.cursorX;
5815 let cursorY = this.cursorY;
5816 window.user.mouseX = cursorX - window.user.offsetX
5817 window.user.mouseY = cursorY - window.user.offsetY
5818 if(window.user.startedBots && window.user.isAlive) window.connection.send(window.buffers.mousePosition(window.user.mouseX, window.user.mouseY))
5819 if (!this.play && this.targeting || this.pause) {
5820 cursorX = this.targetX;
5821 cursorY = this.targetY;
5822 }
5823 const view = this.createView(13);
5824 view.setUint8(0, 16);
5825 view.setInt32(1, cursorX, true);
5826 view.setInt32(5, cursorY, true);
5827 view.setUint32(9, this.protocolKey, true);
5828 this.sendMessage(view);
5829 },
5830 sendAccessToken(shapes, options, oW) {
5831 if (this.accessTokenSent) {
5832 return;
5833 }
5834 if (!oW) {
5835 oW = 102;
5836 }
5837 const curr = shapes.length;
5838 const count = this.clientVersionString.length;
5839 let data = [oW, 8, 1, 18];
5840 this.writeUint32(data, curr + count + 23);
5841 data.push(8, 10, 82);
5842 this.writeUint32(data, curr + count + 18);
5843 data.push(8, options, 18, count + 8, 8, 5, 18, count);
5844 for (var length = 0; length < count; length++) {
5845 data.push(this.clientVersionString.charCodeAt(length));
5846 }
5847 data.push(24, 0, 32, 0, 26);
5848 this.writeUint32(data, curr + 3);
5849 data.push(10);
5850 this.writeUint32(data, curr);
5851 for (length = 0; length < curr; length++) {
5852 data.push(shapes.charCodeAt(length));
5853 }
5854 data = new Uint8Array(data);
5855 const dataView = new DataView(data.buffer);
5856 this.sendMessage(dataView);
5857 },
5858 sendFbToken(token) {
5859 this.sendAccessToken(token, 2);
5860 },
5861 sendGplusToken(token) {
5862 this.sendAccessToken(token, 4);
5863 },
5864 sendRecaptcha(token) {
5865 const view = this.createView(2 + token.length);
5866 view.setUint8(0, 86);
5867 for (let length = 0; length < token.length; length++) {
5868 view.setUint8(1 + length, token.charCodeAt(length));
5869 }
5870 view.setUint8(token.length + 1, 0);
5871 this.sendMessage(view);
5872 },
5873 setClientVersion(version, string) {
5874 this.clientVersion = version;
5875 this.clientVersionString = string;
5876 console.log(`[OGARio by szymy] Client version:`, version, string);
5877 },
5878 generateClientKey(ip, options) {
5879 if (!ip.length || !options.byteLength) {
5880 return null;
5881 }
5882 let x = null;
5883 const Length = 1540483477;
5884 const ipCheck = ip.match(/(ws+:\/\/)([^:]*)(:\d+)/)[2];
5885 const newLength = ipCheck.length + options.byteLength;
5886 const uint8Arr = new Uint8Array(newLength);
5887 for (let length = 0; length < ipCheck.length; length++) {
5888 uint8Arr[length] = ipCheck.charCodeAt(length);
5889 }
5890 uint8Arr.set(options, ipCheck.length);
5891 const dataview = new DataView(uint8Arr.buffer);
5892 let type = newLength - 1;
5893 const value = (type - 4 & -4) + 4 | 0;
5894 let newValue = type ^ 255;
5895 let offset = 0;
5896 while (type > 3) {
5897 x = Math.imul(dataview.getInt32(offset, true), Length) | 0;
5898 newValue = (Math.imul(x >>> 24 ^ x, Length) | 0) ^ (Math.imul(newValue, Length) | 0);
5899 type -= 4;
5900 offset += 4;
5901 }
5902 switch (type) {
5903 case 3:
5904 newValue = uint8Arr[value + 2] << 16 ^ newValue;
5905 newValue = uint8Arr[value + 1] << 8 ^ newValue;
5906 break;
5907 case 2:
5908 newValue = uint8Arr[value + 1] << 8 ^ newValue;
5909 break;
5910 case 1:
5911 break;
5912 default:
5913 x = newValue;
5914 break;
5915 }
5916 if (x != newValue) {
5917 x = Math.imul(uint8Arr[value] ^ newValue, Length) | 0;
5918 }
5919 newValue = x >>> 13;
5920 x = newValue ^ x;
5921 x = Math.imul(x, Length) | 0;
5922 newValue = x >>> 15;
5923 x = newValue ^ x;
5924 console.log(`[OGARio by szymy] Generated client key:`, x);
5925 return x;
5926 },
5927 shiftKey(key) {
5928 const value = 1540483477;
5929 key = Math.imul(key, value) | 0;
5930 key = (Math.imul(key >>> 24 ^ key, value) | 0) ^ 114296087;
5931 key = Math.imul(key >>> 13 ^ key, value) | 0;
5932 return key >>> 15 ^ key;
5933 },
5934 shiftMessage(view, key, write) {
5935 if (!write) {
5936 for (var length = 0; length < view.byteLength; length++) {
5937 view.setUint8(length, view.getUint8(length) ^ key >>> length % 4 * 8 & 255);
5938 }
5939 } else {
5940 for (var length = 0; length < view.length; length++) {
5941 view.writeUInt8(view.readUInt8(length) ^ key >>> length % 4 * 8 & 255, length);
5942 }
5943 }
5944 return view;
5945 },
5946 decompressMessage(message) {
5947 const buffer = window.buffer.Buffer;
5948 const messageBuffer = new buffer(message.buffer);
5949 const readMessage = new buffer(messageBuffer.readUInt32LE(1));
5950 LZ4.decodeBlock(messageBuffer.slice(5), readMessage);
5951 return readMessage;
5952 },
5953 handleMessage(view) {
5954 const encode = () => {
5955 for (var text = '';;) {
5956 const string = view.getUint8(offset++);
5957 if (string == 0) {
5958 break;
5959 }
5960 text += String.fromCharCode(string);
5961 }
5962 return text;
5963 };
5964 var offset = 0;
5965 let opCode = view.getUint8(offset++);
5966 if (opCode == 54) {
5967 opCode = 53;
5968 }
5969 switch (opCode) {
5970 case 5:
5971 break;
5972 case 17:
5973 this.viewX = view.getFloat32(offset, true);
5974 offset += 4;
5975 this.viewY = view.getFloat32(offset, true);
5976 offset += 4;
5977 this.scale = view.getFloat32(offset, true);
5978 break;
5979 case 18:
5980 if (this.protocolKey) {
5981 this.protocolKey = this.shiftKey(this.protocolKey);
5982 }
5983 this.flushCellsData();
5984 break;
5985 case 32:
5986 this.playerCellIDs.push(view.getUint32(offset, true));
5987 if (!this.play) {
5988 this.play = true;
5989 application.hideMenu();
5990 this.playerColor = null;
5991 application.onPlayerSpawn();
5992 window.user.isAlive = true
5993 if(window.user.startedBots) window.connection.send(new Uint8Array([5, Number(window.user.isAlive)]).buffer)
5994 }
5995 break;
5996 case 50:
5997 this.pieChart = [];
5998 const pieLength = view.getUint32(offset, true);
5999 offset += 4;
6000 for (var length = 0; length < pieLength; length++) {
6001 this.pieChart.push(view.getFloat32(offset, true));
6002 offset += 4;
6003 }
6004 drawRender.drawPieChart();
6005 break;
6006 case 53:
6007 this.leaderboard = [];
6008 this.playerPosition = 0;
6009 if (view.getUint8(0) == 54) {
6010 const pos = view.getUint16(offset, true);
6011 offset += 2;
6012 }
6013 for (let position = 0; offset < view.byteLength;) {
6014 var flags = view.getUint8(offset++);
6015 let nick = '';
6016 let id = 0;
6017 let isFriend = false;
6018 position++;
6019 if (flags & 2) {
6020 nick = window.decodeURIComponent(window.escape(encode()));
6021 }
6022 if (flags & 4) {
6023 id = view.getUint32(offset, true);
6024 offset += 4;
6025 }
6026 if (flags & 8) {
6027 nick = this.playerNick;
6028 id = `isPlayer`;
6029 this.playerPosition = position;
6030 }
6031 if (flags & 16) {
6032 isFriend = true;
6033 }
6034 this.leaderboard.push({
6035 nick: nick,
6036 id: id,
6037 isFriend: isFriend
6038 });
6039 }
6040 this.handleLeaderboard();
6041 break;
6042 case 54:
6043 break;
6044 case 69:
6045 const cellLength = view.getUint16(offset, true);
6046 offset += 2;
6047 this.ghostCells = [];
6048 for (var length = 0; length < cellLength; length++) {
6049 offset += 8;
6050 const mass = view.getUint32(offset, true);
6051 offset += 5;
6052 this.ghostCells.push({
6053 mass: mass
6054 });
6055 }
6056 break;
6057 case 85:
6058 console.log(`[OGARio by szymy] Captcha requested`);
6059 if (window.master && window.master.recaptchaRequested) {
6060 window.master.recaptchaRequested();
6061 }
6062 break;
6063 case 102:
6064 const node = new Node(view, offset);
6065 var flags = node.readFlag();
6066 if (flags == 1) {
6067 node.setContentType();
6068 }
6069 flags = node.readFlag();
6070 if (flags == 2) {
6071 node.setUncompressedSize();
6072 }
6073 flags = node.readFlag();
6074 if (flags == 1) {
6075 const option = node.readUint32();
6076 const response = node.readFlag();
6077 const response_2 = node.readUint32();
6078 switch (option) {
6079 case 11:
6080 console.log(`102 login response`, node.view.byteLength, node.contentType, node.uncompressedSize, option, response, response_2);
6081 break;
6082 case 62:
6083 console.log('102 game over');
6084 break;
6085 default:
6086 console.log('102 unknown', option, response);
6087 }
6088 }
6089 if (view.byteLength < 20) {
6090 this.loggedIn = false;
6091 window.logout && window.logout();
6092 }
6093 break;
6094 case 103:
6095 this.accessTokenSent = true;
6096 break;
6097 case 114:
6098 break;
6099 case 161:
6100 break;
6101 case 176:
6102 this.battleRoyale.startTime = view.getUint32(offset, true);
6103 break;
6104 case 177:
6105 this.battleRoyale.joined = true;
6106 break;
6107 case 178:
6108 this.battleRoyale.players = view.getUint16(offset, true);
6109 offset += 2;
6110 var flags = view.getUint16(offset, true);
6111 offset += 2;
6112 if (!flags) {
6113 this.battleRoyale.state = 0;
6114 this.battleRoyale.joined = false;
6115 }
6116 if (flags & 3) {
6117 this.battleRoyale.state = view.getUint8(offset++);
6118 this.battleRoyale.x = view.getInt32(offset, true);
6119 offset += 4;
6120 this.battleRoyale.y = view.getInt32(offset, true);
6121 offset += 4;
6122 this.battleRoyale.radius = view.getUint32(offset, true);
6123 offset += 4;
6124 this.battleRoyale.shrinkTime = view.getUint32(offset, true) * 1000;
6125 offset += 4;
6126 if (this.battleRoyale.shrinkTime) {
6127 this.battleRoyale.timeLeft = ~~((this.battleRoyale.shrinkTime - Date.now() + this.serverTimeDiff) / 1000);
6128 if (this.battleRoyale.timeLeft < 0) {
6129 this.battleRoyale.timeLeft = 0;
6130 }
6131 }
6132 }
6133 if (flags & 2) {
6134 this.battleRoyale.targetX = view.getInt32(offset, true);
6135 offset += 4;
6136 this.battleRoyale.targetY = view.getInt32(offset, true);
6137 offset += 4;
6138 this.battleRoyale.targetRadius = view.getUint32(offset, true);
6139 }
6140 break;
6141 case 179:
6142 var flags = view.getUint8(offset);
6143 const string = window.decodeURIComponent(window.escape(encode()));
6144 let test = null;
6145 if (!flags) {
6146 test = window.decodeURIComponent(window.escape(encode()));
6147 }
6148 break;
6149 case 180:
6150 this.battleRoyale.joined = false;
6151 this.battleRoyale.rank = [];
6152 this.battleRoyale.playerRank = view.getUint32(offset, true);
6153 offset += 8;
6154 const royaleLength = view.getUint16(offset, true);
6155 offset += 2;
6156 for (var length = 0; length < royaleLength; length++) {
6157 const name = window.decodeURIComponent(window.escape(encode()));
6158 const place = view.getUint32(offset, true);
6159 offset += 4;
6160 this.battleRoyale.rank.push({
6161 place: place,
6162 name: name
6163 });
6164 }
6165 break;
6166 case 226:
6167 const ping = view.getUint16(1, true);
6168 view = this.createView(3);
6169 view.setUint8(0, 227);
6170 view.setUint16(1, ping);
6171 this.sendMessage(view);
6172 break;
6173 case 241:
6174 this.protocolKey = view.getUint32(offset, true);
6175 console.log('[OGARio by szymy] Received protocol key:', this.protocolKey);
6176 const agarioReader = new Uint8Array(view.buffer, offset += 4);
6177 this.clientKey = this.generateClientKey(this.ws, agarioReader);
6178 if (window.master && window.master.login) {
6179 window.master.login();
6180 }
6181 break;
6182 case 242:
6183 this.serverTime = view.getUint32(offset, true) * 1000;
6184 this.serverTimeDiff = Date.now() - this.serverTime;
6185 break;
6186 case 255:
6187 this.handleSubmessage(view);
6188 break;
6189 default:
6190 console.log(`[OGARio by szymy] Unknown opcode:`, view.getUint8(0));
6191 break;
6192 }
6193 },
6194 handleSubmessage(message) {
6195 message = this.decompressMessage(message);
6196 let offset = 0;
6197 switch (message.readUInt8(offset++)) {
6198 case 16:
6199 this.updateCells(message, offset);
6200 break;
6201 case 64:
6202 this.viewMinX = message.readDoubleLE(offset);
6203 offset += 8;
6204 this.viewMinY = message.readDoubleLE(offset);
6205 offset += 8;
6206 this.viewMaxX = message.readDoubleLE(offset);
6207 offset += 8;
6208 this.viewMaxY = message.readDoubleLE(offset);
6209 this.setMapOffset(this.viewMinX, this.viewMinY, this.viewMaxX, this.viewMaxY);
6210 if(~~(this.viewMaxX - this.viewMinX) === 14142 && ~~(this.viewMaxY - this.viewMinY) === 14142){
6211 window.user.offsetX = (this.viewMinX + this.viewMaxX) / 2
6212 window.user.offsetY = (this.viewMinY + this.viewMaxY) / 2
6213 }
6214 break;
6215 default:
6216 console.log(`[OGARio by szymy] Unknown sub opcode:`, message.readUInt8(0));
6217 break;
6218 }
6219 },
6220 handleLeaderboard() {
6221 let text = '';
6222 let teamText = '';
6223 for (var length = 0; length < this.leaderboard.length; length++) {
6224 if (length == 10) {
6225 break;
6226 }
6227 let html = '<span>';
6228 if (this.leaderboard[length].id === `isPlayer`) {
6229 html = `<span class="me">`;
6230 } else {
6231 if (mainProfile.clanTag.length && this.leaderboard[length].nick.indexOf(mainProfile.clanTag) == 0) {
6232 html = `<span class="teammate">`;
6233 }
6234 }
6235 text += `${html + (length + 1)}. ${application.escapeHTML(this.leaderboard[length].nick)}${`</span>`}`;
6236 }
6237 if (this.playerPosition > 10) {
6238 text += `<span class="me">${this.playerPosition}. ${application.escapeHTML(this.playerNick)}${`</span>`}`;
6239 }
6240 if (gameOptionSettings.showLbData) {
6241 for (var length = 0; length < this.ghostCells.length; length++) {
6242 if (length == length) {
6243 break;
6244 }
6245 teamText += '<span class="lb-data">';
6246 teamText += `<span class="top5-mass-color">[` + application.shortMassFormat(this.ghostCells[length].mass) + `]</span>`;
6247 teamText += `</span>`;
6248 }
6249 }
6250 application.displayLeaderboard(text, teamText);
6251 },
6252 flushCellsData() {
6253 this.indexedCells = {};
6254 this.cells = [];
6255 this.playerCells = [];
6256 this.playerCellIDs = [];
6257 this.ghostCells = [];
6258 this.food = [];
6259 this.viruses = [];
6260 },
6261 setMapOffset(left, top, right, bottom) {
6262 if (right - left > 14000 && bottom - top > 14000) {
6263 this.mapOffsetX = this.mapOffset - right;
6264 this.mapOffsetY = this.mapOffset - bottom;
6265 this.mapMinX = ~~(-this.mapOffset - this.mapOffsetX);
6266 this.mapMinY = ~~(-this.mapOffset - this.mapOffsetY);
6267 this.mapMaxX = ~~(this.mapOffset - this.mapOffsetX);
6268 this.mapMaxY = ~~(this.mapOffset - this.mapOffsetY);
6269 if (!this.mapOffsetFixed) {
6270 this.viewX = (right + left) / 2;
6271 this.viewY = (bottom + top) / 2;
6272 }
6273 this.mapOffsetFixed = true;
6274 console.log(`[OGARio by szymy] Map offset fixed (x, y):`, this.mapOffsetX, this.mapOffsetY);
6275 }
6276 },
6277 updateCells(view, offset) {
6278 const encode = () => {
6279 for (var text = '';;) {
6280 const string = view.readUInt8(offset++);
6281 if (string == 0) {
6282 break;
6283 }
6284 text += String.fromCharCode(string);
6285 }
6286 return text;
6287 };
6288 this.time = Date.now();
6289 this.removePlayerCell = false;
6290 let eatEventsLength = view.readUInt16LE(offset);
6291 offset += 2;
6292 for (var length = 0; length < eatEventsLength; length++) {
6293 const victimID = this.indexedCells[view.readUInt32LE(offset)];
6294 const eaterID = this.indexedCells[view.readUInt32LE(offset + 4)];
6295 offset += 8;
6296 if (victimID && eaterID) {
6297 eaterID.targetX = victimID.x;
6298 eaterID.targetY = victimID.y;
6299 eaterID.targetSize = eaterID.size;
6300 eaterID.time = this.time;
6301 eaterID.removeCell();
6302 }
6303 }
6304 for (length = 0;;) {
6305 var id = view.readUInt32LE(offset);
6306 offset += 4;
6307 if (id == 0) {
6308 break;
6309 }
6310 const x = view.readInt32LE(offset);
6311 offset += 4;
6312 const y = view.readInt32LE(offset);
6313 offset += 4;
6314 const size = view.readUInt16LE(offset);
6315 offset += 2;
6316 const flags = view.readUInt8(offset++);
6317 let extendedFlags = 0;
6318 if (flags & 128) {
6319 extendedFlags = view.readUInt8(offset++);
6320 }
6321 let color = null;
6322 let skin = null;
6323 let name = '';
6324 let accountID = null;
6325 if (flags & 2) {
6326 const r = view.readUInt8(offset++);
6327 const g = view.readUInt8(offset++);
6328 const b = view.readUInt8(offset++);
6329 color = this.rgb2Hex(~~(r * 0.9), ~~(g * 0.9), ~~(b * 0.9));
6330 }
6331 if (flags & 4) {
6332 skin = encode();
6333 }
6334 if (flags & 8) {
6335 name = window.decodeURIComponent(window.escape(encode()));
6336 }
6337 const isVirus = flags & 1;
6338 const isFood = extendedFlags & 1;
6339 var cell = null;
6340 if (this.indexedCells.hasOwnProperty(id)) {
6341 cell = this.indexedCells[id];
6342 if (color) {
6343 cell.color = color;
6344 }
6345 } else {
6346 cell = new Cell(id, x, y, size, color, isFood, isVirus, false, gameOptionSettings.shortMass, gameOptionSettings.virMassShots);
6347 cell.time = this.time;
6348 if (!isFood) {
6349 if (isVirus && gameOptionSettings.virusesRange) {
6350 this.viruses.push(cell);
6351 }
6352 this.cells.push(cell);
6353 if (this.playerCellIDs.indexOf(id) != -1 && this.playerCells.indexOf(cell) == -1) {
6354 cell.isPlayerCell = true;
6355 this.playerColor = color;
6356 this.playerCells.push(cell);
6357 }
6358 } else {
6359 this.food.push(cell);
6360 }
6361 this.indexedCells[id] = cell;
6362 }
6363 if (cell.isPlayerCell) {
6364 name = this.playerNick;
6365 }
6366 if (name) {
6367 cell.targetNick = name;
6368 }
6369 cell.targetX = x;
6370 cell.targetY = y;
6371 cell.targetSize = size;
6372 cell.isFood = isFood;
6373 cell.isVirus = isVirus;
6374 if (skin) {
6375 cell.skin = skin;
6376 }
6377 if (extendedFlags & 4) {
6378 accountID = view.readUInt32LE(offset);
6379 offset += 4;
6380 }
6381 }
6382 eatEventsLength = view.readUInt16LE(offset);
6383 offset += 2;
6384 for (length = 0; length < eatEventsLength; length++) {
6385 var id = view.readUInt32LE(offset);
6386 offset += 4;
6387 cell = this.indexedCells[id];
6388 if (cell) {
6389 cell.removeCell();
6390 }
6391 }
6392 if (this.removePlayerCell && !this.playerCells.length) {
6393 this.play = false;
6394 application.onPlayerDeath();
6395 application.showMenu(300);
6396 window.user.isAlive = false
6397 if(window.user.startedBots) window.connection.send(new Uint8Array([5, Number(window.user.isAlive)]).buffer)
6398 }
6399 },
6400 color2Hex(number) {
6401 const color = number.toString(16);
6402 return color.length == 1 ? `0${color}` : color;
6403 },
6404 rgb2Hex(r, g, b) {
6405 return `#${this.color2Hex(r)}${this.color2Hex(g)}${this.color2Hex(b)}`;
6406 },
6407 sortCells() {
6408 this.cells.sort((row, conf) => row.size == conf.size ? row.id - conf.id : row.size - conf.size);
6409 },
6410 calculatePlayerMassAndPosition() {
6411 let size = 0;
6412 let targetSize = 0;
6413 let x = 0;
6414 let y = 0;
6415 const playersLength = this.playerCells.length;
6416 for (let length = 0; length < playersLength; length++) {
6417 const currentPlayer = this.playerCells[length];
6418 size += currentPlayer.size;
6419 targetSize += currentPlayer.targetSize * currentPlayer.targetSize;
6420 x += currentPlayer.x / playersLength;
6421 y += currentPlayer.y / playersLength;
6422 }
6423 this.viewX = x;
6424 this.viewY = y;
6425 this.playerSize = size;
6426 this.playerMass = ~~(targetSize / 100);
6427 this.recalculatePlayerMass();
6428 },
6429 recalculatePlayerMass() {
6430 this.playerScore = Math.max(this.playerScore, this.playerMass);
6431 if (gameOptionSettings.virColors || gameOptionSettings.splitRange || gameOptionSettings.oppColors || gameOptionSettings.oppRings || gameOptionSettings.showStatsSTE) {
6432 const cells = this.playerCells;
6433 const CellLength = cells.length;
6434 cells.sort((row, conf) => row.size == conf.size ? row.id - conf.id : row.size - conf.size);
6435 this.playerMinMass = ~~(cells[0].size * cells[0].size / 100);
6436 this.playerMaxMass = ~~(cells[CellLength - 1].size * cells[CellLength - 1].size / 100);
6437 this.playerSplitCells = CellLength;
6438 }
6439 if (gameOptionSettings.showStatsSTE) {
6440 const mass = this.selectBiggestCell ? this.playerMaxMass : this.playerMinMass;
6441 if (mass > 35) {
6442 this.STE = ~~(mass * (mass < 1000 ? 0.35 : 0.38));
6443 } else {
6444 this.STE = null;
6445 }
6446 }
6447 },
6448 compareCells() {
6449 if (!this.play) {
6450 return;
6451 }
6452 if (gameOptionSettings.oppColors || gameOptionSettings.oppRings || gameOptionSettings.splitRange) {
6453 if (gameOptionSettings.oppRings || gameOptionSettings.splitRange) {
6454 this.biggerSTECellsCache = [];
6455 this.biggerCellsCache = [];
6456 this.smallerCellsCache = [];
6457 this.STECellsCache = [];
6458 }
6459
6460 for (const cell of this.cells) {
6461 if (cell.isVirus) {
6462 continue;
6463 }
6464 const size = ~~(cell.size * cell.size / 100);
6465 const mass = this.selectBiggestCell ? this.playerMaxMass : this.playerMinMass;
6466 const fixMass = size / mass;
6467 const smallMass = mass < 1000 ? 0.35 : 0.38;
6468 if (gameOptionSettings.oppColors && !gameOptionSettings.oppRings) {
6469 cell.oppColor = this.setCellOppColor(cell.isPlayerCell, fixMass, smallMass);
6470 }
6471 if (!cell.isPlayerCell && (gameOptionSettings.splitRange || gameOptionSettings.oppRings)) {
6472 this.cacheCells(cell.x, cell.y, cell.size, fixMass, smallMass);
6473 }
6474 }
6475 }
6476 },
6477 cacheCells(x, y, size, mass, smallMass) {
6478 if (mass >= 2.5) {
6479 this.biggerSTECellsCache.push({
6480 x: x,
6481 y: y,
6482 size: size
6483 });
6484 return;
6485 } else if (mass >= 1.25) {
6486 this.biggerCellsCache.push({
6487 x: x,
6488 y: y,
6489 size: size
6490 });
6491 return;
6492 } else if (mass < 1.25 && mass > 0.75) {
6493 return;
6494 } else if (mass > smallMass) {
6495 this.smallerCellsCache.push({
6496 x: x,
6497 y: y,
6498 size: size
6499 });
6500 return;
6501 } else {
6502 this.STECellsCache.push({
6503 x: x,
6504 y: y,
6505 size: size
6506 });
6507 return;
6508 }
6509 },
6510 setCellOppColor(isPlayer, mass, smallMass) {
6511 if (isPlayer) {
6512 return mainProfile.color;
6513 }
6514 if (mass > 11) {
6515 return `#FF008C`;
6516 } else if (mass >= 2.5) {
6517 return `#BE00FF`;
6518 } else if (mass >= 1.25) {
6519 return `#FF0A00`;
6520 } else if (mass < 1.25 && mass > 0.75) {
6521 return `#FFDC00`;
6522 } else if (mass > smallMass) {
6523 return `#00C8FF`;
6524 } else {
6525 return `#64FF00`;
6526 }
6527 },
6528 getCursorPosition() {
6529 this.cursorX = (this.clientX - this.canvasWidth / 2) / this.viewScale + this.viewX;
6530 this.cursorY = (this.clientY - this.canvasHeight / 2) / this.viewScale + this.viewY;
6531 },
6532 setZoom(event) {
6533 this.zoomValue *= gameOptionSettings.zoomSpeedValue ** (event.wheelDelta / -120 || event.detail || 0);
6534 if (this.zoomValue > 4 / this.viewScale) {
6535 this.zoomValue = 4 / this.viewScale;
6536 }
6537 },
6538 setTargetPosition(x, y) {
6539 this.targetX = x - this.mapOffsetX;
6540 this.targetY = y - this.mapOffsetY;
6541 this.targetDistance = Math.round(Math.sqrt((this.playerX - this.targetX) ** 2 + (this.playerY - this.targetY) ** 2));
6542 },
6543 resetTargetPosition() {
6544 this.targetX = this.playerX;
6545 this.targetY = this.playerY;
6546 },
6547 setKeys() {
6548 const app = this;
6549 document.onkeydown = event => {
6550 const key = event.keyCode;
6551 if (app.pressedKeys[key]) {
6552 return;
6553 }
6554 switch (key) {
6555 case 13:
6556 app.sendNick('');
6557 break;
6558 case 32:
6559 app.sendSplit();
6560 break;
6561 case 81:
6562 app.sendFreeSpectate();
6563 break;
6564 case 83:
6565 app.sendSpectate();
6566 break;
6567 case 87:
6568 app.sendEject();
6569 break;
6570 }
6571 };
6572 document.onkeyup = event => {
6573 app.pressedKeys[event.keyCode] = false;
6574 };
6575 },
6576 init() {
6577 const app = this;
6578 if (/firefox/i .test(navigator.userAgent)) {
6579 document.addEventListener(`DOMMouseScroll`, value => {
6580 app.setZoom(value);
6581 }, false);
6582 } else {
6583 document.body.onmousewheel = value => {
6584 app.setZoom(value);
6585 };
6586 }
6587 setInterval(() => {
6588 app.sendPosition();
6589 }, 40);
6590 if (window.master && window.master.clientVersion) {
6591 this.setClientVersion(window.master.clientVersion, window.master.clientVersionString);
6592 }
6593 }
6594 };
6595 window.sendAction = action => {
6596 Connection.sendAction(action);
6597 };
6598 var drawRender = {
6599 canvas: null,
6600 ctx: null,
6601 canvasWidth: 0,
6602 canvasHeight: 0,
6603 camX: 0,
6604 camY: 0,
6605 scale: 1,
6606 fpsLastRequest: null,
6607 renderedFrames: 0,
6608 fps: 0,
6609 pi2: 2 * Math.PI,
6610 battleAreaMap: null,
6611 battleAreaMapCtx: null,
6612 pieChart: null,
6613 pellet: null,
6614 indicator: null,
6615 setCanvas() {
6616 this.canvas = document.getElementById(`canvas`);
6617 this.ctx = this.canvas.getContext('2d');
6618 this.canvas.onmousemove = event => {
6619 Connection.clientX = event.clientX;
6620 Connection.clientY = event.clientY;
6621 Connection.getCursorPosition();
6622 };
6623 },
6624 resizeCanvas() {
6625 this.canvasWidth = window.innerWidth;
6626 this.canvasHeight = window.innerHeight;
6627 this.canvas.width = this.canvasWidth;
6628 this.canvas.height = this.canvasHeight;
6629 Connection.canvasWidth = this.canvasWidth;
6630 Connection.canvasHeight = this.canvasHeight;
6631 this.renderFrame();
6632 },
6633 setView() {
6634 this.setScale();
6635 if (Connection.playerCells.length) {
6636 Connection.calculatePlayerMassAndPosition();
6637 this.camX = (this.camX + Connection.viewX) / 2;
6638 this.camY = (this.camY + Connection.viewY) / 2;
6639 } else {
6640 this.camX = (29 * this.camX + Connection.viewX) / 30;
6641 this.camY = (29 * this.camY + Connection.viewY) / 30;
6642 }
6643 Connection.playerX = this.camX;
6644 Connection.playerY = this.camY;
6645 },
6646 setScale() {
6647 if (!Connection.autoZoom) {
6648 this.scale = (9 * this.scale + this.getZoom()) / 10;
6649 Connection.viewScale = this.scale;
6650 return;
6651 }
6652 if (Connection.play) {
6653 this.scale = (9 * this.scale + Math.min(64 / Connection.playerSize, 1) ** 0.4 * this.getZoom()) / 10;
6654 } else {
6655 this.scale = (9 * this.scale + Connection.scale * this.getZoom()) / 10;
6656 }
6657 Connection.viewScale = this.scale;
6658 },
6659 getZoom() {
6660 return Math.max(this.canvasWidth / 1080, this.canvasHeight / 1920) * Connection.zoomValue;
6661 },
6662 renderFrame() {
6663 Connection.time = Date.now();
6664 for (length = 0; length < Connection.cells.length; length++) {
6665 Connection.cells[length].moveCell();
6666 }
6667 this.setView();
6668 Connection.getCursorPosition();
6669 Connection.sortCells();
6670 Connection.compareCells();
6671 this.ctx.clearRect(0, 0, this.canvasWidth, this.canvasHeight);
6672 if (gameOptionSettings.showGrid) {
6673 this.drawGrid(this.ctx, this.canvasWidth, this.canvasHeight, this.scale, this.camX, this.camY);
6674 }
6675 this.ctx.save();
6676 this.ctx.translate(this.canvasWidth / 2, this.canvasHeight / 2);
6677 this.ctx.scale(this.scale, this.scale);
6678 this.ctx.translate(-this.camX, -this.camY);
6679 if (gameOptionSettings.showBgSectors) {
6680 this.drawSectors(this.ctx, Connection.mapOffsetFixed, gameSetupTheme.sectorsX, gameSetupTheme.sectorsY, Connection.mapMinX, Connection.mapMinY, Connection.mapMaxX, Connection.mapMaxY, gameSetupTheme.gridColor, gameSetupTheme.sectorsColor, gameSetupTheme.sectorsWidth, true);
6681 }
6682 if (Connection.gameMode === ':battleroyale') {
6683 this.drawBattleArea(this.ctx);
6684 }
6685 if (gameOptionSettings.showMapBorders) {
6686 const borderWidth = gameSetupTheme.bordersWidth / 2;
6687 this.drawMapBorders(this.ctx, Connection.mapOffsetFixed, Connection.mapMinX - borderWidth, Connection.mapMinY - borderWidth, Connection.mapMaxX + borderWidth, Connection.mapMaxY + borderWidth, gameSetupTheme.bordersColor, gameSetupTheme.bordersWidth);
6688 }
6689 if (gameOptionSettings.virusesRange) {
6690 this.drawVirusesRange(this.ctx, Connection.viruses);
6691 }
6692 this.drawFood();
6693 if (Connection.play) {
6694 if (gameOptionSettings.splitRange) {
6695 this.drawSplitRange(this.ctx, Connection.biggerSTECellsCache, Connection.playerCells, Connection.selectBiggestCell);
6696 }
6697 if (gameOptionSettings.oppRings) {
6698 this.drawOppRings(this.ctx, this.scale, Connection.biggerSTECellsCache, Connection.biggerCellsCache, Connection.smallerCellsCache, Connection.STECellsCache);
6699 }
6700 if (gameOptionSettings.cursorTracking) {
6701 this.drawCursorTracking(this.ctx, Connection.playerCells, Connection.cursorX, Connection.cursorY);
6702 }
6703 }
6704 for (var length = 0; length < Connection.removedCells.length; length++) {
6705 Connection.removedCells[length].draw(this.ctx, true);
6706 }
6707 for (length = 0; length < Connection.cells.length; length++) {
6708 Connection.cells[length].draw(this.ctx);
6709 }
6710 this.ctx.restore();
6711 if (Connection.gameMode === `:teams`) {
6712 if (this.pieChart && this.pieChart.width) {
6713 this.ctx.drawImage(this.pieChart, this.canvasWidth - this.pieChart.width - 10, 10);
6714 }
6715 }
6716 },
6717 drawGrid(ctx, width, heigth, scale, camX, camY) {
6718 const reWidth = width / scale;
6719 const reHeigth = heigth / scale;
6720 let x = (-camX + reWidth / 2) % 50;
6721 let y = (-camY + reHeigth / 2) % 50;
6722 ctx.strokeStyle = gameSetupTheme.gridColor;
6723 ctx.globalAlpha = 1 * scale;
6724 ctx.beginPath();
6725 for (; x < reWidth; x += 50) {
6726 ctx.moveTo(x * scale - 0.5, 0);
6727 ctx.lineTo(x * scale - 0.5, reHeigth * scale);
6728 }
6729 for (; y < reHeigth; y += 50) {
6730 ctx.moveTo(0, y * scale - 0.5);
6731 ctx.lineTo(reWidth * scale, y * scale - 0.5);
6732 }
6733 ctx.stroke();
6734 ctx.globalAlpha = 1;
6735 },
6736 drawSectors(ctx, mapOffset, x, y, minX, minY, maxX, maxY, stroke, color, width, type) {
6737 if (!mapOffset && type) {
6738 return;
6739 }
6740 const posX = ~~((maxX - minX) / x);
6741 const posY = ~~((maxY - minY) / y);
6742 let rePosX = 0;
6743 let rePosY = 0;
6744 ctx.strokeStyle = stroke;
6745 ctx.fillStyle = color;
6746 ctx.lineWidth = width;
6747 if (type || !type && gameOptionSettings.showMiniMapGrid) {
6748 ctx.beginPath();
6749 for (var length = 0; length < x + 1; length++) {
6750 rePosX = minX + posX * length;
6751 ctx.moveTo(length == x ? maxX : rePosX, minY);
6752 ctx.lineTo(length == x ? maxX : rePosX, maxY);
6753 }
6754 for (var length = 0; length < y + 1; length++) {
6755 rePosY = minY + posY * length;
6756 ctx.moveTo(minX - width / 2, length == y ? maxY : rePosY);
6757 ctx.lineTo(maxX + width / 2, length == y ? maxY : rePosY);
6758 }
6759 ctx.stroke();
6760 } else {
6761 this.drawMapBorders(ctx, mapOffset, minX, minY, maxX, maxY, stroke, width);
6762 }
6763 if (type) {
6764 ctx.font = `${gameSetupTheme.sectorsFontWeight} ${gameSetupTheme.sectorsFontSize}${`px `}${gameSetupTheme.sectorsFontFamily}`;
6765 } else {
6766 ctx.font = `${gameSetupTheme.miniMapFontWeight} ${~~(0.4 * posY)}${`px `}${gameSetupTheme.miniMapFontFamily}`;
6767 }
6768 ctx.textAlign = 'center';
6769 ctx.textBaseline = `middle`;
6770 for (var length = 0; length < y; length++) {
6771 for (let length_2 = 0; length_2 < x; length_2++) {
6772 const text = String.fromCharCode(65 + length) + (length_2 + 1);
6773 rePosX = ~~(minX + posX / 2 + length_2 * posX);
6774 rePosY = ~~(minY + posY / 2 + length * posY);
6775 ctx.fillText(text, rePosX, rePosY);
6776 }
6777 }
6778 },
6779 drawMapBorders(ctx, mapOffset, minX, minY, maxX, maxY, stroke, width) {
6780 if (!mapOffset) {
6781 return;
6782 }
6783 ctx.strokeStyle = stroke;
6784 ctx.lineWidth = width;
6785 ctx.beginPath();
6786 ctx.moveTo(minX, minY);
6787 ctx.lineTo(maxX, minY);
6788 ctx.lineTo(maxX, maxY);
6789 ctx.lineTo(minX, maxY);
6790 ctx.closePath();
6791 ctx.stroke();
6792 },
6793 drawVirusesRange(ctx, viruses, reset) {
6794 if (!viruses.length) {
6795 return;
6796 }
6797 ctx.beginPath();
6798 for (let length = 0; length < viruses.length; length++) {
6799 const x = viruses[length].x;
6800 const y = viruses[length].y;
6801 ctx.moveTo(x, y);
6802 ctx.arc(x, y, viruses[length].size + 820, 0, this.pi2, false);
6803 }
6804 ctx.fillStyle = gameSetupTheme.virusColor;
6805 ctx.globalAlpha = 0.1;
6806 ctx.fill();
6807 ctx.globalAlpha = 1;
6808 if (reset) {
6809 viruses = [];
6810 }
6811 },
6812 drawFood() {
6813 if (!Connection.showFood || gameOptionSettings.autoHideFoodOnZoom && this.scale < 0.2) {
6814 return;
6815 }
6816 if (gameOptionSettings.autoHideFood && !Connection.foodIsHidden && Connection.playerMass > 1000) {
6817 Connection.showFood = false;
6818 Connection.foodIsHidden = true;
6819 return;
6820 }
6821 if (!gameOptionSettings.rainbowFood) {
6822 this.drawCachedFood(this.ctx, Connection.food, this.scale);
6823 return;
6824 }
6825 for (let length = 0; length < Connection.food.length; length++) {
6826 Connection.food[length].moveCell();
6827 Connection.food[length].draw(this.ctx);
6828 }
6829 },
6830 drawCachedFood(ctx, food, scale, reset) {
6831 if (!food.length) {
6832 return;
6833 }
6834 if (gameOptionSettings.optimizedFood && this.pellet) {
6835 for (var length = 0; length < food.length; length++) {
6836 var x = food[length].x - 10 - gameSetupTheme.foodSize;
6837 var y = food[length].y - 10 - gameSetupTheme.foodSize;
6838 ctx.drawImage(this.pellet, x, y);
6839 }
6840 } else {
6841 ctx.beginPath();
6842 for (var length = 0; length < food.length; length++) {
6843 var x = food[length].x;
6844 var y = food[length].y;
6845 ctx.moveTo(x, y);
6846 if (scale < 0.16) {
6847 const size = food[length].size + gameSetupTheme.foodSize;
6848 ctx.rect(x - size, y - size, 2 * size, 2 * size);
6849 continue;
6850 }
6851 ctx.arc(x, y, food[length].size + gameSetupTheme.foodSize, 0, this.pi2, false);
6852 }
6853 ctx.fillStyle = gameSetupTheme.foodColor;
6854 ctx.globalAlpha = 1;
6855 ctx.fill();
6856 }
6857 if (reset) {
6858 food = [];
6859 }
6860 },
6861 drawSplitRange(ctx, biggestCell, players, currentBiggestCell, reset) {
6862 this.drawCircles(ctx, biggestCell, 760, 4, 0.4, `#BE00FF`);
6863 if (players.length) {
6864 const current = currentBiggestCell ? players.length - 1 : 0;
6865 ctx.lineWidth = 6;
6866 ctx.globalAlpha = gameSetupTheme.darkTheme ? 0.7 : 0.35;
6867 ctx.strokeStyle = gameSetupTheme.splitRangeColor;
6868 ctx.beginPath();
6869 ctx.arc(players[current].x, players[current].y, players[current].size + 760, 0, this.pi2, false);
6870 ctx.closePath();
6871 ctx.stroke();
6872 }
6873 ctx.globalAlpha = 1;
6874 if (reset) {
6875 biggestCell = [];
6876 }
6877 },
6878 drawOppRings(ctx, scale, biggerSte, biggetCell, smallerCell, smallSte, reset) {
6879 const width = 14 + 2 / scale;
6880 const alpha = 12 + 1 / scale;
6881 this.drawCircles(ctx, biggerSte, width, alpha, 0.75, `#BE00FF`);
6882 this.drawCircles(ctx, biggetCell, width, alpha, 0.75, `#FF0A00`);
6883 this.drawCircles(ctx, smallerCell, width, alpha, 0.75, '#00C8FF');
6884 this.drawCircles(ctx, smallSte, width, alpha, 0.75, `#64FF00`);
6885 if (reset) {
6886 biggerSte = [];
6887 biggetCell = [];
6888 smallerCell = [];
6889 smallSte = [];
6890 }
6891 },
6892 drawCursorTracking(ctx, players, cursorX, cursorY) {
6893 ctx.lineWidth = 4;
6894 ctx.globalAlpha = gameSetupTheme.darkTheme ? 0.75 : 0.35;
6895 ctx.strokeStyle = gameSetupTheme.cursorTrackingColor;
6896 ctx.beginPath();
6897 for (let length = 0; length < players.length; length++) {
6898 ctx.moveTo(players[length].x, players[length].y);
6899 ctx.lineTo(cursorX, cursorY);
6900 }
6901 ctx.stroke();
6902 ctx.globalAlpha = 1;
6903 },
6904 drawCircles(ctx, players, scale, width, alpha, stroke) {
6905 ctx.lineWidth = width;
6906 ctx.globalAlpha = alpha;
6907 ctx.strokeStyle = stroke;
6908 for (let length = 0; length < players.length; length++) {
6909 ctx.beginPath();
6910 ctx.arc(players[length].x, players[length].y, players[length].size + scale, 0, this.pi2, false);
6911 ctx.closePath();
6912 ctx.stroke();
6913 }
6914 ctx.globalAlpha = 1;
6915 },
6916 drawDashedCircle(ctx, x, y, radius, times, width, color) {
6917 const pi2 = this.pi2 / times;
6918 ctx.lineWidth = width;
6919 ctx.strokeStyle = color;
6920 for (let length = 0; length < times; length += 2) {
6921 ctx.beginPath();
6922 ctx.arc(x, y, radius - width / 2, length * pi2, (length + 1) * pi2, false);
6923 ctx.stroke();
6924 }
6925 },
6926 drawTeammatesInd(ctx, x, y, size) {
6927 if (!this.indicator) {
6928 return;
6929 }
6930 ctx.drawImage(this.indicator, x - 45, y - size - 90);
6931 },
6932 drawPieChart() {
6933 if (!this.pieChart) {
6934 this.pieChart = document.createElement(`canvas`);
6935 }
6936 const ctx = this.pieChart.getContext('2d');
6937 const mincanvasWidth = Math.min(200, 0.3 * this.canvasWidth) / 200;
6938 this.pieChart.width = 200 * mincanvasWidth;
6939 this.pieChart.height = 240 * mincanvasWidth;
6940 ctx.scale(mincanvasWidth, mincanvasWidth);
6941 const colors = [`#333333`, '#FF3333', '#33FF33', `#3333FF`];
6942 for (let time = 0, length = 0; length < Connection.pieChart.length; length++) {
6943 const currentPie = time + Connection.pieChart[length] * this.pi2;
6944 ctx.fillStyle = colors[length + 1];
6945 ctx.beginPath();
6946 ctx.moveTo(100, 140);
6947 ctx.arc(100, 140, 80, time, currentPie, false);
6948 ctx.fill();
6949 time = currentPie;
6950 }
6951 },
6952 drawBattleArea(ctx) {
6953 if (!Connection.battleRoyale.state) {
6954 return;
6955 }
6956 this.drawDangerArea(ctx, Connection.battleRoyale.x, Connection.battleRoyale.y, Connection.battleRoyale.radius, Connection.mapMinX, Connection.mapMinY, Connection.mapMaxX - Connection.mapMinX, Connection.mapMaxY - Connection.mapMinY, gameSetupTheme.dangerAreaColor, 0.25);
6957 this.drawSafeArea(ctx, Connection.battleRoyale.targetX, Connection.battleRoyale.targetY, Connection.battleRoyale.targetRadius, 40, gameSetupTheme.safeAreaColor);
6958 },
6959 drawBattleAreaOnMinimap(ctx, width, heigth, newWidth, offsetX, offsetY) {
6960 if (!Connection.battleRoyale.state) {
6961 return;
6962 }
6963 if (!this.battleAreaMap) {
6964 this.battleAreaMap = document.createElement(`canvas`);
6965 this.battleAreaMapCtx = this.battleAreaMap.getContext('2d');
6966 }
6967 if (this.battleAreaMap.width != width) {
6968 this.battleAreaMap.width = width;
6969 this.battleAreaMap.height = heigth;
6970 } else {
6971 this.battleAreaMapCtx.clearRect(0, 0, width, heigth);
6972 }
6973 let newX = (Connection.battleRoyale.x + offsetX) * newWidth;
6974 let newY = (Connection.battleRoyale.y + offsetY) * newWidth;
6975 let newRadius = Connection.battleRoyale.radius * newWidth;
6976 this.drawDangerArea(this.battleAreaMapCtx, newX, newY, newRadius, 0, 0, width, heigth, gameSetupTheme.dangerAreaColor, 0.25);
6977 newX = ~~((Connection.battleRoyale.targetX + offsetX) * newWidth);
6978 newY = ~~((Connection.battleRoyale.targetY + offsetY) * newWidth);
6979 newRadius = ~~(Connection.battleRoyale.targetRadius * newWidth);
6980 this.drawSafeArea(this.battleAreaMapCtx, newX, newY, newRadius, 2, gameSetupTheme.safeAreaColor);
6981 ctx.drawImage(this.battleAreaMap, 0, 0);
6982 },
6983 drawDangerArea(ctx, x, y, radius, minX, minY, maxX, maxY, color, aplha) {
6984 if (Connection.battleRoyale.radius == Connection.battleRoyale.maxRadius || radius <= 0) {
6985 return;
6986 }
6987 ctx.save();
6988 ctx.globalAlpha = aplha;
6989 ctx.fillStyle = color;
6990 ctx.fillRect(minX, minY, maxX, maxY);
6991 ctx.globalCompositeOperation = 'destination-out';
6992 ctx.globalAlpha = 1;
6993 ctx.beginPath();
6994 ctx.arc(x, y, radius, 0, this.pi2, false);
6995 ctx.fill();
6996 ctx.restore();
6997 },
6998 drawSafeArea(ctx, targetX, targetY, radius, width, color) {
6999 if (Connection.battleRoyale.state > 2 || radius <= 0) {
7000 return;
7001 }
7002 this.drawDashedCircle(ctx, targetX, targetY, radius, 60, width, color);
7003 },
7004 drawGhostCells() {
7005 if (!gameOptionSettings.showGhostCells) {
7006 return;
7007 }
7008 const ghostsCells = Connection.ghostCells;
7009 this.ctx.beginPath();
7010 for (let length = 0; length < ghostsCells.length; length++) {
7011 if (ghostsCells[length].inView) {
7012 continue;
7013 }
7014 const x = ghostsCells[length].x;
7015 const y = ghostsCells[length].y;
7016 this.ctx.moveTo(x, y);
7017 this.ctx.arc(x, y, ghostsCells[length].size, 0, this.pi2, false);
7018 }
7019 this.ctx.fillStyle = gameSetupTheme.ghostCellsColor;
7020 this.ctx.globalAlpha = gameSetupTheme.ghostCellsAlpha;
7021 this.ctx.shadowColor = gameSetupTheme.ghostCellsColor;
7022 this.ctx.shadowBlur = 40;
7023 this.ctx.shadowOffsetX = 0;
7024 this.ctx.shadowOffsetY = 0;
7025 this.ctx.fill();
7026 this.ctx.globalAlpha = 1;
7027 this.ctx.shadowBlur = 0;
7028 },
7029 preDrawPellet() {
7030 this.pellet = null;
7031 const size = 10 + gameSetupTheme.foodSize;
7032 let canvas = document.createElement(`canvas`);
7033 canvas.width = size * 2;
7034 canvas.height = size * 2;
7035 const ctx = canvas.getContext('2d');
7036 ctx.arc(size, size, size, 0, this.pi2, false);
7037 ctx.fillStyle = gameSetupTheme.foodColor;
7038 ctx.fill();
7039 this.pellet = new Image();
7040 this.pellet.src = canvas.toDataURL();
7041 canvas = null;
7042 },
7043 preDrawIndicator() {
7044 this.indicator = null;
7045 let canvas = document.createElement('canvas');
7046 canvas.width = 90;
7047 canvas.height = 50;
7048 const ctx = canvas.getContext('2d');
7049 ctx.lineWidth = 2;
7050 ctx.fillStyle = gameSetupTheme.teammatesIndColor;
7051 ctx.strokeStyle = `#000000`;
7052 ctx.beginPath();
7053 ctx.moveTo(0, 0);
7054 ctx.lineTo(90, 0);
7055 ctx.lineTo(45, 50);
7056 ctx.closePath();
7057 ctx.fill();
7058 ctx.stroke();
7059 this.indicator = new Image();
7060 this.indicator.src = canvas.toDataURL();
7061 canvas = null;
7062 },
7063 countFps() {
7064 if (!gameOptionSettings.showStatsFPS) {
7065 return;
7066 }
7067 const Time = Date.now();
7068 if (!this.fpsLastRequest) {
7069 this.fpsLastRequest = Time;
7070 }
7071 if (Time - this.fpsLastRequest >= 1000) {
7072 this.fps = this.renderedFrames;
7073 this.renderedFrames = 0;
7074 this.fpsLastRequest = Time;
7075 }
7076 this.renderedFrames++;
7077 },
7078 render() {
7079 drawRender.countFps();
7080 drawRender.renderFrame();
7081 window.requestAnimationFrame(drawRender.render);
7082 },
7083 init() {
7084 this.setCanvas();
7085 this.resizeCanvas();
7086 this.preDrawPellet();
7087 this.preDrawIndicator();
7088 window.requestAnimationFrame(drawRender.render);
7089 }
7090 };
7091 const keyBlind = {};
7092 var hotkeys = {};
7093 const hotkeysCommand = {
7094 'hk-bots-split': {
7095 label: textLanguage[`hk-bots-split`],
7096 defaultKey: 'T',
7097 keyDown() {
7098 if(window.user.startedBots && window.user.isAlive) window.connection.send(new Uint8Array([2]).buffer)
7099 },
7100 keyUp: null,
7101 type: 'normal'
7102 },
7103 'hk-bots-feed': {
7104 label: textLanguage[`hk-bots-feed`],
7105 defaultKey: 'A',
7106 keyDown() {
7107 if(window.user.startedBots && window.user.isAlive) window.connection.send(new Uint8Array([3]).buffer)
7108 },
7109 keyUp: null,
7110 type: 'normal'
7111 },
7112 'hk-bots-ai': {
7113 label: textLanguage[`hk-bots-ai`],
7114 defaultKey: 'F',
7115 keyDown() {
7116 if(window.user.startedBots && window.user.isAlive){
7117 if(!window.bots.ai){
7118 document.getElementById('botsAI').style.color = '#00C02E'
7119 document.getElementById('botsAI').innerText = 'Enabled'
7120 window.bots.ai = true
7121 window.connection.send(new Uint8Array([4, Number(window.bots.ai)]).buffer)
7122 }
7123 else {
7124 document.getElementById('botsAI').style.color = '#DA0A00'
7125 document.getElementById('botsAI').innerText = 'Disabled'
7126 window.bots.ai = false
7127 window.connection.send(new Uint8Array([4, Number(window.bots.ai)]).buffer)
7128 }
7129 }
7130 },
7131 keyUp: null,
7132 type: 'normal'
7133 },
7134 'hk-feed': {
7135 label: textLanguage[`hk-feed`],
7136 defaultKey: 'W',
7137 keyDown() {
7138 application && application.feed();
7139 },
7140 keyUp: null,
7141 type: 'normal'
7142 },
7143 'hk-macroFeed': {
7144 label: textLanguage[`hk-macroFeed`],
7145 defaultKey: 'E',
7146 keyDown() {
7147 application && application.macroFeed(true);
7148 },
7149 keyUp() {
7150 application && application.macroFeed(false);
7151 },
7152 type: `normal`
7153 },
7154 'hk-split': {
7155 label: textLanguage[`hk-split`],
7156 defaultKey: 'SPACE',
7157 keyDown() {
7158 application && application.split();
7159 },
7160 keyUp: null,
7161 type: `normal`
7162 },
7163 'hk-doubleSplit': {
7164 label: textLanguage[`hk-doubleSplit`],
7165 defaultKey: 'Q',
7166 keyDown() {
7167 application && application.doubleSplit();
7168 },
7169 keyUp: null,
7170 type: `normal`
7171 },
7172 'hk-popSplit': {
7173 label: `Popsplit`,
7174 defaultKey: `ALT+Q`,
7175 keyDown() {
7176 application && application.popSplit();
7177 },
7178 keyUp: null,
7179 type: 'normal'
7180 },
7181 'hk-split16': {
7182 label: textLanguage[`hk-split16`],
7183 defaultKey: 'SHIFT',
7184 keyDown() {
7185 application && application.split16();
7186 },
7187 keyUp: null,
7188 type: `normal`
7189 },
7190 'hk-pause': {
7191 label: textLanguage['hk-pause'],
7192 defaultKey: 'R',
7193 keyDown() {
7194 application && application.setPause();
7195 },
7196 keyUp: null,
7197 type: 'normal'
7198 },
7199 'hk-showTop5': {
7200 label: textLanguage[`hk-showTop5`],
7201 defaultKey: 'V',
7202 keyDown() {
7203 application && application.setShowTop5();
7204 },
7205 keyUp: null,
7206 type: `normal`
7207 },
7208 'hk-showTime': {
7209 label: textLanguage['hk-showTime'],
7210 defaultKey: 'ALT+T',
7211 keyDown() {
7212 application && application.setShowTime();
7213 },
7214 keyUp: null,
7215 type: `normal`
7216 },
7217 'hk-showSplitRange': {
7218 label: textLanguage[`hk-showSplitRange`],
7219 defaultKey: 'U',
7220 keyDown() {
7221 application && application.setShowSplitRange();
7222 },
7223 keyUp: null,
7224 type: `normal`
7225 },
7226 'hk-showSplitInd': {
7227 label: textLanguage[`hk-showSplitInd`],
7228 defaultKey: 'I',
7229 keyDown() {
7230 application && application.setShowSplitInd();
7231 },
7232 keyUp: null,
7233 type: `normal`
7234 },
7235 'hk-showTeammatesInd': {
7236 label: textLanguage[`hk-showTeammatesInd`],
7237 defaultKey: `ALT+I`,
7238 keyDown() {
7239 application && application.setShowTeammatesInd();
7240 },
7241 keyUp: null,
7242 type: 'normal'
7243 },
7244 'hk-showOppColors': {
7245 label: textLanguage[`hk-showOppColors`],
7246 defaultKey: 'O',
7247 keyDown() {
7248 application && application.setShowOppColors();
7249 },
7250 keyUp: null,
7251 type: `normal`
7252 },
7253 'hk-toggleSkins': {
7254 label: textLanguage['hk-toggleSkins'],
7255 defaultKey: 'K',
7256 keyDown() {
7257 application && application.toggleSkins();
7258 },
7259 keyUp: null,
7260 type: `normal`
7261 },
7262 'hk-transparentSkins': {
7263 label: textLanguage[`hk-transparentSkins`],
7264 defaultKey: '',
7265 keyDown() {
7266 application && application.setTransparentSkins();
7267 },
7268 keyUp: null,
7269 type: `normal`
7270 },
7271 'hk-showSkins': {
7272 label: textLanguage[`hk-showSkins`],
7273 defaultKey: 'S',
7274 keyDown() {
7275 application && application.setShowSkins();
7276 },
7277 keyUp: null,
7278 type: `normal`
7279 },
7280 'hk-showStats': {
7281 label: textLanguage[`hk-showStats`],
7282 defaultKey: `ALT+S`,
7283 keyDown() {
7284 application && application.setShowStats();
7285 },
7286 keyUp: null,
7287 type: `normal`
7288 },
7289 'hk-toggleCells': {
7290 label: textLanguage[`hk-toggleCells`],
7291 defaultKey: 'D',
7292 keyDown() {
7293 application && application.toggleCells();
7294 },
7295 keyUp: null,
7296 type: 'normal'
7297 },
7298 'hk-showFood': {
7299 label: textLanguage[`hk-showFood`],
7300 defaultKey: 'X',
7301 keyDown() {
7302 application && application.setShowFood();
7303 },
7304 keyUp: null,
7305 type: 'normal'
7306 },
7307 'hk-showGrid': {
7308 label: textLanguage[`hk-showGrid`],
7309 defaultKey: 'G',
7310 keyDown() {
7311 application && application.setShowGrid();
7312 },
7313 keyUp: null,
7314 type: `normal`
7315 },
7316 'hk-showMiniMapGuides': {
7317 label: textLanguage[`hk-showMiniMapGuides`],
7318 defaultKey: `ALT+G`,
7319 keyDown() {
7320 application && application.setShowMiniMapGuides();
7321 },
7322 keyUp: null,
7323 type: `normal`
7324 },
7325 'hk-hideChat': {
7326 label: textLanguage[`hk-hideChat`],
7327 defaultKey: 'H',
7328 keyDown() {
7329 application && application.hideChat();
7330 },
7331 keyUp: null,
7332 type: 'normal'
7333 },
7334 'hk-showHUD': {
7335 label: textLanguage['hk-showHUD'],
7336 defaultKey: 'ALT+H',
7337 keyDown() {
7338 application && application.setShowHUD();
7339 },
7340 keyUp: null,
7341 type: `normal`
7342 },
7343 'hk-copyLb': {
7344 label: textLanguage[`hk-copyLb`],
7345 defaultKey: 'L',
7346 keyDown() {
7347 application && application.copyLb();
7348 },
7349 keyUp: null,
7350 type: `normal`
7351 },
7352 'hk-showLb': {
7353 label: textLanguage[`hk-showLb`],
7354 defaultKey: `ALT+L`,
7355 keyDown() {
7356 application && application.setShowLb();
7357 },
7358 keyUp: null,
7359 type: `normal`
7360 },
7361 'hk-toggleAutoZoom': {
7362 label: textLanguage[`hk-toggleAutoZoom`],
7363 defaultKey: '',
7364 keyDown() {
7365 application && application.toggleAutoZoom();
7366 },
7367 keyUp: null,
7368 type: `normal`
7369 },
7370 'hk-resetZoom': {
7371 label: textLanguage[`hk-resetZoom`],
7372 defaultKey: 'ALT+Z',
7373 keyDown() {
7374 application && application.resetZoom(true);
7375 },
7376 keyUp() {
7377 application && application.resetZoom(false);
7378 },
7379 type: `normal`
7380 },
7381 'hk-toggleDeath': {
7382 label: textLanguage['hk-toggleDeath'],
7383 defaultKey: 'Z',
7384 keyDown() {
7385 application && application.toggleDeath();
7386 },
7387 keyUp: null,
7388 type: `normal`
7389 },
7390 'hk-clearChat': {
7391 label: textLanguage[`hk-clearChat`],
7392 defaultKey: 'C',
7393 keyDown() {
7394 application && application.displayChatHistory(true);
7395 },
7396 keyUp() {
7397 application && application.displayChatHistory(false);
7398 },
7399 type: `normal`
7400 },
7401 'hk-showBgSectors': {
7402 label: textLanguage[`hk-showBgSectors`],
7403 defaultKey: 'B',
7404 keyDown() {
7405 application && application.setShowBgSectors();
7406 },
7407 keyUp: null,
7408 type: `normal`
7409 },
7410 'hk-hideBots': {
7411 label: textLanguage[`hk-hideBots`],
7412 defaultKey: 'ALT+B',
7413 keyDown() {
7414 application && application.setHideSmallBots();
7415 },
7416 keyUp: null,
7417 type: `normal`
7418 },
7419 'hk-showNames': {
7420 label: textLanguage['hk-showNames'],
7421 defaultKey: 'N',
7422 keyDown() {
7423 application && application.setShowNames();
7424 },
7425 keyUp: null,
7426 type: `normal`
7427 },
7428 'hk-hideTeammatesNames': {
7429 label: textLanguage[`hk-hideTeammatesNames`],
7430 defaultKey: '',
7431 keyDown() {
7432 application && application.setHideTeammatesNames();
7433 },
7434 keyUp: null,
7435 type: 'normal'
7436 },
7437 'hk-showMass': {
7438 label: textLanguage[`hk-showMass`],
7439 defaultKey: 'M',
7440 keyDown() {
7441 application && application.setShowMass();
7442 },
7443 keyUp: null,
7444 type: `normal`
7445 },
7446 'hk-showMiniMap': {
7447 label: textLanguage[`hk-showMiniMap`],
7448 defaultKey: `ALT+M`,
7449 keyDown() {
7450 application && application.setShowMiniMap();
7451 },
7452 keyUp: null,
7453 type: `normal`
7454 },
7455 'hk-chatMessage': {
7456 label: textLanguage[`hk-chatMessage`],
7457 defaultKey: `ENTER`,
7458 keyDown() {
7459 application && application.enterChatMessage();
7460 },
7461 keyUp: null,
7462 type: `special`
7463 },
7464 'hk-quickResp': {
7465 label: textLanguage[`hk-quickResp`],
7466 defaultKey: 'TILDE',
7467 keyDown() {
7468 application && application.quickResp();
7469 },
7470 keyUp: null,
7471 type: `normal`
7472 },
7473 'hk-autoResp': {
7474 label: textLanguage[`hk-autoResp`],
7475 defaultKey: '',
7476 keyDown() {
7477 application && application.toggleAutoResp();
7478 },
7479 keyUp: null,
7480 type: `normal`
7481 },
7482 'hk-zoom1': {
7483 label: `${textLanguage[`hk-zoomLevel`]} 1`,
7484 defaultKey: `ALT+1`,
7485 keyDown() {
7486 application && application.setZoom(0.5);
7487 },
7488 keyUp: null,
7489 type: `normal`
7490 },
7491 'hk-zoom2': {
7492 label: `${textLanguage[`hk-zoomLevel`]} 2`,
7493 defaultKey: `ALT+2`,
7494 keyDown() {
7495 application && application.setZoom(0.25);
7496 },
7497 keyUp: null,
7498 type: `normal`
7499 },
7500 'hk-zoom3': {
7501 label: `${textLanguage[`hk-zoomLevel`]} 3`,
7502 defaultKey: `ALT+3`,
7503 keyDown() {
7504 application && application.setZoom(0.125);
7505 },
7506 keyUp: null,
7507 type: `normal`
7508 },
7509 'hk-zoom4': {
7510 label: `${textLanguage[`hk-zoomLevel`]} 4`,
7511 defaultKey: `ALT+4`,
7512 keyDown() {
7513 application && application.setZoom(0.075);
7514 },
7515 keyUp: null,
7516 type: `normal`
7517 },
7518 'hk-zoom5': {
7519 label: `${textLanguage[`hk-zoomLevel`]} 5`,
7520 defaultKey: `ALT+5`,
7521 keyDown() {
7522 application && application.setZoom(0.05);
7523 },
7524 keyUp: null,
7525 type: `normal`
7526 },
7527 'hk-switchServerMode': {
7528 label: textLanguage[`hk-switchServerMode`],
7529 defaultKey: '=',
7530 keyDown() {
7531 application && application.switchServerMode();
7532 },
7533 keyUp: null,
7534 type: `normal`
7535 },
7536 'hk-showTargeting': {
7537 label: textLanguage[`hk-showTargeting`],
7538 defaultKey: '',
7539 keyDown() {
7540 application && application.setShowTargeting();
7541 },
7542 keyUp: null,
7543 type: 'normal'
7544 },
7545 'hk-setTargeting': {
7546 label: textLanguage['hk-setTargeting'],
7547 defaultKey: '',
7548 keyDown() {
7549 application && application.setTargeting();
7550 },
7551 keyUp: null,
7552 type: 'normal'
7553 },
7554 'hk-cancelTargeting': {
7555 label: textLanguage['hk-cancelTargeting'],
7556 defaultKey: '',
7557 keyDown() {
7558 application && application.cancelTargeting();
7559 },
7560 keyUp: null,
7561 type: `normal`
7562 },
7563 'hk-changeTarget': {
7564 label: textLanguage[`hk-changeTarget`],
7565 defaultKey: '',
7566 keyDown() {
7567 application && application.changeTarget();
7568 },
7569 keyUp: null,
7570 type: `normal`
7571 },
7572 'hk-privateMiniMap': {
7573 label: textLanguage[`hk-privateMiniMap`],
7574 defaultKey: '',
7575 keyDown() {
7576 application && application.setPrivateMiniMap();
7577 },
7578 keyUp: null,
7579 type: `normal`
7580 },
7581 'hk-showQuest': {
7582 label: textLanguage[`hk-showQuest`],
7583 defaultKey: '',
7584 keyDown() {
7585 application && application.setShowQuest();
7586 },
7587 keyUp: null,
7588 type: `normal`
7589 },
7590 'hk-comm1': {
7591 label: chatCommand.comm1,
7592 defaultKey: '1',
7593 keyDown() {
7594 application && application.sendCommand(1);
7595 },
7596 keyUp: null,
7597 type: `command`
7598 },
7599 'hk-comm2': {
7600 label: chatCommand.comm2,
7601 defaultKey: '2',
7602 keyDown() {
7603 application && application.sendCommand(2);
7604 },
7605 keyUp: null,
7606 type: `command`
7607 },
7608 'hk-comm3': {
7609 label: chatCommand.comm3,
7610 defaultKey: '3',
7611 keyDown() {
7612 application && application.sendCommand(3);
7613 },
7614 keyUp: null,
7615 type: `command`
7616 },
7617 'hk-comm4': {
7618 label: chatCommand.comm4,
7619 defaultKey: '4',
7620 keyDown() {
7621 application && application.sendCommand(4);
7622 },
7623 keyUp: null,
7624 type: `command`
7625 },
7626 'hk-comm5': {
7627 label: chatCommand.comm5,
7628 defaultKey: '5',
7629 keyDown() {
7630 application && application.sendCommand(5);
7631 },
7632 keyUp: null,
7633 type: `command`
7634 },
7635 'hk-comm6': {
7636 label: chatCommand.comm6,
7637 defaultKey: '6',
7638 keyDown() {
7639 application && application.sendCommand(6);
7640 },
7641 keyUp: null,
7642 type: `command`
7643 },
7644 'hk-comm7': {
7645 label: chatCommand.comm7,
7646 defaultKey: '7',
7647 keyDown() {
7648 application && application.sendCommand(7);
7649 },
7650 keyUp: null,
7651 type: `command`
7652 },
7653 'hk-comm8': {
7654 label: chatCommand.comm8,
7655 defaultKey: '8',
7656 keyDown() {
7657 application && application.sendCommand(8);
7658 },
7659 keyUp: null,
7660 type: 'command'
7661 },
7662 'hk-comm9': {
7663 label: chatCommand.comm9,
7664 defaultKey: '9',
7665 keyDown() {
7666 application && application.sendCommand(9);
7667 },
7668 keyUp: null,
7669 type: `command`
7670 },
7671 'hk-comm0': {
7672 label: chatCommand.comm0,
7673 defaultKey: '0',
7674 keyDown() {
7675 application && application.sendCommand(0);
7676 },
7677 keyUp: null,
7678 type: `command`
7679 },
7680 'hk-comm10': {
7681 label: chatCommand.comm10,
7682 defaultKey: `MOUSE WHEEL`,
7683 keyDown() {
7684 application && application.sendCommand(10);
7685 },
7686 keyUp: null,
7687 type: 'command'
7688 },
7689 'hk-comm11': {
7690 label: chatCommand.comm11,
7691 defaultKey: `LEFT`,
7692 keyDown() {
7693 application && application.sendCommand(11);
7694 },
7695 keyUp: null,
7696 type: 'command'
7697 },
7698 'hk-comm12': {
7699 label: chatCommand.comm12,
7700 defaultKey: 'UP',
7701 keyDown() {
7702 application && application.sendCommand(12);
7703 },
7704 keyUp: null,
7705 type: `command`
7706 },
7707 'hk-comm13': {
7708 label: chatCommand.comm13,
7709 defaultKey: 'RIGHT',
7710 keyDown() {
7711 application && application.sendCommand(13);
7712 },
7713 keyUp: null,
7714 type: `command`
7715 },
7716 'hk-comm14': {
7717 label: chatCommand.comm14,
7718 defaultKey: 'DOWN',
7719 keyDown() {
7720 application && application.sendCommand(14);
7721 },
7722 keyUp: null,
7723 type: `command`
7724 }
7725 };
7726 const hotkeysSetup = {
7727 lastPressedKey: '',
7728 lastKeyId: '',
7729 defaultMessageKey: `ENTER`,
7730 inputClassName: 'custom-key-in form-control input-sm',
7731 loadDefaultHotkeys() {
7732 hotkeys = {};
7733 for (const command in hotkeysCommand) {
7734 if (hotkeysCommand.hasOwnProperty(command)) {
7735 hotkeys[hotkeysCommand[command].defaultKey] = command;
7736 }
7737 }
7738 hotkeys[`spec-messageKey`] = this.defaultMessageKey;
7739 },
7740 loadHotkeys() {
7741 if (window.localStorage.getItem(`ogarioHotkeys`) !== null) {
7742 hotkeys = JSON.parse(window.localStorage.getItem('ogarioHotkeys'));
7743 } else {
7744 this.loadDefaultHotkeys();
7745 }
7746 if (window.localStorage.getItem(`ogarioCommands`) !== null) {
7747 chatCommand = JSON.parse(window.localStorage.getItem('ogarioCommands'));
7748 }
7749 },
7750 saveHotkeys() {
7751 window.localStorage.setItem('ogarioHotkeys', JSON.stringify(hotkeys));
7752 this.saveCommands();
7753 },
7754 saveCommands() {
7755 JQuery('#hotkeys .command-in').each(function() {
7756 const element = JQuery(this);
7757 const id = element.attr('id');
7758 if (chatCommand.hasOwnProperty(id)) {
7759 chatCommand[id] = element.val();
7760 }
7761 });
7762 window.localStorage.setItem(`ogarioCommands`, JSON.stringify(chatCommand));
7763 },
7764 resetHotkeys() {
7765 this.loadDefaultHotkeys();
7766 JQuery('#hotkeys-cfg .custom-key-in').each(function() {
7767 const id = JQuery(this).attr('id');
7768 if (hotkeysCommand[id]) {
7769 JQuery(this).val(hotkeysCommand[id].defaultKey);
7770 }
7771 });
7772 },
7773 setHotkeysMenu() {
7774 const setup = this;
7775 JQuery('body').append(`<div id="hotkeys"><div id="hotkeys-menu"><button id="reset-hotkeys" class="btn btn-primary">${textLanguage.restoreSettings}${`</button> <button id="save-hotkeys" class="btn btn-success">`}${textLanguage.saveSett}</button> <button id="close-hotkeys" class="btn btn-danger">${textLanguage.close}${`</button></div><div id="hotkeys-cfg"></div><div id="hotkeys-inst"><ul><li>`}${textLanguage['hk-inst-assign']}${`</li><li>`}${textLanguage[`hk-inst-delete`]}</li><li>${textLanguage[`hk-inst-keys`]}</li></ul></div></div>`);
7776 for (const command in hotkeysCommand) {
7777 if (hotkeysCommand.hasOwnProperty(command)) {
7778 const currentCommand = hotkeysCommand[command];
7779 let text = '';
7780 for (const key in hotkeys) {
7781 if (hotkeys.hasOwnProperty(key) && hotkeys[key] === command) {
7782 text = key;
7783 break;
7784 }
7785 }
7786 if (command === `hk-switchServerMode` && application && !application.privateIP) {
7787 continue;
7788 }
7789 if (currentCommand.type === `command`) {
7790 const replaceHk = command.replace(`hk-`, '');
7791 JQuery(`#hotkeys-cfg`).append(`${`<div class="row"><div class="key-label"><input id="` + replaceHk + `" class="command-in form-control input-sm" value="` + chatCommand[replaceHk] + `" maxlength="80" /></div><div class="default-key">` + currentCommand.defaultKey + `</div><div class="custom-key"><input id="` + command + `" class="custom-key-in form-control input-sm" value="` + text}" /></div></div>`);
7792 } else {
7793 JQuery('#hotkeys-cfg').append(`<div class="row"><div class="key-label">${currentCommand.label}</div><div class="default-key">${currentCommand.defaultKey}</div><div class="custom-key"><input id="${command}${`" class="custom-key-in form-control input-sm" value="`}${text}" /></div></div>`);
7794 }
7795 }
7796 }
7797 JQuery(document).on('click', `#reset-hotkeys`, event => {
7798 event.preventDefault();
7799 setup.resetHotkeys();
7800 });
7801 JQuery(document).on(`click`, `#save-hotkeys`, event => {
7802 event.preventDefault();
7803 setup.saveHotkeys();
7804 JQuery('#hotkeys').fadeOut(500);
7805 });
7806 JQuery(document).on(`click`, `#close-hotkeys`, event => {
7807 event.preventDefault();
7808 JQuery('#hotkeys').fadeOut(500);
7809 });
7810 JQuery(document).on(`click`, `.hotkeys-link`, event => {
7811 JQuery(`#hotkeys`).fadeIn(500);
7812 JQuery(`#hotkeys-cfg`).perfectScrollbar(`update`);
7813 resetonkeydown();
7814 });
7815 JQuery(`#hotkeys-cfg`).perfectScrollbar();
7816 OgarioSettings && OgarioSettings.setMenuBg();
7817 },
7818 getPressedKey(key) {
7819 let specialKey = '';
7820 let normalKey = '';
7821 if (key.ctrlKey || key.keyCode == 17) {
7822 specialKey = 'CTRL';
7823 } else if (key.altKey || key.keyCode == 18) {
7824 specialKey = `ALT`;
7825 }
7826 switch (key.keyCode) {
7827 case 9:
7828 normalKey = `TAB`;
7829 break;
7830 case 13:
7831 normalKey = `ENTER`;
7832 break;
7833 case 16:
7834 normalKey = 'SHIFT';
7835 break;
7836 case 17:
7837 break;
7838 case 18:
7839 break;
7840 case 27:
7841 normalKey = `ESC`;
7842 break;
7843 case 32:
7844 normalKey = 'SPACE';
7845 break;
7846 case 37:
7847 normalKey = `LEFT`;
7848 break;
7849 case 38:
7850 normalKey = 'UP';
7851 break;
7852 case 39:
7853 normalKey = `RIGHT`;
7854 break;
7855 case 40:
7856 normalKey = `DOWN`;
7857 break;
7858 case 46:
7859 normalKey = `DEL`;
7860 break;
7861 case 61:
7862 normalKey = '=';
7863 break;
7864 case 187:
7865 normalKey = '=';
7866 break;
7867 case 192:
7868 normalKey = `TILDE`;
7869 break;
7870 default:
7871 normalKey = String.fromCharCode(key.keyCode);
7872 break;
7873 }
7874 if (specialKey !== '') {
7875 if (normalKey !== '') {
7876 return `${specialKey}+${normalKey}`;
7877 }
7878 return specialKey;
7879 }
7880 return normalKey;
7881 },
7882 deleteHotkey(name, id) {
7883 delete hotkeys[name];
7884 JQuery(`#${id}`).val('');
7885 },
7886 setDefaultHotkey(id) {
7887 let key = false;
7888 if (hotkeysCommand[id] && !hotkeys.hasOwnProperty(hotkeysCommand[id].defaultKey)) {
7889 key = hotkeysCommand[id].defaultKey;
7890 hotkeys[key] = id;
7891 return key;
7892 }
7893 return key;
7894 },
7895 setHotkey(key, id) {
7896 if (!id || this.lastPressedKey === key && this.lastKeyId === id) {
7897 return;
7898 }
7899 const value = JQuery(`#${id}`).val();
7900 this.deleteHotkey(value, id);
7901 if (key === 'DEL') {
7902 return;
7903 }
7904 if (hotkeys[key] && hotkeys[key] !== id) {
7905 const hotkey = hotkeys[key];
7906 const defaultKey = this.setDefaultHotkey(hotkey);
7907 if (defaultKey) {
7908 hotkeys[defaultKey] = hotkey;
7909 JQuery(`#${hotkey}`).val(defaultKey);
7910 } else {
7911 this.deleteHotkey(key, hotkey);
7912 }
7913 }
7914 hotkeys[key] = id;
7915 JQuery(`#${id}`).val(key);
7916 if (id === 'hk-chatMessage') {
7917 hotkeys[`spec-messageKey`] = key;
7918 }
7919 this.lastPressedKey = key;
7920 this.lastKeyId = id;
7921 },
7922 init() {
7923 this.loadHotkeys();
7924 this.setHotkeysMenu();
7925 }
7926 };
7927 document.onkeydown = event => {
7928 const pressKey = hotkeysSetup.getPressedKey(event);
7929 if (event.target.tagName === `INPUT` && event.target.className !== hotkeysSetup.inputClassName && pressKey !== hotkeys['spec-messageKey']) {
7930 return;
7931 }
7932 if (pressKey !== '' && !keyBlind[pressKey]) {
7933 keyBlind[pressKey] = true;
7934 if (pressKey === `ESC`) {
7935 event.preventDefault();
7936 application && application.showMenu();
7937 return;
7938 }
7939 if (event.target.className === hotkeysSetup.inputClassName) {
7940 event.preventDefault();
7941 hotkeysSetup.setHotkey(pressKey, event.target.id);
7942 return;
7943 }
7944 if (hotkeys[pressKey]) {
7945 event.preventDefault();
7946 const key = hotkeys[pressKey];
7947 if (key !== '' && hotkeysCommand[key]) {
7948 if (hotkeysCommand[key].keyDown) {
7949 hotkeysCommand[key].keyDown();
7950 }
7951 }
7952 }
7953 }
7954 };
7955 document.onkeyup = event => {
7956 const pressedKey = hotkeysSetup.getPressedKey(event);
7957 if (pressedKey !== '') {
7958 if (hotkeys[pressedKey]) {
7959 const key = hotkeys[pressedKey];
7960 if (key !== '' && hotkeysCommand[key]) {
7961 if (hotkeysCommand[key].keyUp) {
7962 hotkeysCommand[key].keyUp();
7963 }
7964 }
7965 }
7966 keyBlind[pressedKey] = false;
7967 }
7968 };
7969 window.onmousedown = event => {
7970 if (!JQuery(`#overlays`).is(`:visible`)) {
7971 if (event.which == 2) {
7972 event.preventDefault();
7973 application && application.sendCommand(10);
7974 } else {
7975 if (gameOptionSettings.mouseSplit) {
7976 if (event.which == 1 && !gameOptionSettings.mouseInvert || event.which == 3 && gameOptionSettings.mouseInvert) {
7977 event.preventDefault();
7978 application && application.split();
7979 }
7980 }
7981 if (gameOptionSettings.mouseFeed) {
7982 if (event.which == 3 && !gameOptionSettings.mouseInvert || event.which == 1 && gameOptionSettings.mouseInvert) {
7983 event.preventDefault();
7984 application && application.macroFeed(true);
7985 }
7986 }
7987 }
7988 }
7989 };
7990 window.onmouseup = event => {
7991 if (gameOptionSettings.mouseFeed) {
7992 if (event.which == 3 && !gameOptionSettings.mouseInvert || event.which == 1 && gameOptionSettings.mouseInvert) {
7993 application && application.macroFeed(false);
7994 }
7995 }
7996 };
7997 window.onbeforeunload = event => {
7998 if (ogario.play) {
7999 return textLanguage.exit;
8000 } else {
8001 return;
8002 }
8003 };
8004
8005 function changeHistory(value) {
8006 if (window.history && window.history.replaceState) {
8007 window.history.replaceState({}, window.document.title, value);
8008 }
8009 }
8010
8011 function changeUrl() {
8012 if (window.location.pathname === `/ogario`) {
8013 changeHistory(`/${window.location.hash}`);
8014 }
8015 }
8016
8017 function spectateBlind() {
8018 window.onkeydown = event => {
8019 81 == event.keyCode && window.core.specialOn && window.core.specialOn();
8020 };
8021 window.onkeyup = event => {};
8022 }
8023
8024 function menuScale() {
8025 const innerWidth = window.innerWidth;
8026 const innerHeigth = window.innerHeight;
8027 const helloContainer = JQuery('#helloContainer');
8028 let helloContainerWidth = helloContainer.innerHeight();
8029 if (helloContainerWidth > 0) {
8030 ogario.menuHeight = helloContainerWidth;
8031 } else {
8032 helloContainerWidth = ogario.menuHeight || 618;
8033 }
8034 const scale = Math.min(1, innerHeigth / helloContainerWidth);
8035 const top = helloContainerWidth * scale;
8036 const resizeTop = Math.round(innerHeigth / 2 - 0.5 * top);
8037 const transform = `${`translate(-50%, 0%) scale(` + scale})`;
8038 helloContainer.css('transform', transform);
8039 helloContainer.css('-ms-transform', transform);
8040 helloContainer.css('-webkit-transform', transform);
8041 helloContainer.css('top', `${resizeTop}px`);
8042 ogario.innerW = innerWidth;
8043 ogario.innerH = innerHeigth;
8044 }
8045
8046 function resetonkeydown() {
8047 if (application.protocolMode) {
8048 return;
8049 }
8050 window.onkeydown = event => {};
8051 }
8052
8053 function start() {
8054 window.core = {
8055 connect(url) {
8056 Connection.connect(url);
8057 },
8058 disconnect() {},
8059 sendNick(nick) {
8060 Connection.sendNick(nick);
8061 },
8062 sendSpectate() {
8063 Connection.sendSpectate();
8064 },
8065 eject() {
8066 Connection.sendEject();
8067 },
8068 split() {
8069 Connection.sendSplit();
8070 },
8071 specialOn() {
8072 Connection.sendFreeSpectate();
8073 },
8074 specialOff() {
8075 Connection.sendFreeSpectate();
8076 },
8077 sendFbToken(token) {
8078 Connection.sendFbToken(token);
8079 },
8080 sendGplusToken(token) {
8081 Connection.sendGplusToken(token);
8082 },
8083 recaptchaResponse(token) {
8084 Connection.sendRecaptcha(token);
8085 },
8086 setClientVersion(version, strVersion) {
8087 Connection.setClientVersion(version, strVersion);
8088 },
8089 proxyMobileData(data = []) {
8090 if (!Array.isArray(data)) {
8091 console.log('ProxyMobileData ERROR: Array data required.');
8092 return;
8093 }
8094 if (data[0] == 8) {
8095 data.unshift(102);
8096 }
8097 data = new Uint8Array(data);
8098 Connection.sendMessage(new DataView(data.buffer));
8099 }
8100 };
8101 }
8102
8103 function setGUI(){
8104 document.getElementById('quick-menu').innerHTML = `
8105 <h2 id="botsInfo">
8106 <a href="Pornhub.com" target="_blank">BANG API</a>
8107 </h2>
8108 <h5 id="botsAuthor">
8109 Developed by <a href="https://www.youtube.com/c/DJOHMSR" target="_blank">OHMMYCode</a>
8110 </h5>
8111 <span id="statusText">Status: <b id="userStatus">Disconnected</b></span>
8112 <br>
8113 <br>
8114 <span id="aiText">Bots AI: <b id="botsAI">Disabled</b></span>
8115 <br>
8116 <input type="text" id="botsName" placeholder="Bots Name" maxlength="15" spellcheck="false">
8117 <input type="number" id="botsAmount" placeholder="Bots Amount" min="10" max="300" spellcheck="false">
8118 <button id="connect">Connect</button>
8119 <br>
8120 <button id="startBots" disabled>Start Bots</button>
8121 <button id="stopBots">Stop Bots</button>
8122 `
8123 if(localStorage.getItem('localStoredBotsName') !== null){
8124 window.bots.name = localStorage.getItem('localStoredBotsName')
8125 document.getElementById('botsName').value = window.bots.name
8126 }
8127 if(localStorage.getItem('localStoredBotsAmount') !== null){
8128 window.bots.amount = JSON.parse(localStorage.getItem('localStoredBotsAmount'))
8129 document.getElementById('botsAmount').value = String(window.bots.amount)
8130 }
8131 if(localStorage.getItem('localStoredServerHost') !== null){
8132 window.server.host = localStorage.getItem('localStoredServerHost')
8133 document.getElementById('serverHost').value = window.server.host
8134 }
8135 if(localStorage.getItem('localStoredServerPort') !== null){
8136 window.server.port = JSON.parse(localStorage.getItem('localStoredServerPort'))
8137 document.getElementById('serverPort').value = String(window.server.port)
8138 }
8139 }
8140
8141 function setGUIStyle(){
8142 document.getElementsByTagName('head')[0].innerHTML += `
8143 <style type="text/css">
8144 #quick-menu {
8145 width: 280px !important;
8146 height: 580px !important;
8147 }
8148 #botsInfo > a, #botsAuthor > a {
8149 color: #fff;
8150 text-decoration: none;
8151 }
8152 #botsAuthor {
8153 margin-top: -15px;
8154 letter-spacing: 1px;
8155 }
8156 #statusText, #aiText {
8157 font-weight: bold;
8158 position: absolute;
8159 left: -5px;
8160 }
8161 #userStatus, #botsAI {
8162 color: #DA0A00;
8163 }
8164 #botsName, #botsAmount, #serverHost, #serverPort {
8165 margin-top: 15px;
8166 width: 144px;
8167 padding: 8px;
8168 font-size: 14.5px;
8169 outline: none;
8170 margin-left: 60px;
8171 }
8172 #connect, #startBots, #stopBots {
8173 color: white;
8174 border: none;
8175 padding: 7px;
8176 width: 160px;
8177 font-size: 18px;
8178 outline: none;
8179 margin-top: 15px;
8180 letter-spacing: 1px;
8181 margin-left: 50px;
8182 }
8183 #connect {
8184 display: inline;
8185 background-color: #0074C0;
8186 }
8187 #startBots {
8188 display: inline;
8189 background-color: #00C02E;
8190 }
8191 #stopBots {
8192 display: none;
8193 background-color: #DA0A00;
8194 }
8195 #connect:active {
8196 background-color: #004E82;
8197 }
8198 #startBots:active {
8199 background-color: #009A25;
8200 }
8201 #stopBots:active {
8202 background-color: #9A1B00;
8203 }
8204 </style>
8205 `
8206 }
8207
8208function loadUI(){
8209 $('#overlays-hud').append(`
8210<div id="botClient" style="position: absolute; top: 30%; left: 0%; padding: 0px 8px; font-family: Tahoma; color: rgb(0, 255, 34); z-index: 9999; border-radius: 5px; min-height: 16px; min-width: 200px; background-color: rgba(2, 0, 0, 0.4);">
8211<div><b>จารโอม API Bots</b></div>
8212<b><div><b>Bot Count</b>: <span id="botCount" class="label label-info pull-right">Waiting</span></div>
8213<b><div><b>ServerSlots</b>: <span id="slots" class="label label-info pull-right">Waiting</span></div>
8214</div>`);
8215
8216}
8217
8218 function setGUIEvents(){
8219 document.getElementById('botsAmount').addEventListener('keypress', e => {
8220 e.preventDefault()
8221 })
8222 document.getElementById('botsName').addEventListener('change', function(){
8223 window.bots.name = this.value
8224 localStorage.setItem('localStoredBotsName', window.bots.name)
8225 })
8226 document.getElementById('botsAmount').addEventListener('change', function(){
8227 window.bots.amount = Number(this.value)
8228 localStorage.setItem('localStoredBotsAmount', window.bots.amount)
8229 })
8230 document.getElementById('connect').addEventListener('click', () => {
8231 if(!window.connection.ws || window.connection.ws.readyState !== WebSocket.OPEN) window.connection.connect()
8232 })
8233 document.getElementById('startBots').addEventListener('click', () => {
8234 if(window.game.url && window.game.protocolVersion && window.game.clientVersion && !window.user.startedBots){
8235 if(window.bots.name && window.bots.amount && window.getComputedStyle(document.getElementsByClassName('btn-login-play')[0]).getPropertyValue('display') === 'none') window.connection.send(window.buffers.startBots(window.game.url, window.game.protocolVersion, window.game.clientVersion, window.user.isAlive, window.bots.name, window.bots.amount))
8236 else alert('Bots name and amount are required before starting the bots, also you need to be logged in to your agar.io account in order to start the bots')
8237 }
8238 })
8239 document.getElementById('stopBots').addEventListener('click', () => {
8240 if(window.user.startedBots) window.connection.send(new Uint8Array([1]).buffer)
8241 })
8242 document.getElementById('serverHost').addEventListener('change', function(){
8243 window.server.host = this.value
8244 localStorage.setItem('localStoredServerHost', window.server.host)
8245 })
8246 document.getElementById('serverPort').addEventListener('change', function(){
8247 window.server.port = Number(this.value)
8248 localStorage.setItem('localStoredServerPort', window.server.port)
8249 })
8250 }
8251
8252 function resize() {
8253 window.onresize = () => {
8254 drawRender.resizeCanvas();
8255 menuScale();
8256 };
8257 }((() => {
8258 ogario = Connection;
8259 changeUrl();
8260 resize();
8261 spectateBlind();
8262 start();
8263 window.master.getClientVersion();
8264 OgarioSettings.init();
8265 application.init();
8266 application.getDefaultSettings();
8267 application.connect();
8268 hotkeysSetup.init();
8269 Connection.init();
8270 drawRender.init();
8271 window.master.init();
8272 menuScale();
8273 setTimeout(() => {
8274 setGUI()
8275 setGUIStyle()
8276 setGUIEvents()
8277 loadUI()
8278 }, 3500)
8279 })());
8280}
8281
8282init(window, window.ogario, window.jQuery);