local storage of the custom layers
This commit is contained in:
parent
f5aa70ddc2
commit
dff189b223
@ -25,10 +25,10 @@ class LocalUserStore {
|
||||
return parseInt(window.localStorage.getItem('selectedPlayer') || '');
|
||||
}
|
||||
|
||||
setCustomCursorPosition(x:number, y:number, selectedLayers: number[]): void {
|
||||
window.localStorage.setItem('customCursorPosition', JSON.stringify({x, y, selectedLayers}));
|
||||
setCustomCursorPosition(activeRow:number, selectedLayers: number[]): void {
|
||||
window.localStorage.setItem('customCursorPosition', JSON.stringify({activeRow, selectedLayers}));
|
||||
}
|
||||
getCustomCursorPosition(): {x:number, y:number, selectedLayers:number[]}|null {
|
||||
getCustomCursorPosition(): {activeRow:number, selectedLayers:number[]}|null {
|
||||
return JSON.parse(window.localStorage.getItem('customCursorPosition') || "null");
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ export class CustomizeScene extends ResizableScene {
|
||||
private selectedLayers: number[] = [0];
|
||||
private containersRow: Container[][] = [];
|
||||
private activeRow:number = 0;
|
||||
//private x:number = 0;
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
@ -110,21 +109,17 @@ export class CustomizeScene extends ResizableScene {
|
||||
this.input.keyboard.on('keydown-DOWN', () => this.moveCursorVertically(1));
|
||||
this.input.keyboard.on('keydown-UP', () => this.moveCursorVertically(-1));
|
||||
|
||||
/*const customCursorPosition = localUserStore.getCustomCursorPosition();
|
||||
const customCursorPosition = localUserStore.getCustomCursorPosition();
|
||||
if (customCursorPosition) {
|
||||
this.activeRow = customCursorPosition.activeRow;
|
||||
this.selectedLayers = customCursorPosition.selectedLayers;
|
||||
for (let i = 0; i < customCursorPosition.x; i++) this.moveCursorVertically(1);
|
||||
for (let i = 0; i < customCursorPosition.y; i++) this.moveCursorHorizontally(1);
|
||||
}*/
|
||||
this.moveLayers();
|
||||
this.updateSelectedLayer();
|
||||
}
|
||||
}
|
||||
|
||||
private moveCursorHorizontally(index: number): void {
|
||||
if (this.selectedLayers[this.activeRow] === undefined) {
|
||||
this.selectedLayers[this.activeRow] = index;
|
||||
|
||||
} else {
|
||||
this.selectedLayers[this.activeRow] += index;
|
||||
}
|
||||
this.selectedLayers[this.activeRow] += index;
|
||||
if (this.selectedLayers[this.activeRow] < 0) {
|
||||
this.selectedLayers[this.activeRow] = 0
|
||||
} else if(this.selectedLayers[this.activeRow] > LAYERS[this.activeRow].length - 1) {
|
||||
@ -132,7 +127,7 @@ export class CustomizeScene extends ResizableScene {
|
||||
}
|
||||
this.moveLayers();
|
||||
this.updateSelectedLayer();
|
||||
//this.saveInLocalStorage();
|
||||
this.saveInLocalStorage();
|
||||
}
|
||||
|
||||
private moveCursorVertically(index:number): void {
|
||||
@ -143,12 +138,12 @@ export class CustomizeScene extends ResizableScene {
|
||||
this.activeRow = LAYERS.length - 1
|
||||
}
|
||||
this.moveLayers();
|
||||
//this.saveInLocalStorage();
|
||||
this.saveInLocalStorage();
|
||||
}
|
||||
|
||||
/*private saveInLocalStorage() {
|
||||
localUserStore.setCustomCursorPosition(this.x, this.activeRow, this.selectedLayers);
|
||||
}*/
|
||||
private saveInLocalStorage() {
|
||||
localUserStore.setCustomCursorPosition(this.activeRow, this.selectedLayers);
|
||||
}
|
||||
|
||||
update(time: number, delta: number): void {
|
||||
super.update(time, delta);
|
||||
@ -163,6 +158,7 @@ export class CustomizeScene extends ResizableScene {
|
||||
*/
|
||||
private createCustomizeLayer(x: number, y: number, layerNumber: number): void {
|
||||
this.containersRow[layerNumber] = [];
|
||||
this.selectedLayers[layerNumber] = 0;
|
||||
let alpha = 0;
|
||||
let layerPosX = 0;
|
||||
for (let i = 0; i < LAYERS[layerNumber].length; i++) {
|
||||
|
Loading…
Reference in New Issue
Block a user