Radars are now taken from LHM
@@ -1,5 +1,4 @@
|
||||
import * as I from './types';
|
||||
import { MapConfig } from '../HUD/Radar/LexoRadar/maps';
|
||||
|
||||
|
||||
const query = new URLSearchParams(window.location.search);
|
||||
@@ -8,7 +7,7 @@ export const variant = query.get("variant") || "default";
|
||||
|
||||
export const isDev = !query.get("isProd");
|
||||
|
||||
export const config = {apiAddress:isDev ? `http://localhost:${port}/` : '/'}
|
||||
export const config = { apiAddress: isDev ? `http://localhost:${port}/` : '/' }
|
||||
export const apiUrl = config.apiAddress;
|
||||
|
||||
export async function apiV2(url: string, method = 'GET', body?: any) {
|
||||
@@ -33,11 +32,11 @@ const api = {
|
||||
getCurrent: async (): Promise<I.Match> => apiV2(`match/current`)
|
||||
},
|
||||
camera: {
|
||||
get: (): Promise<{ availablePlayers: ({steamid:string, label: string})[], uuid: string }> => apiV2('camera'),
|
||||
get: (): Promise<{ availablePlayers: ({ steamid: string, label: string })[], uuid: string }> => apiV2('camera'),
|
||||
toggleVmix: (status?: boolean) => new Promise<boolean>(r => {
|
||||
const controller = new AbortController();
|
||||
const signal = controller.signal;
|
||||
// let finished = false;
|
||||
// let finished = false;
|
||||
const timeoutId = setTimeout(() => {
|
||||
controller.abort();
|
||||
r(false);
|
||||
@@ -55,14 +54,14 @@ const api = {
|
||||
get: (): Promise<I.Team[]> => apiV2(`teams`),
|
||||
},
|
||||
players: {
|
||||
get: async (steamids?: string[]): Promise<I.Player[]> => apiV2(steamids ? `players?steamids=${steamids.join(';')}` :`players`),
|
||||
getAvatarURLs: async (steamid: string): Promise<{custom: string, steam: string}> => apiV2(`players/avatar/steamid/${steamid}`)
|
||||
get: async (steamids?: string[]): Promise<I.Player[]> => apiV2(steamids ? `players?steamids=${steamids.join(';')}` : `players`),
|
||||
getAvatarURLs: async (steamid: string): Promise<{ custom: string, steam: string }> => apiV2(`players/avatar/steamid/${steamid}`)
|
||||
},
|
||||
tournaments: {
|
||||
get: () => apiV2('tournament')
|
||||
},
|
||||
maps: {
|
||||
get: (): Promise<{ [key: string] : MapConfig}> => apiV2('radar/maps')
|
||||
get: (): Promise<I.GameMap[]> => apiV2('game-maps/cs2')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -159,3 +159,28 @@ export type Knife =
|
||||
| "knife_ursus"//
|
||||
| "knife_widowmaker"//
|
||||
| "knife_canis";//
|
||||
|
||||
export interface GameMapRadar {
|
||||
id: number;
|
||||
lhmId: string;
|
||||
originHeight?: number;
|
||||
originX?: number;
|
||||
originY?: number;
|
||||
pxPerUX?: number;
|
||||
pxPerUY?: number;
|
||||
radar: string;
|
||||
visibleOverHeight: number | null;
|
||||
visibleUnderHeight: number | null;
|
||||
}
|
||||
|
||||
export interface GameMap {
|
||||
_id: string;
|
||||
name: string;
|
||||
lhmId: string;
|
||||
game: string;
|
||||
image?: string;
|
||||
radars: GameMapRadar[];
|
||||
verticalImage?: string;
|
||||
inVetoPool: boolean;
|
||||
isActive: boolean;
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
import radar from './radar.png'
|
||||
|
||||
const config = {
|
||||
"config": {
|
||||
"origin": {
|
||||
"x": 583.2590342775677,
|
||||
"y": 428.92222042149115
|
||||
},
|
||||
"pxPerUX": 0.1983512056034216,
|
||||
"pxPerUY": -0.20108163914549304
|
||||
},
|
||||
"file":radar
|
||||
}
|
||||
|
||||
export default config;
|
||||
|
Before Width: | Height: | Size: 27 KiB |
@@ -1,15 +0,0 @@
|
||||
import radar from './radar.png'
|
||||
|
||||
const config = {
|
||||
"config": {
|
||||
"origin": {
|
||||
"x": 361.7243823603619,
|
||||
"y": 579.553558767951
|
||||
},
|
||||
"pxPerUX": 0.1830927328891829,
|
||||
"pxPerUY": -0.17650705879909936
|
||||
},
|
||||
"file":radar
|
||||
}
|
||||
|
||||
export default config;
|
||||
|
Before Width: | Height: | Size: 15 KiB |
@@ -1,15 +0,0 @@
|
||||
import radar from './radar.png'
|
||||
|
||||
const config = {
|
||||
"config": {
|
||||
"origin": {
|
||||
"x": 563.1339320329055,
|
||||
"y": 736.9535330430065
|
||||
},
|
||||
"pxPerUX": 0.2278315639654376,
|
||||
"pxPerUY": -0.22776482548619972
|
||||
},
|
||||
"file":radar
|
||||
}
|
||||
|
||||
export default config;
|
||||
|
Before Width: | Height: | Size: 53 KiB |
@@ -1,15 +0,0 @@
|
||||
import radar from './radar.png'
|
||||
|
||||
const config = {
|
||||
"config": {
|
||||
"origin": {
|
||||
"x": 426.51386123945593,
|
||||
"y": 790.7266981544722
|
||||
},
|
||||
"pxPerUX": 0.2041685571162696,
|
||||
"pxPerUY": -0.20465735943851654
|
||||
},
|
||||
"file":radar
|
||||
}
|
||||
|
||||
export default config;
|
||||
|
Before Width: | Height: | Size: 60 KiB |
@@ -1,15 +0,0 @@
|
||||
import radar from './radar.png'
|
||||
|
||||
const config = {
|
||||
"config": {
|
||||
"origin": {
|
||||
"x": 645.7196725473384,
|
||||
"y": 340.2921393569175
|
||||
},
|
||||
"pxPerUX": 0.20118507589946494,
|
||||
"pxPerUY": -0.20138282875746794
|
||||
},
|
||||
"file": radar
|
||||
}
|
||||
|
||||
export default config;
|
||||
|
Before Width: | Height: | Size: 47 KiB |
@@ -1,37 +0,0 @@
|
||||
import radar from './radar.png'
|
||||
|
||||
const high = {
|
||||
"origin": {
|
||||
"x": 473.1284773048749,
|
||||
"y": 165.7329003801045
|
||||
},
|
||||
"pxPerUX": 0.14376095926926907,
|
||||
"pxPerUY": -0.14736670935219626
|
||||
};
|
||||
|
||||
const low = {
|
||||
"origin": {
|
||||
"x": 473.66746071612374,
|
||||
"y": 638.302101754172
|
||||
},
|
||||
"pxPerUX": 0.1436068746398272,
|
||||
"pxPerUY": -0.14533406508526941
|
||||
};
|
||||
|
||||
const config = {
|
||||
configs: [
|
||||
{
|
||||
id: 'high',
|
||||
config: high,
|
||||
isVisible: (height: number) => height >= -450,
|
||||
},
|
||||
{
|
||||
id: 'low',
|
||||
config: low,
|
||||
isVisible: (height: number) => height < -450,
|
||||
},
|
||||
],
|
||||
file: radar
|
||||
}
|
||||
|
||||
export default config;
|
||||
|
Before Width: | Height: | Size: 40 KiB |
@@ -1,15 +0,0 @@
|
||||
import radar from './radar.png'
|
||||
|
||||
const config = {
|
||||
"config": {
|
||||
"origin": {
|
||||
"x": 927.3988878244819,
|
||||
"y": 343.8221009185496
|
||||
},
|
||||
"pxPerUX": 0.1923720959212443,
|
||||
"pxPerUY": -0.19427507725530338
|
||||
},
|
||||
"file":radar
|
||||
}
|
||||
|
||||
export default config;
|
||||
|
Before Width: | Height: | Size: 127 KiB |
@@ -1,15 +0,0 @@
|
||||
import radar from './radar.png'
|
||||
|
||||
const config = {
|
||||
"config": {
|
||||
"origin": {
|
||||
"x": 557.7279495268139,
|
||||
"y": 507.83243734804853
|
||||
},
|
||||
"pxPerUX": 0.22712933753943218,
|
||||
"pxPerUY": -0.23013108811174968
|
||||
},
|
||||
"file":radar
|
||||
}
|
||||
|
||||
export default config;
|
||||
|
Before Width: | Height: | Size: 32 KiB |
@@ -1,51 +0,0 @@
|
||||
import radar from './radar.png'
|
||||
|
||||
const high = {
|
||||
"origin": {
|
||||
"x": 784.4793452283254,
|
||||
"y": 255.42597837029027
|
||||
},
|
||||
"pxPerUX": 0.19856123172015677,
|
||||
"pxPerUY": -0.19820052722907044
|
||||
};
|
||||
|
||||
const low = {
|
||||
"origin": {
|
||||
"x": 780.5145858437052,
|
||||
"y": 695.4259783702903
|
||||
},
|
||||
"pxPerUX": 0.1989615567841087,
|
||||
"pxPerUY": -0.19820052722907044
|
||||
};
|
||||
|
||||
const config = {
|
||||
configs: [
|
||||
{
|
||||
id: 'high',
|
||||
config: high,
|
||||
isVisible: (height: number) => height >= 11700,
|
||||
},
|
||||
{
|
||||
id: 'low',
|
||||
config: low,
|
||||
isVisible: (height: number) => height < 11700,
|
||||
},
|
||||
],
|
||||
file: radar
|
||||
}
|
||||
|
||||
export default config;
|
||||
/*
|
||||
import radar from './radar.png'
|
||||
|
||||
export default {
|
||||
"config": {
|
||||
"origin": {
|
||||
"x": 971.5536135341899,
|
||||
"y": 424.5618319055844
|
||||
},
|
||||
"pxPerUX": 0.34708183044632246,
|
||||
"pxPerUY": -0.3450882697407333
|
||||
},
|
||||
"file":radar
|
||||
}*/
|
||||
|
Before Width: | Height: | Size: 92 KiB |
@@ -1,68 +1,125 @@
|
||||
import de_mirage from './de_mirage';
|
||||
import de_cache from './de_cache';
|
||||
import de_dust2 from './de_dust2';
|
||||
import de_inferno from './de_inferno';
|
||||
import de_train from './de_train';
|
||||
import de_overpass from './de_overpass';
|
||||
import de_nuke from './de_nuke';
|
||||
import de_vertigo from './de_vertigo';
|
||||
import de_ancient from './de_ancient';
|
||||
import api from '../../../../API';
|
||||
import { Player } from 'csgogsi';
|
||||
import { Player } from "csgogsi";
|
||||
import api, { apiUrl } from "../../../../API";
|
||||
import { GameMapRadar } from "../../../../API/types";
|
||||
|
||||
export type ZoomAreas = {
|
||||
threshold: (players: Player[]) => boolean;
|
||||
origin: number[],
|
||||
zoom: number
|
||||
}
|
||||
origin: number[];
|
||||
zoom: number;
|
||||
};
|
||||
|
||||
export interface ScaleConfig {
|
||||
origin: {
|
||||
x:number,
|
||||
y:number
|
||||
},
|
||||
pxPerUX: number,
|
||||
pxPerUY: number,
|
||||
originHeight?: number
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
pxPerUX: number;
|
||||
pxPerUY: number;
|
||||
originHeight?: number;
|
||||
}
|
||||
|
||||
type RadarFile = string;
|
||||
interface SingleLayer {
|
||||
config: ScaleConfig,
|
||||
file: string
|
||||
zooms?: ZoomAreas[]
|
||||
config: ScaleConfig;
|
||||
file: RadarFile;
|
||||
zooms?: ZoomAreas[];
|
||||
}
|
||||
|
||||
interface DoubleLayer {
|
||||
configs: {
|
||||
id: string,
|
||||
config: ScaleConfig,
|
||||
isVisible: (height: number) => boolean
|
||||
}[],
|
||||
file: string
|
||||
zooms?: ZoomAreas[]
|
||||
id: string;
|
||||
config: ScaleConfig;
|
||||
isVisible: (height: number) => boolean;
|
||||
}[];
|
||||
file: RadarFile;
|
||||
zooms?: ZoomAreas[];
|
||||
}
|
||||
|
||||
export type MapConfig = SingleLayer | DoubleLayer;
|
||||
|
||||
const maps: { [key: string] : MapConfig} = {
|
||||
de_mirage,
|
||||
de_cache,
|
||||
de_inferno,
|
||||
de_dust2,
|
||||
de_train,
|
||||
de_overpass,
|
||||
de_nuke,
|
||||
de_vertigo,
|
||||
de_ancient
|
||||
}
|
||||
const maps: { [key: string]: MapConfig } = {};
|
||||
|
||||
api.maps.get().then(fallbackMaps => {
|
||||
const mapNames = Object.keys(fallbackMaps);
|
||||
for(const mapName of mapNames){
|
||||
if(mapName in maps){
|
||||
continue;
|
||||
}
|
||||
maps[mapName] = fallbackMaps[mapName];
|
||||
}
|
||||
}).catch(() => {});
|
||||
api.maps
|
||||
.get()
|
||||
.then((newMaps) => {
|
||||
newMaps.forEach((map) => {
|
||||
const mainRadar: GameMapRadar | null =
|
||||
map.radars.find((radar) => radar.lhmId === "default") ||
|
||||
map.radars[0] ||
|
||||
null;
|
||||
const hasMultipleRadars = map.radars.length > 1;
|
||||
if (!mainRadar) return;
|
||||
|
||||
export default maps;
|
||||
if (!hasMultipleRadars) {
|
||||
maps[map.lhmId] = {
|
||||
config: {
|
||||
origin: {
|
||||
x: mainRadar.originX || 0,
|
||||
y: mainRadar.originY || 0,
|
||||
},
|
||||
pxPerUX: mainRadar.pxPerUX || 0,
|
||||
pxPerUY: mainRadar.pxPerUY || 0,
|
||||
},
|
||||
file: `${apiUrl}api/game-maps/cs2/image/${map.lhmId}/radar`,
|
||||
};
|
||||
} else {
|
||||
maps[map.lhmId] = {
|
||||
configs: map.radars.map((m: any) => ({
|
||||
id: m.lhmId,
|
||||
config: {
|
||||
origin: {
|
||||
x: m.originX || 0,
|
||||
y: m.originY || 0,
|
||||
},
|
||||
pxPerUX: m.pxPerUX || 0,
|
||||
pxPerUY: m.pxPerUY || 0,
|
||||
},
|
||||
isVisible: (height: number) =>
|
||||
(m.visibleUnderHeight !== null
|
||||
? m.visibleUnderHeight < height
|
||||
: true) &&
|
||||
(m.visibleOverHeight !== null
|
||||
? m.visibleOverHeight > height
|
||||
: true),
|
||||
})),
|
||||
file: `${apiUrl}api/game-maps/cs2/image/${map.lhmId}/radar`,
|
||||
};
|
||||
}
|
||||
|
||||
if (map.lhmId === "de_vertigo") {
|
||||
maps[map.lhmId].zooms = [
|
||||
{
|
||||
threshold: (players: Player[]) => {
|
||||
const alivePlayers = players.filter(
|
||||
(player) => player.state.health
|
||||
);
|
||||
return (
|
||||
alivePlayers.length > 0 &&
|
||||
alivePlayers.every((player) => player.position[2] < 11700)
|
||||
);
|
||||
},
|
||||
origin: [472, 1130],
|
||||
zoom: 2,
|
||||
},
|
||||
{
|
||||
threshold: (players: Player[]) => {
|
||||
const alivePlayers = players.filter(
|
||||
(player) => player.state.health
|
||||
);
|
||||
return (
|
||||
alivePlayers.length > 0 &&
|
||||
players
|
||||
.filter((player) => player.state.health)
|
||||
.every((player) => player.position[2] >= 11700)
|
||||
);
|
||||
},
|
||||
origin: [528, 15],
|
||||
zoom: 1.75,
|
||||
},
|
||||
];
|
||||
}
|
||||
});
|
||||
})
|
||||
.catch(() => { });
|
||||
|
||||
export default maps;
|
||||
|
||||