mirror of
https://github.com/ALEZ-DEV/Babylonia-terminal.git
synced 2025-12-16 01:18:50 +00:00
can now update the game from the GUI
This commit is contained in:
parent
9188860db3
commit
62ffdd2dff
@ -17,8 +17,8 @@ class Game with ChangeNotifier {
|
||||
Int64 currentProgress = Int64(0);
|
||||
Int64 maxProgress = Int64(0);
|
||||
|
||||
Future startInstallation(GameStateProvider gameState) async {
|
||||
StartGameInstallation().sendSignalToRust();
|
||||
Future startInstallation(GameStateProvider gameState, bool isUpdating) async {
|
||||
StartGameInstallation(isUpdating: isUpdating).sendSignalToRust();
|
||||
gameInstallationState = GameInstallationState.checkingFile;
|
||||
notifyListeners();
|
||||
|
||||
|
||||
@ -36,4 +36,8 @@ class GameStateProvider with ChangeNotifier {
|
||||
_gameState == States.FontNotInstalled ||
|
||||
_gameState == States.DependecieNotInstalled;
|
||||
}
|
||||
|
||||
bool isGameUpdating() {
|
||||
return _gameState == States.GameNeedUpdate;
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,11 +15,12 @@ class HomeScreen extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final gameStateProvider = Provider.of<GameStateProvider>(context);
|
||||
|
||||
return Stack(
|
||||
children: [
|
||||
const ShowBackground(),
|
||||
Provider.of<GameStateProvider>(context).gameState !=
|
||||
States.GameInstalled
|
||||
gameStateProvider.gameState != States.GameInstalled
|
||||
? const GameSteps()
|
||||
: Padding(
|
||||
padding: const EdgeInsets.all(50.0),
|
||||
|
||||
@ -35,6 +35,8 @@ class _InstallGame extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final gameStateProvider = Provider.of<GameStateProvider>(context);
|
||||
|
||||
return Row(
|
||||
children: [
|
||||
const Expanded(
|
||||
@ -56,11 +58,16 @@ class _InstallGame extends StatelessWidget {
|
||||
onPressed: () async {
|
||||
Provider.of<Game>(context, listen: false).startInstallation(
|
||||
Provider.of<GameStateProvider>(context, listen: false),
|
||||
gameStateProvider.isGameUpdating(),
|
||||
);
|
||||
},
|
||||
child: const Center(
|
||||
child: Text("Download"),
|
||||
),
|
||||
child: gameStateProvider.isGameUpdating()
|
||||
? const Center(
|
||||
child: Text("Update"),
|
||||
)
|
||||
: const Center(
|
||||
child: Text("Download"),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@ -8,7 +8,9 @@ message GameInstallationProgress {
|
||||
}
|
||||
|
||||
// [RINF:DART-SIGNAL]
|
||||
message StartGameInstallation {}
|
||||
message StartGameInstallation {
|
||||
bool isUpdating = 1;
|
||||
}
|
||||
|
||||
// [RINF:RUST-SIGNAL]
|
||||
message NotifyGameStartDownloading {}
|
||||
|
||||
@ -16,7 +16,7 @@ use crate::messages::{
|
||||
|
||||
pub async fn listen_game_installation() {
|
||||
let mut receiver = StartGameInstallation::get_dart_signal_receiver();
|
||||
while let Some(_) = receiver.recv().await {
|
||||
while let Some(info) = receiver.recv().await {
|
||||
thread::spawn(move || {
|
||||
debug_print!("start downloading game...");
|
||||
tokio::runtime::Builder::new_current_thread()
|
||||
@ -24,6 +24,15 @@ pub async fn listen_game_installation() {
|
||||
.build()
|
||||
.unwrap()
|
||||
.block_on(async {
|
||||
if info.message.is_updating {
|
||||
if let Err(e) = GameManager::update_game().await {
|
||||
ReportError {
|
||||
error_message: format!("Failed to start updating the game : {}", e),
|
||||
}
|
||||
.send_signal_to_dart();
|
||||
}
|
||||
}
|
||||
|
||||
let game_dir = GameState::get_config().await.config_dir;
|
||||
|
||||
match GameManager::install_game(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user