improved the local storage of the the selectcharacterScene
This commit is contained in:
parent
88a1e899a3
commit
f5aa70ddc2
4 changed files with 75 additions and 83 deletions
|
@ -6,7 +6,6 @@ class LocalUserStore {
|
|||
saveUser(localUser: LocalUser) {
|
||||
localStorage.setItem('localUser', JSON.stringify(localUser));
|
||||
}
|
||||
|
||||
getLocalUser(): LocalUser|null {
|
||||
const data = localStorage.getItem('localUser');
|
||||
return data ? JSON.parse(data) : null;
|
||||
|
@ -15,11 +14,23 @@ class LocalUserStore {
|
|||
setName(name:string): void {
|
||||
window.localStorage.setItem('playerName', name);
|
||||
}
|
||||
|
||||
getName(): string {
|
||||
return window.localStorage.getItem('playerName') ?? '';
|
||||
}
|
||||
|
||||
|
||||
setPlayerCharacterIndex(playerCharacterIndex: number): void {
|
||||
window.localStorage.setItem('selectedPlayer', ''+playerCharacterIndex);
|
||||
}
|
||||
getPlayerCharacterIndex(): number {
|
||||
return parseInt(window.localStorage.getItem('selectedPlayer') || '');
|
||||
}
|
||||
|
||||
setCustomCursorPosition(x:number, y:number, selectedLayers: number[]): void {
|
||||
window.localStorage.setItem('customCursorPosition', JSON.stringify({x, y, selectedLayers}));
|
||||
}
|
||||
getCustomCursorPosition(): {x:number, y:number, selectedLayers:number[]}|null {
|
||||
return JSON.parse(window.localStorage.getItem('customCursorPosition') || "null");
|
||||
}
|
||||
}
|
||||
|
||||
export const localUserStore = new LocalUserStore();
|
Loading…
Add table
Add a link
Reference in a new issue