Final version

This commit is contained in:
Alessandro Autiero
2023-09-21 16:48:31 +02:00
parent 4bba21c038
commit 73c1cc8526
90 changed files with 3204 additions and 2608 deletions

View File

@@ -0,0 +1,78 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:reboot_launcher/src/dialog/abstract/info_bar.dart' as messenger;
import 'package:reboot_launcher/src/page/abstract/page_setting.dart';
import 'package:reboot_launcher/src/page/abstract/page_type.dart';
abstract class RebootPage extends StatefulWidget {
const RebootPage({super.key});
String get name;
String get iconAsset;
RebootPageType get type;
int get index => type.index;
List<PageSetting> get settings;
bool get hasButton;
@override
RebootPageState createState();
}
abstract class RebootPageState<T extends RebootPage> extends State<T> with AutomaticKeepAliveClientMixin<T> {
@override
Widget build(BuildContext context) {
super.build(context);
var buttonWidget = button;
if(buttonWidget == null) {
return _listView;
}
return Column(
children: [
Expanded(
child: _listView,
),
const SizedBox(
height: 8.0,
),
ConstrainedBox(
constraints: const BoxConstraints(
maxWidth: 1000
),
child: buttonWidget
)
],
);
}
OverlayEntry showInfoBar(dynamic text, {InfoBarSeverity severity = InfoBarSeverity.info, bool loading = false, Duration? duration = snackbarShortDuration, Widget? action}) => messenger.showInfoBar(
text,
pageType: widget.type,
severity: severity,
loading: loading,
duration: duration,
action: action
);
ListView get _listView => ListView.builder(
itemCount: settings.length * 2,
itemBuilder: (context, index) => index.isEven ? Align(
alignment: Alignment.center,
child: settings[index ~/ 2],
) : const SizedBox(height: 8.0),
);
@override
bool get wantKeepAlive => true;
List<Widget> get settings;
Widget? get button;
}

View File

@@ -0,0 +1,26 @@
class PageSetting {
final String name;
final String description;
final String? content;
final List<PageSetting>? children;
final int pageIndex;
PageSetting(
{required this.name,
required this.description,
this.content,
this.children,
this.pageIndex = -1});
PageSetting withPageIndex(int pageIndex) => this.pageIndex != -1
? this
: PageSetting(
name: name,
description: description,
content: content,
children: children,
pageIndex: pageIndex);
@override
String toString() => "$name: $description";
}

View File

@@ -0,0 +1,9 @@
enum RebootPageType {
play,
host,
browser,
authenticator,
matchmaker,
info,
settings
}

View File

@@ -1,142 +0,0 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:reboot_common/common.dart';
import 'package:reboot_launcher/src/controller/authenticator_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/widget/common/setting_tile.dart';
import 'package:reboot_launcher/src/widget/server/start_button.dart';
import 'package:reboot_launcher/src/widget/server/type_selector.dart';
import 'package:url_launcher/url_launcher.dart';
class AuthenticatorPage extends StatefulWidget {
const AuthenticatorPage({Key? key}) : super(key: key);
@override
State<AuthenticatorPage> createState() => _AuthenticatorPageState();
}
class _AuthenticatorPageState extends State<AuthenticatorPage> with AutomaticKeepAliveClientMixin {
final AuthenticatorController _authenticatorController = Get.find<AuthenticatorController>();
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
super.build(context);
return Obx(() => Column(
children: [
Expanded(
child: ListView(
children: [
SettingTile(
title: "Authenticator configuration",
subtitle: "This section contains the authenticator's configuration",
content: const ServerTypeSelector(
authenticator: true
),
expandedContent: [
if(_authenticatorController.type.value == ServerType.remote)
SettingTile(
title: "Host",
subtitle: "The hostname of the authenticator",
isChild: true,
content: TextFormBox(
placeholder: "Host",
controller: _authenticatorController.host
)
),
if(_authenticatorController.type.value != ServerType.embedded)
SettingTile(
title: "Port",
subtitle: "The port of the authenticator",
isChild: true,
content: TextFormBox(
placeholder: "Port",
controller: _authenticatorController.port,
keyboardType: TextInputType.number,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly
]
)
),
if(_authenticatorController.type.value == ServerType.embedded)
SettingTile(
title: "Detached",
subtitle: "Whether the embedded authenticator should be started as a separate process, useful for debugging",
contentWidth: null,
isChild: true,
content: Obx(() => Row(
children: [
Text(
_authenticatorController.detached.value ? "On" : "Off"
),
const SizedBox(
width: 16.0
),
ToggleSwitch(
checked: _authenticatorController.detached(),
onChanged: (value) => _authenticatorController.detached.value = value
),
],
))
),
],
),
const SizedBox(
height: 8.0,
),
SettingTile(
title: "Installation directory",
subtitle: "Opens the folder where the embedded authenticator is located",
content: Button(
onPressed: () => launchUrl(authenticatorDirectory.uri),
child: const Text("Show Files")
)
),
const SizedBox(
height: 8.0,
),
SettingTile(
title: "Reset authenticator",
subtitle: "Resets the authenticator's settings to their default values",
content: Button(
onPressed: () => showAppDialog(
builder: (context) => InfoDialog(
text: "Do you want to reset all the setting in this tab to their default values? This action is irreversible",
buttons: [
DialogButton(
type: ButtonType.secondary,
text: "Close",
),
DialogButton(
type: ButtonType.primary,
text: "Reset",
onTap: () {
_authenticatorController.reset();
Navigator.of(context).pop();
},
)
],
)
),
child: const Text("Reset"),
)
)
]
),
),
const SizedBox(
height: 8.0,
),
const ServerButton(
authenticator: true
)
],
));
}
bool get _isRemote => _authenticatorController.type.value == ServerType.remote;
}

View File

@@ -1,265 +0,0 @@
import 'dart:async';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:get/get.dart';
import 'package:reboot_common/common.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/widget/common/setting_tile.dart';
import 'package:skeletons/skeletons.dart';
class BrowsePage extends StatefulWidget {
const BrowsePage({Key? key}) : super(key: key);
@override
State<BrowsePage> createState() => _BrowsePageState();
}
class _BrowsePageState extends State<BrowsePage> with AutomaticKeepAliveClientMixin {
final HostingController _hostingController = Get.find<HostingController>();
final MatchmakerController _matchmakerController = Get.find<MatchmakerController>();
final TextEditingController _filterController = TextEditingController();
final StreamController<String> _filterControllerStream = StreamController();
@override
Widget build(BuildContext context) {
super.build(context);
return FutureBuilder(
future: Future.delayed(const Duration(seconds: 1)), // Fake delay to show loading
builder: (context, futureSnapshot) => Obx(() {
var ready = futureSnapshot.connectionState == ConnectionState.done;
var data = _hostingController.servers
.value
?.where((entry) => entry["discoverable"] ?? false)
.toSet();
if(ready && data?.isEmpty == true) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"No servers are available right now",
style: FluentTheme.of(context).typography.titleLarge,
),
Text(
"Host a server yourself or come back later",
style: FluentTheme.of(context).typography.body
),
],
);
}
return Column(
children: [
_buildSearchBar(ready),
const SizedBox(
height: 16,
),
Expanded(
child: StreamBuilder<String?>(
stream: _filterControllerStream.stream,
builder: (context, filterSnapshot) {
var items = _getItems(data, filterSnapshot.data, ready);
var itemsCount = items != null ? items.length * 2 : null;
if(itemsCount == 0) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
"No results found",
style: FluentTheme.of(context).typography.titleLarge,
),
Text(
"No server matches your query",
style: FluentTheme.of(context).typography.body
),
],
);
}
return ListView.builder(
itemCount: itemsCount,
itemBuilder: (context, index) {
if(index % 2 != 0) {
return const SizedBox(
height: 8.0
);
}
var entry = _getItem(index ~/ 2, items);
if(!ready || entry == null) {
return const SettingTile(
content: SkeletonAvatar(
style: SkeletonAvatarStyle(
height: 32,
width: 64
),
)
);
}
var hasPassword = entry["password"] != null;
return SettingTile(
title: "${_formatName(entry)}${entry["author"]}",
subtitle: "${_formatDescription(entry)}${_formatVersion(entry)}",
content: Button(
onPressed: () => _matchmakerController.joinServer(_hostingController.uuid, entry),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if(hasPassword)
const Icon(FluentIcons.lock),
if(hasPassword)
const SizedBox(width: 8.0),
Text(_matchmakerController.type.value == ServerType.embedded ? "Join Server" : "Copy IP"),
],
),
)
);
}
);
}
),
)
],
);
}
),
);
}
Set<Map<String, dynamic>>? _getItems(Set<Map<String, dynamic>>? data, String? filter, bool ready) {
if (!ready) {
return null;
}
if (data == null) {
return null;
}
return data.where((entry) => _isValidItem(entry, filter)).toSet();
}
bool _isValidItem(Map<String, dynamic> entry, String? filter) =>
filter == null || _filterServer(entry, filter);
bool _filterServer(Map<String, dynamic> element, String filter) {
String? id = element["id"];
if(id?.toLowerCase().contains(filter) == true) {
return true;
}
var uri = Uri.tryParse(filter);
if(uri != null && id?.toLowerCase().contains(uri.host.toLowerCase()) == true) {
return true;
}
String? name = element["name"];
if(name?.toLowerCase().contains(filter) == true) {
return true;
}
String? author = element["author"];
if(author?.toLowerCase().contains(filter) == true) {
return true;
}
String? description = element["description"];
if(description?.toLowerCase().contains(filter) == true) {
return true;
}
return false;
}
Widget _buildSearchBar(bool ready) {
if(ready) {
return TextBox(
placeholder: 'Find a server',
controller: _filterController,
onChanged: (value) => _filterControllerStream.add(value),
suffix: _searchBarIcon,
);
}
return const SkeletonLine(
style: SkeletonLineStyle(
height: 32
)
);
}
Widget get _searchBarIcon => Button(
onPressed: _filterController.text.isEmpty ? null : () {
_filterController.clear();
_filterControllerStream.add("");
},
style: ButtonStyle(
backgroundColor: _filterController.text.isNotEmpty ? null : ButtonState.all(Colors.transparent),
border: _filterController.text.isNotEmpty ? null : ButtonState.all(const BorderSide(color: Colors.transparent))
),
child: _searchBarIconData
);
Widget get _searchBarIconData {
var color = FluentTheme.of(context).resources.textFillColorPrimary;
if (_filterController.text.isNotEmpty) {
return Icon(
FluentIcons.clear,
size: 8.0,
color: color
);
}
return Transform.flip(
flipX: true,
child: Icon(
FluentIcons.search,
size: 12.0,
color: color
),
);
}
Map<String, dynamic>? _getItem(int index, Set? data) {
if(data == null) {
return null;
}
if (index >= data.length) {
return null;
}
return data.elementAt(index);
}
String _formatName(Map<String, dynamic> entry) {
String result = entry['name'];
return result.isEmpty ? kDefaultServerName : result;
}
String _formatDescription(Map<String, dynamic> entry) {
String result = entry['description'];
return result.isEmpty ? kDefaultDescription : result;
}
String _formatVersion(Map<String, dynamic> entry) {
var version = entry['version'];
var versionSplit = version.indexOf("-");
var minimalVersion = version = versionSplit != -1 ? version.substring(0, versionSplit) : version;
String result = minimalVersion.endsWith(".0") ? minimalVersion.substring(0, minimalVersion.length - 2) : minimalVersion;
if(result.toLowerCase().startsWith("fortnite ")) {
result = result.substring(0, 10);
}
return "Fortnite $result";
}
@override
bool get wantKeepAlive => true;
}

View File

@@ -1,263 +0,0 @@
import 'package:clipboard/clipboard.dart';
import 'package:dart_ipify/dart_ipify.dart';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/material.dart' show Icons;
import 'package:get/get.dart';
import 'package:reboot_launcher/main.dart';
import 'package:reboot_launcher/src/controller/game_controller.dart';
import 'package:reboot_launcher/src/controller/hosting_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';
import 'package:reboot_launcher/src/dialog/implementation/server.dart';
import 'package:reboot_launcher/src/widget/common/setting_tile.dart';
import 'package:reboot_launcher/src/widget/game/start_button.dart';
import 'package:reboot_launcher/src/widget/version/version_selector.dart';
import 'package:sync/semaphore.dart';
class HostingPage extends StatefulWidget {
const HostingPage({Key? key}) : super(key: key);
@override
State<HostingPage> createState() => _HostingPageState();
}
class _HostingPageState extends State<HostingPage> with AutomaticKeepAliveClientMixin {
final GameController _gameController = Get.find<GameController>();
final HostingController _hostingController = Get.find<HostingController>();
final Semaphore _semaphore = Semaphore();
late final RxBool _showPasswordTrailing = RxBool(_hostingController.password.text.isNotEmpty);
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
super.build(context);
return Column(
children: [
Expanded(
child: ListView(
children: [
SettingTile(
title: "Game Server",
subtitle: "Provide basic information about your server",
expandedContent: [
SettingTile(
title: "Name",
subtitle: "The name of your game server",
isChild: true,
content: TextFormBox(
placeholder: "Name",
controller: _hostingController.name,
onChanged: (_) => _updateServer()
)
),
SettingTile(
title: "Description",
subtitle: "The description of your game server",
isChild: true,
content: TextFormBox(
placeholder: "Description",
controller: _hostingController.description,
onChanged: (_) => _updateServer()
)
),
SettingTile(
title: "Password",
subtitle: "The password of your game server for the server browser",
isChild: true,
content: Obx(() => TextFormBox(
placeholder: "Password",
controller: _hostingController.password,
autovalidateMode: AutovalidateMode.always,
obscureText: !_hostingController.showPassword.value,
enableSuggestions: false,
autocorrect: false,
onChanged: (text) {
_showPasswordTrailing.value = text.isNotEmpty;
_updateServer();
},
suffix: Button(
onPressed: () => _hostingController.showPassword.value = !_hostingController.showPassword.value,
style: ButtonStyle(
shape: ButtonState.all(const CircleBorder()),
backgroundColor: ButtonState.all(Colors.transparent)
),
child: Icon(
_hostingController.showPassword.value ? Icons.visibility_off : Icons.visibility,
color: _showPasswordTrailing.value ? null : Colors.transparent
),
)
))
),
SettingTile(
title: "Discoverable",
subtitle: "Make your server available to other players on the server browser",
isChild: true,
contentWidth: null,
content: Obx(() => Row(
children: [
Text(
_hostingController.discoverable.value ? "On" : "Off"
),
const SizedBox(
width: 16.0
),
ToggleSwitch(
checked: _hostingController.discoverable(),
onChanged: (value) async {
_hostingController.discoverable.value = value;
await _updateServer();
}
),
],
))
)
],
),
const SizedBox(
height: 8.0,
),
const SettingTile(
title: "Version",
subtitle: "Select the version of Fortnite you want to host",
content: VersionSelector(),
expandedContent: [
SettingTile(
title: "Add a version from this PC's local storage",
subtitle: "Versions coming from your local disk are not guaranteed to work",
content: Button(
onPressed: VersionSelector.openAddDialog,
child: Text("Add build"),
),
isChild: true
),
SettingTile(
title: "Download any version from the cloud",
subtitle: "Download any Fortnite build easily from the cloud",
content: Button(
onPressed: VersionSelector.openDownloadDialog,
child: Text("Download"),
),
isChild: true
)
]
),
const SizedBox(
height: 8.0
),
SettingTile(
title: "Share",
subtitle: "Make it easy for other people to join your server with the options in this section",
expandedContent: [
SettingTile(
title: "Link",
subtitle: "Copies a link for your server to the clipboard (requires the Reboot Launcher)",
isChild: true,
content: Button(
onPressed: () async {
FlutterClipboard.controlC("$kCustomUrlSchema://${_hostingController.uuid}");
showInfoBar(
"Copied your link to the clipboard",
severity: InfoBarSeverity.success
);
},
child: const Text("Copy Link"),
)
),
SettingTile(
title: "Public IP",
subtitle: "Copies your current public IP to the clipboard (doesn't require the Reboot Launcher)",
isChild: true,
content: Button(
onPressed: () async {
try {
showInfoBar(
"Obtaining your public IP...",
loading: true,
duration: null
);
var ip = await Ipify.ipv4();
FlutterClipboard.controlC(ip);
showInfoBar(
"Copied your IP to the clipboard",
severity: InfoBarSeverity.success
);
}catch(error) {
showInfoBar(
"An error occurred while obtaining your public IP: $error",
severity: InfoBarSeverity.error,
duration: snackbarLongDuration
);
}
},
child: const Text("Copy IP"),
)
)
],
),
const SizedBox(
height: 8.0,
),
SettingTile(
title: "Reset game server",
subtitle: "Resets the game server's settings to their default values",
content: Button(
onPressed: () => showAppDialog(
builder: (context) => InfoDialog(
text: "Do you want to reset all the setting in this tab to their default values? This action is irreversible",
buttons: [
DialogButton(
type: ButtonType.secondary,
text: "Close",
),
DialogButton(
type: ButtonType.primary,
text: "Reset",
onTap: () {
_hostingController.reset();
Navigator.of(context).pop();
},
)
],
)
),
child: const Text("Reset"),
)
)
],
),
),
const SizedBox(
height: 8.0,
),
const LaunchButton(
host: true
)
],
);
}
Future<void> _updateServer() async {
if(!_hostingController.published()) {
return;
}
try {
_semaphore.acquire();
_hostingController.publishServer(
_gameController.username.text,
_hostingController.instance.value!.versionName
);
} catch(error) {
showInfoBar(
"An error occurred while updating the game server: $error",
severity: InfoBarSeverity.success,
duration: snackbarLongDuration
);
} finally {
_semaphore.release();
}
}
}

View File

@@ -0,0 +1,155 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:reboot_common/common.dart';
import 'package:reboot_launcher/src/controller/authenticator_controller.dart';
import 'package:reboot_launcher/src/page/abstract/page.dart';
import 'package:reboot_launcher/src/page/abstract/page_setting.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/common/setting_tile.dart';
import 'package:reboot_launcher/src/widget/server/start_button.dart';
import 'package:reboot_launcher/src/widget/server/type_selector.dart';
import 'package:url_launcher/url_launcher.dart';
import '../../dialog/implementation/data.dart';
class AuthenticatorPage extends RebootPage {
const AuthenticatorPage({Key? key}) : super(key: key);
@override
String get name => translations.authenticatorName;
@override
String get iconAsset => "assets/images/authenticator.png";
@override
RebootPageType get type => RebootPageType.authenticator;
@override
bool get hasButton => true;
@override
List<PageSetting> get settings => [
PageSetting(
name: translations.authenticatorConfigurationName,
description: translations.authenticatorConfigurationDescription,
children: [
PageSetting(
name: translations.authenticatorConfigurationHostName,
description: translations.authenticatorConfigurationHostDescription
),
PageSetting(
name: translations.authenticatorConfigurationPortName,
description: translations.authenticatorConfigurationPortDescription
),
PageSetting(
name: translations.authenticatorConfigurationDetachedName,
description: translations.authenticatorConfigurationDetachedDescription
)
]
),
PageSetting(
name: translations.authenticatorInstallationDirectoryName,
description: translations.authenticatorInstallationDirectoryDescription,
content: translations.authenticatorInstallationDirectoryContent
),
PageSetting(
name: translations.authenticatorResetDefaultsName,
description: translations.authenticatorResetDefaultsDescription,
content: translations.authenticatorResetDefaultsContent
)
];
@override
RebootPageState<AuthenticatorPage> createState() => _AuthenticatorPageState();
}
class _AuthenticatorPageState extends RebootPageState<AuthenticatorPage> {
final AuthenticatorController _authenticatorController = Get.find<AuthenticatorController>();
@override
List<Widget> get settings => [
_configuration,
_installationDirectory,
_resetDefaults
];
@override
Widget get button => const ServerButton(
authenticator: true
);
SettingTile get _resetDefaults => SettingTile(
title: translations.authenticatorResetDefaultsName,
subtitle: translations.authenticatorResetDefaultsDescription,
content: Button(
onPressed: () => showResetDialog(_authenticatorController.reset),
child: Text(translations.authenticatorResetDefaultsContent),
)
);
SettingTile get _installationDirectory => SettingTile(
title: translations.authenticatorInstallationDirectoryName,
subtitle: translations.authenticatorInstallationDirectoryDescription,
content: Button(
onPressed: () => launchUrl(authenticatorDirectory.uri),
child: Text(translations.authenticatorInstallationDirectoryContent)
)
);
Widget get _configuration => Obx(() => SettingTile(
title: translations.authenticatorConfigurationName,
subtitle: translations.authenticatorConfigurationDescription,
content: const ServerTypeSelector(
authenticator: true
),
expandedContent: [
if(_authenticatorController.type.value == ServerType.remote)
SettingTile(
title: translations.authenticatorConfigurationHostName,
subtitle: translations.authenticatorConfigurationHostDescription,
isChild: true,
content: TextFormBox(
placeholder: translations.authenticatorConfigurationHostName,
controller: _authenticatorController.host
)
),
if(_authenticatorController.type.value != ServerType.embedded)
SettingTile(
title: translations.authenticatorConfigurationPortName,
subtitle: translations.authenticatorConfigurationPortDescription,
isChild: true,
content: TextFormBox(
placeholder: translations.authenticatorConfigurationPortName,
controller: _authenticatorController.port,
keyboardType: TextInputType.number,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly
]
)
),
if(_authenticatorController.type.value == ServerType.embedded)
SettingTile(
title: translations.authenticatorConfigurationDetachedName,
subtitle: translations.authenticatorConfigurationDetachedDescription,
contentWidth: null,
isChild: true,
content: Obx(() => Row(
children: [
Text(
_authenticatorController.detached.value ? translations.on : translations.off
),
const SizedBox(
width: 16.0
),
ToggleSwitch(
checked: _authenticatorController.detached(),
onChanged: (value) => _authenticatorController.detached.value = value
),
],
))
)
],
));
}

View File

@@ -1,29 +1,21 @@
import 'dart:collection';
import 'dart:ui';
import 'package:bitsdojo_window/bitsdojo_window.dart';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/material.dart' show MaterialPage;
import 'package:get/get.dart';
import 'package:reboot_launcher/src/controller/settings_controller.dart';
import 'package:reboot_launcher/src/page/authenticator_page.dart';
import 'package:reboot_launcher/src/page/browse_page.dart';
import 'package:reboot_launcher/src/page/hosting_page.dart';
import 'package:reboot_launcher/src/page/info_page.dart';
import 'package:reboot_launcher/src/page/matchmaker_page.dart';
import 'package:reboot_launcher/src/page/play_page.dart';
import 'package:reboot_launcher/src/page/settings_page.dart';
import 'package:reboot_launcher/src/widget/home/pane.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_setting.dart';
import 'package:reboot_launcher/src/page/pages.dart';
import 'package:reboot_launcher/src/util/translations.dart';
import 'package:reboot_launcher/src/widget/common/setting_tile.dart';
import 'package:reboot_launcher/src/widget/home/profile.dart';
import 'package:reboot_launcher/src/widget/os/title_bar.dart';
import 'package:window_manager/window_manager.dart';
GlobalKey appKey = GlobalKey();
const int pagesLength = 7;
final RxInt pageIndex = RxInt(0);
final Queue<int> _pagesStack = Queue();
final List<GlobalKey> _pageKeys = List.generate(pagesLength, (index) => GlobalKey());
GlobalKey get pageKey => _pageKeys[pageIndex.value];
class HomePage extends StatefulWidget {
const HomePage({Key? key}) : super(key: key);
@@ -39,6 +31,8 @@ class _HomePageState extends State<HomePage> with WindowListener, AutomaticKeepA
final FocusNode _searchFocusNode = FocusNode();
final TextEditingController _searchController = TextEditingController();
final RxBool _focused = RxBool(true);
final Queue<int> _pagesStack = Queue();
bool _hitBack = false;
@override
bool get wantKeepAlive => true;
@@ -46,21 +40,26 @@ class _HomePageState extends State<HomePage> with WindowListener, AutomaticKeepA
@override
void initState() {
windowManager.addListener(this);
_searchController.addListener(_onSearch);
var lastValue = pageIndex.value;
pageIndex.listen((value) {
if(value != lastValue) {
_pagesStack.add(lastValue);
lastValue = value;
if(_hitBack) {
_hitBack = false;
return;
}
if(value == lastValue) {
return;
}
_pagesStack.add(lastValue);
WidgetsBinding.instance.addPostFrameCallback((_) {
restoreMessage(value, lastValue);
lastValue = value;
});
});
super.initState();
}
void _onSearch() {
// TODO: Implement
}
@override
void dispose() {
_searchFocusNode.dispose();
@@ -82,18 +81,32 @@ class _HomePageState extends State<HomePage> with WindowListener, AutomaticKeepA
@override
void onWindowResized() {
_settingsController.saveWindowSize(appWindow.size);
_focused.value = true;
}
@override
void onWindowMoved() {
_settingsController.saveWindowOffset(appWindow.position);
_focused.value = true;
}
@override
void onWindowEnterFullScreen() {
_focused.value = true;
}
@override
void onWindowLeaveFullScreen() {
_focused.value = true;
}
@override
Widget build(BuildContext context) {
super.build(context);
windowManager.show();
return Obx(() => NavigationPaneTheme(
return Obx(() {
_settingsController.language.value;
loadTranslations(context);
return NavigationPaneTheme(
data: NavigationPaneThemeData(
backgroundColor: FluentTheme.of(context).micaBackgroundColor.withOpacity(0.93),
),
@@ -128,13 +141,18 @@ class _HomePageState extends State<HomePage> with WindowListener, AutomaticKeepA
items: _items,
header: const ProfileWidget(),
autoSuggestBox: _autoSuggestBox,
autoSuggestBoxReplacement: const Icon(FluentIcons.search),
indicator: const StickyNavigationIndicator(
duration: Duration(milliseconds: 500),
curve: Curves.easeOut,
indicatorSize: 3.25
)
),
contentShape: const RoundedRectangleBorder(),
onOpenSearch: () => _searchFocusNode.requestFocus(),
transitionBuilder: (child, animation) => child
)
));
);
});
}
Widget get _backButton => Obx(() {
@@ -145,7 +163,10 @@ class _HomePageState extends State<HomePage> with WindowListener, AutomaticKeepA
backgroundColor: ButtonState.all(Colors.transparent),
border: ButtonState.all(const BorderSide(color: Colors.transparent))
),
onPressed: _pagesStack.isEmpty ? null : () => pageIndex.value = _pagesStack.removeLast(),
onPressed: _pagesStack.isEmpty ? null : () {
_hitBack = true;
pageIndex.value = _pagesStack.removeLast();
},
child: const Icon(FluentIcons.back, size: 12.0),
);
});
@@ -157,89 +178,89 @@ class _HomePageState extends State<HomePage> with WindowListener, AutomaticKeepA
);
Widget get _autoSuggestBox => Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: TextBox(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: AutoSuggestBox<PageSetting>(
key: _searchKey,
controller: _searchController,
placeholder: 'Find a setting',
placeholder: translations.find,
focusNode: _searchFocusNode,
autofocus: true,
suffix: Button(
onPressed: null,
style: ButtonStyle(
backgroundColor: ButtonState.all(Colors.transparent),
border: ButtonState.all(const BorderSide(color: Colors.transparent))
selectionHeightStyle: BoxHeightStyle.max,
itemBuilder: (context, item) => Wrap(
children: [
ListTile(
onPressed: () {
pageIndex.value = item.value.pageIndex;
_searchController.clear();
_searchFocusNode.unfocus();
},
leading: item.child,
title: Text(
item.value.name,
overflow: TextOverflow.clip,
maxLines: 1
),
subtitle: item.value.description.isNotEmpty ? Text(
item.value.description,
overflow: TextOverflow.clip,
maxLines: 1
) : null
),
child: Transform.flip(
flipX: true,
child: Icon(
FluentIcons.search,
size: 12.0,
color: FluentTheme.of(context).resources.textFillColorPrimary
],
),
items: _suggestedItems,
autofocus: true,
trailingIcon: IgnorePointer(
child: IconButton(
onPressed: () {},
icon: Transform.flip(
flipX: true,
child: const Icon(FluentIcons.search)
),
)
)
),
),
)
);
List<NavigationPaneItem> get _items => [
RebootPaneItem(
title: const Text("Play"),
icon: SizedBox.square(
dimension: 24,
child: Image.asset("assets/images/play.png")
List<AutoSuggestBoxItem<PageSetting>> get _suggestedItems => pages.mapMany((page) {
var icon = SizedBox.square(
dimension: 24,
child: Image.asset(page.iconAsset)
);
var outerResults = <AutoSuggestBoxItem<PageSetting>>[];
outerResults.add(AutoSuggestBoxItem(
value: PageSetting(
name: page.name,
description: "",
pageIndex: page.index
),
body: const PlayPage()
),
RebootPaneItem(
title: const Text("Host"),
icon: SizedBox.square(
dimension: 24,
child: Image.asset("assets/images/host.png")
),
body: const HostingPage()
),
RebootPaneItem(
title: const Text("Server Browser"),
icon: SizedBox.square(
dimension: 24,
child: Image.asset("assets/images/browse.png")
),
body: const BrowsePage()
),
RebootPaneItem(
title: const Text("Authenticator"),
icon: SizedBox.square(
dimension: 24,
child: Image.asset("assets/images/auth.png")
),
body: const AuthenticatorPage()
),
RebootPaneItem(
title: const Text("Matchmaker"),
icon: SizedBox.square(
dimension: 24,
child: Image.asset("assets/images/matchmaker.png")
),
body: const MatchmakerPage()
),
RebootPaneItem(
title: const Text("Info"),
icon: SizedBox.square(
dimension: 24,
child: Image.asset("assets/images/info.png")
),
body: const InfoPage()
),
RebootPaneItem(
title: const Text("Settings"),
icon: SizedBox.square(
dimension: 24,
child: Image.asset("assets/images/settings.png")
),
body: const SettingsPage()
),
];
label: page.name,
child: icon
));
outerResults.addAll(page.settings.mapMany((setting) {
var results = <AutoSuggestBoxItem<PageSetting>>[];
results.add(AutoSuggestBoxItem(
value: setting.withPageIndex(page.index),
label: setting.toString(),
child: icon
));
setting.children?.forEach((childSetting) => results.add(AutoSuggestBoxItem(
value: childSetting.withPageIndex(page.index),
label: childSetting.toString(),
child: icon
)));
return results;
}).toList());
return outerResults;
}).toList();
String get searchValue => _searchController.text;
}
List<NavigationPaneItem> get _items => pages.map((page) => _createItem(page)).toList();
NavigationPaneItem _createItem(RebootPage page) => PaneItem(
title: Text(page.name),
icon: SizedBox.square(
dimension: 24,
child: Image.asset(page.iconAsset)
),
body: page
);
}

View File

@@ -0,0 +1,130 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/gestures.dart';
import 'package:reboot_launcher/src/page/abstract/page.dart';
import 'package:reboot_launcher/src/page/abstract/page_setting.dart';
import 'package:reboot_launcher/src/page/abstract/page_type.dart';
import 'package:reboot_launcher/src/util/translations.dart';
import 'package:reboot_launcher/src/util/tutorial.dart';
import 'package:reboot_launcher/src/widget/common/setting_tile.dart';
class InfoPage extends RebootPage {
const InfoPage({Key? key}) : super(key: key);
@override
RebootPageState<InfoPage> createState() => _InfoPageState();
@override
String get name => translations.infoName;
@override
String get iconAsset => "assets/images/info.png";
@override
bool get hasButton => false;
@override
RebootPageType get type => RebootPageType.info;
@override
List<PageSetting> get settings => [];
}
class _InfoPageState extends RebootPageState<InfoPage> {
@override
Widget? get button => null;
@override
List<SettingTile> get settings => [
SettingTile(
title: 'What is Project Reboot?',
subtitle: 'Project Reboot allows anyone to easily host a game server for most of Fortnite\'s seasons. '
'The project was started on Discord by Milxnor. '
'The project is no longer being actively maintained.',
titleStyle: FluentTheme
.of(context)
.typography
.title,
contentWidth: null,
),
SettingTile(
title: 'What is a game server?',
subtitle: 'When you join a Fortnite Game, your client connects to a game server that allows you to play with others. '
'You can join someone else\'s game server, or host one on your PC by going to the "Host" tab. ',
titleStyle: FluentTheme
.of(context)
.typography
.title,
contentWidth: null,
),
SettingTile(
title: 'What is a client?',
subtitle: 'A client is the actual Fortnite game. '
'You can download any version of Fortnite from the launcher in the "Play" tab. '
'You can also import versions from your local PC, but remember that these may be corrupted. '
'If a local version doesn\'t work, try installing it from the launcher before reporting a bug.',
titleStyle: FluentTheme
.of(context)
.typography
.title,
contentWidth: null,
),
SettingTile(
title: 'What is an authenticator?',
subtitle: 'An authenticator is a program that handles authentication, parties and voice chats. '
'By default, a LawinV1 server will be started for you to play. '
'You can use also use an authenticator running locally(on your PC) or remotely(on another PC). '
'Changing the authenticator settings can break the client and game server: unless you are an advanced user, do not edit, for any reason, these settings! '
'If you need to restore these settings, go to the "Settings" tab and click on "Restore Defaults". ',
titleStyle: FluentTheme
.of(context)
.typography
.title,
contentWidth: null,
),
SettingTile(
title: 'Do I need to update DLLs?',
subtitle: 'No, all the files that the launcher uses are automatically updated. '
'You can use your own DLLs by going to the "Settings" tab, but make sure that they don\'t create a console that reads IO or the launcher will stop working correctly. '
'Unless you are an advanced user, changing these options is not recommended',
titleStyle: FluentTheme
.of(context)
.typography
.title,
contentWidth: null,
),
SettingTile(
title: 'Where can I report bugs or ask for new features?',
subtitle: 'Go to the "Settings" tab and click on report bug. '
'Please make sure to be as specific as possible when filing a report as it\'s crucial to make it as easy to fix/implement',
titleStyle: FluentTheme
.of(context)
.typography
.title,
contentWidth: null,
),
SettingTile(
title: 'How can I make my game server accessible for other players?',
subtitle: Text.rich(
TextSpan(
children: [
TextSpan(
text: 'Follow ',
style: FluentTheme.of(context).typography.body
),
TextSpan(
text: 'this tutorial',
mouseCursor: SystemMouseCursors.click,
style: FluentTheme.of(context).typography.body?.copyWith(color: FluentTheme.of(context).accentColor),
recognizer: TapGestureRecognizer()..onTap = openPortTutorial
)
]
)
),
titleStyle: FluentTheme
.of(context)
.typography
.title,
contentWidth: null,
)
];
}

View File

@@ -0,0 +1,165 @@
import 'package:fluent_ui/fluent_ui.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_setting.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/common/setting_tile.dart';
import 'package:reboot_launcher/src/widget/server/start_button.dart';
import 'package:reboot_launcher/src/widget/server/type_selector.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 get hasButton => true;
@override
RebootPageType get type => RebootPageType.matchmaker;
@override
List<PageSetting> get settings => [
PageSetting(
name: translations.matchmakerConfigurationName,
description: translations.matchmakerConfigurationDescription,
children: [
PageSetting(
name: translations.matchmakerConfigurationHostName,
description: translations.matchmakerConfigurationHostDescription
),
PageSetting(
name: translations.matchmakerConfigurationPortName,
description: translations.matchmakerConfigurationPortDescription
),
PageSetting(
name: translations.matchmakerConfigurationDetachedName,
description: translations.matchmakerConfigurationDetachedDescription
)
]
),
PageSetting(
name: translations.matchmakerInstallationDirectoryName,
description: translations.matchmakerInstallationDirectoryDescription,
content: translations.matchmakerInstallationDirectoryContent
),
PageSetting(
name: translations.matchmakerResetDefaultsName,
description: translations.matchmakerResetDefaultsDescription,
content: translations.matchmakerResetDefaultsContent
)
];
}
class _MatchmakerPageState extends RebootPageState<MatchmakerPage> {
final MatchmakerController _matchmakerController = Get.find<MatchmakerController>();
@override
Widget? get button => const ServerButton(
authenticator: false
);
@override
List<Widget> get settings => [
_configuration,
_installationDirectory,
_resetDefaults
];
Widget get _configuration => Obx(() => SettingTile(
title: translations.matchmakerConfigurationName,
subtitle: translations.matchmakerConfigurationDescription,
content: const ServerTypeSelector(
authenticator: false
),
expandedContent: [
if(_matchmakerController.type.value == ServerType.remote)
SettingTile(
title: translations.matchmakerConfigurationHostName,
subtitle: translations.matchmakerConfigurationHostDescription,
isChild: true,
content: TextFormBox(
placeholder: translations.matchmakerConfigurationHostName,
controller: _matchmakerController.host
)
),
if(_matchmakerController.type.value != ServerType.embedded)
SettingTile(
title: translations.matchmakerConfigurationPortName,
subtitle: translations.matchmakerConfigurationPortDescription,
isChild: true,
content: TextFormBox(
placeholder: translations.matchmakerConfigurationPortName,
controller: _matchmakerController.port,
keyboardType: TextInputType.number,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly
]
)
),
if(_matchmakerController.type.value == ServerType.embedded)
SettingTile(
title: translations.matchmakerConfigurationAddressName,
subtitle: translations.matchmakerConfigurationAddressDescription,
isChild: true,
content: TextFormBox(
placeholder: translations.matchmakerConfigurationAddressName,
controller: _matchmakerController.gameServerAddress,
focusNode: _matchmakerController.gameServerAddressFocusNode
)
),
if(_matchmakerController.type.value == ServerType.embedded)
SettingTile(
title: translations.matchmakerConfigurationDetachedName,
subtitle: translations.matchmakerConfigurationDetachedDescription,
contentWidth: null,
isChild: true,
content: Obx(() => Row(
children: [
Text(
_matchmakerController.detached.value ? translations.on : translations.off
),
const SizedBox(
width: 16.0
),
ToggleSwitch(
checked: _matchmakerController.detached.value,
onChanged: (value) => _matchmakerController.detached.value = value
),
],
)),
)
]
));
SettingTile get _installationDirectory => SettingTile(
title: translations.matchmakerInstallationDirectoryName,
subtitle: translations.matchmakerInstallationDirectoryDescription,
content: Button(
onPressed: () => launchUrl(matchmakerDirectory.uri),
child: Text(translations.matchmakerInstallationDirectoryContent)
)
);
SettingTile get _resetDefaults => SettingTile(
title: translations.matchmakerResetDefaultsName,
subtitle: translations.matchmakerResetDefaultsDescription,
content: Button(
onPressed: () => showResetDialog(_matchmakerController.reset),
child: Text(translations.matchmakerResetDefaultsContent),
)
);
}

View File

@@ -0,0 +1,143 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:get/get.dart';
import 'package:reboot_common/common.dart';
import 'package:reboot_launcher/src/controller/hosting_controller.dart';
import 'package:reboot_launcher/src/controller/matchmaker_controller.dart';
import 'package:reboot_launcher/src/page/abstract/page.dart';
import 'package:reboot_launcher/src/page/abstract/page_setting.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/translations.dart';
import 'package:reboot_launcher/src/widget/common/setting_tile.dart';
import 'package:reboot_launcher/src/widget/game/start_button.dart';
import 'package:reboot_launcher/src/widget/version/version_selector_tile.dart';
class PlayPage extends RebootPage {
const PlayPage({Key? key}) : super(key: key);
@override
RebootPageState<PlayPage> createState() => _PlayPageState();
@override
bool get hasButton => true;
@override
String get name => translations.playName;
@override
String get iconAsset => "assets/images/play.png";
@override
RebootPageType get type => RebootPageType.play;
@override
List<PageSetting> get settings => [
versionSelectorRebootSetting,
PageSetting(
name: translations.playGameServerName,
description: translations.playGameServerDescription,
content: translations.playGameServerContentLocal,
children: [
PageSetting(
name: translations.playGameServerHostName,
description: translations.playGameServerHostDescription,
content: translations.playGameServerHostName
),
PageSetting(
name: translations.playGameServerBrowserName,
description: translations.playGameServerBrowserDescription,
content: translations.playGameServerBrowserName
),
PageSetting(
name: translations.playGameServerCustomName,
description: translations.playGameServerCustomDescription,
content: translations.playGameServerCustomContent
)
]
)
];
}
class _PlayPageState extends RebootPageState<PlayPage> {
final MatchmakerController _matchmakerController = Get.find<MatchmakerController>();
final HostingController _hostingController = Get.find<HostingController>();
late final RxBool _selfServer;
@override
void initState() {
_selfServer = RxBool(_isLocalPlay);
_matchmakerController.gameServerAddress.addListener(() => _selfServer.value = _isLocalPlay);
_hostingController.started.listen((_) => _selfServer.value = _isLocalPlay);
super.initState();
}
bool get _isLocalPlay => isLocalHost(_matchmakerController.gameServerAddress.text)
&& !_hostingController.started.value;
@override
Widget? get button => LaunchButton(
startLabel: translations.launchFortnite,
stopLabel: translations.closeFortnite,
host: false
);
@override
List<SettingTile> get settings => [
versionSelectorSettingTile,
_gameServerSelector
];
SettingTile get _gameServerSelector => SettingTile(
title: translations.playGameServerName,
subtitle: translations.playGameServerDescription,
content: IgnorePointer(
child: Button(
style: ButtonStyle(
backgroundColor: ButtonState.all(FluentTheme.of(context).resources.controlFillColorDefault)
),
onPressed: () {},
child: Obx(() {
var address = _matchmakerController.gameServerAddress.text;
var owner = _matchmakerController.gameServerOwner.value;
return Text(
isLocalHost(address) ? translations.playGameServerContentLocal : owner != null ? translations.playGameServerContentBrowser(owner) : address,
textAlign: TextAlign.start
);
})
),
),
expandedContent: [
SettingTile(
title: translations.playGameServerHostName,
subtitle: translations.playGameServerHostDescription,
content: Button(
onPressed: () => pageIndex.value = RebootPageType.host.index,
child: Text(translations.playGameServerHostName)
),
isChild: true
),
SettingTile(
title: translations.playGameServerBrowserName,
subtitle: translations.playGameServerBrowserDescription,
content: Button(
onPressed: () => pageIndex.value = RebootPageType.browser.index,
child: Text(translations.playGameServerBrowserName)
),
isChild: true
),
SettingTile(
title: translations.playGameServerCustomName,
subtitle: translations.playGameServerCustomDescription,
content: Button(
onPressed: () {
pageIndex.value = RebootPageType.matchmaker.index;
WidgetsBinding.instance.addPostFrameCallback((_) => _matchmakerController.gameServerAddressFocusNode.requestFocus());
},
child: Text(translations.playGameServerCustomContent)
),
isChild: true
)
]
);
}

View File

@@ -0,0 +1,247 @@
import 'dart:async';
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/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_setting.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/common/setting_tile.dart';
import 'package:skeletons/skeletons.dart';
class BrowsePage extends RebootPage {
const BrowsePage({Key? key}) : super(key: key);
@override
String get name => translations.browserName;
@override
RebootPageType get type => RebootPageType.browser;
@override
String get iconAsset => "assets/images/server_browser.png";
@override
bool get hasButton => false;
@override
RebootPageState<BrowsePage> createState() => _BrowsePageState();
@override
List<PageSetting> get settings => [];
}
class _BrowsePageState extends RebootPageState<BrowsePage> {
final HostingController _hostingController = Get.find<HostingController>();
final MatchmakerController _matchmakerController = Get.find<MatchmakerController>();
final TextEditingController _filterController = TextEditingController();
final StreamController<String> _filterControllerStream = StreamController.broadcast();
@override
Widget build(BuildContext context) {
super.build(context);
return Obx(() {
var data = _hostingController.servers.value
?.where((entry) => (kDebugMode || entry["id"] != _hostingController.uuid) && entry["discoverable"])
.toSet();
if(data == null || data.isEmpty == true) {
return _noServers;
}
return _buildPageBody(data);
});
}
Widget get _noServers => Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
translations.noServersAvailableTitle,
style: FluentTheme.of(context).typography.titleLarge,
),
Text(
translations.noServersAvailableSubtitle,
style: FluentTheme.of(context).typography.body
),
],
);
Widget _buildPageBody(Set<Map<String, dynamic>> data) => Column(
children: [
_searchBar,
const SizedBox(
height: 16,
),
Expanded(
child: StreamBuilder<String?>(
stream: _filterControllerStream.stream,
builder: (context, filterSnapshot) {
var items = data.where((entry) => _isValidItem(entry, filterSnapshot.data)).toSet();
if(items.isEmpty) {
return _noServersByQuery;
}
return _buildPopulatedListBody(items);
}
),
)
],
);
Widget _buildPopulatedListBody(Set<Map<String, dynamic>> items) => ListView.builder(
itemCount: items.length * 2,
itemBuilder: (context, index) {
if(index % 2 != 0) {
return const SizedBox(
height: 8.0
);
}
var entry = items.elementAt(index ~/ 2);
var hasPassword = entry["password"] != null;
return SettingTile(
title: "${_formatName(entry)}${entry["author"]}",
subtitle: "${_formatDescription(entry)}${_formatVersion(entry)}",
content: Button(
onPressed: () => _matchmakerController.joinServer(_hostingController.uuid, entry),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if(hasPassword)
const Icon(FluentIcons.lock),
if(hasPassword)
const SizedBox(width: 8.0),
Text(_matchmakerController.type.value == ServerType.embedded ? translations.joinServer : translations.copyIp),
],
),
)
);
}
);
Widget get _noServersByQuery => Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
translations.noServersAvailableByQueryTitle,
style: FluentTheme.of(context).typography.titleLarge,
),
Text(
translations.noServersAvailableByQuerySubtitle,
style: FluentTheme.of(context).typography.body
),
],
);
bool _isValidItem(Map<String, dynamic> entry, String? filter) =>
filter == null || filter.isEmpty || _filterServer(entry, filter);
bool _filterServer(Map<String, dynamic> element, String filter) {
String? id = element["id"];
if(id?.toLowerCase().contains(filter.toLowerCase()) == true) {
return true;
}
var uri = Uri.tryParse(filter);
if(uri != null
&& uri.host.isNotEmpty
&& id?.toLowerCase().contains(uri.host.toLowerCase()) == true) {
return true;
}
String? name = element["name"];
if(name?.toLowerCase().contains(filter) == true) {
return true;
}
String? author = element["author"];
if(author?.toLowerCase().contains(filter) == true) {
return true;
}
String? description = element["description"];
if(description?.toLowerCase().contains(filter) == true) {
return true;
}
return false;
}
Widget get _searchBar => TextBox(
placeholder: translations.findServer,
controller: _filterController,
autofocus: true,
onChanged: (value) => _filterControllerStream.add(value),
suffix: _searchBarIcon,
);
Widget get _searchBarIcon => Button(
onPressed: _filterController.text.isEmpty ? null : () {
_filterController.clear();
_filterControllerStream.add("");
},
style: ButtonStyle(
backgroundColor: _filterController.text.isNotEmpty ? null : ButtonState.all(Colors.transparent),
border: _filterController.text.isNotEmpty ? null : ButtonState.all(const BorderSide(color: Colors.transparent))
),
child: _searchBarIconData
);
Widget get _searchBarIconData {
var color = FluentTheme.of(context).resources.textFillColorPrimary;
if (_filterController.text.isNotEmpty) {
return Icon(
FluentIcons.clear,
size: 8.0,
color: color
);
}
return Transform.flip(
flipX: true,
child: Icon(
FluentIcons.search,
size: 12.0,
color: color
),
);
}
String _formatName(Map<String, dynamic> entry) {
String result = entry['name'];
return result.isEmpty ? translations.defaultServerName : result;
}
String _formatDescription(Map<String, dynamic> entry) {
String result = entry['description'];
return result.isEmpty ? translations.defaultServerDescription : result;
}
String _formatVersion(Map<String, dynamic> entry) {
var version = entry['version'];
var versionSplit = version.indexOf("-");
var minimalVersion = version = versionSplit != -1 ? version.substring(0, versionSplit) : version;
String result = minimalVersion.endsWith(".0") ? minimalVersion.substring(0, minimalVersion.length - 2) : minimalVersion;
if(result.toLowerCase().startsWith("fortnite ")) {
result = result.substring(0, 10);
}
return "Fortnite $result";
}
@override
Widget? get button => null;
@override
List<Widget> get settings => [];
}

View File

@@ -0,0 +1,289 @@
import 'package:clipboard/clipboard.dart';
import 'package:dart_ipify/dart_ipify.dart';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/material.dart' show Icons;
import 'package:get/get.dart';
import 'package:reboot_launcher/main.dart';
import 'package:reboot_launcher/src/controller/game_controller.dart';
import 'package:reboot_launcher/src/controller/hosting_controller.dart';
import 'package:reboot_launcher/src/dialog/implementation/data.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_setting.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/common/setting_tile.dart';
import 'package:reboot_launcher/src/widget/game/start_button.dart';
import 'package:reboot_launcher/src/widget/version/version_selector_tile.dart';
import 'package:sync/semaphore.dart';
class HostPage extends RebootPage {
const HostPage({Key? key}) : super(key: key);
@override
String get name => "Host";
@override
String get iconAsset => "assets/images/host.png";
@override
RebootPageType get type => RebootPageType.host;
@override
bool get hasButton => true;
@override
RebootPageState<HostPage> createState() => _HostingPageState();
@override
List<PageSetting> get settings => [
PageSetting(
name: translations.hostGameServerName,
description: translations.hostGameServerDescription,
children: [
PageSetting(
name: translations.hostGameServerNameName,
description: translations.hostGameServerNameDescription
),
PageSetting(
name: translations.hostGameServerDescriptionName,
description: translations.hostGameServerDescriptionDescription
),
PageSetting(
name: translations.hostGameServerPasswordName,
description: translations.hostGameServerDescriptionDescription
),
PageSetting(
name: translations.hostGameServerDiscoverableName,
description: translations.hostGameServerDiscoverableDescription
)
],
),
versionSelectorRebootSetting,
PageSetting(
name: translations.hostShareName,
description: translations.hostShareDescription,
children: [
PageSetting(
name: translations.hostShareLinkName,
description: translations.hostShareLinkDescription,
content: translations.hostShareLinkContent
),
PageSetting(
name: translations.hostShareIpName,
description: translations.hostShareIpDescription,
content: translations.hostShareIpContent
)
],
),
PageSetting(
name: translations.hostResetName,
description: translations.hostResetDescription,
content: translations.hostResetContent
)
];
}
class _HostingPageState extends RebootPageState<HostPage> {
final GameController _gameController = Get.find<GameController>();
final HostingController _hostingController = Get.find<HostingController>();
final Semaphore _semaphore = Semaphore();
late final RxBool _showPasswordTrailing = RxBool(_hostingController.password.text.isNotEmpty);
@override
void initState() {
if(_hostingController.name.text.isEmpty) {
_hostingController.name.text = translations.defaultServerName;
}
if(_hostingController.description.text.isEmpty) {
_hostingController.description.text = translations.defaultServerDescription;
}
super.initState();
}
@override
Widget get button => const LaunchButton(
host: true
);
@override
List<SettingTile> get settings => [
_gameServer,
versionSelectorSettingTile,
_share,
_resetDefaults
];
SettingTile get _resetDefaults => SettingTile(
title: translations.hostResetName,
subtitle: translations.hostResetDescription,
content: Button(
onPressed: () => showResetDialog(_hostingController.reset),
child: Text(translations.hostResetContent),
)
);
SettingTile get _gameServer => SettingTile(
title: translations.hostGameServerName,
subtitle: translations.hostGameServerDescription,
expandedContent: [
SettingTile(
title: translations.hostGameServerNameName,
subtitle: translations.hostGameServerNameDescription,
isChild: true,
content: TextFormBox(
placeholder: translations.hostGameServerNameName,
controller: _hostingController.name,
onChanged: (_) => _updateServer()
)
),
SettingTile(
title: translations.hostGameServerDescriptionName,
subtitle: translations.hostGameServerDescriptionDescription,
isChild: true,
content: TextFormBox(
placeholder: translations.hostGameServerDescriptionName,
controller: _hostingController.description,
onChanged: (_) => _updateServer()
)
),
SettingTile(
title: translations.hostGameServerPasswordName,
subtitle: translations.hostGameServerDescriptionDescription,
isChild: true,
content: Obx(() => TextFormBox(
placeholder: translations.hostGameServerPasswordName,
controller: _hostingController.password,
autovalidateMode: AutovalidateMode.always,
obscureText: !_hostingController.showPassword.value,
enableSuggestions: false,
autocorrect: false,
onChanged: (text) {
_showPasswordTrailing.value = text.isNotEmpty;
_updateServer();
},
suffix: Button(
onPressed: () => _hostingController.showPassword.value = !_hostingController.showPassword.value,
style: ButtonStyle(
shape: ButtonState.all(const CircleBorder()),
backgroundColor: ButtonState.all(Colors.transparent)
),
child: Icon(
_hostingController.showPassword.value ? Icons.visibility_off : Icons.visibility,
color: _showPasswordTrailing.value ? null : Colors.transparent
),
)
))
),
SettingTile(
title: translations.hostGameServerDiscoverableName,
subtitle: translations.hostGameServerDiscoverableDescription,
isChild: true,
contentWidth: null,
content: Obx(() => Row(
children: [
Text(
_hostingController.discoverable.value ? translations.on : translations.off
),
const SizedBox(
width: 16.0
),
ToggleSwitch(
checked: _hostingController.discoverable(),
onChanged: (value) async {
_hostingController.discoverable.value = value;
await _updateServer();
}
),
],
))
)
]
);
SettingTile get _share => SettingTile(
title: translations.hostShareName,
subtitle: translations.hostShareDescription,
expandedContent: [
SettingTile(
title: translations.hostShareLinkName,
subtitle: translations.hostShareLinkDescription,
isChild: true,
content: Button(
onPressed: () async {
FlutterClipboard.controlC("$kCustomUrlSchema://${_hostingController.uuid}");
_showCopiedLink();
},
child: Text(translations.hostShareLinkContent),
)
),
SettingTile(
title: translations.hostShareIpName,
subtitle: translations.hostShareIpDescription,
isChild: true,
content: Button(
onPressed: () async {
try {
_showCopyingIp();
var ip = await Ipify.ipv4();
FlutterClipboard.controlC(ip);
_showCopiedIp();
}catch(error) {
_showCannotCopyIp(error);
}
},
child: Text(translations.hostShareIpContent),
)
)
],
);
Future<void> _updateServer() async {
if(!_hostingController.published()) {
return;
}
try {
_semaphore.acquire();
_hostingController.publishServer(
_gameController.username.text,
_hostingController.instance.value!.versionName
);
} catch(error) {
_showCannotUpdateGameServer(error);
} finally {
_semaphore.release();
}
}
void _showCopiedLink() => showInfoBar(
translations.hostShareLinkMessageSuccess,
severity: InfoBarSeverity.success
);
void _showCopyingIp() => showInfoBar(
translations.hostShareIpMessageLoading,
loading: true,
duration: null
);
void _showCopiedIp() => showInfoBar(
translations.hostShareIpMessageSuccess,
severity: InfoBarSeverity.success
);
void _showCannotCopyIp(Object error) => showInfoBar(
translations.hostShareIpMessageError(error.toString()),
severity: InfoBarSeverity.error,
duration: snackbarLongDuration
);
void _showCannotUpdateGameServer(Object error) => showInfoBar(
translations.cannotUpdateGameServer(error.toString()),
severity: InfoBarSeverity.success,
duration: snackbarLongDuration
);
}

View File

@@ -0,0 +1,317 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/services.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/game_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/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_setting.dart';
import 'package:reboot_launcher/src/page/abstract/page_type.dart';
import 'package:reboot_launcher/src/util/checks.dart';
import 'package:reboot_launcher/src/util/translations.dart';
import 'package:reboot_launcher/src/widget/common/file_selector.dart';
import 'package:reboot_launcher/src/widget/common/setting_tile.dart';
import 'package:flutter_gen/gen_l10n/reboot_localizations.dart';
import 'package:url_launcher/url_launcher.dart';
class SettingsPage extends RebootPage {
const SettingsPage({Key? key}) : super(key: key);
@override
String get name => translations.settingsName;
@override
String get iconAsset => "assets/images/settings.png";
@override
RebootPageType get type => RebootPageType.settings;
@override
bool get hasButton => false;
@override
RebootPageState<SettingsPage> createState() => _SettingsPageState();
@override
List<PageSetting> get settings => [
PageSetting(
name: translations.settingsClientName,
description: translations.settingsClientDescription,
children: [
PageSetting(
name: translations.settingsClientConsoleName,
description: translations.settingsClientConsoleDescription
),
PageSetting(
name: translations.settingsClientAuthName,
description: translations.settingsClientAuthDescription
),
PageSetting(
name: translations.settingsClientMemoryName,
description: translations.settingsClientMemoryDescription
),
PageSetting(
name: translations.settingsClientArgsName,
description: translations.settingsClientArgsDescription
),
],
),
PageSetting(
name: translations.settingsServerName,
description: translations.settingsServerSubtitle,
children: [
PageSetting(
name: translations.settingsServerFileName,
description: translations.settingsServerFileDescription
),
PageSetting(
name: translations.settingsServerPortName,
description: translations.settingsServerPortDescription
),
PageSetting(
name: translations.settingsServerMirrorName,
description: translations.settingsServerMirrorDescription
),
PageSetting(
name: translations.settingsServerTimerName,
description: translations.settingsServerTimerSubtitle
),
],
),
PageSetting(
name: translations.settingsUtilsName,
description: translations.settingsUtilsSubtitle,
children: [
PageSetting(
name: translations.settingsUtilsThemeName,
description: translations.settingsUtilsThemeDescription,
),
PageSetting(
name: translations.settingsUtilsLanguageName,
description: translations.settingsUtilsLanguageDescription,
),
PageSetting(
name: translations.settingsUtilsInstallationDirectoryName,
description: translations.settingsUtilsInstallationDirectorySubtitle,
content: translations.settingsUtilsInstallationDirectoryContent
),
PageSetting(
name: translations.settingsUtilsBugReportName,
description: translations.settingsUtilsBugReportSubtitle,
content: translations.settingsUtilsBugReportContent
),
PageSetting(
name: translations.settingsUtilsResetDefaultsName,
description: translations.settingsUtilsResetDefaultsSubtitle,
content: translations.settingsUtilsResetDefaultsContent
)
],
)
];
}
class _SettingsPageState extends RebootPageState<SettingsPage> {
final GameController _gameController = Get.find<GameController>();
final SettingsController _settingsController = Get.find<SettingsController>();
final UpdateController _updateController = Get.find<UpdateController>();
@override
Widget? get button => null;
@override
List<Widget> get settings => [
_clientSettings,
_gameServerSettings,
_launcherUtilities
];
SettingTile get _clientSettings => SettingTile(
title: translations.settingsClientName,
subtitle: translations.settingsClientDescription,
expandedContent: [
_createFileSetting(
title: translations.settingsClientConsoleName,
description: translations.settingsClientConsoleDescription,
controller: _settingsController.unrealEngineConsoleDll
),
_createFileSetting(
title: translations.settingsClientAuthName,
description: translations.settingsClientAuthDescription,
controller: _settingsController.authenticatorDll
),
_createFileSetting(
title: translations.settingsClientMemoryName,
description: translations.settingsClientMemoryDescription,
controller: _settingsController.memoryLeakDll
),
SettingTile(
title: translations.settingsClientArgsName,
subtitle: translations.settingsClientArgsDescription,
isChild: true,
content: TextFormBox(
placeholder: translations.settingsClientArgsPlaceholder,
controller: _gameController.customLaunchArgs,
)
),
],
);
SettingTile get _gameServerSettings => SettingTile(
title: translations.settingsServerName,
subtitle: translations.settingsServerSubtitle,
expandedContent: [
_createFileSetting(
title: translations.settingsServerFileName,
description: translations.settingsServerFileDescription,
controller: _settingsController.gameServerDll
),
SettingTile(
title: translations.settingsServerPortName,
subtitle: translations.settingsServerPortDescription,
content: TextFormBox(
placeholder: translations.settingsServerPortName,
controller: _settingsController.gameServerPort,
keyboardType: TextInputType.number,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly
]
),
isChild: true
),
SettingTile(
title: translations.settingsServerMirrorName,
subtitle: translations.settingsServerMirrorDescription,
content: TextFormBox(
placeholder: translations.settingsServerMirrorPlaceholder,
controller: _updateController.url,
validator: checkUpdateUrl
),
isChild: true
),
SettingTile(
title: translations.settingsServerTimerName,
subtitle: 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;
removeMessageByPage(6);
_updateController.update(true);
}
)).toList()
)),
isChild: true
),
],
);
SettingTile get _launcherUtilities => SettingTile(
title: translations.settingsUtilsName,
subtitle: translations.settingsUtilsSubtitle,
expandedContent: [
SettingTile(
title: translations.settingsUtilsLanguageName,
subtitle: translations.settingsUtilsLanguageDescription,
isChild: true,
content: Obx(() => DropDownButton(
leading: Text(_getLocaleName(_settingsController.language.value)),
items: AppLocalizations.supportedLocales.map((locale) => MenuFlyoutItem(
text: Text(_getLocaleName(locale.languageCode)),
onPressed: () => _settingsController.language.value = locale.languageCode
)).toList()
))
),
SettingTile(
title: translations.settingsUtilsThemeName,
subtitle: translations.settingsUtilsThemeDescription,
isChild: true,
content: Obx(() => DropDownButton(
leading: Text(_settingsController.themeMode.value.title),
items: ThemeMode.values.map((themeMode) => MenuFlyoutItem(
text: Text(themeMode.title),
onPressed: () => _settingsController.themeMode.value = themeMode
)).toList()
))
),
SettingTile(
title: translations.settingsUtilsInstallationDirectoryName,
subtitle: translations.settingsUtilsInstallationDirectorySubtitle,
isChild: true,
content: Button(
onPressed: () => launchUrl(installationDirectory.uri),
child: Text(translations.settingsUtilsInstallationDirectoryContent),
)
),
SettingTile(
title: translations.settingsUtilsBugReportName,
subtitle: translations.settingsUtilsBugReportSubtitle,
isChild: true,
content: Button(
onPressed: () => launchUrl(Uri.parse("https://github.com/Auties00/reboot_launcher/issues")),
child: Text(translations.settingsUtilsBugReportContent),
)
),
SettingTile(
title: translations.settingsUtilsResetDefaultsName,
subtitle: translations.settingsUtilsResetDefaultsSubtitle,
isChild: true,
content: Button(
onPressed: () => showResetDialog(_settingsController.reset),
child: Text(translations.settingsUtilsResetDefaultsContent),
)
)
],
);
String _getLocaleName(String locale) {
var result = LocaleNames.of(context)!.nameOf(locale);
if(result != null) {
return "${result.substring(0, 1).toUpperCase()}${result.substring(1).toLowerCase()}";
}
return locale;
}
Widget _createFileSetting({required String title, required String description, required TextEditingController controller}) => SettingTile(
title: title,
subtitle: description,
content: FileSelector(
placeholder: translations.selectPathPlaceholder,
windowTitle: translations.selectPathWindowTitle,
controller: controller,
validator: checkDll,
extension: "dll",
folder: false
),
isChild: true
);
}
extension _UpdateTimerExtension on UpdateTimer {
String get text {
if (this == UpdateTimer.never) {
return translations.updateGameServerDllNever;
}
return translations.updateGameServerDllEvery(name);
}
}
extension _ThemeModeExtension on ThemeMode {
String get title {
switch(this) {
case ThemeMode.system:
return translations.system;
case ThemeMode.dark:
return translations.dark;
case ThemeMode.light:
return translations.light;
}
}
}

View File

@@ -1,161 +0,0 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/gestures.dart';
import 'package:get/get.dart';
import 'package:reboot_launcher/src/controller/settings_controller.dart';
import 'package:reboot_launcher/src/util/tutorial.dart';
import 'package:reboot_launcher/src/widget/common/setting_tile.dart';
class InfoPage extends StatefulWidget {
const InfoPage({Key? key}) : super(key: key);
@override
State<InfoPage> createState() => _InfoPageState();
}
class _InfoPageState extends State<InfoPage> with AutomaticKeepAliveClientMixin {
final SettingsController _settingsController = Get.find<SettingsController>();
late final ScrollController _controller;
@override
bool get wantKeepAlive => true;
@override
void initState() {
_controller = ScrollController(initialScrollOffset: _settingsController.scrollingDistance);
_controller.addListener(() {
_settingsController.scrollingDistance = _controller.offset;
});
super.initState();
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
super.build(context);
return Column(
children: [
Expanded(
child: ListView(
children: [
SettingTile(
title: 'What is Project Reboot?',
subtitle: 'Project Reboot allows anyone to easily host a game server for most of Fortnite\'s seasons. '
'The project was started on Discord by Milxnor. '
'The project is no longer being actively maintained.',
titleStyle: FluentTheme
.of(context)
.typography
.title,
contentWidth: null,
),
const SizedBox(
height: 8.0,
),
SettingTile(
title: 'What is a game server?',
subtitle: 'When you join a Fortnite Game, your client connects to a game server that allows you to play with others. '
'You can join someone else\'s game server, or host one on your PC by going to the "Host" tab. ',
titleStyle: FluentTheme
.of(context)
.typography
.title,
contentWidth: null,
),
const SizedBox(
height: 8.0,
),
SettingTile(
title: 'What is a client?',
subtitle: 'A client is the actual Fortnite game. '
'You can download any version of Fortnite from the launcher in the "Play" tab. '
'You can also import versions from your local PC, but remember that these may be corrupted. '
'If a local version doesn\'t work, try installing it from the launcher before reporting a bug.',
titleStyle: FluentTheme
.of(context)
.typography
.title,
contentWidth: null,
),
const SizedBox(
height: 8.0,
),
SettingTile(
title: 'What is an authenticator?',
subtitle: 'An authenticator is a program that handles authentication, parties and voice chats. '
'By default, a LawinV1 server will be started for you to play. '
'You can use also use an authenticator running locally(on your PC) or remotely(on another PC). '
'Changing the authenticator settings can break the client and game server: unless you are an advanced user, do not edit, for any reason, these settings! '
'If you need to restore these settings, go to the "Settings" tab and click on "Restore Defaults". ',
titleStyle: FluentTheme
.of(context)
.typography
.title,
contentWidth: null,
),
const SizedBox(
height: 8.0,
),
SettingTile(
title: 'Do I need to update DLLs?',
subtitle: 'No, all the files that the launcher uses are automatically updated. '
'You can use your own DLLs by going to the "Settings" tab, but make sure that they don\'t create a console that reads IO or the launcher will stop working correctly. '
'Unless you are an advanced user, changing these options is not recommended',
titleStyle: FluentTheme
.of(context)
.typography
.title,
contentWidth: null,
),
const SizedBox(
height: 8.0,
),
SettingTile(
title: 'Where can I report bugs or ask for new features?',
subtitle: 'Go to the "Settings" tab and click on report bug. '
'Please make sure to be as specific as possible when filing a report as it\'s crucial to make it as easy to fix/implement',
titleStyle: FluentTheme
.of(context)
.typography
.title,
contentWidth: null,
),
const SizedBox(
height: 8.0,
),
SettingTile(
title: 'How can I make my game server accessible for other players?',
subtitle: Text.rich(
TextSpan(
children: [
TextSpan(
text: 'Follow ',
style: FluentTheme.of(context).typography.body
),
TextSpan(
text: 'this tutorial',
mouseCursor: SystemMouseCursors.click,
style: FluentTheme.of(context).typography.body?.copyWith(color: FluentTheme.of(context).accentColor),
recognizer: TapGestureRecognizer()..onTap = openPortTutorial
)
]
)
),
titleStyle: FluentTheme
.of(context)
.typography
.title,
contentWidth: null,
)
],
),
)
],
);
}
}

View File

@@ -1,151 +0,0 @@
import 'package:fluent_ui/fluent_ui.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/abstract/dialog.dart';
import 'package:reboot_launcher/src/dialog/abstract/dialog_button.dart';
import 'package:reboot_launcher/src/widget/common/setting_tile.dart';
import 'package:reboot_launcher/src/widget/server/start_button.dart';
import 'package:reboot_launcher/src/widget/server/type_selector.dart';
import 'package:url_launcher/url_launcher.dart';
class MatchmakerPage extends StatefulWidget {
const MatchmakerPage({Key? key}) : super(key: key);
@override
State<MatchmakerPage> createState() => _MatchmakerPageState();
}
class _MatchmakerPageState extends State<MatchmakerPage> with AutomaticKeepAliveClientMixin {
final MatchmakerController _matchmakerController = Get.find<MatchmakerController>();
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
super.build(context);
return Column(
children: [
Expanded(
child: ListView(
children: [
Obx(() => SettingTile(
title: "Matchmaker configuration",
subtitle: "This section contains the matchmaker's configuration",
content: const ServerTypeSelector(
authenticator: false
),
expandedContent: [
if(_matchmakerController.type.value == ServerType.remote)
SettingTile(
title: "Host",
subtitle: "The hostname of the matchmaker",
isChild: true,
content: TextFormBox(
placeholder: "Host",
controller: _matchmakerController.host
)
),
if(_matchmakerController.type.value != ServerType.embedded)
SettingTile(
title: "Port",
subtitle: "The port of the matchmaker",
isChild: true,
content: TextFormBox(
placeholder: "Port",
controller: _matchmakerController.port,
keyboardType: TextInputType.number,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly
]
)
),
if(_matchmakerController.type.value == ServerType.embedded)
SettingTile(
title: "Game server address",
subtitle: "The address of the game server used by the matchmaker",
isChild: true,
content: TextFormBox(
placeholder: "Address",
controller: _matchmakerController.gameServerAddress,
focusNode: _matchmakerController.gameServerAddressFocusNode
)
),
if(_matchmakerController.type.value == ServerType.embedded)
SettingTile(
title: "Detached",
subtitle: "Whether the embedded matchmaker should be started as a separate process, useful for debugging",
contentWidth: null,
isChild: true,
content: Obx(() => Row(
children: [
Text(
_matchmakerController.detached.value ? "On" : "Off"
),
const SizedBox(
width: 16.0
),
ToggleSwitch(
checked: _matchmakerController.detached.value,
onChanged: (value) => _matchmakerController.detached.value = value
),
],
)),
)
]
)),
const SizedBox(
height: 8.0,
),
SettingTile(
title: "Installation directory",
subtitle: "Opens the folder where the embedded matchmaker is located",
content: Button(
onPressed: () => launchUrl(matchmakerDirectory.uri),
child: const Text("Show Files")
)
),
const SizedBox(
height: 8.0,
),
SettingTile(
title: "Reset matchmaker",
subtitle: "Resets the authenticator's settings to their default values",
content: Button(
onPressed: () => showAppDialog(
builder: (context) => InfoDialog(
text: "Do you want to reset all the setting in this tab to their default values? This action is irreversible",
buttons: [
DialogButton(
type: ButtonType.secondary,
text: "Close",
),
DialogButton(
type: ButtonType.primary,
text: "Reset",
onTap: () {
_matchmakerController.reset();
Navigator.of(context).pop();
},
)
],
)
),
child: const Text("Reset"),
)
)
]
),
),
const SizedBox(
height: 8.0,
),
const ServerButton(
authenticator: false
)
],
);
}
}

View File

@@ -0,0 +1,43 @@
import 'dart:collection';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:get/get_rx/src/rx_types/rx_types.dart';
import 'package:reboot_launcher/src/page/abstract/page.dart';
import 'package:reboot_launcher/src/page/implementation/authenticator_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';
import 'package:reboot_launcher/src/page/implementation/settings_page.dart';
final List<RebootPage> pages = [
const PlayPage(),
const HostPage(),
const BrowsePage(),
const AuthenticatorPage(),
const MatchmakerPage(),
const InfoPage(),
const SettingsPage()
];
final RxInt pageIndex = RxInt(0);
final HashMap<int, GlobalKey> _pageKeys = HashMap();
GlobalKey appKey = GlobalKey();
GlobalKey get pageKey {
var index = pageIndex.value;
var key = _pageKeys[index];
if(key != null) {
return key;
}
var result = GlobalKey();
_pageKeys[index] = result;
return result;
}
List<int> get pagesWithButtonIndexes => pages.where((page) => page.hasButton)
.map((page) => page.index)
.toList();

View File

@@ -1,137 +0,0 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:get/get.dart';
import 'package:reboot_common/common.dart';
import 'package:reboot_launcher/src/controller/hosting_controller.dart';
import 'package:reboot_launcher/src/controller/matchmaker_controller.dart';
import 'package:reboot_launcher/src/page/home_page.dart';
import 'package:reboot_launcher/src/widget/common/setting_tile.dart';
import 'package:reboot_launcher/src/widget/game/start_button.dart';
import 'package:reboot_launcher/src/widget/version/version_selector.dart';
class PlayPage extends StatefulWidget {
const PlayPage({Key? key}) : super(key: key);
@override
State<PlayPage> createState() => _PlayPageState();
}
class _PlayPageState extends State<PlayPage> {
final MatchmakerController _matchmakerController = Get.find<MatchmakerController>();
final HostingController _hostingController = Get.find<HostingController>();
late final RxBool _selfServer;
@override
void initState() {
_selfServer = RxBool(_isLocalPlay);
_matchmakerController.gameServerAddress.addListener(() => _selfServer.value = _isLocalPlay);
_hostingController.started.listen((_) => _selfServer.value = _isLocalPlay);
super.initState();
}
bool get _isLocalPlay => isLocalHost(_matchmakerController.gameServerAddress.text)
&& !_hostingController.started.value;
@override
Widget build(BuildContext context) {
return Column(
children: [
Expanded(
child: ListView(
children: [
const SettingTile(
title: "Version",
subtitle: "Select the version of Fortnite you want to host",
content: VersionSelector(),
expandedContent: [
SettingTile(
title: "Add a version from this PC's local storage",
subtitle: "Versions coming from your local disk are not guaranteed to work",
content: Button(
onPressed: VersionSelector.openAddDialog,
child: Text("Add build"),
),
isChild: true
),
SettingTile(
title: "Download any version from the cloud",
subtitle: "Download any Fortnite build easily from the cloud",
content: Button(
onPressed: VersionSelector.openDownloadDialog,
child: Text("Download"),
),
isChild: true
)
]
),
const SizedBox(
height: 8.0,
),
SettingTile(
title: "Game Server",
subtitle: "Helpful shortcuts to find the server where you want to play",
content: IgnorePointer(
child: Button(
style: ButtonStyle(
backgroundColor: ButtonState.all(FluentTheme.of(context).resources.controlFillColorDefault)
),
onPressed: () {},
child: Obx(() {
var address = _matchmakerController.gameServerAddress.text;
var owner = _matchmakerController.gameServerOwner.value;
return Text(
isLocalHost(address) ? "Your server" : owner != null ? "$owner's server" : address,
textAlign: TextAlign.start
);
})
),
),
expandedContent: [
SettingTile(
title: "Host a server",
subtitle: "Do you want to create a game server for yourself or your friends? Host one!",
content: Button(
onPressed: () => pageIndex.value = 1,
child: const Text("Host")
),
isChild: true
),
SettingTile(
title: "Join a Reboot server",
subtitle: "Find a discoverable server hosted on the Reboot Launcher in the server browser",
content: Button(
onPressed: () => pageIndex.value = 2,
child: const Text("Browse")
),
isChild: true
),
SettingTile(
title: "Join a custom server",
subtitle: "Type the address of any server, whether it was hosted on the Reboot Launcher or not",
content: Button(
onPressed: () {
pageIndex.value = 4;
WidgetsBinding.instance.addPostFrameCallback((_) => _matchmakerController.gameServerAddressFocusNode.requestFocus());
},
child: const Text("Join")
),
isChild: true
)
]
),
],
)
),
const SizedBox(
height: 8.0,
),
const LaunchButton(
startLabel: 'Launch Fortnite',
stopLabel: 'Close Fortnite',
host: false
)
]
);
}
}

View File

@@ -1,189 +0,0 @@
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:reboot_common/common.dart';
import 'package:reboot_launcher/src/controller/game_controller.dart';
import 'package:reboot_launcher/src/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';
import 'package:reboot_launcher/src/util/checks.dart';
import 'package:reboot_launcher/src/widget/common/file_selector.dart';
import 'package:reboot_launcher/src/widget/common/setting_tile.dart';
import 'package:url_launcher/url_launcher.dart';
class SettingsPage extends StatefulWidget {
const SettingsPage({Key? key}) : super(key: key);
@override
State<SettingsPage> createState() => _SettingsPageState();
}
class _SettingsPageState extends State<SettingsPage> with AutomaticKeepAliveClientMixin {
final GameController _gameController = Get.find<GameController>();
final SettingsController _settingsController = Get.find<SettingsController>();
final UpdateController _updateController = Get.find<UpdateController>();
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
super.build(context);
return ListView(
children: [
SettingTile(
title: "Client settings",
subtitle: "This section contains the dlls used to make the Fortnite client work",
expandedContent: [
_createFileSetting(
title: "Unreal engine console",
description: "This file is injected to unlock the Unreal Engine Console",
controller: _settingsController.unrealEngineConsoleDll
),
_createFileSetting(
title: "Authentication patcher",
description: "This file is injected to redirect all HTTP requests to the launcher's authenticator",
controller: _settingsController.authenticatorDll
),
SettingTile(
title: "Custom launch arguments",
subtitle: "Additional arguments to use when launching the game",
isChild: true,
content: TextFormBox(
placeholder: "Arguments...",
controller: _gameController.customLaunchArgs,
)
),
],
),
const SizedBox(
height: 8.0,
),
SettingTile(
title: "Game server settings",
subtitle: "This section contains settings related to the game server implementation",
expandedContent: [
_createFileSetting(
title: "Implementation",
description: "This file is injected to create a game server & host matches",
controller: _settingsController.gameServerDll
),
SettingTile(
title: "Port",
subtitle: "The port used by the game server dll",
content: TextFormBox(
placeholder: "Port",
controller: _settingsController.gameServerPort,
keyboardType: TextInputType.number,
inputFormatters: [
FilteringTextInputFormatter.digitsOnly
]
),
isChild: true
),
SettingTile(
title: "Update mirror",
subtitle: "The URL used to update the game server dll",
content: TextFormBox(
placeholder: "URL",
controller: _updateController.url,
validator: checkUpdateUrl
),
isChild: true
),
SettingTile(
title: "Update timer",
subtitle: "Determines when the game server dll should be updated",
content: Obx(() => DropDownButton(
leading: Text(_updateController.timer.value.text),
items: UpdateTimer.values.map((entry) => MenuFlyoutItem(
text: Text(entry.text),
onPressed: () {
_updateController.timer.value = entry;
removeMessage(6);
_updateController.update(true);
}
)).toList()
)),
isChild: true
),
],
),
const SizedBox(
height: 8.0,
),
SettingTile(
title: "Launcher utilities",
subtitle: "This section contains handy settings for the launcher",
expandedContent: [
SettingTile(
title: "Installation directory",
subtitle: "Opens the installation directory",
isChild: true,
content: Button(
onPressed: () => launchUrl(installationDirectory.uri),
child: const Text("Show Files"),
)
),
SettingTile(
title: "Create a bug report",
subtitle: "Help me fix bugs by reporting them",
isChild: true,
content: Button(
onPressed: () => launchUrl(Uri.parse("https://github.com/Auties00/reboot_launcher/issues")),
child: const Text("Report a bug"),
)
),
SettingTile(
title: "Reset settings",
subtitle: "Resets the launcher's settings to their default values",
isChild: true,
content: Button(
onPressed: () => showAppDialog(
builder: (context) => InfoDialog(
text: "Do you want to reset all the setting in this tab to their default values? This action is irreversible",
buttons: [
DialogButton(
type: ButtonType.secondary,
text: "Close",
),
DialogButton(
type: ButtonType.primary,
text: "Reset",
onTap: () {
_settingsController.reset();
Navigator.of(context).pop();
},
)
],
)
),
child: const Text("Reset"),
)
)
],
),
]
);
}
Widget _createFileSetting({required String title, required String description, required TextEditingController controller}) => SettingTile(
title: title,
subtitle: description,
content: FileSelector(
placeholder: "Path",
windowTitle: "Select a file",
controller: controller,
validator: checkDll,
extension: "dll",
folder: false
),
isChild: true
);
}
extension _UpdateTimerExtension on UpdateTimer {
String get text => this == UpdateTimer.never ? "Never" : "Every $name";
}