|
|
|
@ -6,15 +6,14 @@ import { Rect } from '../_models/generated/Rect';
|
|
|
|
|
import { ShortcutService } from '../_services/shortcut.service';
|
|
|
|
|
import { CarouselComponent } from '../carousel/carousel.component';
|
|
|
|
|
import { PlanService } from '../_services/plan.service';
|
|
|
|
|
import { Plan, PlanElement } from '../_models/plan';
|
|
|
|
|
import { Plan, PlanElement, PlanMetadata } from '../_models/plan';
|
|
|
|
|
import { WorldAreaService } from '../_services/world-area.service';
|
|
|
|
|
import { WorldArea } from '../_models/world-area';
|
|
|
|
|
import { Observable, Subscription, from } from 'rxjs';
|
|
|
|
|
import { Subscription, from } from 'rxjs';
|
|
|
|
|
import { open } from '@tauri-apps/api/dialog';
|
|
|
|
|
import { OverlayService, StateEvent } from '../_services/overlay.service';
|
|
|
|
|
import { appWindow } from '@tauri-apps/api/window';
|
|
|
|
|
import { EventsService } from '../_services/events.service';
|
|
|
|
|
import { UnlistenFn } from '@tauri-apps/api/event';
|
|
|
|
|
import { Event } from '@tauri-apps/api/event';
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
@ -43,6 +42,9 @@ export class PlanDisplayComponent implements AfterViewInit, OnInit {
|
|
|
|
|
nextBind?: Subscription;
|
|
|
|
|
prevBind?: Subscription;
|
|
|
|
|
|
|
|
|
|
currentPlan?: Plan;
|
|
|
|
|
previousPlans: PlanMetadata[] = [];
|
|
|
|
|
|
|
|
|
|
constructor(private events: EventsService, public configService: ConfigService, private cdr: ChangeDetectorRef, private shortcut: ShortcutService, public planService: PlanService, public worldAreaService: WorldAreaService, public overlayService: OverlayService, private zone: NgZone) {
|
|
|
|
|
window.addEventListener("resize", () => {
|
|
|
|
|
this.zone.run(() => {
|
|
|
|
@ -50,21 +52,32 @@ export class PlanDisplayComponent implements AfterViewInit, OnInit {
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.planService.enumerateStoredPlans().subscribe(plans => {
|
|
|
|
|
this.previousPlans = plans;
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.planService.getCurrentPlan().subscribe(plan => {
|
|
|
|
|
this.currentPlan = plan;
|
|
|
|
|
setTimeout(() => this.setIndex(plan.current), 0);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
registerOnZoneEnter() {
|
|
|
|
|
appWindow.listen("entered", (entered) => {
|
|
|
|
|
if (this.planService.currentPlan) {
|
|
|
|
|
const current = this.planService.currentPlan.current;
|
|
|
|
|
const length = this.planService.currentPlan.plan.length;
|
|
|
|
|
if (this.currentPlan) {
|
|
|
|
|
const current = this.currentPlan.current;
|
|
|
|
|
const length = this.currentPlan.plan.length;
|
|
|
|
|
if (current + 1 < length) {
|
|
|
|
|
if (entered.payload === this.planService.currentPlan.plan[current + 1].area_key) {
|
|
|
|
|
if (entered.payload === this.currentPlan.plan[current + 1].area_key) {
|
|
|
|
|
this.zone.run(() => this.next());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.planService.getPreviousPlans();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
windowInitHandler() {
|
|
|
|
|
if (window.innerWidth > 0) {
|
|
|
|
|
this.ngAfterViewInit();
|
|
|
|
@ -110,7 +123,7 @@ export class PlanDisplayComponent implements AfterViewInit, OnInit {
|
|
|
|
|
|
|
|
|
|
hasWaypoint(key?: string): boolean {
|
|
|
|
|
if (!key) {
|
|
|
|
|
key = this.planService.currentPlan!.plan[this.planService.currentPlan!.current].area_key;
|
|
|
|
|
key = this.currentPlan!.plan[this.currentPlan!.current].area_key;
|
|
|
|
|
}
|
|
|
|
|
const world_area = this.worldAreaMap?.get(key);
|
|
|
|
|
return world_area!.has_waypoint;
|
|
|
|
@ -118,7 +131,7 @@ export class PlanDisplayComponent implements AfterViewInit, OnInit {
|
|
|
|
|
|
|
|
|
|
hasTrial(key?: string): boolean {
|
|
|
|
|
if (!key) {
|
|
|
|
|
key = this.planService.currentPlan!.plan[this.planService.currentPlan!.current].area_key;
|
|
|
|
|
key = this.currentPlan!.plan[this.currentPlan!.current].area_key;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.worldAreaService.hasTrial(key);
|
|
|
|
@ -192,7 +205,7 @@ export class PlanDisplayComponent implements AfterViewInit, OnInit {
|
|
|
|
|
|
|
|
|
|
next() {
|
|
|
|
|
if (this.overlayService.visible) {
|
|
|
|
|
this.planService.currentPlan!.next();
|
|
|
|
|
this.currentPlan!.next();
|
|
|
|
|
this.currentSlides?.next();
|
|
|
|
|
this.zoneSlides?.next();
|
|
|
|
|
}
|
|
|
|
@ -200,7 +213,7 @@ export class PlanDisplayComponent implements AfterViewInit, OnInit {
|
|
|
|
|
|
|
|
|
|
prev() {
|
|
|
|
|
if (this.overlayService.visible) {
|
|
|
|
|
this.planService.currentPlan!.prev();
|
|
|
|
|
this.currentPlan!.prev();
|
|
|
|
|
this.currentSlides?.prev();
|
|
|
|
|
this.zoneSlides?.prev();
|
|
|
|
|
}
|
|
|
|
@ -216,9 +229,9 @@ export class PlanDisplayComponent implements AfterViewInit, OnInit {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setPrevious(plan: string) {
|
|
|
|
|
this.planService.loadPrevious(plan).subscribe(plan => {
|
|
|
|
|
setTimeout(() => this.setIndex(plan.current), 0);
|
|
|
|
|
loadPrevious(path: string) {
|
|
|
|
|
this.planService.loadPlanFromPath(path, false).subscribe(plan => {
|
|
|
|
|
this.planService.setCurrentPlan(plan);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -238,7 +251,7 @@ export class PlanDisplayComponent implements AfterViewInit, OnInit {
|
|
|
|
|
]
|
|
|
|
|
})).subscribe(file => {
|
|
|
|
|
if (file) {
|
|
|
|
|
this.planService.loadPlan(file as string).subscribe(plan => {
|
|
|
|
|
this.planService.loadPlanFromPath(file as string).subscribe(plan => {
|
|
|
|
|
if (plan) {
|
|
|
|
|
this.settingsOpen = false;
|
|
|
|
|
}
|
|
|
|
@ -248,8 +261,8 @@ export class PlanDisplayComponent implements AfterViewInit, OnInit {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
loadBasePlan() {
|
|
|
|
|
this.planService.loadBasePlan().subscribe(plan => {
|
|
|
|
|
this.planService.currentPlan = new Plan(plan);
|
|
|
|
|
this.planService.getBasePlan().subscribe(plan => {
|
|
|
|
|
this.currentPlan = new Plan(plan);
|
|
|
|
|
if (this.zoneSlides) {
|
|
|
|
|
this.zoneSlides.setIndex(0);
|
|
|
|
|
}
|
|
|
|
|