Skip to content

Commit 7b7e59c

Browse files
Introduce Location Targetting System (#6)
1 parent a3401a0 commit 7b7e59c

File tree

8 files changed

+322
-138
lines changed

8 files changed

+322
-138
lines changed

web/public/crosshair.svg

Lines changed: 14 additions & 0 deletions
Loading

web/src/api/party.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,11 @@ export const usePartyListOrder = (
297297
export type PartySettings = {
298298
private: boolean;
299299
steam_only: boolean;
300+
location?: {
301+
lat: number;
302+
lng: number;
303+
map_id: string;
304+
};
300305
[key: string]: any;
301306
};
302307

@@ -323,13 +328,27 @@ export const usePartySettings = (party_id: string) => {
323328

324329
for (const event of fEvents) {
325330
if (event.data.type == 'PartySettingChanged') {
331+
if (event.data.setting == 'location') {
332+
const data = event.data.value as {
333+
lat: number;
334+
lng: number;
335+
map_id: string;
336+
};
337+
338+
settings.location = {
339+
lat: data.lat,
340+
lng: data.lng,
341+
map_id: data.map_id,
342+
};
343+
}
344+
326345
settings[event.data.setting] = event.data.value;
327346
}
328347
}
329348

330349
setLocalSettings(settings);
331350
}
332-
}, [events]);
351+
}, [events, setLocalSettings]);
333352

334353
return {
335354
data: localSettings,

web/src/api/schema.gen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,8 @@ export interface components {
777777
* "name": "John D.",
778778
* "avatar_url": "https://avatars.akamai.steamstatic.com/0000000000000000.jpg",
779779
* "profile_url": "https://steamcommunity.com/id/john_doe",
780-
* "created_at": "2025-03-31T17:14:49.346356862+00:00",
781-
* "updated_at": "2025-03-31T17:14:49.346359012+00:00"
780+
* "created_at": "2025-04-02T19:24:57.122836365+00:00",
781+
* "updated_at": "2025-04-02T19:24:57.122838146+00:00"
782782
* }
783783
*/
784784
User: {
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { useRef } from 'react';
2+
3+
import { usePartySettings } from '@/api/party';
4+
5+
import { ServerMapModelInner } from './ServerFinder';
6+
7+
export const MapPreview = ({ party_id }: { party_id: string }) => {
8+
const { data: settings } = usePartySettings(party_id);
9+
10+
const mapRef = useRef<L.Map | null>(null);
11+
12+
return (
13+
<div className="card p-4 h-fit flex flex-col gap-2 w-full">
14+
{settings?.location?.map_id ? (
15+
<ServerMapModelInner
16+
frozen={true}
17+
mapId={settings.location.map_id}
18+
partyId={party_id}
19+
mapRef={mapRef}
20+
/>
21+
) : (
22+
<div className="text-secondary">No map selected</div>
23+
)}
24+
</div>
25+
);
26+
};

web/src/components/party/management/PartySettings.tsx

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,39 @@ import { LocationPicker } from '@/routes/$partyId';
66

77
import { PartyMembers } from './members/PartyMembers';
88

9-
export const PartySettings: FC<{party_id: string}> = ({ party_id }) => {
9+
export const PartySettings: FC<{ party_id: string }> = ({ party_id }) => {
1010
const { data: settings, update } = usePartySettings(party_id);
1111

1212
return (
1313
<div className="flex flex-col gap-2 w-full text">
14-
<div className="card p-4 h-fit flex flex-col gap-2 w-full">
15-
<h3 className="">Settings</h3>
16-
<ul className="text-secondary w-full">
17-
<li className="flex items-center justify-between gap-2">
18-
Private Party
19-
<Switch
20-
checked={settings?.private}
21-
onCheckedChange={(val) => {
22-
update('private', val);
23-
}}
24-
/>
25-
</li>
26-
<li className="flex items-center justify-between gap-2">
27-
Steam Only
28-
<Switch
29-
checked={settings?.steam_only}
30-
onCheckedChange={(val) => {
31-
update('steam_only', val);
32-
}}
33-
/>
34-
</li>
35-
</ul>
36-
<ul className="text-secondary w-full">
37-
<li className="flex items-center justify-between gap-2">
38-
<h3>Location</h3>
39-
<LocationPicker />
40-
</li>
41-
</ul>
14+
<div className="card p-4 h-fit flex flex-col gap-2 w-full">
15+
<h3 className="">Settings</h3>
16+
<ul className="text-secondary w-full">
17+
<li className="flex items-center justify-between gap-2">
18+
Private Party
19+
<Switch
20+
checked={settings?.private}
21+
onCheckedChange={(val) => {
22+
update('private', val);
23+
}}
24+
/>
25+
</li>
26+
<li className="flex items-center justify-between gap-2">
27+
Steam Only
28+
<Switch
29+
checked={settings?.steam_only}
30+
onCheckedChange={(val) => {
31+
update('steam_only', val);
32+
}}
33+
/>
34+
</li>
35+
</ul>
36+
<ul className="text-secondary w-full">
37+
<li className="flex items-center justify-between gap-2">
38+
<h3>Location</h3>
39+
<LocationPicker partyId={party_id} />
40+
</li>
41+
</ul>
4242
</div>
4343
<PartyMembers party_id={party_id} />
4444
</div>

0 commit comments

Comments
 (0)