|
|
|
@ -51,10 +51,10 @@ interface Act {
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
export class EditorComponent implements OnInit {
|
|
|
|
|
planInEditing: Plan;
|
|
|
|
|
|
|
|
|
|
areas?: WorldArea[];
|
|
|
|
|
planAreas: WorldArea[];
|
|
|
|
|
plan: Plan;
|
|
|
|
|
areasMap?: Map<String, WorldArea>;
|
|
|
|
|
areaSearchString: string = "";
|
|
|
|
|
planSearchString: string = "";
|
|
|
|
@ -69,7 +69,7 @@ export class EditorComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
constructor(public worldAreaService: WorldAreaService, private cdr: ChangeDetectorRef, private planService: PlanService, public dialog: MatDialog) {
|
|
|
|
|
this.plan = new Plan({
|
|
|
|
|
this.planInEditing = new Plan({
|
|
|
|
|
plan: [],
|
|
|
|
|
current: 0
|
|
|
|
|
});
|
|
|
|
@ -77,7 +77,7 @@ export class EditorComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
this.autoScrollToEnd = false;
|
|
|
|
|
|
|
|
|
|
this.planFuzzer = new Fuzzr(this.plan.plan, {
|
|
|
|
|
this.planFuzzer = new Fuzzr(this.planInEditing.plan, {
|
|
|
|
|
toString: (e: PlanElement) => {
|
|
|
|
|
return this.areasMap?.get(e.area_key)?.name;
|
|
|
|
|
}
|
|
|
|
@ -113,11 +113,11 @@ export class EditorComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
dropHandler(event: CdkDragDrop<WorldArea[]> | CdkDragDrop<PlanElement[]>) {
|
|
|
|
|
if (event.previousContainer === event.container && !isWorldAreaEvent(event)) {
|
|
|
|
|
const realCurrent = this.plan.plan.indexOf(event.previousContainer.data[event.currentIndex]);
|
|
|
|
|
const realPrev = this.plan.plan.indexOf(event.previousContainer.data[event.previousIndex]);
|
|
|
|
|
moveItemInArray(this.plan.plan, realPrev, realCurrent);
|
|
|
|
|
const realCurrent = this.planInEditing.plan.indexOf(event.previousContainer.data[event.currentIndex]);
|
|
|
|
|
const realPrev = this.planInEditing.plan.indexOf(event.previousContainer.data[event.previousIndex]);
|
|
|
|
|
moveItemInArray(this.planInEditing.plan, realPrev, realCurrent);
|
|
|
|
|
} else
|
|
|
|
|
if (this.plan && this.areas && isWorldAreaEvent(event)) {
|
|
|
|
|
if (this.planInEditing && this.areas && isWorldAreaEvent(event)) {
|
|
|
|
|
if (event.container.data.length > 0 && 'connections_world_areas_keys' in event.container.data[0]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -127,17 +127,15 @@ export class EditorComponent implements OnInit {
|
|
|
|
|
if(bounds) {
|
|
|
|
|
index += bounds[0];
|
|
|
|
|
}
|
|
|
|
|
this.plan.plan.splice(index, 0, this.planItemFromArea(event.previousContainer.data[event.previousIndex]));
|
|
|
|
|
this.planInEditing.plan.splice(index, 0, this.planItemFromArea(event.previousContainer.data[event.previousIndex]));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dropEndHandler(event: CdkDragDrop<WorldArea[]> | CdkDragDrop<PlanElement[]>) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isWorldAreaEvent(event) && this.areas) {
|
|
|
|
|
this.plan.plan.splice(this.getEnd(), 0, this.planItemFromArea(event.previousContainer.data[event.previousIndex]));
|
|
|
|
|
this.planInEditing.plan.splice(this.getEnd(), 0, this.planItemFromArea(event.previousContainer.data[event.previousIndex]));
|
|
|
|
|
} else {
|
|
|
|
|
moveItemInArray(this.plan.plan, event.previousIndex, this.getEnd());
|
|
|
|
|
moveItemInArray(this.planInEditing.plan, event.previousIndex, this.getEnd());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.scrollToEnd();
|
|
|
|
@ -148,12 +146,12 @@ export class EditorComponent implements OnInit {
|
|
|
|
|
if (bounds) {
|
|
|
|
|
return bounds[1];
|
|
|
|
|
} else {
|
|
|
|
|
return this.plan.plan.length;
|
|
|
|
|
return this.planInEditing.plan.length;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
remove(item: PlanElement) {
|
|
|
|
|
this.plan.plan.splice(this.planIndexOf(item), 1);
|
|
|
|
|
this.planInEditing.plan.splice(this.planIndexOf(item), 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
canDrop = () => {
|
|
|
|
@ -192,13 +190,13 @@ export class EditorComponent implements OnInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
doubleClickArea(item: WorldArea) {
|
|
|
|
|
this.plan.plan.splice(this.plan.plan.length, 0, this.planItemFromArea(item));
|
|
|
|
|
this.planInEditing.plan.splice(this.planInEditing.plan.length, 0, this.planItemFromArea(item));
|
|
|
|
|
this.scrollToEnd();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
planElemFilterBounds() {
|
|
|
|
|
if(this.planFilterAct.value !== 0) {
|
|
|
|
|
let bounds = this.plan.plan.filter(item => item.anchor_act === this.planFilterAct.value || this.planFilterAct.value + 1 === item.anchor_act).map((value) => this.planIndexOf(value));
|
|
|
|
|
let bounds = this.planInEditing.plan.filter(item => item.anchor_act === this.planFilterAct.value || this.planFilterAct.value + 1 === item.anchor_act).map((value) => this.planIndexOf(value));
|
|
|
|
|
console.log("bounds, ", bounds);
|
|
|
|
|
if (bounds.length == 2) {
|
|
|
|
|
return bounds;
|
|
|
|
@ -206,7 +204,7 @@ export class EditorComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
if(bounds.length == 1 && this.planFilterAct.value == 10) {
|
|
|
|
|
console.log("Setting bound to last index");
|
|
|
|
|
bounds[1] = this.plan.plan.length;
|
|
|
|
|
bounds[1] = this.planInEditing.plan.length;
|
|
|
|
|
return bounds;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -241,7 +239,7 @@ export class EditorComponent implements OnInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
return this.plan.plan;
|
|
|
|
|
return this.planInEditing.plan;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -253,12 +251,12 @@ export class EditorComponent implements OnInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
planIndexOf(planElement: PlanElement) {
|
|
|
|
|
const index = this.plan.plan.indexOf(planElement);
|
|
|
|
|
const index = this.planInEditing.plan.indexOf(planElement);
|
|
|
|
|
return index;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
clearPlan() {
|
|
|
|
|
this.plan.plan.length = 0;
|
|
|
|
|
this.planInEditing.plan.length = 0;
|
|
|
|
|
this.cdr.detectChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -270,7 +268,7 @@ export class EditorComponent implements OnInit {
|
|
|
|
|
}]
|
|
|
|
|
})).subscribe(file => {
|
|
|
|
|
if (file) {
|
|
|
|
|
this.planService.savePlan(file as string, this.plan);
|
|
|
|
|
this.planService.savePlan(file as string, this.planInEditing);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
@ -287,8 +285,8 @@ export class EditorComponent implements OnInit {
|
|
|
|
|
})).subscribe(file => {
|
|
|
|
|
if (file) {
|
|
|
|
|
this.planService.loadPlanNoSave(file as string).subscribe(plan => {
|
|
|
|
|
this.plan.plan.length = 0;
|
|
|
|
|
plan.plan.forEach(p => this.plan.plan.push(p));
|
|
|
|
|
this.planInEditing.plan.length = 0;
|
|
|
|
|
plan.plan.forEach(p => this.planInEditing.plan.push(p));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -296,8 +294,8 @@ export class EditorComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
loadBasePlan() {
|
|
|
|
|
this.planService.loadBasePlan().subscribe(plan => {
|
|
|
|
|
this.plan.plan.length = 0;
|
|
|
|
|
plan.plan.forEach(p => this.plan.plan.push(p));
|
|
|
|
|
this.planInEditing.plan.length = 0;
|
|
|
|
|
plan.plan.forEach(p => this.planInEditing.plan.push(p));
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|