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();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
MediaKit.ensureInitialized();
|
MediaKit.ensureInitialized();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
final SettingsProvider settings = SettingsProvider();
|
final SettingsProvider settings = SettingsProvider();
|
||||||
await settings.init();
|
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};
|
use crate::messages::config::{ConfigInput, ConfigOutput};
|
||||||
|
|
||||||
pub async fn listen_config() {
|
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 {
|
while let Some(_) = receiver.recv().await {
|
||||||
let config = GameState::get_config().await;
|
let config = GameConfig::get_config().await;
|
||||||
ConfigOutput {
|
ConfigOutput {
|
||||||
config_path: config.config_dir.to_str().unwrap().to_string(),
|
config_path: config.config_dir.to_str().unwrap().to_string(),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
use babylonia_terminal_sdk::{
|
use babylonia_terminal_sdk::game_manager::GameManager;
|
||||||
components::proton_component::ProtonComponent, game_manager::GameManager, game_state::GameState,
|
|
||||||
};
|
|
||||||
use tokio_with_wasm::tokio;
|
use tokio_with_wasm::tokio;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -16,7 +14,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub async fn listen_dependecies_installation() {
|
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 {
|
while let Some(_) = receiver.recv().await {
|
||||||
let proton = get_proton().await;
|
let proton = get_proton().await;
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,9 @@
|
|||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
use babylonia_terminal_sdk::{
|
use babylonia_terminal_sdk::{
|
||||||
components::{
|
components::dxvk_component::{DXVK_DEV, DXVK_REPO},
|
||||||
dxvk_component::{DXVK_DEV, DXVK_REPO},
|
game_config::GameConfig,
|
||||||
proton_component::ProtonComponent,
|
|
||||||
},
|
|
||||||
game_manager::GameManager,
|
game_manager::GameManager,
|
||||||
game_state::GameState,
|
|
||||||
utils::github_requester::{GithubRelease, GithubRequester},
|
utils::github_requester::{GithubRelease, GithubRequester},
|
||||||
};
|
};
|
||||||
use tokio_with_wasm::tokio;
|
use tokio_with_wasm::tokio;
|
||||||
@ -24,7 +21,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub async fn listen_dxvk_installation() {
|
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 {
|
while let Some(info) = receiver.recv().await {
|
||||||
let releases: Result<Vec<GithubRelease>, _> =
|
let releases: Result<Vec<GithubRelease>, _> =
|
||||||
GithubInfo::get_github_releases(DXVK_DEV, DXVK_REPO).await;
|
GithubInfo::get_github_releases(DXVK_DEV, DXVK_REPO).await;
|
||||||
@ -59,7 +56,7 @@ pub async fn listen_dxvk_installation() {
|
|||||||
.block_on(async {
|
.block_on(async {
|
||||||
match GameManager::install_dxvk(
|
match GameManager::install_dxvk(
|
||||||
&proton,
|
&proton,
|
||||||
GameState::get_config().await.config_dir,
|
GameConfig::get_config().await.config_dir,
|
||||||
release_index.unwrap(),
|
release_index.unwrap(),
|
||||||
Some(DownloadReporter::create()),
|
Some(DownloadReporter::create()),
|
||||||
)
|
)
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
use babylonia_terminal_sdk::{
|
use babylonia_terminal_sdk::game_manager::GameManager;
|
||||||
components::proton_component::ProtonComponent, game_manager::GameManager, game_state::GameState,
|
|
||||||
};
|
|
||||||
use tokio_with_wasm::tokio;
|
use tokio_with_wasm::tokio;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -16,7 +14,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub async fn listen_fonts_installation() {
|
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 {
|
while let Some(_) = receiver.recv().await {
|
||||||
let proton = get_proton().await;
|
let proton = get_proton().await;
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
use babylonia_terminal_sdk::{
|
use babylonia_terminal_sdk::{game_config::GameConfig, game_manager::GameManager};
|
||||||
components::proton_component::ProtonComponent, game_manager::GameManager, game_state::GameState,
|
|
||||||
};
|
|
||||||
use rinf::debug_print;
|
use rinf::debug_print;
|
||||||
use tokio_with_wasm::tokio;
|
use tokio_with_wasm::tokio;
|
||||||
|
|
||||||
@ -10,36 +8,44 @@ use crate::{
|
|||||||
messages::{
|
messages::{
|
||||||
error::ReportError,
|
error::ReportError,
|
||||||
steps::game::{
|
steps::game::{
|
||||||
GameInstallationProgress, GameStopped, NotifyGameStartDownloading,
|
GameInstallationProgress, GameStopped, NotifyGameStartPatching,
|
||||||
NotifyGameStartPatching, NotifyGameSuccessfullyInstalled, RunGame,
|
NotifyGameSuccessfullyInstalled, RunGame, StartGameInstallation,
|
||||||
StartGameInstallation,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
proton::get_proton,
|
proton::get_proton,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub async fn listen_game_running() {
|
pub async fn listen_game_running() {
|
||||||
let mut receiver = RunGame::get_dart_signal_receiver();
|
let mut receiver = RunGame::get_dart_signal_receiver().unwrap();
|
||||||
while let Some(_) = receiver.recv().await {
|
thread::spawn(move || {
|
||||||
let proton = get_proton().await;
|
tokio::runtime::Builder::new_current_thread()
|
||||||
let game_dir = GameState::get_game_dir().await;
|
.enable_all()
|
||||||
if game_dir.is_none() {
|
.build()
|
||||||
ReportError {
|
.unwrap()
|
||||||
error_message: "Failed to start game, the game directory was not found".to_string(),
|
.block_on(async {
|
||||||
}
|
while let Some(_) = receiver.recv().await {
|
||||||
.send_signal_to_dart();
|
let proton = get_proton().await;
|
||||||
GameStopped {}.send_signal_to_dart();
|
let game_dir = GameConfig::get_game_dir().await;
|
||||||
continue;
|
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() {
|
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 {
|
while let Some(info) = receiver.recv().await {
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
debug_print!("start downloading game...");
|
debug_print!("start downloading game...");
|
||||||
@ -48,9 +54,9 @@ pub async fn listen_game_installation() {
|
|||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.block_on(async {
|
.block_on(async {
|
||||||
if GameState::get_game_dir().await.is_none() {
|
if GameConfig::get_game_dir().await.is_none() {
|
||||||
if let Err(e) =
|
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
|
.await
|
||||||
{
|
{
|
||||||
ReportError {
|
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() {
|
if game_dir.is_none() {
|
||||||
ReportError {
|
ReportError {
|
||||||
error_message: "Failed to get the game directory".to_string(),
|
error_message: "Failed to get the game directory".to_string(),
|
||||||
|
|||||||
@ -24,7 +24,7 @@ impl GameStateMessage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn listen_game_state() {
|
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 {
|
while let Some(_) = receiver.recv().await {
|
||||||
let result_state = GameState::get_current_state().await;
|
let result_state = GameState::get_current_state().await;
|
||||||
match result_state {
|
match result_state {
|
||||||
|
|||||||
@ -21,7 +21,7 @@ impl GithubRequester for GithubInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn listen_proton_version() {
|
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 {
|
while let Some(_) = receiver.recv().await {
|
||||||
let releases: Result<Vec<GithubRelease>, _> =
|
let releases: Result<Vec<GithubRelease>, _> =
|
||||||
GithubInfo::get_github_releases(PROTON_DEV, PROTON_REPO).await;
|
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() {
|
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 {
|
while let Some(_) = receiver.recv().await {
|
||||||
let releases: Result<Vec<GithubRelease>, _> =
|
let releases: Result<Vec<GithubRelease>, _> =
|
||||||
GithubInfo::get_github_releases(DXVK_DEV, DXVK_REPO).await;
|
GithubInfo::get_github_releases(DXVK_DEV, DXVK_REPO).await;
|
||||||
|
|||||||
@ -1,15 +1,11 @@
|
|||||||
use std::thread;
|
use std::thread;
|
||||||
|
|
||||||
use babylonia_terminal_sdk::{
|
use babylonia_terminal_sdk::{
|
||||||
components::{
|
components::proton_component::{ProtonComponent, PROTON_DEV, PROTON_REPO},
|
||||||
component_downloader::ComponentDownloader,
|
game_config::GameConfig,
|
||||||
proton_component::{ProtonComponent, PROTON_DEV, PROTON_REPO},
|
|
||||||
},
|
|
||||||
game_manager::GameManager,
|
game_manager::GameManager,
|
||||||
game_state::GameState,
|
|
||||||
utils::github_requester::{GithubRelease, GithubRequester},
|
utils::github_requester::{GithubRelease, GithubRequester},
|
||||||
};
|
};
|
||||||
use rinf::debug_print;
|
|
||||||
use tokio_with_wasm::tokio::{self, sync::OnceCell};
|
use tokio_with_wasm::tokio::{self, sync::OnceCell};
|
||||||
use wincompatlib::wine::bundle::proton::Proton;
|
use wincompatlib::wine::bundle::proton::Proton;
|
||||||
|
|
||||||
@ -29,7 +25,7 @@ static PROTON: OnceCell<Proton> = OnceCell::const_new();
|
|||||||
pub async fn get_proton() -> Proton {
|
pub async fn get_proton() -> Proton {
|
||||||
PROTON
|
PROTON
|
||||||
.get_or_init(|| async {
|
.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();
|
let proton = proton_component.init_proton();
|
||||||
if let Err(ref e) = proton {
|
if let Err(ref e) = proton {
|
||||||
ReportError {
|
ReportError {
|
||||||
@ -44,7 +40,7 @@ pub async fn get_proton() -> Proton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub async fn listen_proton_installation() {
|
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 {
|
while let Some(info) = receiver.recv().await {
|
||||||
let releases: Result<Vec<GithubRelease>, _> =
|
let releases: Result<Vec<GithubRelease>, _> =
|
||||||
GithubInfo::get_github_releases(PROTON_DEV, PROTON_REPO).await;
|
GithubInfo::get_github_releases(PROTON_DEV, PROTON_REPO).await;
|
||||||
@ -76,7 +72,7 @@ pub async fn listen_proton_installation() {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.block_on(async {
|
.block_on(async {
|
||||||
match GameManager::install_wine(
|
match GameManager::install_wine(
|
||||||
GameState::get_config().await.config_dir,
|
GameConfig::get_config().await.config_dir,
|
||||||
release_index.unwrap(),
|
release_index.unwrap(),
|
||||||
Some(DownloadReporter::create()),
|
Some(DownloadReporter::create()),
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user