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": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
"maximumWarning": "1500kb",
"maximumError": "2mb"
},
{
"type": "anyComponentStyle",

@ -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::<Mutex<Storage>>().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<PathBuf>, 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<PathBuf>, 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<PathBuf>) -> Option<(Receiver<String>, 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()));
}
}

@ -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 mut lfr = LogFileReader::new(&path, tx).unwrap();
(rx, watch_file_for_writes(path, Box::new(move || lfr.on_write_handler())))
}

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

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

Loading…
Cancel
Save