game picker

This commit is contained in:
Rph :3
2025-04-16 23:23:17 +02:00
parent 7796045b13
commit 89f08ff580
11 changed files with 872 additions and 11 deletions

View File

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