|
|
|
@ -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()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|