Adding the ability to set the player's color outline via the scripting API
(currently not shared with the other players yet)
This commit is contained in:
parent
e086f6dac0
commit
90f7287860
11 changed files with 282 additions and 9 deletions
40
front/src/Stores/OutlineColorStore.ts
Normal file
40
front/src/Stores/OutlineColorStore.ts
Normal file
|
@ -0,0 +1,40 @@
|
|||
import { writable } from "svelte/store";
|
||||
|
||||
export function createColorStore() {
|
||||
const { subscribe, set } = writable<number | undefined>(undefined);
|
||||
|
||||
let color: number | undefined = undefined;
|
||||
let focused: boolean = false;
|
||||
|
||||
const updateColor = () => {
|
||||
if (focused) {
|
||||
set(0xffff00);
|
||||
} else {
|
||||
set(color);
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
|
||||
pointerOver() {
|
||||
focused = true;
|
||||
updateColor();
|
||||
},
|
||||
|
||||
pointerOut() {
|
||||
focused = false;
|
||||
updateColor();
|
||||
},
|
||||
|
||||
setColor(newColor: number) {
|
||||
color = newColor;
|
||||
updateColor();
|
||||
},
|
||||
|
||||
removeColor() {
|
||||
color = undefined;
|
||||
updateColor();
|
||||
},
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue