Skip to content

Commit 62dae46

Browse files
authored
Merge pull request #98 from Auties00/_onLoggedIn
Released 9.2.6
2 parents 232bf8f + a9af282 commit 62dae46

File tree

12 files changed

+327
-154
lines changed

12 files changed

+327
-154
lines changed

gui/lib/l10n/reboot_en.arb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
"defaultServerName": "Reboot Game Server",
146146
"defaultServerDescription": "Just another server",
147147
"downloadingDll": "Downloading {name} dll...",
148+
"dllAlreadyExists": "The {name} was already downloaded",
148149
"downloadDllSuccess": "The {name} dll was downloaded successfully",
149150
"downloadDllError": "An error occurred while downloading {name}: {error}",
150151
"downloadDllRetry": "Retry",
@@ -360,7 +361,7 @@
360361
"promptBackendDetachedActionLabel": "Next",
361362
"promptInfoTabText": "The Info tab contains useful links to report bugs and receive support",
362363
"promptInfoTabActionLabel": "Next",
363-
"promptSettingsTabText": "The Settings tab contains options to customize and reset the launcher",
364+
"promptSettingsTabText": "The Settings tab contains options to customize the launcher",
364365
"promptSettingsTabActionLabel": "Done",
365366
"automaticGameServerDialogContent": "The launcher detected that you are not running a game server, but that your matchmaker is set to your local machine. If you don't want to join another player's server, you should start a game server. This is necessary to be able to play!",
366367
"automaticGameServerDialogIgnore": "Ignore",

gui/lib/src/controller/dll_controller.dart

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class DllController extends GetxController {
2828
late final TextEditingController url;
2929
late final RxBool customGameServer;
3030
late final RxnInt timestamp;
31-
late final Map<String, Future<bool>> _operations;
3231
late final Rx<UpdateStatus> status;
3332
InfoBarEntry? infoBarEntry;
3433
Future<bool>? _updater;
@@ -51,20 +50,19 @@ class DllController extends GetxController {
5150
customGameServer.listen((value) => _storage?.write("custom_game_server", value));
5251
timestamp = RxnInt(_storage?.read("ts"));
5352
timestamp.listen((value) => _storage?.write("ts", value));
54-
_operations = {};
5553
}
5654

5755
TextEditingController _createController(String key, InjectableDll dll) {
58-
final controller = TextEditingController(text: _storage?.read(key) ?? _getDefaultPath(dll));
56+
final controller = TextEditingController(text: _storage?.read(key) ?? getDefaultDllPath(dll));
5957
controller.addListener(() => _storage?.write(key, controller.text));
6058
return controller;
6159
}
6260

6361
void resetGame() {
64-
gameServerDll.text = _getDefaultPath(InjectableDll.reboot);
65-
unrealEngineConsoleDll.text = _getDefaultPath(InjectableDll.console);
66-
backendDll.text = _getDefaultPath(InjectableDll.cobalt);
67-
memoryLeakDll.text = _getDefaultPath(InjectableDll.memory);
62+
gameServerDll.text = getDefaultDllPath(InjectableDll.reboot);
63+
unrealEngineConsoleDll.text = getDefaultDllPath(InjectableDll.console);
64+
backendDll.text = getDefaultDllPath(InjectableDll.cobalt);
65+
memoryLeakDll.text = getDefaultDllPath(InjectableDll.memory);
6866
}
6967

7068
void resetServer() {
@@ -147,7 +145,7 @@ class DllController extends GetxController {
147145
}
148146

149147
(File, bool) getInjectableData(InjectableDll dll) {
150-
final defaultPath = canonicalize(_getDefaultPath(dll));
148+
final defaultPath = canonicalize(getDefaultDllPath(dll));
151149
switch(dll){
152150
case InjectableDll.reboot:
153151
if(customGameServer.value) {
@@ -170,23 +168,10 @@ class DllController extends GetxController {
170168
}
171169
}
172170

173-
String _getDefaultPath(InjectableDll dll) => "${dllsDirectory.path}\\${dll.name}.dll";
171+
String getDefaultDllPath(InjectableDll dll) => "${dllsDirectory.path}\\${dll.name}.dll";
174172

175-
Future<bool> downloadCriticalDllInteractive(String filePath, {bool silent = false}) {
173+
Future<bool> downloadCriticalDllInteractive(String filePath, {bool silent = false, bool force = false}) async {
176174
log("[DLL] Asking for $filePath(silent: $silent)");
177-
final old = _operations[filePath];
178-
if(old != null) {
179-
log("[DLL] Download task already exists");
180-
return old;
181-
}
182-
183-
log("[DLL] Creating new download task...");
184-
final newRun = _downloadCriticalDllInteractive(filePath, silent);
185-
_operations[filePath] = newRun;
186-
return newRun;
187-
}
188-
189-
Future<bool> _downloadCriticalDllInteractive(String filePath, bool silent) async {
190175
final fileName = basename(filePath).toLowerCase();
191176
log("[DLL] File name: $fileName");
192177
InfoBarEntry? entry;
@@ -198,7 +183,7 @@ class DllController extends GetxController {
198183
);
199184
}
200185

201-
if(File(filePath).existsSync()) {
186+
if(!force && File(filePath).existsSync()) {
202187
log("[DLL] File already exists");
203188
return true;
204189
}
@@ -225,7 +210,8 @@ class DllController extends GetxController {
225210
log("[DLL] Error: $message");
226211
entry?.close();
227212
var error = message.toString();
228-
error = error.contains(": ") ? error.substring(error.indexOf(": ") + 2) : error;
213+
error =
214+
error.contains(": ") ? error.substring(error.indexOf(": ") + 2) : error;
229215
error = error.toLowerCase();
230216
final completer = Completer();
231217
await showRebootInfoBar(
@@ -243,8 +229,6 @@ class DllController extends GetxController {
243229
);
244230
await completer.future;
245231
return false;
246-
}finally {
247-
_operations.remove(fileName);
248232
}
249233
}
250234
}

gui/lib/src/controller/settings_controller.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class SettingsController extends GetxController {
2121
late final RxString language;
2222
late final Rx<ThemeMode> themeMode;
2323
late final RxBool firstRun;
24+
late final RxBool debug;
2425
late double width;
2526
late double height;
2627
late double? offsetX;
@@ -38,6 +39,7 @@ class SettingsController extends GetxController {
3839
language.listen((value) => _storage?.write("language", value));
3940
firstRun = RxBool(_storage?.read("first_run_tutorial") ?? true);
4041
firstRun.listen((value) => _storage?.write("first_run_tutorial", value));
42+
debug = RxBool(false);
4143
}
4244

4345
void saveWindowSize(Size size) {

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,18 @@ InfoBarEntry showRebootInfoBar(dynamic text, {
2323

2424
Widget _buildOverlay(text, Widget? action, bool loading, InfoBarSeverity severity) => ConstrainedBox(
2525
constraints: BoxConstraints(
26-
minWidth: double.infinity,
27-
minHeight: _height
26+
minHeight: _height
2827
),
2928
child: Mica(
3029
elevation: 1,
3130
child: InfoBar(
3231
title: Row(
32+
mainAxisSize: MainAxisSize.min,
3333
mainAxisAlignment: MainAxisAlignment.spaceBetween,
3434
children: [
35-
if(text is Widget)
36-
text,
37-
if(text is String)
38-
Text(text),
35+
Expanded(
36+
child: text is Widget ? text : Text(text)
37+
),
3938
if(action != null)
4039
action
4140
],

gui/lib/src/page/abstract/page.dart

Lines changed: 93 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import 'package:fluent_ui/fluent_ui.dart';
2+
import 'package:get/get.dart';
3+
import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';
4+
import 'package:reboot_launcher/src/controller/settings_controller.dart';
5+
import 'package:reboot_launcher/src/messenger/implementation/onboard.dart';
26
import 'package:reboot_launcher/src/page/abstract/page_type.dart';
7+
import 'package:reboot_launcher/src/util/translations.dart';
38

49
abstract class RebootPage extends StatefulWidget {
510
const RebootPage({super.key});
@@ -19,31 +24,109 @@ abstract class RebootPage extends StatefulWidget {
1924
}
2025

2126
abstract class RebootPageState<T extends RebootPage> extends State<T> with AutomaticKeepAliveClientMixin<T> {
27+
final SettingsController _settingsController = Get.find<SettingsController>();
28+
2229
@override
2330
Widget build(BuildContext context) {
2431
super.build(context);
2532
var buttonWidget = button;
2633
if(buttonWidget == null) {
27-
return _listView;
34+
return Column(
35+
crossAxisAlignment: CrossAxisAlignment.start,
36+
children: [
37+
_buildFirstLaunchInfo(),
38+
_buildDebugInfo(),
39+
Expanded(
40+
child: _listView
41+
)
42+
],
43+
);
2844
}
2945

3046
return Column(
47+
crossAxisAlignment: CrossAxisAlignment.start,
3148
children: [
49+
_buildFirstLaunchInfo(),
50+
_buildDebugInfo(),
3251
Expanded(
33-
child: _listView,
52+
child: Column(
53+
children: [
54+
Expanded(
55+
child: _listView,
56+
),
57+
const SizedBox(
58+
height: 8.0,
59+
),
60+
ConstrainedBox(
61+
constraints: const BoxConstraints(
62+
maxWidth: 1000
63+
),
64+
child: buttonWidget
65+
)
66+
],
67+
),
68+
),
69+
],
70+
);
71+
}
72+
73+
Widget _buildFirstLaunchInfo() => Obx(() {
74+
if(!_settingsController.firstRun.value) {
75+
return const SizedBox.shrink();
76+
}
77+
78+
return Padding(
79+
padding: const EdgeInsets.only(
80+
bottom: 8.0
81+
),
82+
child: SizedBox(
83+
width: double.infinity,
84+
child: InfoBar(
85+
title: Text(translations.welcomeTitle),
86+
severity: InfoBarSeverity.warning,
87+
isLong: true,
88+
content: SizedBox(
89+
width: double.infinity,
90+
child: Text(translations.welcomeDescription)
91+
),
92+
action: Button(
93+
child: Text(translations.welcomeAction),
94+
onPressed: () => startOnboarding(),
95+
),
96+
onClose: () => _settingsController.firstRun.value = false
3497
),
35-
const SizedBox(
36-
height: 8.0,
98+
),
99+
);
100+
});
101+
102+
Widget _buildDebugInfo() => Obx(() {
103+
if(!_settingsController.debug.value) {
104+
return const SizedBox.shrink();
105+
}
106+
107+
return Padding(
108+
padding: const EdgeInsets.only(
109+
bottom: 8.0
37110
),
38-
ConstrainedBox(
39-
constraints: const BoxConstraints(
40-
maxWidth: 1000
111+
child: SizedBox(
112+
width: double.infinity,
113+
child: InfoBar(
114+
title: Text("Debug mode is enabled"),
115+
severity: InfoBarSeverity.warning,
116+
isLong: true,
117+
content: SizedBox(
118+
width: double.infinity,
119+
child: Text( "• Automatic dll injection is disabled\n"
120+
"• The game server cannot start automatically\n"
121+
"• The game server runs in a normal window")
41122
),
42-
child: buttonWidget
123+
onClose: () {
124+
_settingsController.debug.value = false;
125+
},
126+
),
43127
)
44-
],
45128
);
46-
}
129+
});
47130

48131
ListView get _listView => ListView.builder(
49132
itemCount: settings.length,

0 commit comments

Comments
 (0)