mirror of
https://github.com/Auties00/Reboot-Launcher.git
synced 2026-01-13 11:12:23 +01:00
9.0.4
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/controller/server_controller.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page_type.dart';
|
||||
import 'package:reboot_launcher/src/util/translations.dart';
|
||||
|
||||
class AuthenticatorController extends ServerController {
|
||||
AuthenticatorController() : super();
|
||||
|
||||
@override
|
||||
String get controllerName => translations.authenticatorName.toLowerCase();
|
||||
|
||||
@override
|
||||
String get storageName => "authenticator";
|
||||
|
||||
@override
|
||||
String get defaultHost => kDefaultAuthenticatorHost;
|
||||
|
||||
@override
|
||||
int get defaultPort => kDefaultAuthenticatorPort;
|
||||
|
||||
@override
|
||||
Future<bool> get isPortFree => isAuthenticatorPortFree();
|
||||
|
||||
@override
|
||||
Future<bool> freePort() => freeAuthenticatorPort();
|
||||
|
||||
@override
|
||||
RebootPageType get pageType => RebootPageType.authenticator;
|
||||
|
||||
@override
|
||||
Future<Win32Process> startEmbeddedInternal() => startEmbeddedAuthenticator(detached.value);
|
||||
|
||||
@override
|
||||
Future<Uri?> pingServer(String host, int port) => pingAuthenticator(host, port);
|
||||
}
|
||||
43
gui/lib/src/controller/backend_controller.dart
Normal file
43
gui/lib/src/controller/backend_controller.dart
Normal file
@@ -0,0 +1,43 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/controller/server_controller.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page_type.dart';
|
||||
import 'package:reboot_launcher/src/util/translations.dart';
|
||||
|
||||
class BackendController extends ServerController {
|
||||
late RxBool detached;
|
||||
|
||||
BackendController() : super() {
|
||||
detached = RxBool(storage.read("detached") ?? false);
|
||||
detached.listen((value) => storage.write("detached", value));
|
||||
}
|
||||
|
||||
@override
|
||||
String get controllerName => translations.backendName.toLowerCase();
|
||||
|
||||
@override
|
||||
String get storageName => "backend";
|
||||
|
||||
@override
|
||||
String get defaultHost => kDefaultBackendHost;
|
||||
|
||||
@override
|
||||
int get defaultPort => kDefaultBackendPort;
|
||||
|
||||
@override
|
||||
Future<bool> get isPortFree => isBackendPortFree();
|
||||
|
||||
@override
|
||||
Future<bool> freePort() => freeBackendPort();
|
||||
|
||||
@override
|
||||
RebootPageType get pageType => RebootPageType.backend;
|
||||
|
||||
@override
|
||||
Future<Process> startEmbeddedInternal() => startEmbeddedBackend(detached.value);
|
||||
|
||||
@override
|
||||
Future<Uri?> pingServer(String host, int port) => pingBackend(host, port);
|
||||
}
|
||||
@@ -1,12 +1,17 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/util/keyboard.dart';
|
||||
|
||||
class GameController extends GetxController {
|
||||
static const PhysicalKeyboardKey _kDefaultConsoleKey = PhysicalKeyboardKey(0x00070041);
|
||||
|
||||
late final GetStorage _storage;
|
||||
late final TextEditingController username;
|
||||
late final TextEditingController password;
|
||||
@@ -15,6 +20,7 @@ class GameController extends GetxController {
|
||||
late final Rxn<FortniteVersion> _selectedVersion;
|
||||
late final RxBool started;
|
||||
late final Rxn<GameInstance> instance;
|
||||
late final Rx<PhysicalKeyboardKey> consoleKey;
|
||||
|
||||
GameController() {
|
||||
_storage = GetStorage("game");
|
||||
@@ -34,12 +40,42 @@ class GameController extends GetxController {
|
||||
username.addListener(() => _storage.write("username", username.text));
|
||||
password = TextEditingController(text: _storage.read("password") ?? "");
|
||||
password.addListener(() => _storage.write("password", password.text));
|
||||
customLaunchArgs =
|
||||
TextEditingController(text: _storage.read("custom_launch_args") ?? "");
|
||||
customLaunchArgs = TextEditingController(text: _storage.read("custom_launch_args") ?? "");
|
||||
customLaunchArgs.addListener(() =>
|
||||
_storage.write("custom_launch_args", customLaunchArgs.text));
|
||||
started = RxBool(false);
|
||||
instance = Rxn();
|
||||
consoleKey = Rx(_readConsoleKey());
|
||||
_writeConsoleKey(consoleKey.value);
|
||||
consoleKey.listen((newValue) {
|
||||
_storage.write("console_key", newValue.usbHidUsage);
|
||||
_writeConsoleKey(newValue);
|
||||
});
|
||||
}
|
||||
|
||||
PhysicalKeyboardKey _readConsoleKey() {
|
||||
final consoleKeyValue = _storage.read("console_key");
|
||||
if(consoleKeyValue == null) {
|
||||
return _kDefaultConsoleKey;
|
||||
}
|
||||
|
||||
final consoleKeyNumber = int.tryParse(consoleKeyValue.toString());
|
||||
if(consoleKeyNumber == null) {
|
||||
return _kDefaultConsoleKey;
|
||||
}
|
||||
|
||||
final consoleKey = PhysicalKeyboardKey(consoleKeyNumber);
|
||||
if(!consoleKey.isUnrealEngineKey) {
|
||||
return _kDefaultConsoleKey;
|
||||
}
|
||||
|
||||
return consoleKey;
|
||||
}
|
||||
|
||||
Future<void> _writeConsoleKey(PhysicalKeyboardKey keyValue) async {
|
||||
final defaultInput = File("${backendDirectory.path}\\CloudStorage\\DefaultInput.ini");
|
||||
await defaultInput.parent.create(recursive: true);
|
||||
await defaultInput.writeAsString("[/Script/Engine.InputSettings]\n+ConsoleKeys=Tilde\n+ConsoleKeys=${keyValue.unrealEngineName}", flush: true);
|
||||
}
|
||||
|
||||
void reset() {
|
||||
|
||||
@@ -14,9 +14,9 @@ class HostingController extends GetxController {
|
||||
late final RxBool showPassword;
|
||||
late final RxBool discoverable;
|
||||
late final RxBool headless;
|
||||
late final RxBool virtualDesktop;
|
||||
late final RxBool started;
|
||||
late final RxBool published;
|
||||
late final RxBool automaticServer;
|
||||
late final Rxn<GameInstance> instance;
|
||||
late final Rxn<Set<Map<String, dynamic>>> servers;
|
||||
|
||||
@@ -34,12 +34,12 @@ class HostingController extends GetxController {
|
||||
discoverable.listen((value) => _storage.write("discoverable", value));
|
||||
headless = RxBool(_storage.read("headless") ?? true);
|
||||
headless.listen((value) => _storage.write("headless", value));
|
||||
virtualDesktop = RxBool(_storage.read("virtual_desktop") ?? true);
|
||||
virtualDesktop.listen((value) => _storage.write("virtual_desktop", value));
|
||||
started = RxBool(false);
|
||||
published = RxBool(false);
|
||||
showPassword = RxBool(false);
|
||||
instance = Rxn();
|
||||
automaticServer = RxBool(_storage.read("auto") ?? true);
|
||||
automaticServer.listen((value) => _storage.write("auto", value));
|
||||
final supabase = Supabase.instance.client;
|
||||
servers = Rxn();
|
||||
supabase.from("hosting")
|
||||
@@ -60,6 +60,8 @@ class HostingController extends GetxController {
|
||||
discoverable.value = false;
|
||||
started.value = false;
|
||||
instance.value = null;
|
||||
headless.value = true;
|
||||
virtualDesktop.value = true;
|
||||
}
|
||||
|
||||
Map<String, dynamic>? findServerById(String uuid) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:get/get_rx/src/rx_types/rx_types.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
@@ -57,7 +59,7 @@ class MatchmakerController extends ServerController {
|
||||
RebootPageType get pageType => RebootPageType.matchmaker;
|
||||
|
||||
@override
|
||||
Future<Win32Process> startEmbeddedInternal() => startEmbeddedMatchmaker(detached.value);
|
||||
Future<Process> startEmbeddedInternal() => startEmbeddedMatchmaker();
|
||||
|
||||
@override
|
||||
Future<Uri?> pingServer(String host, int port) => pingMatchmaker(host, port);
|
||||
|
||||
@@ -15,7 +15,6 @@ abstract class ServerController extends GetxController {
|
||||
late final Rx<ServerType> type;
|
||||
late final Semaphore semaphore;
|
||||
late RxBool started;
|
||||
late RxBool detached;
|
||||
StreamSubscription? worker;
|
||||
HttpServer? localServer;
|
||||
HttpServer? remoteServer;
|
||||
@@ -40,8 +39,6 @@ abstract class ServerController extends GetxController {
|
||||
port = TextEditingController(text: _readPort());
|
||||
port.addListener(() =>
|
||||
storage.write("${type.value.name}_port", port.text));
|
||||
detached = RxBool(storage.read("detached") ?? false);
|
||||
detached.listen((value) => storage.write("detached", value));
|
||||
semaphore = Semaphore();
|
||||
}
|
||||
|
||||
@@ -64,7 +61,7 @@ abstract class ServerController extends GetxController {
|
||||
Future<bool> freePort();
|
||||
|
||||
@protected
|
||||
Future<Win32Process> startEmbeddedInternal();
|
||||
Future<Process> startEmbeddedInternal();
|
||||
|
||||
void reset() async {
|
||||
type.value = ServerType.values.elementAt(0);
|
||||
@@ -100,7 +97,7 @@ abstract class ServerController extends GetxController {
|
||||
yield ServerResult(ServerResultType.starting);
|
||||
}else {
|
||||
started.value = false;
|
||||
if(portData != defaultPort) {
|
||||
if(portData != defaultPort.toString()) {
|
||||
yield ServerResult(ServerResultType.starting);
|
||||
}
|
||||
}
|
||||
@@ -124,7 +121,7 @@ abstract class ServerController extends GetxController {
|
||||
return;
|
||||
}
|
||||
|
||||
if ((type() != ServerType.local || portData != defaultPort) && await isPortTaken) {
|
||||
if ((type() != ServerType.local || portData != defaultPort.toString()) && await isPortTaken) {
|
||||
yield ServerResult(ServerResultType.freeingPort);
|
||||
final result = await freePort();
|
||||
yield ServerResult(result ? ServerResultType.freePortSuccess : ServerResultType.freePortError);
|
||||
@@ -138,12 +135,6 @@ abstract class ServerController extends GetxController {
|
||||
case ServerType.embedded:
|
||||
final process = await startEmbeddedInternal();
|
||||
final processPid = process.pid;
|
||||
if(processPid == null) {
|
||||
yield ServerResult(ServerResultType.startError);
|
||||
started.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
watchProcess(processPid).then((value) {
|
||||
if(started()) {
|
||||
started.value = false;
|
||||
@@ -159,11 +150,11 @@ abstract class ServerController extends GetxController {
|
||||
return;
|
||||
}
|
||||
|
||||
remoteServer = await startRemoteAuthenticatorProxy(uriResult);
|
||||
remoteServer = await startRemoteBackendProxy(uriResult);
|
||||
break;
|
||||
case ServerType.local:
|
||||
if(portData != defaultPort) {
|
||||
localServer = await startRemoteAuthenticatorProxy(Uri.parse("http://$defaultHost:$port"));
|
||||
if(portData != defaultPort.toString()) {
|
||||
localServer = await startRemoteBackendProxy(Uri.parse("http://$defaultHost:$portData"));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -10,7 +10,7 @@ class SettingsController extends GetxController {
|
||||
late final String originalDll;
|
||||
late final TextEditingController gameServerDll;
|
||||
late final TextEditingController unrealEngineConsoleDll;
|
||||
late final TextEditingController authenticatorDll;
|
||||
late final TextEditingController backendDll;
|
||||
late final TextEditingController memoryLeakDll;
|
||||
late final TextEditingController gameServerPort;
|
||||
late final RxBool firstRun;
|
||||
@@ -25,7 +25,7 @@ class SettingsController extends GetxController {
|
||||
_storage = GetStorage("settings");
|
||||
gameServerDll = _createController("game_server", "reboot.dll");
|
||||
unrealEngineConsoleDll = _createController("unreal_engine_console", "console.dll");
|
||||
authenticatorDll = _createController("authenticator", "cobalt.dll");
|
||||
backendDll = _createController("backend", "cobalt.dll");
|
||||
memoryLeakDll = _createController("memory_leak", "memoryleak.dll");
|
||||
gameServerPort = TextEditingController(text: _storage.read("game_server_port") ?? kDefaultGameServerPort);
|
||||
gameServerPort.addListener(() => _storage.write("game_server_port", gameServerPort.text));
|
||||
@@ -33,8 +33,8 @@ class SettingsController extends GetxController {
|
||||
height = _storage.read("height") ?? kDefaultWindowHeight;
|
||||
offsetX = _storage.read("offset_x");
|
||||
offsetY = _storage.read("offset_y");
|
||||
firstRun = RxBool(_storage.read("first_run") ?? true);
|
||||
firstRun.listen((value) => _storage.write("first_run", value));
|
||||
firstRun = RxBool(_storage.read("first_run_new1") ?? true);
|
||||
firstRun.listen((value) => _storage.write("first_run_new1", value));
|
||||
themeMode = Rx(ThemeMode.values.elementAt(_storage.read("theme") ?? 0));
|
||||
themeMode.listen((value) => _storage.write("theme", value.index));
|
||||
language = RxString(_storage.read("language") ?? currentLocale);
|
||||
@@ -62,7 +62,7 @@ class SettingsController extends GetxController {
|
||||
void reset(){
|
||||
gameServerDll.text = _controllerDefaultPath("reboot.dll");
|
||||
unrealEngineConsoleDll.text = _controllerDefaultPath("console.dll");
|
||||
authenticatorDll.text = _controllerDefaultPath("cobalt.dll");
|
||||
backendDll.text = _controllerDefaultPath("cobalt.dll");
|
||||
gameServerPort.text = kDefaultGameServerPort;
|
||||
firstRun.value = true;
|
||||
}
|
||||
|
||||
@@ -11,13 +11,15 @@ class UpdateController {
|
||||
late final Rx<UpdateStatus> status;
|
||||
late final Rx<UpdateTimer> timer;
|
||||
late final TextEditingController url;
|
||||
InfoBarEntry? infoBarEntry;
|
||||
Future? _updater;
|
||||
|
||||
UpdateController() {
|
||||
_storage = GetStorage("update");
|
||||
timestamp = RxnInt(_storage.read("ts"));
|
||||
timestamp.listen((value) => _storage.write("ts", value));
|
||||
var timerIndex = _storage.read("timer");
|
||||
timer = Rx(timerIndex == null ? UpdateTimer.hour : UpdateTimer.values.elementAt(timerIndex));
|
||||
timer = Rx(timerIndex == null ? UpdateTimer.day : UpdateTimer.values.elementAt(timerIndex));
|
||||
timer.listen((value) => _storage.write("timer", value.index));
|
||||
url = TextEditingController(text: _storage.read("update_url") ?? kRebootDownloadUrl);
|
||||
url.addListener(() => _storage.write("update_url", url.text));
|
||||
@@ -25,6 +27,16 @@ class UpdateController {
|
||||
}
|
||||
|
||||
Future<void> update([bool force = false]) async {
|
||||
if(_updater != null) {
|
||||
return await _updater;
|
||||
}
|
||||
|
||||
final result = _update(force);
|
||||
_updater = result;
|
||||
return await result;
|
||||
}
|
||||
|
||||
Future<void> _update([bool force = false]) async {
|
||||
try {
|
||||
final needsUpdate = await hasRebootDllUpdate(
|
||||
timestamp.value,
|
||||
@@ -36,25 +48,27 @@ class UpdateController {
|
||||
return;
|
||||
}
|
||||
|
||||
showInfoBar(
|
||||
infoBarEntry = showInfoBar(
|
||||
translations.downloadingDll("reboot"),
|
||||
loading: true,
|
||||
duration: null
|
||||
);
|
||||
timestamp.value = await downloadRebootDll(url.text);
|
||||
status.value = UpdateStatus.success;
|
||||
showInfoBar(
|
||||
infoBarEntry?.close();
|
||||
infoBarEntry = showInfoBar(
|
||||
translations.downloadDllSuccess("reboot"),
|
||||
severity: InfoBarSeverity.success,
|
||||
duration: infoBarShortDuration
|
||||
);
|
||||
}catch(message) {
|
||||
infoBarEntry?.close();
|
||||
var error = message.toString();
|
||||
error = error.contains(": ") ? error.substring(error.indexOf(": ") + 2) : error;
|
||||
error = error.toLowerCase();
|
||||
status.value = UpdateStatus.error;
|
||||
showInfoBar(
|
||||
translations.downloadDllError(error.toString()),
|
||||
translations.downloadDllError("reboot.dll", error.toString()),
|
||||
duration: infoBarLongDuration,
|
||||
severity: InfoBarSeverity.error,
|
||||
action: Button(
|
||||
@@ -62,6 +76,8 @@ class UpdateController {
|
||||
child: Text(translations.downloadDllRetry),
|
||||
)
|
||||
);
|
||||
}finally {
|
||||
_updater = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user