mirror of
https://github.com/Auties00/Reboot-Launcher.git
synced 2026-01-13 11:12:23 +01:00
9.0.8
This commit is contained in:
@@ -1,43 +1,235 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get_storage/get_storage.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;
|
||||
class BackendController extends GetxController {
|
||||
late final GetStorage storage;
|
||||
late final TextEditingController host;
|
||||
late final TextEditingController port;
|
||||
late final Rx<ServerType> type;
|
||||
late final TextEditingController gameServerAddress;
|
||||
late final FocusNode gameServerAddressFocusNode;
|
||||
late final RxnString gameServerOwner;
|
||||
late final RxBool started;
|
||||
late final RxBool detached;
|
||||
StreamSubscription? worker;
|
||||
HttpServer? localServer;
|
||||
HttpServer? remoteServer;
|
||||
|
||||
BackendController() : super() {
|
||||
BackendController() {
|
||||
storage = GetStorage("backend");
|
||||
started = RxBool(false);
|
||||
type = Rx(ServerType.values.elementAt(storage.read("type") ?? 0));
|
||||
type.listen((value) {
|
||||
host.text = _readHost();
|
||||
port.text = _readPort();
|
||||
storage.write("type", value.index);
|
||||
if (!started.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
stop();
|
||||
});
|
||||
host = TextEditingController(text: _readHost());
|
||||
host.addListener(() =>
|
||||
storage.write("${type.value.name}_host", host.text));
|
||||
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));
|
||||
gameServerAddress = TextEditingController(text: storage.read("game_server_address") ?? "127.0.0.1");
|
||||
var lastValue = gameServerAddress.text;
|
||||
writeMatchmakingIp(lastValue);
|
||||
gameServerAddress.addListener(() {
|
||||
var newValue = gameServerAddress.text;
|
||||
if(newValue.trim().toLowerCase() == lastValue.trim().toLowerCase()) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastValue = newValue;
|
||||
gameServerAddress.selection = TextSelection.collapsed(offset: newValue.length);
|
||||
storage.write("game_server_address", newValue);
|
||||
writeMatchmakingIp(newValue);
|
||||
});
|
||||
watchMatchmakingIp().listen((event) {
|
||||
if(event != null && gameServerAddress.text != event) {
|
||||
gameServerAddress.text = event;
|
||||
}
|
||||
});
|
||||
gameServerAddressFocusNode = FocusNode();
|
||||
gameServerOwner = RxnString(storage.read("game_server_owner"));
|
||||
gameServerOwner.listen((value) => storage.write("game_server_owner", value));
|
||||
}
|
||||
|
||||
@override
|
||||
String get controllerName => translations.backendName.toLowerCase();
|
||||
void reset() async {
|
||||
type.value = ServerType.values.elementAt(0);
|
||||
for (final type in ServerType.values) {
|
||||
storage.write("${type.name}_host", null);
|
||||
storage.write("${type.name}_port", null);
|
||||
}
|
||||
|
||||
@override
|
||||
String get storageName => "backend";
|
||||
host.text = type.value != ServerType.remote ? kDefaultBackendHost : "";
|
||||
port.text = kDefaultBackendPort.toString();
|
||||
detached.value = false;
|
||||
}
|
||||
|
||||
@override
|
||||
String get defaultHost => kDefaultBackendHost;
|
||||
String _readHost() {
|
||||
String? value = storage.read("${type.value.name}_host");
|
||||
if (value != null && value.isNotEmpty) {
|
||||
return value;
|
||||
}
|
||||
|
||||
@override
|
||||
int get defaultPort => kDefaultBackendPort;
|
||||
if (type.value != ServerType.remote) {
|
||||
return kDefaultBackendHost;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> get isPortFree => isBackendPortFree();
|
||||
return "";
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> freePort() => freeBackendPort();
|
||||
String _readPort() =>
|
||||
storage.read("${type.value.name}_port") ?? kDefaultBackendPort.toString();
|
||||
|
||||
@override
|
||||
RebootPageType get pageType => RebootPageType.backend;
|
||||
Stream<ServerResult> start() async* {
|
||||
try {
|
||||
if(started.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Process> startEmbeddedInternal() => startEmbeddedBackend(detached.value);
|
||||
final hostData = this.host.text.trim();
|
||||
final portData = this.port.text.trim();
|
||||
if(type() != ServerType.local) {
|
||||
started.value = true;
|
||||
yield ServerResult(ServerResultType.starting);
|
||||
}else {
|
||||
started.value = false;
|
||||
if(portData != kDefaultBackendPort.toString()) {
|
||||
yield ServerResult(ServerResultType.starting);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Uri?> pingServer(String host, int port) => pingBackend(host, port);
|
||||
if (hostData.isEmpty) {
|
||||
yield ServerResult(ServerResultType.missingHostError);
|
||||
started.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (portData.isEmpty) {
|
||||
yield ServerResult(ServerResultType.missingPortError);
|
||||
started.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
final portNumber = int.tryParse(portData);
|
||||
if (portNumber == null) {
|
||||
yield ServerResult(ServerResultType.illegalPortError);
|
||||
started.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((type() != ServerType.local || portData != kDefaultBackendPort.toString()) && !(await isBackendPortFree())) {
|
||||
yield ServerResult(ServerResultType.freeingPort);
|
||||
final result = await freeBackendPort();
|
||||
yield ServerResult(result ? ServerResultType.freePortSuccess : ServerResultType.freePortError);
|
||||
if(!result) {
|
||||
started.value = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch(type()){
|
||||
case ServerType.embedded:
|
||||
final process = await startEmbeddedBackend(detached.value);
|
||||
final processPid = process.pid;
|
||||
watchProcess(processPid).then((value) {
|
||||
if(started()) {
|
||||
started.value = false;
|
||||
}
|
||||
});
|
||||
break;
|
||||
case ServerType.remote:
|
||||
yield ServerResult(ServerResultType.pingingRemote);
|
||||
final uriResult = await pingBackend(hostData, portNumber);
|
||||
if(uriResult == null) {
|
||||
yield ServerResult(ServerResultType.pingError);
|
||||
started.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
remoteServer = await startRemoteBackendProxy(uriResult);
|
||||
break;
|
||||
case ServerType.local:
|
||||
if(portData != kDefaultBackendPort.toString()) {
|
||||
localServer = await startRemoteBackendProxy(Uri.parse("http://$kDefaultBackendHost:$portData"));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
yield ServerResult(ServerResultType.pingingLocal);
|
||||
final uriResult = await pingBackend(kDefaultBackendHost, kDefaultBackendPort);
|
||||
if(uriResult == null) {
|
||||
yield ServerResult(ServerResultType.pingError);
|
||||
remoteServer?.close(force: true);
|
||||
localServer?.close(force: true);
|
||||
started.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
yield ServerResult(ServerResultType.startSuccess);
|
||||
}catch(error, stackTrace) {
|
||||
yield ServerResult(
|
||||
ServerResultType.startError,
|
||||
error: error,
|
||||
stackTrace: stackTrace
|
||||
);
|
||||
remoteServer?.close(force: true);
|
||||
localServer?.close(force: true);
|
||||
started.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
Stream<ServerResult> stop() async* {
|
||||
if(!started.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
yield ServerResult(ServerResultType.stopping);
|
||||
started.value = false;
|
||||
try{
|
||||
switch(type()){
|
||||
case ServerType.embedded:
|
||||
killProcessByPort(kDefaultBackendPort);
|
||||
break;
|
||||
case ServerType.remote:
|
||||
await remoteServer?.close(force: true);
|
||||
remoteServer = null;
|
||||
break;
|
||||
case ServerType.local:
|
||||
await localServer?.close(force: true);
|
||||
localServer = null;
|
||||
break;
|
||||
}
|
||||
yield ServerResult(ServerResultType.stopSuccess);
|
||||
}catch(error, stackTrace){
|
||||
yield ServerResult(
|
||||
ServerResultType.stopError,
|
||||
error: error,
|
||||
stackTrace: stackTrace
|
||||
);
|
||||
started.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
Stream<ServerResult> toggle() async* {
|
||||
if(started()) {
|
||||
yield* stop();
|
||||
}else {
|
||||
yield* start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,10 +4,8 @@ import 'package:reboot_common/common.dart';
|
||||
class BuildController extends GetxController {
|
||||
List<FortniteBuild>? _builds;
|
||||
Rxn<FortniteBuild> _selectedBuild;
|
||||
Rx<FortniteBuildSource> _selectedBuildSource;
|
||||
|
||||
BuildController() : _selectedBuild = Rxn(),
|
||||
_selectedBuildSource = Rx(FortniteBuildSource.manifest);
|
||||
BuildController() : _selectedBuild = Rxn();
|
||||
|
||||
List<FortniteBuild>? get builds => _builds;
|
||||
|
||||
@@ -15,26 +13,10 @@ class BuildController extends GetxController {
|
||||
|
||||
set selectedBuild(FortniteBuild? value) {
|
||||
_selectedBuild.value = value;
|
||||
if(value != null && value.source != value.source) {
|
||||
_selectedBuildSource.value = value.source;
|
||||
}
|
||||
}
|
||||
|
||||
FortniteBuildSource get selectedBuildSource => _selectedBuildSource.value;
|
||||
|
||||
set selectedBuildSource(FortniteBuildSource value) {
|
||||
_selectedBuildSource.value = value;
|
||||
final selected = selectedBuild;
|
||||
if(selected == null || selected.source != value) {
|
||||
final selectable = builds?.firstWhereOrNull((element) => element.source == value);
|
||||
_selectedBuild.value = selectable;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
set builds(List<FortniteBuild>? builds) {
|
||||
_builds = builds;
|
||||
final selectable = builds?.firstWhereOrNull((element) => element.source == selectedBuildSource);
|
||||
_selectedBuild.value = selectable;
|
||||
_selectedBuild.value = builds?.firstOrNull;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ class HostingController extends GetxController {
|
||||
late final RxBool discoverable;
|
||||
late final RxBool headless;
|
||||
late final RxBool virtualDesktop;
|
||||
late final RxBool autoRestart;
|
||||
late final RxBool started;
|
||||
late final RxBool published;
|
||||
late final Rxn<GameInstance> instance;
|
||||
@@ -36,6 +37,8 @@ class HostingController extends GetxController {
|
||||
headless.listen((value) => _storage.write("headless", value));
|
||||
virtualDesktop = RxBool(_storage.read("virtual_desktop") ?? true);
|
||||
virtualDesktop.listen((value) => _storage.write("virtual_desktop", value));
|
||||
autoRestart = RxBool(_storage.read("auto_restart") ?? true);
|
||||
autoRestart.listen((value) => _storage.write("auto_restart", value));
|
||||
started = RxBool(false);
|
||||
published = RxBool(false);
|
||||
showPassword = RxBool(false);
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
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';
|
||||
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 MatchmakerController extends ServerController {
|
||||
late final TextEditingController gameServerAddress;
|
||||
late final FocusNode gameServerAddressFocusNode;
|
||||
late final RxnString gameServerOwner;
|
||||
|
||||
MatchmakerController() : super() {
|
||||
gameServerAddress = TextEditingController(text: storage.read("game_server_address") ?? kDefaultMatchmakerHost);
|
||||
var lastValue = gameServerAddress.text;
|
||||
writeMatchmakingIp(lastValue);
|
||||
gameServerAddress.addListener(() {
|
||||
var newValue = gameServerAddress.text;
|
||||
if(newValue.trim().toLowerCase() == lastValue.trim().toLowerCase()) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastValue = newValue;
|
||||
gameServerAddress.selection = TextSelection.collapsed(offset: newValue.length);
|
||||
storage.write("game_server_address", newValue);
|
||||
writeMatchmakingIp(newValue);
|
||||
});
|
||||
watchMatchmakingIp().listen((event) {
|
||||
if(event != null && gameServerAddress.text != event) {
|
||||
gameServerAddress.text = event;
|
||||
}
|
||||
});
|
||||
gameServerAddressFocusNode = FocusNode();
|
||||
gameServerOwner = RxnString(storage.read("game_server_owner"));
|
||||
gameServerOwner.listen((value) => storage.write("game_server_owner", value));
|
||||
}
|
||||
|
||||
@override
|
||||
String get controllerName => translations.matchmakerName.toLowerCase();
|
||||
|
||||
@override
|
||||
String get storageName => "matchmaker";
|
||||
|
||||
@override
|
||||
String get defaultHost => kDefaultMatchmakerHost;
|
||||
|
||||
@override
|
||||
int get defaultPort => kDefaultMatchmakerPort;
|
||||
|
||||
@override
|
||||
Future<bool> get isPortFree => isMatchmakerPortFree();
|
||||
|
||||
@override
|
||||
Future<bool> freePort() => freeMatchmakerPort();
|
||||
|
||||
@override
|
||||
RebootPageType get pageType => RebootPageType.matchmaker;
|
||||
|
||||
@override
|
||||
Future<Process> startEmbeddedInternal() => startEmbeddedMatchmaker();
|
||||
|
||||
@override
|
||||
Future<Uri?> pingServer(String host, int port) => pingMatchmaker(host, port);
|
||||
}
|
||||
@@ -1,225 +0,0 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page_type.dart';
|
||||
import 'package:sync/semaphore.dart';
|
||||
|
||||
abstract class ServerController extends GetxController {
|
||||
late final GetStorage storage;
|
||||
late final TextEditingController host;
|
||||
late final TextEditingController port;
|
||||
late final Rx<ServerType> type;
|
||||
late final Semaphore semaphore;
|
||||
late RxBool started;
|
||||
StreamSubscription? worker;
|
||||
HttpServer? localServer;
|
||||
HttpServer? remoteServer;
|
||||
|
||||
ServerController() {
|
||||
storage = GetStorage(storageName);
|
||||
started = RxBool(false);
|
||||
type = Rx(ServerType.values.elementAt(storage.read("type") ?? 0));
|
||||
type.listen((value) {
|
||||
host.text = _readHost();
|
||||
port.text = _readPort();
|
||||
storage.write("type", value.index);
|
||||
if (!started.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
stop();
|
||||
});
|
||||
host = TextEditingController(text: _readHost());
|
||||
host.addListener(() =>
|
||||
storage.write("${type.value.name}_host", host.text));
|
||||
port = TextEditingController(text: _readPort());
|
||||
port.addListener(() =>
|
||||
storage.write("${type.value.name}_port", port.text));
|
||||
semaphore = Semaphore();
|
||||
}
|
||||
|
||||
String get controllerName;
|
||||
|
||||
String get storageName;
|
||||
|
||||
String get defaultHost;
|
||||
|
||||
int get defaultPort;
|
||||
|
||||
Future<Uri?> pingServer(String host, int port);
|
||||
|
||||
Future<bool> get isPortFree;
|
||||
|
||||
Future<bool> get isPortTaken async => !(await isPortFree);
|
||||
|
||||
RebootPageType get pageType;
|
||||
|
||||
Future<bool> freePort();
|
||||
|
||||
@protected
|
||||
Future<Process> startEmbeddedInternal();
|
||||
|
||||
void reset() async {
|
||||
type.value = ServerType.values.elementAt(0);
|
||||
for (final type in ServerType.values) {
|
||||
storage.write("${type.name}_host", null);
|
||||
storage.write("${type.name}_port", null);
|
||||
}
|
||||
|
||||
host.text = type.value != ServerType.remote ? defaultHost : "";
|
||||
port.text = defaultPort.toString();
|
||||
detached.value = false;
|
||||
}
|
||||
|
||||
String _readHost() {
|
||||
String? value = storage.read("${type.value.name}_host");
|
||||
return value != null && value.isNotEmpty ? value
|
||||
: type.value != ServerType.remote ? defaultHost : "";
|
||||
}
|
||||
|
||||
String _readPort() =>
|
||||
storage.read("${type.value.name}_port") ?? defaultPort.toString();
|
||||
|
||||
Stream<ServerResult> start() async* {
|
||||
try {
|
||||
if(started.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
final hostData = this.host.text.trim();
|
||||
final portData = this.port.text.trim();
|
||||
if(type() != ServerType.local) {
|
||||
started.value = true;
|
||||
yield ServerResult(ServerResultType.starting);
|
||||
}else {
|
||||
started.value = false;
|
||||
if(portData != defaultPort.toString()) {
|
||||
yield ServerResult(ServerResultType.starting);
|
||||
}
|
||||
}
|
||||
|
||||
if (hostData.isEmpty) {
|
||||
yield ServerResult(ServerResultType.missingHostError);
|
||||
started.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (portData.isEmpty) {
|
||||
yield ServerResult(ServerResultType.missingPortError);
|
||||
started.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
final portNumber = int.tryParse(portData);
|
||||
if (portNumber == null) {
|
||||
yield ServerResult(ServerResultType.illegalPortError);
|
||||
started.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if ((type() != ServerType.local || portData != defaultPort.toString()) && await isPortTaken) {
|
||||
yield ServerResult(ServerResultType.freeingPort);
|
||||
final result = await freePort();
|
||||
yield ServerResult(result ? ServerResultType.freePortSuccess : ServerResultType.freePortError);
|
||||
if(!result) {
|
||||
started.value = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
switch(type()){
|
||||
case ServerType.embedded:
|
||||
final process = await startEmbeddedInternal();
|
||||
final processPid = process.pid;
|
||||
watchProcess(processPid).then((value) {
|
||||
if(started()) {
|
||||
started.value = false;
|
||||
}
|
||||
});
|
||||
break;
|
||||
case ServerType.remote:
|
||||
yield ServerResult(ServerResultType.pingingRemote);
|
||||
final uriResult = await pingServer(hostData, portNumber);
|
||||
if(uriResult == null) {
|
||||
yield ServerResult(ServerResultType.pingError);
|
||||
started.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
remoteServer = await startRemoteBackendProxy(uriResult);
|
||||
break;
|
||||
case ServerType.local:
|
||||
if(portData != defaultPort.toString()) {
|
||||
localServer = await startRemoteBackendProxy(Uri.parse("http://$defaultHost:$portData"));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
yield ServerResult(ServerResultType.pingingLocal);
|
||||
final uriResult = await pingServer(defaultHost, defaultPort);
|
||||
if(uriResult == null) {
|
||||
yield ServerResult(ServerResultType.pingError);
|
||||
remoteServer?.close(force: true);
|
||||
localServer?.close(force: true);
|
||||
started.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
yield ServerResult(ServerResultType.startSuccess);
|
||||
}catch(error, stackTrace) {
|
||||
yield ServerResult(
|
||||
ServerResultType.startError,
|
||||
error: error,
|
||||
stackTrace: stackTrace
|
||||
);
|
||||
remoteServer?.close(force: true);
|
||||
localServer?.close(force: true);
|
||||
started.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
Stream<ServerResult> stop() async* {
|
||||
if(!started.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
yield ServerResult(ServerResultType.stopping);
|
||||
started.value = false;
|
||||
try{
|
||||
switch(type()){
|
||||
case ServerType.embedded:
|
||||
killProcessByPort(defaultPort);
|
||||
break;
|
||||
case ServerType.remote:
|
||||
await remoteServer?.close(force: true);
|
||||
remoteServer = null;
|
||||
break;
|
||||
case ServerType.local:
|
||||
await localServer?.close(force: true);
|
||||
localServer = null;
|
||||
break;
|
||||
}
|
||||
yield ServerResult(ServerResultType.stopSuccess);
|
||||
}catch(error, stackTrace){
|
||||
yield ServerResult(
|
||||
ServerResultType.stopError,
|
||||
error: error,
|
||||
stackTrace: stackTrace
|
||||
);
|
||||
started.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
Stream<ServerResult> toggle() async* {
|
||||
if(started()) {
|
||||
yield* stop();
|
||||
}else {
|
||||
yield* start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,14 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get_storage/get_storage.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/main.dart';
|
||||
import 'package:reboot_launcher/src/dialog/abstract/info_bar.dart';
|
||||
import 'package:reboot_launcher/src/util/translations.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:version/version.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
class UpdateController {
|
||||
late final GetStorage _storage;
|
||||
@@ -11,6 +16,7 @@ class UpdateController {
|
||||
late final Rx<UpdateStatus> status;
|
||||
late final Rx<UpdateTimer> timer;
|
||||
late final TextEditingController url;
|
||||
late final RxBool customGameServer;
|
||||
InfoBarEntry? infoBarEntry;
|
||||
Future? _updater;
|
||||
|
||||
@@ -19,25 +25,63 @@ class UpdateController {
|
||||
timestamp = RxnInt(_storage.read("ts"));
|
||||
timestamp.listen((value) => _storage.write("ts", value));
|
||||
var timerIndex = _storage.read("timer");
|
||||
timer = Rx(timerIndex == null ? UpdateTimer.day : UpdateTimer.values.elementAt(timerIndex));
|
||||
timer = Rx(timerIndex == null ? UpdateTimer.hour : 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));
|
||||
status = Rx(UpdateStatus.waiting);
|
||||
customGameServer = RxBool(_storage.read("custom_game_server") ?? false);
|
||||
customGameServer.listen((value) => _storage.write("custom_game_server", value));
|
||||
}
|
||||
|
||||
Future<void> update([bool force = false]) async {
|
||||
Future<void> notifyLauncherUpdate() async {
|
||||
if(appVersion == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
final pubspecResponse = await http.get(Uri.parse("https://raw.githubusercontent.com/Auties00/reboot_launcher/master/gui/pubspec.yaml"));
|
||||
if(pubspecResponse.statusCode != 200) {
|
||||
return;
|
||||
}
|
||||
|
||||
final pubspec = loadYaml(pubspecResponse.body);
|
||||
final latestVersion = Version.parse(pubspec["version"]);
|
||||
if(latestVersion <= appVersion) {
|
||||
return;
|
||||
}
|
||||
|
||||
late InfoBarEntry infoBar;
|
||||
infoBar = showInfoBar(
|
||||
translations.updateAvailable(latestVersion.toString()),
|
||||
duration: null,
|
||||
severity: InfoBarSeverity.warning,
|
||||
action: Button(
|
||||
child: Text(translations.updateAvailableAction),
|
||||
onPressed: () {
|
||||
infoBar.close();
|
||||
launchUrl(Uri.parse("https://github.com/Auties00/reboot_launcher/releases"));
|
||||
},
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> updateReboot([bool force = false]) async {
|
||||
if(_updater != null) {
|
||||
return await _updater;
|
||||
}
|
||||
|
||||
final result = _update(force);
|
||||
final result = _updateReboot(force);
|
||||
_updater = result;
|
||||
return await result;
|
||||
}
|
||||
|
||||
Future<void> _update([bool force = false]) async {
|
||||
Future<void> _updateReboot([bool force = false]) async {
|
||||
try {
|
||||
if(customGameServer.value) {
|
||||
status.value = UpdateStatus.success;
|
||||
return;
|
||||
}
|
||||
|
||||
final needsUpdate = await hasRebootDllUpdate(
|
||||
timestamp.value,
|
||||
hours: timer.value.hours,
|
||||
@@ -72,7 +116,7 @@ class UpdateController {
|
||||
duration: infoBarLongDuration,
|
||||
severity: InfoBarSeverity.error,
|
||||
action: Button(
|
||||
onPressed: () => update(true),
|
||||
onPressed: () => updateReboot(true),
|
||||
child: Text(translations.downloadDllRetry),
|
||||
)
|
||||
);
|
||||
@@ -86,7 +130,8 @@ class UpdateController {
|
||||
timer.value = UpdateTimer.never;
|
||||
url.text = kRebootDownloadUrl;
|
||||
status.value = UpdateStatus.waiting;
|
||||
update();
|
||||
customGameServer.value = false;
|
||||
updateReboot();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,9 +6,8 @@ import 'package:fluent_ui/fluent_ui.dart' hide FluentIcons;
|
||||
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/controller/backend_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/hosting_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/matchmaker_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/server_controller.dart';
|
||||
import 'package:reboot_launcher/src/dialog/abstract/dialog.dart';
|
||||
import 'package:reboot_launcher/src/dialog/abstract/dialog_button.dart';
|
||||
import 'package:reboot_launcher/src/dialog/abstract/info_bar.dart';
|
||||
@@ -19,7 +18,9 @@ import 'package:reboot_launcher/src/util/translations.dart';
|
||||
import 'package:supabase_flutter/supabase_flutter.dart';
|
||||
import 'package:sync/semaphore.dart';
|
||||
|
||||
extension ServerControllerDialog on ServerController {
|
||||
final Semaphore _publishingSemaphore = Semaphore();
|
||||
|
||||
extension ServerControllerDialog on BackendController {
|
||||
Future<bool> toggleInteractive() async {
|
||||
final stream = toggle();
|
||||
final completer = Completer<bool>();
|
||||
@@ -41,19 +42,19 @@ extension ServerControllerDialog on ServerController {
|
||||
switch (event.type) {
|
||||
case ServerResultType.starting:
|
||||
return showInfoBar(
|
||||
translations.startingServer(controllerName),
|
||||
translations.startingServer,
|
||||
severity: InfoBarSeverity.info,
|
||||
loading: true,
|
||||
duration: null
|
||||
);
|
||||
case ServerResultType.startSuccess:
|
||||
return showInfoBar(
|
||||
type.value == ServerType.local ? translations.checkedServer(controllerName) : translations.startedServer(controllerName),
|
||||
type.value == ServerType.local ? translations.checkedServer : translations.startedServer,
|
||||
severity: InfoBarSeverity.success
|
||||
);
|
||||
case ServerResultType.startError:
|
||||
return showInfoBar(
|
||||
type.value == ServerType.local ? translations.localServerError(event.error ?? translations.unknownError, controllerName) : translations.startServerError(event.error ?? translations.unknownError, controllerName),
|
||||
type.value == ServerType.local ? translations.localServerError(event.error ?? translations.unknownError) : translations.startServerError(event.error ?? translations.unknownError),
|
||||
severity: InfoBarSeverity.error,
|
||||
duration: infoBarLongDuration
|
||||
);
|
||||
@@ -66,75 +67,70 @@ extension ServerControllerDialog on ServerController {
|
||||
);
|
||||
case ServerResultType.stopSuccess:
|
||||
return showInfoBar(
|
||||
translations.stoppedServer(controllerName),
|
||||
translations.stoppedServer,
|
||||
severity: InfoBarSeverity.success
|
||||
);
|
||||
case ServerResultType.stopError:
|
||||
return showInfoBar(
|
||||
translations.stopServerError(
|
||||
event.error ?? translations.unknownError, controllerName),
|
||||
translations.stopServerError(event.error ?? translations.unknownError),
|
||||
severity: InfoBarSeverity.error,
|
||||
duration: infoBarLongDuration
|
||||
);
|
||||
case ServerResultType.missingHostError:
|
||||
return showInfoBar(
|
||||
translations.missingHostNameError(controllerName),
|
||||
translations.missingHostNameError,
|
||||
severity: InfoBarSeverity.error
|
||||
);
|
||||
case ServerResultType.missingPortError:
|
||||
return showInfoBar(
|
||||
translations.missingPortError(controllerName),
|
||||
translations.missingPortError,
|
||||
severity: InfoBarSeverity.error
|
||||
);
|
||||
case ServerResultType.illegalPortError:
|
||||
return showInfoBar(
|
||||
translations.illegalPortError(controllerName),
|
||||
translations.illegalPortError,
|
||||
severity: InfoBarSeverity.error
|
||||
);
|
||||
case ServerResultType.freeingPort:
|
||||
return showInfoBar(
|
||||
translations.freeingPort(defaultPort),
|
||||
translations.freeingPort,
|
||||
loading: true,
|
||||
duration: null
|
||||
);
|
||||
case ServerResultType.freePortSuccess:
|
||||
return showInfoBar(
|
||||
translations.freedPort(defaultPort),
|
||||
translations.freedPort,
|
||||
severity: InfoBarSeverity.success,
|
||||
duration: infoBarShortDuration
|
||||
);
|
||||
case ServerResultType.freePortError:
|
||||
return showInfoBar(
|
||||
translations.freePortError(event.error ?? translations.unknownError, controllerName),
|
||||
translations.freePortError(event.error ?? translations.unknownError),
|
||||
severity: InfoBarSeverity.error,
|
||||
duration: infoBarLongDuration
|
||||
);
|
||||
case ServerResultType.pingingRemote:
|
||||
return showInfoBar(
|
||||
translations.pingingRemoteServer(controllerName),
|
||||
translations.pingingRemoteServer,
|
||||
severity: InfoBarSeverity.info,
|
||||
loading: true,
|
||||
duration: null
|
||||
);
|
||||
case ServerResultType.pingingLocal:
|
||||
return showInfoBar(
|
||||
translations.pingingLocalServer(controllerName, type().name),
|
||||
translations.pingingLocalServer(type.value.name),
|
||||
severity: InfoBarSeverity.info,
|
||||
loading: true,
|
||||
duration: null
|
||||
);
|
||||
case ServerResultType.pingError:
|
||||
return showInfoBar(
|
||||
translations.pingError(controllerName, type().name),
|
||||
translations.pingError(type.value.name),
|
||||
severity: InfoBarSeverity.error
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Semaphore _publishingSemaphore = Semaphore();
|
||||
|
||||
extension MatchmakerControllerExtension on MatchmakerController {
|
||||
void joinLocalHost() {
|
||||
gameServerAddress.text = kDefaultGameServerHost;
|
||||
gameServerOwner.value = null;
|
||||
|
||||
@@ -3,7 +3,6 @@ enum RebootPageType {
|
||||
host,
|
||||
browser,
|
||||
backend,
|
||||
matchmaker,
|
||||
info,
|
||||
settings
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import 'package:reboot_launcher/src/controller/game_controller.dart';
|
||||
import 'package:reboot_launcher/src/dialog/abstract/info_bar.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page_type.dart';
|
||||
import 'package:reboot_launcher/src/page/pages.dart';
|
||||
import 'package:reboot_launcher/src/util/keyboard.dart';
|
||||
import 'package:reboot_launcher/src/util/translations.dart';
|
||||
import 'package:reboot_launcher/src/widget/server_start_button.dart';
|
||||
@@ -67,12 +66,32 @@ class _BackendPageState extends RebootPageState<BackendPage> {
|
||||
_type,
|
||||
_hostName,
|
||||
_port,
|
||||
_detached,
|
||||
_gameServerAddress,
|
||||
_unrealEngineConsoleKey,
|
||||
_detached,
|
||||
_installationDirectory,
|
||||
_resetDefaults
|
||||
];
|
||||
|
||||
Widget get _gameServerAddress => Obx(() {
|
||||
if(_backendController.type.value != ServerType.embedded) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.stream_input_20_regular
|
||||
),
|
||||
title: Text(translations.matchmakerConfigurationAddressName),
|
||||
subtitle: Text(translations.matchmakerConfigurationAddressDescription),
|
||||
content: TextFormBox(
|
||||
placeholder: translations.matchmakerConfigurationAddressName,
|
||||
controller: _backendController.gameServerAddress,
|
||||
focusNode: _backendController.gameServerAddressFocusNode
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
Widget get _hostName => Obx(() {
|
||||
if(_backendController.type.value != ServerType.remote) {
|
||||
return const SizedBox.shrink();
|
||||
@@ -202,13 +221,9 @@ class _BackendPageState extends RebootPageState<BackendPage> {
|
||||
),
|
||||
title: Text(translations.backendTypeName),
|
||||
subtitle: Text(translations.backendTypeDescription),
|
||||
content: const ServerTypeSelector(
|
||||
backend: true
|
||||
)
|
||||
content: const ServerTypeSelector()
|
||||
);
|
||||
|
||||
@override
|
||||
Widget get button => const ServerButton(
|
||||
backend: true
|
||||
);
|
||||
Widget get button => const ServerButton();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,8 @@ class _HomePageState extends State<HomePage> with WindowListener, AutomaticKeepA
|
||||
void initState() {
|
||||
windowManager.addListener(this);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_updateController.update();
|
||||
_updateController.notifyLauncherUpdate();
|
||||
_updateController.updateReboot();
|
||||
watchDlls().listen((filePath) => showDllDeletedDialog(() {
|
||||
downloadCriticalDllInteractive(filePath);
|
||||
}));
|
||||
|
||||
@@ -6,8 +6,8 @@ import 'package:reboot_launcher/src/controller/settings_controller.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page_type.dart';
|
||||
import 'package:reboot_launcher/src/page/pages.dart';
|
||||
import 'package:reboot_launcher/src/util/info.dart';
|
||||
import 'package:reboot_launcher/src/util/translations.dart';
|
||||
import 'package:reboot_launcher/src/widget/info_tile.dart';
|
||||
|
||||
class InfoPage extends RebootPage {
|
||||
const InfoPage({Key? key}) : super(key: key);
|
||||
@@ -32,153 +32,6 @@ class _InfoPageState extends RebootPageState<InfoPage> {
|
||||
final SettingsController _settingsController = Get.find<SettingsController>();
|
||||
RxInt _counter = RxInt(180);
|
||||
|
||||
static final List<InfoTile> _infoTiles = [
|
||||
InfoTile(
|
||||
title: Text("What is Project Reboot?"),
|
||||
content: Text(
|
||||
"Project Reboot is a game server for Fortnite that aims to support as many seasons as possible.\n"
|
||||
"The project was started on Discord by Milxnor, while the launcher is developed by Auties00.\n"
|
||||
"Both are open source on GitHub, anyone can easily contribute or audit the code!"
|
||||
)
|
||||
),
|
||||
InfoTile(
|
||||
title: Text("What is a Fortnite game server?"),
|
||||
content: Text(
|
||||
"If you have ever played Minecraft multiplayer, you might know that the servers you join are hosted on a computer running a program, called Minecraft Game Server.\n"
|
||||
"While the Minecraft Game server is written by the creators of Minecraft, Mojang, Epic Games doesn't provide an equivalent for Fortnite.\n"
|
||||
"By exploiting the Fortnite internals, though, it's possible to create a game server just like in Minecraft: this is in easy terms what Project Reboot does.\n"
|
||||
"Some Fortnite versions support running this game server in the background without rendering the game(\"headless\"), while others still require the full game to be open.\n"
|
||||
"Just like in Minecraft, you need a game client to play the game and one to host the server.\n"
|
||||
"By default, a game server is automatically started on your PC when you start a Fortnite version from the \"Play\" section in the launcher.\n"
|
||||
"If you want to play in another way, for example by joining a server hosted by one of your friends instead of running one yourself, you can checkout the \"Multiplayer\" section in the \"Play\" tab of the launcher."
|
||||
)
|
||||
),
|
||||
InfoTile(
|
||||
title: Text("Types of Fortnite game server"),
|
||||
content: Text(
|
||||
"Some Fortnite versions support running this game server in the background without rendering the game: this type of server is called \"headless\" as the game is running, but you can't see it on your screen.\n"
|
||||
"If headless is not supported by the Fortnite version you want to play, or if you disabled it manually from the \"Configuration\" section in the \"Host\" tab of the launcher, you will see an instance of Fortnite open on your screen.\n"
|
||||
"For convenience, this window will be opened on a new Virtual Desktop, if your Windows version supports it. This feature can be disabled as well from from the \"Configuration\" section in the \"Host\" tab of the launcher."
|
||||
"Just like in Minecraft, you need a game client to play the game and one to host the server."
|
||||
)
|
||||
),
|
||||
InfoTile(
|
||||
title: Text("How can others join my game server?"),
|
||||
content: Text(
|
||||
"For others to join your game server, port 7777 must be accessible on your PC.\n"
|
||||
"One option is to use a private VPN service like Hamachi or Radmin, but all of the players will need to download this software.\n"
|
||||
"The best solution is to use port forwarding:\n"
|
||||
"1. Set a static IP\n"
|
||||
" If you don't have already a static IP set, set one by following any tutorial on Google\n"
|
||||
"2. Log into your router's admin panel\n"
|
||||
" Usually this can be accessed on any web browser by going to http://192.168.1.1/\n"
|
||||
" You might need a username and a password to log in: refer to your router's manual for precise instructions\n"
|
||||
"3. Find the port forwarding section\n"
|
||||
" Once logged in into the admin panel, navigate to the port forwarding section of your router's settings\n"
|
||||
" This location may vary from router to router, but it's typically labelled as \"Port Forwarding,\" \"Port Mapping\" or \"Virtual Server\"\n"
|
||||
" Refer to your router's manual for precise instructions\n"
|
||||
"4. Add a port forwarding rule\n"
|
||||
" Now, you'll need to create a new port forwarding rule. Here's what you'll typically need to specify:\n"
|
||||
" - Service Name: Choose a name for your port forwarding rule (e.g., \"Fortnite Game Server\")\n"
|
||||
" - Port Number: Enter 7777 for both the external and internal ports\n"
|
||||
" - Protocol: Select the UDP protocol\n"
|
||||
" - Internal IP Address: Enter the static IP address you set earlier\n"
|
||||
" - Enable: Make sure the port forwarding rule is enabled\n"
|
||||
"5. Save and apply the changes\n"
|
||||
" After configuring the port forwarding rule, save your changes and apply them\n"
|
||||
" This step may involve clicking a \"Save\" or \"Apply\" button on your router's web interface"
|
||||
)
|
||||
),
|
||||
InfoTile(
|
||||
title: Text("What is a backend?"),
|
||||
content: Text(
|
||||
"A backend is a piece of software that emulates the Epic Games server responsible for authentication and related features.\n"
|
||||
"By default, the Reboot Launcher ships with a slightly customized version of LawinV1, an open source implementation available on Github.\n"
|
||||
"If you are having any problems with the built in backend, enable the \"Detached\" option in the \"Backend\" tab of the Reboot Laucher to troubleshoot the issue."
|
||||
"LawinV1 was chosen to allow users to log into Fortnite and join games easily, but keep in mind that if you want to use features such as parties, voice chat or skins, you will need to use a custom backend.\n"
|
||||
"Other popular options are LawinV2 and Momentum, both available on Github, but it's not recommended to use them if you are not an advanced user.\n"
|
||||
"You can run these alternatives either either on your PC or on a server by selecting respectively \"Local\" or \"Remote\" from the \"Type\" section in the \"Backend\" tab of the Reboot Launcher."
|
||||
)
|
||||
),
|
||||
InfoTile(
|
||||
title: Text("What is the Unreal Engine console?"),
|
||||
content: Text(
|
||||
"Many Fortnite versions don't support entering in game by clicking the \"Play\" button.\n"
|
||||
"Instead, you need to click the key assigned to the Unreal Engine console, by default F8 or the tilde(the button above tab), and type open 127.0.0.1\n"
|
||||
"Keep in mind that the Unreal Engine console key is controlled by the backend, so this is true only if you are using the embedded backend: custom backends might use different keys.\n"
|
||||
"When using the embedded backend, you can customize the key used to open the console in the \"Backend\" tab of the Reboot Launcher."
|
||||
)
|
||||
),
|
||||
InfoTile(
|
||||
title: Text("What is a matchmaker?"),
|
||||
content: Text(
|
||||
"A matchmaker is a piece of software that emulates the Epic Games server responsible for putting you in game when you click the \"Play\" button in Fortnite.\n"
|
||||
"By default, the Reboot Launcher ships with a slightly customized version of Lawin's FortMatchmaker, an open source implementation available on Github.\n"
|
||||
"If you are having any problems with the built in matchmaker, enable the \"Detached\" option in the \"Matchmaker\" tab of the Reboot Launcher to troubleshoot the issue.\n"
|
||||
"Lawin's FortMatchmaker is an extremely basic implementation of a matchmaker: it takes the IP you configured in the \"Matchmaker\" tab, by default 127.0.0.1(your local machine) of the Reboot Launcher and send you with no wait to that game server.\n"
|
||||
"Unfortunately right now the play button still doesn't work on many Fortnite versions, you so might need to use the Unreal Engine console.\n"
|
||||
"Just like a backend, you can run a custom matchmaker, either on your PC or on a server with the appropriate configuration."
|
||||
)
|
||||
),
|
||||
InfoTile(
|
||||
title: Text("The backend is not working correctly"),
|
||||
content: Text(
|
||||
"To resolve this issue:\n"
|
||||
"- Check that your backend is working correctly from the \"Backend\" tab\n"
|
||||
"- If you are using a custom backend, try to use the embedded one\n"
|
||||
"- Try to run the backend as detached by enabling the \"Detached\" option in the \"Backend\" tab"
|
||||
)
|
||||
),
|
||||
InfoTile(
|
||||
title: Text("The matchmaker is not working correctly"),
|
||||
content: Text(
|
||||
"To resolve this issue:\n"
|
||||
"- Check that your matchmaker is working correctly from the \"Matchmaker\" tab\n"
|
||||
"- If you are using a custom matchmaker, try to use the embedded one\n"
|
||||
"- Try to run the matchmaker as detached by enabling the \"Detached\" option in the \"Matchmaker\" tab"
|
||||
)
|
||||
),
|
||||
InfoTile(
|
||||
title: Text("Why do I see two Fortnite versions opened on my PC?"),
|
||||
content: Text(
|
||||
"As explained in the \"What is a Fortnite game server?\" section, one instance of Fortnite is used to host the game server, while the other is used to let you play.\n"
|
||||
"The Fortnite instance used up by the game server is usually frozen, so it should be hard to use the wrong one to try to play.\n"
|
||||
"If you do not want to host a game server yourself, you can:\n"
|
||||
"1. Set a custom IP in the \"Matchmaker\" tab\n"
|
||||
"2. Set a custom matchmaker in the \"Matchmaker\" tab\n"
|
||||
"3. Disable the automatic game server from the \"Configuration\" section in the \"Host\" tab\n"
|
||||
)
|
||||
),
|
||||
InfoTile(
|
||||
title: Text("I cannot open Fortnite because of an authentication error"),
|
||||
content: Text(
|
||||
"To resolve this issue:\n"
|
||||
"- Check that your backend is working correctly from the \"Backend\" tab\n"
|
||||
"- If you are using a custom backend, try to use the embedded one\n"
|
||||
"- Try to run the backend as detached by enabling the \"Detached\" option in the \"Backend\" tab"
|
||||
)
|
||||
),
|
||||
InfoTile(
|
||||
title: Text("I cannot enter in a match when I'm in Fortnite"),
|
||||
content: Text(
|
||||
"As explained in the \"What is the Unreal Engine console?\" section, the \"Play\" button doesn't work in many Fortnite versions.\n"
|
||||
"Instead, you need to click the key assigned to the Unreal Engine console, by default F8 or the tilde(the button above tab), and type open 127.0.0.1"
|
||||
)
|
||||
),
|
||||
InfoTile(
|
||||
title: Text("An error occurred while downloading a build (DioException)"),
|
||||
content: Text(
|
||||
"Unfortunately the servers that host the Fortnite builds are not reliable all the time so it might take a few tries, or downloading another version, to get started"
|
||||
)
|
||||
),
|
||||
InfoTile(
|
||||
title: Text("Failed to open descriptor file / Fortnite crash Reporter / Unreal Engine crash reporter"),
|
||||
content: Text(
|
||||
"Your version of Fortnite is corrupted, download it again from the launcher or use another build."
|
||||
)
|
||||
),
|
||||
];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if(_settingsController.firstRun.value) {
|
||||
@@ -195,7 +48,7 @@ class _InfoPageState extends RebootPageState<InfoPage> {
|
||||
}
|
||||
|
||||
@override
|
||||
List<Widget> get settings => _infoTiles;
|
||||
List<Widget> get settings => infoTiles;
|
||||
|
||||
@override
|
||||
Widget? get button => Obx(() {
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart' as fluentUi show FluentIcons;
|
||||
import 'package:fluent_ui/fluent_ui.dart' hide FluentIcons;
|
||||
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/controller/matchmaker_controller.dart';
|
||||
import 'package:reboot_launcher/src/dialog/implementation/data.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page_type.dart';
|
||||
import 'package:reboot_launcher/src/util/translations.dart';
|
||||
import 'package:reboot_launcher/src/widget/server_start_button.dart';
|
||||
import 'package:reboot_launcher/src/widget/server_type_selector.dart';
|
||||
import 'package:reboot_launcher/src/widget/setting_tile.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class MatchmakerPage extends RebootPage {
|
||||
const MatchmakerPage({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
RebootPageState<MatchmakerPage> createState() => _MatchmakerPageState();
|
||||
|
||||
@override
|
||||
String get name => translations.matchmakerName;
|
||||
|
||||
@override
|
||||
String get iconAsset => "assets/images/matchmaker.png";
|
||||
|
||||
@override
|
||||
bool hasButton(String? pageName) => pageName == null;
|
||||
|
||||
@override
|
||||
RebootPageType get type => RebootPageType.matchmaker;
|
||||
}
|
||||
|
||||
class _MatchmakerPageState extends RebootPageState<MatchmakerPage> {
|
||||
final MatchmakerController _matchmakerController = Get.find<MatchmakerController>();
|
||||
|
||||
@override
|
||||
Widget? get button => const ServerButton(
|
||||
backend: false
|
||||
);
|
||||
|
||||
@override
|
||||
List<Widget> get settings => [
|
||||
_type,
|
||||
_hostName,
|
||||
_port,
|
||||
_gameServerAddress,
|
||||
_installationDirectory,
|
||||
_resetDefaults
|
||||
];
|
||||
|
||||
Widget get _gameServerAddress => Obx(() {
|
||||
if(_matchmakerController.type.value != ServerType.embedded) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.stream_input_20_regular
|
||||
),
|
||||
title: Text(translations.matchmakerConfigurationAddressName),
|
||||
subtitle: Text(translations.matchmakerConfigurationAddressDescription),
|
||||
content: TextFormBox(
|
||||
placeholder: translations.matchmakerConfigurationAddressName,
|
||||
controller: _matchmakerController.gameServerAddress,
|
||||
focusNode: _matchmakerController.gameServerAddressFocusNode
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
Widget get _port => Obx(() {
|
||||
if(_matchmakerController.type.value == ServerType.embedded) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return SettingTile(
|
||||
icon: Icon(
|
||||
fluentUi.FluentIcons.number_field
|
||||
),
|
||||
title: Text(translations.matchmakerConfigurationPortName),
|
||||
subtitle: Text(translations.matchmakerConfigurationPortDescription),
|
||||
content: TextFormBox(
|
||||
placeholder: translations.matchmakerConfigurationPortName,
|
||||
controller: _matchmakerController.port,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly
|
||||
]
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
Widget get _hostName => Obx(() {
|
||||
if(_matchmakerController.type.value != ServerType.remote) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.globe_24_regular
|
||||
),
|
||||
title: Text(translations.matchmakerConfigurationHostName),
|
||||
subtitle: Text(translations.matchmakerConfigurationHostDescription),
|
||||
content: TextFormBox(
|
||||
placeholder: translations.matchmakerConfigurationHostName,
|
||||
controller: _matchmakerController.host
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
Widget get _type => SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.people_24_regular
|
||||
),
|
||||
title: Text(translations.matchmakerTypeName),
|
||||
subtitle: Text(translations.matchmakerTypeDescription),
|
||||
content: const ServerTypeSelector(
|
||||
backend: false
|
||||
)
|
||||
);
|
||||
|
||||
Widget get _installationDirectory => Obx(() {
|
||||
if(_matchmakerController.type.value != ServerType.embedded) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.folder_24_regular
|
||||
),
|
||||
title: Text(translations.matchmakerInstallationDirectoryName),
|
||||
subtitle: Text(translations.matchmakerInstallationDirectoryDescription),
|
||||
content: Button(
|
||||
onPressed: () => launchUrl(matchmakerDirectory.uri),
|
||||
child: Text(translations.matchmakerInstallationDirectoryContent)
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
SettingTile get _resetDefaults => SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.arrow_reset_24_regular
|
||||
),
|
||||
title: Text(translations.matchmakerResetDefaultsName),
|
||||
subtitle: Text(translations.matchmakerResetDefaultsDescription),
|
||||
content: Button(
|
||||
onPressed: () => showResetDialog(_matchmakerController.reset),
|
||||
child: Text(translations.matchmakerResetDefaultsContent),
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -1,17 +1,12 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart' hide FluentIcons;
|
||||
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/controller/backend_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/game_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/hosting_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/matchmaker_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/settings_controller.dart';
|
||||
import 'package:reboot_launcher/src/dialog/abstract/info_bar.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page_type.dart';
|
||||
import 'package:reboot_launcher/src/page/pages.dart';
|
||||
import 'package:reboot_launcher/src/util/keyboard.dart';
|
||||
import 'package:reboot_launcher/src/util/translations.dart';
|
||||
import 'package:reboot_launcher/src/widget/file_setting_tile.dart';
|
||||
import 'package:reboot_launcher/src/widget/game_start_button.dart';
|
||||
@@ -39,9 +34,9 @@ class PlayPage extends RebootPage {
|
||||
}
|
||||
|
||||
class _PlayPageState extends RebootPageState<PlayPage> {
|
||||
final MatchmakerController _matchmakerController = Get.find<MatchmakerController>();
|
||||
final SettingsController _settingsController = Get.find<SettingsController>();
|
||||
final GameController _gameController = Get.find<GameController>();
|
||||
final BackendController _backendController = Get.find<BackendController>();
|
||||
|
||||
@override
|
||||
Widget? get button => LaunchButton(
|
||||
@@ -52,8 +47,9 @@ class _PlayPageState extends RebootPageState<PlayPage> {
|
||||
|
||||
@override
|
||||
List<SettingTile> get settings => [
|
||||
_clientSettings,
|
||||
versionSelectSettingTile,
|
||||
_options,
|
||||
_internalFiles,
|
||||
_multiplayer
|
||||
];
|
||||
|
||||
@@ -70,7 +66,7 @@ class _PlayPageState extends RebootPageState<PlayPage> {
|
||||
],
|
||||
);
|
||||
|
||||
SettingTile get _clientSettings => SettingTile(
|
||||
SettingTile get _internalFiles => SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.archive_settings_24_regular
|
||||
),
|
||||
@@ -92,24 +88,34 @@ class _PlayPageState extends RebootPageState<PlayPage> {
|
||||
description: translations.settingsClientMemoryDescription,
|
||||
controller: _settingsController.memoryLeakDll
|
||||
),
|
||||
SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.options_24_regular
|
||||
),
|
||||
title: Text(translations.settingsClientArgsName),
|
||||
subtitle: Text(translations.settingsClientArgsDescription),
|
||||
content: TextFormBox(
|
||||
placeholder: translations.settingsClientArgsPlaceholder,
|
||||
controller: _gameController.customLaunchArgs,
|
||||
)
|
||||
)
|
||||
],
|
||||
);
|
||||
|
||||
SettingTile get _options => SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.options_24_regular
|
||||
),
|
||||
title: Text(translations.settingsServerOptionsName),
|
||||
subtitle: Text(translations.settingsServerOptionsSubtitle),
|
||||
children: [
|
||||
SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.options_24_regular
|
||||
),
|
||||
title: Text(translations.settingsClientArgsName),
|
||||
subtitle: Text(translations.settingsClientArgsDescription),
|
||||
content: TextFormBox(
|
||||
placeholder: translations.settingsClientArgsPlaceholder,
|
||||
controller: _gameController.customLaunchArgs,
|
||||
)
|
||||
)
|
||||
]
|
||||
);
|
||||
|
||||
SettingTile get _matchmakerTile => SettingTile(
|
||||
onPressed: () {
|
||||
pageIndex.value = RebootPageType.matchmaker.index;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => _matchmakerController.gameServerAddressFocusNode.requestFocus());
|
||||
pageIndex.value = RebootPageType.backend.index;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => _backendController.gameServerAddressFocusNode.requestFocus());
|
||||
},
|
||||
icon: Icon(
|
||||
FluentIcons.globe_24_regular
|
||||
|
||||
@@ -5,8 +5,8 @@ import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/controller/backend_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/hosting_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/matchmaker_controller.dart';
|
||||
import 'package:reboot_launcher/src/dialog/implementation/server.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page_type.dart';
|
||||
@@ -34,7 +34,7 @@ class BrowsePage extends RebootPage {
|
||||
|
||||
class _BrowsePageState extends RebootPageState<BrowsePage> {
|
||||
final HostingController _hostingController = Get.find<HostingController>();
|
||||
final MatchmakerController _matchmakerController = Get.find<MatchmakerController>();
|
||||
final BackendController _backendController = Get.find<BackendController>();
|
||||
final TextEditingController _filterController = TextEditingController();
|
||||
final StreamController<String> _filterControllerStream = StreamController.broadcast();
|
||||
|
||||
@@ -98,11 +98,11 @@ class _BrowsePageState extends RebootPageState<BrowsePage> {
|
||||
title: Text("${_formatName(entry)} • ${entry["author"]}"),
|
||||
subtitle: Text("${_formatDescription(entry)} • ${_formatVersion(entry)}"),
|
||||
content: Button(
|
||||
onPressed: () => _matchmakerController.joinServer(_hostingController.uuid, entry),
|
||||
onPressed: () => _backendController.joinServer(_hostingController.uuid, entry),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(_matchmakerController.type.value == ServerType.embedded ? translations.joinServer : translations.copyIp),
|
||||
Text(_backendController.type.value == ServerType.embedded ? translations.joinServer : translations.copyIp),
|
||||
],
|
||||
),
|
||||
)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:clipboard/clipboard.dart';
|
||||
import 'package:dart_ipify/dart_ipify.dart';
|
||||
import 'package:fluent_ui/fluent_ui.dart' as fluentUi show FluentIcons;
|
||||
import 'package:fluent_ui/fluent_ui.dart' hide FluentIcons;
|
||||
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
@@ -20,7 +21,6 @@ import 'package:reboot_launcher/src/widget/file_setting_tile.dart';
|
||||
import 'package:reboot_launcher/src/widget/game_start_button.dart';
|
||||
import 'package:reboot_launcher/src/widget/setting_tile.dart';
|
||||
import 'package:reboot_launcher/src/widget/version_selector_tile.dart';
|
||||
import 'package:fluent_ui/fluent_ui.dart' as fluentUi show FluentIcons;
|
||||
|
||||
import '../../util/checks.dart';
|
||||
|
||||
@@ -72,8 +72,9 @@ class _HostingPageState extends RebootPageState<HostPage> {
|
||||
@override
|
||||
List<Widget> get settings => [
|
||||
_information,
|
||||
_configuration,
|
||||
versionSelectSettingTile,
|
||||
_options,
|
||||
_internalFiles,
|
||||
_share,
|
||||
_resetDefaults
|
||||
];
|
||||
@@ -179,63 +180,104 @@ class _HostingPageState extends RebootPageState<HostPage> {
|
||||
]
|
||||
);
|
||||
|
||||
SettingTile get _configuration => SettingTile(
|
||||
SettingTile get _internalFiles => SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.archive_settings_24_regular
|
||||
),
|
||||
title: Text(translations.settingsServerName),
|
||||
subtitle: Text(translations.settingsServerSubtitle),
|
||||
children: [
|
||||
createFileSetting(
|
||||
title: translations.settingsServerFileName,
|
||||
description: translations.settingsServerFileDescription,
|
||||
controller: _settingsController.gameServerDll
|
||||
),
|
||||
SettingTile(
|
||||
icon: Icon(
|
||||
fluentUi.FluentIcons.number_field
|
||||
),
|
||||
title: Text(translations.settingsServerPortName),
|
||||
subtitle: Text(translations.settingsServerPortDescription),
|
||||
content: TextFormBox(
|
||||
placeholder: translations.settingsServerPortName,
|
||||
controller: _settingsController.gameServerPort,
|
||||
keyboardType: TextInputType.number,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly
|
||||
]
|
||||
)
|
||||
),
|
||||
SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.globe_24_regular
|
||||
),
|
||||
title: Text(translations.settingsServerMirrorName),
|
||||
subtitle: Text(translations.settingsServerMirrorDescription),
|
||||
content: TextFormBox(
|
||||
placeholder: translations.settingsServerMirrorPlaceholder,
|
||||
controller: _updateController.url,
|
||||
validator: checkUpdateUrl
|
||||
)
|
||||
),
|
||||
SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.timer_24_regular
|
||||
),
|
||||
title: Text(translations.settingsServerTimerName),
|
||||
subtitle: Text(translations.settingsServerTimerSubtitle),
|
||||
title: Text(translations.settingsServerTypeName),
|
||||
subtitle: Text(translations.settingsServerTypeDescription),
|
||||
content: Obx(() => DropDownButton(
|
||||
leading: Text(_updateController.timer.value.text),
|
||||
items: UpdateTimer.values.map((entry) => MenuFlyoutItem(
|
||||
text: Text(entry.text),
|
||||
leading: Text(_updateController.customGameServer.value ? translations.settingsServerTypeCustomName : translations.settingsServerTypeEmbeddedName),
|
||||
items: {
|
||||
false: translations.settingsServerTypeEmbeddedName,
|
||||
true: translations.settingsServerTypeCustomName
|
||||
}.entries.map((entry) => MenuFlyoutItem(
|
||||
text: Text(entry.value),
|
||||
onPressed: () {
|
||||
_updateController.timer.value = entry;
|
||||
final oldValue = _updateController.customGameServer.value;
|
||||
if(oldValue == entry.key) {
|
||||
return;
|
||||
}
|
||||
|
||||
_updateController.customGameServer.value = entry.key;
|
||||
_updateController.infoBarEntry?.close();
|
||||
_updateController.update(true);
|
||||
if(!entry.key) {
|
||||
_updateController.updateReboot(true);
|
||||
}
|
||||
}
|
||||
)).toList()
|
||||
))
|
||||
),
|
||||
Obx(() {
|
||||
if(!_updateController.customGameServer.value) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return createFileSetting(
|
||||
title: translations.settingsServerFileName,
|
||||
description: translations.settingsServerFileDescription,
|
||||
controller: _settingsController.gameServerDll
|
||||
);
|
||||
}),
|
||||
Obx(() {
|
||||
if(_updateController.customGameServer.value) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.globe_24_regular
|
||||
),
|
||||
title: Text(translations.settingsServerMirrorName),
|
||||
subtitle: Text(translations.settingsServerMirrorDescription),
|
||||
content: TextFormBox(
|
||||
placeholder: translations.settingsServerMirrorPlaceholder,
|
||||
controller: _updateController.url,
|
||||
validator: checkUpdateUrl
|
||||
)
|
||||
);
|
||||
}),
|
||||
Obx(() {
|
||||
if(_updateController.customGameServer.value) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
|
||||
return SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.timer_24_regular
|
||||
),
|
||||
title: Text(translations.settingsServerTimerName),
|
||||
subtitle: Text(translations.settingsServerTimerSubtitle),
|
||||
content: Obx(() => DropDownButton(
|
||||
leading: Text(_updateController.timer.value.text),
|
||||
items: UpdateTimer.values.map((entry) => MenuFlyoutItem(
|
||||
text: Text(entry.text),
|
||||
onPressed: () {
|
||||
_updateController.timer.value = entry;
|
||||
_updateController.infoBarEntry?.close();
|
||||
_updateController.updateReboot(true);
|
||||
}
|
||||
)).toList()
|
||||
))
|
||||
);
|
||||
}),
|
||||
],
|
||||
);
|
||||
|
||||
SettingTile get _options => SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.options_24_regular
|
||||
),
|
||||
title: Text(translations.settingsServerOptionsName),
|
||||
subtitle: Text(translations.settingsServerOptionsSubtitle),
|
||||
children: [
|
||||
Obx(() => SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.window_console_20_regular
|
||||
@@ -280,6 +322,45 @@ class _HostingPageState extends RebootPageState<HostPage> {
|
||||
],
|
||||
),
|
||||
)),
|
||||
Obx(() => SettingTile(
|
||||
icon: Icon(
|
||||
FluentIcons.arrow_reset_24_regular
|
||||
),
|
||||
title: Text(translations.hostAutomaticRestartName),
|
||||
subtitle: Text(translations.hostAutomaticRestartDescription),
|
||||
contentWidth: null,
|
||||
content: Row(
|
||||
children: [
|
||||
Text(
|
||||
_hostingController.autoRestart.value ? translations.on : translations.off
|
||||
),
|
||||
const SizedBox(
|
||||
width: 16.0
|
||||
),
|
||||
ToggleSwitch(
|
||||
checked: _hostingController.autoRestart.value,
|
||||
onChanged: (value) => _hostingController.autoRestart.value = value
|
||||
),
|
||||
],
|
||||
),
|
||||
)),
|
||||
SettingTile(
|
||||
icon: Icon(
|
||||
fluentUi.FluentIcons.number_field
|
||||
),
|
||||
title: Text(translations.settingsServerPortName),
|
||||
subtitle: Text(translations.settingsServerPortDescription),
|
||||
contentWidth: 64,
|
||||
content: TextFormBox(
|
||||
placeholder: translations.settingsServerPortName,
|
||||
controller: _settingsController.gameServerPort,
|
||||
keyboardType: TextInputType.number,
|
||||
textAlign: TextAlign.center,
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.digitsOnly
|
||||
]
|
||||
)
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
@@ -1,19 +1,13 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:archive/archive_io.dart';
|
||||
import 'package:fluent_ui/fluent_ui.dart' hide FluentIcons;
|
||||
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_gen/gen_l10n/reboot_localizations.dart';
|
||||
import 'package:flutter_localized_locales/flutter_localized_locales.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/controller/settings_controller.dart';
|
||||
import 'package:reboot_launcher/src/dialog/abstract/info_bar.dart';
|
||||
import 'package:reboot_launcher/src/dialog/implementation/data.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page_type.dart';
|
||||
import 'package:reboot_launcher/src/util/picker.dart';
|
||||
import 'package:reboot_launcher/src/util/translations.dart';
|
||||
import 'package:reboot_launcher/src/widget/setting_tile.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
@@ -3,13 +3,11 @@ import 'dart:collection';
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:get/get_rx/src/rx_types/rx_types.dart';
|
||||
import 'package:reboot_launcher/src/controller/settings_controller.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page.dart';
|
||||
import 'package:reboot_launcher/src/page/abstract/page_type.dart';
|
||||
import 'package:reboot_launcher/src/page/implementation/backend_page.dart';
|
||||
import 'package:reboot_launcher/src/page/implementation/info_page.dart';
|
||||
import 'package:reboot_launcher/src/page/implementation/matchmaker_page.dart';
|
||||
import 'package:reboot_launcher/src/page/implementation/play_page.dart';
|
||||
import 'package:reboot_launcher/src/page/implementation/server_browser_page.dart';
|
||||
import 'package:reboot_launcher/src/page/implementation/server_host_page.dart';
|
||||
@@ -24,7 +22,6 @@ final List<RebootPage> pages = [
|
||||
const HostPage(),
|
||||
const BrowsePage(),
|
||||
const BackendPage(),
|
||||
const MatchmakerPage(),
|
||||
const InfoPage(),
|
||||
const SettingsPage()
|
||||
];
|
||||
|
||||
@@ -27,7 +27,7 @@ Future<void> _downloadCriticalDllInteractive(String filePath) async {
|
||||
InfoBarEntry? entry;
|
||||
try {
|
||||
if (fileName == "reboot.dll") {
|
||||
await _updateController.update(true);
|
||||
await _updateController.updateReboot(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
41
gui/lib/src/util/info.dart
Normal file
41
gui/lib/src/util/info.dart
Normal file
@@ -0,0 +1,41 @@
|
||||
import 'dart:collection';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/util/log.dart';
|
||||
import 'package:reboot_launcher/src/util/translations.dart';
|
||||
import 'package:reboot_launcher/src/widget/info_tile.dart';
|
||||
|
||||
final _entries = SplayTreeMap<int, InfoTile>();
|
||||
|
||||
void initInfoTiles() {
|
||||
try {
|
||||
final directory = Directory("${assetsDirectory.path}\\info\\$currentLocale");
|
||||
for(final entry in directory.listSync()) {
|
||||
if(entry is File) {
|
||||
final name = Uri.decodeQueryComponent(path.basename(entry.path));
|
||||
final splitter = name.indexOf(".");
|
||||
if(splitter == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final index = int.tryParse(name.substring(0, splitter));
|
||||
if(index == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final questionName = Uri.decodeQueryComponent(name.substring(splitter + 2));
|
||||
_entries[index] = InfoTile(
|
||||
title: Text(questionName),
|
||||
content: Text(entry.readAsStringSync())
|
||||
);
|
||||
}
|
||||
}
|
||||
}catch(error) {
|
||||
log("[INFO] Error occurred while initializing info tiles: $error");
|
||||
}
|
||||
}
|
||||
|
||||
List<InfoTile> get infoTiles => _entries.values.toList(growable: false);
|
||||
@@ -1,10 +1,10 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'dart:collection';
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:win32/win32.dart';
|
||||
|
||||
final RegExp _winBuildRegex = RegExp(r'(?<=\(Build )(.*)(?=\))');
|
||||
@@ -38,15 +38,15 @@ class _ServiceProvider10 extends IUnknown {
|
||||
Pointer<COMObject> queryService(String classId, String instanceId) {
|
||||
final result = calloc<COMObject>();
|
||||
final code = (ptr.ref.vtable + 3)
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<
|
||||
HRESULT Function(Pointer, Pointer<GUID>, Pointer<GUID>,
|
||||
Pointer<COMObject>)>>>()
|
||||
.value
|
||||
.asFunction<
|
||||
int Function(Pointer, Pointer<GUID>, Pointer<GUID>,
|
||||
Pointer<COMObject>)>()(ptr.ref.lpVtbl,
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<
|
||||
HRESULT Function(Pointer, Pointer<GUID>, Pointer<GUID>,
|
||||
Pointer<COMObject>)>>>()
|
||||
.value
|
||||
.asFunction<
|
||||
int Function(Pointer, Pointer<GUID>, Pointer<GUID>,
|
||||
Pointer<COMObject>)>()(ptr.ref.lpVtbl,
|
||||
GUIDFromString(classId), GUIDFromString(instanceId), result);
|
||||
if (code != 0) {
|
||||
free(result);
|
||||
@@ -66,11 +66,11 @@ class IVirtualDesktop extends IUnknown {
|
||||
final result = calloc<HSTRING>();
|
||||
final code = (ptr.ref.vtable + 5)
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<HRESULT Function(Pointer, Pointer<HSTRING>)>>>()
|
||||
Pointer<
|
||||
NativeFunction<HRESULT Function(Pointer, Pointer<HSTRING>)>>>()
|
||||
.value
|
||||
.asFunction<
|
||||
int Function(Pointer, Pointer<HSTRING>)>()(ptr.ref.lpVtbl, result);
|
||||
int Function(Pointer, Pointer<HSTRING>)>()(ptr.ref.lpVtbl, result);
|
||||
if (code != 0) {
|
||||
free(result);
|
||||
throw WindowsException(code);
|
||||
@@ -93,11 +93,11 @@ class _IObjectArray extends IUnknown {
|
||||
final result = calloc<Int32>();
|
||||
final code = (ptr.ref.vtable + 3)
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<HRESULT Function(Pointer, Pointer<Int32>)>>>()
|
||||
Pointer<
|
||||
NativeFunction<HRESULT Function(Pointer, Pointer<Int32>)>>>()
|
||||
.value
|
||||
.asFunction<
|
||||
int Function(Pointer, Pointer<Int32>)>()(ptr.ref.lpVtbl, result);
|
||||
int Function(Pointer, Pointer<Int32>)>()(ptr.ref.lpVtbl, result);
|
||||
if (code != 0) {
|
||||
free(result);
|
||||
throw WindowsException(code);
|
||||
@@ -109,15 +109,15 @@ class _IObjectArray extends IUnknown {
|
||||
Pointer<COMObject> getAt(int index, String guid) {
|
||||
final result = calloc<COMObject>();
|
||||
final code = (ptr.ref.vtable + 4)
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<
|
||||
HRESULT Function(Pointer, Int32 index, Pointer<GUID>,
|
||||
Pointer<COMObject>)>>>()
|
||||
.value
|
||||
.asFunction<
|
||||
int Function(
|
||||
Pointer, int index, Pointer<GUID>, Pointer<COMObject>)>()(
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<
|
||||
HRESULT Function(Pointer, Int32 index, Pointer<GUID>,
|
||||
Pointer<COMObject>)>>>()
|
||||
.value
|
||||
.asFunction<
|
||||
int Function(
|
||||
Pointer, int index, Pointer<GUID>, Pointer<COMObject>)>()(
|
||||
ptr.ref.lpVtbl, index, GUIDFromString(guid), result);
|
||||
if (code != 0) {
|
||||
free(result);
|
||||
@@ -137,8 +137,8 @@ class _IObjectArrayList<T> extends ListBase<T> {
|
||||
|
||||
_IObjectArrayList(
|
||||
{required _IObjectArray array,
|
||||
required String guid,
|
||||
required _IObjectMapper<T> mapper})
|
||||
required String guid,
|
||||
required _IObjectMapper<T> mapper})
|
||||
: _array = array,
|
||||
_guid = guid,
|
||||
_mapper = mapper;
|
||||
@@ -173,11 +173,11 @@ class _IVirtualDesktopManagerInternal extends IUnknown {
|
||||
final result = calloc<Int32>();
|
||||
final code = (ptr.ref.vtable + 3)
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<HRESULT Function(Pointer, Pointer<Int32>)>>>()
|
||||
Pointer<
|
||||
NativeFunction<HRESULT Function(Pointer, Pointer<Int32>)>>>()
|
||||
.value
|
||||
.asFunction<
|
||||
int Function(Pointer, Pointer<Int32>)>()(ptr.ref.lpVtbl, result);
|
||||
int Function(Pointer, Pointer<Int32>)>()(ptr.ref.lpVtbl, result);
|
||||
if (code != 0) {
|
||||
free(result);
|
||||
throw WindowsException(code);
|
||||
@@ -189,12 +189,12 @@ class _IVirtualDesktopManagerInternal extends IUnknown {
|
||||
List<IVirtualDesktop> getDesktops() {
|
||||
final result = calloc<COMObject>();
|
||||
final code = (ptr.ref.vtable + 7)
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<
|
||||
HRESULT Function(Pointer, Pointer<COMObject>)>>>()
|
||||
.value
|
||||
.asFunction<int Function(Pointer, Pointer<COMObject>)>()(
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<
|
||||
HRESULT Function(Pointer, Pointer<COMObject>)>>>()
|
||||
.value
|
||||
.asFunction<int Function(Pointer, Pointer<COMObject>)>()(
|
||||
ptr.ref.lpVtbl, result);
|
||||
if (code != 0) {
|
||||
free(result);
|
||||
@@ -210,27 +210,27 @@ class _IVirtualDesktopManagerInternal extends IUnknown {
|
||||
|
||||
void moveWindowToDesktop(IApplicationView view, IVirtualDesktop desktop) {
|
||||
final code = (ptr.ref.vtable + 4)
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<
|
||||
Int32 Function(Pointer, COMObject, COMObject)>>>()
|
||||
.value
|
||||
.asFunction<int Function(Pointer, COMObject, COMObject)>()(
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<
|
||||
Int32 Function(Pointer, COMObject, COMObject)>>>()
|
||||
.value
|
||||
.asFunction<int Function(Pointer, COMObject, COMObject)>()(
|
||||
ptr.ref.lpVtbl, view.ptr.ref, desktop.ptr.ref);
|
||||
if (code != 0) {
|
||||
throw WindowsException(code);
|
||||
throw WindowsException(code, message: "Cannot move window");
|
||||
}
|
||||
}
|
||||
|
||||
IVirtualDesktop createDesktop() {
|
||||
final result = calloc<COMObject>();
|
||||
final code = (ptr.ref.vtable + 10)
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<
|
||||
HRESULT Function(Pointer, Pointer<COMObject>)>>>()
|
||||
.value
|
||||
.asFunction<int Function(Pointer, Pointer<COMObject>)>()(
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<
|
||||
HRESULT Function(Pointer, Pointer<COMObject>)>>>()
|
||||
.value
|
||||
.asFunction<int Function(Pointer, Pointer<COMObject>)>()(
|
||||
ptr.ref.lpVtbl, result);
|
||||
if (code != 0) {
|
||||
free(result);
|
||||
@@ -242,12 +242,12 @@ class _IVirtualDesktopManagerInternal extends IUnknown {
|
||||
|
||||
void removeDesktop(IVirtualDesktop desktop, IVirtualDesktop fallback) {
|
||||
final code = (ptr.ref.vtable + 12)
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<
|
||||
HRESULT Function(Pointer, COMObject, COMObject)>>>()
|
||||
.value
|
||||
.asFunction<int Function(Pointer, COMObject, COMObject)>()(
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<
|
||||
HRESULT Function(Pointer, COMObject, COMObject)>>>()
|
||||
.value
|
||||
.asFunction<int Function(Pointer, COMObject, COMObject)>()(
|
||||
ptr.ref.lpVtbl, desktop.ptr.ref, fallback.ptr.ref);
|
||||
if (code != 0) {
|
||||
throw WindowsException(code);
|
||||
@@ -256,14 +256,14 @@ class _IVirtualDesktopManagerInternal extends IUnknown {
|
||||
|
||||
void setDesktopName(IVirtualDesktop desktop, String newName) {
|
||||
final code =
|
||||
(ptr.ref.vtable + 15)
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<
|
||||
HRESULT Function(Pointer, COMObject, Int8)>>>()
|
||||
.value
|
||||
.asFunction<int Function(Pointer, COMObject, int)>()(
|
||||
ptr.ref.lpVtbl, desktop.ptr.ref, convertToHString(newName));
|
||||
(ptr.ref.vtable + 15)
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<
|
||||
HRESULT Function(Pointer, COMObject, Int8)>>>()
|
||||
.value
|
||||
.asFunction<int Function(Pointer, COMObject, int)>()(
|
||||
ptr.ref.lpVtbl, desktop.ptr.ref, convertToHString(newName));
|
||||
if (code != 0) {
|
||||
throw WindowsException(code);
|
||||
}
|
||||
@@ -276,57 +276,75 @@ class _IApplicationViewCollection extends IUnknown {
|
||||
|
||||
_IApplicationViewCollection._internal(super.ptr);
|
||||
|
||||
IApplicationView getViewForHWnd(int HWnd) {
|
||||
IApplicationView? getViewForHWnd(int HWnd) {
|
||||
final result = calloc<COMObject>();
|
||||
final code =
|
||||
(ptr.ref.vtable + 6)
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<
|
||||
HRESULT Function(
|
||||
Pointer, IntPtr, Pointer<COMObject>)>>>()
|
||||
.value
|
||||
.asFunction<int Function(Pointer, int, Pointer<COMObject>)>()(
|
||||
ptr.ref.lpVtbl, HWnd, result);
|
||||
(ptr.ref.vtable + 6)
|
||||
.cast<
|
||||
Pointer<
|
||||
NativeFunction<
|
||||
HRESULT Function(
|
||||
Pointer, IntPtr, Pointer<COMObject>)>>>()
|
||||
.value
|
||||
.asFunction<int Function(Pointer, int, Pointer<COMObject>)>()(
|
||||
ptr.ref.lpVtbl, HWnd, result);
|
||||
if (code != 0) {
|
||||
free(result);
|
||||
throw WindowsException(code);
|
||||
return null;
|
||||
}
|
||||
|
||||
return IApplicationView._internal(result);
|
||||
}
|
||||
}
|
||||
|
||||
final class _Process extends Struct {
|
||||
final class Win32Process extends Struct {
|
||||
@Uint32()
|
||||
external int pid;
|
||||
|
||||
@Uint32()
|
||||
external int HWnd;
|
||||
external int HWndLength;
|
||||
|
||||
static int _filter(int HWnd, int lParam) {
|
||||
final structure = Pointer.fromAddress(lParam).cast<_Process>();
|
||||
final pidPointer = calloc<Uint32>();
|
||||
GetWindowThreadProcessId(HWnd, pidPointer);
|
||||
final pid = pidPointer.value;
|
||||
free(pidPointer);
|
||||
if (pid != structure.ref.pid) {
|
||||
return TRUE;
|
||||
external Pointer<Uint32> HWnd;
|
||||
}
|
||||
|
||||
int _filter(int HWnd, int lParam) {
|
||||
final structure = Pointer.fromAddress(lParam).cast<Win32Process>();
|
||||
final pidPointer = calloc<Uint32>();
|
||||
GetWindowThreadProcessId(HWnd, pidPointer);
|
||||
final pid = pidPointer.value;
|
||||
if (pid == structure.ref.pid) {
|
||||
final length = structure.ref.HWndLength;
|
||||
final newLength = length + 1;
|
||||
final ptr = malloc.allocate<Uint32>(sizeOf<Uint32>() * newLength);
|
||||
final list = structure.ref.HWnd.asTypedList(length);
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
(ptr + i).value = list[i];
|
||||
}
|
||||
|
||||
structure.ref.HWnd = HWnd;
|
||||
return FALSE;
|
||||
ptr[list.length] = HWnd;
|
||||
structure.ref.HWndLength = newLength;
|
||||
free(structure.ref.HWnd);
|
||||
structure.ref.HWnd = ptr;
|
||||
}
|
||||
|
||||
static int getHWndFromPid(int pid) {
|
||||
final result = calloc<_Process>();
|
||||
result.ref.pid = pid;
|
||||
EnumWindows(
|
||||
Pointer.fromFunction<EnumWindowsProc>(_filter, TRUE), result.address);
|
||||
final HWnd = result.ref.HWnd;
|
||||
free(pidPointer);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
List<int> _getHWnds(int pid) {
|
||||
final result = calloc<Win32Process>();
|
||||
result.ref.pid = pid;
|
||||
EnumWindows(Pointer.fromFunction<EnumWindowsProc>(_filter, TRUE), result.address);
|
||||
final length = result.ref.HWndLength;
|
||||
final HWndsPointer = result.ref.HWnd;
|
||||
if(HWndsPointer == nullptr) {
|
||||
calloc.free(result);
|
||||
return HWnd;
|
||||
return [];
|
||||
}
|
||||
|
||||
final HWnds = HWndsPointer.asTypedList(length)
|
||||
.toList(growable: false);
|
||||
calloc.free(result);
|
||||
return HWnds;
|
||||
}
|
||||
|
||||
class VirtualDesktopManager {
|
||||
@@ -382,10 +400,24 @@ class VirtualDesktopManager {
|
||||
|
||||
List<IVirtualDesktop> getDesktops() => windowManager.getDesktops();
|
||||
|
||||
void moveWindowToDesktop(int pid, IVirtualDesktop desktop) {
|
||||
final HWnd = _Process.getHWndFromPid(pid);
|
||||
final window = applicationViewCollection.getViewForHWnd(HWnd);
|
||||
windowManager.moveWindowToDesktop(window, desktop);
|
||||
Future<void> moveWindowToDesktop(int pid, IVirtualDesktop desktop, {Duration pollTime = const Duration(seconds: 1)}) async {
|
||||
final hWNDs = _getHWnds(pid);
|
||||
if(hWNDs.isEmpty) {
|
||||
await Future.delayed(pollTime);
|
||||
await moveWindowToDesktop(pid, desktop, pollTime: pollTime);
|
||||
return;
|
||||
}
|
||||
|
||||
for(final hWND in hWNDs) {
|
||||
final window = applicationViewCollection.getViewForHWnd(hWND);
|
||||
if(window != null) {
|
||||
windowManager.moveWindowToDesktop(window, desktop);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await Future.delayed(pollTime);
|
||||
await moveWindowToDesktop(pid, desktop, pollTime: pollTime);
|
||||
}
|
||||
|
||||
IVirtualDesktop createDesktop() => windowManager.createDesktop();
|
||||
|
||||
@@ -256,12 +256,6 @@ class _AddServerVersionState extends State<AddServerVersion> {
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
_buildSelectorType(),
|
||||
|
||||
const SizedBox(
|
||||
height: 16.0
|
||||
),
|
||||
|
||||
_buildSelector(),
|
||||
|
||||
const SizedBox(
|
||||
@@ -291,24 +285,6 @@ class _AddServerVersionState extends State<AddServerVersion> {
|
||||
],
|
||||
);
|
||||
|
||||
Widget _buildSelectorType() => InfoLabel(
|
||||
label: translations.source,
|
||||
child: Obx(() => ComboBox<FortniteBuildSource>(
|
||||
placeholder: Text(translations.selectBuild),
|
||||
isExpanded: true,
|
||||
items: _buildSources,
|
||||
value: _buildController.selectedBuildSource,
|
||||
onChanged: (value) {
|
||||
if(value == null){
|
||||
return;
|
||||
}
|
||||
|
||||
_buildController.selectedBuildSource = value;
|
||||
_updateFormDefaults();
|
||||
}
|
||||
))
|
||||
);
|
||||
|
||||
Widget _buildSelector() => InfoLabel(
|
||||
label: translations.build,
|
||||
child: Obx(() => ComboBox<FortniteBuild>(
|
||||
@@ -328,7 +304,6 @@ class _AddServerVersionState extends State<AddServerVersion> {
|
||||
);
|
||||
|
||||
List<ComboBoxItem<FortniteBuild>> get _builds => _buildController.builds!
|
||||
.where((element) => element.source == _buildController.selectedBuild?.source)
|
||||
.map((element) => _buildItem(element))
|
||||
.toList();
|
||||
|
||||
@@ -337,24 +312,6 @@ class _AddServerVersionState extends State<AddServerVersion> {
|
||||
child: Text(element.version.toString())
|
||||
);
|
||||
|
||||
List<ComboBoxItem<FortniteBuildSource>> get _buildSources => FortniteBuildSource.values
|
||||
.map((element) => _buildSourceItem(element))
|
||||
.toList();
|
||||
|
||||
ComboBoxItem<FortniteBuildSource> _buildSourceItem(FortniteBuildSource element) => ComboBoxItem<FortniteBuildSource>(
|
||||
value: element,
|
||||
child: Text(_getBuildSourceName(element))
|
||||
);
|
||||
|
||||
String _getBuildSourceName(FortniteBuildSource element) {
|
||||
switch(element) {
|
||||
case FortniteBuildSource.archive:
|
||||
return translations.archive;
|
||||
case FortniteBuildSource.manifest:
|
||||
return translations.manifest;
|
||||
}
|
||||
}
|
||||
|
||||
List<DialogButton> get _stopButton => [
|
||||
DialogButton(
|
||||
text: "Stop",
|
||||
|
||||
@@ -5,13 +5,14 @@ import 'package:async/async.dart';
|
||||
import 'package:dart_ipify/dart_ipify.dart';
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:local_notifier/local_notifier.dart';
|
||||
import 'package:path/path.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/controller/backend_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/game_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/hosting_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/matchmaker_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/settings_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/update_controller.dart';
|
||||
import 'package:reboot_launcher/src/dialog/abstract/dialog.dart';
|
||||
import 'package:reboot_launcher/src/dialog/abstract/dialog_button.dart';
|
||||
import 'package:reboot_launcher/src/dialog/abstract/info_bar.dart';
|
||||
@@ -23,7 +24,6 @@ import 'package:reboot_launcher/src/util/log.dart';
|
||||
import 'package:reboot_launcher/src/util/matchmaker.dart';
|
||||
import 'package:reboot_launcher/src/util/os.dart';
|
||||
import 'package:reboot_launcher/src/util/translations.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
class LaunchButton extends StatefulWidget {
|
||||
final bool host;
|
||||
@@ -37,11 +37,13 @@ class LaunchButton extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _LaunchButtonState extends State<LaunchButton> {
|
||||
static const Duration _kRebootDelay = Duration(seconds: 10);
|
||||
|
||||
final GameController _gameController = Get.find<GameController>();
|
||||
final HostingController _hostingController = Get.find<HostingController>();
|
||||
final BackendController _backendController = Get.find<BackendController>();
|
||||
final MatchmakerController _matchmakerController = Get.find<MatchmakerController>();
|
||||
final SettingsController _settingsController = Get.find<SettingsController>();
|
||||
final UpdateController _updateController = Get.find<UpdateController>();
|
||||
InfoBarEntry? _gameClientInfoBar;
|
||||
InfoBarEntry? _gameServerInfoBar;
|
||||
CancelableOperation? _operation;
|
||||
@@ -129,18 +131,6 @@ class _LaunchButtonState extends State<LaunchButton> {
|
||||
return;
|
||||
}
|
||||
log("[${widget.host ? 'HOST' : 'GAME'}] Backend works");
|
||||
|
||||
log("[${widget.host ? 'HOST' : 'GAME'}] Checking matchmaker(port: ${_matchmakerController.type.value.name}, type: ${_matchmakerController.type.value.name})...");
|
||||
final matchmakerResult = _matchmakerController.started() || await _matchmakerController.toggleInteractive();
|
||||
if(!matchmakerResult){
|
||||
log("[${widget.host ? 'HOST' : 'GAME'}] Cannot start matchmaker");
|
||||
_onStop(
|
||||
reason: _StopReason.matchmakerError
|
||||
);
|
||||
return;
|
||||
}
|
||||
log("[${widget.host ? 'HOST' : 'GAME'}] Matchmaker works");
|
||||
|
||||
final headless = !forceGUI && _hostingController.headless.value;
|
||||
final virtualDesktop = _hostingController.virtualDesktop.value;
|
||||
log("[${widget.host ? 'HOST' : 'GAME'}] Implicit game server metadata: headless($headless)");
|
||||
@@ -170,9 +160,8 @@ class _LaunchButtonState extends State<LaunchButton> {
|
||||
return null;
|
||||
}
|
||||
|
||||
final matchmakingIp = _matchmakerController.gameServerAddress.text;
|
||||
if(!isLocalHost(matchmakingIp)) {
|
||||
log("[${widget.host ? 'HOST' : 'GAME'}] The current IP($matchmakingIp) is not set to localhost");
|
||||
if(_backendController.type.value != ServerType.embedded || !isLocalHost(_backendController.gameServerAddress.text)) {
|
||||
log("[${widget.host ? 'HOST' : 'GAME'}] Backend is not set to embedded and/or not pointing to the local game server");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -267,7 +256,7 @@ class _LaunchButtonState extends State<LaunchButton> {
|
||||
_gameController.password.text,
|
||||
host,
|
||||
_hostingController.headless.value,
|
||||
_gameController.customLaunchArgs.text
|
||||
""
|
||||
);
|
||||
log("[${host ? 'HOST' : 'GAME'}] Generated game args: $gameArgs");
|
||||
final gameProcess = await startProcess(
|
||||
@@ -276,60 +265,37 @@ class _LaunchButtonState extends State<LaunchButton> {
|
||||
wrapProcess: false,
|
||||
name: "${version.name}-${host ? 'HOST' : 'GAME'}"
|
||||
);
|
||||
gameProcess.stdOutput.listen((line) => _onGameOutput(line, host, virtualDesktop, false));
|
||||
gameProcess.stdError.listen((line) => _onGameOutput(line, host, virtualDesktop, true));
|
||||
gameProcess.stdOutput.listen((line) => _onGameOutput(line, version, host, virtualDesktop, false));
|
||||
gameProcess.stdError.listen((line) => _onGameOutput(line, version, host, virtualDesktop, true));
|
||||
watchProcess(gameProcess.pid).then((_) async {
|
||||
final instance = host ? _hostingController.instance.value : _gameController.instance.value;
|
||||
if(instance == null || !host || !headless || instance.launched) {
|
||||
if(instance == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!host || !headless || instance.launched) {
|
||||
_onStop(reason: _StopReason.exitCode);
|
||||
return;
|
||||
}
|
||||
|
||||
if(widget.host) {
|
||||
await _onStop(reason: _StopReason.exitCode);
|
||||
_toggle(forceGUI: true);
|
||||
return;
|
||||
}
|
||||
|
||||
await _onStop(
|
||||
reason: _StopReason.exitCode,
|
||||
host: true
|
||||
);
|
||||
final linkedHostingInstance = await _startMatchMakingServer(version, false, virtualDesktop, true);
|
||||
_gameController.instance.value?.child = linkedHostingInstance;
|
||||
if(linkedHostingInstance != null){
|
||||
_setStarted(true, true);
|
||||
_showLaunchingGameServerWidget();
|
||||
}
|
||||
await _restartGameServer(version, virtualDesktop, _StopReason.exitCode);
|
||||
});
|
||||
if(host && !headless && virtualDesktop) {
|
||||
final name = version.name;
|
||||
final pid = gameProcess.pid;
|
||||
_moveProcessToVirtualDesktop(name, pid);
|
||||
}
|
||||
return gameProcess.pid;
|
||||
}
|
||||
|
||||
Future<void> _moveProcessToVirtualDesktop(String versionName, int pid) async {
|
||||
try {
|
||||
final windowManager = VirtualDesktopManager.getInstance();
|
||||
_virtualDesktop = windowManager.createDesktop();
|
||||
windowManager.setDesktopName(_virtualDesktop!, "$versionName Server (Reboot Launcher)");
|
||||
Object? lastError;
|
||||
for(var i = 0; i < 10; i++) {
|
||||
try {
|
||||
windowManager.moveWindowToDesktop(pid, _virtualDesktop!);
|
||||
break;
|
||||
}catch(error) {
|
||||
lastError = error;
|
||||
await Future.delayed(Duration(seconds: 1));
|
||||
}
|
||||
Future<void> _restartGameServer(FortniteVersion version, bool virtualDesktop, _StopReason reason) async {
|
||||
if (widget.host) {
|
||||
await _onStop(reason: reason);
|
||||
_toggle(forceGUI: true);
|
||||
} else {
|
||||
await _onStop(reason: reason, host: true);
|
||||
final linkedHostingInstance =
|
||||
await _startMatchMakingServer(version, false, virtualDesktop, true);
|
||||
_gameController.instance.value?.child = linkedHostingInstance;
|
||||
if (linkedHostingInstance != null) {
|
||||
_setStarted(true, true);
|
||||
_showLaunchingGameServerWidget();
|
||||
}
|
||||
if(lastError != null) {
|
||||
log("[VIRTUAL_DESKTOP] Cannot move window: $lastError");
|
||||
}
|
||||
}catch(error) {
|
||||
log("[VIRTUAL_DESKTOP] Virtual desktop is not supported: $error");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,7 +314,7 @@ class _LaunchButtonState extends State<LaunchButton> {
|
||||
return pid;
|
||||
}
|
||||
|
||||
void _onGameOutput(String line, bool host, bool virtualDesktop, bool error) async {
|
||||
void _onGameOutput(String line, FortniteVersion version, bool host, bool virtualDesktop, bool error) async {
|
||||
if (line.contains(kShutdownLine)) {
|
||||
_onStop(
|
||||
reason: _StopReason.normal
|
||||
@@ -371,17 +337,74 @@ class _LaunchButtonState extends State<LaunchButton> {
|
||||
}
|
||||
|
||||
if(kLoggedInLines.every((entry) => line.contains(entry))) {
|
||||
await _injectOrShowError(_Injectable.memoryFix, host);
|
||||
if(!host){
|
||||
await _injectOrShowError(_Injectable.console, host);
|
||||
_onGameClientInjected();
|
||||
}else {
|
||||
await _injectOrShowError(_Injectable.reboot, host);
|
||||
_onGameServerInjected();
|
||||
}
|
||||
final instance = host ? _hostingController.instance.value : _gameController.instance.value;
|
||||
instance?.launched = true;
|
||||
instance?.tokenError = false;
|
||||
if(instance != null && !instance.launched) {
|
||||
instance.launched = true;
|
||||
instance.tokenError = false;
|
||||
await _injectOrShowError(_Injectable.memoryFix, host);
|
||||
if(!host){
|
||||
await _injectOrShowError(_Injectable.console, host);
|
||||
_onGameClientInjected();
|
||||
}else {
|
||||
final gameServerPort = int.tryParse(_settingsController.gameServerPort.text);
|
||||
if(gameServerPort != null) {
|
||||
await killProcessByPort(gameServerPort);
|
||||
}
|
||||
await _injectOrShowError(_Injectable.reboot, host);
|
||||
_onGameServerInjected();
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if(line.contains(kGameFinishedLine) && host) {
|
||||
if(_hostingController.autoRestart.value) {
|
||||
final notification = LocalNotification(
|
||||
title: translations.gameServerEnd,
|
||||
body: translations.gameServerRestart(_kRebootDelay.inSeconds),
|
||||
);
|
||||
notification.show();
|
||||
Future.delayed(_kRebootDelay).then((_) {
|
||||
_restartGameServer(version, virtualDesktop, _StopReason.normal);
|
||||
});
|
||||
}else {
|
||||
final notification = LocalNotification(
|
||||
title: translations.gameServerEnd,
|
||||
body: translations.gameServerShutdown(_kRebootDelay.inSeconds)
|
||||
);
|
||||
notification.show();
|
||||
Future.delayed(_kRebootDelay).then((_) {
|
||||
_onStop(reason: _StopReason.normal, host: true);
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(line.contains("Display") && host && virtualDesktop) {
|
||||
final hostingInstance = _hostingController.instance.value;
|
||||
if(hostingInstance != null && !hostingInstance.movedToVirtualDesktop) {
|
||||
hostingInstance.movedToVirtualDesktop = true;
|
||||
try {
|
||||
final windowManager = VirtualDesktopManager.getInstance();
|
||||
_virtualDesktop = windowManager.createDesktop();
|
||||
windowManager.setDesktopName(_virtualDesktop!, "${version.name} Server (Reboot Launcher)");
|
||||
try {
|
||||
await windowManager.moveWindowToDesktop(hostingInstance.gamePid, _virtualDesktop!);
|
||||
}catch(error) {
|
||||
log("[VIRTUAL_DESKTOP] $error");
|
||||
try {
|
||||
windowManager.removeDesktop(_virtualDesktop!);
|
||||
}catch(error) {
|
||||
log("[VIRTUAL_DESKTOP] $error");
|
||||
}finally {
|
||||
_virtualDesktop = null;
|
||||
}
|
||||
}
|
||||
}catch(error) {
|
||||
log("[VIRTUAL_DESKTOP] $error");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -404,12 +427,12 @@ class _LaunchButtonState extends State<LaunchButton> {
|
||||
duration: null
|
||||
);
|
||||
final gameServerPort = _settingsController.gameServerPort.text;
|
||||
_gameServerInfoBar?.close();
|
||||
final localPingResult = await pingGameServer(
|
||||
"127.0.0.1:$gameServerPort",
|
||||
timeout: const Duration(minutes: 2)
|
||||
);
|
||||
if (!localPingResult) {
|
||||
_gameServerInfoBar?.close();
|
||||
showInfoBar(
|
||||
translations.gameServerStartWarning,
|
||||
severity: InfoBarSeverity.error,
|
||||
@@ -418,7 +441,7 @@ class _LaunchButtonState extends State<LaunchButton> {
|
||||
return;
|
||||
}
|
||||
|
||||
_matchmakerController.joinLocalHost();
|
||||
_backendController.joinLocalHost();
|
||||
final accessible = await _checkGameServer(theme, gameServerPort);
|
||||
if (!accessible) {
|
||||
showInfoBar(
|
||||
@@ -445,7 +468,6 @@ class _LaunchButtonState extends State<LaunchButton> {
|
||||
|
||||
Future<bool> _checkGameServer(FluentThemeData theme, String gameServerPort) async {
|
||||
try {
|
||||
_gameServerInfoBar?.close();
|
||||
_gameServerInfoBar = showInfoBar(
|
||||
translations.checkingGameServer,
|
||||
loading: true,
|
||||
@@ -494,11 +516,11 @@ class _LaunchButtonState extends State<LaunchButton> {
|
||||
await _operation?.cancel();
|
||||
_operation = null;
|
||||
await _backendController.worker?.cancel();
|
||||
await _matchmakerController.worker?.cancel();
|
||||
}
|
||||
|
||||
host = host ?? widget.host;
|
||||
log("[${host ? 'HOST' : 'GAME'}] Called stop with reason $reason, error data $error $stackTrace");
|
||||
log("[${host ? 'HOST' : 'GAME'}] Caller: ${StackTrace.current}");
|
||||
if(host) {
|
||||
_hostingController.discardServer();
|
||||
}
|
||||
@@ -526,12 +548,10 @@ class _LaunchButtonState extends State<LaunchButton> {
|
||||
}
|
||||
|
||||
_setStarted(host, false);
|
||||
if(!reason.isError) {
|
||||
if(host) {
|
||||
_gameServerInfoBar?.close();
|
||||
}else {
|
||||
_gameClientInfoBar?.close();
|
||||
}
|
||||
if(host) {
|
||||
_gameServerInfoBar?.close();
|
||||
}else {
|
||||
_gameClientInfoBar?.close();
|
||||
}
|
||||
|
||||
switch(reason) {
|
||||
@@ -633,7 +653,14 @@ class _LaunchButtonState extends State<LaunchButton> {
|
||||
String _getDllPath(_Injectable injectable) {
|
||||
switch(injectable){
|
||||
case _Injectable.reboot:
|
||||
return _settingsController.gameServerDll.text;
|
||||
if(_updateController.customGameServer.value) {
|
||||
final file = File(_settingsController.gameServerDll.text);
|
||||
if(file.existsSync()) {
|
||||
return file.path;
|
||||
}
|
||||
}
|
||||
|
||||
return rebootDllFile.path;
|
||||
case _Injectable.console:
|
||||
return _settingsController.unrealEngineConsoleDll.text;
|
||||
case _Injectable.sslBypassV2:
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart' hide FluentIcons;
|
||||
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
||||
import 'package:reboot_launcher/src/page/pages.dart';
|
||||
import 'package:skeletons/skeletons.dart';
|
||||
|
||||
class InfoTile extends StatelessWidget {
|
||||
final Key? expanderKey;
|
||||
|
||||
@@ -4,21 +4,18 @@ import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/controller/backend_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/matchmaker_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/server_controller.dart';
|
||||
import 'package:reboot_launcher/src/dialog/implementation/server.dart';
|
||||
import 'package:reboot_launcher/src/util/translations.dart';
|
||||
|
||||
class ServerButton extends StatefulWidget {
|
||||
final bool backend;
|
||||
const ServerButton({Key? key, required this.backend}) : super(key: key);
|
||||
const ServerButton({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
State<ServerButton> createState() => _ServerButtonState();
|
||||
}
|
||||
|
||||
class _ServerButtonState extends State<ServerButton> {
|
||||
late final ServerController _controller = widget.backend ? Get.find<BackendController>() : Get.find<MatchmakerController>();
|
||||
late final BackendController _controller = Get.find<BackendController>();
|
||||
late final StreamController<void> _textController = StreamController.broadcast();
|
||||
late final void Function() _listener = () => _textController.add(null);
|
||||
|
||||
@@ -55,14 +52,14 @@ class _ServerButtonState extends State<ServerButton> {
|
||||
);
|
||||
|
||||
String get _buttonText {
|
||||
if(_controller.type.value == ServerType.local && _controller.port.text.trim() == _controller.defaultPort.toString()){
|
||||
return translations.checkServer(_controller.controllerName);
|
||||
if(_controller.type.value == ServerType.local && _controller.port.text.trim() == kDefaultBackendPort.toString()){
|
||||
return translations.checkServer;
|
||||
}
|
||||
|
||||
if(_controller.started.value){
|
||||
return translations.stopServer(_controller.controllerName);
|
||||
return translations.stopServer;
|
||||
}
|
||||
|
||||
return translations.startServer(_controller.controllerName);
|
||||
return translations.startServer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,10 @@ import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/controller/backend_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/matchmaker_controller.dart';
|
||||
import 'package:reboot_launcher/src/controller/server_controller.dart';
|
||||
import 'package:reboot_launcher/src/util/translations.dart';
|
||||
|
||||
class ServerTypeSelector extends StatefulWidget {
|
||||
final bool backend;
|
||||
|
||||
const ServerTypeSelector({Key? key, required this.backend})
|
||||
const ServerTypeSelector({Key? key})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@@ -17,7 +13,7 @@ class ServerTypeSelector extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _ServerTypeSelectorState extends State<ServerTypeSelector> {
|
||||
late final ServerController _controller = widget.backend ? Get.find<BackendController>() : Get.find<MatchmakerController>();
|
||||
late final BackendController _controller = Get.find<BackendController>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart';
|
||||
import 'package:reboot_common/common.dart';
|
||||
import 'package:reboot_launcher/src/util/os.dart';
|
||||
import 'package:reboot_launcher/src/widget/title_bar_buttons.dart';
|
||||
import 'package:system_theme/system_theme.dart';
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
import 'package:fluent_ui/fluent_ui.dart' hide FluentIcons;
|
||||
import 'package:fluentui_system_icons/fluentui_system_icons.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:reboot_launcher/src/controller/game_controller.dart';
|
||||
import 'package:reboot_launcher/src/util/translations.dart';
|
||||
import 'package:reboot_launcher/src/widget/setting_tile.dart';
|
||||
import 'package:reboot_launcher/src/widget/version_selector.dart';
|
||||
|
||||
Reference in New Issue
Block a user