Skip to content

Commit

Permalink
10.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Auties00 committed Dec 9, 2024
1 parent 0a59a32 commit d42946c
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 31 deletions.
2 changes: 1 addition & 1 deletion gui/lib/l10n/reboot_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
"startGame": "Start fortnite",
"stopGame": "Close fortnite",
"waitingForGameServer": "Waiting for the game server to boot up...",
"gameServerStartWarning": "The game server was started successfully, but Reboot didn't load",
"gameServerStartWarning": "Unsupported version: the game server crashed while setting up the server",
"gameServerStartLocalWarning": "The game server was started successfully, but other players can't join",
"gameServerStarted": "The game server was started successfully",
"gameClientStarted": "The game client was started successfully",
Expand Down
2 changes: 1 addition & 1 deletion gui/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Future<void> _initWindow() async {
await windowManager.setAlignment(Alignment.center);
}
await windowManager.setPreventClose(true);

await windowManager.setResizable(true);
if(isWin11) {
await Window.setEffect(
effect: WindowEffect.acrylic,
Expand Down
24 changes: 11 additions & 13 deletions gui/lib/src/messenger/implementation/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import 'package:get/get.dart';
import 'package:reboot_common/common.dart';
import 'package:reboot_launcher/src/controller/game_controller.dart';
import 'package:reboot_launcher/src/messenger/abstract/dialog.dart';
import 'package:reboot_launcher/src/util/os.dart';
import 'package:reboot_launcher/src/util/translations.dart';
import 'package:reboot_launcher/src/util/types.dart';
import 'package:reboot_launcher/src/widget/file_selector.dart';
import 'package:universal_disk_space/universal_disk_space.dart';
import 'package:windows_taskbar/windows_taskbar.dart';

class AddVersionDialog extends StatefulWidget {
Expand All @@ -35,20 +35,18 @@ class _AddVersionDialogState extends State<AddVersionDialog> {
final Rxn<double> _progress = Rxn();
final RxInt _speed = RxInt(0);

late DiskSpace _diskSpace;
late Future<List<FortniteBuild>> _fetchFuture;
late Future _diskFuture;

SendPort? _downloadPort;
Object? _error;
StackTrace? _stackTrace;

@override
void initState() {
_fetchFuture = compute(fetchBuilds, null);
_diskSpace = DiskSpace();
_diskFuture = _diskSpace.scan()
.then((_) => _updateFormDefaults());
_fetchFuture = compute(fetchBuilds, null).then((value) {
_updateFormDefaults();
return value;
});
super.initState();
}

Expand All @@ -71,7 +69,7 @@ class _AddVersionDialogState extends State<AddVersionDialog> {
switch(_status.value){
case _DownloadStatus.form:
return FutureBuilder(
future: Future.wait([_fetchFuture, _diskFuture]).then((_) async => await _fetchFuture),
future: _fetchFuture,
builder: (context, snapshot) {
if (snapshot.hasError) {
WidgetsBinding.instance.addPostFrameCallback((_) => _onDownloadError(snapshot.error, snapshot.stackTrace));
Expand Down Expand Up @@ -444,16 +442,16 @@ class _AddVersionDialogState extends State<AddVersionDialog> {
_build.value = null;
}

if(_source.value != _BuildSource.local && _diskSpace.disks.isNotEmpty) {
await _fetchFuture;
final bestDisk = _diskSpace.disks
.reduce((first, second) => first.availableSpace > second.availableSpace ? first : second);
final disks = WindowsDisk.available();
if(_source.value != _BuildSource.local && disks.isNotEmpty) {
final bestDisk = disks.reduce((first, second) => first.freeBytesAvailable > second.freeBytesAvailable ? first : second);
final build = _build.value;
if(build == null){
return;
}

final pathText = "${bestDisk.devicePath}\\FortniteBuilds\\${build.version}";
print("${bestDisk.path}\\FortniteBuilds\\${build.version}");
final pathText = "${bestDisk.path}FortniteBuilds\\${build.version}";
_pathController.text = pathText;
_pathController.selection = TextSelection.collapsed(offset: pathText.length);
}
Expand Down
29 changes: 16 additions & 13 deletions gui/lib/src/util/matchmaker.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'dart:math';

import 'package:reboot_common/common.dart';

Expand All @@ -9,22 +10,24 @@ const Duration _timeout = Duration(seconds: 5);
Completer<bool> pingGameServerOrTimeout(String address, Duration timeout) {
final completer = Completer<bool>();
final start = DateTime.now();
(() async {
while (!completer.isCompleted && DateTime.now().millisecondsSinceEpoch - start.millisecondsSinceEpoch < timeout.inMilliseconds) {
final result = await pingGameServer(address);
if(result) {
completer.complete(true);
}else {
await Future.delayed(_timeout);
}
}
if(!completer.isCompleted) {
completer.complete(false);
}
})();
_pingGameServerOrTimeout(completer, start, timeout, address);
return completer;
}

Future<void> _pingGameServerOrTimeout(Completer<bool> completer, DateTime start, Duration timeout, String address) async {
while (!completer.isCompleted && max(DateTime.now().millisecondsSinceEpoch - start.millisecondsSinceEpoch, 0) < timeout.inMilliseconds) {
final result = await pingGameServer(address);
if(result) {
completer.complete(true);
}else {
await Future.delayed(_timeout);
}
}
if(!completer.isCompleted) {
completer.complete(false);
}
}

Future<bool> pingGameServer(String address) async {
final split = address.split(":");
var hostname = split[0];
Expand Down
54 changes: 54 additions & 0 deletions gui/lib/src/util/os.dart
Original file line number Diff line number Diff line change
Expand Up @@ -491,4 +491,58 @@ int _convertToHString(String string) {

extension WindowManagerExtension on WindowManager {
Future<void> maximizeOrRestore() async => await windowManager.isMaximized() ? windowManager.restore() : windowManager.maximize();
}

class WindowsDisk {
static final String _nullTerminator = String.fromCharCode(0);

final String path;
final int freeBytesAvailable;
final int totalNumberOfBytes;

const WindowsDisk._internal(this.path, this.freeBytesAvailable, this.totalNumberOfBytes);

static List<WindowsDisk> available() {
final buffer = malloc.allocate<Utf16>(MAX_PATH);
try {
final length = GetLogicalDriveStrings(MAX_PATH, buffer);
if (length == 0) {
return [];
}

return buffer.toDartString(length: length)
.split(_nullTerminator)
.where((drive) => drive.length > 1)
.map((driveName) {
final freeBytesAvailable = calloc<Uint64>();
final totalNumberOfBytes = calloc<Uint64>();
final totalNumberOfFreeBytes = calloc<Uint64>();
try {
GetDiskFreeSpaceEx(
driveName.toNativeUtf16(),
freeBytesAvailable,
totalNumberOfBytes,
totalNumberOfFreeBytes
);
return WindowsDisk._internal(
driveName,
freeBytesAvailable.value,
totalNumberOfBytes.value
);
} finally {
calloc.free(freeBytesAvailable);
calloc.free(totalNumberOfBytes);
calloc.free(totalNumberOfFreeBytes);
}
})
.toList(growable: false);
} finally {
calloc.free(buffer);
}
}

@override
String toString() {
return 'WindowsDisk{path: $path, freeBytesAvailable: $freeBytesAvailable, totalNumberOfBytes: $totalNumberOfBytes}';
}
}
2 changes: 1 addition & 1 deletion gui/lib/src/widget/game_start_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ class _LaunchButtonState extends State<LaunchButton> {

final pingOperation = pingGameServerOrTimeout(
"$publicIp:$gameServerPort",
const Duration(days: 365)
const Duration(days: 1)
);
this._pingOperation = pingOperation;
_gameServerInfoBar = showRebootInfoBar(
Expand Down
3 changes: 1 addition & 2 deletions gui/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: reboot_launcher
description: Graphical User Interface for Project Reboot
version: "10.0.2"
version: "10.0.3"

publish_to: 'none'

Expand Down Expand Up @@ -58,7 +58,6 @@ dependencies:

# Storage
get_storage: ^2.1.1
universal_disk_space: ^0.2.3
path: ^1.9.0

# Translations
Expand Down

0 comments on commit d42946c

Please sign in to comment.