Skip to content

Commit 0c38528

Browse files
authored
Merge pull request #118 from Auties00/_onLoggedIn
On logged in
2 parents 62dae46 + dfebe74 commit 0c38528

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2487
-419
lines changed

common/lib/src/model/dll.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
enum InjectableDll {
22
console,
3-
cobalt,
3+
sinum,
44
reboot,
55
memory
66
}

common/lib/src/util/dll.dart

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@ import 'package:path/path.dart' as path;
66
import 'package:reboot_common/common.dart';
77

88
bool _watcher = false;
9-
final File rebootDllFile = File("${dllsDirectory.path}\\reboot.dll");
10-
const String kRebootDownloadUrl =
9+
final File rebootBeforeS20DllFile = File("${dllsDirectory.path}\\reboot.dll");
10+
final File rebootAboveS20DllFile = File("${dllsDirectory.path}\\rebootS20.dll");
11+
const String kRebootBelowS20DownloadUrl =
1112
"http://nightly.link/Milxnor/Project-Reboot-3.0/workflows/msbuild/master/Release.zip";
13+
const String kRebootAboveS20DownloadUrl =
14+
"http://nightly.link/Milxnor/Project-Reboot-3.0/workflows/msbuild/aboveS20/Release.zip";
1215

1316
Future<bool> hasRebootDllUpdate(int? lastUpdateMs, {int hours = 24, bool force = false}) async {
1417
final lastUpdate = await _getLastUpdate(lastUpdateMs);
15-
final exists = await rebootDllFile.exists();
18+
final exists = await rebootBeforeS20DllFile.exists() && await rebootAboveS20DllFile.exists();
1619
final now = DateTime.now();
1720
return force || !exists || (hours > 0 && lastUpdate != null && now.difference(lastUpdate).inHours > hours);
1821
}
@@ -28,9 +31,8 @@ Future<void> downloadCriticalDll(String name, String outputPath) async {
2831
await output.writeAsBytes(response.bodyBytes, flush: true);
2932
}
3033

31-
Future<int> downloadRebootDll(String url) async {
34+
Future<void> downloadRebootDll(File file, String url) async {
3235
Directory? outputDir;
33-
final now = DateTime.now();
3436
try {
3537
final response = await http.get(Uri.parse(url));
3638
if(response.statusCode != 200) {
@@ -42,8 +44,7 @@ Future<int> downloadRebootDll(String url) async {
4244
await tempZip.writeAsBytes(response.bodyBytes, flush: true);
4345
await extractFileToDisk(tempZip.path, outputDir.path);
4446
final rebootDll = File(outputDir.listSync().firstWhere((element) => path.extension(element.path) == ".dll").path);
45-
await rebootDllFile.writeAsBytes(await rebootDll.readAsBytes(), flush: true);
46-
return now.millisecondsSinceEpoch;
47+
await file.writeAsBytes(await rebootDll.readAsBytes(), flush: true);
4748
} finally{
4849
if(outputDir != null) {
4950
delete(outputDir);
@@ -63,7 +64,7 @@ Stream<String> watchDlls() async* {
6364
}
6465

6566
_watcher = true;
66-
await for(final event in rebootDllFile.parent.watch(events: FileSystemEvent.delete | FileSystemEvent.move)) {
67+
await for(final event in dllsDirectory.watch(events: FileSystemEvent.delete | FileSystemEvent.move)) {
6768
if (event.path.endsWith(".dll")) {
6869
yield event.path;
6970
}

common/pubspec.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ environment:
77
sdk: ">=3.0.0 <=4.0.0"
88

99
dependencies:
10-
dio: ^5.3.2
11-
win32: 3.0.0
12-
ffi: ^2.1.0
13-
path: ^1.8.3
14-
http: ^1.1.0
15-
crypto: ^3.0.2
16-
archive: ^3.3.7
10+
dio: ^5.7.0
11+
win32: ^5.5.4
12+
ffi: ^2.1.3
13+
path: ^1.9.0
14+
http: ^1.2.2
15+
crypto: ^3.0.5
16+
archive: ^3.6.1
1717
ini: ^2.1.0
1818
shelf_proxy: ^1.0.2
1919
sync: ^0.3.0
@@ -22,4 +22,4 @@ dependencies:
2222
version: ^3.0.2
2323

2424
dev_dependencies:
25-
flutter_lints: ^2.0.1
25+
flutter_lints: ^5.0.0

gui/dependencies/dlls/sinum.dll

22 KB
Binary file not shown.

gui/lib/l10n/reboot_en.arb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@
9898
"settingsServerTypeDescription": "The type of game server to inject",
9999
"settingsServerTypeEmbeddedName": "Embedded",
100100
"settingsServerTypeCustomName": "Custom",
101-
"settingsServerFileName": "Implementation",
101+
"settingsOldServerFileName": "Game server (Before Fortnite Season 20)",
102+
"settingsNewServerFileName": "Game server (After Fortnite Season 20)",
102103
"settingsServerFileDescription": "The file injected to create the game server",
103104
"settingsServerPortName": "Port",
104105
"settingsServerPortDescription": "The port the launcher expects the game server to be hosted on",
105-
"settingsServerMirrorName": "Update mirror",
106+
"settingsServerOldMirrorName": "Update mirror (Before Fortnite Season 20)",
107+
"settingsServerNewMirrorName": "Update mirror (After Fortnite Season 20)",
106108
"settingsServerMirrorDescription": "The URL used to update the game server dll",
107109
"settingsServerMirrorPlaceholder": "mirror",
108110
"settingsServerTimerName": "Update timer",
@@ -368,5 +370,7 @@
368370
"automaticGameServerDialogStart": "Start server",
369371
"gameResetDefaultsName": "Reset",
370372
"gameResetDefaultsDescription": "Resets the game's settings to their default values",
371-
"gameResetDefaultsContent": "Reset"
373+
"gameResetDefaultsContent": "Reset",
374+
"selectFile": "Select a file",
375+
"reset": "Reset"
372376
}

gui/lib/main.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import 'dart:async';
22
import 'dart:io';
33

44
import 'package:bitsdojo_window/bitsdojo_window.dart';
5+
import 'package:file_picker/file_picker.dart';
56
import 'package:fluent_ui/fluent_ui.dart';
67
import 'package:flutter_acrylic/flutter_acrylic.dart';
78
import 'package:flutter_gen/gen_l10n/reboot_localizations.dart';
@@ -19,9 +20,9 @@ import 'package:reboot_launcher/src/controller/settings_controller.dart';
1920
import 'package:reboot_launcher/src/messenger/implementation/error.dart';
2021
import 'package:reboot_launcher/src/page/implementation/home_page.dart';
2122
import 'package:reboot_launcher/src/util/os.dart';
23+
import 'package:reboot_launcher/src/util/url_protocol.dart';
2224
import 'package:supabase_flutter/supabase_flutter.dart';
2325
import 'package:system_theme/system_theme.dart';
24-
import 'package:url_protocol/url_protocol.dart';
2526
import 'package:version/version.dart';
2627
import 'package:window_manager/window_manager.dart';
2728

@@ -146,7 +147,7 @@ Future<Object?> _initVersion() async {
146147

147148
Future<Object?> _initUrlHandler() async {
148149
try {
149-
registerProtocolHandler(kCustomUrlSchema, arguments: ['%s']);
150+
registerUrlProtocol(kCustomUrlSchema, arguments: ['%s']);
150151
return null;
151152
}catch(error) {
152153
return error;

gui/lib/src/controller/dll_controller.dart

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ import 'dart:io';
44
import 'package:fluent_ui/fluent_ui.dart';
55
import 'package:get/get.dart';
66
import 'package:get_storage/get_storage.dart';
7-
import 'package:http/http.dart' as http;
87
import 'package:path/path.dart';
98
import 'package:reboot_common/common.dart';
109
import 'package:reboot_launcher/main.dart';
1110
import 'package:reboot_launcher/src/messenger/abstract/info_bar.dart';
1211
import 'package:reboot_launcher/src/util/translations.dart';
13-
import 'package:url_launcher/url_launcher.dart';
14-
import 'package:version/version.dart';
15-
import 'package:yaml/yaml.dart';
1612

1713
class DllController extends GetxController {
1814
static const String storageName = "dll_storage";
@@ -25,7 +21,8 @@ class DllController extends GetxController {
2521
late final TextEditingController memoryLeakDll;
2622
late final TextEditingController gameServerPort;
2723
late final Rx<UpdateTimer> timer;
28-
late final TextEditingController url;
24+
late final TextEditingController beforeS20Mirror;
25+
late final TextEditingController aboveS20Mirror;
2926
late final RxBool customGameServer;
3027
late final RxnInt timestamp;
3128
late final Rx<UpdateStatus> status;
@@ -43,8 +40,10 @@ class DllController extends GetxController {
4340
final timerIndex = _storage?.read("timer");
4441
timer = Rx(timerIndex == null ? UpdateTimer.hour : UpdateTimer.values.elementAt(timerIndex));
4542
timer.listen((value) => _storage?.write("timer", value.index));
46-
url = TextEditingController(text: _storage?.read("update_url") ?? kRebootDownloadUrl);
47-
url.addListener(() => _storage?.write("update_url", url.text));
43+
beforeS20Mirror = TextEditingController(text: _storage?.read("update_url") ?? kRebootBelowS20DownloadUrl);
44+
beforeS20Mirror.addListener(() => _storage?.write("update_url", beforeS20Mirror.text));
45+
aboveS20Mirror = TextEditingController(text: _storage?.read("old_update_url") ?? kRebootAboveS20DownloadUrl);
46+
aboveS20Mirror.addListener(() => _storage?.write("new_update_url", aboveS20Mirror.text));
4847
status = Rx(UpdateStatus.waiting);
4948
customGameServer = RxBool(_storage?.read("custom_game_server") ?? false);
5049
customGameServer.listen((value) => _storage?.write("custom_game_server", value));
@@ -68,7 +67,8 @@ class DllController extends GetxController {
6867
void resetServer() {
6968
gameServerPort.text = kDefaultGameServerPort;
7069
timer.value = UpdateTimer.hour;
71-
url.text = kRebootDownloadUrl;
70+
beforeS20Mirror.text = kRebootBelowS20DownloadUrl;
71+
aboveS20Mirror.text = kRebootAboveS20DownloadUrl;
7272
status.value = UpdateStatus.waiting;
7373
customGameServer.value = false;
7474
timestamp.value = null;
@@ -109,7 +109,15 @@ class DllController extends GetxController {
109109
duration: null
110110
);
111111
}
112-
timestamp.value = await downloadRebootDll(url.text);
112+
await Future.wait(
113+
[
114+
downloadRebootDll(rebootBeforeS20DllFile, beforeS20Mirror.text),
115+
downloadRebootDll(rebootAboveS20DllFile, aboveS20Mirror.text),
116+
Future.delayed(const Duration(seconds: 1))
117+
],
118+
eagerError: false
119+
);
120+
timestamp.value = DateTime.now().millisecondsSinceEpoch;
113121
status.value = UpdateStatus.success;
114122
infoBarEntry?.close();
115123
if(!silent) {
@@ -126,15 +134,18 @@ class DllController extends GetxController {
126134
error = error.contains(": ") ? error.substring(error.indexOf(": ") + 2) : error;
127135
error = error.toLowerCase();
128136
status.value = UpdateStatus.error;
129-
showRebootInfoBar(
130-
translations.downloadDllError("reboot.dll", error.toString()),
137+
infoBarEntry = showRebootInfoBar(
138+
translations.downloadDllError(error.toString(), "reboot.dll"),
131139
duration: infoBarLongDuration,
132140
severity: InfoBarSeverity.error,
133141
action: Button(
134-
onPressed: () => updateGameServerDll(
135-
force: true,
136-
silent: silent
137-
),
142+
onPressed: () async {
143+
infoBarEntry?.close();
144+
updateGameServerDll(
145+
force: true,
146+
silent: silent
147+
);
148+
},
138149
child: Text(translations.downloadDllRetry),
139150
)
140151
);
@@ -155,7 +166,7 @@ class DllController extends GetxController {
155166
}
156167
}
157168

158-
return (rebootDllFile, false);
169+
return (rebootBeforeS20DllFile, false);
159170
case InjectableDll.console:
160171
final ue4ConsoleFile = File(unrealEngineConsoleDll.text);
161172
return (ue4ConsoleFile, canonicalize(ue4ConsoleFile.path) != defaultPath);
@@ -215,7 +226,7 @@ class DllController extends GetxController {
215226
error = error.toLowerCase();
216227
final completer = Completer();
217228
await showRebootInfoBar(
218-
translations.downloadDllError(fileName, error.toString()),
229+
translations.downloadDllError(error.toString(), fileName),
219230
duration: infoBarLongDuration,
220231
severity: InfoBarSeverity.error,
221232
onDismissed: () => completer.complete(null),

gui/lib/src/controller/hosting_controller.dart

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,36 @@ class HostingController extends GetxController {
5656
published = RxBool(false);
5757
showPassword = RxBool(false);
5858
instance = Rxn();
59-
final supabase = Supabase.instance.client;
6059
servers = Rxn();
61-
supabase.from("hosting_v2")
62-
.stream(primaryKey: ['id'])
63-
.map((event) => event.map((element) => FortniteServer.fromJson(element)).where((element) => element.ip.isNotEmpty).toSet())
64-
.listen((event) {
65-
servers.value = event;
66-
published.value = event.any((element) => element.id == uuid);
67-
});
60+
_listenServers();
6861
customLaunchArgs = TextEditingController(text: _storage?.read("custom_launch_args") ?? "");
6962
customLaunchArgs.addListener(() => _storage?.write("custom_launch_args", customLaunchArgs.text));
7063
_semaphore = Semaphore();
7164
}
7265

66+
void _listenServers([int attempt = 0]) {
67+
log("[SUPABASE] Listening...");
68+
final supabase = Supabase.instance.client;
69+
supabase.from("hosting_v2")
70+
.stream(primaryKey: ['id'])
71+
.map((event) => event.map((element) => FortniteServer.fromJson(element)).where((element) => element.ip.isNotEmpty).toSet())
72+
.listen(
73+
_onNewServer,
74+
onError: (error) async {
75+
log("[SUPABASE] Error: ${error}");
76+
await Future.delayed(Duration(seconds: attempt * 5));
77+
_listenServers(attempt + 1);
78+
},
79+
cancelOnError: true
80+
);
81+
}
82+
83+
void _onNewServer(Set<FortniteServer> event) {
84+
log("[SUPABASE] New event: ${event}");
85+
servers.value = event;
86+
published.value = event.any((element) => element.id == uuid);
87+
}
88+
7389
Future<void> publishServer(String author, String version) async {
7490
try {
7591
_semaphore.acquire();

gui/lib/src/controller/settings_controller.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import 'dart:async';
2-
import 'dart:io';
32

43
import 'package:fluent_ui/fluent_ui.dart';
54
import 'package:get/get.dart';
65
import 'package:get_storage/get_storage.dart';
76
import 'package:http/http.dart' as http;
8-
import 'package:path/path.dart';
97
import 'package:reboot_common/common.dart';
108
import 'package:reboot_launcher/main.dart';
119
import 'package:reboot_launcher/src/messenger/abstract/info_bar.dart';
@@ -21,7 +19,6 @@ class SettingsController extends GetxController {
2119
late final RxString language;
2220
late final Rx<ThemeMode> themeMode;
2321
late final RxBool firstRun;
24-
late final RxBool debug;
2522
late double width;
2623
late double height;
2724
late double? offsetX;
@@ -39,7 +36,6 @@ class SettingsController extends GetxController {
3936
language.listen((value) => _storage?.write("language", value));
4037
firstRun = RxBool(_storage?.read("first_run_tutorial") ?? true);
4138
firstRun.listen((value) => _storage?.write("first_run_tutorial", value));
42-
debug = RxBool(false);
4339
}
4440

4541
void saveWindowSize(Size size) {

gui/lib/src/messenger/abstract/dialog.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,15 +300,15 @@ class _DialogButtonState extends State<DialogButton> {
300300

301301
Widget get _primaryButton => Button(
302302
style: ButtonStyle(
303-
backgroundColor: ButtonState.all(FluentTheme.of(context).accentColor)
303+
backgroundColor: WidgetStateProperty.all(FluentTheme.of(context).accentColor)
304304
),
305305
onPressed: widget.onTap!,
306306
child: Text(widget.text!),
307307
);
308308

309309
Widget get _secondaryButton => Button(
310310
style: widget.color != null ? ButtonStyle(
311-
backgroundColor: ButtonState.all(widget.color!)
311+
backgroundColor: WidgetStateProperty.all(widget.color!)
312312
) : null,
313313
onPressed: widget.onTap ?? _onDefaultSecondaryActionTap,
314314
child: Text(widget.text ?? translations.defaultDialogSecondaryAction),

0 commit comments

Comments
 (0)