mirror of
https://github.com/ALEZ-DEV/Babylonia-terminal.git
synced 2025-12-16 09:28:53 +00:00
update rust backend on the flutter side
This commit is contained in:
parent
b0b76354fa
commit
2bbcc3e5af
@ -12,8 +12,6 @@ void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
MediaKit.ensureInitialized();
|
||||
|
||||
|
||||
|
||||
final SettingsProvider settings = SettingsProvider();
|
||||
await settings.init();
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
use babylonia_terminal_sdk::game_state::GameState;
|
||||
use babylonia_terminal_sdk::game_config::GameConfig;
|
||||
|
||||
use crate::messages::config::{ConfigInput, ConfigOutput};
|
||||
|
||||
pub async fn listen_config() {
|
||||
let mut receiver = ConfigInput::get_dart_signal_receiver();
|
||||
let mut receiver = ConfigInput::get_dart_signal_receiver().unwrap();
|
||||
while let Some(_) = receiver.recv().await {
|
||||
let config = GameState::get_config().await;
|
||||
let config = GameConfig::get_config().await;
|
||||
ConfigOutput {
|
||||
config_path: config.config_dir.to_str().unwrap().to_string(),
|
||||
}
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
use std::thread;
|
||||
|
||||
use babylonia_terminal_sdk::{
|
||||
components::proton_component::ProtonComponent, game_manager::GameManager, game_state::GameState,
|
||||
};
|
||||
use babylonia_terminal_sdk::game_manager::GameManager;
|
||||
use tokio_with_wasm::tokio;
|
||||
|
||||
use crate::{
|
||||
@ -16,7 +14,7 @@ use crate::{
|
||||
};
|
||||
|
||||
pub async fn listen_dependecies_installation() {
|
||||
let mut receiver = StartDependenciesInstallation::get_dart_signal_receiver();
|
||||
let mut receiver = StartDependenciesInstallation::get_dart_signal_receiver().unwrap();
|
||||
while let Some(_) = receiver.recv().await {
|
||||
let proton = get_proton().await;
|
||||
|
||||
|
||||
@ -1,12 +1,9 @@
|
||||
use std::thread;
|
||||
|
||||
use babylonia_terminal_sdk::{
|
||||
components::{
|
||||
dxvk_component::{DXVK_DEV, DXVK_REPO},
|
||||
proton_component::ProtonComponent,
|
||||
},
|
||||
components::dxvk_component::{DXVK_DEV, DXVK_REPO},
|
||||
game_config::GameConfig,
|
||||
game_manager::GameManager,
|
||||
game_state::GameState,
|
||||
utils::github_requester::{GithubRelease, GithubRequester},
|
||||
};
|
||||
use tokio_with_wasm::tokio;
|
||||
@ -24,7 +21,7 @@ use crate::{
|
||||
};
|
||||
|
||||
pub async fn listen_dxvk_installation() {
|
||||
let mut receiver = StartDxvkInstallation::get_dart_signal_receiver();
|
||||
let mut receiver = StartDxvkInstallation::get_dart_signal_receiver().unwrap();
|
||||
while let Some(info) = receiver.recv().await {
|
||||
let releases: Result<Vec<GithubRelease>, _> =
|
||||
GithubInfo::get_github_releases(DXVK_DEV, DXVK_REPO).await;
|
||||
@ -59,7 +56,7 @@ pub async fn listen_dxvk_installation() {
|
||||
.block_on(async {
|
||||
match GameManager::install_dxvk(
|
||||
&proton,
|
||||
GameState::get_config().await.config_dir,
|
||||
GameConfig::get_config().await.config_dir,
|
||||
release_index.unwrap(),
|
||||
Some(DownloadReporter::create()),
|
||||
)
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
use std::thread;
|
||||
|
||||
use babylonia_terminal_sdk::{
|
||||
components::proton_component::ProtonComponent, game_manager::GameManager, game_state::GameState,
|
||||
};
|
||||
use babylonia_terminal_sdk::game_manager::GameManager;
|
||||
use tokio_with_wasm::tokio;
|
||||
|
||||
use crate::{
|
||||
@ -16,7 +14,7 @@ use crate::{
|
||||
};
|
||||
|
||||
pub async fn listen_fonts_installation() {
|
||||
let mut receiver = StartFontsInstallation::get_dart_signal_receiver();
|
||||
let mut receiver = StartFontsInstallation::get_dart_signal_receiver().unwrap();
|
||||
while let Some(_) = receiver.recv().await {
|
||||
let proton = get_proton().await;
|
||||
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
use std::thread;
|
||||
|
||||
use babylonia_terminal_sdk::{
|
||||
components::proton_component::ProtonComponent, game_manager::GameManager, game_state::GameState,
|
||||
};
|
||||
use babylonia_terminal_sdk::{game_config::GameConfig, game_manager::GameManager};
|
||||
use rinf::debug_print;
|
||||
use tokio_with_wasm::tokio;
|
||||
|
||||
@ -10,36 +8,44 @@ use crate::{
|
||||
messages::{
|
||||
error::ReportError,
|
||||
steps::game::{
|
||||
GameInstallationProgress, GameStopped, NotifyGameStartDownloading,
|
||||
NotifyGameStartPatching, NotifyGameSuccessfullyInstalled, RunGame,
|
||||
StartGameInstallation,
|
||||
GameInstallationProgress, GameStopped, NotifyGameStartPatching,
|
||||
NotifyGameSuccessfullyInstalled, RunGame, StartGameInstallation,
|
||||
},
|
||||
},
|
||||
proton::get_proton,
|
||||
};
|
||||
|
||||
pub async fn listen_game_running() {
|
||||
let mut receiver = RunGame::get_dart_signal_receiver();
|
||||
while let Some(_) = receiver.recv().await {
|
||||
let proton = get_proton().await;
|
||||
let game_dir = GameState::get_game_dir().await;
|
||||
if game_dir.is_none() {
|
||||
ReportError {
|
||||
error_message: "Failed to start game, the game directory was not found".to_string(),
|
||||
}
|
||||
.send_signal_to_dart();
|
||||
GameStopped {}.send_signal_to_dart();
|
||||
continue;
|
||||
}
|
||||
let mut receiver = RunGame::get_dart_signal_receiver().unwrap();
|
||||
thread::spawn(move || {
|
||||
tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
.unwrap()
|
||||
.block_on(async {
|
||||
while let Some(_) = receiver.recv().await {
|
||||
let proton = get_proton().await;
|
||||
let game_dir = GameConfig::get_game_dir().await;
|
||||
if game_dir.is_none() {
|
||||
ReportError {
|
||||
error_message: "Failed to start game, the game directory was not found"
|
||||
.to_string(),
|
||||
}
|
||||
.send_signal_to_dart();
|
||||
GameStopped {}.send_signal_to_dart();
|
||||
continue;
|
||||
}
|
||||
|
||||
GameManager::start_game(&proton, game_dir.unwrap()).await;
|
||||
GameManager::start_game(&proton, game_dir.unwrap(), None, false).await;
|
||||
|
||||
GameStopped {}.send_signal_to_dart();
|
||||
}
|
||||
GameStopped {}.send_signal_to_dart();
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
pub async fn listen_game_installation() {
|
||||
let mut receiver = StartGameInstallation::get_dart_signal_receiver();
|
||||
let mut receiver = StartGameInstallation::get_dart_signal_receiver().unwrap();
|
||||
while let Some(info) = receiver.recv().await {
|
||||
thread::spawn(move || {
|
||||
debug_print!("start downloading game...");
|
||||
@ -48,9 +54,9 @@ pub async fn listen_game_installation() {
|
||||
.build()
|
||||
.unwrap()
|
||||
.block_on(async {
|
||||
if GameState::get_game_dir().await.is_none() {
|
||||
if GameConfig::get_game_dir().await.is_none() {
|
||||
if let Err(e) =
|
||||
GameState::set_game_dir(Some(GameState::get_config_directory().await))
|
||||
GameConfig::set_game_dir(Some(GameConfig::get_config_directory().await))
|
||||
.await
|
||||
{
|
||||
ReportError {
|
||||
@ -69,7 +75,7 @@ pub async fn listen_game_installation() {
|
||||
}
|
||||
}
|
||||
|
||||
let game_dir = GameState::get_game_dir().await;
|
||||
let game_dir = GameConfig::get_game_dir().await;
|
||||
if game_dir.is_none() {
|
||||
ReportError {
|
||||
error_message: "Failed to get the game directory".to_string(),
|
||||
|
||||
@ -24,7 +24,7 @@ impl GameStateMessage {
|
||||
}
|
||||
|
||||
pub async fn listen_game_state() {
|
||||
let mut receiver = AskGameState::get_dart_signal_receiver();
|
||||
let mut receiver = AskGameState::get_dart_signal_receiver().unwrap();
|
||||
while let Some(_) = receiver.recv().await {
|
||||
let result_state = GameState::get_current_state().await;
|
||||
match result_state {
|
||||
|
||||
@ -21,7 +21,7 @@ impl GithubRequester for GithubInfo {
|
||||
}
|
||||
|
||||
pub async fn listen_proton_version() {
|
||||
let mut receiver = AskProtonVersions::get_dart_signal_receiver();
|
||||
let mut receiver = AskProtonVersions::get_dart_signal_receiver().unwrap();
|
||||
while let Some(_) = receiver.recv().await {
|
||||
let releases: Result<Vec<GithubRelease>, _> =
|
||||
GithubInfo::get_github_releases(PROTON_DEV, PROTON_REPO).await;
|
||||
@ -39,7 +39,7 @@ pub async fn listen_proton_version() {
|
||||
}
|
||||
|
||||
pub async fn listen_dxvk_version() {
|
||||
let mut receiver = AskDxvkVersions::get_dart_signal_receiver();
|
||||
let mut receiver = AskDxvkVersions::get_dart_signal_receiver().unwrap();
|
||||
while let Some(_) = receiver.recv().await {
|
||||
let releases: Result<Vec<GithubRelease>, _> =
|
||||
GithubInfo::get_github_releases(DXVK_DEV, DXVK_REPO).await;
|
||||
|
||||
@ -1,15 +1,11 @@
|
||||
use std::thread;
|
||||
|
||||
use babylonia_terminal_sdk::{
|
||||
components::{
|
||||
component_downloader::ComponentDownloader,
|
||||
proton_component::{ProtonComponent, PROTON_DEV, PROTON_REPO},
|
||||
},
|
||||
components::proton_component::{ProtonComponent, PROTON_DEV, PROTON_REPO},
|
||||
game_config::GameConfig,
|
||||
game_manager::GameManager,
|
||||
game_state::GameState,
|
||||
utils::github_requester::{GithubRelease, GithubRequester},
|
||||
};
|
||||
use rinf::debug_print;
|
||||
use tokio_with_wasm::tokio::{self, sync::OnceCell};
|
||||
use wincompatlib::wine::bundle::proton::Proton;
|
||||
|
||||
@ -29,7 +25,7 @@ static PROTON: OnceCell<Proton> = OnceCell::const_new();
|
||||
pub async fn get_proton() -> Proton {
|
||||
PROTON
|
||||
.get_or_init(|| async {
|
||||
let proton_component = ProtonComponent::new(GameState::get_config().await.config_dir);
|
||||
let proton_component = ProtonComponent::new(GameConfig::get_config().await.config_dir);
|
||||
let proton = proton_component.init_proton();
|
||||
if let Err(ref e) = proton {
|
||||
ReportError {
|
||||
@ -44,7 +40,7 @@ pub async fn get_proton() -> Proton {
|
||||
}
|
||||
|
||||
pub async fn listen_proton_installation() {
|
||||
let mut receiver = StartProtonInstallation::get_dart_signal_receiver();
|
||||
let mut receiver = StartProtonInstallation::get_dart_signal_receiver().unwrap();
|
||||
while let Some(info) = receiver.recv().await {
|
||||
let releases: Result<Vec<GithubRelease>, _> =
|
||||
GithubInfo::get_github_releases(PROTON_DEV, PROTON_REPO).await;
|
||||
@ -76,7 +72,7 @@ pub async fn listen_proton_installation() {
|
||||
.unwrap()
|
||||
.block_on(async {
|
||||
match GameManager::install_wine(
|
||||
GameState::get_config().await.config_dir,
|
||||
GameConfig::get_config().await.config_dir,
|
||||
release_index.unwrap(),
|
||||
Some(DownloadReporter::create()),
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user