game picker
This commit is contained in:
@@ -1,14 +1,16 @@
|
||||
use std::{sync::Arc, thread, time::Duration};
|
||||
use std::{f32::consts::E, path::PathBuf, sync::Arc, thread, time::Duration};
|
||||
|
||||
use crossbeam_channel::Receiver;
|
||||
use egui::{mutex::Mutex};
|
||||
use log::debug;
|
||||
|
||||
use crate::{config, omori_locator};
|
||||
use crate::{config::{self, ConfigProvider}, omori_locator};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub enum UiState {
|
||||
Loading,
|
||||
KeyRequired(String),
|
||||
PickGame(Result<PathBuf, String>, Vec<PathBuf>),
|
||||
Error(String)
|
||||
}
|
||||
|
||||
@@ -47,6 +49,19 @@ impl AppThread {
|
||||
}
|
||||
}
|
||||
|
||||
fn pick_game(&mut self, provider: &ConfigProvider) -> anyhow::Result<()> {
|
||||
let steam_location = match omori_locator::get_omori_path() {
|
||||
Ok(l) => Ok(l),
|
||||
Err(e) => Err(String::from(format!("{:#}", e)))
|
||||
};
|
||||
|
||||
let location_history = provider.get_game_paths()?;
|
||||
|
||||
self.commit(UiState::PickGame(steam_location.clone(), location_history.clone()));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn create(state_holder: &UiStateHolder, context: &egui::Context, ui_event_channel: &Receiver<UiEvent>) -> AppThread {
|
||||
AppThread {
|
||||
ui_state: state_holder.clone(),
|
||||
@@ -57,6 +72,7 @@ impl AppThread {
|
||||
}
|
||||
|
||||
fn real_main(&mut self) -> anyhow::Result<()> {
|
||||
debug!("I am ALIVE! HAHAHAHA!");
|
||||
self.commit(UiState::Loading);
|
||||
|
||||
let mut config_provider = config::ConfigProvider::new()?;
|
||||
@@ -71,6 +87,8 @@ impl AppThread {
|
||||
|
||||
config_provider.set_key(&self.decryption_key)?;
|
||||
|
||||
self.pick_game(&config_provider);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user