This commit is contained in:
2026-08-17 20:25:08 +04:00
parent b64dffca9a
commit 25e7ad156b
12 changed files with 368 additions and 13 deletions
@@ -80,6 +80,7 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
Timer? _realmRefreshTimer;
int? _activeGamePid;
bool _pauseRequested = false;
bool _gameLaunchPending = false;
Future<void> _onHomeScreenLoad(
HomeScreenLoad event,
@@ -337,17 +338,26 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
HomeScreenPlayRequested event,
Emitter<HomeScreenState> emit,
) async {
if (_gameLaunchPending || state.model.isGameRunning) {
return;
}
final outputPath = state.model.outputPath;
if (outputPath == null) {
emit(_buildErrorState('Сначала выберите папку установки.'));
return;
}
_gameLaunchPending = true;
try {
final installationDir = outputPath.toFilePath();
await _gameInstallationService.clearCache(installationDir);
final authorization = await _launcherApiClient.issueGameTicket(
_session.accessToken,
);
final process = await _gameInstallationService.launchGame(
installationDir,
authorization: authorization,
);
_activeGamePid = process.pid;
unawaited(
@@ -382,6 +392,8 @@ class HomeScreenBloc extends Bloc<HomeScreenEvent, HomeScreenState> {
errorMessage: _formatError(error),
),
);
} finally {
_gameLaunchPending = false;
}
}