Release 9.2.2

This commit is contained in:
Alessandro Autiero
2024-07-09 20:38:01 +02:00
parent 3e2c2e96b1
commit a2505011d9
12 changed files with 126 additions and 782 deletions

View File

@@ -16,8 +16,17 @@ import 'package:reboot_launcher/src/util/cryptography.dart';
import 'package:reboot_launcher/src/util/matchmaker.dart';
import 'package:reboot_launcher/src/util/translations.dart';
final List<InfoBarEntry> _infoBars = [];
extension ServerControllerDialog on BackendController {
void cancelInteractive() {
worker?.cancel(); // Do not await or it will hang
_infoBars.forEach((infoBar) => infoBar.close());
_infoBars.clear();
}
Future<bool> toggleInteractive() async {
cancelInteractive();
final stream = toggle();
final completer = Completer<bool>();
InfoBarEntry? entry;
@@ -38,105 +47,113 @@ extension ServerControllerDialog on BackendController {
log("[BACKEND] Handling event: $event");
switch (event.type) {
case ServerResultType.starting:
return showRebootInfoBar(
return _showRebootInfoBar(
translations.startingServer,
severity: InfoBarSeverity.info,
loading: true,
duration: null
);
case ServerResultType.startSuccess:
return showRebootInfoBar(
final embeddedProcessPid = this.embeddedProcessPid;
if(embeddedProcessPid != null) {
watchProcess(embeddedProcessPid).then((_) {
if(started.value) {
started.value = false;
_showRebootInfoBar(
translations.backendProcessError,
severity: InfoBarSeverity.error
);
}
});
}
return _showRebootInfoBar(
type.value == ServerType.local ? translations.checkedServer : translations.startedServer,
severity: InfoBarSeverity.success
);
case ServerResultType.startError:
print(event.stackTrace);
return showRebootInfoBar(
return _showRebootInfoBar(
type.value == ServerType.local ? translations.localServerError(event.error ?? translations.unknownError) : translations.startServerError(event.error ?? translations.unknownError),
severity: InfoBarSeverity.error,
duration: infoBarLongDuration
);
case ServerResultType.stopping:
return showRebootInfoBar(
return _showRebootInfoBar(
translations.stoppingServer,
severity: InfoBarSeverity.info,
loading: true,
duration: null
);
case ServerResultType.stopSuccess:
return showRebootInfoBar(
return _showRebootInfoBar(
translations.stoppedServer,
severity: InfoBarSeverity.success
);
case ServerResultType.stopError:
return showRebootInfoBar(
return _showRebootInfoBar(
translations.stopServerError(event.error ?? translations.unknownError),
severity: InfoBarSeverity.error,
duration: infoBarLongDuration
);
case ServerResultType.missingHostError:
return showRebootInfoBar(
return _showRebootInfoBar(
translations.missingHostNameError,
severity: InfoBarSeverity.error
);
case ServerResultType.missingPortError:
return showRebootInfoBar(
return _showRebootInfoBar(
translations.missingPortError,
severity: InfoBarSeverity.error
);
case ServerResultType.illegalPortError:
return showRebootInfoBar(
return _showRebootInfoBar(
translations.illegalPortError,
severity: InfoBarSeverity.error
);
case ServerResultType.freeingPort:
return showRebootInfoBar(
return _showRebootInfoBar(
translations.freeingPort,
loading: true,
duration: null
);
case ServerResultType.freePortSuccess:
return showRebootInfoBar(
return _showRebootInfoBar(
translations.freedPort,
severity: InfoBarSeverity.success,
duration: infoBarShortDuration
);
case ServerResultType.freePortError:
return showRebootInfoBar(
return _showRebootInfoBar(
translations.freePortError(event.error ?? translations.unknownError),
severity: InfoBarSeverity.error,
duration: infoBarLongDuration
);
case ServerResultType.pingingRemote:
return showRebootInfoBar(
return _showRebootInfoBar(
translations.pingingServer(ServerType.remote.name),
severity: InfoBarSeverity.info,
loading: true,
duration: null
);
case ServerResultType.pingingLocal:
return showRebootInfoBar(
return _showRebootInfoBar(
translations.pingingServer(type.value.name),
severity: InfoBarSeverity.info,
loading: true,
duration: null
);
case ServerResultType.pingError:
return showRebootInfoBar(
return _showRebootInfoBar(
translations.pingError(type.value.name),
severity: InfoBarSeverity.error
);
case ServerResultType.processError:
return showRebootInfoBar(
translations.backendProcessError,
severity: InfoBarSeverity.error
);
}
}
Future<void> joinServerInteractive(String uuid, FortniteServer server) async {
if(!kDebugMode && uuid == server.id) {
showRebootInfoBar(
_showRebootInfoBar(
translations.joinSelfServer,
duration: infoBarLongDuration,
severity: InfoBarSeverity.error
@@ -147,7 +164,7 @@ extension ServerControllerDialog on BackendController {
final gameController = Get.find<GameController>();
final version = gameController.getVersionByName(server.version.toString());
if(version == null) {
showRebootInfoBar(
_showRebootInfoBar(
translations.cannotJoinServerVersion(server.version.toString()),
duration: infoBarLongDuration,
severity: InfoBarSeverity.error
@@ -176,7 +193,7 @@ extension ServerControllerDialog on BackendController {
}
if(!checkPassword(confirmPassword, hashedPassword)) {
showRebootInfoBar(
_showRebootInfoBar(
translations.wrongServerPassword,
duration: infoBarLongDuration,
severity: InfoBarSeverity.error
@@ -199,7 +216,7 @@ extension ServerControllerDialog on BackendController {
return true;
}
showRebootInfoBar(
_showRebootInfoBar(
translations.offlineServer,
duration: infoBarLongDuration,
severity: InfoBarSeverity.error
@@ -268,10 +285,29 @@ extension ServerControllerDialog on BackendController {
FlutterClipboard.controlC(decryptedIp);
}
controller.selectedVersion = version;
WidgetsBinding.instance.addPostFrameCallback((_) => showRebootInfoBar(
WidgetsBinding.instance.addPostFrameCallback((_) => _showRebootInfoBar(
embedded ? translations.joinedServer(author) : translations.copiedIp,
duration: infoBarLongDuration,
severity: InfoBarSeverity.success
));
}
InfoBarEntry _showRebootInfoBar(dynamic text, {
InfoBarSeverity severity = InfoBarSeverity.info,
bool loading = false,
Duration? duration = infoBarShortDuration,
void Function()? onDismissed,
Widget? action
}) {
final result = showRebootInfoBar(
text,
severity: severity,
loading: loading,
duration: duration,
onDismissed: onDismissed,
action: action
);
_infoBars.add(result);
return result;
}
}