Skip to content

Commit 769d3d1

Browse files
committed
[radio] better overlay drag system
1 parent f17cb1e commit 769d3d1

File tree

2 files changed

+45
-4
lines changed

2 files changed

+45
-4
lines changed

ui/src/components/overlay.svelte

+10-1
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,22 @@
4141
if (moving) {
4242
right -= e.movementX;
4343
top += e.movementY;
44+
45+
right = Math.min(Math.max(right, 0), window.innerWidth - node.offsetWidth);
46+
top = Math.min(Math.max(top, 0), window.innerHeight - node.offsetHeight);
47+
4448
node.style.top = `${top}px`;
4549
node.style.right = `${right}px`;
50+
51+
RADIODATA.update((old: any) => {
52+
return { ...old, userData: { ...old.userData, playerlist: { ...old.userData.playerlist, coords: { x: right, y: top } } } }
53+
})
4654
}
4755
});
4856
4957
window.addEventListener('mouseup', () => {
5058
moving = false;
59+
SendNUI('updatePlayerListPosition', { y: top, x: right })
5160
});
5261
5362
SHOWFORCEPLAYERLIST.subscribe(() => {
@@ -58,7 +67,7 @@
5867

5968
{#if isPlayerListVisible}
6069
{#if $RADIODATA.onRadio}
61-
<div class="w-[15vw] absolute z-[1000] text-right select-none" style="top: {$RADIODATA.userData.playerlist.coords.y}px; right: {$RADIODATA.userData.playerlist.coords.x}px;cursor:{$SHOW? 'move':'no-drop'}" use:dragMe>
70+
<div class="max-w-[15vw] absolute z-[1000] text-right select-none" style="top: {$RADIODATA.userData.playerlist.coords.y}px; right: {$RADIODATA.userData.playerlist.coords.x}px;cursor:{$SHOW? 'move':'no-drop'}" use:dragMe>
6271
{#each Object.entries($PLAYERLIST) as [id, player], index (id)}
6372
{#if player.isTalking || $SHOWFORCEPLAYERLIST}
6473
<div class="text-[1.7vh] font-bold px-2 text-white">{player.name}</div>

ui/src/providers/DebugBrowser.svelte

+35-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,32 @@
2424
volume: 80,
2525
favourite: [56.2, 54.1, 57.3, 58.6, 59.8, 56.2, 54.1, 57.3, 58.6, 59.8],
2626
recomended: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0],
27+
userData: {
28+
playerlist: {
29+
show: true,
30+
coords: {
31+
x: 15,
32+
y: 40,
33+
},
34+
},
35+
},
2736
time: "18:46",
2837
street: "Mirror Park Boulevard",
29-
players: {}
38+
maxChannel: 500,
39+
locale: {
40+
"header": "IN RADIO",
41+
"frequency": "Frequency",
42+
"disconnect": "DISCONNECT",
43+
"notconnected": "NOT CONNECTED",
44+
"channels": "Channels",
45+
"radio": "Radio",
46+
"members": "Members",
47+
"favorites": "Favorites",
48+
"recommended": "Recommended",
49+
"clear": "CLEAR",
50+
"hide_overlay": "HIDE OVERLAY",
51+
"show_overlay": "SHOW OVERLAY"
52+
}
3053
},
3154
},
3255
{
@@ -41,8 +64,17 @@
4164
actions : [
4265
{
4366
name: "toggle",
44-
action: "notify",
45-
data: true,
67+
action: "updateRadioList",
68+
data: {
69+
"1": {
70+
name: "Uday Shetty",
71+
isTalking: true
72+
},
73+
"2": {
74+
name: "Uday Shetty",
75+
isTalking: true
76+
}
77+
},
4678
}
4779
]
4880
},

0 commit comments

Comments
 (0)