Fixed the overlay syncing zone changes with client file updates. Some visuals at minimum before 'usable'

merge-notes
isark 2 years ago
parent f140ed279b
commit d1176043d3

@ -39,8 +39,8 @@
"budgets": [ "budgets": [
{ {
"type": "initial", "type": "initial",
"maximumWarning": "500kb", "maximumWarning": "1500kb",
"maximumError": "1mb" "maximumError": "2mb"
}, },
{ {
"type": "anyComponentStyle", "type": "anyComponentStyle",

@ -13,7 +13,7 @@ use plan::Plan;
use poe_data::world_area::Matcher; use poe_data::world_area::Matcher;
use poe_data::world_area::WorldAreasMap; use poe_data::world_area::WorldAreasMap;
use poe_reader::filter_func; 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 simple_logger::SimpleLogger;
use storage::Storage; use storage::Storage;
use tauri::AppHandle; use tauri::AppHandle;
@ -65,14 +65,6 @@ fn set_config(
if let Ok(mut storage) = state.lock() { if let Ok(mut storage) = state.lock() {
storage.config = config.clone(); storage.config = config.clone();
storage.save(); 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::<Mutex<Storage>>().lock() { if let Ok(storage) = app.state::<Mutex<Storage>>().lock() {
listen_for_zone_changes( listen_for_zone_changes(
&storage.config.poe_client_log_path, storage.config.poe_client_log_path.clone(),
app.get_window("Overlay") app.get_window("Overlay")
.expect("Could not get main overlay window"), .expect("Could not get main overlay window"),
); );
} }
app.get_window("Overlay") // app.get_window("Overlay")
.expect("Could not get main overlay window") // .expect("Could not get main overlay window")
.open_devtools(); // .open_devtools();
Ok(()) Ok(())
}) })
@ -179,31 +171,27 @@ fn main() {
.expect("error while running tauri application"); .expect("error while running tauri application");
} }
fn listen_for_zone_changes(poe_client_log_path: &Option<PathBuf>, window: Window) { fn listen_for_zone_changes(poe_client_log_path: Option<PathBuf>, window: Window) {
if let Some((enter_area_receiver, _watcher)) = receiver_from_path(poe_client_log_path) {
log::info!("got receiver!");
std::thread::spawn(move || { std::thread::spawn(move || {
let world_areas: WorldAreasMap = load_world_areas(); // need _watcher
if let Some((enter_area_receiver, _watcher)) = receiver_from_path(&poe_client_log_path) {
for area in blocking_area_filtered_rx(&enter_area_receiver) { let world_areas: WorldAreasMap = load_world_areas();
log::info!("Got area: {area}"); for area in blocking_area_filtered_rx(&enter_area_receiver) {
if let Some(area) = filter_func(area) { if let Some(area) = filter_func(area) {
log::info!("Filtered area: {area}"); if let Some(entered) = world_areas.get(&area) {
if let Some(entered) = world_areas.get(&area) { window.emit_to("Overlay", "entered", &entered.named_id).ok();
log::info!("Entered: {entered:?}"); }
window.emit_to("Overlay", "entered", &entered.named_id).ok();
} }
} }
} }
}); });
}
} }
fn receiver_from_path(path: &Option<PathBuf>) -> Option<(Receiver<String>, PollWatcher)> { fn receiver_from_path(path: &Option<PathBuf>) -> Option<(Receiver<String>, PollWatcher)> {
if let Some(poe_path) = path { if let Some(poe_path) = path {
if poe_path.exists() { if poe_path.exists() {
return Some(entered_strings_receiver(poe_path.clone())); return Some(poe_client_log_receiver(poe_path.clone()));
} }
} }

@ -84,12 +84,10 @@ impl LogFileReader {
} }
} }
pub fn entered_strings_receiver(path: PathBuf) -> (Receiver<String>, PollWatcher) { pub fn poe_client_log_receiver(path: PathBuf) -> (Receiver<String>, PollWatcher) {
let (tx, rx) = channel(); let (tx, rx) = channel();
let mut lfr = LogFileReader::new(&path, tx).unwrap(); let mut lfr = LogFileReader::new(&path, tx).unwrap();
(rx, watch_file_for_writes(path, Box::new(move || lfr.on_write_handler()))) (rx, watch_file_for_writes(path, Box::new(move || lfr.on_write_handler())))
} }

@ -30,7 +30,12 @@
"icons/icon.ico" "icons/icon.ico"
], ],
"identifier": "me.isark.poe.Nothing", "identifier": "me.isark.poe.Nothing",
"targets": "all" "targets": "all",
"windows": {
"wix": {
"language": "en-US"
}
}
}, },
"security": { "security": {
"csp": null "csp": null

@ -31,6 +31,7 @@
<div class="zone-name">{{areasMap?.get(item.area_key)?.name}}</div> <div class="zone-name">{{areasMap?.get(item.area_key)?.name}}</div>
<div class="act">Act {{areasMap?.get(item.area_key)?.act}}</div> <div class="act">Act {{areasMap?.get(item.area_key)?.act}}</div>
</div> </div>
<div *ngIf="item.notes" class="notes">(Note)</div>
<div class="index">#{{planIndexOf(item)}}</div> <div class="index">#{{planIndexOf(item)}}</div>
<div class="delete" (click)="remove(item)">+</div> <div class="delete" (click)="remove(item)">+</div>
</div> </div>

@ -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 { NgxMoveableComponent, OnDragEnd, OnResize, OnResizeEnd } from 'ngx-moveable';
import { OnDrag } from 'ngx-moveable'; import { OnDrag } from 'ngx-moveable';
import { ConfigService } from '../services/config.service'; import { ConfigService } from '../services/config.service';
@ -38,30 +38,28 @@ export class PlanDisplayComponent implements AfterViewInit, OnInit {
settingsOpen: boolean = false; settingsOpen: boolean = false;
init: boolean = false; init: boolean = false;
hasAttachedOnce: 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) { 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) {
// for (let i = 0; i < 100; i++) { window.addEventListener("resize", this.windowInitHandler.bind(this));
// this.slides.push(i);
// } const test = this.events.listen<StateEvent>("OverlayStateChange").subscribe(event => {
window.addEventListener("resize", this.windowInitHandler.bind(this)); if (!this.hasAttachedOnce) {
const test = this.events.listen<StateEvent>("OverlayStateChange").subscribe(event => { this.hasAttachedOnce = true;
if (!this.hasAttachedOnce) { test.unsubscribe();
this.hasAttachedOnce = true; if (!event.payload.Hidden)
test.unsubscribe(); overlayService.setInteractable();
if(!event.payload.Hidden) }
overlayService.setInteractable();
} });
});
appWindow.listen("entered", (entered) => { appWindow.listen("entered", (entered) => {
console.log("entered", entered); console.log("entered", entered);
if (this.planService.currentPlan) { if (this.planService.currentPlan) {
const current = this.planService.currentPlan.current; const current = this.planService.currentPlan.current;
const length = this.planService.currentPlan.plan.length; const length = this.planService.currentPlan.plan.length;
if (current + 1 < length) { if (current + 1 < length) {
if (entered.payload === this.planService.currentPlan.plan[current + 1]) { if (entered.payload === this.planService.currentPlan.plan[current + 1].area_key) {
this.next(); this.zone.run(() => this.next());
} }
} }
} }
@ -159,11 +157,17 @@ export class PlanDisplayComponent implements AfterViewInit, OnInit {
} }
next() { next() {
if (this.planService.currentPlan!.current + 1 < this.planService.currentPlan!.plan.length) {
this.planService.currentPlan!.current++;
}
this.currentSlides?.next(); this.currentSlides?.next();
this.zoneSlides?.next(); this.zoneSlides?.next();
} }
prev() { prev() {
if (this.planService.currentPlan!.current - 1 >= 0) {
this.planService.currentPlan!.current--;
}
this.currentSlides?.prev(); this.currentSlides?.prev();
this.zoneSlides?.prev(); this.zoneSlides?.prev();
} }

Loading…
Cancel
Save