mirror of
https://github.com/ALEZ-DEV/Babylonia-terminal.git
synced 2026-03-21 21:58:52 +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 currentProgress = Int64(0);
|
||||||
Int64 maxProgress = Int64(0);
|
Int64 maxProgress = Int64(0);
|
||||||
|
|
||||||
Future startInstallation(GameStateProvider gameState) async {
|
Future startInstallation(GameStateProvider gameState, bool isUpdating) async {
|
||||||
StartGameInstallation().sendSignalToRust();
|
StartGameInstallation(isUpdating: isUpdating).sendSignalToRust();
|
||||||
gameInstallationState = GameInstallationState.checkingFile;
|
gameInstallationState = GameInstallationState.checkingFile;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
|
||||||
|
|||||||
@ -36,4 +36,8 @@ class GameStateProvider with ChangeNotifier {
|
|||||||
_gameState == States.FontNotInstalled ||
|
_gameState == States.FontNotInstalled ||
|
||||||
_gameState == States.DependecieNotInstalled;
|
_gameState == States.DependecieNotInstalled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isGameUpdating() {
|
||||||
|
return _gameState == States.GameNeedUpdate;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,11 +15,12 @@ class HomeScreen extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final gameStateProvider = Provider.of<GameStateProvider>(context);
|
||||||
|
|
||||||
return Stack(
|
return Stack(
|
||||||
children: [
|
children: [
|
||||||
const ShowBackground(),
|
const ShowBackground(),
|
||||||
Provider.of<GameStateProvider>(context).gameState !=
|
gameStateProvider.gameState != States.GameInstalled
|
||||||
States.GameInstalled
|
|
||||||
? const GameSteps()
|
? const GameSteps()
|
||||||
: Padding(
|
: Padding(
|
||||||
padding: const EdgeInsets.all(50.0),
|
padding: const EdgeInsets.all(50.0),
|
||||||
|
|||||||
@ -35,6 +35,8 @@ class _InstallGame extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
final gameStateProvider = Provider.of<GameStateProvider>(context);
|
||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
children: [
|
children: [
|
||||||
const Expanded(
|
const Expanded(
|
||||||
@ -56,11 +58,16 @@ class _InstallGame extends StatelessWidget {
|
|||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
Provider.of<Game>(context, listen: false).startInstallation(
|
Provider.of<Game>(context, listen: false).startInstallation(
|
||||||
Provider.of<GameStateProvider>(context, listen: false),
|
Provider.of<GameStateProvider>(context, listen: false),
|
||||||
|
gameStateProvider.isGameUpdating(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: const Center(
|
child: gameStateProvider.isGameUpdating()
|
||||||
child: Text("Download"),
|
? const Center(
|
||||||
),
|
child: Text("Update"),
|
||||||
|
)
|
||||||
|
: const Center(
|
||||||
|
child: Text("Download"),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|||||||
@ -8,7 +8,9 @@ message GameInstallationProgress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// [RINF:DART-SIGNAL]
|
// [RINF:DART-SIGNAL]
|
||||||
message StartGameInstallation {}
|
message StartGameInstallation {
|
||||||
|
bool isUpdating = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// [RINF:RUST-SIGNAL]
|
// [RINF:RUST-SIGNAL]
|
||||||
message NotifyGameStartDownloading {}
|
message NotifyGameStartDownloading {}
|
||||||
|
|||||||
@ -16,7 +16,7 @@ use crate::messages::{
|
|||||||
|
|
||||||
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();
|
||||||
while let Some(_) = 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...");
|
||||||
tokio::runtime::Builder::new_current_thread()
|
tokio::runtime::Builder::new_current_thread()
|
||||||
@ -24,6 +24,15 @@ pub async fn listen_game_installation() {
|
|||||||
.build()
|
.build()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.block_on(async {
|
.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;
|
let game_dir = GameState::get_config().await.config_dir;
|
||||||
|
|
||||||
match GameManager::install_game(
|
match GameManager::install_game(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user