mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Merge branch 'main' of https://github.com/PhilipK/BoilR
This commit is contained in:
+46
-14
@@ -1,11 +1,11 @@
|
||||
use eframe::{egui, epi::{self, IconData},};
|
||||
use egui::{ScrollArea, TextureHandle, Stroke, Rounding, Image};
|
||||
use eframe::{egui, epi::{self},};
|
||||
use egui::{ScrollArea, TextureHandle, Stroke, Rounding, ImageButton};
|
||||
use futures::executor::block_on;
|
||||
use steam_shortcuts_util::shortcut::ShortcutOwned;
|
||||
use std::error::Error;
|
||||
use tokio::runtime::Runtime;
|
||||
use std::{error::Error};
|
||||
use tokio::{runtime::Runtime, sync::watch::{Receiver, self}};
|
||||
|
||||
use crate::{settings::Settings, sync::{download_images, self}, };
|
||||
use crate::{settings::Settings, sync::{download_images, self, SyncProgress}};
|
||||
|
||||
use super::{ui_images::{get_import_image, get_logo, get_logo_icon}, ui_colors::{TEXT_COLOR, BACKGROUND_COLOR, BG_STROKE_COLOR, ORANGE, PURLPLE, LIGHT_ORANGE}};
|
||||
|
||||
@@ -22,9 +22,12 @@ struct MyEguiApp {
|
||||
settings: Settings,
|
||||
rt: Runtime,
|
||||
ui_images: UiImages,
|
||||
games_to_sync:Option<Vec<(String, Vec<ShortcutOwned>)>>
|
||||
games_to_sync:Option<Vec<(String, Vec<ShortcutOwned>)>>,
|
||||
status_reciever: Receiver<SyncProgress>,
|
||||
}
|
||||
|
||||
|
||||
|
||||
impl MyEguiApp {
|
||||
pub fn new() -> Self {
|
||||
let runtime = Runtime::new().unwrap();
|
||||
@@ -34,17 +37,24 @@ impl MyEguiApp {
|
||||
rt: runtime,
|
||||
games_to_sync:None,
|
||||
ui_images: UiImages::default(),
|
||||
status_reciever: watch::channel(SyncProgress::NotStarted).1,
|
||||
}
|
||||
}
|
||||
pub fn run_sync(&self) {
|
||||
let settings = self.settings.clone();
|
||||
self.rt.spawn_blocking(move || {
|
||||
|
||||
pub fn run_sync(&mut self) {
|
||||
let (sender,mut reciever ) = watch::channel(SyncProgress::NotStarted);
|
||||
let settings = self.settings.clone();
|
||||
self.status_reciever = reciever;
|
||||
self.rt.spawn_blocking(move || {
|
||||
|
||||
MyEguiApp::save_settings_to_file(&settings);
|
||||
//TODO get status back to ui
|
||||
let usersinfo = sync::run_sync(&settings).unwrap();
|
||||
let task = download_images(&settings, &usersinfo);
|
||||
let mut some_sender =Some(sender);
|
||||
let usersinfo = sync::run_sync(&settings,&mut some_sender).unwrap();
|
||||
let task = download_images(&settings, &usersinfo,&mut some_sender);
|
||||
block_on(task);
|
||||
if let Some(sender) = some_sender{
|
||||
let _ = sender.send(SyncProgress::Done);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -93,9 +103,31 @@ impl epi::App for MyEguiApp {
|
||||
|
||||
egui::TopBottomPanel::new(egui::panel::TopBottomSide::Bottom, "Bottom Panel")
|
||||
.show(ctx,|ui|{
|
||||
{
|
||||
let status = &*self.status_reciever.borrow();
|
||||
match status{
|
||||
SyncProgress::NotStarted => {},
|
||||
SyncProgress::Starting => {
|
||||
ui.label("Starting Import");
|
||||
},
|
||||
SyncProgress::FoundGames { games_found } => {
|
||||
ui.label(format!("Found {} games to import",games_found));
|
||||
},
|
||||
SyncProgress::FindingImages => {
|
||||
ui.label(format!("Searching for images"));
|
||||
},
|
||||
SyncProgress::DownloadingImages { to_download } => {
|
||||
ui.label(format!("Downloading {} images ",to_download));
|
||||
},
|
||||
SyncProgress::Done =>{
|
||||
ui.label(format!("Done importing games"));
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
let texture = self.get_import_image(ui);
|
||||
let size = texture.size_vec2();
|
||||
let image_button = Image::new(texture, size);
|
||||
let image_button = ImageButton::new(texture, size);
|
||||
if ui.add(image_button).on_hover_text("Import your games into steam").clicked() {
|
||||
self.run_sync();
|
||||
}
|
||||
@@ -325,7 +357,7 @@ impl MyEguiApp{
|
||||
|
||||
|
||||
pub fn run_sync() {
|
||||
let app = MyEguiApp::new();
|
||||
let mut app = MyEguiApp::new();
|
||||
app.run_sync();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user