From d1176043d3cb3c4de5737defd140e0a409f2fe09 Mon Sep 17 00:00:00 2001 From: isark Date: Tue, 15 Aug 2023 22:13:02 +0200 Subject: [PATCH] Fixed the overlay syncing zone changes with client file updates. Some visuals at minimum before 'usable' --- angular.json | 4 +- src-tauri/src/main.rs | 44 +++++++------------ src-tauri/src/poe_reader.rs | 4 +- src-tauri/tauri.conf.json | 7 ++- src/app/editor/editor.component.html | 1 + .../plan-display/plan-display.component.ts | 42 ++++++++++-------- 6 files changed, 49 insertions(+), 53 deletions(-) diff --git a/angular.json b/angular.json index e51cc8b..4a7ea49 100644 --- a/angular.json +++ b/angular.json @@ -39,8 +39,8 @@ "budgets": [ { "type": "initial", - "maximumWarning": "500kb", - "maximumError": "1mb" + "maximumWarning": "1500kb", + "maximumError": "2mb" }, { "type": "anyComponentStyle", diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index db05b66..0d499ab 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -13,7 +13,7 @@ use plan::Plan; use poe_data::world_area::Matcher; use poe_data::world_area::WorldAreasMap; use poe_reader::filter_func; -use poe_reader::{blocking_area_filtered_rx, entered_strings_receiver}; +use poe_reader::{blocking_area_filtered_rx, poe_client_log_receiver}; use simple_logger::SimpleLogger; use storage::Storage; use tauri::AppHandle; @@ -65,14 +65,6 @@ fn set_config( if let Ok(mut storage) = state.lock() { storage.config = config.clone(); storage.save(); - - let other_window = if window.label() == "Overlay" { - "Normal" - } else { - "Overlay" - }; - //Ignore failures! woohoo - // app.emit_to(other_window, "config", config).ok(); } } @@ -132,15 +124,15 @@ fn main() { if let Ok(storage) = app.state::>().lock() { listen_for_zone_changes( - &storage.config.poe_client_log_path, + storage.config.poe_client_log_path.clone(), app.get_window("Overlay") .expect("Could not get main overlay window"), ); } - app.get_window("Overlay") - .expect("Could not get main overlay window") - .open_devtools(); + // app.get_window("Overlay") + // .expect("Could not get main overlay window") + // .open_devtools(); Ok(()) }) @@ -179,31 +171,27 @@ fn main() { .expect("error while running tauri application"); } -fn listen_for_zone_changes(poe_client_log_path: &Option, window: Window) { - if let Some((enter_area_receiver, _watcher)) = receiver_from_path(poe_client_log_path) { - log::info!("got receiver!"); +fn listen_for_zone_changes(poe_client_log_path: Option, window: Window) { std::thread::spawn(move || { - let world_areas: WorldAreasMap = load_world_areas(); - - for area in blocking_area_filtered_rx(&enter_area_receiver) { - log::info!("Got area: {area}"); - - if let Some(area) = filter_func(area) { - log::info!("Filtered area: {area}"); - if let Some(entered) = world_areas.get(&area) { - log::info!("Entered: {entered:?}"); - window.emit_to("Overlay", "entered", &entered.named_id).ok(); + // need _watcher + if let Some((enter_area_receiver, _watcher)) = receiver_from_path(&poe_client_log_path) { + let world_areas: WorldAreasMap = load_world_areas(); + for area in blocking_area_filtered_rx(&enter_area_receiver) { + + if let Some(area) = filter_func(area) { + if let Some(entered) = world_areas.get(&area) { + window.emit_to("Overlay", "entered", &entered.named_id).ok(); + } } } } }); - } } fn receiver_from_path(path: &Option) -> Option<(Receiver, PollWatcher)> { if let Some(poe_path) = path { if poe_path.exists() { - return Some(entered_strings_receiver(poe_path.clone())); + return Some(poe_client_log_receiver(poe_path.clone())); } } diff --git a/src-tauri/src/poe_reader.rs b/src-tauri/src/poe_reader.rs index 50535d1..af5a7a1 100644 --- a/src-tauri/src/poe_reader.rs +++ b/src-tauri/src/poe_reader.rs @@ -84,12 +84,10 @@ impl LogFileReader { } } -pub fn entered_strings_receiver(path: PathBuf) -> (Receiver, PollWatcher) { +pub fn poe_client_log_receiver(path: PathBuf) -> (Receiver, PollWatcher) { let (tx, rx) = channel(); let mut lfr = LogFileReader::new(&path, tx).unwrap(); - - (rx, watch_file_for_writes(path, Box::new(move || lfr.on_write_handler()))) } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 1c0aa30..8428f10 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -30,7 +30,12 @@ "icons/icon.ico" ], "identifier": "me.isark.poe.Nothing", - "targets": "all" + "targets": "all", + "windows": { + "wix": { + "language": "en-US" + } + } }, "security": { "csp": null diff --git a/src/app/editor/editor.component.html b/src/app/editor/editor.component.html index 8349b2c..e7748c0 100644 --- a/src/app/editor/editor.component.html +++ b/src/app/editor/editor.component.html @@ -31,6 +31,7 @@
{{areasMap?.get(item.area_key)?.name}}
Act {{areasMap?.get(item.area_key)?.act}}
+
(Note)
#{{planIndexOf(item)}}
+
diff --git a/src/app/plan-display/plan-display.component.ts b/src/app/plan-display/plan-display.component.ts index d657929..f96a0eb 100644 --- a/src/app/plan-display/plan-display.component.ts +++ b/src/app/plan-display/plan-display.component.ts @@ -1,4 +1,4 @@ -import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core'; +import { AfterViewInit, ChangeDetectorRef, Component, ElementRef, Input, NgZone, OnInit, ViewChild } from '@angular/core'; import { NgxMoveableComponent, OnDragEnd, OnResize, OnResizeEnd } from 'ngx-moveable'; import { OnDrag } from 'ngx-moveable'; import { ConfigService } from '../services/config.service'; @@ -38,30 +38,28 @@ export class PlanDisplayComponent implements AfterViewInit, OnInit { settingsOpen: boolean = false; init: boolean = false; hasAttachedOnce: boolean = false; - - constructor(private events: EventsService, private configService: ConfigService, private cdr: ChangeDetectorRef, private shortcut: ShortcutService, public planService: PlanService, public worldAreaService: WorldAreaService, public overlayService: OverlayService) { - // for (let i = 0; i < 100; i++) { - // this.slides.push(i); - // } - window.addEventListener("resize", this.windowInitHandler.bind(this)); - const test = this.events.listen("OverlayStateChange").subscribe(event => { - if (!this.hasAttachedOnce) { - this.hasAttachedOnce = true; - test.unsubscribe(); - if(!event.payload.Hidden) - overlayService.setInteractable(); - } - - }); - + + constructor(private events: EventsService, private configService: ConfigService, private cdr: ChangeDetectorRef, private shortcut: ShortcutService, public planService: PlanService, public worldAreaService: WorldAreaService, public overlayService: OverlayService, private zone: NgZone) { + window.addEventListener("resize", this.windowInitHandler.bind(this)); + + const test = this.events.listen("OverlayStateChange").subscribe(event => { + if (!this.hasAttachedOnce) { + this.hasAttachedOnce = true; + test.unsubscribe(); + if (!event.payload.Hidden) + overlayService.setInteractable(); + } + + }); + appWindow.listen("entered", (entered) => { console.log("entered", entered); if (this.planService.currentPlan) { const current = this.planService.currentPlan.current; const length = this.planService.currentPlan.plan.length; if (current + 1 < length) { - if (entered.payload === this.planService.currentPlan.plan[current + 1]) { - this.next(); + if (entered.payload === this.planService.currentPlan.plan[current + 1].area_key) { + this.zone.run(() => this.next()); } } } @@ -159,11 +157,17 @@ export class PlanDisplayComponent implements AfterViewInit, OnInit { } next() { + if (this.planService.currentPlan!.current + 1 < this.planService.currentPlan!.plan.length) { + this.planService.currentPlan!.current++; + } this.currentSlides?.next(); this.zoneSlides?.next(); } prev() { + if (this.planService.currentPlan!.current - 1 >= 0) { + this.planService.currentPlan!.current--; + } this.currentSlides?.prev(); this.zoneSlides?.prev(); }