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